42 , m_bIsMenuBar(bIsMenuBar)
44 m_xGearBtn = m_xBuilder->weld_menu_button(
"menugearbtn");
53 MenuEntriesSizeAllocHdl(aSize);
113 std::vector<int> aWidths;
118 aWidths.push_back(rSize.Width() - (nMargin + nStandardImageColWidth));
156 && weld::fromId<SvxConfigEntry*>(
m_xContentsListBox->get_id(selection))->IsSeparator();
165 m_xModifyBtn->set_sensitive(bIsValidSelection && !bIsSeparator);
180 if (bIsValidSelection)
244 OUString msg =
CuiResId(RID_CUISTR_CONFIRM_MENU_RESET);
252 return xQueryBox->run();
267 pEntries->size(), [
this, &rTreeView, pEntries](
weld::TreeIter& rIter,
int nIdx) {
268 auto const& entry = (*pEntries)[nIdx];
269 OUString sId(weld::toId(entry));
270 rTreeView.set_id(rIter, sId);
271 InsertEntryIntoUI(entry, rTreeView, rIter, true);
280 if (rIdent ==
"menu_gear_add")
289 GetSaveInData()->SetModified();
292 else if (rIdent ==
"menu_gear_delete")
294 DeleteSelectedTopLevel();
296 else if (rIdent ==
"menu_gear_rename")
301 OUString sDesc =
CuiResId(RID_CUISTR_LABEL_NEW_NAME);
309 OUString sNewName = aNameDialog.
GetName();
311 if (sCurrentName == sNewName)
316 ReloadTopLevelListBox();
318 GetSaveInData()->SetModified();
321 else if (rIdent ==
"menu_gear_move")
331 ReloadTopLevelListBox();
333 GetSaveInData()->SetModified();
339 SAL_WARN(
"cui.customize",
"Unknown gear menu option: " << rIdent);
343 UpdateButtonStates();
348 OUString aSearchTerm(m_xSearchEdit->get_text());
350 m_xCommandCategoryListBox->categorySelected(m_xFunctions.get(), aSearchTerm, GetSaveInData());
352 SelectFunctionHdl(m_xFunctions->get_widget());
357 int nPos = AddFunction(-1,
false);
362 InsertEntryIntoUI(pEntry, rTreeView,
nPos,
true);
367 DeleteSelectedContent();
368 if (GetSaveInData()->IsModified())
370 UpdateButtonStates();
377 if (rIdent ==
"insertseparator")
381 int nPos = AppendEntry(pNewEntryData, -1);
382 InsertEntryIntoUI(pNewEntryData, rTreeView,
nPos,
true);
384 else if (rIdent ==
"insertsubmenu")
387 OUString aDesc =
CuiResId(RID_CUISTR_SUBMENU_NAME);
395 aNewName = aNameDialog.
GetName();
399 pNewEntryData->
SetName(aNewName);
402 int nPos = AppendEntry(pNewEntryData, -1);
403 InsertEntryIntoUI(pNewEntryData, rTreeView,
nPos,
true);
405 ReloadTopLevelListBox();
407 m_xContentsListBox->scroll_to_row(
nPos);
408 m_xContentsListBox->select(
nPos);
410 GetSaveInData()->SetModified();
416 SAL_WARN(
"cui.customize",
"Unknown insert option: " << rIdent);
420 if (GetSaveInData()->IsModified())
422 UpdateButtonStates();
428 if (rIdent ==
"renameItem")
430 int nActEntry = m_xContentsListBox->get_selected_index();
432 = weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(nActEntry));
435 OUString aDesc =
CuiResId(RID_CUISTR_LABEL_NEW_NAME);
443 aNewName = aNameDialog.
GetName();
446 m_xContentsListBox->set_text(nActEntry, aNewName, 0);
448 GetSaveInData()->SetModified();
449 GetTopLevelSelection()->SetModified();
455 SAL_WARN(
"cui.customize",
"Unknown insert option: " << rIdent);
459 if (GetSaveInData()->IsModified())
461 UpdateButtonStates();
469 if (pMenuData ==
nullptr)
472 "RHB top level selection is null. A menu must be selected to reset!");
477 GetFrameWeld(), VclMessageType::Question, VclButtonsType::YesNo,
478 CuiResId(RID_CUISTR_CONFIRM_RESTORE_DEFAULT_MENU)));
482 if (m_bIsMenuBar || xQueryBox->run() !=
RET_YES)
485 sal_Int32
nPos = m_xTopLevelListBox->get_active();
491 m_xTopLevelListBox->clear();
492 m_xContentsListBox->clear();
494 ReloadTopLevelListBox();
497 m_xTopLevelListBox->set_active(
nPos);
502 const css::uno::Reference<css::ui::XUIConfigurationManager>& xCfgMgr,
503 const css::uno::Reference<css::ui::XUIConfigurationManager>& xParentCfgMgr,
504 const OUString& aModuleId,
bool bDocConfig)
511 new MenuSaveInData(xCfgMgr, xParentCfgMgr, aModuleId, bDocConfig));
516 if (rCEvt.GetCommand() != CommandEventId::ContextMenu)
522 std::unique_ptr<weld::TreeIter> xIter(rTreeView.
make_iterator());
526 SelectMenuEntry(rTreeView);
528 int nSelectIndex = m_xContentsListBox->get_selected_index();
532 && weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(nSelectIndex))->IsSeparator();
533 bool bIsValidSelection = (m_xContentsListBox->n_children() != 0 && nSelectIndex != -1);
535 std::unique_ptr<weld::Builder> xBuilder(
537 auto xContextMenu = xBuilder->weld_menu(
"menu");
538 xContextMenu->set_visible(
"add",
false);
539 xContextMenu->set_visible(
"remove", bIsValidSelection);
540 xContextMenu->set_visible(
"rename", bIsValidSelection && !bIsSeparator);
541 xContextMenu->set_visible(
"changeIcon",
false);
542 xContextMenu->set_visible(
"resetIcon",
false);
543 xContextMenu->set_visible(
"restoreDefault",
false);
544 OString sCommand(xContextMenu->popup_at_rect(
547 if (sCommand ==
"remove")
549 RemoveCommandHdl(*m_xRemoveCommandButton);
551 else if (sCommand ==
"rename")
553 ModifyItemHdl(
"renameItem");
555 else if (!sCommand.isEmpty())
556 SAL_WARN(
"cui.customize",
"Unknown context menu action: " << sCommand);
562 if (rCEvt.GetCommand() != CommandEventId::ContextMenu)
568 std::unique_ptr<weld::TreeIter> xIter(rTreeView.
make_iterator());
572 SelectFunctionHdl(rTreeView);
574 std::unique_ptr<weld::Builder> xBuilder(
576 auto xContextMenu = xBuilder->weld_menu(
"menu");
577 xContextMenu->set_visible(
"add",
true);
578 xContextMenu->set_visible(
"remove",
false);
579 xContextMenu->set_visible(
"rename",
false);
580 xContextMenu->set_visible(
"changeIcon",
false);
581 xContextMenu->set_visible(
"resetIcon",
false);
582 xContextMenu->set_visible(
"restoreDefault",
false);
583 OString sCommand(xContextMenu->popup_at_rect(
586 if (sCommand ==
"add")
588 AddCommandHdl(*m_xAddCommandButton);
590 else if (!sCommand.isEmpty())
591 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 OString &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 OStringLiteral HID_SVX_CONFIG_RENAME_MENU_ITEM
constexpr OStringLiteral HID_SVX_CONFIG_NAME_SUBMENU
constexpr OStringLiteral HID_SVX_CONFIG_RENAME_MENU
#define LINK(Instance, Class, Member)
#define SAL_WARN(area, stream)
Reference< XComponentContext > getProcessComponentContext()