From a655117db4b25f8b06a947295058e7257e3b45dd Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 25 Nov 2019 10:20:32 +0000 Subject: tdf#126043 load the xml just once MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I98cfeeeddf2fb2d86259a11368bf3db752f5e556 Reviewed-on: https://gerrit.libreoffice.org/83656 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara (cherry picked from commit 7c949066e6aae6ffe3b88d6500e70cdb7cc03b69) Reviewed-on: https://gerrit.libreoffice.org/83902 --- cui/source/customize/SvxNotebookbarConfigPage.cxx | 28 ++++++++++++----------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'cui/source/customize') diff --git a/cui/source/customize/SvxNotebookbarConfigPage.cxx b/cui/source/customize/SvxNotebookbarConfigPage.cxx index 70c9c5e10510..b74353a95758 100644 --- a/cui/source/customize/SvxNotebookbarConfigPage.cxx +++ b/cui/source/customize/SvxNotebookbarConfigPage.cxx @@ -417,31 +417,28 @@ void SvxNotebookbarConfigPage::searchNodeandAttribute(std::vector& aEntries, +void SvxNotebookbarConfigPage::FillFunctionsList(xmlNodePtr pRootNodePtr, + std::vector& aEntries, std::vector& aCategoryList, OUString& sActiveCategory) { - OString sUIFileUIPath = CustomNotebookbarGenerator::getSystemPath( - CustomNotebookbarGenerator::getCustomizedUIPath()); - xmlDocPtr pDoc = xmlParseFile(sUIFileUIPath.getStr()); - xmlNodePtr pNodePtr = xmlDocGetRootElement(pDoc); - CategoriesEntries aCurItemEntry; - searchNodeandAttribute(aEntries, aCategoryList, sActiveCategory, aCurItemEntry, pNodePtr, + searchNodeandAttribute(aEntries, aCategoryList, sActiveCategory, aCurItemEntry, pRootNodePtr, false); - if (pDoc != nullptr) - { - xmlFreeDoc(pDoc); - } } void SvxNotebookbarConfigPage::SelectElement() { + OString sUIFileUIPath = CustomNotebookbarGenerator::getSystemPath( + CustomNotebookbarGenerator::getCustomizedUIPath()); + xmlDocPtr pDoc = xmlParseFile(sUIFileUIPath.getStr()); + xmlNodePtr pNodePtr = xmlDocGetRootElement(pDoc); + m_xContentsListBox->clear(); std::vector aEntries; std::vector aCategoryList; OUString sActiveCategory = m_xTopLevelListBox->get_active_id(); - FillFunctionsList(aEntries, aCategoryList, sActiveCategory); + FillFunctionsList(pNodePtr, aEntries, aCategoryList, sActiveCategory); if (m_xTopLevelListBox->get_count() == 1) { @@ -463,7 +460,7 @@ void SvxNotebookbarConfigPage::SelectElement() std::vector aGtkEntries; sal_Int32 rPos = 1; sActiveCategory = aEntries[nIdx].sUIItemId.getToken(rPos, ':', rPos); - FillFunctionsList(aGtkEntries, aCategoryList, sActiveCategory); + FillFunctionsList(pNodePtr, aGtkEntries, aCategoryList, sActiveCategory); for (std::size_t Idx = 0; Idx < aGtkEntries.size(); Idx++) aTempEntries.push_back(aGtkEntries[Idx]); aGtkEntries.clear(); @@ -502,6 +499,11 @@ void SvxNotebookbarConfigPage::SelectElement() rTreeView.thaw(); aEntries.clear(); + + if (pDoc != nullptr) + { + xmlFreeDoc(pDoc); + } } SvxNotebookbarEntriesListBox::SvxNotebookbarEntriesListBox(std::unique_ptr xParent, -- cgit