[Libreoffice-commits] core.git: drawinglayer/source editeng/source include/vcl sw/source vcl/source

Keith Curtis keithcu at gmail.com
Wed Mar 5 07:01:34 PST 2014


 drawinglayer/source/processor2d/helperwrongspellrenderer.cxx |   14 ----
 editeng/source/editeng/impedit3.cxx                          |   16 ----
 include/vcl/outdev.hxx                                       |    7 --
 sw/source/core/inc/wrong.hxx                                 |    7 --
 sw/source/core/txtnode/fntcache.cxx                          |   34 ----------
 vcl/source/gdi/outdev3.cxx                                   |   37 +++--------
 6 files changed, 22 insertions(+), 93 deletions(-)

New commits:
commit ff6f3164dfc454354bee79eac30d6cc279b8a0ec
Author: Keith Curtis <keithcu at gmail.com>
Date:   Sat Feb 22 05:30:00 2014 -0500

    Simplify DrawWave
    
    This patch simplifies the DrawWave logic. Callers of that code would try to
    figure out what size wave to draw and pass down a style integer to
    DrawWaveLine, but DrawWaveLine already has logic which trims the height of the
    wave so it doesn't need the hint.
    
    This doesn't change the UNO API
    (::com::sun::star::awt::FontUnderline::SMALLWAVE), but it does get rid of
    internal usages and maps those small waves to normal.
    
    Note that changing the zoom in Calc right now causes spelling underlines to
    disappear. That bug is not related to these changes.
    
    Conflicts:
    	editeng/source/editeng/impedit3.cxx
    
    Change-Id: I3caa2a74a0f5228b924d4e1b0a77f96eaef5fa00
    Reviewed-on: https://gerrit.libreoffice.org/8168
    Tested-by: Caolán McNamara <caolanm at redhat.com>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/drawinglayer/source/processor2d/helperwrongspellrenderer.cxx b/drawinglayer/source/processor2d/helperwrongspellrenderer.cxx
index 8d1e69f..13a015f 100644
--- a/drawinglayer/source/processor2d/helperwrongspellrenderer.cxx
+++ b/drawinglayer/source/processor2d/helperwrongspellrenderer.cxx
@@ -42,8 +42,6 @@ namespace drawinglayer
         const sal_uInt32 nFontPixelHeight(basegfx::fround(aFontVectorPixel.getLength()));
 
         static const sal_uInt32 nMinimumFontHeight(5); // #define WRONG_SHOW_MIN         5
-        static const sal_uInt32 nSmallFontHeight(11);  // #define WRONG_SHOW_SMALL      11
-        static const sal_uInt32 nMediumFontHeight(15); // #define WRONG_SHOW_MEDIUM     15
 
         if(nFontPixelHeight > nMinimumFontHeight)
         {
@@ -51,16 +49,6 @@ namespace drawinglayer
             const basegfx::B2DPoint aStop(aLocalTransform * basegfx::B2DPoint(rWrongSpellCandidate.getStop(), 0.0));
             const Point aVclStart(basegfx::fround(aStart.getX()), basegfx::fround(aStart.getY()));
             const Point aVclStop(basegfx::fround(aStop.getX()), basegfx::fround(aStop.getY()));
-            sal_uInt16 nWaveStyle(WAVE_FLAT);
-
-            if(nFontPixelHeight > nMediumFontHeight)
-            {
-                nWaveStyle = WAVE_NORMAL;
-            }
-            else if(nFontPixelHeight > nSmallFontHeight)
-            {
-                nWaveStyle = WAVE_SMALL;
-            }
 
             // #i101075# draw it. Do not forget to use the evtl. offsetted origin of the target device,
             // e.g. when used with mask/transparence buffer device
@@ -72,7 +60,7 @@ namespace drawinglayer
             rOutputDevice.EnableMapMode(false);
             rOutputDevice.SetLineColor(Color(aProcessedColor));
             rOutputDevice.SetFillColor();
-            rOutputDevice.DrawWaveLine(aOrigin + aVclStart, aOrigin + aVclStop, nWaveStyle);
+            rOutputDevice.DrawWaveLine(aOrigin + aVclStart, aOrigin + aVclStop);
             rOutputDevice.EnableMapMode(bMapModeEnabledState);
         }
 
diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx
index 1ee1a1b..c095ba2 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -83,8 +83,6 @@ using namespace ::com::sun::star::linguistic2;
 #define RESDIFF     10
 
 #define WRONG_SHOW_MIN       5
