cui/source/customize/SvxNotebookbarConfigPage.cxx | 28 +++++++++++----------- cui/source/inc/SvxNotebookbarConfigPage.hxx | 3 +- 2 files changed, 17 insertions(+), 14 deletions(-)
New commits: commit 7c949066e6aae6ffe3b88d6500e70cdb7cc03b69 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Mon Nov 25 10:20:32 2019 +0000 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Mon Nov 25 16:13:27 2019 +0100 tdf#126043 load the xml just once Change-Id: I98cfeeeddf2fb2d86259a11368bf3db752f5e556 Reviewed-on: https://gerrit.libreoffice.org/83656 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> diff --git a/cui/source/customize/SvxNotebookbarConfigPage.cxx b/cui/source/customize/SvxNotebookbarConfigPage.cxx index cd654fa717c8..fc54f4628705 100644 --- a/cui/source/customize/SvxNotebookbarConfigPage.cxx +++ b/cui/source/customize/SvxNotebookbarConfigPage.cxx @@ -431,31 +431,28 @@ void SvxNotebookbarConfigPage::searchNodeandAttribute(std::vector<NotebookbarEnt } } -void SvxNotebookbarConfigPage::FillFunctionsList(std::vector<NotebookbarEntries>& aEntries, +void SvxNotebookbarConfigPage::FillFunctionsList(xmlNodePtr pRootNodePtr, + std::vector<NotebookbarEntries>& aEntries, std::vector<CategoriesEntries>& 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<NotebookbarEntries> aEntries; std::vector<CategoriesEntries> aCategoryList; OUString sActiveCategory = m_xTopLevelListBox->get_active_id(); - FillFunctionsList(aEntries, aCategoryList, sActiveCategory); + FillFunctionsList(pNodePtr, aEntries, aCategoryList, sActiveCategory); if (m_xTopLevelListBox->get_count() == 1) { @@ -477,7 +474,7 @@ void SvxNotebookbarConfigPage::SelectElement() std::vector<NotebookbarEntries> 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(); @@ -510,6 +507,11 @@ void SvxNotebookbarConfigPage::SelectElement() ++nId; } aEntries.clear(); + + if (pDoc != nullptr) + { + xmlFreeDoc(pDoc); + } } SvxNotebookbarEntriesListBox::SvxNotebookbarEntriesListBox(std::unique_ptr<weld::TreeView> xParent, diff --git a/cui/source/inc/SvxNotebookbarConfigPage.hxx b/cui/source/inc/SvxNotebookbarConfigPage.hxx index 7793d6e6415b..3c657db3ca84 100644 --- a/cui/source/inc/SvxNotebookbarConfigPage.hxx +++ b/cui/source/inc/SvxNotebookbarConfigPage.hxx @@ -60,7 +60,8 @@ public: SaveInData* CreateSaveInData(const css::uno::Reference<css::ui::XUIConfigurationManager>&, const css::uno::Reference<css::ui::XUIConfigurationManager>&, const OUString& aModuleId, bool docConfig) override; - static void FillFunctionsList(std::vector<NotebookbarEntries>& aEntries, + static void FillFunctionsList(xmlNodePtr pRootNodePtr, + std::vector<NotebookbarEntries>& aEntries, std::vector<CategoriesEntries>& aCategoryList, OUString& sActiveCategory); static void searchNodeandAttribute(std::vector<NotebookbarEntries>& aEntries, _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits