41 , m_bIsMenuBar(bIsMenuBar)
43 m_xGearBtn = m_xBuilder->weld_menu_button(
"menugearbtn");
52 MenuEntriesSizeAllocHdl(aSize);
112 std::vector<int> aWidths;
117 aWidths.push_back(rSize.Width() - (nMargin + nStandardImageColWidth));
155 && weld::fromId<SvxConfigEntry*>(
m_xContentsListBox->get_id(selection))->IsSeparator();
164 m_xModifyBtn->set_sensitive(bIsValidSelection && !bIsSeparator);
179 if (bIsValidSelection)
243 OUString msg =
CuiResId(RID_CUISTR_CONFIRM_MENU_RESET);
251 return xQueryBox->run();
266 pEntries->size(), [
this, &rTreeView, pEntries](
weld::TreeIter& rIter,
int nIdx) {
267 auto const& entry = (*pEntries)[nIdx];
268 OUString sId(weld::toId(entry));
269 rTreeView.set_id(rIter, sId);
270 InsertEntryIntoUI(entry, rTreeView, rIter, true);
279 if (rIdent ==
"menu_gear_add")
288 GetSaveInData()->SetModified();
291 else if (rIdent ==
"menu_gear_delete")
293 DeleteSelectedTopLevel();
295 else if (rIdent ==
"menu_gear_rename")
300 OUString sDesc =
CuiResId(RID_CUISTR_LABEL_NEW_NAME);
308 OUString sNewName = aNameDialog.
GetName();
310 if (sCurrentName == sNewName)
315 ReloadTopLevelListBox();
317 GetSaveInData()->SetModified();
320 else if (rIdent ==
"menu_gear_move")
330 ReloadTopLevelListBox();
332 GetSaveInData()->SetModified();
338 SAL_WARN(
"cui.customize",
"Unknown gear menu option: " << rIdent);
342 UpdateButtonStates();
347 OUString aSearchTerm(m_xSearchEdit->get_text());
349 m_xCommandCategoryListBox->categorySelected(m_xFunctions.get(), aSearchTerm, GetSaveInData());
351 SelectFunctionHdl(m_xFunctions->get_widget());
356 int nPos = AddFunction(-1,
false);
361 InsertEntryIntoUI(pEntry, rTreeView,
nPos,
true);
366 DeleteSelectedContent();
367 if (GetSaveInData()->IsModified())
369 UpdateButtonStates();
376 if (rIdent ==
"insertseparator")
380 int nPos = AppendEntry(pNewEntryData, -1);
381 InsertEntryIntoUI(pNewEntryData, rTreeView,
nPos,
true);
383 else if (rIdent ==
"insertsubmenu")
386 OUString aDesc =
CuiResId(RID_CUISTR_SUBMENU_NAME);
394 aNewName = aNameDialog.
GetName();
398 pNewEntryData->
SetName(aNewName);
401 int nPos = AppendEntry(pNewEntryData, -1);
402 InsertEntryIntoUI(pNewEntryData, rTreeView,
nPos,
true);
404 ReloadTopLevelListBox();
406 m_xContentsListBox->scroll_to_row(
nPos);
407 m_xContentsListBox->select(
nPos);
409 GetSaveInData()->SetModified();
415 SAL_WARN(
"cui.customize",
"Unknown insert option: " << rIdent);
419 if (GetSaveInData()->IsModified())
421 UpdateButtonStates();
427 if (rIdent ==
"renameItem")
429 int nActEntry = m_xContentsListBox->get_selected_index();
431 = weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(nActEntry));
434 OUString aDesc =
CuiResId(RID_CUISTR_LABEL_NEW_NAME);
442 aNewName = aNameDialog.
GetName();
445 m_xContentsListBox->set_text(nActEntry, aNewName, 0);
447 GetSaveInData()->SetModified();
448 GetTopLevelSelection()->SetModified();
454 SAL_WARN(
"cui.customize",
"Unknown insert option: " << rIdent);
458 if (GetSaveInData()->IsModified())
460 UpdateButtonStates();
468 if (pMenuData ==
nullptr)
471 "RHB top level selection is null. A menu must be selected to reset!");
476 GetFrameWeld(), VclMessageType::Question, VclButtonsType::YesNo,
477 CuiResId(RID_CUISTR_CONFIRM_RESTORE_DEFAULT_MENU)));
481 if (m_bIsMenuBar || xQueryBox->run() !=
RET_YES)
484 sal_Int32
nPos = m_xTopLevelListBox->get_active();
490 m_xTopLevelListBox->clear();
491 m_xContentsListBox->clear();
493 ReloadTopLevelListBox();
496 m_xTopLevelListBox->set_active(
nPos);
501 const css::uno::Reference<css::ui::XUIConfigurationManager>& xCfgMgr,
502 const css::uno::Reference<css::ui::XUIConfigurationManager>& xParentCfgMgr,
503 const OUString& aModuleId,
bool bDocConfig)
510 new MenuSaveInData(xCfgMgr, xParentCfgMgr, aModuleId, bDocConfig));
515 if (rCEvt.GetCommand() != CommandEventId::ContextMenu)
521 std::unique_ptr<weld::TreeIter> xIter(rTreeView.
make_iterator());
525 SelectMenuEntry(rTreeView);
527 int nSelectIndex = m_xContentsListBox->get_selected_index();
531 && weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(nSelectIndex))->IsSeparator();
532 bool bIsValidSelection = (m_xContentsListBox->n_children() != 0 && nSelectIndex != -1);
534 std::unique_ptr<weld::Builder> xBuilder(
536 auto xContextMenu = xBuilder->weld_menu(
"menu");
537 xContextMenu->set_visible(
"add",
false);
538 xContextMenu->set_visible(
"remove", bIsValidSelection);
539 xContextMenu->set_visible(
"rename", bIsValidSelection && !bIsSeparator);
540 xContextMenu->set_visible(
"changeIcon",
false);
541 xContextMenu->set_visible(
"resetIcon",
false);
542 xContextMenu->set_visible(
"restoreDefault",
false);
543 OUString sCommand(xContextMenu->popup_at_rect(
546 if (sCommand ==
"remove")
548 RemoveCommandHdl(*m_xRemoveCommandButton);
550 else if (sCommand ==
"rename")
552 ModifyItemHdl(
"renameItem");
554 else if (!sCommand.isEmpty())
555 SAL_WARN(
"cui.customize",
"Unknown context menu action: " << sCommand);
561 if (rCEvt.GetCommand() != CommandEventId::ContextMenu)
567 std::unique_ptr<weld::TreeIter> xIter(rTreeView.
make_iterator());
571 SelectFunctionHdl(rTreeView);
573 std::unique_ptr<weld::Builder> xBuilder(
575 auto xContextMenu = xBuilder->weld_menu(
"menu");
576 xContextMenu->set_visible(
"add",
true);
577 xContextMenu->set_visible(
"remove",
false);
578 xContextMenu->set_visible(
"rename",
false);
579 xContextMenu->set_visible(
"changeIcon",
false);
580 xContextMenu->set_visible(
"resetIcon",
false);
581 xContextMenu->set_visible(
"restoreDefault",
false);
582 OUString sCommand(xContextMenu->popup_at_rect(
585 if (sCommand ==
"add")
587 AddCommandHdl(*m_xAddCommandButton);
589 else if (!sCommand.isEmpty())
590 SAL_WARN(
"cui.customize",
"Unknown context menu action: " << sCommand);
std::vector< SvxConfigEntry * > SvxEntries
static std::unique_ptr< weld::Builder > CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false, sal_uInt64 nLOKWindowId=0)
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
void SetModified(bool bValue=true)
weld::Window * GetFrameWeld() const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
SvxEntries * GetEntries() const
void SetName(const OUString &rStr)
void SetModified(bool bValue=true)
void SetUserDefined(bool bOn=true)
const OUString & GetName() const
static OUString replaceSaveInName(const OUString &rMessage, std::u16string_view rSaveInName)
static OUString stripHotKey(const OUString &str)
static void RemoveEntry(SvxEntries *pEntries, SvxConfigEntry const *pChildEntry)
void ReloadTopLevelListBox(SvxConfigEntry const *pSelection=nullptr)
OUString GetScriptURL() const
std::unique_ptr< weld::Button > m_xMoveUpButton
std::unique_ptr< weld::ComboBox > m_xTopLevelListBox
std::unique_ptr< weld::MenuButton > m_xGearBtn
std::unique_ptr< SvxConfigPageFunctionDropTarget > m_xDropTargetHelper
SvxConfigEntry * GetTopLevelSelection()
std::unique_ptr< CuiConfigFunctionListBox > m_xFunctions
std::unique_ptr< weld::Button > m_xRemoveCommandButton
std::unique_ptr< CommandCategoryListBox > m_xCommandCategoryListBox
std::unique_ptr< weld::Button > m_xResetBtn
static bool IsCommandInMenuList(const SvxConfigEntry *pEntryData, const SvxEntries *pEntries)
std::unique_ptr< weld::MenuButton > m_xInsertBtn
SvxConfigEntry * CreateCommandFromSelection(const OUString &aURL)
std::unique_ptr< weld::Button > m_xMoveDownButton
css::uno::Reference< css::frame::XFrame > m_xFrame
std::unique_ptr< weld::MenuButton > m_xModifyBtn
std::unique_ptr< weld::Button > m_xAddCommandButton
std::unique_ptr< weld::ComboBox > m_xSaveInListBox
SaveInData * GetSaveInData()
SvxEntries * FindParentForChild(SvxEntries *pParentEntries, SvxConfigEntry *pChildData)
std::unique_ptr< SvxMenuEntriesListBox > m_xContentsListBox
std::unique_ptr< SvxEntries > ReleaseEntries()
SvxConfigEntry * GetSelectedEntry()
void set_title(const OUString &rTitle)
void set_help_id(const OUString &rHelpId)
virtual std::unique_ptr< TreeIter > make_iterator(const TreeIter *pOrig=nullptr) const=0
virtual void connect_popup_menu(const Link< const CommandEvent &, bool > &rLink)
int get_checkbox_column_width() const
virtual bool get_dest_row_at_pos(const Point &rPos, weld::TreeIter *pResult, bool bDnDMode, bool bAutoScroll=true)=0
void connect_changed(const Link< TreeView &, void > &rLink)
virtual void select(int pos)=0
virtual void set_column_fixed_widths(const std::vector< int > &rWidths)=0
virtual void bulk_insert_for_each(int nSourceCount, const std::function< void(TreeIter &, int nSourceIndex)> &func, const weld::TreeIter *pParent=nullptr, const std::vector< int > *pFixedWidths=nullptr)=0
virtual OUString get_id(int pos) const=0
OUString CuiResId(TranslateId aKey)
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
constexpr OUStringLiteral HID_SVX_CONFIG_NAME_SUBMENU
constexpr OUStringLiteral HID_SVX_CONFIG_RENAME_MENU_ITEM
constexpr OUStringLiteral HID_SVX_CONFIG_RENAME_MENU
#define LINK(Instance, Class, Member)
#define SAL_WARN(area, stream)
Reference< XComponentContext > getProcessComponentContext()