summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2022-04-04 09:50:26 +0200
committerLuboš Luňák <l.lunak@collabora.com>2022-04-08 18:46:38 +0200
commit14bfb0933073e5bf8ce4f810c38e91125066257a (patch)
tree8e975fc5759de67106faf8357f2b0a744a5176e6
parent881cfbf77567194f5016a961d1c3db869734d68b (diff)
allow to override the generator/producer string in output documents
Add a (non-gui) setting GeneratorOverride that, if set, is used for odt/docx/pdf generator string identifying the application that has written it instead of the normal productname etc. string. Change-Id: Ibe12a063e7e6b5a09c69cdf66cba073793650d62 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132495 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
-rw-r--r--filter/source/pdf/pdfexport.cxx14
-rw-r--r--officecfg/registry/schema/org/openoffice/Office/Common.xcs8
-rw-r--r--unotools/source/config/docinfohelper.cxx5
-rw-r--r--vcl/source/filter/eps/eps.cxx10
4 files changed, 31 insertions, 6 deletions
diff --git a/filter/source/pdf/pdfexport.cxx b/filter/source/pdf/pdfexport.cxx
index d6f451f8392d..9b07ae1a9306 100644
--- a/filter/source/pdf/pdfexport.cxx
+++ b/filter/source/pdf/pdfexport.cxx
@@ -38,6 +38,7 @@
#include <unotools/configmgr.hxx>
#include <cppuhelper/compbase.hxx>
#include <cppuhelper/basemutex.hxx>
+#include <officecfg/Office/Common.hxx>
#include "pdfexport.hxx"
#include <strings.hrc>
@@ -479,10 +480,15 @@ bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue >&
}
}
// getting the string for the producer
- aContext.DocumentInfo.Producer =
- utl::ConfigManager::getProductName() +
- " " +
- utl::ConfigManager::getProductVersion();
+ OUString aProducerOverride = officecfg::Office::Common::Save::Document::GeneratorOverride::get();
+ if( !aProducerOverride.isEmpty())
+ aContext.DocumentInfo.Producer = aProducerOverride;
+ else
+ aContext.DocumentInfo.Producer =
+ utl::ConfigManager::getProductName() +
+ " " +
+ utl::ConfigManager::getProductVersion();
+
aContext.DocumentInfo.Creator = aCreator;
OUString aSignCertificateSubjectName;
diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
index d1b16d62554b..781dcde05734 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
@@ -2391,6 +2391,14 @@
</info>
<value>true</value>
</prop>
+ <prop oor:name="GeneratorOverride" oor:type="xs:string" oor:nillable="false">
+ <info>
+ <desc>If set, the value will be used as the generator information saved
+ in documents. Note that the generator information may affect document import
+ and using an inappropriate value here may change how the document is imported.</desc>
+ </info>
+ <value></value>
+ </prop>
</group>
<group oor:name="Graphic">
<info>
diff --git a/unotools/source/config/docinfohelper.cxx b/unotools/source/config/docinfohelper.cxx
index 7e605d187c75..735f0ac2d56e 100644
--- a/unotools/source/config/docinfohelper.cxx
+++ b/unotools/source/config/docinfohelper.cxx
@@ -22,6 +22,7 @@
#include <unotools/bootstrap.hxx>
#include <unotools/docinfohelper.hxx>
#include <rtl/bootstrap.hxx>
+#include <officecfg/Office/Common.hxx>
using namespace ::com::sun::star;
@@ -30,6 +31,10 @@ namespace utl
OUString DocInfoHelper::GetGeneratorString()
{
+ OUString aResultOverride = officecfg::Office::Common::Save::Document::GeneratorOverride::get();
+ if( !aResultOverride.isEmpty())
+ return aResultOverride;
+
OUStringBuffer aResult(128);
// First product: branded name + version
diff --git a/vcl/source/filter/eps/eps.cxx b/vcl/source/filter/eps/eps.cxx
index 374b4c78218b..bb25bdccb57e 100644
--- a/vcl/source/filter/eps/eps.cxx
+++ b/vcl/source/filter/eps/eps.cxx
@@ -39,6 +39,7 @@
#include <strings.hrc>
#include <osl/diagnose.h>
#include <com/sun/star/task/XStatusIndicator.hpp>
+#include <officecfg/Office/Common.hxx>
#include <cstdlib>
#include <memory>
@@ -449,8 +450,13 @@ void PSWriter::ImplWriteProlog( const Graphic* pPreview )
ImplWriteLong( aSizePoint.Width() );
ImplWriteLong( aSizePoint.Height() ,PS_RET );
ImplWriteLine( "%%Pages: 0" );
- OUString aCreator( "%%Creator: " + utl::ConfigManager::getProductName() + " " +
- utl::ConfigManager::getProductVersion() );
+ OUString aCreator;
+ OUString aCreatorOverride = officecfg::Office::Common::Save::Document::GeneratorOverride::get();
+ if( !aCreatorOverride.isEmpty())
+ aCreator = aCreatorOverride;
+ else
+ aCreator = "%%Creator: " + utl::ConfigManager::getProductName() + " " +
+ utl::ConfigManager::getProductVersion();
ImplWriteLine( OUStringToOString( aCreator, RTL_TEXTENCODING_UTF8 ).getStr() );
ImplWriteLine( "%%Title: none" );
ImplWriteLine( "%%CreationDate: none" );