sw_redlinehide_4b: tdf#113479 SetRedlineFlags() calls no longer...

...able to be triggered by the UI, so the performance problem should be
gone.

The SwXTextDocument "ShowChanges" property allows API clients to call
SetRedlineFlags() and change the model; this API should be retained
as-is for now, because there is no way currently (outside of the rather
specialised a11y API) to get a "merged view" of the paragraphs in the
document, so API clients may want to (temporarily) toggle this property
to then retrieve properties from the model.  In case we later find that
there are no API clients that want to do such things, the property can
be removed.

A run with assert() instead of SAL_WARN_IF() found only 2 tests that
explicitly call SetRedlineFlags() to clear ShowDelete.

Change-Id: I44aee90f7727948ca0bbaaff9d04f8dd6b97cbd1
Reviewed-on: https://gerrit.libreoffice.org/65350
Tested-by: Jenkins
Reviewed-by: Michael Stahl <Michael.Stahl@cib.de>
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index 6e34a5d..e38d1ea 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -3689,7 +3689,6 @@
    assert(m_rDoc.getIDocumentRedlineAccess().IsRedlineOn());

    RedlineFlags eOld = m_rDoc.getIDocumentRedlineAccess().GetRedlineFlags();
    m_rDoc.GetDocumentRedlineManager().checkRedlining( eOld );

    if (*rPam.GetPoint() == *rPam.GetMark())
    {
@@ -3750,9 +3749,10 @@
    std::vector<std::unique_ptr<SwUndoRedlineDelete>> undos;
    if (m_rDoc.GetIDocumentUndoRedo().DoesUndo())
    {
        /* please don't translate -- for cultural reasons this comment is protected
           until the redline implementation is finally fixed some day */
        //JP 06.01.98: MUSS noch optimiert werden!!!
        // this should no longer happen in calls from the UI but maybe via API
        // (randomTest and testTdf54819 triggers it)
        SAL_WARN_IF((eOld & RedlineFlags::ShowMask) != RedlineFlags::ShowMask,
                "sw.core", "redlines will be moved in DeleteAndJoin");
        m_rDoc.getIDocumentRedlineAccess().SetRedlineFlags(
            RedlineFlags::On | RedlineFlags::ShowInsert | RedlineFlags::ShowDelete);
        for (SwRangeRedline * pRedline : redlines)
@@ -3811,7 +3811,6 @@
        {
            m_rDoc.GetIDocumentUndoRedo().EndUndo(SwUndoId::EMPTY, nullptr);
        }
        //JP 06.01.98: MUSS noch optimiert werden!!!
        m_rDoc.getIDocumentRedlineAccess().SetRedlineFlags( eOld );
    }
    return true;
@@ -4075,9 +4074,12 @@
        if( m_rDoc.getIDocumentRedlineAccess().IsRedlineOn() )
        {
            RedlineFlags eOld = m_rDoc.getIDocumentRedlineAccess().GetRedlineFlags();
            m_rDoc.GetDocumentRedlineManager().checkRedlining(eOld);
            if (m_rDoc.GetIDocumentUndoRedo().DoesUndo())
            {
                // this should no longer happen in calls from the UI but maybe via API
                SAL_WARN_IF((eOld & RedlineFlags::ShowMask) != RedlineFlags::ShowMask,
                        "sw.core", "redlines will be moved in ReplaceRange");

                m_rDoc.GetIDocumentUndoRedo().StartUndo(SwUndoId::EMPTY, nullptr);

                // If any Redline will change (split!) the node
@@ -4086,7 +4088,6 @@
                        OUString(), IDocumentMarkAccess::MarkType::UNO_BOOKMARK,
                        ::sw::mark::InsertMode::New);

                //JP 06.01.98: MUSS noch optimiert werden!!!
                m_rDoc.getIDocumentRedlineAccess().SetRedlineFlags(
                    RedlineFlags::On | RedlineFlags::ShowInsert | RedlineFlags::ShowDelete );

@@ -4185,7 +4186,6 @@
                rPam.GetPoint()->nNode = 0;
                rPam.GetPoint()->nContent = rIdx;
                *rPam.GetMark() = *rPam.GetPoint();
                //JP 06.01.98: MUSS noch optimiert werden!!!
                m_rDoc.getIDocumentRedlineAccess().SetRedlineFlags( eOld );

                *rPam.GetPoint() = pBkmk->GetMarkPos();
diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx
index a584a553..4415030 100644
--- a/sw/source/core/doc/docnum.cxx
+++ b/sw/source/core/doc/docnum.cxx
@@ -2261,10 +2261,12 @@
            }

            RedlineFlags eOld = getIDocumentRedlineAccess().GetRedlineFlags();
            GetDocumentRedlineManager().checkRedlining(eOld);
            if (GetIDocumentUndoRedo().DoesUndo())
            {
                // Still NEEDS to be optimized (even after 14 years)
                // this should no longer happen in calls from the UI but maybe via API
                SAL_WARN_IF((eOld & RedlineFlags::ShowMask) != RedlineFlags::ShowMask,
                    "sw.core", "redlines will be moved in DeleteAndJoin");

                getIDocumentRedlineAccess().SetRedlineFlags(
                   RedlineFlags::On | RedlineFlags::ShowInsert | RedlineFlags::ShowDelete );
                GetIDocumentUndoRedo().AppendUndo(
@@ -2285,7 +2287,6 @@
            aPam.GetBound(false).nContent.Assign(aPam.GetBound(false).nNode.GetNode().GetContentNode(), 0);
            sw::UpdateFramesForAddDeleteRedline(*this, aPam);

            // Still NEEDS to be optimized!
            getIDocumentRedlineAccess().SetRedlineFlags( eOld );
            GetIDocumentUndoRedo().EndUndo( SwUndoId::END, nullptr );
            getIDocumentState().SetModified();