[Libreoffice-commits] core.git: Branch 'feature/borderline2' - 221 commits - android/Bootstrap android/source basctl/source basic/qa bin/find-unused-defines-in-hrc-files.py canvas/source chart2/qa chart2/source comphelper/source compilerplugins/clang configure.ac connectivity/source cppcanvas/source cui/Library_cui.mk cui/source dbaccess/source desktop/source drawinglayer/source editeng/source extensions/inc extensions/source filter/Configuration_filter.mk filter/inc filter/source forms/source formula/inc formula/source framework/inc framework/source helpcontent2 hwpfilter/source i18npool/source icon-themes/galaxy icon-themes/sifr icon-themes/sifr_dark idl/source include/comphelper include/connectivity include/cppcanvas include/drawinglayer include/editeng include/filter include/formula include/oox include/sax include/sfx2 include/svl include/svtools include/svx include/tools include/unotools include/vcl include/xmloff include/xmlreader io/source l10ntools/inc l10ntools/source lingucomponent/sour ce lotuswordpro/source Makefile.in offapi/com oovbaapi/ooo oox/source qadevOOo/tests reportdesign/source sal/osl sal/qa sal/rtl sc/inc sc/qa sc/sdi sc/source sdext/source sd/inc sd/Library_sd.mk sd/qa sd/sdi sd/source sd/util sfx2/sdi sfx2/source slideshow/source solenv/gbuild solenv/vs starmath/inc starmath/sdi starmath/source stoc/source svl/source svtools/source svx/inc svx/sdi svx/source sw/inc sw/Library_swui.mk sw/qa sw/sdi sw/source toolkit/source tools/source ucb/source uitest/libreoffice uitest/uitest uitest/writer_tests unotools/source uui/source vcl/commonfuzzer.mk vcl/CppunitTest_vcl_mnemonic.mk vcl/headless vcl/inc vcl/Module_vcl.mk vcl/qa vcl/source vcl/unx vcl/win writerfilter/source writerperfect/source xmlhelp/source xmloff/inc xmloff/source xmlreader/source xmlsecurity/inc xmlsecurity/Library_xsec_xmlsec.mk xmlsecurity/source

arminl arminl at KRANIX
Thu Jul 27 15:50:59 UTC 2017


Rebased ref, commits from common ancestor:
commit 5cf88f60c3ea3e548b611fa28d7bbd301880ef9b
Author: arminl <arminl at KRANIX>
Date:   Thu Jul 27 16:03:48 2017 +0200

    borderline: corrections for calc and writer
    
    Made corrections/finetuning for Calc and Writer.
    Had to remove some former code which tried to do
    corrections
    
    Change-Id: Ia7669c9eb7f3338d250cd350bfa5c2bc8e61763b

diff --git a/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx b/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx
index 724ba8772c44..1dfa77a80f7c 100644
--- a/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx
@@ -104,13 +104,17 @@ namespace drawinglayer
                     // double line with gap. Use mfDiscreteGapDistance (see get2DDecomposition) as distance.
                     // That value is prepared to be at least one pixel (discrete unit) so that the
                     // decomposition is view-dependent in this cases
