summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2019-08-14 12:21:11 +0200
committerMiklos Vajna <vmiklos@collabora.com>2019-08-16 11:12:54 +0200
commit475de9ce84ff56b93e2b2de2500dc77fe08d83bb (patch)
tree74fcc976a9ddc3d5f2a530f49f617e982b4e604d
parentdb41142bc4c0d44a999ed570e7e6d102277b9cb4 (diff)
embeddedobj: respect config for Insert -> Object -> OLE Object -> from file
Tools -> Options -> Load/Save -> Microsoft Office has config options to decide that Word/Excel/PowerPoint formats are loaded into our doc models (default) or handled via external OLE applications instead. This is used in the MSO import/export filters, but in case the UI is used to insert a new file as an embedded object, then we ignored this setting, and the embedding type depended on if we found an import filter for the data or not (if yes, load it; handle externally otherwise). Fix this inconsistency by checking for the usual MSO import filter names and respect the existing configuration in those cases, so the user can choose to not handle these formats internally if wanted. Reviewed-on: https://gerrit.libreoffice.org/77449 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins (cherry picked from commit 88afec70112c95a016e92e26c1d06d7dd002e4e8) Change-Id: I6bce8b5467768ef3f21d97b4e0fe3f4d18d9466b
-rw-r--r--embeddedobj/Library_embobj.mk4
-rw-r--r--embeddedobj/source/general/xcreator.cxx39
2 files changed, 43 insertions, 0 deletions
diff --git a/embeddedobj/Library_embobj.mk b/embeddedobj/Library_embobj.mk
index 87c33c893d6f..80660adc0e35 100644
--- a/embeddedobj/Library_embobj.mk
+++ b/embeddedobj/Library_embobj.mk
@@ -10,6 +10,10 @@
$(eval $(call gb_Library_Library,embobj))
+$(eval $(call gb_Library_use_custom_headers,embobj,\
+ officecfg/registry \
+))
+
$(eval $(call gb_Library_set_componentfile,embobj,embeddedobj/util/embobj))
$(eval $(call gb_Library_set_include,embobj,\
diff --git a/embeddedobj/source/general/xcreator.cxx b/embeddedobj/source/general/xcreator.cxx
index 492e02b4a7b4..d9bc8d7869c0 100644
--- a/embeddedobj/source/general/xcreator.cxx
+++ b/embeddedobj/source/general/xcreator.cxx
@@ -32,6 +32,7 @@
#include <comphelper/processfactory.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <comphelper/documentconstants.hxx>
+#include <officecfg/Office/Common.hxx>
#include <xcreator.hxx>
#include <dummyobject.hxx>
@@ -209,6 +210,42 @@ uno::Reference< uno::XInterface > SAL_CALL UNOEmbeddedObjectCreator::createInsta
return xResult;
}
+/**
+ * Decides if rFilter should be used to load data into a doc model or real OLE embedding should
+ * happen. Empty return value means the later.
+ */
+static OUString HandleFilter(const uno::Reference<uno::XComponentContext>& xComponentContext,
+ const OUString& rFilter)
+{
+ OUString aRet = rFilter;
+
+ if (!officecfg::Office::Common::Filter::Microsoft::Import::WinWordToWriter::get(
+ xComponentContext))
+ {
+ if (rFilter == "MS Word 97" || rFilter == "MS Word 2007 XML")
+ {
+ aRet.clear();
+ }
+ }
+
+ if (!officecfg::Office::Common::Filter::Microsoft::Import::ExcelToCalc::get(xComponentContext))
+ {
+ if (rFilter == "MS Excel 97" || rFilter == "Calc MS Excel 2007 XML")
+ {
+ aRet.clear();
+ }
+ }
+ if (!officecfg::Office::Common::Filter::Microsoft::Import::PowerPointToImpress::get(
+ xComponentContext))
+ {
+ if (rFilter == "MS PowerPoint 97" || rFilter == "Impress MS PowerPoint 2007 XML")
+ {
+ aRet.clear();
+ }
+ }
+
+ return aRet;
+}
uno::Reference< uno::XInterface > SAL_CALL UNOEmbeddedObjectCreator::createInstanceInitFromMediaDescriptor(
const uno::Reference< embed::XStorage >& xStorage,
@@ -234,6 +271,8 @@ uno::Reference< uno::XInterface > SAL_CALL UNOEmbeddedObjectCreator::createInsta
// check if there is FilterName
OUString aFilterName = m_aConfigHelper.UpdateMediaDescriptorWithFilterName( aTempMedDescr, false );
+ aFilterName = HandleFilter(m_xContext, aFilterName);
+
if ( !aFilterName.isEmpty() )
{
// the object can be loaded by one of the office application