summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2023-09-25 09:03:54 +0200
committerTomaž Vajngerl <quikee@gmail.com>2023-12-06 08:23:34 +0100
commit1db193c6c744289139b1df2af0b8defcf974b238 (patch)
tree2651e967a8fb4c72ea7b715ee48aef648b993b62 /oox
parentfa38d98155a857908641380c7a1a5a34fafe934e (diff)
tdf#126084 import svg image from ooxml document that use svgBlip elem.
In an OOXML document the svg image is defined in an svgBlip, which is an OOXML extension. This change checks for the svgBlip element and imports that instead the normal "blip" element that is still provided as a fallback (PNG image). Add roundtrip SVG image test for ODF and OOXML, Impress and Writer. testGraphicBlipXLSX test failed after this change, because some component was missing. Changed to enable use_rdb for all chart2 export tests, so issues like this won't happen anymore. Change-Id: Idf0e754775254d7dcfd0321dfca2ed6d00c42c09 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157238 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'oox')
-rw-r--r--oox/inc/drawingml/misccontexts.hxx4
-rw-r--r--oox/source/core/xmlfilterbase.cxx1
-rw-r--r--oox/source/drawingml/misccontexts.cxx37
3 files changed, 31 insertions, 11 deletions
diff --git a/oox/inc/drawingml/misccontexts.hxx b/oox/inc/drawingml/misccontexts.hxx
index c79816282ae7..1b7f05444ac7 100644
--- a/oox/inc/drawingml/misccontexts.hxx
+++ b/oox/inc/drawingml/misccontexts.hxx
@@ -102,7 +102,8 @@ class BlipExtensionContext final : public ::oox::core::ContextHandler2
public:
explicit BlipExtensionContext(
::oox::core::ContextHandler2Helper const & rParent,
- BlipFillProperties& rBlipProps );
+ BlipFillProperties& rBlipProps,
+ model::BlipFill* pBlipFill);
virtual ~BlipExtensionContext() override;
virtual ::oox::core::ContextHandlerRef
@@ -112,6 +113,7 @@ public:
private:
BlipFillProperties& mrBlipProps;
+ model::BlipFill* mpBlipFill;
};
diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx
index d197440133da..93b5816812a1 100644
--- a/oox/source/core/xmlfilterbase.cxx
+++ b/oox/source/core/xmlfilterbase.cxx
@@ -149,6 +149,7 @@ const Sequence< beans::Pair< OUString, sal_Int32 > >& NamespaceIds()
{"http://schemas.microsoft.com/office/spreadsheetml/2015/revision2",
NMSP_xr2},
{"http://schemas.microsoft.com/office/drawing/2017/decorative", NMSP_adec},
+ {"http://schemas.microsoft.com/office/drawing/2016/SVG/main", NMSP_asvg},
};
return SINGLETON;
};
diff --git a/oox/source/drawingml/misccontexts.cxx b/oox/source/drawingml/misccontexts.cxx
index 2eef9ab6133a..244d17d9fc62 100644
--- a/oox/source/drawingml/misccontexts.cxx
+++ b/oox/source/drawingml/misccontexts.cxx
@@ -369,7 +369,7 @@ ContextHandlerRef BlipContext::onCreateContext(
return new DuotoneContext( *this, mrBlipProps );
case A_TOKEN( extLst ):
- return new BlipExtensionContext( *this, mrBlipProps );
+ return new BlipExtensionContext(*this, mrBlipProps, mpBlipFill);
case A_TOKEN( lum ):
{
@@ -598,9 +598,10 @@ SimpleFillPropertiesContext::~SimpleFillPropertiesContext()
mrColor = getBestSolidColor();
}
-BlipExtensionContext::BlipExtensionContext( ContextHandler2Helper const & rParent, BlipFillProperties& rBlipProps ) :
- ContextHandler2( rParent ),
- mrBlipProps( rBlipProps )
+BlipExtensionContext::BlipExtensionContext(ContextHandler2Helper const & rParent, BlipFillProperties& rBlipProps, model::BlipFill* pBlipFill)
+ : ContextHandler2(rParent)
+ , mrBlipProps(rBlipProps)
+ , mpBlipFill(pBlipFill)
{
}
@@ -608,16 +609,32 @@ BlipExtensionContext::~BlipExtensionContext()
{
}
-ContextHandlerRef BlipExtensionContext::onCreateContext(
- sal_Int32 nElement, const AttributeList& )
+ContextHandlerRef BlipExtensionContext::onCreateContext(sal_Int32 nElement, const AttributeList& rAttribs)
{
switch( nElement )
{
- case A_TOKEN( ext ):
- return new BlipExtensionContext( *this, mrBlipProps );
+ case A_TOKEN(ext):
+ return new BlipExtensionContext(*this, mrBlipProps, mpBlipFill);
+
+ case OOX_TOKEN(a14, imgProps):
+ return new ArtisticEffectContext(*this, mrBlipProps.maEffect);
- case OOX_TOKEN( a14, imgProps ):
- return new ArtisticEffectContext( *this, mrBlipProps.maEffect );
+ case OOX_TOKEN(asvg, svgBlip):
+ {
+ if (rAttribs.hasAttribute(R_TOKEN(embed)))
+ {
+ // internal picture URL
+ OUString aFragmentPath = getFragmentPathFromRelId(rAttribs.getStringDefaulted(R_TOKEN(embed)));
+ if (!aFragmentPath.isEmpty())
+ {
+ auto xGraphic = getFilter().getGraphicHelper().importEmbeddedGraphic(aFragmentPath);
+ mrBlipProps.mxFillGraphic = xGraphic;
+ if (mpBlipFill)
+ mpBlipFill->mxGraphic = xGraphic;
+ }
+ }
+ }
+ break;
}
return nullptr;
}