summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2015-09-04 11:49:25 +0200
committerCaolán McNamara <caolanm@redhat.com>2015-09-11 09:37:02 +0000
commitd5220fcd4d2583ce7fdfaad4cc5ea2ca881f8c37 (patch)
treeab94bdfc4024cd36c034d8e5edd4e74e10afdf3b
parent8920a191411a291248fb68434a79f10cb739af1c (diff)
tdf#93097 oox: fix import of metadata from non-relative stream paths
Commit ef2668bad976f1fbb70759887cafd35ea7833655 (PPTX import: fix missing document metadata, 2014-08-28) implemented metadata import for the PPTX filter, but in case the metadata stream is not an existing one, then OHierarchyHolder_Impl::GetListPathFromString() invoked by OStorage::openStreamElementByHierarchicalName() throws. The bugdoc is generated by a 3rd-party tool that always starts the stream path with a slash, and MSO seems to just ignore that: so let's do the same to be able to open the document. (cherry picked from commit 46cf9bb76b29f2bfa6639d9aaf4f26dee365bc0c) Conflicts: sd/qa/unit/import-tests.cxx Change-Id: I6c0715adeb19b9055669f6a45055415dd2c44e28 Reviewed-on: https://gerrit.libreoffice.org/18372 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--oox/source/docprop/ooxmldocpropimport.cxx7
-rw-r--r--sd/qa/unit/data/pptx/tdf93097.pptxbin0 -> 29386 bytes
-rw-r--r--sd/qa/unit/import-tests.cxx12
3 files changed, 18 insertions, 1 deletions
diff --git a/oox/source/docprop/ooxmldocpropimport.cxx b/oox/source/docprop/ooxmldocpropimport.cxx
index c711f2f97de7..646c09c68437 100644
--- a/oox/source/docprop/ooxmldocpropimport.cxx
+++ b/oox/source/docprop/ooxmldocpropimport.cxx
@@ -80,8 +80,13 @@ Sequence< InputSource > lclGetRelatedStreams( const Reference< XStorage >& rxSto
const StringPair& rEntry = rEntries[ nEntryIndex ];
if ( rEntry.First == "Target" )
{
+ // The stream path is always a relative one, ignore the leading "/" if it's there.
+ OUString aStreamPath = rEntry.Second;
+ if (aStreamPath.startsWith("/"))
+ aStreamPath = aStreamPath.copy(1);
+
Reference< XExtendedStorageStream > xExtStream(
- xHierarchy->openStreamElementByHierarchicalName( rEntry.Second, ElementModes::READ ), UNO_QUERY_THROW );
+ xHierarchy->openStreamElementByHierarchicalName( aStreamPath, ElementModes::READ ), UNO_QUERY_THROW );
Reference< XInputStream > xInStream = xExtStream->getInputStream();
if( xInStream.is() )
{
diff --git a/sd/qa/unit/data/pptx/tdf93097.pptx b/sd/qa/unit/data/pptx/tdf93097.pptx
new file mode 100644
index 000000000000..687110db3540
--- /dev/null
+++ b/sd/qa/unit/data/pptx/tdf93097.pptx
Binary files differ
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index 024801bc7281..c92834176d27 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -97,6 +97,7 @@ public:
void testPDFImport();
void testPDFImportSkipImages();
void testBnc910045();
+ void testTdf93097();
CPPUNIT_TEST_SUITE(SdImportTest);
@@ -132,6 +133,7 @@ public:
CPPUNIT_TEST(testPDFImport);
CPPUNIT_TEST(testPDFImportSkipImages);
CPPUNIT_TEST(testBnc910045);
+ CPPUNIT_TEST(testTdf93097);
CPPUNIT_TEST_SUITE_END();
};
@@ -1137,6 +1139,16 @@ void SdImportTest::testBnc910045()
CPPUNIT_ASSERT_EQUAL(sal_Int32(5210557), nColor);
}
+void SdImportTest::testTdf93097()
+{
+ // Throwing metadata import aborted the filter, check that metadata is now imported.
+ sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/tdf93097.pptx"), PPTX);
+ uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier(xDocShRef->GetModel(), uno::UNO_QUERY);
+ uno::Reference<document::XDocumentProperties> xDocumentProperties = xDocumentPropertiesSupplier->getDocumentProperties();
+ CPPUNIT_ASSERT_EQUAL(OUString("ss"), xDocumentProperties->getTitle());
+ xDocShRef->DoClose();
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTest);
CPPUNIT_PLUGIN_IMPLEMENT();