diff options
author | Armin Le Grand <Armin.Le.Grand@cib.de> | 2017-08-31 17:57:46 +0200 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@cib.de> | 2017-09-15 12:58:03 +0200 |
commit | 2135e461167dd873fd622e948b88b4194e6854b7 (patch) | |
tree | cffc50fb80240bb585cd8adc278938a2490ba039 /svx | |
parent | 2813d70f4a7e5522db1056352cd646a585a5c5d0 (diff) |
borderline: Adapted Writer to use CreateBorderPrimitives
Also further refined svx::frame::Style, some more cleanups
in svx using CreateBorderPrimitives, got rid of one
implementation of CreateBorderPrimitives
Change-Id: I4c2481181df4fc4aa0dbb4cb9f4352066b9d8ec0
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/dialog/framelink.cxx | 171 | ||||
-rw-r--r-- | svx/source/dialog/framelinkarray.cxx | 66 |
2 files changed, 154 insertions, 83 deletions
diff --git a/svx/source/dialog/framelink.cxx b/svx/source/dialog/framelink.cxx index 4a921db5f8cc..d3f4aef8024a 100644 --- a/svx/source/dialog/framelink.cxx +++ b/svx/source/dialog/framelink.cxx @@ -42,15 +42,21 @@ namespace svx { namespace frame { // Classes -Style::Style() : maImplStyle(new implStyle()) +void Style::implEnsureImplStyle() +{ + if(!maImplStyle) + { + maImplStyle.reset(new implStyle()); + } +} + +Style::Style() : maImplStyle() { - Clear(); } Style::Style( double nP, double nD, double nS, SvxBorderLineStyle nType ) : maImplStyle(new implStyle()) { maImplStyle->mnType = nType; - Clear(); Set( nP, nD, nS ); } @@ -66,16 +72,28 @@ Style::Style( const editeng::SvxBorderLine* pBorder, double fScale ) : maImplSty Set( pBorder, fScale ); } -double Style::GetWidth() const +void Style::SetPatternScale( double fScale ) { - implStyle* pTarget = maImplStyle.get(); + if(!maImplStyle) + { + if(1.0 == fScale) + { + return; + } - return pTarget->mfPrim + pTarget->mfDist + pTarget->mfSecn; + implEnsureImplStyle(); + } + + maImplStyle->mfPatternScale = fScale; } void Style::Clear() { - Set( Color(), Color(), Color(), false, 0, 0, 0 ); + if(maImplStyle) + { + Set( Color(), Color(), Color(), false, 0, 0, 0 ); + maImplStyle->mnType = SvxBorderLineStyle::SOLID; + } } void Style::Set( double nP, double nD, double nS ) @@ -87,6 +105,7 @@ void Style::Set( double nP, double nD, double nS ) >0 0 >0 nP 0 0 >0 >0 >0 nP nD nS */ + implEnsureImplStyle(); implStyle* pTarget = maImplStyle.get(); pTarget->mfPrim = rtl::math::round(nP ? nP : nS, 2); pTarget->mfDist = rtl::math::round((nP && nS) ? nD : 0, 2); @@ -95,6 +114,7 @@ void Style::Set( double nP, double nD, double nS ) void Style::Set( const Color& rColorPrim, const Color& rColorSecn, const Color& rColorGap, bool bUseGapColor, double nP, double nD, double nS ) { + implEnsureImplStyle(); implStyle* pTarget = maImplStyle.get(); pTarget->maColorPrim = rColorPrim; pTarget->maColorSecn = rColorSecn; @@ -105,6 +125,7 @@ void Style::Set( const Color& rColorPrim, const Color& rColorSecn, const Color& void Style::Set( const SvxBorderLine& rBorder, double fScale, sal_uInt16 nMaxWidth ) { + implEnsureImplStyle(); implStyle* pTarget = maImplStyle.get(); pTarget->maColorPrim = rBorder.GetColorOut(); pTarget->maColorSecn = rBorder.GetColorIn(); @@ -173,12 +194,76 @@ void Style::Set( const SvxBorderLine* pBorder, double fScale, sal_uInt16 nMaxWid else { Clear(); - maImplStyle->mnType = SvxBorderLineStyle::SOLID; } } +void Style::SetRefMode( RefMode eRefMode ) +{ + if(!maImplStyle) + { + if(RefMode::Centered == eRefMode) + { + return; + } + + implEnsureImplStyle(); + } + + maImplStyle->meRefMode = eRefMode; +} + +void Style::SetColorPrim( const Color& rColor ) +{ + if(!maImplStyle) + { + if(Color() == rColor) + { + return; + } + + implEnsureImplStyle(); + } + + maImplStyle->maColorPrim = rColor; +} + +void Style::SetColorSecn( const Color& rColor ) +{ + if(!maImplStyle) + { + if(Color() == rColor) + { + return; + } + + implEnsureImplStyle(); + } + + maImplStyle->maColorSecn = rColor; +} + +void Style::SetType( SvxBorderLineStyle nType ) +{ + if(!maImplStyle) + { + if(SvxBorderLineStyle::SOLID == nType) + { + return; + } + + implEnsureImplStyle(); + } + + maImplStyle->mnType = nType; +} + Style& Style::MirrorSelf() { + if(!maImplStyle) + { + return *this; + } + implStyle* pTarget = maImplStyle.get(); if (pTarget->mfSecn) @@ -194,8 +279,30 @@ Style& Style::MirrorSelf() return *this; } -const Cell* Style::GetUsingCell() const { return maImplStyle->mpUsingCell; } -void Style::SetUsingCell(const Cell* pCell) { maImplStyle->mpUsingCell = pCell; } +const Cell* Style::GetUsingCell() const +{ + if(!maImplStyle) + { + return nullptr; + } + + return maImplStyle->mpUsingCell; +} + +void Style::SetUsingCell(const Cell* pCell) +{ + if(!maImplStyle) + { + if(nullptr == pCell) + { + return; + } + + implEnsureImplStyle(); + } + + maImplStyle->mpUsingCell = pCell; +} bool operator==( const Style& rL, const Style& rR ) { @@ -298,7 +405,7 @@ const OffsetCutSet* getMinMaxCutSet(bool bMin, const std::vector< OffsetCutSet > void getOffsetPairsFromStyle(const Style& rStyle, std::vector< OffsetPair >& offsets) { - if (rStyle.Prim()) + if (rStyle.IsUsed()) { if (rStyle.Dist() && rStyle.Secn()) { @@ -355,7 +462,7 @@ void createCutsWithStyle( const basegfx::B2DVector& rMyVector, std::vector< OffsetCutSet>& rOtherCuts) { - if (rStyle.Prim()) + if (rStyle.IsUsed()) { // get values dependent on source vector const basegfx::B2DVector aMyUnifiedPerpendicular(basegfx::getNormalizedPerpendicular(rMyVector)); @@ -495,7 +602,7 @@ void CreateBorderPrimitives( const Style& /*rRFromBL*/, const Color* pForceColor) { - if (rBorder.Prim()) + if (rBorder.IsUsed()) { const basegfx::B2DVector aPerpendX(basegfx::getNormalizedPerpendicular(rX)); const double fLength(rX.getLength()); @@ -630,7 +737,7 @@ void CreateBorderPrimitives( const Color* pForceColor) { /// rough mapping for testing - if (rBorder.Prim() || rBorder.Secn()) + if (rBorder.IsUsed()) { const size_t nStart(rStartStyleVectorTable.size()); const size_t nEnd(rEndStyleVectorTable.size()); @@ -658,42 +765,6 @@ void CreateBorderPrimitives( } } -void CreateBorderPrimitives( - drawinglayer::primitive2d::Primitive2DContainer& rTarget, - const basegfx::B2DPoint& rOrigin, - const basegfx::B2DVector& rX, - const basegfx::B2DVector& rY, - const Style& rBorder, - const Style& rLFromT, - const Style& rLFromL, - const Style& rLFromB, - const Style& rRFromT, - const Style& rRFromR, - const Style& rRFromB, - const Color* pForceColor) -{ - if (rBorder.Prim() || rBorder.Secn()) - { - CreateBorderPrimitives( - rTarget, - rOrigin, - rX, - rY, - rBorder, - Style(), - rLFromT, - rLFromL, - rLFromB, - Style(), - Style(), - rRFromT, - rRFromR, - rRFromB, - Style(), - pForceColor); - } -} - } } diff --git a/svx/source/dialog/framelinkarray.cxx b/svx/source/dialog/framelinkarray.cxx index 586e095f18bc..c8520d5278de 100644 --- a/svx/source/dialog/framelinkarray.cxx +++ b/svx/source/dialog/framelinkarray.cxx @@ -947,17 +947,17 @@ void HelperCreateHorizontalBorderPrimitives( StyleVectorTable aStart; StyleVectorTable aEnd; - if(rStartFromTR.Prim()) aStart.push_back(StyleVectorCombination(rStartFromTR, aX - aY)); - if(rStartLFromT.Prim()) aStart.push_back(StyleVectorCombination(rStartLFromT, -aY)); - if(rStartLFromL.Prim()) aStart.push_back(StyleVectorCombination(rStartLFromL, -aX)); - if(rStartLFromB.Prim()) aStart.push_back(StyleVectorCombination(rStartLFromB, aY)); - if(rStartFromBR.Prim()) aStart.push_back(StyleVectorCombination(rStartFromBR, aX + aY)); - - if(rEndFromTL.Prim()) aEnd.push_back(StyleVectorCombination(rEndFromTL, -aX -aY)); - if(rEndRFromT.Prim()) aEnd.push_back(StyleVectorCombination(rEndRFromT, -aY)); - if(rEndRFromR.Prim()) aEnd.push_back(StyleVectorCombination(rEndRFromR, aX)); - if(rEndRFromB.Prim()) aEnd.push_back(StyleVectorCombination(rEndRFromB, aY)); - if(rEndFromBL.Prim()) aEnd.push_back(StyleVectorCombination(rEndFromBL, aY - aX)); + if(rStartFromTR.IsUsed()) aStart.push_back(StyleVectorCombination(rStartFromTR, aX - aY)); + if(rStartLFromT.IsUsed()) aStart.push_back(StyleVectorCombination(rStartLFromT, -aY)); + if(rStartLFromL.IsUsed()) aStart.push_back(StyleVectorCombination(rStartLFromL, -aX)); + if(rStartLFromB.IsUsed()) aStart.push_back(StyleVectorCombination(rStartLFromB, aY)); + if(rStartFromBR.IsUsed()) aStart.push_back(StyleVectorCombination(rStartFromBR, aX + aY)); + + if(rEndFromTL.IsUsed()) aEnd.push_back(StyleVectorCombination(rEndFromTL, -aX -aY)); + if(rEndRFromT.IsUsed()) aEnd.push_back(StyleVectorCombination(rEndRFromT, -aY)); + if(rEndRFromR.IsUsed()) aEnd.push_back(StyleVectorCombination(rEndRFromR, aX)); + if(rEndRFromB.IsUsed()) aEnd.push_back(StyleVectorCombination(rEndRFromB, aY)); + if(rEndFromBL.IsUsed()) aEnd.push_back(StyleVectorCombination(rEndFromBL, aY - aX)); CreateBorderPrimitives( rSequence, @@ -986,17 +986,17 @@ void HelperCreateVerticalBorderPrimitives( StyleVectorTable aStart; StyleVectorTable aEnd; - if(rStartFromBR.Prim()) aStart.push_back(StyleVectorCombination(rStartFromBR, aX + aY)); - if(rStartTFromR.Prim()) aStart.push_back(StyleVectorCombination(rStartTFromR, aX)); - if(rStartTFromT.Prim()) aStart.push_back(StyleVectorCombination(rStartTFromT, aY)); - if(rStartTFromL.Prim()) aStart.push_back(StyleVectorCombination(rStartTFromL, -aX)); - if(rStartFromBL.Prim()) aStart.push_back(StyleVectorCombination(rStartFromBL, aY - aX)); + if(rStartFromBR.IsUsed()) aStart.push_back(StyleVectorCombination(rStartFromBR, aX + aY)); + if(rStartTFromR.IsUsed()) aStart.push_back(StyleVectorCombination(rStartTFromR, aX)); + if(rStartTFromT.IsUsed()) aStart.push_back(StyleVectorCombination(rStartTFromT, aY)); + if(rStartTFromL.IsUsed()) aStart.push_back(StyleVectorCombination(rStartTFromL, -aX)); + if(rStartFromBL.IsUsed()) aStart.push_back(StyleVectorCombination(rStartFromBL, aY - aX)); - if(rEndFromTR.Prim()) aEnd.push_back(StyleVectorCombination(rEndFromTR, aX - aY)); - if(rEndBFromR.Prim()) aEnd.push_back(StyleVectorCombination(rEndBFromR, aX)); - if(rEndBFromB.Prim()) aEnd.push_back(StyleVectorCombination(rEndBFromB, -aY)); - if(rEndBFromL.Prim()) aEnd.push_back(StyleVectorCombination(rEndBFromL, aX)); - if(rEndFromTL.Prim()) aEnd.push_back(StyleVectorCombination(rEndFromTL, aX + aY)); + if(rEndFromTR.IsUsed()) aEnd.push_back(StyleVectorCombination(rEndFromTR, aX - aY)); + if(rEndBFromR.IsUsed()) aEnd.push_back(StyleVectorCombination(rEndBFromR, aX)); + if(rEndBFromB.IsUsed()) aEnd.push_back(StyleVectorCombination(rEndBFromB, -aY)); + if(rEndBFromL.IsUsed()) aEnd.push_back(StyleVectorCombination(rEndBFromL, aX)); + if(rEndFromTL.IsUsed()) aEnd.push_back(StyleVectorCombination(rEndFromTL, aX + aY)); CreateBorderPrimitives( rSequence, @@ -1058,15 +1058,15 @@ void Array::DrawRange( drawinglayer::processor2d::BaseProcessor2D& rProcessor, /// Fill top-left Style Table const Style& rTLFromRight(GetCellStyleTop(_nFirstCol, _nFirstRow)); - if(rTLFromRight.Prim()) aStart.push_back(StyleVectorCombination(rTLFromRight, aX)); + if(rTLFromRight.IsUsed()) aStart.push_back(StyleVectorCombination(rTLFromRight, aX)); const Style& rTLFromBottom(GetCellStyleLeft(_nFirstCol, _nFirstRow)); - if(rTLFromBottom.Prim()) aStart.push_back(StyleVectorCombination(rTLFromBottom, aY)); + if(rTLFromBottom.IsUsed()) aStart.push_back(StyleVectorCombination(rTLFromBottom, aY)); /// Fill bottom-right Style Table const Style& rBRFromBottom(GetCellStyleRight(_nLastCol, _nLastRow)); - if(rBRFromBottom.Prim()) aEnd.push_back(StyleVectorCombination(rBRFromBottom, -aY)); + if(rBRFromBottom.IsUsed()) aEnd.push_back(StyleVectorCombination(rBRFromBottom, -aY)); const Style& rBRFromLeft(GetCellStyleBottom(_nLastCol, _nLastRow)); - if(rBRFromLeft.Prim()) aEnd.push_back(StyleVectorCombination(rBRFromLeft, -aX)); + if(rBRFromLeft.IsUsed()) aEnd.push_back(StyleVectorCombination(rBRFromLeft, -aX)); CreateBorderPrimitives( aSequence, @@ -1087,15 +1087,15 @@ void Array::DrawRange( drawinglayer::processor2d::BaseProcessor2D& rProcessor, /// Fill bottom-left Style Table const Style& rBLFromTop(GetCellStyleLeft(_nFirstCol, _nLastRow)); - if(rBLFromTop.Prim()) aStart.push_back(StyleVectorCombination(rBLFromTop, -aY)); + if(rBLFromTop.IsUsed()) aStart.push_back(StyleVectorCombination(rBLFromTop, -aY)); const Style& rBLFromBottom(GetCellStyleBottom(_nFirstCol, _nLastRow)); - if(rBLFromBottom.Prim()) aStart.push_back(StyleVectorCombination(rBLFromBottom, aX)); + if(rBLFromBottom.IsUsed()) aStart.push_back(StyleVectorCombination(rBLFromBottom, aX)); /// Fill top-right Style Table const Style& rTRFromBottom(GetCellStyleRight(_nLastCol, _nFirstRow)); - if(rTRFromBottom.Prim()) aEnd.push_back(StyleVectorCombination(rTRFromBottom, -aY)); + if(rTRFromBottom.IsUsed()) aEnd.push_back(StyleVectorCombination(rTRFromBottom, -aY)); const Style& rTRFromLeft(GetCellStyleTop(_nLastCol, _nFirstRow)); - if(rTRFromLeft.Prim()) aEnd.push_back(StyleVectorCombination(rTRFromLeft, -aX)); + if(rTRFromLeft.IsUsed()) aEnd.push_back(StyleVectorCombination(rTRFromLeft, -aX)); CreateBorderPrimitives( aSequence, @@ -1156,7 +1156,7 @@ void Array::DrawRange( drawinglayer::processor2d::BaseProcessor2D& rProcessor, // draw previous frame border basegfx::B2DPoint aEndPos( mxImpl->GetColPosition( nCol ), aStartPos.getY() ); - if ((pStart->Prim() || pStart->Secn()) && (aStartPos.getX() <= aEndPos.getX())) + if (pStart->IsUsed() && (aStartPos.getX() <= aEndPos.getX())) { // prepare defaults for borderline coordinate system const Cell* pCell = pStart->GetUsingCell(); @@ -1196,7 +1196,7 @@ void Array::DrawRange( drawinglayer::processor2d::BaseProcessor2D& rProcessor, // draw last frame border basegfx::B2DPoint aEndPos( mxImpl->GetColPosition( nCol ), aStartPos.getY() ); - if ((pStart->Prim() || pStart->Secn()) && (aStartPos.getX() <= aEndPos.getX())) + if (pStart->IsUsed() && (aStartPos.getX() <= aEndPos.getX())) { // for description of involved coordinate systems have a look at // the first CreateBorderPrimitives call above @@ -1259,7 +1259,7 @@ void Array::DrawRange( drawinglayer::processor2d::BaseProcessor2D& rProcessor, { // draw previous frame border basegfx::B2DPoint aEndPos( aStartPos.getX(), mxImpl->GetRowPosition( nRow ) ); - if ((pStart->Prim() || pStart->Secn()) && (aStartPos.getY() <= aEndPos.getY())) + if (pStart->IsUsed() && (aStartPos.getY() <= aEndPos.getY())) { // for description of involved coordinate systems have a look at // the first CreateBorderPrimitives call above. Additionally adapt to vertical @@ -1300,7 +1300,7 @@ void Array::DrawRange( drawinglayer::processor2d::BaseProcessor2D& rProcessor, // draw last frame border basegfx::B2DPoint aEndPos( aStartPos.getX(), mxImpl->GetRowPosition( nRow ) ); - if ((pStart->Prim() || pStart->Secn()) && (aStartPos.getY() <= aEndPos.getY())) + if (pStart->IsUsed() && (aStartPos.getY() <= aEndPos.getY())) { // for description of involved coordinate systems have a look at // the first CreateBorderPrimitives call above, adapt to vertical |