summaryrefslogtreecommitdiff
path: root/embeddedobj
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2019-08-15 10:55:53 +0200
committerMiklos Vajna <vmiklos@collabora.com>2019-08-15 11:42:55 +0200
commit5827e30109b683cb74efa21d154e5219fe9e2a0c (patch)
tree7a1557f85069e434393228f0be75a4266022eddc /embeddedobj
parentbb9bad31b9e9f741fed91b2a4b3043814cb07f13 (diff)
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 <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'embeddedobj')
-rw-r--r--embeddedobj/qa/cppunit/data/insert-file-config.vsdxbin0 -> 12483 bytes
-rw-r--r--embeddedobj/qa/cppunit/general.cxx33
-rw-r--r--embeddedobj/source/general/xcreator.cxx7
3 files changed, 40 insertions, 0 deletions
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
--- /dev/null
+++ b/embeddedobj/qa/cppunit/data/insert-file-config.vsdx
Binary files 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<comphelper::ConfigurationChanges> pBatch(
+ comphelper::ConfigurationChanges::create());
+ officecfg::Office::Common::Filter::Microsoft::Import::VisioToDraw::set(false, pBatch);
+ pBatch->commit();
+ comphelper::ScopeGuard g([]() {
+ std::shared_ptr<comphelper::ConfigurationChanges> 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<embed::XStorage> xStorage = comphelper::OStorageHelper::GetTemporaryStorage();
+ comphelper::EmbeddedObjectContainer aContainer(xStorage);
+ OUString aFileName
+ = m_directories.getURLFromSrc("embeddedobj/qa/cppunit/data/insert-file-config.vsdx");
+ uno::Sequence<beans::PropertyValue> aMedium{ comphelper::makePropertyValue("URL", aFileName) };
+ OUString aName("Object 1");
+ uno::Reference<embed::XEmbeddedObject> 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<uno::XComponentContext>& xComp
aRet.clear();
}
}
+ if (!officecfg::Office::Common::Filter::Microsoft::Import::VisioToDraw::get(xComponentContext))
+ {
+ if (rFilter == "Visio Document")
+ {
+ aRet.clear();
+ }
+ }
return aRet;
}