summaryrefslogtreecommitdiff
path: root/svx/source/xml
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2021-08-30 15:14:10 +0200
committerMiklos Vajna <vmiklos@collabora.com>2021-08-30 22:15:46 +0200
commit56f593c9aa00f87fb8780060fece991b91b5c0a7 (patch)
tree58a3f5de2033fe3402550479a7e9310901c5aff8 /svx/source/xml
parentbe7e6940a328a5002457eb5be26836365bfe3ab4 (diff)
tdf#137310 ODF import: fix loading of images with multiple slashes in path
Regression from commit 1b02ba03bd62a712e15c15384a3d105d2c088120 (shapes: don't use "GraphicURL" property, always use "Graphic", 2018-02-13), the problem was that now the loading of Models/Fallbacks/duck.png goes via SvXMLGraphicHelper::ImplGetGraphicStream(), which assumed that the directory part of the picture path contains no slashes, so can be handled via ImplGetGraphicStorage(). That functions works with Pictures/something.png, but not with Models/Fallbacks/duck.png. Fix the problem by using openStreamElementByHierarchicalName() to open the picture stream in case we got no stream and the storage name contains a slash. Change-Id: I0e04fb4286777b04286c4979af31e6df19988873 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121308 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'svx/source/xml')
-rw-r--r--svx/source/xml/xmlgrhlp.cxx40
1 files changed, 31 insertions, 9 deletions
diff --git a/svx/source/xml/xmlgrhlp.cxx b/svx/source/xml/xmlgrhlp.cxx
index f6731422f0da..522e6c076d19 100644
--- a/svx/source/xml/xmlgrhlp.cxx
+++ b/svx/source/xml/xmlgrhlp.cxx
@@ -28,6 +28,7 @@
#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/util/XCancellable.hpp>
+#include <com/sun/star/embed/XHierarchicalStorageAccess.hpp>
#include <comphelper/fileformat.h>
#include <comphelper/graphicmimetype.hxx>
#include <cppuhelper/compbase.hxx>
@@ -450,22 +451,43 @@ SvxGraphicHelperStream_Impl SvXMLGraphicHelper::ImplGetGraphicStream( const OUSt
SvxGraphicHelperStream_Impl aRet;
aRet.xStorage = ImplGetGraphicStorage( rPictureStorageName );
- if( aRet.xStorage.is() )
+ sal_Int32 nMode = embed::ElementModes::READ;
+ if (SvXMLGraphicHelperMode::Write == meCreateMode)
{
- sal_Int32 nMode = embed::ElementModes::READ;
- if ( SvXMLGraphicHelperMode::Write == meCreateMode )
- {
- nMode = embed::ElementModes::READWRITE;
- }
+ nMode = embed::ElementModes::READWRITE;
+ }
+ if (aRet.xStorage.is())
+ {
aRet.xStream = aRet.xStorage->openStreamElement( rPictureStreamName, nMode );
- if( aRet.xStream.is() && ( SvXMLGraphicHelperMode::Write == meCreateMode ) )
+ }
+ else if (rPictureStorageName.indexOf('/') != -1)
+ {
+ uno::Reference<embed::XHierarchicalStorageAccess> xHierRootStorage(mxRootStorage,
+ uno::UNO_QUERY);
+ if (xHierRootStorage.is())
{
- uno::Reference < beans::XPropertySet > xProps( aRet.xStream, uno::UNO_QUERY );
- xProps->setPropertyValue( "UseCommonStoragePasswordEncryption", uno::makeAny( true) );
+ try
+ {
+ aRet.xStream = xHierRootStorage->openStreamElementByHierarchicalName(
+ rPictureStorageName + "/" + rPictureStreamName, nMode);
+ aRet.xStorage = mxRootStorage;
+ }
+ catch (const uno::Exception&)
+ {
+ TOOLS_WARN_EXCEPTION("svx",
+ "SvXMLGraphicHelper::ImplGetGraphicStream: failed to open "
+ << rPictureStreamName);
+ }
}
}
+ if (aRet.xStream.is() && (SvXMLGraphicHelperMode::Write == meCreateMode))
+ {
+ uno::Reference<beans::XPropertySet> xProps(aRet.xStream, uno::UNO_QUERY);
+ xProps->setPropertyValue("UseCommonStoragePasswordEncryption", uno::makeAny(true));
+ }
+
return aRet;
}