summaryrefslogtreecommitdiff
path: root/cui/source/customize
diff options
context:
space:
mode:
Diffstat (limited to 'cui/source/customize')
-rw-r--r--cui/source/customize/CommandCategoryListBox.cxx67
-rw-r--r--cui/source/customize/CustomNotebookbarGenerator.cxx40
-rw-r--r--cui/source/customize/SvxConfigPageHelper.cxx79
-rw-r--r--cui/source/customize/SvxMenuConfigPage.cxx63
-rw-r--r--cui/source/customize/SvxNotebookbarConfigPage.cxx96
-rw-r--r--cui/source/customize/SvxToolbarConfigPage.cxx107
-rw-r--r--cui/source/customize/acccfg.cxx158
-rw-r--r--cui/source/customize/cfg.cxx388
-rw-r--r--cui/source/customize/cfgutil.cxx352
-rw-r--r--cui/source/customize/eventdlg.cxx6
-rw-r--r--cui/source/customize/macropg.cxx339
-rw-r--r--cui/source/customize/macropg_impl.hxx3
12 files changed, 993 insertions, 705 deletions
diff --git a/cui/source/customize/CommandCategoryListBox.cxx b/cui/source/customize/CommandCategoryListBox.cxx
index 5b8903f3d199..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>
@@ -44,6 +44,7 @@
#include <comphelper/sequenceashashmap.hxx>
#include <comphelper/SetFlagContextHelper.hxx>
#include <comphelper/string.hxx>
+#include <officecfg/Office/Common.hxx>
#include <i18nlangtag/languagetag.hxx>
#include <i18nutil/searchopt.hxx>
#include <sal/log.hxx>
@@ -133,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_SVXSTR_ALLFUNCTIONS));
+ m_xControl->append(weld::toId(m_aGroupInfo.back().get()),
+ CuiResId(RID_CUISTR_ALLFUNCTIONS));
}
// Separate the "All commands"category from the actual categories
@@ -180,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
@@ -191,15 +189,14 @@ 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_SVXSTR_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())),
- CuiResId(RID_SVXSTR_GROUP_STYLES));
+ m_xControl->append(weld::toId(m_aGroupInfo.back().get()),
+ CuiResId(RID_CUISTR_GROUP_STYLES));
}
catch (const css::uno::RuntimeException&)
{
@@ -222,6 +219,7 @@ void CommandCategoryListBox::FillFunctionsList(
// Setup search filter parameters
m_searchOptions.searchString = filterTerm;
utl::TextSearch textSearch(m_searchOptions);
+ const bool bInExperimentalMode = officecfg::Office::Common::Misc::ExperimentalMode::get();
for (const auto& rInfo : xCommands)
{
@@ -234,11 +232,17 @@ void CommandCategoryListBox::FillFunctionsList(
= vcl::CommandInfoProvider::GetTooltipForCommand(rInfo.Command, aProperties, m_xFrame);
OUString sPopupLabel = (vcl::CommandInfoProvider::GetPopupLabelForCommand(aProperties))
.replaceFirst("~", "");
+ bool bIsExperimental
+ = vcl::CommandInfoProvider::IsExperimental(rInfo.Command, m_sModuleLongName);
+
+ // Hide experimental commands when not in experimental mode
+ bool bHideExperimental = bIsExperimental && !bInExperimentalMode;
// Apply the search filter
- if (!filterTerm.isEmpty() && !textSearch.searchForward(sUIName)
- && !textSearch.searchForward(sLabel) && !textSearch.searchForward(sTooltipLabel)
- && !textSearch.searchForward(sPopupLabel))
+ if (bHideExperimental
+ || (!filterTerm.isEmpty() && !textSearch.searchForward(sUIName)
+ && !textSearch.searchForward(sLabel) && !textSearch.searchForward(sTooltipLabel)
+ && !textSearch.searchForward(sPopupLabel)))
{
continue;
}
@@ -252,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);
}
}
@@ -293,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();
@@ -310,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;
@@ -384,11 +385,11 @@ void CommandCategoryListBox::categorySelected(CuiConfigFunctionListBox* pFunctio
OUString sUIName;
if (childGroup->getName() == "user")
{
- sUIName = CuiResId(RID_SVXSTR_MYMACROS);
+ sUIName = CuiResId(RID_CUISTR_MYMACROS);
}
else if (childGroup->getName() == "share")
{
- sUIName = CuiResId(RID_SVXSTR_PRODMACROS);
+ sUIName = CuiResId(RID_CUISTR_PRODMACROS);
}
else
{
@@ -403,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,
@@ -447,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);
@@ -478,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
@@ -539,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);
@@ -588,7 +584,7 @@ void CommandCategoryListBox::addChildren(
if (description.isEmpty())
{
- description = CuiResId(RID_SVXSTR_NOMACRODESC);
+ description = CuiResId(RID_CUISTR_NOMACRODESC);
}
OUString* pScriptURI = new OUString(uri);
@@ -602,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 365c7f9f00d5..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
@@ -42,19 +43,14 @@ static OUString lcl_activeAppName(vcl::EnumContext::Application eApp)
{
case vcl::EnumContext::Application::Writer:
return "ActiveWriter";
- break;
case vcl::EnumContext::Application::Calc:
return "ActiveCalc";
- break;
case vcl::EnumContext::Application::Impress:
return "ActiveImpress";
- break;
case vcl::EnumContext::Application::Draw:
return "ActiveDraw";
- break;
default:
return OUString();
- break;
}
}
@@ -64,30 +60,28 @@ static OUString lcl_getAppName(vcl::EnumContext::Application eApp)
{
case vcl::EnumContext::Application::Writer:
return "Writer";
- break;
case vcl::EnumContext::Application::Calc:
return "Calc";
- break;
case vcl::EnumContext::Application::Impress:
return "Impress";
- break;
case vcl::EnumContext::Application::Draw:
return "Draw";
- break;
default:
return OUString();
- break;
}
}
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;
@@ -190,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],
@@ -267,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 527754d5cf5f..59a2cdb64017 100644
--- a/cui/source/customize/SvxConfigPageHelper.cxx
+++ b/cui/source/customize/SvxConfigPageHelper.cxx
@@ -23,6 +23,7 @@
#include <com/sun/star/ui/ImageType.hpp>
#include <com/sun/star/ui/ItemType.hpp>
+#include <comphelper/propertyvalue.hxx>
#include <comphelper/random.hxx>
#include <svtools/imgdef.hxx>
#include <svtools/miscopt.hxx>
@@ -65,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;
}
@@ -177,7 +178,7 @@ sal_uInt32 SvxConfigPageHelper::generateRandomValue()
OUString SvxConfigPageHelper::generateCustomURL(SvxEntries* entries)
{
- OUString url = OUStringLiteral(ITEM_TOOLBAR_URL) + CUSTOM_TOOLBAR_STR +
+ OUString url = OUString::Concat(ITEM_TOOLBAR_URL) + CUSTOM_TOOLBAR_STR +
// use a random number to minimize possible clash with existing custom toolbars
OUString::number(generateRandomValue(), 16);
@@ -247,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")
{
@@ -281,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)
{
@@ -324,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)
{
@@ -361,29 +362,20 @@ bool SvxConfigPageHelper::GetToolbarItemData(
css::uno::Sequence<css::beans::PropertyValue>
SvxConfigPageHelper::ConvertSvxConfigEntry(const SvxConfigEntry* pEntry)
{
- css::uno::Sequence<css::beans::PropertyValue> aPropSeq(4);
-
- aPropSeq[0].Name = ITEM_DESCRIPTOR_COMMANDURL;
- aPropSeq[0].Value <<= pEntry->GetCommand();
-
- aPropSeq[1].Name = ITEM_DESCRIPTOR_TYPE;
- aPropSeq[1].Value <<= css::ui::ItemType::DEFAULT;
-
// If the name has not been changed, then the label can be stored
// as an empty string.
// It will be initialised again later using the command to label map.
- aPropSeq[2].Name = ITEM_DESCRIPTOR_LABEL;
- if (!pEntry->HasChangedName() && !pEntry->GetCommand().isEmpty())
- {
- aPropSeq[2].Value <<= OUString();
- }
- else
- {
- aPropSeq[2].Value <<= pEntry->GetName();
- }
-
- aPropSeq[3].Name = ITEM_DESCRIPTOR_STYLE;
- aPropSeq[3].Value <<= static_cast<sal_Int16>(pEntry->GetStyle());
+ OUString sLabel;
+ if (pEntry->HasChangedName() || pEntry->GetCommand().isEmpty())
+ sLabel = pEntry->GetName();
+
+ css::uno::Sequence<css::beans::PropertyValue> aPropSeq{
+ comphelper::makePropertyValue(ITEM_DESCRIPTOR_COMMANDURL, pEntry->GetCommand()),
+ comphelper::makePropertyValue(ITEM_DESCRIPTOR_TYPE, css::ui::ItemType::DEFAULT),
+ comphelper::makePropertyValue(ITEM_DESCRIPTOR_LABEL, sLabel),
+ comphelper::makePropertyValue(ITEM_DESCRIPTOR_STYLE,
+ static_cast<sal_Int16>(pEntry->GetStyle()))
+ };
return aPropSeq;
}
@@ -391,32 +383,21 @@ SvxConfigPageHelper::ConvertSvxConfigEntry(const SvxConfigEntry* pEntry)
css::uno::Sequence<css::beans::PropertyValue>
SvxConfigPageHelper::ConvertToolbarEntry(const SvxConfigEntry* pEntry)
{
- css::uno::Sequence<css::beans::PropertyValue> aPropSeq(5);
-
- aPropSeq[0].Name = ITEM_DESCRIPTOR_COMMANDURL;
- aPropSeq[0].Value <<= pEntry->GetCommand();
-
- aPropSeq[1].Name = ITEM_DESCRIPTOR_TYPE;
- aPropSeq[1].Value <<= css::ui::ItemType::DEFAULT;
-
// If the name has not been changed, then the label can be stored
// as an empty string.
// It will be initialised again later using the command to label map.
- aPropSeq[2].Name = ITEM_DESCRIPTOR_LABEL;
- if (!pEntry->HasChangedName() && !pEntry->GetCommand().isEmpty())
- {
- aPropSeq[2].Value <<= OUString();
- }
- else
- {
- aPropSeq[2].Value <<= pEntry->GetName();
- }
-
- aPropSeq[3].Name = ITEM_DESCRIPTOR_ISVISIBLE;
- aPropSeq[3].Value <<= pEntry->IsVisible();
-
- aPropSeq[4].Name = ITEM_DESCRIPTOR_STYLE;
- aPropSeq[4].Value <<= static_cast<sal_Int16>(pEntry->GetStyle());
+ OUString sLabel;
+ if (pEntry->HasChangedName() || pEntry->GetCommand().isEmpty())
+ sLabel = pEntry->GetName();
+
+ css::uno::Sequence<css::beans::PropertyValue> aPropSeq{
+ comphelper::makePropertyValue(ITEM_DESCRIPTOR_COMMANDURL, pEntry->GetCommand()),
+ comphelper::makePropertyValue(ITEM_DESCRIPTOR_TYPE, css::ui::ItemType::DEFAULT),
+ comphelper::makePropertyValue(ITEM_DESCRIPTOR_LABEL, sLabel),
+ comphelper::makePropertyValue(ITEM_DESCRIPTOR_ISVISIBLE, pEntry->IsVisible()),
+ comphelper::makePropertyValue(ITEM_DESCRIPTOR_STYLE,
+ static_cast<sal_Int16>(pEntry->GetStyle()))
+ };
return aPropSeq;
}
diff --git a/cui/source/customize/SvxMenuConfigPage.cxx b/cui/source/customize/SvxMenuConfigPage.cxx
index 3181a78bbb07..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);
@@ -172,8 +169,17 @@ void SvxMenuConfigPage::UpdateButtonStates()
m_xInsertBtn->set_sensitive(pMenuData != nullptr);
- m_xAddCommandButton->set_sensitive(pMenuData != nullptr);
- m_xRemoveCommandButton->set_sensitive(pMenuData != nullptr);
+ SvxConfigEntry* selectedCmd = CreateCommandFromSelection(GetScriptURL());
+
+ m_xAddCommandButton->set_sensitive(
+ pMenuData != nullptr && !IsCommandInMenuList(selectedCmd, pMenuData->GetEntries()));
+
+ delete selectedCmd;
+
+ if (bIsValidSelection)
+ {
+ m_xRemoveCommandButton->set_sensitive(pMenuData != nullptr);
+ }
//Handle the gear button
if (pMenuData && m_bIsMenuBar)
@@ -208,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();
@@ -234,7 +240,7 @@ void SvxMenuConfigPage::DeleteSelectedContent()
short SvxMenuConfigPage::QueryReset()
{
- OUString msg = CuiResId(RID_SVXSTR_CONFIRM_MENU_RESET);
+ OUString msg = CuiResId(RID_CUISTR_CONFIRM_MENU_RESET);
OUString saveInName = m_xSaveInListBox->get_active_text();
@@ -259,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);
});
@@ -268,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")
{
@@ -291,11 +297,11 @@ IMPL_LINK(SvxMenuConfigPage, GearHdl, const OString&, rIdent, void)
SvxConfigEntry* pMenuData = GetTopLevelSelection();
OUString sCurrentName(SvxConfigPageHelper::stripHotKey(pMenuData->GetName()));
- OUString sDesc = CuiResId(RID_SVXSTR_LABEL_NEW_NAME);
+ OUString sDesc = CuiResId(RID_CUISTR_LABEL_NEW_NAME);
SvxNameDialog aNameDialog(GetFrameWeld(), sCurrentName, sDesc);
aNameDialog.set_help_id(HID_SVX_CONFIG_RENAME_MENU);
- aNameDialog.set_title(CuiResId(RID_SVXSTR_RENAME_MENU));
+ aNameDialog.set_title(CuiResId(RID_CUISTR_RENAME_MENU));
if (aNameDialog.run() == RET_OK)
{
@@ -351,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);
}
@@ -364,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")
@@ -377,11 +383,11 @@ IMPL_LINK(SvxMenuConfigPage, InsertHdl, const OString&, rIdent, void)
else if (rIdent == "insertsubmenu")
{
OUString aNewName;
- OUString aDesc = CuiResId(RID_SVXSTR_SUBMENU_NAME);
+ OUString aDesc = CuiResId(RID_CUISTR_SUBMENU_NAME);
SvxNameDialog aNameDialog(GetFrameWeld(), aNewName, aDesc);
aNameDialog.set_help_id(HID_SVX_CONFIG_NAME_SUBMENU);
- aNameDialog.set_title(CuiResId(RID_SVXSTR_ADD_SUBMENU));
+ aNameDialog.set_title(CuiResId(RID_CUISTR_ADD_SUBMENU));
if (aNameDialog.run() == RET_OK)
{
@@ -416,20 +422,20 @@ 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_SVXSTR_LABEL_NEW_NAME);
+ OUString aDesc = CuiResId(RID_CUISTR_LABEL_NEW_NAME);
SvxNameDialog aNameDialog(GetFrameWeld(), aNewName, aDesc);
aNameDialog.set_help_id(HID_SVX_CONFIG_RENAME_MENU_ITEM);
- aNameDialog.set_title(CuiResId(RID_SVXSTR_RENAME_MENU));
+ aNameDialog.set_title(CuiResId(RID_CUISTR_RENAME_MENU));
if (aNameDialog.run() == RET_OK)
{
@@ -468,7 +474,7 @@ IMPL_LINK_NOARG(SvxMenuConfigPage, ResetMenuHdl, weld::Button&, void)
std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(
GetFrameWeld(), VclMessageType::Question, VclButtonsType::YesNo,
- CuiResId(RID_SVXSTR_CONFIRM_RESTORE_DEFAULT_MENU)));
+ CuiResId(RID_CUISTR_CONFIRM_RESTORE_DEFAULT_MENU)));
// Resetting individual top-level menus is not possible at the moment.
// So we are resetting only if it is a context menu
@@ -522,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(
@@ -535,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")
@@ -574,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 7e93dae121af..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)
@@ -70,13 +69,13 @@ static OUString charToString(const char* cString)
static OUString getFileName(std::u16string_view aFileName)
{
if (aFileName == u"notebookbar.ui")
- return "Tabbed";
+ return CuiResId(RID_CUISTR_TABBED);
else if (aFileName == u"notebookbar_compact.ui")
- return "TabbedCompact";
+ return CuiResId(RID_CUISTR_TABBED_COMPACT);
else if (aFileName == u"notebookbar_groupedbar_full.ui")
- return "Groupedbar";
+ return CuiResId(RID_CUISTR_GROUPEDBAR);
else if (aFileName == u"notebookbar_groupedbar_compact.ui")
- return "GroupedbarCompact";
+ return CuiResId(RID_CUISTR_GROUPEDBAR_COMPACT);
else
return "None";
}
@@ -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
@@ -154,7 +149,7 @@ void SvxNotebookbarConfigPage::Init()
m_xSaveInListBox->append(sSaveInListBoxID, sScopeName);
m_xSaveInListBox->set_active_id(sSaveInListBoxID);
- m_xTopLevelListBox->append("NotebookBar", "All Commands");
+ m_xTopLevelListBox->append("NotebookBar", CuiResId(RID_CUISTR_ALL_COMMANDS));
m_xTopLevelListBox->set_active_id("NotebookBar");
SelectElement();
}
@@ -172,7 +167,7 @@ void SvxNotebookbarConfigPage::UpdateButtonStates() {}
short SvxNotebookbarConfigPage::QueryReset()
{
- OUString msg = CuiResId(RID_SVXSTR_CONFIRM_TOOLBAR_RESET);
+ OUString msg = CuiResId(RID_CUISTR_CONFIRM_TOOLBAR_RESET);
OUString saveInName = m_xSaveInListBox->get_active_text();
@@ -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"
@@ -423,26 +424,20 @@ void SvxNotebookbarConfigPage::SelectElement()
if (aEntries[nIdx].sClassId == "svtlo-ManagedMenuButton")
{
aTempEntries.push_back(aEntries[nIdx]);
- std::vector<NotebookbarEntries> aGtkEntries;
sal_Int32 rPos = 1;
sActiveCategory = aEntries[nIdx].sUIItemId.getToken(rPos, ':', rPos);
- FillFunctionsList(pNodePtr, aGtkEntries, aCategoryList, sActiveCategory);
- for (std::size_t Idx = 0; Idx < aGtkEntries.size(); Idx++)
- aTempEntries.push_back(aGtkEntries[Idx]);
- aGtkEntries.clear();
+ FillFunctionsList(pNodePtr, aTempEntries, aCategoryList, sActiveCategory);
}
else
aTempEntries.push_back(aEntries[nIdx]);
}
- aEntries = aTempEntries;
- aTempEntries.clear();
+ 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")
@@ -456,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();
@@ -470,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() {}
@@ -481,22 +486,23 @@ static void EditRegistryFile(std::u16string_view sUIItemId, const OUString& sSet
Sequence<OUString> aOldEntries
= CustomNotebookbarGenerator::getCustomizedUIItem(sNotebookbarInterface);
Sequence<OUString> aNewEntries(aOldEntries.getLength() + 1);
+ auto pNewEntries = aNewEntries.getArray();
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[nIdx] = sSetEntry;
+ aOldEntries.getArray()[nIdx] = sSetEntry;
nFlag = 1;
break;
}
- aNewEntries[nIdx] = aOldEntries[nIdx];
+ pNewEntries[nIdx] = aOldEntries[nIdx];
}
if (nFlag == 0)
{
- aNewEntries[aOldEntries.getLength()] = sSetEntry;
+ pNewEntries[aOldEntries.getLength()] = sSetEntry;
CustomNotebookbarGenerator::setCustomizedUIItem(aNewEntries, sNotebookbarInterface);
}
else
@@ -516,8 +522,7 @@ void SvxNotebookbarEntriesListBox::ChangedVisibility(int nRow)
else
sVisible = "False";
OUString sSetEntries = sUIItemId + ",visible," + sVisible;
- Sequence<OUString> sSeqOfEntries(1);
- sSeqOfEntries[0] = sSetEntries;
+ Sequence<OUString> sSeqOfEntries{ sSetEntries };
EditRegistryFile(sUIItemId, sSetEntries, sNotebookbarInterface);
CustomNotebookbarGenerator::modifyCustomizedUIFile(sSeqOfEntries);
OUString sUIPath = "modules/s" + m_pPage->GetAppName().toAsciiLowerCase() + "/ui/";
@@ -543,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 57f78dcd6161..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,13 +286,13 @@ 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();
if (rIdent == "toolbar_gear_add")
{
- OUString prefix = CuiResId(RID_SVXSTR_NEW_TOOLBAR);
+ OUString prefix = CuiResId(RID_CUISTR_NEW_TOOLBAR);
OUString aNewName
= SvxConfigPageHelper::generateCustomName(prefix, GetSaveInData()->GetEntries());
@@ -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,17 +349,17 @@ 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
OUString sCurrentName(SvxConfigPageHelper::stripHotKey(pToolbar->GetName()));
- OUString sDesc = CuiResId(RID_SVXSTR_LABEL_NEW_NAME);
+ OUString sDesc = CuiResId(RID_CUISTR_LABEL_NEW_NAME);
SvxNameDialog aNameDialog(GetFrameWeld(), sCurrentName, sDesc);
aNameDialog.set_help_id(HID_SVX_CONFIG_RENAME_TOOLBAR);
- aNameDialog.set_title(CuiResId(RID_SVXSTR_RENAME_TOOLBAR));
+ aNameDialog.set_title(CuiResId(RID_CUISTR_RENAME_TOOLBAR));
if (aNameDialog.run() == RET_OK)
{
@@ -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,14 +468,14 @@ 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_SVXSTR_LABEL_NEW_NAME);
+ OUString aDesc = CuiResId(RID_CUISTR_LABEL_NEW_NAME);
SvxNameDialog aNameDialog(GetFrameWeld(), aNewName, aDesc);
aNameDialog.set_help_id(HID_SVX_CONFIG_RENAME_TOOLBAR_ITEM);
- aNameDialog.set_title(CuiResId(RID_SVXSTR_RENAME_TOOLBAR));
+ aNameDialog.set_title(CuiResId(RID_CUISTR_RENAME_TOOLBAR));
if (aNameDialog.run() == RET_OK)
{
@@ -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());
@@ -508,8 +505,6 @@ IMPL_LINK(SvxToolbarConfigPage, ModifyItemHdl, const OString&, rIdent, void)
if (newgraphic.is())
{
- css::uno::Sequence<css::uno::Reference<css::graphic::XGraphic>> aGraphicSeq(1);
-
css::uno::Sequence<OUString> aURLSeq{ pEntry->GetCommand() };
if (!pEntry->GetBackupGraphic().is())
@@ -524,7 +519,9 @@ IMPL_LINK(SvxToolbarConfigPage, ModifyItemHdl, const OString&, rIdent, void)
}
}
- aGraphicSeq[0] = newgraphic;
+ css::uno::Sequence<css::uno::Reference<css::graphic::XGraphic>> aGraphicSeq{
+ newgraphic
+ };
try
{
GetSaveInData()->GetImageManager()->replaceImages(
@@ -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,12 +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(1);
- aGraphicSeq[0] = backup;
+ css::uno::Sequence<css::uno::Reference<css::graphic::XGraphic>> aGraphicSeq{
+ pEntry->GetBackupGraphic()
+ };
css::uno::Sequence<OUString> aURLSeq{ pEntry->GetCommand() };
@@ -570,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);
@@ -593,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());
@@ -621,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);
@@ -656,11 +652,11 @@ 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,
- CuiResId(RID_SVXSTR_CONFIRM_RESTORE_DEFAULT)));
+ CuiResId(RID_CUISTR_CONFIRM_RESTORE_DEFAULT)));
if (xQueryBox->run() == RET_YES)
{
ToolbarSaveInData* pSaveInData = static_cast<ToolbarSaveInData*>(GetSaveInData());
@@ -678,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);
@@ -697,7 +692,7 @@ void SvxToolbarConfigPage::UpdateButtonStates()
short SvxToolbarConfigPage::QueryReset()
{
- OUString msg = CuiResId(RID_SVXSTR_CONFIRM_TOOLBAR_RESET);
+ OUString msg = CuiResId(RID_CUISTR_CONFIRM_TOOLBAR_RESET);
OUString saveInName = m_xSaveInListBox->get_active_text();
@@ -752,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);
@@ -776,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 ?
{
@@ -812,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())
{
@@ -839,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
@@ -871,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(
@@ -884,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")
@@ -924,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 a8e780a6b008..027ac72968e8 100644
--- a/cui/source/customize/acccfg.cxx
+++ b/cui/source/customize/acccfg.cxx
@@ -61,13 +61,17 @@
#include <svtools/acceleratorexecute.hxx>
#include <vcl/svapp.hxx>
#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,
@@ -182,10 +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,
@@ -264,10 +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,
@@ -342,10 +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,
@@ -418,10 +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,
@@ -495,13 +515,18 @@ 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,
+ KEY_MOD1 | KEY_MOD2 | KEY_EQUAL,
KEY_MOD1 | KEY_MOD2 | KEY_F1,
KEY_MOD1 | KEY_MOD2 | KEY_F2,
@@ -570,10 +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,
@@ -648,10 +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,
@@ -730,10 +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,
@@ -774,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.
@@ -786,23 +823,24 @@ IMPL_LINK(SfxAcceleratorConfigPage, KeyInputHdl, const KeyEvent&, rKey, bool)
sal_uInt16 nMod1 = aCode1.GetModifier();
// is it related to our list box ?
- if ((nCode1 != KEY_DOWN) && (nCode1 != KEY_UP) && (nCode1 != KEY_LEFT) && (nCode1 != KEY_RIGHT)
- && (nCode1 != KEY_PAGEUP) && (nCode1 != KEY_PAGEDOWN))
+ if ((nCode1 == KEY_DOWN) || (nCode1 == KEY_UP) || (nCode1 == KEY_LEFT) || (nCode1 == KEY_RIGHT)
+ || (nCode1 == KEY_PAGEUP) || (nCode1 == KEY_PAGEDOWN))
+ // no - handle it as normal dialog input
+ return false;
+
+ for (int i = 0, nCount = m_xEntriesBox->n_children(); i < nCount; ++i)
{
- for (int i = 0, nCount = m_xEntriesBox->n_children(); i < nCount; ++i)
+ TAccInfo* pUserData = weld::fromId<TAccInfo*>(m_xEntriesBox->get_id(i));
+ if (pUserData)
{
- TAccInfo* pUserData = reinterpret_cast<TAccInfo*>(m_xEntriesBox->get_id(i).toInt64());
- if (pUserData)
- {
- sal_uInt16 nCode2 = pUserData->m_aKey.GetCode();
- sal_uInt16 nMod2 = pUserData->m_aKey.GetModifier();
+ sal_uInt16 nCode2 = pUserData->m_aKey.GetCode();
+ sal_uInt16 nMod2 = pUserData->m_aKey.GetModifier();
- if (nCode1 == nCode2 && nMod1 == nMod2)
- {
- m_xEntriesBox->select(i);
- m_xEntriesBox->scroll_to_row(i);
- return true;
- }
+ if (nCode1 == nCode2 && nMod1 == nMod2)
+ {
+ m_xEntriesBox->select(i);
+ m_xEntriesBox->scroll_to_row(i);
+ return true;
}
}
}
@@ -815,16 +853,16 @@ SfxAcceleratorConfigPage::SfxAcceleratorConfigPage(weld::Container* pPage,
weld::DialogController* pController,
const SfxItemSet& aSet)
: SfxTabPage(pPage, pController, "cui/ui/accelconfigpage.ui", "AccelConfigPage", &aSet)
+#if HAVE_FEATURE_SCRIPTING
, m_pMacroInfoItem()
- , aLoadAccelConfigStr(CuiResId(RID_SVXSTR_LOADACCELCONFIG))
- , aSaveAccelConfigStr(CuiResId(RID_SVXSTR_SAVEACCELCONFIG))
+#endif
+ , aLoadAccelConfigStr(CuiResId(RID_CUISTR_LOADACCELCONFIG))
+ , aSaveAccelConfigStr(CuiResId(RID_CUISTR_SAVEACCELCONFIG))
, aFilterAllStr(SfxResId(STR_SFX_FILTERNAME_ALL))
- , aFilterCfgStr(CuiResId(RID_SVXSTR_FILTERNAME_CFG))
+ , aFilterCfgStr(CuiResId(RID_CUISTR_FILTERNAME_CFG))
, m_bStylesInfoInitialized(false)
- , m_xGlobal()
- , m_xModule()
- , m_xAct()
- , m_aUpdateDataTimer("UpdateDataTimer")
+ , m_aUpdateDataTimer("SfxAcceleratorConfigPage UpdateDataTimer")
+ , m_aFillGroupIdle("SfxAcceleratorConfigPage m_aFillGroupIdle")
, m_xEntriesBox(m_xBuilder->weld_tree_view("shortcuts"))
, m_xOfficeButton(m_xBuilder->weld_radio_button("office"))
, m_xModuleButton(m_xBuilder->weld_radio_button("module"))
@@ -839,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
@@ -862,8 +900,7 @@ SfxAcceleratorConfigPage::SfxAcceleratorConfigPage(weld::Container* pPage,
m_xLoadButton->connect_clicked(LINK(this, SfxAcceleratorConfigPage, Load));
m_xSaveButton->connect_clicked(LINK(this, SfxAcceleratorConfigPage, Save));
m_xResetButton->connect_clicked(LINK(this, SfxAcceleratorConfigPage, Default));
- m_xOfficeButton->connect_clicked(LINK(this, SfxAcceleratorConfigPage, RadioHdl));
- m_xModuleButton->connect_clicked(LINK(this, SfxAcceleratorConfigPage, RadioHdl));
+ m_xOfficeButton->connect_toggled(LINK(this, SfxAcceleratorConfigPage, RadioHdl));
m_xSearchEdit->connect_changed(LINK(this, SfxAcceleratorConfigPage, SearchUpdateHdl));
m_xSearchEdit->connect_focus_out(LINK(this, SfxAcceleratorConfigPage, FocusOut_Impl));
@@ -879,8 +916,7 @@ SfxAcceleratorConfigPage::SfxAcceleratorConfigPage(weld::Container* pPage,
auto nNewTab = nMaxWidth + 5; // additional space
// initialize Entriesbox
- std::vector<int> aWidths;
- aWidths.push_back(nNewTab);
+ std::vector<int> aWidths{ nNewTab };
m_xEntriesBox->set_column_fixed_widths(aWidths);
//Initialize search util
@@ -895,12 +931,10 @@ SfxAcceleratorConfigPage::SfxAcceleratorConfigPage(weld::Container* pPage,
m_xKeyBox->make_sorted();
m_aUpdateDataTimer.SetInvokeHandler(LINK(this, SfxAcceleratorConfigPage, ImplUpdateDataHdl));
- m_aUpdateDataTimer.SetDebugName("SfxAcceleratorConfigPage UpdateDataTimer");
m_aUpdateDataTimer.SetTimeout(EDIT_UPDATEDATA_TIMEOUT);
m_aFillGroupIdle.SetInvokeHandler(LINK(this, SfxAcceleratorConfigPage, TimeOut_Impl));
m_aFillGroupIdle.SetPriority(TaskPriority::HIGHEST);
- m_aFillGroupIdle.SetDebugName("SfxAcceleratorConfigPage m_aFillGroupIdle");
}
SfxAcceleratorConfigPage::~SfxAcceleratorConfigPage()
@@ -910,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;
}
}
@@ -995,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);
@@ -1019,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;
@@ -1037,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);
@@ -1054,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;
@@ -1133,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())
@@ -1152,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);
@@ -1165,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();
@@ -1207,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();
@@ -1226,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());
}
}
}
@@ -1241,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)
@@ -1253,7 +1285,7 @@ IMPL_LINK(SfxAcceleratorConfigPage, SelectHdl, weld::TreeView&, rListBox, void)
}
}
-IMPL_LINK_NOARG(SfxAcceleratorConfigPage, RadioHdl, weld::Button&, void)
+IMPL_LINK_NOARG(SfxAcceleratorConfigPage, RadioHdl, weld::Toggleable&, void)
{
uno::Reference<ui::XAcceleratorConfiguration> xOld = m_xAct;
@@ -1312,9 +1344,8 @@ IMPL_LINK_NOARG(SfxAcceleratorConfigPage, LoadHdl, sfx2::FileDialogHelper*, void
// don't forget to release the storage afterwards!
uno::Reference<lang::XSingleServiceFactory> xStorageFactory(
embed::StorageFactory::create(m_xContext));
- uno::Sequence<uno::Any> lArgs(2);
- lArgs[0] <<= sCfgName;
- lArgs[1] <<= css::embed::ElementModes::READ;
+ uno::Sequence<uno::Any> lArgs{ uno::Any(sCfgName),
+ uno::Any(css::embed::ElementModes::READ) };
xRootStorage.set(xStorageFactory->createInstanceWithArguments(lArgs), uno::UNO_QUERY_THROW);
uno::Reference<embed::XStorage> xUIConfig
@@ -1383,9 +1414,7 @@ IMPL_LINK_NOARG(SfxAcceleratorConfigPage, SaveHdl, sfx2::FileDialogHelper*, void
{
uno::Reference<lang::XSingleServiceFactory> xStorageFactory(
embed::StorageFactory::create(m_xContext));
- uno::Sequence<uno::Any> lArgs(2);
- lArgs[0] <<= sCfgName;
- lArgs[1] <<= embed::ElementModes::WRITE;
+ uno::Sequence<uno::Any> lArgs{ uno::Any(sCfgName), uno::Any(embed::ElementModes::WRITE) };
xRootStorage.set(xStorageFactory->createInstanceWithArguments(lArgs), uno::UNO_QUERY_THROW);
@@ -1455,6 +1484,7 @@ void SfxAcceleratorConfigPage::StartFileDialog(StartFileDialogType nType, const
m_pFileDlg->AddFilter(aFilterAllStr, FILEDIALOG_FILTER_ALL);
m_pFileDlg->AddFilter(aFilterCfgStr, "*.cfg");
m_pFileDlg->SetCurrentFilter(aFilterCfgStr);
+ m_pFileDlg->SetContext(sfx2::FileDialogHelper::AcceleratorConfig);
Link<sfx2::FileDialogHelper*, void> aDlgClosedLink
= bSave ? LINK(this, SfxAcceleratorConfigPage, SaveHdl)
@@ -1468,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&)
{
@@ -1505,12 +1542,15 @@ void SfxAcceleratorConfigPage::Reset(const SfxItemSet* rSet)
RadioHdl(*m_xOfficeButton);
- const SfxPoolItem* pMacroItem = nullptr;
- if (SfxItemState::SET == rSet->GetItemState(SID_MACROINFO, true, &pMacroItem))
+#if HAVE_FEATURE_SCRIPTING
+ if (const SfxMacroInfoItem* pMacroItem = rSet->GetItemIfSet(SID_MACROINFO))
{
- m_pMacroInfoItem = &dynamic_cast<const SfxMacroInfoItem&>(*pMacroItem);
+ m_pMacroInfoItem = pMacroItem;
m_xGroupLBox->SelectMacro(m_pMacroInfoItem);
}
+#else
+ (void)rSet;
+#endif
}
sal_Int32 SfxAcceleratorConfigPage::MapKeyCodeToPos(const vcl::KeyCode& aKey) const
@@ -1518,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 0988fca71feb..ff5702121755 100644
--- a/cui/source/customize/cfg.cxx
+++ b/cui/source/customize/cfg.cxx
@@ -24,16 +24,19 @@
#include <stdlib.h>
#include <typeinfo>
+#include <utility>
#include <vcl/stdtext.hxx>
#include <vcl/commandinfoprovider.hxx>
#include <vcl/event.hxx>
#include <vcl/graph.hxx>
+#include <vcl/graphicfilter.hxx>
#include <vcl/svapp.hxx>
#include <vcl/toolbox.hxx>
#include <vcl/weld.hxx>
#include <vcl/decoview.hxx>
#include <vcl/virdev.hxx>
+#include <sfx2/minfitem.hxx>
#include <sfx2/sfxhelp.hxx>
#include <sfx2/viewfrm.hxx>
#include <sfx2/filedlghelper.hxx>
@@ -41,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>
@@ -87,7 +90,9 @@
#include <com/sun/star/util/thePathSettings.hpp>
#include <comphelper/documentinfo.hxx>
#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;
@@ -212,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)
@@ -241,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")
@@ -265,21 +281,19 @@ 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) }
{
- m_aSeparatorSeq.realloc( 1 );
- m_aSeparatorSeq[0].Name = ITEM_DESCRIPTOR_TYPE;
- m_aSeparatorSeq[0].Value <<= css::ui::ItemType::SEPARATOR_LINE;
-
if ( bDocConfig )
{
uno::Reference< css::ui::XUIConfigurationPersistence >
@@ -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 )
{
@@ -602,8 +616,9 @@ void MenuSaveInData::Apply(
sal_Int32 nIndex = aPropValueSeq.getLength();
aPropValueSeq.realloc( nIndex + 1 );
- aPropValueSeq[nIndex].Name = m_aDescriptorContainer;
- aPropValueSeq[nIndex].Value <<= xSubMenuBar;
+ auto pPropValueSeq = aPropValueSeq.getArray();
+ pPropValueSeq[nIndex].Name = m_aDescriptorContainer;
+ pPropValueSeq[nIndex].Value <<= xSubMenuBar;
rMenuBar->insertByIndex(
rMenuBar->getCount(), uno::Any( aPropValueSeq ));
ApplyMenu( xSubMenuBar, rFactory, entryData );
@@ -630,8 +645,9 @@ void SaveInData::ApplyMenu(
sal_Int32 nIndex = aPropValueSeq.getLength();
aPropValueSeq.realloc( nIndex + 1 );
- aPropValueSeq[nIndex].Name = ITEM_DESCRIPTOR_CONTAINER;
- aPropValueSeq[nIndex].Value <<= xSubMenuBar;
+ auto pPropValueSeq = aPropValueSeq.getArray();
+ pPropValueSeq[nIndex].Name = ITEM_DESCRIPTOR_CONTAINER;
+ pPropValueSeq[nIndex].Value <<= xSubMenuBar;
rMenuBar->insertByIndex(
rMenuBar->getCount(), uno::Any( aPropValueSeq ));
@@ -707,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 )
{
@@ -735,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 )
@@ -783,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 )
@@ -929,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()
@@ -960,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
@@ -969,7 +1001,7 @@ IMPL_LINK(SvxMenuEntriesListBox, KeyInputHdl, const KeyEvent&, rKeyEvent, bool)
*****************************************************************************/
SvxConfigPage::SvxConfigPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet)
: SfxTabPage(pPage, pController, "cui/ui/menuassignpage.ui", "MenuAssignPage", &rSet)
- , m_aUpdateDataTimer("UpdateDataTimer")
+ , m_aUpdateDataTimer( "SvxConfigPage UpdateDataTimer" )
, bInitialised(false)
, pCurrentSaveInData(nullptr)
, m_xCommandCategoryListBox(new CommandCategoryListBox(m_xBuilder->weld_combo_box("commandcategorylist")))
@@ -985,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"))
{
@@ -1001,7 +1035,6 @@ SvxConfigPage::SvxConfigPage(weld::Container* pPage, weld::DialogController* pCo
m_xDescriptionField->set_size_request(aSize.Width(), m_xDescriptionField->get_height_rows(3));
m_aUpdateDataTimer.SetInvokeHandler(LINK(this, SvxConfigPage, ImplUpdateDataHdl));
- m_aUpdateDataTimer.SetDebugName( "SvxConfigPage UpdateDataTimer" );
m_aUpdateDataTimer.SetTimeout(EDIT_UPDATEDATA_TIMEOUT);
m_xSearchEdit->connect_changed(LINK(this, SvxConfigPage, SearchUpdateHdl));
@@ -1018,6 +1051,12 @@ IMPL_LINK_NOARG(SvxConfigPage, SelectElementHdl, weld::ComboBox&, void)
SvxConfigPage::~SvxConfigPage()
{
+ int cnt = m_xSaveInListBox->get_count();
+ for(int i=0; i < cnt; ++i)
+ {
+ SaveInData *pData = weld::fromId<SaveInData*>(m_xSaveInListBox->get_id(i));
+ delete pData;
+ }
}
void SvxConfigPage::Reset( const SfxItemSet* )
@@ -1067,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);
}
@@ -1098,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);
}
}
@@ -1164,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 )
{
@@ -1207,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);
}
}
@@ -1254,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() )
{
@@ -1277,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 ) ||
@@ -1305,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();
}
}
@@ -1316,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();
}
@@ -1329,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)
@@ -1363,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 );
@@ -1395,18 +1437,14 @@ SvxEntries* SvxConfigPage::FindParentForChild(
return nullptr;
}
-int SvxConfigPage::AddFunction(int nTarget, bool bAllowDuplicates)
+SvxConfigEntry *SvxConfigPage::CreateCommandFromSelection(const OUString &aURL)
{
- OUString aURL = GetScriptURL();
- SvxConfigEntry* pParent = GetTopLevelSelection();
+ OUString aDisplayName;
- if ( aURL.isEmpty() || pParent == nullptr )
- {
- return -1;
+ if ( aURL.isEmpty() ) {
+ return nullptr;
}
- OUString aDisplayName;
-
auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(aURL, m_aModuleId);
if ( typeid(*pCurrentSaveInData) == typeid(ContextMenuSaveInData) )
@@ -1416,30 +1454,64 @@ int SvxConfigPage::AddFunction(int nTarget, bool bAllowDuplicates)
else
aDisplayName = vcl::CommandInfoProvider::GetLabelForCommand(aProperties);
- SvxConfigEntry* pNewEntryData =
+ SvxConfigEntry* toret =
new SvxConfigEntry( aDisplayName, aURL, false, /*bParentData*/false );
- pNewEntryData->SetUserDefined();
+
+ toret->SetUserDefined();
if ( aDisplayName.isEmpty() )
- pNewEntryData->SetName( GetSelectedDisplayName() );
+ toret->SetName( GetSelectedDisplayName() );
- // check that this function is not already in the menu
- if ( !bAllowDuplicates )
+ return toret;
+}
+
+bool SvxConfigPage::IsCommandInMenuList(const SvxConfigEntry *pEntryData,
+ const SvxEntries *pEntries)
+{
+ bool toret = false;
+
+ if ( pEntries != nullptr
+ && pEntryData != nullptr )
{
- for (auto const& entry : *pParent->GetEntries())
+ for (auto const& entry : *pEntries)
{
- if ( entry->GetCommand() == pNewEntryData->GetCommand() )
- {
- std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(),
- VclMessageType::Info, VclButtonsType::Ok, CuiResId(RID_SVXSTR_MNUCFG_ALREADY_INCLUDED)));
- xBox->run();
- delete pNewEntryData;
- return -1;
- }
+ if ( entry->GetCommand() == pEntryData->GetCommand() )
+ {
+ toret = true;
+ break;
+ }
}
}
- return AppendEntry(pNewEntryData, nTarget);
+ return toret;
+}
+
+int SvxConfigPage::AddFunction(int nTarget, bool bAllowDuplicates)
+{
+ int toret = -1;
+ OUString aURL = GetScriptURL();
+ SvxConfigEntry* pParent = GetTopLevelSelection();
+
+ if ( aURL.isEmpty() || pParent == nullptr )
+ {
+ return -1;
+ }
+
+
+ SvxConfigEntry * pNewEntryData = CreateCommandFromSelection( aURL );
+
+ // check that this function is not already in the menu
+ if ( !bAllowDuplicates
+ && IsCommandInMenuList( pNewEntryData, pParent->GetEntries() )
+ )
+ {
+ delete pNewEntryData;
+ } else {
+ toret = AppendEntry( pNewEntryData, nTarget );
+ }
+
+ UpdateButtonStates();
+ return toret;
}
int SvxConfigPage::AppendEntry(
@@ -1458,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)
{
@@ -1469,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();
@@ -1511,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);
@@ -1581,13 +1653,20 @@ 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)
{
- OUString aLabel = CuiResId(RID_SVXSTR_COMMANDLABEL) + ": " + pData->sLabel + "\n";
- OUString aName = CuiResId(RID_SVXSTR_COMMANDNAME) + ": " + pData->sCommand + "\n";
- OUString aTip = CuiResId(RID_SVXSTR_COMMANDTIP) + ": " + pData->sTooltip;
- m_xDescriptionField->set_text(aLabel + aName + aTip);
+ bool bIsExperimental
+ = vcl::CommandInfoProvider::IsExperimental(pData->sCommand, m_aModuleId);
+
+ OUString aExperimental = "\n" + CuiResId(RID_CUISTR_COMMANDEXPERIMENTAL);
+ OUString aLabel = CuiResId(RID_CUISTR_COMMANDLABEL) + ": " + pData->sLabel + "\n";
+ OUString aName = CuiResId(RID_CUISTR_COMMANDNAME) + ": " + pData->sCommand + "\n";
+ OUString aTip = CuiResId(RID_CUISTR_COMMANDTIP) + ": " + pData->sTooltip;
+ if (bIsExperimental)
+ m_xDescriptionField->set_text(aLabel + aName + aTip + aExperimental);
+ else
+ m_xDescriptionField->set_text(aLabel + aName + aTip);
}
}
}
@@ -1599,6 +1678,8 @@ IMPL_LINK_NOARG(SvxConfigPage, SelectFunctionHdl, weld::TreeView&, void)
m_xDescriptionField->set_text("");
}
+
+ UpdateButtonStates();
}
IMPL_LINK_NOARG(SvxConfigPage, ImplUpdateDataHdl, Timer*, void)
@@ -1670,32 +1751,30 @@ 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 )
- {
- // remove the source entry from our list
- SvxConfigPageHelper::RemoveEntry( pEntries, pSourceData );
+ if ( pSourceData == nullptr || pTargetData == nullptr )
+ return false;
- SvxEntries::iterator iter = pEntries->begin();
- SvxEntries::const_iterator end = pEntries->end();
+ // remove the source entry from our list
+ SvxConfigPageHelper::RemoveEntry( pEntries, pSourceData );
- // advance the iterator to the position of the target entry
- while (*iter != pTargetData && ++iter != end) ;
+ SvxEntries::iterator iter = pEntries->begin();
+ SvxEntries::const_iterator end = pEntries->end();
- // insert the source entry at the position after the target
- pEntries->insert( ++iter, pSourceData );
+ // advance the iterator to the position of the target entry
+ while (*iter != pTargetData && ++iter != end) ;
- GetSaveInData()->SetModified();
- GetTopLevelSelection()->SetModified();
+ // insert the source entry at the position after the target
+ pEntries->insert( ++iter, pSourceData );
- return true;
- }
+ GetSaveInData()->SetModified();
+ GetTopLevelSelection()->SetModified();
- return false;
+ return true;
}
SvxMainMenuOrganizerDialog::SvxMainMenuOrganizerDialog(
@@ -1716,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)
@@ -1729,7 +1808,7 @@ SvxMainMenuOrganizerDialog::SvxMainMenuOrganizerDialog(
if ( bCreateMenu )
{
// Generate custom name for new menu
- OUString prefix = CuiResId( RID_SVXSTR_NEW_MENU );
+ OUString prefix = CuiResId( RID_CUISTR_NEW_MENU );
OUString newname = SvxConfigPageHelper::generateCustomName( prefix, entries );
OUString newurl = SvxConfigPageHelper::generateCustomMenuURL( mpEntries.get() );
@@ -1740,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);
@@ -1756,7 +1835,7 @@ SvxMainMenuOrganizerDialog::SvxMainMenuOrganizerDialog(
// hide name label and textfield
m_xMenuBox->hide();
// change the title
- m_xDialog->set_title(CuiResId(RID_SVXSTR_MOVE_MENU));
+ m_xDialog->set_title(CuiResId(RID_CUISTR_MOVE_MENU));
}
m_xMenuListBox->connect_changed(LINK(this, SvxMainMenuOrganizerDialog, SelectHdl));
@@ -1779,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);
@@ -1836,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 )
@@ -1922,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 )
{
@@ -1973,7 +2052,7 @@ void ToolbarSaveInData::SetSystemStyle(
if ( xUIElement.is() )
xWindow.set( xUIElement->getRealInterface(), uno::UNO_QUERY );
- window = VCLUnoHelper::GetWindow( xWindow ).get();
+ window = VCLUnoHelper::GetWindow( xWindow );
}
if ( window == nullptr || window->GetType() != WindowType::TOOLBOX )
@@ -2012,7 +2091,7 @@ void ToolbarSaveInData::SetSystemStyle(
if ( a >>= aProps )
{
- for ( beans::PropertyValue& prop : aProps )
+ for ( beans::PropertyValue& prop : asNonConstRange(aProps) )
{
if ( prop.Name == ITEM_DESCRIPTOR_STYLE )
{
@@ -2049,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 )
{
@@ -2076,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 )
{
@@ -2349,8 +2428,9 @@ void ToolbarSaveInData::ApplyToolbar(
sal_Int32 nIndex = aPropValueSeq.getLength();
aPropValueSeq.realloc( nIndex + 1 );
- aPropValueSeq[nIndex].Name = m_aDescriptorContainer;
- aPropValueSeq[nIndex].Value <<= xSubMenuBar;
+ auto pPropValueSeq = aPropValueSeq.getArray();
+ pPropValueSeq[nIndex].Name = m_aDescriptorContainer;
+ pPropValueSeq[nIndex].Value <<= xSubMenuBar;
rToolbarBar->insertByIndex(
rToolbarBar->getCount(), uno::Any( aPropValueSeq ));
@@ -2510,9 +2590,10 @@ void ToolbarSaveInData::RestoreToolbar( SvxConfigEntry* pToolbar )
// After reloading, ensure that the icon is reset of each entry
// in the toolbar
uno::Sequence< OUString > aURLSeq( 1 );
+ auto pURLSeq = aURLSeq.getArray();
for (auto const& entry : *pToolbar->GetEntries())
{
- aURLSeq[ 0 ] = entry->GetCommand();
+ pURLSeq[ 0 ] = entry->GetCommand();
try
{
@@ -2576,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" )
{
@@ -2612,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);
@@ -2629,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"))
@@ -2693,9 +2773,8 @@ SvxIconSelectorDialog::SvxIconSelectorDialog(weld::Window *pWindow,
uno::Reference< lang::XSingleServiceFactory > xStorageFactory(
css::embed::FileSystemStorageFactory::create( xComponentContext ) );
- uno::Sequence< uno::Any > aArgs( 2 );
- aArgs[ 0 ] <<= aDirectory;
- aArgs[ 1 ] <<= css::embed::ElementModes::READWRITE;
+ uno::Sequence< uno::Any > aArgs{ uno::Any(aDirectory),
+ uno::Any(css::embed::ElementModes::READWRITE) };
uno::Reference< css::embed::XStorage > xStorage(
xStorageFactory->createInstanceWithArguments( aArgs ), uno::UNO_QUERY );
@@ -2717,9 +2796,10 @@ SvxIconSelectorDialog::SvxIconSelectorDialog(weld::Window *pWindow,
}
uno::Sequence< OUString > name( 1 );
+ auto pname = name.getArray();
for (auto const& elem : aImageInfo1)
{
- name[ 0 ] = elem.first;
+ pname[ 0 ] = elem.first;
uno::Sequence< uno::Reference< graphic::XGraphic> > graphics = m_xImportedImageManager->getImages( SvxConfigPageHelper::GetImageType(), name );
if ( graphics.hasElements() )
{
@@ -2751,7 +2831,7 @@ SvxIconSelectorDialog::SvxIconSelectorDialog(weld::Window *pWindow,
// large growth factor, expecting many entries
for (auto const& elem : aImageInfo)
{
- name[ 0 ] = elem.first;
+ pname[ 0 ] = elem.first;
uno::Sequence< uno::Reference< graphic::XGraphic> > graphics;
try
@@ -2828,6 +2908,7 @@ IMPL_LINK_NOARG(SvxIconSelectorDialog, ImportHdl, weld::Button&, void)
sfx2::FileDialogHelper aImportDialog(
css::ui::dialogs::TemplateDescription::FILEOPEN_LINK_PREVIEW,
FileDialogFlags::Graphic | FileDialogFlags::MultiSelection, m_xDialog.get());
+ aImportDialog.SetContext(sfx2::FileDialogHelper::IconImport);
// disable the link checkbox in the dialog
uno::Reference< css::ui::dialogs::XFilePickerControlAccess >
@@ -2839,8 +2920,9 @@ IMPL_LINK_NOARG(SvxIconSelectorDialog, ImportHdl, weld::Button&, void)
false);
}
- aImportDialog.SetCurrentFilter(
- "PNG - Portable Network Graphic");
+ GraphicFilter& rFilter = GraphicFilter::GetGraphicFilter();
+ sal_uInt16 nFilter = rFilter.GetImportFormatNumberForShortName(u"png");
+ aImportDialog.SetCurrentFilter(rFilter.GetImportFormatName(nFilter));
if ( ERRCODE_NONE == aImportDialog.Execute() )
{
@@ -2851,7 +2933,7 @@ IMPL_LINK_NOARG(SvxIconSelectorDialog, ImportHdl, weld::Button&, void)
IMPL_LINK_NOARG(SvxIconSelectorDialog, DeleteHdl, weld::Button&, void)
{
- OUString message = CuiResId( RID_SVXSTR_DELETE_ICON_CONFIRM );
+ OUString message = CuiResId( RID_CUISTR_DELETE_ICON_CONFIRM );
std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(m_xDialog.get(),
VclMessageType::Warning, VclButtonsType::OkCancel,
@@ -2861,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() )
@@ -2874,13 +2955,8 @@ IMPL_LINK_NOARG(SvxIconSelectorDialog, DeleteHdl, weld::Button&, void)
bool SvxIconSelectorDialog::ReplaceGraphicItem(
const OUString& aURL )
{
- uno::Sequence< OUString > URLs(1);
- uno::Sequence< uno::Reference<graphic::XGraphic > > aImportGraph( 1 );
-
uno::Reference< graphic::XGraphic > xGraphic;
- uno::Sequence< beans::PropertyValue > aMediaProps( 1 );
- aMediaProps[0].Name = "URL";
- aMediaProps[0].Value <<= aURL;
+ uno::Sequence< beans::PropertyValue > aMediaProps{ comphelper::makePropertyValue("URL", aURL) };
css::awt::Size aSize;
bool bOK = false;
@@ -2916,7 +2992,6 @@ bool SvxIconSelectorDialog::ReplaceGraphicItem(
size_t nPos = nId - 1;
assert(nPos == m_xTbSymbol->GetItemPos(nId));
m_xTbSymbol->RemoveItem(nId);
- aMediaProps[0].Value <<= aURL;
Image aImage( xGraphic );
if ( bOK && ((aSize.Width != m_nExpectedSize) || (aSize.Height != m_nExpectedSize)) )
@@ -2929,9 +3004,7 @@ bool SvxIconSelectorDialog::ReplaceGraphicItem(
m_aGraphics[nPos] = Graphic(aImage.GetBitmapEx()).GetXGraphic();
- URLs[0] = aURL;
- aImportGraph[ 0 ] = xGraphic;
- m_xImportedImageManager->replaceImages( SvxConfigPageHelper::GetImageType(), URLs, aImportGraph );
+ m_xImportedImageManager->replaceImages( SvxConfigPageHelper::GetImageType(), { aURL }, { xGraphic } );
m_xImportedImageManager->store();
bResult = true;
@@ -2949,10 +3022,10 @@ bool SvxIconSelectorDialog::ReplaceGraphicItem(
namespace
{
- OUString ReplaceIconName(const OUString& rMessage)
+ OUString ReplaceIconName(std::u16string_view rMessage)
{
OUString name;
- OUString message = CuiResId( RID_SVXSTR_REPLACE_ICON_WARNING );
+ OUString message = CuiResId( RID_CUISTR_REPLACE_ICON_WARNING );
OUString placeholder("%ICONNAME" );
sal_Int32 pos = message.indexOf( placeholder );
if ( pos != -1 )
@@ -2968,13 +3041,13 @@ namespace
private:
std::unique_ptr<weld::MessageDialog> m_xQueryBox;
public:
- SvxIconReplacementDialog(weld::Window *pParent, const OUString& rMessage, bool bYestoAll)
+ SvxIconReplacementDialog(weld::Window *pParent, std::u16string_view rMessage, bool bYestoAll)
: m_xQueryBox(Application::CreateMessageDialog(pParent, VclMessageType::Warning, VclButtonsType::NONE, ReplaceIconName(rMessage)))
{
- m_xQueryBox->set_title(CuiResId(RID_SVXSTR_REPLACE_ICON_CONFIRM));
+ m_xQueryBox->set_title(CuiResId(RID_CUISTR_REPLACE_ICON_CONFIRM));
m_xQueryBox->add_button(GetStandardText(StandardButtonType::Yes), 2);
if (bYestoAll)
- m_xQueryBox->add_button(CuiResId(RID_SVXSTR_YESTOALL), 5);
+ m_xQueryBox->add_button(CuiResId(RID_CUISTR_YESTOALL), 5);
m_xQueryBox->add_button(GetStandardText(StandardButtonType::No), 4);
m_xQueryBox->add_button(GetStandardText(StandardButtonType::Cancel), 6);
m_xQueryBox->set_default_response(2);
@@ -2986,7 +3059,7 @@ namespace
void SvxIconSelectorDialog::ImportGraphics(
const uno::Sequence< OUString >& rPaths )
{
- uno::Sequence< OUString > rejected( rPaths.getLength() );
+ std::vector< OUString > rejected( rPaths.getLength() );
sal_Int32 rejectedCount = 0;
sal_uInt16 ret = 0;
@@ -3075,7 +3148,7 @@ void SvxIconSelectorDialog::ImportGraphics(
fPath = OUString::Concat(rPaths[0].subView(8)) + "/";
for ( sal_Int32 i = 0; i < rejectedCount; ++i )
{
- message.append(fPath).append(rejected[i]).append("\n");
+ message.append(fPath + rejected[i] + "\n");
}
SvxIconChangeDialog aDialog(m_xDialog.get(), message.makeStringAndClear());
@@ -3086,11 +3159,8 @@ bool SvxIconSelectorDialog::ImportGraphic( const OUString& aURL )
{
bool result = false;
- uno::Sequence< beans::PropertyValue > aMediaProps( 1 );
- aMediaProps[0].Name = "URL";
+ uno::Sequence< beans::PropertyValue > aMediaProps{ comphelper::makePropertyValue("URL", aURL) };
- uno::Reference< graphic::XGraphic > xGraphic;
- aMediaProps[0].Value <<= aURL;
try
{
uno::Reference< beans::XPropertySet > props =
@@ -3098,7 +3168,7 @@ bool SvxIconSelectorDialog::ImportGraphic( const OUString& aURL )
uno::Any a = props->getPropertyValue("SizePixel");
- xGraphic = m_xGraphProvider->queryGraphic( aMediaProps );
+ uno::Reference< graphic::XGraphic > xGraphic = m_xGraphProvider->queryGraphic( aMediaProps );
if ( xGraphic.is() )
{
bool bOK = true;
@@ -3122,8 +3192,7 @@ bool SvxIconSelectorDialog::ImportGraphic( const OUString& aURL )
m_xTbSymbol->InsertItem(m_aGraphics.size(), aImage, aURL);
uno::Sequence<OUString> aImportURL { aURL };
- uno::Sequence< uno::Reference<graphic::XGraphic > > aImportGraph( 1 );
- aImportGraph[ 0 ] = xGraphic;
+ uno::Sequence< uno::Reference<graphic::XGraphic > > aImportGraph{ xGraphic };
m_xImportedImageManager->insertImages( SvxConfigPageHelper::GetImageType(), aImportURL, aImportGraph );
if ( m_xImportedImageManager->isModified() )
{
@@ -3164,39 +3233,16 @@ SvxIconChangeDialog::SvxIconChangeDialog(weld::Window *pWindow, const OUString&
}
SvxConfigPageFunctionDropTarget::SvxConfigPageFunctionDropTarget(SvxConfigPage&rPage, weld::TreeView& rTreeView)
- : DropTargetHelper(rTreeView.get_drop_target())
+ : weld::ReorderingDropTarget(rTreeView)
, m_rPage(rPage)
- , m_rTreeView(rTreeView)
-{
-}
-
-sal_Int8 SvxConfigPageFunctionDropTarget::AcceptDrop(const AcceptDropEvent& rEvt)
{
- // to enable the autoscroll when we're close to the edges
- m_rTreeView.get_dest_row_at_pos(rEvt.maPosPixel, nullptr, true);
- return DND_ACTION_MOVE;
}
-sal_Int8 SvxConfigPageFunctionDropTarget::ExecuteDrop( const ExecuteDropEvent& rEvt )
+sal_Int8 SvxConfigPageFunctionDropTarget::ExecuteDrop(const ExecuteDropEvent& rEvt)
{
- weld::TreeView* pSource = m_rTreeView.get_drag_source();
- // only dragging within the same widget allowed
- if (!pSource || pSource != &m_rTreeView)
- return DND_ACTION_NONE;
-
- std::unique_ptr<weld::TreeIter> xSource(m_rTreeView.make_iterator());
- if (!m_rTreeView.get_selected(xSource.get()))
- return DND_ACTION_NONE;
-
- std::unique_ptr<weld::TreeIter> xTarget(m_rTreeView.make_iterator());
- int nTargetPos = -1;
- if (m_rTreeView.get_dest_row_at_pos(rEvt.maPosPixel, xTarget.get(), true))
- nTargetPos = m_rTreeView.get_iter_index_in_parent(*xTarget);
- m_rTreeView.move_subtree(*xSource, nullptr, nTargetPos);
-
+ sal_Int8 nRet = weld::ReorderingDropTarget::ExecuteDrop(rEvt);
m_rPage.ListModified();
-
- return DND_ACTION_NONE;
+ return nRet;;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cui/source/customize/cfgutil.cxx b/cui/source/customize/cfgutil.cxx
index 4d17928b3b39..3a2cdbc1b05e 100644
--- a/cui/source/customize/cfgutil.cxx
+++ b/cui/source/customize/cfgutil.cxx
@@ -49,11 +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;
@@ -74,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)
@@ -239,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 )
@@ -259,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;
@@ -267,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())
@@ -291,12 +298,12 @@ 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_SVXSTR_COMMANDLABEL) + ": ";
- OUString aName = CuiResId(RID_SVXSTR_COMMANDNAME) + ": ";
- OUString aTip = CuiResId(RID_SVXSTR_COMMANDTIP) + ": ";
+ OUString aLabel = CuiResId(RID_CUISTR_COMMANDLABEL) + ": ";
+ OUString aName = CuiResId(RID_CUISTR_COMMANDNAME) + ": ";
+ OUString aTip = CuiResId(RID_CUISTR_COMMANDTIP) + ": ";
return aLabel + pData->sLabel + "\n" + aName + pData->sCommand+ "\n" + aTip + pData->sTooltip;
}
@@ -333,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();
@@ -343,19 +350,19 @@ struct SvxConfigGroupBoxResource_Impl
{
OUString m_sMyMacros;
OUString m_sProdMacros;
- OUString m_sMacros;
OUString m_sDlgMacros;
OUString m_aStrGroupStyles;
+ OUString m_aStrGroupSidebarDecks;
SvxConfigGroupBoxResource_Impl();
};
SvxConfigGroupBoxResource_Impl::SvxConfigGroupBoxResource_Impl() :
- m_sMyMacros(CuiResId(RID_SVXSTR_MYMACROS)),
- m_sProdMacros(CuiResId(RID_SVXSTR_PRODMACROS)),
- m_sMacros(CuiResId(RID_SVXSTR_BASICMACROS)),
- m_sDlgMacros(CuiResId(RID_SVXSTR_PRODMACROS)),
- m_aStrGroupStyles(CuiResId(RID_SVXSTR_GROUP_STYLES))
+ m_sMyMacros(CuiResId(RID_CUISTR_MYMACROS)),
+ m_sProdMacros(CuiResId(RID_CUISTR_PRODMACROS)),
+ m_sDlgMacros(CuiResId(RID_CUISTR_PRODMACROS)),
+ m_aStrGroupStyles(CuiResId(RID_CUISTR_GROUP_STYLES)),
+ m_aStrGroupSidebarDecks(CuiResId(RID_CUISTR_GROUP_SIDEBARDECKS))
{
}
@@ -462,27 +469,21 @@ 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_SVXSTR_ALLFUNCTIONS));
- }
+ sal_Int32 nAddedGroups = 0;
for (i1=0; i1<c1; ++i1)
{
- sal_Int16& rGroupID = lGroups[i1];
- OUString sGroupID = OUString::number(rGroupID);
+ sal_Int16 nGroupID = lGroups[i1];
+ OUString sGroupID = OUString::number(nGroupID);
OUString sGroupName ;
try
@@ -494,19 +495,21 @@ void CuiConfigGroupListBox::InitModule()
catch(const css::container::NoSuchElementException&)
{ continue; }
- aArr.push_back( std::make_unique<SfxGroupInfo_Impl>( SfxCfgKind::GROUP_FUNCTION, rGroupID ) );
- m_xTreeView->append(OUString::number(reinterpret_cast<sal_Int64>(aArr.back().get())),
- sGroupName);
+ aArr.push_back( std::make_unique<SfxGroupInfo_Impl>( SfxCfgKind::GROUP_FUNCTION, nGroupID ) );
+ 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,
- const weld::TreeIter* pParentEntry, bool bCheapChildrenOnDemand)
+ const weld::TreeIter* pParentEntry)
{
try {
if ( xRootNode->hasChildNodes() )
@@ -568,7 +571,8 @@ void CuiConfigGroupListBox::FillScriptList(const css::uno::Reference< css::scrip
theChild->acquire();
bool bChildOnDemand = false;
- if ( !bCheapChildrenOnDemand && theChild->hasChildNodes() )
+
+ if ( theChild->hasChildNodes() )
{
const Sequence< Reference< browse::XBrowseNode > > grandchildren =
theChild->getChildNodes();
@@ -582,21 +586,13 @@ void CuiConfigGroupListBox::FillScriptList(const css::uno::Reference< css::scrip
}
}
}
- else
- {
- /* i30923 - Would be nice if there was a better
- * way to determine if a basic lib had children
- * without having to ask for them (which forces
- * the library to be loaded */
- bChildOnDemand = true;
- }
OUString aImage = GetImage(theChild, m_xContext, bIsRootNode);
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);
}
@@ -621,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();
}
@@ -636,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;
@@ -643,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");
@@ -660,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 )
@@ -672,24 +683,29 @@ 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
{
//We are only showing scripts not slot APIs so skip
//Root node and show location nodes
- FillScriptList(rootNode, nullptr, false);
+ FillScriptList(rootNode, nullptr);
}
}
- // add styles
+ // 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 = weld::toId(aArr.back().get());
+ m_xTreeView->insert(nullptr, -1, &sSidebarDecks, &sId, nullptr, nullptr, false, nullptr);
}
m_xTreeView->thaw();
@@ -823,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();
@@ -835,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;
@@ -908,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);
}
}
@@ -933,13 +949,37 @@ 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);
}
}
break;
}
+ case SfxCfgKind::GROUP_SIDEBARDECKS:
+ {
+ sfx2::sidebar::ResourceManager aResourceManager;
+ sfx2::sidebar::Context aContext(m_sModuleLongName, OUString());
+ sfx2::sidebar::ResourceManager::DeckContextDescriptorContainer aDecks;
+ aResourceManager.GetMatchingDecks(aDecks, aContext, false, m_xFrame->getController());
+
+ for (auto const& rDeck : aDecks)
+ {
+ const OUString sCommand = ".uno:SidebarDeck." + rDeck.msId;
+ m_pFunctionListBox->aArr.push_back(std::make_unique<SfxGroupInfo_Impl>(
+ SfxCfgKind::GROUP_SIDEBARDECKS, 0,
+ nullptr));
+ m_pFunctionListBox->aArr.back()->sCommand = sCommand;
+ m_pFunctionListBox->aArr.back()->sLabel = rDeck.msId;
+ m_pFunctionListBox->aArr.back()->sTooltip =
+ vcl::CommandInfoProvider::GetCommandShortcut(sCommand, m_xFrame);
+ m_pFunctionListBox->append(weld::toId(m_pFunctionListBox->aArr.back().get()),
+ rDeck.msId);
+ }
+
+ break;
+ }
+
default:
// Do nothing, the list box will stay empty
SAL_INFO( "cui.customize", "Ignoring unexpected SfxCfgKind: " << static_cast<int>(pInfo->nKind) );
@@ -957,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:
@@ -966,7 +1006,7 @@ IMPL_LINK(CuiConfigGroupListBox, ExpandingHdl, const weld::TreeIter&, rIter, boo
{
Reference< browse::XBrowseNode > rootNode(
static_cast< browse::XBrowseNode* >( pInfo->pObject ) ) ;
- FillScriptList(rootNode, &rIter, true /* i30923 */ );
+ FillScriptList(rootNode, &rIter);
}
break;
}
@@ -980,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);
}
}
@@ -994,29 +1034,24 @@ IMPL_LINK(CuiConfigGroupListBox, ExpandingHdl, const weld::TreeIter&, rIter, boo
return true;
}
+#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 );
}
}
@@ -1027,48 +1062,65 @@ 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));
}
+#endif
/*
* Implementation of SvxScriptSelectorDialog
@@ -1084,21 +1136,18 @@ SvxScriptSelectorDialog::SvxScriptSelectorDialog(
, m_xCategories(new CuiConfigGroupListBox(m_xBuilder->weld_tree_view("categories")))
, m_xCommands(new CuiConfigFunctionListBox(m_xBuilder->weld_tree_view("commands")))
, m_xLibraryFT(m_xBuilder->weld_label("libraryft"))
- , m_xCategoryFT(m_xBuilder->weld_label("categoryft"))
, m_xMacronameFT(m_xBuilder->weld_label("macronameft"))
- , m_xCommandsFT(m_xBuilder->weld_label("commandsft"))
, m_xOKButton(m_xBuilder->weld_button("ok"))
, m_xCancelButton(m_xBuilder->weld_button("cancel"))
, m_xDescriptionText(m_xBuilder->weld_text_view("description"))
+ , m_xDescriptionFrame(m_xBuilder->weld_frame("descriptionframe"))
{
m_xCancelButton->show();
m_xDialogDescription->show();
m_xOKButton->show();
m_xLibraryFT->set_visible(true);
- m_xCategoryFT->set_visible(false);
m_xMacronameFT->set_visible(true);
- m_xCommandsFT->set_visible(false);
const OUString aModuleName(vcl::CommandInfoProvider::GetModuleIdentifier(xFrame));
m_xCategories->SetFunctionListBox(m_xCommands.get());
@@ -1126,7 +1175,14 @@ 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())
+ m_xDescriptionFrame->hide();
}
SvxScriptSelectorDialog::~SvxScriptSelectorDialog()
@@ -1161,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();
@@ -1189,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
@@ -1207,6 +1262,7 @@ IMPL_LINK(SvxScriptSelectorDialog, ClickHdl, weld::Button&, rButton, void)
}
else if (&rButton == m_xOKButton.get())
{
+ SaveLastUsedMacro();
m_xDialog->response(RET_OK);
}
}
@@ -1214,7 +1270,7 @@ IMPL_LINK(SvxScriptSelectorDialog, ClickHdl, weld::Button&, rButton, void)
void
SvxScriptSelectorDialog::SetRunLabel()
{
- m_xOKButton->set_label(CuiResId(RID_SVXSTR_SELECTOR_RUN));
+ m_xOKButton->set_label(CuiResId(RID_CUISTR_SELECTOR_RUN));
}
OUString
@@ -1225,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 )
@@ -1238,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 72cd08b168fa..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,
@@ -123,7 +124,6 @@ IMPL_LINK_NOARG( SvxEventConfigPage, SelectHdl_Impl, weld::ComboBox&, void )
{
bool bApp = m_xSaveInListBox->get_active_id().toBoolean();
- mpImpl->xEventLB->freeze();
if (bApp)
{
SetReadOnly( false );
@@ -155,8 +155,6 @@ IMPL_LINK_NOARG( SvxEventConfigPage, SelectHdl_Impl, weld::ComboBox&, void )
SetReadOnly( isReadonly );
SvxMacroTabPage_::DisplayAppEvents( false );
}
-
- mpImpl->xEventLB->thaw();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cui/source/customize/macropg.cxx b/cui/source/customize/macropg.cxx
index b6e4694dddac..79197be4bf43 100644
--- a/cui/source/customize/macropg.cxx
+++ b/cui/source/customize/macropg.cxx
@@ -20,22 +20,25 @@
#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>
#include <helpids.h>
#include <headertablistbox.hxx>
#include "macropg_impl.hxx"
+#include <o3tl/safeint.hxx>
#include <svl/macitem.hxx>
#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;
-const char aVndSunStarUNO[] = "vnd.sun.star.UNO:";
+constexpr OUString aVndSunStarUNO = u"vnd.sun.star.UNO:"_ustr;
SvxMacroTabPage_Impl::SvxMacroTabPage_Impl( const SfxItemSet& rAttrSet )
: bReadOnly(false)
@@ -58,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)
@@ -88,81 +92,81 @@ void SvxMacroTabPage_::InitResources()
// Note: the order here controls the order in which the events are displayed in the UI!
// the event name to UI string mappings for App Events
- aDisplayNames.emplace_back( "OnStartApp", RID_SVXSTR_EVENT_STARTAPP );
- aDisplayNames.emplace_back( "OnCloseApp", RID_SVXSTR_EVENT_CLOSEAPP );
- aDisplayNames.emplace_back( "OnCreate", RID_SVXSTR_EVENT_CREATEDOC );
- aDisplayNames.emplace_back( "OnNew", RID_SVXSTR_EVENT_NEWDOC );
- aDisplayNames.emplace_back( "OnLoadFinished", RID_SVXSTR_EVENT_LOADDOCFINISHED );
- aDisplayNames.emplace_back( "OnLoad", RID_SVXSTR_EVENT_OPENDOC );
- aDisplayNames.emplace_back( "OnPrepareUnload", RID_SVXSTR_EVENT_PREPARECLOSEDOC );
- aDisplayNames.emplace_back( "OnUnload", RID_SVXSTR_EVENT_CLOSEDOC ) ;
- aDisplayNames.emplace_back( "OnViewCreated", RID_SVXSTR_EVENT_VIEWCREATED );
- aDisplayNames.emplace_back( "OnPrepareViewClosing", RID_SVXSTR_EVENT_PREPARECLOSEVIEW );
- aDisplayNames.emplace_back( "OnViewClosed", RID_SVXSTR_EVENT_CLOSEVIEW ) ;
- aDisplayNames.emplace_back( "OnFocus", RID_SVXSTR_EVENT_ACTIVATEDOC );
- aDisplayNames.emplace_back( "OnUnfocus", RID_SVXSTR_EVENT_DEACTIVATEDOC );
- aDisplayNames.emplace_back( "OnSave", RID_SVXSTR_EVENT_SAVEDOC );
- aDisplayNames.emplace_back( "OnSaveDone", RID_SVXSTR_EVENT_SAVEDOCDONE );
- aDisplayNames.emplace_back( "OnSaveFailed", RID_SVXSTR_EVENT_SAVEDOCFAILED );
- aDisplayNames.emplace_back( "OnSaveAs", RID_SVXSTR_EVENT_SAVEASDOC );
- aDisplayNames.emplace_back( "OnSaveAsDone", RID_SVXSTR_EVENT_SAVEASDOCDONE );
- aDisplayNames.emplace_back( "OnSaveAsFailed", RID_SVXSTR_EVENT_SAVEASDOCFAILED );
- aDisplayNames.emplace_back( "OnCopyTo", RID_SVXSTR_EVENT_COPYTODOC );
- aDisplayNames.emplace_back( "OnCopyToDone", RID_SVXSTR_EVENT_COPYTODOCDONE );
- aDisplayNames.emplace_back( "OnCopyToFailed", RID_SVXSTR_EVENT_COPYTODOCFAILED );
- aDisplayNames.emplace_back( "OnPrint", RID_SVXSTR_EVENT_PRINTDOC );
- aDisplayNames.emplace_back( "OnModifyChanged", RID_SVXSTR_EVENT_MODIFYCHANGED );
- aDisplayNames.emplace_back( "OnTitleChanged", RID_SVXSTR_EVENT_TITLECHANGED );
+ aDisplayNames.emplace_back( "OnStartApp", RID_CUISTR_EVENT_STARTAPP );
+ aDisplayNames.emplace_back( "OnCloseApp", RID_CUISTR_EVENT_CLOSEAPP );
+ aDisplayNames.emplace_back( "OnCreate", RID_CUISTR_EVENT_CREATEDOC );
+ aDisplayNames.emplace_back( "OnNew", RID_CUISTR_EVENT_NEWDOC );
+ aDisplayNames.emplace_back( "OnLoadFinished", RID_CUISTR_EVENT_LOADDOCFINISHED );
+ aDisplayNames.emplace_back( "OnLoad", RID_CUISTR_EVENT_OPENDOC );
+ aDisplayNames.emplace_back( "OnPrepareUnload", RID_CUISTR_EVENT_PREPARECLOSEDOC );
+ aDisplayNames.emplace_back( "OnUnload", RID_CUISTR_EVENT_CLOSEDOC ) ;
+ aDisplayNames.emplace_back( "OnViewCreated", RID_CUISTR_EVENT_VIEWCREATED );
+ aDisplayNames.emplace_back( "OnPrepareViewClosing", RID_CUISTR_EVENT_PREPARECLOSEVIEW );
+ aDisplayNames.emplace_back( "OnViewClosed", RID_CUISTR_EVENT_CLOSEVIEW ) ;
+ aDisplayNames.emplace_back( "OnFocus", RID_CUISTR_EVENT_ACTIVATEDOC );
+ aDisplayNames.emplace_back( "OnUnfocus", RID_CUISTR_EVENT_DEACTIVATEDOC );
+ aDisplayNames.emplace_back( "OnSave", RID_CUISTR_EVENT_SAVEDOC );
+ aDisplayNames.emplace_back( "OnSaveDone", RID_CUISTR_EVENT_SAVEDOCDONE );
+ aDisplayNames.emplace_back( "OnSaveFailed", RID_CUISTR_EVENT_SAVEDOCFAILED );
+ aDisplayNames.emplace_back( "OnSaveAs", RID_CUISTR_EVENT_SAVEASDOC );
+ aDisplayNames.emplace_back( "OnSaveAsDone", RID_CUISTR_EVENT_SAVEASDOCDONE );
+ aDisplayNames.emplace_back( "OnSaveAsFailed", RID_CUISTR_EVENT_SAVEASDOCFAILED );
+ aDisplayNames.emplace_back( "OnCopyTo", RID_CUISTR_EVENT_COPYTODOC );
+ aDisplayNames.emplace_back( "OnCopyToDone", RID_CUISTR_EVENT_COPYTODOCDONE );
+ aDisplayNames.emplace_back( "OnCopyToFailed", RID_CUISTR_EVENT_COPYTODOCFAILED );
+ aDisplayNames.emplace_back( "OnPrint", RID_CUISTR_EVENT_PRINTDOC );
+ aDisplayNames.emplace_back( "OnModifyChanged", RID_CUISTR_EVENT_MODIFYCHANGED );
+ aDisplayNames.emplace_back( "OnTitleChanged", RID_CUISTR_EVENT_TITLECHANGED );
// application specific events
- aDisplayNames.emplace_back( "OnMailMerge", RID_SVXSTR_EVENT_MAILMERGE );
- aDisplayNames.emplace_back( "OnMailMergeFinished", RID_SVXSTR_EVENT_MAILMERGE_END );
- aDisplayNames.emplace_back( "OnFieldMerge", RID_SVXSTR_EVENT_FIELDMERGE );
- aDisplayNames.emplace_back( "OnFieldMergeFinished", RID_SVXSTR_EVENT_FIELDMERGE_FINISHED );
- aDisplayNames.emplace_back( "OnPageCountChange", RID_SVXSTR_EVENT_PAGECOUNTCHANGE );
- aDisplayNames.emplace_back( "OnSubComponentOpened", RID_SVXSTR_EVENT_SUBCOMPONENT_OPENED );
- aDisplayNames.emplace_back( "OnSubComponentClosed", RID_SVXSTR_EVENT_SUBCOMPONENT_CLOSED );
- aDisplayNames.emplace_back( "OnSelect", RID_SVXSTR_EVENT_SELECTIONCHANGED );
- aDisplayNames.emplace_back( "OnDoubleClick", RID_SVXSTR_EVENT_DOUBLECLICK );
- aDisplayNames.emplace_back( "OnRightClick", RID_SVXSTR_EVENT_RIGHTCLICK );
- aDisplayNames.emplace_back( "OnCalculate", RID_SVXSTR_EVENT_CALCULATE );
- aDisplayNames.emplace_back( "OnChange", RID_SVXSTR_EVENT_CONTENTCHANGED );
+ aDisplayNames.emplace_back( "OnMailMerge", RID_CUISTR_EVENT_MAILMERGE );
+ aDisplayNames.emplace_back( "OnMailMergeFinished", RID_CUISTR_EVENT_MAILMERGE_END );
+ aDisplayNames.emplace_back( "OnFieldMerge", RID_CUISTR_EVENT_FIELDMERGE );
+ aDisplayNames.emplace_back( "OnFieldMergeFinished", RID_CUISTR_EVENT_FIELDMERGE_FINISHED );
+ aDisplayNames.emplace_back( "OnPageCountChange", RID_CUISTR_EVENT_PAGECOUNTCHANGE );
+ aDisplayNames.emplace_back( "OnSubComponentOpened", RID_CUISTR_EVENT_SUBCOMPONENT_OPENED );
+ aDisplayNames.emplace_back( "OnSubComponentClosed", RID_CUISTR_EVENT_SUBCOMPONENT_CLOSED );
+ aDisplayNames.emplace_back( "OnSelect", RID_CUISTR_EVENT_SELECTIONCHANGED );
+ aDisplayNames.emplace_back( "OnDoubleClick", RID_CUISTR_EVENT_DOUBLECLICK );
+ aDisplayNames.emplace_back( "OnRightClick", RID_CUISTR_EVENT_RIGHTCLICK );
+ aDisplayNames.emplace_back( "OnCalculate", RID_CUISTR_EVENT_CALCULATE );
+ aDisplayNames.emplace_back( "OnChange", RID_CUISTR_EVENT_CONTENTCHANGED );
// the event name to UI string mappings for forms & dialogs
- aDisplayNames.emplace_back( "approveAction", RID_SVXSTR_EVENT_APPROVEACTIONPERFORMED );
- aDisplayNames.emplace_back( "actionPerformed", RID_SVXSTR_EVENT_ACTIONPERFORMED );
- aDisplayNames.emplace_back( "changed", RID_SVXSTR_EVENT_CHANGED );
- aDisplayNames.emplace_back( "textChanged", RID_SVXSTR_EVENT_TEXTCHANGED );
- aDisplayNames.emplace_back( "itemStateChanged", RID_SVXSTR_EVENT_ITEMSTATECHANGED );
- aDisplayNames.emplace_back( "focusGained", RID_SVXSTR_EVENT_FOCUSGAINED );
- aDisplayNames.emplace_back( "focusLost", RID_SVXSTR_EVENT_FOCUSLOST );
- aDisplayNames.emplace_back( "keyPressed", RID_SVXSTR_EVENT_KEYTYPED );
- aDisplayNames.emplace_back( "keyReleased", RID_SVXSTR_EVENT_KEYUP );
- aDisplayNames.emplace_back( "mouseEntered", RID_SVXSTR_EVENT_MOUSEENTERED );
- aDisplayNames.emplace_back( "mouseDragged", RID_SVXSTR_EVENT_MOUSEDRAGGED );
- aDisplayNames.emplace_back( "mouseMoved", RID_SVXSTR_EVENT_MOUSEMOVED );
- aDisplayNames.emplace_back( "mousePressed", RID_SVXSTR_EVENT_MOUSEPRESSED );
- aDisplayNames.emplace_back( "mouseReleased", RID_SVXSTR_EVENT_MOUSERELEASED );
- aDisplayNames.emplace_back( "mouseExited", RID_SVXSTR_EVENT_MOUSEEXITED );
- aDisplayNames.emplace_back( "approveReset", RID_SVXSTR_EVENT_APPROVERESETTED );
- aDisplayNames.emplace_back( "resetted", RID_SVXSTR_EVENT_RESETTED );
- aDisplayNames.emplace_back( "approveSubmit", RID_SVXSTR_EVENT_SUBMITTED );
- aDisplayNames.emplace_back( "approveUpdate", RID_SVXSTR_EVENT_BEFOREUPDATE );
- aDisplayNames.emplace_back( "updated", RID_SVXSTR_EVENT_AFTERUPDATE );
- aDisplayNames.emplace_back( "loaded", RID_SVXSTR_EVENT_LOADED );
- aDisplayNames.emplace_back( "reloading", RID_SVXSTR_EVENT_RELOADING );
- aDisplayNames.emplace_back( "reloaded", RID_SVXSTR_EVENT_RELOADED );
- aDisplayNames.emplace_back( "unloading", RID_SVXSTR_EVENT_UNLOADING );
- aDisplayNames.emplace_back( "unloaded", RID_SVXSTR_EVENT_UNLOADED );
- aDisplayNames.emplace_back( "confirmDelete", RID_SVXSTR_EVENT_CONFIRMDELETE );
- aDisplayNames.emplace_back( "approveRowChange", RID_SVXSTR_EVENT_APPROVEROWCHANGE );
- aDisplayNames.emplace_back( "rowChanged", RID_SVXSTR_EVENT_ROWCHANGE );
- aDisplayNames.emplace_back( "approveCursorMove", RID_SVXSTR_EVENT_POSITIONING );
- aDisplayNames.emplace_back( "cursorMoved", RID_SVXSTR_EVENT_POSITIONED );
- aDisplayNames.emplace_back( "approveParameter", RID_SVXSTR_EVENT_APPROVEPARAMETER );
- aDisplayNames.emplace_back( "errorOccured", RID_SVXSTR_EVENT_ERROROCCURRED );
- aDisplayNames.emplace_back( "adjustmentValueChanged", RID_SVXSTR_EVENT_ADJUSTMENTVALUECHANGED );
+ aDisplayNames.emplace_back( "approveAction", RID_CUISTR_EVENT_APPROVEACTIONPERFORMED );
+ aDisplayNames.emplace_back( "actionPerformed", RID_CUISTR_EVENT_ACTIONPERFORMED );
+ aDisplayNames.emplace_back( "changed", RID_CUISTR_EVENT_CHANGED );
+ aDisplayNames.emplace_back( "textChanged", RID_CUISTR_EVENT_TEXTCHANGED );
+ aDisplayNames.emplace_back( "itemStateChanged", RID_CUISTR_EVENT_ITEMSTATECHANGED );
+ aDisplayNames.emplace_back( "focusGained", RID_CUISTR_EVENT_FOCUSGAINED );
+ aDisplayNames.emplace_back( "focusLost", RID_CUISTR_EVENT_FOCUSLOST );
+ aDisplayNames.emplace_back( "keyPressed", RID_CUISTR_EVENT_KEYTYPED );
+ aDisplayNames.emplace_back( "keyReleased", RID_CUISTR_EVENT_KEYUP );
+ aDisplayNames.emplace_back( "mouseEntered", RID_CUISTR_EVENT_MOUSEENTERED );
+ aDisplayNames.emplace_back( "mouseDragged", RID_CUISTR_EVENT_MOUSEDRAGGED );
+ aDisplayNames.emplace_back( "mouseMoved", RID_CUISTR_EVENT_MOUSEMOVED );
+ aDisplayNames.emplace_back( "mousePressed", RID_CUISTR_EVENT_MOUSEPRESSED );
+ aDisplayNames.emplace_back( "mouseReleased", RID_CUISTR_EVENT_MOUSERELEASED );
+ aDisplayNames.emplace_back( "mouseExited", RID_CUISTR_EVENT_MOUSEEXITED );
+ aDisplayNames.emplace_back( "approveReset", RID_CUISTR_EVENT_APPROVERESETTED );
+ aDisplayNames.emplace_back( "resetted", RID_CUISTR_EVENT_RESETTED );
+ aDisplayNames.emplace_back( "approveSubmit", RID_CUISTR_EVENT_SUBMITTED );
+ aDisplayNames.emplace_back( "approveUpdate", RID_CUISTR_EVENT_BEFOREUPDATE );
+ aDisplayNames.emplace_back( "updated", RID_CUISTR_EVENT_AFTERUPDATE );
+ aDisplayNames.emplace_back( "loaded", RID_CUISTR_EVENT_LOADED );
+ aDisplayNames.emplace_back( "reloading", RID_CUISTR_EVENT_RELOADING );
+ aDisplayNames.emplace_back( "reloaded", RID_CUISTR_EVENT_RELOADED );
+ aDisplayNames.emplace_back( "unloading", RID_CUISTR_EVENT_UNLOADING );
+ aDisplayNames.emplace_back( "unloaded", RID_CUISTR_EVENT_UNLOADED );
+ aDisplayNames.emplace_back( "confirmDelete", RID_CUISTR_EVENT_CONFIRMDELETE );
+ aDisplayNames.emplace_back( "approveRowChange", RID_CUISTR_EVENT_APPROVEROWCHANGE );
+ aDisplayNames.emplace_back( "rowChanged", RID_CUISTR_EVENT_ROWCHANGE );
+ aDisplayNames.emplace_back( "approveCursorMove", RID_CUISTR_EVENT_POSITIONING );
+ aDisplayNames.emplace_back( "cursorMoved", RID_CUISTR_EVENT_POSITIONED );
+ aDisplayNames.emplace_back( "approveParameter", RID_CUISTR_EVENT_APPROVEPARAMETER );
+ aDisplayNames.emplace_back( "errorOccured", RID_CUISTR_EVENT_ERROROCCURRED );
+ aDisplayNames.emplace_back( "adjustmentValueChanged", RID_CUISTR_EVENT_ADJUSTMENTVALUECHANGED );
}
// the following method is called when the user clicks OK
@@ -268,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(strlen(aVndSunStarUNO));
+ 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;
}
}
@@ -304,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)
@@ -319,7 +323,10 @@ void SvxMacroTabPage_::DisplayAppEvents( bool appEvents)
// have to use the original XNameReplace since the hash iterators do
// not guarantee the order in which the elements are returned
if(!nameReplace.is())
+ {
+ mpImpl->xEventLB->thaw();
return;
+ }
for (auto const& displayableEvent : aDisplayNames)
{
@@ -340,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();
@@ -370,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)
{
@@ -391,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)
+ if (const EventPair* pEventPair = LookupEvent(sEventName))
{
- 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
- {
- 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.
@@ -492,14 +549,17 @@ 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 ) );
mpImpl->xEventLB->connect_changed( LINK( this, SvxMacroTabPage_, SelectEvent_Impl ));
- std::vector<int> aWidths;
- aWidths.push_back(mpImpl->xEventLB->get_approximate_digit_width() * 32);
- aWidths.push_back(mpImpl->xEventLB->get_checkbox_column_width());
+ std::vector<int> aWidths
+ {
+ o3tl::narrowing<int>(mpImpl->xEventLB->get_approximate_digit_width() * 32),
+ mpImpl->xEventLB->get_checkbox_column_width()
+ };
mpImpl->xEventLB->set_column_fixed_widths(aWidths);
mpImpl->xEventLB->show();
@@ -542,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;
@@ -558,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;
@@ -583,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 );
@@ -619,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"))
{
@@ -630,7 +691,7 @@ AssignComponentDialog::AssignComponentDialog(weld::Window* pParent, const OUStri
OUString aMethodName;
if( maURL.startsWith( aVndSunStarUNO ) )
{
- aMethodName = maURL.copy( strlen(aVndSunStarUNO) );
+ aMethodName = maURL.copy( aVndSunStarUNO.getLength() );
}
mxMethodEdit->set_text(aMethodName);
mxMethodEdit->select_region(0, -1);
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; }