svx/source/form/fmshimp.cxx     |    5 ++
 sw/inc/iodetect.hxx             |    1 
 sw/source/filter/xml/xmlimp.cxx |   83 ++++++++++++++++++++++++++++++++++++++++
 vcl/workben/fftester.cxx        |   10 ++++
 4 files changed, 99 insertions(+)

New commits:
commit bcccaf2322a7bd6ac4204ff48f623517a273922a
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Thu Apr 27 09:30:05 2023 +0100
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Thu Apr 27 21:16:15 2023 +0200

    add something for fodt to pdf
    
    Change-Id: Ia2dd8a4d5c6e558ebea6c170a0b01b5f361e1d39
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151135
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/sw/inc/iodetect.hxx b/sw/inc/iodetect.hxx
index c81d84742403..cc8f6693d630 100644
--- a/sw/inc/iodetect.hxx
+++ b/sw/inc/iodetect.hxx
@@ -115,6 +115,7 @@ public:
 };
 
 extern "C" SAL_DLLPUBLIC_EXPORT bool SAL_CALL TestImportFODT(SvStream 
&rStream);
+extern "C" SAL_DLLPUBLIC_EXPORT bool SAL_CALL TestPDFExportFODT(SvStream 
&rStream);
 
 #endif
 
diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx
index eaf3a6bec72e..49066780635b 100644
--- a/sw/source/filter/xml/xmlimp.cxx
+++ b/sw/source/filter/xml/xmlimp.cxx
@@ -23,8 +23,10 @@
 #include <cassert>
 
 #include <com/sun/star/document/PrinterIndependentLayout.hpp>
+#include <com/sun/star/document/XExporter.hpp>
 #include <com/sun/star/drawing/XDrawPage.hpp>
 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
+#include <com/sun/star/frame/Desktop.hpp>
 #include <com/sun/star/text/XTextDocument.hpp>
 #include <com/sun/star/text/XTextRange.hpp>
 
@@ -60,8 +62,12 @@
 #include <svx/xmlgrhlp.hxx>
 #include <svx/xmleohlp.hxx>
 #include <sfx2/printer.hxx>
+#include <sfx2/sfxmodelfactory.hxx>
 #include <xmloff/xmluconv.hxx>
+#include <unotools/fcm.hxx>
+#include <unotools/mediadescriptor.hxx>
 #include <unotools/streamwrap.hxx>
+#include <unotools/tempfile.hxx>
 #include <tools/UnitConversion.hxx>
 #include <comphelper/diagnose_ex.hxx>
 
@@ -1767,6 +1773,83 @@ extern "C" SAL_DLLPUBLIC_EXPORT bool 
TestImportFODT(SvStream &rStream)
     return ret;
 }
 
