summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMuhammet Kara <muhammet.kara@pardus.org.tr>2017-08-04 20:03:47 +0300
committerKatarina Behrens <Katarina.Behrens@cib.de>2017-08-09 22:10:47 +0200
commitccbf0168a950cb61d28e7fca47c71f384b3be1d0 (patch)
treee45de4f5eb6b794f0d40d31c6fb4f0e97c5fdc94
parent0bf8a4f768d52e6f5233dd9b352e4485a503c834 (diff)
Add custom widget class: CommandCategoryListBox
It now lists all command categories which can be added based on the current module (writer, calc etc.) This class will be expanded later with macros and styles handling stuff. It will also update the commands listbox when it is added. Change-Id: I4f50408641db067118f63fe0e9a1ee755873412f Reviewed-on: https://gerrit.libreoffice.org/40833 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de>
-rw-r--r--cui/Library_cui.mk1
-rw-r--r--cui/source/customize/CommandCategoryListBox.cxx113
-rw-r--r--cui/source/customize/SvxMenuConfigPage.cxx6
-rw-r--r--cui/source/customize/cfg.cxx2
-rw-r--r--cui/source/inc/CommandCategoryListBox.hxx47
-rw-r--r--cui/source/inc/cfg.hxx2
-rw-r--r--cui/uiconfig/ui/menuassignpage.ui2
7 files changed, 172 insertions, 1 deletions
diff --git a/cui/Library_cui.mk b/cui/Library_cui.mk
index 4efdb440b242..d10011fad7d7 100644
--- a/cui/Library_cui.mk
+++ b/cui/Library_cui.mk
@@ -86,6 +86,7 @@ $(eval $(call gb_Library_add_exception_objects,cui,\
cui/source/customize/acccfg \
cui/source/customize/cfg \
cui/source/customize/cfgutil \
+ cui/source/customize/CommandCategoryListBox \
cui/source/customize/eventdlg \
cui/source/customize/macropg \
cui/source/customize/SvxConfigPageHelper \
diff --git a/cui/source/customize/CommandCategoryListBox.cxx b/cui/source/customize/CommandCategoryListBox.cxx
new file mode 100644
index 000000000000..fac557fcf210
--- /dev/null
+++ b/cui/source/customize/CommandCategoryListBox.cxx
@@ -0,0 +1,113 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "CommandCategoryListBox.hxx"
+
+#include <com/sun/star/frame/XDispatchInformationProvider.hpp>
+#include <com/sun/star/frame/theUICommandDescription.hpp>
+#include <com/sun/star/ui/theUICategoryDescription.hpp>
+#include <vcl/builderfactory.hxx>
+
+#include "dialmgr.hxx"
+#include "strings.hrc"
+#include <o3tl/make_unique.hxx>
+
+CommandCategoryListBox::CommandCategoryListBox(vcl::Window* pParent, WinBits nStyle)
+ : ListBox( pParent, nStyle)
+{
+ SetDropDownLineCount(25);
+}
+
+VCL_BUILDER_FACTORY(CommandCategoryListBox);
+
+void CommandCategoryListBox::Init(
+ const css::uno::Reference< css::uno::XComponentContext >& xContext,
+ const css::uno::Reference< css::frame::XFrame >& xFrame,
+ const OUString& sModuleLongName)
+{
+ SetUpdateMode(false);
+ ClearAll();
+
+ m_xContext = xContext;
+ m_xFrame = xFrame;
+
+ m_sModuleLongName = sModuleLongName;
+ m_xGlobalCategoryInfo = css::ui::theUICategoryDescription::get( m_xContext );
+ m_xModuleCategoryInfo.set(m_xGlobalCategoryInfo->getByName(m_sModuleLongName), css::uno::UNO_QUERY_THROW);
+
+/**** InitModule Start ****/
+ try
+ {
+ css::uno::Reference< css::frame::XDispatchInformationProvider > xProvider(m_xFrame, css::uno::UNO_QUERY_THROW);
+ css::uno::Sequence< sal_Int16 > lGroups = xProvider->getSupportedCommandGroups();
+
+ sal_Int32 nGroupsLength = lGroups.getLength();
+ sal_Int32 nEntryPos;
+
+ if ( nGroupsLength > 0 )
+ {
+ // Add the category of "All commands"
+ nEntryPos = InsertEntry( CuiResId(RID_SVXSTR_ALLFUNCTIONS) );
+ m_aGroupInfo.push_back( o3tl::make_unique<SfxGroupInfo_Impl>( SfxCfgKind::GROUP_ALLFUNCTIONS, 0 ) );
+ SetEntryData( nEntryPos, m_aGroupInfo.back().get() );
+ }
+
+ // Add the actual categories
+ for (sal_Int32 i = 0; i < nGroupsLength; ++i)
+ {
+ sal_Int16& rGroupID = lGroups[i];
+ OUString sGroupID = OUString::number(rGroupID);
+ OUString sGroupName;
+
+ try
+ {
+ m_xModuleCategoryInfo->getByName(sGroupID) >>= sGroupName;
+ if (sGroupName.isEmpty())
+ continue;
+ }
+ catch(const css::container::NoSuchElementException&)
+ {
+ continue;
+ }
+
+ nEntryPos = InsertEntry( sGroupName );
+ m_aGroupInfo.push_back( o3tl::make_unique<SfxGroupInfo_Impl>( SfxCfgKind::GROUP_FUNCTION, rGroupID ) );
+ SetEntryData( nEntryPos, m_aGroupInfo.back().get() );
+ }
+
+
+ }
+ catch(const css::uno::RuntimeException&)
+ { throw; }
+ catch(const css::uno::Exception&)
+ {}
+/**** InitModule End ****/
+
+ SetUpdateMode(true);
+ SelectEntryPos(0);
+}
+
+void CommandCategoryListBox::ClearAll()
+{
+ //TODO: Handle SfxCfgKind::GROUP_SCRIPTCONTAINER when it gets added to Init
+ m_aGroupInfo.clear();
+ Clear();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/cui/source/customize/SvxMenuConfigPage.cxx b/cui/source/customize/SvxMenuConfigPage.cxx
index 36291d5e3cf1..85bf089d9287 100644
--- a/cui/source/customize/SvxMenuConfigPage.cxx
+++ b/cui/source/customize/SvxMenuConfigPage.cxx
@@ -146,6 +146,12 @@ void SvxMenuConfigPage::Init()
m_pTopLevelListBox->SelectEntryPos(0);
m_pTopLevelListBox->GetSelectHdl().Call(*m_pTopLevelListBox);
+
+ m_pCommandCategoryListBox->Clear();
+ m_pCommandCategoryListBox->Init(
+ comphelper::getProcessComponentContext(),
+ m_xFrame,
+ vcl::CommandInfoProvider::GetModuleIdentifier(m_xFrame));
}
void SvxMenuConfigPage::dispose()
diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx
index 9af0621b1b72..1e34c8e98bfa 100644
--- a/cui/source/customize/cfg.cxx
+++ b/cui/source/customize/cfg.cxx
@@ -1134,6 +1134,7 @@ SvxConfigPage::SvxConfigPage(vcl::Window *pParent, const SfxItemSet& rSet)
, m_pSelectorDlg(nullptr)
{
get(m_pTopLevelListBox, "toplevellist");
+ get(m_pCommandCategoryListBox, "commandcategorylist");
get(m_pContents, "contents");
get(m_pMoveUpButton, "up");
get(m_pMoveDownButton, "down");
@@ -1160,6 +1161,7 @@ SvxConfigPage::~SvxConfigPage()
void SvxConfigPage::dispose()
{
m_pTopLevelListBox.clear();
+ m_pCommandCategoryListBox.clear();
m_pContents.clear();
m_pEntries.clear();
m_pFunctions.clear();
diff --git a/cui/source/inc/CommandCategoryListBox.hxx b/cui/source/inc/CommandCategoryListBox.hxx
new file mode 100644
index 000000000000..19138b6ceb77
--- /dev/null
+++ b/cui/source/inc/CommandCategoryListBox.hxx
@@ -0,0 +1,47 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CUI_SOURCE_INC_COMMANDCATEGORYLISTBOX_HXX
+#define INCLUDED_CUI_SOURCE_INC_COMMANDCATEGORYLISTBOX_HXX
+
+#include <vcl/lstbox.hxx>
+#include "cfgutil.hxx"
+
+class CommandCategoryListBox : public ListBox
+{
+ SfxGroupInfoArr_Impl m_aGroupInfo;
+ OUString m_sModuleLongName;
+ css::uno::Reference< css::uno::XComponentContext > m_xContext;
+ css::uno::Reference< css::frame::XFrame > m_xFrame;
+ css::uno::Reference< css::container::XNameAccess > m_xGlobalCategoryInfo;
+ css::uno::Reference< css::container::XNameAccess > m_xModuleCategoryInfo;
+
+public:
+ CommandCategoryListBox( vcl::Window* pParent, WinBits nBits = WB_BORDER | WB_DROPDOWN );
+
+ void Init(
+ const css::uno::Reference< css::uno::XComponentContext >& xContext,
+ const css::uno::Reference< css::frame::XFrame >& xFrame,
+ const OUString& sModuleLongName);
+
+ void ClearAll();
+};
+
+#endif // INCLUDED_CUI_SOURCE_INC_COMMANDCATEGORYLISTBOX_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/cui/source/inc/cfg.hxx b/cui/source/inc/cfg.hxx
index f19a4f817fc3..6027f971a56b 100644
--- a/cui/source/inc/cfg.hxx
+++ b/cui/source/inc/cfg.hxx
@@ -54,6 +54,7 @@
#include <vcl/msgbox.hxx>
#include "cfgutil.hxx"
+#include "CommandCategoryListBox.hxx"
static const char ITEM_DESCRIPTOR_COMMANDURL[] = "CommandURL";
static const char ITEM_DESCRIPTOR_CONTAINER[] = "ItemDescriptorContainer";
@@ -384,6 +385,7 @@ protected:
// the top section of the tab page where top level menus and toolbars
// are displayed in a listbox
VclPtr<ListBox> m_pTopLevelListBox;
+ VclPtr<CommandCategoryListBox> m_pCommandCategoryListBox;
// the contents section where the contents of the selected
// menu or toolbar are displayed
diff --git a/cui/uiconfig/ui/menuassignpage.ui b/cui/uiconfig/ui/menuassignpage.ui
index 4e46e29e8690..f9cac5ae58dc 100644
--- a/cui/uiconfig/ui/menuassignpage.ui
+++ b/cui/uiconfig/ui/menuassignpage.ui
@@ -537,7 +537,7 @@
</packing>
</child>
<child>
- <object class="GtkComboBoxText" id="toplevellist1">
+ <object class="cuilo-CommandCategoryListBox" id="commandcategorylist">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_bottom">5</property>