summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-11-28 10:18:34 +0000
committerCaolán McNamara <caolanm@redhat.com>2017-11-28 17:53:53 +0100
commitf6a2c667d19bb199a97a5822ab718758df421e7f (patch)
treeacb02003d1026e34d4835dd2d5e7d631567db0ca
parent97dabf63f6d0a432afcd176f669b272ca939a29f (diff)
add xlsx support to fftester
Change-Id: I07198f24a3e096fab67333cf6a98185d5b40fffc Reviewed-on: https://gerrit.libreoffice.org/45399 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--sc/source/filter/xml/xmlimprt.cxx46
-rw-r--r--vcl/workben/fftester.cxx14
2 files changed, 60 insertions, 0 deletions
diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx
index 1bf8d576fe38..e0795f56808d 100644
--- a/sc/source/filter/xml/xmlimprt.cxx
+++ b/sc/source/filter/xml/xmlimprt.cxx
@@ -82,6 +82,8 @@
#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/io/IOException.hpp>
+#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
#include <com/sun/star/sheet/XSheetCellRange.hpp>
#include <com/sun/star/document/XActionLockable.hpp>
#include <com/sun/star/util/MalformedNumberFormatException.hpp>
@@ -2102,4 +2104,48 @@ extern "C" SAL_DLLPUBLIC_EXPORT bool SAL_CALL TestImportFODS(SvStream &rStream)
return ret;
}
+extern "C" SAL_DLLPUBLIC_EXPORT bool SAL_CALL TestImportXLSX(SvStream &rStream)
+{
+ ScDLL::Init();
+
+ SfxObjectShellLock xDocSh(new ScDocShell);
+ 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.xls.ExcelFilter"), 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 591a28589022..7e78903a625f 100644
--- a/vcl/workben/fftester.cxx
+++ b/vcl/workben/fftester.cxx
@@ -417,6 +417,20 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
SvFileStream aFileStream(out, StreamMode::READ);
ret = (int) (*pfnImport)(aFileStream);
}
+ else if (strcmp(argv[2], "xlsx") == 0)
+ {
+ static FFilterCall pfnImport(nullptr);
+ if (!pfnImport)
+ {
+ osl::Module aLibrary;
+ aLibrary.loadRelative(&thisModule, "libsclo.so", SAL_LOADMODULE_LAZY);
+ pfnImport = reinterpret_cast<FFilterCall>(
+ aLibrary.getFunctionSymbol("TestImportXLSX"));
+ aLibrary.release();
+ }
+ SvFileStream aFileStream(out, StreamMode::READ);
+ ret = (int) (*pfnImport)(aFileStream);
+ }
else if (strcmp(argv[2], "fodp") == 0)
{
static FFilterCall pfnImport(nullptr);