17#include <sfx2/strings.hrc>
23#include <bitmaps.hlst>
26 std::unique_ptr<weld::Menu> xMenu,
27 std::unique_ptr<weld::TreeView> xTreeView)
61 if (pRegion->maTitle == rName)
83 if (pRegion->mnRegionId == nRegionId)
99 const bool bIsSingleSel,
const OUString& rDefaultImg)
151 if (rIdent ==
u"open")
153 else if (rIdent ==
u"edit")
155 else if (rIdent ==
u"rename")
166 OUString sTooltip(
SfxResId(STR_TOOLTIP_ERROR_RENAME_TEMPLATE));
169 if (sNewTitle.isEmpty() || sNewTitle == sOldTitle)
171 for (
const auto& rItem : aCurRegionItems)
173 if (rItem.
aName == sNewTitle)
175 aTitleEditDlg.SetTooltip(sTooltip.replaceFirst(
"$1", sNewTitle));
181 if (!aTitleEditDlg.
run())
185 if (!sNewTitle.isEmpty() && sNewTitle != sOldTitle)
191 else if (rIdent ==
u"delete")
194 GetDrawingArea(), VclMessageType::Question, VclButtonsType::YesNo,
195 SfxResId(STR_QMSG_SEL_TEMPLATE_DELETE)));
196 if (xQueryDlg->run() !=
RET_YES)
202 else if (rIdent ==
u"default")
207 else if (rIdent ==
u"move")
211 else if (rIdent ==
u"export")
226 OUString
sId = OUString::number(pViewItem->
mnId);
228 pViewItem->
getPath(), isDefault);
234 bool isRegionSelected =
true,
235 bool bShowCategoryInTooltip =
false)
277 if ((*it)->mbSelected)
294 if (aSelRows.empty())
302 if ((*it)->mnId == nCursorId)
336 maOpenTemplateHdl.Call(maSelectedItem);
342 if (rCEvt.GetCommand() != CommandEventId::ContextMenu)
345 if (rCEvt.IsMouseEvent())
349 Point aPosition(rCEvt.GetMousePosPixel());
353 maCreateContextMenuHdl.Call(maSelectedItem);
363 maCreateContextMenuHdl.Call(maSelectedItem);
381 if (!pItem->isSelected())
383 pItem->setSelection(
true);
395 GetDrawingArea(), VclMessageType::Question, VclButtonsType::YesNo,
396 SfxResId(STR_QMSG_SEL_TEMPLATE_DELETE)));
397 if (xQueryDlg->run() !=
RET_YES)
411 if (aKeyCode ==
KEY_DELETE && !mFilteredItemList.empty()
415 mxTreeView.get(), VclMessageType::Question, VclButtonsType::YesNo,
416 SfxResId(STR_QMSG_SEL_TEMPLATE_DELETE)));
417 if (xQueryDlg->run() !=
RET_YES)
420 maDeleteTemplateHdl.Call(maSelectedItem);
geometry::RealPoint2D maPosition
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
const vcl::KeyCode & GetKeyCode() const
void rename(const OUString &rId, const OUString &rTitle)
sal_uInt16 get_cursor_nId() const
bool IsListViewVisible() const
int get_index(sal_uInt16 nId) const
void AppendItem(const OUString &rId, const OUString &rTitle, const OUString &rSubtitle, const OUString &rPath, bool bDefault)
std::unique_ptr< weld::TreeView > mxTreeView
void refreshDefaultColumn()
std::vector< int > get_selected_rows() const
sal_uInt16 get_nId(int pos) const
std::vector< TemplateItemProperties > maTemplates
void showRegion(TemplateContainerItem const *pItem)
virtual void Hide() override
void insertItems(const std::vector< TemplateItemProperties > &rTemplates, bool isRegionSelected, bool bShowCategoryInTooltip)
void insertFilteredItems()
virtual void Show() override
virtual void showAllTemplates() override
void ContextMenuSelectHdl(std::u16string_view rIdent)
void MakeItemVisible(sal_uInt16 nId)
TemplateDlgLocalView(std::unique_ptr< weld::ScrolledWindow > xWindow, std::unique_ptr< weld::Menu > xMenu, std::unique_ptr< weld::TreeView > xTreeView)
TemplateViewMode mViewMode
void setTemplateViewMode(TemplateViewMode eMode)
virtual bool KeyInput(const KeyEvent &rKEvt) override
void createContextMenu(const bool bIsDefault, const bool bIsBuiltIn, const bool bIsSingleSel, const OUString &rDefaultImg)
std::vector< TemplateItemProperties > maAllTemplates
Link< ThumbnailViewItem *, void > maEditTemplateHdl
OUString getRegionName(const sal_uInt16 nRegionId) const
Link< ThumbnailViewItem *, void > maDefaultTemplateHdl
sal_uInt16 getRegionId(size_t pos) const
OUString getRegionItemName(const sal_uInt16 nItemId) const
Link< void *, void > maOpenRegionHdl
Link< void *, void > maExportTemplateHdl
Link< void *, void > maDeleteTemplateHdl
std::unique_ptr< SfxDocumentTemplates > mpDocTemplates
std::vector< TemplateItemProperties > getFilteredItems(const std::function< bool(const TemplateItemProperties &) > &rFunc) const
void insertItems(const std::vector< TemplateItemProperties > &rTemplates, bool isRegionSelected=true, bool bShowCategoryInTooltip=false)
Link< ThumbnailViewItem *, void > maOpenTemplateHdl
std::vector< std::unique_ptr< TemplateContainerItem > > maRegions
TemplateViewItem * maSelectedItem
Link< void *, void > maMoveTemplateHdl
bool IsDefaultTemplate() const
const OUString & getPath() const
OUString const & getTitle() const
void setTitle(const OUString &rTitle)
size_t GetItemPos(sal_uInt16 nItemId) const
void deselectItems()
deselect all current selected items.
Link< const ThumbnailViewItem *, void > maItemStateHdl
size_t ImplGetItem(const Point &rPoint) const
virtual bool KeyInput(const KeyEvent &rKEvt) override
ThumbnailValueItemList::iterator mpStartSelRange
std::unique_ptr< weld::Menu > mxContextMenu
virtual void Show() override
void SelectItem(sal_uInt16 nItemId)
ThumbnailValueItemList mFilteredItemList
Cache to store the filtered items.
virtual void Hide() override
void set_title(const OUString &rTitle)
constexpr OUStringLiteral HID_TEMPLATEDLG_EDIT
constexpr OUStringLiteral HID_TEMPLATEDLG_OPEN
constexpr OUStringLiteral HID_TEMPLATEDLG_RENAME
constexpr OUStringLiteral HID_TEMPLATEDLG_EXPORT
constexpr OUStringLiteral HID_TEMPLATEDLG_MOVE
constexpr OUStringLiteral HID_TEMPLATEDLG_DEFAULT
constexpr OUStringLiteral HID_TEMPLATEDLG_DELETE
constexpr sal_uInt16 KEY_MOD1
constexpr sal_uInt16 KEY_A
constexpr sal_uInt16 KEY_DELETE
#define LINK(Instance, Class, Member)
OString strip(const OString &rIn, char c)
OUString SfxResId(TranslateId aId)
IMPL_LINK_NOARG(TemplateDlgLocalView, RowActivatedHdl, weld::TreeView &, bool)
IMPL_LINK(TemplateDlgLocalView, PopupMenuHdl, const CommandEvent &, rCEvt, bool)