summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-09-21 09:43:17 +0100
committerCaolán McNamara <caolanm@redhat.com>2017-09-24 17:29:44 +0200
commit14b057b7fe224ebf9409bf834e0c4c1a83187f76 (patch)
tree60c4f609862716bc7a4ea667ed7d1af5ab258277 /sd
parentfe0f1dba1369f5d9f382ee3432833e22fe0da442 (diff)
add fodp fuzzer
Change-Id: Ib6c439fa8db7de0544c8ee3340c07a40bf10bcb6 Reviewed-on: https://gerrit.libreoffice.org/42582 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sd')
-rw-r--r--sd/source/filter/xml/sdxmlwrp.cxx51
1 files changed, 51 insertions, 0 deletions
diff --git a/sd/source/filter/xml/sdxmlwrp.cxx b/sd/source/filter/xml/sdxmlwrp.cxx
index fa3bcfa10cdf..4370f37b3828 100644
--- a/sd/source/filter/xml/sdxmlwrp.cxx
+++ b/sd/source/filter/xml/sdxmlwrp.cxx
@@ -24,6 +24,7 @@
#include <com/sun/star/embed/ElementModes.hpp>
#include <com/sun/star/xml/sax/SAXParseException.hpp>
#include <comphelper/processfactory.hxx>
+#include <comphelper/propertysequence.hxx>
#include <sfx2/docfile.hxx>
#include <sfx2/docfilt.hxx>
#include <sfx2/sfxsids.hrc>
@@ -43,6 +44,7 @@
#include <com/sun/star/document/XFilter.hpp>
#include <com/sun/star/document/XImporter.hpp>
#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/document/XGraphicObjectResolver.hpp>
#include <com/sun/star/beans/PropertyAttribute.hpp>
@@ -68,6 +70,7 @@
#include <svl/stritem.hxx>
#include <svtools/sfxecode.hxx>
+#include "sddll.hxx"
#include "sderror.hxx"
#include "sdresid.hxx"
#include "sdtransform.hxx"
@@ -1002,4 +1005,52 @@ bool SdXMLFilter::Export()
return bDocRet;
}
+extern "C" SAL_DLLPUBLIC_EXPORT bool SAL_CALL TestImportFODP(SvStream &rStream)
+{
+ SdDLL::Init();
+
+ sd::DrawDocShellRef xDocSh(new sd::DrawDocShell(SfxObjectCreateMode::EMBEDDED, false));
+ 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<uno::XInterface> xInterface(xMultiServiceFactory->createInstance("com.sun.star.comp.Writer.XmlFilterAdaptor"), uno::UNO_QUERY_THROW);
+
+ css::uno::Sequence<OUString> aUserData(7);
+ aUserData[0] = "com.sun.star.comp.filter.OdfFlatXml";
+ aUserData[2] = "com.sun.star.comp.Impress.XMLOasisImporter";
+ aUserData[3] = "com.sun.star.comp.Impress.XMLOasisExporter";
+ aUserData[6] = "true";
+ uno::Sequence<beans::PropertyValue> aAdaptorArgs(comphelper::InitPropertySequence(
+ {
+ { "UserData", uno::Any(aUserData) },
+ }));
+ css::uno::Sequence<uno::Any> aOuterArgs(1);
+ aOuterArgs[0] <<= 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> xFilter(xInterface, uno::UNO_QUERY_THROW);
+ //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 = xFilter->filter(aArgs);
+ xDocSh->SetLoading(SfxLoadedFlags::ALL);
+
+ return ret;
+}
+
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */