summaryrefslogtreecommitdiff
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
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
-rw-r--r--cui/inc/strings.hrc1
-rw-r--r--cui/source/options/optfltr.cxx26
-rw-r--r--cui/source/options/optfltr.hxx3
-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
-rw-r--r--officecfg/registry/schema/org/openoffice/Office/Common.xcs17
7 files changed, 85 insertions, 2 deletions
diff --git a/cui/inc/strings.hrc b/cui/inc/strings.hrc
index e6edf6cca478..9b70cbf55301 100644
--- a/cui/inc/strings.hrc
+++ b/cui/inc/strings.hrc
@@ -257,6 +257,7 @@
#define RID_SVXSTR_CHG_IMPRESS NC_("RID_SVXSTR_CHG_IMPRESS", "PowerPoint to %PRODUCTNAME Impress or reverse")
#define RID_SVXSTR_CHG_SMARTART NC_("RID_SVXSTR_CHG_SMARTART", "SmartArt to %PRODUCTNAME shapes or reverse")
#define RID_SVXSTR_CHG_VISIO NC_("RID_SVXSTR_CHG_VISIO", "Visio to %PRODUCTNAME Draw or reverse")
+#define RID_SVXSTR_CHG_PDF NC_("RID_SVXSTR_CHG_PDF", "PDF to %PRODUCTNAME Draw or reverse")
#define RID_SVXSTR_OPT_DOUBLE_DICTS NC_("RID_SVXSTR_OPT_DOUBLE_DICTS", "The specified name already exists.\nPlease enter a new name.")
#define RID_SVXSTR_OPT_INVALID_DICT_NAME NC_("RID_SVXSTR_OPT_INVALID_DICT_NAME", "The specified name is invalid.\nPlease enter a new name.")
diff --git a/cui/source/options/optfltr.cxx b/cui/source/options/optfltr.cxx
index 925c0c7981d4..85abc803b07e 100644
--- a/cui/source/options/optfltr.cxx
+++ b/cui/source/options/optfltr.cxx
@@ -35,6 +35,7 @@ enum class MSFltrPg2_CheckBoxEntries {
Impress,
SmartArt,
Visio,
+ PDF,
InvalidCBEntry
};
@@ -134,6 +135,7 @@ OfaMSFilterTabPage2::OfaMSFilterTabPage2(TabPageParent pParent, const SfxItemSet
, sChgToFromImpress(CuiResId(RID_SVXSTR_CHG_IMPRESS))
, sChgToFromSmartArt(CuiResId(RID_SVXSTR_CHG_SMARTART))
, sChgToFromVisio(CuiResId(RID_SVXSTR_CHG_VISIO))
+ , sChgToFromPDF(CuiResId(RID_SVXSTR_CHG_PDF))
, m_xCheckLB(m_xBuilder->weld_tree_view("checklbcontainer"))
, m_xHighlightingRB(m_xBuilder->weld_radio_button("highlighting"))
, m_xShadingRB(m_xBuilder->weld_radio_button("shading"))
@@ -209,6 +211,15 @@ bool OfaMSFilterTabPage2::FillItemSet( SfxItemSet* )
bFirstCol = !bFirstCol;
}
}
+ int nPDFEntry = GetEntry4Type(MSFltrPg2_CheckBoxEntries::PDF);
+ bool bPDFCheck = m_xCheckLB->get_toggle(nPDFEntry, 0);
+ if (bPDFCheck != officecfg::Office::Common::Filter::Adobe::Import::PDFToDraw::get())
+ {
+ std::shared_ptr<comphelper::ConfigurationChanges> pBatch(
+ comphelper::ConfigurationChanges::create());
+ officecfg::Office::Common::Filter::Adobe::Import::PDFToDraw::set(bPDFCheck, pBatch);
+ pBatch->commit();
+ }
if( m_xHighlightingRB->get_state_changed_from_saved() )
{
@@ -246,7 +257,10 @@ void OfaMSFilterTabPage2::Reset( const SfxItemSet* )
InsertEntry( sChgToFromImpress, MSFltrPg2_CheckBoxEntries::Impress );
InsertEntry( sChgToFromSmartArt, MSFltrPg2_CheckBoxEntries::SmartArt, false );
if (aModuleOpt.IsModuleInstalled(SvtModuleOptions::EModule::DRAW))
+ {
InsertEntry(sChgToFromVisio, MSFltrPg2_CheckBoxEntries::Visio, false);
+ InsertEntry(sChgToFromPDF, MSFltrPg2_CheckBoxEntries::PDF, false);
+ }
static struct ChkCBoxEntries{
MSFltrPg2_CheckBoxEntries eType;
@@ -262,6 +276,7 @@ void OfaMSFilterTabPage2::Reset( const SfxItemSet* )
{ MSFltrPg2_CheckBoxEntries::Impress, &SvtFilterOptions::IsImpress2PowerPoint },
{ MSFltrPg2_CheckBoxEntries::SmartArt, &SvtFilterOptions::IsSmartArt2Shape },
{ MSFltrPg2_CheckBoxEntries::Visio, &SvtFilterOptions::IsVisio2Draw },
+ { MSFltrPg2_CheckBoxEntries::PDF, nullptr },
};
bool bFirstCol = true;
@@ -275,7 +290,16 @@ void OfaMSFilterTabPage2::Reset( const SfxItemSet* )
int nEntry = GetEntry4Type( rArr.eType );
if (nEntry != -1)
{
- bool bCheck = (rOpt.*rArr.FnIs)();
+ bool bCheck = false;
+ if (rArr.eType != MSFltrPg2_CheckBoxEntries::PDF)
+ {
+ bCheck = (rOpt.*rArr.FnIs)();
+ }
+ else
+ {
+ bCheck = officecfg::Office::Common::Filter::Adobe::Import::PDFToDraw::get();
+ nCol = 0;
+ }
m_xCheckLB->set_toggle(nEntry, bCheck ? TRISTATE_TRUE : TRISTATE_FALSE, nCol);
}
if (rArr.eType == MSFltrPg2_CheckBoxEntries::SmartArt)
diff --git a/cui/source/options/optfltr.hxx b/cui/source/options/optfltr.hxx
index 0495b8c49514..db954aa4684b 100644
--- a/cui/source/options/optfltr.hxx
+++ b/cui/source/options/optfltr.hxx
@@ -56,7 +56,8 @@ class OfaMSFilterTabPage2 : public SfxTabPage
sChgToFromCalc,
sChgToFromImpress,
sChgToFromSmartArt,
- sChgToFromVisio;
+ sChgToFromVisio,
+ sChgToFromPDF;
std::unique_ptr<weld::TreeView> m_xCheckLB;
std::unique_ptr<weld::RadioButton> m_xHighlightingRB;
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;
}
diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
index af847483bb7a..8d4f26fc6cab 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
@@ -3792,6 +3792,23 @@
<desc>Specifies default settings of Microsoft-, Graphic- and HTML
filters.</desc>
</info>
+ <group oor:name="Adobe">
+ <info>
+ <desc>Specifies default settings of Adobe filters.</desc>
+ </info>
+ <group oor:name="Import">
+ <info>
+ <desc>Specifies default settings of Adobe import filters.</desc>
+ </info>
+ <prop oor:name="PDFToDraw" oor:type="xs:boolean" oor:nillable="false">
+ <info>
+ <desc>Specifies if convertible PDF OLE objects are converted
+ into Draw objects.</desc>
+ </info>
+ <value>true</value>
+ </prop>
+ </group>
+ </group>
<group oor:name="Microsoft">
<info>
<desc>Specifies default settings of Microsoft filters.</desc>