diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2021-04-30 22:47:30 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2021-05-01 04:29:31 +0200 |
commit | bd0c965b1ba9a15497f92102d5d11c84df091b2f (patch) | |
tree | c21148dc4f6ffe469f37c393620fe1c219b0caef /svgio | |
parent | a52590d76b89dc75be2aa87f4287624c89f1e82f (diff) |
convert enums to enum classes in svgtools.hxx
converted SvgUnits, NumberType, SvgUnit, SvgAlign
Change-Id: I703b1d9396f42b3af1a36c683628e90161f2717d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114952
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'svgio')
-rw-r--r-- | svgio/inc/svgtools.hxx | 62 | ||||
-rw-r--r-- | svgio/source/svgreader/svgcharacternode.cxx | 16 | ||||
-rw-r--r-- | svgio/source/svgreader/svgcirclenode.cxx | 4 | ||||
-rw-r--r-- | svgio/source/svgreader/svgclippathnode.cxx | 8 | ||||
-rw-r--r-- | svgio/source/svgreader/svgellipsenode.cxx | 8 | ||||
-rw-r--r-- | svgio/source/svgreader/svggradientnode.cxx | 22 | ||||
-rw-r--r-- | svgio/source/svgreader/svgimagenode.cxx | 8 | ||||
-rw-r--r-- | svgio/source/svgreader/svglinenode.cxx | 8 | ||||
-rw-r--r-- | svgio/source/svgreader/svgmasknode.cxx | 40 | ||||
-rw-r--r-- | svgio/source/svgreader/svgnode.cxx | 4 | ||||
-rw-r--r-- | svgio/source/svgreader/svgpatternnode.cxx | 30 | ||||
-rw-r--r-- | svgio/source/svgreader/svgrectnode.cxx | 12 | ||||
-rw-r--r-- | svgio/source/svgreader/svgstyleattributes.cxx | 80 | ||||
-rw-r--r-- | svgio/source/svgreader/svgsvgnode.cxx | 36 | ||||
-rw-r--r-- | svgio/source/svgreader/svgtextpathnode.cxx | 2 | ||||
-rw-r--r-- | svgio/source/svgreader/svgtools.cxx | 138 | ||||
-rw-r--r-- | svgio/source/svgreader/svgusenode.cxx | 4 |
17 files changed, 241 insertions, 241 deletions
diff --git a/svgio/inc/svgtools.hxx b/svgio/inc/svgtools.hxx index 82d58cc2e472..c4a88d89d05f 100644 --- a/svgio/inc/svgtools.hxx +++ b/svgio/inc/svgtools.hxx @@ -44,13 +44,13 @@ namespace svgio::svgreader static constexpr OUStringLiteral aStrEvenOdd = u"evenodd"; }; - enum SvgUnits + enum class SvgUnits { userSpaceOnUse, objectBoundingBox }; - enum NumberType + enum class NumberType { xcoordinate, ycoordinate, @@ -68,20 +68,20 @@ namespace svgio::svgreader virtual double getCurrentXHeightInherited() const = 0; }; - enum SvgUnit + enum class SvgUnit { - Unit_em = 0, // relative to current font size - Unit_ex, // relative to current x-height - - Unit_px, // 'user unit' - Unit_pt, // points, 1.25 px - Unit_pc, // 15.0 px - Unit_cm, // 35.43307 px - Unit_mm, // 3.543307 px - Unit_in, // 90 px - - Unit_percent, // relative to range - Unit_none // for stroke-miterlimit, which has no unit + em = 0, // relative to current font size + ex, // relative to current x-height + + px, // 'user unit' + pt, // points, 1.25 px + pc, // 15.0 px + cm, // 35.43307 px + mm, // 3.543307 px + in, // 90 px + + percent, // relative to range + none // for stroke-miterlimit, which has no unit }; class SvgNumber @@ -95,12 +95,12 @@ namespace svgio::svgreader public: SvgNumber() : mfNumber(0.0), - meUnit(Unit_px), + meUnit(SvgUnit::px), mbSet(false) { } - SvgNumber(double fNum, SvgUnit aSvgUnit = Unit_px, bool bSet = true) + SvgNumber(double fNum, SvgUnit aSvgUnit = SvgUnit::px, bool bSet = true) : mfNumber(fNum), meUnit(aSvgUnit), mbSet(bSet) @@ -124,28 +124,28 @@ namespace svgio::svgreader bool isPositive() const; - // Only usable in cases, when the unit is not Unit_percent, otherwise use method solve + // Only usable in cases, when the unit is not SvgUnit::percent, otherwise use method solve double solveNonPercentage(const InfoProvider& rInfoProvider) const; - double solve(const InfoProvider& rInfoProvider, NumberType aNumberType = length) const; + double solve(const InfoProvider& rInfoProvider, NumberType aNumberType = NumberType::length) const; }; typedef ::std::vector< SvgNumber > SvgNumberVector; - enum SvgAlign + enum class SvgAlign { - Align_none, - Align_xMinYMin, - Align_xMidYMin, - Align_xMaxYMin, - Align_xMinYMid, - Align_xMidYMid, // default - Align_xMaxYMid, - Align_xMinYMax, - Align_xMidYMax, - Align_xMaxYMax + none, + xMinYMin, + xMidYMin, + xMaxYMin, + xMinYMid, + xMidYMid, // default + xMaxYMid, + xMinYMax, + xMidYMax, + xMaxYMax }; class SvgAspectRatio @@ -158,7 +158,7 @@ namespace svgio::svgreader public: SvgAspectRatio() - : maSvgAlign(Align_xMidYMid), + : maSvgAlign(SvgAlign::xMidYMid), mbMeetOrSlice(true), mbSet(false) { diff --git a/svgio/source/svgreader/svgcharacternode.cxx b/svgio/source/svgreader/svgcharacternode.cxx index 5443fd56067a..ff30730cf1eb 100644 --- a/svgio/source/svgreader/svgcharacternode.cxx +++ b/svgio/source/svgreader/svgcharacternode.cxx @@ -594,7 +594,7 @@ namespace svgio::svgreader if(nSizeX) { // we have absolute positions, get first one as current text position X - maPosition.setX(rSvgTextPositions.getX()[0].solve(rInfoProvider, xcoordinate)); + maPosition.setX(rSvgTextPositions.getX()[0].solve(rInfoProvider, NumberType::xcoordinate)); mbAbsoluteX = true; if(nSizeX > 1) @@ -604,7 +604,7 @@ namespace svgio::svgreader for(sal_uInt32 a(1); a < nSizeX; a++) { - maX.push_back(rSvgTextPositions.getX()[a].solve(rInfoProvider, xcoordinate) - maPosition.getX()); + maX.push_back(rSvgTextPositions.getX()[a].solve(rInfoProvider, NumberType::xcoordinate) - maPosition.getX()); } } } @@ -621,7 +621,7 @@ namespace svgio::svgreader if(nSizeDx) { // relative positions given, translate position derived from parent - maPosition.setX(maPosition.getX() + rSvgTextPositions.getDx()[0].solve(rInfoProvider, xcoordinate)); + maPosition.setX(maPosition.getX() + rSvgTextPositions.getDx()[0].solve(rInfoProvider, NumberType::xcoordinate)); if(nSizeDx > 1) { @@ -630,7 +630,7 @@ namespace svgio::svgreader for(sal_uInt32 a(1); a < nSizeDx; a++) { - maX.push_back(rSvgTextPositions.getDx()[a].solve(rInfoProvider, xcoordinate)); + maX.push_back(rSvgTextPositions.getDx()[a].solve(rInfoProvider, NumberType::xcoordinate)); } } } @@ -642,7 +642,7 @@ namespace svgio::svgreader if(nSizeY) { // we have absolute positions, get first one as current text position Y - maPosition.setY(rSvgTextPositions.getY()[0].solve(rInfoProvider, ycoordinate)); + maPosition.setY(rSvgTextPositions.getY()[0].solve(rInfoProvider, NumberType::ycoordinate)); mbAbsoluteX = true; if(nSizeY > 1) @@ -652,7 +652,7 @@ namespace svgio::svgreader for(sal_uInt32 a(1); a < nSizeY; a++) { - maY.push_back(rSvgTextPositions.getY()[a].solve(rInfoProvider, ycoordinate) - maPosition.getY()); + maY.push_back(rSvgTextPositions.getY()[a].solve(rInfoProvider, NumberType::ycoordinate) - maPosition.getY()); } } } @@ -669,7 +669,7 @@ namespace svgio::svgreader if(nSizeDy) { // relative positions given, translate position derived from parent - maPosition.setY(maPosition.getY() + rSvgTextPositions.getDy()[0].solve(rInfoProvider, ycoordinate)); + maPosition.setY(maPosition.getY() + rSvgTextPositions.getDy()[0].solve(rInfoProvider, NumberType::ycoordinate)); if(nSizeDy > 1) { @@ -678,7 +678,7 @@ namespace svgio::svgreader for(sal_uInt32 a(1); a < nSizeDy; a++) { - maY.push_back(rSvgTextPositions.getDy()[a].solve(rInfoProvider, ycoordinate)); + maY.push_back(rSvgTextPositions.getDy()[a].solve(rInfoProvider, NumberType::ycoordinate)); } } } diff --git a/svgio/source/svgreader/svgcirclenode.cxx b/svgio/source/svgreader/svgcirclenode.cxx index 6ba6ded89134..78e280eb0a26 100644 --- a/svgio/source/svgreader/svgcirclenode.cxx +++ b/svgio/source/svgreader/svgcirclenode.cxx @@ -125,8 +125,8 @@ namespace svgio::svgreader const basegfx::B2DPolygon aPath( basegfx::utils::createPolygonFromCircle( basegfx::B2DPoint( - getCx().isSet() ? getCx().solve(*this, xcoordinate) : 0.0, - getCy().isSet() ? getCy().solve(*this, ycoordinate) : 0.0), + getCx().isSet() ? getCx().solve(*this, NumberType::xcoordinate) : 0.0, + getCy().isSet() ? getCy().solve(*this, NumberType::ycoordinate) : 0.0), fR)); drawinglayer::primitive2d::Primitive2DContainer aNewTarget; diff --git a/svgio/source/svgreader/svgclippathnode.cxx b/svgio/source/svgreader/svgclippathnode.cxx index d5ff52dd97e0..a90d6adb8c2b 100644 --- a/svgio/source/svgreader/svgclippathnode.cxx +++ b/svgio/source/svgreader/svgclippathnode.cxx @@ -33,7 +33,7 @@ namespace svgio::svgreader SvgNode* pParent) : SvgNode(SVGToken::ClipPathNode, rDocument, pParent), maSvgStyleAttributes(*this), - maClipPathUnits(userSpaceOnUse) + maClipPathUnits(SvgUnits::userSpaceOnUse) { } @@ -78,11 +78,11 @@ namespace svgio::svgreader { if(aContent.match(commonStrings::aStrUserSpaceOnUse)) { - setClipPathUnits(userSpaceOnUse); + setClipPathUnits(SvgUnits::userSpaceOnUse); } else if(aContent.match(commonStrings::aStrObjectBoundingBox)) { - setClipPathUnits(objectBoundingBox); + setClipPathUnits(SvgUnits::objectBoundingBox); } } break; @@ -158,7 +158,7 @@ namespace svgio::svgreader if(aClipPolyPolygon.count()) { - if(objectBoundingBox == getClipPathUnits()) + if (SvgUnits::objectBoundingBox == getClipPathUnits()) { // clip is object-relative, transform using content transformation const basegfx::B2DRange aContentRange(rContent.getB2DRange(aViewInformation2D)); diff --git a/svgio/source/svgreader/svgellipsenode.cxx b/svgio/source/svgreader/svgellipsenode.cxx index 4e83e010d3c7..7fd431aeb0f6 100644 --- a/svgio/source/svgreader/svgellipsenode.cxx +++ b/svgio/source/svgreader/svgellipsenode.cxx @@ -131,8 +131,8 @@ namespace svgio::svgreader if(!(pStyle && getRx().isSet() && getRy().isSet())) return; - const double fRx(getRx().solve(*this, xcoordinate)); - const double fRy(getRy().solve(*this, ycoordinate)); + const double fRx(getRx().solve(*this, NumberType::xcoordinate)); + const double fRy(getRy().solve(*this, NumberType::ycoordinate)); if(fRx <= 0.0 || fRy <= 0.0) return; @@ -140,8 +140,8 @@ namespace svgio::svgreader const basegfx::B2DPolygon aPath( basegfx::utils::createPolygonFromEllipse( basegfx::B2DPoint( - getCx().isSet() ? getCx().solve(*this, xcoordinate) : 0.0, - getCy().isSet() ? getCy().solve(*this, ycoordinate) : 0.0), + getCx().isSet() ? getCx().solve(*this, NumberType::xcoordinate) : 0.0, + getCy().isSet() ? getCy().solve(*this, NumberType::ycoordinate) : 0.0), fRx, fRy)); drawinglayer::primitive2d::Primitive2DContainer aNewTarget; diff --git a/svgio/source/svgreader/svggradientnode.cxx b/svgio/source/svgreader/svggradientnode.cxx index a35ebb76504c..8aa4371e0cfc 100644 --- a/svgio/source/svgreader/svggradientnode.cxx +++ b/svgio/source/svgreader/svggradientnode.cxx @@ -46,7 +46,7 @@ namespace svgio::svgreader maR(), maFx(), maFy(), - maGradientUnits(objectBoundingBox), + maGradientUnits(SvgUnits::objectBoundingBox), maSpreadMethod(drawinglayer::primitive2d::SpreadMethod::Pad), mbResolvingLink(false), maXLink(), @@ -182,11 +182,11 @@ namespace svgio::svgreader { if(aContent.match(commonStrings::aStrUserSpaceOnUse)) { - setGradientUnits(userSpaceOnUse); + setGradientUnits(SvgUnits::userSpaceOnUse); } else if(aContent.match(commonStrings::aStrObjectBoundingBox)) { - setGradientUnits(objectBoundingBox); + setGradientUnits(SvgUnits::objectBoundingBox); } } break; @@ -268,7 +268,7 @@ namespace svgio::svgreader const SvgNumber aOffset(pCandidate->getOffset()); double fOffset(0.0); - if(Unit_percent == aOffset.getUnit()) + if(SvgUnit::percent == aOffset.getUnit()) { // percent is not relative to distances in ColorStop context, solve locally fOffset = aOffset.getNumber() * 0.01; @@ -321,7 +321,7 @@ namespace svgio::svgreader } // default is 0% - return SvgNumber(0.0, Unit_percent); + return SvgNumber(0.0, SvgUnit::percent); } SvgNumber SvgGradientNode::getY1() const @@ -342,7 +342,7 @@ namespace svgio::svgreader } // default is 0% - return SvgNumber(0.0, Unit_percent); + return SvgNumber(0.0, SvgUnit::percent); } SvgNumber SvgGradientNode::getX2() const @@ -363,7 +363,7 @@ namespace svgio::svgreader } // default is 100% - return SvgNumber(100.0, Unit_percent); + return SvgNumber(100.0, SvgUnit::percent); } SvgNumber SvgGradientNode::getY2() const @@ -384,7 +384,7 @@ namespace svgio::svgreader } // default is 0% - return SvgNumber(0.0, Unit_percent); + return SvgNumber(0.0, SvgUnit::percent); } SvgNumber SvgGradientNode::getCx() const @@ -405,7 +405,7 @@ namespace svgio::svgreader } // default is 50% - return SvgNumber(50.0, Unit_percent); + return SvgNumber(50.0, SvgUnit::percent); } SvgNumber SvgGradientNode::getCy() const @@ -426,7 +426,7 @@ namespace svgio::svgreader } // default is 50% - return SvgNumber(50.0, Unit_percent); + return SvgNumber(50.0, SvgUnit::percent); } SvgNumber SvgGradientNode::getR() const @@ -447,7 +447,7 @@ namespace svgio::svgreader } // default is 50% - return SvgNumber(50.0, Unit_percent); + return SvgNumber(50.0, SvgUnit::percent); } const SvgNumber* SvgGradientNode::getFx() const diff --git a/svgio/source/svgreader/svgimagenode.cxx b/svgio/source/svgreader/svgimagenode.cxx index e1ed24faf36a..994be83224c9 100644 --- a/svgio/source/svgreader/svgimagenode.cxx +++ b/svgio/source/svgreader/svgimagenode.cxx @@ -193,8 +193,8 @@ namespace svgio::svgreader if(!(pStyle && getWidth().isSet() && getHeight().isSet())) return; - const double fWidth(getWidth().solve(*this, xcoordinate)); - const double fHeight(getHeight().solve(*this, ycoordinate)); + const double fWidth(getWidth().solve(*this, NumberType::xcoordinate)); + const double fHeight(getHeight().solve(*this, NumberType::ycoordinate)); if(fWidth <= 0.0 || fHeight <= 0.0) return; @@ -203,8 +203,8 @@ namespace svgio::svgreader drawinglayer::primitive2d::Primitive2DContainer aNewTarget; // prepare Target and ViewBox for evtl. AspectRatio mappings - const double fX(getX().isSet() ? getX().solve(*this, xcoordinate) : 0.0); - const double fY(getY().isSet() ? getY().solve(*this, ycoordinate) : 0.0); + const double fX(getX().isSet() ? getX().solve(*this, NumberType::xcoordinate) : 0.0); + const double fY(getY().isSet() ? getY().solve(*this, NumberType::ycoordinate) : 0.0); const basegfx::B2DRange aTarget(fX, fY, fX + fWidth, fY + fHeight); basegfx::B2DRange aViewBox(aTarget); diff --git a/svgio/source/svgreader/svglinenode.cxx b/svgio/source/svgreader/svglinenode.cxx index 155da1ee9a2d..1f4ef9bbd60d 100644 --- a/svgio/source/svgreader/svglinenode.cxx +++ b/svgio/source/svgreader/svglinenode.cxx @@ -125,11 +125,11 @@ namespace svgio::svgreader return; const basegfx::B2DPoint X( - getX1().isSet() ? getX1().solve(*this, xcoordinate) : 0.0, - getY1().isSet() ? getY1().solve(*this, ycoordinate) : 0.0); + getX1().isSet() ? getX1().solve(*this, NumberType::xcoordinate) : 0.0, + getY1().isSet() ? getY1().solve(*this, NumberType::ycoordinate) : 0.0); const basegfx::B2DPoint Y( - getX2().isSet() ? getX2().solve(*this, xcoordinate) : 0.0, - getY2().isSet() ? getY2().solve(*this, ycoordinate) : 0.0); + getX2().isSet() ? getX2().solve(*this, NumberType::xcoordinate) : 0.0, + getY2().isSet() ? getY2().solve(*this, NumberType::ycoordinate) : 0.0); // X and Y may be equal, do not drop them. Markers or linecaps 'round' and 'square' // need to be drawn for zero-length lines too. diff --git a/svgio/source/svgreader/svgmasknode.cxx b/svgio/source/svgreader/svgmasknode.cxx index e5573a77928a..631ae3e7c01f 100644 --- a/svgio/source/svgreader/svgmasknode.cxx +++ b/svgio/source/svgreader/svgmasknode.cxx @@ -34,12 +34,12 @@ namespace svgio::svgreader SvgNode* pParent) : SvgNode(SVGToken::Mask, rDocument, pParent), maSvgStyleAttributes(*this), - maX(SvgNumber(-10.0, Unit_percent, true)), - maY(SvgNumber(-10.0, Unit_percent, true)), - maWidth(SvgNumber(120.0, Unit_percent, true)), - maHeight(SvgNumber(120.0, Unit_percent, true)), - maMaskUnits(objectBoundingBox), - maMaskContentUnits(userSpaceOnUse) + maX(SvgNumber(-10.0, SvgUnit::percent, true)), + maY(SvgNumber(-10.0, SvgUnit::percent, true)), + maWidth(SvgNumber(120.0, SvgUnit::percent, true)), + maHeight(SvgNumber(120.0, SvgUnit::percent, true)), + maMaskUnits(SvgUnits::objectBoundingBox), + maMaskContentUnits(SvgUnits::userSpaceOnUse) { } @@ -130,11 +130,11 @@ namespace svgio::svgreader { if(aContent.match(commonStrings::aStrUserSpaceOnUse)) { - setMaskUnits(userSpaceOnUse); + setMaskUnits(SvgUnits::userSpaceOnUse); } else if(aContent.match(commonStrings::aStrObjectBoundingBox)) { - setMaskUnits(objectBoundingBox); + setMaskUnits(SvgUnits::objectBoundingBox); } } break; @@ -145,11 +145,11 @@ namespace svgio::svgreader { if(aContent.match(commonStrings::aStrUserSpaceOnUse)) { - setMaskContentUnits(userSpaceOnUse); + setMaskContentUnits(SvgUnits::userSpaceOnUse); } else if(aContent.match(commonStrings::aStrObjectBoundingBox)) { - setMaskContentUnits(objectBoundingBox); + setMaskContentUnits(SvgUnits::objectBoundingBox); } } break; @@ -212,13 +212,13 @@ namespace svgio::svgreader // create OffscreenBufferRange basegfx::B2DRange aOffscreenBufferRange; - if(objectBoundingBox == maMaskUnits) + if (SvgUnits::objectBoundingBox == maMaskUnits) { // fractions or percentages of the bounding box of the element to which the mask is applied - const double fX(Unit_percent == getX().getUnit() ? getX().getNumber() * 0.01 : getX().getNumber()); - const double fY(Unit_percent == getY().getUnit() ? getY().getNumber() * 0.01 : getY().getNumber()); - const double fW(Unit_percent == getWidth().getUnit() ? getWidth().getNumber() * 0.01 : getWidth().getNumber()); - const double fH(Unit_percent == getHeight().getUnit() ? getHeight().getNumber() * 0.01 : getHeight().getNumber()); + const double fX(SvgUnit::percent == getX().getUnit() ? getX().getNumber() * 0.01 : getX().getNumber()); + const double fY(SvgUnit::percent == getY().getUnit() ? getY().getNumber() * 0.01 : getY().getNumber()); + const double fW(SvgUnit::percent == getWidth().getUnit() ? getWidth().getNumber() * 0.01 : getWidth().getNumber()); + const double fH(SvgUnit::percent == getHeight().getUnit() ? getHeight().getNumber() * 0.01 : getHeight().getNumber()); aOffscreenBufferRange = basegfx::B2DRange( aContentRange.getMinX() + (fX * fContentWidth), @@ -228,17 +228,17 @@ namespace svgio::svgreader } else { - const double fX(getX().isSet() ? getX().solve(*this, xcoordinate) : 0.0); - const double fY(getY().isSet() ? getY().solve(*this, ycoordinate) : 0.0); + const double fX(getX().isSet() ? getX().solve(*this, NumberType::xcoordinate) : 0.0); + const double fY(getY().isSet() ? getY().solve(*this, NumberType::ycoordinate) : 0.0); aOffscreenBufferRange = basegfx::B2DRange( fX, fY, - fX + (getWidth().isSet() ? getWidth().solve(*this, xcoordinate) : 0.0), - fY + (getHeight().isSet() ? getHeight().solve(*this, ycoordinate) : 0.0)); + fX + (getWidth().isSet() ? getWidth().solve(*this, NumberType::xcoordinate) : 0.0), + fY + (getHeight().isSet() ? getHeight().solve(*this, NumberType::ycoordinate) : 0.0)); } - if(objectBoundingBox == maMaskContentUnits) + if (SvgUnits::objectBoundingBox == maMaskContentUnits) { // mask is object-relative, embed in content transformation const drawinglayer::primitive2d::Primitive2DReference xTransform( diff --git a/svgio/source/svgreader/svgnode.cxx b/svgio/source/svgreader/svgnode.cxx index 82cd4d6d8014..ac0c98a42000 100644 --- a/svgio/source/svgreader/svgnode.cxx +++ b/svgio/source/svgreader/svgnode.cxx @@ -612,7 +612,7 @@ namespace svgio::svgreader double SvgNode::getCurrentFontSize() const { if(getSvgStyleAttributes()) - return getSvgStyleAttributes()->getFontSizeNumber().solve(*this, xcoordinate); + return getSvgStyleAttributes()->getFontSizeNumber().solve(*this, NumberType::xcoordinate); return getCurrentFontSizeInherited(); } @@ -633,7 +633,7 @@ namespace svgio::svgreader { if(getSvgStyleAttributes()) // for XHeight, use FontSize currently - return getSvgStyleAttributes()->getFontSizeNumber().solve(*this, ycoordinate); + return getSvgStyleAttributes()->getFontSizeNumber().solve(*this, NumberType::ycoordinate); return getCurrentXHeightInherited(); } diff --git a/svgio/source/svgreader/svgpatternnode.cxx b/svgio/source/svgreader/svgpatternnode.cxx index 1aea78255108..3a62e2510c8a 100644 --- a/svgio/source/svgreader/svgpatternnode.cxx +++ b/svgio/source/svgreader/svgpatternnode.cxx @@ -139,11 +139,11 @@ namespace svgio::svgreader { if(aContent.match(commonStrings::aStrUserSpaceOnUse)) { - setPatternUnits(userSpaceOnUse); + setPatternUnits(SvgUnits::userSpaceOnUse); } else if(aContent.match(commonStrings::aStrObjectBoundingBox)) { - setPatternUnits(objectBoundingBox); + setPatternUnits(SvgUnits::objectBoundingBox); } } break; @@ -154,11 +154,11 @@ namespace svgio::svgreader { if(aContent.match(commonStrings::aStrUserSpaceOnUse)) { - setPatternContentUnits(userSpaceOnUse); + setPatternContentUnits(SvgUnits::userSpaceOnUse); } else if(aContent.match(commonStrings::aStrObjectBoundingBox)) { - setPatternContentUnits(objectBoundingBox); + setPatternContentUnits(SvgUnits::objectBoundingBox); } } break; @@ -199,27 +199,27 @@ namespace svgio::svgreader if(fTargetWidth <= 0.0 || fTargetHeight <= 0.0) return; - const SvgUnits aPatternUnits(getPatternUnits() ? *getPatternUnits() : objectBoundingBox); + const SvgUnits aPatternUnits(getPatternUnits() ? *getPatternUnits() : SvgUnits::objectBoundingBox); - if(objectBoundingBox == aPatternUnits) + if (SvgUnits::objectBoundingBox == aPatternUnits) { rfW = (getWidth().isSet()) ? getWidth().getNumber() : 0.0; rfH = (getHeight().isSet()) ? getHeight().getNumber() : 0.0; - if(Unit_percent == getWidth().getUnit()) + if(SvgUnit::percent == getWidth().getUnit()) { rfW *= 0.01; } - if(Unit_percent == getHeight().getUnit()) + if(SvgUnit::percent == getHeight().getUnit()) { rfH *= 0.01; } } else { - rfW = (getWidth().isSet()) ? getWidth().solve(rUser, xcoordinate) : 0.0; - rfH = (getHeight().isSet()) ? getHeight().solve(rUser, ycoordinate) : 0.0; + rfW = (getWidth().isSet()) ? getWidth().solve(rUser, NumberType::xcoordinate) : 0.0; + rfH = (getHeight().isSet()) ? getHeight().solve(rUser, NumberType::ycoordinate) : 0.0; // make relative to rGeoRange rfW /= fTargetWidth; @@ -229,25 +229,25 @@ namespace svgio::svgreader if(rfW <= 0.0 || rfH <= 0.0) return; - if(objectBoundingBox == aPatternUnits) + if (SvgUnits::objectBoundingBox == aPatternUnits) { rfX = (getX().isSet()) ? getX().getNumber() : 0.0; rfY = (getY().isSet()) ? getY().getNumber() : 0.0; - if(Unit_percent == getX().getUnit()) + if(SvgUnit::percent == getX().getUnit()) { rfX *= 0.01; } - if(Unit_percent == getY().getUnit()) + if(SvgUnit::percent == getY().getUnit()) { rfY *= 0.01; } } else { - rfX = (getX().isSet()) ? getX().solve(rUser, xcoordinate) : 0.0; - rfY = (getY().isSet()) ? getY().solve(rUser, ycoordinate) : 0.0; + rfX = (getX().isSet()) ? getX().solve(rUser, NumberType::xcoordinate) : 0.0; + rfY = (getY().isSet()) ? getY().solve(rUser, NumberType::ycoordinate) : 0.0; // make relative to rGeoRange rfX = (rfX - rGeoRange.getMinX()) / fTargetWidth; diff --git a/svgio/source/svgreader/svgrectnode.cxx b/svgio/source/svgreader/svgrectnode.cxx index 03018fbd1d34..aa23954237e4 100644 --- a/svgio/source/svgreader/svgrectnode.cxx +++ b/svgio/source/svgreader/svgrectnode.cxx @@ -160,21 +160,21 @@ namespace svgio::svgreader if(!(pStyle && getWidth().isSet() && getHeight().isSet())) return; - const double fWidth(getWidth().solve(*this, xcoordinate)); - const double fHeight(getHeight().solve(*this, ycoordinate)); + const double fWidth(getWidth().solve(*this, NumberType::xcoordinate)); + const double fHeight(getHeight().solve(*this, NumberType::ycoordinate)); if(fWidth <= 0.0 || fHeight <= 0.0) return; - const double fX(getX().isSet() ? getX().solve(*this, xcoordinate) : 0.0); - const double fY(getY().isSet() ? getY().solve(*this, ycoordinate) : 0.0); + const double fX(getX().isSet() ? getX().solve(*this, NumberType::xcoordinate) : 0.0); + const double fY(getY().isSet() ? getY().solve(*this, NumberType::ycoordinate) : 0.0); const basegfx::B2DRange aRange(fX, fY, fX + fWidth, fY + fHeight); basegfx::B2DPolygon aPath; if(getRx().isSet() || getRy().isSet()) { - double frX(getRx().isSet() ? getRx().solve(*this, xcoordinate) : 0.0); - double frY(getRy().isSet() ? getRy().solve(*this, ycoordinate) : 0.0); + double frX(getRx().isSet() ? getRx().solve(*this, NumberType::xcoordinate) : 0.0); + double frY(getRy().isSet() ? getRy().solve(*this, NumberType::ycoordinate) : 0.0); frX = std::max(0.0, frX); frY = std::max(0.0, frY); diff --git a/svgio/source/svgreader/svgstyleattributes.cxx b/svgio/source/svgreader/svgstyleattributes.cxx index cfc6381e8d0d..a8521e4c817e 100644 --- a/svgio/source/svgreader/svgstyleattributes.cxx +++ b/svgio/source/svgreader/svgstyleattributes.cxx @@ -355,7 +355,7 @@ namespace svgio::svgreader aGradientTransform = *rFillGradient.getGradientTransform(); } - if(userSpaceOnUse == rFillGradient.getGradientUnits()) + if (SvgUnits::userSpaceOnUse == rFillGradient.getGradientUnits()) { aGeoToUnit.translate(-rGeoRange.getMinX(), -rGeoRange.getMinY()); aGeoToUnit.scale(1.0 / rGeoRange.getWidth(), 1.0 / rGeoRange.getHeight()); @@ -366,13 +366,13 @@ namespace svgio::svgreader basegfx::B2DPoint aStart(0.0, 0.0); basegfx::B2DPoint aEnd(1.0, 0.0); - if(userSpaceOnUse == rFillGradient.getGradientUnits()) + if (SvgUnits::userSpaceOnUse == rFillGradient.getGradientUnits()) { // all possible units - aStart.setX(rFillGradient.getX1().solve(mrOwner, xcoordinate)); - aStart.setY(rFillGradient.getY1().solve(mrOwner, ycoordinate)); - aEnd.setX(rFillGradient.getX2().solve(mrOwner, xcoordinate)); - aEnd.setY(rFillGradient.getY2().solve(mrOwner, ycoordinate)); + aStart.setX(rFillGradient.getX1().solve(mrOwner, NumberType::xcoordinate)); + aStart.setY(rFillGradient.getY1().solve(mrOwner, NumberType::ycoordinate)); + aEnd.setX(rFillGradient.getX2().solve(mrOwner, NumberType::xcoordinate)); + aEnd.setY(rFillGradient.getY2().solve(mrOwner, NumberType::ycoordinate)); } else { @@ -382,10 +382,10 @@ namespace svgio::svgreader const SvgNumber X2(rFillGradient.getX2()); const SvgNumber Y2(rFillGradient.getY2()); - aStart.setX(Unit_percent == X1.getUnit() ? X1.getNumber() * 0.01 : X1.getNumber()); - aStart.setY(Unit_percent == Y1.getUnit() ? Y1.getNumber() * 0.01 : Y1.getNumber()); - aEnd.setX(Unit_percent == X2.getUnit() ? X2.getNumber() * 0.01 : X2.getNumber()); - aEnd.setY(Unit_percent == Y2.getUnit() ? Y2.getNumber() * 0.01 : Y2.getNumber()); + aStart.setX(SvgUnit::percent == X1.getUnit() ? X1.getNumber() * 0.01 : X1.getNumber()); + aStart.setY(SvgUnit::percent == Y1.getUnit() ? Y1.getNumber() * 0.01 : Y1.getNumber()); + aEnd.setX(SvgUnit::percent == X2.getUnit() ? X2.getNumber() * 0.01 : X2.getNumber()); + aEnd.setY(SvgUnit::percent == Y2.getUnit() ? Y2.getNumber() * 0.01 : Y2.getNumber()); } if(!aGeoToUnit.isIdentity()) @@ -401,7 +401,7 @@ namespace svgio::svgreader aSvgGradientEntryVector, aStart, aEnd, - userSpaceOnUse != rFillGradient.getGradientUnits(), + SvgUnits::userSpaceOnUse != rFillGradient.getGradientUnits(), rFillGradient.getSpreadMethod())); } else @@ -413,17 +413,17 @@ namespace svgio::svgreader const SvgNumber* pFy = rFillGradient.getFy(); const bool bFocal(pFx || pFy); - if(userSpaceOnUse == rFillGradient.getGradientUnits()) + if (SvgUnits::userSpaceOnUse == rFillGradient.getGradientUnits()) { // all possible units - aStart.setX(rFillGradient.getCx().solve(mrOwner, xcoordinate)); - aStart.setY(rFillGradient.getCy().solve(mrOwner, ycoordinate)); + aStart.setX(rFillGradient.getCx().solve(mrOwner, NumberType::xcoordinate)); + aStart.setY(rFillGradient.getCy().solve(mrOwner, NumberType::ycoordinate)); fRadius = rFillGradient.getR().solve(mrOwner); if(bFocal) { - aFocal.setX(pFx ? pFx->solve(mrOwner, xcoordinate) : aStart.getX()); - aFocal.setY(pFy ? pFy->solve(mrOwner, ycoordinate) : aStart.getY()); + aFocal.setX(pFx ? pFx->solve(mrOwner, NumberType::xcoordinate) : aStart.getX()); + aFocal.setY(pFy ? pFy->solve(mrOwner, NumberType::ycoordinate) : aStart.getY()); } } else @@ -433,14 +433,14 @@ namespace svgio::svgreader const SvgNumber Cy(rFillGradient.getCy()); const SvgNumber R(rFillGradient.getR()); - aStart.setX(Unit_percent == Cx.getUnit() ? Cx.getNumber() * 0.01 : Cx.getNumber()); - aStart.setY(Unit_percent == Cy.getUnit() ? Cy.getNumber() * 0.01 : Cy.getNumber()); - fRadius = (Unit_percent == R.getUnit()) ? R.getNumber() * 0.01 : R.getNumber(); + aStart.setX(SvgUnit::percent == Cx.getUnit() ? Cx.getNumber() * 0.01 : Cx.getNumber()); + aStart.setY(SvgUnit::percent == Cy.getUnit() ? Cy.getNumber() * 0.01 : Cy.getNumber()); + fRadius = (SvgUnit::percent == R.getUnit()) ? R.getNumber() * 0.01 : R.getNumber(); if(bFocal) { - aFocal.setX(pFx ? (Unit_percent == pFx->getUnit() ? pFx->getNumber() * 0.01 : pFx->getNumber()) : aStart.getX()); - aFocal.setY(pFy ? (Unit_percent == pFy->getUnit() ? pFy->getNumber() * 0.01 : pFy->getNumber()) : aStart.getY()); + aFocal.setX(pFx ? (SvgUnit::percent == pFx->getUnit() ? pFx->getNumber() * 0.01 : pFx->getNumber()) : aStart.getX()); + aFocal.setY(pFy ? (SvgUnit::percent == pFy->getUnit() ? pFy->getNumber() * 0.01 : pFy->getNumber()) : aStart.getY()); } } @@ -462,7 +462,7 @@ namespace svgio::svgreader aSvgGradientEntryVector, aStart, fRadius, - userSpaceOnUse != rFillGradient.getGradientUnits(), + SvgUnits::userSpaceOnUse != rFillGradient.getGradientUnits(), rFillGradient.getSpreadMethod(), bFocal ? &aFocal : nullptr)); } @@ -558,9 +558,9 @@ namespace svgio::svgreader else { // use patternContentUnits - const SvgUnits aPatternContentUnits(rFillPattern.getPatternContentUnits() ? *rFillPattern.getPatternContentUnits() : userSpaceOnUse); + const SvgUnits aPatternContentUnits(rFillPattern.getPatternContentUnits() ? *rFillPattern.getPatternContentUnits() : SvgUnits::userSpaceOnUse); - if(userSpaceOnUse == aPatternContentUnits) + if (SvgUnits::userSpaceOnUse == aPatternContentUnits) { // create relative mapping to unit coordinates aMapPrimitivesToUnitRange.scale(1.0 / (fW * fTargetWidth), 1.0 / (fH * fTargetHeight)); @@ -829,8 +829,8 @@ namespace svgio::svgreader if(aPrimitiveRange.getWidth() > 0.0 && aPrimitiveRange.getHeight() > 0.0) { - double fTargetWidth(rMarker.getMarkerWidth().isSet() ? rMarker.getMarkerWidth().solve(mrOwner, xcoordinate) : 3.0); - double fTargetHeight(rMarker.getMarkerHeight().isSet() ? rMarker.getMarkerHeight().solve(mrOwner, xcoordinate) : 3.0); + double fTargetWidth(rMarker.getMarkerWidth().isSet() ? rMarker.getMarkerWidth().solve(mrOwner, NumberType::xcoordinate) : 3.0); + double fTargetHeight(rMarker.getMarkerHeight().isSet() ? rMarker.getMarkerHeight().solve(mrOwner, NumberType::xcoordinate) : 3.0); const bool bStrokeWidth(SvgMarkerNode::MarkerUnits::strokeWidth == rMarker.getMarkerUnits()); const double fStrokeWidth(getStrokeWidth().isSet() ? getStrokeWidth().solve(mrOwner) : 1.0); @@ -877,8 +877,8 @@ namespace svgio::svgreader // get and apply reference point. Initially it's in marker local coordinate system basegfx::B2DPoint aRefPoint( - rMarker.getRefX().isSet() ? rMarker.getRefX().solve(mrOwner, xcoordinate) : 0.0, - rMarker.getRefY().isSet() ? rMarker.getRefY().solve(mrOwner, ycoordinate) : 0.0); + rMarker.getRefX().isSet() ? rMarker.getRefX().solve(mrOwner, NumberType::xcoordinate) : 0.0, + rMarker.getRefY().isSet() ? rMarker.getRefY().solve(mrOwner, NumberType::ycoordinate) : 0.0); // apply MarkerTransform to have it in mapped coordinates aRefPoint *= rMarkerTransform; @@ -1189,7 +1189,7 @@ namespace svgio::svgreader const SvgClipPathNode* pClip = accessClipPathXLink(); while(pClip) { - // #i124852# transform may be needed when userSpaceOnUse + // #i124852# transform may be needed when SvgUnits::userSpaceOnUse pClip->apply(aSource, pTransform); pClip = pClip->getSvgStyleAttributes()->accessClipPathXLink(); } @@ -1199,7 +1199,7 @@ namespace svgio::svgreader const SvgMaskNode* pMask = accessMaskXLink(); if(pMask) { - // #i124852# transform may be needed when userSpaceOnUse + // #i124852# transform may be needed when SvgUnits::userSpaceOnUse pMask->apply(aSource, pTransform); } } @@ -1458,8 +1458,8 @@ namespace svgio::svgreader if(readSingleNumber(aContent, aNum)) { if(basegfx::fTools::moreOrEqual(aNum.getNumber(), 1.0)) - { //readSingleNumber sets Unit_px as default, if unit is missing. Correct it here. - maStrokeMiterLimit = SvgNumber(aNum.getNumber(), Unit_none); + { //readSingleNumber sets SvgUnit::px as default, if unit is missing. Correct it here. + maStrokeMiterLimit = SvgNumber(aNum.getNumber(), SvgUnit::none); } } break; @@ -1939,7 +1939,7 @@ namespace svgio::svgreader { maBaselineShiftNumber = aNum; - if(Unit_percent == aNum.getUnit()) + if(SvgUnit::percent == aNum.getUnit()) { setBaselineShift(BaselineShift_Percentage); } @@ -2467,7 +2467,7 @@ namespace svgio::svgreader } // default is 4 - return SvgNumber(4.0, Unit_none); + return SvgNumber(4.0, SvgUnit::none); } SvgNumber SvgStyleAttributes::getStrokeOpacity() const @@ -2523,10 +2523,10 @@ namespace svgio::svgreader if(!maFontSizeNumber.isPositive()) return aDefaultSize; - // #122524# Handle Unit_percent relative to parent FontSize (see SVG1.1 + // #122524# Handle SvgUnit::percent relative to parent FontSize (see SVG1.1 // spec 10.10 Font selection properties \91font-size\92, lastline (click 'normative // definition of the property') - if(Unit_percent == maFontSizeNumber.getUnit()) + if(SvgUnit::percent == maFontSizeNumber.getUnit()) { const SvgStyleAttributes* pSvgStyleAttributes = getParentStyle(); @@ -2542,9 +2542,9 @@ namespace svgio::svgreader // if there's no parent style, set the font size based on the default size // 100% = 16px return SvgNumber( - maFontSizeNumber.getNumber() * aDefaultSize / 100.0, Unit_px, true); + maFontSizeNumber.getNumber() * aDefaultSize / 100.0, SvgUnit::px, true); } - else if((Unit_em == maFontSizeNumber.getUnit()) || (Unit_ex == maFontSizeNumber.getUnit())) + else if((SvgUnit::em == maFontSizeNumber.getUnit()) || (SvgUnit::ex == maFontSizeNumber.getUnit())) { const SvgStyleAttributes* pSvgStyleAttributes = getParentStyle(); @@ -2987,8 +2987,8 @@ namespace svgio::svgreader SvgNumber SvgStyleAttributes::getBaselineShiftNumber() const { - // #122524# Handle Unit_percent relative to parent BaselineShift - if(Unit_percent == maBaselineShiftNumber.getUnit()) + // #122524# Handle SvgUnit::percent relative to parent BaselineShift + if(SvgUnit::percent == maBaselineShiftNumber.getUnit()) { const SvgStyleAttributes* pSvgStyleAttributes = getParentStyle(); diff --git a/svgio/source/svgreader/svgsvgnode.cxx b/svgio/source/svgreader/svgsvgnode.cxx index d071c1aed87b..57e7832ebce3 100644 --- a/svgio/source/svgreader/svgsvgnode.cxx +++ b/svgio/source/svgreader/svgsvgnode.cxx @@ -233,7 +233,7 @@ namespace svgio::svgreader // take absolute value or cumulate percentage if (pParentSvgSvgNode->getWidth().isSet()) { - if (Unit_percent == pParentSvgSvgNode->getWidth().getUnit()) + if (SvgUnit::percent == pParentSvgSvgNode->getWidth().getUnit()) { fPercentage *= pParentSvgSvgNode->getWidth().getNumber() * 0.01; } @@ -275,7 +275,7 @@ namespace svgio::svgreader // take absolute value or cumulate percentage if (pParentSvgSvgNode->getHeight().isSet()) { - if (Unit_percent == pParentSvgSvgNode->getHeight().getUnit()) + if (SvgUnit::percent == pParentSvgSvgNode->getHeight().getUnit()) { fPercentage *= pParentSvgSvgNode->getHeight().getNumber() * 0.01; } @@ -327,17 +327,17 @@ namespace svgio::svgreader // If width or height is not provided, the default 100% is used, see SVG 1.1 section 5.1.2 // value 0.0 here is only to initialize variable - bool bWidthIsAbsolute(getWidth().isSet() && Unit_percent != getWidth().getUnit()); + bool bWidthIsAbsolute(getWidth().isSet() && SvgUnit::percent != getWidth().getUnit()); double fW( bWidthIsAbsolute ? getWidth().solveNonPercentage(*this) : 0.0); - bool bHeightIsAbsolute(getHeight().isSet() && Unit_percent != getHeight().getUnit()); + bool bHeightIsAbsolute(getHeight().isSet() && SvgUnit::percent != getHeight().getUnit()); double fH( bHeightIsAbsolute ? getHeight().solveNonPercentage(*this) : 0.0); // If x or y not provided, then default 0.0 is used, see SVG 1.1 Section 5.1.2 - bool bXIsAbsolute((getX().isSet() && Unit_percent != getX().getUnit()) || !getX().isSet()); + bool bXIsAbsolute((getX().isSet() && SvgUnit::percent != getX().getUnit()) || !getX().isSet()); double fX( bXIsAbsolute && getX().isSet() ? getX().solveNonPercentage(*this) : 0.0); - bool bYIsAbsolute((getY().isSet() && Unit_percent != getY().getUnit()) || !getY().isSet()); + bool bYIsAbsolute((getY().isSet() && SvgUnit::percent != getY().getUnit()) || !getY().isSet()); double fY( bYIsAbsolute && getY().isSet() ? getY().solveNonPercentage(*this) : 0.0); if ( !bXIsAbsolute || !bWidthIsAbsolute) @@ -428,7 +428,7 @@ namespace svgio::svgreader // create mapping // #i122610 SVG 1.1 defines in section 5.1.2 that if the attribute preserveAspectRatio is not specified, // then the effect is as if a value of 'xMidYMid meet' were specified. - SvgAspectRatio aRatioDefault(Align_xMidYMid,true); + SvgAspectRatio aRatioDefault(SvgAlign::xMidYMid,true); const SvgAspectRatio& rRatio = getSvgAspectRatio().isSet()? getSvgAspectRatio() : aRatioDefault; // let mapping be created from SvgAspectRatio @@ -511,8 +511,8 @@ namespace svgio::svgreader // or by the width and height of the viewBox, if svg width or svg height is relative. // see SVG 1.1 section 7.12 bool bNeedsMapping(true); - const bool bWidthIsAbsolute(getWidth().isSet() && Unit_percent != getWidth().getUnit()); - const bool bHeightIsAbsolute(getHeight().isSet() && Unit_percent != getHeight().getUnit()); + const bool bWidthIsAbsolute(getWidth().isSet() && SvgUnit::percent != getWidth().getUnit()); + const bool bHeightIsAbsolute(getHeight().isSet() && SvgUnit::percent != getHeight().getUnit()); const double fViewBoxRatio(fViewBoxWidth/fViewBoxHeight); if(bWidthIsAbsolute && bHeightIsAbsolute) { @@ -562,7 +562,7 @@ namespace svgio::svgreader // create mapping // SVG 1.1 defines in section 5.1.2 that if the attribute preserveAspectRatio is not specified, // then the effect is as if a value of 'xMidYMid meet' were specified. - SvgAspectRatio aRatioDefault(Align_xMidYMid,true); + SvgAspectRatio aRatioDefault(SvgAlign::xMidYMid, true); const SvgAspectRatio& rRatio = getSvgAspectRatio().isSet()? getSvgAspectRatio() : aRatioDefault; basegfx::B2DHomMatrix aViewBoxMapping = rRatio.createMapping(aSvgCanvasRange, *pBox); @@ -581,8 +581,8 @@ namespace svgio::svgreader } else // no viewbox => no mapping { - const bool bWidthIsAbsolute(getWidth().isSet() && Unit_percent != getWidth().getUnit()); - const bool bHeightIsAbsolute(getHeight().isSet() && Unit_percent != getHeight().getUnit()); + const bool bWidthIsAbsolute(getWidth().isSet() && SvgUnit::percent != getWidth().getUnit()); + const bool bHeightIsAbsolute(getHeight().isSet() && SvgUnit::percent != getHeight().getUnit()); if (bWidthIsAbsolute && bHeightIsAbsolute) { fW =getWidth().solveNonPercentage(*this); @@ -738,16 +738,16 @@ namespace svgio::svgreader { // If width or height is not provided, the default 100% is used, see SVG 1.1 section 5.1.2 // value 0.0 here is only to initialize variable - bool bWidthIsAbsolute(getWidth().isSet() && Unit_percent != getWidth().getUnit()); + bool bWidthIsAbsolute(getWidth().isSet() && SvgUnit::percent != getWidth().getUnit()); double fW( bWidthIsAbsolute ? getWidth().solveNonPercentage(*this) : 0.0); - bool bHeightIsAbsolute(getHeight().isSet() && Unit_percent != getHeight().getUnit()); + bool bHeightIsAbsolute(getHeight().isSet() && SvgUnit::percent != getHeight().getUnit()); double fH( bHeightIsAbsolute ? getHeight().solveNonPercentage(*this) : 0.0); // If x or y not provided, then default 0.0 is used, see SVG 1.1 Section 5.1.2 - bool bXIsAbsolute((getX().isSet() && Unit_percent != getX().getUnit()) || !getX().isSet()); + bool bXIsAbsolute((getX().isSet() && SvgUnit::percent != getX().getUnit()) || !getX().isSet()); double fX( bXIsAbsolute && getX().isSet() ? getX().solveNonPercentage(*this) : 0.0); - bool bYIsAbsolute((getY().isSet() && Unit_percent != getY().getUnit()) || !getY().isSet()); + bool bYIsAbsolute((getY().isSet() && SvgUnit::percent != getY().getUnit()) || !getY().isSet()); double fY( bYIsAbsolute && getY().isSet() ? getY().solveNonPercentage(*this) : 0.0); if (bXIsAbsolute && bYIsAbsolute && bWidthIsAbsolute && bHeightIsAbsolute) @@ -808,8 +808,8 @@ namespace svgio::svgreader // If width or height is not provided, the default would be 100%, see SVG 1.1 section 5.1.2 // But here it cannot be resolved and no fallback exists. // SVG 1.1 defines in section 5.1.2 that x,y has no meaning for the outermost SVG element. - bool bWidthIsAbsolute(getWidth().isSet() && Unit_percent != getWidth().getUnit()); - bool bHeightIsAbsolute(getHeight().isSet() && Unit_percent != getHeight().getUnit()); + bool bWidthIsAbsolute(getWidth().isSet() && SvgUnit::percent != getWidth().getUnit()); + bool bHeightIsAbsolute(getHeight().isSet() && SvgUnit::percent != getHeight().getUnit()); if (bWidthIsAbsolute && bHeightIsAbsolute) { double fW( getWidth().solveNonPercentage(*this) ); diff --git a/svgio/source/svgreader/svgtextpathnode.cxx b/svgio/source/svgreader/svgtextpathnode.cxx index 46b749434c95..210d674b09ac 100644 --- a/svgio/source/svgreader/svgtextpathnode.cxx +++ b/svgio/source/svgreader/svgtextpathnode.cxx @@ -385,7 +385,7 @@ namespace svgio::svgreader if(getStartOffset().isSet()) { - if(Unit_percent == getStartOffset().getUnit()) + if (SvgUnit::percent == getStartOffset().getUnit()) { // percent are relative to path length fPosition = getStartOffset().getNumber() * 0.01 * fBasegfxPathLength; diff --git a/svgio/source/svgreader/svgtools.cxx b/svgio/source/svgreader/svgtools.cxx index 6a7f04f12055..beb735e2044e 100644 --- a/svgio/source/svgreader/svgtools.cxx +++ b/svgio/source/svgreader/svgtools.cxx @@ -53,7 +53,7 @@ namespace svgio::svgreader { // removed !isSet() from below. Due to correct defaults in the constructor an instance // of this class is perfectly useful without being set by any importer - if(Align_none == getSvgAlign()) + if(SvgAlign::none == getSvgAlign()) { // create linear mapping (default) return createLinearMapping(rTarget, rSource); @@ -79,18 +79,18 @@ namespace svgio::svgreader switch(getSvgAlign()) { - case Align_xMidYMin: - case Align_xMidYMid: - case Align_xMidYMax: + case SvgAlign::xMidYMin: + case SvgAlign::xMidYMid: + case SvgAlign::xMidYMax: { // centerX const double fFreeSpace(rTarget.getWidth() - fNewWidth); fTransX = fFreeSpace * 0.5; break; } - case Align_xMaxYMin: - case Align_xMaxYMid: - case Align_xMaxYMax: + case SvgAlign::xMaxYMin: + case SvgAlign::xMaxYMid: + case SvgAlign::xMaxYMax: { // Right align const double fFreeSpace(rTarget.getWidth() - fNewWidth); @@ -106,18 +106,18 @@ namespace svgio::svgreader switch(getSvgAlign()) { - case Align_xMinYMid: - case Align_xMidYMid: - case Align_xMaxYMid: + case SvgAlign::xMinYMid: + case SvgAlign::xMidYMid: + case SvgAlign::xMaxYMid: { // centerY const double fFreeSpace(rTarget.getHeight() - fNewHeight); fTransY = fFreeSpace * 0.5; break; } - case Align_xMinYMax: - case Align_xMidYMax: - case Align_xMaxYMax: + case SvgAlign::xMinYMax: + case SvgAlign::xMidYMax: + case SvgAlign::xMaxYMax: { // Bottom align const double fFreeSpace(rTarget.getHeight() - fNewHeight); @@ -141,39 +141,39 @@ namespace svgio::svgreader { switch(meUnit) { - case Unit_em: + case SvgUnit::em: { return mfNumber * rInfoProvider.getCurrentFontSizeInherited(); } - case Unit_ex: + case SvgUnit::ex: { return mfNumber * rInfoProvider.getCurrentXHeightInherited() * 0.5; } - case Unit_px: + case SvgUnit::px: { return mfNumber; } - case Unit_pt: - case Unit_pc: - case Unit_cm: - case Unit_mm: - case Unit_in: + case SvgUnit::pt: + case SvgUnit::pc: + case SvgUnit::cm: + case SvgUnit::mm: + case SvgUnit::in: { double fRetval(mfNumber); switch(meUnit) { - case Unit_pt: fRetval *= F_SVG_PIXEL_PER_INCH / 72.0; break; - case Unit_pc: fRetval *= F_SVG_PIXEL_PER_INCH / 6.0; break; - case Unit_cm: fRetval *= F_SVG_PIXEL_PER_INCH / 2.54; break; - case Unit_mm: fRetval *= 0.1 * F_SVG_PIXEL_PER_INCH / 2.54; break; - case Unit_in: fRetval *= F_SVG_PIXEL_PER_INCH; break; + case SvgUnit::pt: fRetval *= F_SVG_PIXEL_PER_INCH / 72.0; break; + case SvgUnit::pc: fRetval *= F_SVG_PIXEL_PER_INCH / 6.0; break; + case SvgUnit::cm: fRetval *= F_SVG_PIXEL_PER_INCH / 2.54; break; + case SvgUnit::mm: fRetval *= 0.1 * F_SVG_PIXEL_PER_INCH / 2.54; break; + case SvgUnit::in: fRetval *= F_SVG_PIXEL_PER_INCH; break; default: break; } return fRetval; } - case Unit_none: + case SvgUnit::none: { SAL_WARN("svgio", "Design error, this case should have been handled in the caller"); return mfNumber; @@ -197,22 +197,22 @@ namespace svgio::svgreader { switch(meUnit) { - case Unit_px: + case SvgUnit::px: { return mfNumber; } - case Unit_pt: - case Unit_pc: - case Unit_cm: - case Unit_mm: - case Unit_in: - case Unit_em: - case Unit_ex: - case Unit_none: + case SvgUnit::pt: + case SvgUnit::pc: + case SvgUnit::cm: + case SvgUnit::mm: + case SvgUnit::in: + case SvgUnit::em: + case SvgUnit::ex: + case SvgUnit::none: { return solveNonPercentage( rInfoProvider); } - case Unit_percent: + case SvgUnit::percent: { double fRetval(mfNumber * 0.01); basegfx::B2DRange aViewPort = rInfoProvider.getCurrentViewPort(); @@ -231,12 +231,12 @@ namespace svgio::svgreader if ( !aViewPort.isEmpty() ) { - if(xcoordinate == aNumberType) + if (NumberType::xcoordinate == aNumberType) { // it's a x-coordinate, relative to current width (w) fRetval *= aViewPort.getWidth(); } - else if(ycoordinate == aNumberType) + else if (NumberType::ycoordinate == aNumberType) { // it's a y-coordinate, relative to current height (h) fRetval *= aViewPort.getHeight(); @@ -423,7 +423,7 @@ namespace svgio::svgreader SvgUnit readUnit(std::u16string_view rCandidate, sal_Int32& nPos, const sal_Int32 nLen) { - SvgUnit aRetval(Unit_px); + SvgUnit aRetval(SvgUnit::px); if(nPos < nLen) { @@ -441,13 +441,13 @@ namespace svgio::svgreader if('m' == aCharB) { // 'em' Relative to current font size - aRetval = Unit_em; + aRetval = SvgUnit::em; bTwoCharValid = true; } else if('x' == aCharB) { // 'ex' Relative to current font x-height - aRetval = Unit_ex; + aRetval = SvgUnit::ex; bTwoCharValid = true; } break; @@ -462,13 +462,13 @@ namespace svgio::svgreader else if('t' == aCharB) { // 'pt' == 4/3 px - aRetval = Unit_pt; + aRetval = SvgUnit::pt; bTwoCharValid = true; } else if('c' == aCharB) { // 'pc' == 16 px - aRetval = Unit_pc; + aRetval = SvgUnit::pc; bTwoCharValid = true; } break; @@ -478,7 +478,7 @@ namespace svgio::svgreader if('n' == aCharB) { // 'in' == 96 px, since CSS 2.1 - aRetval = Unit_in; + aRetval = SvgUnit::in; bTwoCharValid = true; } break; @@ -488,7 +488,7 @@ namespace svgio::svgreader if('m' == aCharB) { // 'cm' == 37.79527559 px - aRetval = Unit_cm; + aRetval = SvgUnit::cm; bTwoCharValid = true; } break; @@ -498,7 +498,7 @@ namespace svgio::svgreader if('m' == aCharB) { // 'mm' == 3.779528 px - aRetval = Unit_mm; + aRetval = SvgUnit::mm; bTwoCharValid = true; } break; @@ -516,7 +516,7 @@ namespace svgio::svgreader { // percent used, relative to current nPos++; - aRetval = Unit_percent; + aRetval = SvgUnit::percent; } } } @@ -973,10 +973,10 @@ namespace svgio::svgreader if(readNumberAndUnit(rCandidate, nPos, aHeight, nLen)) { - double fX(aMinX.solve(rInfoProvider, xcoordinate)); - double fY(aMinY.solve(rInfoProvider, ycoordinate)); - double fW(aWidth.solve(rInfoProvider,xcoordinate)); - double fH(aHeight.solve(rInfoProvider,ycoordinate)); + double fX(aMinX.solve(rInfoProvider, NumberType::xcoordinate)); + double fY(aMinY.solve(rInfoProvider, NumberType::ycoordinate)); + double fW(aWidth.solve(rInfoProvider, NumberType::xcoordinate)); + double fH(aHeight.solve(rInfoProvider, NumberType::ycoordinate)); return basegfx::B2DRange(fX,fY,fX+fW,fY+fH); } } @@ -1042,12 +1042,12 @@ namespace svgio::svgreader if(readNumberAndUnit(rCandidate, nPos, aVal, nLen)) { - aNew.set(0, 2, aVal.solve(rInfoProvider, xcoordinate)); // Element E + aNew.set(0, 2, aVal.solve(rInfoProvider, NumberType::xcoordinate)); // Element E skip_char(rCandidate, ' ', ',', nPos, nLen); if(readNumberAndUnit(rCandidate, nPos, aVal, nLen)) { - aNew.set(1, 2, aVal.solve(rInfoProvider, ycoordinate)); // Element F + aNew.set(1, 2, aVal.solve(rInfoProvider, NumberType::ycoordinate)); // Element F skip_char(rCandidate, ' ', ')', nPos, nLen); skip_char(rCandidate, ' ', ',', nPos, nLen); @@ -1082,8 +1082,8 @@ namespace svgio::svgreader skip_char(rCandidate, ' ', ',', nPos, nLen); aMatrix = aMatrix * basegfx::utils::createTranslateB2DHomMatrix( - aTransX.solve(rInfoProvider, xcoordinate), - aTransY.solve(rInfoProvider, ycoordinate)); + aTransX.solve(rInfoProvider, NumberType::xcoordinate), + aTransY.solve(rInfoProvider, NumberType::ycoordinate)); } } break; @@ -1162,8 +1162,8 @@ namespace svgio::svgreader skip_char(rCandidate, ' ', ')', nPos, nLen); skip_char(rCandidate, ' ', ',', nPos, nLen); - const double fX(aX.isSet() ? aX.solve(rInfoProvider, xcoordinate) : 0.0); - const double fY(aY.isSet() ? aY.solve(rInfoProvider, ycoordinate) : 0.0); + const double fX(aX.isSet() ? aX.solve(rInfoProvider, NumberType::xcoordinate) : 0.0); + const double fY(aY.isSet() ? aY.solve(rInfoProvider, NumberType::ycoordinate) : 0.0); if(!basegfx::fTools::equalZero(fX) || !basegfx::fTools::equalZero(fY)) { @@ -1285,7 +1285,7 @@ namespace svgio::svgreader if(nLen) { sal_Int32 nPos(0); - SvgAlign aSvgAlign(Align_xMidYMid); + SvgAlign aSvgAlign(SvgAlign::xMidYMid); bool bMeetOrSlice(true); bool bChanged(false); @@ -1307,61 +1307,61 @@ namespace svgio::svgreader } case SVGToken::None: { - aSvgAlign = Align_none; + aSvgAlign = SvgAlign::none; bChanged = true; break; } case SVGToken::XMinYMin: { - aSvgAlign = Align_xMinYMin; + aSvgAlign = SvgAlign::xMinYMin; bChanged = true; break; } case SVGToken::XMidYMin: { - aSvgAlign = Align_xMidYMin; + aSvgAlign = SvgAlign::xMidYMin; bChanged = true; break; } case SVGToken::XMaxYMin: { - aSvgAlign = Align_xMaxYMin; + aSvgAlign = SvgAlign::xMaxYMin; bChanged = true; break; } case SVGToken::XMinYMid: { - aSvgAlign = Align_xMinYMid; + aSvgAlign = SvgAlign::xMinYMid; bChanged = true; break; } case SVGToken::XMidYMid: { - aSvgAlign = Align_xMidYMid; + aSvgAlign = SvgAlign::xMidYMid; bChanged = true; break; } case SVGToken::XMaxYMid: { - aSvgAlign = Align_xMaxYMid; + aSvgAlign = SvgAlign::xMaxYMid; bChanged = true; break; } case SVGToken::XMinYMax: { - aSvgAlign = Align_xMinYMax; + aSvgAlign = SvgAlign::xMinYMax; bChanged = true; break; } case SVGToken::XMidYMax: { - aSvgAlign = Align_xMidYMax; + aSvgAlign = SvgAlign::xMidYMax; bChanged = true; break; } case SVGToken::XMaxYMax: { - aSvgAlign = Align_xMaxYMax; + aSvgAlign = SvgAlign::xMaxYMax; bChanged = true; break; } diff --git a/svgio/source/svgreader/svgusenode.cxx b/svgio/source/svgreader/svgusenode.cxx index ce305ed98ea2..e4b59ba733e3 100644 --- a/svgio/source/svgreader/svgusenode.cxx +++ b/svgio/source/svgreader/svgusenode.cxx @@ -163,8 +163,8 @@ namespace svgio::svgreader if(getX().isSet() || getY().isSet()) { aTransform.translate( - getX().solve(*this, xcoordinate), - getY().solve(*this, ycoordinate)); + getX().solve(*this, NumberType::xcoordinate), + getY().solve(*this, NumberType::ycoordinate)); } if(getTransform()) |