diff options
author | Armin Le Grand <Armin.Le.Grand@cib.de> | 2017-09-18 12:31:45 +0200 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@cib.de> | 2017-09-18 15:42:33 +0200 |
commit | b86a3aa00dbaf94398cccfe3af312f123edc6093 (patch) | |
tree | 4a526fc430bc8f82463354cb0ee879ed867ea300 /include | |
parent | 89879b0051529cb8d16da6c8b4b1203679f8f734 (diff) |
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 <Armin.Le.Grand@cib.de>
Tested-by: Armin Le Grand <Armin.Le.Grand@cib.de>
Diffstat (limited to 'include')
-rw-r--r-- | include/svx/framelink.hxx | 82 |
1 files changed, 70 insertions, 12 deletions
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 |