tdf#150846: FilterOptions in descriptor could come from import filter
Tolerate failure parsing json here. Unfortunately this means that
we can't provide a diagnostics to user when they provide bad json
in the command line parameters.
Change-Id: Ia3fa18e709a4c0b891faf4365453b79e6c58a9c6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139613
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
(cherry picked from commit 467308d679a3f2b4bbdd117fcc73636d57d66c09)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139568
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
diff --git a/filter/source/pdf/pdffilter.cxx b/filter/source/pdf/pdffilter.cxx
index d7fc558..f12559b 100644
--- a/filter/source/pdf/pdffilter.cxx
+++ b/filter/source/pdf/pdffilter.cxx
@@ -33,6 +33,8 @@
#include <comphelper/propertysequence.hxx>
#include <comphelper/sequence.hxx>
#include <boost/property_tree/json_parser/error.hpp>
using namespace ::com::sun::star::io;
PDFFilter::PDFFilter( const Reference< XComponentContext > &rxContext ) :
@@ -78,11 +80,19 @@ bool PDFFilter::implExport( const Sequence< PropertyValue >& rDescriptor )
pValue[i].Value >>= bIsRedactMode;
}
if (!aFilterData.hasElements() && !aFilterOptions.isEmpty())
if (!aFilterData.hasElements() && aFilterOptions.startsWith("{"))
{
// Allow setting filter data keys from the cmdline.
std::vector<PropertyValue> aData = comphelper::JsonToPropertyValues(aFilterOptions.toUtf8());
aFilterData = comphelper::containerToSequence(aData);
try
{
// Allow setting filter data keys from the cmdline.
std::vector<PropertyValue> aData
= comphelper::JsonToPropertyValues(aFilterOptions.toUtf8());
aFilterData = comphelper::containerToSequence(aData);
}
catch (const boost::property_tree::json_parser::json_parser_error&)
{
// This wasn't a valid json; maybe came from import filter (tdf#150846)
}
}
/* we don't get FilterData if we are exporting directly