From 5827e30109b683cb74efa21d154e5219fe9e2a0c Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 15 Aug 2019 10:55:53 +0200 Subject: embeddedobj: allow controlling if Visio documents are converted to Draw or not At the moment this affects only Insert -> Object -> OLE Object -> from file. Change-Id: I8d1c6456481610491916e3be3766b0bb04dfa296 Reviewed-on: https://gerrit.libreoffice.org/77489 Reviewed-by: Miklos Vajna Tested-by: Jenkins --- .../qa/cppunit/data/insert-file-config.vsdx | Bin 0 -> 12483 bytes embeddedobj/qa/cppunit/general.cxx | 33 +++++++++++++++++++++ embeddedobj/source/general/xcreator.cxx | 7 +++++ 3 files changed, 40 insertions(+) create mode 100644 embeddedobj/qa/cppunit/data/insert-file-config.vsdx (limited to 'embeddedobj') diff --git a/embeddedobj/qa/cppunit/data/insert-file-config.vsdx b/embeddedobj/qa/cppunit/data/insert-file-config.vsdx new file mode 100644 index 000000000000..bb3a129cfa7b Binary files /dev/null and b/embeddedobj/qa/cppunit/data/insert-file-config.vsdx differ diff --git a/embeddedobj/qa/cppunit/general.cxx b/embeddedobj/qa/cppunit/general.cxx index 43b8dd9f4c1b..bbab17440fe3 100644 --- a/embeddedobj/qa/cppunit/general.cxx +++ b/embeddedobj/qa/cppunit/general.cxx @@ -85,6 +85,39 @@ CPPUNIT_TEST_FIXTURE(EmbeddedobjGeneralTest, testInsertFileConfig) CPPUNIT_ASSERT(!xObject.is()); } +CPPUNIT_TEST_FIXTURE(EmbeddedobjGeneralTest, testInsertFileConfigVsdx) +{ + // Explicitly disable Word->Writer mapping for this test. + std::shared_ptr pBatch( + comphelper::ConfigurationChanges::create()); + officecfg::Office::Common::Filter::Microsoft::Import::VisioToDraw::set(false, pBatch); + pBatch->commit(); + comphelper::ScopeGuard g([]() { + std::shared_ptr pBatchReset( + comphelper::ConfigurationChanges::create()); + officecfg::Office::Common::Filter::Microsoft::Import::VisioToDraw::set(true, pBatchReset); + pBatchReset->commit(); + }); + getComponent().set( + loadFromDesktop("private:factory/swriter", "com.sun.star.text.TextDocument")); + + // Insert a file as an embedded object. + uno::Reference xStorage = comphelper::OStorageHelper::GetTemporaryStorage(); + comphelper::EmbeddedObjectContainer aContainer(xStorage); + OUString aFileName + = m_directories.getURLFromSrc("embeddedobj/qa/cppunit/data/insert-file-config.vsdx"); + uno::Sequence aMedium{ comphelper::makePropertyValue("URL", aFileName) }; + OUString aName("Object 1"); + uno::Reference xObject + = aContainer.InsertEmbeddedObject(aMedium, aName); + + // Make sure that the insertion fails: + // 1) the user explicitly requested that the data is not loaded into Writer + // 2) this is non-Windows, so OLE embedding is not an option + // so silently still loading the data into Writer would be bad. + CPPUNIT_ASSERT(!xObject.is()); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/embeddedobj/source/general/xcreator.cxx b/embeddedobj/source/general/xcreator.cxx index aa19cf429185..640244d1134c 100644 --- a/embeddedobj/source/general/xcreator.cxx +++ b/embeddedobj/source/general/xcreator.cxx @@ -242,6 +242,13 @@ static OUString HandleFilter(const uno::Reference& xComp aRet.clear(); } } + if (!officecfg::Office::Common::Filter::Microsoft::Import::VisioToDraw::get(xComponentContext)) + { + if (rFilter == "Visio Document") + { + aRet.clear(); + } + } return aRet; } -- cgit