summaryrefslogtreecommitdiff
path: root/embeddedobj/source
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2019-08-14 12:21:11 +0200
committerMiklos Vajna <vmiklos@collabora.com>2019-08-14 14:32:44 +0200
commit88afec70112c95a016e92e26c1d06d7dd002e4e8 (patch)
treee90e697236d2ca29dc628b8977ac356be707948d /embeddedobj/source
parentd3d13140f0036c53aa74820b41acfeffa3572168 (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. Change-Id: I6bce8b5467768ef3f21d97b4e0fe3f4d18d9466b Reviewed-on: https://gerrit.libreoffice.org/77449 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'embeddedobj/source')
-rw-r--r--embeddedobj/source/general/xcreator.cxx39
1 files changed, 39 insertions, 0 deletions
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