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.mehrbrodt@allotropia.de>
This commit is contained in:
Binary file not shown.
@@ -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: */
|
||||
|
||||
@@ -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 );
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user