[Libreoffice-commits] core.git: embeddedobj/Library_embobj.mk embeddedobj/source

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Wed Aug 14 12:33:38 UTC 2019


 embeddedobj/Library_embobj.mk           |    4 +++
 embeddedobj/source/general/xcreator.cxx |   39 ++++++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+)

New commits:
commit 88afec70112c95a016e92e26c1d06d7dd002e4e8
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Wed Aug 14 12:21:11 2019 +0200
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Wed Aug 14 14:32:44 2019 +0200

    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.
    
    Change-Id: I6bce8b5467768ef3f21d97b4e0fe3f4d18d9466b
    Reviewed-on: https://gerrit.libreoffice.org/77449
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
    Tested-by: Jenkins

diff --git a/embeddedobj/Library_embobj.mk b/embeddedobj/Library_embobj.mk
index 3030e2ae70c5..6e9929e95016 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 f825c852ade4..aa19cf429185 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>
@@ -208,6 +209,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,
@@ -233,6 +270,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


More information about the Libreoffice-commits mailing list