[Libreoffice-commits] core.git: sw/source

Michael Stahl (via logerrit) logerrit at kemper.freedesktop.org
Tue Nov 17 21:19:01 UTC 2020


 sw/source/core/inc/rootfrm.hxx   |    8 ++++
 sw/source/core/layout/newfrm.cxx |    1 
 sw/source/core/layout/wsfrm.cxx  |   71 ++++++++++++++++++++++++++++++---------
 3 files changed, 64 insertions(+), 16 deletions(-)

New commits:
commit 0fef9628547c6132b165a478a9320262304f2435
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Tue Nov 3 21:48:02 2020 +0100
Commit:     Michael Stahl <michael.stahl at cib.de>
CommitDate: Tue Nov 17 22:18:22 2020 +0100

    sw_fieldmarkhide: add FieldmarkMode to SwRootFrame
    
    Change-Id: I366fe171fbcadad7643c54d76c3e28cc4b6b5dfa
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105981
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.stahl at cib.de>

diff --git a/sw/source/core/inc/rootfrm.hxx b/sw/source/core/inc/rootfrm.hxx
index 74a015c90d53..fbc95b8a8691 100644
--- a/sw/source/core/inc/rootfrm.hxx
+++ b/sw/source/core/inc/rootfrm.hxx
@@ -46,6 +46,8 @@ namespace sw {
     {
         Shown, Hidden
     };
+
+    enum class FieldmarkMode { ShowCommand = 1, ShowResult = 2, ShowBoth = 3 };
 };
 
 enum class SwInvalidateFlags
@@ -118,6 +120,7 @@ class SAL_DLLPUBLIC_RTTI SwRootFrame: public SwLayoutFrame
                                       // @see dcontact.cxx, ::Changed()
     bool    mbLayoutFreezed;
     bool    mbHideRedlines;
+    sw::FieldmarkMode m_FieldmarkMode;
 
     /**
      * For BrowseMode
@@ -416,6 +419,11 @@ public:
      */
     bool IsHideRedlines() const { return mbHideRedlines; }
     void SetHideRedlines(bool);
+    sw::FieldmarkMode GetFieldmarkMode() const { return m_FieldmarkMode; }
+    void SetFieldmarkMode(sw::FieldmarkMode);
+    bool HasMergedParas() const {
+        return IsHideRedlines() || GetFieldmarkMode() != sw::FieldmarkMode::ShowBoth;
+    }
 };
 
 inline tools::Long SwRootFrame::GetBrowseWidth() const
diff --git a/sw/source/core/layout/newfrm.cxx b/sw/source/core/layout/newfrm.cxx
index 8a62abd8aa54..cd527d13903c 100644
--- a/sw/source/core/layout/newfrm.cxx
+++ b/sw/source/core/layout/newfrm.cxx
@@ -414,6 +414,7 @@ SwRootFrame::SwRootFrame( SwFrameFormat *pFormat, SwViewShell * pSh ) :
     mbCallbackActionEnabled ( false ),
     mbLayoutFreezed ( false ),
     mbHideRedlines(pFormat->GetDoc()->GetDocumentRedlineManager().IsHideRedlines()),
+    m_FieldmarkMode(sw::FieldmarkMode::ShowBoth),
     mnBrowseWidth(MIN_BROWSE_WIDTH),
     mpTurbo( nullptr ),
     mpLastPage( nullptr ),
diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx
index bdc24e8dd21a..ae9242cbd13e 100644
--- a/sw/source/core/layout/wsfrm.cxx
+++ b/sw/source/core/layout/wsfrm.cxx
@@ -4513,15 +4513,10 @@ static void UnHideRedlinesExtras(SwRootFrame & rLayout,
     }
 }
 
