[Libreoffice-commits] core.git: sd/source vcl/workben

Caolán McNamara caolanm at redhat.com
Wed Nov 29 10:45:36 UTC 2017


 sd/source/filter/xml/sdxmlwrp.cxx |   45 ++++++++++++++++++++++++++++++++++++++
 vcl/workben/fftester.cxx          |   14 +++++++++++
 2 files changed, 59 insertions(+)

New commits:
commit 434036d8100fbb6845a55eff2e544983163ed277
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Nov 29 10:02:31 2017 +0000

    add pptx support to fftester
    
    Change-Id: I517fa449ec75d8817cc3e03d0d90ab4c289a7c0f
    Reviewed-on: https://gerrit.libreoffice.org/45477
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

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: */
diff --git a/vcl/workben/fftester.cxx b/vcl/workben/fftester.cxx
index 7e78903a625f..4c9c131e39b2 100644
--- a/vcl/workben/fftester.cxx
+++ b/vcl/workben/fftester.cxx
@@ -445,6 +445,20 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
             SvFileStream aFileStream(out, StreamMode::READ);
             ret = (int) (*pfnImport)(aFileStream);
         }
+        else if (strcmp(argv[2], "pptx") == 0)
+        {
+            static FFilterCall pfnImport(nullptr);
+            if (!pfnImport)
+            {
+                osl::Module aLibrary;
+                aLibrary.loadRelative(&thisModule, "libsdlo.so", SAL_LOADMODULE_LAZY);
+                pfnImport = reinterpret_cast<FFilterCall>(
+                    aLibrary.getFunctionSymbol("TestImportPPTX"));
+                aLibrary.release();
+            }
+            SvFileStream aFileStream(out, StreamMode::READ);
+            ret = (int) (*pfnImport)(aFileStream);
+        }
         else if (strcmp(argv[2], "xls") == 0)
         {
             static FFilterCall pfnImport(nullptr);


More information about the Libreoffice-commits mailing list