summaryrefslogtreecommitdiff
path: root/svgio/source
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2023-06-14 12:39:06 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2023-06-14 21:08:17 +0200
commit41bf4139cab36984cff514bfdd6b1b13576746a3 (patch)
treef976deb977ad2b7bc372b1193fde8984a3842bd8 /svgio/source
parentb6474249caa697513affdbcb02c7a69fda8203be (diff)
tdf#155735: Add support for saturate type
Add getModifierName to BColorModifier class so when can assert which modifier is being used Change-Id: I2bc2a36470a449df4dc84a8440f232149c1f8278 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153048 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'svgio/source')
-rw-r--r--svgio/source/svgreader/svgfecolormatrixnode.cxx29
-rw-r--r--svgio/source/svgreader/svgtoken.cxx2
2 files changed, 28 insertions, 3 deletions
diff --git a/svgio/source/svgreader/svgfecolormatrixnode.cxx b/svgio/source/svgreader/svgfecolormatrixnode.cxx
index fb53f1d5c503..2a02ddc3c0bd 100644
--- a/svgio/source/svgreader/svgfecolormatrixnode.cxx
+++ b/svgio/source/svgreader/svgfecolormatrixnode.cxx
@@ -25,7 +25,8 @@ namespace svgio::svgreader
{
SvgFeColorMatrixNode::SvgFeColorMatrixNode(SvgDocument& rDocument, SvgNode* pParent)
: SvgNode(SVGToken::FeColorMatrix, rDocument, pParent)
- , maType(Type::None)
+ , maType(ColorType::None)
+ , maValues(1.0)
{
}
@@ -43,8 +44,22 @@ void SvgFeColorMatrixNode::parseAttribute(const OUString& /*rTokenName*/, SVGTok
{
if (o3tl::equalsIgnoreAsciiCase(o3tl::trim(aContent), u"luminanceToAlpha"))
{
- maType = Type::LuminanceToAlpha;
+ maType = ColorType::LuminanceToAlpha;
}
+ else if (o3tl::equalsIgnoreAsciiCase(o3tl::trim(aContent), u"saturate"))
+ {
+ maType = ColorType::Saturate;
+ }
+ }
+ break;
+ }
+ case SVGToken::Values:
+ {
+ SvgNumber aNum;
+
+ if (readSingleNumber(aContent, aNum))
+ {
+ maValues = aNum;
}
break;
}
@@ -57,7 +72,7 @@ void SvgFeColorMatrixNode::parseAttribute(const OUString& /*rTokenName*/, SVGTok
void SvgFeColorMatrixNode::apply(drawinglayer::primitive2d::Primitive2DContainer& rTarget) const
{
- if (maType == Type::LuminanceToAlpha)
+ if (maType == ColorType::LuminanceToAlpha)
{
const drawinglayer::primitive2d::Primitive2DReference xRef(
new drawinglayer::primitive2d::ModifiedColorPrimitive2D(
@@ -65,6 +80,14 @@ void SvgFeColorMatrixNode::apply(drawinglayer::primitive2d::Primitive2DContainer
std::make_shared<basegfx::BColorModifier_luminance_to_alpha>()));
rTarget = drawinglayer::primitive2d::Primitive2DContainer{ xRef };
}
+ else if (maType == ColorType::Saturate)
+ {
+ const drawinglayer::primitive2d::Primitive2DReference xRef(
+ new drawinglayer::primitive2d::ModifiedColorPrimitive2D(
+ std::move(rTarget),
+ std::make_shared<basegfx::BColorModifier_saturate>(maValues.getNumber())));
+ rTarget = drawinglayer::primitive2d::Primitive2DContainer{ xRef };
+ }
}
} // end of namespace svgio::svgreader
diff --git a/svgio/source/svgreader/svgtoken.cxx b/svgio/source/svgreader/svgtoken.cxx
index 8228689606bf..09ed13459b2e 100644
--- a/svgio/source/svgreader/svgtoken.cxx
+++ b/svgio/source/svgreader/svgtoken.cxx
@@ -113,6 +113,7 @@ namespace svgio::svgreader
const char aSVGStrXMaxYMax[] = "xMaxYMax";
const char aSVGStrMeet[] = "meet";
const char aSVGStrSlice[] = "slice";
+ const char aSVGStrValues[] = "values";
const char aSVGStrDefs[] = "defs";
const char aSVGStrG[] = "g";
@@ -265,6 +266,7 @@ namespace svgio::svgreader
{ aSVGStrXMaxYMax, SVGToken::XMaxYMax },
{ aSVGStrMeet, SVGToken::Meet },
{ aSVGStrSlice, SVGToken::Slice },
+ { aSVGStrValues, SVGToken::Values },
{ aSVGStrDefs, SVGToken::Defs },
{ aSVGStrG, SVGToken::G },