28#include <sfx2/sfxsids.hrc>
49 m_xGearBtn = m_xBuilder->weld_menu_button(
"toolbargearbtn");
101 m_xGearBtn->set_item_sensitive(
"toolbar_gear_move",
false);
159 if (nSelectionPos !=
nCount - 1)
208 GetFrameWeld(), VclMessageType::Question, VclButtonsType::YesNo,
209 CuiResId(RID_SXVSTR_CONFIRM_DELETE_TOOLBAR)));
210 if (xQueryBox->run() ==
RET_YES)
219 MoveEntry(&rButton == m_xMoveUpButton.get());
232 SAL_WARN(
"cui.customize",
"SvxToolbarConfigPage::MoveEntry(): no entry");
276 const css::uno::Reference<css::ui::XUIConfigurationManager>& xCfgMgr,
277 const css::uno::Reference<css::ui::XUIConfigurationManager>& xParentCfgMgr,
278 const OUString& aModuleId,
bool bDocConfig)
286 UpdateButtonStates();
293 if (rIdent ==
"toolbar_gear_add")
305 for (
int i = 0,
nCount = m_xSaveInListBox->get_count();
i <
nCount; ++
i)
312 aNewName = aNameDialog.
GetName();
318 = weld::fromId<ToolbarSaveInData*>(m_xSaveInListBox->get_id(nInsertPos));
320 if (GetSaveInData() !=
pData)
322 m_xSaveInListBox->set_active(nInsertPos);
323 SelectSaveInLocation(*m_xSaveInListBox);
331 pData->CreateToolbar(pToolbar);
334 m_xTopLevelListBox->append(
sId, pToolbar->
GetName());
335 m_xTopLevelListBox->set_active_id(
sId);
338 pData->SetModified();
341 else if (rIdent ==
"toolbar_gear_delete")
343 if (pCurrentToolbar && pCurrentToolbar->
IsDeletable())
345 DeleteSelectedTopLevel();
346 UpdateButtonStates();
349 else if (rIdent ==
"toolbar_gear_rename")
351 sal_Int32 nSelectionPos = m_xTopLevelListBox->get_active();
353 = weld::fromId<SvxConfigEntry*>(m_xTopLevelListBox->get_id(nSelectionPos));
358 OUString sDesc =
CuiResId(RID_CUISTR_LABEL_NEW_NAME);
366 OUString sNewName = aNameDialog.
GetName();
368 if (sCurrentName == sNewName)
375 m_xTopLevelListBox->remove(nSelectionPos);
377 m_xTopLevelListBox->insert(nSelectionPos, sNewName, &
sId,
nullptr,
nullptr);
378 m_xTopLevelListBox->set_active_id(
sId);
381 else if (rIdent ==
"toolbar_gear_iconOnly" || rIdent ==
"toolbar_gear_textOnly"
382 || rIdent ==
"toolbar_gear_iconAndText")
386 if (pCurrentToolbar ==
nullptr || pSaveInData ==
nullptr)
388 SAL_WARN(
"cui.customize",
"NULL toolbar or savein data");
392 sal_Int32 nStyle = 0;
393 if (rIdent ==
"toolbar_gear_iconOnly")
395 else if (rIdent ==
"toolbar_gear_textOnly")
397 else if (rIdent ==
"toolbar_gear_iconAndText")
408 SAL_WARN(
"cui.customize",
"Unknown gear menu option: " << rIdent);
415 OUString aSearchTerm(m_xSearchEdit->get_text());
417 m_xCommandCategoryListBox->categorySelected(m_xFunctions.get(), aSearchTerm, GetSaveInData());
419 SelectFunctionHdl(m_xFunctions->get_widget());
426 DeleteSelectedContent();
431 if (rIdent ==
"insertseparator")
439 int nPos = AppendEntry(pNewEntryData, -1);
440 InsertEntryIntoUI(pNewEntryData, m_xContentsListBox->get_widget(),
nPos);
444 UpdateButtonStates();
449 SAL_WARN(
"cui.customize",
"Unknown insert option: " << rIdent);
456 bool bNeedsApply =
false;
461 if (rIdent.isEmpty() || pToolbar ==
nullptr)
463 SAL_WARN(
"cui.customize",
"No toolbar selected, or empty rIdent!");
467 if (rIdent ==
"renameItem")
469 int nActEntry = m_xContentsListBox->get_selected_index();
471 = weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(nActEntry));
474 OUString aDesc =
CuiResId(RID_CUISTR_LABEL_NEW_NAME);
482 aNewName = aNameDialog.
GetName();
484 if (aNewName.isEmpty())
489 m_xContentsListBox->set_text(nActEntry, aNewName, 0);
493 else if (rIdent ==
"changeIcon")
495 int nActEntry = m_xContentsListBox->get_selected_index();
497 = weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(nActEntry));
500 GetSaveInData()->GetParentImageManager());
504 css::uno::Reference<css::graphic::XGraphic> newgraphic = aIconDialog.
GetSelectedIcon();
508 css::uno::Sequence<OUString> aURLSeq{ pEntry->
GetCommand() };
512 css::uno::Reference<css::graphic::XGraphic> backup
522 css::uno::Sequence<css::uno::Reference<css::graphic::XGraphic>> aGraphicSeq{
527 GetSaveInData()->GetImageManager()->replaceImages(
530 m_xContentsListBox->remove(nActEntry);
533 m_xContentsListBox->insert(nActEntry,
sId);
536 InsertEntryIntoUI(pEntry, m_xContentsListBox->get_widget(), nActEntry);
538 m_xContentsListBox->select(nActEntry);
539 m_xContentsListBox->scroll_to_row(nActEntry);
541 GetSaveInData()->PersistChanges(GetSaveInData()->GetImageManager());
543 catch (
const css::uno::Exception&)
550 else if (rIdent ==
"resetIcon")
552 int nActEntry = m_xContentsListBox->get_selected_index();
554 = weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(nActEntry));
556 css::uno::Reference<css::graphic::XGraphic> backup = pEntry->
GetBackupGraphic();
558 css::uno::Sequence<css::uno::Reference<css::graphic::XGraphic>> aGraphicSeq{ backup };
560 css::uno::Sequence<OUString> aURLSeq{ pEntry->
GetCommand() };
565 aURLSeq, aGraphicSeq);
567 m_xContentsListBox->remove(nActEntry);
570 m_xContentsListBox->insert(nActEntry,
sId);
571 m_xContentsListBox->set_toggle(nActEntry,
573 InsertEntryIntoUI(pEntry, m_xContentsListBox->get_widget(), nActEntry);
575 m_xContentsListBox->select(nActEntry);
576 m_xContentsListBox->scroll_to_row(nActEntry);
581 GetSaveInData()->PersistChanges(GetSaveInData()->GetImageManager());
583 catch (
const css::uno::Exception&)
588 else if (rIdent ==
"restoreItem")
590 int nActEntry = m_xContentsListBox->get_selected_index();
592 = weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(nActEntry));
598 if (!pEntry->
GetName().equals(aSystemName))
606 css::uno::Sequence<OUString> aURLSeq{ pEntry->
GetCommand() };
616 GetSaveInData()->PersistChanges(GetSaveInData()->GetImageManager());
618 m_xContentsListBox->remove(nActEntry);
621 m_xContentsListBox->insert(nActEntry,
sId);
622 m_xContentsListBox->set_toggle(nActEntry,
624 InsertEntryIntoUI(pEntry, m_xContentsListBox->get_widget(), nActEntry);
626 m_xContentsListBox->select(nActEntry);
627 m_xContentsListBox->scroll_to_row(nActEntry);
631 catch (
const css::uno::Exception&)
639 SAL_WARN(
"cui.customize",
"Unknown insert option: " << rIdent);
646 UpdateButtonStates();
652 sal_Int32 nSelectionPos = m_xTopLevelListBox->get_active();
655 = weld::fromId<SvxConfigEntry*>(m_xTopLevelListBox->get_id(nSelectionPos));
658 GetFrameWeld(), VclMessageType::Question, VclButtonsType::YesNo,
659 CuiResId(RID_CUISTR_CONFIRM_RESTORE_DEFAULT)));
660 if (xQueryBox->run() ==
RET_YES)
677 && weld::fromId<SvxConfigEntry*>(
m_xContentsListBox->get_id(selection))->IsSeparator();
685 m_xModifyBtn->set_sensitive(bIsValidSelection && !bIsSeparator);
695 OUString msg =
CuiResId(RID_CUISTR_CONFIRM_TOOLBAR_RESET);
703 return xQueryBox->run();
711 if (pToolbar ==
nullptr)
731 m_xGearBtn->set_item_active(
"toolbar_gear_iconOnly",
true);
736 m_xGearBtn->set_item_active(
"toolbar_gear_textOnly",
true);
741 m_xGearBtn->set_item_active(
"toolbar_gear_iconAndText",
true);
748 for (
auto const& entry : *pEntries)
752 if (entry->IsBinding() && !entry->IsSeparator())
765 if (pToolbar ==
nullptr)
771 if (nNewLBEntry == -1)
788 if (pToolbar !=
nullptr)
826 ChangedVisibility(
m_xControl->get_iter_index_in_parent(rRowCol.first));
841 ChangedVisibility(nRow);
845 return SvxMenuEntriesListBox::KeyInputHdl(rKeyEvent);
850 if (rCEvt.GetCommand() != CommandEventId::ContextMenu)
856 std::unique_ptr<weld::TreeIter> xIter(rTreeView.
make_iterator());
860 SelectToolbarEntry(rTreeView);
862 int nSelectIndex = m_xContentsListBox->get_selected_index();
866 && weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(nSelectIndex))->IsSeparator();
867 bool bIsValidSelection = (m_xContentsListBox->n_children() != 0 && nSelectIndex != -1);
869 std::unique_ptr<weld::Builder> xBuilder(
871 auto xContextMenu = xBuilder->weld_menu(
"menu");
872 xContextMenu->set_visible(
"add",
false);
873 xContextMenu->set_visible(
"remove", bIsValidSelection);
874 xContextMenu->set_visible(
"rename", bIsValidSelection && !bIsSeparator);
875 xContextMenu->set_visible(
"changeIcon", bIsValidSelection && !bIsSeparator);
876 xContextMenu->set_visible(
"resetIcon", bIsValidSelection && !bIsSeparator);
877 xContextMenu->set_visible(
"restoreDefault", bIsValidSelection && !bIsSeparator);
878 OUString sCommand(xContextMenu->popup_at_rect(
881 if (sCommand ==
"remove")
882 RemoveCommandHdl(*m_xRemoveCommandButton);
883 else if (sCommand ==
"rename")
884 ModifyItemHdl(
"renameItem");
885 else if (sCommand ==
"changeIcon")
886 ModifyItemHdl(
"changeIcon");
887 else if (sCommand ==
"resetIcon")
888 ModifyItemHdl(
"resetIcon");
889 else if (sCommand ==
"restoreDefault")
890 ModifyItemHdl(
"restoreItem");
891 else if (!sCommand.isEmpty())
892 SAL_WARN(
"cui.customize",
"Unknown context menu action: " << sCommand);
898 if (rCEvt.GetCommand() != CommandEventId::ContextMenu)
904 std::unique_ptr<weld::TreeIter> xIter(rTreeView.
make_iterator());
908 SelectFunctionHdl(rTreeView);
909 std::unique_ptr<weld::Builder> xBuilder(
911 auto xContextMenu = xBuilder->weld_menu(
"menu");
912 xContextMenu->set_visible(
"add",
true);
913 xContextMenu->set_visible(
"remove",
false);
914 xContextMenu->set_visible(
"rename",
false);
915 xContextMenu->set_visible(
"changeIcon",
false);
916 xContextMenu->set_visible(
"resetIcon",
false);
917 xContextMenu->set_visible(
"restoreDefault",
false);
918 OUString sCommand(xContextMenu->popup_at_rect(
921 if (sCommand ==
"add")
922 AddCommandHdl(*m_xAddCommandButton);
923 else if (!sCommand.isEmpty())
924 SAL_WARN(
"cui.customize",
"Unknown context menu action: " << sCommand);
IMPL_LINK(SvxToolbarConfigPage, MoveHdl, weld::Button &, rButton, void)
IMPL_LINK_NOARG(SvxToolbarConfigPage, SelectToolbarEntry, weld::TreeView &, void)
css::uno::Reference< css::lang::XComponent > m_xFrame
constexpr OUStringLiteral ITEM_TOOLBAR_URL
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)
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
weld::Window * GetFrameWeld() const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
sal_Int32 GetStyle() const
const OUString & GetCommand() const
void SetStyle(sal_Int32 style)
SvxEntries * GetEntries() const
const css::uno::Reference< css::graphic::XGraphic > & GetBackupGraphic() const
void SetBackupGraphic(css::uno::Reference< css::graphic::XGraphic > const &graphic)
void SetName(const OUString &rStr)
void SetModified(bool bValue=true)
void SetUserDefined(bool bOn=true)
const OUString & GetName() const
static sal_Int16 GetImageType()
static OUString generateCustomURL(SvxEntries *entries)
Generates a custom resource URL for a new toolbar.
static OUString replaceSaveInName(const OUString &rMessage, std::u16string_view rSaveInName)
static OUString stripHotKey(const OUString &str)
static OUString generateCustomName(const OUString &prefix, SvxEntries *entries, sal_Int32 suffix=1)
static void RemoveEntry(SvxEntries *pEntries, SvxConfigEntry const *pChildEntry)
static css::uno::Reference< css::graphic::XGraphic > GetGraphic(const css::uno::Reference< css::ui::XImageManager > &xImageManager, const OUString &rCommandURL)
void ReloadTopLevelListBox(SvxConfigEntry const *pSelection=nullptr)
void InsertEntryIntoUI(SvxConfigEntry *pNewEntryData, weld::TreeView &rTreeView, int nPos, bool bMenu=false)
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
int AddFunction(int nTarget, bool bAllowDuplicates)
OUString m_aURLToSelect
the ResourceURL to select when opening the dialog
std::unique_ptr< weld::Button > m_xResetBtn
std::unique_ptr< weld::TextView > m_xDescriptionField
std::unique_ptr< weld::MenuButton > m_xInsertBtn
std::unique_ptr< weld::Button > m_xMoveDownButton
css::uno::Reference< css::frame::XFrame > m_xFrame
std::unique_ptr< weld::MenuButton > m_xModifyBtn
virtual void MoveEntry(bool bMoveUp)
std::unique_ptr< weld::Button > m_xAddCommandButton
std::unique_ptr< weld::ComboBox > m_xSaveInListBox
SaveInData * GetSaveInData()
std::unique_ptr< SvxMenuEntriesListBox > m_xContentsListBox
css::uno::Reference< css::graphic::XGraphic > GetSelectedIcon()
SvxToolbarConfigPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rItemSet)
virtual void SelectElement() override
void UpdateButtonStates() override
short QueryReset() override
virtual void ListModified() override
SaveInData * CreateSaveInData(const css::uno::Reference< css::ui::XUIConfigurationManager > &, const css::uno::Reference< css::ui::XUIConfigurationManager > &, const OUString &aModuleId, bool docConfig) override
void MoveEntry(bool bMoveUp) override
void DeleteSelectedTopLevel() override
virtual ~SvxToolbarConfigPage() override
void DeleteSelectedContent() override
void AddFunction(int nTarget=-1)
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)
virtual bool get_dest_row_at_pos(const Point &rPos, weld::TreeIter *pResult, bool bDnDMode, bool bAutoScroll=true)=0
std::pair< const TreeIter &, int > iter_col
void connect_changed(const Link< TreeView &, void > &rLink)
virtual void select(int pos)=0
OUString CuiResId(TranslateId aKey)
#define TOOLS_WARN_EXCEPTION(area, stream)
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
virtual tools::Long GetValue() const override
constexpr OUStringLiteral HID_SVX_SAVE_IN
constexpr OUStringLiteral HID_SVX_CONFIG_RENAME_TOOLBAR_ITEM
constexpr OUStringLiteral HID_SVX_CONFIG_TOOLBAR
constexpr OUStringLiteral HID_SVX_CONFIG_RENAME_TOOLBAR
constexpr OUStringLiteral HID_SVX_DESCFIELD
constexpr OUStringLiteral HID_SVX_DOWN_TOOLBAR_ITEM
constexpr OUStringLiteral HID_SVX_UP_TOOLBAR_ITEM
constexpr OUStringLiteral HID_SVX_TOPLEVELLISTBOX
constexpr OUStringLiteral HID_SVX_CONFIG_TOOLBAR_CONTENTS
constexpr sal_uInt16 KEY_SPACE
#define LINK(Instance, Class, Member)
#define SAL_WARN(area, stream)
std::unique_ptr< sal_Int32[]> pData
Reference< XComponentContext > getProcessComponentContext()
OUString toId(const void *pValue)
Reference< XNameAccess > m_xContainer