[Libreoffice-commits] core.git: Branch 'feature/borderline3' - include/svx svx/source sw/source

Armin Le Grand Armin.Le.Grand at cib.de
Thu Aug 31 16:05:13 UTC 2017


 include/svx/framelink.hxx            |   90 +++++++-----------
 svx/source/dialog/framelink.cxx      |  171 ++++++++++++++++++++++++-----------
 svx/source/dialog/framelinkarray.cxx |   66 ++++++-------
 sw/source/core/layout/paintfrm.cxx   |  106 ++++++++++++---------
 4 files changed, 252 insertions(+), 181 deletions(-)

New commits:
commit d9571a002397230d3b2a880ed1ca434fb842c240
Author: Armin Le Grand <Armin.Le.Grand at cib.de>
Date:   Thu Aug 31 17:57:46 2017 +0200

    borderline: Adapted Writer to use CreateBorderPrimitives
    
    Also further refined svx::frame::Style, some more cleanups
    in svx using CreateBorderPrimitives, got rid of one
    implementation of CreateBorderPrimitives
    
    Change-Id: I4c2481181df4fc4aa0dbb4cb9f4352066b9d8ec0

diff --git a/include/svx/framelink.hxx b/include/svx/framelink.hxx
index 3efd7165c75a..b2e0da985ff0 100644
--- a/include/svx/framelink.hxx
+++ b/include/svx/framelink.hxx
@@ -142,70 +142,74 @@ private:
         {}
     };
 
+    /// the impl class holding the data
     std::shared_ptr< implStyle >        maImplStyle;
 
+    /// call to set maImplStyle on demand
+    void implEnsureImplStyle();
+
+    /// need information which cell this style info comes from due to needed
+    /// rotation info (which is in the cell). Rotation depends on the cell.
+    friend class Cell;
+    void SetUsingCell(const Cell* pCell);
+
 public:
     /** Constructs an invisible frame style. */
     explicit Style();
     /** Constructs a frame style with passed line widths. */
     explicit Style( double nP, double nD, double nS, SvxBorderLineStyle nType );
     /** Constructs a frame style with passed color and line widths. */
-    explicit Style( const Color& rColorPrim, const Color& rColorSecn, const Color& rColorGap, bool bUseGapColor,
-                    double nP, double nD, double nS, SvxBorderLineStyle nType );
+    explicit Style( const Color& rColorPrim, const Color& rColorSecn, const Color& rColorGap, bool bUseGapColor, double nP, double nD, double nS, SvxBorderLineStyle nType );
     /** Constructs a frame style from the passed SvxBorderLine struct. Clears the style, if pBorder is 0. */
     explicit Style( const editeng::SvxBorderLine* pBorder, double fScale = 1.0 );
 
-    RefMode      GetRefMode() const { return maImplStyle->meRefMode; }
-    const Color& GetColorPrim() const { return maImplStyle->maColorPrim; }
-    const Color& GetColorSecn() const { return maImplStyle->maColorSecn; }
-    const Color& GetColorGap() const { return maImplStyle->maColorGap; }
-    bool         UseGapColor() const { return maImplStyle->mbUseGapColor; }
-    double       Prim() const { return maImplStyle->mfPrim; }
-    double       Dist() const { return maImplStyle->mfDist; }
-    double       Secn() const { return maImplStyle->mfSecn; }
-    double PatternScale() const { return maImplStyle->mfPatternScale;}
-    void SetPatternScale( double fScale ) { maImplStyle->mfPatternScale = fScale; }
-    SvxBorderLineStyle Type() const { return maImplStyle->mnType; }
+    RefMode GetRefMode() const { if(!maImplStyle) return RefMode::Centered; return maImplStyle->meRefMode; }
+    const Color GetColorPrim() const { if(!maImplStyle) return Color(); return maImplStyle->maColorPrim; }
+    const Color GetColorSecn() const { if(!maImplStyle) return Color(); return maImplStyle->maColorSecn; }
+    const Color GetColorGap() const { if(!maImplStyle) return Color(); return maImplStyle->maColorGap; }
+    bool UseGapColor() const { if(!maImplStyle) return false; return maImplStyle->mbUseGapColor; }
+    double Prim() const { if(!maImplStyle) return 0.0; return maImplStyle->mfPrim; }
+    double Dist() const { if(!maImplStyle) return 0.0; return maImplStyle->mfDist; }
+    double Secn() const { if(!maImplStyle) return 0.0; return maImplStyle->mfSecn; }
+    double PatternScale() const { if(!maImplStyle) return 0.0; return maImplStyle->mfPatternScale;}
+    void SetPatternScale( double fScale );
+    SvxBorderLineStyle Type() const { if(!maImplStyle) return SvxBorderLineStyle::SOLID; return maImplStyle->mnType; }
+
+    /// Check if this style is used - this depends on it having any width definition.
+    /// As can be seen in the definition comment above, Prim() *must* be non zero to have a width
+    bool IsUsed() const { if(!maImplStyle) return false; return 0.0 != maImplStyle->mfPrim; }
 
     /** Returns the total width of this frame style. */
