[Libreoffice-commits] core.git: Branch 'private/mst/sw_redlinehide_3' - 5 commits - sw/inc sw/qa sw/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Oct 16 16:19:01 UTC 2018


 sw/inc/doc.hxx                                          |    4 
 sw/inc/fmtftn.hxx                                       |    7 
 sw/inc/ftnidx.hxx                                       |   10 
 sw/inc/txtftn.hxx                                       |    4 
 sw/qa/extras/layout/layout.cxx                          |   16 -
 sw/source/core/access/accfootnote.cxx                   |    4 
 sw/source/core/doc/DocumentContentOperationsManager.cxx |    2 
 sw/source/core/doc/DocumentRedlineManager.cxx           |    7 
 sw/source/core/doc/docdesc.cxx                          |    2 
 sw/source/core/doc/docftn.cxx                           |   14 -
 sw/source/core/doc/ftnidx.cxx                           |  176 +++++++++++++---
 sw/source/core/edit/edattr.cxx                          |    4 
 sw/source/core/fields/reffld.cxx                        |    2 
 sw/source/core/inc/UndoAttribute.hxx                    |    3 
 sw/source/core/inc/rootfrm.hxx                          |    4 
 sw/source/core/inc/txtfrm.hxx                           |    2 
 sw/source/core/layout/ftnfrm.cxx                        |   26 ++
 sw/source/core/layout/wsfrm.cxx                         |   13 +
 sw/source/core/text/txtftn.cxx                          |    9 
 sw/source/core/txtnode/atrftn.cxx                       |   25 +-
 sw/source/core/txtnode/modeltoviewhelper.cxx            |    2 
 sw/source/core/undo/unattr.cxx                          |    7 
 sw/source/core/undo/unredln.cxx                         |    4 
 sw/source/core/unocore/unoftn.cxx                       |    2 
 sw/source/filter/html/htmlftn.cxx                       |    4 
 sw/source/filter/ww8/ww8par2.cxx                        |    2 
 26 files changed, 268 insertions(+), 87 deletions(-)

New commits:
commit 264b4a053177723fe3ec3c58983fffc235090a1e
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Tue Oct 16 17:31:25 2018 +0200
Commit:     Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Tue Oct 16 18:15:49 2018 +0200

    sw_redlinehide_3: invalidate footnotes in UnHideRedlines
    
    ... so the numbers are repainted, both in the document body and in
    the footnotes.
    
    Change-Id: I4164f1bace1b984a841f520f4832a324b811ab3f

diff --git a/sw/inc/txtftn.hxx b/sw/inc/txtftn.hxx
index 4a3408c5e290..01aa9c5801d5 100644
--- a/sw/inc/txtftn.hxx
+++ b/sw/inc/txtftn.hxx
@@ -57,6 +57,8 @@ public:
     // Check conditional paragraph styles.
     void CheckCondColl();
 
+    void InvalidateNumberInLayout();
+
     // For references to footnotes.
     void SetSeqRefNo();
     void SetSeqNo( sal_uInt16 n )       { m_nSeqNo = n; }   // For Readers.
diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx
index 14ada1f0d5d4..7aff243c691a 100644
--- a/sw/source/core/layout/wsfrm.cxx
+++ b/sw/source/core/layout/wsfrm.cxx
@@ -35,6 +35,7 @@
 #include <fesh.hxx>
 #include <docsh.hxx>
 #include <ftninfo.hxx>
+#include <ftnidx.hxx>
 #include <fmtclbl.hxx>
 #include <fmtfsize.hxx>
 #include <fmtpdsc.hxx>
@@ -4482,6 +4483,18 @@ void SwRootFrame::SetHideRedlines(bool const bHideRedlines)
         }
     }
 
+    // invalidate all footnotes to reformat their numbers
+    SwFootnoteIdxs const& rFootnotes(rDoc.GetFootnoteIdxs());
+    for (SwTextFootnote *const pFootnote : rFootnotes)
+    {
+        SwFormatFootnote const& rFootnote(pFootnote->GetFootnote());
+        if (rFootnote.GetNumber() != rFootnote.GetNumberRLHidden()
+            && rFootnote.GetNumStr().isEmpty())
+        {
+            pFootnote->InvalidateNumberInLayout();
+        }
+    }
+
 //    InvalidateAllContent(SwInvalidateFlags::Size); // ??? TODO what to invalidate?  this is the big hammer
 }
 
diff --git a/sw/source/core/txtnode/atrftn.cxx b/sw/source/core/txtnode/atrftn.cxx
index 3a9d02439f91..de299bcc0cc8 100644
--- a/sw/source/core/txtnode/atrftn.cxx
+++ b/sw/source/core/txtnode/atrftn.cxx
@@ -345,8 +345,13 @@ void SwTextFootnote::SetNumber(const sal_uInt16 nNewNum,
         rFootnote.m_nNumber = nNewNum;
         rFootnote.m_nNumberRLHidden = nNumberRLHidden;
     }
+    InvalidateNumberInLayout();
+}
 
-    OSL_ENSURE( m_pTextNode, "SwTextFootnote: where is my TextNode?" );
+void SwTextFootnote::InvalidateNumberInLayout()
+{
+    assert(m_pTextNode);
+    SwFormatFootnote const& rFootnote(GetFootnote());
     SwNodes &rNodes = m_pTextNode->GetDoc()->GetNodes();
     m_pTextNode->ModifyNotification( nullptr, &rFootnote );
     if ( m_pStartNode )
commit 6fadb93aab965a2430cfe1f1522c4e858c07fb75
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Tue Oct 16 16:28:19 2018 +0200
Commit:     Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Tue Oct 16 18:15:49 2018 +0200

    sw_redlinehide_3: update footnote numbers on redline ops
    
    Needed for FTNNUM_CHAPTER and FTNNUM_DOC, as well as end-notes.
    
    It should be enough to update from the start node until the end.
    
    Change-Id: I47414f93b9ad29bc4ab4ee0fc25ae40fae160427

diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index 63b38d75bc86..97c693372940 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -908,7 +908,7 @@ void SwLayoutWriter::testRedlineFlysInFootnote()
         xmlDocPtr pXmlDoc = parseLayoutDump();
         assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/merged", "paraPropsNodeIndex", "25");
         assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Special[1]", "nType", "POR_FTN");
-        assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Special[1]", "rText", "2");
+        assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Special[1]", "rText", "1");
         assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/merged", "paraPropsNodeIndex",
                     "7");
         assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/anchored/fly[1]/txt[1]/merged",
@@ -919,7 +919,7 @@ void SwLayoutWriter::testRedlineFlysInFootnote()
                     "Portion", "ahi");
         assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/Special[1]", "nType",
                     "POR_FTNNUM");
-        assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/Special[1]", "rText", "2");
+        assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/Special[1]", "rText", "1");
 
         lcl_dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {});
         CPPUNIT_ASSERT(!pLayout->IsHideRedlines());
@@ -1006,12 +1006,12 @@ void SwLayoutWriter::testRedlineFlysInFootnote()
 
         assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/merged", "paraPropsNodeIndex", "25");
         assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Special[1]", "nType", "POR_FTN");
-        assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Special[1]", "rText", "2");
+        assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Special[1]", "rText", "1");
         assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/merged", "paraPropsNodeIndex",
                     "7");
         assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/Special[1]", "nType",
                     "POR_FTNNUM");
-        assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/Special[1]", "rText", "2");
+        assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/Special[1]", "rText", "1");
 
         { // hide: no anchored object shown
             xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, "//anchored");
@@ -1105,7 +1105,7 @@ void SwLayoutWriter::testRedlineFlysInFootnote()
         xmlDocPtr pXmlDoc = parseLayoutDump();
         assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/merged", "paraPropsNodeIndex", "25");
         assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Special[1]", "nType", "POR_FTN");
-        assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Special[1]", "rText", "2");
+        assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Special[1]", "rText", "1");
         assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/merged", "paraPropsNodeIndex",
                     "7");
         assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/anchored/fly[1]/txt[1]/merged",
@@ -1116,7 +1116,7 @@ void SwLayoutWriter::testRedlineFlysInFootnote()
                     "Portion", "ahi");
         assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/Special[1]", "nType",
                     "POR_FTNNUM");
