[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-4.1' - drawinglayer/source include/svx svx/source sw/source

Kohei Yoshida kohei.yoshida at collabora.com
Tue Mar 18 12:34:17 PDT 2014


 drawinglayer/source/primitive2d/borderlineprimitive2d.cxx |   56 +++++------
 include/svx/framelink.hxx                                 |   19 ++-
 svx/source/dialog/framelink.cxx                           |   53 +++++-----
 sw/source/core/layout/paintfrm.cxx                        |   70 +++-----------
 4 files changed, 84 insertions(+), 114 deletions(-)

New commits:
commit b44f22bf0a67eca8d34ca4f561de6a1cc13f9e27
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Mon Mar 17 19:11:35 2014 -0400

    fdo#75260: Improve double line drawing for writer table.
    
    (cherry picked from commit 1c6fb266567c8e397e3c65663b21f0fa50696aa5)
    (cherry picked from commit 77b6c1602aaa0bd059077765e7fabb53d9e6ddeb)
    (cherry picked from commit 32391d25293935fbbf0075e3ccf68625951427f0)
    (cherry picked from commit 24b4fbfa39f212c769bf4d966258a8fb4c98c201)
    (cherry picked from commit 07909e0045d9f94329861fe2e7b3403a5c4befed)
    (cherry picked from commit 335470edf00cabb47abb9d7dcc4dd3a5a0e79616)
    
    Change-Id: Id350531f09b3ded66fd05ea7ebeefe8771260b62

diff --git a/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx b/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx
index e34256d..384c9bc 100644
--- a/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx
@@ -183,37 +183,33 @@ primitive2d::Primitive2DReference makeSolidLinePrimitive(
 
                     xRetval.realloc(2);
 
-                    {
-                        // "inside" line
-                        double fWidth = getLeftWidth();
-                        basegfx::BColor aColor = getRGBColorLeft();
-                        bool bIsHairline = lcl_UseHairline(
-                                fWidth, getStart(), getEnd(), rViewInformation);
-                        fWidth = lcl_GetCorrectedWidth(fWidth,
-                                    getStart(), getEnd(), rViewInformation);
-
-                        if (bIsHairline)
-                            xRetval[0] = makeHairLinePrimitive(getStart(), getEnd(), aVector, aColor, 0.0);
-                        else
-                            xRetval[0] = makeSolidLinePrimitive(
-                                aClipRegion, aTmpStart, aTmpEnd, aVector, aColor, fWidth, 0.0);
-                    }
+                    double fLeftWidth = getLeftWidth();
+                    bool bLeftHairline = lcl_UseHairline(fLeftWidth, getStart(), getEnd(), rViewInformation);
+                    if (bLeftHairline)
+                        fLeftWidth = 0.0;
 
-                    {
-                        // "outside" line
-                        double fWidth = getRightWidth();
-                        basegfx::BColor aColor = getRGBColorRight();
-                        bool bIsHairline = lcl_UseHairline(
-                                fWidth, getStart(), getEnd(), rViewInformation);
-                        fWidth = lcl_GetCorrectedWidth(fWidth,
-                                    getStart(), getEnd(), rViewInformation);
-
-                        if (bIsHairline)
-                            xRetval[1] = makeHairLinePrimitive(getStart(), getEnd(), aVector, aColor, mfDistance);
-                        else
-                            xRetval[1] = makeSolidLinePrimitive(
-                                aClipRegion, aTmpStart, aTmpEnd, aVector, aColor, fWidth, mfDistance);
-                    }
+                    double fRightWidth = getRightWidth();
+                    bool bRightHairline = lcl_UseHairline(fRightWidth, getStart(), getEnd(), rViewInformation);
+                    if (bRightHairline)
+                        fRightWidth = 0.0;
+
+                    // "inside" line
+
+                    if (bLeftHairline)
+                        xRetval[0] = makeHairLinePrimitive(
+                            getStart(), getEnd(), aVector, getRGBColorLeft(), 0.0);
+                    else
+                        xRetval[0] = makeSolidLinePrimitive(
+                            aClipRegion, aTmpStart, aTmpEnd, aVector, getRGBColorLeft(), fLeftWidth, -fLeftWidth/2.0);
+
+                    // "outside" line
+
+                    if (bRightHairline)
+                        xRetval[1] = makeHairLinePrimitive(
+                            getStart(), getEnd(), aVector, getRGBColorRight(), fLeftWidth+mfDistance);
+                    else
+                        xRetval[1] = makeSolidLinePrimitive(
+                            aClipRegion, aTmpStart, aTmpEnd, aVector, getRGBColorRight(), fRightWidth, mfDistance+fRightWidth/2.0);
                 }
                 else
                 {
diff --git a/include/svx/framelink.hxx b/include/svx/framelink.hxx
index e17de58..b8724d6 100644
--- a/include/svx/framelink.hxx
+++ b/include/svx/framelink.hxx
@@ -124,14 +124,15 @@ public:
     inline const Color& GetColorSecn() const { return maColorSecn; }
     inline const Color& GetColorGap() const { return maColorGap; }
     inline bool         UseGapColor() const { return mbUseGapColor; }
-    inline double       Prim() const { return mnPrim; }
-    inline double       Dist() const { return mnDist; }
-    inline double       Secn() const { return mnSecn; }
-    double Scale() const;
+    inline double       Prim() const { return mfPrim; }
+    inline double       Dist() const { return mfDist; }
+    inline double       Secn() const { return mfSecn; }
+    double PatternScale() const;
+    void SetPatternScale( double fScale );
     inline editeng::SvxBorderStyle Type() const { return mnType; }
 
     /** Returns the total width of this frame style. */
-    inline double       GetWidth() const { return mnPrim + mnDist + mnSecn; }
+    inline double       GetWidth() const { return mfPrim + mfDist + mfSecn; }
 
     /** Sets the frame style to invisible state. */
     void                Clear();
@@ -165,10 +166,10 @@ private:
     Color               maColorGap;
     bool                mbUseGapColor;
     RefMode             meRefMode;  /// Reference point handling for this frame border.
-    double              mnPrim;     /// Width of primary (single, left, or top) line.
-    double              mnDist;     /// Distance between primary and secondary line.
-    double              mnSecn;     /// Width of secondary (right or bottom) line.
-    double              mfScale;
+    double              mfPrim;     /// Width of primary (single, left, or top) line.
+    double              mfDist;     /// Distance between primary and secondary line.
+    double              mfSecn;     /// Width of secondary (right or bottom) line.
+    double mfPatternScale; /// Scale used for line pattern spacing.
     editeng::SvxBorderStyle      mnType;
 };
 
diff --git a/svx/source/dialog/framelink.cxx b/svx/source/dialog/framelink.cxx
index 8268374..28383a9 100644
--- a/svx/source/dialog/framelink.cxx
+++ b/svx/source/dialog/framelink.cxx
@@ -1126,7 +1126,7 @@ void lclDrawDiagFrameBorders(
 
 Style::Style() :
     meRefMode(REFMODE_CENTERED),
-    mfScale(1.0),
+    mfPatternScale(1.0),
     mnType(table::BorderLineStyle::SOLID)
 {
     Clear();
@@ -1134,7 +1134,7 @@ Style::Style() :
 
 Style::Style( double nP, double nD, double nS, editeng::SvxBorderStyle nType ) :
     meRefMode(REFMODE_CENTERED),
-    mfScale(1.0),
+    mfPatternScale(1.0),
     mnType(nType)
 {
     Clear();
@@ -1144,7 +1144,7 @@ Style::Style( double nP, double nD, double nS, editeng::SvxBorderStyle nType ) :
 Style::Style( const Color& rColorPrim, const Color& rColorSecn, const Color& rColorGap, bool bUseGapColor,
               double nP, double nD, double nS, editeng::SvxBorderStyle nType ) :
     meRefMode(REFMODE_CENTERED),
-    mfScale(1.0),
+    mfPatternScale(1.0),
     mnType(nType)
 {
     Set( rColorPrim, rColorSecn, rColorGap, bUseGapColor, nP, nD, nS );
@@ -1152,21 +1152,26 @@ Style::Style( const Color& rColorPrim, const Color& rColorSecn, const Color& rCo
 
 Style::Style( const editeng::SvxBorderLine& rBorder, double fScale, sal_uInt16 nMaxWidth ) :
     meRefMode(REFMODE_CENTERED),
-    mfScale(fScale)
+    mfPatternScale(fScale)
 {
     Set( rBorder, fScale, nMaxWidth );
 }
 
 Style::Style( const editeng::SvxBorderLine* pBorder, double fScale, sal_uInt16 nMaxWidth ) :
     meRefMode(REFMODE_CENTERED),
-    mfScale(fScale)
+    mfPatternScale(fScale)
 {
     Set( pBorder, fScale, nMaxWidth );
 }
 
-double Style::Scale() const
+double Style::PatternScale() const
 {
-    return mfScale;
+    return mfPatternScale;
+}
+
+void Style::SetPatternScale( double fScale )
+{
+    mfPatternScale = fScale;
 }
 
 void Style::Clear()
@@ -1183,9 +1188,9 @@ void Style::Set( double nP, double nD, double nS )
         >0  0   >0      nP      0       0
         >0  >0  >0      nP      nD      nS
      */
-    mnPrim = rtl::math::round(nP ? nP : nS, 2);
-    mnDist = rtl::math::round((nP && nS) ? nD : 0, 2);
-    mnSecn = rtl::math::round((nP && nD) ? nS : 0, 2);
+    mfPrim = rtl::math::round(nP ? nP : nS, 2);
+    mfDist = rtl::math::round((nP && nS) ? nD : 0, 2);
+    mfSecn = rtl::math::round((nP && nD) ? nS : 0, 2);
 }
 
 void Style::Set( const Color& rColorPrim, const Color& rColorSecn, const Color& rColorGap, bool bUseGapColor, double nP, double nD, double nS )
@@ -1219,29 +1224,29 @@ void Style::Set( const SvxBorderLine& rBorder, double fScale, sal_uInt16 nMaxWid
         // Enlarge the style if distance is too small due to rounding losses.
         double nPixWidth = SCALEVALUE( nPrim + nDist + nSecn );
         if( nPixWidth > GetWidth() )
-            mnDist = nPixWidth - mnPrim - mnSecn;
+            mfDist = nPixWidth - mfPrim - mfSecn;
         // Shrink the style if it is too thick for the control.
         while( GetWidth() > nMaxWidth )
         {
             // First decrease space between lines.
-            if( mnDist )
-                --mnDist;
+            if( mfDist )
+                --mfDist;
             // Still too thick? Decrease the line widths.
             if( GetWidth() > nMaxWidth )
             {
-                if( rtl::math::approxEqual(mnPrim, 0.0) && rtl::math::approxEqual(mnPrim, mnSecn) )
+                if( rtl::math::approxEqual(mfPrim, 0.0) && rtl::math::approxEqual(mfPrim, mfSecn) )
                 {
                     // Both lines equal - decrease both to keep symmetry.
-                    --mnPrim;
-                    --mnSecn;
+                    --mfPrim;
+                    --mfSecn;
                 }
                 else
                 {
                     // Decrease each line for itself
-                    if( mnPrim )
-                        --mnPrim;
-                    if( (GetWidth() > nMaxWidth) && !rtl::math::approxEqual(mnSecn, 0.0) )
-                        --mnSecn;
+                    if( mfPrim )
+                        --mfPrim;
+                    if( (GetWidth() > nMaxWidth) && !rtl::math::approxEqual(mfSecn, 0.0) )
+                        --mfSecn;
                 }
             }
         }
@@ -1261,8 +1266,8 @@ void Style::Set( const SvxBorderLine* pBorder, double fScale, sal_uInt16 nMaxWid
 
 Style& Style::MirrorSelf()
 {
-    if( mnSecn )
-        std::swap( mnPrim, mnSecn );
+    if( mfSecn )
+        std::swap( mfPrim, mfSecn );
     if( meRefMode != REFMODE_CENTERED )
         meRefMode = (meRefMode == REFMODE_BEGIN) ? REFMODE_END : REFMODE_BEGIN;
     return *this;
@@ -1429,7 +1434,7 @@ drawinglayer::primitive2d::Primitive2DSequence CreateClippedBorderPrimitives (
         rBorder.GetColorSecn().getBColor(),
         rBorder.GetColorPrim().getBColor(),
         rBorder.GetColorGap().getBColor(),
-        rBorder.UseGapColor(), rBorder.Type(), rBorder.Scale() );
+        rBorder.UseGapColor(), rBorder.Type(), rBorder.PatternScale() );
 
     return aSequence;
 }
@@ -1457,7 +1462,7 @@ drawinglayer::primitive2d::Primitive2DSequence CreateBorderPrimitives(
         rBorder.GetColorSecn().getBColor(),
         rBorder.GetColorPrim().getBColor(),
         rBorder.GetColorGap().getBColor(),
-        rBorder.UseGapColor(), rBorder.Type(), rBorder.Scale() );
+        rBorder.UseGapColor(), rBorder.Type(), rBorder.PatternScale() );
 
     return aSequence;
 }
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index 7af9380..24ee0f3 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -2371,9 +2371,6 @@ void SwTabFrmPainter::PaintLines(OutputDevice& rDev, const SwRect& rRect) const
     // #i16816# tagged pdf support
     SwTaggedPDFHelper aTaggedPDFHelper( 0, 0, 0, rDev );
 
-    const SwFrm* pTmpFrm = &mrTabFrm;
-    const bool bVert = pTmpFrm->IsVertical();
-
     SwLineEntryMapConstIter aIter = maHoriLines.begin();
     bool bHori = true;
 
@@ -2391,17 +2388,6 @@ void SwTabFrmPainter::PaintLines(OutputDevice& rDev, const SwRect& rRect) const
         rDev.SetDrawMode( 0 );
     }
 
-    // set clip region:
-    rDev.Push( PUSH_CLIPREGION );
-    Size aSize( rRect.SSize() );
-    // Hack! Necessary, because the layout is not pixel aligned!
-    aSize.Width() += nPixelSzW; aSize.Height() += nPixelSzH;
-    rDev.SetClipRegion(Region(Rectangle(rRect.Pos(), aSize)));
-
-    // The following stuff is necessary to have the new table borders fit
-    // into a ::SwAlignRect adjusted world.
-    const SwTwips nTwipXCorr =  bVert ? 0 : std::max( 0L, nHalfPixelSzW - 2 );    // 1 < 2 < 3 ;-)
-    const SwTwips nTwipYCorr = !bVert ? 0 : std::max( 0L, nHalfPixelSzW - 2 );    // 1 < 2 < 3 ;-)
     const SwFrm* pUpper = mrTabFrm.GetUpper();
     SwRect aUpper( pUpper->Prt() );
     aUpper.Pos() += pUpper->Frm().Pos();
@@ -2513,25 +2499,6 @@ void SwTabFrmPainter::PaintLines(OutputDevice& rDev, const SwRect& rRect) const
             else
                 pTmpColor = pHCColor;
 
-            // The line sizes stored in the line style have to be adjusted as
-            // well.  This will guarantee that lines with the same twip size
-            // will have the same pixel size.
-            for ( int i = 0; i < 7; ++i )
-            {
-                sal_uInt16 nPrim = aStyles[ i ].Prim();
-                sal_uInt16 nDist = aStyles[ i ].Dist();
-                sal_uInt16 nSecn = aStyles[ i ].Secn();
-
-                if (nPrim > 0)
-                    nPrim = (sal_uInt16)( std::max( 1L, nPixelSzH * ( nPrim / nPixelSzH ) ) );
-                if (nDist > 0)
-                    nDist = (sal_uInt16)( std::max( 1L, nPixelSzH * ( nDist / nPixelSzH ) ) );
-                if (nSecn > 0)
-                    nSecn = (sal_uInt16)( std::max( 1L, nPixelSzH * ( nSecn / nPixelSzH ) ) );
-
-                aStyles[ i ].Set( nPrim, nDist, nSecn );
-            }
-
             // The (twip) positions will be adjusted to meet these requirements:
             // 1. The y coordinates are located in the middle of the pixel grid
             // 2. The x coordinated are located at the beginning of the pixel grid
@@ -2589,12 +2556,6 @@ void SwTabFrmPainter::PaintLines(OutputDevice& rDev, const SwRect& rRect) const
                 aPaintEnd.Y()   += static_cast<long>(offsetEnd   + 0.5);
             }
 
-            aPaintStart.X() -= nTwipXCorr; // nHalfPixelSzW - 2 to assure that we do not leave the pixel
-            aPaintEnd.X()   -= nTwipXCorr;
-            aPaintStart.Y() -= nTwipYCorr;
-            aPaintEnd.Y()   -= nTwipYCorr;
-
-            // Here comes the painting stuff: Thank you, DR, great job!!!
             if (bHori)
             {
                 mrTabFrm.ProcessPrimitives( svx::frame::CreateBorderPrimitives(
@@ -2631,7 +2592,6 @@ void SwTabFrmPainter::PaintLines(OutputDevice& rDev, const SwRect& rRect) const
     }
 
     // restore output device:
-    rDev.Pop();
     rDev.SetDrawMode( nOldDrawMode );
 }
 
@@ -2755,13 +2715,17 @@ void calcOffsetForDoubleLine( SwLineEntryMap& rLines )
             for (size_t i = 0; itSet != itSetEnd; ++itSet, ++i)
             {
                 SwLineEntry aLine = *itSet;
-                aLine.mnOffset = static_cast<SwTwips>(aLine.maAttribute.Dist());
-                aLine.mbOffsetPerp = true;
-
-                if (i == 0)
-                    aLine.mbOffsetStart = true;
-                if (i == nEntryCount - 1)
-                    aLine.mbOffsetEnd = true;
+                if (aLine.maAttribute.Secn())
+                {
+                    // Apply offset only for double lines.
+                    aLine.mnOffset = static_cast<SwTwips>(aLine.maAttribute.Dist());
+                    aLine.mbOffsetPerp = true;
+
+                    if (i == 0)
+                        aLine.mbOffsetStart = true;
+                    if (i == nEntryCount - 1)
+                        aLine.mbOffsetEnd = true;
+                }
 
                 aNewSet.insert(aLine);
             }
@@ -2823,10 +2787,14 @@ void SwTabFrmPainter::Insert( const SwFrm& rFrm, const SvxBoxItem& rBoxItem )
     const Fraction& rFracX = rMapMode.GetScaleX();
     const Fraction& rFracY = rMapMode.GetScaleY();
 
-    svx::frame::Style aL(rBoxItem.GetLeft(), rFracX);
-    svx::frame::Style aR(rBoxItem.GetRight(), rFracY);
-    svx::frame::Style aT(rBoxItem.GetTop(), rFracX);
-    svx::frame::Style aB(rBoxItem.GetBottom(), rFracY);
+    svx::frame::Style aL(rBoxItem.GetLeft());
+    aL.SetPatternScale(rFracY);
+    svx::frame::Style aR(rBoxItem.GetRight());
+    aR.SetPatternScale(rFracY);
+    svx::frame::Style aT(rBoxItem.GetTop());
+    aT.SetPatternScale(rFracX);
+    svx::frame::Style aB(rBoxItem.GetBottom());
+    aB.SetPatternScale(rFracX);
 
     aR.MirrorSelf();
     aB.MirrorSelf();


More information about the Libreoffice-commits mailing list