summaryrefslogtreecommitdiff
path: root/filter/source/pdf/pdfexport.cxx
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2022-11-17 13:11:27 +0100
committerMiklos Vajna <vmiklos@collabora.com>2022-11-17 14:50:07 +0100
commit21c4749d0205d1ba90494edc2527ff9d11f86f87 (patch)
tree3af18599462129e0712ac63fd7488a30309c175f /filter/source/pdf/pdfexport.cxx
parent5dee0f895bd5650db974be0c24c7b8d78035fd0b (diff)
Related: tdf#54053 PDF export: add UNO API to customize the watermark color
PDF export has a watermark feature, but its color is hardcoded to light green, which won't fit all documents. On the other hand, the input from Heiko in <https://bugs.documentfoundation.org/show_bug.cgi?id=54053#c12> is to keep the dialog clean, so adding one more UI option is not great. Fix the problem by only adding the option at an UNO API level for now, this relaxes the hardcoded color without cluttering the UI. Also available on the cmdline for e.g. 0xff0000 / red color: soffice --convert-to pdf:writer_pdf_Export:'{"Watermark":{"type":"string","value":"draft"}, "WatermarkColor":{"type":"long","value":"16711680"}}' test.odt Change-Id: I38a3650df86fd34dfc09e3a5643511baa371aa83 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142835 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'filter/source/pdf/pdfexport.cxx')
-rw-r--r--filter/source/pdf/pdfexport.cxx11
1 files changed, 10 insertions, 1 deletions
diff --git a/filter/source/pdf/pdfexport.cxx b/filter/source/pdf/pdfexport.cxx
index b02c200e7e85..9633919da14f 100644
--- a/filter/source/pdf/pdfexport.cxx
+++ b/filter/source/pdf/pdfexport.cxx
@@ -108,6 +108,7 @@ PDFExport::PDFExport( const Reference< XComponent >& rxSrcDoc,
mbRemoveTransparencies ( false ),
mbIsRedactMode ( false ),
+ maWatermarkColor ( COL_LIGHTGREEN ),
mbHideViewerToolbar ( false ),
mbHideViewerMenubar ( false ),
@@ -559,6 +560,14 @@ bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue >&
rProp.Value >>= mbAddStream;
else if ( rProp.Name == "Watermark" )
rProp.Value >>= msWatermark;
+ else if ( rProp.Name == "WatermarkColor" )
+ {
+ sal_Int32 nColor{};
+ if (rProp.Value >>= nColor)
+ {
+ maWatermarkColor = Color(ColorTransparency, nColor);
+ }
+ }
else if ( rProp.Name == "TiledWatermark" )
rProp.Value >>= msTiledWatermark;
// now all the security related properties...
@@ -1192,7 +1201,7 @@ void PDFExport::ImplWriteWatermark( vcl::PDFWriter& rWriter, const Size& rPageSi
rWriter.Push();
rWriter.SetMapMode( MapMode( MapUnit::MapPoint ) );
rWriter.SetFont( aFont );
- rWriter.SetTextColor( COL_LIGHTGREEN );
+ rWriter.SetTextColor(maWatermarkColor);
Point aTextPoint;
tools::Rectangle aTextRect;
if( rPageSize.Width() > rPageSize.Height() )