-#define WRONG_SHOW_SMALL    11
-#define WRONG_SHOW_MEDIUM   15
 
 struct TabInfo
 {
@@ -169,14 +167,6 @@ static void lcl_DrawRedLines(
     long nHght = pOutDev->LogicToPixel( Size( 0, nFontHeight ) ).Height();
     if( WRONG_SHOW_MIN < nHght )
     {
-        sal_uInt16 nStyle;
-        if( WRONG_SHOW_MEDIUM < nHght )
-            nStyle = WAVE_NORMAL;
-        else if( WRONG_SHOW_SMALL < nHght )
-            nStyle = WAVE_SMALL;
-        else
-            nStyle = WAVE_FLAT;
-
         size_t nEnd, nStart = nIndex;
         bool bWrong = pWrongs->NextWrong( nStart, nEnd );
         while ( bWrong )
@@ -189,12 +179,12 @@ static void lcl_DrawRedLines(
             if ( nEnd > nMaxEnd )
                 nEnd = nMaxEnd;
             Point aPnt1( rPnt );
-            if ( bVertical && ( nStyle != WAVE_FLAT ) )
+            if ( bVertical )
             {
                 // VCL doesn't know that the text is vertical, and is manipulating
                 // the positions a little bit in y direction...
                 long nOnePixel = pOutDev->PixelToLogic( Size( 0, 1 ) ).Height();
-                long nCorrect = ( nStyle == WAVE_NORMAL ) ? 2*nOnePixel : nOnePixel;
+                long nCorrect = 2*nOnePixel;
                 aPnt1.Y() -= nCorrect;
                 aPnt1.X() -= nCorrect;
             }
@@ -227,7 +217,7 @@ static void lcl_DrawRedLines(
                 aPnt2 = Rotate( aPnt2, nOrientation, rOrigin );
             }
 
-            pOutDev->DrawWaveLine( aPnt1, aPnt2, nStyle );
+            pOutDev->DrawWaveLine( aPnt1, aPnt2 );
 
             nStart = nEnd+1;
             if ( nEnd < nMaxEnd )
diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index 1e5659a..6ee194b 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -177,11 +177,6 @@ struct ImplThresholdRes
 #define IMAGE_DRAW_COLORTRANSFORM       ((sal_uInt16)0x0008)
 #define IMAGE_DRAW_SEMITRANSPARENT      ((sal_uInt16)0x0010)
 
-// WaveLine
-#define WAVE_FLAT                       1
-#define WAVE_SMALL                      2
-#define WAVE_NORMAL                     3
-
 // Grid
 #define GRID_DOTS                       ((sal_uLong)0x00000001)
 #define GRID_HORZLINES                  ((sal_uLong)0x00000002)
@@ -1046,7 +1041,7 @@ public:
 #endif
 
     void                        DrawWallpaper( const Rectangle& rRect, const Wallpaper& rWallpaper );
-    void                        DrawWaveLine( const Point& rStartPos, const Point& rEndPos, sal_uInt16 nStyle );
+    void                        DrawWaveLine( const Point& rStartPos, const Point& rEndPos );
     void                        DrawGrid( const Rectangle& rRect, const Size& rDist, sal_uLong nFlags );
 
     void                        DrawTransparent( const PolyPolygon& rPolyPoly, sal_uInt16 nTransparencePercent );
diff --git a/sw/source/core/inc/wrong.hxx b/sw/source/core/inc/wrong.hxx
index 89d6c0b..f2a8831 100644
--- a/sw/source/core/inc/wrong.hxx
+++ b/sw/source/core/inc/wrong.hxx
@@ -38,9 +38,6 @@ enum WrongAreaLineType
 {
     WRONGAREA_DASHED,
     WRONGAREA_WAVE,
-    WRONGAREA_WAVE_NORMAL,
-    WRONGAREA_WAVE_SMALL,
-    WRONGAREA_WAVE_FLAT,
     WRONGAREA_NONE
 };
 
@@ -122,11 +119,11 @@ private:
                 }
                 if (::com::sun::star::awt::FontUnderline::WAVE == lineType)
                 {
-                    return WRONGAREA_WAVE_NORMAL;
+                    return WRONGAREA_WAVE;
                 }
                 if (::com::sun::star::awt::FontUnderline::SMALLWAVE == lineType)
                 {
-                    return WRONGAREA_WAVE_SMALL;
+                    return WRONGAREA_WAVE; //Code draws wave height based on space that fits.
                 }
             }
         }
diff --git a/sw/source/core/txtnode/fntcache.cxx b/sw/source/core/txtnode/fntcache.cxx
index 3bcbb08..66efedb 100644
--- a/sw/source/core/txtnode/fntcache.cxx
+++ b/sw/source/core/txtnode/fntcache.cxx
@@ -628,8 +628,6 @@ void SwFntObj::SetDevFont( const SwViewShell *pSh, OutputDevice& rOut )
 }
 
 #define WRONG_SHOW_MIN 5
