Kaydet (Commit) b042cbcf authored tarafından Miklos Vajna's avatar Miklos Vajna Kaydeden (comit) Andras Timar

tdf#93097 oox: fix import of metadata from non-relative stream paths

Commit ef2668ba (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.

Change-Id: I6c0715adeb19b9055669f6a45055415dd2c44e28
(cherry picked from commit 46cf9bb7)
Reviewed-on: https://gerrit.libreoffice.org/18368Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 31bdd12b
...@@ -80,8 +80,13 @@ Sequence< InputSource > lclGetRelatedStreams( const Reference< XStorage >& rxSto ...@@ -80,8 +80,13 @@ Sequence< InputSource > lclGetRelatedStreams( const Reference< XStorage >& rxSto
const StringPair& rEntry = rEntries[ nEntryIndex ]; const StringPair& rEntry = rEntries[ nEntryIndex ];
if ( rEntry.First == "Target" ) 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( 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(); Reference< XInputStream > xInStream = xExtStream->getInputStream();
if( xInStream.is() ) if( xInStream.is() )
{ {
......
...@@ -105,6 +105,7 @@ public: ...@@ -105,6 +105,7 @@ public:
void testBnc910045(); void testBnc910045();
void testRowHeight(); void testRowHeight();
void testTdf93830(); void testTdf93830();
void testTdf93097();
CPPUNIT_TEST_SUITE(SdImportTest); CPPUNIT_TEST_SUITE(SdImportTest);
...@@ -145,6 +146,7 @@ public: ...@@ -145,6 +146,7 @@ public:
CPPUNIT_TEST(testBnc910045); CPPUNIT_TEST(testBnc910045);
CPPUNIT_TEST(testRowHeight); CPPUNIT_TEST(testRowHeight);
CPPUNIT_TEST(testTdf93830); CPPUNIT_TEST(testTdf93830);
CPPUNIT_TEST(testTdf93097);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
}; };
...@@ -1225,6 +1227,16 @@ void SdImportTest::testTdf93830() ...@@ -1225,6 +1227,16 @@ void SdImportTest::testTdf93830()
xDocShRef->DoClose(); xDocShRef->DoClose();
} }
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_TEST_SUITE_REGISTRATION(SdImportTest);
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment