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

Jim Raykowski (via logerrit) logerrit at kemper.freedesktop.org
Wed Oct 6 06:04:05 UTC 2021


 sw/inc/strings.hrc                 |    1 
 sw/source/uibase/inc/content.hxx   |    6 ++--
 sw/source/uibase/utlui/content.cxx |   53 ++++++++++++++++++++++++++++++++-----
 3 files changed, 50 insertions(+), 10 deletions(-)

New commits:
commit cca6092c43e6f5ff56251b2fd43e7530b99358e3
Author:     Jim Raykowski <raykowj at gmail.com>
AuthorDate: Mon Oct 4 18:57:55 2021 -0800
Commit:     Jim Raykowski <raykowj at gmail.com>
CommitDate: Wed Oct 6 08:03:30 2021 +0200

    tdf#144788 SwNavigator: Group footnotes and endnotes separately
    
    This is a follow-up patch to separately group footnotes and endnotes
    under the Footnotes and Endnotes category. A separator line is shown to
    distinguish between footnote and endnote entries. Entries above the
    line are footnotes, entries below are endnotes. A tool tip is also
    displayed to distinguish between them.
    
    Change-Id: I2c4c3ab074da3bd6ba60220f8e7bcc60125bf81f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123124
    Tested-by: Jenkins
    Reviewed-by: Jim Raykowski <raykowj at gmail.com>

diff --git a/sw/inc/strings.hrc b/sw/inc/strings.hrc
index 395cfc63bd53..baf845d9a150 100644
--- a/sw/inc/strings.hrc
+++ b/sw/inc/strings.hrc
@@ -404,6 +404,7 @@
 #define STR_CONTENT_TYPE_SINGLE_FOOTNOTE        NC_("STR_CONTENT_TYPE_SINGLE_FOOTNOTE", "Footnote or Endnote")
 #define STR_CONTENT_FOOTNOTE                    NC_("STR_CONTENT_FOOTNOTE", "Footnote")
 #define STR_CONTENT_ENDNOTE                     NC_("STR_CONTENT_ENDNOTE", "Endnote")
+#define STR_FOOTNOTE_ENDNOTE_SEPARATOR_TIP      NC_("STR_FOOTNOTE_ENDNOTE_SEPARATOR_TIP", "Foonotes are listed above this line and Endnotes are listed below")
 #define STR_DEFINE_NUMBERFORMAT                 NC_("STR_DEFINE_NUMBERFORMAT", "Additional formats...")
 #define RID_STR_SYSTEM                          NC_("RID_STR_SYSTEM", "[System]")
 #define STR_MULT_INTERACT_HYPH_WARN             NC_("STR_MULT_INTERACT_HYPH_WARN", "The interactive hyphenation is already active\nin a different document")
diff --git a/sw/source/uibase/inc/content.hxx b/sw/source/uibase/inc/content.hxx
index 195dfd5ff6f3..38d2d9cdbf1c 100644
--- a/sw/source/uibase/inc/content.hxx
+++ b/sw/source/uibase/inc/content.hxx
@@ -110,9 +110,9 @@ class SwTextFootnoteContent final : public SwContent
     const SwTextFootnote* m_pTextFootnote;
 public:
     SwTextFootnoteContent(const SwContentType* pCnt,
-                       const OUString& rName,
-                       const SwTextFootnote* pTextFootnote,
-                       tools::Long nYPos)
+                          const OUString& rName,
+                          const SwTextFootnote* pTextFootnote,
+                          tools::Long nYPos)
         : SwContent(pCnt, rName, nYPos),
           m_pTextFootnote(pTextFootnote)
     {}
diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx
index e26179b42348..fb7aab99847d 100644
--- a/sw/source/uibase/utlui/content.cxx
+++ b/sw/source/uibase/utlui/content.cxx
@@ -864,6 +864,21 @@ void SwContentType::FillMemberList(bool* pbLevelOrVisibilityChanged)
         case ContentTypeId::FOOTNOTE:
         {
             const SwFootnoteIdxs& rFootnoteIdxs = m_pWrtShell->GetDoc()->GetFootnoteIdxs();
+            size_t nFootnoteCount = 0;
+            for (SwTextFootnote* pTextFootnote : rFootnoteIdxs)
+                if (!pTextFootnote->GetFootnote().IsEndNote())
+                    ++nFootnoteCount;
+            // insert a separator bar between footnote and endnote entries
+            if (rFootnoteIdxs.size())
+            {
+
+                std::unique_ptr<SwTextFootnoteContent> pCnt(new SwTextFootnoteContent(
+                                                            this, "-------------------------------",
+                                                            nullptr, nFootnoteCount + 1));
+                pCnt->SetInvisible();
+                m_pMember->insert(std::move(pCnt));
+            }
+            tools::Long nPos = 0, nInsertPos = 0;
             for (SwTextFootnote* pTextFootnote : rFootnoteIdxs)
             {
                 const SwFormatFootnote& rFormatFootnote = pTextFootnote->GetFootnote();
@@ -871,9 +886,13 @@ void SwContentType::FillMemberList(bool* pbLevelOrVisibilityChanged)
                         rFormatFootnote.GetViewNumStr(*m_pWrtShell->GetDoc(),
                                                       m_pWrtShell->GetLayout(), true) + " " +
                         rFormatFootnote.GetFootnoteText(*m_pWrtShell->GetLayout());
+                if (rFormatFootnote.IsEndNote())
+                    nInsertPos = nPos + nFootnoteCount + 2;
+                else
+                    nInsertPos = ++nPos;
                 std::unique_ptr<SwTextFootnoteContent> pCnt(new SwTextFootnoteContent(
                                                                 this, sText, pTextFootnote,
-                                                                rFormatFootnote.GetNumber()));
+                                                                nInsertPos));
                 if (!pTextFootnote->GetTextNode().getLayoutFrame(m_pWrtShell->GetLayout()))
                     pCnt->SetInvisible();
                 m_pMember->insert(std::move(pCnt));
@@ -1627,6 +1646,14 @@ IMPL_LINK(SwContentTree, CommandHdl, const CommandEvent&, rCEvt, bool)
                 ContentTypeId::INDEX == nContentType ||
                 ContentTypeId::DRAWOBJECT == nContentType);
 
+        if (ContentTypeId::FOOTNOTE == nContentType)
+        {
+            void* pUserData = reinterpret_cast<void*>(m_xTreeView->get_id(*xEntry).toInt64());
+            const SwTextFootnote* pFootnote =
+                    static_cast<const SwTextFootnoteContent*>(pUserData)->GetTextFootnote();
+            if (!pFootnote)
+                xPop->remove(OString::number(900)); // go to
+        }
         if(ContentTypeId::OUTLINE == nContentType)
         {
             bOutline = true;
@@ -4143,10 +4170,15 @@ IMPL_LINK(SwContentTree, QueryTooltipHdl, const weld::TreeIter&, rEntry, OUStrin
             }
             break;
             case ContentTypeId::FOOTNOTE:
+            {
                 assert(dynamic_cast<SwTextFootnoteContent*>(static_cast<SwTypeNumber*>(pUserData)));
-                sEntry = static_cast<SwTextFootnoteContent*>(pUserData)->GetTextFootnote()->
-                        GetFootnote().IsEndNote() ? SwResId(STR_CONTENT_ENDNOTE) :
-                                                    SwResId(STR_CONTENT_FOOTNOTE);
+                const SwTextFootnote* pFootnote =
+                        static_cast<const SwTextFootnoteContent*>(pUserData)->GetTextFootnote();
+                if (!pFootnote)
+                    return SwResId(STR_FOOTNOTE_ENDNOTE_SEPARATOR_TIP);
+                sEntry = pFootnote->GetFootnote().IsEndNote() ? SwResId(STR_CONTENT_ENDNOTE) :
+                                                                SwResId(STR_CONTENT_FOOTNOTE);
+            }
             break;
             default: break;
         }
@@ -4159,7 +4191,9 @@ IMPL_LINK(SwContentTree, QueryTooltipHdl, const weld::TreeIter&, rEntry, OUStrin
     }
     else
     {
-        const size_t nMemberCount = static_cast<SwContentType*>(pUserData)->GetMemberCount();
+        size_t nMemberCount = static_cast<SwContentType*>(pUserData)->GetMemberCount();
+        if (nMemberCount && nType == ContentTypeId::FOOTNOTE)
+            --nMemberCount; // account for horizontal footnote endnote separator entry
         sEntry = OUString::number(nMemberCount) + " " +
             (nMemberCount == 1
                     ? static_cast<SwContentType*>(pUserData)->GetSingleName()
@@ -4886,8 +4920,13 @@ void SwContentTree::GotoContent(const SwContent* pCnt)
         }
         break;
         case ContentTypeId::FOOTNOTE:
-            m_pActiveShell->GotoFootnoteAnchor(
-                        *static_cast<const SwTextFootnoteContent*>(pCnt)->GetTextFootnote());
+        {
+            const SwTextFootnote* pFootnote =
+                    static_cast<const SwTextFootnoteContent*>(pCnt)->GetTextFootnote();
+            if (!pFootnote)
+                return;
+            m_pActiveShell->GotoFootnoteAnchor(*pFootnote);
+        }
         break;
         default: break;
     }


More information about the Libreoffice-commits mailing list