-void SwRootFrame::SetHideRedlines(bool const bHideRedlines)
+static void UnHide(SwRootFrame & rLayout)
 {
-    if (bHideRedlines == mbHideRedlines)
-    {
-        return;
-    }
-    mbHideRedlines = bHideRedlines;
-    assert(GetCurrShell()->ActionPend()); // tdf#125754 avoid recursive layout
-    SwDoc & rDoc(*GetFormat()->GetDoc());
+    assert(rLayout.GetCurrShell()->ActionPend()); // tdf#125754 avoid recursive layout
+    SwDoc & rDoc(*rLayout.GetFormat()->GetDoc());
     // don't do early return if there are no redlines:
     // Show->Hide must init hidden number trees
     // Hide->Show may be called after all redlines have been deleted but there
@@ -4551,26 +4546,26 @@ void SwRootFrame::SetHideRedlines(bool const bHideRedlines)
     // vice-versa; alas flys may contain flys, so we skip some of them
     // if they have already been created from scratch via their anchor flys.
     std::set<sal_uLong> skippedFlys;
-    UnHideRedlinesExtras(*this, rNodes, rNodes.GetEndOfAutotext(),
+    UnHideRedlinesExtras(rLayout, rNodes, rNodes.GetEndOfAutotext(),
         // when un-hiding, delay all fly frame creation to AppendAllObjs below
-                         IsHideRedlines() ? &skippedFlys : nullptr);
+                         rLayout.IsHideRedlines() ? &skippedFlys : nullptr);
     // Footnotes are created automatically (after invalidation etc.) by
     // ConnectFootnote(), but need to be deleted manually. Footnotes do not
     // occur in flys or headers/footers.
-    UnHideRedlinesExtras(*this, rNodes, rNodes.GetEndOfInserts(), nullptr);
-    UnHideRedlines(*this, rNodes, rNodes.GetEndOfContent(), nullptr);
+    UnHideRedlinesExtras(rLayout, rNodes, rNodes.GetEndOfInserts(), nullptr);
+    UnHideRedlines(rLayout, rNodes, rNodes.GetEndOfContent(), nullptr);
 
-    if (!IsHideRedlines())
+    if (!rLayout.IsHideRedlines())
     {   // create all previously hidden flys at once:
         // * Flys on first node of pre-existing merged frames that are hidden
         //   (in delete redline), to be added to the existing frame
         // * Flys on non-first (hidden/merged) nodes of pre-existing merged
         //   frames, to be added to the new frame of their node
         // * Flys anchored in other flys that are hidden
-        AppendAllObjs(rDoc.GetSpzFrameFormats(), this);
+        AppendAllObjs(rDoc.GetSpzFrameFormats(), &rLayout);
     }
 
-    const bool bIsShowChangesInMargin = GetCurrShell()->GetViewOptions()->IsShowChangesInMargin();
+    const bool bIsShowChangesInMargin = rLayout.GetCurrShell()->GetViewOptions()->IsShowChangesInMargin();
     for (auto const pRedline : rDoc.getIDocumentRedlineAccess().GetRedlineTable())
     {   // DELETE are handled by the code above; for other types, need to
         // trigger repaint of text frames to add/remove the redline color font
@@ -4613,7 +4608,7 @@ void SwRootFrame::SetHideRedlines(bool const bHideRedlines)
 
     // update SwPostItMgr / notes in the margin
     // note: as long as all shells share layout, broadcast to all shells!
-    rDoc.GetDocShell()->Broadcast( SwFormatFieldHint(nullptr, bHideRedlines
+    rDoc.GetDocShell()->Broadcast( SwFormatFieldHint(nullptr, rLayout.IsHideRedlines()
             ? SwFormatFieldHintWhich::REMOVED
             : SwFormatFieldHintWhich::INSERTED) );
 
@@ -4621,4 +4616,48 @@ void SwRootFrame::SetHideRedlines(bool const bHideRedlines)
 //    InvalidateAllContent(SwInvalidateFlags::Size); // ??? TODO what to invalidate?  this is the big hammer
 }
 
+void SwRootFrame::SetHideRedlines(bool const bHideRedlines)
+{
+    if (bHideRedlines == mbHideRedlines)
+    {
+        return;
+    }
+    // TODO: remove temporary ShowBoth
+    sw::FieldmarkMode const eMode(m_FieldmarkMode);
+    if (HasMergedParas())
+    {
+        m_FieldmarkMode = sw::FieldmarkMode::ShowBoth;
+        mbHideRedlines = false;
+        UnHide(*this);
+    }
+    if (bHideRedlines || eMode != m_FieldmarkMode)
+    {
+        m_FieldmarkMode = eMode;
+        mbHideRedlines = bHideRedlines;
+        UnHide(*this);
+    }
+}
+
+void SwRootFrame::SetFieldmarkMode(sw::FieldmarkMode const eMode)
+{
+    if (eMode == m_FieldmarkMode)
+    {
+        return;
+    }
+    // TODO: remove temporary ShowBoth
+    bool const isHideRedlines(mbHideRedlines);
+    if (HasMergedParas())
+    {
+        mbHideRedlines = false;
+        m_FieldmarkMode = sw::FieldmarkMode::ShowBoth;
+        UnHide(*this);
+    }
+    if (eMode != sw::FieldmarkMode::ShowBoth || isHideRedlines)
+    {
+        mbHideRedlines = isHideRedlines;
+        m_FieldmarkMode = eMode;
+        UnHide(*this);
+    }
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list