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);
162 if (nSelectionPos != nCount - 1)
212 GetFrameWeld(), VclMessageType::Question, VclButtonsType::YesNo,
213 CuiResId(RID_SXVSTR_CONFIRM_DELETE_TOOLBAR)));
214 if (xQueryBox->run() ==
RET_YES)
223 MoveEntry(&rButton == m_xMoveUpButton.get());
236 SAL_WARN(
"cui.customize",
"SvxToolbarConfigPage::MoveEntry(): no entry");
279 const css::uno::Reference<css::ui::XUIConfigurationManager>& xCfgMgr,
280 const css::uno::Reference<css::ui::XUIConfigurationManager>& xParentCfgMgr,
281 const OUString& aModuleId,
bool bDocConfig)
289 UpdateButtonStates();
296 if (rIdent ==
"toolbar_gear_add")
308 for (
int i = 0,
nCount = m_xSaveInListBox->get_count();
i <
nCount; ++
i)
315 aNewName = aNameDialog.
GetName();
321 m_xSaveInListBox->get_id(nInsertPos).toInt64());
323 if (GetSaveInData() != pData)
325 m_xSaveInListBox->set_active(nInsertPos);
326 SelectSaveInLocation(*m_xSaveInListBox);
336 OUString
sId(OUString::number(reinterpret_cast<sal_Int64>(pToolbar)));
337 m_xTopLevelListBox->append(sId, pToolbar->
GetName());
338 m_xTopLevelListBox->set_active_id(sId);
344 else if (rIdent ==
"toolbar_gear_delete")
346 if (pCurrentToolbar && pCurrentToolbar->
IsDeletable())
348 DeleteSelectedTopLevel();
349 UpdateButtonStates();
352 else if (rIdent ==
"toolbar_gear_rename")
354 sal_Int32 nSelectionPos = m_xTopLevelListBox->get_active();
356 m_xTopLevelListBox->get_id(nSelectionPos).toInt64());
361 OUString sDesc =
CuiResId(RID_SVXSTR_LABEL_NEW_NAME);
369 OUString sNewName = aNameDialog.
GetName();
371 if (sCurrentName == sNewName)
378 m_xTopLevelListBox->remove(nSelectionPos);
379 OUString
sId(OUString::number(reinterpret_cast<sal_Int64>(pToolbar)));
380 m_xTopLevelListBox->insert(nSelectionPos, sNewName, &sId,
nullptr,
nullptr);
381 m_xTopLevelListBox->set_active_id(sId);
384 else if (rIdent ==
"toolbar_gear_iconOnly" || rIdent ==
"toolbar_gear_textOnly"
385 || rIdent ==
"toolbar_gear_iconAndText")
389 if (pCurrentToolbar ==
nullptr || pSaveInData ==
nullptr)
391 SAL_WARN(
"cui.customize",
"NULL toolbar or savein data");
395 sal_Int32 nStyle = 0;
396 if (rIdent ==
"toolbar_gear_iconOnly")
398 else if (rIdent ==
"toolbar_gear_textOnly")
400 else if (rIdent ==
"toolbar_gear_iconAndText")
411 SAL_WARN(
"cui.customize",
"Unknown gear menu option: " << rIdent);
418 OUString aSearchTerm(m_xSearchEdit->get_text());
420 m_xCommandCategoryListBox->categorySelected(m_xFunctions.get(), aSearchTerm, GetSaveInData());
422 SelectFunctionHdl(m_xFunctions->get_widget());
429 DeleteSelectedContent();
434 if (rIdent ==
"insertseparator")
442 int nPos = AppendEntry(pNewEntryData, -1);
443 InsertEntryIntoUI(pNewEntryData, m_xContentsListBox->get_widget(), nPos);
447 UpdateButtonStates();
452 SAL_WARN(
"cui.customize",
"Unknown insert option: " << rIdent);
459 bool bNeedsApply =
false;
464 if (rIdent.isEmpty() || pToolbar ==
nullptr)
466 SAL_WARN(
"cui.customize",
"No toolbar selected, or empty rIdent!");
470 if (rIdent ==
"renameItem")
472 int nActEntry = m_xContentsListBox->get_selected_index();
474 =
reinterpret_cast<SvxConfigEntry*
>(m_xContentsListBox->get_id(nActEntry).toInt64());
477 OUString aDesc =
CuiResId(RID_SVXSTR_LABEL_NEW_NAME);
485 aNewName = aNameDialog.
GetName();
487 if (aNewName.isEmpty())
492 m_xContentsListBox->set_text(nActEntry, aNewName, 0);
496 else if (rIdent ==
"changeIcon")
498 int nActEntry = m_xContentsListBox->get_selected_index();
500 =
reinterpret_cast<SvxConfigEntry*
>(m_xContentsListBox->get_id(nActEntry).toInt64());
503 GetSaveInData()->GetParentImageManager());
507 css::uno::Reference<css::graphic::XGraphic> newgraphic = aIconDialog.
GetSelectedIcon();
511 css::uno::Sequence<css::uno::Reference<css::graphic::XGraphic>> aGraphicSeq(1);
513 css::uno::Sequence<OUString> aURLSeq{ pEntry->
GetCommand() };
517 css::uno::Reference<css::graphic::XGraphic> backup
527 aGraphicSeq[0] = newgraphic;
530 GetSaveInData()->GetImageManager()->replaceImages(
533 m_xContentsListBox->remove(nActEntry);
535 OUString
sId(OUString::number(reinterpret_cast<sal_Int64>(pEntry)));
536 m_xContentsListBox->insert(nActEntry, sId);
539 InsertEntryIntoUI(pEntry, m_xContentsListBox->get_widget(), nActEntry);
541 m_xContentsListBox->select(nActEntry);
542 m_xContentsListBox->scroll_to_row(nActEntry);
544 GetSaveInData()->PersistChanges(GetSaveInData()->GetImageManager());
546 catch (
const css::uno::Exception&)
553 else if (rIdent ==
"resetIcon")
555 int nActEntry = m_xContentsListBox->get_selected_index();
557 =
reinterpret_cast<SvxConfigEntry*
>(m_xContentsListBox->get_id(nActEntry).toInt64());
559 css::uno::Reference<css::graphic::XGraphic> backup = pEntry->
GetBackupGraphic();
561 css::uno::Sequence<css::uno::Reference<css::graphic::XGraphic>> aGraphicSeq(1);
562 aGraphicSeq[0] = backup;
564 css::uno::Sequence<OUString> aURLSeq{ pEntry->
GetCommand() };
569 aURLSeq, aGraphicSeq);
571 m_xContentsListBox->remove(nActEntry);
573 OUString
sId(OUString::number(reinterpret_cast<sal_Int64>(pEntry)));
574 m_xContentsListBox->insert(nActEntry, sId);
575 m_xContentsListBox->set_toggle(nActEntry,
577 InsertEntryIntoUI(pEntry, m_xContentsListBox->get_widget(), nActEntry);
579 m_xContentsListBox->select(nActEntry);
580 m_xContentsListBox->scroll_to_row(nActEntry);
585 GetSaveInData()->PersistChanges(GetSaveInData()->GetImageManager());
587 catch (
const css::uno::Exception&)
592 else if (rIdent ==
"restoreItem")
594 int nActEntry = m_xContentsListBox->get_selected_index();
596 =
reinterpret_cast<SvxConfigEntry*
>(m_xContentsListBox->get_id(nActEntry).toInt64());
602 if (!pEntry->
GetName().equals(aSystemName))
610 css::uno::Sequence<OUString> aURLSeq{ pEntry->
GetCommand() };
620 GetSaveInData()->PersistChanges(GetSaveInData()->GetImageManager());
622 m_xContentsListBox->remove(nActEntry);
624 OUString
sId(OUString::number(reinterpret_cast<sal_Int64>(pEntry)));
625 m_xContentsListBox->insert(nActEntry, sId);
626 m_xContentsListBox->set_toggle(nActEntry,
628 InsertEntryIntoUI(pEntry, m_xContentsListBox->get_widget(), nActEntry);
630 m_xContentsListBox->select(nActEntry);
631 m_xContentsListBox->scroll_to_row(nActEntry);
635 catch (
const css::uno::Exception&)
643 SAL_WARN(
"cui.customize",
"Unknown insert option: " << rIdent);
650 UpdateButtonStates();
656 sal_Int32 nSelectionPos = m_xTopLevelListBox->get_active();
659 =
reinterpret_cast<SvxConfigEntry*
>(m_xTopLevelListBox->get_id(nSelectionPos).toInt64());
662 GetFrameWeld(), VclMessageType::Question, VclButtonsType::YesNo,
663 CuiResId(RID_SVXSTR_CONFIRM_RESTORE_DEFAULT)));
664 if (xQueryBox->run() ==
RET_YES)
690 m_xModifyBtn->set_sensitive(bIsValidSelection && !bIsSeparator);
700 OUString msg =
CuiResId(RID_SVXSTR_CONFIRM_TOOLBAR_RESET);
707 GetFrameWeld(), VclMessageType::Question, VclButtonsType::YesNo, label));
708 return xQueryBox->run();
716 if (pToolbar ==
nullptr)
736 m_xGearBtn->set_item_active(
"toolbar_gear_iconOnly",
true);
741 m_xGearBtn->set_item_active(
"toolbar_gear_textOnly",
true);
746 m_xGearBtn->set_item_active(
"toolbar_gear_iconAndText",
true);
753 for (
auto const& entry : *pEntries)
755 OUString
sId(OUString::number(reinterpret_cast<sal_Int64>(entry)));
757 if (entry->IsBinding() && !entry->IsSeparator())
770 if (pToolbar ==
nullptr)
776 if (nNewLBEntry == -1)
794 if (pToolbar !=
nullptr)
833 ChangedVisibility(
m_xControl->get_iter_index_in_parent(rRowCol.first));
849 ChangedVisibility(nRow);
853 return SvxMenuEntriesListBox::KeyInputHdl(rKeyEvent);
858 if (rCEvt.GetCommand() != CommandEventId::ContextMenu)
864 std::unique_ptr<weld::TreeIter> xIter(rTreeView.
make_iterator());
868 SelectToolbarEntry(rTreeView);
870 int nSelectIndex = m_xContentsListBox->get_selected_index();
874 &&
reinterpret_cast<SvxConfigEntry*
>(m_xContentsListBox->get_id(nSelectIndex).toInt64())
876 bool bIsValidSelection = (m_xContentsListBox->n_children() != 0 && nSelectIndex != -1);
878 std::unique_ptr<weld::Builder> xBuilder(
880 auto xContextMenu = xBuilder->weld_menu(
"menu");
881 xContextMenu->set_visible(
"add",
false);
882 xContextMenu->set_visible(
"remove", bIsValidSelection);
883 xContextMenu->set_visible(
"rename", bIsValidSelection && !bIsSeparator);
884 xContextMenu->set_visible(
"changeIcon", bIsValidSelection && !bIsSeparator);
885 xContextMenu->set_visible(
"resetIcon", bIsValidSelection && !bIsSeparator);
886 xContextMenu->set_visible(
"restoreDefault", bIsValidSelection && !bIsSeparator);
887 OString sCommand(xContextMenu->popup_at_rect(
890 if (sCommand ==
"remove")
891 RemoveCommandHdl(*m_xRemoveCommandButton);
892 else if (sCommand ==
"rename")
893 ModifyItemHdl(
"renameItem");
894 else if (sCommand ==
"changeIcon")
895 ModifyItemHdl(
"changeIcon");
896 else if (sCommand ==
"resetIcon")
897 ModifyItemHdl(
"resetIcon");
898 else if (sCommand ==
"restoreDefault")
899 ModifyItemHdl(
"restoreItem");
900 else if (!sCommand.isEmpty())
901 SAL_WARN(
"cui.customize",
"Unknown context menu action: " << sCommand);
907 if (rCEvt.GetCommand() != CommandEventId::ContextMenu)
913 std::unique_ptr<weld::TreeIter> xIter(rTreeView.
make_iterator());
917 SelectFunctionHdl(rTreeView);
918 std::unique_ptr<weld::Builder> xBuilder(
920 auto xContextMenu = xBuilder->weld_menu(
"menu");
921 xContextMenu->set_visible(
"add",
true);
922 xContextMenu->set_visible(
"remove",
false);
923 xContextMenu->set_visible(
"rename",
false);
924 xContextMenu->set_visible(
"changeIcon",
false);
925 xContextMenu->set_visible(
"resetIcon",
false);
926 xContextMenu->set_visible(
"restoreDefault",
false);
927 OString sCommand(xContextMenu->popup_at_rect(
930 if (sCommand ==
"add")
931 AddCommandHdl(*m_xAddCommandButton);
932 else if (!sCommand.isEmpty())
933 SAL_WARN(
"cui.customize",
"Unknown context menu action: " << sCommand);
#define LINK(Instance, Class, Member)
std::unique_ptr< CuiConfigFunctionListBox > m_xFunctions
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)
std::unique_ptr< ContentProperties > pData
void SetModified(bool bValue=true)
std::unique_ptr< SvxConfigPageFunctionDropTarget > m_xDropTargetHelper
css::uno::Reference< css::frame::XFrame > m_xFrame
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)
static weld::Builder * CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false)
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)
#define HID_SVX_CONFIG_TOOLBAR_CONTENTS
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
#define HID_SVX_CONFIG_RENAME_TOOLBAR
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)
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)
exports com.sun.star. text
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)
#define HID_SVX_CONFIG_RENAME_TOOLBAR_ITEM
#define HID_SVX_TOPLEVELLISTBOX
virtual void ListModified() override
void SetStyle(sal_Int32 style)
void set_help_id(const OString &rHelpId)
SfxItemPool * GetPool() const
#define HID_SVX_CONFIG_TOOLBAR
OUString CuiResId(const char *pKey)
std::unique_ptr< weld::MenuButton > m_xInsertBtn
sal_Int32 GetStyle() const
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)
sal_uInt16 GetWhich(sal_uInt16 nSlot, bool bDeep=true) const
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()
constexpr char16_t ITEM_TOOLBAR_URL[]
short QueryReset() override
std::unique_ptr< weld::ComboBox > m_xSaveInListBox
std::unique_ptr< weld::TextView > m_xDescriptionField
std::unique_ptr< weld::Button > m_xMoveDownButton
#define SAL_WARN(area, stream)
#define HID_SVX_DOWN_TOOLBAR_ITEM
css::uno::Reference< css::graphic::XGraphic > GetSelectedIcon()
void DeleteSelectedTopLevel() override
std::unique_ptr< weld::Button > m_xMoveUpButton
#define HID_SVX_DESCFIELD
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)
#define HID_SVX_UP_TOOLBAR_ITEM
std::unique_ptr< weld::Button > m_xAddCommandButton