diff options
author | Jim Raykowski <raykowj@gmail.com> | 2021-10-04 18:57:55 -0800 |
---|---|---|
committer | Jim Raykowski <raykowj@gmail.com> | 2021-10-06 08:03:30 +0200 |
commit | cca6092c43e6f5ff56251b2fd43e7530b99358e3 (patch) | |
tree | fdfd722bf569a2fa8e5e71c6863bea14cd9b3cf4 /sw | |
parent | cf739db1d6261c43b5b28c6795a4b5b30156478f (diff) |
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@gmail.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/strings.hrc | 1 | ||||
-rw-r--r-- | sw/source/uibase/inc/content.hxx | 6 | ||||
-rw-r--r-- | sw/source/uibase/utlui/content.cxx | 53 |
3 files changed, 50 insertions, 10 deletions
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; } |