+                    const BorderLine& rLeft(getBorderLines()[0]);
+                    const BorderLine& rGap(getBorderLines()[1]);
+                    const BorderLine& rRight(getBorderLines()[2]);
+                    const double fFullWidth(rLeft.getWidth() + mfDiscreteGapDistance + rRight.getWidth());
+
                     {
-                        // inside line (left of vector). Create stroke primitive centered on line width
-                        const BorderLine& rLeft(getBorderLines()[0]);
-                        const double fDeltaY((mfDiscreteGapDistance + rLeft.getWidth()) * 0.5);
+                        // inside line (left of vector). Create stroke primitive centered on left line width
+                        const double fDeltaY((rLeft.getWidth() - fFullWidth) * 0.5);
                         const basegfx::B2DVector aDeltaY(aPerpendicular * fDeltaY);
-                        const basegfx::B2DPoint aStart(getStart() - (aVector * rLeft.getExtendStart()) - aDeltaY);
-                        const basegfx::B2DPoint aEnd(getEnd() + (aVector * rLeft.getExtendEnd()) - aDeltaY);
+                        const basegfx::B2DPoint aStart(getStart() - (aVector * rLeft.getExtendStart()) + aDeltaY);
+                        const basegfx::B2DPoint aEnd(getEnd() + (aVector * rLeft.getExtendEnd()) + aDeltaY);
                         const attribute::LineAttribute aLineAttribute(rLeft.getRGBColor(), rLeft.getWidth());
 
                         addPolygonStrokePrimitive2D(
@@ -124,10 +128,11 @@ namespace drawinglayer
                     if (hasGapColor())
                     {
                         // gap (if visible, found practical usage in Writer MultiColorBorderLines).
-                        // Create stroke primitive on vector with given color
-                        const BorderLine& rGap(getBorderLines()[1]);
-                        const basegfx::B2DPoint aStart(getStart() - (aVector * rGap.getExtendStart()));
-                        const basegfx::B2DPoint aEnd(getEnd() + (aVector * rGap.getExtendEnd()));
+                        // Create stroke primitive on vector with given color centered on gap position
+                        const double fDeltaY(((fFullWidth - mfDiscreteGapDistance) * 0.5) - rRight.getWidth());
+                        const basegfx::B2DVector aDeltaY(aPerpendicular * fDeltaY);
+                        const basegfx::B2DPoint aStart(getStart() - (aVector * rGap.getExtendStart()) + aDeltaY);
+                        const basegfx::B2DPoint aEnd(getEnd() + (aVector * rGap.getExtendEnd()) + aDeltaY);
                         const attribute::LineAttribute aLineAttribute(rGap.getRGBColor(), mfDiscreteGapDistance);
 
                         addPolygonStrokePrimitive2D(
@@ -139,9 +144,8 @@ namespace drawinglayer
                     }
 
                     {
-                        // outside line (right of vector). Create stroke primitive centered on line width
-                        const BorderLine& rRight(getBorderLines()[2]);
-                        const double fDeltaY((mfDiscreteGapDistance + rRight.getWidth()) * 0.5);
+                        // outside line (right of vector). Create stroke primitive centered on right line width
+                        const double fDeltaY((fFullWidth - rRight.getWidth()) * 0.5);
                         const basegfx::B2DVector aDeltaY(aPerpendicular * fDeltaY);
                         const basegfx::B2DPoint aStart(getStart() - (aVector * rRight.getExtendStart()) + aDeltaY);
                         const basegfx::B2DPoint aEnd(getEnd() + (aVector * rRight.getExtendEnd()) + aDeltaY);
diff --git a/svx/source/dialog/framelink.cxx b/svx/source/dialog/framelink.cxx
index c746e881679c..faa408c29dcc 100644
--- a/svx/source/dialog/framelink.cxx
+++ b/svx/source/dialog/framelink.cxx
@@ -523,7 +523,14 @@ double getSimpleExtendedLineValues(
 
     if (pResult)
     {
-        return (pResult->mfLeftRight + pResult->mfRightRight) * 0.5 * (bEdgeStart ? -fLength : fLength);
+        if (bEdgeStart)
+        {
+            return (pResult->mfLeftRight + pResult->mfRightRight) * -0.5 * fLength;
+        }
+        else
+        {
+            return (pResult->mfLeftLeft + pResult->mfRightLeft) * 0.5 * fLength;
+        }
     }
 
     return 0.0;
@@ -552,8 +559,17 @@ double getComplexExtendedLineValues(
 
     if (pResult)
     {
-        return (pResult->mfLeftRight + pResult->mfRightRight) * 0.5 * (bEdgeStart ? -fLength : fLength);
+        if (bEdgeStart)
+        {
+            return (pResult->mfLeftRight + pResult->mfRightRight) * 0.5 * -fLength;
+        }
+        else
+        {
+            return (pResult->mfLeftLeft + pResult->mfRightLeft) * 0.5 * fLength;
+        }
     }
+
+    return 0.0;
 }
 
 void CreateBorderPrimitives(
diff --git a/svx/source/dialog/framelinkarray.cxx b/svx/source/dialog/framelinkarray.cxx
index 839e9bef5d77..0817a474320a 100644
--- a/svx/source/dialog/framelinkarray.cxx
+++ b/svx/source/dialog/framelinkarray.cxx
@@ -1122,7 +1122,7 @@ void Array::DrawRange( drawinglayer::processor2d::BaseProcessor2D& rProcessor,
                         aY.normalize();
                     }
 
-                    drawinglayer::primitive2d::Primitive2DContainer aSequence(1);
+                    drawinglayer::primitive2d::Primitive2DContainer aSequence;
                     CreateBorderPrimitives(
                         aSequence,
                         aOrigin,
@@ -1188,7 +1188,7 @@ void Array::DrawRange( drawinglayer::processor2d::BaseProcessor2D& rProcessor,
                 aY.normalize();
             }
 
-            drawinglayer::primitive2d::Primitive2DContainer aSequence(1);
+            drawinglayer::primitive2d::Primitive2DContainer aSequence;
             CreateBorderPrimitives(
                 aSequence,
                 aOrigin,
@@ -1288,7 +1288,7 @@ void Array::DrawRange( drawinglayer::processor2d::BaseProcessor2D& rProcessor,
                         aY = -aY;
                     }
 
-                    drawinglayer::primitive2d::Primitive2DContainer aSequence(1);
+                    drawinglayer::primitive2d::Primitive2DContainer aSequence;
                     CreateBorderPrimitives(
                         // This replaces DrawVerFrameBorder which went from top to bottom. To be able to use
                         // the same method as for horizontal (CreateBorderPrimitives), the given borders
@@ -1367,7 +1367,7 @@ void Array::DrawRange( drawinglayer::processor2d::BaseProcessor2D& rProcessor,
                 aY = -aY;
             }
 
-            drawinglayer::primitive2d::Primitive2DContainer aSequence(1);
+            drawinglayer::primitive2d::Primitive2DContainer aSequence;
             CreateBorderPrimitives(
                 // also reordered, see call to CreateBorderPrimitives above
                 aSequence,
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index 407ac441ecf7..493eb8ea3185 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -2448,11 +2448,6 @@ struct SwLineEntry
     SwTwips mnKey;
     SwTwips mnStartPos;
     SwTwips mnEndPos;
-    SwTwips mnOffset;
-
-    bool mbOffsetPerp;
-    bool mbOffsetStart;
-    bool mbOffsetEnd;
 
     svx::frame::Style maAttribute;
 
@@ -2474,10 +2469,6 @@ SwLineEntry::SwLineEntry( SwTwips nKey,
     :   mnKey( nKey ),
         mnStartPos( nStartPos ),
         mnEndPos( nEndPos ),
-        mnOffset( 0 ),
-        mbOffsetPerp(false),
-        mbOffsetStart(false),
-        mbOffsetEnd(false),
         maAttribute( rAttribute )
 {
 }
@@ -2556,8 +2547,6 @@ class SwTabFramePainter
                             svx::frame::Style*,
                             bool bHori ) const;
 
-    void AdjustTopLeftFrames();
-
 public:
     explicit SwTabFramePainter( const SwTabFrame& rTabFrame );
 
@@ -2568,7 +2557,6 @@ SwTabFramePainter::SwTabFramePainter( const SwTabFrame& rTabFrame )
     : mrTabFrame( rTabFrame )
 {
     HandleFrame( rTabFrame );
-    AdjustTopLeftFrames();
 }
 
 void SwTabFramePainter::HandleFrame( const SwLayoutFrame& rLayoutFrame )
@@ -2666,42 +2654,6 @@ void SwTabFramePainter::PaintLines(OutputDevice& rDev, const SwRect& rRect) cons
             svx::frame::Style aStyles[ 7 ];
             aStyles[ 0 ] = rEntryStyle;
             FindStylesForLine( aStart, aEnd, aStyles, bHori );
-
-            // Account for double line thicknesses for the top- and left-most borders.
-            if (rEntry.mnOffset)
-            {
-                if (bHori)
-                {
-                    if (rEntry.mbOffsetPerp)
-                    {
-                        // Apply offset in perpendicular direction.
-                        aStart.Y() -= rEntry.mnOffset;
-                        aEnd.Y() -= rEntry.mnOffset;
-                    }
-                    if (rEntry.mbOffsetStart)
-                        // Apply offset at the start of a border.
-                        aStart.X() -= rEntry.mnOffset;
-                    if (rEntry.mbOffsetEnd)
-                        // Apply offset at the end of a border.
-                        aEnd.X() += rEntry.mnOffset;
-                }
-                else
-                {
-                    if (rEntry.mbOffsetPerp)
-                    {
-                        // Apply offset in perpendicular direction.
-                        aStart.X() -= rEntry.mnOffset;
-                        aEnd.X() -= rEntry.mnOffset;
-                    }
-                    if (rEntry.mbOffsetStart)
-                        // Apply offset at the start of a border.
-                        aStart.Y() -= rEntry.mnOffset;
-                    if (rEntry.mbOffsetEnd)
-                        // Apply offset at the end of a border.
-                        aEnd.Y() += rEntry.mnOffset;
-                }
-            }
-
             SwRect aRepaintRect( aStart, aEnd );
 
             // the repaint rectangle has to be moved a bit for the centered lines:
@@ -2769,47 +2721,25 @@ void SwTabFramePainter::PaintLines(OutputDevice& rDev, const SwRect& rRect) cons
                     aPaintEnd.Y() = aUpperAligned.Bottom_();
             }
 
-            // logically vertical lines are painted centered on the line,
-            // logically horizontal lines are painted "below" the line
-            //
-            // This does not need to be done here, it is set in SwTabFramePainter::Insert
-            // already using SetRefMode(...) as property of the BorderLine Style, see there.
-            // When additionally adding the offset here manually, it will be applied
-            // double and will be rendered wrong. This did not happen before because
-            // the setting of the svx::frame::RefMode at svx::frame::Style was ignored there.
-            //
-            // bool const isBelow((mrTabFrame.IsVertical()) ? !bHori : bHori);
-            // double const offsetStart = (isBelow)
-            //     ?   aStyles[0].GetWidth() / 2.0
-            //     :   std::max<double>(aStyles[1].GetWidth(),
-            //             aStyles[3].GetWidth()) / 2.0;
-            // double const offsetEnd = (isBelow)
-            //     ?   aStyles[0].GetWidth() / 2.0
-            //     :   std::max<double>(aStyles[4].GetWidth(),
-            //             aStyles[6].GetWidth()) / 2.0;
-            // if (mrTabFrame.IsVertical())
-            // {
-            //     aPaintStart.X() -= static_cast<long>(offsetStart + 0.5);
-            //     aPaintEnd.X()   -= static_cast<long>(offsetEnd   + 0.5);
-            // }
-            // else
-            // {
-            //     aPaintStart.Y() += static_cast<long>(offsetStart + 0.5);
-            //     aPaintEnd.Y()   += static_cast<long>(offsetEnd   + 0.5);
-            // }
-
             if (bHori)
             {
                 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(1);
+                drawinglayer::primitive2d::Primitive2DContainer aSequence;
 
                 svx::frame::CreateBorderPrimitives(
                     aSequence,
                     aOrigin,
                     aX,
-                    aY,
+
+                    // 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 orientatoin of the 'other'
+                    // incoming edges
+                    -aY,
+
                     aStyles[ 0 ],   // current style
                     aStyles[ 1 ],   // aLFromT
                     aStyles[ 2 ],   // aLFromL
@@ -2825,7 +2755,7 @@ void SwTabFramePainter::PaintLines(OutputDevice& rDev, const SwRect& rRect) cons
                 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(1);
+                drawinglayer::primitive2d::Primitive2DContainer aSequence;
 
                 svx::frame::CreateBorderPrimitives(
                     aSequence,
@@ -2954,58 +2884,6 @@ void SwTabFramePainter::FindStylesForLine( const Point& rStartPoint,
     }
 }
 
-namespace {
-
-void calcOffsetForDoubleLine( SwLineEntryMap& rLines )
-{
-    SwLineEntryMap aNewLines;
-    SwLineEntryMap::iterator it = rLines.begin(), itEnd = rLines.end();
-    bool bFirst = true;
-    for (; it != itEnd; ++it)
-    {
-        if (bFirst)
-        {
-            // First line needs to be offset to account for double line thickness.
-            SwLineEntrySet aNewSet;
-            const SwLineEntrySet& rSet = it->second;
-            SwLineEntrySet::iterator itSet = rSet.begin(), itSetEnd = rSet.end();
-            size_t nEntryCount = rSet.size();
-            for (size_t i = 0; itSet != itSetEnd; ++itSet, ++i)
-            {
-                SwLineEntry aLine = *itSet;
-                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);
-            }
-
-            aNewLines.insert(SwLineEntryMap::value_type(it->first, aNewSet));
-        }
-        else
-            aNewLines.insert(SwLineEntryMap::value_type(it->first, it->second));
-
-        bFirst = false;
-    }
-    rLines.swap(aNewLines);
-}
-
-}
-
-void SwTabFramePainter::AdjustTopLeftFrames()
-{
-    calcOffsetForDoubleLine(maHoriLines);
-    calcOffsetForDoubleLine(maVertLines);
-}
-
 /**
  * Special case: #i9860#
  * first line in follow table without repeated headlines
commit 86dd631bb84dbeaaba412f74ed13426f89b8a057
Author: arminl <arminl at KRANIX>
Date:   Wed Jul 26 16:34:52 2017 +0200

    borderline: Unified primitive creation
    
    Overhauled the edge extension calculations to better
    use all existing cuts, for cases with single and double
    lines. Also a preparation for more complex edge cuts.
    Changed BorderLine paint in Writer, it was setting the
    svx::frame::RefMode attribute at the Style *and*
    was manually moving the geometry which lead to a
    double applying of the offsets
    
    Change-Id: I446d04632050272849f43accb8dcbde574d10cf4

diff --git a/svx/source/dialog/framelink.cxx b/svx/source/dialog/framelink.cxx
index e5b6abb8f5f8..c746e881679c 100644
--- a/svx/source/dialog/framelink.cxx
+++ b/svx/source/dialog/framelink.cxx
@@ -345,7 +345,53 @@ double lcl_GetExtent(
     return nCut;
 }
 
-void getOffsetsFromStyle(const Style& rStyle, std::vector< double >& offsets)
+struct OffsetPair
+{
+    double          mfLeft;
+    double          mfRight;
+
+    OffsetPair(double a, double b) : mfLeft(a), mfRight(b) {}
+};
+
+struct OffsetCutSet
+{
+    double          mfLeftLeft;
+    double          mfRightLeft;
+    double          mfLeftRight;
+    double          mfRightRight;
+};
+
+const OffsetCutSet* getMinMaxCutSet(bool bMin, const std::vector< OffsetCutSet >& myCutSets)
+{
+    if (myCutSets.empty())
+    {
+        return nullptr;
+    }
+
+    if (1 == myCutSets.size())
+    {
+        return &myCutSets[0];
+    }
+
+    const OffsetCutSet* pRetval = &myCutSets[0];
+    double fRetval(pRetval->mfLeftLeft + pRetval->mfLeftRight + pRetval->mfRightLeft + pRetval->mfRightRight);
+
+    for (size_t a(1); a < myCutSets.size(); a++)
+    {
+        const OffsetCutSet* pCandidate = &myCutSets[a];
+        const double fCandidate(pCandidate->mfLeftLeft + pCandidate->mfLeftRight + pCandidate->mfRightLeft + pCandidate->mfRightRight);
+
+        if ((bMin && fCandidate < fRetval) || (!bMin && fCandidate > fRetval))
+        {
+            pRetval = pCandidate;
+            fRetval = fCandidate;
+        }
+    }
+
+    return pRetval;
+}
+
+void getOffsetPairsFromStyle(const Style& rStyle, std::vector< OffsetPair >& offsets)
 {
     if (rStyle.Prim())
     {
@@ -357,25 +403,21 @@ void getOffsetsFromStyle(const Style& rStyle, std::vector< double >& offsets)
             case RefMode::Centered:
             {
                 const double fHalfFullWidth(rStyle.GetWidth() * 0.5);
-                offsets.push_back(-fHalfFullWidth);
-                offsets.push_back(rStyle.Prim() - fHalfFullWidth);
-                offsets.push_back((rStyle.Prim() + rStyle.Dist()) - fHalfFullWidth);
-                offsets.push_back(fHalfFullWidth);
+                offsets.push_back(OffsetPair(-fHalfFullWidth, rStyle.Prim() - fHalfFullWidth));
+                offsets.push_back(OffsetPair((rStyle.Prim() + rStyle.Dist()) - fHalfFullWidth, fHalfFullWidth));
                 break;
             }
             case RefMode::Begin:
-                offsets.push_back(0.0);
-                offsets.push_back(rStyle.Prim());
-                offsets.push_back(rStyle.Prim() + rStyle.Dist());
-                offsets.push_back(rStyle.GetWidth());
+            {
+                offsets.push_back(OffsetPair(0.0, rStyle.Prim()));
+                offsets.push_back(OffsetPair(rStyle.Prim() + rStyle.Dist(), rStyle.GetWidth()));
                 break;
+            }
             default: // case RefMode::End:
             {
                 const double fFullWidth(rStyle.GetWidth());
-                offsets.push_back(-fFullWidth);
-                offsets.push_back(rStyle.Prim() - fFullWidth);
-                offsets.push_back((rStyle.Prim() + rStyle.Dist()) - fFullWidth);
-                offsets.push_back(0.0);
+                offsets.push_back(OffsetPair(-fFullWidth, rStyle.Prim() - fFullWidth));
+                offsets.push_back(OffsetPair((rStyle.Prim() + rStyle.Dist()) - fFullWidth, 0.0));
                 break;
             }
             }
@@ -386,110 +428,132 @@ void getOffsetsFromStyle(const Style& rStyle, std::vector< double >& offsets)
             switch (rStyle.GetRefMode())
             {
             case RefMode::Centered:
-                offsets.push_back(rStyle.Prim() * -0.5);
-                offsets.push_back(rStyle.Prim() * 0.5);
+                offsets.push_back(OffsetPair(rStyle.Prim() * -0.5, rStyle.Prim() * 0.5));
                 break;
             case RefMode::Begin:
-                offsets.push_back(0.0);
-                offsets.push_back(rStyle.Prim());
+                offsets.push_back(OffsetPair(0.0, rStyle.Prim()));
                 break;
             default: // case RefMode::End:
-                offsets.push_back(-rStyle.Prim());
-                offsets.push_back(0.0);
+                offsets.push_back(OffsetPair(-rStyle.Prim(), 0.0));
                 break;
             }
         }
     }
 }
 
-void compareToStyle(
+void createCutsWithStyle(
     const basegfx::B2DPoint& rOrigin,
     const basegfx::B2DVector& rOtherVector,
     const basegfx::B2DVector& rOtherUnifiedPerpendicular,
-    const std::vector< double >& rOtherOffsets,
+    const OffsetPair& rOtherOffsets,
     const Style& rStyle,
     const basegfx::B2DVector& rMyVector,
-    std::vector< std::vector< double >>& rOtherCuts)
+    std::vector< OffsetCutSet>& rOtherCuts)
 {
     if (rStyle.Prim())
     {
-        std::vector< double > myOffsets;
+        // get values dependent on source vector
+        const basegfx::B2DVector aMyUnifiedPerpendicular(basegfx::getNormalizedPerpendicular(rMyVector));
+        const basegfx::B2DPoint aOtherPosLeft(rOrigin + (rOtherUnifiedPerpendicular * rOtherOffsets.mfLeft));
+        const basegfx::B2DPoint aOtherPosRight(rOrigin + (rOtherUnifiedPerpendicular * rOtherOffsets.mfRight));
+        std::vector< OffsetPair > myOffsets;
 
-        // get offsets from outer to inner (two or four, depending on style)
-        getOffsetsFromStyle(rStyle, myOffsets);
+        // get offsets from outer to inner from target style (one or two)
+        getOffsetPairsFromStyle(rStyle, myOffsets);
 
-        if (!myOffsets.empty())
+        for (const auto& myOffset : myOffsets)
         {
-            const basegfx::B2DVector aMyUnifiedPerpendicular(basegfx::getNormalizedPerpendicular(rMyVector));
-
-            for (size_t a(0); a < rOtherOffsets.size(); a++)
-            {
-                const basegfx::B2DPoint aOtherPos(rOrigin + (rOtherUnifiedPerpendicular * rOtherOffsets[a]));
-
-                for (size_t b(0); b < myOffsets.size(); b++)
-                {
-                    const basegfx::B2DPoint aMyPos(rOrigin + (aMyUnifiedPerpendicular * myOffsets[b]));
-                    double fCut(0.0);
-                    basegfx::tools::findCut(
-                        aOtherPos,
-                        rOtherVector,
-                        aMyPos,
-                        rMyVector,
-                        CutFlagValue::LINE,
-                        &fCut);
-
-                    rOtherCuts[a].push_back(fCut);
-                }
-            }
+            // get values for new vectors and create all four cuts
+            const basegfx::B2DPoint aMyPosLeft(rOrigin + (aMyUnifiedPerpendicular * myOffset.mfLeft));
+            const basegfx::B2DPoint aMyPosRight(rOrigin + (aMyUnifiedPerpendicular * myOffset.mfRight));
+            OffsetCutSet aNewCuts;
+
+            basegfx::tools::findCut(
+                aOtherPosLeft,
+                rOtherVector,
+                aMyPosLeft,
+                rMyVector,
+                CutFlagValue::LINE,
+                &aNewCuts.mfLeftLeft);
+
+            basegfx::tools::findCut(
+                aOtherPosLeft,
+                rOtherVector,
+                aMyPosRight,
+                rMyVector,
+                CutFlagValue::LINE,
+                &aNewCuts.mfLeftRight);
+
+            basegfx::tools::findCut(
+                aOtherPosRight,
+                rOtherVector,
+                aMyPosLeft,
+                rMyVector,
+                CutFlagValue::LINE,
+                &aNewCuts.mfRightLeft);
+
+            basegfx::tools::findCut(
+                aOtherPosRight,
+                rOtherVector,
+                aMyPosRight,
+                rMyVector,
+                CutFlagValue::LINE,
+                &aNewCuts.mfRightRight);
+
+            rOtherCuts.push_back(aNewCuts);
         }
     }
 }
 
-double getMinMaxCut(bool bMin, const std::vector< double >& rVector)
+double getSimpleExtendedLineValues(
+    const basegfx::B2DPoint& rOrigin,
+    const basegfx::B2DVector& rX,
+    const basegfx::B2DVector& rY,
+    const basegfx::B2DVector& rPerpendX,
+    const OffsetPair& myOffset,
+    const Style& rFirst,
+    const Style& rSecond,
+    bool bEdgeStart,
+    double fLength)
 {
-    if (rVector.empty())
-    {
-        return 0.0;
-    }
-
-    if (1 == rVector.size())
-    {
-        return rVector[0];
-    }
-
-    double fRetval(rVector[0]);
+    std::vector< OffsetCutSet > myCutSets;
+    createCutsWithStyle(rOrigin, rX, rPerpendX, myOffset, rFirst, rY, myCutSets);
+    createCutsWithStyle(rOrigin, rX, rPerpendX, myOffset, rSecond, rY, myCutSets);
+    const OffsetCutSet* pResult = getMinMaxCutSet(bEdgeStart, myCutSets);
 
-    for (size_t a(1); a < rVector.size(); a++)
+    if (pResult)
     {
-        fRetval = bMin ? std::min(fRetval, rVector[a]) : std::max(fRetval, rVector[a]);
+        return (pResult->mfLeftRight + pResult->mfRightRight) * 0.5 * (bEdgeStart ? -fLength : fLength);
     }
 
-    return fRetval;
+    return 0.0;
 }
 
-std::vector< double > getMinMaxCuts(bool bMin, const std::vector< std::vector< double >>& rCuts)
+double getComplexExtendedLineValues(
+    const basegfx::B2DPoint& rOrigin,
+    const basegfx::B2DVector& rX,
+    const basegfx::B2DVector& rY,
+    const basegfx::B2DVector& rPerpendX,
+    const OffsetPair& myOffset,
+    const Style& rFirst,
+    const Style& rSecond,
+    bool bEdgeStart,
+    double fLength)
 {
-    std::vector< double > aRetval(rCuts.size());
+    std::vector< OffsetCutSet > myCutSets;
+    createCutsWithStyle(rOrigin, rX, rPerpendX, myOffset, rFirst, rY, myCutSets);
+    const OffsetCutSet* pResult = getMinMaxCutSet(!bEdgeStart, myCutSets);
 
-    for (size_t a(0); a < rCuts.size(); a++)
+    if (!pResult)
     {
-        aRetval[a] = getMinMaxCut(bMin, rCuts[a]);
+        createCutsWithStyle(rOrigin, rX, rPerpendX, myOffset, rSecond, rY, myCutSets);
+        pResult = getMinMaxCutSet(bEdgeStart, myCutSets);
     }
 
-    return aRetval;
-}
-
-bool areCutsEmpty(std::vector< std::vector< double >>& rCuts)
-{
-    for (const auto& rVec : rCuts)
+    if (pResult)
     {
-        if (!rVec.empty())
-        {
-            return false;
-        }
+        return (pResult->mfLeftRight + pResult->mfRightRight) * 0.5 * (bEdgeStart ? -fLength : fLength);
     }
-
-    return true;
 }
 
 void CreateBorderPrimitives(
@@ -512,12 +576,6 @@ void CreateBorderPrimitives(
 {
     if (rBorder.Prim())
     {
-        double mfExtendLeftStart(0.0);
-        double mfExtendLeftEnd(0.0);
-        double mfExtendRightStart(0.0);
-        double mfExtendRightEnd(0.0);
-        std::vector< double > myOffsets;
-        getOffsetsFromStyle(rBorder, myOffsets);
         const basegfx::B2DVector aPerpendX(basegfx::getNormalizedPerpendicular(rX));
         const double fLength(rX.getLength());
 
@@ -526,7 +584,6 @@ void CreateBorderPrimitives(
 
         if (RefMode::Centered != rBorder.GetRefMode())
         {
-            const basegfx::B2DVector aPerpendX(basegfx::getNormalizedPerpendicular(rX));
             const double fHalfWidth(rBorder.GetWidth() * 0.5);
 
             if (RefMode::Begin == rBorder.GetRefMode())
@@ -541,23 +598,27 @@ void CreateBorderPrimitives(
             }
         }
 
-        // create start/end for RefMode::Centered
+        // create start/end (use RefMode)
         const basegfx::B2DPoint aStart(rOrigin + aRefModeOffset);
         const basegfx::B2DPoint aEnd(aStart + rX);
 
-        if (2 == myOffsets.size())
+        // get offsets for my style (one or two)
+        std::vector< OffsetPair > myOffsets;
+        getOffsetPairsFromStyle(rBorder, myOffsets);
+
+        if (1 == myOffsets.size())
         {
-            std::vector< std::vector< double >> myCutsS(myOffsets.size());
-            compareToStyle(rOrigin, rX, aPerpendX, myOffsets, rLFromT, rY, myCutsS);
-            compareToStyle(rOrigin, rX, aPerpendX, myOffsets, rLFromB, rY, myCutsS);
-            std::vector< double > nMinCutsS(getMinMaxCuts(true, myCutsS));
-            mfExtendLeftStart = ((nMinCutsS[0] + nMinCutsS[1]) * 0.5) * -1.0 * fLength;
-
-            std::vector< std::vector< double >> myCutsE(myOffsets.size());
-            compareToStyle(rOrigin, rX, aPerpendX, myOffsets, rRFromT, rY, myCutsE);
-            compareToStyle(rOrigin, rX, aPerpendX, myOffsets, rRFromB, rY, myCutsE);
-            std::vector< double > nMinCutsE(getMinMaxCuts(false, myCutsE));
-            mfExtendLeftEnd = ((nMinCutsE[0] + nMinCutsE[1]) * 0.5) * fLength;
+            // we are a single edge, calculate cuts with edges coming from above/below
+            // to detect the line start/end extensions
+            const OffsetPair& myOffset(myOffsets[0]);
+            double mfExtendStart(0.0);
+            double mfExtendEnd(0.0);
+
+            // for start: get cuts with all left target styles and use the minimum
+            mfExtendStart = getSimpleExtendedLineValues(rOrigin, rX, rY, aPerpendX, myOffset, rLFromT, rLFromB, true, fLength);
+
+            // for end: get cuts with all right target styles and use the maximum
+            mfExtendEnd = getSimpleExtendedLineValues(rOrigin, rX, rY, aPerpendX, myOffset, rRFromT, rRFromB, false, fLength);
 
             rTarget.append(
                 drawinglayer::primitive2d::Primitive2DReference(
@@ -567,88 +628,35 @@ void CreateBorderPrimitives(
                         drawinglayer::primitive2d::BorderLine(
                             rBorder.Prim(),
                             (pForceColor ? *pForceColor : rBorder.GetColorPrim()).getBColor(),
-                            mfExtendLeftStart,
-                            mfExtendLeftEnd),
+                            mfExtendStart,
+                            mfExtendEnd),
                         rBorder.Type(),
                         rBorder.PatternScale())));
         }
-        else if (4 == myOffsets.size())
+        else if (2 == myOffsets.size())
         {
-            {
-                std::vector< double > myOffsetsA;
-                myOffsetsA.push_back(myOffsets[0]);
-                myOffsetsA.push_back(myOffsets[1]);
+            // we are a double edge, calculate cuts with edges coming from above/below
+            // for both edges to detect the line start/end extensions
+            double mfExtendLeftStart(0.0);
+            double mfExtendLeftEnd(0.0);
+            double mfExtendRightStart(0.0);
+            double mfExtendRightEnd(0.0);
 
-                std::vector< std::vector< double >> myCutsS(myOffsetsA.size());
-                std::vector< double > nMinCutsS;
-                compareToStyle(rOrigin, rX, aPerpendX, myOffsetsA, rLFromT, rY, myCutsS);
+            // for start of first edge, get cuts with left targets. Start with upper and take maximum when
+            // cut exists. Else use lower and take minimum when cut exists
+            mfExtendLeftStart = getComplexExtendedLineValues(rOrigin, rX, rY, aPerpendX, myOffsets[0], rLFromT, rLFromB, true, fLength);
 
-                if (!areCutsEmpty(myCutsS))
-                {
-                    nMinCutsS = getMinMaxCuts(false, myCutsS);
-                }
-                else
-                {
-                    compareToStyle(rOrigin, rX, aPerpendX, myOffsetsA, rLFromB, rY, myCutsS);
-                    nMinCutsS = getMinMaxCuts(true, myCutsS);
-                }
-
-                mfExtendLeftStart = ((nMinCutsS[0] + nMinCutsS[1]) * 0.5) * -1.0 * fLength;
+            // for end of first edge, get cuts with right targets. Start with upper and take minimum when
+            // cut exists. Else use lower and take maximum when cut exists
+            mfExtendLeftEnd = getComplexExtendedLineValues(rOrigin, rX, rY, aPerpendX, myOffsets[0], rRFromT, rRFromB, false, fLength);
 
-                std::vector< std::vector< double >> myCutsE(myOffsetsA.size());
-                std::vector< double > nMinCutsE;
-                compareToStyle(rOrigin, rX, aPerpendX, myOffsetsA, rRFromT, rY, myCutsE);
+            // for start of second edge, get cuts with left targets. Start with lower and take maximum when
+            // cut exists. Else use upper and take minimum when cut exists
+            mfExtendRightStart = getComplexExtendedLineValues(rOrigin, rX, rY, aPerpendX, myOffsets[1], rLFromB, rLFromT, true, fLength);
 
-                if (!areCutsEmpty(myCutsE))
-                {
-                    nMinCutsE = getMinMaxCuts(true, myCutsE);
-                }
-                else
-                {
-                    compareToStyle(rOrigin, rX, aPerpendX, myOffsetsA, rRFromB, rY, myCutsE);
-                    nMinCutsE = getMinMaxCuts(false, myCutsE);
-                }
-
-                mfExtendLeftEnd = ((nMinCutsE[0] + nMinCutsE[1]) * 0.5) * fLength;
-            }
-
-            {
-                std::vector< double > myOffsetsB;
-                myOffsetsB.push_back(myOffsets[2]);
-                myOffsetsB.push_back(myOffsets[3]);
-
-                std::vector< std::vector< double >> myCutsS(myOffsetsB.size());
-                std::vector< double > nMinCutsS;
-                compareToStyle(rOrigin, rX, aPerpendX, myOffsetsB, rLFromB, rY, myCutsS);
-
-                if (!areCutsEmpty(myCutsS))
-                {
-                    nMinCutsS = getMinMaxCuts(false, myCutsS);
-                }
-                else
-                {
-                    compareToStyle(rOrigin, rX, aPerpendX, myOffsetsB, rLFromT, rY, myCutsS);
-                    nMinCutsS = getMinMaxCuts(true, myCutsS);
-                }
-
-                mfExtendRightStart = ((nMinCutsS[0] + nMinCutsS[1]) * 0.5) * -1.0 * fLength;
-
-                std::vector< std::vector< double >> myCutsE(myOffsetsB.size());
-                std::vector< double > nMinCutsE;
-                compareToStyle(rOrigin, rX, aPerpendX, myOffsetsB, rRFromB, rY, myCutsE);
-
-                if (!areCutsEmpty(myCutsE))
-                {
-                    nMinCutsE = getMinMaxCuts(true, myCutsE);
-                }
-                else
-                {
-                    compareToStyle(rOrigin, rX, aPerpendX, myOffsetsB, rRFromT, rY, myCutsE);
-                    nMinCutsE = getMinMaxCuts(false, myCutsE);
-                }
-
-                mfExtendRightEnd = ((nMinCutsE[0] + nMinCutsE[1]) * 0.5) * fLength;
-            }
+            // for end of second edge, get cuts with right targets. Start with lower and take minimum when
+            // cut exists. Else use upper and take maximum when cut exists
+            mfExtendRightEnd = getComplexExtendedLineValues(rOrigin, rX, rY, aPerpendX, myOffsets[1], rRFromB, rRFromT, false, fLength);
 
             rTarget.append(
                 drawinglayer::primitive2d::Primitive2DReference(
@@ -720,16 +728,19 @@ void CreateDiagFrameBorderPrimitives(
     const basegfx::B2DVector& rYAxis,
     const Style& rTLBR,
     const Style& rBLTR,
-    const Style& rTLFromB,
-    const Style& rTLFromR,
-    const Style& rBRFromT,
-    const Style& rBRFromL,
-    const Style& rBLFromT,
-    const Style& rBLFromR,
-    const Style& rTRFromB,
-    const Style& rTRFromL,
+    const Style& /*rTLFromB*/,
+    const Style& /*rTLFromR*/,
+    const Style& /*rBRFromT*/,
+    const Style& /*rBRFromL*/,
+    const Style& /*rBLFromT*/,
+    const Style& /*rBLFromR*/,
+    const Style& /*rTRFromB*/,
+    const Style& /*rTRFromL*/,
     const Color* pForceColor)
 {
+    // currently the diagonal edges are just added as-is without cutting them against the incoming
+    // edges. This needs to be improved in the future, so please do *not* remove the currently unused
+    // parameters from above
     if (rTLBR.Prim())
     {
         // top-left to bottom-right
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index 20c362b0f8e4..407ac441ecf7 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -2771,25 +2771,32 @@ void SwTabFramePainter::PaintLines(OutputDevice& rDev, const SwRect& rRect) cons
 
             // logically vertical lines are painted centered on the line,
             // logically horizontal lines are painted "below" the line
-            bool const isBelow((mrTabFrame.IsVertical()) ? !bHori : bHori);
-            double const offsetStart = (isBelow)
-                ?   aStyles[0].GetWidth() / 2.0
-                :   std::max<double>(aStyles[1].GetWidth(),
-                        aStyles[3].GetWidth()) / 2.0;
-            double const offsetEnd = (isBelow)
-                ?   aStyles[0].GetWidth() / 2.0
-                :   std::max<double>(aStyles[4].GetWidth(),
-                        aStyles[6].GetWidth()) / 2.0;
-            if (mrTabFrame.IsVertical())
-            {
-                aPaintStart.X() -= static_cast<long>(offsetStart + 0.5);
-                aPaintEnd.X()   -= static_cast<long>(offsetEnd   + 0.5);
-            }
-            else
-            {
-                aPaintStart.Y() += static_cast<long>(offsetStart + 0.5);
-                aPaintEnd.Y()   += static_cast<long>(offsetEnd   + 0.5);
-            }
+            //
+            // This does not need to be done here, it is set in SwTabFramePainter::Insert
+            // already using SetRefMode(...) as property of the BorderLine Style, see there.
+            // When additionally adding the offset here manually, it will be applied
+            // double and will be rendered wrong. This did not happen before because
+            // the setting of the svx::frame::RefMode at svx::frame::Style was ignored there.
+            //
+            // bool const isBelow((mrTabFrame.IsVertical()) ? !bHori : bHori);
+            // double const offsetStart = (isBelow)
+            //     ?   aStyles[0].GetWidth() / 2.0
+            //     :   std::max<double>(aStyles[1].GetWidth(),
+            //             aStyles[3].GetWidth()) / 2.0;
+            // double const offsetEnd = (isBelow)
+            //     ?   aStyles[0].GetWidth() / 2.0
+            //     :   std::max<double>(aStyles[4].GetWidth(),
+            //             aStyles[6].GetWidth()) / 2.0;
+            // if (mrTabFrame.IsVertical())
+            // {
+            //     aPaintStart.X() -= static_cast<long>(offsetStart + 0.5);
+            //     aPaintEnd.X()   -= static_cast<long>(offsetEnd   + 0.5);
+            // }
+            // else
+            // {
+            //     aPaintStart.Y() += static_cast<long>(offsetStart + 0.5);
+            //     aPaintEnd.Y()   += static_cast<long>(offsetEnd   + 0.5);
+            // }
 
             if (bHori)
             {
commit 06f0411d64b88b5efc0d3c7804e11c0bf89fafe4
Author: arminl <arminl at KRANIX>
Date:   Wed Jul 26 13:19:50 2017 +0200

    borderline: Simplified BorderLinePrimitive
    
    Overhauled BorderLinePrimitive to use two constructors
    offering using one or three edge definitions for
    construction to better refrlect possibilities. Adapted
    usages. Better processing, less memory. Preparation
    for using more decent LineExtend values (four per line
    needed)
    
    Change-Id: Iac9d9ae64874fea38fd6e2a04221698481cc0d0e

diff --git a/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx b/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx
index a9822d6bcd06..724ba8772c44 100644
--- a/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx
@@ -37,119 +37,136 @@ namespace drawinglayer
 {
     namespace primitive2d
     {
+        BorderLine::BorderLine(
+            double fWidth,
+            const basegfx::BColor& rRGBColor,
+            double fExtendStart,
+            double fExtendEnd)
+        :   mfWidth(fWidth),
+            maRGBColor(rRGBColor),
+            mfExtendStart(fExtendStart),
+            mfExtendEnd(fExtendEnd)
+        {
+        }
+
+        bool BorderLine::operator==(const BorderLine& rBorderLine) const
+        {
+            return getWidth() == rBorderLine.getWidth()
+                && getRGBColor() == rBorderLine.getRGBColor()
+                && getExtendStart() == rBorderLine.getExtendStart()
+                && getExtendEnd() == rBorderLine.getExtendEnd();
+        }
+
         // helper to add a centered, maybe stroked line primitive to rContainer
         void addPolygonStrokePrimitive2D(
             Primitive2DContainer& rContainer,
             const basegfx::B2DPoint& rStart,
             const basegfx::B2DPoint& rEnd,
-            const basegfx::BColor& rColor,
-            double fWidth,
-            SvxBorderLineStyle aStyle,
-            double fPatternScale)
+            const attribute::LineAttribute& rLineAttribute,
+            const attribute::StrokeAttribute & rStrokeAttribute)
         {
             basegfx::B2DPolygon aPolygon;
 
             aPolygon.append(rStart);
             aPolygon.append(rEnd);
 
-            const attribute::LineAttribute aLineAttribute(rColor, fWidth);
-            static double fPatScFact(10.0); // 10.0 multiply, see old code
-            const std::vector<double> aDashing(svtools::GetLineDashing(aStyle, fPatternScale * fPatScFact));
-
-            if (aDashing.empty())
+            if (rStrokeAttribute.isDefault())
             {
                 rContainer.push_back(
                     new PolygonStrokePrimitive2D(
                         aPolygon,
-                        aLineAttribute));
+                        rLineAttribute));
             }
             else
             {
-                const attribute::StrokeAttribute aStrokeAttribute(aDashing);
-
                 rContainer.push_back(
                     new PolygonStrokePrimitive2D(
                         aPolygon,
-                        aLineAttribute,
-                        aStrokeAttribute));
+                        rLineAttribute,
+                        rStrokeAttribute));
             }
         }
 
         void BorderLinePrimitive2D::create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& /*rViewInformation*/) const
         {
-            if (!getStart().equal(getEnd()) && (isInsideUsed() || isOutsideUsed()))
+            if (!getStart().equal(getEnd()))
             {
                 // get data and vectors
                 basegfx::B2DVector aVector(getEnd() - getStart());
                 aVector.normalize();
                 const basegfx::B2DVector aPerpendicular(basegfx::getPerpendicular(aVector));
+                static double fPatScFact(10.0); // 10.0 multiply, see old code
+                const std::vector<double> aDashing(svtools::GetLineDashing(getStyle(), getPatternScale() * fPatScFact));
+                const attribute::StrokeAttribute aStrokeAttribute(aDashing);
 
-                if (isOutsideUsed() && isInsideUsed())
+                if (3 == getBorderLines().size())
                 {
-                    // double line with gap. Use mfDiscreteDistance (see get2DDecomposition) as distance.
+                    // double line with gap. Use mfDiscreteGapDistance (see get2DDecomposition) as distance.
                     // That value is prepared to be at least one pixel (discrete unit) so that the
                     // decomposition is view-dependent in this cases
-                    if (isInsideUsed())
                     {
-                        // inside line (left). Create stroke primitive centered on line width
-                        const double fDeltaY((mfDiscreteDistance + getLeftWidth()) * 0.5);
+                        // inside line (left of vector). Create stroke primitive centered on line width
+                        const BorderLine& rLeft(getBorderLines()[0]);
+                        const double fDeltaY((mfDiscreteGapDistance + rLeft.getWidth()) * 0.5);
                         const basegfx::B2DVector aDeltaY(aPerpendicular * fDeltaY);
-                        const basegfx::B2DPoint aStart(getStart() - (aVector * getExtendLeftStart()) - aDeltaY);
-                        const basegfx::B2DPoint aEnd(getEnd() + (aVector * getExtendLeftEnd()) - aDeltaY);
+                        const basegfx::B2DPoint aStart(getStart() - (aVector * rLeft.getExtendStart()) - aDeltaY);
+                        const basegfx::B2DPoint aEnd(getEnd() + (aVector * rLeft.getExtendEnd()) - aDeltaY);
+                        const attribute::LineAttribute aLineAttribute(rLeft.getRGBColor(), rLeft.getWidth());
 
                         addPolygonStrokePrimitive2D(
                             rContainer,
                             aStart,
                             aEnd,
-                            getRGBColorLeft(),
-                            getLeftWidth(),
-                            getStyle(),
-                            getPatternScale());
+                            aLineAttribute,
+                            aStrokeAttribute);
                     }
 
-                    if (hasGapColor() && isDistanceUsed())
+                    if (hasGapColor())
                     {
-                        // gap (if visible, found no practical usage).
+                        // gap (if visible, found practical usage in Writer MultiColorBorderLines).
                         // Create stroke primitive on vector with given color
+                        const BorderLine& rGap(getBorderLines()[1]);
+                        const basegfx::B2DPoint aStart(getStart() - (aVector * rGap.getExtendStart()));
+                        const basegfx::B2DPoint aEnd(getEnd() + (aVector * rGap.getExtendEnd()));
+                        const attribute::LineAttribute aLineAttribute(rGap.getRGBColor(), mfDiscreteGapDistance);
+
                         addPolygonStrokePrimitive2D(
                             rContainer,
-                            getStart(),
-                            getEnd(),
-                            getRGBColorGap(),
-                            mfDiscreteDistance,
-                            getStyle(),
-                            getPatternScale());
+                            aStart,
+                            aEnd,
+                            aLineAttribute,
+                            aStrokeAttribute);
                     }
 
-                    if (isOutsideUsed())
                     {
-                        // outside line (right). Create stroke primitive centered on line width
-                        const double fDeltaY((mfDiscreteDistance + getRightWidth()) * 0.5);
+                        // outside line (right of vector). Create stroke primitive centered on line width
+                        const BorderLine& rRight(getBorderLines()[2]);
+                        const double fDeltaY((mfDiscreteGapDistance + rRight.getWidth()) * 0.5);
                         const basegfx::B2DVector aDeltaY(aPerpendicular * fDeltaY);
-                        const basegfx::B2DPoint aStart(getStart() - (aVector * getExtendRightStart()) + aDeltaY);
-                        const basegfx::B2DPoint aEnd(getEnd() + (aVector * getExtendRightEnd()) + aDeltaY);
+                        const basegfx::B2DPoint aStart(getStart() - (aVector * rRight.getExtendStart()) + aDeltaY);
+                        const basegfx::B2DPoint aEnd(getEnd() + (aVector * rRight.getExtendEnd()) + aDeltaY);
+                        const attribute::LineAttribute aLineAttribute(rRight.getRGBColor(), rRight.getWidth());
 
                         addPolygonStrokePrimitive2D(
                             rContainer,
                             aStart,
                             aEnd,
-                            getRGBColorRight(),
-                            getRightWidth(),
-                            getStyle(),
-                            getPatternScale());
+                            aLineAttribute,
+                            aStrokeAttribute);
                     }
                 }
-                else if(isInsideUsed())
+                else
                 {
                     // single line, only inside values used, no vertical offsets
+                    const BorderLine& rBorderLine(getBorderLines()[0]);
+                    const attribute::LineAttribute aLineAttribute(rBorderLine.getRGBColor(), rBorderLine.getWidth());
+
                     addPolygonStrokePrimitive2D(
                         rContainer,
-                        getStart() - (aVector * getExtendLeftStart()),
-                        getEnd() + (aVector * getExtendLeftEnd()),
-                        getRGBColorLeft(),
-                        getLeftWidth(),
-                        getStyle(),
-                        getPatternScale());
+                        getStart() - (aVector * rBorderLine.getExtendStart()),
+                        getEnd() + (aVector * rBorderLine.getExtendEnd()),
+                        aLineAttribute,
+                        aStrokeAttribute);
                 }
             }
         }
@@ -170,37 +187,42 @@ namespace drawinglayer
         BorderLinePrimitive2D::BorderLinePrimitive2D(
             const basegfx::B2DPoint& rStart,
             const basegfx::B2DPoint& rEnd,
-            double fLeftWidth,
-            double fDistance,
-            double fRightWidth,
-            double fExtendLeftStart,
-            double fExtendLeftEnd,
-            double fExtendRightStart,
-            double fExtendRightEnd,
-            const basegfx::BColor& rRGBColorRight,
-            const basegfx::BColor& rRGBColorLeft,
-            const basegfx::BColor& rRGBColorGap,
+            const BorderLine& rBorderLine,
+            SvxBorderLineStyle nStyle,
+            double fPatternScale)
+        :   BufferedDecompositionPrimitive2D(),
+            maStart(rStart),
+            maEnd(rEnd),
+            maBorderLines(),
+            mbHasGapColor(false),
+            mnStyle(nStyle),
+            mfPatternScale(fPatternScale),
+            mfDiscreteGapDistance(0.0)
+        {
+            maBorderLines.push_back(rBorderLine);
+        }
+
+        BorderLinePrimitive2D::BorderLinePrimitive2D(
+            const basegfx::B2DPoint& rStart,
+            const basegfx::B2DPoint& rEnd,
+            const BorderLine& rLeft,
+            const BorderLine& rGap,
+            const BorderLine& rRight,
             bool bHasGapColor,
             SvxBorderLineStyle nStyle,
             double fPatternScale)
         :   BufferedDecompositionPrimitive2D(),
             maStart(rStart),
             maEnd(rEnd),
-            mfLeftWidth(fLeftWidth),
-            mfDistance(fDistance),
-            mfRightWidth(fRightWidth),
-            mfExtendLeftStart(fExtendLeftStart),
-            mfExtendLeftEnd(fExtendLeftEnd),
-            mfExtendRightStart(fExtendRightStart),
-            mfExtendRightEnd(fExtendRightEnd),
-            maRGBColorRight(rRGBColorRight),
-            maRGBColorLeft(rRGBColorLeft),
-            maRGBColorGap(rRGBColorGap),
+            maBorderLines(),
             mbHasGapColor(bHasGapColor),
             mnStyle(nStyle),
             mfPatternScale(fPatternScale),
-            mfDiscreteDistance(0.0)
+            mfDiscreteGapDistance(0.0)
         {
+            maBorderLines.push_back(rLeft);
+            maBorderLines.push_back(rGap);
+            maBorderLines.push_back(rRight);
         }
 
         bool BorderLinePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
@@ -209,21 +231,23 @@ namespace drawinglayer
             {
                 const BorderLinePrimitive2D& rCompare = static_cast<const BorderLinePrimitive2D&>(rPrimitive);
 
-                return (getStart() == rCompare.getStart()
+                if (getStart() == rCompare.getStart()
                     && getEnd() == rCompare.getEnd()
-                    && getLeftWidth() == rCompare.getLeftWidth()
-                    && getDistance() == rCompare.getDistance()
-                    && getRightWidth() == rCompare.getRightWidth()
-                    && getExtendLeftStart() == rCompare.getExtendLeftStart()
-                    && getExtendLeftEnd() == rCompare.getExtendLeftEnd()
-                    && getExtendRightStart() == rCompare.getExtendRightStart()
-                    && getExtendRightEnd() == rCompare.getExtendRightEnd()
-                    && getRGBColorRight() == rCompare.getRGBColorRight()
-                    && getRGBColorLeft() == rCompare.getRGBColorLeft()
-                    && getRGBColorGap() == rCompare.getRGBColorGap()
                     && hasGapColor() == rCompare.hasGapColor()
                     && getStyle() == rCompare.getStyle()
-                    && getPatternScale() == rCompare.getPatternScale());
+                    && getPatternScale() == rCompare.getPatternScale())
+                {
+                    if (getBorderLines().size() == rCompare.getBorderLines().size())
+                    {
+                        for (size_t a(0); a < getBorderLines().size(); a++)
+                        {
+                            if (!(getBorderLines()[a] == rCompare.getBorderLines()[a]))
+                            {
+                                return false;
+                            }
+                        }
+                    }
+                }
             }
 
             return false;
@@ -233,7 +257,7 @@ namespace drawinglayer
         {
             ::osl::MutexGuard aGuard(m_aMutex);
 
-            if (!getStart().equal(getEnd()) && isOutsideUsed() && isInsideUsed())
+            if (!getStart().equal(getEnd()) && 3 == getBorderLines().size())
             {
                 // Double line with gap. In this case, we want to be view-dependent.
                 // Get the current DiscreteUnit, look at X and Y and use the maximum
@@ -246,9 +270,10 @@ namespace drawinglayer
                 // This can also be done using DiscreteMetricDependentPrimitive2D as base class
                 // for this class, but specialization is better here for later buffering (only
                 // do this when 'double line with gap')
-                const double fNewDiscreteDistance(std::max(fDiscreteUnit, getDistance()));
+                const double fDistance(getBorderLines()[1].getWidth());
+                const double fNewDiscreteDistance(std::max(fDiscreteUnit, fDistance));
 
-                if (!rtl::math::approxEqual(fNewDiscreteDistance, mfDiscreteDistance))
+                if (!rtl::math::approxEqual(fNewDiscreteDistance, mfDiscreteGapDistance))
                 {
                     if (!getBuffered2DDecomposition().empty())
                     {
@@ -257,7 +282,7 @@ namespace drawinglayer
                     }
 
                     // remember value for usage in create2DDecomposition
-                    const_cast< BorderLinePrimitive2D* >(this)->mfDiscreteDistance = fNewDiscreteDistance;
+                    const_cast< BorderLinePrimitive2D* >(this)->mfDiscreteGapDistance = fNewDiscreteDistance;
                 }
             }
 
diff --git a/include/drawinglayer/primitive2d/borderlineprimitive2d.hxx b/include/drawinglayer/primitive2d/borderlineprimitive2d.hxx
index 4645bde2a2c5..3108a81f619b 100644
--- a/include/drawinglayer/primitive2d/borderlineprimitive2d.hxx
+++ b/include/drawinglayer/primitive2d/borderlineprimitive2d.hxx
@@ -33,14 +33,49 @@ namespace drawinglayer
 {
     namespace primitive2d
     {
+        /** BorderLine class
+        Helper class holding the style definition for a single part of a full BNorderLine definition
+        */
+        class DRAWINGLAYER_DLLPUBLIC BorderLine
+        {
+        private:
+            // line width
+            double              mfWidth;
+
+            // line color
+            basegfx::BColor     maRGBColor;
+
+            // line extends
+            double              mfExtendStart;
+            double              mfExtendEnd;
+
+            // not implemented
+            virtual bool operator!=(const BorderLine& rBorderLine) const = delete;
+
+        public:
+            BorderLine(
+                double fWidth,
+                const basegfx::BColor& rRGBColor,
+                double fExtendStart = 0.0,
+                double fExtendEnd = 0.0);
+
+            double getWidth() const { return mfWidth; }
+            const basegfx::BColor& getRGBColor() const { return maRGBColor; }
+            double getExtendStart() const { return mfExtendStart; }
+            double getExtendEnd() const { return mfExtendEnd; }
+
+            /// compare operator
+            virtual bool operator==(const BorderLine& rBorderLine) const;
+        };
+
         /** BorderLinePrimitive2D class
 
-            This is the basic primitive to build frames around objects, e.g. tables.
-            It defines a single or double line from Start to End using the LeftWidth,
-            Distance and RightWidth definitions.
-            The LineStart/End overlap is defined by the Extend(Left|Right)(Start|End)
-            definitions.
-         */
+        This is the basic primitive to build frames around objects, e.g. tables.
+        It defines a single or double line from Start to End using the LeftWidth,
+        Distance and RightWidth definitions.
+        The LineStart/End overlap is defined by the Extend(Left|Right)(Start|End)
+        definitions.
+        */
         class DRAWINGLAYER_DLLPUBLIC BorderLinePrimitive2D : public BufferedDecompositionPrimitive2D
         {
         private:
@@ -48,84 +83,49 @@ namespace drawinglayer
             basegfx::B2DPoint                               maStart;
             basegfx::B2DPoint                               maEnd;
 
-            /// the widths of single/double line
-            double                                          mfLeftWidth;
-            double                                          mfDistance;
-            double                                          mfRightWidth;
-
-            /// edge overlap sizes
-            double                                          mfExtendLeftStart;
-            double                                          mfExtendLeftEnd;
-            double                                          mfExtendRightStart;
-            double                                          mfExtendRightEnd;
-
-            /// the line colors
-            basegfx::BColor                                 maRGBColorRight;
-            basegfx::BColor                                 maRGBColorLeft;
-            basegfx::BColor                                 maRGBColorGap;
+            /// the single BorderLine style definition(s), one or three allowed (see constructors)
+            std::vector< BorderLine >                       maBorderLines;
+
             bool                                            mbHasGapColor;
 
+            /// common style definitions
             SvxBorderLineStyle                              mnStyle;
             double                                          mfPatternScale;
 
             // for view dependent decomposition in the case with distance (gap),
             // remember the last used concrete mfDistance, see get2DDecomposition
             // implementation
-            double                                          mfDiscreteDistance;
-
-            /// local helpers
-            bool isInsideUsed() const
-            {
-                return !basegfx::fTools::equalZero(mfLeftWidth);
-            }
-
-            bool isDistanceUsed() const
-            {
-                return !basegfx::fTools::equalZero(mfDistance);
-            }
-
-            bool isOutsideUsed() const
-            {
-                return !basegfx::fTools::equalZero(mfRightWidth);
-            }
+            double                                          mfDiscreteGapDistance;
 
             /// create local decomposition
             virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const override;
 
         public:
-            /// constructor
+            /// simplified constructor for BorderLine with single edge
+            BorderLinePrimitive2D(
+                const basegfx::B2DPoint& rStart,
+                const basegfx::B2DPoint& rEnd,
+                const BorderLine& rBorderLine,
+                SvxBorderLineStyle nStyle,
+                double fPatternScale = 1.0);
+
+            /// constructor for full-fledged BorderLine with two edges and gap
             BorderLinePrimitive2D(
                 const basegfx::B2DPoint& rStart,
                 const basegfx::B2DPoint& rEnd,
-                double fLeftWidth,
-                double fDistance,
-                double fRightWidth,
-                double fExtendLeftStart,
-                double fExtendLeftEnd,
-                double fExtendRightStart,
-                double fExtendRightEnd,
-                const basegfx::BColor& rRGBColorRight,
-                const basegfx::BColor& rRGBColorLeft,
-                const basegfx::BColor& rRGBColorGap,
+                const BorderLine& rLeft,
+                const BorderLine& rGap,
+                const BorderLine& rRight,
                 bool bHasGapColor,
                 SvxBorderLineStyle nStyle,
-                double fPatternScale = 1.0 );
+                double fPatternScale = 1.0);
 
             /// data read access
             const basegfx::B2DPoint& getStart() const { return maStart; }
             const basegfx::B2DPoint& getEnd() const { return maEnd; }
-            double getLeftWidth() const { return mfLeftWidth; }
-            double getDistance() const { return mfDistance; }
-            double getRightWidth() const { return mfRightWidth; }
-            double getExtendLeftStart() const { return mfExtendLeftStart; }
-            double getExtendLeftEnd() const { return mfExtendLeftEnd; }
-            double getExtendRightStart() const { return mfExtendRightStart; }
-            double getExtendRightEnd() const { return mfExtendRightEnd; }
-            const basegfx::BColor& getRGBColorRight () const { return maRGBColorRight; }
-            const basegfx::BColor& getRGBColorLeft () const { return maRGBColorLeft; }
-            const basegfx::BColor& getRGBColorGap () const { return maRGBColorGap; }
-            bool hasGapColor( ) const { return mbHasGapColor; }
-            SvxBorderLineStyle getStyle () const { return mnStyle; }
+            const std::vector< BorderLine >& getBorderLines() const { return maBorderLines; }
+            bool hasGapColor() const { return mbHasGapColor; }
+            SvxBorderLineStyle getStyle() const { return mnStyle; }
             double getPatternScale() const { return mfPatternScale; }
 
             /// helper to decide if AntiAliasing should be used
diff --git a/svx/source/dialog/framelink.cxx b/svx/source/dialog/framelink.cxx
index de93c9372d88..e5b6abb8f5f8 100644
--- a/svx/source/dialog/framelink.cxx
+++ b/svx/source/dialog/framelink.cxx
@@ -510,9 +510,7 @@ void CreateBorderPrimitives(
     const DiagStyle& /*rRFromBL*/,
     const Color* pForceColor)
 {
-    static bool bCheckNewStuff(true);
-
-    if (bCheckNewStuff && rBorder.Prim())
+    if (rBorder.Prim())
     {
         double mfExtendLeftStart(0.0);
         double mfExtendLeftEnd(0.0);
@@ -523,6 +521,30 @@ void CreateBorderPrimitives(
         const basegfx::B2DVector aPerpendX(basegfx::getNormalizedPerpendicular(rX));
         const double fLength(rX.getLength());
 
+        // do not forget RefMode offset, primitive will assume RefMode::Centered
+        basegfx::B2DVector aRefModeOffset;
+
+        if (RefMode::Centered != rBorder.GetRefMode())
+        {
+            const basegfx::B2DVector aPerpendX(basegfx::getNormalizedPerpendicular(rX));
+            const double fHalfWidth(rBorder.GetWidth() * 0.5);
+
+            if (RefMode::Begin == rBorder.GetRefMode())
+            {
+                // move aligned below vector
+                aRefModeOffset = aPerpendX * fHalfWidth;
+            }
+            else if (RefMode::End == rBorder.GetRefMode())
+            {
+                // move aligned above vector
+                aRefModeOffset = aPerpendX * -fHalfWidth;
+            }
+        }
+
+        // create start/end for RefMode::Centered
+        const basegfx::B2DPoint aStart(rOrigin + aRefModeOffset);
+        const basegfx::B2DPoint aEnd(aStart + rX);
+
         if (2 == myOffsets.size())
         {
             std::vector< std::vector< double >> myCutsS(myOffsets.size());
@@ -537,6 +559,18 @@ void CreateBorderPrimitives(
             std::vector< double > nMinCutsE(getMinMaxCuts(false, myCutsE));
             mfExtendLeftEnd = ((nMinCutsE[0] + nMinCutsE[1]) * 0.5) * fLength;
 
+            rTarget.append(
+                drawinglayer::primitive2d::Primitive2DReference(
+                    new drawinglayer::primitive2d::BorderLinePrimitive2D(
+                        aStart,
+                        aEnd,
+                        drawinglayer::primitive2d::BorderLine(
+                            rBorder.Prim(),
+                            (pForceColor ? *pForceColor : rBorder.GetColorPrim()).getBColor(),
+                            mfExtendLeftStart,
+                            mfExtendLeftEnd),
+                        rBorder.Type(),
+                        rBorder.PatternScale())));
         }
         else if (4 == myOffsets.size())
         {
@@ -615,74 +649,31 @@ void CreateBorderPrimitives(
 
                 mfExtendRightEnd = ((nMinCutsE[0] + nMinCutsE[1]) * 0.5) * fLength;
             }
-        }
 
-        // do not forget RefMode offset, primitive will assume RefMode::Centered
-        basegfx::B2DVector aRefModeOffset;
-
-        if (RefMode::Centered != rBorder.GetRefMode())
-        {
-            const basegfx::B2DVector aPerpendX(basegfx::getNormalizedPerpendicular(rX));
-            const double fHalfWidth(rBorder.GetWidth() * 0.5);
-
-            if (RefMode::Begin == rBorder.GetRefMode())
-            {
-                // move aligned below vector
-                aRefModeOffset = aPerpendX * fHalfWidth;
-            }
-            else if (RefMode::End == rBorder.GetRefMode())
-            {
-                // move aligned above vector
-                aRefModeOffset = aPerpendX * -fHalfWidth;
-            }
+            rTarget.append(
+                drawinglayer::primitive2d::Primitive2DReference(
+                    new drawinglayer::primitive2d::BorderLinePrimitive2D(
+                        aStart,
+                        aEnd,
+                        drawinglayer::primitive2d::BorderLine(
+                            rBorder.Prim(),
+                            (pForceColor ? *pForceColor : rBorder.GetColorPrim()).getBColor(),
+                            mfExtendLeftStart,
+                            mfExtendLeftEnd),
+                        drawinglayer::primitive2d::BorderLine(
+                            rBorder.Dist(),
+                            (pForceColor ? *pForceColor : rBorder.GetColorGap()).getBColor(),
+                            (mfExtendLeftStart + mfExtendRightStart) * 0.5,
+                            (mfExtendLeftEnd + mfExtendRightEnd) * 0.5),
+                        drawinglayer::primitive2d::BorderLine(
+                            rBorder.Secn(),
+                            (pForceColor ? *pForceColor : rBorder.GetColorSecn()).getBColor(),
+                            mfExtendRightStart,
+                            mfExtendRightEnd),
+                        rBorder.UseGapColor(),
+                        rBorder.Type(),
+                        rBorder.PatternScale())));
         }
-
-        // create start/end for RefMode::Centered
-        const basegfx::B2DPoint aStart(rOrigin + aRefModeOffset);
-        const basegfx::B2DPoint aEnd(aStart + rX);
-
-        rTarget.append(
-            drawinglayer::primitive2d::Primitive2DReference(
-                new drawinglayer::primitive2d::BorderLinePrimitive2D(
-                    aStart,
-                    aEnd,
-                    rBorder.Prim(),
-                    rBorder.Dist(),
-                    rBorder.Secn(),
-                    mfExtendLeftStart,
-                    mfExtendLeftEnd,
-                    mfExtendRightStart,
-                    mfExtendRightEnd,
-                    (pForceColor ? *pForceColor : rBorder.GetColorSecn()).getBColor(),
-                    (pForceColor ? *pForceColor : rBorder.GetColorPrim()).getBColor(),
-                    (pForceColor ? *pForceColor : rBorder.GetColorGap()).getBColor(),
-                    rBorder.UseGapColor(),
-                    rBorder.Type(),
-                    rBorder.PatternScale())));
-    }
-
-    if (!bCheckNewStuff && (rBorder.Prim() || rBorder.Secn()))
-    {
-        basegfx::B2DPoint aStart(rOrigin);
-        basegfx::B2DPoint aEnd(rOrigin + rX);
-        const long nRotateT = 9000; /// Angle of the top slanted frames in 100th of degree
-        const long nRotateB = 9000; /// Angle of the bottom slanted frames in 100th of degree
-
-        rTarget.append(
-            drawinglayer::primitive2d::Primitive2DReference(
-                new drawinglayer::primitive2d::BorderLinePrimitive2D(
-                    aStart, aEnd,
-                    rBorder.Prim(),
-                    rBorder.Dist(),
-                    rBorder.Secn(),
-                    lcl_GetExtent(rBorder, rLFromT, rLFromB, nRotateT, -nRotateB, true, false),                  // top-left, so left for rBorder and right for left outer
-                    lcl_GetExtent(rBorder, rRFromT, rRFromB, 18000 - nRotateT, nRotateB - 18000, true, true),     // top-right
-                    lcl_GetExtent(rBorder, rLFromB, rLFromT, nRotateB, -nRotateT, false, false),                 // bottom-left
-                    lcl_GetExtent(rBorder, rRFromB, rRFromT, 18000 - nRotateB, nRotateT - 18000, false, true),    // bottom-right
-                    (pForceColor ? *pForceColor : rBorder.GetColorSecn()).getBColor(),
-                    (pForceColor ? *pForceColor : rBorder.GetColorPrim()).getBColor(),
-                    (pForceColor ? *pForceColor : rBorder.GetColorGap()).getBColor(),
-                    rBorder.UseGapColor(), rBorder.Type(), rBorder.PatternScale())));
     }
 }
 
@@ -742,45 +733,57 @@ void CreateDiagFrameBorderPrimitives(
     if (rTLBR.Prim())
     {
         // top-left to bottom-right
-        rTarget.append(
-            new drawinglayer::primitive2d::BorderLinePrimitive2D(
-                rOrigin,
-                rOrigin + rXAxis + rYAxis,
-                rTLBR.Prim(),
-                rTLBR.Dist(),
-                rTLBR.Secn(),
-                0.0,
-                0.0,
-                0.0,
-                0.0,
-                (pForceColor ? *pForceColor : rTLBR.GetColorSecn()).getBColor(),
-                (pForceColor ? *pForceColor : rTLBR.GetColorPrim()).getBColor(),
-                (pForceColor ? *pForceColor : rTLBR.GetColorGap()).getBColor(),
-                rTLBR.UseGapColor(),
-                rTLBR.Type(),
-                rTLBR.PatternScale()));
+        if (basegfx::fTools::equalZero(rTLBR.Secn()))
+        {
+            rTarget.append(
+                new drawinglayer::primitive2d::BorderLinePrimitive2D(
+                    rOrigin,
+                    rOrigin + rXAxis + rYAxis,
+                    drawinglayer::primitive2d::BorderLine(rTLBR.Prim(), (pForceColor ? *pForceColor : rTLBR.GetColorPrim()).getBColor()),
+                    rTLBR.Type(),
+                    rTLBR.PatternScale()));
+        }
+        else
+        {
+            rTarget.append(
+                new drawinglayer::primitive2d::BorderLinePrimitive2D(
+                    rOrigin,
+                    rOrigin + rXAxis + rYAxis,
+                    drawinglayer::primitive2d::BorderLine(rTLBR.Prim(), (pForceColor ? *pForceColor : rTLBR.GetColorPrim()).getBColor()),
+                    drawinglayer::primitive2d::BorderLine(rTLBR.Dist(), (pForceColor ? *pForceColor : rTLBR.GetColorGap()).getBColor()),
+                    drawinglayer::primitive2d::BorderLine(rTLBR.Secn(), (pForceColor ? *pForceColor : rTLBR.GetColorSecn()).getBColor()),
+                    rTLBR.UseGapColor(),
+                    rTLBR.Type(),
+                    rTLBR.PatternScale()));
+        }
     }
 
     if (rBLTR.Prim())
     {
         // bottom-left to top-right
-        rTarget.append(
-            new drawinglayer::primitive2d::BorderLinePrimitive2D(
-                rOrigin + rYAxis,
-                rOrigin + rXAxis,
-                rBLTR.Prim(),
-                rBLTR.Dist(),
-                rBLTR.Secn(),
-                0.0,
-                0.0,
-                0.0,
-                0.0,
-                (pForceColor ? *pForceColor : rBLTR.GetColorSecn()).getBColor(),
-                (pForceColor ? *pForceColor : rBLTR.GetColorPrim()).getBColor(),
-                (pForceColor ? *pForceColor : rBLTR.GetColorGap()).getBColor(),
-                rBLTR.UseGapColor(),
-                rBLTR.Type(),
-                rBLTR.PatternScale()));
+        if (basegfx::fTools::equalZero(rTLBR.Secn()))
+        {
+            rTarget.append(
+                new drawinglayer::primitive2d::BorderLinePrimitive2D(
+                    rOrigin + rYAxis,
+                    rOrigin + rXAxis,
+                    drawinglayer::primitive2d::BorderLine(rTLBR.Prim(), (pForceColor ? *pForceColor : rTLBR.GetColorPrim()).getBColor()),
+                    rBLTR.Type(),
+                    rBLTR.PatternScale()));
+        }
+        else
+        {
+            rTarget.append(
+                new drawinglayer::primitive2d::BorderLinePrimitive2D(
+                    rOrigin + rYAxis,
+                    rOrigin + rXAxis,
+                    drawinglayer::primitive2d::BorderLine(rTLBR.Prim(), (pForceColor ? *pForceColor : rTLBR.GetColorPrim()).getBColor()),
+                    drawinglayer::primitive2d::BorderLine(rTLBR.Dist(), (pForceColor ? *pForceColor : rTLBR.GetColorGap()).getBColor()),
+                    drawinglayer::primitive2d::BorderLine(rTLBR.Secn(), (pForceColor ? *pForceColor : rTLBR.GetColorSecn()).getBColor()),
+                    rBLTR.UseGapColor(),
+                    rBLTR.Type(),
+                    rBLTR.PatternScale()));
+        }
     }
 }
 }
diff --git a/svx/source/table/viewcontactoftableobj.cxx b/svx/source/table/viewcontactoftableobj.cxx
index 27409ce2ddee..5ec9b6c6da99 100644
--- a/svx/source/table/viewcontactoftableobj.cxx
+++ b/svx/source/table/viewcontactoftableobj.cxx
@@ -295,24 +295,31 @@ namespace drawinglayer
                 {
                     const double fExtendIS(getExtend(getTopLine(), maTopFromLLine));
                     const double fExtendIE(getExtend(getBottomLine(), maBottomFromLLine));
-                    const double fExtendOS(getExtend(maTopFromLLine, getTopLine()));
-                    const double fExtendOE(getExtend(maBottomFromLLine, getBottomLine()));
-
-                    rContainer.push_back(new BorderLinePrimitive2D(
-                        aStart,
-                        aEnd,
-                        getChangedValue(getLeftLine().GetOutWidth(), true/*InTwips*/),
-                        getChangedValue(getLeftLine().GetDistance(), true/*InTwips*/),
-                        getChangedValue(getLeftLine().GetInWidth(), true/*InTwips*/),
-                        fExtendIS * fTwipsToMM,
-                        fExtendIE * fTwipsToMM,
-                        fExtendOS * fTwipsToMM,
-                        fExtendOE * fTwipsToMM,
-                        getLeftLine().GetColorOut().getBColor(),
-                        getLeftLine().GetColorIn().getBColor(),
-                        getLeftLine().GetColorGap().getBColor(),
-                        getLeftLine().HasGapColor(),
-                        getLeftLine().GetBorderLineStyle()));
+
+                    if (basegfx::fTools::equalZero(getLeftLine().GetInWidth()))
+                    {
+                        rContainer.push_back(
+                            new BorderLinePrimitive2D(
+                                aStart,
+                                aEnd,
+                                BorderLine(getChangedValue(getLeftLine().GetOutWidth(), true/*InTwips*/), getLeftLine().GetColorOut().getBColor(), fExtendIS * fTwipsToMM, fExtendIE * fTwipsToMM),
+                                getLeftLine().GetBorderLineStyle()));
+                    }
+                    else
+                    {
+                        const double fExtendOS(getExtend(maTopFromLLine, getTopLine()));
+                        const double fExtendOE(getExtend(maBottomFromLLine, getBottomLine()));
+
+                        rContainer.push_back(
+                            new BorderLinePrimitive2D(
+                                aStart,
+                                aEnd,
+                                BorderLine(getChangedValue(getLeftLine().GetOutWidth(), true/*InTwips*/), getLeftLine().GetColorOut().getBColor(), fExtendIS * fTwipsToMM, fExtendIE * fTwipsToMM),
+                                BorderLine(getChangedValue(getLeftLine().GetDistance(), true/*InTwips*/), getLeftLine().GetColorGap().getBColor()),
+                                BorderLine(getChangedValue(getLeftLine().GetInWidth(), true/*InTwips*/), getLeftLine().GetColorIn().getBColor(), fExtendOS * fTwipsToMM, fExtendOE * fTwipsToMM),
+                                getLeftLine().HasGapColor(),
+                                getLeftLine().GetBorderLineStyle()));
+                    }
                 }
             }
 
@@ -326,24 +333,31 @@ namespace drawinglayer
                 {
                     const double fExtendIS(getExtend(getLeftLine(), maLeftFromBLine ));
                     const double fExtendIE(getExtend(getRightLine(), maRightFromBLine));
-                    const double fExtendOS(getExtend(maLeftFromBLine, getLeftLine()));
-                    const double fExtendOE(getExtend(maRightFromBLine, getRightLine()));
-
-                    rContainer.push_back(new BorderLinePrimitive2D(
-                        aStart,
-                        aEnd,
-                        getChangedValue(getBottomLine().GetOutWidth(), true/*InTwips*/),
-                        getChangedValue(getBottomLine().GetDistance(), true/*InTwips*/),
-                        getChangedValue(getBottomLine().GetInWidth(), true/*InTwips*/),
-                        fExtendIS * fTwipsToMM,
-                        fExtendIE * fTwipsToMM,
-                        fExtendOS * fTwipsToMM,
-                        fExtendOE * fTwipsToMM,
-                        getBottomLine().GetColorOut(false).getBColor(),
-                        getBottomLine().GetColorIn(false).getBColor(),
-                        getBottomLine().GetColorGap().getBColor(),
-                        getBottomLine().HasGapColor(),
-                        getBottomLine().GetBorderLineStyle()));
+
+                    if (basegfx::fTools::equalZero(getBottomLine().GetInWidth()))
+                    {
+                        rContainer.push_back(
+                            new BorderLinePrimitive2D(
+                                aStart,
+                                aEnd,
+                                BorderLine(getChangedValue(getBottomLine().GetOutWidth(), true/*InTwips*/), getBottomLine().GetColorOut(false).getBColor(), fExtendIS * fTwipsToMM, fExtendIE * fTwipsToMM),
+                                getBottomLine().GetBorderLineStyle()));
+                    }
+                    else
+                    {
+                        const double fExtendOS(getExtend(maLeftFromBLine, getLeftLine()));
+                        const double fExtendOE(getExtend(maRightFromBLine, getRightLine()));
+
+                        rContainer.push_back(
+                            new BorderLinePrimitive2D(
+                                aStart,
+                                aEnd,
+                                BorderLine(getChangedValue(getBottomLine().GetOutWidth(), true/*InTwips*/), getBottomLine().GetColorOut(false).getBColor(), fExtendIS * fTwipsToMM, fExtendIE * fTwipsToMM),
+                                BorderLine(getChangedValue(getBottomLine().GetDistance(), true/*InTwips*/), getBottomLine().GetColorGap().getBColor()),
+                                BorderLine(getChangedValue(getBottomLine().GetInWidth(), true/*InTwips*/), getBottomLine().GetColorIn(false).getBColor(), fExtendOS * fTwipsToMM, fExtendOE * fTwipsToMM),
+                                getBottomLine().HasGapColor(),
+                                getBottomLine().GetBorderLineStyle()));
+                    }
                 }
             }
 
@@ -355,26 +369,33 @@ namespace drawinglayer
 
                 if(!aStart.equal(aEnd))
                 {
-                    const double fExtendIS(getExtend(getTopLine(), maTopFromRLine));
-                    const double fExtendIE(getExtend(getBottomLine(), maBottomFromRLine));
                     const double fExtendOS(getExtend(maTopFromRLine, getTopLine()));
                     const double fExtendOE(getExtend(maBottomFromRLine, getBottomLine()));
 
-                    rContainer.push_back(new BorderLinePrimitive2D(
-                        aStart,
-                        aEnd,
-                        getChangedValue(getRightLine().GetOutWidth(), true/*InTwips*/),
-                        getChangedValue(getRightLine().GetDistance(), true/*InTwips*/),
-                        getChangedValue(getRightLine().GetInWidth(), true/*InTwips*/),
-                        fExtendOS * fTwipsToMM,
-                        fExtendOE * fTwipsToMM,
-                        fExtendIS * fTwipsToMM,
-                        fExtendIE * fTwipsToMM,
-                        getRightLine().GetColorOut().getBColor(),
-                        getRightLine().GetColorIn().getBColor(),
-                        getRightLine().GetColorGap().getBColor(),
-                        getRightLine().HasGapColor(),
-                        getRightLine().GetBorderLineStyle()));
+                    if (basegfx::fTools::equalZero(getRightLine().GetInWidth()))
+                    {
+                        rContainer.push_back(
+                            new BorderLinePrimitive2D(
+                                aStart,
+                                aEnd,
+                                BorderLine(getChangedValue(getRightLine().GetOutWidth(), true/*InTwips*/), getRightLine().GetColorOut().getBColor(), fExtendOS * fTwipsToMM, fExtendOE * fTwipsToMM),
+                                getRightLine().GetBorderLineStyle()));
+                    }
+                    else
+                    {
+                        const double fExtendIS(getExtend(getTopLine(), maTopFromRLine));
+                        const double fExtendIE(getExtend(getBottomLine(), maBottomFromRLine));
+
+                        rContainer.push_back(
+                            new BorderLinePrimitive2D(
+                                aStart,
+                                aEnd,
+                                BorderLine(getChangedValue(getRightLine().GetOutWidth(), true/*InTwips*/), getRightLine().GetColorOut().getBColor(), fExtendOS * fTwipsToMM, fExtendOE * fTwipsToMM),
+                                BorderLine(getChangedValue(getRightLine().GetDistance(), true/*InTwips*/), getRightLine().GetColorGap().getBColor()),
+                                BorderLine(getChangedValue(getRightLine().GetInWidth(), true/*InTwips*/), getRightLine().GetColorIn().getBColor(), fExtendIS * fTwipsToMM, fExtendIE * fTwipsToMM),
+                                getRightLine().HasGapColor(),
+                                getRightLine().GetBorderLineStyle()));
+                    }
                 }
             }
 
@@ -391,26 +412,33 @@ namespace drawinglayer
 
                 if(!aStart.equal(aEnd))
                 {
-                    const double fExtendIS(getExtend(getLeftLine(), maLeftFromTLine));
-                    const double fExtendIE(getExtend(getRightLine(), maRightFromTLine));
                     const double fExtendOS(getExtend(maLeftFromTLine, getLeftLine()));
                     const double fExtendOE(getExtend(maRightFromTLine, getRightLine()));
 
-                    rContainer.push_back(new BorderLinePrimitive2D(
-                        aStart,
-                        aEnd,
-                        getChangedValue(getTopLine().GetOutWidth(), true/*InTwips*/),
-                        getChangedValue(getTopLine().GetDistance(), true/*InTwips*/),
-                        getChangedValue(getTopLine().GetInWidth(), true/*InTwips*/),
-                        fExtendOS * fTwipsToMM,
-                        fExtendOE * fTwipsToMM,
-                        fExtendIS * fTwipsToMM,
-                        fExtendIE * fTwipsToMM,
-                        getTopLine().GetColorOut(false).getBColor(),
-                        getTopLine().GetColorIn(false).getBColor(),
-                        getTopLine().GetColorGap().getBColor(),
-                        getTopLine().HasGapColor(),
-                        getTopLine().GetBorderLineStyle()));
+                    if (basegfx::fTools::equalZero(getTopLine().GetInWidth()))
+                    {
+                        rContainer.push_back(
+                            new BorderLinePrimitive2D(
+                                aStart,
+                                aEnd,
+                                BorderLine(getChangedValue(getTopLine().GetOutWidth(), true/*InTwips*/), getTopLine().GetColorOut(false).getBColor(), fExtendOS * fTwipsToMM, fExtendOE * fTwipsToMM),
+                                getTopLine().GetBorderLineStyle()));
+                    }
+                    else
+                    {
+                        const double fExtendIS(getExtend(getLeftLine(), maLeftFromTLine));
+                        const double fExtendIE(getExtend(getRightLine(), maRightFromTLine));
+
+                        rContainer.push_back(
+                            new BorderLinePrimitive2D(
+                                aStart,
+                                aEnd,
+                                BorderLine(getChangedValue(getTopLine().GetOutWidth(), true/*InTwips*/), getTopLine().GetColorOut(false).getBColor(), fExtendOS * fTwipsToMM, fExtendOE * fTwipsToMM),
+                                BorderLine(getChangedValue(getTopLine().GetDistance(), true/*InTwips*/), getTopLine().GetColorGap().getBColor()),
+                                BorderLine(getChangedValue(getTopLine().GetInWidth(), true/*InTwips*/), getTopLine().GetColorIn(false).getBColor(), fExtendIS * fTwipsToMM, fExtendIE * fTwipsToMM),
+                                getTopLine().HasGapColor(),
+                                getTopLine().GetBorderLineStyle()));
+                    }
                 }
             }
         }
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index cbb9ed9adc28..20c362b0f8e4 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -110,6 +110,7 @@
 using namespace ::editeng;
 using namespace ::com::sun::star;
 using ::drawinglayer::primitive2d::BorderLinePrimitive2D;
+using ::drawinglayer::primitive2d::BorderLine;
 using std::pair;
 using std::make_pair;
 
@@ -512,22 +513,38 @@ static sal_uInt8 lcl_TryMergeLines(
 **/
 static rtl::Reference<BorderLinePrimitive2D>
 lcl_MergeBorderLines(
-    BorderLinePrimitive2D const& rLine, BorderLinePrimitive2D const& rOther,
-    basegfx::B2DPoint const& rStart, basegfx::B2DPoint const& rEnd)
-{
-    return new BorderLinePrimitive2D(rStart, rEnd,
-                rLine.getLeftWidth(),
-                rLine.getDistance(),
-                rLine.getRightWidth(),
-                rLine.getExtendLeftStart(),
-                rOther.getExtendLeftEnd(),
-                rLine.getExtendRightStart(),
-                rOther.getExtendRightEnd(),
-                rLine.getRGBColorLeft(),
-                rLine.getRGBColorGap(),
-                rLine.getRGBColorRight(),
-                rLine.hasGapColor(),
-                rLine.getStyle());
+    BorderLinePrimitive2D const& rLine,
+    BorderLinePrimitive2D const& rOther,
+    basegfx::B2DPoint const& rStart,
+    basegfx::B2DPoint const& rEnd)
+{
+    const BorderLine& rLineLeft = rLine.getBorderLines()[0];
+    const BorderLine& rOtherLeft(rOther.getBorderLines()[0]);
+
+    if (1 == rLine.getBorderLines().size())
+    {
+        return new BorderLinePrimitive2D(
+            rStart,
+            rEnd,
+            BorderLine(rLineLeft.getWidth(), rLineLeft.getRGBColor(), rLineLeft.getExtendStart(), rOtherLeft.getExtendEnd()),
+            rLine.getStyle());
+    }
+    else
+    {
+        const BorderLine& rLineGap(rLine.getBorderLines()[1]);
+        // const BorderLine& rOtherGap(rOther.getBorderLines()[1]);
+        const BorderLine& rLineRight(rLine.getBorderLines()[2]);
+        const BorderLine& rOtherRight(rOther.getBorderLines()[2]);
+
+        return new BorderLinePrimitive2D(
+            rStart,
+            rEnd,
+            BorderLine(rLineLeft.getWidth(), rLineLeft.getRGBColor(), rLineLeft.getExtendStart(), rOtherLeft.getExtendEnd()),
+            BorderLine(rLineGap.getWidth(), rLineGap.getRGBColor()),
+            BorderLine(rLineRight.getWidth(), rLineRight.getRGBColor(), rLineRight.getExtendStart(), rOtherRight.getExtendEnd()),
+            rLine.hasGapColor(),
+            rLine.getStyle());
+    }
 }
 
 /**
@@ -547,21 +564,51 @@ lcl_TryMergeBorderLine(BorderLinePrimitive2D const& rThis,
     assert(rThis.getEnd().getY() >= rThis.getStart().getY());
     assert(rOther.getEnd().getX() >= rOther.getStart().getX());
     assert(rOther.getEnd().getY() >= rOther.getStart().getY());
+    const bool bSameEdgeNumber(rThis.getBorderLines().size() == rOther.getBorderLines().size());
+
+    if (!bSameEdgeNumber)
+    {
+        return nullptr;
+    }
+
     double thisHeight = rThis.getEnd().getY() - rThis.getStart().getY();
     double thisWidth  = rThis.getEnd().getX() - rThis.getStart().getX();
     double otherHeight = rOther.getEnd().getY() -  rOther.getStart().getY();
     double otherWidth  = rOther.getEnd().getX() -  rOther.getStart().getX();
+
     // check for same orientation, same line width, same style and matching colors
-    if (    ((thisHeight > thisWidth) == (otherHeight > otherWidth))
-        &&  (rtl::math::approxEqual(rThis.getLeftWidth(),  rOther.getLeftWidth()))
-        &&  (rtl::math::approxEqual(rThis.getDistance(),   rOther.getDistance()))
-        &&  (rtl::math::approxEqual(rThis.getRightWidth(), rOther.getRightWidth()))
-        &&  (rThis.getStyle()         == rOther.getStyle())
-        &&  (rThis.getRGBColorLeft()  == rOther.getRGBColorLeft())
-        &&  (rThis.getRGBColorRight() == rOther.getRGBColorRight())
-        &&  (rThis.hasGapColor()      == rOther.hasGapColor())
-        &&  (!rThis.hasGapColor() ||
-             (rThis.getRGBColorGap()  == rOther.getRGBColorGap())))
+    bool bSameStuff(false);
+    const BorderLine& rThisLeft(rThis.getBorderLines()[0]);
+    const BorderLine& rOtherLeft(rOther.getBorderLines()[0]);
+
+    if (1 == rThis.getBorderLines().size())
+    {
+        bSameStuff = ((thisHeight > thisWidth) == (otherHeight > otherWidth))
+            && (rtl::math::approxEqual(rThisLeft.getWidth(), rOtherLeft.getWidth()))
+            && (rThis.getStyle() == rOther.getStyle())
+            && (rThisLeft.getRGBColor() == rOtherLeft.getRGBColor());
+    }
+    else
+    {
+        const BorderLine& rThisGap(rThis.getBorderLines()[1]);
+        const BorderLine& rOtherGap(rOther.getBorderLines()[1]);
+        const BorderLine& rThisRight(rThis.getBorderLines()[2]);
+        const BorderLine& rOtherRight(rOther.getBorderLines()[2]);
+
+        bSameStuff = ((thisHeight > thisWidth) == (otherHeight > otherWidth))
+            && (rtl::math::approxEqual(rThisLeft.getWidth(), rOtherLeft.getWidth()))
+            && (rtl::math::approxEqual(rThisGap.getWidth(), rOtherGap.getWidth()))
+            && (rtl::math::approxEqual(rThisRight.getWidth(), rOtherRight.getWidth()))
+            && (rThis.getStyle() == rOther.getStyle())
+            && (rThisLeft.getRGBColor() == rOtherLeft.getRGBColor())
+            && (rThisRight.getRGBColor() == rOtherRight.getRGBColor())
+            && (rThis.hasGapColor() == rOther.hasGapColor())
+            && (!rThis.hasGapColor() ||
+            (rThisGap.getRGBColor() == rOtherGap.getRGBColor()));
+    }
+
+
+    if (bSameStuff)
     {
         int nRet = 0;
         if (thisHeight > thisWidth) // vertical line
@@ -4923,14 +4970,28 @@ static void lcl_MakeBorderLine(SwRect const& rRect,
     Color const aLeftColor = rBorder.GetColorOut(isLeftOrTopBorder);
     Color const aRightColor = rBorder.GetColorIn(isLeftOrTopBorder);
 
-    rtl::Reference<BorderLinePrimitive2D> const xLine =
-        new BorderLinePrimitive2D(
-            aStart, aEnd, nLeftWidth, rBorder.GetDistance(), nRightWidth,
-            nExtentLeftStart, nExtentLeftEnd,
-            nExtentRightStart, nExtentRightEnd,
-            aLeftColor.getBColor(), aRightColor.getBColor(),
-            rBorder.GetColorGap().getBColor(), rBorder.HasGapColor(),
-            rBorder.GetBorderLineStyle() );
+    rtl::Reference<BorderLinePrimitive2D> xLine;
+
+    if (basegfx::fTools::equalZero(nRightWidth))
+    {
+        xLine = new BorderLinePrimitive2D(
+            aStart,
+            aEnd,
+            BorderLine(nLeftWidth, aLeftColor.getBColor(), nExtentLeftStart, nExtentLeftEnd),
+            rBorder.GetBorderLineStyle());
+    }
+    else
+    {
+        xLine = new BorderLinePrimitive2D(
+            aStart,
+            aEnd,
+            BorderLine(nLeftWidth, aLeftColor.getBColor(), nExtentLeftStart, nExtentLeftEnd),
+            BorderLine(rBorder.GetDistance(), rBorder.GetColorGap().getBColor()),
+            BorderLine(nRightWidth, aRightColor.getBColor(), nExtentRightStart, nExtentRightEnd),
+            rBorder.HasGapColor(),
+            rBorder.GetBorderLineStyle());
+    }
+
     properties.pBLines->AddBorderLine(xLine.get(), properties);
 }
 
commit cc0a5cbf8ae968977db50b62d42f9e525c9f91ec
Author: Armin Le Grand <Armin.Le.Grand at cib.de>
Date:   Fri Jul 21 17:34:40 2017 +0200

    borderline: first versionj with line end adaptions
    
    Added usage of defined extensions to the BorderLinePrimitive,
    also added a first version to detect all cuts with adjacent
    borders and produce the correct extensions, for single and
    double lines. Not completely happy with it, but a first
    version
    
    Change-Id: I4b12a6cc0a70278bd5c506e9b3b2c5c126930dad

diff --git a/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx b/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx
index 84ea9fff10ca..a9822d6bcd06 100644
--- a/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx
@@ -144,8 +144,8 @@ namespace drawinglayer
                     // single line, only inside values used, no vertical offsets
                     addPolygonStrokePrimitive2D(
                         rContainer,
-                        getStart(),
-                        getEnd(),
+                        getStart() - (aVector * getExtendLeftStart()),
+                        getEnd() + (aVector * getExtendLeftEnd()),
                         getRGBColorLeft(),
                         getLeftWidth(),
                         getStyle(),
diff --git a/svx/source/dialog/framelink.cxx b/svx/source/dialog/framelink.cxx
index c193285b1a25..de93c9372d88 100644
--- a/svx/source/dialog/framelink.cxx
+++ b/svx/source/dialog/framelink.cxx
@@ -345,6 +345,153 @@ double lcl_GetExtent(
     return nCut;
 }
 
+void getOffsetsFromStyle(const Style& rStyle, std::vector< double >& offsets)
+{
+    if (rStyle.Prim())
+    {
+        if (rStyle.Dist() && rStyle.Secn())
+        {
+            // both lines used (or all three), push four values, from outer to inner
+            switch (rStyle.GetRefMode())
+            {
+            case RefMode::Centered:
+            {
+                const double fHalfFullWidth(rStyle.GetWidth() * 0.5);
+                offsets.push_back(-fHalfFullWidth);
+                offsets.push_back(rStyle.Prim() - fHalfFullWidth);
+                offsets.push_back((rStyle.Prim() + rStyle.Dist()) - fHalfFullWidth);
+                offsets.push_back(fHalfFullWidth);
+                break;
+            }
+            case RefMode::Begin:
+                offsets.push_back(0.0);
+                offsets.push_back(rStyle.Prim());
+                offsets.push_back(rStyle.Prim() + rStyle.Dist());
+                offsets.push_back(rStyle.GetWidth());
+                break;
+            default: // case RefMode::End:
+            {
+                const double fFullWidth(rStyle.GetWidth());
+                offsets.push_back(-fFullWidth);
+                offsets.push_back(rStyle.Prim() - fFullWidth);
+                offsets.push_back((rStyle.Prim() + rStyle.Dist()) - fFullWidth);
+                offsets.push_back(0.0);
+                break;
+            }
+            }
+        }
+        else
+        {
+            // one line used, push two values, from outer to inner
+            switch (rStyle.GetRefMode())
+            {
+            case RefMode::Centered:
+                offsets.push_back(rStyle.Prim() * -0.5);
+                offsets.push_back(rStyle.Prim() * 0.5);
+                break;
+            case RefMode::Begin:
+                offsets.push_back(0.0);
+                offsets.push_back(rStyle.Prim());
+                break;
+            default: // case RefMode::End:
+                offsets.push_back(-rStyle.Prim());
+                offsets.push_back(0.0);
+                break;
+            }
+        }
+    }
+}
+
+void compareToStyle(
+    const basegfx::B2DPoint& rOrigin,
+    const basegfx::B2DVector& rOtherVector,
+    const basegfx::B2DVector& rOtherUnifiedPerpendicular,
+    const std::vector< double >& rOtherOffsets,
+    const Style& rStyle,
+    const basegfx::B2DVector& rMyVector,
+    std::vector< std::vector< double >>& rOtherCuts)
+{
+    if (rStyle.Prim())
+    {
+        std::vector< double > myOffsets;
+
+        // get offsets from outer to inner (two or four, depending on style)
+        getOffsetsFromStyle(rStyle, myOffsets);
+
+        if (!myOffsets.empty())
+        {
+            const basegfx::B2DVector aMyUnifiedPerpendicular(basegfx::getNormalizedPerpendicular(rMyVector));
+
+            for (size_t a(0); a < rOtherOffsets.size(); a++)
+            {

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list