28 #include <sfx2/sfxsids.hrc>
34 #include <strings.hrc>
39 #include <dialmgr.hxx>
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");
247 sal_Int32
nPos = nCount > 0 ? 0 : -1;
251 for (sal_Int32
i = 0;
i < nCount; ++
i)
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);
335 m_xTopLevelListBox->append(sId, pToolbar->
GetName());
336 m_xTopLevelListBox->set_active_id(sId);
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)
373 pSaveInData->ApplyToolbar(pToolbar);
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());
503 if (aIconDialog.run() ==
RET_OK)
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);
703 GetFrameWeld(), VclMessageType::Question, VclButtonsType::YesNo, label));
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);
#define LINK(Instance, Class, Member)
std::unique_ptr< CuiConfigFunctionListBox > m_xFunctions
constexpr OStringLiteral HID_SVX_DESCFIELD
SvxEntries * GetEntries() const
std::unique_ptr< weld::Button > m_xResetBtn
void AddFunction(int nTarget=-1)
void set_title(const OUString &rTitle)
const OUString & GetName() const
static OUString generateCustomURL(SvxEntries *entries)
Generates a custom resource URL for a new toolbar.
std::unique_ptr< weld::MenuButton > m_xModifyBtn
std::unique_ptr< CommandCategoryListBox > m_xCommandCategoryListBox
OUString m_aURLToSelect
the ResourceURL to select when opening the dialog
virtual ~SvxToolbarConfigPage() override
static OUString stripHotKey(const OUString &str)
void SetModified(bool bValue=true)
std::unique_ptr< SvxConfigPageFunctionDropTarget > m_xDropTargetHelper
std::unique_ptr< sal_Int32[]> pData
css::uno::Reference< css::frame::XFrame > m_xFrame
constexpr OStringLiteral HID_SVX_CONFIG_TOOLBAR
SvxConfigEntry * GetTopLevelSelection()
static sal_Int16 GetImageType()
std::unique_ptr< weld::Button > m_xRemoveCommandButton
css::uno::Reference< css::lang::XComponent > m_xFrame
void SetBackupGraphic(css::uno::Reference< css::graphic::XGraphic > const &graphic)
constexpr OStringLiteral HID_SVX_SAVE_IN
virtual void MoveEntry(bool bMoveUp)
constexpr sal_uInt16 KEY_SPACE
std::unique_ptr< SvxMenuEntriesListBox > m_xContentsListBox
void ReloadTopLevelListBox(SvxConfigEntry const *pSelection=nullptr)
static css::uno::Reference< css::graphic::XGraphic > GetGraphic(const css::uno::Reference< css::ui::XImageManager > &xImageManager, const OUString &rCommandURL)
virtual std::unique_ptr< TreeIter > make_iterator(const TreeIter *pOrig=nullptr) const =0
std::vector< SvxConfigEntry * > SvxEntries
std::unique_ptr< weld::ComboBox > m_xTopLevelListBox
const OUString & GetCommand() const
void DeleteSelectedContent() override
void connect_changed(const Link< TreeView &, void > &rLink)
Reference< XNameAccess > m_xContainer
std::pair< const TreeIter &, int > iter_col
static void RemoveEntry(SvxEntries *pEntries, SvxConfigEntry const *pChildEntry)
static OUString replaceSaveInName(const OUString &rMessage, std::u16string_view rSaveInName)
void SetName(const OUString &rStr)
constexpr OUStringLiteral ITEM_TOOLBAR_URL
SaveInData * CreateSaveInData(const css::uno::Reference< css::ui::XUIConfigurationManager > &, const css::uno::Reference< css::ui::XUIConfigurationManager > &, const OUString &aModuleId, bool docConfig) override
static OUString generateCustomName(const OUString &prefix, SvxEntries *entries, sal_Int32 suffix=1)
virtual void SelectElement() override
IMPL_LINK(SvxToolbarConfigPage, MoveHdl, weld::Button &, rButton, void)
virtual tools::Long GetValue() const override
exports com.sun.star. text
OUString CuiResId(TranslateId aKey)
const css::uno::Reference< css::graphic::XGraphic > & GetBackupGraphic() const
#define TOOLS_WARN_EXCEPTION(area, stream)
virtual bool get_dest_row_at_pos(const Point &rPos, weld::TreeIter *pResult, bool bDnDMode)=0
void SetUserDefined(bool bOn=true)
virtual void ListModified() override
constexpr OStringLiteral HID_SVX_CONFIG_RENAME_TOOLBAR_ITEM
constexpr OStringLiteral HID_SVX_CONFIG_RENAME_TOOLBAR
void SetStyle(sal_Int32 style)
constexpr OStringLiteral HID_SVX_CONFIG_TOOLBAR_CONTENTS
void set_help_id(const OString &rHelpId)
constexpr OStringLiteral HID_SVX_TOPLEVELLISTBOX
std::unique_ptr< weld::MenuButton > m_xInsertBtn
constexpr OStringLiteral HID_SVX_DOWN_TOOLBAR_ITEM
sal_Int32 GetStyle() const
OUString toId(const void *pValue)
virtual void select(int pos)=0
weld::Window * GetFrameWeld() const
void UpdateButtonStates() override
void InsertEntryIntoUI(SvxConfigEntry *pNewEntryData, weld::TreeView &rTreeView, int nPos, bool bMenu=false)
void SetModified(bool bValue=true)
int AddFunction(int nTarget, bool bAllowDuplicates)
IMPL_LINK_NOARG(SvxToolbarConfigPage, SelectToolbarEntry, weld::TreeView &, void)
SvxToolbarConfigPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rItemSet)
Reference< XComponentContext > getProcessComponentContext()
short QueryReset() override
std::unique_ptr< weld::ComboBox > m_xSaveInListBox
constexpr OStringLiteral HID_SVX_UP_TOOLBAR_ITEM
std::unique_ptr< weld::TextView > m_xDescriptionField
std::unique_ptr< weld::Button > m_xMoveDownButton
#define SAL_WARN(area, stream)
void DeleteSelectedTopLevel() override
std::unique_ptr< weld::Button > m_xMoveUpButton
std::unique_ptr< weld::MenuButton > m_xGearBtn
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
void MoveEntry(bool bMoveUp) override
virtual void connect_popup_menu(const Link< const CommandEvent &, bool > &rLink)
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
SaveInData * GetSaveInData()
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, bool bMobile=false)
static std::unique_ptr< weld::Builder > CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false, sal_uInt64 nLOKWindowId=0)
std::unique_ptr< weld::Button > m_xAddCommandButton