diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2018-02-13 21:49:57 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2018-02-14 07:47:26 +0100 |
commit | 1b02ba03bd62a712e15c15384a3d105d2c088120 (patch) | |
tree | b46f383c7ea60de65dbbede5b658a7babd813610 | |
parent | 733d77570771e2536d5ce1f18ba82f68ac6c22ee (diff) |
shapes: don't use "GraphicURL" property, always use "Graphic"
With GraphicURL property on shapes (XShape) we transported the
external or internal URL to the model, which also included the
GraphicObject uniqueID style URLs. This changes that - now we
always use "Graphic" property and transfer XGraphic to and from
graphic filters. "Graphic" property is already present for XShape
so it wasn't needed to add it.
Filters changed are: OOXML (oox), ODF (xmloff), RTF and
binary MS (esherex).
Also start using originURL on Graphic which now transports the
URL of the external (linked) graphic/image if it was created that
way.
Change-Id: Ic338c60b7cfaaae354cf1e1ca3ae7a6373220230
Reviewed-on: https://gerrit.libreoffice.org/49648
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
-rw-r--r-- | filter/source/msfilter/escherex.cxx | 76 | ||||
-rw-r--r-- | filter/source/msfilter/eschesdo.cxx | 4 | ||||
-rw-r--r-- | filter/source/msfilter/msdffimp.cxx | 4 | ||||
-rw-r--r-- | include/oox/export/drawingml.hxx | 9 | ||||
-rw-r--r-- | include/xmloff/xmlimp.hxx | 3 | ||||
-rw-r--r-- | oox/source/export/drawingml.cxx | 33 | ||||
-rw-r--r-- | oox/source/export/shapes.cxx | 19 | ||||
-rw-r--r-- | sd/CppunitTest_sd_import_tests.mk | 1 | ||||
-rw-r--r-- | sd/qa/unit/import-tests.cxx | 10 | ||||
-rw-r--r-- | sd/source/filter/eppt/epptso.cxx | 4 | ||||
-rw-r--r-- | svx/source/svdraw/svdograf.cxx | 3 | ||||
-rw-r--r-- | sw/qa/extras/globalfilter/globalfilter.cxx | 50 | ||||
-rw-r--r-- | sw/source/filter/ww8/rtfsdrexport.cxx | 37 | ||||
-rw-r--r-- | xmloff/inc/xmlmultiimagehelper.hxx | 1 | ||||
-rw-r--r-- | xmloff/source/core/xmlexp.cxx | 23 | ||||
-rw-r--r-- | xmloff/source/core/xmlimp.cxx | 44 | ||||
-rw-r--r-- | xmloff/source/core/xmlmultiimagehelper.cxx | 52 | ||||
-rw-r--r-- | xmloff/source/draw/shapeexport.cxx | 82 | ||||
-rw-r--r-- | xmloff/source/draw/ximpshap.cxx | 66 | ||||
-rw-r--r-- | xmloff/source/draw/ximpshap.hxx | 2 |
20 files changed, 390 insertions, 133 deletions
diff --git a/filter/source/msfilter/escherex.cxx b/filter/source/msfilter/escherex.cxx index 8807d84173c2..a308d9edc53b 100644 --- a/filter/source/msfilter/escherex.cxx +++ b/filter/source/msfilter/escherex.cxx @@ -85,6 +85,7 @@ #include <com/sun/star/drawing/Position3D.hpp> #include <com/sun/star/drawing/Direction3D.hpp> #include <com/sun/star/drawing/Hatch.hpp> +#include <com/sun/star/graphic/XGraphic.hpp> #include <com/sun/star/text/GraphicCrop.hpp> #include <unotools/ucbstreamhelper.hxx> #include <unotools/localfilehelper.hxx> @@ -1390,10 +1391,12 @@ void EscherPropertyContainer::CreateEmbeddedHatchProperties(const drawing::Hatch AddOpt( ESCHER_Prop_fillType, ESCHER_FillTexture ); } -bool EscherPropertyContainer::CreateGraphicProperties( - const uno::Reference<beans::XPropertySet> & rXPropSet, - const OUString& rSource, const bool bCreateFillBitmap, const bool bCreateCroppingAttributes, - const bool bFillBitmapModeAllowed, const bool bOOxmlExport ) +bool EscherPropertyContainer::CreateGraphicProperties(const uno::Reference<beans::XPropertySet> & rXPropSet, + const OUString& rSource, + const bool bCreateFillBitmap, + const bool bCreateCroppingAttributes, + const bool bFillBitmapModeAllowed, + const bool bOOxmlExport ) { bool bRetValue = false; bool bCreateFillStyles = false; @@ -1403,6 +1406,8 @@ bool EscherPropertyContainer::CreateGraphicProperties( OUString aGraphicUrl; OString aUniqueId; + uno::Reference<graphic::XGraphic> xGraphic; + drawing::BitmapMode eBitmapMode(drawing::BitmapMode_NO_REPEAT); uno::Any aAny; @@ -1465,6 +1470,11 @@ bool EscherPropertyContainer::CreateGraphicProperties( aGraphicUrl = *o3tl::doAccess<OUString>(aAny); bCreateFillStyles = true; } + else if ( rSource == "Graphic" ) + { + xGraphic = aAny.get<uno::Reference<graphic::XGraphic>>(); + bCreateFillStyles = true; + } else if ( rSource == "FillHatch" ) { drawing::Hatch aHatch; @@ -1531,6 +1541,12 @@ bool EscherPropertyContainer::CreateGraphicProperties( : 0; } + if (xGraphic.is()) + { + Graphic aGraphic(xGraphic); + aGraphicUrl = aGraphic.getOriginURL(); + } + if ( aGraphicUrl.getLength() ) { OUString aVndUrl( "vnd.sun.star.GraphicObject:" ); @@ -1598,7 +1614,7 @@ bool EscherPropertyContainer::CreateGraphicProperties( } } - if ( aGraphicUrl.getLength() || !aUniqueId.isEmpty() ) + if ( aGraphicUrl.getLength() || !aUniqueId.isEmpty() || xGraphic.is()) { if(bMirrored || nTransparency || nRed || nGreen || nBlue || (1.0 != fGamma)) { @@ -1675,7 +1691,55 @@ bool EscherPropertyContainer::CreateGraphicProperties( else AddOpt( ESCHER_Prop_fillType, ESCHER_FillPicture ); - if ( !aUniqueId.isEmpty() ) + if (xGraphic.is()) + { + Graphic aGraphic(xGraphic); + if (!aGraphic.getOriginURL().isEmpty()) + { + AddOpt(ESCHER_Prop_pibName, aGraphicUrl); + sal_uInt32 nPibFlags = 0; + GetOpt(ESCHER_Prop_pibFlags, nPibFlags); + AddOpt(ESCHER_Prop_pibFlags, ESCHER_BlipFlagLinkToFile | ESCHER_BlipFlagFile | ESCHER_BlipFlagDoNotSave | nPibFlags); + } + else if (pGraphicProvider && pPicOutStrm && pShapeBoundRect) // write out embedded graphic + { + GraphicObject aGraphicObject(aGraphic); + const sal_uInt32 nBlibId(pGraphicProvider->GetBlibID(*pPicOutStrm, aGraphicObject, nullptr, pGraphicAttr.get())); + + if(nBlibId) + { + if(bCreateFillBitmap) + { + AddOpt(ESCHER_Prop_fillBlip, nBlibId, true); + } + else + { + AddOpt( ESCHER_Prop_pib, nBlibId, true ); + ImplCreateGraphicAttributes( rXPropSet, nBlibId, bCreateCroppingAttributes ); + } + + bRetValue = true; + } + } + else + { + EscherGraphicProvider aProvider; + SvMemoryStream aMemStrm; + GraphicObject aGraphicObject(aGraphic); + + if (aProvider.GetBlibID(aMemStrm, aGraphicObject, nullptr, pGraphicAttr.get(), bOOxmlExport)) + { + // grab BLIP from stream and insert directly as complex property + // ownership of stream memory goes to complex property + aMemStrm.ObjectOwnsMemory( false ); + sal_uInt8 const * pBuf = static_cast<sal_uInt8 const *>(aMemStrm.GetData()); + sal_uInt32 nSize = aMemStrm.Seek( STREAM_SEEK_TO_END ); + AddOpt(ESCHER_Prop_fillBlip, true, nSize, const_cast<sal_uInt8 *>(pBuf), nSize ); + bRetValue = true; + } + } + } + else if ( !aUniqueId.isEmpty() ) { // write out embedded graphic if ( pGraphicProvider && pPicOutStrm && pShapeBoundRect ) diff --git a/filter/source/msfilter/eschesdo.cxx b/filter/source/msfilter/eschesdo.cxx index d10e96bb5765..a4df39e814ed 100644 --- a/filter/source/msfilter/eschesdo.cxx +++ b/filter/source/msfilter/eschesdo.cxx @@ -549,7 +549,7 @@ sal_uInt32 ImplEESdrWriter::ImplWriteShape( ImplEESdrObject& rObj, have to create a simple Rectangle with fill bitmap instead (while not allowing BitmapMode_Repeat). */ addShape( ESCHER_ShpInst_Rectangle, ShapeFlag::HaveShapeProperty | ShapeFlag::HaveAnchor ); - if ( aPropOpt.CreateGraphicProperties( rObj.mXPropSet, "GraphicURL", true, true, false ) ) + if ( aPropOpt.CreateGraphicProperties( rObj.mXPropSet, "Graphic", true, true, false ) ) { aPropOpt.AddOpt( ESCHER_Prop_WrapText, ESCHER_WrapNone ); aPropOpt.AddOpt( ESCHER_Prop_AnchorText, ESCHER_AnchorMiddle ); @@ -565,7 +565,7 @@ sal_uInt32 ImplEESdrWriter::ImplWriteShape( ImplEESdrObject& rObj, else { addShape( ESCHER_ShpInst_PictureFrame, ShapeFlag::HaveShapeProperty | ShapeFlag::HaveAnchor ); - if ( aPropOpt.CreateGraphicProperties( rObj.mXPropSet, "GraphicURL", false, true, true, bOOxmlExport ) ) + if ( aPropOpt.CreateGraphicProperties( rObj.mXPropSet, "Graphic", false, true, true, bOOxmlExport ) ) aPropOpt.AddOpt( ESCHER_Prop_LockAgainstGrouping, 0x800080 ); } } diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx index 6743f503480e..dc26bc4a6c57 100644 --- a/filter/source/msfilter/msdffimp.cxx +++ b/filter/source/msfilter/msdffimp.cxx @@ -4010,7 +4010,11 @@ SdrObject* SvxMSDffManager::ImportGraphic( SvStream& rSt, SfxItemSet& rSet, cons if ( dynamic_cast<const SdrGrafObj* >(pRet) != nullptr ) { if( aLinkFileName.getLength() ) + { static_cast<SdrGrafObj*>(pRet)->SetGraphicLink( aLinkFileName, ""/*TODO?*/, aLinkFilterName ); + Graphic aGraphic(static_cast<SdrGrafObj*>(pRet)->GetGraphic()); + aGraphic.setOriginURL(aLinkFileName); + } if ( bLinkGrf && !bGrfRead ) { diff --git a/include/oox/export/drawingml.hxx b/include/oox/export/drawingml.hxx index 2f02f783462c..216fe5316a13 100644 --- a/include/oox/export/drawingml.hxx +++ b/include/oox/export/drawingml.hxx @@ -38,6 +38,8 @@ #include <sax/fshelper.hxx> #include <svx/msdffdef.hxx> #include <vcl/checksum.hxx> +#include <tools/gen.hxx> +#include <vcl/mapmod.hxx> #ifndef OOX_DRAWINGML_EXPORT_ROTATE_CLOCKWISIFY // Our rotation is counter-clockwise and is in 100ths of a degree. @@ -198,7 +200,14 @@ public: void WritePattFill( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet ); void WritePattFill(const css::uno::Reference<css::beans::XPropertySet>& rXPropSet, const css::drawing::Hatch& rHatch); + + void WriteGraphicCropProperties(css::uno::Reference<css::beans::XPropertySet> const & rxPropertySet, + Size const & rOriginalSize, MapMode const & rMapMode); + void WriteSrcRect( const css::uno::Reference< css::beans::XPropertySet >&, const OUString& ); + void WriteSrcRectXGraphic(css::uno::Reference<css::beans::XPropertySet> const & rxPropertySet, + css::uno::Reference<css::graphic::XGraphic> const & rxGraphic); + void WriteOutline( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet ); void WriteStretch( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet, const OUString& rURL ); diff --git a/include/xmloff/xmlimp.hxx b/include/xmloff/xmlimp.hxx index 50c4e0f10612..691d3e704b54 100644 --- a/include/xmloff/xmlimp.hxx +++ b/include/xmloff/xmlimp.hxx @@ -400,7 +400,8 @@ public: mxNumberFormatsSupplier = _xNumberFormatSupplier; } - css::uno::Reference<css::graphic::XGraphic> loadGraphicByURL(const OUString& rURL); + css::uno::Reference<css::graphic::XGraphic> loadGraphicByURL(OUString const & rURL); + css::uno::Reference<css::graphic::XGraphic> loadGraphicFromBase64(css::uno::Reference<css::io::XOutputStream> const & rxOutputStream); // Convert a local package URL into either a graphic manager or a // internal package URL. The later one happens only if bLoadURL is true diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index d56077c5240a..0503a088faf7 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -1325,18 +1325,16 @@ void DrawingML::WritePattFill(const Reference<XPropertySet>& rXPropSet, const cs mpFS->endElementNS( XML_a , XML_pattFill ); } -void DrawingML::WriteSrcRect( const Reference< XPropertySet >& rXPropSet, const OUString& rURL ) +void DrawingML::WriteGraphicCropProperties(uno::Reference<beans::XPropertySet> const & rXPropSet, Size const & rOriginalSize, MapMode const & rMapMode) { - GraphicObject aGraphicObject = GraphicObject::CreateGraphicObjectFromURL(rURL); - Size aOriginalSize = aGraphicObject.GetPrefSize(); - const MapMode& rMapMode = aGraphicObject.GetPrefMapMode(); + if (GetProperty(rXPropSet, "GraphicCrop")) + { + Size aOriginalSize(rOriginalSize); - // GraphicCrop is in mm100, so in case the original size is in pixels, convert it over. - if (rMapMode.GetMapUnit() == MapUnit::MapPixel) - aOriginalSize = Application::GetDefaultDevice()->PixelToLogic(aOriginalSize, MapMode(MapUnit::Map100thMM)); + // GraphicCrop is in mm100, so in case the original size is in pixels, convert it over. + if (rMapMode.GetMapUnit() == MapUnit::MapPixel) + aOriginalSize = Application::GetDefaultDevice()->PixelToLogic(aOriginalSize, MapMode(MapUnit::Map100thMM)); - if ( GetProperty( rXPropSet, "GraphicCrop" ) ) - { css::text::GraphicCrop aGraphicCropStruct; mAny >>= aGraphicCropStruct; @@ -1352,6 +1350,23 @@ void DrawingML::WriteSrcRect( const Reference< XPropertySet >& rXPropSet, const } } +void DrawingML::WriteSrcRect(const uno::Reference<beans::XPropertySet>& rxPropertySet, const OUString& rURL) +{ + GraphicObject aGraphicObject = GraphicObject::CreateGraphicObjectFromURL(rURL); + Size aOriginalSize = aGraphicObject.GetPrefSize(); + const MapMode& rMapMode = aGraphicObject.GetPrefMapMode(); + WriteGraphicCropProperties(rxPropertySet, aOriginalSize, rMapMode); +} + +void DrawingML::WriteSrcRectXGraphic(uno::Reference<beans::XPropertySet> const & rxPropertySet, + uno::Reference<graphic::XGraphic> const & rxGraphic) +{ + Graphic aGraphic(rxGraphic); + Size aOriginalSize = aGraphic.GetPrefSize(); + const MapMode& rMapMode = aGraphic.GetPrefMapMode(); + WriteGraphicCropProperties(rxPropertySet, aOriginalSize, rMapMode); +} + void DrawingML::WriteStretch( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet, const OUString& rURL ) { mpFS->startElementNS( XML_a, XML_stretch, FSEND ); diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx index 8199221686f3..e922a3bce934 100644 --- a/oox/source/export/shapes.cxx +++ b/oox/source/export/shapes.cxx @@ -1098,13 +1098,20 @@ void ShapeExport::WriteGraphicObjectShapePart( const Reference< XShape >& xShape SAL_INFO("oox.shape", "graphicObject without text"); OUString sGraphicURL; + uno::Reference<graphic::XGraphic> xGraphic; OUString sMediaURL; + Reference< XPropertySet > xShapeProps( xShape, UNO_QUERY ); bool bHasGraphicURL = xShapeProps.is() && xShapeProps->getPropertySetInfo()->hasPropertyByName("GraphicURL") && (xShapeProps->getPropertyValue("GraphicURL") >>= sGraphicURL); + + if (xShapeProps.is() && xShapeProps->getPropertySetInfo()->hasPropertyByName("Graphic")) + xShapeProps->getPropertyValue("Graphic") >>= xGraphic; + + bool bHasAnyGraphic = bHasGraphicURL || xGraphic.is(); bool bHasMediaURL = xShapeProps.is() && xShapeProps->getPropertySetInfo()->hasPropertyByName("MediaURL") && (xShapeProps->getPropertyValue("MediaURL") >>= sMediaURL); - if (!pGraphic && !bHasGraphicURL && !bHasMediaURL) + if (!pGraphic && !bHasAnyGraphic && !bHasMediaURL) { SAL_INFO("oox.shape", "no graphic or media URL found"); return; @@ -1158,8 +1165,14 @@ void ShapeExport::WriteGraphicObjectShapePart( const Reference< XShape >& xShape pFS->startElementNS( mnXmlNamespace, XML_blipFill, FSEND ); - if (pGraphic || bHasGraphicURL) + if (xGraphic.is()) + { + WriteXGraphicBlip(xShapeProps, xGraphic, false); + } + else if (pGraphic || bHasGraphicURL) + { WriteBlip(xShapeProps, sGraphicURL, false, pGraphic); + } else if (bHasMediaURL) { Reference<graphic::XGraphic> rGraphic; @@ -1172,6 +1185,8 @@ void ShapeExport::WriteGraphicObjectShapePart( const Reference< XShape >& xShape if (bHasGraphicURL) WriteSrcRect(xShapeProps, sGraphicURL); + else if (xGraphic.is()) + WriteSrcRectXGraphic(xShapeProps, xGraphic); // now we stretch always when we get pGraphic (when changing that // behavior, test n#780830 for regression, where the OLE sheet might get tiled diff --git a/sd/CppunitTest_sd_import_tests.mk b/sd/CppunitTest_sd_import_tests.mk index 27c7f9181b71..12ad80637323 100644 --- a/sd/CppunitTest_sd_import_tests.mk +++ b/sd/CppunitTest_sd_import_tests.mk @@ -99,6 +99,7 @@ $(eval $(call gb_CppunitTest_use_components,sd_import_tests,\ svl/source/fsstor/fsstorage \ svtools/util/svt \ svx/util/svxcore \ + svgio/svgio \ toolkit/util/tk \ ucb/source/core/ucb1 \ ucb/source/ucp/expand/ucpexpand1 \ diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx index 257a59fbd05f..2ed7337438fd 100644 --- a/sd/qa/unit/import-tests.cxx +++ b/sd/qa/unit/import-tests.cxx @@ -2323,10 +2323,12 @@ void SdImportTest::testTdf114488() // This doc has two images - one WMF and the other PNG (fallback image). // When loading this doc, the WMF image should be preferred over the PNG image. sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/odg/tdf114488.fodg"), FODG); - uno::Reference< beans::XPropertySet > xShape(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY_THROW); - OUString sGraphicUrl; - xShape->getPropertyValue("GraphicURL") >>= sGraphicUrl; - OUString sMimeType(comphelper::GraphicMimeTypeHelper::GetMimeTypeForImageUrl(sGraphicUrl)); + uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY_THROW); + uno::Reference<graphic::XGraphic> xGraphic; + xShape->getPropertyValue("Graphic") >>= xGraphic; + CPPUNIT_ASSERT(xGraphic.is()); + Graphic aGraphic(xGraphic); + OUString sMimeType(comphelper::GraphicMimeTypeHelper::GetMimeTypeForXGraphic(xGraphic)); CPPUNIT_ASSERT_EQUAL(OUString("image/x-wmf"), sMimeType); } diff --git a/sd/source/filter/eppt/epptso.cxx b/sd/source/filter/eppt/epptso.cxx index 24eba89c4b38..89080a1a8db4 100644 --- a/sd/source/filter/eppt/epptso.cxx +++ b/sd/source/filter/eppt/epptso.cxx @@ -2219,7 +2219,7 @@ void PPTWriter::ImplWritePage( const PHLayout& rLayout, EscherSolverContainer& a ImplCreateShape( ESCHER_ShpInst_Rectangle, ShapeFlag::HaveAnchor | ShapeFlag::HaveShapeProperty, aSolverContainer ); - if ( aPropOpt.CreateGraphicProperties( mXPropSet, "GraphicURL", true, true, false ) ) + if ( aPropOpt.CreateGraphicProperties( mXPropSet, "Graphic", true, true, false ) ) { aPropOpt.AddOpt( ESCHER_Prop_WrapText, ESCHER_WrapNone ); aPropOpt.AddOpt( ESCHER_Prop_AnchorText, ESCHER_AnchorMiddle ); @@ -2236,7 +2236,7 @@ void PPTWriter::ImplWritePage( const PHLayout& rLayout, EscherSolverContainer& a ShapeFlag::HaveAnchor | ShapeFlag::HaveShapeProperty, aSolverContainer ); - if ( aPropOpt.CreateGraphicProperties( mXPropSet, "GraphicURL", false, true ) ) + if ( aPropOpt.CreateGraphicProperties( mXPropSet, "Graphic", false, true ) ) { aPropOpt.AddOpt( ESCHER_Prop_LockAgainstGrouping, 0x800080 ); } diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx index 29dffa90fd3b..ceac4a34628b 100644 --- a/svx/source/svdraw/svdograf.cxx +++ b/svx/source/svdraw/svdograf.cxx @@ -676,10 +676,9 @@ void SdrGrafObj::ReleaseGraphicLink() bool SdrGrafObj::IsLinkedGraphic() const { - return !aFileName.isEmpty(); + return !mpGraphicObject->GetGraphic().getOriginURL().isEmpty(); } - void SdrGrafObj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const { bool bNoPresGrf = ( mpGraphicObject->GetType() != GraphicType::NONE ) && !bEmptyPresObj; diff --git a/sw/qa/extras/globalfilter/globalfilter.cxx b/sw/qa/extras/globalfilter/globalfilter.cxx index 296517528a91..7bd0c1bb2633 100644 --- a/sw/qa/extras/globalfilter/globalfilter.cxx +++ b/sw/qa/extras/globalfilter/globalfilter.cxx @@ -289,24 +289,29 @@ void Test::testImageWithSpecialID() /// Gives the first embedded or linked image in a document. uno::Reference<drawing::XShape> lcl_getShape(const uno::Reference<lang::XComponent>& xComponent, bool bEmbedded) { - uno::Reference<drawing::XShape> xRet; + uno::Reference<drawing::XShape> xShape; uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xComponent, uno::UNO_QUERY); uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage(); for (sal_Int32 i = 0; i < xDrawPage->getCount(); ++i) { - uno::Reference<beans::XPropertySet> xShape(xDrawPage->getByIndex(i), uno::UNO_QUERY); - OUString sURL; - xShape->getPropertyValue("GraphicURL") >>= sURL; - // Linked image: working starts with file://, broken is e.g. 'vnd.sun.star.GraphicObject:3000000000000000000000000000000000000000'. - if ((sURL.startsWith("file://") || sURL.endsWith("0000000000000000")) != bEmbedded) + uno::Reference<beans::XPropertySet> xShapeProperties(xDrawPage->getByIndex(i), uno::UNO_QUERY); + uno::Reference<graphic::XGraphic> xGraphic; + xShapeProperties->getPropertyValue("Graphic") >>= xGraphic; + if (xGraphic.is()) { - xRet.set(xShape, uno::UNO_QUERY); - break; + Graphic aGraphic(xGraphic); + + if ((bEmbedded && aGraphic.getOriginURL().isEmpty()) || + (!bEmbedded && !aGraphic.getOriginURL().isEmpty())) + { + xShape.set(xShapeProperties, uno::UNO_QUERY); + return xShape; + } } } - return xRet; + return xShape; } void Test::testGraphicShape() @@ -353,18 +358,14 @@ void Test::testGraphicShape() CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(2), xDraws->getCount()); uno::Reference<drawing::XShape> xImage = lcl_getShape(mxComponent, true); - uno::Reference< beans::XPropertySet > XPropSet( xImage, uno::UNO_QUERY_THROW ); + CPPUNIT_ASSERT_MESSAGE("Couldn't load the shape/image", xImage.is()); + uno::Reference< beans::XPropertySet > XPropSet( xImage, uno::UNO_QUERY ); // First image is embedded - // Check URL - { - OUString sURL; - XPropSet->getPropertyValue("GraphicURL") >>= sURL; - CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), sURL != "vnd.sun.star.GraphicObject:00000000000000000000000000000000"); - } // Check size { uno::Reference<graphic::XGraphic> xGraphic; XPropSet->getPropertyValue("Graphic") >>= xGraphic; + CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xGraphic.is()); uno::Reference<awt::XBitmap> xBitmap(xGraphic, uno::UNO_QUERY); CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xBitmap.is()); CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(610), xBitmap->getSize().Width ); @@ -377,17 +378,20 @@ void Test::testGraphicShape() // Second image is a linked one xImage = lcl_getShape(mxComponent, false); - XPropSet.set( xImage, uno::UNO_QUERY_THROW ); - // Check URL - { - OUString sURL; - XPropSet->getPropertyValue("GraphicURL") >>= sURL; - CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), sURL.endsWith("linked_graphic.jpg")); - } + XPropSet.set( xImage, uno::UNO_QUERY ); + const OString sFailedImageLoad = OString("Couldn't load the shape/image for ") + aFilterNames[nFilter]; + CPPUNIT_ASSERT_MESSAGE(sFailedImageLoad.getStr(), xImage.is()); + // Check size { uno::Reference<graphic::XGraphic> xGraphic; XPropSet->getPropertyValue("Graphic") >>= xGraphic; + CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xGraphic.is()); + + Graphic aGraphic(xGraphic); + OUString sURL = aGraphic.getOriginURL(); + CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), sURL.endsWith("linked_graphic.jpg")); + uno::Reference<awt::XBitmap> xBitmap(xGraphic, uno::UNO_QUERY); CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xBitmap.is()); CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(620), xBitmap->getSize().Width ); diff --git a/sw/source/filter/ww8/rtfsdrexport.cxx b/sw/source/filter/ww8/rtfsdrexport.cxx index b65b50be104e..b62dd2b7c16b 100644 --- a/sw/source/filter/ww8/rtfsdrexport.cxx +++ b/sw/source/filter/ww8/rtfsdrexport.cxx @@ -499,21 +499,42 @@ void RtfSdrExport::impl_writeGraphic() uno::Reference<drawing::XShape> xShape = GetXShapeForSdrObject(const_cast<SdrObject*>(m_pSdrObject)); uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY); - OUString sGraphicURL; + + uno::Reference<graphic::XGraphic> xGraphic; + + Graphic aGraphic; + try { - xPropertySet->getPropertyValue("GraphicURL") >>= sGraphicURL; + xPropertySet->getPropertyValue("Graphic") >>= xGraphic; } catch (beans::UnknownPropertyException& rException) { - // ATM groupshapes are not supported, just make sure we don't crash on them. SAL_WARN("sw.rtf", "failed. Message: " << rException); - return; } - OString aURLBS(OUStringToOString(sGraphicURL, RTL_TEXTENCODING_UTF8)); - Graphic aGraphic - = GraphicObject(aURLBS.copy(RTL_CONSTASCII_LENGTH("vnd.sun.star.GraphicObject:"))) - .GetTransformedGraphic(); + + if (xGraphic.is()) + { + aGraphic = Graphic(xGraphic); + } + else + { + OUString sGraphicURL; + try + { + xPropertySet->getPropertyValue("GraphicURL") >>= sGraphicURL; + } + catch (beans::UnknownPropertyException& rException) + { + // ATM groupshapes are not supported, just make sure we don't crash on them. + SAL_WARN("sw.rtf", "failed. Message: " << rException); + return; + } + + OString aURLBS(OUStringToOString(sGraphicURL, RTL_TEXTENCODING_UTF8)); + OString aUrl = aURLBS.copy(RTL_CONSTASCII_LENGTH("vnd.sun.star.GraphicObject:")); + aGraphic = GraphicObject(aUrl).GetTransformedGraphic(); + } // Export it to a stream. SvMemoryStream aStream; diff --git a/xmloff/inc/xmlmultiimagehelper.hxx b/xmloff/inc/xmlmultiimagehelper.hxx index ee2df0f53c74..2b29835c2f26 100644 --- a/xmloff/inc/xmlmultiimagehelper.hxx +++ b/xmloff/inc/xmlmultiimagehelper.hxx @@ -34,6 +34,7 @@ protected: /// helper to get the created xShape instance, override this virtual OUString getGraphicURLFromImportContext(const SvXMLImportContext& rContext) const = 0; virtual void removeGraphicFromImportContext(const SvXMLImportContext& rContext) = 0; + virtual css::uno::Reference<css::graphic::XGraphic> getGraphicFromImportContext(const SvXMLImportContext& rContext) const; public: MultiImageImportHelper(); diff --git a/xmloff/source/core/xmlexp.cxx b/xmloff/source/core/xmlexp.cxx index a3015b8903ef..7f5df92e5875 100644 --- a/xmloff/source/core/xmlexp.cxx +++ b/xmloff/source/core/xmlexp.cxx @@ -27,6 +27,7 @@ #include <xmloff/unointerfacetouniqueidentifiermapper.hxx> #include <osl/mutex.hxx> #include <tools/urlobj.hxx> +#include <vcl/graph.hxx> #include <comphelper/genericpropertyset.hxx> #include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/io/XInputStream.hpp> @@ -1884,19 +1885,27 @@ OUString SvXMLExport::AddEmbeddedGraphicObject( const OUString& rGraphicObjectUR OUString SvXMLExport::AddEmbeddedXGraphic(uno::Reference<graphic::XGraphic> const & rxGraphic, OUString const & rRequestedName) { - OUString sInternalURL; + OUString sURL; - uno::Reference<document::XGraphicStorageHandler> xGraphicStorageHandler(mxGraphicResolver, uno::UNO_QUERY); + Graphic aGraphic(rxGraphic); + OUString aOriginURL = aGraphic.getOriginURL(); - if (mxGraphicResolver.is() && xGraphicStorageHandler.is()) + if (!aOriginURL.isEmpty()) { - if (!(getExportFlags() & SvXMLExportFlags::EMBEDDED)) + sURL = GetRelativeReference(aOriginURL); + } + else + { + uno::Reference<document::XGraphicStorageHandler> xGraphicStorageHandler(mxGraphicResolver, uno::UNO_QUERY); + if (mxGraphicResolver.is() && xGraphicStorageHandler.is()) { - sInternalURL = xGraphicStorageHandler->saveGraphicByName(rxGraphic, rRequestedName); + if (!(getExportFlags() & SvXMLExportFlags::EMBEDDED)) + { + sURL = xGraphicStorageHandler->saveGraphicByName(rxGraphic, rRequestedName); + } } } - - return sInternalURL; + return sURL; } Reference< XInputStream > SvXMLExport::GetEmbeddedGraphicObjectStream( const OUString& rGraphicObjectURL ) diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx index 5203cdc4d751..c77193ba38cb 100644 --- a/xmloff/source/core/xmlimp.cxx +++ b/xmloff/source/core/xmlimp.cxx @@ -23,6 +23,7 @@ #include <tools/diagnose_ex.h> #include <com/sun/star/beans/XPropertySetInfo.hpp> #include <tools/urlobj.hxx> +#include <vcl/graph.hxx> #include <xmloff/unointerfacetouniqueidentifiermapper.hxx> #include <xmloff/nmspmap.hxx> #include <xmloff/xmluconv.hxx> @@ -45,6 +46,7 @@ #include <com/sun/star/document/XBinaryStreamResolver.hpp> #include <com/sun/star/document/XStorageBasedDocument.hpp> #include <com/sun/star/document/XGraphicStorageHandler.hpp> +#include <com/sun/star/graphic/GraphicProvider.hpp> #include <com/sun/star/xml/sax/XLocator.hpp> #include <com/sun/star/xml/sax/FastParser.hpp> #include <com/sun/star/packages/zip/ZipIOException.hpp> @@ -57,6 +59,7 @@ #include <comphelper/processfactory.hxx> #include <comphelper/documentconstants.hxx> #include <comphelper/storagehelper.hxx> +#include <comphelper/propertysequence.hxx> #include <unotools/fontcvt.hxx> #include <o3tl/make_unique.hxx> #include <xmloff/fasttokenhandler.hxx> @@ -1353,14 +1356,47 @@ bool SvXMLImport::IsPackageURL( const OUString& rURL ) const return true; } -css::uno::Reference<css::graphic::XGraphic> SvXMLImport::loadGraphicByURL(const OUString& rURL) +uno::Reference<graphic::XGraphic> SvXMLImport::loadGraphicByURL(OUString const & rURL) { - css::uno::Reference<css::graphic::XGraphic> xGraphic; + uno::Reference<graphic::XGraphic> xGraphic; uno::Reference<document::XGraphicStorageHandler> xGraphicStorageHandler(mxGraphicResolver, uno::UNO_QUERY); - if (IsPackageURL(rURL) && xGraphicStorageHandler.is()) + if (xGraphicStorageHandler.is()) { - xGraphic = xGraphicStorageHandler->loadGraphic(rURL); + if (IsPackageURL(rURL)) + { + xGraphic = xGraphicStorageHandler->loadGraphic(rURL); + } + else + { + uno::Reference<graphic::XGraphicProvider> xProvider(graphic::GraphicProvider::create(GetComponentContext())); + OUString const & rAbsoluteURL = GetAbsoluteReference(rURL); + uno::Sequence<beans::PropertyValue> aLoadProperties(comphelper::InitPropertySequence( + { + { "URL", uno::makeAny(rAbsoluteURL) } + })); + + xGraphic = xProvider->queryGraphic(aLoadProperties); + if (xGraphic.is()) + { + Graphic aGraphic(xGraphic); + aGraphic.setOriginURL(rAbsoluteURL); + printf ("URL %s\n", rAbsoluteURL.toUtf8().getStr()); + } + } + } + + return xGraphic; +} + +uno::Reference<graphic::XGraphic> SvXMLImport::loadGraphicFromBase64(uno::Reference<io::XOutputStream> const & rxOutputStream) +{ + uno::Reference<graphic::XGraphic> xGraphic; + uno::Reference<document::XGraphicStorageHandler> xGraphicStorageHandler(mxGraphicResolver, uno::UNO_QUERY); + + if (xGraphicStorageHandler.is()) + { + xGraphic = xGraphicStorageHandler->loadGraphicFromOutputStream(rxOutputStream); } return xGraphic; diff --git a/xmloff/source/core/xmlmultiimagehelper.cxx b/xmloff/source/core/xmlmultiimagehelper.cxx index 3d7725a3b24f..83cee5bbae2a 100644 --- a/xmloff/source/core/xmlmultiimagehelper.cxx +++ b/xmloff/source/core/xmlmultiimagehelper.cxx @@ -26,7 +26,7 @@ using namespace ::com::sun::star; namespace { - sal_uInt32 getQualityIndex(const OUString& rString) + OUString getMimeTypeForURL(const OUString& rString) { OUString sMimeType; if (rString.startsWith("vnd.sun.star.GraphicObject")) @@ -42,45 +42,48 @@ namespace else { SAL_WARN("xmloff", "Unknown image source: " << rString); - return 0; } + return sMimeType; + } + sal_uInt32 getQualityIndex(const OUString& rMimeType) + { // pixel formats first - if(sMimeType == "image/bmp") + if (rMimeType == "image/bmp") { return 10; } - if(sMimeType == "image/gif") + if (rMimeType == "image/gif") { return 20; } - if(sMimeType == "image/jpeg") + if (rMimeType == "image/jpeg") { return 30; } - if(sMimeType == "image/png") + if (rMimeType == "image/png") { return 40; } // vector formats, prefer always - if(sMimeType == "image/x-svm") + if (rMimeType == "image/x-svm") { return 1000; } - if(sMimeType == "image/x-wmf") + if (rMimeType == "image/x-wmf") { return 1010; } - if(sMimeType == "image/x-emf") + if (rMimeType == "image/x-emf") { return 1020; } - if(sMimeType == "application/pdf") + if (rMimeType == "application/pdf") { return 1030; } - if(sMimeType == "image/svg+xml") + if (rMimeType == "image/svg+xml") { return 1040; } @@ -111,10 +114,26 @@ SvXMLImportContextRef MultiImageImportHelper::solveMultipleImages() for(std::vector<SvXMLImportContextRef>::size_type a = 0; a < maImplContextVector.size(); a++) { - const OUString aStreamURL(getGraphicURLFromImportContext(*maImplContextVector[a].get())); - const sal_uInt32 nNewQuality(getQualityIndex(aStreamURL)); + const SvXMLImportContext& rContext = *maImplContextVector[a].get(); + + sal_uInt32 nNewQuality = 0; + + uno::Reference<graphic::XGraphic> xGraphic(getGraphicFromImportContext(rContext)); + if (xGraphic.is()) + { + OUString sMimeType = comphelper::GraphicMimeTypeHelper::GetMimeTypeForXGraphic(xGraphic); + nNewQuality = getQualityIndex(sMimeType); + } + else + { + const OUString aStreamURL(getGraphicURLFromImportContext(rContext)); + if (!aStreamURL.isEmpty()) + { + nNewQuality = getQualityIndex(getMimeTypeForURL(aStreamURL)); + } + } - if(nNewQuality > nBestQuality) + if (nNewQuality > nBestQuality) { nBestQuality = nNewQuality; nIndexOfPreferred = a; @@ -156,4 +175,9 @@ void MultiImageImportHelper::addContent(const SvXMLImportContext& rSvXMLImportCo maImplContextVector.emplace_back(const_cast< SvXMLImportContext* >(&rSvXMLImportContext)); } +uno::Reference<graphic::XGraphic> MultiImageImportHelper::getGraphicFromImportContext(const SvXMLImportContext& /*rContext*/) const +{ + return uno::Reference<graphic::XGraphic>(); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmloff/source/draw/shapeexport.cxx b/xmloff/source/draw/shapeexport.cxx index 81293655dea7..b1b5ea0e1537 100644 --- a/xmloff/source/draw/shapeexport.cxx +++ b/xmloff/source/draw/shapeexport.cxx @@ -2307,6 +2307,33 @@ void XMLShapeExport::ImpExportPolygonShape( } +namespace +{ + +OUString getNameFromStreamURL(OUString const & rURL) +{ + const OUString sPackageURL("vnd.sun.star.Package:"); + + OUString sResult; + + if (rURL.match(sPackageURL)) + { + OUString sRequestedName = rURL.copy(sPackageURL.getLength()); + sal_Int32 nLastIndex = sRequestedName.lastIndexOf('/') + 1; + if ((nLastIndex > 0) && (nLastIndex < sRequestedName.getLength())) + sRequestedName = sRequestedName.copy(nLastIndex); + nLastIndex = sRequestedName.lastIndexOf('.'); + if (nLastIndex >= 0) + sRequestedName = sRequestedName.copy(0, nLastIndex); + if (!sRequestedName.isEmpty()) + sResult = sRequestedName; + } + + return sResult; +} + +} // end anonymous namespace + void XMLShapeExport::ImpExportGraphicObjectShape( const uno::Reference< drawing::XShape >& xShape, XmlShapeType eShapeType, XMLShapeExportFlags nFeatures, awt::Point* pRefPoint) @@ -2320,8 +2347,6 @@ void XMLShapeExport::ImpExportGraphicObjectShape( // Transformation ImpExportNewTrans(xPropSet, nFeatures, pRefPoint); - OUString sImageURL; - if(eShapeType == XmlShapeTypePresGraphicObjectShape) bIsEmptyPresObj = ImpExportPresentationAttributes( xPropSet, GetXMLToken(XML_PRESENTATION_GRAPHIC) ); @@ -2331,53 +2356,56 @@ void XMLShapeExport::ImpExportGraphicObjectShape( const bool bSaveBackwardsCompatible = bool( mrExport.getExportFlags() & SvXMLExportFlags::SAVEBACKWARDCOMPATIBLE ); + OUString sImageURL; + uno::Reference<graphic::XGraphic> xGraphic; + if( !bIsEmptyPresObj || bSaveBackwardsCompatible ) { if( !bIsEmptyPresObj ) { OUString aStreamURL; - xPropSet->getPropertyValue("GraphicStreamURL") >>= aStreamURL; + + OUString sRequestedName = getNameFromStreamURL(aStreamURL); + xPropSet->getPropertyValue("GraphicURL") >>= sImageURL; - OUString aResolveURL( sImageURL ); - const OUString sPackageURL( "vnd.sun.star.Package:" ); + uno::Any aGraphicAny = xPropSet->getPropertyValue("Graphic"); + if (aGraphicAny.has<uno::Reference<graphic::XGraphic>>()) + xGraphic = aGraphicAny.get<uno::Reference<graphic::XGraphic>>(); + + OUString aStoredURL; - // trying to preserve the filename for embedded images which already have its stream inside the package - bool bIsEmbeddedImageWithExistingStreamInPackage = false; - if ( aStreamURL.match( sPackageURL ) ) + if (xGraphic.is()) { - bIsEmbeddedImageWithExistingStreamInPackage = true; - - OUString sRequestedName = aStreamURL.copy( sPackageURL.getLength() ); - sal_Int32 nLastIndex = sRequestedName.lastIndexOf( '/' ) + 1; - if ( ( nLastIndex > 0 ) && ( nLastIndex < sRequestedName.getLength() ) ) - sRequestedName = sRequestedName.copy( nLastIndex ); - nLastIndex = sRequestedName.lastIndexOf( '.' ); - if ( nLastIndex >= 0 ) - sRequestedName = sRequestedName.copy( 0, nLastIndex ); - if ( !sRequestedName.isEmpty() ) - { + aStoredURL = mrExport.AddEmbeddedXGraphic(xGraphic, sRequestedName); + } + else + { + OUString aResolveURL(sImageURL); + if (!sRequestedName.isEmpty()) aResolveURL += "?requestedName=" + sRequestedName; - } + + aStoredURL = mrExport.AddEmbeddedGraphicObject(aResolveURL); } - const OUString aStr = mrExport.AddEmbeddedGraphicObject( aResolveURL ); - mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, aStr ); + mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, aStoredURL); - if( !aStr.isEmpty() ) + if (!aStoredURL.isEmpty()) { + const OUString sPackageURL("vnd.sun.star.Package:"); + // apply possible changed stream URL to embedded image object - if ( bIsEmbeddedImageWithExistingStreamInPackage ) + if (!sRequestedName.isEmpty()) { OUString newStreamURL = sPackageURL; - if ( aStr[0] == '#' ) + if (aStoredURL[0] == '#') { - newStreamURL += aStr.copy( 1, aStr.getLength() - 1 ); + newStreamURL += aStoredURL.copy(1, aStoredURL.getLength() - 1); } else { - newStreamURL += aStr; + newStreamURL += aStoredURL; } if (newStreamURL != aStreamURL) diff --git a/xmloff/source/draw/ximpshap.cxx b/xmloff/source/draw/ximpshap.cxx index 4ccdb68d5ff1..187262720251 100644 --- a/xmloff/source/draw/ximpshap.cxx +++ b/xmloff/source/draw/ximpshap.cxx @@ -2402,15 +2402,10 @@ void SdXMLGraphicObjectShapeContext::StartElement( const css::uno::Reference< cs { if( !maURL.isEmpty() ) { - uno::Any aAny; - aAny <<= GetImport().ResolveGraphicObjectURL( maURL, GetImport().isGraphicLoadOnDemandSupported() ); - try - { - xPropset->setPropertyValue("GraphicURL", aAny ); - xPropset->setPropertyValue("GraphicStreamURL", aAny ); - } - catch (const lang::IllegalArgumentException&) + uno::Reference<graphic::XGraphic> xGraphic = GetImport().loadGraphicByURL(maURL); + if (xGraphic.is()) { + xPropset->setPropertyValue("Graphic", uno::makeAny(xGraphic)); } } } @@ -2439,23 +2434,15 @@ void SdXMLGraphicObjectShapeContext::StartElement( const css::uno::Reference< cs void SdXMLGraphicObjectShapeContext::EndElement() { - if( mxBase64Stream.is() ) + if (mxBase64Stream.is()) { - OUString sURL( GetImport().ResolveGraphicObjectURLFromBase64( mxBase64Stream ) ); - if( !sURL.isEmpty() ) + uno::Reference<graphic::XGraphic> xGraphic(GetImport().loadGraphicFromBase64(mxBase64Stream)); + if (xGraphic.is()) { - try - { - uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY); - if(xProps.is()) - { - const uno::Any aAny( uno::makeAny( sURL ) ); - xProps->setPropertyValue("GraphicURL", aAny ); - xProps->setPropertyValue("GraphicStreamURL", aAny ); - } - } - catch (const lang::IllegalArgumentException&) + uno::Reference<beans::XPropertySet> xProperties(mxShape, uno::UNO_QUERY); + if (xProperties.is()) { + xProperties->setPropertyValue("Graphic", uno::makeAny(xGraphic)); } } } @@ -3365,6 +3352,41 @@ void SdXMLFrameShapeContext::removeGraphicFromImportContext(const SvXMLImportCon } } +namespace +{ +uno::Reference<beans::XPropertySet> getGraphicPropertySetFromImportContext(const SvXMLImportContext& rContext) +{ + uno::Reference<beans::XPropertySet> aPropertySet; + const SdXMLGraphicObjectShapeContext* pSdXMLGraphicObjectShapeContext = dynamic_cast<const SdXMLGraphicObjectShapeContext*>(&rContext); + + if (pSdXMLGraphicObjectShapeContext) + aPropertySet.set(pSdXMLGraphicObjectShapeContext->getShape(), uno::UNO_QUERY); + + return aPropertySet; +} + +} // end anonymous namespace + +uno::Reference<graphic::XGraphic> SdXMLFrameShapeContext::getGraphicFromImportContext(const SvXMLImportContext& rContext) const +{ + uno::Reference<graphic::XGraphic> xGraphic; + try + { + const uno::Reference<beans::XPropertySet> xPropertySet = getGraphicPropertySetFromImportContext(rContext); + + if (xPropertySet.is()) + { + xPropertySet->getPropertyValue("Graphic") >>= xGraphic; + } + } + catch( uno::Exception& ) + { + DBG_UNHANDLED_EXCEPTION_WHEN("Error in cleanup of multiple graphic object import."); + } + + return xGraphic; +} + OUString SdXMLFrameShapeContext::getGraphicURLFromImportContext(const SvXMLImportContext& rContext) const { OUString aRetval; diff --git a/xmloff/source/draw/ximpshap.hxx b/xmloff/source/draw/ximpshap.hxx index 950d8645aae8..c6376719c637 100644 --- a/xmloff/source/draw/ximpshap.hxx +++ b/xmloff/source/draw/ximpshap.hxx @@ -550,6 +550,8 @@ protected: virtual OUString getGraphicURLFromImportContext(const SvXMLImportContext& rContext) const override; virtual void removeGraphicFromImportContext(const SvXMLImportContext& rContext) override; + css::uno::Reference<css::graphic::XGraphic> getGraphicFromImportContext(const SvXMLImportContext& rContext) const override; + public: SdXMLFrameShapeContext( SvXMLImport& rImport, sal_uInt16 nPrfx, |