-        assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/Special[1]", "rText", "2");
+        assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/Special[1]", "rText", "1");
 
         lcl_dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {});
         CPPUNIT_ASSERT(!pLayout->IsHideRedlines());
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index 679fd7d1f098..85cef08f4698 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -3690,7 +3690,7 @@ bool DocumentContentOperationsManager::DeleteAndJoinWithRedlineImpl( SwPaM & rPa
         // sw_redlinehide: 2 reasons why this is needed:
         // 1. it's the first redline in node => RedlineDelText was sent but ignored
         // 2. redline spans multiple nodes => must merge text frames
-        sw::UpdateFramesForAddDeleteRedline(*pCursor);
+        sw::UpdateFramesForAddDeleteRedline(m_rDoc, *pCursor);
     }
     m_rDoc.getIDocumentState().SetModified();
 
diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx
index 5f94d27311c1..bd14dd415f06 100644
--- a/sw/source/core/doc/DocumentRedlineManager.cxx
+++ b/sw/source/core/doc/DocumentRedlineManager.cxx
@@ -28,6 +28,7 @@
 #include <docary.hxx>
 #include <ndtxt.hxx>
 #include <unocrsr.hxx>
+#include <ftnidx.hxx>
 #include <strings.hrc>
 #include <swmodule.hxx>
 #include <editsh.hxx>
