sc/qa/unit/data/xlsx/cell-note.xlsx |binary sc/qa/unit/subsequent_export_test4.cxx | 20 ++++++++++++++++++++ sc/source/filter/excel/xeescher.cxx | 12 ++++++++++++ sc/source/filter/inc/xeescher.hxx | 3 +++ 4 files changed, 35 insertions(+)
New commits: commit 0acac1a2741d47b98ae600800e2db0e7a5fb3efe Author: Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de> AuthorDate: Thu Jun 27 09:23:08 2024 +0200 Commit: Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de> CommitDate: Thu Jun 27 13:49:05 2024 +0200 xlsx: Don't export notes author when in privacy mode Change-Id: Id0b3f0aca7bd4e21f41c2a8307964423debcf5bb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169616 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de> diff --git a/sc/qa/unit/data/xlsx/cell-note.xlsx b/sc/qa/unit/data/xlsx/cell-note.xlsx new file mode 100644 index 000000000000..9df212a2970f Binary files /dev/null and b/sc/qa/unit/data/xlsx/cell-note.xlsx differ diff --git a/sc/qa/unit/subsequent_export_test4.cxx b/sc/qa/unit/subsequent_export_test4.cxx index a6e5802cf98f..fbf31673ada3 100644 --- a/sc/qa/unit/subsequent_export_test4.cxx +++ b/sc/qa/unit/subsequent_export_test4.cxx @@ -1917,6 +1917,26 @@ CPPUNIT_TEST_FIXTURE(ScExportTest4, testChangesAuthorDateXLSX) pBatch->commit(); } +CPPUNIT_TEST_FIXTURE(ScExportTest4, testNotesAuthor) +{ + createScDoc("xlsx/cell-note.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/comments1.xml"_ustr); + CPPUNIT_ASSERT(pXmlDoc); + + assertXPathContent(pXmlDoc, "/x:comments/x:authors/x:author"_ostr, u"Author1"_ustr); + + // Reset config change + officecfg::Office::Common::Security::Scripting::RemovePersonalInfoOnSaving::set(false, pBatch); + pBatch->commit(); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/filter/excel/xeescher.cxx b/sc/source/filter/excel/xeescher.cxx index 314f2ebe5b1c..625021e7555b 100644 --- a/sc/source/filter/excel/xeescher.cxx +++ b/sc/source/filter/excel/xeescher.cxx @@ -38,6 +38,7 @@ #include <editeng/outlobj.hxx> #include <unotools/tempfile.hxx> #include <unotools/ucbstreamhelper.hxx> +#include <unotools/securityoptions.hxx> #include <svtools/embedhlp.hxx> #include <unonames.hxx> @@ -1639,6 +1640,7 @@ XclExpNote::XclExpNote(const XclExpRoot& rRoot, const ScAddress& rScPos, , mbAutoFill(false) , mbColHidden(false) , mbRowHidden(false) + , mpAuthorIDs(new SvtSecurityMapPersonalInfo) { // get the main note text OUString aNoteText; @@ -1681,8 +1683,18 @@ XclExpNote::XclExpNote(const XclExpRoot& rRoot, const ScAddress& rScPos, // stAuthor (variable): An XLUnicodeString that specifies the name of the comment // author. String length MUST be greater than or equal to 1 and less than or equal // to 54. + bool bRemovePersonalInfo + = SvtSecurityOptions::IsOptionSet( + SvtSecurityOptions::EOption::DocWarnRemovePersonalInfo) + && !SvtSecurityOptions::IsOptionSet( + SvtSecurityOptions::EOption::DocWarnKeepNoteAuthorDateInfo); if( pScNote->GetAuthor().isEmpty() ) maAuthor = XclExpString( u" "_ustr ); + else if (bRemovePersonalInfo) + maAuthor = XclExpString( + "Author" + + OUString::number(mpAuthorIDs->GetInfoID(pScNote->GetAuthor())), + XclStrFlags::NONE, 54); else maAuthor = XclExpString( pScNote->GetAuthor(), XclStrFlags::NONE, 54 ); diff --git a/sc/source/filter/inc/xeescher.hxx b/sc/source/filter/inc/xeescher.hxx index c7adf1050b9b..2d7aefcf07d7 100644 --- a/sc/source/filter/inc/xeescher.hxx +++ b/sc/source/filter/inc/xeescher.hxx @@ -26,6 +26,7 @@ #include "xlformula.hxx" #include <svx/sdtaitm.hxx> #include <rtl/ustring.hxx> +#include <unotools/securityoptions.hxx> #include <unotools/tempfile.hxx> #include <memory> #include <optional> @@ -382,6 +383,8 @@ private: bool mbRowHidden; /// Row containing the comment is hidden tools::Rectangle maCommentFrom; /// From and From Offset tools::Rectangle maCommentTo; /// To and To Offsets + /// map authors to remove personal info + std::unique_ptr<SvtSecurityMapPersonalInfo> mpAuthorIDs; }; class XclExpComments : public XclExpRecord