Kaydet (Commit) ecc7f698 authored tarafından Xisco Fauli's avatar Xisco Fauli Kaydeden (comit) Noel Grandin

SVGIO: Fix problem when style's parent contains a mask element

Change-Id: I26aab6c0f959f6cc78d040f59f1acf0c7e29931b
Reviewed-on: https://gerrit.libreoffice.org/23045Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noelgrandin@gmail.com>
üst 49b78749
......@@ -33,6 +33,7 @@ namespace svgio { namespace svgreader {
class SvgPatternNode;
class SvgMarkerNode;
class SvgClipPathNode;
class SvgMaskNode;
}}
......@@ -218,6 +219,7 @@ namespace svgio
OUString maClipPathXLink;
const SvgClipPathNode* mpClipPathXLink;
OUString maMaskXLink;
const SvgMaskNode* mpMaskXLink;
/// link to markers. If set, the node can be fetched on demand
OUString maMarkerStartXLink;
......@@ -447,7 +449,8 @@ namespace svgio
const SvgClipPathNode* accessClipPathXLink() const;
// MaskXLink content
const OUString getMaskXLink() const { return maMaskXLink; }
OUString getMaskXLink() const;
const SvgMaskNode* accessMaskXLink() const;
// MarkerStartXLink content
OUString getMarkerStartXLink() const;
......
......@@ -1154,16 +1154,11 @@ namespace svgio
if(!aSource.empty()) // test again, applied clipPath may have lead to empty geometry
{
if(!getMaskXLink().isEmpty())
const SvgMaskNode* mpMask = accessMaskXLink();
if(mpMask)
{
// try to access linked Mask
const SvgMaskNode* mpMask = dynamic_cast< const SvgMaskNode* >(mrOwner.getDocument().findSvgNodeById(getMaskXLink()));
if(mpMask)
{
// #i124852# transform may be needed when userSpaceOnUse
mpMask->apply(aSource, pTransform);
}
// #i124852# transform may be needed when userSpaceOnUse
mpMask->apply(aSource, pTransform);
}
if(!aSource.empty()) // test again, applied mask may have lead to empty geometry
......@@ -1212,6 +1207,7 @@ namespace svgio
maClipPathXLink(),
mpClipPathXLink(nullptr),
maMaskXLink(),
mpMaskXLink(nullptr),
maMarkerStartXLink(),
mpMarkerStartXLink(nullptr),
maMarkerMidXLink(),
......@@ -2687,6 +2683,38 @@ namespace svgio
return mpClipPathXLink;
}
OUString SvgStyleAttributes::getMaskXLink() const
{
if(!maMaskXLink.isEmpty())
{
return maMaskXLink;
}
const SvgStyleAttributes* pSvgStyleAttributes = getParentStyle();
if(pSvgStyleAttributes && !pSvgStyleAttributes->maMaskXLink.isEmpty())
{
return pSvgStyleAttributes->getMaskXLink();
}
return OUString();
}
const SvgMaskNode* SvgStyleAttributes::accessMaskXLink() const
{
if(!mpMaskXLink)
{
const OUString aMask(getMaskXLink());
if(!aMask.isEmpty())
{
const_cast< SvgStyleAttributes* >(this)->mpMaskXLink = dynamic_cast< const SvgMaskNode* >(mrOwner.getDocument().findSvgNodeById(getMaskXLink()));
}
}
return mpMaskXLink;
}
OUString SvgStyleAttributes::getMarkerStartXLink() const
{
if(!maMarkerStartXLink.isEmpty())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment