diff options
author | Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de> | 2024-06-24 11:11:15 +0200 |
---|---|---|
committer | Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de> | 2024-06-27 13:45:05 +0200 |
commit | 9d0d9d8aa0ba4bb465e376621b426fb9ff00507e (patch) | |
tree | 87d432023aeb80343faf88953ca0a9de067a6700 | |
parent | 2a9b53bb9f85c2869c779dde36a2d77353fef14b (diff) |
xlsx: Don't export changes author/date when in privacy mode
Change-Id: I1b1ef4dd75f02cc545721d5458617cfa92b26615
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169453
Reviewed-by: Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>
Tested-by: Jenkins
-rw-r--r-- | sc/qa/unit/data/xlsx/change-tracking.xlsx | bin | 0 -> 7159 bytes | |||
-rw-r--r-- | sc/qa/unit/subsequent_export_test4.cxx | 26 | ||||
-rw-r--r-- | sc/source/filter/inc/XclExpChangeTrack.hxx | 5 | ||||
-rw-r--r-- | sc/source/filter/xcl97/XclExpChangeTrack.cxx | 13 |
4 files changed, 43 insertions, 1 deletions
diff --git a/sc/qa/unit/data/xlsx/change-tracking.xlsx b/sc/qa/unit/data/xlsx/change-tracking.xlsx Binary files differnew file mode 100644 index 000000000000..cba56b971d64 --- /dev/null +++ b/sc/qa/unit/data/xlsx/change-tracking.xlsx diff --git a/sc/qa/unit/subsequent_export_test4.cxx b/sc/qa/unit/subsequent_export_test4.cxx index 0814c915d81b..a6e5802cf98f 100644 --- a/sc/qa/unit/subsequent_export_test4.cxx +++ b/sc/qa/unit/subsequent_export_test4.cxx @@ -1889,6 +1889,32 @@ CPPUNIT_TEST_FIXTURE(ScExportTest4, testChangesAuthorDate) pXmlDoc, "/office:document-content/office:body/office:spreadsheet/table:tracked-changes/table:cell-content-change[1]/office:change-info/dc:date"_ostr, u"1970-01-01T12:00:00"_ustr); + + // Reset config change + officecfg::Office::Common::Security::Scripting::RemovePersonalInfoOnSaving::set(false, pBatch); + pBatch->commit(); +} + +CPPUNIT_TEST_FIXTURE(ScExportTest4, testChangesAuthorDateXLSX) +{ + createScDoc("xlsx/change-tracking.xlsx"); + + auto pBatch(comphelper::ConfigurationChanges::create()); + // Remove all personal info + officecfg::Office::Common::Security::Scripting::RemovePersonalInfoOnSaving::set(true, pBatch); + pBatch->commit(); + + save(u"Calc Office Open XML"_ustr); + xmlDocUniquePtr pXmlDoc = parseExport(u"xl/revisions/revisionHeaders.xml"_ustr); + CPPUNIT_ASSERT(pXmlDoc); + + assertXPath(pXmlDoc, "/x:headers/x:header[1]"_ostr, "userName"_ostr, u"Author1"_ustr); + assertXPath(pXmlDoc, "/x:headers/x:header[1]"_ostr, "dateTime"_ostr, + u"1970-01-01T12:00:00.000000000Z"_ustr); + + // Reset config change + officecfg::Office::Common::Security::Scripting::RemovePersonalInfoOnSaving::set(false, pBatch); + pBatch->commit(); } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sc/source/filter/inc/XclExpChangeTrack.hxx b/sc/source/filter/inc/XclExpChangeTrack.hxx index b23b6f8cdcaf..746125e50ab1 100644 --- a/sc/source/filter/inc/XclExpChangeTrack.hxx +++ b/sc/source/filter/inc/XclExpChangeTrack.hxx @@ -22,6 +22,7 @@ #include <memory> #include <stack> #include <tools/datetime.hxx> +#include <unotools/securityoptions.hxx> #include <chgtrack.hxx> #include <document.hxx> #include "xelink.hxx" @@ -262,6 +263,10 @@ public: virtual void SaveXml( XclExpXmlStream& rStrm ) override; void AppendAction( std::unique_ptr<XclExpChTrAction> pAction ); + +private: + /// map authors to remove personal info + std::unique_ptr<SvtSecurityMapPersonalInfo> mpAuthorIDs; }; // XclExpChTrInfo - header of action group of a user diff --git a/sc/source/filter/xcl97/XclExpChangeTrack.cxx b/sc/source/filter/xcl97/XclExpChangeTrack.cxx index 52d2150e9f75..30812d7bb9e2 100644 --- a/sc/source/filter/xcl97/XclExpChangeTrack.cxx +++ b/sc/source/filter/xcl97/XclExpChangeTrack.cxx @@ -37,6 +37,9 @@ #include <oox/token/tokens.hxx> #include <rtl/uuid.h> #include <svl/sharedstring.hxx> +#include <unotools/securityoptions.hxx> + +#include <com/sun/star/util/DateTime.hpp> using namespace oox; @@ -395,7 +398,7 @@ XclExpXmlChTrHeader::XclExpXmlChTrHeader( OUString aUserName, const DateTime& rDateTime, const sal_uInt8* pGUID, sal_Int32 nLogNumber, const XclExpChTrTabIdBuffer& rBuf ) : maUserName(std::move(aUserName)), maDateTime(rDateTime), mnLogNumber(nLogNumber), - mnMinAction(0), mnMaxAction(0) + mnMinAction(0), mnMaxAction(0), mpAuthorIDs(new SvtSecurityMapPersonalInfo) { memcpy(maGUID, pGUID, 16); if (rBuf.GetBufferCount()) @@ -421,6 +424,14 @@ void XclExpXmlChTrHeader::SaveXml( XclExpXmlStream& rStrm ) &aRelId); tools::Guid aGuid(maGUID); + bool bRemovePersonalInfo + = SvtSecurityOptions::IsOptionSet(SvtSecurityOptions::EOption::DocWarnRemovePersonalInfo) + && !SvtSecurityOptions::IsOptionSet(SvtSecurityOptions::EOption::DocWarnKeepRedlineInfo); + if (bRemovePersonalInfo) + { + maDateTime = css::util::DateTime(0, 0, 0, 12, 1, 1, 1970, true); + maUserName = "Author" + OUString::number(mpAuthorIDs->GetInfoID(maUserName)); + } rStrm.WriteAttributes( XML_guid, aGuid.getString(), XML_dateTime, lcl_DateTimeToOString(maDateTime), |