28#include <sfx2/sfxsids.hrc>
50 m_xGearBtn = m_xBuilder->weld_menu_button(
"toolbargearbtn");
102 m_xGearBtn->set_item_sensitive(
"toolbar_gear_move",
false);
160 if (nSelectionPos !=
nCount - 1)
209 GetFrameWeld(), VclMessageType::Question, VclButtonsType::YesNo,
210 CuiResId(RID_SXVSTR_CONFIRM_DELETE_TOOLBAR)));
211 if (xQueryBox->run() ==
RET_YES)
220 MoveEntry(&rButton == m_xMoveUpButton.get());
233 SAL_WARN(
"cui.customize",
"SvxToolbarConfigPage::MoveEntry(): no entry");
277 const css::uno::Reference<css::ui::XUIConfigurationManager>& xCfgMgr,
278 const css::uno::Reference<css::ui::XUIConfigurationManager>& xParentCfgMgr,
279 const OUString& aModuleId,
bool bDocConfig)
287 UpdateButtonStates();
294 if (rIdent ==
"toolbar_gear_add")
306 for (
int i = 0,
nCount = m_xSaveInListBox->get_count();
i <
nCount; ++
i)
313 aNewName = aNameDialog.
GetName();
319 = weld::fromId<ToolbarSaveInData*>(m_xSaveInListBox->get_id(nInsertPos));
321 if (GetSaveInData() !=
pData)
323 m_xSaveInListBox->set_active(nInsertPos);
324 SelectSaveInLocation(*m_xSaveInListBox);
332 pData->CreateToolbar(pToolbar);
335 m_xTopLevelListBox->append(
sId, pToolbar->
GetName());
336 m_xTopLevelListBox->set_active_id(
sId);
339 pData->SetModified();
342 else if (rIdent ==
"toolbar_gear_delete")
344 if (pCurrentToolbar && pCurrentToolbar->
IsDeletable())
346 DeleteSelectedTopLevel();
347 UpdateButtonStates();
350 else if (rIdent ==
"toolbar_gear_rename")
352 sal_Int32 nSelectionPos = m_xTopLevelListBox->get_active();
354 = weld::fromId<SvxConfigEntry*>(m_xTopLevelListBox->get_id(nSelectionPos));
359 OUString sDesc =
CuiResId(RID_CUISTR_LABEL_NEW_NAME);
367 OUString sNewName = aNameDialog.
GetName();
369 if (sCurrentName == sNewName)
376 m_xTopLevelListBox->remove(nSelectionPos);
378 m_xTopLevelListBox->insert(nSelectionPos, sNewName, &
sId,
nullptr,
nullptr);
379 m_xTopLevelListBox->set_active_id(
sId);
382 else if (rIdent ==
"toolbar_gear_iconOnly" || rIdent ==
"toolbar_gear_textOnly"
383 || rIdent ==
"toolbar_gear_iconAndText")
387 if (pCurrentToolbar ==
nullptr || pSaveInData ==
nullptr)
389 SAL_WARN(
"cui.customize",
"NULL toolbar or savein data");
393 sal_Int32 nStyle = 0;
394 if (rIdent ==
"toolbar_gear_iconOnly")
396 else if (rIdent ==
"toolbar_gear_textOnly")
398 else if (rIdent ==
"toolbar_gear_iconAndText")
409 SAL_WARN(
"cui.customize",
"Unknown gear menu option: " << rIdent);
416 OUString aSearchTerm(m_xSearchEdit->get_text());
418 m_xCommandCategoryListBox->categorySelected(m_xFunctions.get(), aSearchTerm, GetSaveInData());
420 SelectFunctionHdl(m_xFunctions->get_widget());
427 DeleteSelectedContent();
432 if (rIdent ==
"insertseparator")
440 int nPos = AppendEntry(pNewEntryData, -1);
441 InsertEntryIntoUI(pNewEntryData, m_xContentsListBox->get_widget(),
nPos);
445 UpdateButtonStates();
450 SAL_WARN(
"cui.customize",
"Unknown insert option: " << rIdent);
457 bool bNeedsApply =
false;
462 if (rIdent.isEmpty() || pToolbar ==
nullptr)
464 SAL_WARN(
"cui.customize",
"No toolbar selected, or empty rIdent!");
468 if (rIdent ==
"renameItem")
470 int nActEntry = m_xContentsListBox->get_selected_index();
472 = weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(nActEntry));
475 OUString aDesc =
CuiResId(RID_CUISTR_LABEL_NEW_NAME);
483 aNewName = aNameDialog.
GetName();
485 if (aNewName.isEmpty())
490 m_xContentsListBox->set_text(nActEntry, aNewName, 0);
494 else if (rIdent ==
"changeIcon")
496 int nActEntry = m_xContentsListBox->get_selected_index();
498 = weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(nActEntry));
501 GetSaveInData()->GetParentImageManager());
505 css::uno::Reference<css::graphic::XGraphic> newgraphic = aIconDialog.
GetSelectedIcon();
509 css::uno::Sequence<OUString> aURLSeq{ pEntry->
GetCommand() };
513 css::uno::Reference<css::graphic::XGraphic> backup
523 css::uno::Sequence<css::uno::Reference<css::graphic::XGraphic>> aGraphicSeq{
528 GetSaveInData()->GetImageManager()->replaceImages(
531 m_xContentsListBox->remove(nActEntry);
534 m_xContentsListBox->insert(nActEntry,
sId);
537 InsertEntryIntoUI(pEntry, m_xContentsListBox->get_widget(), nActEntry);
539 m_xContentsListBox->select(nActEntry);
540 m_xContentsListBox->scroll_to_row(nActEntry);
542 GetSaveInData()->PersistChanges(GetSaveInData()->GetImageManager());
544 catch (
const css::uno::Exception&)
551 else if (rIdent ==
"resetIcon")
553 int nActEntry = m_xContentsListBox->get_selected_index();
555 = weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(nActEntry));
557 css::uno::Reference<css::graphic::XGraphic> backup = pEntry->
GetBackupGraphic();
559 css::uno::Sequence<css::uno::Reference<css::graphic::XGraphic>> aGraphicSeq{ backup };
561 css::uno::Sequence<OUString> aURLSeq{ pEntry->
GetCommand() };
566 aURLSeq, aGraphicSeq);
568 m_xContentsListBox->remove(nActEntry);
571 m_xContentsListBox->insert(nActEntry,
sId);
572 m_xContentsListBox->set_toggle(nActEntry,
574 InsertEntryIntoUI(pEntry, m_xContentsListBox->get_widget(), nActEntry);
576 m_xContentsListBox->select(nActEntry);
577 m_xContentsListBox->scroll_to_row(nActEntry);
582 GetSaveInData()->PersistChanges(GetSaveInData()->GetImageManager());
584 catch (
const css::uno::Exception&)
589 else if (rIdent ==
"restoreItem")
591 int nActEntry = m_xContentsListBox->get_selected_index();
593 = weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(nActEntry));
599 if (!pEntry->
GetName().equals(aSystemName))
607 css::uno::Sequence<OUString> aURLSeq{ pEntry->
GetCommand() };
617 GetSaveInData()->PersistChanges(GetSaveInData()->GetImageManager());
619 m_xContentsListBox->remove(nActEntry);
622 m_xContentsListBox->insert(nActEntry,
sId);
623 m_xContentsListBox->set_toggle(nActEntry,
625 InsertEntryIntoUI(pEntry, m_xContentsListBox->get_widget(), nActEntry);
627 m_xContentsListBox->select(nActEntry);
628 m_xContentsListBox->scroll_to_row(nActEntry);
632 catch (
const css::uno::Exception&)
640 SAL_WARN(
"cui.customize",
"Unknown insert option: " << rIdent);
647 UpdateButtonStates();
653 sal_Int32 nSelectionPos = m_xTopLevelListBox->get_active();
656 = weld::fromId<SvxConfigEntry*>(m_xTopLevelListBox->get_id(nSelectionPos));
659 GetFrameWeld(), VclMessageType::Question, VclButtonsType::YesNo,
660 CuiResId(RID_CUISTR_CONFIRM_RESTORE_DEFAULT)));
661 if (xQueryBox->run() ==
RET_YES)
678 && weld::fromId<SvxConfigEntry*>(
m_xContentsListBox->get_id(selection))->IsSeparator();
686 m_xModifyBtn->set_sensitive(bIsValidSelection && !bIsSeparator);
696 OUString msg =
CuiResId(RID_CUISTR_CONFIRM_TOOLBAR_RESET);
704 return xQueryBox->run();
712 if (pToolbar ==
nullptr)
732 m_xGearBtn->set_item_active(
"toolbar_gear_iconOnly",
true);
737 m_xGearBtn->set_item_active(
"toolbar_gear_textOnly",
true);
742 m_xGearBtn->set_item_active(
"toolbar_gear_iconAndText",
true);
749 for (
auto const& entry : *pEntries)
753 if (entry->IsBinding() && !entry->IsSeparator())
766 if (pToolbar ==
nullptr)
772 if (nNewLBEntry == -1)
789 if (pToolbar !=
nullptr)
827 ChangedVisibility(
m_xControl->get_iter_index_in_parent(rRowCol.first));
842 ChangedVisibility(nRow);
846 return SvxMenuEntriesListBox::KeyInputHdl(rKeyEvent);
851 if (rCEvt.GetCommand() != CommandEventId::ContextMenu)
857 std::unique_ptr<weld::TreeIter> xIter(rTreeView.
make_iterator());
861 SelectToolbarEntry(rTreeView);
863 int nSelectIndex = m_xContentsListBox->get_selected_index();
867 && weld::fromId<SvxConfigEntry*>(m_xContentsListBox->get_id(nSelectIndex))->IsSeparator();
868 bool bIsValidSelection = (m_xContentsListBox->n_children() != 0 && nSelectIndex != -1);
870 std::unique_ptr<weld::Builder> xBuilder(
872 auto xContextMenu = xBuilder->weld_menu(
"menu");
873 xContextMenu->set_visible(
"add",
false);
874 xContextMenu->set_visible(
"remove", bIsValidSelection);
875 xContextMenu->set_visible(
"rename", bIsValidSelection && !bIsSeparator);
876 xContextMenu->set_visible(
"changeIcon", bIsValidSelection && !bIsSeparator);
877 xContextMenu->set_visible(
"resetIcon", bIsValidSelection && !bIsSeparator);
878 xContextMenu->set_visible(
"restoreDefault", bIsValidSelection && !bIsSeparator);
879 OString sCommand(xContextMenu->popup_at_rect(
882 if (sCommand ==
"remove")
883 RemoveCommandHdl(*m_xRemoveCommandButton);
884 else if (sCommand ==
"rename")
885 ModifyItemHdl(
"renameItem");
886 else if (sCommand ==
"changeIcon")
887 ModifyItemHdl(
"changeIcon");
888 else if (sCommand ==
"resetIcon")
889 ModifyItemHdl(
"resetIcon");
890 else if (sCommand ==
"restoreDefault")
891 ModifyItemHdl(
"restoreItem");
892 else if (!sCommand.isEmpty())
893 SAL_WARN(
"cui.customize",
"Unknown context menu action: " << sCommand);
899 if (rCEvt.GetCommand() != CommandEventId::ContextMenu)
905 std::unique_ptr<weld::TreeIter> xIter(rTreeView.
make_iterator());
909 SelectFunctionHdl(rTreeView);
910 std::unique_ptr<weld::Builder> xBuilder(
912 auto xContextMenu = xBuilder->weld_menu(
"menu");
913 xContextMenu->set_visible(
"add",
true);
914 xContextMenu->set_visible(
"remove",
false);
915 xContextMenu->set_visible(
"rename",
false);
916 xContextMenu->set_visible(
"changeIcon",
false);
917 xContextMenu->set_visible(
"resetIcon",
false);
918 xContextMenu->set_visible(
"restoreDefault",
false);
919 OString sCommand(xContextMenu->popup_at_rect(
922 if (sCommand ==
"add")
923 AddCommandHdl(*m_xAddCommandButton);
924 else if (!sCommand.isEmpty())
925 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 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)
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 OStringLiteral HID_SVX_TOPLEVELLISTBOX
constexpr OStringLiteral HID_SVX_CONFIG_TOOLBAR_CONTENTS
constexpr OStringLiteral HID_SVX_SAVE_IN
constexpr OStringLiteral HID_SVX_DESCFIELD
constexpr OStringLiteral HID_SVX_CONFIG_RENAME_TOOLBAR
constexpr OStringLiteral HID_SVX_DOWN_TOOLBAR_ITEM
constexpr OStringLiteral HID_SVX_CONFIG_TOOLBAR
constexpr OStringLiteral HID_SVX_CONFIG_RENAME_TOOLBAR_ITEM
constexpr OStringLiteral HID_SVX_UP_TOOLBAR_ITEM
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