summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/source/filter/xml/xmlimp.cxx57
-rw-r--r--sw/source/uibase/app/swdll.cxx4
-rw-r--r--sw/source/uibase/app/swmodule.cxx4
-rw-r--r--sw/source/uibase/uiview/view0.cxx3
-rw-r--r--vcl/workben/fftester.cxx14
5 files changed, 76 insertions, 6 deletions
diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx
index 5960e4092650..4ea3cebeef1e 100644
--- a/sw/source/filter/xml/xmlimp.cxx
+++ b/sw/source/filter/xml/xmlimp.cxx
@@ -24,6 +24,8 @@
#include <com/sun/star/document/PrinterIndependentLayout.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/frame/XSynchronousFrameLoader.hpp>
#include <com/sun/star/text/XTextDocument.hpp>
#include <com/sun/star/text/XTextRange.hpp>
@@ -53,15 +55,20 @@
#include <strings.hrc>
#include "xmlimp.hxx"
#include "xmltexti.hxx"
+#include "swdll.hxx"
#include <xmloff/DocumentSettingsContext.hxx>
#include <docsh.hxx>
#include <editeng/unolingu.hxx>
#include <svx/svdmodel.hxx>
#include <svx/xmlgrhlp.hxx>
#include <svx/xmleohlp.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/docfilt.hxx>
+#include <sfx2/frame.hxx>
#include <sfx2/printer.hxx>
#include <xmloff/xmluconv.hxx>
#include <unotools/saveopt.hxx>
+#include <unotools/streamwrap.hxx>
#include <tools/diagnose_ex.h>
#include <vcl/svapp.hxx>
@@ -71,6 +78,7 @@
#include <xmloff/xformsimport.hxx>
#include <comphelper/servicehelper.hxx>
#include <comphelper/processfactory.hxx>
+#include <comphelper/propertysequence.hxx>
#include <unordered_set>
@@ -397,7 +405,6 @@ SwXMLImport::SwXMLImport(
m_pDoc( nullptr )
{
InitItemImport();
-
}
SwXMLImport::~SwXMLImport() throw ()
@@ -1540,4 +1547,52 @@ com_sun_star_comp_Writer_XMLOasisSettingsImporter_get_implementation(css::uno::X
return cppu::acquire(new SwXMLImport(context, "com.sun.star.comp.Writer.XMLOasisSettingsImporter",
SvXMLImportFlags::SETTINGS));
}
+
+extern "C" SAL_DLLPUBLIC_EXPORT bool SAL_CALL TestImportFODT(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<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.Writer.XMLOasisImporter";
+ aUserData[3] = "com.sun.star.comp.Writer.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: */
diff --git a/sw/source/uibase/app/swdll.cxx b/sw/source/uibase/app/swdll.cxx
index d47a700af7a2..5bbee4388b53 100644
--- a/sw/source/uibase/app/swdll.cxx
+++ b/sw/source/uibase/app/swdll.cxx
@@ -89,7 +89,7 @@ SwDLL::SwDLL()
xOpt.reset(new SvtModuleOptions);
SfxObjectFactory* pDocFact = nullptr;
SfxObjectFactory* pGlobDocFact = nullptr;
- if (xOpt && xOpt->IsWriter())
+ if (!xOpt || xOpt->IsWriter())
{
pDocFact = &SwDocShell::Factory();
pGlobDocFact = &SwGlobalDocShell::Factory();
@@ -103,7 +103,7 @@ SwDLL::SwDLL()
pWDocFact->SetDocumentServiceName("com.sun.star.text.WebDocument");
- if (xOpt && xOpt->IsWriter())
+ if (!xOpt || xOpt->IsWriter())
{
pGlobDocFact->SetDocumentServiceName("com.sun.star.text.GlobalDocument");
pDocFact->SetDocumentServiceName("com.sun.star.text.TextDocument");
diff --git a/sw/source/uibase/app/swmodule.cxx b/sw/source/uibase/app/swmodule.cxx
index 962f7e7f14f1..72af465176a9 100644
--- a/sw/source/uibase/app/swmodule.cxx
+++ b/sw/source/uibase/app/swmodule.cxx
@@ -235,13 +235,13 @@ void SwDLL::RegisterFactories()
{
// These Id's must not be changed. Through these Id's the View (resume Documentview)
// is created by Sfx.
- if (!utl::ConfigManager::IsAvoidConfig() && SvtModuleOptions().IsWriter())
+ if (utl::ConfigManager::IsAvoidConfig() || SvtModuleOptions().IsWriter())
SwView::RegisterFactory ( SFX_INTERFACE_SFXDOCSH );
#if HAVE_FEATURE_DESKTOP
SwWebView::RegisterFactory ( SFX_INTERFACE_SFXMODULE );
- if (!utl::ConfigManager::IsAvoidConfig() && SvtModuleOptions().IsWriter())
+ if (utl::ConfigManager::IsAvoidConfig() || SvtModuleOptions().IsWriter())
{
SwSrcView::RegisterFactory ( SfxInterfaceId(6) );
SwPagePreview::RegisterFactory ( SfxInterfaceId(7) );
diff --git a/sw/source/uibase/uiview/view0.cxx b/sw/source/uibase/uiview/view0.cxx
index 59f90e5eede2..1a62e8ee7e91 100644
--- a/sw/source/uibase/uiview/view0.cxx
+++ b/sw/source/uibase/uiview/view0.cxx
@@ -24,6 +24,7 @@
#include <svl/srchitem.hxx>
#include <SwSpellDialogChildWindow.hxx>
#include <svl/eitem.hxx>
+#include <unotools/configmgr.hxx>
#include <unotools/linguprops.hxx>
#include <unotools/lingucfg.hxx>
#include <viewopt.hxx>
@@ -76,7 +77,7 @@ using namespace ::com::sun::star;
SFX_IMPL_NAMED_VIEWFACTORY(SwView, "Default")
{
- if ( SvtModuleOptions().IsWriter() )
+ if (utl::ConfigManager::IsAvoidConfig() || SvtModuleOptions().IsWriter())
{
SFX_VIEW_REGISTRATION(SwDocShell);
SFX_VIEW_REGISTRATION(SwGlobalDocShell);
diff --git a/vcl/workben/fftester.cxx b/vcl/workben/fftester.cxx
index 19e37ca0b0d6..aaf05df5311e 100644
--- a/vcl/workben/fftester.cxx
+++ b/vcl/workben/fftester.cxx
@@ -379,6 +379,20 @@ try_again:
SvFileStream aFileStream(out, StreamMode::READ);
ret = (int) (*pfnImport)(aFileStream);
}
+ else if (strcmp(argv[2], "fodt") == 0)
+ {
+ static FFilterCall pfnImport(nullptr);
+ if (!pfnImport)
+ {
+ osl::Module aLibrary;
+ aLibrary.loadRelative(&thisModule, "libswlo.so", SAL_LOADMODULE_LAZY);
+ pfnImport = reinterpret_cast<FFilterCall>(
+ aLibrary.getFunctionSymbol("TestImportFODT"));
+ aLibrary.release();
+ }
+ SvFileStream aFileStream(out, StreamMode::READ);
+ ret = (int) (*pfnImport)(aFileStream);
+ }
else if (strcmp(argv[2], "xls") == 0)
{
static WFilterCall pfnImport(nullptr);