summaryrefslogtreecommitdiffstats
path: root/svgio/source/svgreader/svgstyleattributes.cxx
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 11:48:25 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 11:48:25 +0000
commit9c0049cfae49c8e4ddef9125a69db2ad134c10c6 (patch)
tree812a86c0eee63dfc5ace12f2622ed3ce9cd3d680 /svgio/source/svgreader/svgstyleattributes.cxx
parentReleasing progress-linux version 4:24.2.3-2~progress7.99u1. (diff)
downloadlibreoffice-9c0049cfae49c8e4ddef9125a69db2ad134c10c6.tar.xz
libreoffice-9c0049cfae49c8e4ddef9125a69db2ad134c10c6.zip
Merging upstream version 4:24.2.4.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'svgio/source/svgreader/svgstyleattributes.cxx')
-rw-r--r--svgio/source/svgreader/svgstyleattributes.cxx80
1 files changed, 72 insertions, 8 deletions
diff --git a/svgio/source/svgreader/svgstyleattributes.cxx b/svgio/source/svgreader/svgstyleattributes.cxx
index 58bdb9add8..42e19c51fc 100644
--- a/svgio/source/svgreader/svgstyleattributes.cxx
+++ b/svgio/source/svgreader/svgstyleattributes.cxx
@@ -817,6 +817,16 @@ namespace svgio::svgreader
rMarkerTransform.identity();
rClipRange.reset();
+ // Set the current fill to the marker before calling getMarkerPrimitives,
+ // which calls decomposeSvgNode to decompose the children of the marker.
+ // If any of the children uses 'fill="context-fill"', then it will use it
+ const_cast<SvgStyleAttributes*>(rMarker.getSvgStyleAttributes())->maContextFill = getFill();
+
+ // Set the current stroke to the marker before calling getMarkerPrimitives,
+ // which calls decomposeSvgNode to decompose the children of the marker.
+ // If any of the children uses 'stroke="context-stroke"', then it will use it
+ const_cast<SvgStyleAttributes*>(rMarker.getSvgStyleAttributes())->maContextStroke = getStroke();
+
// get marker primitive representation
rMarkerPrimitives = rMarker.getMarkerPrimitives();
@@ -1287,8 +1297,12 @@ namespace svgio::svgreader
maBaselineShift(BaselineShift::Baseline),
maBaselineShiftNumber(0),
maDominantBaseline(DominantBaseline::Auto),
- maResolvingParent(32, 0),
- mbStrokeDasharraySet(false)
+ maResolvingParent(34, 0),
+ mbStrokeDasharraySet(false),
+ mbContextFill(false),
+ mbContextStroke(false),
+ maContextFill(nullptr),
+ maContextStroke(nullptr)
{
}
@@ -1308,7 +1322,11 @@ namespace svgio::svgreader
OUString aURL;
SvgNumber aOpacity;
- if(readSvgPaint(aContent, aSvgPaint, aURL, aOpacity))
+ if(o3tl::equalsIgnoreAsciiCase(o3tl::trim(aContent), u"context-fill"))
+ {
+ mbContextFill = true;
+ }
+ else if(readSvgPaint(aContent, aSvgPaint, aURL, aOpacity))
{
setFill(aSvgPaint);
if(aOpacity.isSet())
@@ -1353,7 +1371,11 @@ namespace svgio::svgreader
OUString aURL;
SvgNumber aOpacity;
- if(readSvgPaint(aContent, aSvgPaint, aURL, aOpacity))
+ if(o3tl::equalsIgnoreAsciiCase(o3tl::trim(aContent), u"context-stroke"))
+ {
+ mbContextStroke = true;
+ }
+ else if(readSvgPaint(aContent, aSvgPaint, aURL, aOpacity))
{
maStroke = aSvgPaint;
if(aOpacity.isSet())
@@ -1996,6 +2018,40 @@ namespace svgio::svgreader
}
}
+ const basegfx::BColor* SvgStyleAttributes::getContextFill() const
+ {
+ if (SVGToken::Marker == mrOwner.getType())
+ return maContextFill;
+
+ const SvgStyleAttributes* pSvgStyleAttributes = getParentStyle();
+ if (pSvgStyleAttributes && maResolvingParent[33] < nStyleDepthLimit)
+ {
+ ++maResolvingParent[33];
+ auto ret = pSvgStyleAttributes->getContextFill();
+ --maResolvingParent[33];
+ return ret;
+ }
+
+ return nullptr;
+ }
+
+ const basegfx::BColor* SvgStyleAttributes::getContextStroke() const
+ {
+ if (SVGToken::Marker == mrOwner.getType())
+ return maContextStroke;
+
+ const SvgStyleAttributes* pSvgStyleAttributes = getParentStyle();
+ if (pSvgStyleAttributes && maResolvingParent[32] < nStyleDepthLimit)
+ {
+ ++maResolvingParent[32];
+ auto ret = pSvgStyleAttributes->getContextStroke();
+ --maResolvingParent[32];
+ return ret;
+ }
+
+ return nullptr;
+ }
+
bool SvgStyleAttributes::isClipPathContent() const
{
if (SVGToken::ClipPathNode == mrOwner.getType())
@@ -2064,6 +2120,10 @@ namespace svgio::svgreader
}
}
}
+ else if (mbContextFill)
+ {
+ return getContextFill();
+ }
else if (maNodeFillURL.isEmpty())
{
const SvgStyleAttributes* pSvgStyleAttributes = getParentStyle();
@@ -2109,6 +2169,10 @@ namespace svgio::svgreader
return &maStroke.getBColor();
}
}
+ else if (mbContextStroke)
+ {
+ return getContextStroke();
+ }
else if (maNodeStrokeURL.isEmpty())
{
const SvgStyleAttributes* pSvgStyleAttributes = getParentStyle();
@@ -2642,11 +2706,11 @@ namespace svgio::svgreader
if(pSvgStyleAttributes)
{
const SvgNumber aParentNumber = pSvgStyleAttributes->getFontSizeNumber();
+ double n = aParentNumber.getNumber() * maFontSizeNumber.getNumber();
+ if (SvgUnit::ex == maFontSizeNumber.getUnit())
+ n *= 0.5; // FIXME: use "x-height of the first available font"
- return SvgNumber(
- aParentNumber.getNumber() * maFontSizeNumber.getNumber(),
- aParentNumber.getUnit(),
- true);
+ return SvgNumber(n, aParentNumber.getUnit());
}
}