-    double       GetWidth() const;
+    double GetWidth() const { if(!maImplStyle) return 0.0; implStyle* pTarget = maImplStyle.get(); return pTarget->mfPrim + pTarget->mfDist + pTarget->mfSecn; }
 
     /** Sets the frame style to invisible state. */
-    void                Clear();
+    void Clear();
     /** Sets the frame style to the passed line widths. */
-    void                Set( double nP, double nD, double nS );
+    void Set( double nP, double nD, double nS );
     /** Sets the frame style to the passed line widths. */
-    void                Set( const Color& rColorPrim, const Color& rColorSecn, const Color& rColorGap, bool bUseGapColor,
-                            double nP, double nD, double nS );
+    void Set( const Color& rColorPrim, const Color& rColorSecn, const Color& rColorGap, bool bUseGapColor, double nP, double nD, double nS );
     /** Sets the frame style to the passed SvxBorderLine struct. */
-    void                Set( const editeng::SvxBorderLine& rBorder, double fScale, sal_uInt16 nMaxWidth = SAL_MAX_UINT16 );
+    void Set( const editeng::SvxBorderLine& rBorder, double fScale, sal_uInt16 nMaxWidth = SAL_MAX_UINT16 );
     /** Sets the frame style to the passed SvxBorderLine struct. Clears the style, if pBorder is 0. */
-    void                Set( const editeng::SvxBorderLine* pBorder, double fScale, sal_uInt16 nMaxWidth = SAL_MAX_UINT16 );
+    void Set( const editeng::SvxBorderLine* pBorder, double fScale, sal_uInt16 nMaxWidth = SAL_MAX_UINT16 );
 
     /** Sets a new reference point handling mode, does not modify other settings. */
-    void         SetRefMode( RefMode eRefMode ) { maImplStyle->meRefMode = eRefMode; }
+    void SetRefMode( RefMode eRefMode );
     /** Sets a new color, does not modify other settings. */
-    void         SetColorPrim( const Color& rColor ) { maImplStyle->maColorPrim = rColor; }
-    void         SetColorSecn( const Color& rColor ) { maImplStyle->maColorSecn = rColor; }
+    void SetColorPrim( const Color& rColor );
+    void SetColorSecn( const Color& rColor );
     /** Sets whether to use dotted style for single hair lines. */
-    void         SetType( SvxBorderLineStyle nType ) { maImplStyle->mnType = nType; }
+    void SetType( SvxBorderLineStyle nType );
 
     /** Mirrors this style (exchanges primary and secondary), if it is a double frame style. */
-    Style&              MirrorSelf();
+    Style& MirrorSelf();
 
     /** return the Cell using this style (if set) */
     const Cell* GetUsingCell() const;
-
-private:
-    /// need information which cell this style info comes from due to needed
-    /// rotation info (which is in the cell). Rotation depends on the cell.
-    friend class Cell;
-    void SetUsingCell(const Cell* pCell);
 };
 
 bool operator==( const Style& rL, const Style& rR );
 SVX_DLLPUBLIC bool operator<( const Style& rL, const Style& rR );
-
 inline bool operator>( const Style& rL, const Style& rR ) { return rR < rL; }
 
 // Various helper functions
@@ -314,27 +318,7 @@ SVX_DLLPUBLIC void CreateBorderPrimitives(
     const Color*        pForceColor     /// If specified, overrides frame border color.
 );
 
