summaryrefslogtreecommitdiff
path: root/sw/source/uibase/utlui
diff options
context:
space:
mode:
authorJim Raykowski <raykowj@gmail.com>2023-11-24 00:40:30 -0900
committerJim Raykowski <raykowj@gmail.com>2023-12-13 07:23:38 +0100
commitbb0a2be91930fbae07657f214b53117b9e8cc204 (patch)
tree0eae371abce3d17a88f4b630b364e29e8fc56adf /sw/source/uibase/utlui
parent22727f590cf0e1c5512f60d47824e78a6cce4c32 (diff)
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 <raykowj@gmail.com>
Diffstat (limited to 'sw/source/uibase/utlui')
-rw-r--r--sw/source/uibase/utlui/content.cxx23
-rw-r--r--sw/source/uibase/utlui/navicfg.cxx5
2 files changed, 24 insertions, 4 deletions
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<int>(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<int>(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<SwContentType*>(rId);
else
pCntType = const_cast<SwContentType*>(weld::fromId<SwContent*>(rId)->GetParent());
- pCntType->SetAlphabeticSort(!pCntType->IsAlphabeticSort());
+
+ // toggle and persist alphabetical sort setting
+ const int nShift = static_cast<int>(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<OUString> 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<bool>(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);