summaryrefslogtreecommitdiff
path: root/embeddedobj
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2019-08-15 15:47:42 +0200
committerMiklos Vajna <vmiklos@collabora.com>2019-08-15 16:45:23 +0200
commitbdfa6b678bc0cc22f983a0c23187a8ba9d2e6730 (patch)
treea0bc4fa9969178014dd5f266fa53be1cfe6a1ca1 /embeddedobj
parent0a66deda5d37907068331efe4d611f73fc46ff91 (diff)
embeddedobj: allow controlling if PDF documents are converted to Draw or not
This is a bit custom, since it's not a Microsoft filter. At the moment this affects only Insert -> Object -> OLE Object -> from file. Change-Id: If79602742a533db1b04e11a90890f8768186046d Reviewed-on: https://gerrit.libreoffice.org/77520 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'embeddedobj')
-rw-r--r--embeddedobj/qa/cppunit/data/insert-file-config.pdfbin0 -> 11157 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.pdf b/embeddedobj/qa/cppunit/data/insert-file-config.pdf
new file mode 100644
index 000000000000..6302457402fe
--- /dev/null
+++ b/embeddedobj/qa/cppunit/data/insert-file-config.pdf
Binary files differ
diff --git a/embeddedobj/qa/cppunit/general.cxx b/embeddedobj/qa/cppunit/general.cxx
index bbab17440fe3..ba862d3a86f0 100644
--- a/embeddedobj/qa/cppunit/general.cxx
+++ b/embeddedobj/qa/cppunit/general.cxx
@@ -118,6 +118,39 @@ CPPUNIT_TEST_FIXTURE(EmbeddedobjGeneralTest, testInsertFileConfigVsdx)
CPPUNIT_ASSERT(!xObject.is());
}
+CPPUNIT_TEST_FIXTURE(EmbeddedobjGeneralTest, testInsertFileConfigPdf)
+{
+ // Explicitly disable Word->Writer mapping for this test.
+ std::shared_ptr<comphelper::ConfigurationChanges> pBatch(
+ comphelper::ConfigurationChanges::create());
+ officecfg::Office::Common::Filter::Adobe::Import::PDFToDraw::set(false, pBatch);
+ pBatch->commit();
+ comphelper::ScopeGuard g([]() {
+ std::shared_ptr<comphelper::ConfigurationChanges> pBatchReset(
+ comphelper::ConfigurationChanges::create());
+ officecfg::Office::Common::Filter::Adobe::Import::PDFToDraw::set(true, pBatchReset);
+ pBatchReset->commit();
+ });
+ getComponent().set(
+ loadFromDesktop("private:factory/swriter", "com.sun.star.text.TextDocument"));
+
+ // Insert a PDF 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.pdf");
+ 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 640244d1134c..fe6c79d73da5 100644
--- a/embeddedobj/source/general/xcreator.cxx
+++ b/embeddedobj/source/general/xcreator.cxx
@@ -249,6 +249,13 @@ static OUString HandleFilter(const uno::Reference<uno::XComponentContext>& xComp
aRet.clear();
}
}
+ if (!officecfg::Office::Common::Filter::Adobe::Import::PDFToDraw::get(xComponentContext))
+ {
+ if (rFilter == "draw_pdf_import")
+ {
+ aRet.clear();
+ }
+ }
return aRet;
}