diff options
author | Jim Raykowski <raykowj@gmail.com> | 2021-09-29 20:56:57 -0800 |
---|---|---|
committer | Jim Raykowski <raykowj@gmail.com> | 2021-10-04 08:57:43 +0200 |
commit | c8aa07cae1821560a5bc6f15168f11e2407556c1 (patch) | |
tree | f679cb0b9391c983bb36b25ca6f3390998332c3d | |
parent | 05f92eb1359c399c43d3bcbe8942034408fa23eb (diff) |
tdf#144817 SwNavigator: Section tracking option
Add a check button to the section context menu in the content tree to
turn section tracking on or off.
Change-Id: Ib8c49626f31f41cf85818630d126dee98e1db809
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122844
Tested-by: Jenkins
Reviewed-by: Jim Raykowski <raykowj@gmail.com>
-rw-r--r-- | sw/source/uibase/inc/conttree.hxx | 1 | ||||
-rw-r--r-- | sw/source/uibase/utlui/content.cxx | 27 | ||||
-rw-r--r-- | sw/uiconfig/swriter/ui/navigatorcontextmenu.ui | 8 |
3 files changed, 31 insertions, 5 deletions
diff --git a/sw/source/uibase/inc/conttree.hxx b/sw/source/uibase/inc/conttree.hxx index 9364e36c6181..2e321c9c23ba 100644 --- a/sw/source/uibase/inc/conttree.hxx +++ b/sw/source/uibase/inc/conttree.hxx @@ -113,6 +113,7 @@ class SwContentTree final : public SfxListener sal_uInt32 m_nOutlineTracking = 1; bool m_bTableTracking = true; + bool m_bSectionTracking = true; enum class State { ACTIVE, CONSTANT, HIDDEN } m_eState; diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx index dfb49bc7f6b3..da92775a4ba0 100644 --- a/sw/source/uibase/utlui/content.cxx +++ b/sw/source/uibase/utlui/content.cxx @@ -1598,6 +1598,7 @@ IMPL_LINK(SwContentTree, CommandHdl, const CommandEvent&, rCEvt, bool) bool bRemoveChapterEntries = true; bool bRemoveSendOutlineEntry = true; bool bRemoveTableTracking = true; + bool bRemoveSectionTracking = true; // Edit only if the shown content is coming from the current view. if (State::HIDDEN != m_eState && @@ -1670,8 +1671,10 @@ IMPL_LINK(SwContentTree, CommandHdl, const CommandEvent&, rCEvt, bool) } else if(ContentTypeId::REGION == nContentType) { + xPop->set_active("sectiontracking", m_bSectionTracking); bRemoveSelectEntry = false; bRemoveEditEntry = false; + bRemoveSectionTracking = false; } else { @@ -1702,7 +1705,8 @@ IMPL_LINK(SwContentTree, CommandHdl, const CommandEvent&, rCEvt, bool) m_xTreeView->get_id(*xEntry).toInt64())->GetParent(); if (pType) { - if (ContentTypeId::OUTLINE == pType->GetType()) + const ContentTypeId nContentType = pType->GetType(); + if (ContentTypeId::OUTLINE == nContentType) { bOutline = true; if (State::HIDDEN != m_eState) @@ -1715,15 +1719,20 @@ IMPL_LINK(SwContentTree, CommandHdl, const CommandEvent&, rCEvt, bool) *xPop); } else if (State::HIDDEN != m_eState && - pType->GetType() == ContentTypeId::POSTIT && + nContentType == ContentTypeId::POSTIT && !m_pActiveShell->GetView().GetDocShell()->IsReadOnly() && pType->GetMemberCount() > 0) bRemovePostItEntries = false; - else if (ContentTypeId::TABLE == pType->GetType()) + else if (ContentTypeId::TABLE == nContentType) { xPop->set_active("tabletracking", m_bTableTracking); bRemoveTableTracking = false; } + else if (ContentTypeId::REGION == nContentType) + { + xPop->set_active("sectiontracking", m_bSectionTracking); + bRemoveSectionTracking = false; + } } } @@ -1811,6 +1820,9 @@ IMPL_LINK(SwContentTree, CommandHdl, const CommandEvent&, rCEvt, bool) if (bRemoveTableTracking) xPop->remove("tabletracking"); + if (bRemoveSectionTracking) + xPop->remove("sectiontracking"); + OString sCommand = xPop->popup_at_rect(m_xTreeView.get(), tools::Rectangle(rCEvt.GetMousePosPixel(), Size(1,1))); if (!sCommand.isEmpty()) ExecuteContextMenuAction(sCommand); @@ -3663,8 +3675,8 @@ void SwContentTree::UpdateTracking() return; } // section - if (const SwSection* pSection = m_pActiveShell->GetCurrSection(); pSection && - !(m_bIsRoot && m_nRootType != ContentTypeId::REGION)) + if (const SwSection* pSection = m_pActiveShell->GetCurrSection(); m_bSectionTracking && + pSection && !(m_bIsRoot && m_nRootType != ContentTypeId::REGION)) { lcl_SelectByContentTypeAndName(this, *m_xTreeView, SwResId(STR_CONTENT_TYPE_REGION), pSection->GetSectionName()); @@ -4164,6 +4176,11 @@ void SwContentTree::ExecuteContextMenuAction(const OString& rSelectedPopupEntry) m_bTableTracking = !m_bTableTracking; return; } + if (rSelectedPopupEntry == "sectiontracking") + { + m_bSectionTracking = !m_bSectionTracking; + return; + } std::unique_ptr<weld::TreeIter> xFirst(m_xTreeView->make_iterator()); if (!m_xTreeView->get_selected(xFirst.get())) diff --git a/sw/uiconfig/swriter/ui/navigatorcontextmenu.ui b/sw/uiconfig/swriter/ui/navigatorcontextmenu.ui index c3a5b64bde47..db918b084bb0 100644 --- a/sw/uiconfig/swriter/ui/navigatorcontextmenu.ui +++ b/sw/uiconfig/swriter/ui/navigatorcontextmenu.ui @@ -239,6 +239,14 @@ </object> </child> <child> + <object class="GtkCheckMenuItem" id="sectiontracking"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes" context="navigatorcontextmenu|STR_SECTION_TRACKING">Section Tracking</property> + <property name="use_underline">True</property> + </object> + </child> + <child> <object class="GtkMenuItem" id="2"> <property name="visible">True</property> <property name="can_focus">False</property> |