[Libreoffice-commits] .: 2 commits - svtools/inc svtools/source vcl/inc vcl/unx

Jan Holesovsky kendy at kemper.freedesktop.org
Fri Jun 1 13:27:48 PDT 2012


 svtools/inc/svtools/ruler.hxx    |    2 -
 svtools/source/control/ruler.cxx |   71 +++++++++------------------------------
 vcl/inc/generic/glyphcache.hxx   |    1 
 vcl/unx/generic/gdi/salgdi3.cxx  |   16 ++++++++
 4 files changed, 35 insertions(+), 55 deletions(-)

New commits:
commit 9311947aa0bbfda60af8f97d850d6e5b909d62b5
Author: Jan Holesovsky <kendy at suse.cz>
Date:   Fri Jun 1 22:24:45 2012 +0200

    rulers: Fix the drawing on Windows, the text was still off there.
    
    Change-Id: I8a71851c0c602c17a4088fb969afa07808f5fe20

diff --git a/svtools/inc/svtools/ruler.hxx b/svtools/inc/svtools/ruler.hxx
index 529cb17..bbb0f8e 100644
--- a/svtools/inc/svtools/ruler.hxx
+++ b/svtools/inc/svtools/ruler.hxx
@@ -658,7 +658,7 @@ private:
 #ifdef _SV_RULER_CXX
     SVT_DLLPRIVATE void                ImplVDrawLine( long nX1, long nY1, long nX2, long nY2 );
     SVT_DLLPRIVATE void                ImplVDrawRect( long nX1, long nY1, long nX2, long nY2 );
-    SVT_DLLPRIVATE void                ImplVDrawText( long nX, long nY, const String& rText );
+    SVT_DLLPRIVATE void                ImplVDrawText( long nX, long nY, const String& rText, long nMin = LONG_MIN, long nMax = LONG_MAX );
 
     SVT_DLLPRIVATE void                ImplDrawTicks( long nMin, long nMax, long nStart, long nCenter );
     SVT_DLLPRIVATE void                ImplDrawBorders( long nMin, long nMax, long nVirTop, long nVirBottom );
diff --git a/svtools/source/control/ruler.cxx b/svtools/source/control/ruler.cxx
index f7519a5..a50e465 100644
--- a/svtools/source/control/ruler.cxx
+++ b/svtools/source/control/ruler.cxx
@@ -39,7 +39,7 @@
 // =======================================================================
 
 #define RULER_OFF           3
-#define RULER_TEXTOFF       2
+#define RULER_TEXTOFF       5
 #define RULER_RESIZE_OFF    4
 #define RULER_LINE_WIDTH    7
 #define RULER_MIN_SIZE      3
@@ -286,10 +286,10 @@ void Ruler::ImplInit( WinBits nWinBits )
     // Einstellungen setzen
     ImplInitSettings( sal_True, sal_True, sal_True );
 
-    // Default-Groesse setzen
-    long nDefHeight = GetTextHeight() + RULER_OFF*2 + RULER_TEXTOFF*2 + mnBorderWidth;
-    if ( ( nDefHeight % 2 ) != 0 )
-        ++nDefHeight;
+    // Setup the default size
+    Rectangle aRect;
+    GetTextBoundRect( aRect, rtl::OUString( "0123456789" ) );
+    long nDefHeight = aRect.GetHeight() + RULER_OFF*2 + RULER_TEXTOFF*2 + mnBorderWidth;
 
     Size aDefSize;
     if ( nWinBits & WB_HORZ )
@@ -373,14 +373,20 @@ void Ruler::ImplVDrawRect( long nX1, long nY1, long nX2, long nY2 )
 
 // -----------------------------------------------------------------------
 
-void Ruler::ImplVDrawText( long nX, long nY, const String& rText )
+void Ruler::ImplVDrawText( long nX, long nY, const String& rText, long nMin, long nMax )
 {
-    if ( (nX > -RULER_CLIP) && (nX < mnVirWidth+RULER_CLIP) )
+    Rectangle aRect;
+    maVirDev.GetTextBoundRect( aRect, rText );
+
+    long nShiftX = ( aRect.GetWidth() / 2 ) + aRect.Left();
+    long nShiftY = ( aRect.GetHeight() / 2 ) + aRect.Top();
+
+    if ( (nX > -RULER_CLIP) && (nX < mnVirWidth+RULER_CLIP) && ( nX < nMax - nShiftX ) && ( nX > nMin + nShiftX ) )
     {
         if ( mnWinStyle & WB_HORZ )
-            maVirDev.DrawText( Point( nX, nY ), rText );
+            maVirDev.DrawText( Point( nX - nShiftX, nY - nShiftY ), rText );
         else
-            maVirDev.DrawText( Point( nY, nX ), rText );
+            maVirDev.DrawText( Point( nY - nShiftX, nX - nShiftY ), rText );
     }
 }
 
@@ -456,8 +462,6 @@ void Ruler::ImplDrawTicks( long nMin, long nMax, long nStart, long nCenter )
     long    nTickCount = aImplRulerUnitTab[mnUnitIndex].nTick1;
     Size    aPixSize = maVirDev.LogicToPixel( Size( nTick3, nTick3 ), maMapMode );
     long    nTickWidth;
-    long    nX;
-    long    nY;
     sal_Bool    bNoTicks = sal_False;
 
     //Amelia
@@ -485,17 +489,13 @@ void Ruler::ImplDrawTicks( long nMin, long nMax, long nStart, long nCenter )
 
     // Groessenvorberechnung
     // Sizes calculation
-    sal_Bool bVertRight = sal_False;
     if ( mnWinStyle & WB_HORZ )
         nTickWidth = aPixSize.Width();
     else
     {
         Font aFont = GetFont();
         if ( mnWinStyle & WB_RIGHT_ALIGNED )
-        {
             aFont.SetOrientation( 2700 );
-            bVertRight = sal_True;
-        }
         else
             aFont.SetOrientation( 900 );
         maVirDev.SetFont( aFont );
@@ -565,17 +565,7 @@ void Ruler::ImplDrawTicks( long nMin, long nMax, long nStart, long nCenter )
                     if ( (mpData->nMargin1Style & RULER_STYLE_INVISIBLE) || (mpData->nMargin1 != 0) )
                     {
                         aNumStr = (sal_Unicode)'0';
-                        Rectangle aRect;
-                        GetTextBoundRect( aRect, aNumStr );
-                        long nTxtWidth2 = aRect.Right() / 2 + 1;
-                        long nTxtHeight2 = aRect.Bottom() / 2 + 1;
-
-                        if ( (mnWinStyle & WB_HORZ)^mpData->bTextRTL )
-                            nX = nStart-nTxtWidth2;
-                        else
-                            nX = nStart+nTxtWidth2;
-                        long n_Y = bVertRight ? nCenter+nTxtHeight2 : nCenter-nTxtHeight2;
-                        ImplVDrawText( nX, n_Y, aNumStr );
+                        ImplVDrawText( nStart, nCenter, aNumStr );
                     }
                 }
             }
@@ -596,33 +586,8 @@ void Ruler::ImplDrawTicks( long nMin, long nMax, long nStart, long nCenter )
                     else
                         aNumStr = UniString::CreateFromInt32( nTick / aImplRulerUnitTab[mnUnitIndex].nTickUnit );
 
-                    Rectangle aRect;
-                    GetTextBoundRect( aRect, aNumStr );
-                    long nTxtWidth2 = aRect.Right() / 2 + 1;
-                    long nTxtHeight2 = aRect.Bottom() / 2 + 1;
-
-                    nX = nStart+n;
-                    //different orientation needs a different starting position
-                    nY = bVertRight ? nCenter+nTxtHeight2 : nCenter-nTxtHeight2;
-
-                    // Check if we can display full number
-                    if ( nX < (nMax-nTxtWidth2) )
-                    {
-                        if ( mnWinStyle & WB_HORZ )
-                            nX -= nTxtWidth2;
-                        else
-                            nX += nTxtWidth2;
-                        ImplVDrawText( nX, nY, aNumStr );
-                    }
-                    nX = nStart-n;
-                    if ( nX > (nMin+nTxtWidth2) )
-                    {
-                        if ( mnWinStyle & WB_HORZ )
-                            nX -= nTxtWidth2;
-                        else
-                            nX += nTxtWidth2;
-                        ImplVDrawText( nX, nY, aNumStr );
-                    }
+                    ImplVDrawText( nStart + n, nCenter, aNumStr, nMin, nMax );
+                    ImplVDrawText( nStart - n, nCenter, aNumStr, nMin, nMax );
                 }
                 // Tick/Tick2 - Output (Strokes)
                 else
commit ac25f124858b79e302adcc533d6a658d5c529394
Author: Jan Holesovsky <kendy at suse.cz>
Date:   Fri Jun 1 22:16:37 2012 +0200

    Return correct bounding box of glyphs on Linux, we forgot to rotate it.
    
    This makes the behavior consistent with what happens on Windows.
    
    Change-Id: Ifb04d4a8e485182c5ef2771025b06832bfd75ae0

diff --git a/vcl/inc/generic/glyphcache.hxx b/vcl/inc/generic/glyphcache.hxx
index 1ab2a74..4b3286f 100644
--- a/vcl/inc/generic/glyphcache.hxx
+++ b/vcl/inc/generic/glyphcache.hxx
@@ -234,6 +234,7 @@ public:
 private:
     friend class GlyphCache;
     friend class ServerFontLayout;
+    friend class X11SalGraphics;
 
     void                        AddRef() const      { ++mnRefCount; }
     long                        GetRefCount() const { return mnRefCount; }
diff --git a/vcl/unx/generic/gdi/salgdi3.cxx b/vcl/unx/generic/gdi/salgdi3.cxx
index 7761445..04d2142 100644
--- a/vcl/unx/generic/gdi/salgdi3.cxx
+++ b/vcl/unx/generic/gdi/salgdi3.cxx
@@ -701,7 +701,21 @@ sal_Bool X11SalGraphics::GetGlyphBoundRect( sal_GlyphId nGlyphIndex, Rectangle&
 
     nGlyphIndex &= GF_IDXMASK;
     const GlyphMetric& rGM = pSF->GetGlyphMetric( nGlyphIndex );
-    rRect = Rectangle( rGM.GetOffset(), rGM.GetSize() );
+    Rectangle aRect( rGM.GetOffset(), rGM.GetSize() );
+
+    if ( pSF->mnCos != 0x10000 && pSF->mnSin != 0 )
+    {
+        double nCos = pSF->mnCos / 65536.0;
+        double nSin = pSF->mnSin / 65536.0;
+        rRect.Left() =  nCos*aRect.Left() + nSin*aRect.Top();
+        rRect.Top()  = -nSin*aRect.Left() - nCos*aRect.Top();
+
+        rRect.Right()  =  nCos*aRect.Right() + nSin*aRect.Bottom();
+        rRect.Bottom() = -nSin*aRect.Right() - nCos*aRect.Bottom();
+    }
+    else
+        rRect = aRect;
+
     return sal_True;
 }
 


More information about the Libreoffice-commits mailing list