Kaydet (Commit) 6191f701 authored tarafından Caolán McNamara's avatar Caolán McNamara

add docx support to fftester

Change-Id: Ia761e23c011c53f8f786ac336efd4b9e94fc6e35
Reviewed-on: https://gerrit.libreoffice.org/45033Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst a32eabb6
......@@ -1559,7 +1559,7 @@ extern "C" SAL_DLLPUBLIC_EXPORT bool SAL_CALL TestImportFODT(SvStream &rStream)
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<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);
......@@ -1599,4 +1599,38 @@ extern "C" SAL_DLLPUBLIC_EXPORT bool SAL_CALL TestImportFODT(SvStream &rStream)
return ret;
}
extern "C" SAL_DLLPUBLIC_EXPORT bool SAL_CALL TestImportDOCX(SvStream &rStream)
{
SwGlobals::ensure();
SfxObjectShellLock xDocSh(new SwDocShell(SfxObjectCreateMode::INTERNAL));
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.Writer.WriterFilter"), 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 = xFilter->filter(aArgs);
xDocSh->SetLoading(SfxLoadedFlags::ALL);
xDocSh->DoClose();
return ret;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -386,6 +386,20 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
SvFileStream aFileStream(out, StreamMode::READ);
ret = (int) (*pfnImport)(aFileStream);
}
else if (strcmp(argv[2], "docx") == 0)
{
static FFilterCall pfnImport(nullptr);
if (!pfnImport)
{
osl::Module aLibrary;
aLibrary.loadRelative(&thisModule, "libswlo.so", SAL_LOADMODULE_LAZY);
pfnImport = reinterpret_cast<FFilterCall>(
aLibrary.getFunctionSymbol("TestImportDOCX"));
aLibrary.release();
}
SvFileStream aFileStream(out, StreamMode::READ);
ret = (int) (*pfnImport)(aFileStream);
}
else if (strcmp(argv[2], "fods") == 0)
{
static FFilterCall pfnImport(nullptr);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment