doc: Don't export notes author/date when in privacy mode

Change-Id: I54459ed5f556f2dbe88d149ea859105db35f1cd0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169647
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>
diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx
index 28309d9..6cbc270 100644
--- a/sw/source/filter/ww8/wrtw8sty.cxx
+++ b/sw/source/filter/ww8/wrtw8sty.cxx
@@ -31,6 +31,7 @@
#include <editeng/lrspitem.hxx>
#include <editeng/fhgtitem.hxx>
#include <rtl/character.hxx>
#include <unotools/securityoptions.hxx>

#include <doc.hxx>
#include "wrtww8.hxx"
@@ -2193,27 +2194,41 @@ void WW8_WrPlcFootnoteEdn::Append( WW8_CP nCp, const SwFormatFootnote& rFootnote

WW8_Annotation::WW8_Annotation(const SwPostItField* pPostIt, WW8_CP nRangeStart, WW8_CP nRangeEnd)
    :
        maDateTime( DateTime::EMPTY ),
        m_nRangeStart(nRangeStart),
        m_nRangeEnd(nRangeEnd)
        m_nRangeEnd(nRangeEnd),
        mpAuthorIDs(new SvtSecurityMapPersonalInfo)
{
    mpRichText = pPostIt->GetTextObject();
    if (!mpRichText)
        msSimpleText = pPostIt->GetText();
    msOwner = pPostIt->GetPar1();
    m_sInitials = pPostIt->GetInitials();
    maDateTime = DateTime(pPostIt->GetDate(), pPostIt->GetTime());
    initPersonalInfo(pPostIt->GetPar1(), pPostIt->GetInitials(),
                     DateTime(pPostIt->GetDate(), pPostIt->GetTime()));
}

WW8_Annotation::WW8_Annotation(const SwRedlineData* pRedline)
    :
        mpRichText(nullptr),
        msSimpleText(pRedline->GetComment()),
        msOwner(SW_MOD()->GetRedlineAuthor(pRedline->GetAuthor())),
        maDateTime(pRedline->GetTimeStamp()),
        m_nRangeStart(0),
        m_nRangeEnd(0)
        m_nRangeEnd(0),
        mpAuthorIDs(new SvtSecurityMapPersonalInfo)
{
    initPersonalInfo(SW_MOD()->GetRedlineAuthor(pRedline->GetAuthor()), u""_ustr,
                     pRedline->GetTimeStamp());
}

void WW8_Annotation::initPersonalInfo(const OUString& sAuthor, const OUString& sInitials,
                                      DateTime aDateTime)
{
    bool bRemovePersonalInfo
        = SvtSecurityOptions::IsOptionSet(SvtSecurityOptions::EOption::DocWarnRemovePersonalInfo)
          && !SvtSecurityOptions::IsOptionSet(
                 SvtSecurityOptions::EOption::DocWarnKeepNoteAuthorDateInfo);
    msOwner = bRemovePersonalInfo ? "Author" + OUString::number(mpAuthorIDs->GetInfoID(sAuthor))
                                  : sAuthor;
    m_sInitials = bRemovePersonalInfo ? "A" + OUString::number(mpAuthorIDs->GetInfoID(sAuthor))
                                      : sInitials;
    maDateTime = bRemovePersonalInfo ? DateTime(DateTime::EMPTY) : aDateTime;
}

bool WW8_Annotation::HasRange() const
diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx
index af58e08..94a7b56 100644
--- a/sw/source/filter/ww8/wrtww8.hxx
+++ b/sw/source/filter/ww8/wrtww8.hxx
@@ -27,6 +27,7 @@
#include <editeng/editdata.hxx>
#include <filter/msfilter/ww8fields.hxx>
#include <filter/msfilter/msoleexp.hxx>
#include <unotools/securityoptions.hxx>

#include <shellio.hxx>

@@ -1273,13 +1274,16 @@ struct WW8_Annotation
    OUString msSimpleText;
    OUString msOwner;
    OUString m_sInitials;
    DateTime maDateTime;
    DateTime maDateTime = DateTime(DateTime::EMPTY);
    WW8_CP m_nRangeStart, m_nRangeEnd;
    bool m_bIgnoreEmpty = true;
    /// map authors to remove personal info
    std::unique_ptr<SvtSecurityMapPersonalInfo> mpAuthorIDs;
    WW8_Annotation(const SwPostItField* pPostIt, WW8_CP nRangeStart, WW8_CP nRangeEnd);
    explicit WW8_Annotation(const SwRedlineData* pRedline);
    /// An annotation has a range if start != end or the m_bIgnoreEmpty flag is cleared.
    bool HasRange() const;
    void initPersonalInfo(const OUString& sAuthor, const OUString& sInitials, DateTime aDateTime);
};

class WW8_WrPlcAnnotations : public WW8_WrPlcSubDoc  // double Plc for Postits