From 88afec70112c95a016e92e26c1d06d7dd002e4e8 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 14 Aug 2019 12:21:11 +0200 Subject: 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 Tested-by: Jenkins --- embeddedobj/source/general/xcreator.cxx | 39 +++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'embeddedobj/source') 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 #include #include +#include #include #include @@ -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& 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 -- cgit