summaryrefslogtreecommitdiff
path: root/svgio/source/svgreader/svgstyleattributes.cxx
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2023-07-10 14:46:34 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2023-07-10 16:54:06 +0200
commit56039daae4a436d7ea1b093a02cf0e8ad3bda4a9 (patch)
tree0b4e73635d20fe250d26146ce7b6bd9033185ff4 /svgio/source/svgreader/svgstyleattributes.cxx
parent3d5b5914ef56395a8ba3d4c0a2eff8a5c52046b4 (diff)
tdf#149673: only check opacity from parent...
... if it has a local css style Because it's the first in the style stack Partially reverts 3e0e67a152e9631574e28dacb6e06a96f03ebca2 "tdf#155932: tdf#97717: only apply opacity when primitive" Change-Id: I6a6bf08a519c84ac58c6111fd7da308cbf8a3021 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154270 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'svgio/source/svgreader/svgstyleattributes.cxx')
-rw-r--r--svgio/source/svgreader/svgstyleattributes.cxx46
1 files changed, 21 insertions, 25 deletions
diff --git a/svgio/source/svgreader/svgstyleattributes.cxx b/svgio/source/svgreader/svgstyleattributes.cxx
index 91c27aeff637..fd4482057f17 100644
--- a/svgio/source/svgreader/svgstyleattributes.cxx
+++ b/svgio/source/svgreader/svgstyleattributes.cxx
@@ -1163,8 +1163,7 @@ namespace svgio::svgreader
void SvgStyleAttributes::add_postProcess(
drawinglayer::primitive2d::Primitive2DContainer& rTarget,
drawinglayer::primitive2d::Primitive2DContainer&& rSource,
- const std::optional<basegfx::B2DHomMatrix>& pTransform,
- bool bIsPrimitive) const
+ const std::optional<basegfx::B2DHomMatrix>& pTransform) const
{
const double fOpacity(getOpacity().solve(mrOwner));
@@ -1175,20 +1174,15 @@ namespace svgio::svgreader
drawinglayer::primitive2d::Primitive2DContainer aSource(std::move(rSource));
- // tdf#97717: only apply opacity when it's a primitive, otherwise, it might be
- // applied more than once, since getOpacity() checks the parents
- if (bIsPrimitive)
+ if(basegfx::fTools::less(fOpacity, 1.0))
{
- if(basegfx::fTools::less(fOpacity, 1.0))
- {
- // embed in UnifiedTransparencePrimitive2D
- const drawinglayer::primitive2d::Primitive2DReference xRef(
- new drawinglayer::primitive2d::UnifiedTransparencePrimitive2D(
- std::move(aSource),
- 1.0 - fOpacity));
+ // embed in UnifiedTransparencePrimitive2D
+ const drawinglayer::primitive2d::Primitive2DReference xRef(
+ new drawinglayer::primitive2d::UnifiedTransparencePrimitive2D(
+ std::move(aSource),
+ 1.0 - fOpacity));
- aSource = drawinglayer::primitive2d::Primitive2DContainer { xRef };
- }
+ aSource = drawinglayer::primitive2d::Primitive2DContainer { xRef };
}
if(pTransform)
@@ -1291,7 +1285,7 @@ namespace svgio::svgreader
maClipRule(FillRule::notset),
maBaselineShift(BaselineShift::Baseline),
maBaselineShiftNumber(0),
- maResolvingParent(30, 0),
+ maResolvingParent(29, 0),
mbIsClipPathContent(SVGToken::ClipPathNode == mrOwner.getType()),
mbStrokeDasharraySet(false)
{
@@ -2282,14 +2276,16 @@ namespace svgio::svgreader
return maOpacity;
}
- const SvgStyleAttributes* pSvgStyleAttributes = getParentStyle();
-
- if (pSvgStyleAttributes && maResolvingParent[8] < nStyleDepthLimit)
+ // This is called from add_postProcess so only check the parent style
+ // if it has a local css style, because it's the first in the stack
+ if(mrOwner.hasLocalCssStyle())
{
- ++maResolvingParent[8];
- auto ret = pSvgStyleAttributes->getOpacity();
- --maResolvingParent[8];
- return ret;
+ const SvgStyleAttributes* pSvgStyleAttributes = getParentStyle();
+
+ if (pSvgStyleAttributes && pSvgStyleAttributes->maOpacity.isSet())
+ {
+ return pSvgStyleAttributes->maOpacity;
+ }
}
// default is 1
@@ -3051,11 +3047,11 @@ namespace svgio::svgreader
{
const SvgStyleAttributes* pSvgStyleAttributes = getParentStyle();
- if (pSvgStyleAttributes && maResolvingParent[29] < nStyleDepthLimit)
+ if (pSvgStyleAttributes && maResolvingParent[8] < nStyleDepthLimit)
{
- ++maResolvingParent[29];
+ ++maResolvingParent[8];
const SvgNumber aParentNumber = pSvgStyleAttributes->getBaselineShiftNumber();
- --maResolvingParent[29];
+ --maResolvingParent[8];
return SvgNumber(
aParentNumber.getNumber() * maBaselineShiftNumber.getNumber() * 0.01,