comphelper/source/container/embeddedobjectcontainer.cxx | 15 ++++++--- sw/CppunitTest_sw_odfexport.mk | 13 +++++--- sw/qa/extras/odfexport/data/fdo58949.docx |binary sw/qa/extras/odfexport/odfexport.cxx | 25 ++++++++++++++++ 4 files changed, 44 insertions(+), 9 deletions(-)
New commits: commit dc92bac5df72ecca123472a5e945b1864a17f457 Author: Miklos Vajna <vmik...@suse.cz> Date: Fri Apr 26 12:41:22 2013 +0200 fdo#58949 testcase Change-Id: I584efc83ef1643a683757ac369cd140f52610293 diff --git a/sw/CppunitTest_sw_odfexport.mk b/sw/CppunitTest_sw_odfexport.mk index aae298d..a484b9a 100644 --- a/sw/CppunitTest_sw_odfexport.mk +++ b/sw/CppunitTest_sw_odfexport.mk @@ -49,28 +49,33 @@ $(eval $(call gb_CppunitTest_use_api,sw_odfexport,\ $(eval $(call gb_CppunitTest_use_ure,sw_odfexport)) $(eval $(call gb_CppunitTest_use_components,sw_odfexport,\ - basic/util/sb \ + basic/util/sb \ comphelper/util/comphelp \ configmgr/source/configmgr \ + embeddedobj/util/embobj \ fileaccess/source/fileacc \ filter/source/config/cache/filterconfig1 \ framework/util/fwk \ i18npool/util/i18npool \ linguistic/source/lng \ - package/util/package2 \ + oox/util/oox \ package/source/xstor/xstor \ - sw/util/sw \ - sw/util/swd \ + package/util/package2 \ sax/source/expatwrap/expwrap \ + sax/source/fastparser/fastsax \ sfx2/util/sfx \ + starmath/util/sm \ svl/source/fsstor/fsstorage \ svtools/util/svt \ + sw/util/sw \ + sw/util/swd \ toolkit/util/tk \ ucb/source/core/ucb1 \ ucb/source/ucp/file/ucpfile1 \ unotools/util/utl \ unoxml/source/service/unoxml \ uui/util/uui \ + writerfilter/util/writerfilter \ $(if $(filter DESKTOP,$(BUILD_TYPE)),xmlhelp/util/ucpchelp1) \ xmloff/util/xo \ )) diff --git a/sw/qa/extras/odfexport/data/fdo58949.docx b/sw/qa/extras/odfexport/data/fdo58949.docx new file mode 100644 index 0000000..d8f568b Binary files /dev/null and b/sw/qa/extras/odfexport/data/fdo58949.docx differ diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx index 81fcaec..5c4c408 100644 --- a/sw/qa/extras/odfexport/odfexport.cxx +++ b/sw/qa/extras/odfexport/odfexport.cxx @@ -17,6 +17,7 @@ public: void testFirstHeaderFooter(); void testTextframeGradient(); void testFdo60769(); + void testFdo58949(); CPPUNIT_TEST_SUITE(Test); #if !defined(MACOSX) && !defined(WNT) @@ -35,6 +36,7 @@ void Test::run() {"first-header-footer.odt", &Test::testFirstHeaderFooter}, {"textframe-gradient.odt", &Test::testTextframeGradient}, {"fdo60769.odt", &Test::testFdo60769}, + {"fdo58949.docx", &Test::testFdo58949}, }; header(); for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i) @@ -142,6 +144,29 @@ void Test::testFdo60769() } } +void Test::testFdo58949() +{ + /* + * The problem was that the exporter didn't insert "Obj102" to the + * resulting zip file. No idea how to check for "broken" (missing OLE data + * and replacement image) OLE objects using UNO, so we'll check the zip file directly. + */ + + // Create the zip file. + utl::TempFile aTempFile; + aTempFile.EnableKillingFile(); + uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY); + uno::Sequence<beans::PropertyValue> aFilterArgs(1); + aFilterArgs[0].Name = "FilterName"; + aFilterArgs[0].Value <<= OUString("writer8"); + xStorable->storeToURL(aTempFile.GetURL(), aFilterArgs); + + uno::Sequence<uno::Any> aArgs(1); + aArgs[0] <<= OUString(aTempFile.GetURL()); + uno::Reference<container::XNameAccess> xNameAccess(m_xSFactory->createInstanceWithArguments("com.sun.star.packages.zip.ZipFileAccess", aArgs), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(true, bool(xNameAccess->hasByName("Obj102"))); +} + CPPUNIT_TEST_SUITE_REGISTRATION(Test); CPPUNIT_PLUGIN_IMPLEMENT(); commit 6238cfe27f0a202f3fbf482cde2b0a3189adc86f Author: Miklos Vajna <vmik...@suse.cz> Date: Fri Apr 26 11:46:57 2013 +0200 fdo#58949 EmbeddedObjectContainer: guard against embed::WrongStateException The problem was that in case an exception was thrown, it was only caught outside the loop, so in case any error occurred, we didn't even try to export the remaining objects. At least in case of embed::WrongStateException, this is safe to do. Change-Id: I71a7abc45a89bebc667664bc001245bb886a8d83 diff --git a/comphelper/source/container/embeddedobjectcontainer.cxx b/comphelper/source/container/embeddedobjectcontainer.cxx index 87b214e..a988a1e 100644 --- a/comphelper/source/container/embeddedobjectcontainer.cxx +++ b/comphelper/source/container/embeddedobjectcontainer.cxx @@ -1417,10 +1417,14 @@ sal_Bool EmbeddedObjectContainer::StoreAsChildren(sal_Bool _bOasisFormat,sal_Boo aArgs[2].Value <<= xStream; } - xPersist->storeAsEntry( _xStorage, - xPersist->getEntryName(), - uno::Sequence< beans::PropertyValue >(), - aArgs ); + try + { + xPersist->storeAsEntry( _xStorage, xPersist->getEntryName(), uno::Sequence< beans::PropertyValue >(), aArgs ); + } + catch (const embed::WrongStateException& e) + { + SAL_WARN("comphelper", "failed to store '" << *pIter << "'"); + } } if ( bSwitchBackToLoaded ) @@ -1432,10 +1436,11 @@ sal_Bool EmbeddedObjectContainer::StoreAsChildren(sal_Bool _bOasisFormat,sal_Boo bResult = aCnt.CommitImageSubStorage(); } - catch (const uno::Exception&) + catch (const uno::Exception& e) { // TODO/LATER: error handling bResult = sal_False; + SAL_WARN("comphelper", "failed. Message: " << e.Message); } // the old SO6 format does not store graphical replacements _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits