summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-02-16 09:16:43 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-02-16 09:16:43 +0100
commit6083a8f188e2cd3fe6849e2112a6b06fbf8e1ad3 (patch)
treefe15c1470e806b7eb4ef132221c47474b19dd35c /writerfilter
parentec935c9b83ff2872c039522398c49e070149eea1 (diff)
Related: tdf#59699 DOCX import: fix linked graphics with relative URLs
Because the writerfilter::ooxml::OOXMLFastContextHandlerShape constructor only sent the input stream (and not the full media descriptor) to oox::shape::ShapeContextHandler, it's startFastElement() tried to reconstruct a media descriptor from just the input stream. As a result, the base URL of the document got lost at the time the oox::drawingml::BlipContext constructor tried to call getAbsoluteUrl(), to convert the relative URL to an absolute one. Fix the problem by sending not only the input stream, but the full media descriptor to the shape importer. As a bonus that makes code simpler, too. Change-Id: I1f06c04d0745aa7e2e06d4848cf454790d5073ca
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/inc/ooxml/OOXMLDocument.hxx2
-rw-r--r--writerfilter/source/filter/WriterFilter.cxx3
-rw-r--r--writerfilter/source/ooxml/OOXMLDocumentImpl.cxx19
-rw-r--r--writerfilter/source/ooxml/OOXMLDocumentImpl.hxx6
-rw-r--r--writerfilter/source/ooxml/OOXMLFastContextHandler.cxx2
5 files changed, 20 insertions, 12 deletions
diff --git a/writerfilter/inc/ooxml/OOXMLDocument.hxx b/writerfilter/inc/ooxml/OOXMLDocument.hxx
index 5ef9247011fa..9b2528ef8564 100644
--- a/writerfilter/inc/ooxml/OOXMLDocument.hxx
+++ b/writerfilter/inc/ooxml/OOXMLDocument.hxx
@@ -254,7 +254,7 @@ public:
static OOXMLDocument *
createDocument(OOXMLStream::Pointer_t pStream,
const css::uno::Reference<css::task::XStatusIndicator>& xStatusIndicator,
- bool bSkipImage, OUString const& rBaseURL);
+ bool bSkipImage, const css::uno::Sequence<css::beans::PropertyValue>& rDescriptor);
};
diff --git a/writerfilter/source/filter/WriterFilter.cxx b/writerfilter/source/filter/WriterFilter.cxx
index 432ef51e633c..f3c370c85369 100644
--- a/writerfilter/source/filter/WriterFilter.cxx
+++ b/writerfilter/source/filter/WriterFilter.cxx
@@ -153,7 +153,6 @@ sal_Bool WriterFilter::filter(const uno::Sequence< beans::PropertyValue >& aDesc
utl::MediaDescriptor aMediaDesc(aDescriptor);
bool bRepairStorage = aMediaDesc.getUnpackedValueOrDefault("RepairPackage", false);
bool bSkipImages = aMediaDesc.getUnpackedValueOrDefault("FilterOptions", OUString("")) == "SkipImages";
- OUString const baseURI = aMediaDesc.getUnpackedValueOrDefault("DocumentBaseURL", OUString(""));
uno::Reference< io::XInputStream > xInputStream;
try
@@ -174,7 +173,7 @@ sal_Bool WriterFilter::filter(const uno::Sequence< beans::PropertyValue >& aDesc
//create the tokenizer and domain mapper
writerfilter::ooxml::OOXMLStream::Pointer_t pDocStream = writerfilter::ooxml::OOXMLDocumentFactory::createStream(m_xContext, xInputStream, bRepairStorage);
uno::Reference<task::XStatusIndicator> xStatusIndicator = aMediaDesc.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_STATUSINDICATOR(), uno::Reference<task::XStatusIndicator>());
- writerfilter::ooxml::OOXMLDocument::Pointer_t pDocument(writerfilter::ooxml::OOXMLDocumentFactory::createDocument(pDocStream, xStatusIndicator, bSkipImages, baseURI));
+ writerfilter::ooxml::OOXMLDocument::Pointer_t pDocument(writerfilter::ooxml::OOXMLDocumentFactory::createDocument(pDocStream, xStatusIndicator, bSkipImages, aDescriptor));
uno::Reference<frame::XModel> xModel(m_xDstDoc, uno::UNO_QUERY_THROW);
pDocument->setModel(xModel);
diff --git a/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx b/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx
index 210384a89681..c3f99d216352 100644
--- a/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx
+++ b/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx
@@ -38,6 +38,7 @@
#include <vcl/settings.hxx>
#include <svx/dialogs.hrc>
#include <comphelper/sequence.hxx>
+#include <unotools/mediadescriptor.hxx>
#include <iostream>
@@ -49,7 +50,7 @@ namespace writerfilter {
namespace ooxml
{
-OOXMLDocumentImpl::OOXMLDocumentImpl(OOXMLStream::Pointer_t pStream, const uno::Reference<task::XStatusIndicator>& xStatusIndicator, bool bSkipImages, OUString const& rBaseURL)
+OOXMLDocumentImpl::OOXMLDocumentImpl(OOXMLStream::Pointer_t pStream, const uno::Reference<task::XStatusIndicator>& xStatusIndicator, bool bSkipImages, const uno::Sequence<beans::PropertyValue>& rDescriptor)
: mpStream(pStream)
, mxStatusIndicator(xStatusIndicator)
, mnXNoteId(0)
@@ -61,7 +62,8 @@ OOXMLDocumentImpl::OOXMLDocumentImpl(OOXMLStream::Pointer_t pStream, const uno::
, mnProgressLastPos(0)
, mnProgressCurrentPos(0)
, mnProgressEndPos(0)
- , m_rBaseURL(rBaseURL)
+ , m_rBaseURL(utl::MediaDescriptor(rDescriptor).getUnpackedValueOrDefault("DocumentBaseURL", OUString()))
+ , maMediaDescriptor(rDescriptor)
{
}
@@ -266,7 +268,7 @@ OOXMLDocumentImpl::getSubStream(const OUString & rId)
OOXMLDocumentImpl * pTemp;
// Do not pass status indicator to sub-streams: they are typically marginal in size, so we just track the main document for now.
- writerfilter::Reference<Stream>::Pointer_t pRet( pTemp = new OOXMLDocumentImpl(pStream, uno::Reference<task::XStatusIndicator>(), mbSkipImages, m_rBaseURL));
+ writerfilter::Reference<Stream>::Pointer_t pRet( pTemp = new OOXMLDocumentImpl(pStream, uno::Reference<task::XStatusIndicator>(), mbSkipImages, maMediaDescriptor));
pTemp->setModel(mxModel);
pTemp->setDrawPage(mxDrawPage);
pTemp->setIsSubstream( true );
@@ -280,7 +282,7 @@ OOXMLDocumentImpl::getXNoteStream(OOXMLStream::StreamType_t nType, const Id & rT
OOXMLStream::Pointer_t pStream =
(OOXMLDocumentFactory::createStream(mpStream, nType));
// See above, no status indicator for the note stream, either.
- OOXMLDocumentImpl * pDocument = new OOXMLDocumentImpl(pStream, uno::Reference<task::XStatusIndicator>(), mbSkipImages, m_rBaseURL);
+ OOXMLDocumentImpl * pDocument = new OOXMLDocumentImpl(pStream, uno::Reference<task::XStatusIndicator>(), mbSkipImages, maMediaDescriptor);
pDocument->setXNoteId(nId);
pDocument->setXNoteType(rType);
pDocument->setModel(getModel());
@@ -886,6 +888,11 @@ uno::Reference<io::XInputStream> OOXMLDocumentImpl::getStorageStream()
return mpStream->getStorageStream();
}
+const uno::Sequence<beans::PropertyValue>& OOXMLDocumentImpl::getMediaDescriptor()
+{
+ return maMediaDescriptor;
+}
+
void OOXMLDocumentImpl::setShapeContext( uno::Reference<xml::sax::XFastShapeContextHandler> xContext )
{
mxShapeContext = xContext;
@@ -930,9 +937,9 @@ OOXMLDocument *
OOXMLDocumentFactory::createDocument
(OOXMLStream::Pointer_t pStream,
const uno::Reference<task::XStatusIndicator>& xStatusIndicator,
- bool mbSkipImages, OUString const& rBaseURL)
+ bool mbSkipImages, const uno::Sequence<beans::PropertyValue>& rDescriptor)
{
- return new OOXMLDocumentImpl(pStream, xStatusIndicator, mbSkipImages, rBaseURL);
+ return new OOXMLDocumentImpl(pStream, xStatusIndicator, mbSkipImages, rDescriptor);
}
}}
diff --git a/writerfilter/source/ooxml/OOXMLDocumentImpl.hxx b/writerfilter/source/ooxml/OOXMLDocumentImpl.hxx
index 82a57deff7d4..6af6f8a1ac5c 100644
--- a/writerfilter/source/ooxml/OOXMLDocumentImpl.hxx
+++ b/writerfilter/source/ooxml/OOXMLDocumentImpl.hxx
@@ -64,7 +64,8 @@ class OOXMLDocumentImpl : public OOXMLDocument
/// End position, i.e. the estimated number of paragraphs.
sal_Int32 mnProgressEndPos;
/// DocumentBaseURL
- OUString const m_rBaseURL;
+ OUString m_rBaseURL;
+ css::uno::Sequence<css::beans::PropertyValue> maMediaDescriptor;
protected:
void resolveFastSubStream(Stream & rStream,
@@ -92,7 +93,7 @@ protected:
void resolveGlossaryStream(Stream & rStream);
void resolveEmbeddingsStream(OOXMLStream::Pointer_t pStream);
public:
- OOXMLDocumentImpl(OOXMLStream::Pointer_t pStream, const css::uno::Reference<css::task::XStatusIndicator>& xStatusIndicator, bool bSkipImages, OUString const& rBaseURL);
+ OOXMLDocumentImpl(OOXMLStream::Pointer_t pStream, const css::uno::Reference<css::task::XStatusIndicator>& xStatusIndicator, bool bSkipImages, const css::uno::Sequence<css::beans::PropertyValue>& rDescriptor);
virtual ~OOXMLDocumentImpl();
virtual void resolve(Stream & rStream) override;
@@ -141,6 +142,7 @@ public:
void incrementProgress();
bool IsSkipImages() { return mbSkipImages; };
OUString const& GetDocumentBaseURL() { return m_rBaseURL; };
+ const css::uno::Sequence<css::beans::PropertyValue>& getMediaDescriptor();
};
}}
#endif // OOXML_DOCUMENT_IMPL_HXX
diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
index 3d2c3668050c..9721aef46e95 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
@@ -1511,7 +1511,7 @@ OOXMLFastContextHandlerShape::OOXMLFastContextHandlerShape
uno::Reference<document::XDocumentPropertiesSupplier> xDocSupplier(getDocument()->getModel(), uno::UNO_QUERY_THROW);
mrShapeContext->setDocumentProperties(xDocSupplier->getDocumentProperties());
mrShapeContext->setDrawPage(getDocument()->getDrawPage());
- mrShapeContext->setInputStream(getDocument()->getStorageStream());
+ mrShapeContext->setMediaDescriptor(getDocument()->getMediaDescriptor());
mrShapeContext->setRelationFragmentPath
(mpParserState->getTarget());