diff options
author | Sumit Chauhan <sumitcn25@gmail.com> | 2019-06-23 21:49:12 +0530 |
---|---|---|
committer | Szymon Kłos <szymon.klos@collabora.com> | 2019-06-24 16:18:45 +0200 |
commit | 7eab1e14c5874901757a291609f289911ac64031 (patch) | |
tree | f663fc5f26a84e458b92ec756347c0d9998b6b69 /cui/source | |
parent | 8f7e5883d66afbf6c04ca64cd6ec86d209bd124e (diff) |
Category Target, now available for customization tab
The patch activates the category target i.e one can filter the widgets
on the basis of categories.
The patch also solves
-> GtkMenuToolButton is added in treeview(customization dialog)
-> Code refractor suggested by mike
Change-Id: I0c9f80300cc1202f19e90abe42fb5c5f7ca53915
Reviewed-on: https://gerrit.libreoffice.org/74609
Tested-by: Jenkins
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Diffstat (limited to 'cui/source')
-rw-r--r-- | cui/source/customize/CustomNotebookbarGenerator.cxx | 17 | ||||
-rw-r--r-- | cui/source/customize/SvxNotebookbarConfigPage.cxx | 84 | ||||
-rw-r--r-- | cui/source/inc/SvxNotebookbarConfigPage.hxx | 9 |
3 files changed, 69 insertions, 41 deletions
diff --git a/cui/source/customize/CustomNotebookbarGenerator.cxx b/cui/source/customize/CustomNotebookbarGenerator.cxx index 1d5a2eb83ba7..ceb5bd30fa64 100644 --- a/cui/source/customize/CustomNotebookbarGenerator.cxx +++ b/cui/source/customize/CustomNotebookbarGenerator.cxx @@ -105,27 +105,18 @@ static OUString customizedUIPathBuffer() OUString CustomNotebookbarGenerator::getCustomizedUIPath() { - OUStringBuffer aCustomizedUIPathBuffer; - aCustomizedUIPathBuffer.append(customizedUIPathBuffer()); OUString sAppName, sNotebookbarUIFileName; CustomNotebookbarGenerator::getFileNameAndAppName(sAppName, sNotebookbarUIFileName); - OUString sUIFilePath - = "modules/s" + sAppName.toAsciiLowerCase() + "/ui/" + sNotebookbarUIFileName; - aCustomizedUIPathBuffer.append(sUIFilePath); - OUString sCustomizedUIPath = aCustomizedUIPathBuffer.makeStringAndClear(); - return sCustomizedUIPath; + return customizedUIPathBuffer() + "modules/s" + sAppName.toAsciiLowerCase() + "/ui/" + + sNotebookbarUIFileName; } OUString CustomNotebookbarGenerator::getOriginalUIPath() { - OUStringBuffer aOriginalUIPathBuffer = VclBuilderContainer::getUIRootDir(); OUString sAppName, sNotebookbarUIFileName; CustomNotebookbarGenerator::getFileNameAndAppName(sAppName, sNotebookbarUIFileName); - OUString sUIFilePath - = "modules/s" + sAppName.toAsciiLowerCase() + "/ui/" + sNotebookbarUIFileName; - aOriginalUIPathBuffer.append(sUIFilePath); - OUString sOriginalUIPath = aOriginalUIPathBuffer.makeStringAndClear(); - return sOriginalUIPath; + return VclBuilderContainer::getUIRootDir() + "modules/s" + sAppName.toAsciiLowerCase() + "/ui/" + + sNotebookbarUIFileName; } static OUString getUIDirPath() diff --git a/cui/source/customize/SvxNotebookbarConfigPage.cxx b/cui/source/customize/SvxNotebookbarConfigPage.cxx index 181e1b3d0ee3..c8ad0b8d3c18 100644 --- a/cui/source/customize/SvxNotebookbarConfigPage.cxx +++ b/cui/source/customize/SvxNotebookbarConfigPage.cxx @@ -65,7 +65,20 @@ #include <sfx2/notebookbar/SfxNotebookBar.hxx> #include <unotools/configmgr.hxx> -#define sTopLevelListBoxID "sTopLevelListBoxID" +static bool isCategoryAvailable(OUString& sClassId, OUString& sUIItemID, OUString& sActiveCategory, + bool& isCategory) +{ + if (sClassId == "GtkMenu" && sUIItemID != sActiveCategory) + { + isCategory = false; + return false; + } + else if (sActiveCategory == "All Commands") + return true; + else if (sUIItemID == sActiveCategory) + return true; + return false; +} static OUString charToString(const char* cString) { @@ -156,8 +169,7 @@ void SvxNotebookbarConfigPage::Init() m_xContentsListBox->clear(); m_xSaveInListBox->clear(); CustomNotebookbarGenerator::createCustomizedUIFile(); - OUString sAppName; - OUString sFileName; + OUString sAppName, sFileName; CustomNotebookbarGenerator::getFileNameAndAppName(sAppName, sFileName); OUString sNotebookbarInterface = getFileName(sFileName); @@ -168,8 +180,8 @@ void SvxNotebookbarConfigPage::Init() m_xSaveInListBox->append(sSaveInListBoxID, sScopeName); m_xSaveInListBox->set_active_id(sSaveInListBoxID); - m_xTopLevelListBox->append(sTopLevelListBoxID, "All Commands"); - m_xTopLevelListBox->set_active_id(sTopLevelListBoxID); + m_xTopLevelListBox->append("All Commands", "All Commands"); + m_xTopLevelListBox->set_active_id("All Commands"); SelectElement(); } @@ -200,8 +212,7 @@ short SvxNotebookbarConfigPage::QueryReset() OUString sOriginalUIPath = CustomNotebookbarGenerator::getOriginalUIPath(); OUString sCustomizedUIPath = CustomNotebookbarGenerator::getCustomizedUIPath(); osl::File::copy(sOriginalUIPath, sCustomizedUIPath); - OUString sAppName; - OUString sFileName; + OUString sAppName, sFileName; CustomNotebookbarGenerator::getFileNameAndAppName(sAppName, sFileName); OUString sNotebookbarInterface = getFileName(sFileName); Sequence<OUString> sSequenceEntries; @@ -257,7 +268,9 @@ void SvxNotebookbarConfigPage::getNodeValue(xmlNode* pNodePtr, NotebookbarEntrie } void SvxNotebookbarConfigPage::searchNodeandAttribute(std::vector<NotebookbarEntries>& aEntries, - xmlNode* pNodePtr, int nPos) + std::vector<OUString>& aCategoryList, + OUString& sActiveCategory, xmlNode* pNodePtr, + int nPos, bool isCategory) { pNodePtr = pNodePtr->xmlChildrenNode; while (pNodePtr) @@ -279,30 +292,45 @@ void SvxNotebookbarConfigPage::searchNodeandAttribute(std::vector<NotebookbarEnt xmlFree(UriValue); NotebookbarEntries nodeEntries; + if (sClassId == "sfxlo-PriorityHBox" || sClassId == "GtkMenu") + aCategoryList.push_back(sUIItemID); - if (sClassId == "GtkMenuItem" || sClassId == "GtkToolButton") - { - nodeEntries.sUIItemID = sUIItemID; - nodeEntries.nPos = nPos; - getNodeValue(pNodePtr, nodeEntries); - aEntries.push_back(nodeEntries); - } - else + if (isCategoryAvailable(sClassId, sUIItemID, sActiveCategory, isCategory) + || isCategory) { - nodeEntries.sUIItemID = sUIItemID; - nodeEntries.nPos = nPos; - nodeEntries.sVisibleValue = "Null"; - nodeEntries.sActionName = "Null"; - aEntries.push_back(nodeEntries); + isCategory = true; + if (sClassId == "GtkMenuItem" || sClassId == "GtkToolButton" + || sClassId == "GtkMenuToolButton") + { + nodeEntries.sUIItemID = sUIItemID; + nodeEntries.nPos = nPos; + getNodeValue(pNodePtr, nodeEntries); + aEntries.push_back(nodeEntries); + } + else + { + nodeEntries.sUIItemID = sUIItemID; + nodeEntries.nPos = nPos; + nodeEntries.sVisibleValue = "Null"; + nodeEntries.sActionName = "Null"; + aEntries.push_back(nodeEntries); + } } } - searchNodeandAttribute(aEntries, pNodePtr, nPos + 1); + if (isCategory) + searchNodeandAttribute(aEntries, aCategoryList, sActiveCategory, pNodePtr, nPos + 1, + isCategory); + else + searchNodeandAttribute(aEntries, aCategoryList, sActiveCategory, pNodePtr, nPos, + isCategory); } pNodePtr = pNodePtr->next; } } -void SvxNotebookbarConfigPage::FillFunctionsList(std::vector<NotebookbarEntries>& aEntries) +void SvxNotebookbarConfigPage::FillFunctionsList(std::vector<NotebookbarEntries>& aEntries, + std::vector<OUString>& aCategoryList, + OUString& sActiveCategory) { xmlDocPtr pDoc; xmlNodePtr pNodePtr; @@ -311,7 +339,7 @@ void SvxNotebookbarConfigPage::FillFunctionsList(std::vector<NotebookbarEntries> pDoc = xmlParseFile(cUIFileUIPath); pNodePtr = xmlDocGetRootElement(pDoc); int aRightPos = 0; - searchNodeandAttribute(aEntries, pNodePtr, aRightPos); + searchNodeandAttribute(aEntries, aCategoryList, sActiveCategory, pNodePtr, aRightPos, false); if (pDoc != nullptr) { xmlFreeDoc(pDoc); @@ -323,7 +351,13 @@ void SvxNotebookbarConfigPage::SelectElement() { m_xContentsListBox->clear(); std::vector<NotebookbarEntries> aEntries; - FillFunctionsList(aEntries); + std::vector<OUString> aCategoryList; + OUString sActiveCategory = m_xTopLevelListBox->get_active_id(); + FillFunctionsList(aEntries, aCategoryList, sActiveCategory); + + if (m_xTopLevelListBox->get_count() == 1) + for (unsigned long nIdx = 0; nIdx < aCategoryList.size(); nIdx++) + m_xTopLevelListBox->append(aCategoryList[nIdx], aCategoryList[nIdx]); sal_Int64 nId = 0; for (unsigned long nIdx = 0; nIdx < aEntries.size(); nIdx++) diff --git a/cui/source/inc/SvxNotebookbarConfigPage.hxx b/cui/source/inc/SvxNotebookbarConfigPage.hxx index 97ae96be19c3..8add4f12c56d 100644 --- a/cui/source/inc/SvxNotebookbarConfigPage.hxx +++ b/cui/source/inc/SvxNotebookbarConfigPage.hxx @@ -62,9 +62,12 @@ 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 searchNodeandAttribute(std::vector<NotebookbarEntries>& aEntries, xmlNode* pNodePtr, - int nPos); + static void FillFunctionsList(std::vector<NotebookbarEntries>& aEntries, + std::vector<OUString>& aCategoryList, OUString& sActiveCategory); + static void searchNodeandAttribute(std::vector<NotebookbarEntries>& aEntries, + std::vector<OUString>& aCategoryList, + OUString& sActiveCategory, xmlNode* pNodePtr, int nPos, + bool isCategory); static void getNodeValue(xmlNode* pNodePtr, NotebookbarEntries& aNodeEntries); }; |