[Libreoffice-commits] core.git: cui/source sfx2/source
Sumit Chauhan (via logerrit)
logerrit at kemper.freedesktop.org
Mon Jun 24 14:19:45 UTC 2019
cui/source/customize/CustomNotebookbarGenerator.cxx | 17 ----
cui/source/customize/SvxNotebookbarConfigPage.cxx | 84 ++++++++++++++------
cui/source/inc/SvxNotebookbarConfigPage.hxx | 9 +-
sfx2/source/notebookbar/SfxNotebookBar.cxx | 3
4 files changed, 70 insertions(+), 43 deletions(-)
New commits:
commit 7eab1e14c5874901757a291609f289911ac64031
Author: Sumit Chauhan <sumitcn25 at gmail.com>
AuthorDate: Sun Jun 23 21:49:12 2019 +0530
Commit: Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Mon Jun 24 16:18:45 2019 +0200
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 at collabora.com>
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);
};
diff --git a/sfx2/source/notebookbar/SfxNotebookBar.cxx b/sfx2/source/notebookbar/SfxNotebookBar.cxx
index 402874ccb4ef..d1fb95dd730a 100644
--- a/sfx2/source/notebookbar/SfxNotebookBar.cxx
+++ b/sfx2/source/notebookbar/SfxNotebookBar.cxx
@@ -335,10 +335,9 @@ bool SfxNotebookBar::StateMethod(SystemWindow* pSysWindow,
OUStringBuffer aBuf(rUIFile);
aBuf.append( sFile );
- OUString aVal = aBuf.makeStringAndClear();
// setup if necessary
- pSysWindow->SetNotebookBar(aVal, xFrame, bReloadNotebookbar);
+ pSysWindow->SetNotebookBar(aBuf.makeStringAndClear(), xFrame, bReloadNotebookbar);
pNotebookBar = pSysWindow->GetNotebookBar();
pNotebookBar->Show();
pNotebookBar->GetParent()->Resize();
More information about the Libreoffice-commits
mailing list