include/unotools/securityoptions.hxx | 1 officecfg/registry/schema/org/openoffice/Office/Common.xcs | 6 ++ oox/source/core/xmlfilterbase.cxx | 2 sfx2/source/doc/objcont.cxx | 12 +++++ sw/qa/extras/odfexport/odfexport4.cxx | 27 +++++++++++++ sw/qa/extras/ooxmlexport/ooxmlexport21.cxx | 27 +++++++++++++ unotools/source/config/securityoptions.cxx | 6 ++ xmloff/source/meta/xmlmetae.cxx | 8 +-- 8 files changed, 83 insertions(+), 6 deletions(-)
New commits: commit e275a6e6a08d1e53e5e921a701586c894d07ab2f Author: Balazs Varga <balazs.varga.ext...@allotropia.de> AuthorDate: Tue Apr 29 18:55:51 2025 +0200 Commit: Balazs Varga <balazs.varga.ext...@allotropia.de> CommitDate: Wed Apr 30 15:57:51 2025 +0200 tdf#166379 - Add export config option to remove "Total editing time" separately from all private info files during save. The new expert config option name is: RemoveEditingTimeOnSaving (There wasn't any UI element added for this expert config option.) Change-Id: Iab69d062d161ef6aee1c3eb87ada1c16f8b4fd41 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184789 Tested-by: Jenkins Reviewed-by: Balazs Varga <balazs.varga.ext...@allotropia.de> diff --git a/include/unotools/securityoptions.hxx b/include/unotools/securityoptions.hxx index 5322f2615ba3..debd0a772b82 100644 --- a/include/unotools/securityoptions.hxx +++ b/include/unotools/securityoptions.hxx @@ -40,6 +40,7 @@ namespace SvtSecurityOptions DocWarnSigning, DocWarnPrint, DocWarnCreatePdf, + DocWarnRemoveEditingTimeInfo, DocWarnRemovePersonalInfo, DocWarnKeepRedlineInfo, DocWarnKeepDocUserInfo, diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs index 3b6ca946acde..afab119c23d1 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs @@ -2436,6 +2436,12 @@ </info> <value>false</value> </prop> + <prop oor:name="RemoveEditingTimeOnSaving" oor:type="xs:boolean" oor:nillable="false"> + <info> + <desc>Specifies whether to remove editing duration on saving.</desc> + </info> + <value>false</value> + </prop> <prop oor:name="RemovePersonalInfoOnSaving" oor:type="xs:boolean" oor:nillable="false"> <info> <desc>Specifies whether to remove personal information on diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx index daf4ce7cd281..ffe41fd79afb 100644 --- a/oox/source/core/xmlfilterbase.cxx +++ b/oox/source/core/xmlfilterbase.cxx @@ -770,7 +770,7 @@ writeAppProperties( XmlFilterBase& rSelf, const Reference< XDocumentProperties > writeElement( pAppProps, XML_Notes, "notes" ); #endif /* def OOXTODO */ // EditingDuration is in seconds, TotalTime is in minutes. - if (!bRemovePersonalInfo) + if (!bRemovePersonalInfo && !SvtSecurityOptions::IsOptionSet(SvtSecurityOptions::EOption::DocWarnRemoveEditingTimeInfo)) writeElement(pAppProps, XML_TotalTime, xProperties->getEditingDuration() / 60); #ifdef OOXTODO writeElement( pAppProps, XML_HiddenSlides, "hidden slides" ); diff --git a/sfx2/source/doc/objcont.cxx b/sfx2/source/doc/objcont.cxx index 6aa790d22fc4..2da8f42a438d 100644 --- a/sfx2/source/doc/objcont.cxx +++ b/sfx2/source/doc/objcont.cxx @@ -236,8 +236,18 @@ void SfxObjectShell::UpdateDocInfoForSave() ::DateTime now( ::DateTime::SYSTEM ); xDocProps->setModificationDate( now.GetUNODateTime() ); xDocProps->setModifiedBy( aUserName ); - UpdateTime_Impl( xDocProps ); + if (!SvtSecurityOptions::IsOptionSet(SvtSecurityOptions::EOption::DocWarnRemoveEditingTimeInfo)) + UpdateTime_Impl( xDocProps ); } + // reset only editing time to zero if RemoveEditingTimeOnSaving is true + if (SvtSecurityOptions::IsOptionSet(SvtSecurityOptions::EOption::DocWarnRemoveEditingTimeInfo)) + xDocProps->setEditingDuration(0); + } + else + { + // reset only editing time to zero if RemoveEditingTimeOnSaving is true + if (SvtSecurityOptions::IsOptionSet(SvtSecurityOptions::EOption::DocWarnRemoveEditingTimeInfo)) + xDocProps->setEditingDuration(0); } } diff --git a/sw/qa/extras/odfexport/odfexport4.cxx b/sw/qa/extras/odfexport/odfexport4.cxx index ce5349cded29..0f39c4d1a440 100644 --- a/sw/qa/extras/odfexport/odfexport4.cxx +++ b/sw/qa/extras/odfexport/odfexport4.cxx @@ -129,6 +129,33 @@ CPPUNIT_TEST_FIXTURE(Test, testPersonalMetaData) "/office:document-settings/office:settings/config:config-item-set[2]/" "config:config-item[@config:name='PrinterSetup']", 0); + + // Reset config change + officecfg::Office::Common::Security::Scripting::RemovePersonalInfoOnSaving::set(false, pBatch); + pBatch->commit(); +} + +CPPUNIT_TEST_FIXTURE(Test, testRemoveOnlyEditTimeMetaData) +{ + // 1. Check we have the original edit time info + loadAndSave("personalmetadata.odt"); + xmlDocUniquePtr pXmlDoc = parseExport(u"meta.xml"_ustr); + assertXPathContent(pXmlDoc, "/office:document-meta/office:meta/meta:editing-duration", + u"PT21M22S"); + + // Set config RemoveEditingTimeOnSaving to true + auto pBatch(comphelper::ConfigurationChanges::create()); + officecfg::Office::Common::Security::Scripting::RemoveEditingTimeOnSaving::set(true, pBatch); + pBatch->commit(); + + // 2. Check edit time info is 0 + loadAndSave("personalmetadata.odt"); + pXmlDoc = parseExport(u"meta.xml"_ustr); + assertXPathContent(pXmlDoc, "/office:document-meta/office:meta/meta:editing-duration", u"P0D"); + + // Reset config change + officecfg::Office::Common::Security::Scripting::RemoveEditingTimeOnSaving::set(false, pBatch); + pBatch->commit(); } CPPUNIT_TEST_FIXTURE(Test, tdf151100) diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx index fbca4c1b046b..36fa8fcf009c 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx @@ -810,6 +810,33 @@ CPPUNIT_TEST_FIXTURE(Test, testPersonalMetaData) assertXPath(pCoreDoc, "/cp:coreProperties/cp:lastModifiedBy", 1); assertXPath(pCoreDoc, "/cp:coreProperties/cp:lastPrinted", 1); assertXPath(pCoreDoc, "/cp:coreProperties/cp:revision", 0); + + // Reset config change + officecfg::Office::Common::Security::Scripting::RemovePersonalInfoOnSaving::set(false, pBatch); + officecfg::Office::Common::Security::Scripting::KeepDocUserInfoOnSaving::set(false, pBatch); + pBatch->commit(); +} + +CPPUNIT_TEST_FIXTURE(Test, testRemoveOnlyEditTimeMetaData) +{ + // 1. Check we have the original edit time info + loadAndSave("personalmetadata.docx"); + xmlDocUniquePtr pAppDoc = parseExport(u"docProps/app.xml"_ustr); + assertXPath(pAppDoc, "/extended-properties:Properties/extended-properties:TotalTime", 1); + + // Set config RemoveEditingTimeOnSaving to true + auto pBatch(comphelper::ConfigurationChanges::create()); + officecfg::Office::Common::Security::Scripting::RemoveEditingTimeOnSaving::set(true, pBatch); + pBatch->commit(); + + // 2. Check edit time info is removed + loadAndSave("personalmetadata.docx"); + pAppDoc = parseExport(u"docProps/app.xml"_ustr); + assertXPath(pAppDoc, "/extended-properties:Properties/extended-properties:TotalTime", 0); + + // Reset config change + officecfg::Office::Common::Security::Scripting::RemoveEditingTimeOnSaving::set(false, pBatch); + pBatch->commit(); } DECLARE_OOXMLEXPORT_TEST(testTdf126533_noPageBitmap, "tdf126533_noPageBitmap.docx") diff --git a/unotools/source/config/securityoptions.cxx b/unotools/source/config/securityoptions.cxx index 19fa71b3beba..03fe5d5c0df4 100644 --- a/unotools/source/config/securityoptions.cxx +++ b/unotools/source/config/securityoptions.cxx @@ -317,6 +317,9 @@ bool IsOptionSet( EOption eOption ) case SvtSecurityOptions::EOption::DocWarnCreatePdf: bSet = officecfg::Office::Common::Security::Scripting::WarnCreatePDF::get(); break; + case SvtSecurityOptions::EOption::DocWarnRemoveEditingTimeInfo: + bSet = officecfg::Office::Common::Security::Scripting::RemoveEditingTimeOnSaving::get(); + break; case SvtSecurityOptions::EOption::DocWarnRemovePersonalInfo: bSet = officecfg::Office::Common::Security::Scripting::RemovePersonalInfoOnSaving::get(); break; @@ -373,6 +376,9 @@ void SetOption( EOption eOption, bool bValue ) case SvtSecurityOptions::EOption::DocWarnCreatePdf: officecfg::Office::Common::Security::Scripting::WarnCreatePDF::set(bValue, xChanges); break; + case SvtSecurityOptions::EOption::DocWarnRemoveEditingTimeInfo: + officecfg::Office::Common::Security::Scripting::RemoveEditingTimeOnSaving::set(bValue, xChanges); + break; case SvtSecurityOptions::EOption::DocWarnRemovePersonalInfo: officecfg::Office::Common::Security::Scripting::RemovePersonalInfoOnSaving::set(bValue, xChanges); break; diff --git a/xmloff/source/meta/xmlmetae.cxx b/xmloff/source/meta/xmlmetae.cxx index 608ba86de7da..db05f2923737 100644 --- a/xmloff/source/meta/xmlmetae.cxx +++ b/xmloff/source/meta/xmlmetae.cxx @@ -162,15 +162,15 @@ void SvXMLMetaExport::MExport_() // editing duration // property is a int32 (seconds) - if (!bRemovePersonalInfo) + if (!bRemovePersonalInfo && !SvtSecurityOptions::IsOptionSet(SvtSecurityOptions::EOption::DocWarnRemoveEditingTimeInfo)) { sal_Int32 secs = mxDocProps->getEditingDuration(); SvXMLElementExport aElem( mrExport, - XML_NAMESPACE_META, XML_EDITING_DURATION, - true, false ); + XML_NAMESPACE_META, XML_EDITING_DURATION, + true, false ); OUStringBuffer buf; ::sax::Converter::convertDuration(buf, util::Duration( - false, 0, 0, 0, secs/3600, (secs%3600)/60, secs%60, 0)); + false, 0, 0, 0, secs/3600, (secs%3600)/60, secs%60, 0)); mrExport.Characters(buf.makeStringAndClear()); }