+extern "C" SAL_DLLPUBLIC_EXPORT bool TestPDFExportFODT(SvStream &rStream)
+{
+    Reference<css::frame::XDesktop2> xDesktop = 
css::frame::Desktop::create(comphelper::getProcessComponentContext());
+    Reference<css::frame::XFrame> xTargetFrame = xDesktop->findFrame("_blank", 
0);
+
+    Reference<uno::XComponentContext> 
xContext(comphelper::getProcessComponentContext());
+    Reference<css::frame::XModel2> 
xModel(xContext->getServiceManager()->createInstanceWithContext(
+                "com.sun.star.text.TextDocument", xContext), UNO_QUERY_THROW);
+
+    Reference<css::frame::XLoadable> xModelLoad(xModel, UNO_QUERY_THROW);
+    xModelLoad->initNew();
+
+    css::uno::Reference<css::frame::XController2> 
xController(xModel->createDefaultViewController(xTargetFrame), UNO_SET_THROW);
+
+    utl::ConnectFrameControllerModel(xTargetFrame, xController, xModel);
+
+    uno::Reference<lang::XMultiServiceFactory> 
xMultiServiceFactory(comphelper::getProcessServiceFactory());
+    uno::Reference<io::XInputStream> xStream(new 
utl::OSeekableInputStreamWrapper(rStream));
+    uno::Reference<uno::XInterface> 
xInterface(xMultiServiceFactory->createInstance("com.sun.star.comp.Writer.XmlFilterAdaptor"),
 uno::UNO_SET_THROW);
+
+    css::uno::Sequence<OUString> aUserData
+    {
+        "com.sun.star.comp.filter.OdfFlatXml",
+        "",
+        "com.sun.star.comp.Writer.XMLOasisImporter",
+        "com.sun.star.comp.Writer.XMLOasisExporter",
+        "",
+        "",
+        "true"
+    };
+    uno::Sequence<beans::PropertyValue> 
aAdaptorArgs(comphelper::InitPropertySequence(
+    {
+        { "UserData", uno::Any(aUserData) },
+    }));
+    css::uno::Sequence<uno::Any> aOuterArgs{ uno::Any(aAdaptorArgs) };
+
+    uno::Reference<lang::XInitialization> xInit(xInterface, 
uno::UNO_QUERY_THROW);
+    xInit->initialize(aOuterArgs);
+
+    uno::Reference<document::XImporter> xImporter(xInterface, 
uno::UNO_QUERY_THROW);
+    uno::Sequence<beans::PropertyValue> aArgs(comphelper::InitPropertySequence(
+    {
+        { "InputStream", uno::Any(xStream) },
+        { "URL", uno::Any(OUString("private:stream")) },
+    }));
+    xImporter->setTargetDocument(xModel);
+
+    uno::Reference<document::XFilter> xFODTFilter(xInterface, 
uno::UNO_QUERY_THROW);
+    bool ret = xFODTFilter->filter(aArgs);
+
+    utl::MediaDescriptor aMediaDescriptor;
+    aMediaDescriptor["FilterName"] <<= OUString("writer_pdf_Export");
+
+    utl::TempFileNamed aTempFile;
+    aTempFile.EnableKillingFile();
+
+    uno::Reference<document::XFilter> xPDFFilter(
+        
xMultiServiceFactory->createInstance("com.sun.star.document.PDFFilter"), 
uno::UNO_QUERY);
+    uno::Reference<document::XExporter> xExporter(xPDFFilter, uno::UNO_QUERY);
+    xExporter->setSourceDocument(xModel);
+
+    SvFileStream aOutputStream(aTempFile.GetURL(), StreamMode::WRITE);
+    uno::Reference<io::XOutputStream> xOutputStream(new 
utl::OStreamWrapper(aOutputStream));
+
+    uno::Sequence<beans::PropertyValue> 
aDescriptor(comphelper::InitPropertySequence({
+        { "FilterName", uno::Any(OUString("writer_pdf_Export")) },
+        { "OutputStream", uno::Any(xOutputStream) }
+    }));
+    xPDFFilter->filter(aDescriptor);
+    aOutputStream.Close();
+
+    css::uno::Reference<css::util::XCloseable> xClose(xModel, 
css::uno::UNO_QUERY);
+    xClose->close(false);
+
+    return ret;
+}
+
 extern "C" SAL_DLLPUBLIC_EXPORT bool TestImportDOCX(SvStream &rStream)
 {
     SwGlobals::ensure();
diff --git a/vcl/workben/fftester.cxx b/vcl/workben/fftester.cxx
index c396b28f1ede..44fb5338f808 100644
--- a/vcl/workben/fftester.cxx
+++ b/vcl/workben/fftester.cxx
@@ -322,6 +322,16 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
             SvFileStream aFileStream(out, StreamMode::READ);
             ret = static_cast<int>((*pfnImport)(aFileStream));
         }
+        else if (strcmp(argv[2], "fodt2pdf") == 0)
+        {
+            static FFilterCall pfnImport(nullptr);
+            if (!pfnImport)
+            {
+                pfnImport = load(u"libswlo.so", "TestPDFExportFODT");
+            }
+            SvFileStream aFileStream(out, StreamMode::READ);
+            ret = static_cast<int>((*pfnImport)(aFileStream));
+        }
         else if (strcmp(argv[2], "docx") == 0)
         {
             static FFilterCall pfnImport(nullptr);
commit dfd1a83a42791973ff8db36960089e2a00c36e99
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Thu Apr 27 16:33:32 2023 +0100
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Thu Apr 27 21:16:04 2023 +0200

    avoid config when fuzzing
    
    Change-Id: If7778a7799db8d14c990a398166358b084da48d5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151134
    Tested-by: Caolán McNamara <caol...@redhat.com>
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/svx/source/form/fmshimp.cxx b/svx/source/form/fmshimp.cxx
index 607c7055472e..3b5d896cd0a0 100644
--- a/svx/source/form/fmshimp.cxx
+++ b/svx/source/form/fmshimp.cxx
@@ -92,6 +92,7 @@
 #include <toolkit/helper/vclunohelper.hxx>
 #include <tools/debug.hxx>
 #include <comphelper/diagnose_ex.hxx>
+#include <unotools/configmgr.hxx>
 #include <vcl/settings.hxx>
 #include <vcl/svapp.hxx>
 #include <vcl/weld.hxx>
@@ -3461,6 +3462,10 @@ void FmXFormShell::CreateExternalView_Lock()
 
 void FmXFormShell::implAdjustConfigCache_Lock()
 {
+    const bool bFuzzing(utl::ConfigManager::IsFuzzing());
+    if (bFuzzing)
+        return;
+
     // get (cache) the wizard usage flag
     Sequence< OUString > aNames { "FormControlPilotsEnabled" };
     Sequence< Any > aFlags = GetProperties(aNames);

Reply via email to