diff --git a/starmath/inc/ElementsDockingWindow.hxx b/starmath/inc/ElementsDockingWindow.hxx index 70ee4fafddc2..589694779f8d 100644 --- a/starmath/inc/ElementsDockingWindow.hxx +++ b/starmath/inc/ElementsDockingWindow.hxx @@ -40,7 +40,7 @@ class SmElementsControl SmDocShell* mpDocShell; SmFormat maFormat; - size_t mnCurrentSetIndex; + int mnCurrentSetIndex; sal_uInt16 m_nSmSyntaxVersion; bool mbVerticalMode; @@ -50,7 +50,7 @@ class SmElementsControl Link maSelectHdlLink; void addElement(const OUString& aElementVisual, const OUString& aElementSource, const OUString& aHelpText); - void addElements(size_t nCategory); + void addElements(int nCategory); void build(); @@ -66,7 +66,7 @@ public: ~SmElementsControl(); static const std::vector& categories(); - void setElementSetIndex(size_t nSetIndex); + void setElementSetIndex(int nSetIndex); void setVerticalMode(bool bVertical); diff --git a/starmath/source/ElementsDockingWindow.cxx b/starmath/source/ElementsDockingWindow.cxx index 4ded72c08f2c..b946cea28949 100644 --- a/starmath/source/ElementsDockingWindow.cxx +++ b/starmath/source/ElementsDockingWindow.cxx @@ -454,6 +454,7 @@ const std::vector& SmElementsControl::categories() SmElementsControl::SmElementsControl(std::unique_ptr pIconView) : mpDocShell(new SmDocShell(SfxModelFlags::EMBEDDED_OBJECT)) + , mnCurrentSetIndex(-1) , m_nSmSyntaxVersion(SM_MOD()->GetConfig()->GetDefaultSmSyntaxVersion()) , mbVerticalMode(true) , mpIconView(std::move(pIconView)) @@ -540,7 +541,7 @@ OUString SmElementsControl::GetElementHelpText(const OUString& itemId) return weld::fromId(itemId)->maHelpText; } -void SmElementsControl::setElementSetIndex(size_t nSetIndex) +void SmElementsControl::setElementSetIndex(int nSetIndex) { if (mnCurrentSetIndex == nSetIndex) return; @@ -548,13 +549,15 @@ void SmElementsControl::setElementSetIndex(size_t nSetIndex) build(); } -void SmElementsControl::addElements(size_t nCategory) +void SmElementsControl::addElements(int nCategory) { mpIconView->freeze(); mpIconView->clear(); mpIconView->set_item_width(0); maItemDatas.clear(); + assert(nCategory >= 0 && o3tl::make_unsigned(nCategory) < s_a5CategoryDescriptions.size()); + const auto& [aElementsArray, aElementsArraySize] = s_a5CategoryDescriptions[nCategory]; for (size_t i = 0; i < aElementsArraySize; i++)