diff options
author | Armin Le Grand <Armin.Le.Grand@cib.de> | 2017-07-26 13:19:50 +0200 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@cib.de> | 2017-07-28 17:51:57 +0200 |
commit | 5e061435a74a5461e6b9fa5a48ce44d266a3d957 (patch) | |
tree | 8ba859b4a61f7763d6efa42083518f63546833bd /svx | |
parent | bc47d7138a8d8dd239831a38bb2eca9db13addb6 (diff) |
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
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/dialog/framelink.cxx | 209 | ||||
-rw-r--r-- | svx/source/table/viewcontactoftableobj.cxx | 168 |
2 files changed, 204 insertions, 173 deletions
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())); + } } } } |