From bb0a2be91930fbae07657f214b53117b9e8cc204 Mon Sep 17 00:00:00 2001 From: Jim Raykowski Date: Fri, 24 Nov 2023 00:40:30 -0900 Subject: tdf#158276 tdf#86395 Make alphabetical sort setting persist by using a bitwise storage approach inspired by the ActiveBlock setting where each content type corresponds to one bit position of the stored integer, e.g., bookmarks content type corresponds to bit 5. Change-Id: I50de26e44a8d2afb917f3a651eef9a8f704b751f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159916 Tested-by: Jenkins Reviewed-by: Jim Raykowski --- sw/source/uibase/utlui/content.cxx | 23 ++++++++++++++++++++--- sw/source/uibase/utlui/navicfg.cxx | 5 ++++- 2 files changed, 24 insertions(+), 4 deletions(-) (limited to 'sw/source/uibase/utlui') diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx index 8d46ef52303a..72fd76cbe1ce 100644 --- a/sw/source/uibase/utlui/content.cxx +++ b/sw/source/uibase/utlui/content.cxx @@ -431,6 +431,13 @@ SwContentType::SwContentType(SwWrtShell* pShell, ContentTypeId nType, sal_uInt8 break; default: break; } + + const int nShift = static_cast(m_nContentType); + assert(nShift > -1); + const sal_Int32 nMask = 1 << nShift; + const sal_Int32 nBlock = SW_MOD()->GetNavigationConfig()->GetSortAlphabeticallyBlock(); + m_bAlphabeticSort = nBlock & nMask; + FillMemberList(); } @@ -1739,10 +1746,12 @@ IMPL_LINK(SwContentTree, CommandHdl, const CommandEvent&, rCEvt, bool) const ContentTypeId nContentType = pType->GetType(); if (nContentType != ContentTypeId::FOOTNOTE && nContentType != ContentTypeId::ENDNOTE - && nContentType != ContentTypeId::POSTIT) + && nContentType != ContentTypeId::POSTIT && nContentType != ContentTypeId::UNKNOWN) { bRemoveSortEntry = false; - xPop->set_active("sort", pType->IsAlphabeticSort()); + const sal_Int32 nMask = 1 << static_cast(nContentType); + sal_uInt64 nSortAlphabeticallyBlock = m_pConfig->GetSortAlphabeticallyBlock(); + xPop->set_active("sort", nSortAlphabeticallyBlock & nMask); } OUString aIdent; @@ -4960,7 +4969,15 @@ void SwContentTree::ExecuteContextMenuAction(const OUString& rSelectedPopupEntry pCntType = weld::fromId(rId); else pCntType = const_cast(weld::fromId(rId)->GetParent()); - pCntType->SetAlphabeticSort(!pCntType->IsAlphabeticSort()); + + // toggle and persist alphabetical sort setting + const int nShift = static_cast(pCntType->GetType()); + assert(nShift > -1); + const sal_Int32 nMask = 1 << nShift; + const sal_Int32 nBlock = m_pConfig->GetSortAlphabeticallyBlock(); + pCntType->SetAlphabeticSort(~nBlock & nMask); + m_pConfig->SetSortAlphabeticallyBlock(nBlock ^ nMask); + pCntType->FillMemberList(); Display(true); return; diff --git a/sw/source/uibase/utlui/navicfg.cxx b/sw/source/uibase/utlui/navicfg.cxx index 0170a8f68a97..dfda8827292f 100644 --- a/sw/source/uibase/utlui/navicfg.cxx +++ b/sw/source/uibase/utlui/navicfg.cxx @@ -74,7 +74,8 @@ Sequence SwNavigationConfig::GetPropertyNames() OUString("FieldTracking"), OUString("FootnoteTracking"), OUString("EndnoteTracking"), - OUString("NavigateOnSelect")}; + OUString("NavigateOnSelect"), + OUString("SortAlphabeticallyBlock")}; } SwNavigationConfig::SwNavigationConfig() : @@ -146,6 +147,7 @@ void SwNavigationConfig::Load() break; } case 22: m_bIsNavigateOnSelect = *o3tl::doAccess(pValues[nProp]); break; + case 23: pValues[nProp] >>= m_nSortAlphabeticallyBlock; break; } } } @@ -180,6 +182,7 @@ void SwNavigationConfig::ImplCommit() break; } case 22: pValues[nProp] <<= m_bIsNavigateOnSelect; break; + case 23: pValues[nProp] <<= m_nSortAlphabeticallyBlock; break; } } PutProperties(aNames, aValues); -- cgit