@@ -118,8 +119,11 @@ using namespace com::sun::star;
 
 namespace sw {
 
-void UpdateFramesForAddDeleteRedline(SwPaM const& rPam)
+void UpdateFramesForAddDeleteRedline(SwDoc & rDoc, SwPaM const& rPam)
 {
+    // no need to call UpdateFootnoteNums for FTNNUM_PAGE:
+    // the AppendFootnote/RemoveFootnote will do it by itself!
+    rDoc.GetFootnoteIdxs().UpdateFootnote(rPam.Start()->nNode);
     SwTextNode *const pStartNode(rPam.Start()->nNode.GetNode().GetTextNode());
     std::vector<SwTextFrame*> frames;
     SwIterator<SwTextFrame, SwTextNode, sw::IteratorMode::UnwrapMulti> aIter(*pStartNode);
@@ -148,6 +152,7 @@ void UpdateFramesForAddDeleteRedline(SwPaM const& rPam)
 
 void UpdateFramesForRemoveDeleteRedline(SwDoc & rDoc, SwPaM const& rPam)
 {
+    rDoc.GetFootnoteIdxs().UpdateFootnote(rPam.Start()->nNode);
     SwTextNode *const pStartNode(rPam.Start()->nNode.GetNode().GetTextNode());
     std::vector<SwTextFrame*> frames;
     std::set<SwRootFrame*> layouts;
diff --git a/sw/source/core/inc/txtfrm.hxx b/sw/source/core/inc/txtfrm.hxx
index f537a98d0f95..93c1e9a6b7a1 100644
--- a/sw/source/core/inc/txtfrm.hxx
+++ b/sw/source/core/inc/txtfrm.hxx
@@ -112,7 +112,7 @@ void MoveDeletedPrevFrames(SwTextNode & rDeletedPrev, SwTextNode & rNode);
 enum class Recreate { No, ThisNode, Predecessor };
 void CheckResetRedlineMergeFlag(SwTextNode & rNode, Recreate eRecreateMerged);
 
-void UpdateFramesForAddDeleteRedline(SwPaM const& rPam);
+void UpdateFramesForAddDeleteRedline(SwDoc & rDoc, SwPaM const& rPam);
 void UpdateFramesForRemoveDeleteRedline(SwDoc & rDoc, SwPaM const& rPam);
 
 void AddRemoveFlysAnchoredToFrameStartingAtNode(
diff --git a/sw/source/core/undo/unredln.cxx b/sw/source/core/undo/unredln.cxx
index a2eaa3f6d72d..09b7651e2eed 100644
--- a/sw/source/core/undo/unredln.cxx
+++ b/sw/source/core/undo/unredln.cxx
@@ -116,7 +116,7 @@ void SwUndoRedline::UndoImpl(::sw::UndoRedoContext & rContext)
     else if (dynamic_cast<SwUndoAcceptRedline*>(this)
           || dynamic_cast<SwUndoRejectRedline*>(this))
     {   // (can't check here if there's a delete redline being accepted)
-        sw::UpdateFramesForAddDeleteRedline(rPam);
+        sw::UpdateFramesForAddDeleteRedline(rDoc, rPam);
     }
 }
 
@@ -203,7 +203,7 @@ void SwUndoRedlineDelete::RedoRedlineImpl(SwDoc & rDoc, SwPaM & rPam)
     {
         rDoc.getIDocumentRedlineAccess().AppendRedline( new SwRangeRedline(*mpRedlData, rPam), false );
     }
-    sw::UpdateFramesForAddDeleteRedline(rPam);
+    sw::UpdateFramesForAddDeleteRedline(rDoc, rPam);
 }
 
 bool SwUndoRedlineDelete::CanGrouping( const SwUndoRedlineDelete& rNext )
commit 8aba5c7028936b3ae88e54f92e045cb7b9084e84
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Tue Oct 16 14:24:14 2018 +0200
Commit:     Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Tue Oct 16 18:15:49 2018 +0200

    sw_redlinehide_3: use appropriate footnote number in text formatting
    
    Add layout parameter to SwFormatFootnote::GetViewNumStr().
    
    Change-Id: Iff9c9ff31d1793b66ba7e3ebdfa5cfe413324471

diff --git a/sw/inc/fmtftn.hxx b/sw/inc/fmtftn.hxx
index b6560544b12f..5c22c157fb49 100644
--- a/sw/inc/fmtftn.hxx
+++ b/sw/inc/fmtftn.hxx
@@ -32,6 +32,7 @@ namespace com { namespace sun { namespace star {
 
 class SwDoc;
 class SwTextFootnote;
+class SwRootFrame;
 
 // ATT_FTN
 
@@ -87,7 +88,8 @@ public:
     void GetFootnoteText( OUString& rStr ) const;
 
     /// Returns string to be displayed of footnote / endnote.
-    OUString GetViewNumStr( const SwDoc& rDoc, bool bInclStrs = false ) const;
+    OUString GetViewNumStr(const SwDoc& rDoc, SwRootFrame const* pLayout,
+            bool bInclStrings = false) const;
 
     css::uno::WeakReference<css::text::XFootnote> const& GetXFootnote() const
         { return m_wXFootnote; }
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index 0233252ae88e..63b38d75bc86 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -131,7 +131,7 @@ void SwLayoutWriter::CheckRedlineFootnotesHidden()
     assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "nType", "POR_TXT");
     assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Text[1]", "Portion", "foaz");
     assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Special[2]", "nType", "POR_FTN");
-    assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Special[2]", "rText", "5"); // TODO 2
+    assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Special[2]", "rText", "2");
     assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/merged", "paraPropsNodeIndex", "13");
     assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/Special[1]", "nType", "POR_FTNNUM");
     assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/Special[1]", "rText", "1");
@@ -139,7 +139,7 @@ void SwLayoutWriter::CheckRedlineFootnotesHidden()
     assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[1]/txt[1]/Text[1]", "Portion", "ac");
     assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[1]/merged", "paraPropsNodeIndex", "16");
     assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[1]/Special[1]", "nType", "POR_FTNNUM");
-    assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[1]/Special[1]", "rText", "5"); // TODO 2
+    assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[1]/Special[1]", "rText", "2");
     assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[1]/Text[1]", "nType", "POR_TXT");
     assertXPath(pXmlDoc, "/root/page[1]/ftncont/ftn[2]/txt[1]/Text[1]", "Portion", "mo");
 }
diff --git a/sw/source/core/access/accfootnote.cxx b/sw/source/core/access/accfootnote.cxx
index 2dd90b3e6079..14ff4d43f889 100644
--- a/sw/source/core/access/accfootnote.cxx
+++ b/sw/source/core/access/accfootnote.cxx
@@ -54,7 +54,7 @@ SwAccessibleFootnote::SwAccessibleFootnote(
     if( pTextFootnote )
     {
         const SwDoc *pDoc = GetShell()->GetDoc();
-        sArg = pTextFootnote->GetFootnote().GetViewNumStr( *pDoc );
+        sArg = pTextFootnote->GetFootnote().GetViewNumStr(*pDoc, pFootnoteFrame->getRootFrame());
     }
 
     SetName(GetResource(pResId, &sArg));
@@ -80,7 +80,7 @@ OUString SAL_CALL SwAccessibleFootnote::getAccessibleDescription()
     if( pTextFootnote )
     {
         const SwDoc *pDoc = GetMap()->GetShell()->GetDoc();
-        sArg = pTextFootnote->GetFootnote().GetViewNumStr( *pDoc );
+        sArg = pTextFootnote->GetFootnote().GetViewNumStr(*pDoc, GetFrame()->getRootFrame());
     }
 
     return GetResource(pResId, &sArg);
diff --git a/sw/source/core/edit/edattr.cxx b/sw/source/core/edit/edattr.cxx
index 7cd3a4217be7..afe1b0baffb2 100644
--- a/sw/source/core/edit/edattr.cxx
+++ b/sw/source/core/edit/edattr.cxx
@@ -463,7 +463,7 @@ size_t SwEditShell::GetSeqFootnoteList( SwSeqFieldList& rList, bool bEndNotes )
 
             if( pTextNd )
             {
-                OUString sText( rFootnote.GetViewNumStr( *mxDoc ));
+                OUString sText(rFootnote.GetViewNumStr(*mxDoc, GetLayout()));
                 if( !sText.isEmpty() )
                     sText += " ";
                 sText += pTextNd->GetExpandText();
diff --git a/sw/source/core/fields/reffld.cxx b/sw/source/core/fields/reffld.cxx
index 8211f3b18ebd..627e41268c68 100644
--- a/sw/source/core/fields/reffld.cxx
+++ b/sw/source/core/fields/reffld.cxx
@@ -524,7 +524,7 @@ void SwGetRefField::UpdateField( const SwTextField* pFieldTextAttr )
                     SwTextFootnote* const pFootnoteIdx = pDoc->GetFootnoteIdxs()[i];
                     if( m_nSeqNo == pFootnoteIdx->GetSeqRefNo() )
                     {
-                        m_sText = pFootnoteIdx->GetFootnote().GetViewNumStr( *pDoc );
+                        m_sText = pFootnoteIdx->GetFootnote().GetViewNumStr(*pDoc, nullptr/*TODO?*/);
                         if (!m_sSetReferenceLanguage.isEmpty())
                             lcl_formatReferenceLanguage(m_sText, false, GetLanguage(), m_sSetReferenceLanguage);
                         break;
diff --git a/sw/source/core/text/txtftn.cxx b/sw/source/core/text/txtftn.cxx
index 586750276517..0014d09831e2 100644
--- a/sw/source/core/text/txtftn.cxx
+++ b/sw/source/core/text/txtftn.cxx
@@ -779,7 +779,7 @@ SwFootnotePortion *SwTextFormatter::NewFootnotePortion( SwTextFormatInfo &rInf,
     SwDoc *const pDoc = &m_pFrame->GetDoc();
 
     if( rInf.IsTest() )
-        return new SwFootnotePortion( rFootnote.GetViewNumStr( *pDoc ), pFootnote );
+        return new SwFootnotePortion(rFootnote.GetViewNumStr(*pDoc, m_pFrame->getRootFrame()), pFootnote);
 
     SwSwapIfSwapped swap(m_pFrame);
 
@@ -893,7 +893,8 @@ SwFootnotePortion *SwTextFormatter::NewFootnotePortion( SwTextFormatInfo &rInf,
         }
     }
     // Finally: Create FootnotePortion and exit ...
-    SwFootnotePortion *pRet = new SwFootnotePortion( rFootnote.GetViewNumStr( *pDoc ),
+    SwFootnotePortion *pRet = new SwFootnotePortion(
+            rFootnote.GetViewNumStr(*pDoc, m_pFrame->getRootFrame()),
                                            pFootnote, nReal );
     rInf.SetFootnoteInside( true );
 
@@ -918,7 +919,7 @@ SwNumberPortion *SwTextFormatter::NewFootnoteNumPortion( SwTextFormatInfo const
     SwFormatFootnote& rFootnote = const_cast<SwFormatFootnote&>(pFootnote->GetFootnote());
 
     SwDoc *const pDoc = &m_pFrame->GetDoc();
-    OUString aFootnoteText( rFootnote.GetViewNumStr( *pDoc, true ));
+    OUString aFootnoteText(rFootnote.GetViewNumStr(*pDoc, m_pFrame->getRootFrame(), true));
 
     const SwEndNoteInfo* pInfo;
     if( rFootnote.IsEndNote() )
@@ -1249,7 +1250,7 @@ SwFootnoteSave::SwFootnoteSave( const SwTextSizeInfo &rInf,
         else
         {
             // examine text and set script
-            OUString aTmpStr( rFootnote.GetViewNumStr( *pDoc ) );
+            OUString aTmpStr(rFootnote.GetViewNumStr(*pDoc, rInf.GetTextFrame()->getRootFrame()));
             pFnt->SetActual( SwScriptInfo::WhichFont(0, aTmpStr) );
         }
 
diff --git a/sw/source/core/txtnode/atrftn.cxx b/sw/source/core/txtnode/atrftn.cxx
index 7444b4768b64..3a9d02439f91 100644
--- a/sw/source/core/txtnode/atrftn.cxx
+++ b/sw/source/core/txtnode/atrftn.cxx
@@ -23,6 +23,7 @@
 #include <DocumentContentOperationsManager.hxx>
 #include <IDocumentStylePoolAccess.hxx>
 #include <cntfrm.hxx>
+#include <rootfrm.hxx>
 #include <pagefrm.hxx>
 #include <txtftn.hxx>
 #include <ftnidx.hxx>
@@ -202,7 +203,8 @@ void SwFormatFootnote::GetFootnoteText( OUString& rStr ) const
 }
 
 /// return the view string of the foot/endnote
-OUString SwFormatFootnote::GetViewNumStr( const SwDoc& rDoc, bool bInclStrings ) const
+OUString SwFormatFootnote::GetViewNumStr(const SwDoc& rDoc,
+        SwRootFrame const*const pLayout, bool bInclStrings) const
 {
     OUString sRet( GetNumStr() );
     if( sRet.isEmpty() )
@@ -212,6 +214,9 @@ OUString SwFormatFootnote::GetViewNumStr( const SwDoc& rDoc, bool bInclStrings )
         const SwSectionNode* pSectNd = m_pTextAttr
                     ? SwUpdFootnoteEndNtAtEnd::FindSectNdWithEndAttr( *m_pTextAttr )
                     : nullptr;
+        sal_uInt16 const nNumber(pLayout && pLayout->IsHideRedlines()
+                ? GetNumberRLHidden()
+                : GetNumber());
 
         if( pSectNd )
         {
@@ -224,7 +229,7 @@ OUString SwFormatFootnote::GetViewNumStr( const SwDoc& rDoc, bool bInclStrings )
             if( FTNEND_ATTXTEND_OWNNUMANDFMT == rFootnoteEnd.GetValue() )
             {
                 bMakeNum = false;
-                sRet = rFootnoteEnd.GetSwNumType().GetNumStr( GetNumber() );
+                sRet = rFootnoteEnd.GetSwNumType().GetNumStr( nNumber );
                 if( bInclStrings )
                 {
                     sRet = rFootnoteEnd.GetPrefix() + sRet + rFootnoteEnd.GetSuffix();
@@ -239,7 +244,7 @@ OUString SwFormatFootnote::GetViewNumStr( const SwDoc& rDoc, bool bInclStrings )
                 pInfo = &rDoc.GetEndNoteInfo();
             else
                 pInfo = &rDoc.GetFootnoteInfo();
-            sRet = pInfo->aFormat.GetNumStr( GetNumber() );
+            sRet = pInfo->aFormat.GetNumStr( nNumber );
             if( bInclStrings )
             {
                 sRet = pInfo->GetPrefix() + sRet + pInfo->GetSuffix();
diff --git a/sw/source/core/txtnode/modeltoviewhelper.cxx b/sw/source/core/txtnode/modeltoviewhelper.cxx
index 8c2b2c078996..b147e6976d2b 100644
--- a/sw/source/core/txtnode/modeltoviewhelper.cxx
+++ b/sw/source/core/txtnode/modeltoviewhelper.cxx
@@ -162,7 +162,7 @@ ModelToViewHelper::ModelToViewHelper(const SwTextNode &rNode, ExpandMode eMode)
                                 const SwDoc *pDoc = rNode.GetDoc();
                                 aFieldResult.m_sExpand = (eMode & ExpandMode::ReplaceMode)
                                     ? OUString(CHAR_ZWSP)
-                                    : rFootnote.GetViewNumStr(*pDoc);
+                                    : rFootnote.GetViewNumStr(*pDoc, nullptr/*TODO?*/);
                                 aFieldResult.m_eType = FieldResult::FOOTNOTE;
                             }
                             break;
diff --git a/sw/source/filter/html/htmlftn.cxx b/sw/source/filter/html/htmlftn.cxx
index 90f5aae2b9cc..6319ea9663bf 100644
--- a/sw/source/filter/html/htmlftn.cxx
+++ b/sw/source/filter/html/htmlftn.cxx
@@ -293,7 +293,7 @@ Writer& OutHTML_SwFormatFootnote( Writer& rWrt, const SfxPoolItem& rHt )
     rWrt.Strm().WriteCharPtr( sOut.makeStringAndClear().getStr() );
     HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_superscript );
 
-    HTMLOutFuncs::Out_String( rWrt.Strm(), rFormatFootnote.GetViewNumStr(*rWrt.m_pDoc),
+    HTMLOutFuncs::Out_String( rWrt.Strm(), rFormatFootnote.GetViewNumStr(*rWrt.m_pDoc, nullptr),
                                  rHTMLWrt.m_eDestEnc, &rHTMLWrt.m_aNonConvertableCharacters );
     HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_superscript, false );
     HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_anchor, false );
@@ -393,7 +393,7 @@ OUString SwHTMLWriter::GetFootEndNoteSym( const SwFormatFootnote& rFormatFootnot
     OUString sRet;
     if( pInfo )
         sRet = pInfo->GetPrefix();
-    sRet += rFormatFootnote.GetViewNumStr( *m_pDoc );
+    sRet += rFormatFootnote.GetViewNumStr(*m_pDoc, nullptr);
     if( pInfo )
         sRet += pInfo->GetSuffix();
 
commit ed8b552769afb61a72adf5dbe8bad94949c714c7
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Tue Oct 16 13:51:54 2018 +0200
Commit:     Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Tue Oct 16 18:15:49 2018 +0200

    sw_redlinehide_3: add second footnote number
    
    Add a separate footnote number to SwFormatFootnote for the case when
    the layout hides redlines.
    
    If the footnote is in a delete redline, the value will be an arbitrary
    number, let's use the same number as the last visible footnote for
    simplicity.
    
    Change-Id: Ic7fff9d1bb2c90f5ad811b859c6501a193b7ae70

diff --git a/sw/inc/fmtftn.hxx b/sw/inc/fmtftn.hxx
index 1aa2e6f315d9..b6560544b12f 100644
--- a/sw/inc/fmtftn.hxx
+++ b/sw/inc/fmtftn.hxx
@@ -44,6 +44,7 @@ class SW_DLLPUBLIC SwFormatFootnote
     SwTextFootnote* m_pTextAttr;   ///< My TextAttribute.
     OUString m_aNumber;     ///< User-defined 'Number'.
     sal_uInt16 m_nNumber;   ///< automatic sequence number
+    sal_uInt16 m_nNumberRLHidden; ///< automatic sequence number (hidden redlines)
     bool    m_bEndNote;     ///< Is it an End note?
 
     css::uno::WeakReference<css::text::XFootnote> m_wXFootnote;
@@ -67,6 +68,7 @@ public:
 
     const OUString& GetNumStr() const { return m_aNumber; }
     sal_uInt16 GetNumber() const { return m_nNumber; }
+    sal_uInt16 GetNumberRLHidden() const { return m_nNumberRLHidden; }
     bool       IsEndNote() const { return m_bEndNote;}
 
     void SetNumStr( const OUString& rStr ) { m_aNumber = rStr; }
@@ -75,6 +77,7 @@ public:
     void SetNumber( const SwFormatFootnote& rFootnote )
     {
         m_nNumber = rFootnote.m_nNumber;
+        m_nNumberRLHidden = rFootnote.m_nNumberRLHidden;
         m_aNumber = rFootnote.m_aNumber;
     }
 
diff --git a/sw/inc/ftnidx.hxx b/sw/inc/ftnidx.hxx
index 41205a34b540..3dfb118a1f6b 100644
--- a/sw/inc/ftnidx.hxx
+++ b/sw/inc/ftnidx.hxx
@@ -23,6 +23,7 @@
 #include <sal/types.h>
 #include <o3tl/sorted_vector.hxx>
 
+class IDocumentRedlineAccess;
 class SwTextFootnote;
 class SwNodeIndex;
 class SwSectionNode;
@@ -51,7 +52,7 @@ public:
 class SwUpdFootnoteEndNtAtEnd
 {
     std::vector<const SwSectionNode*> aFootnoteSects, aEndSects;
-    std::vector<sal_uInt16> aFootnoteNums, aEndNums;
+    std::vector<std::pair<sal_uInt16, sal_uInt16>> aFootnoteNums, aEndNums;
 
 public:
     SwUpdFootnoteEndNtAtEnd() : aFootnoteSects(), aEndSects() {}
@@ -59,8 +60,11 @@ public:
     static const SwSectionNode* FindSectNdWithEndAttr(
                                             const SwTextFootnote& rTextFootnote );
 
-    sal_uInt16 GetNumber( const SwTextFootnote& rTextFootnote, const SwSectionNode& rNd );
-    sal_uInt16 ChkNumber( const SwTextFootnote& rTextFootnote );
+    std::pair<sal_uInt16, sal_uInt16> GetNumber(
+            IDocumentRedlineAccess const&, const SwTextFootnote& rTextFootnote,
+            const SwSectionNode& rNd);
+    std::pair<sal_uInt16, sal_uInt16> ChkNumber(
+            IDocumentRedlineAccess const&, const SwTextFootnote& rTextFootnote);
 };
 
 #endif // INCLUDED_SW_INC_FTNIDX_HXX
diff --git a/sw/inc/txtftn.hxx b/sw/inc/txtftn.hxx
index 3c830e7ff273..4a3408c5e290 100644
--- a/sw/inc/txtftn.hxx
+++ b/sw/inc/txtftn.hxx
@@ -41,7 +41,7 @@ public:
 
     SwNodeIndex *GetStartNode() const { return m_pStartNode.get(); }
     void SetStartNode( const SwNodeIndex *pNode, bool bDelNodes = true );
-    void SetNumber( const sal_uInt16 nNumber, const OUString &sNumStr );
+    void SetNumber(sal_uInt16 nNumber, sal_uInt16 nNumberRLHidden, const OUString &sNumStr);
     void CopyFootnote(SwTextFootnote & rDest, SwTextNode & rDestNode) const;
 
     // Get and set TextNode pointer.
diff --git a/sw/source/core/doc/docdesc.cxx b/sw/source/core/doc/docdesc.cxx
index d64aeaccebc2..ac172c00a94c 100644
--- a/sw/source/core/doc/docdesc.cxx
+++ b/sw/source/core/doc/docdesc.cxx
@@ -424,7 +424,7 @@ void SwDoc::ChgPageDesc( size_t i, const SwPageDesc &rChged )
         {
             SwTextFootnote *pTextFootnote = rFootnoteIdxs[ nPos ];
             const SwFormatFootnote &rFootnote = pTextFootnote->GetFootnote();
-            pTextFootnote->SetNumber(rFootnote.GetNumber(), rFootnote.GetNumStr());
+            pTextFootnote->SetNumber(rFootnote.GetNumber(), rFootnote.GetNumberRLHidden(), rFootnote.GetNumStr());
         }
     }
 
diff --git a/sw/source/core/doc/docftn.cxx b/sw/source/core/doc/docftn.cxx
index 9a6c558d1c73..d2f1a800bf4d 100644
--- a/sw/source/core/doc/docftn.cxx
+++ b/sw/source/core/doc/docftn.cxx
@@ -198,7 +198,7 @@ void SwEndNoteInfo::SwClientNotify( const SwModify& rModify, const SfxHint& rHin
                 const SwFormatFootnote &rFootnote = pTextFootnote->GetFootnote();
                 if ( rFootnote.IsEndNote() == m_bEndNote )
                 {
-                    pTextFootnote->SetNumber(rFootnote.GetNumber(), rFootnote.GetNumStr());
+                    pTextFootnote->SetNumber(rFootnote.GetNumber(), rFootnote.GetNumberRLHidden(), rFootnote.GetNumStr());
                 }
             }
         }
@@ -306,7 +306,7 @@ void SwDoc::SetFootnoteInfo(const SwFootnoteInfo& rInfo)
                     SwTextFootnote *pTextFootnote = rFootnoteIdxs[ nPos ];
                     const SwFormatFootnote &rFootnote = pTextFootnote->GetFootnote();
                     if ( !rFootnote.IsEndNote() )
-                        pTextFootnote->SetNumber(rFootnote.GetNumber(), rFootnote.GetNumStr());
+                        pTextFootnote->SetNumber(rFootnote.GetNumber(), rFootnote.GetNumberRLHidden(), rFootnote.GetNumStr());
                 }
             }
         }
@@ -376,7 +376,7 @@ void SwDoc::SetEndNoteInfo(const SwEndNoteInfo& rInfo)
                 SwTextFootnote *pTextFootnote = rFootnoteIdxs[ nPos ];
                 const SwFormatFootnote &rFootnote = pTextFootnote->GetFootnote();
                 if ( rFootnote.IsEndNote() )
-                    pTextFootnote->SetNumber(rFootnote.GetNumber(), rFootnote.GetNumStr());
+                    pTextFootnote->SetNumber(rFootnote.GetNumber(), rFootnote.GetNumberRLHidden(), rFootnote.GetNumStr());
             }
         }
     }
@@ -442,7 +442,7 @@ bool SwDoc::SetCurFootnote( const SwPaM& rPam, const OUString& rNumStr,
                     pUndo->GetHistory().Add( *pTextFootnote );
                 }
 
-                pTextFootnote->SetNumber(rFootnote.GetNumber(), rNumStr);
+                pTextFootnote->SetNumber(rFootnote.GetNumber(), rFootnote.GetNumberRLHidden(), rNumStr);
                 if( rFootnote.IsEndNote() != bIsEndNote )
                 {
                     const_cast<SwFormatFootnote&>(rFootnote).SetEndNote( bIsEndNote );
@@ -472,7 +472,7 @@ bool SwDoc::SetCurFootnote( const SwPaM& rPam, const OUString& rNumStr,
                     pUndo->GetHistory().Add( *pTextFootnote );
                 }
 
-                pTextFootnote->SetNumber(rFootnote.GetNumber(), rNumStr);
+                pTextFootnote->SetNumber(rFootnote.GetNumber(), rFootnote.GetNumberRLHidden(), rNumStr);
                 if( rFootnote.IsEndNote() != bIsEndNote )
                 {
                     const_cast<SwFormatFootnote&>(rFootnote).SetEndNote( bIsEndNote );
diff --git a/sw/source/core/doc/ftnidx.cxx b/sw/source/core/doc/ftnidx.cxx
index 5b753c56733c..d4aad90404bc 100644
--- a/sw/source/core/doc/ftnidx.cxx
+++ b/sw/source/core/doc/ftnidx.cxx
@@ -22,6 +22,8 @@
 #include <ftninfo.hxx>
 #include <doc.hxx>
 #include <IDocumentLayoutAccess.hxx>
+#include <IDocumentRedlineAccess.hxx>
+#include <redline.hxx>
 #include <ftnidx.hxx>
 #include <ndtxt.hxx>
 #include <ndindex.hxx>
@@ -29,6 +31,18 @@
 #include <fmtftntx.hxx>
 #include <rootfrm.hxx>
 
+static bool IsFootnoteDeleted(IDocumentRedlineAccess const& rIDRA,
+        SwTextFootnote const& rTextFootnote)
+{
+    SwRedlineTable::size_type tmp;
+    SwPosition const pos(const_cast<SwTextNode&>(rTextFootnote.GetTextNode()),
+            rTextFootnote.GetStart());
+    SwRangeRedline const*const pRedline(rIDRA.GetRedline(pos, &tmp));
+    return (pRedline
+        && pRedline->GetType() == nsRedlineType_t::REDLINE_DELETE
+        && *pRedline->GetPoint() != *pRedline->GetMark());
+}
+
 bool CompareSwFootnoteIdxs::operator()(SwTextFootnote* const& lhs, SwTextFootnote* const& rhs) const
 {
     sal_uLong nIdxLHS = SwTextFootnote_GetIndex( lhs );
@@ -49,6 +63,7 @@ void SwFootnoteIdxs::UpdateFootnote( const SwNodeIndex& rStt )
 
     const SwEndNoteInfo& rEndInfo = pDoc->GetEndNoteInfo();
     const SwFootnoteInfo& rFootnoteInfo = pDoc->GetFootnoteInfo();
+    IDocumentRedlineAccess const& rIDRA(pDoc->getIDocumentRedlineAccess());
 
     // For normal foot notes we treat per-chapter and per-document numbering
     // separately. For Endnotes we only have per-document numbering.
@@ -78,6 +93,7 @@ void SwFootnoteIdxs::UpdateFootnote( const SwNodeIndex& rStt )
 
         size_t nPos = 0;
         size_t nFootnoteNo = 1;
+        size_t nFootnoteNoHidden = 1;
         if( SeekEntry( *pCapStt, &nPos ) && nPos )
         {
             // Step forward until the Index is not the same anymore
@@ -91,7 +107,13 @@ void SwFootnoteIdxs::UpdateFootnote( const SwNodeIndex& rStt )
             return;
 
         if( rOutlNds.empty() )
+        {
             nFootnoteNo = nPos+1;
+            if (nPos)
+            {
+                nFootnoteNoHidden = (*this)[nPos - 1]->GetFootnote().GetNumberRLHidden() + 1;
+            }
+        }
 
         for( ; nPos < size(); ++nPos )
         {
@@ -103,7 +125,15 @@ void SwFootnoteIdxs::UpdateFootnote( const SwNodeIndex& rStt )
             if( rFootnote.GetNumStr().isEmpty() && !rFootnote.IsEndNote() &&
                 !SwUpdFootnoteEndNtAtEnd::FindSectNdWithEndAttr( *pTextFootnote ))
             {
-                pTextFootnote->SetNumber( rFootnoteInfo.nFootnoteOffset + nFootnoteNo++, rFootnote.GetNumStr() );
+                pTextFootnote->SetNumber(
+                    rFootnoteInfo.nFootnoteOffset + nFootnoteNo,
+                    rFootnoteInfo.nFootnoteOffset + nFootnoteNoHidden,
+                    rFootnote.GetNumStr() );
+                ++nFootnoteNo;
+                if (!IsFootnoteDeleted(rIDRA, *pTextFootnote))
+                {
+                    ++nFootnoteNoHidden;
+                }
             }
         }
     }
@@ -116,6 +146,8 @@ void SwFootnoteIdxs::UpdateFootnote( const SwNodeIndex& rStt )
     size_t nPos;
     size_t nFootnoteNo = 1;
     size_t nEndNo = 1;
+    size_t nFootnoteNoHidden = 1;
+    size_t nEndNoHidden = 1;
     sal_uLong nUpdNdIdx = rStt.GetIndex();
     for( nPos = 0; nPos < size(); ++nPos )
     {
@@ -126,12 +158,24 @@ void SwFootnoteIdxs::UpdateFootnote( const SwNodeIndex& rStt )
         const SwFormatFootnote &rFootnote = pTextFootnote->GetFootnote();
         if( rFootnote.GetNumStr().isEmpty() )
         {
-            if( !aNumArr.ChkNumber( *pTextFootnote ) )
+            if (!aNumArr.ChkNumber(rIDRA, *pTextFootnote).first)
             {
                 if( pTextFootnote->GetFootnote().IsEndNote() )
+                {
                     nEndNo++;
+                    if (!IsFootnoteDeleted(rIDRA, *pTextFootnote))
+                    {
+                        ++nEndNoHidden;
+                    }
+                }
                 else
+                {
                     nFootnoteNo++;
+                    if (!IsFootnoteDeleted(rIDRA, *pTextFootnote))
+                    {
+                        ++nFootnoteNoHidden;
+                    }
+                }
             }
         }
     }
@@ -143,15 +187,34 @@ void SwFootnoteIdxs::UpdateFootnote( const SwNodeIndex& rStt )
         const SwFormatFootnote &rFootnote = pTextFootnote->GetFootnote();
         if( rFootnote.GetNumStr().isEmpty() )
         {
-            sal_uInt16 nSectNo = aNumArr.ChkNumber( *pTextFootnote );
-            if( !nSectNo && ( rFootnote.IsEndNote() || !bEndNoteOnly ))
-                nSectNo = rFootnote.IsEndNote()
-                            ? rEndInfo.nFootnoteOffset + nEndNo++
-                            : rFootnoteInfo.nFootnoteOffset + nFootnoteNo++;
+            std::pair<sal_uInt16, sal_uInt16> nSectNo = aNumArr.ChkNumber(rIDRA, *pTextFootnote);
+            if (!nSectNo.first && (rFootnote.IsEndNote() || !bEndNoteOnly))
+            {
+                if (rFootnote.IsEndNote())
+                {
+                    nSectNo.first = rEndInfo.nFootnoteOffset + nEndNo;
+                    ++nEndNo;
+                    nSectNo.second = rEndInfo.nFootnoteOffset + nEndNoHidden;
+                    if (!IsFootnoteDeleted(rIDRA, *pTextFootnote))
+                    {
+                        ++nEndNoHidden;
+                    }
+                }
+                else
+                {
+                    nSectNo.first = rFootnoteInfo.nFootnoteOffset + nFootnoteNo;
+                    ++nFootnoteNo;
+                    nSectNo.second = rFootnoteInfo.nFootnoteOffset + nFootnoteNoHidden;
+                    if (!IsFootnoteDeleted(rIDRA, *pTextFootnote))
+                    {
+                        ++nFootnoteNoHidden;
+                    }
+                }
+            }
 
-            if( nSectNo )
+            if (nSectNo.first)
             {
-                pTextFootnote->SetNumber( nSectNo, rFootnote.GetNumStr() );
+                pTextFootnote->SetNumber(nSectNo.first, nSectNo.second, rFootnote.GetNumStr());
             }
         }
     }
@@ -167,6 +230,7 @@ void SwFootnoteIdxs::UpdateAllFootnote()
     SwTextFootnote* pTextFootnote;
     const SwEndNoteInfo& rEndInfo = pDoc->GetEndNoteInfo();
     const SwFootnoteInfo& rFootnoteInfo = pDoc->GetFootnoteInfo();
+    IDocumentRedlineAccess const& rIDRA(pDoc->getIDocumentRedlineAccess());
 
     SwUpdFootnoteEndNtAtEnd aNumArr;
 
@@ -178,6 +242,7 @@ void SwFootnoteIdxs::UpdateAllFootnote()
     {
         const SwOutlineNodes& rOutlNds = pDoc->GetNodes().GetOutLineNds();
         sal_uInt16 nNo = 1;     // Number for the Footnotes
+        sal_uInt16 nNoNo = 1;
         size_t nFootnoteIdx = 0;     // Index into theFootnoteIdx array
         for( size_t n = 0; n < rOutlNds.size(); ++n )
         {
@@ -195,16 +260,25 @@ void SwFootnoteIdxs::UpdateAllFootnote()
                     if( !rFootnote.IsEndNote() && rFootnote.GetNumStr().isEmpty() &&
                         !SwUpdFootnoteEndNtAtEnd::FindSectNdWithEndAttr( *pTextFootnote ))
                     {
-                        pTextFootnote->SetNumber( rFootnoteInfo.nFootnoteOffset + nNo++, rFootnote.GetNumStr() );
+                        pTextFootnote->SetNumber(
+                            rFootnoteInfo.nFootnoteOffset + nNo,
+                            rFootnoteInfo.nFootnoteOffset + nNoNo,
+                            rFootnote.GetNumStr() );
+                        ++nNo;
+                        if (!IsFootnoteDeleted(rIDRA, *pTextFootnote))
+                        {
+                            ++nNoNo;
+                        }
                     }
                 }
                 if( nFootnoteIdx >= size() )
                     break;          // ok, everything is updated
                 nNo = 1;
+                nNoNo = 1;
             }
         }
 
-        for( nNo = 1; nFootnoteIdx < size(); ++nFootnoteIdx )
+        for (nNo = 1, nNoNo = 1; nFootnoteIdx < size(); ++nFootnoteIdx)
         {
             // Endnotes are per-document
             pTextFootnote = (*this)[ nFootnoteIdx ];
@@ -212,29 +286,59 @@ void SwFootnoteIdxs::UpdateAllFootnote()
             if( !rFootnote.IsEndNote() && rFootnote.GetNumStr().isEmpty() &&
                 !SwUpdFootnoteEndNtAtEnd::FindSectNdWithEndAttr( *pTextFootnote ))
             {
-                pTextFootnote->SetNumber( rFootnoteInfo.nFootnoteOffset + nNo++, rFootnote.GetNumStr() );
+                pTextFootnote->SetNumber(
+                        rFootnoteInfo.nFootnoteOffset + nNo,
+                        rFootnoteInfo.nFootnoteOffset + nNoNo,
+                        rFootnote.GetNumStr() );
+                ++nNo;
+                if (!IsFootnoteDeleted(rIDRA, *pTextFootnote))
+                {
+                    ++nNoNo;
+                }
             }
         }
     }
 
     // We use bool here, so that we also iterate through the Endnotes with a chapter setting.
     const bool bEndNoteOnly = FTNNUM_DOC != rFootnoteInfo.eNum;
-    sal_uInt16 nFootnoteNo = 0, nEndNo = 0;
+    sal_uInt16 nFootnoteNo = 1;
+    sal_uInt16 nEndnoteNo = 1;
+    sal_uInt16 nFootnoteNoHidden = 1;
+    sal_uInt16 nEndnoteNoHidden = 1;
     for( size_t nPos = 0; nPos < size(); ++nPos )
     {
         pTextFootnote = (*this)[ nPos ];
         const SwFormatFootnote &rFootnote = pTextFootnote->GetFootnote();
         if( rFootnote.GetNumStr().isEmpty() )
         {
-            sal_uInt16 nSectNo = aNumArr.ChkNumber( *pTextFootnote );
-            if( !nSectNo && ( rFootnote.IsEndNote() || !bEndNoteOnly ))
-                nSectNo = rFootnote.IsEndNote()
-                                ? rEndInfo.nFootnoteOffset + (++nEndNo)
-                                : rFootnoteInfo.nFootnoteOffset + (++nFootnoteNo);
+            std::pair<sal_uInt16, sal_uInt16> nSectNo = aNumArr.ChkNumber(rIDRA, *pTextFootnote);
+            if (!nSectNo.first && (rFootnote.IsEndNote() || !bEndNoteOnly))
+            {
+                if (rFootnote.IsEndNote())
+                {
+                    nSectNo.first = rEndInfo.nFootnoteOffset + nEndnoteNo;
+                    ++nEndnoteNo;
+                    nSectNo.second = rEndInfo.nFootnoteOffset + nEndnoteNoHidden;
+                    if (!IsFootnoteDeleted(rIDRA, *pTextFootnote))
+                    {
+                        ++nEndnoteNoHidden;
+                    }
+                }
+                else
+                {
+                    nSectNo.first = rFootnoteInfo.nFootnoteOffset + nFootnoteNo;
+                    ++nFootnoteNo;
+                    nSectNo.second = rFootnoteInfo.nFootnoteOffset + nFootnoteNoHidden;
+                    if (!IsFootnoteDeleted(rIDRA, *pTextFootnote))
+                    {
+                        ++nFootnoteNoHidden;
+                    }
+                }
+            }
 
-            if( nSectNo )
+            if (nSectNo.first)
             {
-                pTextFootnote->SetNumber( nSectNo, rFootnote.GetNumStr() );
+                pTextFootnote->SetNumber(nSectNo.first, nSectNo.second, rFootnote.GetNumStr());
             }
         }
     }
@@ -296,12 +400,15 @@ const SwSectionNode* SwUpdFootnoteEndNtAtEnd::FindSectNdWithEndAttr(
     return pNd;
 }
 
-sal_uInt16 SwUpdFootnoteEndNtAtEnd::GetNumber( const SwTextFootnote& rTextFootnote,
+std::pair<sal_uInt16, sal_uInt16> SwUpdFootnoteEndNtAtEnd::GetNumber(
+        IDocumentRedlineAccess const& rIDRA,
+        const SwTextFootnote& rTextFootnote,
                                     const SwSectionNode& rNd )
 {
-    sal_uInt16 nRet = 0, nWh;
+    std::pair<sal_uInt16, sal_uInt16> nRet(0, 0);
+    sal_uInt16 nWh;
     std::vector<const SwSectionNode*>* pArr;
-    std::vector<sal_uInt16> *pNum;
+    std::vector<std::pair<sal_uInt16, sal_uInt16>> *pNum;
     if( rTextFootnote.GetFootnote().IsEndNote() )
     {
         pArr = &aEndSects;
@@ -318,25 +425,36 @@ sal_uInt16 SwUpdFootnoteEndNtAtEnd::GetNumber( const SwTextFootnote& rTextFootno
     for( size_t n = pArr->size(); n; )
         if( (*pArr)[ --n ] == &rNd )
         {
-            nRet = ++((*pNum)[ n ]);
+            nRet.first = ++((*pNum)[ n ].first);
+            nRet.second = ((*pNum)[ n ].second);
+            if (!IsFootnoteDeleted(rIDRA, rTextFootnote))
+            {
+                ++((*pNum)[ n ].second);
+            }
             break;
         }
 
-    if( !nRet )
+    if (!nRet.first)
     {
         pArr->push_back( &rNd );
-        nRet = static_cast<const SwFormatFootnoteEndAtTextEnd&>(rNd.GetSection().GetFormat()->
+        sal_uInt16 const tmp = static_cast<const SwFormatFootnoteEndAtTextEnd&>(
+                rNd.GetSection().GetFormat()->
                                 GetFormatAttr( nWh )).GetOffset();
-        ++nRet;
+        nRet.first = tmp + 1;
+        nRet.second = tmp + 1;
         pNum->push_back( nRet );
     }
     return nRet;
 }
 
-sal_uInt16 SwUpdFootnoteEndNtAtEnd::ChkNumber( const SwTextFootnote& rTextFootnote )
+std::pair<sal_uInt16, sal_uInt16> SwUpdFootnoteEndNtAtEnd::ChkNumber(
+        IDocumentRedlineAccess const& rIDRA,
+        const SwTextFootnote& rTextFootnote)
 {
     const SwSectionNode* pSectNd = FindSectNdWithEndAttr( rTextFootnote );
-    return pSectNd ? GetNumber( rTextFootnote, *pSectNd ) : 0;
+    return pSectNd
+            ? GetNumber(rIDRA, rTextFootnote, *pSectNd)
+            : std::pair<sal_uInt16, sal_uInt16>(0, 0);
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/layout/ftnfrm.cxx b/sw/source/core/layout/ftnfrm.cxx
index de19e6ffec2e..31e56985cb1e 100644
--- a/sw/source/core/layout/ftnfrm.cxx
+++ b/sw/source/core/layout/ftnfrm.cxx
@@ -2372,10 +2372,30 @@ void SwPageFrame::UpdateFootnoteNum()
                     SwTextFootnote* pTextFootnote = pFootnote->GetAttr();
                     if( !pTextFootnote->GetFootnote().IsEndNote() &&
                          pTextFootnote->GetFootnote().GetNumStr().isEmpty() &&
-                         !pFootnote->GetMaster() &&
-                         (pTextFootnote->GetFootnote().GetNumber() != ++nNum) )
+                         !pFootnote->GetMaster())
                     {
-                        pTextFootnote->SetNumber( nNum, OUString() );
+                        // sw_redlinehide: the layout can only keep one number
+                        // up to date; depending on its setting, this is either
+                        // the non-hidden or the hidden number; the other
+                        // number will simply be preserved as-is (so in case
+                        // there are 2 layouts, maybe both can be updated...)
+                        ++nNum;
+                        sal_uInt16 const nOldNum(pTextFootnote->GetFootnote().GetNumber());
+                        sal_uInt16 const nOldNumRLHidden(pTextFootnote->GetFootnote().GetNumberRLHidden());
+                        if (getRootFrame()->IsHideRedlines())
+                        {
+                            if (nNum != nOldNumRLHidden)
+                            {
+                                pTextFootnote->SetNumber(nOldNum, nNum, OUString());
+                            }
+                        }
+                        else
+                        {
+                            if (nNum != nOldNum)
+                            {
+                                pTextFootnote->SetNumber(nNum, nOldNumRLHidden, OUString());
+                            }
+                        }
                     }
                     if ( pFootnote->GetNext() )
                         pFootnote = static_cast<SwFootnoteFrame*>(pFootnote->GetNext());
diff --git a/sw/source/core/txtnode/atrftn.cxx b/sw/source/core/txtnode/atrftn.cxx
index cc0e6f0ea12a..7444b4768b64 100644
--- a/sw/source/core/txtnode/atrftn.cxx
+++ b/sw/source/core/txtnode/atrftn.cxx
@@ -123,6 +123,7 @@ SwFormatFootnote::SwFormatFootnote( bool bEndNote )
     , SwModify(nullptr)
     , m_pTextAttr(nullptr)
     , m_nNumber(0)
+    , m_nNumberRLHidden(0)
     , m_bEndNote(bEndNote)
 {
 }
@@ -131,6 +132,7 @@ bool SwFormatFootnote::operator==( const SfxPoolItem& rAttr ) const
 {
     assert(SfxPoolItem::operator==(rAttr));
     return m_nNumber  == static_cast<const SwFormatFootnote&>(rAttr).m_nNumber &&
+        //FIXME?
            m_aNumber  == static_cast<const SwFormatFootnote&>(rAttr).m_aNumber &&
            m_bEndNote == static_cast<const SwFormatFootnote&>(rAttr).m_bEndNote;
 }
@@ -140,6 +142,7 @@ SfxPoolItem* SwFormatFootnote::Clone( SfxItemPool* ) const
     SwFormatFootnote* pNew  = new SwFormatFootnote;
     pNew->m_aNumber = m_aNumber;
     pNew->m_nNumber = m_nNumber;
+    pNew->m_nNumberRLHidden = m_nNumberRLHidden;
     pNew->m_bEndNote = m_bEndNote;
     return pNew;
 }
@@ -326,7 +329,8 @@ void SwTextFootnote::SetStartNode( const SwNodeIndex *pNewNode, bool bDelNode )
     }
 }
 
-void SwTextFootnote::SetNumber( const sal_uInt16 nNewNum, const OUString &sNumStr )
+void SwTextFootnote::SetNumber(const sal_uInt16 nNewNum,
+        sal_uInt16 const nNumberRLHidden, const OUString &sNumStr)
 {
     SwFormatFootnote& rFootnote = const_cast<SwFormatFootnote&>(GetFootnote());
 
@@ -334,6 +338,7 @@ void SwTextFootnote::SetNumber( const sal_uInt16 nNewNum, const OUString &sNumSt
     if ( sNumStr.isEmpty() )
     {
         rFootnote.m_nNumber = nNewNum;
+        rFootnote.m_nNumberRLHidden = nNumberRLHidden;
     }
 
     OSL_ENSURE( m_pTextNode, "SwTextFootnote: where is my TextNode?" );
diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx
index 447083d83ab6..809801df662c 100644
--- a/sw/source/filter/ww8/ww8par2.cxx
+++ b/sw/source/filter/ww8/ww8par2.cxx
@@ -236,7 +236,7 @@ sal_uInt16 SwWW8ImplReader::End_Footnote()
         // If no automatic numbering use the following char from the main text
         // as the footnote number
         if (!rDesc.mbAutoNum)
-            static_cast<SwTextFootnote*>(pFN)->SetNumber(0, sChar);
+            static_cast<SwTextFootnote*>(pFN)->SetNumber(0, 0, sChar);
 
         /*
             Delete the footnote char from the footnote if its at the beginning
commit 1d318edcc04caebea931d6f26a94ec105ad6992c
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Tue Oct 16 12:03:54 2018 +0200
Commit:     Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Tue Oct 16 12:22:03 2018 +0200

    sw_redlinehide_3: remove number parameter from SwDoc::SetCurFootnote
    
    The number is pretty useless: none of the callers know what the proper
    auto-counted number is going to be, so they either pass in the number
    that the footnote already has, or 0.
    
    It is particularly funny if the SwPaM is actually a range containing
    multiple footnotes; fortunately such a call is apparently not possible
    currently.
    
    Just remove the parameter and use the existing footnote number directly.
    
    Change-Id: I45dee999b8b0b630eff4347a563ccca2869f84cc

diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index b06048cbadbc..70eb61154c26 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -622,9 +622,9 @@ public:
     void SetEndNoteInfo(const SwEndNoteInfo& rInfo);
           SwFootnoteIdxs& GetFootnoteIdxs()       { return *mpFootnoteIdxs; }
     const SwFootnoteIdxs& GetFootnoteIdxs() const { return *mpFootnoteIdxs; }
-    // change footnotes in area
+    /// change footnotes in range
     bool SetCurFootnote( const SwPaM& rPam, const OUString& rNumStr,
-                    sal_uInt16 nNumber, bool bIsEndNote );
+                    bool bIsEndNote );
 
     /** Operations on the content of the document e.g.
         spell-checking/hyphenating/word-counting
diff --git a/sw/source/core/doc/docftn.cxx b/sw/source/core/doc/docftn.cxx
index b2055f8afcdd..9a6c558d1c73 100644
--- a/sw/source/core/doc/docftn.cxx
+++ b/sw/source/core/doc/docftn.cxx
@@ -399,7 +399,7 @@ void SwDoc::SetEndNoteInfo(const SwEndNoteInfo& rInfo)
 }
 
 bool SwDoc::SetCurFootnote( const SwPaM& rPam, const OUString& rNumStr,
-                       sal_uInt16 nNumber, bool bIsEndNote )
+                       bool bIsEndNote)
 {
     SwFootnoteIdxs& rFootnoteArr = GetFootnoteIdxs();
     SwRootFrame* pTmpRoot = getIDocumentLayoutAccess().GetCurrentLayout();
@@ -417,7 +417,7 @@ bool SwDoc::SetCurFootnote( const SwPaM& rPam, const OUString& rNumStr,
     if (GetIDocumentUndoRedo().DoesUndo())
     {
         GetIDocumentUndoRedo().ClearRedo(); // AppendUndo far below, so leave it
-        pUndo.reset(new SwUndoChangeFootNote( rPam, rNumStr, nNumber, bIsEndNote ));
+        pUndo.reset(new SwUndoChangeFootNote( rPam, rNumStr, bIsEndNote ));
     }
 
     SwTextFootnote* pTextFootnote;
@@ -442,7 +442,7 @@ bool SwDoc::SetCurFootnote( const SwPaM& rPam, const OUString& rNumStr,
                     pUndo->GetHistory().Add( *pTextFootnote );
                 }
 
-                pTextFootnote->SetNumber( nNumber, rNumStr );
+                pTextFootnote->SetNumber(rFootnote.GetNumber(), rNumStr);
                 if( rFootnote.IsEndNote() != bIsEndNote )
                 {
                     const_cast<SwFormatFootnote&>(rFootnote).SetEndNote( bIsEndNote );
@@ -472,7 +472,7 @@ bool SwDoc::SetCurFootnote( const SwPaM& rPam, const OUString& rNumStr,
                     pUndo->GetHistory().Add( *pTextFootnote );
                 }
 
-                pTextFootnote->SetNumber( nNumber, rNumStr );
+                pTextFootnote->SetNumber(rFootnote.GetNumber(), rNumStr);
                 if( rFootnote.IsEndNote() != bIsEndNote )
                 {
                     const_cast<SwFormatFootnote&>(rFootnote).SetEndNote( bIsEndNote );
diff --git a/sw/source/core/edit/edattr.cxx b/sw/source/core/edit/edattr.cxx
index 6d9bcab5fcc8..7cd3a4217be7 100644
--- a/sw/source/core/edit/edattr.cxx
+++ b/sw/source/core/edit/edattr.cxx
@@ -419,7 +419,7 @@ bool SwEditShell::SetCurFootnote( const SwFormatFootnote& rFillFootnote )
     for(SwPaM& rCursor : GetCursor()->GetRingContainer())
     {
         bChgd |=
-            mxDoc->SetCurFootnote( rCursor, rFillFootnote.GetNumStr(), rFillFootnote.GetNumber(), rFillFootnote.IsEndNote() );
+            mxDoc->SetCurFootnote(rCursor, rFillFootnote.GetNumStr(), rFillFootnote.IsEndNote());
 
     }
 
diff --git a/sw/source/core/inc/UndoAttribute.hxx b/sw/source/core/inc/UndoAttribute.hxx
index 3197a9107841..ab66b6d234c6 100644
--- a/sw/source/core/inc/UndoAttribute.hxx
+++ b/sw/source/core/inc/UndoAttribute.hxx
@@ -212,12 +212,11 @@ class SwUndoChangeFootNote : public SwUndo, private SwUndRng
 {
     const std::unique_ptr<SwHistory> m_pHistory;
     const OUString m_Text;
-    const sal_uInt16 m_nNumber;
     const bool m_bEndNote;
 
 public:
     SwUndoChangeFootNote( const SwPaM& rRange, const OUString& rText,
-                          sal_uInt16 nNum, bool bIsEndNote );
+                          bool bIsEndNote );
     virtual ~SwUndoChangeFootNote() override;
 
     virtual void UndoImpl( ::sw::UndoRedoContext & ) override;
diff --git a/sw/source/core/inc/rootfrm.hxx b/sw/source/core/inc/rootfrm.hxx
index fa1c88ee79f5..e0dfd88f919b 100644
--- a/sw/source/core/inc/rootfrm.hxx
+++ b/sw/source/core/inc/rootfrm.hxx
@@ -340,8 +340,8 @@ public:
     void ResetTurbo() { mpTurbo = nullptr; }
     const SwContentFrame *GetTurbo() { return mpTurbo; }
 
-    /// Update the footernumbers of all Pages
-    void UpdateFootnoteNums(); // Only for page by page numnbering!
+    /// Update the footnote numbers of all Pages
+    void UpdateFootnoteNums(); // Only for page by page numbering!
 
     /// Remove all footnotes (but no references)
     void RemoveFootnotes( SwPageFrame *pPage = nullptr, bool bPageOnly = false,
diff --git a/sw/source/core/undo/unattr.cxx b/sw/source/core/undo/unattr.cxx
index 514e4aaa1d13..e67d5c1b7ba6 100644
--- a/sw/source/core/undo/unattr.cxx
+++ b/sw/source/core/undo/unattr.cxx
@@ -914,11 +914,10 @@ void SwUndoMoveLeftMargin::RepeatImpl(::sw::RepeatContext & rContext)
 
 SwUndoChangeFootNote::SwUndoChangeFootNote(
     const SwPaM& rRange, const OUString& rText,
-    sal_uInt16 nNum, bool bIsEndNote )
+        bool const bIsEndNote)
     : SwUndo( SwUndoId::CHGFTN, rRange.GetDoc() ), SwUndRng( rRange )
     , m_pHistory( new SwHistory() )
     , m_Text( rText )
-    , m_nNumber( nNum )
     , m_bEndNote( bIsEndNote )
 {
 }
@@ -943,14 +942,14 @@ void SwUndoChangeFootNote::RedoImpl(::sw::UndoRedoContext & rContext)
 {
     SwDoc & rDoc( rContext.GetDoc() );
     SwPaM & rPaM = AddUndoRedoPaM(rContext);
-    rDoc.SetCurFootnote(rPaM, m_Text, m_nNumber, m_bEndNote);
+    rDoc.SetCurFootnote(rPaM, m_Text, m_bEndNote);
     SetPaM(rPaM);
 }
 
 void SwUndoChangeFootNote::RepeatImpl(::sw::RepeatContext & rContext)
 {
     SwDoc & rDoc = rContext.GetDoc();
-    rDoc.SetCurFootnote( rContext.GetRepeatPaM(), m_Text, m_nNumber, m_bEndNote );
+    rDoc.SetCurFootnote(rContext.GetRepeatPaM(), m_Text, m_bEndNote);
 }
 
 SwUndoFootNoteInfo::SwUndoFootNoteInfo( const SwFootnoteInfo &rInfo, const SwDoc* pDoc )
diff --git a/sw/source/core/unocore/unoftn.cxx b/sw/source/core/unocore/unoftn.cxx
index da5f24e9a46c..0a8ae616032e 100644
--- a/sw/source/core/unocore/unoftn.cxx
+++ b/sw/source/core/unocore/unoftn.cxx
@@ -266,7 +266,7 @@ SwXFootnote::setLabel(const OUString& aLabel)
         SwTextNode& rTextNode = const_cast<SwTextNode&>(pTextFootnote->GetTextNode());
 
         SwPaM aPam(rTextNode, pTextFootnote->GetStart());
-        GetDoc()->SetCurFootnote(aPam, newLabel, pFormat->GetNumber(), pFormat->IsEndNote());
+        GetDoc()->SetCurFootnote(aPam, newLabel, pFormat->IsEndNote());
     }
     else if (m_pImpl->m_bIsDescriptor)
     {


More information about the Libreoffice-commits mailing list