include/svx/framelink.hxx | 82 ++++++- svx/source/dialog/framelink.cxx | 315 +++++++++++++---------------- svx/source/dialog/framelinkarray.cxx | 78 ++++--- svx/source/table/viewcontactoftableobj.cxx | 20 + sw/source/core/layout/paintfrm.cxx | 46 ++-- 5 files changed, 301 insertions(+), 240 deletions(-)
New commits: commit b86a3aa00dbaf94398cccfe3af312f123edc6093 Author: Armin Le Grand <[email protected]> Date: Mon Sep 18 12:31:45 2017 +0200 borderline: restuctured used classes Restructuring for more efficcient usage of helper values, some obstacles removed with that Change-Id: Ia8c4b2d4c423db9500cda507107d87913b79e23c Reviewed-on: https://gerrit.libreoffice.org/42409 Reviewed-by: Armin Le Grand <[email protected]> Tested-by: Armin Le Grand <[email protected]> diff --git a/include/svx/framelink.hxx b/include/svx/framelink.hxx index 414f23aaaca7..771bc1e6dc7f 100644 --- a/include/svx/framelink.hxx +++ b/include/svx/framelink.hxx @@ -214,29 +214,87 @@ public: inline bool operator>( const Style& rL, const Style& rR ) { return rR.operator<(rL); } // Drawing functions - class SAL_WARN_UNUSED SVX_DLLPUBLIC StyleVectorCombination { private: - const Style& mrStyle; - const basegfx::B2DVector maB2DVector; - const bool mbMirrored; + struct OffsetAndHalfWidthAndColor + { + double mfOffset; + double mfHalfWidth; + Color maColor; + + OffsetAndHalfWidthAndColor(double offset, double halfWidth, Color color) : + mfOffset(offset), + mfHalfWidth(halfWidth), + maColor(color) + {} + }; + double mfRefModeOffset; + basegfx::B2DVector maB2DVector; + std::vector< OffsetAndHalfWidthAndColor > maOffsets; public: - StyleVectorCombination(const Style& rStyle, const basegfx::B2DVector& rB2DVector, bool bMirrored) : - mrStyle(rStyle), - maB2DVector(rB2DVector), - mbMirrored(bMirrored) + StyleVectorCombination( + const Style& rStyle, + const basegfx::B2DVector& rB2DVector, + bool bMirrored, + const Color* pForceColor = nullptr); + + double getRefModeOffset() const { return mfRefModeOffset; } + const basegfx::B2DVector& getB2DVector() const { return maB2DVector; } + + bool empty() const { return maOffsets.empty(); } + size_t size() const { return maOffsets.size(); } + + void getColorAndOffsetAndHalfWidth(size_t nIndex, Color& rColor, double& rfOffset, double& rfHalfWidth) const { + if(nIndex >= maOffsets.size()) + return; + const OffsetAndHalfWidthAndColor& rCandidate(maOffsets[nIndex]); + rfOffset = rCandidate.mfOffset; + rfHalfWidth = rCandidate.mfHalfWidth; + rColor = rCandidate.maColor; } - const Style& getStyle() const { return mrStyle; } - const basegfx::B2DVector& getB2DVector() const { return maB2DVector; } - bool isMirrored() const { return mbMirrored; } + bool operator<(const StyleVectorCombination& rOther) const + { + return getB2DVector().cross(rOther.getB2DVector()) < 0.0; + } }; -typedef std::vector< StyleVectorCombination > StyleVectorTable; +class SAL_WARN_UNUSED SVX_DLLPUBLIC StyleVectorTable +{ +private: + std::vector< StyleVectorCombination > maEntries; + +public: + StyleVectorTable() + : maEntries() + { + } + + void add( + const Style& rStyle, + const basegfx::B2DVector& rMyVector, + const basegfx::B2DVector& rOtherVector, + bool bMirrored) + { + if(rStyle.IsUsed() && !basegfx::areParallel(rMyVector, rOtherVector)) + { + maEntries.emplace_back(rStyle, rOtherVector, bMirrored); + } + } + + void sort() + { + std::sort(maEntries.begin(), maEntries.end()); + } + + bool empty() const { return maEntries.empty(); } + size_t size() const { return maEntries.size(); } + const std::vector< StyleVectorCombination >& getEntries() const{ return maEntries; } +}; SVX_DLLPUBLIC void CreateBorderPrimitives( drawinglayer::primitive2d::Primitive2DContainer& rTarget, /// target for created primitives diff --git a/svx/source/dialog/framelink.cxx b/svx/source/dialog/framelink.cxx index e205560df33c..2c58e3c28528 100644 --- a/svx/source/dialog/framelink.cxx +++ b/svx/source/dialog/framelink.cxx @@ -338,19 +338,6 @@ bool Style::operator<( const Style& rOther) const } // Drawing functions -struct OffsetAndHalfWidthAndColor -{ - double mfOffset; - double mfHalfWidth; - Color maColor; - - OffsetAndHalfWidthAndColor(double offset, double halfWidth, Color color) : - mfOffset(offset), - mfHalfWidth(halfWidth), - maColor(color) - {} -}; - struct CutSet { double mfOLML; @@ -367,108 +354,6 @@ struct ExtendSet ExtendSet() : mfExtLeft(0.0), mfExtRight(0.0) {} }; -double getOffsetAndHalfWidthAndColorFromStyle( - const Style& rStyle, - const Color* pForceColor, - bool bMirrored, - std::vector< OffsetAndHalfWidthAndColor >& offsets) -{ - // do not forget RefMode offset, primitive is free of it - double fRefModeOffset(0.0); - - if (rStyle.IsUsed()) - { - RefMode aRefMode(rStyle.GetRefMode()); - Color aPrim(rStyle.GetColorPrim()); - Color aSecn(rStyle.GetColorSecn()); - double fPrim(rStyle.Prim()); - double fSecn(rStyle.Secn()); - const bool bSecnUsed(0.0 != fSecn); - - if(bMirrored) - { - switch(aRefMode) - { - case RefMode::Begin: aRefMode = RefMode::End; break; - case RefMode::End: aRefMode = RefMode::Begin; break; - default: break; - } - - if(bSecnUsed) - { - std::swap(aPrim, aSecn); - std::swap(fPrim, fSecn); - } - } - - if (RefMode::Centered != aRefMode) - { - const double fHalfWidth(rStyle.GetWidth() * 0.5); - - if (RefMode::Begin == aRefMode) - { - // move aligned below vector - fRefModeOffset = fHalfWidth; - } - else if (RefMode::End == aRefMode) - { - // move aligned above vector - fRefModeOffset = -fHalfWidth; - } - } - - if (bSecnUsed) - { - // both or all three lines used - const bool bPrimTransparent(0xff == rStyle.GetColorPrim().GetTransparency()); - const bool bDistTransparent(!rStyle.UseGapColor() || 0xff == rStyle.GetColorGap().GetTransparency()); - const bool bSecnTransparent(0xff == aSecn.GetTransparency()); - - if(!bPrimTransparent || !bDistTransparent || !bSecnTransparent) - { - const double a(fRefModeOffset - (rStyle.GetWidth() * 0.5)); - const double b(a + fPrim); - const double c(b + rStyle.Dist()); - const double d(c + fSecn); - - offsets.push_back( - OffsetAndHalfWidthAndColor( - (a + b) * 0.5, - fPrim * 0.5, - nullptr != pForceColor ? *pForceColor : aPrim)); - - offsets.push_back( - OffsetAndHalfWidthAndColor( - (b + c) * 0.5, - rStyle.Dist() * 0.5, - rStyle.UseGapColor() - ? (nullptr != pForceColor ? *pForceColor : rStyle.GetColorGap()) - : Color(COL_TRANSPARENT))); - - offsets.push_back( - OffsetAndHalfWidthAndColor( - (c + d) * 0.5, - fSecn * 0.5, - nullptr != pForceColor ? *pForceColor : aSecn)); - } - } - else - { - // one line used, push two values, from outer to inner - if(0xff != rStyle.GetColorPrim().GetTransparency()) - { - offsets.push_back( - OffsetAndHalfWidthAndColor( - fRefModeOffset, - fPrim * 0.5, - nullptr != pForceColor ? *pForceColor : aPrim)); - } - } - } - - return fRefModeOffset; -} - void getCutSet( CutSet& rCutSet, const basegfx::B2DPoint& rLeft, @@ -521,12 +406,12 @@ void getAllCutSets( bool bUpper, bool bLower) { - for(const auto& rStyleVectorCombination : rStyleVectorTable) + for(const auto& rCombination : rStyleVectorTable.getEntries()) { if(bUpper || bLower) { // use only upper or lower vectors compared to rX - const double fCross(rX.cross(rStyleVectorCombination.getB2DVector())); + const double fCross(rX.cross(rCombination.getB2DVector())); if(bUpper && fCross > 0.0) { @@ -541,22 +426,25 @@ void getAllCutSets( } } - std::vector< OffsetAndHalfWidthAndColor > otherOffsets; - getOffsetAndHalfWidthAndColorFromStyle(rStyleVectorCombination.getStyle(), nullptr, rStyleVectorCombination.isMirrored(), otherOffsets); - - if(!otherOffsets.empty()) + if(!rCombination.empty()) { - const basegfx::B2DVector aOtherPerpend(basegfx::getNormalizedPerpendicular(rStyleVectorCombination.getB2DVector())); + const basegfx::B2DVector aOtherPerpend(basegfx::getNormalizedPerpendicular(rCombination.getB2DVector())); + const size_t nOffsets(rCombination.size()); - for(const auto& rOtherOffset : otherOffsets) + for(size_t a(0); a < nOffsets; a++) { - if(0xff != rOtherOffset.maColor.GetTransparency()) + Color aOtherColor; + double fOtherOffset(0.0); + double fOtherHalfWidth(0.0); + rCombination.getColorAndOffsetAndHalfWidth(a, aOtherColor, fOtherOffset, fOtherHalfWidth); + + if(0xff != aOtherColor.GetTransparency()) { - const basegfx::B2DPoint aOtherLeft(rOrigin + (aOtherPerpend * (rOtherOffset.mfOffset - rOtherOffset.mfHalfWidth))); - const basegfx::B2DPoint aOtherRight(rOrigin + (aOtherPerpend * (rOtherOffset.mfOffset + rOtherOffset.mfHalfWidth))); + const basegfx::B2DPoint aOtherLeft(rOrigin + (aOtherPerpend * (fOtherOffset - fOtherHalfWidth))); + const basegfx::B2DPoint aOtherRight(rOrigin + (aOtherPerpend * (fOtherOffset + fOtherHalfWidth))); CutSet aCutSet; - getCutSet(aCutSet, rLeft, rRight, rX, aOtherLeft, aOtherRight, rStyleVectorCombination.getB2DVector()); + getCutSet(aCutSet, rLeft, rRight, rX, aOtherLeft, aOtherRight, rCombination.getB2DVector()); rCutSets.push_back(aCutSet); } } @@ -634,23 +522,25 @@ CutSet getMinMaxCutSet( void getExtends( std::vector<ExtendSet>& rExtendSet, // target Left/Right values to fill const basegfx::B2DPoint& rOrigin, // own vector start - const basegfx::B2DVector& rX, // own vector direction and length - const basegfx::B2DVector& rPerpendX, // normalized perpendicular to rX - const std::vector< OffsetAndHalfWidthAndColor >& rOffsets, // own vector derivations + const StyleVectorCombination& rCombination, // own vector and offstets for lines + const basegfx::B2DVector& rPerpendX, // normalized perpendicular to own vector const StyleVectorTable& rStyleVectorTable) // other vectors emerging in this point { - if(!rOffsets.empty() && rOffsets.size() == rExtendSet.size()) + if(!rCombination.empty() && rCombination.size() == rExtendSet.size()) { - const size_t nOffsets(rOffsets.size()); + const size_t nOffsets(rCombination.size()); for(size_t a(0); a < nOffsets; a++) { - const OffsetAndHalfWidthAndColor& rOffset(rOffsets[a]); + Color aMyColor; + double fMyOffset(0.0); + double fMyHalfWidth(0.0); + rCombination.getColorAndOffsetAndHalfWidth(a, aMyColor, fMyOffset, fMyHalfWidth); - if(0xff != rOffset.maColor.GetTransparency()) + if(0xff != aMyColor.GetTransparency()) { - const basegfx::B2DPoint aLeft(rOrigin + (rPerpendX * (rOffset.mfOffset - rOffset.mfHalfWidth))); - const basegfx::B2DPoint aRight(rOrigin + (rPerpendX * (rOffset.mfOffset + rOffset.mfHalfWidth))); + const basegfx::B2DPoint aLeft(rOrigin + (rPerpendX * (fMyOffset - fMyHalfWidth))); + const basegfx::B2DPoint aRight(rOrigin + (rPerpendX * (fMyOffset + fMyHalfWidth))); std::vector< CutSet > aCutSets; CutSet aResult; bool bResultSet(false); @@ -660,7 +550,7 @@ void getExtends( // single line: // - get all CutSets // - get minimum values as extension (biggest possible overlap) - getAllCutSets(aCutSets, rOrigin, aLeft, aRight, rX, rStyleVectorTable, false, false); + getAllCutSets(aCutSets, rOrigin, aLeft, aRight, rCombination.getB2DVector(), rStyleVectorTable, false, false); if(!aCutSets.empty()) { @@ -676,7 +566,7 @@ void getExtends( if(bUpper) { - getAllCutSets(aCutSets, rOrigin, aLeft, aRight, rX, rStyleVectorTable, true, false); + getAllCutSets(aCutSets, rOrigin, aLeft, aRight, rCombination.getB2DVector(), rStyleVectorTable, true, false); if(!aCutSets.empty()) { @@ -685,7 +575,7 @@ void getExtends( } else { - getAllCutSets(aCutSets, rOrigin, aLeft, aRight, rX, rStyleVectorTable, false, true); + getAllCutSets(aCutSets, rOrigin, aLeft, aRight, rCombination.getB2DVector(), rStyleVectorTable, false, true); if(!aCutSets.empty()) { @@ -696,7 +586,7 @@ void getExtends( } else if(bLower) { - getAllCutSets(aCutSets, rOrigin, aLeft, aRight, rX, rStyleVectorTable, false, true); + getAllCutSets(aCutSets, rOrigin, aLeft, aRight, rCombination.getB2DVector(), rStyleVectorTable, false, true); if(!aCutSets.empty()) { @@ -705,7 +595,7 @@ void getExtends( } else { - getAllCutSets(aCutSets, rOrigin, aLeft, aRight, rX, rStyleVectorTable, true, false); + getAllCutSets(aCutSets, rOrigin, aLeft, aRight, rCombination.getB2DVector(), rStyleVectorTable, true, false); if(!aCutSets.empty()) { @@ -716,7 +606,7 @@ void getExtends( } else // middle line { - getAllCutSets(aCutSets, rOrigin, aLeft, aRight, rX, rStyleVectorTable, false, false); + getAllCutSets(aCutSets, rOrigin, aLeft, aRight, rCombination.getB2DVector(), rStyleVectorTable, false, false); if(!aCutSets.empty()) { @@ -744,6 +634,106 @@ void getExtends( } } +StyleVectorCombination::StyleVectorCombination( + const Style& rStyle, + const basegfx::B2DVector& rB2DVector, + bool bMirrored, + const Color* pForceColor) +: mfRefModeOffset(0.0), + maB2DVector(rB2DVector), + maOffsets() +{ + if (rStyle.IsUsed()) + { + RefMode aRefMode(rStyle.GetRefMode()); + Color aPrim(rStyle.GetColorPrim()); + Color aSecn(rStyle.GetColorSecn()); + double fPrim(rStyle.Prim()); + double fSecn(rStyle.Secn()); + const bool bSecnUsed(0.0 != fSecn); + + if(bMirrored) + { + switch(aRefMode) + { + case RefMode::Begin: aRefMode = RefMode::End; break; + case RefMode::End: aRefMode = RefMode::Begin; break; + default: break; + } + + if(bSecnUsed) + { + std::swap(aPrim, aSecn); + std::swap(fPrim, fSecn); + } + } + + if (RefMode::Centered != aRefMode) + { + const double fHalfWidth(rStyle.GetWidth() * 0.5); + + if (RefMode::Begin == aRefMode) + { + // move aligned below vector + mfRefModeOffset = fHalfWidth; + } + else if (RefMode::End == aRefMode) + { + // move aligned above vector + mfRefModeOffset = -fHalfWidth; + } + } + + if (bSecnUsed) + { + // both or all three lines used + const bool bPrimTransparent(0xff == rStyle.GetColorPrim().GetTransparency()); + const bool bDistTransparent(!rStyle.UseGapColor() || 0xff == rStyle.GetColorGap().GetTransparency()); + const bool bSecnTransparent(0xff == aSecn.GetTransparency()); + + if(!bPrimTransparent || !bDistTransparent || !bSecnTransparent) + { + const double a(mfRefModeOffset - (rStyle.GetWidth() * 0.5)); + const double b(a + fPrim); + const double c(b + rStyle.Dist()); + const double d(c + fSecn); + + maOffsets.push_back( + OffsetAndHalfWidthAndColor( + (a + b) * 0.5, + fPrim * 0.5, + nullptr != pForceColor ? *pForceColor : aPrim)); + + maOffsets.push_back( + OffsetAndHalfWidthAndColor( + (b + c) * 0.5, + rStyle.Dist() * 0.5, + rStyle.UseGapColor() + ? (nullptr != pForceColor ? *pForceColor : rStyle.GetColorGap()) + : Color(COL_TRANSPARENT))); + + maOffsets.push_back( + OffsetAndHalfWidthAndColor( + (c + d) * 0.5, + fSecn * 0.5, + nullptr != pForceColor ? *pForceColor : aSecn)); + } + } + else + { + // one line used, push two values, from outer to inner + if(0xff != rStyle.GetColorPrim().GetTransparency()) + { + maOffsets.push_back( + OffsetAndHalfWidthAndColor( + mfRefModeOffset, + fPrim * 0.5, + nullptr != pForceColor ? *pForceColor : aPrim)); + } + } + } +} + void CreateBorderPrimitives( drawinglayer::primitive2d::Primitive2DContainer& rTarget, const basegfx::B2DPoint& rOrigin, @@ -754,41 +744,31 @@ void CreateBorderPrimitives( const Color* pForceColor) { // get offset color pairs for style, one per visible line - std::vector< OffsetAndHalfWidthAndColor > myOffsets; - const double fRefModeOffset(getOffsetAndHalfWidthAndColorFromStyle(rBorder, pForceColor, false, myOffsets)); - const size_t nOffsets(myOffsets.size()); + const StyleVectorCombination aCombination(rBorder, rX, false, pForceColor); - if(nOffsets) + if(!aCombination.empty()) { const basegfx::B2DVector aPerpendX(basegfx::getNormalizedPerpendicular(rX)); const bool bHasStartStyles(!rStartStyleVectorTable.empty()); const bool bHasEndStyles(!rEndStyleVectorTable.empty()); + const size_t nOffsets(aCombination.size()); std::vector<ExtendSet> aExtendSetStart(nOffsets); std::vector<ExtendSet> aExtendSetEnd(nOffsets); if(bHasStartStyles) { // create extends for line starts, use given point/vector and offsets - getExtends(aExtendSetStart, rOrigin, rX, aPerpendX, myOffsets, rStartStyleVectorTable); + getExtends(aExtendSetStart, rOrigin, aCombination, aPerpendX, rStartStyleVectorTable); } if(bHasEndStyles) { - // Create extends for line ends, use inverse point/vector and inverse offsets. - // Offsets need to be inverted for different width of lines. To invert, change - // order, but also sign of offset. Do this on a copy since myOffsets will be - // used below to create the primitives - std::vector< OffsetAndHalfWidthAndColor > myInverseOffsets(myOffsets); - std::reverse(myInverseOffsets.begin(), myInverseOffsets.end()); - - for(auto& offset : myInverseOffsets) - { - offset.mfOffset *= -1; - } + // Create extends for line ends, create inverse point/vector and inverse offsets. + const StyleVectorCombination aMirroredCombination(rBorder, -rX, true, pForceColor); - getExtends(aExtendSetEnd, rOrigin + rX, -rX, -aPerpendX, myInverseOffsets, rEndStyleVectorTable); + getExtends(aExtendSetEnd, rOrigin + rX, aMirroredCombination, -aPerpendX, rEndStyleVectorTable); - // also need to reverse the result to apply to the correct lines + // also need to inverse the result to apply to the correct lines std::reverse(aExtendSetEnd.begin(), aExtendSetEnd.end()); } @@ -797,23 +777,26 @@ void CreateBorderPrimitives( for(size_t a(0); a < nOffsets; a++) { - const OffsetAndHalfWidthAndColor& rOffset(myOffsets[a]); + Color aMyColor; + double fMyOffset(0.0); + double fMyHalfWidth(0.0); + aCombination.getColorAndOffsetAndHalfWidth(a, aMyColor, fMyOffset, fMyHalfWidth); const ExtendSet& rExtStart(aExtendSetStart[a]); const ExtendSet& rExtEnd(aExtendSetEnd[a]); - if(0xff == rOffset.maColor.GetTransparency()) + if(0xff == aMyColor.GetTransparency()) { aBorderlines.push_back( drawinglayer::primitive2d::BorderLine( - rOffset.mfHalfWidth * 2.0)); + fMyHalfWidth * 2.0)); } else { aBorderlines.push_back( drawinglayer::primitive2d::BorderLine( drawinglayer::attribute::LineAttribute( - rOffset.maColor.getBColor(), - rOffset.mfHalfWidth * 2.0), + aMyColor.getBColor(), + fMyHalfWidth * 2.0), fNegLength * rExtStart.mfExtLeft, fNegLength * rExtStart.mfExtRight, fNegLength * rExtEnd.mfExtRight, @@ -824,7 +807,7 @@ void CreateBorderPrimitives( static double fPatScFact(10.0); // 10.0 multiply, see old code const std::vector<double> aDashing(svtools::GetLineDashing(rBorder.Type(), rBorder.PatternScale() * fPatScFact)); const drawinglayer::attribute::StrokeAttribute aStrokeAttribute(aDashing); - const basegfx::B2DPoint aStart(rOrigin + (aPerpendX * fRefModeOffset)); + const basegfx::B2DPoint aStart(rOrigin + (aPerpendX * aCombination.getRefModeOffset())); rTarget.append( drawinglayer::primitive2d::Primitive2DReference( diff --git a/svx/source/dialog/framelinkarray.cxx b/svx/source/dialog/framelinkarray.cxx index 5a526145cd54..529b155fcf54 100644 --- a/svx/source/dialog/framelinkarray.cxx +++ b/svx/source/dialog/framelinkarray.cxx @@ -941,11 +941,12 @@ void HelperCreateHorizontalEntry( const Style& rStartFromBR(rArray.GetCellStyleTL( col, row )); StyleVectorTable aStart; - if(rStartFromTR.IsUsed()) aStart.push_back(StyleVectorCombination(rStartFromTR, rX - rY, false)); - if(rStartLFromT.IsUsed()) aStart.push_back(StyleVectorCombination(rStartLFromT, -rY, true)); - if(rStartLFromL.IsUsed()) aStart.push_back(StyleVectorCombination(rStartLFromL, -rX, true)); - if(rStartLFromB.IsUsed()) aStart.push_back(StyleVectorCombination(rStartLFromB, rY, false)); - if(rStartFromBR.IsUsed()) aStart.push_back(StyleVectorCombination(rStartFromBR, rX + rY, false)); + aStart.add(rStartFromTR, rX, rX - rY, false); + aStart.add(rStartLFromT, rX, -rY, true); + aStart.add(rStartLFromL, rX, -rX, true); + aStart.add(rStartLFromB, rX, rY, false); + aStart.add(rStartFromBR, rX, rX + rY, false); + aStart.sort(); // get involved styles at end const Style& rEndFromTL(rArray.GetCellStyleBR( col, row - 1 )); @@ -955,11 +956,12 @@ void HelperCreateHorizontalEntry( const Style& rEndFromBL(rArray.GetCellStyleTR( col, row )); StyleVectorTable aEnd; - if(rEndFromTL.IsUsed()) aEnd.push_back(StyleVectorCombination(rEndFromTL, -rX -rY, true)); - if(rEndRFromT.IsUsed()) aEnd.push_back(StyleVectorCombination(rEndRFromT, -rY, true)); - if(rEndRFromR.IsUsed()) aEnd.push_back(StyleVectorCombination(rEndRFromR, rX, false)); - if(rEndRFromB.IsUsed()) aEnd.push_back(StyleVectorCombination(rEndRFromB, rY, false)); - if(rEndFromBL.IsUsed()) aEnd.push_back(StyleVectorCombination(rEndFromBL, rY - rX, true)); + aEnd.add(rEndFromTL, -rX, -rX -rY, true); + aEnd.add(rEndRFromT, -rX, -rY, true); + aEnd.add(rEndRFromR, -rX, rX, false); + aEnd.add(rEndRFromB, -rX, rY, false); + aEnd.add(rEndFromBL, -rX, rY - rX, true); + aEnd.sort(); CreateBorderPrimitives( rSequence, @@ -986,11 +988,12 @@ void HelperCreateVerticalEntry( const Style& rStartFromBR(rArray.GetCellStyleTL( col, row )); StyleVectorTable aStart; - if(rStartFromBR.IsUsed()) aStart.push_back(StyleVectorCombination(rStartFromBR, rX + rY, false)); - if(rStartTFromR.IsUsed()) aStart.push_back(StyleVectorCombination(rStartTFromR, rX, false)); - if(rStartTFromT.IsUsed()) aStart.push_back(StyleVectorCombination(rStartTFromT, -rY, true)); - if(rStartTFromL.IsUsed()) aStart.push_back(StyleVectorCombination(rStartTFromL, -rX, true)); - if(rStartFromBL.IsUsed()) aStart.push_back(StyleVectorCombination(rStartFromBL, rY - rX, true)); + aStart.add(rStartFromBR, rY, rX + rY, false); + aStart.add(rStartTFromR, rY, rX, false); + aStart.add(rStartTFromT, rY, -rY, true); + aStart.add(rStartTFromL, rY, -rX, true); + aStart.add(rStartFromBL, rY, rY - rX, true); + aStart.sort(); // get involved styles at end const Style& rEndFromTL(rArray.GetCellStyleBR( col - 1, row )); @@ -1000,11 +1003,12 @@ void HelperCreateVerticalEntry( const Style& rEndFromTR(rArray.GetCellStyleBL( col, row )); StyleVectorTable aEnd; - if(rEndFromTR.IsUsed()) aEnd.push_back(StyleVectorCombination(rEndFromTR, rX - rY, false)); - if(rEndBFromR.IsUsed()) aEnd.push_back(StyleVectorCombination(rEndBFromR, rX, false)); - if(rEndBFromB.IsUsed()) aEnd.push_back(StyleVectorCombination(rEndBFromB, rY, false)); - if(rEndBFromL.IsUsed()) aEnd.push_back(StyleVectorCombination(rEndBFromL, -rX, true)); - if(rEndFromTL.IsUsed()) aEnd.push_back(StyleVectorCombination(rEndFromTL, -rX - rY, true)); + aEnd.add(rEndFromTR, -rY, rX - rY, false); + aEnd.add(rEndBFromR, -rY, rX, false); + aEnd.add(rEndBFromB, -rY, rY, false); + aEnd.add(rEndBFromL, -rY, -rX, true); + aEnd.add(rEndFromTL, -rY, -rX - rY, true); + aEnd.sort(); CreateBorderPrimitives( rSequence, @@ -1180,20 +1184,23 @@ drawinglayer::primitive2d::Primitive2DContainer Array::CreateB2DPrimitiveRange( if(rTLBR.IsUsed()) { /// top-left and bottom-right Style Tables - StyleVectorTable aStart; - StyleVectorTable aEnd; - /// Fill top-left Style Table const Style& rTLFromRight(GetCellStyleTop(_nFirstCol, _nFirstRow)); - if(rTLFromRight.IsUsed()) aStart.push_back(StyleVectorCombination(rTLFromRight, aX, false)); const Style& rTLFromBottom(GetCellStyleLeft(_nFirstCol, _nFirstRow)); - if(rTLFromBottom.IsUsed()) aStart.push_back(StyleVectorCombination(rTLFromBottom, aY, false)); + StyleVectorTable aStart; + + aStart.add(rTLFromRight, aX + aY, aX, false); + aStart.add(rTLFromBottom, aX + aY, aY, false); + aStart.sort(); /// Fill bottom-right Style Table const Style& rBRFromBottom(GetCellStyleRight(_nLastCol, _nLastRow)); - if(rBRFromBottom.IsUsed()) aEnd.push_back(StyleVectorCombination(rBRFromBottom, -aY, true)); const Style& rBRFromLeft(GetCellStyleBottom(_nLastCol, _nLastRow)); - if(rBRFromLeft.IsUsed()) aEnd.push_back(StyleVectorCombination(rBRFromLeft, -aX, true)); + StyleVectorTable aEnd; + + aEnd.add(rBRFromBottom, -aX -aY, -aY, true); + aEnd.add(rBRFromLeft, -aX -aY, -aX, true); + aEnd.sort(); CreateBorderPrimitives( aCrossSequence, @@ -1210,20 +1217,23 @@ drawinglayer::primitive2d::Primitive2DContainer Array::CreateB2DPrimitiveRange( if(rBLTR.IsUsed()) { /// bottom-left and top-right Style Tables - StyleVectorTable aStart; - StyleVectorTable aEnd; - /// Fill bottom-left Style Table const Style& rBLFromTop(GetCellStyleLeft(_nFirstCol, _nLastRow)); - if(rBLFromTop.IsUsed()) aStart.push_back(StyleVectorCombination(rBLFromTop, -aY, true)); const Style& rBLFromBottom(GetCellStyleBottom(_nFirstCol, _nLastRow)); - if(rBLFromBottom.IsUsed()) aStart.push_back(StyleVectorCombination(rBLFromBottom, aX, false)); + StyleVectorTable aStart; + + aStart.add(rBLFromTop, aX - aY, -aY, true); + aStart.add(rBLFromBottom, aX - aY, aX, false); + aStart.sort(); /// Fill top-right Style Table const Style& rTRFromBottom(GetCellStyleRight(_nLastCol, _nFirstRow)); - if(rTRFromBottom.IsUsed()) aEnd.push_back(StyleVectorCombination(rTRFromBottom, -aY, true)); const Style& rTRFromLeft(GetCellStyleTop(_nLastCol, _nFirstRow)); - if(rTRFromLeft.IsUsed()) aEnd.push_back(StyleVectorCombination(rTRFromLeft, -aX, false)); + StyleVectorTable aEnd; + + aEnd.add(rTRFromBottom, aY - aX, -aY, true); + aEnd.add(rTRFromLeft, aY - aX, -aX, false); + aEnd.sort(); CreateBorderPrimitives( aCrossSequence, diff --git a/svx/source/table/viewcontactoftableobj.cxx b/svx/source/table/viewcontactoftableobj.cxx index 90d143665140..0f6a0f8065ab 100644 --- a/svx/source/table/viewcontactoftableobj.cxx +++ b/svx/source/table/viewcontactoftableobj.cxx @@ -203,19 +203,23 @@ namespace sdr const svx::frame::Style& rRightA, const svx::frame::Style& rRightB, const svx::frame::Style& rRightC) { /// top-left and bottom-right Style Tables - svx::frame::StyleVectorTable aStart; - svx::frame::StyleVectorTable aEnd; const basegfx::B2DVector aY(basegfx::getNormalizedPerpendicular(rX)); /// Fill top-left Style Table - if(rLeftA.IsUsed()) aStart.push_back(svx::frame::StyleVectorCombination(rLeftA, -aY, bHor)); // bHor ? true : false)); - if(rLeftB.IsUsed()) aStart.push_back(svx::frame::StyleVectorCombination(rLeftB, -rX, true)); // bHor ? true : true)); - if(rLeftC.IsUsed()) aStart.push_back(svx::frame::StyleVectorCombination(rLeftC, aY, !bHor)); // bHor ? false : true)); + svx::frame::StyleVectorTable aStart; + + aStart.add(rLeftA, rX, -aY, bHor); // bHor ? true : false)); + aStart.add(rLeftB, rX, -rX, true); // bHor ? true : true)); + aStart.add(rLeftC, rX, aY, !bHor); // bHor ? false : true)); + aStart.sort(); /// Fill bottom-right Style Table - if(rRightA.IsUsed()) aEnd.push_back(svx::frame::StyleVectorCombination(rRightA, -aY, bHor)); // bHor ? true : false)); - if(rRightB.IsUsed()) aEnd.push_back(svx::frame::StyleVectorCombination(rRightB, rX, false)); // bHor ? false : false)); - if(rRightC.IsUsed()) aEnd.push_back(svx::frame::StyleVectorCombination(rRightC, aY, !bHor)); // bHor ? false : true)); + svx::frame::StyleVectorTable aEnd; + + aEnd.add(rRightA, -rX, -aY, bHor); // bHor ? true : false)); + aEnd.add(rRightB, -rX, rX, false); // bHor ? false : false)); + aEnd.add(rRightC, -rX, aY, !bHor); // bHor ? false : true)); + aEnd.sort(); CreateBorderPrimitives( rContainer, diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx index 4098b2add8f4..351ac1a8ba35 100644 --- a/sw/source/core/layout/paintfrm.cxx +++ b/sw/source/core/layout/paintfrm.cxx @@ -2549,24 +2549,27 @@ void SwTabFramePainter::PaintLines(OutputDevice& rDev, const SwRect& rRect) cons if(!aX.equalZero()) { const basegfx::B2DVector aY(basegfx::getNormalizedPerpendicular(aX)); - svx::frame::StyleVectorTable aStartTable; - svx::frame::StyleVectorTable aEndTable; + svx::frame::StyleVectorTable aStartVector; - if(aStyles[ 1 ].IsUsed()) aStartTable.push_back(svx::frame::StyleVectorCombination(aStyles[ 1 ], -aY, true)); // aLFromT - if(aStyles[ 2 ].IsUsed()) aStartTable.push_back(svx::frame::StyleVectorCombination(aStyles[ 2 ], -aX, true)); // aLFromL - if(aStyles[ 3 ].IsUsed()) aStartTable.push_back(svx::frame::StyleVectorCombination(aStyles[ 3 ], aY, false)); // aLFromB + aStartVector.add(aStyles[ 1 ], aX, -aY, true); // aLFromT + aStartVector.add(aStyles[ 2 ], aX, -aX, true); // aLFromL + aStartVector.add(aStyles[ 3 ], aX, aY, false); // aLFromB + aStartVector.sort(); - if(aStyles[ 4 ].IsUsed()) aEndTable.push_back(svx::frame::StyleVectorCombination(aStyles[ 4 ], -aY, true)); // aRFromT - if(aStyles[ 5 ].IsUsed()) aEndTable.push_back(svx::frame::StyleVectorCombination(aStyles[ 5 ], aX, false)); // aRFromR - if(aStyles[ 6 ].IsUsed()) aEndTable.push_back(svx::frame::StyleVectorCombination(aStyles[ 6 ], aY, false)); // aRFromB + svx::frame::StyleVectorTable aEndVector; + + aEndVector.add(aStyles[ 4 ], -aX, -aY, true); // aRFromT + aEndVector.add(aStyles[ 5 ], -aX, aX, false); // aRFromR + aEndVector.add(aStyles[ 6 ], -aX, aY, false); // aRFromB + aEndVector.sort(); CreateBorderPrimitives( aHorizontalSequence, aOrigin, aX, aStyles[ 0 ], - aStartTable, - aEndTable, + aStartVector, + aEndVector, pTmpColor ); } @@ -2579,24 +2582,27 @@ void SwTabFramePainter::PaintLines(OutputDevice& rDev, const SwRect& rRect) cons if(!aX.equalZero()) { const basegfx::B2DVector aY(basegfx::getNormalizedPerpendicular(aX)); - svx::frame::StyleVectorTable aStartTable; - svx::frame::StyleVectorTable aEndTable; + svx::frame::StyleVectorTable aStartVector; + + aStartVector.add(aStyles[ 3 ], aX, -aY, false); // aTFromR + aStartVector.add(aStyles[ 2 ], aX, -aX, true); // aTFromT + aStartVector.add(aStyles[ 1 ], aX, aY, true); // aTFromL + aStartVector.sort(); - if(aStyles[ 3 ].IsUsed()) aStartTable.push_back(svx::frame::StyleVectorCombination(aStyles[ 3 ], -aY, false)); // aTFromR - if(aStyles[ 2 ].IsUsed()) aStartTable.push_back(svx::frame::StyleVectorCombination(aStyles[ 2 ], -aX, true)); // aTFromT - if(aStyles[ 1 ].IsUsed()) aStartTable.push_back(svx::frame::StyleVectorCombination(aStyles[ 1 ], aY, true)); // aTFromL + svx::frame::StyleVectorTable aEndVector; - if(aStyles[ 6 ].IsUsed()) aEndTable.push_back(svx::frame::StyleVectorCombination(aStyles[ 6 ], -aY, false)); // aBFromR - if(aStyles[ 5 ].IsUsed()) aEndTable.push_back(svx::frame::StyleVectorCombination(aStyles[ 5 ], aX, false)); // aBFromB - if(aStyles[ 4 ].IsUsed()) aEndTable.push_back(svx::frame::StyleVectorCombination(aStyles[ 4 ], aY, true)); // aBFromL + aEndVector.add(aStyles[ 6 ], -aX, -aY, false); // aBFromR + aEndVector.add(aStyles[ 5 ], -aX, aX, false); // aBFromB + aEndVector.add(aStyles[ 4 ], -aX, aY, true); // aBFromL + aEndVector.sort(); CreateBorderPrimitives( aVerticalSequence, aOrigin, aX, aStyles[ 0 ], - aStartTable, - aEndTable, + aStartVector, + aEndVector, pTmpColor ); } _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