-SVX_DLLPUBLIC void CreateBorderPrimitives(
-    drawinglayer::primitive2d::Primitive2DContainer&    rTarget,        /// target for created primitives
-
-    const basegfx::B2DPoint&    rOrigin,    /// start point of borderline
-    const basegfx::B2DVector&   rX,         /// X-Axis with length
-    const basegfx::B2DVector&   rY,         /// Y-Axis for perpendicular, normalized. Does *not* need to be perpendicular, but may express a rotation
-
-    const Style&        rBorder,        /// Style of the processed frame border.
-
-    const Style&        rLFromT,        /// Vertical frame border from top to left end of rBorder.
-    const Style&        rLFromL,        /// Horizontal frame border from left to left end of rBorder.
-    const Style&        rLFromB,        /// Vertical frame border from bottom to left end of rBorder.
-
-    const Style&        rRFromT,        /// Vertical frame border from top to right end of rBorder.
-    const Style&        rRFromR,        /// Horizontal frame border from right to right end of rBorder.
-    const Style&        rRFromB,        /// Vertical frame border from bottom to right end of rBorder.
-
-    const Color*        pForceColor     /// If specified, overrides frame border color.
-);
-
-class StyleVectorCombination
+class SAL_WARN_UNUSED SVX_DLLPUBLIC StyleVectorCombination
 {
 private:
     const Style&                mrStyle;
diff --git a/svx/source/dialog/framelink.cxx b/svx/source/dialog/framelink.cxx
index 36c5e9ae8130..8279cf756597 100644
--- a/svx/source/dialog/framelink.cxx
+++ b/svx/source/dialog/framelink.cxx
@@ -42,15 +42,21 @@ namespace svx {
 namespace frame {
 
 // Classes
-Style::Style() : maImplStyle(new implStyle())
+void Style::implEnsureImplStyle()
+{
+    if(!maImplStyle)
+    {
+        maImplStyle.reset(new implStyle());
+    }
+}
+
+Style::Style() : maImplStyle()
 {
-    Clear();
 }
 
 Style::Style( double nP, double nD, double nS, SvxBorderLineStyle nType ) : maImplStyle(new implStyle())
 {
     maImplStyle->mnType = nType;
-    Clear();
     Set( nP, nD, nS );
 }
 
@@ -66,16 +72,28 @@ Style::Style( const editeng::SvxBorderLine* pBorder, double fScale ) : maImplSty
     Set( pBorder, fScale );
 }
 
-double Style::GetWidth() const
+void Style::SetPatternScale( double fScale )
 {
-    implStyle* pTarget = maImplStyle.get();
+    if(!maImplStyle)
+    {
+        if(1.0 == fScale)
+        {
+            return;
+        }
 
-    return pTarget->mfPrim + pTarget->mfDist + pTarget->mfSecn;
+        implEnsureImplStyle();
+    }
+
+    maImplStyle->mfPatternScale = fScale;
 }
 
 void Style::Clear()
 {
-    Set( Color(), Color(), Color(), false, 0, 0, 0 );
+    if(maImplStyle)
+    {
+        Set( Color(), Color(), Color(), false, 0, 0, 0 );
+        maImplStyle->mnType = SvxBorderLineStyle::SOLID;
+    }
 }
 
 void Style::Set( double nP, double nD, double nS )
@@ -87,6 +105,7 @@ void Style::Set( double nP, double nD, double nS )
         >0  0   >0      nP      0       0
         >0  >0  >0      nP      nD      nS
      */
+    implEnsureImplStyle();
     implStyle* pTarget = maImplStyle.get();
     pTarget->mfPrim = rtl::math::round(nP ? nP : nS, 2);
     pTarget->mfDist = rtl::math::round((nP && nS) ? nD : 0, 2);
@@ -95,6 +114,7 @@ void Style::Set( double nP, double nD, double nS )
 
 void Style::Set( const Color& rColorPrim, const Color& rColorSecn, const Color& rColorGap, bool bUseGapColor, double nP, double nD, double nS )
 {
+    implEnsureImplStyle();
     implStyle* pTarget = maImplStyle.get();
     pTarget->maColorPrim = rColorPrim;
     pTarget->maColorSecn = rColorSecn;
@@ -105,6 +125,7 @@ void Style::Set( const Color& rColorPrim, const Color& rColorSecn, const Color&
 
 void Style::Set( const SvxBorderLine& rBorder, double fScale, sal_uInt16 nMaxWidth )
 {
+    implEnsureImplStyle();
     implStyle* pTarget = maImplStyle.get();
     pTarget->maColorPrim = rBorder.GetColorOut();
     pTarget->maColorSecn = rBorder.GetColorIn();
@@ -173,12 +194,76 @@ void Style::Set( const SvxBorderLine* pBorder, double fScale, sal_uInt16 nMaxWid
     else
     {
         Clear();
-        maImplStyle->mnType = SvxBorderLineStyle::SOLID;
     }
 }
 
+void Style::SetRefMode( RefMode eRefMode )
+{
+    if(!maImplStyle)
+    {
+        if(RefMode::Centered == eRefMode)
+        {
+            return;
+        }
+
+        implEnsureImplStyle();
+    }
+
+    maImplStyle->meRefMode = eRefMode;
+}
+
+void Style::SetColorPrim( const Color& rColor )
+{
+    if(!maImplStyle)
+    {
+        if(Color() == rColor)
+        {
+            return;
+        }
+
+        implEnsureImplStyle();
+    }
+
+    maImplStyle->maColorPrim = rColor;
+}
+
+void Style::SetColorSecn( const Color& rColor )
+{
+    if(!maImplStyle)
+    {
+        if(Color() == rColor)
+        {
+            return;
+        }
+
+        implEnsureImplStyle();
+    }
+
+    maImplStyle->maColorSecn = rColor;
+}
+
+void Style::SetType( SvxBorderLineStyle nType )
+{
+    if(!maImplStyle)
+    {
+        if(SvxBorderLineStyle::SOLID == nType)
+        {
+            return;
+        }
+
+        implEnsureImplStyle();
+    }
+
+    maImplStyle->mnType = nType;
+}
+
 Style& Style::MirrorSelf()
 {
+    if(!maImplStyle)
+    {
+        return *this;
+    }
+
     implStyle* pTarget = maImplStyle.get();
 
     if (pTarget->mfSecn)
@@ -194,8 +279,30 @@ Style& Style::MirrorSelf()
     return *this;
 }
 
-const Cell* Style::GetUsingCell() const { return maImplStyle->mpUsingCell; }
-void Style::SetUsingCell(const Cell* pCell) { maImplStyle->mpUsingCell = pCell; }
+const Cell* Style::GetUsingCell() const
+{
+    if(!maImplStyle)
+    {
+        return nullptr;
+    }
+
+    return maImplStyle->mpUsingCell;
+}
+
+void Style::SetUsingCell(const Cell* pCell)
+{
+    if(!maImplStyle)
+    {
+        if(nullptr == pCell)
+        {
+            return;
+        }
+
+        implEnsureImplStyle();
+    }
+
+    maImplStyle->mpUsingCell = pCell;
+}
 
 bool operator==( const Style& rL, const Style& rR )
 {
@@ -298,7 +405,7 @@ const OffsetCutSet* getMinMaxCutSet(bool bMin, const std::vector< OffsetCutSet >
 
 void getOffsetPairsFromStyle(const Style& rStyle, std::vector< OffsetPair >& offsets)
 {
-    if (rStyle.Prim())
+    if (rStyle.IsUsed())
     {
         if (rStyle.Dist() && rStyle.Secn())
         {
@@ -355,7 +462,7 @@ void createCutsWithStyle(
     const basegfx::B2DVector& rMyVector,
     std::vector< OffsetCutSet>& rOtherCuts)
 {
-    if (rStyle.Prim())
+    if (rStyle.IsUsed())
     {
         // get values dependent on source vector
         const basegfx::B2DVector aMyUnifiedPerpendicular(basegfx::getNormalizedPerpendicular(rMyVector));
@@ -495,7 +602,7 @@ void CreateBorderPrimitives(
     const Style& /*rRFromBL*/,
     const Color* pForceColor)
 {
-    if (rBorder.Prim())
+    if (rBorder.IsUsed())
     {
         const basegfx::B2DVector aPerpendX(basegfx::getNormalizedPerpendicular(rX));
         const double fLength(rX.getLength());
@@ -630,7 +737,7 @@ void CreateBorderPrimitives(
     const Color* pForceColor)
 {
     /// rough mapping for testing
-    if (rBorder.Prim() || rBorder.Secn())
+    if (rBorder.IsUsed())
     {
         const size_t nStart(rStartStyleVectorTable.size());
         const size_t nEnd(rEndStyleVectorTable.size());
@@ -658,42 +765,6 @@ void CreateBorderPrimitives(
     }
 }
 
-void CreateBorderPrimitives(
-    drawinglayer::primitive2d::Primitive2DContainer& rTarget,
-    const basegfx::B2DPoint& rOrigin,
-    const basegfx::B2DVector& rX,
-    const basegfx::B2DVector& rY,
-    const Style& rBorder,
-    const Style& rLFromT,
-    const Style& rLFromL,
-    const Style& rLFromB,
-    const Style& rRFromT,
-    const Style& rRFromR,
-    const Style& rRFromB,
-    const Color* pForceColor)
-{
-    if (rBorder.Prim() || rBorder.Secn())
-    {
-        CreateBorderPrimitives(
-            rTarget,
-            rOrigin,
-            rX,
-            rY,
-            rBorder,
-            Style(),
-            rLFromT,
-            rLFromL,
-            rLFromB,
-            Style(),
-            Style(),
-            rRFromT,
-            rRFromR,
-            rRFromB,
-            Style(),
-            pForceColor);
-    }
-}
-
 }
 }
 
diff --git a/svx/source/dialog/framelinkarray.cxx b/svx/source/dialog/framelinkarray.cxx
index 586e095f18bc..c8520d5278de 100644
--- a/svx/source/dialog/framelinkarray.cxx
+++ b/svx/source/dialog/framelinkarray.cxx
@@ -947,17 +947,17 @@ void HelperCreateHorizontalBorderPrimitives(
         StyleVectorTable aStart;
         StyleVectorTable aEnd;
 
-        if(rStartFromTR.Prim()) aStart.push_back(StyleVectorCombination(rStartFromTR, aX - aY));
-        if(rStartLFromT.Prim()) aStart.push_back(StyleVectorCombination(rStartLFromT, -aY));
-        if(rStartLFromL.Prim()) aStart.push_back(StyleVectorCombination(rStartLFromL, -aX));
-        if(rStartLFromB.Prim()) aStart.push_back(StyleVectorCombination(rStartLFromB, aY));
-        if(rStartFromBR.Prim()) aStart.push_back(StyleVectorCombination(rStartFromBR, aX + aY));
-
-        if(rEndFromTL.Prim()) aEnd.push_back(StyleVectorCombination(rEndFromTL, -aX -aY));
-        if(rEndRFromT.Prim()) aEnd.push_back(StyleVectorCombination(rEndRFromT, -aY));
-        if(rEndRFromR.Prim()) aEnd.push_back(StyleVectorCombination(rEndRFromR, aX));
-        if(rEndRFromB.Prim()) aEnd.push_back(StyleVectorCombination(rEndRFromB, aY));
-        if(rEndFromBL.Prim()) aEnd.push_back(StyleVectorCombination(rEndFromBL, aY - aX));
+        if(rStartFromTR.IsUsed()) aStart.push_back(StyleVectorCombination(rStartFromTR, aX - aY));
+        if(rStartLFromT.IsUsed()) aStart.push_back(StyleVectorCombination(rStartLFromT, -aY));
+        if(rStartLFromL.IsUsed()) aStart.push_back(StyleVectorCombination(rStartLFromL, -aX));
+        if(rStartLFromB.IsUsed()) aStart.push_back(StyleVectorCombination(rStartLFromB, aY));
+        if(rStartFromBR.IsUsed()) aStart.push_back(StyleVectorCombination(rStartFromBR, aX + aY));
+
+        if(rEndFromTL.IsUsed()) aEnd.push_back(StyleVectorCombination(rEndFromTL, -aX -aY));
+        if(rEndRFromT.IsUsed()) aEnd.push_back(StyleVectorCombination(rEndRFromT, -aY));
+        if(rEndRFromR.IsUsed()) aEnd.push_back(StyleVectorCombination(rEndRFromR, aX));
+        if(rEndRFromB.IsUsed()) aEnd.push_back(StyleVectorCombination(rEndRFromB, aY));
+        if(rEndFromBL.IsUsed()) aEnd.push_back(StyleVectorCombination(rEndFromBL, aY - aX));
 
         CreateBorderPrimitives(
             rSequence,
@@ -986,17 +986,17 @@ void HelperCreateVerticalBorderPrimitives(
         StyleVectorTable aStart;
         StyleVectorTable aEnd;
 
-        if(rStartFromBR.Prim()) aStart.push_back(StyleVectorCombination(rStartFromBR, aX + aY));
-        if(rStartTFromR.Prim()) aStart.push_back(StyleVectorCombination(rStartTFromR, aX));
-        if(rStartTFromT.Prim()) aStart.push_back(StyleVectorCombination(rStartTFromT, aY));
-        if(rStartTFromL.Prim()) aStart.push_back(StyleVectorCombination(rStartTFromL, -aX));
-        if(rStartFromBL.Prim()) aStart.push_back(StyleVectorCombination(rStartFromBL, aY - aX));
+        if(rStartFromBR.IsUsed()) aStart.push_back(StyleVectorCombination(rStartFromBR, aX + aY));
+        if(rStartTFromR.IsUsed()) aStart.push_back(StyleVectorCombination(rStartTFromR, aX));
+        if(rStartTFromT.IsUsed()) aStart.push_back(StyleVectorCombination(rStartTFromT, aY));
+        if(rStartTFromL.IsUsed()) aStart.push_back(StyleVectorCombination(rStartTFromL, -aX));
+        if(rStartFromBL.IsUsed()) aStart.push_back(StyleVectorCombination(rStartFromBL, aY - aX));
 
-        if(rEndFromTR.Prim()) aEnd.push_back(StyleVectorCombination(rEndFromTR, aX - aY));
-        if(rEndBFromR.Prim()) aEnd.push_back(StyleVectorCombination(rEndBFromR, aX));
-        if(rEndBFromB.Prim()) aEnd.push_back(StyleVectorCombination(rEndBFromB, -aY));
-        if(rEndBFromL.Prim()) aEnd.push_back(StyleVectorCombination(rEndBFromL, aX));
-        if(rEndFromTL.Prim()) aEnd.push_back(StyleVectorCombination(rEndFromTL, aX + aY));
+        if(rEndFromTR.IsUsed()) aEnd.push_back(StyleVectorCombination(rEndFromTR, aX - aY));
+        if(rEndBFromR.IsUsed()) aEnd.push_back(StyleVectorCombination(rEndBFromR, aX));
+        if(rEndBFromB.IsUsed()) aEnd.push_back(StyleVectorCombination(rEndBFromB, -aY));
+        if(rEndBFromL.IsUsed()) aEnd.push_back(StyleVectorCombination(rEndBFromL, aX));
+        if(rEndFromTL.IsUsed()) aEnd.push_back(StyleVectorCombination(rEndFromTL, aX + aY));
 
         CreateBorderPrimitives(
             rSequence,
@@ -1058,15 +1058,15 @@ void Array::DrawRange( drawinglayer::processor2d::BaseProcessor2D& rProcessor,
 
                             /// Fill top-left Style Table
                             const Style& rTLFromRight(GetCellStyleTop(_nFirstCol, _nFirstRow));
-                            if(rTLFromRight.Prim()) aStart.push_back(StyleVectorCombination(rTLFromRight, aX));
+                            if(rTLFromRight.IsUsed()) aStart.push_back(StyleVectorCombination(rTLFromRight, aX));
                             const Style& rTLFromBottom(GetCellStyleLeft(_nFirstCol, _nFirstRow));
-                            if(rTLFromBottom.Prim()) aStart.push_back(StyleVectorCombination(rTLFromBottom, aY));
+                            if(rTLFromBottom.IsUsed()) aStart.push_back(StyleVectorCombination(rTLFromBottom, aY));
 
                             /// Fill bottom-right Style Table
                             const Style& rBRFromBottom(GetCellStyleRight(_nLastCol, _nLastRow));
-                            if(rBRFromBottom.Prim()) aEnd.push_back(StyleVectorCombination(rBRFromBottom, -aY));
+                            if(rBRFromBottom.IsUsed()) aEnd.push_back(StyleVectorCombination(rBRFromBottom, -aY));
                             const Style& rBRFromLeft(GetCellStyleBottom(_nLastCol, _nLastRow));
-                            if(rBRFromLeft.Prim()) aEnd.push_back(StyleVectorCombination(rBRFromLeft, -aX));
+                            if(rBRFromLeft.IsUsed()) aEnd.push_back(StyleVectorCombination(rBRFromLeft, -aX));
 
                             CreateBorderPrimitives(
                                 aSequence,
@@ -1087,15 +1087,15 @@ void Array::DrawRange( drawinglayer::processor2d::BaseProcessor2D& rProcessor,
 
                             /// Fill bottom-left Style Table
                             const Style& rBLFromTop(GetCellStyleLeft(_nFirstCol, _nLastRow));
-                            if(rBLFromTop.Prim()) aStart.push_back(StyleVectorCombination(rBLFromTop, -aY));
+                            if(rBLFromTop.IsUsed()) aStart.push_back(StyleVectorCombination(rBLFromTop, -aY));
                             const Style& rBLFromBottom(GetCellStyleBottom(_nFirstCol, _nLastRow));
-                            if(rBLFromBottom.Prim()) aStart.push_back(StyleVectorCombination(rBLFromBottom, aX));
+                            if(rBLFromBottom.IsUsed()) aStart.push_back(StyleVectorCombination(rBLFromBottom, aX));
 
                             /// Fill top-right Style Table
                             const Style& rTRFromBottom(GetCellStyleRight(_nLastCol, _nFirstRow));
-                            if(rTRFromBottom.Prim()) aEnd.push_back(StyleVectorCombination(rTRFromBottom, -aY));
+                            if(rTRFromBottom.IsUsed()) aEnd.push_back(StyleVectorCombination(rTRFromBottom, -aY));
                             const Style& rTRFromLeft(GetCellStyleTop(_nLastCol, _nFirstRow));
-                            if(rTRFromLeft.Prim()) aEnd.push_back(StyleVectorCombination(rTRFromLeft, -aX));
+                            if(rTRFromLeft.IsUsed()) aEnd.push_back(StyleVectorCombination(rTRFromLeft, -aX));
 
                             CreateBorderPrimitives(
                                 aSequence,
@@ -1156,7 +1156,7 @@ void Array::DrawRange( drawinglayer::processor2d::BaseProcessor2D& rProcessor,
                 // draw previous frame border
                 basegfx::B2DPoint aEndPos( mxImpl->GetColPosition( nCol ), aStartPos.getY() );
 
-                if ((pStart->Prim() || pStart->Secn()) && (aStartPos.getX() <= aEndPos.getX()))
+                if (pStart->IsUsed() && (aStartPos.getX() <= aEndPos.getX()))
                 {
                     // prepare defaults for borderline coordinate system
                     const Cell* pCell = pStart->GetUsingCell();
@@ -1196,7 +1196,7 @@ void Array::DrawRange( drawinglayer::processor2d::BaseProcessor2D& rProcessor,
 
         // draw last frame border
         basegfx::B2DPoint aEndPos( mxImpl->GetColPosition( nCol ), aStartPos.getY() );
-        if ((pStart->Prim() || pStart->Secn()) && (aStartPos.getX() <= aEndPos.getX()))
+        if (pStart->IsUsed() && (aStartPos.getX() <= aEndPos.getX()))
         {
             // for description of involved coordinate systems have a look at
             // the first CreateBorderPrimitives call above
@@ -1259,7 +1259,7 @@ void Array::DrawRange( drawinglayer::processor2d::BaseProcessor2D& rProcessor,
             {
                 // draw previous frame border
                 basegfx::B2DPoint aEndPos( aStartPos.getX(), mxImpl->GetRowPosition( nRow ) );
-                if ((pStart->Prim() || pStart->Secn()) && (aStartPos.getY() <= aEndPos.getY()))
+                if (pStart->IsUsed() && (aStartPos.getY() <= aEndPos.getY()))
                 {
                     // for description of involved coordinate systems have a look at
                     // the first CreateBorderPrimitives call above. Additionally adapt to vertical
@@ -1300,7 +1300,7 @@ void Array::DrawRange( drawinglayer::processor2d::BaseProcessor2D& rProcessor,
 
         // draw last frame border
         basegfx::B2DPoint aEndPos( aStartPos.getX(), mxImpl->GetRowPosition( nRow ) );
-        if ((pStart->Prim() || pStart->Secn()) && (aStartPos.getY() <= aEndPos.getY()))
+        if (pStart->IsUsed() && (aStartPos.getY() <= aEndPos.getY()))
         {
             // for description of involved coordinate systems have a look at
             // the first CreateBorderPrimitives call above, adapt to vertical
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index b99e2a3c467c..4c9270d42dd8 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -2745,55 +2745,71 @@ void SwTabFramePainter::PaintLines(OutputDevice& rDev, const SwRect& rRect) cons
                     aPaintEnd.Y() = aUpperAligned.Bottom_();
             }
 
-            if (bHori)
+            if(aStyles[0].Prim())
             {
-                const basegfx::B2DPoint aOrigin(aPaintStart.X(), aPaintStart.Y());
-                const basegfx::B2DVector aX(basegfx::B2DPoint(aPaintEnd.X(), aPaintEnd.Y()) - aOrigin);
-                const basegfx::B2DVector aY(basegfx::getNormalizedPerpendicular(aX));
                 drawinglayer::primitive2d::Primitive2DContainer aSequence;
 
-                svx::frame::CreateBorderPrimitives(
-                    aSequence,
-                    aOrigin,
-                    aX,
-
-                    // Writer creates it's vertical BorderLines bottom-to-top (see below).
-                    // To make the horizontal lines correctly 'guess' the line extensions
-                    // for the then mirrored svx::frame::Style for irregular double lines,
-                    // hand over the for that case correct orientation of the 'other'
-                    // incoming edges
-                    -aY,
-
-                    aStyles[ 0 ],   // current style
-                    aStyles[ 1 ],   // aLFromT
-                    aStyles[ 2 ],   // aLFromL
-                    aStyles[ 3 ],   // aLFromB
-                    aStyles[ 4 ],   // aRFromT
-                    aStyles[ 5 ],   // aRFromR
-                    aStyles[ 6 ],   // aRFromB
-                    pTmpColor);
-                mrTabFrame.ProcessPrimitives(aSequence);
-            }
-            else
-            {
-                const basegfx::B2DPoint aOrigin(aPaintEnd.X(), aPaintEnd.Y());
-                const basegfx::B2DVector aX(basegfx::B2DPoint(aPaintStart.X(), aPaintStart.Y()) - aOrigin);
-                const basegfx::B2DVector aY(basegfx::getNormalizedPerpendicular(aX));
-                drawinglayer::primitive2d::Primitive2DContainer aSequence;
+                if (bHori)
+                {
+                    const basegfx::B2DPoint aOrigin(aPaintStart.X(), aPaintStart.Y());
+                    const basegfx::B2DVector aX(basegfx::B2DPoint(aPaintEnd.X(), aPaintEnd.Y()) - aOrigin);
+
+                    if(!aX.equalZero())
+                    {
+                        const basegfx::B2DVector aY(basegfx::getNormalizedPerpendicular(aX));
+                        svx::frame::StyleVectorTable aStartTable;
+                        svx::frame::StyleVectorTable aEndTable;
+
+                        if(aStyles[ 1 ].Prim()) aStartTable.push_back(svx::frame::StyleVectorCombination(aStyles[ 1 ], -aY)); // aLFromT
+                        if(aStyles[ 2 ].Prim()) aStartTable.push_back(svx::frame::StyleVectorCombination(aStyles[ 2 ], -aX)); // aLFromL
+                        if(aStyles[ 3 ].Prim()) aStartTable.push_back(svx::frame::StyleVectorCombination(aStyles[ 3 ], aY)); // aLFromB
+
+                        if(aStyles[ 4 ].Prim()) aEndTable.push_back(svx::frame::StyleVectorCombination(aStyles[ 4 ], -aY)); // aRFromT
+                        if(aStyles[ 5 ].Prim()) aEndTable.push_back(svx::frame::StyleVectorCombination(aStyles[ 5 ], aX)); // aRFromR
+                        if(aStyles[ 6 ].Prim()) aEndTable.push_back(svx::frame::StyleVectorCombination(aStyles[ 6 ], aY)); // aRFromB
+
+                        CreateBorderPrimitives(
+                            aSequence,
+                            aOrigin,
+                            aX,
+                            aStyles[ 0 ],
+                            aStartTable,
+                            aEndTable,
+                            nullptr
+                        );
+                    }
+                }
+                else // vertical
+                {
+                    const basegfx::B2DPoint aOrigin(aPaintStart.X(), aPaintStart.Y());
+                    const basegfx::B2DVector aX(basegfx::B2DPoint(aPaintEnd.X(), aPaintEnd.Y()) - aOrigin);
+
+                    if(!aX.equalZero())
+                    {
+                        const basegfx::B2DVector aY(basegfx::getNormalizedPerpendicular(aX));
+                        svx::frame::StyleVectorTable aStartTable;
+                        svx::frame::StyleVectorTable aEndTable;
+
+                        if(aStyles[ 3 ].Prim()) aStartTable.push_back(svx::frame::StyleVectorCombination(aStyles[ 3 ], -aY)); // aTFromR
+                        if(aStyles[ 2 ].Prim()) aStartTable.push_back(svx::frame::StyleVectorCombination(aStyles[ 2 ], -aX)); // aTFromT
+                        if(aStyles[ 1 ].Prim()) aStartTable.push_back(svx::frame::StyleVectorCombination(aStyles[ 1 ], aY)); // aTFromL
+
+                        if(aStyles[ 6 ].Prim()) aEndTable.push_back(svx::frame::StyleVectorCombination(aStyles[ 6 ], -aY)); // aBFromR
+                        if(aStyles[ 5 ].Prim()) aEndTable.push_back(svx::frame::StyleVectorCombination(aStyles[ 5 ], aX)); // aBFromB
+                        if(aStyles[ 4 ].Prim()) aEndTable.push_back(svx::frame::StyleVectorCombination(aStyles[ 4 ], aY)); // aBFromL
+
+                        CreateBorderPrimitives(
+                            aSequence,
+                            aOrigin,
+                            aX,
+                            aStyles[ 0 ],
+                            aStartTable,
+                            aEndTable,
+                            nullptr
+                        );
+                    }
+                }
 
-                svx::frame::CreateBorderPrimitives(
-                    aSequence,
-                    aOrigin,
-                    aX,
-                    aY,
-                    aStyles[ 0 ],   // current style
-                    aStyles[ 4 ],   // aBFromL
-                    aStyles[ 5 ],   // aBFromB
-                    aStyles[ 6 ],   // aBFromR
-                    aStyles[ 1 ],   // aTFromL
-                    aStyles[ 2 ],   // aTFromT
-                    aStyles[ 3 ],   // aTFromR
-                    pTmpColor);
                 mrTabFrame.ProcessPrimitives(aSequence);
             }
         }


More information about the Libreoffice-commits mailing list