summaryrefslogtreecommitdiff
path: root/xmloff/source/core/xmlimp.cxx
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2018-02-13 21:49:57 +0900
committerTomaž Vajngerl <quikee@gmail.com>2018-02-14 07:47:26 +0100
commit1b02ba03bd62a712e15c15384a3d105d2c088120 (patch)
treeb46f383c7ea60de65dbbede5b658a7babd813610 /xmloff/source/core/xmlimp.cxx
parent733d77570771e2536d5ce1f18ba82f68ac6c22ee (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>
Diffstat (limited to 'xmloff/source/core/xmlimp.cxx')
-rw-r--r--xmloff/source/core/xmlimp.cxx44
1 files changed, 40 insertions, 4 deletions
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;