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 <[email protected]>
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 0000000..9df212a
--- /dev/null
+++ b/sc/qa/unit/data/xlsx/cell-note.xlsx
Binary files differ
diff --git a/sc/qa/unit/subsequent_export_test4.cxx b/sc/qa/unit/subsequent_export_test4.cxx
index a6e5802..fbf3167 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 314f2eb..625021e 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 c7adf10..2d7aefc 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