summaryrefslogtreecommitdiffstats
path: root/filter/source/pdf/pdffilter.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'filter/source/pdf/pdffilter.cxx')
-rw-r--r--filter/source/pdf/pdffilter.cxx54
1 files changed, 39 insertions, 15 deletions
diff --git a/filter/source/pdf/pdffilter.cxx b/filter/source/pdf/pdffilter.cxx
index 6d1a793a7158..dcfc918bbdd0 100644
--- a/filter/source/pdf/pdffilter.cxx
+++ b/filter/source/pdf/pdffilter.cxx
@@ -26,10 +26,16 @@
#include <unotools/ucbstreamhelper.hxx>
#include <unotools/tempfile.hxx>
#include <vcl/FilterConfigItem.hxx>
+#include <vcl/glyphitemcache.hxx>
#include <memory>
#include <com/sun/star/io/XOutputStream.hpp>
+#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 ) :
@@ -47,29 +53,42 @@ bool PDFFilter::implExport( const Sequence< PropertyValue >& rDescriptor )
{
Reference< XOutputStream > xOStm;
Sequence< PropertyValue > aFilterData;
- sal_Int32 nLength = rDescriptor.getLength();
- const PropertyValue* pValue = rDescriptor.getConstArray();
+ OUString aFilterOptions;
bool bIsRedactMode = false;
bool bRet = false;
Reference< task::XStatusIndicator > xStatusIndicator;
Reference< task::XInteractionHandler > xIH;
- for (sal_Int32 i = 0; i < nLength; ++i)
+ for (const auto& rValue : rDescriptor)
{
- if ( pValue[ i ].Name == "OutputStream" )
- pValue[ i ].Value >>= xOStm;
- else if ( pValue[ i ].Name == "FilterData" )
- pValue[ i ].Value >>= aFilterData;
- else if ( pValue[ i ].Name == "StatusIndicator" )
- pValue[ i ].Value >>= xStatusIndicator;
- else if ( pValue[i].Name == "InteractionHandler" )
- pValue[i].Value >>= xIH;
+ if (rValue.Name == "OutputStream")
+ rValue.Value >>= xOStm;
+ else if (rValue.Name == "FilterData")
+ rValue.Value >>= aFilterData;
+ else if (rValue.Name == "FilterOptions")
+ rValue.Value >>= aFilterOptions;
+ else if (rValue.Name == "StatusIndicator")
+ rValue.Value >>= xStatusIndicator;
+ else if (rValue.Name == "InteractionHandler")
+ rValue.Value >>= xIH;
+ else if (rValue.Name == "IsRedactMode")
+ rValue.Value >>= bIsRedactMode;
}
- for (sal_Int32 i = 0 ; i < nLength; ++i)
+ if (!aFilterData.hasElements() && aFilterOptions.startsWith("{"))
{
- if ( pValue[i].Name == "IsRedactMode")
- pValue[i].Value >>= bIsRedactMode;
+ 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& e)
+ {
+ // This wasn't a valid json; maybe came from import filter (tdf#150846)
+ SAL_WARN("filter.pdf", "error parsing FilterOptions: " << e.message());
+ }
}
/* we don't get FilterData if we are exporting directly
@@ -85,6 +104,7 @@ bool PDFFilter::implExport( const Sequence< PropertyValue >& rDescriptor )
aCfgItem.ReadInt32( "SelectPdfVersion", 0 );
aCfgItem.ReadBool("PDFUACompliance", false);
aCfgItem.ReadBool( "ExportNotes", false );
+ aCfgItem.ReadBool( "ExportNotesInMargin", false );
aCfgItem.ReadBool( "ExportPlaceholders", false );
aCfgItem.ReadBool( "ExportNotesPages", false );
aCfgItem.ReadBool( "ExportOnlyNotesPages", false );
@@ -155,7 +175,7 @@ bool PDFFilter::implExport( const Sequence< PropertyValue >& rDescriptor )
if( mxSrcDoc.is() && xOStm.is() )
{
PDFExport aExport( mxSrcDoc, xStatusIndicator, xIH, mxContext );
- ::utl::TempFile aTempFile;
+ ::utl::TempFileNamed aTempFile;
aTempFile.EnableKillingFile();
bRet = aExport.Export( aTempFile.GetURL(), aFilterData );
@@ -221,8 +241,12 @@ sal_Bool SAL_CALL PDFFilter::filter( const Sequence< PropertyValue >& rDescripto
{
FocusWindowWaitCursor aCur;
+ SalLayoutGlyphsCache::self()->SetCacheGlyphsWhenDoingFallbackFonts(true);
+
const bool bRet = implExport( rDescriptor );
+ SalLayoutGlyphsCache::self()->SetCacheGlyphsWhenDoingFallbackFonts(false);
+
return bRet;
}