diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2020-09-07 17:00:44 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-09-08 12:27:32 +0200 |
commit | 5ebfd7e82fef5c8cf509917ea7f04bc1314be0f7 (patch) | |
tree | 3e5784cba5f28bb6d7df9c00153a4943313329dc | |
parent | f3d2a591db8b14d5d83ec6f7e7d4273b44f0a354 (diff) |
SVG export: fix failure on trying to read graphic of a 3D shape
Regression from commit 8fc1b60f62c213a0476f3acc9f89cd5eccbf335d (sw SVG
export: try to reuse original bitmap data for JPG and PNG bitmaps,
2020-02-27), which generalized the code that tries to get the original
bitmap of shapes for performance reasons. Originally this worked with
SdrGrafObj, but now we try every XShape which has a Graphic property.
Add the missing check, so shapes without a graphic property just miss
the fast path, but doesn't fail the entire SVG export.
(cherry picked from commit fbcdbfef8664430e15b9429187b58dede992accf)
Conflicts:
filter/qa/unit/svg.cxx
filter/source/svg/svgexport.cxx
Change-Id: I6b20083110f3269337b9df6a23bd193cc6f7d13b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102223
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
-rw-r--r-- | filter/qa/unit/data/shape-nographic.odp | bin | 0 -> 14769 bytes | |||
-rw-r--r-- | filter/qa/unit/svg.cxx | 19 | ||||
-rw-r--r-- | filter/source/svg/svgexport.cxx | 3 | ||||
-rw-r--r-- | filter/source/svg/svgwriter.cxx | 5 |
4 files changed, 25 insertions, 2 deletions
diff --git a/filter/qa/unit/data/shape-nographic.odp b/filter/qa/unit/data/shape-nographic.odp Binary files differnew file mode 100644 index 000000000000..43186d614986 --- /dev/null +++ b/filter/qa/unit/data/shape-nographic.odp diff --git a/filter/qa/unit/svg.cxx b/filter/qa/unit/svg.cxx index 4ef95bebdc65..36c7e643466d 100644 --- a/filter/qa/unit/svg.cxx +++ b/filter/qa/unit/svg.cxx @@ -120,6 +120,25 @@ CPPUNIT_TEST_FIXTURE(SvgFilterTest, testPreserveJpg) #endif } +CPPUNIT_TEST_FIXTURE(SvgFilterTest, testShapeNographic) +{ + // Load a document containing a 3D shape. + load("shape-nographic.odp"); + + // Export to SVG. + uno::Reference<frame::XStorable> xStorable(getComponent(), uno::UNO_QUERY_THROW); + SvMemoryStream aStream; + uno::Reference<io::XOutputStream> xOut = new utl::OOutputStreamWrapper(aStream); + utl::MediaDescriptor aMediaDescriptor; + aMediaDescriptor["FilterName"] <<= OUString("impress_svg_Export"); + aMediaDescriptor["OutputStream"] <<= xOut; + + // Without the accompanying fix in place, this test would have failed with: + // An uncaught exception of type com.sun.star.io.IOException + // - SfxBaseModel::impl_store <private:stream> failed: 0xc10(Error Area:Io Class:Write Code:16) + xStorable->storeToURL("private:stream", aMediaDescriptor.getAsConstPropertyValueList()); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/filter/source/svg/svgexport.cxx b/filter/source/svg/svgexport.cxx index accbab0d6965..ac16f7e754f6 100644 --- a/filter/source/svg/svgexport.cxx +++ b/filter/source/svg/svgexport.cxx @@ -56,6 +56,7 @@ #include <xmloff/animationexport.hxx> #include <svx/svdograf.hxx> #include <svx/svdpage.hxx> +#include <sal/log.hxx> #include <memory> @@ -602,7 +603,7 @@ bool SVGFilter::implExportImpressOrDraw( const Reference< XOutputStream >& rxOSt { delete mpSVGDoc; mpSVGDoc = nullptr; - OSL_FAIL( "Exception caught" ); + SAL_WARN("filter.svg", "Exception caught"); } if( nullptr != pSdrModel ) diff --git a/filter/source/svg/svgwriter.cxx b/filter/source/svg/svgwriter.cxx index 1ea8af01e6eb..1558836a21e9 100644 --- a/filter/source/svg/svgwriter.cxx +++ b/filter/source/svg/svgwriter.cxx @@ -2693,7 +2693,10 @@ void GetGraphicFromXShape(const css::uno::Reference<css::drawing::XShape>* pShap } uno::Reference<graphic::XGraphic> xGraphic; - xPropertySet->getPropertyValue("Graphic") >>= xGraphic; + if (xPropertySet->getPropertySetInfo()->hasPropertyByName("Graphic")) + { + xPropertySet->getPropertyValue("Graphic") >>= xGraphic; + } rGraphic= Graphic(xGraphic); } } |