-#define WRONG_SHOW_SMALL 11
-#define WRONG_SHOW_MEDIUM 15
 
 /*************************************************************************
  *
@@ -775,31 +773,7 @@ static void lcl_DrawLineForWrongListData(
                 {
                     rInf.GetOut().SetLineColor( wrongArea->mColor );
 
-                    // get wavy line type to use
-                    sal_uInt16 nWave =
-                        WRONG_SHOW_MEDIUM < nHght ? WAVE_NORMAL :
-                        ( WRONG_SHOW_SMALL < nHght ? WAVE_SMALL : WAVE_FLAT );
-
-                    rInf.GetOut().DrawWaveLine( aStart, aEnd, nWave );
-                }
-                else if (WRONGAREA_WAVE_NORMAL == wrongArea->mLineType)
-                {
-                    rInf.GetOut().SetLineColor( wrongArea->mColor );
-
-                    rInf.GetOut().DrawWaveLine( aStart, aEnd, WAVE_NORMAL);
-                }
-
-                else if (WRONGAREA_WAVE_SMALL == wrongArea->mLineType)
-                {
-                    rInf.GetOut().SetLineColor( wrongArea->mColor );
-
-                    rInf.GetOut().DrawWaveLine( aStart, aEnd, WAVE_SMALL);
-                }
-                else if (WRONGAREA_WAVE_FLAT == wrongArea->mLineType)
-                {
-                    rInf.GetOut().SetLineColor( wrongArea->mColor );
-
-                    rInf.GetOut().DrawWaveLine( aStart, aEnd, WAVE_FLAT);
+                    rInf.GetOut().DrawWaveLine( aStart, aEnd );
                 }
             }
         }
@@ -1702,10 +1676,6 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
                         if ( rInf.GetOut().GetConnectMetaFile() )
                             rInf.GetOut().Push();
 
-                        sal_uInt16 nWave =
-                            WRONG_SHOW_MEDIUM < nHght ? WAVE_NORMAL :
-                            ( WRONG_SHOW_SMALL < nHght ? WAVE_SMALL :
-                            WAVE_FLAT );
                         Color aCol( rInf.GetOut().GetLineColor() );
                         bool bColSave = aCol != *pWaveCol;
                         if ( bColSave )
@@ -1753,7 +1723,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
                             rInf.GetFrm()->SwitchHorizontalToVertical( aCurrPos );
                             rInf.GetFrm()->SwitchHorizontalToVertical( aEnd );
                         }
-                        rInf.GetOut().DrawWaveLine( aCurrPos, aEnd, nWave );
+                        rInf.GetOut().DrawWaveLine( aCurrPos, aEnd );
 
                         if ( bColSave )
                             rInf.GetOut().SetLineColor( aCol );
diff --git a/vcl/source/gdi/outdev3.cxx b/vcl/source/gdi/outdev3.cxx
index c9ded12..74cd8e7 100644
--- a/vcl/source/gdi/outdev3.cxx
+++ b/vcl/source/gdi/outdev3.cxx
@@ -5303,8 +5303,7 @@ void OutputDevice::DrawTextLine( const Point& rPos, long nWidth,
         mpAlphaVDev->DrawTextLine( rPos, nWidth, eStrikeout, eUnderline, eOverline, bUnderlineAbove );
 }
 
-void OutputDevice::DrawWaveLine( const Point& rStartPos, const Point& rEndPos,
-                                 sal_uInt16 nStyle )
+void OutputDevice::DrawWaveLine( const Point& rStartPos, const Point& rEndPos )
 {
 
     if ( !IsDeviceOutputNecessary() || ImplIsRecordLayout() )
@@ -5344,32 +5343,22 @@ void OutputDevice::DrawWaveLine( const Point& rStartPos, const Point& rEndPos,
 
     long nWaveHeight;
 
-    if ( nStyle == WAVE_NORMAL )
+    nWaveHeight = 3;
+    nStartY++;
+    nEndY++;
+
+    if (mnDPIScaleFactor > 1)
     {
-        nWaveHeight = 3;
-        nStartY++;
-        nEndY++;
+        nWaveHeight *= mnDPIScaleFactor;
 
-        if (mnDPIScaleFactor > 1)
-        {
-            nWaveHeight *= mnDPIScaleFactor;
+        nStartY += mnDPIScaleFactor - 1; // Shift down additional pixel(s) to create more visual separation.
 
-            // odd heights look better than even
-            if (mnDPIScaleFactor % 2 == 0)
-            {
-                nStartY++; // Shift down an additional pixel to create more visual separation.
-                nWaveHeight--;
-            }
+        // odd heights look better than even
+        if (mnDPIScaleFactor % 2 == 0)
+        {
+            nWaveHeight--;
         }
     }
-    else if( nStyle == WAVE_SMALL )
-    {
-        nWaveHeight = 2;
-        nStartY++;
-        nEndY++;
-    }
-    else // WAVE_FLAT
-        nWaveHeight = 1;
 
     // #109280# make sure the waveline does not exceed the descent to avoid paint problems
     ImplFontEntry* pFontEntry = mpFontEntry;
@@ -5381,7 +5370,7 @@ void OutputDevice::DrawWaveLine( const Point& rStartPos, const Point& rEndPos,
             mnDPIScaleFactor, nOrientation, GetLineColor());
 
     if( mpAlphaVDev )
-        mpAlphaVDev->DrawWaveLine( rStartPos, rEndPos, nStyle );
+        mpAlphaVDev->DrawWaveLine( rStartPos, rEndPos );
 }
 
 void OutputDevice::DrawText( const Point& rStartPt, const OUString& rStr,


More information about the Libreoffice-commits mailing list