[Libreoffice-commits] core.git: 3 commits - vcl/inc vcl/quartz vcl/source vcl/win

Norbert Thiebaud nthiebaud at gmail.com
Thu Aug 14 13:44:37 PDT 2014


 vcl/inc/graphite_layout.hxx           |    2 +-
 vcl/inc/graphite_serverfont.hxx       |    2 +-
 vcl/inc/sallayout.hxx                 |    6 +++---
 vcl/quartz/ctlayout.cxx               |   14 ++++++++++----
 vcl/source/gdi/sallayout.cxx          |    6 +++---
 vcl/source/glyphs/graphite_layout.cxx |    4 ++--
 vcl/source/outdev/map.cxx             |    9 +++++----
 vcl/source/outdev/text.cxx            |   12 ++++++------
 vcl/win/source/gdi/winlayout.cxx      |   13 ++++++-------
 9 files changed, 37 insertions(+), 31 deletions(-)

New commits:
commit 47f3485579929724afc0c4c5ebdfd2143cf952be
Author: Norbert Thiebaud <nthiebaud at gmail.com>
Date:   Thu Aug 14 22:43:26 2014 +0200

    Revert "Resolves: fdo#82550 MacOSX GetTextBreak always return -1"
    
    This reverts commit 4c1e2c446865b355f50720b8b96ec704822006dc.
    it was just hiding the underlying bug.

diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx
index f60062b..75ac162 100644
--- a/vcl/source/outdev/text.cxx
+++ b/vcl/source/outdev/text.cxx
@@ -1428,12 +1428,12 @@ sal_Int32 OutputDevice::GetTextBreak( const OUString& rStr, long nTextWidth,
         long nWidthFactor = pSalLayout->GetUnitsPerPixel();
         long nSubPixelFactor = (nWidthFactor < 64 ) ? 64 : 1;
         nTextWidth *= nWidthFactor * nSubPixelFactor;
-        long nTextPixelWidth = ImplLogicWidthToDevicePixel( nTextWidth );
-        long nExtraPixelWidth = 0;
+        DeviceCoordinate nTextPixelWidth = LogicWidthToDeviceCoordinate( nTextWidth );
+        DeviceCoordinate nExtraPixelWidth = 0;
         if( nCharExtra != 0 )
         {
             nCharExtra *= nWidthFactor * nSubPixelFactor;
-            nExtraPixelWidth = ImplLogicWidthToDevicePixel( nCharExtra );
+            nExtraPixelWidth = LogicWidthToDeviceCoordinate( nCharExtra );
         }
         nRetVal = pSalLayout->GetTextBreak( nTextPixelWidth, nExtraPixelWidth, nSubPixelFactor );
 
@@ -1462,12 +1462,12 @@ sal_Int32 OutputDevice::GetTextBreak( const OUString& rStr, long nTextWidth,
         long nSubPixelFactor = (nWidthFactor < 64 ) ? 64 : 1;
 
         nTextWidth *= nWidthFactor * nSubPixelFactor;
-        long nTextPixelWidth = ImplLogicWidthToDevicePixel( nTextWidth );
-        long nExtraPixelWidth = 0;
+        DeviceCoordinate nTextPixelWidth = LogicWidthToDeviceCoordinate( nTextWidth );
+        DeviceCoordinate nExtraPixelWidth = 0;
         if( nCharExtra != 0 )
         {
             nCharExtra *= nWidthFactor * nSubPixelFactor;
-            nExtraPixelWidth = ImplLogicWidthToDevicePixel( nCharExtra );
+            nExtraPixelWidth = LogicWidthToDeviceCoordinate( nCharExtra );
         }
 
         // calculate un-hyphenated break position
commit d8584f62e28369594c5d1b733e5804837a98dd85
Author: Norbert Thiebaud <nthiebaud at gmail.com>
Date:   Thu Aug 14 22:41:26 2014 +0200

    fdo#82550 LogicWidthToDeviceCoordinate missed handling of mbMap == false
    
    Change-Id: I98902ed266ae7b2737fa9720d69a4b87cc958d51

diff --git a/vcl/source/outdev/map.cxx b/vcl/source/outdev/map.cxx
index 819f7db..deaddcb 100644
--- a/vcl/source/outdev/map.cxx
+++ b/vcl/source/outdev/map.cxx
@@ -2144,11 +2144,12 @@ long Window::ImplLogicUnitToPixelY( long nY, MapUnit eUnit )
 
 DeviceCoordinate OutputDevice::LogicWidthToDeviceCoordinate( long nWidth ) const
 {
+    if ( !mbMap )
+        return (DeviceCoordinate)nWidth;
+
 #if VCL_FLOAT_DEVICE_PIXEL
     return (double)nWidth * maMapRes.mfScaleX * mnDPIX;
 #else
-    if ( !mbMap )
-        return nWidth;
 
     return ImplLogicToPixel( nWidth, mnDPIX,
                              maMapRes.mnMapScNumX, maMapRes.mnMapScDenomX,
@@ -2158,11 +2159,11 @@ DeviceCoordinate OutputDevice::LogicWidthToDeviceCoordinate( long nWidth ) const
 
 DeviceCoordinate OutputDevice::LogicHeightToDeviceCoordinate( long nHeight ) const
 {
+    if ( !mbMap )
+        return (DeviceCoordinate)nHeight;
 #if VCL_FLOAT_DEVICE_PIXEL
     return (double)nHeight * maMapRes.mfScaleY * mnDPIY;
 #else
-    if ( !mbMap )
-        return nHeight;
 
     return ImplLogicToPixel( nHeight, mnDPIY,
                              maMapRes.mnMapScNumY, maMapRes.mnMapScDenomY,
commit 32a92502fdbabe7615330e668357568cc4812e54
Author: Norbert Thiebaud <nthiebaud at gmail.com>
Date:   Thu Aug 14 18:08:38 2014 +0200

    GetTextBreak takes a DeviceCoordinate as width
    
    Change-Id: Ie03732a0966eedf6c0226beed83356ae4886a016

diff --git a/vcl/inc/graphite_layout.hxx b/vcl/inc/graphite_layout.hxx
index 77bab7e..24b668d 100644
--- a/vcl/inc/graphite_layout.hxx
+++ b/vcl/inc/graphite_layout.hxx
@@ -123,7 +123,7 @@ public:
     virtual void  AdjustLayout( ImplLayoutArgs& ) SAL_OVERRIDE;  // adjusting positions
 
     // methods using string indexing
-    virtual sal_Int32 GetTextBreak(long nMaxWidth, long nCharExtra=0, int nFactor=1) const SAL_OVERRIDE;
+    virtual sal_Int32 GetTextBreak(DeviceCoordinate nMaxWidth, long nCharExtra=0, int nFactor=1) const SAL_OVERRIDE;
     virtual DeviceCoordinate FillDXArray( DeviceCoordinate* pDXArray ) const SAL_OVERRIDE;
     virtual void  ApplyDXArray(ImplLayoutArgs &rArgs, std::vector<int> & rDeltaWidth);
 
diff --git a/vcl/inc/graphite_serverfont.hxx b/vcl/inc/graphite_serverfont.hxx
index ffbcc06..50063e4 100644
--- a/vcl/inc/graphite_serverfont.hxx
+++ b/vcl/inc/graphite_serverfont.hxx
@@ -76,7 +76,7 @@ public:
         {
             return maImpl.FillDXArray(dxa);
         }
-        virtual sal_Int32 GetTextBreak(long mw, long ce, int f) const SAL_OVERRIDE
+        virtual sal_Int32 GetTextBreak(DeviceCoordinate mw, long ce, int f) const SAL_OVERRIDE
         {
             return maImpl.GetTextBreak(mw, ce, f);
         }
diff --git a/vcl/inc/sallayout.hxx b/vcl/inc/sallayout.hxx
index 7f30727..d68a364 100644
--- a/vcl/inc/sallayout.hxx
+++ b/vcl/inc/sallayout.hxx
@@ -171,7 +171,7 @@ public:
     int             GetOrientation() const                  { return mnOrientation; }
 
     // methods using string indexing
-    virtual sal_Int32 GetTextBreak(long nMaxWidth, long nCharExtra=0, int nFactor=1) const = 0;
+    virtual sal_Int32 GetTextBreak(DeviceCoordinate nMaxWidth, long nCharExtra=0, int nFactor=1) const = 0;
     virtual DeviceCoordinate FillDXArray( DeviceCoordinate* pDXArray ) const = 0;
     virtual long    GetTextWidth() const { return FillDXArray( NULL ); }
     virtual void    GetCaretPositions( int nArraySize, long* pCaretXArray ) const = 0;
@@ -229,7 +229,7 @@ class VCL_PLUGIN_PUBLIC MultiSalLayout : public SalLayout
 {
 public:
     virtual void    DrawText( SalGraphics& ) const SAL_OVERRIDE;
-    virtual sal_Int32 GetTextBreak(long nMaxWidth, long nCharExtra, int nFactor) const SAL_OVERRIDE;
+    virtual sal_Int32 GetTextBreak(DeviceCoordinate nMaxWidth, long nCharExtra, int nFactor) const SAL_OVERRIDE;
     virtual DeviceCoordinate FillDXArray( DeviceCoordinate* pDXArray ) const SAL_OVERRIDE;
     virtual void    GetCaretPositions( int nArraySize, long* pCaretXArray ) const SAL_OVERRIDE;
     virtual int     GetNextGlyphs( int nLen, sal_GlyphId* pGlyphIdxAry, Point& rPos,
@@ -331,7 +331,7 @@ public:
     // used by upper layers
     virtual long    GetTextWidth() const SAL_OVERRIDE;
     virtual DeviceCoordinate FillDXArray( DeviceCoordinate* pDXArray ) const SAL_OVERRIDE;
-    virtual sal_Int32 GetTextBreak(long nMaxWidth, long nCharExtra, int nFactor) const SAL_OVERRIDE;
+    virtual sal_Int32 GetTextBreak(DeviceCoordinate nMaxWidth, long nCharExtra, int nFactor) const SAL_OVERRIDE;
     virtual void    GetCaretPositions( int nArraySize, long* pCaretXArray ) const SAL_OVERRIDE;
 
     // used by display layers
diff --git a/vcl/quartz/ctlayout.cxx b/vcl/quartz/ctlayout.cxx
index 7c851d3..659d89b 100644
--- a/vcl/quartz/ctlayout.cxx
+++ b/vcl/quartz/ctlayout.cxx
@@ -44,7 +44,7 @@ public:
 
     virtual long    GetTextWidth() const SAL_OVERRIDE;
     virtual DeviceCoordinate FillDXArray( DeviceCoordinate* pDXArray ) const SAL_OVERRIDE;
-    virtual sal_Int32 GetTextBreak(long nMaxWidth, long nCharExtra, int nFactor) const SAL_OVERRIDE;
+    virtual sal_Int32 GetTextBreak(DeviceCoordinate nMaxWidth, long nCharExtra, int nFactor) const SAL_OVERRIDE;
     virtual void    GetCaretPositions( int nArraySize, long* pCaretXArray ) const SAL_OVERRIDE;
     virtual bool    GetBoundRect( SalGraphics&, Rectangle& ) const SAL_OVERRIDE;
 
@@ -762,13 +762,16 @@ DeviceCoordinate CTLayout::FillDXArray( DeviceCoordinate* pDXArray ) const
     return nPixWidth;
 }
 
-sal_Int32 CTLayout::GetTextBreak( long nMaxWidth, long nCharExtra, int nFactor ) const
+sal_Int32 CTLayout::GetTextBreak( DeviceCoordinate nMaxWidth, long nCharExtra, int nFactor ) const
 {
     if( !mpCTLine )
+    {
+        SAL_INFO("vcl.ct", "GetTextBreak mpCTLine == NULL");
         return -1;
-
+    }
     CTTypesetterRef aCTTypeSetter = CTTypesetterCreateWithAttributedString( mpAttrString );
     CFIndex nBestGuess = (nCharExtra >= 0) ? 0 : mnCharCount;
+    SAL_INFO("vcl.ct", "GetTextBreak nMaxWidth:" << nMaxWidth << " nBestGuess:" << nBestGuess << " nCharExtra:" << nCharExtra << " nFactor:" << nFactor);
     for( int i = 1; i <= mnCharCount; i *= 2 )
     {
         // guess the target width considering char-extra expansion/condensation
@@ -776,7 +779,9 @@ sal_Int32 CTLayout::GetTextBreak( long nMaxWidth, long nCharExtra, int nFactor )
         const double fCTMaxWidth = nTargetWidth / nFactor;
         // calculate the breaking index for the guessed target width
         const CFIndex nNewIndex = CTTypesetterSuggestClusterBreak( aCTTypeSetter, 0, fCTMaxWidth );
-        if( nNewIndex >= mnCharCount ) {
+        SAL_INFO("vcl.ct", "GetTextBreak nTargetWidth:" << nTargetWidth << " fCTMaxWidth:" << fCTMaxWidth << " nNewIndex:" << nNewIndex);
+        if( nNewIndex >= mnCharCount )
+        {
             CFRelease( aCTTypeSetter );
             return -1;
         }
@@ -795,6 +800,7 @@ sal_Int32 CTLayout::GetTextBreak( long nMaxWidth, long nCharExtra, int nFactor )
     // suggest the best fitting cluster break as breaking position
     CFRelease( aCTTypeSetter );
     const int nIndex = nBestGuess + mnMinCharPos;
+    SAL_INFO("vcl.ct", "GetTextBreak nIndex:" << nIndex);
     return nIndex;
 }
 
diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx
index 21ee47f..de39d87 100644
--- a/vcl/source/gdi/sallayout.cxx
+++ b/vcl/source/gdi/sallayout.cxx
@@ -1278,14 +1278,14 @@ void GenericSalLayout::GetCaretPositions( int nMaxIndex, long* pCaretXArray ) co
     }
 }
 
-sal_Int32 GenericSalLayout::GetTextBreak( long nMaxWidth, long nCharExtra, int nFactor ) const
+sal_Int32 GenericSalLayout::GetTextBreak( DeviceCoordinate nMaxWidth, long nCharExtra, int nFactor ) const
 {
     int nCharCapacity = mnEndCharPos - mnMinCharPos;
     DeviceCoordinate* pCharWidths = (DeviceCoordinate*)alloca( nCharCapacity * sizeof(DeviceCoordinate) );
     if( !GetCharWidths( pCharWidths ) )
         return -1;
 
-    long nWidth = 0;
+    DeviceCoordinate nWidth = 0;
     for( int i = mnMinCharPos; i < mnEndCharPos; ++i )
     {
         nWidth += pCharWidths[ i - mnMinCharPos ] * nFactor;
@@ -1908,7 +1908,7 @@ void MultiSalLayout::DrawText( SalGraphics& rGraphics ) const
     // NOTE: now the baselevel font is active again
 }
 
-sal_Int32 MultiSalLayout::GetTextBreak( long nMaxWidth, long nCharExtra, int nFactor ) const
+sal_Int32 MultiSalLayout::GetTextBreak( DeviceCoordinate nMaxWidth, long nCharExtra, int nFactor ) const
 {
     if( mnLevel <= 0 )
         return -1;
diff --git a/vcl/source/glyphs/graphite_layout.cxx b/vcl/source/glyphs/graphite_layout.cxx
index e5cb5a7..12b5ea9 100644
--- a/vcl/source/glyphs/graphite_layout.cxx
+++ b/vcl/source/glyphs/graphite_layout.cxx
@@ -681,7 +681,7 @@ bool GraphiteLayout::LayoutGlyphs(ImplLayoutArgs& rArgs, gr_segment * pSegment)
     return true;
 }
 
-sal_Int32 GraphiteLayout::GetTextBreak(long maxmnWidth, long char_extra, int factor) const
+sal_Int32 GraphiteLayout::GetTextBreak(DeviceCoordinate maxmnWidth, long char_extra, int factor) const
 {
 #ifdef GRLAYOUT_DEBUG
     fprintf(grLog(),"Gr::GetTextBreak c[%d-%d) maxWidth %ld char extra %ld factor %d\n",
@@ -692,7 +692,7 @@ sal_Int32 GraphiteLayout::GetTextBreak(long maxmnWidth, long char_extra, int fac
     if (maxmnWidth > mnWidth * factor + char_extra * (mnEndCharPos - mnMinCharPos - 1))
         return -1;
 
-    long nWidth = mvCharDxs[0] * factor;
+    DeviceCoordinate nWidth = mvCharDxs[0] * factor;
     long wLastBreak = 0;
     int nLastBreak = -1;
     int nEmergency = -1;
diff --git a/vcl/win/source/gdi/winlayout.cxx b/vcl/win/source/gdi/winlayout.cxx
index 3eb5c5e..a0a0602 100644
--- a/vcl/win/source/gdi/winlayout.cxx
+++ b/vcl/win/source/gdi/winlayout.cxx
@@ -146,7 +146,7 @@ public:
                                    const PhysicalFontFace** pFallbackFonts = NULL ) const;
 
     virtual DeviceCoordinate FillDXArray( DeviceCoordinate* pDXArray ) const;
-    virtual sal_Int32 GetTextBreak(long nMaxWidth, long nCharExtra, int nFactor) const SAL_OVERRIDE;
+    virtual sal_Int32 GetTextBreak(DeviceCoordinate nMaxWidth, long nCharExtra, int nFactor) const SAL_OVERRIDE;
     virtual void    GetCaretPositions( int nArraySize, long* pCaretXArray ) const;
 
     // for glyph+font+script fallback
@@ -644,7 +644,7 @@ DeviceCoordinate SimpleWinLayout::FillDXArray( DeviceCoordinate* pDXArray ) cons
     return mnWidth;
 }
 
-sal_Int32 SimpleWinLayout::GetTextBreak( long nMaxWidth, long nCharExtra, int nFactor ) const
+sal_Int32 SimpleWinLayout::GetTextBreak( DeviceCoordinate nMaxWidth, long nCharExtra, int nFactor ) const
 // NOTE: the nFactor is used to prevent rounding errors for small nCharExtra values
 {
     if( mnWidth )
@@ -967,7 +967,7 @@ public:
                                    const PhysicalFontFace** pFallbackFonts = NULL ) const;
 
     virtual DeviceCoordinate FillDXArray( DeviceCoordinate* pDXArray ) const;
-    virtual sal_Int32 GetTextBreak(long nMaxWidth, long nCharExtra, int nFactor) const SAL_OVERRIDE;
+    virtual sal_Int32 GetTextBreak(DeviceCoordinate nMaxWidth, long nCharExtra, int nFactor) const SAL_OVERRIDE;
     virtual void    GetCaretPositions( int nArraySize, long* pCaretXArray ) const;
     virtual bool    IsKashidaPosValid ( int nCharPos ) const;
 
@@ -2115,7 +2115,7 @@ DeviceCoordinate UniscribeLayout::FillDXArray( DeviceCoordinate* pDXArray ) cons
     return nWidth;
 }
 
-sal_Int32 UniscribeLayout::GetTextBreak( long nMaxWidth, long nCharExtra, int nFactor ) const
+sal_Int32 UniscribeLayout::GetTextBreak( DeviceCoordinate nMaxWidth, long nCharExtra, int nFactor ) const
 {
     long nWidth = 0;
     for( int i = mnMinCharPos; i < mnEndCharPos; ++i )
@@ -2640,7 +2640,7 @@ public:
     virtual void  DrawText( SalGraphics& ) const;
 
     // methods using string indexing
-    virtual sal_Int32 GetTextBreak(long nMaxWidth, long nCharExtra=0, int nFactor=1) const SAL_OVERRIDE;
+    virtual sal_Int32 GetTextBreak(DeviceCoordinate nMaxWidth, long nCharExtra=0, int nFactor=1) const SAL_OVERRIDE;
     virtual DeviceCoordinate FillDXArray( DeviceCoordinate* pDXArray ) const;
 
     virtual void  GetCaretPositions( int nArraySize, long* pCaretXArray ) const;
@@ -2776,8 +2776,7 @@ void GraphiteWinLayout::DrawText(SalGraphics &sal_graphics) const
           DeleteFont( SelectFont( aHDC, hOrigFont ) );
 }
 
-sal_Int32 GraphiteWinLayout::GetTextBreak(
-        long nMaxWidth, long nCharExtra, int nFactor) const
+sal_Int32 GraphiteWinLayout::GetTextBreak(DeviceCoordinate nMaxWidth, long nCharExtra, int nFactor) const
 {
     sal_Int32 nBreak = maImpl.GetTextBreak(nMaxWidth, nCharExtra, nFactor);
     return nBreak;


More information about the Libreoffice-commits mailing list