summaryrefslogtreecommitdiffstats
path: root/cui/source/customize
diff options
context:
space:
mode:
Diffstat (limited to 'cui/source/customize')
-rw-r--r--cui/source/customize/CommandCategoryListBox.cxx45
-rw-r--r--cui/source/customize/CustomNotebookbarGenerator.cxx30
-rw-r--r--cui/source/customize/SvxConfigPageHelper.cxx10
-rw-r--r--cui/source/customize/SvxMenuConfigPage.cxx34
-rw-r--r--cui/source/customize/SvxNotebookbarConfigPage.cxx65
-rw-r--r--cui/source/customize/SvxToolbarConfigPage.cxx86
-rw-r--r--cui/source/customize/acccfg.cxx82
-rw-r--r--cui/source/customize/cfg.cxx141
-rw-r--r--cui/source/customize/cfgutil.cxx274
-rw-r--r--cui/source/customize/eventdlg.cxx3
-rw-r--r--cui/source/customize/macropg.cxx185
-rw-r--r--cui/source/customize/macropg_impl.hxx3
12 files changed, 604 insertions, 354 deletions
diff --git a/cui/source/customize/CommandCategoryListBox.cxx b/cui/source/customize/CommandCategoryListBox.cxx
index c5bc7da17ca3..f7f3295a921d 100644
--- a/cui/source/customize/CommandCategoryListBox.cxx
+++ b/cui/source/customize/CommandCategoryListBox.cxx
@@ -35,7 +35,7 @@
// include search util
#include <com/sun/star/util/SearchFlags.hpp>
#include <com/sun/star/util/SearchAlgorithms2.hpp>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <unotools/textsearch.hxx>
#include <dialmgr.hxx>
@@ -134,9 +134,8 @@ void CommandCategoryListBox::Init(const css::uno::Reference<css::uno::XComponent
// Add the category of "All commands"
m_aGroupInfo.push_back(
std::make_unique<SfxGroupInfo_Impl>(SfxCfgKind::GROUP_ALLFUNCTIONS, 0));
- m_xControl->append(
- OUString::number(reinterpret_cast<sal_Int64>(m_aGroupInfo.back().get())),
- CuiResId(RID_CUISTR_ALLFUNCTIONS));
+ m_xControl->append(weld::toId(m_aGroupInfo.back().get()),
+ CuiResId(RID_CUISTR_ALLFUNCTIONS));
}
// Separate the "All commands"category from the actual categories
@@ -181,9 +180,7 @@ void CommandCategoryListBox::Init(const css::uno::Reference<css::uno::XComponent
sal_Int16 nGroupID = a.second;
m_aGroupInfo.push_back(
std::make_unique<SfxGroupInfo_Impl>(SfxCfgKind::GROUP_FUNCTION, nGroupID));
- m_xControl->append(
- OUString::number(reinterpret_cast<sal_Int64>(m_aGroupInfo.back().get())),
- rGroupName);
+ m_xControl->append(weld::toId(m_aGroupInfo.back().get()), rGroupName);
}
// Separate regular commands from styles and macros
@@ -192,14 +189,13 @@ void CommandCategoryListBox::Init(const css::uno::Reference<css::uno::XComponent
// Add macros category
m_aGroupInfo.push_back(
std::make_unique<SfxGroupInfo_Impl>(SfxCfgKind::GROUP_SCRIPTCONTAINER, 0, nullptr));
- m_xControl->append(OUString::number(reinterpret_cast<sal_Int64>(m_aGroupInfo.back().get())),
- CuiResId(RID_CUISTR_MACROS));
+ m_xControl->append(weld::toId(m_aGroupInfo.back().get()), CuiResId(RID_CUISTR_MACROS));
// Add styles category
//TODO: last param should contain user data?
m_aGroupInfo.push_back(
std::make_unique<SfxGroupInfo_Impl>(SfxCfgKind::GROUP_STYLES, 0, nullptr));
- m_xControl->append(OUString::number(reinterpret_cast<sal_Int64>(m_aGroupInfo.back().get())),
+ m_xControl->append(weld::toId(m_aGroupInfo.back().get()),
CuiResId(RID_CUISTR_GROUP_STYLES));
}
catch (const css::uno::RuntimeException&)
@@ -260,9 +256,7 @@ void CommandCategoryListBox::FillFunctionsList(
pGrpInfo->sCommand = rInfo.Command;
pGrpInfo->sLabel = sUIName;
pGrpInfo->sTooltip = sTooltipLabel;
- pFunctionListBox->append(
- OUString::number(reinterpret_cast<sal_Int64>(m_aGroupInfo.back().get())), sUIName,
- xImage);
+ pFunctionListBox->append(weld::toId(m_aGroupInfo.back().get()), sUIName, xImage);
}
}
@@ -301,8 +295,7 @@ void CommandCategoryListBox::categorySelected(CuiConfigFunctionListBox* pFunctio
const OUString& filterTerm,
SaveInData* pCurrentSaveInData)
{
- SfxGroupInfo_Impl* pInfo
- = reinterpret_cast<SfxGroupInfo_Impl*>(m_xControl->get_active_id().toInt64());
+ SfxGroupInfo_Impl* pInfo = weld::fromId<SfxGroupInfo_Impl*>(m_xControl->get_active_id());
std::vector<std::unique_ptr<weld::TreeIter>> aNodesToExpand;
pFunctionListBox->freeze();
pFunctionListBox->ClearAll();
@@ -318,7 +311,7 @@ void CommandCategoryListBox::categorySelected(CuiConfigFunctionListBox* pFunctio
for (sal_Int32 nCurPos = 0; nCurPos < nEntryCount; ++nCurPos)
{
SfxGroupInfo_Impl* pCurrentInfo
- = reinterpret_cast<SfxGroupInfo_Impl*>(m_xControl->get_id(nCurPos).toInt64());
+ = weld::fromId<SfxGroupInfo_Impl*>(m_xControl->get_id(nCurPos));
if (!pCurrentInfo) //separator
continue;
@@ -411,9 +404,7 @@ void CommandCategoryListBox::categorySelected(CuiConfigFunctionListBox* pFunctio
m_aGroupInfo.push_back(std::make_unique<SfxGroupInfo_Impl>(
SfxCfgKind::GROUP_SCRIPTCONTAINER, 0));
std::unique_ptr<weld::TreeIter> xMacroGroup(pFunctionListBox->tree_append(
- OUString::number(
- reinterpret_cast<sal_Int64>(m_aGroupInfo.back().get())),
- sUIName));
+ weld::toId(m_aGroupInfo.back().get()), sUIName));
{
// tdf#128010: Do not nag user asking to enable JRE: if it's disabled,
@@ -455,8 +446,7 @@ void CommandCategoryListBox::categorySelected(CuiConfigFunctionListBox* pFunctio
std::make_unique<SfxGroupInfo_Impl>(SfxCfgKind::GROUP_STYLES, 0));
// pIt.sLabel is Name of the style family
std::unique_ptr<weld::TreeIter> xFuncEntry(pFunctionListBox->tree_append(
- OUString::number(reinterpret_cast<sal_Int64>(m_aGroupInfo.back().get())),
- pIt.sLabel));
+ weld::toId(m_aGroupInfo.back().get()), pIt.sLabel));
const std::vector<SfxStyleInfo_Impl> lStyles = pStylesInfo->getStyles(pIt.sFamily);
@@ -486,9 +476,8 @@ void CommandCategoryListBox::categorySelected(CuiConfigFunctionListBox* pFunctio
m_aGroupInfo.back()->sCommand = pStyle->sCommand;
m_aGroupInfo.back()->sLabel = pStyle->sLabel;
- pFunctionListBox->append(
- OUString::number(reinterpret_cast<sal_Int64>(m_aGroupInfo.back().get())),
- sUIName, xFuncEntry.get());
+ pFunctionListBox->append(weld::toId(m_aGroupInfo.back().get()), sUIName,
+ xFuncEntry.get());
}
// Remove the style group from the list if no children
@@ -547,8 +536,7 @@ void CommandCategoryListBox::addChildren(
m_aGroupInfo.push_back(std::make_unique<SfxGroupInfo_Impl>(
SfxCfgKind::GROUP_SCRIPTCONTAINER, 0, static_cast<void*>(child.get())));
std::unique_ptr<weld::TreeIter> xNewEntry(pFunctionListBox->tree_append(
- OUString::number(reinterpret_cast<sal_Int64>(m_aGroupInfo.back().get())), sUIName,
- parentEntry));
+ weld::toId(m_aGroupInfo.back().get()), sUIName, parentEntry));
addChildren(xNewEntry.get(), child, pFunctionListBox, filterTerm, pCurrentSaveInData,
rNodesToExpand);
@@ -610,9 +598,8 @@ void CommandCategoryListBox::addChildren(
m_aGroupInfo.back()->sCommand = uri;
m_aGroupInfo.back()->sLabel = sUIName;
m_aGroupInfo.back()->sHelpText = description;
- pFunctionListBox->append(
- OUString::number(reinterpret_cast<sal_Int64>(m_aGroupInfo.back().get())), sUIName,
- xImage, parentEntry);
+ pFunctionListBox->append(weld::toId(m_aGroupInfo.back().get()), sUIName, xImage,
+ parentEntry);
}
}
}
diff --git a/cui/source/customize/CustomNotebookbarGenerator.cxx b/cui/source/customize/CustomNotebookbarGenerator.cxx
index 392ea3e37a4e..1d013654d8f7 100644
--- a/cui/source/customize/CustomNotebookbarGenerator.cxx
+++ b/cui/source/customize/CustomNotebookbarGenerator.cxx
@@ -29,6 +29,7 @@
#include <com/sun/star/frame/ModuleManager.hpp>
#include <unotools/confignode.hxx>
#include <libxml/parser.h>
+#include <o3tl/string_view.hxx>
#define aUIPropertiesCount 3
@@ -73,11 +74,14 @@ static OUString lcl_getAppName(vcl::EnumContext::Application eApp)
static OUString getAppNameRegistryPath()
{
vcl::EnumContext::Application eApp = vcl::EnumContext::Application::Any;
- const Reference<frame::XFrame>& xFrame
- = SfxViewFrame::Current()->GetFrame().GetFrameInterface();
- const Reference<frame::XModuleManager> xModuleManager
- = frame::ModuleManager::create(::comphelper::getProcessComponentContext());
- eApp = vcl::EnumContext::GetApplicationEnum(xModuleManager->identify(xFrame));
+
+ if (SfxViewFrame* pViewFrame = SfxViewFrame::Current())
+ {
+ const Reference<frame::XFrame>& xFrame = pViewFrame->GetFrame().GetFrameInterface();
+ const Reference<frame::XModuleManager> xModuleManager
+ = frame::ModuleManager::create(::comphelper::getProcessComponentContext());
+ eApp = vcl::EnumContext::GetApplicationEnum(xModuleManager->identify(xFrame));
+ }
OUString sAppName(lcl_getAppName(eApp));
return "org.openoffice.Office.UI.ToolbarMode/Applications/" + sAppName;
@@ -180,14 +184,18 @@ static xmlDocPtr notebookbarXMLParser(const OString& rDocName, const OString& rU
void CustomNotebookbarGenerator::modifyCustomizedUIFile(const Sequence<OUString>& sUIItemProperties)
{
- OString sCustomizedUIPath = getSystemPath(getCustomizedUIPath());
+ const OUString sUIPath = getCustomizedUIPath();
+ if (osl::File(sUIPath).open(osl_File_OpenFlag_Read) != osl::FileBase::E_None)
+ createCustomizedUIFile();
+
+ const OString sCustomizedUIPath = getSystemPath(sUIPath);
for (auto const& aValue : sUIItemProperties)
{
std::vector<OString> aProperties(aUIPropertiesCount);
for (sal_Int32 aIndex = 0; aIndex < aUIPropertiesCount; aIndex++)
{
sal_Int32 nPos = aIndex;
- OUString sToken = aValue.getToken(nPos, ',', nPos);
+ std::u16string_view sToken = o3tl::getToken(aValue, nPos, ',', nPos);
aProperties[aIndex] = OUStringToOString(sToken, RTL_TEXTENCODING_UTF8);
}
xmlDocPtr doc = notebookbarXMLParser(sCustomizedUIPath, aProperties[0], aProperties[1],
@@ -257,16 +265,16 @@ Sequence<OUString> CustomNotebookbarGenerator::getCustomizedUIItem(OUString sNot
return aValues;
}
-void CustomNotebookbarGenerator::setCustomizedUIItem(Sequence<OUString> sUIItemProperties,
- OUString sNotebookbarConfigType)
+void CustomNotebookbarGenerator::setCustomizedUIItem(const Sequence<OUString>& rUIItemProperties,
+ const OUString& rNotebookbarConfigType)
{
OUString aPath = getAppNameRegistryPath();
const utl::OConfigurationTreeRoot aAppNode(::comphelper::getProcessComponentContext(), aPath,
true);
const utl::OConfigurationNode aModesNode = aAppNode.openNode("Modes");
- const utl::OConfigurationNode aModeNode(aModesNode.openNode(sNotebookbarConfigType));
+ const utl::OConfigurationNode aModeNode(aModesNode.openNode(rNotebookbarConfigType));
- css::uno::Any aUIItemProperties(makeAny(sUIItemProperties));
+ css::uno::Any aUIItemProperties(rUIItemProperties);
aModeNode.setNodeValue("UIItemProperties", aUIItemProperties);
aAppNode.commit();
}
diff --git a/cui/source/customize/SvxConfigPageHelper.cxx b/cui/source/customize/SvxConfigPageHelper.cxx
index 52265ef093e6..59a2cdb64017 100644
--- a/cui/source/customize/SvxConfigPageHelper.cxx
+++ b/cui/source/customize/SvxConfigPageHelper.cxx
@@ -66,11 +66,11 @@ void SvxConfigPageHelper::InitImageType()
{
theImageType = css::ui::ImageType::COLOR_NORMAL | css::ui::ImageType::SIZE_DEFAULT;
- if (SvtMiscOptions().GetCurrentSymbolsSize() == SFX_SYMBOLS_SIZE_LARGE)
+ if (SvtMiscOptions::GetCurrentSymbolsSize() == SFX_SYMBOLS_SIZE_LARGE)
{
theImageType |= css::ui::ImageType::SIZE_LARGE;
}
- else if (SvtMiscOptions().GetCurrentSymbolsSize() == SFX_SYMBOLS_SIZE_32)
+ else if (SvtMiscOptions::GetCurrentSymbolsSize() == SFX_SYMBOLS_SIZE_32)
{
theImageType |= css::ui::ImageType::SIZE_32;
}
@@ -248,7 +248,7 @@ OUString SvxConfigPageHelper::GetUIModuleName(
if (a >>= aSeq)
{
- for (css::beans::PropertyValue const& rProp : std::as_const(aSeq))
+ for (css::beans::PropertyValue const& rProp : aSeq)
{
if (rProp.Name == "ooSetupFactoryUIName")
{
@@ -282,7 +282,7 @@ bool SvxConfigPageHelper::GetMenuItemData(
css::uno::Sequence<css::beans::PropertyValue> aProps;
if (rItemContainer->getByIndex(nIndex) >>= aProps)
{
- for (css::beans::PropertyValue const& rProp : std::as_const(aProps))
+ for (css::beans::PropertyValue const& rProp : aProps)
{
if (rProp.Name == ITEM_DESCRIPTOR_COMMANDURL)
{
@@ -325,7 +325,7 @@ bool SvxConfigPageHelper::GetToolbarItemData(
css::uno::Sequence<css::beans::PropertyValue> aProps;
if (rItemContainer->getByIndex(nIndex) >>= aProps)
{
- for (css::beans::PropertyValue const& rProp : std::as_const(aProps))
+ for (css::beans::PropertyValue const& rProp : aProps)
{
if (rProp.Name == ITEM_DESCRIPTOR_COMMANDURL)
{
diff --git a/cui/source/customize/SvxMenuConfigPage.cxx b/cui/source/customize/SvxMenuConfigPage.cxx
index 73d01792798a..4ee5ce9be0ca 100644
--- a/cui/source/customize/SvxMenuConfigPage.cxx
+++ b/cui/source/customize/SvxMenuConfigPage.cxx
@@ -20,6 +20,7 @@
#include <sal/config.h>
#include <sal/log.hxx>
+#include <dlgname.hxx>
#include <vcl/weld.hxx>
#include <vcl/svapp.hxx>
#include <vcl/commandevent.hxx>
@@ -34,8 +35,6 @@
#include <comphelper/processfactory.hxx>
-#include <dlgname.hxx>
-
SvxMenuConfigPage::SvxMenuConfigPage(weld::Container* pPage, weld::DialogController* pController,
const SfxItemSet& rSet, bool bIsMenuBar)
: SvxConfigPage(pPage, pController, rSet)
@@ -100,8 +99,7 @@ void SvxMenuConfigPage::ListModified()
pEntries->clear();
for (int i = 0; i < m_xContentsListBox->n_children(); ++i)
- pEntries->push_back(
- reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(i).toInt64()));
+ pEntries->push_back(weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(i)));
GetSaveInData()->SetModified();
GetTopLevelSelection()->SetModified();
@@ -123,7 +121,7 @@ IMPL_LINK(SvxMenuConfigPage, MenuEntriesSizeAllocHdl, const Size&, rSize, void)
SvxMenuConfigPage::~SvxMenuConfigPage()
{
for (int i = 0, nCount = m_xSaveInListBox->get_count(); i < nCount; ++i)
- delete reinterpret_cast<SaveInData*>(m_xSaveInListBox->get_id(i).toInt64());
+ delete weld::fromId<SaveInData*>(m_xSaveInListBox->get_id(i));
m_xSaveInListBox->clear();
}
@@ -136,7 +134,7 @@ void SvxMenuConfigPage::Init()
ReloadTopLevelListBox();
- m_xTopLevelListBox->set_active(0);
+ m_xTopLevelListBox->set_active(m_xTopLevelListBox->get_count() ? 0 : -1);
SelectElement();
m_xCommandCategoryListBox->Init(comphelper::getProcessComponentContext(), m_xFrame,
@@ -154,8 +152,7 @@ void SvxMenuConfigPage::UpdateButtonStates()
bool bIsSeparator
= selection != -1
- && reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(selection).toInt64())
- ->IsSeparator();
+ && weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(selection))->IsSeparator();
bool bIsValidSelection = (m_xContentsListBox->n_children() != 0 && selection != -1);
m_xMoveUpButton->set_sensitive(bIsValidSelection && selection != 0);
@@ -217,7 +214,7 @@ void SvxMenuConfigPage::DeleteSelectedContent()
// get currently selected menu entry
SvxConfigEntry* pMenuEntry
- = reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(nActEntry).toInt64());
+ = weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(nActEntry));
// get currently selected menu
SvxConfigEntry* pMenu = GetTopLevelSelection();
@@ -268,7 +265,7 @@ void SvxMenuConfigPage::SelectElement()
rTreeView.bulk_insert_for_each(
pEntries->size(), [this, &rTreeView, pEntries](weld::TreeIter& rIter, int nIdx) {
auto const& entry = (*pEntries)[nIdx];
- OUString sId(OUString::number(reinterpret_cast<sal_Int64>(entry)));
+ OUString sId(weld::toId(entry));
rTreeView.set_id(rIter, sId);
InsertEntryIntoUI(entry, rTreeView, rIter, true);
});
@@ -277,7 +274,7 @@ void SvxMenuConfigPage::SelectElement()
UpdateButtonStates();
}
-IMPL_LINK(SvxMenuConfigPage, GearHdl, const OString&, rIdent, void)
+IMPL_LINK(SvxMenuConfigPage, GearHdl, const OUString&, rIdent, void)
{
if (rIdent == "menu_gear_add")
{
@@ -360,7 +357,7 @@ IMPL_LINK_NOARG(SvxMenuConfigPage, AddCommandHdl, weld::Button&, void)
if (nPos == -1)
return;
weld::TreeView& rTreeView = m_xContentsListBox->get_widget();
- SvxConfigEntry* pEntry = reinterpret_cast<SvxConfigEntry*>(rTreeView.get_id(nPos).toInt64());
+ SvxConfigEntry* pEntry = weld::fromId<SvxConfigEntry*>(rTreeView.get_id(nPos));
InsertEntryIntoUI(pEntry, rTreeView, nPos, true);
}
@@ -373,7 +370,7 @@ IMPL_LINK_NOARG(SvxMenuConfigPage, RemoveCommandHdl, weld::Button&, void)
}
}
-IMPL_LINK(SvxMenuConfigPage, InsertHdl, const OString&, rIdent, void)
+IMPL_LINK(SvxMenuConfigPage, InsertHdl, const OUString&, rIdent, void)
{
weld::TreeView& rTreeView = m_xContentsListBox->get_widget();
if (rIdent == "insertseparator")
@@ -425,13 +422,13 @@ IMPL_LINK(SvxMenuConfigPage, InsertHdl, const OString&, rIdent, void)
}
}
-IMPL_LINK(SvxMenuConfigPage, ModifyItemHdl, const OString&, rIdent, void)
+IMPL_LINK(SvxMenuConfigPage, ModifyItemHdl, const OUString&, rIdent, void)
{
if (rIdent == "renameItem")
{
int nActEntry = m_xContentsListBox->get_selected_index();
SvxConfigEntry* pEntry
- = reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(nActEntry).toInt64());
+ = weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(nActEntry));
OUString aNewName(SvxConfigPageHelper::stripHotKey(pEntry->GetName()));
OUString aDesc = CuiResId(RID_CUISTR_LABEL_NEW_NAME);
@@ -531,8 +528,7 @@ IMPL_LINK(SvxMenuConfigPage, ContentContextMenuHdl, const CommandEvent&, rCEvt,
bool bIsSeparator
= nSelectIndex != -1
- && reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(nSelectIndex).toInt64())
- ->IsSeparator();
+ && weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(nSelectIndex))->IsSeparator();
bool bIsValidSelection = (m_xContentsListBox->n_children() != 0 && nSelectIndex != -1);
std::unique_ptr<weld::Builder> xBuilder(
@@ -544,7 +540,7 @@ IMPL_LINK(SvxMenuConfigPage, ContentContextMenuHdl, const CommandEvent&, rCEvt,
xContextMenu->set_visible("changeIcon", false);
xContextMenu->set_visible("resetIcon", false);
xContextMenu->set_visible("restoreDefault", false);
- OString sCommand(xContextMenu->popup_at_rect(
+ OUString sCommand(xContextMenu->popup_at_rect(
&rTreeView, tools::Rectangle(rCEvt.GetMousePosPixel(), Size(1, 1))));
if (sCommand == "remove")
@@ -583,7 +579,7 @@ IMPL_LINK(SvxMenuConfigPage, FunctionContextMenuHdl, const CommandEvent&, rCEvt,
xContextMenu->set_visible("changeIcon", false);
xContextMenu->set_visible("resetIcon", false);
xContextMenu->set_visible("restoreDefault", false);
- OString sCommand(xContextMenu->popup_at_rect(
+ OUString sCommand(xContextMenu->popup_at_rect(
&rTreeView, tools::Rectangle(rCEvt.GetMousePosPixel(), Size(1, 1))));
if (sCommand == "add")
diff --git a/cui/source/customize/SvxNotebookbarConfigPage.cxx b/cui/source/customize/SvxNotebookbarConfigPage.cxx
index af08789c67b0..7389d05b91d2 100644
--- a/cui/source/customize/SvxNotebookbarConfigPage.cxx
+++ b/cui/source/customize/SvxNotebookbarConfigPage.cxx
@@ -40,14 +40,13 @@
#include <sfx2/notebookbar/SfxNotebookBar.hxx>
#include <unotools/configmgr.hxx>
#include <comphelper/processfactory.hxx>
+#include <o3tl/string_view.hxx>
#include <com/sun/star/frame/theUICommandDescription.hpp>
namespace uno = com::sun::star::uno;
namespace frame = com::sun::star::frame;
-namespace lang = com::sun::star::lang;
namespace container = com::sun::star::container;
namespace beans = com::sun::star::beans;
-namespace graphic = com::sun::star::graphic;
static bool isCategoryAvailable(std::u16string_view sClassId, std::u16string_view sUIItemId,
std::u16string_view sActiveCategory, bool& isCategory)
@@ -106,14 +105,11 @@ SvxNotebookbarConfigPage::SvxNotebookbarConfigPage(weld::Container* pPage,
m_xDescriptionField->set_visible(false);
m_xMoveUpButton->set_visible(false);
m_xMoveDownButton->set_visible(false);
- m_xAddCommandButton->set_visible(false);
- m_xRemoveCommandButton->set_visible(false);
+ m_xCommandButtons->set_visible(false);
m_xLeftFunctionLabel->set_visible(false);
m_xSearchLabel->set_visible(false);
m_xCategoryLabel->set_visible(false);
- m_xInsertBtn->set_visible(false);
- m_xModifyBtn->set_visible(false);
- m_xResetBtn->set_visible(false);
+ m_xCustomizeBox->set_visible(false);
m_xCustomizeLabel->set_visible(false);
weld::TreeView& rCommandCategoryBox = m_xFunctions->get_widget();
@@ -144,7 +140,6 @@ void SvxNotebookbarConfigPage::Init()
m_xTopLevelListBox->clear();
m_xContentsListBox->clear();
m_xSaveInListBox->clear();
- CustomNotebookbarGenerator::createCustomizedUIFile();
OUString sNotebookbarInterface = getFileName(m_sFileName);
OUString sScopeName
@@ -183,9 +178,8 @@ short SvxNotebookbarConfigPage::QueryReset()
int nValue = xQueryBox->run();
if (nValue == RET_YES)
{
- OUString sOriginalUIPath = CustomNotebookbarGenerator::getOriginalUIPath();
- OUString sCustomizedUIPath = CustomNotebookbarGenerator::getCustomizedUIPath();
- osl::File::copy(sOriginalUIPath, sCustomizedUIPath);
+ osl::File::remove(CustomNotebookbarGenerator::getCustomizedUIPath());
+
OUString sNotebookbarInterface = getFileName(m_sFileName);
Sequence<OUString> sSequenceEntries;
CustomNotebookbarGenerator::setCustomizedUIItem(sSequenceEntries, sNotebookbarInterface);
@@ -221,7 +215,7 @@ void SvxConfigPage::InsertEntryIntoNotebookbarTabUI(std::u16string_view sClassId
}
OUString aLabel;
- for (auto const& prop : std::as_const(aPropSeq))
+ for (auto const& prop : aPropSeq)
if (prop.Name == "Name")
prop.Value >>= aLabel;
@@ -317,8 +311,9 @@ void SvxNotebookbarConfigPage::searchNodeandAttribute(std::vector<NotebookbarEnt
{
sal_Int32 rPos = 0;
aCategoryEntry.sDisplayName
- = aCurItemEntry.sDisplayName.getToken(rPos, ' ', rPos) + " | "
- + sUIItemId;
+ = OUString::Concat(
+ o3tl::getToken(aCurItemEntry.sDisplayName, rPos, ' ', rPos))
+ + " | " + sUIItemId;
}
aCategoryList.push_back(aCategoryEntry);
aCurItemEntry = aCategoryEntry;
@@ -398,6 +393,13 @@ void SvxNotebookbarConfigPage::SelectElement()
CustomNotebookbarGenerator::getCustomizedUIPath());
xmlDocPtr pDoc = xmlParseFile(sUIFileUIPath.getStr());
if (!pDoc)
+ {
+ sUIFileUIPath = CustomNotebookbarGenerator::getSystemPath(
+ CustomNotebookbarGenerator::getOriginalUIPath());
+ pDoc = xmlParseFile(sUIFileUIPath.getStr());
+ }
+
+ if (!pDoc)
return;
xmlNodePtr pNodePtr = xmlDocGetRootElement(pDoc);
@@ -408,9 +410,8 @@ void SvxNotebookbarConfigPage::SelectElement()
if (m_xTopLevelListBox->get_count() == 1)
{
- for (std::size_t nIdx = 0; nIdx < aCategoryList.size(); nIdx++)
- m_xTopLevelListBox->append(aCategoryList[nIdx].sUIItemId,
- aCategoryList[nIdx].sDisplayName);
+ for (const auto& rCategory : aCategoryList)
+ m_xTopLevelListBox->append(rCategory.sUIItemId, rCategory.sDisplayName);
}
tools::ULong nStart = 0;
if (aEntries[nStart].sClassId == "sfxlo-PriorityHBox"
@@ -433,11 +434,10 @@ void SvxNotebookbarConfigPage::SelectElement()
aEntries = std::move(aTempEntries);
+ static_cast<SvxNotebookbarEntriesListBox*>(m_xContentsListBox.get())->GetTooltipMap().clear();
weld::TreeView& rTreeView = m_xContentsListBox->get_widget();
rTreeView.bulk_insert_for_each(
aEntries.size(), [this, &rTreeView, &aEntries](weld::TreeIter& rIter, int nIdx) {
- OUString sId(OUString::number(nIdx));
- rTreeView.set_id(rIter, sId);
if (aEntries[nIdx].sActionName != "Null")
{
if (aEntries[nIdx].sVisibleValue == "True")
@@ -451,6 +451,13 @@ void SvxNotebookbarConfigPage::SelectElement()
}
InsertEntryIntoNotebookbarTabUI(aEntries[nIdx].sClassId, aEntries[nIdx].sDisplayName,
aEntries[nIdx].sActionName, rTreeView, rIter);
+ if (aEntries[nIdx].sClassId != u"GtkSeparatorMenuItem"
+ && aEntries[nIdx].sClassId != u"GtkSeparator")
+ {
+ static_cast<SvxNotebookbarEntriesListBox*>(m_xContentsListBox.get())
+ ->GetTooltipMap()[aEntries[nIdx].sDisplayName]
+ = aEntries[nIdx].sActionName;
+ }
});
aEntries.clear();
@@ -465,6 +472,9 @@ SvxNotebookbarEntriesListBox::SvxNotebookbarEntriesListBox(std::unique_ptr<weld:
m_xControl->connect_toggled(LINK(this, SvxNotebookbarEntriesListBox, CheckButtonHdl));
m_xControl->connect_key_press(Link<const KeyEvent&, bool>());
m_xControl->connect_key_press(LINK(this, SvxNotebookbarEntriesListBox, KeyInputHdl));
+ // remove the inherited connect_query_tooltip then add the new one
+ m_xControl->connect_query_tooltip(Link<const weld::TreeIter&, OUString>());
+ m_xControl->connect_query_tooltip(LINK(this, SvxNotebookbarEntriesListBox, QueryTooltip));
}
SvxNotebookbarEntriesListBox::~SvxNotebookbarEntriesListBox() {}
@@ -480,7 +490,7 @@ static void EditRegistryFile(std::u16string_view sUIItemId, const OUString& sSet
for (int nIdx = 0; nIdx < aOldEntries.getLength(); nIdx++)
{
sal_Int32 rPos = 0;
- OUString sFirstValue = aOldEntries[nIdx].getToken(rPos, ',', rPos);
+ std::u16string_view sFirstValue = o3tl::getToken(aOldEntries[nIdx], rPos, ',', rPos);
if (sFirstValue == sUIItemId)
{
aOldEntries.getArray()[nIdx] = sSetEntry;
@@ -538,4 +548,19 @@ IMPL_LINK(SvxNotebookbarEntriesListBox, KeyInputHdl, const KeyEvent&, rKeyEvent,
return SvxMenuEntriesListBox::KeyInputHdl(rKeyEvent);
}
+IMPL_LINK(SvxNotebookbarEntriesListBox, QueryTooltip, const weld::TreeIter&, rIter, OUString)
+{
+ const OUString& rsCommand = m_aTooltipMap[m_xControl->get_id(rIter)];
+ if (rsCommand.isEmpty())
+ return OUString();
+ OUString aModuleName(vcl::CommandInfoProvider::GetModuleIdentifier(m_pPage->GetFrame()));
+ auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(rsCommand, aModuleName);
+ OUString sTooltipLabel = vcl::CommandInfoProvider::GetTooltipForCommand(rsCommand, aProperties,
+ m_pPage->GetFrame());
+ return CuiResId(RID_CUISTR_COMMANDLABEL) + ": "
+ + m_xControl->get_text(rIter).replaceFirst("~", "") + "\n"
+ + CuiResId(RID_CUISTR_COMMANDNAME) + ": " + rsCommand + "\n"
+ + CuiResId(RID_CUISTR_COMMANDTIP) + ": " + sTooltipLabel.replaceFirst("~", "");
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cui/source/customize/SvxToolbarConfigPage.cxx b/cui/source/customize/SvxToolbarConfigPage.cxx
index 7ba649d010ff..1997de819d29 100644
--- a/cui/source/customize/SvxToolbarConfigPage.cxx
+++ b/cui/source/customize/SvxToolbarConfigPage.cxx
@@ -27,7 +27,7 @@
#include <sfx2/sfxsids.hrc>
#include <svl/stritem.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <algorithm>
#include <helpids.h>
@@ -38,9 +38,8 @@
#include <SvxConfigPageHelper.hxx>
#include <dialmgr.hxx>
-#include <comphelper/processfactory.hxx>
-
#include <dlgname.hxx>
+#include <comphelper/processfactory.hxx>
SvxToolbarConfigPage::SvxToolbarConfigPage(weld::Container* pPage,
weld::DialogController* pController,
@@ -106,7 +105,7 @@ SvxToolbarConfigPage::SvxToolbarConfigPage(weld::Container* pPage,
m_aURLToSelect = ITEM_TOOLBAR_URL;
m_aURLToSelect += "standardbar";
- const SfxPoolItem* pItem = rSet.GetItem(rSet.GetPool()->GetWhich(SID_CONFIG));
+ const SfxPoolItem* pItem = rSet.GetItem(SID_CONFIG);
if (pItem)
{
@@ -125,8 +124,7 @@ void SvxToolbarConfigPage::ListModified()
pEntries->clear();
for (int i = 0; i < m_xContentsListBox->n_children(); ++i)
- pEntries->push_back(
- reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(i).toInt64()));
+ pEntries->push_back(weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(i)));
GetSaveInData()->SetModified();
GetTopLevelSelection()->SetModified();
@@ -140,8 +138,7 @@ SvxToolbarConfigPage::~SvxToolbarConfigPage()
{
for (int i = 0, nCount = m_xSaveInListBox->get_count(); i < nCount; ++i)
{
- ToolbarSaveInData* pData
- = reinterpret_cast<ToolbarSaveInData*>(m_xSaveInListBox->get_id(i).toInt64());
+ ToolbarSaveInData* pData = weld::fromId<ToolbarSaveInData*>(m_xSaveInListBox->get_id(i));
delete pData;
}
m_xSaveInListBox->clear();
@@ -186,8 +183,7 @@ void SvxToolbarConfigPage::DeleteSelectedContent()
return;
// get currently selected entry
- SvxConfigEntry* pEntry
- = reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(nActEntry).toInt64());
+ SvxConfigEntry* pEntry = weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(nActEntry));
SvxConfigEntry* pToolbar = GetTopLevelSelection();
@@ -246,13 +242,14 @@ void SvxToolbarConfigPage::Init()
ReloadTopLevelListBox();
- sal_Int32 nPos = 0;
+ sal_Int32 nCount = m_xTopLevelListBox->get_count();
+ sal_Int32 nPos = nCount > 0 ? 0 : -1;
+
if (!m_aURLToSelect.isEmpty())
{
- for (sal_Int32 i = 0, nCount = m_xTopLevelListBox->get_count(); i < nCount; ++i)
+ for (sal_Int32 i = 0; i < nCount; ++i)
{
- SvxConfigEntry* pData
- = reinterpret_cast<SvxConfigEntry*>(m_xTopLevelListBox->get_id(i).toInt64());
+ SvxConfigEntry* pData = weld::fromId<SvxConfigEntry*>(m_xTopLevelListBox->get_id(i));
if (pData->GetCommand().equals(m_aURLToSelect))
{
@@ -289,7 +286,7 @@ IMPL_LINK_NOARG(SvxToolbarConfigPage, SelectToolbarEntry, weld::TreeView&, void)
UpdateButtonStates();
}
-IMPL_LINK(SvxToolbarConfigPage, GearHdl, const OString&, rIdent, void)
+IMPL_LINK(SvxToolbarConfigPage, GearHdl, const OUString&, rIdent, void)
{
SvxConfigEntry* pCurrentToolbar = GetTopLevelSelection();
@@ -317,8 +314,8 @@ IMPL_LINK(SvxToolbarConfigPage, GearHdl, const OString&, rIdent, void)
// Where to save the new toolbar? (i.e. Modulewise or documentwise)
int nInsertPos = aNameDialog.m_xSaveInListBox->get_active();
- ToolbarSaveInData* pData = reinterpret_cast<ToolbarSaveInData*>(
- m_xSaveInListBox->get_id(nInsertPos).toInt64());
+ ToolbarSaveInData* pData
+ = weld::fromId<ToolbarSaveInData*>(m_xSaveInListBox->get_id(nInsertPos));
if (GetSaveInData() != pData)
{
@@ -333,7 +330,7 @@ IMPL_LINK(SvxToolbarConfigPage, GearHdl, const OString&, rIdent, void)
pData->CreateToolbar(pToolbar);
- OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pToolbar)));
+ OUString sId(weld::toId(pToolbar));
m_xTopLevelListBox->append(sId, pToolbar->GetName());
m_xTopLevelListBox->set_active_id(sId);
SelectElement();
@@ -352,8 +349,8 @@ IMPL_LINK(SvxToolbarConfigPage, GearHdl, const OString&, rIdent, void)
else if (rIdent == "toolbar_gear_rename")
{
sal_Int32 nSelectionPos = m_xTopLevelListBox->get_active();
- SvxConfigEntry* pToolbar = reinterpret_cast<SvxConfigEntry*>(
- m_xTopLevelListBox->get_id(nSelectionPos).toInt64());
+ SvxConfigEntry* pToolbar
+ = weld::fromId<SvxConfigEntry*>(m_xTopLevelListBox->get_id(nSelectionPos));
ToolbarSaveInData* pSaveInData = static_cast<ToolbarSaveInData*>(GetSaveInData());
//Rename the toolbar
@@ -376,7 +373,7 @@ IMPL_LINK(SvxToolbarConfigPage, GearHdl, const OString&, rIdent, void)
// have to use remove and insert to change the name
m_xTopLevelListBox->remove(nSelectionPos);
- OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pToolbar)));
+ OUString sId(weld::toId(pToolbar));
m_xTopLevelListBox->insert(nSelectionPos, sNewName, &sId, nullptr, nullptr);
m_xTopLevelListBox->set_active_id(sId);
}
@@ -429,7 +426,7 @@ IMPL_LINK_NOARG(SvxToolbarConfigPage, RemoveCommandHdl, weld::Button&, void)
DeleteSelectedContent();
}
-IMPL_LINK(SvxToolbarConfigPage, InsertHdl, const OString&, rIdent, void)
+IMPL_LINK(SvxToolbarConfigPage, InsertHdl, const OUString&, rIdent, void)
{
if (rIdent == "insertseparator")
{
@@ -454,7 +451,7 @@ IMPL_LINK(SvxToolbarConfigPage, InsertHdl, const OString&, rIdent, void)
}
}
-IMPL_LINK(SvxToolbarConfigPage, ModifyItemHdl, const OString&, rIdent, void)
+IMPL_LINK(SvxToolbarConfigPage, ModifyItemHdl, const OUString&, rIdent, void)
{
bool bNeedsApply = false;
@@ -471,7 +468,7 @@ IMPL_LINK(SvxToolbarConfigPage, ModifyItemHdl, const OString&, rIdent, void)
{
int nActEntry = m_xContentsListBox->get_selected_index();
SvxConfigEntry* pEntry
- = reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(nActEntry).toInt64());
+ = weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(nActEntry));
OUString aNewName(SvxConfigPageHelper::stripHotKey(pEntry->GetName()));
OUString aDesc = CuiResId(RID_CUISTR_LABEL_NEW_NAME);
@@ -497,7 +494,7 @@ IMPL_LINK(SvxToolbarConfigPage, ModifyItemHdl, const OString&, rIdent, void)
{
int nActEntry = m_xContentsListBox->get_selected_index();
SvxConfigEntry* pEntry
- = reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(nActEntry).toInt64());
+ = weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(nActEntry));
SvxIconSelectorDialog aIconDialog(GetFrameWeld(), GetSaveInData()->GetImageManager(),
GetSaveInData()->GetParentImageManager());
@@ -532,7 +529,7 @@ IMPL_LINK(SvxToolbarConfigPage, ModifyItemHdl, const OString&, rIdent, void)
m_xContentsListBox->remove(nActEntry);
- OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pEntry)));
+ OUString sId(weld::toId(pEntry));
m_xContentsListBox->insert(nActEntry, sId);
m_xContentsListBox->set_toggle(nActEntry, pEntry->IsVisible() ? TRISTATE_TRUE
: TRISTATE_FALSE);
@@ -554,11 +551,11 @@ IMPL_LINK(SvxToolbarConfigPage, ModifyItemHdl, const OString&, rIdent, void)
{
int nActEntry = m_xContentsListBox->get_selected_index();
SvxConfigEntry* pEntry
- = reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(nActEntry).toInt64());
-
- css::uno::Reference<css::graphic::XGraphic> backup = pEntry->GetBackupGraphic();
+ = weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(nActEntry));
- css::uno::Sequence<css::uno::Reference<css::graphic::XGraphic>> aGraphicSeq{ backup };
+ css::uno::Sequence<css::uno::Reference<css::graphic::XGraphic>> aGraphicSeq{
+ pEntry->GetBackupGraphic()
+ };
css::uno::Sequence<OUString> aURLSeq{ pEntry->GetCommand() };
@@ -569,7 +566,7 @@ IMPL_LINK(SvxToolbarConfigPage, ModifyItemHdl, const OString&, rIdent, void)
m_xContentsListBox->remove(nActEntry);
- OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pEntry)));
+ OUString sId(weld::toId(pEntry));
m_xContentsListBox->insert(nActEntry, sId);
m_xContentsListBox->set_toggle(nActEntry,
pEntry->IsVisible() ? TRISTATE_TRUE : TRISTATE_FALSE);
@@ -592,7 +589,7 @@ IMPL_LINK(SvxToolbarConfigPage, ModifyItemHdl, const OString&, rIdent, void)
{
int nActEntry = m_xContentsListBox->get_selected_index();
SvxConfigEntry* pEntry
- = reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(nActEntry).toInt64());
+ = weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(nActEntry));
ToolbarSaveInData* pSaveInData = static_cast<ToolbarSaveInData*>(GetSaveInData());
@@ -620,7 +617,7 @@ IMPL_LINK(SvxToolbarConfigPage, ModifyItemHdl, const OString&, rIdent, void)
m_xContentsListBox->remove(nActEntry);
- OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pEntry)));
+ OUString sId(weld::toId(pEntry));
m_xContentsListBox->insert(nActEntry, sId);
m_xContentsListBox->set_toggle(nActEntry,
pEntry->IsVisible() ? TRISTATE_TRUE : TRISTATE_FALSE);
@@ -655,7 +652,7 @@ IMPL_LINK_NOARG(SvxToolbarConfigPage, ResetToolbarHdl, weld::Button&, void)
sal_Int32 nSelectionPos = m_xTopLevelListBox->get_active();
SvxConfigEntry* pToolbar
- = reinterpret_cast<SvxConfigEntry*>(m_xTopLevelListBox->get_id(nSelectionPos).toInt64());
+ = weld::fromId<SvxConfigEntry*>(m_xTopLevelListBox->get_id(nSelectionPos));
std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(
GetFrameWeld(), VclMessageType::Question, VclButtonsType::YesNo,
@@ -677,8 +674,7 @@ void SvxToolbarConfigPage::UpdateButtonStates()
bool bIsSeparator
= selection != -1
- && reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(selection).toInt64())
- ->IsSeparator();
+ && weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(selection))->IsSeparator();
bool bIsValidSelection = (m_xContentsListBox->n_children() != 0 && selection != -1);
m_xMoveUpButton->set_sensitive(bIsValidSelection);
@@ -751,7 +747,7 @@ void SvxToolbarConfigPage::SelectElement()
SvxEntries* pEntries = pToolbar->GetEntries();
for (auto const& entry : *pEntries)
{
- OUString sId(OUString::number(reinterpret_cast<sal_Int64>(entry)));
+ OUString sId(weld::toId(entry));
m_xContentsListBox->insert(i, sId);
if (entry->IsBinding() && !entry->IsSeparator())
m_xContentsListBox->set_toggle(i, entry->IsVisible() ? TRISTATE_TRUE : TRISTATE_FALSE);
@@ -775,8 +771,7 @@ void SvxToolbarConfigPage::AddFunction(int nTarget)
if (nNewLBEntry == -1)
return;
- SvxConfigEntry* pEntry
- = reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(nNewLBEntry).toInt64());
+ SvxConfigEntry* pEntry = weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(nNewLBEntry));
if (pEntry->IsBinding()) //TODO sep ?
{
@@ -811,8 +806,7 @@ SvxToolbarEntriesListBox::~SvxToolbarEntriesListBox() {}
void SvxToolbarEntriesListBox::ChangedVisibility(int nRow)
{
- SvxConfigEntry* pEntryData
- = reinterpret_cast<SvxConfigEntry*>(m_xControl->get_id(nRow).toInt64());
+ SvxConfigEntry* pEntryData = weld::fromId<SvxConfigEntry*>(m_xControl->get_id(nRow));
if (pEntryData->IsBinding())
{
@@ -838,8 +832,7 @@ IMPL_LINK(SvxToolbarEntriesListBox, KeyInputHdl, const KeyEvent&, rKeyEvent, boo
if (rKeyEvent.GetKeyCode() == KEY_SPACE)
{
int nRow = m_xControl->get_selected_index();
- SvxConfigEntry* pEntryData
- = reinterpret_cast<SvxConfigEntry*>(m_xControl->get_id(nRow).toInt64());
+ SvxConfigEntry* pEntryData = weld::fromId<SvxConfigEntry*>(m_xControl->get_id(nRow));
if (pEntryData->IsBinding() && !pEntryData->IsSeparator())
{
m_xControl->set_toggle(nRow, m_xControl->get_toggle(nRow) == TRISTATE_TRUE
@@ -870,8 +863,7 @@ IMPL_LINK(SvxToolbarConfigPage, ContentContextMenuHdl, const CommandEvent&, rCEv
bool bIsSeparator
= nSelectIndex != -1
- && reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(nSelectIndex).toInt64())
- ->IsSeparator();
+ && weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(nSelectIndex))->IsSeparator();
bool bIsValidSelection = (m_xContentsListBox->n_children() != 0 && nSelectIndex != -1);
std::unique_ptr<weld::Builder> xBuilder(
@@ -883,7 +875,7 @@ IMPL_LINK(SvxToolbarConfigPage, ContentContextMenuHdl, const CommandEvent&, rCEv
xContextMenu->set_visible("changeIcon", bIsValidSelection && !bIsSeparator);
xContextMenu->set_visible("resetIcon", bIsValidSelection && !bIsSeparator);
xContextMenu->set_visible("restoreDefault", bIsValidSelection && !bIsSeparator);
- OString sCommand(xContextMenu->popup_at_rect(
+ OUString sCommand(xContextMenu->popup_at_rect(
&rTreeView, tools::Rectangle(rCEvt.GetMousePosPixel(), Size(1, 1))));
if (sCommand == "remove")
@@ -923,7 +915,7 @@ IMPL_LINK(SvxToolbarConfigPage, FunctionContextMenuHdl, const CommandEvent&, rCE
xContextMenu->set_visible("changeIcon", false);
xContextMenu->set_visible("resetIcon", false);
xContextMenu->set_visible("restoreDefault", false);
- OString sCommand(xContextMenu->popup_at_rect(
+ OUString sCommand(xContextMenu->popup_at_rect(
&rTreeView, tools::Rectangle(rCEvt.GetMousePosPixel(), Size(1, 1))));
if (sCommand == "add")
diff --git a/cui/source/customize/acccfg.cxx b/cui/source/customize/acccfg.cxx
index 398ca509dbd7..027ac72968e8 100644
--- a/cui/source/customize/acccfg.cxx
+++ b/cui/source/customize/acccfg.cxx
@@ -63,13 +63,15 @@
#include <comphelper/sequenceashashmap.hxx>
#include <config_features.h>
+#include <com/sun/star/frame/LayoutManager.hpp>
+
// namespaces
using namespace css;
-constexpr OUStringLiteral FOLDERNAME_UICONFIG = u"Configurations2";
+constexpr OUString FOLDERNAME_UICONFIG = u"Configurations2"_ustr;
-constexpr OUStringLiteral MEDIATYPE_PROPNAME = u"MediaType";
+constexpr OUString MEDIATYPE_PROPNAME = u"MediaType"_ustr;
const sal_uInt16 KEYCODE_ARRAY[] = { KEY_F1,
KEY_F2,
@@ -184,11 +186,14 @@ const sal_uInt16 KEYCODE_ARRAY[] = { KEY_F1,
KEY_MOD1 | KEY_X,
KEY_MOD1 | KEY_Y,
KEY_MOD1 | KEY_Z,
+ KEY_MOD1 | KEY_NUMBERSIGN,
+ KEY_MOD1 | KEY_COLON,
KEY_MOD1 | KEY_SEMICOLON,
KEY_MOD1 | KEY_QUOTELEFT,
KEY_MOD1 | KEY_QUOTERIGHT,
KEY_MOD1 | KEY_BRACKETLEFT,
KEY_MOD1 | KEY_BRACKETRIGHT,
+ KEY_MOD1 | KEY_RIGHTCURLYBRACKET,
KEY_MOD1 | KEY_POINT,
KEY_MOD1 | KEY_COMMA,
KEY_MOD1 | KEY_TILDE,
@@ -267,11 +272,14 @@ const sal_uInt16 KEYCODE_ARRAY[] = { KEY_F1,
KEY_SHIFT | KEY_MOD1 | KEY_X,
KEY_SHIFT | KEY_MOD1 | KEY_Y,
KEY_SHIFT | KEY_MOD1 | KEY_Z,
+ KEY_SHIFT | KEY_MOD1 | KEY_NUMBERSIGN,
+ KEY_SHIFT | KEY_MOD1 | KEY_COLON,
KEY_SHIFT | KEY_MOD1 | KEY_SEMICOLON,
KEY_SHIFT | KEY_MOD1 | KEY_QUOTELEFT,
KEY_SHIFT | KEY_MOD1 | KEY_QUOTERIGHT,
KEY_SHIFT | KEY_MOD1 | KEY_BRACKETLEFT,
KEY_SHIFT | KEY_MOD1 | KEY_BRACKETRIGHT,
+ KEY_SHIFT | KEY_MOD1 | KEY_RIGHTCURLYBRACKET,
KEY_SHIFT | KEY_MOD1 | KEY_POINT,
KEY_SHIFT | KEY_MOD1 | KEY_COMMA,
KEY_SHIFT | KEY_MOD1 | KEY_TILDE,
@@ -346,11 +354,14 @@ const sal_uInt16 KEYCODE_ARRAY[] = { KEY_F1,
KEY_MOD2 | KEY_X,
KEY_MOD2 | KEY_Y,
KEY_MOD2 | KEY_Z,
+ KEY_MOD2 | KEY_NUMBERSIGN,
+ KEY_MOD2 | KEY_COLON,
KEY_MOD2 | KEY_SEMICOLON,
KEY_MOD2 | KEY_QUOTELEFT,
KEY_MOD2 | KEY_QUOTERIGHT,
KEY_MOD2 | KEY_BRACKETLEFT,
KEY_MOD2 | KEY_BRACKETRIGHT,
+ KEY_MOD2 | KEY_RIGHTCURLYBRACKET,
KEY_MOD2 | KEY_POINT,
KEY_MOD2 | KEY_COMMA,
KEY_MOD2 | KEY_TILDE,
@@ -423,11 +434,14 @@ const sal_uInt16 KEYCODE_ARRAY[] = { KEY_F1,
KEY_SHIFT | KEY_MOD2 | KEY_X,
KEY_SHIFT | KEY_MOD2 | KEY_Y,
KEY_SHIFT | KEY_MOD2 | KEY_Z,
+ KEY_SHIFT | KEY_MOD2 | KEY_NUMBERSIGN,
+ KEY_SHIFT | KEY_MOD2 | KEY_COLON,
KEY_SHIFT | KEY_MOD2 | KEY_SEMICOLON,
KEY_SHIFT | KEY_MOD2 | KEY_QUOTELEFT,
KEY_SHIFT | KEY_MOD2 | KEY_QUOTERIGHT,
KEY_SHIFT | KEY_MOD2 | KEY_BRACKETLEFT,
KEY_SHIFT | KEY_MOD2 | KEY_BRACKETRIGHT,
+ KEY_SHIFT | KEY_MOD2 | KEY_RIGHTCURLYBRACKET,
KEY_SHIFT | KEY_MOD2 | KEY_POINT,
KEY_SHIFT | KEY_MOD2 | KEY_COMMA,
KEY_SHIFT | KEY_MOD2 | KEY_TILDE,
@@ -501,11 +515,14 @@ const sal_uInt16 KEYCODE_ARRAY[] = { KEY_F1,
KEY_MOD1 | KEY_MOD2 | KEY_X,
KEY_MOD1 | KEY_MOD2 | KEY_Y,
KEY_MOD1 | KEY_MOD2 | KEY_Z,
+ KEY_MOD1 | KEY_MOD2 | KEY_NUMBERSIGN,
+ KEY_MOD1 | KEY_MOD2 | KEY_COLON,
KEY_MOD1 | KEY_MOD2 | KEY_SEMICOLON,
KEY_MOD1 | KEY_MOD2 | KEY_QUOTELEFT,
KEY_MOD1 | KEY_MOD2 | KEY_QUOTERIGHT,
KEY_MOD1 | KEY_MOD2 | KEY_BRACKETLEFT,
KEY_MOD1 | KEY_MOD2 | KEY_BRACKETRIGHT,
+ KEY_MOD1 | KEY_MOD2 | KEY_RIGHTCURLYBRACKET,
KEY_MOD1 | KEY_MOD2 | KEY_POINT,
KEY_MOD1 | KEY_MOD2 | KEY_COMMA,
KEY_MOD1 | KEY_MOD2 | KEY_TILDE,
@@ -578,11 +595,14 @@ const sal_uInt16 KEYCODE_ARRAY[] = { KEY_F1,
KEY_SHIFT | KEY_MOD1 | KEY_MOD2 | KEY_X,
KEY_SHIFT | KEY_MOD1 | KEY_MOD2 | KEY_Y,
KEY_SHIFT | KEY_MOD1 | KEY_MOD2 | KEY_Z,
+ KEY_SHIFT | KEY_MOD1 | KEY_MOD2 | KEY_NUMBERSIGN,
+ KEY_SHIFT | KEY_MOD1 | KEY_MOD2 | KEY_COLON,
KEY_SHIFT | KEY_MOD1 | KEY_MOD2 | KEY_SEMICOLON,
KEY_SHIFT | KEY_MOD1 | KEY_MOD2 | KEY_QUOTELEFT,
KEY_SHIFT | KEY_MOD1 | KEY_MOD2 | KEY_QUOTERIGHT,
KEY_SHIFT | KEY_MOD1 | KEY_MOD2 | KEY_BRACKETLEFT,
KEY_SHIFT | KEY_MOD1 | KEY_MOD2 | KEY_BRACKETRIGHT,
+ KEY_SHIFT | KEY_MOD1 | KEY_MOD2 | KEY_RIGHTCURLYBRACKET,
KEY_SHIFT | KEY_MOD1 | KEY_MOD2 | KEY_POINT,
KEY_SHIFT | KEY_MOD1 | KEY_MOD2 | KEY_COMMA,
KEY_SHIFT | KEY_MOD1 | KEY_MOD2 | KEY_TILDE,
@@ -657,11 +677,14 @@ const sal_uInt16 KEYCODE_ARRAY[] = { KEY_F1,
KEY_MOD3 | KEY_X,
KEY_MOD3 | KEY_Y,
KEY_MOD3 | KEY_Z,
+ KEY_MOD2 | KEY_NUMBERSIGN,
+ KEY_MOD3 | KEY_COLON,
KEY_MOD3 | KEY_SEMICOLON,
KEY_MOD3 | KEY_QUOTELEFT,
KEY_MOD3 | KEY_QUOTERIGHT,
KEY_MOD3 | KEY_BRACKETLEFT,
KEY_MOD3 | KEY_BRACKETRIGHT,
+ KEY_MOD3 | KEY_RIGHTCURLYBRACKET,
KEY_MOD3 | KEY_POINT,
KEY_MOD3 | KEY_COMMA,
KEY_MOD3 | KEY_TILDE,
@@ -740,11 +763,14 @@ const sal_uInt16 KEYCODE_ARRAY[] = { KEY_F1,
KEY_SHIFT | KEY_MOD3 | KEY_X,
KEY_SHIFT | KEY_MOD3 | KEY_Y,
KEY_SHIFT | KEY_MOD3 | KEY_Z,
+ KEY_SHIFT | KEY_MOD3 | KEY_NUMBERSIGN,
+ KEY_SHIFT | KEY_MOD3 | KEY_COLON,
KEY_SHIFT | KEY_MOD3 | KEY_SEMICOLON,
KEY_SHIFT | KEY_MOD3 | KEY_QUOTELEFT,
KEY_SHIFT | KEY_MOD3 | KEY_QUOTERIGHT,
KEY_SHIFT | KEY_MOD3 | KEY_BRACKETLEFT,
KEY_SHIFT | KEY_MOD3 | KEY_BRACKETRIGHT,
+ KEY_SHIFT | KEY_MOD3 | KEY_RIGHTCURLYBRACKET,
KEY_SHIFT | KEY_MOD3 | KEY_POINT,
KEY_SHIFT | KEY_MOD3 | KEY_COMMA,
KEY_SHIFT | KEY_MOD3 | KEY_TILDE,
@@ -785,7 +811,7 @@ const sal_uInt16 KEYCODE_ARRAY[] = { KEY_F1,
#endif
};
-const sal_uInt16 KEYCODE_ARRAY_SIZE = SAL_N_ELEMENTS(KEYCODE_ARRAY);
+const sal_uInt16 KEYCODE_ARRAY_SIZE = std::size(KEYCODE_ARRAY);
/** select the entry, which match the current key input ... excepting
keys, which are used for the dialog itself.
@@ -804,7 +830,7 @@ IMPL_LINK(SfxAcceleratorConfigPage, KeyInputHdl, const KeyEvent&, rKey, bool)
for (int i = 0, nCount = m_xEntriesBox->n_children(); i < nCount; ++i)
{
- TAccInfo* pUserData = reinterpret_cast<TAccInfo*>(m_xEntriesBox->get_id(i).toInt64());
+ TAccInfo* pUserData = weld::fromId<TAccInfo*>(m_xEntriesBox->get_id(i));
if (pUserData)
{
sal_uInt16 nCode2 = pUserData->m_aKey.GetCode();
@@ -851,16 +877,16 @@ SfxAcceleratorConfigPage::SfxAcceleratorConfigPage(weld::Container* pPage,
, m_xResetButton(m_xBuilder->weld_button("reset"))
{
Size aSize(m_xEntriesBox->get_approximate_digit_width() * 40,
- m_xEntriesBox->get_height_rows(12));
+ m_xEntriesBox->get_height_rows(10));
m_xEntriesBox->set_size_request(aSize.Width(), aSize.Height());
aSize = Size(m_xEntriesBox->get_approximate_digit_width() * 19,
- m_xEntriesBox->get_height_rows(10));
+ m_xEntriesBox->get_height_rows(9));
m_xGroupLBox->set_size_request(aSize.Width(), aSize.Height());
aSize = Size(m_xEntriesBox->get_approximate_digit_width() * 21,
- m_xEntriesBox->get_height_rows(10));
+ m_xEntriesBox->get_height_rows(9));
m_xFunctionBox->set_size_request(aSize.Width(), aSize.Height());
aSize = Size(m_xEntriesBox->get_approximate_digit_width() * 20,
- m_xEntriesBox->get_height_rows(10));
+ m_xEntriesBox->get_height_rows(9));
m_xKeyBox->set_size_request(aSize.Width(), aSize.Height());
// install handler functions
@@ -918,7 +944,7 @@ SfxAcceleratorConfigPage::~SfxAcceleratorConfigPage()
// free memory - remove all dynamic user data
for (int i = 0, nCount = m_xEntriesBox->n_children(); i < nCount; ++i)
{
- TAccInfo* pUserData = reinterpret_cast<TAccInfo*>(m_xEntriesBox->get_id(i).toInt64());
+ TAccInfo* pUserData = weld::fromId<TAccInfo*>(m_xEntriesBox->get_id(i));
delete pUserData;
}
}
@@ -1003,7 +1029,7 @@ void SfxAcceleratorConfigPage::Init(const uno::Reference<ui::XAcceleratorConfigu
if (sKey.isEmpty())
continue;
TAccInfo* pEntry = new TAccInfo(i1, 0 /*nListPos*/, aKey);
- m_xEntriesBox->append(OUString::number(reinterpret_cast<sal_Int64>(pEntry)), sKey);
+ m_xEntriesBox->append(weld::toId(pEntry), sKey);
int nPos = m_xEntriesBox->n_children() - 1;
m_xEntriesBox->set_text(nPos, OUString(), 1);
m_xEntriesBox->set_sensitive(nPos, true);
@@ -1027,7 +1053,7 @@ void SfxAcceleratorConfigPage::Init(const uno::Reference<ui::XAcceleratorConfigu
m_xEntriesBox->set_text(nPos, sLabel, 1);
- TAccInfo* pEntry = reinterpret_cast<TAccInfo*>(m_xEntriesBox->get_id(nPos).toInt64());
+ TAccInfo* pEntry = weld::fromId<TAccInfo*>(m_xEntriesBox->get_id(nPos));
pEntry->m_bIsConfigurable = true;
pEntry->m_sCommand = sCommand;
@@ -1045,7 +1071,7 @@ void SfxAcceleratorConfigPage::Init(const uno::Reference<ui::XAcceleratorConfigu
continue;
// Hardcoded function mapped so no ID possible and mark entry as not changeable
- TAccInfo* pEntry = reinterpret_cast<TAccInfo*>(m_xEntriesBox->get_id(nPos).toInt64());
+ TAccInfo* pEntry = weld::fromId<TAccInfo*>(m_xEntriesBox->get_id(nPos));
pEntry->m_bIsConfigurable = false;
m_xEntriesBox->set_sensitive(nPos, false);
@@ -1062,7 +1088,7 @@ void SfxAcceleratorConfigPage::Apply(const uno::Reference<ui::XAcceleratorConfig
// physical ones!
for (int i = 0, nCount = m_xEntriesBox->n_children(); i < nCount; ++i)
{
- TAccInfo* pUserData = reinterpret_cast<TAccInfo*>(m_xEntriesBox->get_id(i).toInt64());
+ TAccInfo* pUserData = weld::fromId<TAccInfo*>(m_xEntriesBox->get_id(i));
OUString sCommand;
awt::KeyEvent aAWTKey;
@@ -1141,7 +1167,7 @@ IMPL_LINK_NOARG(SfxAcceleratorConfigPage, ChangeHdl, weld::Button&, void)
if (nPos == -1)
return;
- TAccInfo* pEntry = reinterpret_cast<TAccInfo*>(m_xEntriesBox->get_id(nPos).toInt64());
+ TAccInfo* pEntry = weld::fromId<TAccInfo*>(m_xEntriesBox->get_id(nPos));
OUString sNewCommand = m_xFunctionBox->GetCurCommand();
OUString sLabel = m_xFunctionBox->GetCurLabel();
if (sLabel.isEmpty())
@@ -1160,7 +1186,7 @@ IMPL_LINK_NOARG(SfxAcceleratorConfigPage, RemoveHdl, weld::Button&, void)
if (nPos == -1)
return;
- TAccInfo* pEntry = reinterpret_cast<TAccInfo*>(m_xEntriesBox->get_id(nPos).toInt64());
+ TAccInfo* pEntry = weld::fromId<TAccInfo*>(m_xEntriesBox->get_id(nPos));
// remove function name from selected entry
m_xEntriesBox->set_text(nPos, OUString(), 1);
@@ -1173,7 +1199,7 @@ IMPL_LINK(SfxAcceleratorConfigPage, SelectHdl, weld::TreeView&, rListBox, void)
{
if (&rListBox == m_xEntriesBox.get())
{
- TAccInfo* pEntry = reinterpret_cast<TAccInfo*>(m_xEntriesBox->get_selected_id().toInt64());
+ TAccInfo* pEntry = weld::fromId<TAccInfo*>(m_xEntriesBox->get_selected_id());
OUString sPossibleNewCommand = m_xFunctionBox->GetCurCommand();
@@ -1215,7 +1241,7 @@ IMPL_LINK(SfxAcceleratorConfigPage, SelectHdl, weld::TreeView&, rListBox, void)
m_xChangeButton->set_sensitive(false);
// #i36994 First selected can return null!
- TAccInfo* pEntry = reinterpret_cast<TAccInfo*>(m_xEntriesBox->get_selected_id().toInt64());
+ TAccInfo* pEntry = weld::fromId<TAccInfo*>(m_xEntriesBox->get_selected_id());
if (pEntry)
{
OUString sPossibleNewCommand = m_xFunctionBox->GetCurCommand();
@@ -1234,12 +1260,10 @@ IMPL_LINK(SfxAcceleratorConfigPage, SelectHdl, weld::TreeView&, rListBox, void)
{
for (int i = 0, nCount = m_xEntriesBox->n_children(); i < nCount; ++i)
{
- TAccInfo* pUserData
- = reinterpret_cast<TAccInfo*>(m_xEntriesBox->get_id(i).toInt64());
+ TAccInfo* pUserData = weld::fromId<TAccInfo*>(m_xEntriesBox->get_id(i));
if (pUserData && pUserData->m_sCommand == sPossibleNewCommand)
{
- m_xKeyBox->append(OUString::number(reinterpret_cast<sal_Int64>(pUserData)),
- pUserData->m_aKey.GetName());
+ m_xKeyBox->append(weld::toId(pUserData), pUserData->m_aKey.GetName());
}
}
}
@@ -1249,7 +1273,7 @@ IMPL_LINK(SfxAcceleratorConfigPage, SelectHdl, weld::TreeView&, rListBox, void)
{
// goto selected "key" entry of the key box
int nP2 = -1;
- TAccInfo* pU2 = reinterpret_cast<TAccInfo*>(m_xKeyBox->get_selected_id().toInt64());
+ TAccInfo* pU2 = weld::fromId<TAccInfo*>(m_xKeyBox->get_selected_id());
if (pU2)
nP2 = MapKeyCodeToPos(pU2->m_aKey);
if (nP2 != -1)
@@ -1474,6 +1498,13 @@ bool SfxAcceleratorConfigPage::FillItemSet(SfxItemSet*)
try
{
m_xAct->store();
+ css::uno::Reference<css::beans::XPropertySet> xFrameProps(m_xFrame,
+ css::uno::UNO_QUERY_THROW);
+ css::uno::Reference<css::frame::XLayoutManager> xLayoutManager;
+ xFrameProps->getPropertyValue("LayoutManager") >>= xLayoutManager;
+ css::uno::Reference<css::beans::XPropertySet> xLayoutProps(xLayoutManager,
+ css::uno::UNO_QUERY_THROW);
+ xLayoutProps->setPropertyValue("RefreshContextToolbarToolTip", css::uno::Any(true));
}
catch (const uno::RuntimeException&)
{
@@ -1512,10 +1543,9 @@ void SfxAcceleratorConfigPage::Reset(const SfxItemSet* rSet)
RadioHdl(*m_xOfficeButton);
#if HAVE_FEATURE_SCRIPTING
- const SfxPoolItem* pMacroItem = nullptr;
- if (SfxItemState::SET == rSet->GetItemState(SID_MACROINFO, true, &pMacroItem))
+ if (const SfxMacroInfoItem* pMacroItem = rSet->GetItemIfSet(SID_MACROINFO))
{
- m_pMacroInfoItem = &dynamic_cast<const SfxMacroInfoItem&>(*pMacroItem);
+ m_pMacroInfoItem = pMacroItem;
m_xGroupLBox->SelectMacro(m_pMacroInfoItem);
}
#else
@@ -1528,7 +1558,7 @@ sal_Int32 SfxAcceleratorConfigPage::MapKeyCodeToPos(const vcl::KeyCode& aKey) co
sal_uInt16 nCode1 = aKey.GetCode() + aKey.GetModifier();
for (int i = 0, nCount = m_xEntriesBox->n_children(); i < nCount; ++i)
{
- TAccInfo* pUserData = reinterpret_cast<TAccInfo*>(m_xEntriesBox->get_id(i).toInt64());
+ TAccInfo* pUserData = weld::fromId<TAccInfo*>(m_xEntriesBox->get_id(i));
if (pUserData)
{
sal_uInt16 nCode2 = pUserData->m_aKey.GetCode() + pUserData->m_aKey.GetModifier();
diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx
index 8531907e805c..ff5702121755 100644
--- a/cui/source/customize/cfg.cxx
+++ b/cui/source/customize/cfg.cxx
@@ -24,6 +24,7 @@
#include <stdlib.h>
#include <typeinfo>
+#include <utility>
#include <vcl/stdtext.hxx>
#include <vcl/commandinfoprovider.hxx>
#include <vcl/event.hxx>
@@ -35,6 +36,7 @@
#include <vcl/decoview.hxx>
#include <vcl/virdev.hxx>
+#include <sfx2/minfitem.hxx>
#include <sfx2/sfxhelp.hxx>
#include <sfx2/viewfrm.hxx>
#include <sfx2/filedlghelper.hxx>
@@ -42,7 +44,7 @@
#include <svl/stritem.hxx>
#include <rtl/ustrbuf.hxx>
#include <tools/debug.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <algorithm>
@@ -90,6 +92,7 @@
#include <comphelper/propertysequence.hxx>
#include <comphelper/propertyvalue.hxx>
#include <comphelper/processfactory.hxx>
+#include <config_features.h>
namespace uno = com::sun::star::uno;
namespace frame = com::sun::star::frame;
@@ -214,18 +217,29 @@ SvxConfigDialog::SvxConfigDialog(weld::Window * pParent, const SfxItemSet* pInSe
AddTabPage("keyboard", CreateKeyboardConfigPage, nullptr);
AddTabPage("events", CreateSvxEventConfigPage, nullptr);
- const SfxPoolItem* pItem =
- pInSet->GetItem( pInSet->GetPool()->GetWhich( SID_CONFIG ) );
-
- if ( pItem )
+ if (const SfxPoolItem* pItem = pInSet->GetItem(SID_CONFIG))
{
OUString text = static_cast<const SfxStringItem*>(pItem)->GetValue();
-
if (text.startsWith( ITEM_TOOLBAR_URL ) )
- {
SetCurPageId("toolbars");
- }
+ else if (text.startsWith( ITEM_EVENT_URL) )
+ SetCurPageId("events");
}
+#if HAVE_FEATURE_SCRIPTING
+ else if (pInSet->GetItemIfSet(SID_MACROINFO))
+ {
+ // for the "assign" button in the Basic Macros chooser automatically switch
+ // to the keyboard tab in which this macro will be pre-selected for assigning
+ // to a keystroke
+ SetCurPageId("keyboard");
+ }
+#endif
+}
+
+void SvxConfigDialog::ActivatePage(const OUString& rPage)
+{
+ SfxTabDialogController::ActivatePage(rPage);
+ GetResetButton()->set_visible(rPage != "keyboard");
}
void SvxConfigDialog::SetFrame(const css::uno::Reference<css::frame::XFrame>& xFrame)
@@ -243,7 +257,7 @@ void SvxConfigDialog::SetFrame(const css::uno::Reference<css::frame::XFrame>& xF
RemoveTabPage("keyboard");
}
-void SvxConfigDialog::PageCreated(const OString &rId, SfxTabPage& rPage)
+void SvxConfigDialog::PageCreated(const OUString &rId, SfxTabPage& rPage)
{
if (rId == "menus" || rId == "keyboard" || rId == "notebookbar"
|| rId == "toolbars" || rId == "contextmenus")
@@ -267,16 +281,16 @@ void SvxConfigDialog::PageCreated(const OString &rId, SfxTabPage& rPage)
uno::Reference< css::ui::XImageManager>* SaveInData::xDefaultImgMgr = nullptr;
SaveInData::SaveInData(
- const uno::Reference< css::ui::XUIConfigurationManager >& xCfgMgr,
- const uno::Reference< css::ui::XUIConfigurationManager >& xParentCfgMgr,
+ uno::Reference< css::ui::XUIConfigurationManager > xCfgMgr,
+ uno::Reference< css::ui::XUIConfigurationManager > xParentCfgMgr,
const OUString& aModuleId,
bool isDocConfig )
:
bModified( false ),
bDocConfig( isDocConfig ),
bReadOnly( false ),
- m_xCfgMgr( xCfgMgr ),
- m_xParentCfgMgr( xParentCfgMgr ),
+ m_xCfgMgr(std::move( xCfgMgr )),
+ m_xParentCfgMgr(std::move( xParentCfgMgr )),
m_aSeparatorSeq{ comphelper::makePropertyValue(ITEM_DESCRIPTOR_TYPE,
css::ui::ItemType::SEPARATOR_LINE) }
{
@@ -478,7 +492,7 @@ void SaveInData::LoadSubMenus( const uno::Reference< container::XIndexAccess >&
if ( a >>= aPropSeq )
{
OUString aMenuLabel;
- for ( const beans::PropertyValue& prop : std::as_const(aPropSeq) )
+ for (const beans::PropertyValue& prop : aPropSeq)
{
if ( bContextMenu )
{
@@ -709,7 +723,7 @@ OUString ContextMenuSaveInData::GetUIName( const OUString& rResourceURL )
catch ( const css::uno::Exception& )
{}
- for ( const auto& aProp : std::as_const(aProps) )
+ for (const auto& aProp : aProps)
{
if ( aProp.Name == ITEM_DESCRIPTOR_UINAME )
{
@@ -737,7 +751,7 @@ SvxEntries* ContextMenuSaveInData::GetEntries()
catch ( const css::lang::IllegalArgumentException& )
{}
- for ( const auto& aElement : std::as_const(aElementsInfo) )
+ for (const auto& aElement : aElementsInfo)
{
OUString aUrl;
for ( const auto& aElementProp : aElement )
@@ -785,7 +799,7 @@ SvxEntries* ContextMenuSaveInData::GetEntries()
catch ( const css::lang::IllegalArgumentException& )
{}
- for ( const auto& aElement : std::as_const(aParentElementsInfo) )
+ for (const auto& aElement : aParentElementsInfo)
{
OUString aUrl;
for ( const auto& aElementProp : aElement )
@@ -931,6 +945,7 @@ SvxMenuEntriesListBox::SvxMenuEntriesListBox(std::unique_ptr<weld::TreeView> xCo
m_xControl->enable_toggle_buttons(weld::ColumnToggleType::Check);
CreateDropDown();
m_xControl->connect_key_press(LINK(this, SvxMenuEntriesListBox, KeyInputHdl));
+ m_xControl->connect_query_tooltip(LINK(this, SvxMenuEntriesListBox, QueryTooltip));
}
SvxMenuEntriesListBox::~SvxMenuEntriesListBox()
@@ -962,6 +977,21 @@ IMPL_LINK(SvxMenuEntriesListBox, KeyInputHdl, const KeyEvent&, rKeyEvent, bool)
return true;
}
+IMPL_LINK(SvxMenuEntriesListBox, QueryTooltip, const weld::TreeIter&, rIter, OUString)
+{
+ SvxConfigEntry *pEntry = weld::fromId<SvxConfigEntry*>(m_xControl->get_id(rIter));
+ if (!pEntry || pEntry->GetCommand().isEmpty())
+ return OUString();
+ const OUString sCommand(pEntry->GetCommand());
+ OUString aModuleName(vcl::CommandInfoProvider::GetModuleIdentifier(m_pPage->GetFrame()));
+ auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(sCommand, aModuleName);
+ OUString sTooltipLabel = vcl::CommandInfoProvider::GetTooltipForCommand(sCommand, aProperties,
+ m_pPage->GetFrame());
+ return CuiResId(RID_CUISTR_COMMANDLABEL) + ": " + pEntry->GetName().replaceFirst("~", "") + "\n" +
+ CuiResId(RID_CUISTR_COMMANDNAME) + ": " + sCommand + "\n" +
+ CuiResId(RID_CUISTR_COMMANDTIP) + ": " + sTooltipLabel.replaceFirst("~", "");
+}
+
/******************************************************************************
*
* SvxConfigPage is the abstract base class on which the Menu and Toolbar
@@ -987,9 +1017,11 @@ SvxConfigPage::SvxConfigPage(weld::Container* pPage, weld::DialogController* pCo
, m_xMoveUpButton(m_xBuilder->weld_button("up"))
, m_xMoveDownButton(m_xBuilder->weld_button("down"))
, m_xSaveInListBox(m_xBuilder->weld_combo_box("savein"))
+ , m_xCustomizeBox(m_xBuilder->weld_widget("customizebox"))
, m_xInsertBtn(m_xBuilder->weld_menu_button("insert"))
, m_xModifyBtn(m_xBuilder->weld_menu_button("modify"))
, m_xResetBtn(m_xBuilder->weld_button("defaultsbtn"))
+ , m_xCommandButtons(m_xBuilder->weld_widget("arrowgrid"))
, m_xAddCommandButton(m_xBuilder->weld_button("add"))
, m_xRemoveCommandButton(m_xBuilder->weld_button("remove"))
{
@@ -1022,7 +1054,7 @@ SvxConfigPage::~SvxConfigPage()
int cnt = m_xSaveInListBox->get_count();
for(int i=0; i < cnt; ++i)
{
- SaveInData *pData = reinterpret_cast<SaveInData*>(m_xSaveInListBox->get_id(i).toInt64());
+ SaveInData *pData = weld::fromId<SaveInData*>(m_xSaveInListBox->get_id(i));
delete pData;
}
}
@@ -1074,7 +1106,7 @@ void SvxConfigPage::Reset( const SfxItemSet* )
if ( pModuleData != nullptr )
{
- OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pModuleData)));
+ OUString sId(weld::toId(pModuleData));
m_xSaveInListBox->append(sId, utl::ConfigManager::getProductName() + " " + aModuleName);
}
@@ -1105,7 +1137,7 @@ void SvxConfigPage::Reset( const SfxItemSet* )
if ( !pDocData->IsReadOnly() )
{
- OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pDocData)));
+ OUString sId(weld::toId(pDocData));
m_xSaveInListBox->append(sId, aTitle);
}
}
@@ -1171,7 +1203,7 @@ void SvxConfigPage::Reset( const SfxItemSet* )
DBG_UNHANDLED_EXCEPTION("cui.customize");
}
- for ( uno::Reference < frame::XFrame > const & xf : std::as_const(aFrameList) )
+ for (uno::Reference<frame::XFrame> const& xf : aFrameList)
{
if ( xf.is() && xf != m_xFrame )
{
@@ -1214,7 +1246,7 @@ void SvxConfigPage::Reset( const SfxItemSet* )
if ( pData && !pData->IsReadOnly() )
{
- OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pData)));
+ OUString sId(weld::toId(pData));
m_xSaveInListBox->append(sId, aTitle2);
}
}
@@ -1261,8 +1293,11 @@ OUString SvxConfigPage::GetFrameWithDefaultAndIdentify( uno::Reference< frame::X
_inout_rxFrame = xDesktop->getCurrentFrame();
}
- if ( !_inout_rxFrame.is() && SfxViewFrame::Current() )
- _inout_rxFrame = SfxViewFrame::Current()->GetFrame().GetFrameInterface();
+ if ( !_inout_rxFrame.is())
+ {
+ if (SfxViewFrame* pViewFrame = SfxViewFrame::Current())
+ _inout_rxFrame = pViewFrame->GetFrame().GetFrameInterface();
+ }
if ( !_inout_rxFrame.is() )
{
@@ -1284,7 +1319,7 @@ OUString SvxConfigPage::GetScriptURL() const
{
OUString result;
- SfxGroupInfo_Impl *pData = reinterpret_cast<SfxGroupInfo_Impl*>(m_xFunctions->get_selected_id().toInt64());
+ SfxGroupInfo_Impl *pData = weld::fromId<SfxGroupInfo_Impl*>(m_xFunctions->get_selected_id());
if (pData)
{
if ( ( pData->nKind == SfxCfgKind::FUNCTION_SLOT ) ||
@@ -1312,7 +1347,7 @@ bool SvxConfigPage::FillItemSet( SfxItemSet* )
OUString sId = m_xSaveInListBox->get_id(i);
if (sId != notebookbarTabScope)
{
- SaveInData* pData = reinterpret_cast<SaveInData*>(sId.toInt64());
+ SaveInData* pData = weld::fromId<SaveInData*>(sId);
result = pData->Apply();
}
}
@@ -1323,7 +1358,7 @@ IMPL_LINK_NOARG(SvxConfigPage, SelectSaveInLocation, weld::ComboBox&, void)
{
OUString sId = m_xSaveInListBox->get_active_id();
if (sId != notebookbarTabScope)
- pCurrentSaveInData = reinterpret_cast<SaveInData*>(sId.toInt64());
+ pCurrentSaveInData = weld::fromId<SaveInData*>(sId);
Init();
}
@@ -1336,7 +1371,7 @@ void SvxConfigPage::ReloadTopLevelListBox( SvxConfigEntry const * pToSelect )
{
for (auto const& entryData : *GetSaveInData()->GetEntries())
{
- OUString sId(OUString::number(reinterpret_cast<sal_Int64>(entryData)));
+ OUString sId(weld::toId(entryData));
m_xTopLevelListBox->append(sId, SvxConfigPageHelper::stripHotKey(entryData->GetName()));
if (entryData == pToSelect)
@@ -1370,7 +1405,7 @@ void SvxConfigPage::AddSubMenusToUI(
{
OUString subMenuTitle = OUString::Concat(rBaseTitle) + aMenuSeparatorStr + SvxConfigPageHelper::stripHotKey(entryData->GetName());
- OUString sId(OUString::number(reinterpret_cast<sal_Int64>(entryData)));
+ OUString sId(weld::toId(entryData));
m_xTopLevelListBox->append(sId, subMenuTitle);
AddSubMenusToUI( subMenuTitle, entryData );
@@ -1495,7 +1530,7 @@ int SvxConfigPage::AppendEntry(
int nCurEntry =
nTarget != -1 ? nTarget : m_xContentsListBox->get_selected_index();
- OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pNewEntryData)));
+ OUString sId(weld::toId(pNewEntryData));
if (nCurEntry == -1 || nCurEntry == m_xContentsListBox->n_children() - 1)
{
@@ -1506,7 +1541,7 @@ int SvxConfigPage::AppendEntry(
else
{
SvxConfigEntry* pEntryData =
- reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(nCurEntry).toInt64());
+ weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(nCurEntry));
SvxEntries::iterator iter = pEntries->begin();
SvxEntries::const_iterator end = pEntries->end();
@@ -1548,7 +1583,7 @@ namespace
template<typename itertype> void TmplInsertEntryIntoUI(SvxConfigEntry* pNewEntryData, weld::TreeView& rTreeView, itertype& rIter, SaveInData* pSaveInData,
VirtualDevice& rDropDown, bool bMenu)
{
- OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pNewEntryData)));
+ OUString sId(weld::toId(pNewEntryData));
rTreeView.set_id(rIter, sId);
@@ -1618,7 +1653,7 @@ IMPL_LINK_NOARG(SvxConfigPage, SelectFunctionHdl, weld::TreeView&, void)
}
else
{
- SfxGroupInfo_Impl *pData = reinterpret_cast<SfxGroupInfo_Impl*>(m_xFunctions->get_selected_id().toInt64());
+ SfxGroupInfo_Impl *pData = weld::fromId<SfxGroupInfo_Impl*>(m_xFunctions->get_selected_id());
if (pData)
{
bool bIsExperimental
@@ -1716,10 +1751,10 @@ bool SvxConfigPage::MoveEntryData(int nSourceEntry, int nTargetEntry)
SvxEntries* pEntries = GetTopLevelSelection()->GetEntries();
SvxConfigEntry* pSourceData =
- reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(nSourceEntry).toInt64());
+ weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(nSourceEntry));
SvxConfigEntry* pTargetData =
- reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(nTargetEntry).toInt64());
+ weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(nTargetEntry));
if ( pSourceData == nullptr || pTargetData == nullptr )
return false;
@@ -1760,7 +1795,7 @@ SvxMainMenuOrganizerDialog::SvxMainMenuOrganizerDialog(
mpEntries.reset( new SvxEntries );
for (auto const& entry : *entries)
{
- m_xMenuListBox->append(OUString::number(reinterpret_cast<sal_uInt64>(entry)),
+ m_xMenuListBox->append(weld::toId(entry),
SvxConfigPageHelper::stripHotKey(entry->GetName()));
mpEntries->push_back(entry);
if (entry == selection)
@@ -1784,7 +1819,7 @@ SvxMainMenuOrganizerDialog::SvxMainMenuOrganizerDialog(
pNewEntryData->SetUserDefined();
pNewEntryData->SetMain();
- m_sNewMenuEntryId = OUString::number(reinterpret_cast<sal_uInt64>(pNewEntryData));
+ m_sNewMenuEntryId = weld::toId(pNewEntryData);
m_xMenuListBox->append(m_sNewMenuEntryId,
SvxConfigPageHelper::stripHotKey(pNewEntryData->GetName()));
m_xMenuListBox->select(m_xMenuListBox->n_children() - 1);
@@ -1823,7 +1858,7 @@ IMPL_LINK_NOARG(SvxMainMenuOrganizerDialog, ModifyHdl, weld::Entry&, void)
return;
}
- SvxConfigEntry* pNewEntryData = reinterpret_cast<SvxConfigEntry*>(m_sNewMenuEntryId.toUInt64());
+ SvxConfigEntry* pNewEntryData = weld::fromId<SvxConfigEntry*>(m_sNewMenuEntryId);
pNewEntryData->SetName(m_xMenuNameEdit->get_text());
const int nNewMenuPos = m_xMenuListBox->find_id(m_sNewMenuEntryId);
@@ -1880,14 +1915,14 @@ SvxConfigEntry* SvxMainMenuOrganizerDialog::GetSelectedEntry()
const int nSelected(m_xMenuListBox->get_selected_index());
if (nSelected == -1)
return nullptr;
- return reinterpret_cast<SvxConfigEntry*>(m_xMenuListBox->get_id(nSelected).toUInt64());
+ return weld::fromId<SvxConfigEntry*>(m_xMenuListBox->get_id(nSelected));
}
-SvxConfigEntry::SvxConfigEntry( const OUString& rDisplayName,
- const OUString& rCommandURL, bool bPopup, bool bParentData )
+SvxConfigEntry::SvxConfigEntry( OUString aDisplayName,
+ OUString aCommandURL, bool bPopup, bool bParentData )
: nId( 1 )
- , aLabel(rDisplayName)
- , aCommand(rCommandURL)
+ , aLabel(std::move(aDisplayName))
+ , aCommand(std::move(aCommandURL))
, bPopUp(bPopup)
, bStrEdited( false )
, bIsUserDefined( false )
@@ -1966,7 +2001,7 @@ sal_Int32 ToolbarSaveInData::GetSystemStyle( const OUString& rResourceURL )
if ( a >>= aProps )
{
- for ( beans::PropertyValue const & prop : std::as_const(aProps) )
+ for (beans::PropertyValue const& prop : aProps)
{
if ( prop.Name == ITEM_DESCRIPTOR_STYLE )
{
@@ -2093,7 +2128,7 @@ OUString ToolbarSaveInData::GetSystemUIName( const OUString& rResourceURL )
if ( a >>= aProps )
{
- for ( beans::PropertyValue const & prop : std::as_const(aProps) )
+ for (beans::PropertyValue const& prop : aProps)
{
if ( prop.Name == ITEM_DESCRIPTOR_UINAME )
{
@@ -2120,7 +2155,7 @@ OUString ToolbarSaveInData::GetSystemUIName( const OUString& rResourceURL )
uno::Sequence< beans::PropertyValue > aPropSeq;
if ( a >>= aPropSeq )
{
- for ( beans::PropertyValue const & prop : std::as_const(aPropSeq) )
+ for (beans::PropertyValue const& prop : aPropSeq)
{
if ( prop.Name == ITEM_DESCRIPTOR_LABEL )
{
@@ -2622,7 +2657,7 @@ void ToolbarSaveInData::LoadToolbar(
uno::Sequence< beans::PropertyValue > aPropSeq;
if ( a >>= aPropSeq )
{
- for ( beans::PropertyValue const & prop : std::as_const(aPropSeq) )
+ for (beans::PropertyValue const& prop : aPropSeq)
{
if ( prop.Name == "Name" )
{
@@ -2658,7 +2693,6 @@ void ToolbarSaveInData::LoadToolbar(
SvxNewToolbarDialog::SvxNewToolbarDialog(weld::Window* pWindow, const OUString& rName)
: GenericDialogController(pWindow, "cui/ui/newtoolbardialog.ui", "NewToolbarDialog")
, m_xEdtName(m_xBuilder->weld_entry("edit"))
- , m_xBtnOK(m_xBuilder->weld_button("ok"))
, m_xSaveInListBox(m_xBuilder->weld_combo_box("savein"))
{
m_xEdtName->set_text(rName);
@@ -2675,11 +2709,11 @@ SvxNewToolbarDialog::~SvxNewToolbarDialog()
*
*******************************************************************************/
SvxIconSelectorDialog::SvxIconSelectorDialog(weld::Window *pWindow,
- const uno::Reference< css::ui::XImageManager >& rXImageManager,
- const uno::Reference< css::ui::XImageManager >& rXParentImageManager)
+ uno::Reference< css::ui::XImageManager > xImageManager,
+ uno::Reference< css::ui::XImageManager > xParentImageManager)
: GenericDialogController(pWindow, "cui/ui/iconselectordialog.ui", "IconSelector")
- , m_xImageManager(rXImageManager)
- , m_xParentImageManager(rXParentImageManager)
+ , m_xImageManager(std::move(xImageManager))
+ , m_xParentImageManager(std::move(xParentImageManager))
, m_xTbSymbol(new ValueSet(m_xBuilder->weld_scrolled_window("symbolswin", true)))
, m_xTbSymbolWin(new weld::CustomWeld(*m_xBuilder, "symbolsToolbar", *m_xTbSymbol))
, m_xFtNote(m_xBuilder->weld_label("noteLabel"))
@@ -2909,8 +2943,7 @@ IMPL_LINK_NOARG(SvxIconSelectorDialog, DeleteHdl, weld::Button&, void)
sal_uInt16 nId = m_xTbSymbol->GetSelectedItemId();
- OUString aSelImageText = m_xTbSymbol->GetItemText( nId );
- uno::Sequence< OUString > URLs { aSelImageText };
+ uno::Sequence<OUString> URLs { m_xTbSymbol->GetItemText(nId) };
m_xTbSymbol->RemoveItem(nId);
m_xImportedImageManager->removeImages( SvxConfigPageHelper::GetImageType(), URLs );
if ( m_xImportedImageManager->isModified() )
diff --git a/cui/source/customize/cfgutil.cxx b/cui/source/customize/cfgutil.cxx
index baf37c92ce8a..3a2cdbc1b05e 100644
--- a/cui/source/customize/cfgutil.cxx
+++ b/cui/source/customize/cfgutil.cxx
@@ -49,14 +49,16 @@
#include <sal/log.hxx>
#include <osl/diagnose.h>
#include <dialmgr.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <vcl/commandevent.hxx>
#include <vcl/commandinfoprovider.hxx>
#include <vcl/help.hxx>
#include <vcl/svapp.hxx>
+#include <o3tl/string_view.hxx>
#include <sfx2/sidebar/ResourceManager.hxx>
#include <sfx2/sidebar/Context.hxx>
+#include <unotools/viewoptions.hxx>
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -77,7 +79,9 @@ const char CMDURL_STYLEPROT_ONLY[] = ".uno:StyleApply?";
const char CMDURL_SPART_ONLY [] = "Style:string=";
const char CMDURL_FPART_ONLY [] = "FamilyName:string=";
-constexpr OUStringLiteral STYLEPROP_UINAME = u"DisplayName";
+constexpr OUString STYLEPROP_UINAME = u"DisplayName"_ustr;
+constexpr OUString MACRO_SELECTOR_CONFIGNAME = u"MacroSelectorDialog"_ustr;
+constexpr OUString LAST_RUN_MACRO_INFO = u"LastRunMacro"_ustr;
OUString SfxStylesInfo_Impl::generateCommand(
std::u16string_view sFamily, std::u16string_view sStyle)
@@ -242,7 +246,7 @@ std::vector< SfxStyleInfo_Impl > SfxStylesInfo_Impl::getStyles(const OUString& s
OUString CuiConfigFunctionListBox::GetHelpText( bool bConsiderParent )
{
- SfxGroupInfo_Impl *pData = reinterpret_cast<SfxGroupInfo_Impl*>(get_selected_id().toInt64());
+ SfxGroupInfo_Impl *pData = weld::fromId<SfxGroupInfo_Impl*>(get_selected_id());
if (pData)
{
if ( pData->nKind == SfxCfgKind::FUNCTION_SLOT )
@@ -262,7 +266,7 @@ OUString CuiConfigFunctionListBox::GetHelpText( bool bConsiderParent )
OUString CuiConfigFunctionListBox::GetCurCommand() const
{
- SfxGroupInfo_Impl *pData = reinterpret_cast<SfxGroupInfo_Impl*>(get_selected_id().toInt64());
+ SfxGroupInfo_Impl *pData = weld::fromId<SfxGroupInfo_Impl*>(get_selected_id());
if (!pData)
return OUString();
return pData->sCommand;
@@ -270,7 +274,7 @@ OUString CuiConfigFunctionListBox::GetCurCommand() const
OUString CuiConfigFunctionListBox::GetCurLabel() const
{
- SfxGroupInfo_Impl *pData = reinterpret_cast<SfxGroupInfo_Impl*>(get_selected_id().toInt64());
+ SfxGroupInfo_Impl *pData = weld::fromId<SfxGroupInfo_Impl*>(get_selected_id());
if (!pData)
return OUString();
if (!pData->sLabel.isEmpty())
@@ -294,7 +298,7 @@ CuiConfigFunctionListBox::~CuiConfigFunctionListBox()
IMPL_LINK(CuiConfigFunctionListBox, QueryTooltip, const weld::TreeIter&, rIter, OUString)
{
- SfxGroupInfo_Impl *pData = reinterpret_cast<SfxGroupInfo_Impl*>(m_xTreeView->get_id(rIter).toInt64());
+ SfxGroupInfo_Impl *pData = weld::fromId<SfxGroupInfo_Impl*>(m_xTreeView->get_id(rIter));
if (!pData)
return OUString();
OUString aLabel = CuiResId(RID_CUISTR_COMMANDLABEL) + ": ";
@@ -336,7 +340,7 @@ void CuiConfigFunctionListBox::ClearAll()
OUString CuiConfigFunctionListBox::GetSelectedScriptURI() const
{
- SfxGroupInfo_Impl *pData = reinterpret_cast<SfxGroupInfo_Impl*>(get_selected_id().toInt64());
+ SfxGroupInfo_Impl *pData = weld::fromId<SfxGroupInfo_Impl*>(get_selected_id());
if (pData && pData->nKind == SfxCfgKind::FUNCTION_SCRIPT)
return *static_cast<OUString*>(pData->pObject);
return OUString();
@@ -346,7 +350,6 @@ struct SvxConfigGroupBoxResource_Impl
{
OUString m_sMyMacros;
OUString m_sProdMacros;
- OUString m_sMacros;
OUString m_sDlgMacros;
OUString m_aStrGroupStyles;
OUString m_aStrGroupSidebarDecks;
@@ -357,7 +360,6 @@ struct SvxConfigGroupBoxResource_Impl
SvxConfigGroupBoxResource_Impl::SvxConfigGroupBoxResource_Impl() :
m_sMyMacros(CuiResId(RID_CUISTR_MYMACROS)),
m_sProdMacros(CuiResId(RID_CUISTR_PRODMACROS)),
- m_sMacros(CuiResId(RID_CUISTR_BASICMACROS)),
m_sDlgMacros(CuiResId(RID_CUISTR_PRODMACROS)),
m_aStrGroupStyles(CuiResId(RID_CUISTR_GROUP_STYLES)),
m_aStrGroupSidebarDecks(CuiResId(RID_CUISTR_GROUP_SIDEBARDECKS))
@@ -467,22 +469,16 @@ void CuiConfigGroupListBox::ClearAll()
m_xTreeView->clear();
}
-void CuiConfigGroupListBox::InitModule()
+sal_Int32 CuiConfigGroupListBox::InitModule()
{
try
{
+ // return the number of added groups
css::uno::Reference< css::frame::XDispatchInformationProvider > xProvider(m_xFrame, css::uno::UNO_QUERY_THROW);
css::uno::Sequence< sal_Int16 > lGroups = xProvider->getSupportedCommandGroups();
sal_Int32 c1 = lGroups.getLength();
sal_Int32 i1 = 0;
-
- if ( c1 )
- {
- // Add All Commands category
- aArr.push_back(std::make_unique<SfxGroupInfo_Impl>(SfxCfgKind::GROUP_ALLFUNCTIONS, 0));
- m_xTreeView->append(OUString::number(reinterpret_cast<sal_Int64>(aArr.back().get())),
- CuiResId(RID_CUISTR_ALLFUNCTIONS));
- }
+ sal_Int32 nAddedGroups = 0;
for (i1=0; i1<c1; ++i1)
{
@@ -500,14 +496,16 @@ void CuiConfigGroupListBox::InitModule()
{ continue; }
aArr.push_back( std::make_unique<SfxGroupInfo_Impl>( SfxCfgKind::GROUP_FUNCTION, nGroupID ) );
- m_xTreeView->append(OUString::number(reinterpret_cast<sal_Int64>(aArr.back().get())),
- sGroupName);
+ m_xTreeView->append(weld::toId(aArr.back().get()), sGroupName);
+ nAddedGroups++;
}
+ return nAddedGroups;
}
catch(const css::uno::RuntimeException&)
{ throw; }
catch(const css::uno::Exception&)
{}
+ return 0;
}
void CuiConfigGroupListBox::FillScriptList(const css::uno::Reference< css::script::browse::XBrowseNode >& xRootNode,
@@ -594,7 +592,7 @@ void CuiConfigGroupListBox::FillScriptList(const css::uno::Reference< css::scrip
aArr.push_back( std::make_unique<SfxGroupInfo_Impl>(SfxCfgKind::GROUP_SCRIPTCONTAINER,
0, static_cast<void *>( theChild.get())));
- OUString sId(OUString::number(reinterpret_cast<sal_Int64>(aArr.back().get())));
+ OUString sId(weld::toId(aArr.back().get()));
m_xTreeView->insert(pParentEntry, -1, &uiName, &sId, nullptr, nullptr, bChildOnDemand, m_xScratchIter.get());
m_xTreeView->set_image(*m_xScratchIter, aImage);
}
@@ -619,7 +617,7 @@ void CuiConfigGroupListBox::FillFunctionsList(const css::uno::Sequence<DispatchI
pGrpInfo->sCommand = rInfo.Command;
pGrpInfo->sLabel = sUIName;
pGrpInfo->sTooltip = vcl::CommandInfoProvider::GetTooltipForCommand(rInfo.Command, aProperties, m_xFrame);
- m_pFunctionListBox->append(OUString::number(reinterpret_cast<sal_Int64>(pGrpInfo)), sUIName);
+ m_pFunctionListBox->append(weld::toId(pGrpInfo), sUIName);
}
m_pFunctionListBox->thaw();
}
@@ -634,6 +632,7 @@ void CuiConfigGroupListBox::Init(const css::uno::Reference< css::uno::XComponent
m_xContext = xContext;
m_xFrame = xFrame;
+ sal_Int32 nAddedGroups = 0;
if( bEventMode )
{
m_sModuleLongName = sModuleLongName;
@@ -641,7 +640,7 @@ void CuiConfigGroupListBox::Init(const css::uno::Reference< css::uno::XComponent
m_xModuleCategoryInfo.set(m_xGlobalCategoryInfo->getByName(m_sModuleLongName), css::uno::UNO_QUERY_THROW);
m_xUICmdDescription = css::frame::theUICommandDescription::get( m_xContext );
- InitModule();
+ nAddedGroups = InitModule();
}
SAL_INFO("cui.customize", "** ** About to initialise SF Scripts");
@@ -658,7 +657,21 @@ void CuiConfigGroupListBox::Init(const css::uno::Reference< css::uno::XComponent
// TODO exception handling
}
+ m_xTreeView->thaw();
+ m_xTreeView->make_sorted();
+ m_xTreeView->make_unsorted();
+ m_xTreeView->freeze();
+ // add All Commands to the top
+ if ( bEventMode && nAddedGroups )
+ {
+ aArr.insert(aArr.begin(), std::make_unique<SfxGroupInfo_Impl>(SfxCfgKind::GROUP_ALLFUNCTIONS, 0));
+ OUString sId(weld::toId(aArr.front().get()));
+ OUString s(CuiResId(RID_CUISTR_ALLFUNCTIONS));
+ m_xTreeView->insert(nullptr, 0, &s, &sId, nullptr, nullptr, false, nullptr);
+ }
+
+ // add application macros to the end
if ( rootNode.is() )
{
if ( bEventMode )
@@ -670,7 +683,7 @@ void CuiConfigGroupListBox::Init(const css::uno::Reference< css::uno::XComponent
aArr.push_back( std::make_unique<SfxGroupInfo_Impl>( SfxCfgKind::GROUP_SCRIPTCONTAINER, 0,
static_cast<void *>(rootNode.get())));
OUString aTitle(xImp->m_sDlgMacros);
- OUString sId(OUString::number(reinterpret_cast<sal_Int64>(aArr.back().get())));
+ OUString sId(weld::toId(aArr.back().get()));
m_xTreeView->insert(nullptr, -1, &aTitle, &sId, nullptr, nullptr, true, nullptr);
}
else
@@ -681,17 +694,17 @@ void CuiConfigGroupListBox::Init(const css::uno::Reference< css::uno::XComponent
}
}
- // add styles and sidebar decks
+ // add styles and sidebar decks to the end
if ( bEventMode )
{
aArr.push_back( std::make_unique<SfxGroupInfo_Impl>( SfxCfgKind::GROUP_STYLES, 0, nullptr ) ); // TODO last parameter should contain user data
OUString sStyle(xImp->m_aStrGroupStyles);
- OUString sId(OUString::number(reinterpret_cast<sal_Int64>(aArr.back().get())));
+ OUString sId(weld::toId(aArr.back().get()));
m_xTreeView->insert(nullptr, -1, &sStyle, &sId, nullptr, nullptr, true, nullptr);
aArr.push_back( std::make_unique<SfxGroupInfo_Impl>(SfxCfgKind::GROUP_SIDEBARDECKS, 0));
OUString sSidebarDecks(xImp->m_aStrGroupSidebarDecks);
- sId = OUString::number(reinterpret_cast<sal_Int64>(aArr.back().get()));
+ sId = weld::toId(aArr.back().get());
m_xTreeView->insert(nullptr, -1, &sSidebarDecks, &sId, nullptr, nullptr, false, nullptr);
}
@@ -826,7 +839,7 @@ void CuiConfigGroupListBox::GroupSelected()
if (!m_xTreeView->get_selected(xIter.get()))
return;
- SfxGroupInfo_Impl *pInfo = reinterpret_cast<SfxGroupInfo_Impl*>(m_xTreeView->get_id(*xIter).toInt64());
+ SfxGroupInfo_Impl *pInfo = weld::fromId<SfxGroupInfo_Impl*>(m_xTreeView->get_id(*xIter));
m_pFunctionListBox->freeze();
m_pFunctionListBox->ClearAll();
@@ -838,7 +851,7 @@ void CuiConfigGroupListBox::GroupSelected()
bool bValidIter = m_xTreeView->get_iter_first(*xIter);
while (bValidIter)
{
- SfxGroupInfo_Impl *pCurrentInfo = reinterpret_cast<SfxGroupInfo_Impl*>(m_xTreeView->get_id(*xIter).toInt64());
+ SfxGroupInfo_Impl *pCurrentInfo = weld::fromId<SfxGroupInfo_Impl*>(m_xTreeView->get_id(*xIter));
if (pCurrentInfo->nKind == SfxCfgKind::GROUP_FUNCTION)
{
css::uno::Sequence< css::frame::DispatchInformation > lCommands;
@@ -911,7 +924,7 @@ void CuiConfigGroupListBox::GroupSelected()
m_pFunctionListBox->aArr.back()->sLabel = childNode->getName();
m_pFunctionListBox->aArr.back()->sHelpText = description;
- OUString sId(OUString::number(reinterpret_cast<sal_Int64>(m_pFunctionListBox->aArr.back().get())));
+ OUString sId(weld::toId(m_pFunctionListBox->aArr.back().get()));
m_pFunctionListBox->append(sId, childNode->getName(), aImage);
}
}
@@ -936,7 +949,7 @@ void CuiConfigGroupListBox::GroupSelected()
m_pFunctionListBox->aArr.push_back(std::make_unique<SfxGroupInfo_Impl>(SfxCfgKind::GROUP_STYLES, 0, pStyle));
m_pFunctionListBox->aArr.back()->sCommand = pStyle->sCommand;
m_pFunctionListBox->aArr.back()->sLabel = pStyle->sLabel;
- OUString sId(OUString::number(reinterpret_cast<sal_Int64>(m_pFunctionListBox->aArr.back().get())));
+ OUString sId(weld::toId(m_pFunctionListBox->aArr.back().get()));
m_pFunctionListBox->append(sId, pStyle->sLabel);
}
}
@@ -960,8 +973,7 @@ void CuiConfigGroupListBox::GroupSelected()
m_pFunctionListBox->aArr.back()->sLabel = rDeck.msId;
m_pFunctionListBox->aArr.back()->sTooltip =
vcl::CommandInfoProvider::GetCommandShortcut(sCommand, m_xFrame);
- m_pFunctionListBox->append(OUString::number(reinterpret_cast<sal_Int64>(
- m_pFunctionListBox->aArr.back().get())),
+ m_pFunctionListBox->append(weld::toId(m_pFunctionListBox->aArr.back().get()),
rDeck.msId);
}
@@ -985,7 +997,7 @@ void CuiConfigGroupListBox::GroupSelected()
*/
IMPL_LINK(CuiConfigGroupListBox, ExpandingHdl, const weld::TreeIter&, rIter, bool)
{
- SfxGroupInfo_Impl *pInfo = reinterpret_cast<SfxGroupInfo_Impl*>(m_xTreeView->get_id(rIter).toInt64());
+ SfxGroupInfo_Impl *pInfo = weld::fromId<SfxGroupInfo_Impl*>(m_xTreeView->get_id(rIter));
switch ( pInfo->nKind )
{
case SfxCfgKind::GROUP_SCRIPTCONTAINER:
@@ -1008,7 +1020,7 @@ IMPL_LINK(CuiConfigGroupListBox, ExpandingHdl, const weld::TreeIter&, rIter, boo
{
SfxStyleInfo_Impl* pFamily = new SfxStyleInfo_Impl(lStyleFamily);
aArr.push_back( std::make_unique<SfxGroupInfo_Impl>( SfxCfgKind::GROUP_STYLES, 0, pFamily ));
- OUString sId(OUString::number(reinterpret_cast<sal_Int64>(aArr.back().get())));
+ OUString sId(weld::toId(aArr.back().get()));
m_xTreeView->insert(&rIter, -1, &pFamily->sLabel, &sId, nullptr, nullptr, false, nullptr);
}
}
@@ -1025,27 +1037,21 @@ IMPL_LINK(CuiConfigGroupListBox, ExpandingHdl, const weld::TreeIter&, rIter, boo
#if HAVE_FEATURE_SCRIPTING
void CuiConfigGroupListBox::SelectMacro( const SfxMacroInfoItem *pItem )
{
- SelectMacro( pItem->GetBasicManager()->GetName(),
- pItem->GetQualifiedName() );
-}
-
-void CuiConfigGroupListBox::SelectMacro( std::u16string_view rBasic,
- const OUString& rMacro )
-{
- const OUString aBasicName(OUString::Concat(rBasic) + " " + xImp->m_sMacros);
+ auto const rMacro = pItem->GetQualifiedName();
sal_Int32 nIdx {rMacro.lastIndexOf('.')};
- const OUString aMethod( rMacro.copy(nIdx+1) );
- OUString aLib;
- OUString aModule;
+ const std::u16string_view aMethod( rMacro.subView(nIdx + 1) );
+ std::u16string_view aLib;
+ std::u16string_view aModule;
if ( nIdx>0 )
{
// string contains at least 2 tokens
nIdx = rMacro.lastIndexOf('.', nIdx);
- if (nIdx>=0)
+ if (nIdx != -1)
{
// string contains at least 3 tokens
- aLib = rMacro.getToken( 0, '.' );
- aModule = rMacro.getToken( 0, '.', ++nIdx );
+ aLib = o3tl::getToken(rMacro, 0, '.' );
+ sal_Int32 nIdx2 = nIdx + 1;
+ aModule = o3tl::getToken(rMacro, 0, '.', nIdx2 );
}
}
@@ -1056,45 +1062,61 @@ void CuiConfigGroupListBox::SelectMacro( std::u16string_view rBasic,
do
{
OUString aEntryBas = m_xTreeView->get_text(*xIter);
- if (aEntryBas == aBasicName)
+ if (aEntryBas == xImp->m_sDlgMacros)
{
m_xTreeView->expand_row(*xIter);
- std::unique_ptr<weld::TreeIter> xLibIter = m_xTreeView->make_iterator(xIter.get());
- if (m_xTreeView->get_iter_first(*xLibIter))
+ std::unique_ptr<weld::TreeIter> xLocationIter = m_xTreeView->make_iterator(xIter.get());
+ if (m_xTreeView->iter_children(*xLocationIter))
{
do
{
- OUString aEntryLib = m_xTreeView->get_text(*xLibIter);
- if (aEntryLib == aLib)
+ m_xTreeView->expand_row(*xLocationIter);
+ std::unique_ptr<weld::TreeIter> xLibIter = m_xTreeView->make_iterator(xLocationIter.get());
+ if (m_xTreeView->iter_children(*xLibIter))
{
- m_xTreeView->expand_row(*xLibIter);
- std::unique_ptr<weld::TreeIter> xModIter = m_xTreeView->make_iterator(xLibIter.get());
- if (m_xTreeView->get_iter_first(*xModIter))
+ do
{
- do
+ OUString aEntryLib = m_xTreeView->get_text(*xLibIter);
+ if (aEntryLib == aLib)
{
- OUString aEntryMod = m_xTreeView->get_text(*xModIter);
- if ( aEntryMod == aModule )
+ m_xTreeView->expand_row(*xLibIter);
+ std::unique_ptr<weld::TreeIter> xModIter = m_xTreeView->make_iterator(xLibIter.get());
+ if (m_xTreeView->iter_children(*xModIter))
{
- m_xTreeView->expand_row(*xModIter);
- m_xTreeView->scroll_to_row(*xModIter);
- m_xTreeView->select(*xModIter);
- for (int i = 0, nCount = m_pFunctionListBox->n_children(); i < nCount; ++i)
+ do
{
- OUString aEntryMethod = m_pFunctionListBox->get_text(i);
- if (aEntryMethod == aMethod)
+ OUString aEntryMod = m_xTreeView->get_text(*xModIter);
+ if ( aEntryMod == aModule )
{
- m_pFunctionListBox->select(i);
- m_pFunctionListBox->scroll_to_row(i);
- return;
+ m_xTreeView->expand_row(*xModIter);
+ m_xTreeView->scroll_to_row(*xModIter);
+ m_xTreeView->select(*xModIter);
+ GroupSelected();
+ for (int i = 0, nCount = m_pFunctionListBox->n_children(); i < nCount; ++i)
+ {
+ OUString aEntryMethod = m_pFunctionListBox->get_text(i);
+ if (aEntryMethod == aMethod)
+ {
+ m_pFunctionListBox->select(i);
+ m_pFunctionListBox->scroll_to_row(i);
+ return;
+ }
+ }
+ m_xTreeView->collapse_row(*xModIter);
}
- }
+ } while (m_xTreeView->iter_next_sibling(*xModIter));
}
- } while (m_xTreeView->iter_next_sibling(*xModIter));
- }
+ m_xTreeView->collapse_row(*xLibIter);
+ }
+ } while (m_xTreeView->iter_next_sibling(*xLibIter));
}
- } while (m_xTreeView->iter_next_sibling(*xLibIter));
+ m_xTreeView->collapse_row(*xLocationIter);
+ } while (m_xTreeView->iter_next_sibling(*xLocationIter));
}
+ // If the macro can't be located, preselect the "Application Macros" category:
+ m_xTreeView->scroll_to_row(*xIter);
+ m_xTreeView->select(*xIter);
+ return;
}
} while (m_xTreeView->iter_next_sibling(*xIter));
}
@@ -1153,6 +1175,10 @@ SvxScriptSelectorDialog::SvxScriptSelectorDialog(
m_aStylesInfo.init(aModuleName, xModel);
m_xCategories->SetStylesInfo(&m_aStylesInfo);
+ // The following call is a workaround to make scroll_to_row work as expected in kf5/x11
+ m_xDialog->resize_to_request();
+
+ LoadLastUsedMacro();
UpdateUI();
if (comphelper::LibreOfficeKit::isActive())
@@ -1191,7 +1217,7 @@ IMPL_LINK(SvxScriptSelectorDialog, ContextMenuHdl, const CommandEvent&, rCEvt, b
xDropMenu->set_active("alphabetically", xTreeView.get_sort_order());
xDropMenu->set_active("properorder", !xTreeView.get_sort_order());
- OString sCommand(xPopup->popup_at_rect(&xTreeView, tools::Rectangle(rCEvt.GetMousePosPixel(), Size(1,1))));
+ OUString sCommand(xPopup->popup_at_rect(&xTreeView, tools::Rectangle(rCEvt.GetMousePosPixel(), Size(1,1))));
if (sCommand == "alphabetically")
{
xTreeView.make_sorted();
@@ -1219,7 +1245,6 @@ SvxScriptSelectorDialog::UpdateUI()
{
OUString sMessage = m_xCommands->GetHelpText();
m_xDescriptionText->set_text(sMessage.isEmpty() ? m_sDefaultDesc : sMessage);
-
m_xOKButton->set_sensitive(true);
}
else
@@ -1237,6 +1262,7 @@ IMPL_LINK(SvxScriptSelectorDialog, ClickHdl, weld::Button&, rButton, void)
}
else if (&rButton == m_xOKButton.get())
{
+ SaveLastUsedMacro();
m_xDialog->response(RET_OK);
}
}
@@ -1255,7 +1281,7 @@ SvxScriptSelectorDialog::GetScriptURL() const
std::unique_ptr<weld::TreeIter> xIter = m_xCommands->make_iterator();
if (m_xCommands->get_selected(xIter.get()))
{
- SfxGroupInfo_Impl *pData = reinterpret_cast<SfxGroupInfo_Impl*>(m_xCommands->get_id(*xIter).toInt64());
+ SfxGroupInfo_Impl *pData = weld::fromId<SfxGroupInfo_Impl*>(m_xCommands->get_id(*xIter));
if ( ( pData->nKind == SfxCfgKind::FUNCTION_SLOT )
|| ( pData->nKind == SfxCfgKind::FUNCTION_SCRIPT )
|| ( pData->nKind == SfxCfgKind::GROUP_STYLES )
@@ -1268,4 +1294,100 @@ SvxScriptSelectorDialog::GetScriptURL() const
return result;
}
+void
+SvxScriptSelectorDialog::SaveLastUsedMacro()
+{
+ // Gets the current selection in the dialog as a series of selected entries
+ OUString sMacroInfo;
+ sMacroInfo = m_xCommands->get_selected_text();
+ weld::TreeView& xCategories = m_xCategories->get_widget();
+ std::unique_ptr<weld::TreeIter> xIter = xCategories.make_iterator();
+
+ if (!xCategories.get_selected(xIter.get()))
+ return;
+
+ do
+ {
+ sMacroInfo = xCategories.get_text(*xIter) + "|" + sMacroInfo;
+ } while (xCategories.iter_parent(*xIter));
+
+ SvtViewOptions( EViewType::Dialog, MACRO_SELECTOR_CONFIGNAME ).SetUserItem(
+ LAST_RUN_MACRO_INFO, Any(sMacroInfo));
+}
+
+void
+SvxScriptSelectorDialog::LoadLastUsedMacro()
+{
+ SvtViewOptions aDlgOpt( EViewType::Dialog, MACRO_SELECTOR_CONFIGNAME );
+ if (!aDlgOpt.Exists())
+ return;
+
+ OUString sMacroInfo;
+ aDlgOpt.GetUserItem(LAST_RUN_MACRO_INFO) >>= sMacroInfo;
+ if (sMacroInfo.isEmpty())
+ return;
+
+ // Counts how many entries exist in the macro info string
+ sal_Int16 nInfoParts = 0;
+ sal_Int16 nLastIndex = sMacroInfo.indexOf('|');
+ if (nLastIndex > -1)
+ {
+ nInfoParts = 1;
+ while ( nLastIndex != -1 )
+ {
+ nInfoParts++;
+ nLastIndex = sMacroInfo.indexOf('|', nLastIndex + 1);
+ }
+ }
+
+ weld::TreeView& xCategories = m_xCategories->get_widget();
+ std::unique_ptr<weld::TreeIter> xIter = xCategories.make_iterator();
+ if (!xCategories.get_iter_first(*xIter))
+ return;
+
+ // Expand the nodes in the category tree
+ OUString sNodeToExpand;
+ bool bIsIterValid;
+ sal_Int16 nOpenedNodes = 0;
+ for (sal_Int16 i=0; i<nInfoParts - 1; i++)
+ {
+ sNodeToExpand = sMacroInfo.getToken(i, '|');
+ bIsIterValid = true;
+ while (bIsIterValid && xCategories.get_text(*xIter) != sNodeToExpand)
+ bIsIterValid = xCategories.iter_next_sibling(*xIter);
+
+ if (bIsIterValid)
+ {
+ xCategories.expand_row(*xIter);
+ nOpenedNodes++;
+ }
+ if (xCategories.iter_has_child(*xIter))
+ (void)xCategories.iter_children(*xIter);
+ else if (nOpenedNodes < nInfoParts - 1)
+ // If the number of levels in the tree is smaller than the
+ // number of parts in the macro info string, then return
+ return;
+ }
+ xCategories.select(*xIter);
+ xCategories.scroll_to_row(*xIter);
+ m_xCategories->GroupSelected();
+
+ // Select the macro in the command tree
+ weld::TreeView& xCommands = m_xCommands->get_widget();
+ xIter = xCommands.make_iterator();
+ if (!xCommands.get_iter_first(*xIter))
+ return;
+
+ OUString sMacroName = sMacroInfo.getToken(nInfoParts - 1, '|');
+ bIsIterValid = true;
+ while (bIsIterValid && xCommands.get_text(*xIter) != sMacroName)
+ bIsIterValid = xCommands.iter_next_sibling(*xIter);
+
+ if (bIsIterValid)
+ {
+ xCommands.scroll_to_row(*xIter);
+ xCommands.select(*xIter);
+ }
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cui/source/customize/eventdlg.cxx b/cui/source/customize/eventdlg.cxx
index 54ebcdefa0c7..755fd16b416a 100644
--- a/cui/source/customize/eventdlg.cxx
+++ b/cui/source/customize/eventdlg.cxx
@@ -17,7 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <com/sun/star/document/XEventsSupplier.hpp>
#include <com/sun/star/frame/Desktop.hpp>
#include <com/sun/star/frame/theGlobalEventBroadcaster.hpp>
@@ -44,6 +44,7 @@ SvxEventConfigPage::SvxEventConfigPage(weld::Container* pPage, weld::DialogContr
mpImpl->xEventLB = m_xBuilder->weld_tree_view("events");
mpImpl->xAssignPB = m_xBuilder->weld_button("macro");
mpImpl->xDeletePB = m_xBuilder->weld_button("delete");
+ mpImpl->xDeleteAllPB = m_xBuilder->weld_button("deleteall");
mpImpl->xAssignComponentPB = m_xBuilder->weld_button("component");
mpImpl->xEventLB->set_size_request(mpImpl->xEventLB->get_approximate_digit_width() * 70,
diff --git a/cui/source/customize/macropg.cxx b/cui/source/customize/macropg.cxx
index 451ff0b0e9df..79197be4bf43 100644
--- a/cui/source/customize/macropg.cxx
+++ b/cui/source/customize/macropg.cxx
@@ -20,7 +20,7 @@
#include <macropg.hxx>
#include <svl/eitem.hxx>
#include <tools/debug.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <bitmaps.hlst>
#include <cfgutil.hxx>
#include <dialmgr.hxx>
@@ -32,11 +32,13 @@
#include <svx/svxids.hrc>
#include <strings.hrc>
#include <comphelper/namedvaluecollection.hxx>
+#include <o3tl/string_view.hxx>
+#include <utility>
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
-constexpr OUStringLiteral aVndSunStarUNO = u"vnd.sun.star.UNO:";
+constexpr OUString aVndSunStarUNO = u"vnd.sun.star.UNO:"_ustr;
SvxMacroTabPage_Impl::SvxMacroTabPage_Impl( const SfxItemSet& rAttrSet )
: bReadOnly(false)
@@ -59,19 +61,20 @@ MacroEventListBox::MacroEventListBox(std::unique_ptr<weld::TreeView> xTreeView)
// and it is not read only
void SvxMacroTabPage_::EnableButtons()
{
+ mpImpl->xDeleteAllPB->set_sensitive(m_nAssignedEvents != 0);
int nEvent = mpImpl->xEventLB->get_selected_index();
- if (nEvent != -1)
- {
- mpImpl->xDeletePB->set_sensitive( !mpImpl->bReadOnly );
- mpImpl->xAssignPB->set_sensitive( !mpImpl->bReadOnly );
- if( mpImpl->xAssignComponentPB )
- mpImpl->xAssignComponentPB->set_sensitive( !mpImpl->bReadOnly );
- }
+ const EventPair* pEventPair = nEvent == -1 ? nullptr : LookupEvent(mpImpl->xEventLB->get_id(nEvent));
+ const bool bAssigned = pEventPair && !pEventPair->second.isEmpty();
+ mpImpl->xDeletePB->set_sensitive(!mpImpl->bReadOnly && bAssigned);
+ mpImpl->xAssignPB->set_sensitive(!mpImpl->bReadOnly);
+ if (mpImpl->xAssignComponentPB)
+ mpImpl->xAssignComponentPB->set_sensitive( !mpImpl->bReadOnly );
}
SvxMacroTabPage_::SvxMacroTabPage_(weld::Container* pPage, weld::DialogController* pController, const OUString& rUIXMLDescription,
- const OString& rID, const SfxItemSet& rAttrSet)
+ const OUString& rID, const SfxItemSet& rAttrSet)
: SfxTabPage(pPage, pController, rUIXMLDescription, rID, &rAttrSet)
+ , m_nAssignedEvents(0)
, bDocModified(false)
, bAppEvents(false)
, bInitialized(false)
@@ -269,32 +272,31 @@ bool SvxMacroTabPage_::IsReadOnly() const
namespace
{
- OUString GetEventDisplayText(const OUString &rURL)
+ std::u16string_view GetEventDisplayText(std::u16string_view rURL)
{
- if (rURL.isEmpty())
- return OUString();
- sal_Int32 nIndex = rURL.indexOf(aVndSunStarUNO);
- bool bUNO = nIndex == 0;
- OUString aPureMethod;
+ if (rURL.empty())
+ return std::u16string_view();
+ bool bUNO = o3tl::starts_with(rURL, aVndSunStarUNO);
+ std::u16string_view aPureMethod;
if (bUNO)
{
- aPureMethod = rURL.copy(aVndSunStarUNO.getLength());
+ aPureMethod = rURL.substr(aVndSunStarUNO.getLength());
}
else
{
- aPureMethod = rURL.copy(strlen("vnd.sun.star.script:"));
- aPureMethod = aPureMethod.copy( 0, aPureMethod.indexOf( '?' ) );
+ aPureMethod = rURL.substr(strlen("vnd.sun.star.script:"));
+ aPureMethod = aPureMethod.substr( 0, aPureMethod.find( '?' ) );
}
return aPureMethod;
}
- OUString GetEventDisplayImage(const OUString &rURL)
+ OUString GetEventDisplayImage(std::u16string_view rURL)
{
- if (rURL.isEmpty())
+ if (rURL.empty())
return OUString();
- sal_Int32 nIndex = rURL.indexOf(aVndSunStarUNO);
+ size_t nIndex = rURL.find(aVndSunStarUNO);
bool bUNO = nIndex == 0;
- return bUNO ? OUString(RID_SVXBMP_COMPONENT) : OUString(RID_SVXBMP_MACRO);
+ return bUNO ? RID_SVXBMP_COMPONENT : RID_SVXBMP_MACRO;
}
}
@@ -305,6 +307,7 @@ void SvxMacroTabPage_::DisplayAppEvents( bool appEvents)
mpImpl->xEventLB->freeze();
mpImpl->xEventLB->clear();
+ m_nAssignedEvents = 0;
EventsHash* eventsHash;
Reference< container::XNameReplace> nameReplace;
if(bAppEvents)
@@ -344,7 +347,10 @@ void SvxMacroTabPage_::DisplayAppEvents( bool appEvents)
int nRow = mpImpl->xEventLB->n_children();
mpImpl->xEventLB->append(sEventName, displayName);
mpImpl->xEventLB->set_image(nRow, GetEventDisplayImage(eventURL), 1);
- mpImpl->xEventLB->set_text(nRow, GetEventDisplayText(eventURL), 2);
+ mpImpl->xEventLB->set_text(nRow, OUString(GetEventDisplayText(eventURL)), 2);
+
+ if (!eventURL.isEmpty())
+ ++m_nAssignedEvents;
}
mpImpl->xEventLB->thaw();
@@ -374,20 +380,37 @@ IMPL_LINK_NOARG( SvxMacroTabPage_, SelectEvent_Impl, weld::TreeView&, void)
IMPL_LINK( SvxMacroTabPage_, AssignDeleteHdl_Impl, weld::Button&, rBtn, void )
{
- GenericHandler_Impl(this, &rBtn);
+ GenericHandler_Impl(&rBtn);
}
IMPL_LINK_NOARG( SvxMacroTabPage_, DoubleClickHdl_Impl, weld::TreeView&, bool)
{
- GenericHandler_Impl(this, nullptr);
+ GenericHandler_Impl(nullptr);
return true;
}
+const EventPair* SvxMacroTabPage_::LookupEvent(const OUString& rEventName)
+{
+ const EventPair* pRet = nullptr;
+ if (bAppEvents)
+ {
+ EventsHash::iterator h_it = m_appEventsHash.find(rEventName);
+ if (h_it != m_appEventsHash.end() )
+ pRet = &h_it->second;
+ }
+ else
+ {
+ EventsHash::iterator h_it = m_docEventsHash.find(rEventName);
+ if (h_it != m_docEventsHash.end() )
+ pRet = &h_it->second;
+ }
+ return pRet;
+}
+
// handler for double click on the listbox, and for the assign/delete buttons
-void SvxMacroTabPage_::GenericHandler_Impl(SvxMacroTabPage_* pThis, const weld::Button* pBtn)
+void SvxMacroTabPage_::GenericHandler_Impl(const weld::Button* pBtn)
{
- SvxMacroTabPage_Impl* pImpl = pThis->mpImpl.get();
- weld::TreeView& rListBox = *pImpl->xEventLB;
+ weld::TreeView& rListBox = *mpImpl->xEventLB;
int nEntry = rListBox.get_selected_index();
if (nEntry == -1)
{
@@ -395,95 +418,125 @@ void SvxMacroTabPage_::GenericHandler_Impl(SvxMacroTabPage_* pThis, const weld::
return;
}
- const bool bAssEnabled = pBtn != pImpl->xDeletePB.get() && pImpl->xAssignPB->get_sensitive();
+ const bool bAssEnabled = pBtn != mpImpl->xDeletePB.get() && mpImpl->xAssignPB->get_sensitive();
OUString sEventName = rListBox.get_id(nEntry);
OUString sEventURL;
OUString sEventType;
- if(pThis->bAppEvents)
- {
- EventsHash::iterator h_it = pThis->m_appEventsHash.find(sEventName);
- if(h_it != pThis->m_appEventsHash.end() )
- {
- sEventType = h_it->second.first;
- sEventURL = h_it->second.second;
- }
- }
- else
+ if (const EventPair* pEventPair = LookupEvent(sEventName))
{
- EventsHash::iterator h_it = pThis->m_docEventsHash.find(sEventName);
- if(h_it != pThis->m_docEventsHash.end() )
- {
- sEventType = h_it->second.first;
- sEventURL = h_it->second.second;
- }
+ sEventType = pEventPair->first;
+ sEventURL = pEventPair->second;
}
+ if (!sEventURL.isEmpty())
+ --m_nAssignedEvents;
+
bool bDoubleClick = (pBtn == nullptr);
bool bUNOAssigned = sEventURL.startsWith( aVndSunStarUNO );
- if( pBtn == pImpl->xDeletePB.get() )
+ if (pBtn == mpImpl->xDeletePB.get())
{
// delete pressed
sEventType = "Script" ;
sEventURL.clear();
- if(!pThis->bAppEvents)
- pThis->bDocModified = true;
+ if (!bAppEvents)
+ bDocModified = true;
}
else if ( ( ( pBtn != nullptr )
- && ( pBtn == pImpl->xAssignComponentPB.get() )
+ && ( pBtn == mpImpl->xAssignComponentPB.get() )
)
|| ( bDoubleClick
&& bUNOAssigned
)
)
{
- AssignComponentDialog aAssignDlg(pThis->GetFrameWeld(), sEventURL);
+ AssignComponentDialog aAssignDlg(GetFrameWeld(), sEventURL);
short ret = aAssignDlg.run();
if( ret )
{
sEventType = "UNO";
sEventURL = aAssignDlg.getURL();
- if(!pThis->bAppEvents)
- pThis->bDocModified = true;
+ if (!bAppEvents)
+ bDocModified = true;
}
}
else if( bAssEnabled )
{
// assign pressed
- SvxScriptSelectorDialog aDlg(pThis->GetFrameWeld(), pThis->GetFrame());
+ SvxScriptSelectorDialog aDlg(GetFrameWeld(), GetFrame());
short ret = aDlg.run();
if ( ret )
{
sEventType = "Script";
sEventURL = aDlg.GetScriptURL();
- if(!pThis->bAppEvents)
- pThis->bDocModified = true;
+ if (!bAppEvents)
+ bDocModified = true;
}
}
// update the hashes
- if(pThis->bAppEvents)
+ if (bAppEvents)
{
- EventsHash::iterator h_it = pThis->m_appEventsHash.find(sEventName);
+ EventsHash::iterator h_it = m_appEventsHash.find(sEventName);
h_it->second.first = sEventType;
h_it->second.second = sEventURL;
}
else
{
- EventsHash::iterator h_it = pThis->m_docEventsHash.find(sEventName);
+ EventsHash::iterator h_it = m_docEventsHash.find(sEventName);
h_it->second.first = sEventType;
h_it->second.second = sEventURL;
}
+ if (!sEventURL.isEmpty())
+ ++m_nAssignedEvents;
+
rListBox.set_image(nEntry, GetEventDisplayImage(sEventURL), 1);
- rListBox.set_text(nEntry, GetEventDisplayText(sEventURL), 2);
+ rListBox.set_text(nEntry, OUString(GetEventDisplayText(sEventURL)), 2);
rListBox.select(nEntry );
rListBox.scroll_to_row(nEntry);
- pThis->EnableButtons();
+ EnableButtons();
+}
+
+IMPL_LINK_NOARG(SvxMacroTabPage_, DeleteAllHdl_Impl, weld::Button&, void)
+{
+ OUString sEventType = "Script" ;
+ OUString sEmptyString;
+
+ mpImpl->xEventLB->all_foreach([this, &sEventType, &sEmptyString](weld::TreeIter& rEntry) {
+ weld::TreeView& rListBox = *mpImpl->xEventLB;
+ OUString sEventName = rListBox.get_id(rEntry);
+ // update the hashes
+ if (bAppEvents)
+ {
+ EventsHash::iterator h_it = m_appEventsHash.find(sEventName);
+ assert(h_it != m_appEventsHash.end());
+ h_it->second.first = sEventType;
+ h_it->second.second = sEmptyString;
+ }
+ else
+ {
+ EventsHash::iterator h_it = m_docEventsHash.find(sEventName);
+ assert(h_it != m_docEventsHash.end());
+ h_it->second.first = sEventType;
+ h_it->second.second = sEmptyString;
+ }
+
+ rListBox.set_image(rEntry, sEmptyString, 1);
+ rListBox.set_text(rEntry, sEmptyString, 2);
+ return false;
+ });
+
+ if (!bAppEvents)
+ bDocModified = true;
+
+ m_nAssignedEvents = 0;
+
+ EnableButtons();
}
// pass in the XNameReplace.
@@ -496,6 +549,7 @@ void SvxMacroTabPage_::InitAndSetHandler( const Reference< container::XNameRepla
Link<weld::Button&,void> aLnk(LINK(this, SvxMacroTabPage_, AssignDeleteHdl_Impl ));
mpImpl->xDeletePB->connect_clicked(aLnk);
mpImpl->xAssignPB->connect_clicked(aLnk);
+ mpImpl->xDeleteAllPB->connect_clicked(LINK(this, SvxMacroTabPage_, DeleteAllHdl_Impl));
if( mpImpl->xAssignComponentPB )
mpImpl->xAssignComponentPB->connect_clicked( aLnk );
mpImpl->xEventLB->connect_row_activated( LINK(this, SvxMacroTabPage_, DoubleClickHdl_Impl ) );
@@ -548,7 +602,7 @@ void SvxMacroTabPage_::InitAndSetHandler( const Reference< container::XNameRepla
// returns the two props EventType & Script for a given event name
Any SvxMacroTabPage_::GetPropsByName( const OUString& eventName, EventsHash& eventsHash )
{
- const std::pair< OUString, OUString >& rAssignedEvent( eventsHash[ eventName ] );
+ const EventPair& rAssignedEvent(eventsHash[eventName]);
Any aReturn;
::comphelper::NamedValueCollection aProps;
@@ -564,7 +618,7 @@ Any SvxMacroTabPage_::GetPropsByName( const OUString& eventName, EventsHash& eve
// converts the Any returned by GetByName into a pair which can be stored in
// the EventHash
-std::pair< OUString, OUString > SvxMacroTabPage_::GetPairFromAny( const Any& aAny )
+EventPair SvxMacroTabPage_::GetPairFromAny( const Any& aAny )
{
Sequence< beans::PropertyValue > props;
OUString type, url;
@@ -589,6 +643,7 @@ SvxMacroTabPage::SvxMacroTabPage(weld::Container* pPage, weld::DialogController*
mpImpl->xEventLB->get_height_rows(9));
mpImpl->xAssignPB = m_xBuilder->weld_button("assign");
mpImpl->xDeletePB = m_xBuilder->weld_button("delete");
+ mpImpl->xDeleteAllPB = m_xBuilder->weld_button("deleteall");
mpImpl->xAssignComponentPB = m_xBuilder->weld_button("component");
SetFrame( _rxDocumentFrame );
@@ -625,9 +680,9 @@ IMPL_LINK_NOARG(AssignComponentDialog, ButtonHandler, weld::Button&, void)
m_xDialog->response(RET_OK);
}
-AssignComponentDialog::AssignComponentDialog(weld::Window* pParent, const OUString& rURL)
+AssignComponentDialog::AssignComponentDialog(weld::Window* pParent, OUString aURL)
: GenericDialogController(pParent, "cui/ui/assigncomponentdialog.ui", "AssignComponent")
- , maURL( rURL )
+ , maURL(std::move( aURL ))
, mxMethodEdit(m_xBuilder->weld_entry("methodEntry"))
, mxOKButton(m_xBuilder->weld_button("ok"))
{
diff --git a/cui/source/customize/macropg_impl.hxx b/cui/source/customize/macropg_impl.hxx
index 2a36d0f5cada..1073e4bb36ff 100644
--- a/cui/source/customize/macropg_impl.hxx
+++ b/cui/source/customize/macropg_impl.hxx
@@ -30,6 +30,7 @@ public:
std::unique_ptr<weld::Button> xAssignPB;
std::unique_ptr<weld::Button> xAssignComponentPB;
std::unique_ptr<weld::Button> xDeletePB;
+ std::unique_ptr<weld::Button> xDeleteAllPB;
std::unique_ptr<weld::TreeView> xEventLB;
bool bReadOnly;
bool bIDEDialogMode;
@@ -46,7 +47,7 @@ private:
DECL_LINK(ButtonHandler, weld::Button&, void);
public:
- AssignComponentDialog(weld::Window* pParent, const OUString& rURL);
+ AssignComponentDialog(weld::Window* pParent, OUString aURL);
virtual ~AssignComponentDialog() override;
const OUString& getURL() const { return maURL; }