diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-11-29 10:02:31 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-11-29 11:44:56 +0100 |
commit | 434036d8100fbb6845a55eff2e544983163ed277 (patch) | |
tree | e7efa2144cf7745ecf76f24be09987e05ee88eb6 /sd/source | |
parent | 454d1f464c3979a50d8b02ceb518e65703ac751d (diff) |
add pptx support to fftester
Change-Id: I517fa449ec75d8817cc3e03d0d90ab4c289a7c0f
Reviewed-on: https://gerrit.libreoffice.org/45477
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sd/source')
-rw-r--r-- | sd/source/filter/xml/sdxmlwrp.cxx | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/sd/source/filter/xml/sdxmlwrp.cxx b/sd/source/filter/xml/sdxmlwrp.cxx index 85ee835876f9..5b5f7a4bc52b 100644 --- a/sd/source/filter/xml/sdxmlwrp.cxx +++ b/sd/source/filter/xml/sdxmlwrp.cxx @@ -46,6 +46,7 @@ #include <com/sun/star/document/XExporter.hpp> #include <com/sun/star/lang/XInitialization.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp> #include <com/sun/star/document/XGraphicObjectResolver.hpp> #include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/container/XNameAccess.hpp> @@ -1058,5 +1059,49 @@ extern "C" SAL_DLLPUBLIC_EXPORT bool SAL_CALL TestImportFODP(SvStream &rStream) return ret; } +extern "C" SAL_DLLPUBLIC_EXPORT bool SAL_CALL TestImportPPTX(SvStream &rStream) +{ + SdDLL::Init(); + + sd::DrawDocShellRef xDocSh(new sd::DrawDocShell(SfxObjectCreateMode::EMBEDDED, false, DocumentType::Impress)); + xDocSh->DoInitNew(); + uno::Reference<frame::XModel> xModel(xDocSh->GetModel()); + + uno::Reference<lang::XMultiServiceFactory> xMultiServiceFactory(comphelper::getProcessServiceFactory()); + uno::Reference<io::XInputStream> xStream(new utl::OSeekableInputStreamWrapper(rStream)); + + uno::Reference<document::XFilter> xFilter(xMultiServiceFactory->createInstance("com.sun.star.comp.oox.ppt.PowerPointImport"), uno::UNO_QUERY_THROW); + + uno::Reference<document::XImporter> xImporter(xFilter, uno::UNO_QUERY_THROW); + uno::Sequence<beans::PropertyValue> aArgs(comphelper::InitPropertySequence( + { + { "InputStream", uno::makeAny(xStream) }, + { "InputMode", uno::makeAny(true) }, + })); + xImporter->setTargetDocument(xModel); + + //SetLoading hack because the document properties will be re-initted + //by the xml filter and during the init, while its considered uninitialized, + //setting a property will inform the document its modified, which attempts + //to update the properties, which throws cause the properties are uninitialized + xDocSh->SetLoading(SfxLoadedFlags::NONE); + bool ret = false; + try + { + ret = xFilter->filter(aArgs); + } + catch (const css::io::IOException&) + { + } + catch (const css::lang::WrappedTargetRuntimeException&) + { + } + xDocSh->SetLoading(SfxLoadedFlags::ALL); + + xDocSh->DoClose(); + + return ret; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |