[Libreoffice-commits] core.git: include/sfx2 sfx2/inc sfx2/Library_sfx.mk sfx2/source sfx2/uiconfig
Vert D (via logerrit)
logerrit at kemper.freedesktop.org
Mon Jul 5 10:53:57 UTC 2021
include/sfx2/strings.hrc | 26 -
include/sfx2/templatedlg.hxx | 30 -
include/sfx2/templatedlglocalview.hxx | 6
include/sfx2/templatelocalview.hxx | 12
sfx2/Library_sfx.mk | 1
sfx2/inc/bitmaps.hlst | 17
sfx2/source/control/templatedlglocalview.cxx | 85 +--
sfx2/source/control/templatelocalview.cxx | 47 +
sfx2/source/control/templatesearchview.cxx | 462 -------------------
sfx2/source/doc/doctemplates.cxx | 8
sfx2/source/doc/doctemplateslocal.hxx | 1
sfx2/source/doc/templatedlg.cxx | 637 ++++++++++++---------------
sfx2/source/inc/templatesearchview.hxx | 99 ----
sfx2/uiconfig/ui/templatedlg.ui | 316 +------------
14 files changed, 465 insertions(+), 1282 deletions(-)
New commits:
commit 06d063a9de41a24922f15cd3aa47411b61d30c23
Author: Vert D <devoptmsoi at gmx.com>
AuthorDate: Thu Apr 29 10:29:00 2021 -0500
Commit: Heiko Tietze <heiko.tietze at documentfoundation.org>
CommitDate: Mon Jul 5 12:53:22 2021 +0200
tdf#138906 prevent built-in category deletion
*Remove category selection dialog for Delete Category.
*Delete Category now deletes the current Category.
*Import now imports to current category.
*Remove Buttons, add items to menu.
*Enable delete multi selection.
*Change Dialog titles.
*Remove searchview class. (I see no reason for it, it just copies code from localview and localview can handle search results on its own.)
Change-Id: I5add4aa9fa68ac68c796a6b98fb54a5d0da93bd0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113712
Tested-by: Jenkins
Reviewed-by: Heiko Tietze <heiko.tietze at documentfoundation.org>
diff --git a/include/sfx2/strings.hrc b/include/sfx2/strings.hrc
index 0967a31c1109..676ff541059b 100644
--- a/include/sfx2/strings.hrc
+++ b/include/sfx2/strings.hrc
@@ -27,13 +27,15 @@
#define STR_SAVEASDOC NC_("STR_SAVEASDOC", "Save ~As...")
#define STR_SAVEACOPY NC_("STR_SAVEACOPY", "Save a Copy...")
#define STR_CLOSEDOC NC_("STR_CLOSEDOC", "~Close")
-#define STR_OPEN NC_("STR_OPEN", "Open")
-#define STR_EDIT_TEMPLATE NC_("STR_EDIT_TEMPLATE", "Edit")
-#define STR_DEFAULT_TEMPLATE NC_("STR_DEFAULT_TEMPLATE", "Set as Default")
-#define STR_RESET_DEFAULT NC_("STR_RESET_DEFAULT", "Reset Default")
-#define STR_DELETE NC_("STR_DELETE", "Delete")
-#define STR_SFX_RENAME NC_("STR_SFX_RENAME", "Rename")
-#define STR_CATEGORY_RENAME NC_("STR_CATEGORY_RENAME", "Rename Category")
+#define STR_OPEN NC_("STR_OPEN", "~Open")
+#define STR_EDIT_TEMPLATE NC_("STR_EDIT_TEMPLATE", "~Edit")
+#define STR_DEFAULT_TEMPLATE NC_("STR_DEFAULT_TEMPLATE", "Set as De~fault")
+#define STR_RESET_DEFAULT NC_("STR_RESET_DEFAULT", "Reset De~fault")
+#define STR_DELETE_TEMPLATE NC_("STR_DELETE_TEMPLATE", "~Delete")
+#define STR_SFX_RENAME NC_("STR_SFX_RENAME", "~Rename")
+#define STR_MOVE NC_("STR_ACTION_MOVE","~Move")
+#define STR_EXPORT NC_("STR_ACTION_EXPORT","E~xport")
+#define STR_CATEGORY_RENAME NC_("STR_CATEGORY_RENAME", "Ren~ame Category")
#define STR_RENAME_TEMPLATE NC_("STR_RENAME_TEMPLATE", "Enter new template name:")
#define STR_TEMPLATE_TOOLTIP NC_("STR_TEMPLATE_TOOLTIP", "Title: $1\nCategory: $2")
#define STR_TEMPLATE_SELECTION NC_("STR_TEMPLATE_SELECTION", "Select a Template")
@@ -351,6 +353,16 @@
#define STR_RECENT NC_("STR_RECENT", "Recently used")
#define STR_NORECENT NC_("STR_NORECENT", "No recent characters")
+#define STR_ACTION_RESET_ALL_DEAULT_TEMPLATES NC_("STR_ACTION_RESET_ALL_DEAULT_TEMPLATES","Reset All De~fault Templates")
+#define STR_ACTION_RESET_WRITER_TEMPLATE NC_("STR_ACTION_RESET_WRITER_TEMPLATE","Reset De~fault Text Document")
+#define STR_ACTION_RESET_CALC_TEMPLATE NC_("STR_ACTION_RESET_CALC_TEMPLATE","Reset De~fault Spreadsheet")
+#define STR_ACTION_RESET_IMPRESS_TEMPLATE NC_("STR_ACTION_RESET_IMPRESS_TEMPLATE","Reset De~fault Presentation")
+#define STR_ACTION_RESET_DRAW_TEMPLATE NC_("STR_ACTION_RESET_DRAW_TEMPLATE","Reset De~fault Drawing")
+#define STR_ACTION_IMPORT NC_("STR_ACTION_IMPORT","~Import")
+#define STR_ACTION_EXTENSIONS NC_("STR_ACTION_EXTENSIONS","E~xtensions")
+#define STR_WINDOW_TITLE_RENAME_TEMPLATE NC_("STR_WINDOW_TITLE_RENAME_TEMPLATE","Rename")
+#define STR_WINDOW_TITLE_RENAME_CATEGORY NC_("STR_WINDOW_TITLE_RENAME_CATEGORY","Rename Category")
+#define STR_WINDOW_TITLE_RENAME_NEW_CATEGORY NC_("STR_WINDOW_TITLE_RENAME_NEW_CATEGORY","New Category")
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/sfx2/templatedlg.hxx b/include/sfx2/templatedlg.hxx
index 89d0b6d3d61e..40af96278d47 100644
--- a/include/sfx2/templatedlg.hxx
+++ b/include/sfx2/templatedlg.hxx
@@ -22,7 +22,6 @@
#include <sfx2/templatedlglocalview.hxx>
-class TemplateSearchView;
class ThumbnailViewItem;
namespace com
@@ -61,10 +60,9 @@ protected:
DECL_LINK(SelectRegionHdl, weld::ComboBox&, void);
DECL_LINK(OkClickHdl, weld::Button&, void);
- DECL_LINK(MoveClickHdl, weld::Button&, void);
- DECL_LINK(ExportClickHdl, weld::Button&, void);
- DECL_LINK(ImportClickHdl, weld::Button&, void);
- DECL_STATIC_LINK(SfxTemplateManagerDlg, LinkClickHdl, weld::Button&, void);
+ void ImportActionHdl();
+ void ExportActionHdl();
+ static void ExtensionsActionHdl();
DECL_LINK(TVItemStateHdl, const ThumbnailViewItem*, void);
@@ -75,10 +73,13 @@ protected:
DECL_LINK(CreateContextMenuHdl, ThumbnailViewItem*, void);
DECL_LINK(OpenTemplateHdl, ThumbnailViewItem*, void);
DECL_LINK(EditTemplateHdl, ThumbnailViewItem*, void);
- DECL_LINK(DeleteTemplateHdl, ThumbnailViewItem*, void);
+ DECL_LINK(DeleteTemplateHdl, void*, void);
DECL_LINK(DefaultTemplateHdl, ThumbnailViewItem*, void);
+ DECL_LINK(MoveTemplateHdl, void*, void);
+ DECL_LINK(ExportTemplateHdl, void*, void);
void SearchUpdate();
+ void FilterSearch();
DECL_LINK(SearchUpdateHdl, weld::Entry&, void);
DECL_LINK(GetFocusHdl, weld::Widget&, void);
@@ -89,7 +90,6 @@ protected:
DECL_LINK(ListViewHdl, weld::Toggleable&, void);
DECL_LINK(ThumbnailViewHdl, weld::Toggleable&, void);
DECL_LINK(FocusRectLocalHdl, weld::Widget&, tools::Rectangle);
- DECL_LINK(FocusRectSearchHdl, weld::Widget&, tools::Rectangle);
void OnTemplateImportCategory(std::u16string_view sCategory);
// static void OnTemplateLink ();
@@ -102,7 +102,7 @@ protected:
void OnCategoryRename();
void OnCategoryDelete();
- void createDefaultTemplateMenu();
+ void updateMenuItems();
/**
*
@@ -112,14 +112,6 @@ protected:
void localMoveTo(sal_uInt16 nMenuId);
- /**
- *
- * Move search result templates stored in the filesystem to another folder.
- *
- **/
-
- void localSearchMoveTo(sal_uInt16 nMenuId);
-
/// Return filter according to the currently selected application filter.
FILTER_APPLICATION getCurrentApplicationFilter() const;
@@ -135,16 +127,10 @@ protected:
std::unique_ptr<weld::ComboBox> mxCBFolder;
std::unique_ptr<weld::Button> mxOKButton;
- std::unique_ptr<weld::Button> mxMoveButton;
- std::unique_ptr<weld::Button> mxExportButton;
- std::unique_ptr<weld::Button> mxImportButton;
- std::unique_ptr<weld::Button> mxMoreTemplatesButton;
std::unique_ptr<weld::CheckButton> mxCBXHideDlg;
std::unique_ptr<weld::MenuButton> mxActionBar;
- std::unique_ptr<TemplateSearchView> mxSearchView;
std::unique_ptr<TemplateDlgLocalView> mxLocalView;
std::unique_ptr<weld::Menu> mxTemplateDefaultMenu;
- std::unique_ptr<weld::CustomWeld> mxSearchViewWeld;
std::unique_ptr<weld::CustomWeld> mxLocalViewWeld;
std::unique_ptr<weld::Toggleable> mxListViewButton;
std::unique_ptr<weld::Toggleable> mxThumbnailViewButton;
diff --git a/include/sfx2/templatedlglocalview.hxx b/include/sfx2/templatedlglocalview.hxx
index 409a1acaa578..65b77ead1c9a 100644
--- a/include/sfx2/templatedlglocalview.hxx
+++ b/include/sfx2/templatedlglocalview.hxx
@@ -30,7 +30,8 @@ public:
virtual bool KeyInput(const KeyEvent& rKEvt) override;
- void createContextMenu(const bool bIsDefault, const bool bIsBuiltIn);
+ void createContextMenu(const bool bIsDefault, const bool bIsBuiltIn, const bool bIsSingleSel,
+ const OUString& rDefaultImg);
virtual void Show() override;
@@ -45,6 +46,9 @@ public:
void MakeItemVisible(sal_uInt16 nId) { ThumbnailView::MakeItemVisible(nId); }
+ void insertItems(const std::vector<TemplateItemProperties>& rTemplates, bool isRegionSelected,
+ bool bShowCategoryInTooltip);
+
private:
void ContextMenuSelectHdl(std::string_view rIdent);
diff --git a/include/sfx2/templatelocalview.hxx b/include/sfx2/templatelocalview.hxx
index a37d72d1cf50..5ee5b60ed30a 100644
--- a/include/sfx2/templatelocalview.hxx
+++ b/include/sfx2/templatelocalview.hxx
@@ -137,14 +137,20 @@ public:
void setEditTemplateHdl(const Link<ThumbnailViewItem*,void> &rLink);
- void setDeleteTemplateHdl(const Link<ThumbnailViewItem*,void> &rLink);
+ void setDeleteTemplateHdl(const Link<void*,void> &rLink);
void setDefaultTemplateHdl(const Link<ThumbnailViewItem*,void> &rLink);
+ void setMoveTemplateHdl(const Link<void*,void> &rLink);
+
+ void setExportTemplateHdl(const Link<void*,void> &rLink);
+
void updateThumbnailDimensions(tools::Long itemMaxSize);
void RemoveDefaultTemplateIcon( std::u16string_view rPath);
+ bool IsBuiltInRegion(const OUString& rRegionName);
+
static BitmapEx scaleImg (const BitmapEx &rImg, tools::Long width, tools::Long height);
static BitmapEx getDefaultThumbnail( const OUString& rPath );
@@ -171,8 +177,10 @@ protected:
Link<ThumbnailViewItem*,void> maCreateContextMenuHdl;
Link<ThumbnailViewItem*,void> maOpenTemplateHdl;
Link<ThumbnailViewItem*,void> maEditTemplateHdl;
- Link<ThumbnailViewItem*,void> maDeleteTemplateHdl;
+ Link<void*,void> maDeleteTemplateHdl;
Link<ThumbnailViewItem*,void> maDefaultTemplateHdl;
+ Link<void*,void> maMoveTemplateHdl;
+ Link<void*,void> maExportTemplateHdl;
std::unique_ptr<SfxDocumentTemplates> mpDocTemplates;
std::vector<std::unique_ptr<TemplateContainerItem> > maRegions;
diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk
index 0120cee75b4e..fff97d011a02 100644
--- a/sfx2/Library_sfx.mk
+++ b/sfx2/Library_sfx.mk
@@ -156,7 +156,6 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\
sfx2/source/control/templateviewitem \
sfx2/source/control/templatelocalview \
sfx2/source/control/templatecontaineritem \
- sfx2/source/control/templatesearchview \
sfx2/source/control/templatedlglocalview \
sfx2/source/control/listview \
sfx2/source/control/thumbnailviewitem \
diff --git a/sfx2/inc/bitmaps.hlst b/sfx2/inc/bitmaps.hlst
index 3c236ff50d64..9d385c9765b3 100644
--- a/sfx2/inc/bitmaps.hlst
+++ b/sfx2/inc/bitmaps.hlst
@@ -91,7 +91,24 @@
#define SFX_BMP_CLOSE_DOC "sfx2/res/closedoc.png"
#define SIDEBAR_CLOSE_INDICATOR "cmd/lc_decrementlevel.png"
+#define BMP_ACTION_DEFAULT_WRITER "res/odt_16_8.png"
+#define BMP_ACTION_DEFAULT_CALC "res/ods_16_8.png"
+#define BMP_ACTION_DEFAULT_IMPRESS "res/odp_16_8.png"
+#define BMP_ACTION_DEFAULT_DRAW "res/odg_16_8.png"
+#define BMP_ACTION_MOVE "cmd/sc_move.png"
+#define BMP_ACTION_IMPORT "cmd/sc_dataimport.png"
+#define BMP_ACTION_EXPORT "cmd/sc_exportto.png"
+#define BMP_ACTION_EXTENSIONS "cmd/sc_additionsdialog.png"
+#define BMP_ACTION_DELETE_CATEGORY "cmd/sc_delete.png"
+#define BMP_ACTION_NEW_CATEGORY "cmd/sc_add.png"
+#define BMP_ACTION_RENAME "cmd/sc_editdoc.png"
+#define BMP_MENU_OPEN "cmd/sc_opentemplate.png"
+#define BMP_MENU_EDIT "cmd/sc_opentemplate.png"
+#define BMP_MENU_MOVE "cmd/sc_move.png"
+#define BMP_MENU_RENAME "cmd/sc_editdoc.png"
+#define BMP_MENU_DELETE "cmd/sc_delete.png"
+#define BMP_MENU_EXPORT "cmd/sc_exportto.png"
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/sfx2/source/control/templatedlglocalview.cxx b/sfx2/source/control/templatedlglocalview.cxx
index f916e57c8d7d..704468681fb8 100644
--- a/sfx2/source/control/templatedlglocalview.cxx
+++ b/sfx2/source/control/templatedlglocalview.cxx
@@ -19,6 +19,7 @@
#include <vcl/svapp.hxx>
#include <vcl/event.hxx>
#include <sfx2/doctempl.hxx>
+#include <bitmaps.hlst>
TemplateDlgLocalView::TemplateDlgLocalView(std::unique_ptr<weld::ScrolledWindow> xWindow,
std::unique_ptr<weld::Menu> xMenu,
@@ -39,7 +40,6 @@ void TemplateDlgLocalView::showAllTemplates()
mnCurRegionId = 0;
insertItems(maAllTemplates, false, true);
- insertFilteredItems();
maOpenRegionHdl.Call(nullptr);
}
@@ -48,8 +48,7 @@ void TemplateDlgLocalView::showRegion(TemplateContainerItem const* pItem)
{
mnCurRegionId = pItem->mnRegionId + 1;
- insertItems(pItem->maTemplates);
- insertFilteredItems();
+ insertItems(pItem->maTemplates, true, false);
maOpenRegionHdl.Call(nullptr);
}
@@ -95,31 +94,39 @@ void TemplateDlgLocalView::reload()
ListView::unselect_all();
}
-void TemplateDlgLocalView::createContextMenu(const bool bIsDefault, const bool bIsBuiltIn)
+void TemplateDlgLocalView::createContextMenu(const bool bIsDefault, const bool bIsBuiltIn,
+ const bool bIsSingleSel, const OUString& rDefaultImg)
{
mxContextMenu->clear();
- mxContextMenu->append("open", SfxResId(STR_OPEN));
- mxContextMenu->append("edit", SfxResId(STR_EDIT_TEMPLATE));
+ mxContextMenu->append("open", SfxResId(STR_OPEN), BMP_MENU_OPEN);
+ mxContextMenu->append("edit", SfxResId(STR_EDIT_TEMPLATE), BMP_MENU_EDIT);
if (!bIsDefault)
- mxContextMenu->append("default", SfxResId(STR_DEFAULT_TEMPLATE));
+ mxContextMenu->append("default", SfxResId(STR_DEFAULT_TEMPLATE), rDefaultImg);
else
- mxContextMenu->append("default", SfxResId(STR_RESET_DEFAULT));
+ mxContextMenu->append("default", SfxResId(STR_RESET_DEFAULT), rDefaultImg);
- mxContextMenu->append_separator("separator");
- mxContextMenu->append("rename", SfxResId(STR_SFX_RENAME));
- mxContextMenu->append("delete", SfxResId(STR_DELETE));
+ mxContextMenu->append_separator("separator1");
+ mxContextMenu->append("rename", SfxResId(STR_SFX_RENAME), BMP_MENU_RENAME);
+ mxContextMenu->append("delete", SfxResId(STR_DELETE_TEMPLATE), BMP_MENU_DELETE);
+ mxContextMenu->append_separator("separator2");
+ mxContextMenu->append("move", SfxResId(STR_MOVE), BMP_MENU_MOVE);
+ mxContextMenu->append("export", SfxResId(STR_EXPORT), BMP_MENU_EXPORT);
+
+ if (!bIsSingleSel)
+ {
+ mxContextMenu->set_sensitive("open", false);
+ mxContextMenu->set_sensitive("edit", false);
+ mxContextMenu->set_sensitive("default", false);
+ mxContextMenu->set_sensitive("rename", false);
+ }
if (bIsBuiltIn)
{
mxContextMenu->set_sensitive("rename", false);
- mxContextMenu->set_sensitive("edit", false);
mxContextMenu->set_sensitive("delete", false);
}
if (mViewMode == TemplateViewMode::eThumbnailView)
{
- deselectItems();
- maSelectedItem->setSelection(true);
- maItemStateHdl.Call(maSelectedItem);
ContextMenuSelectHdl(mxContextMenu->popup_at_rect(
GetDrawingArea(), tools::Rectangle(maPosition, Size(1, 1))));
Invalidate();
@@ -138,6 +145,7 @@ void TemplateDlgLocalView::ContextMenuSelectHdl(std::string_view rIdent)
else if (rIdent == "rename")
{
InputDialog aTitleEditDlg(GetDrawingArea(), SfxResId(STR_RENAME_TEMPLATE));
+ aTitleEditDlg.set_title(SfxResId(STR_WINDOW_TITLE_RENAME_TEMPLATE));
OUString sOldTitle = maSelectedItem->getTitle();
aTitleEditDlg.SetEntryText(sOldTitle);
aTitleEditDlg.HideHelpBtn();
@@ -186,6 +194,14 @@ void TemplateDlgLocalView::ContextMenuSelectHdl(std::string_view rIdent)
maDefaultTemplateHdl.Call(maSelectedItem);
ListView::refreshDefaultColumn();
}
+ else if (rIdent == "move")
+ {
+ maMoveTemplateHdl.Call(maSelectedItem);
+ }
+ else if (rIdent == "export")
+ {
+ maExportTemplateHdl.Call(maSelectedItem);
+ }
}
void TemplateDlgLocalView::insertFilteredItems()
@@ -204,6 +220,14 @@ void TemplateDlgLocalView::insertFilteredItems()
ListView::sort();
}
+void TemplateDlgLocalView::insertItems(const std::vector<TemplateItemProperties>& rTemplates,
+ bool isRegionSelected = true,
+ bool bShowCategoryInTooltip = false)
+{
+ TemplateLocalView::insertItems(rTemplates, isRegionSelected, bShowCategoryInTooltip);
+ insertFilteredItems();
+}
+
void TemplateDlgLocalView::setTemplateViewMode(TemplateViewMode eMode) { mViewMode = eMode; }
void TemplateDlgLocalView::Show()
@@ -313,10 +337,6 @@ IMPL_LINK(TemplateDlgLocalView, PopupMenuHdl, const CommandEvent&, rCEvt, bool)
{
if (ListView::get_selected_rows().empty())
return true;
- int nIndex = ListView::get_cursor_index();
- ListView::unselect_all();
- ListView::select(nIndex);
- ListView::set_cursor(nIndex);
Point aPosition(rCEvt.GetMousePosPixel());
maPosition = aPosition;
updateSelection();
@@ -328,10 +348,6 @@ IMPL_LINK(TemplateDlgLocalView, PopupMenuHdl, const CommandEvent&, rCEvt, bool)
{
if (ListView::get_selected_rows().empty())
return true;
- int nIndex = ListView::get_cursor_index();
- ListView::unselect_all();
- ListView::select(nIndex);
- ListView::set_cursor(nIndex);
maPosition = Point(0, 0);
updateSelection();
if (maSelectedItem)
@@ -372,16 +388,7 @@ bool TemplateDlgLocalView::KeyInput(const KeyEvent& rKEvt)
if (xQueryDlg->run() != RET_YES)
return true;
- //copy to avoid changing filtered item list during deletion
- ThumbnailValueItemList mFilteredItemListCopy = mFilteredItemList;
-
- for (ThumbnailViewItem* pItem : mFilteredItemListCopy)
- {
- if (pItem->isSelected())
- {
- maDeleteTemplateHdl.Call(pItem);
- }
- }
+ maDeleteTemplateHdl.Call(maSelectedItem);
reload();
}
@@ -401,17 +408,7 @@ IMPL_LINK(TemplateDlgLocalView, KeyPressHdl, const KeyEvent&, rKEvt, bool)
if (xQueryDlg->run() != RET_YES)
return true;
- //copy to avoid changing filtered item list during deletion
- ThumbnailValueItemList mFilteredItemListCopy = mFilteredItemList;
-
- for (ThumbnailViewItem* pItem : mFilteredItemListCopy)
- {
- if (pItem->isSelected())
- {
- maDeleteTemplateHdl.Call(pItem);
- }
- }
-
+ maDeleteTemplateHdl.Call(maSelectedItem);
reload();
}
return false;
diff --git a/sfx2/source/control/templatelocalview.cxx b/sfx2/source/control/templatelocalview.cxx
index a933a00285dd..c1916a44656a 100644
--- a/sfx2/source/control/templatelocalview.cxx
+++ b/sfx2/source/control/templatelocalview.cxx
@@ -30,6 +30,7 @@
#include <com/sun/star/util/thePathSettings.hpp>
#include <unotools/ucbhelper.hxx>
#include <sfxurlrelocator.hxx>
+#include <../doc/doctemplateslocal.hxx>
using namespace ::com::sun::star;
@@ -760,7 +761,6 @@ bool TemplateLocalView::Command(const CommandEvent& rCEvt)
if (rCEvt.IsMouseEvent())
{
- deselectItems();
size_t nPos = ImplGetItem(rCEvt.GetMousePosPixel());
Point aPosition(rCEvt.GetMousePosPixel());
maPosition = aPosition;
@@ -769,6 +769,12 @@ bool TemplateLocalView::Command(const CommandEvent& rCEvt)
if(pViewItem)
{
+ if(!pItem->isSelected())
+ {
+ deselectItems();
+ pItem->setSelection(true);
+ maItemStateHdl.Call(pItem);
+ }
maSelectedItem = dynamic_cast<TemplateViewItem*>(pItem);
maCreateContextMenuHdl.Call(pItem);
}
@@ -777,12 +783,8 @@ bool TemplateLocalView::Command(const CommandEvent& rCEvt)
{
for (ThumbnailViewItem* pItem : mFilteredItemList)
{
- //create context menu for the first selected item
if (pItem->isSelected())
{
- deselectItems();
- pItem->setSelection(true);
- maItemStateHdl.Call(pItem);
tools::Rectangle aRect = pItem->getDrawArea();
maPosition = aRect.Center();
maSelectedItem = dynamic_cast<TemplateViewItem*>(pItem);
@@ -856,7 +858,7 @@ void TemplateLocalView::setEditTemplateHdl(const Link<ThumbnailViewItem*,void> &
maEditTemplateHdl = rLink;
}
-void TemplateLocalView::setDeleteTemplateHdl(const Link<ThumbnailViewItem*,void> &rLink)
+void TemplateLocalView::setDeleteTemplateHdl(const Link<void*,void> &rLink)
{
maDeleteTemplateHdl = rLink;
}
@@ -866,6 +868,16 @@ void TemplateLocalView::setDefaultTemplateHdl(const Link<ThumbnailViewItem*,void
maDefaultTemplateHdl = rLink;
}
+void TemplateLocalView::setMoveTemplateHdl(const Link<void*,void> &rLink)
+{
+ maMoveTemplateHdl = rLink;
+}
+
+void TemplateLocalView::setExportTemplateHdl(const Link<void*,void> &rLink)
+{
+ maExportTemplateHdl = rLink;
+}
+
BitmapEx TemplateLocalView::scaleImg (const BitmapEx &rImg, tools::Long width, tools::Long height)
{
BitmapEx aImg = rImg;
@@ -961,4 +973,27 @@ bool TemplateLocalView::IsInternalTemplate(const OUString& rPath)
return false;
}
+bool TemplateLocalView::IsBuiltInRegion(const OUString& rRegionName)
+{
+ bool isBuiltInCategory = false;
+ auto aGroupNames = DocTemplLocaleHelper::GetBuiltInGroupNames();
+ isBuiltInCategory = std::find(aGroupNames.begin(), aGroupNames.end(),
+ rRegionName) != aGroupNames.end();
+ if(isBuiltInCategory)
+ return true;
+ //check if it contains any internal template
+ for(const auto& rItem : maRegions)
+ {
+ if(rItem->maTitle == rRegionName)
+ {
+ for(const auto& rTemplateItem : rItem->maTemplates)
+ {
+ if(IsInternalTemplate(rTemplateItem.aPath))
+ return true;
+ }
+ break;
+ }
+ }
+ return false;
+}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/control/templatesearchview.cxx b/sfx2/source/control/templatesearchview.cxx
deleted file mode 100644
index 009dbb9f4c15..000000000000
--- a/sfx2/source/control/templatesearchview.cxx
+++ /dev/null
@@ -1,462 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-#include <templatesearchview.hxx>
-#include <templatesearchviewitem.hxx>
-#include <sfx2/templatelocalview.hxx>
-#include <sfx2/sfxresid.hxx>
-#include <tools/urlobj.hxx>
-#include <vcl/svapp.hxx>
-#include <vcl/weld.hxx>
-#include <vcl/commandevent.hxx>
-#include <vcl/event.hxx>
-
-#include <sfx2/strings.hrc>
-#include <bitmaps.hlst>
-
-#define MNI_OPEN "open"
-#define MNI_EDIT "edit"
-#define MNI_DEFAULT_TEMPLATE "default"
-#define MNI_DELETE "delete"
-
-TemplateSearchView::TemplateSearchView(std::unique_ptr<weld::ScrolledWindow> xWindow,
- std::unique_ptr<weld::Menu> xMenu,
- std::unique_ptr<weld::TreeView> xTreeView)
- : ThumbnailView(std::move(xWindow), std::move(xMenu))
- , ListView(std::move(xTreeView))
- , maSelectedItem(nullptr)
- , maPosition(0,0)
- , mViewMode(TemplateViewMode::eThumbnailView)
-{
- mxTreeView->connect_row_activated(LINK(this, TemplateSearchView, RowActivatedHdl));
- mxTreeView->connect_column_clicked(LINK(this, ListView, ColumnClickedHdl));
- mxTreeView->connect_changed(LINK(this, TemplateSearchView, ListViewChangedHdl));
- mxTreeView->connect_popup_menu(LINK(this, TemplateSearchView, PopupMenuHdl));
- mxTreeView->connect_key_press(LINK(this, TemplateSearchView, KeyPressHdl));
-}
-
-bool TemplateSearchView::MouseButtonDown( const MouseEvent& rMEvt )
-{
- GrabFocus();
- return ThumbnailView::MouseButtonDown(rMEvt);
-}
-
-bool TemplateSearchView::KeyInput( const KeyEvent& rKEvt )
-{
- vcl::KeyCode aKeyCode = rKEvt.GetKeyCode();
-
- if(aKeyCode == ( KEY_MOD1 | KEY_A ) )
- {
- for (ThumbnailViewItem* pItem : mFilteredItemList)
- {
- if (!pItem->isSelected())
- {
- pItem->setSelection(true);
- maItemStateHdl.Call(pItem);
- }
- }
-
- if (IsReallyVisible() && IsUpdateMode())
- Invalidate();
- return true;
- }
- else if( aKeyCode == KEY_DELETE && !mFilteredItemList.empty())
- {
- std::unique_ptr<weld::MessageDialog> xQueryDlg(Application::CreateMessageDialog(GetDrawingArea(), VclMessageType::Question, VclButtonsType::YesNo,
- SfxResId(STR_QMSG_SEL_TEMPLATE_DELETE)));
- if (xQueryDlg->run() != RET_YES)
- return true;
-
- //copy to avoid changing filtered item list during deletion
- ThumbnailValueItemList mFilteredItemListCopy = mFilteredItemList;
-
- for (ThumbnailViewItem* pItem : mFilteredItemListCopy)
- {
- if (pItem->isSelected())
- {
- maDeleteTemplateHdl.Call(pItem);
- ListView::remove(OUString::number(pItem->mnId));
- ThumbnailView::RemoveItem(pItem->mnId);
- CalculateItemPositions();
- }
- }
- }
-
- return ThumbnailView::KeyInput(rKEvt);
-}
-
-bool TemplateSearchView::Command(const CommandEvent& rCEvt)
-{
- if (rCEvt.GetCommand() != CommandEventId::ContextMenu)
- return CustomWidgetController::Command(rCEvt);
-
- if (rCEvt.IsMouseEvent())
- {
- deselectItems();
- size_t nPos = ImplGetItem(rCEvt.GetMousePosPixel());
- Point aPosition(rCEvt.GetMousePosPixel());
- maPosition = aPosition;
- ThumbnailViewItem* pItem = ImplGetItem(nPos);
- const TemplateViewItem *pViewItem = dynamic_cast<const TemplateViewItem*>(pItem);
-
- if(pViewItem)
- {
- maSelectedItem = dynamic_cast<TemplateViewItem*>(pItem);
- maCreateContextMenuHdl.Call(pItem);
- }
- }
- else
- {
- for (ThumbnailViewItem* pItem : mFilteredItemList)
- {
- //create context menu for the first selected item
- if (pItem->isSelected())
- {
- deselectItems();
- pItem->setSelection(true);
- maItemStateHdl.Call(pItem);
- tools::Rectangle aRect = pItem->getDrawArea();
- maPosition = aRect.Center();
- maSelectedItem = dynamic_cast<TemplateViewItem*>(pItem);
- maCreateContextMenuHdl.Call(pItem);
- break;
- }
- }
- }
- return true;
-}
-
-void TemplateSearchView::createContextMenu(const bool bIsDefault, const bool bIsBuiltIn)
-{
- mxContextMenu->clear();
- mxContextMenu->append(MNI_OPEN,SfxResId(STR_OPEN));
- mxContextMenu->append(MNI_EDIT,SfxResId(STR_EDIT_TEMPLATE));
-
- if (!bIsDefault)
- mxContextMenu->append(MNI_DEFAULT_TEMPLATE,SfxResId(STR_DEFAULT_TEMPLATE));
- else
- mxContextMenu->append(MNI_DEFAULT_TEMPLATE,SfxResId(STR_RESET_DEFAULT));
-
- mxContextMenu->append_separator("separator");
- mxContextMenu->append(MNI_DELETE,SfxResId(STR_DELETE));
- if(bIsBuiltIn)
- {
- mxContextMenu->set_sensitive(MNI_EDIT, false);
- mxContextMenu->set_sensitive(MNI_DELETE, false);
- }
- if(mViewMode == TemplateViewMode::eThumbnailView)
- {
- maSelectedItem->setSelection(true);
- maItemStateHdl.Call(maSelectedItem);
- ContextMenuSelectHdl(mxContextMenu->popup_at_rect(GetDrawingArea(), tools::Rectangle(maPosition, Size(1,1))));
- Invalidate();
- }
- else if(mViewMode == TemplateViewMode::eListView)
- ContextMenuSelectHdl(mxContextMenu->popup_at_rect(mxTreeView.get(), tools::Rectangle(maPosition, Size(1,1))));
-}
-
-void TemplateSearchView::ContextMenuSelectHdl(std::string_view rIdent)
-{
- if (rIdent == MNI_OPEN)
- maOpenTemplateHdl.Call(maSelectedItem);
- else if (rIdent == MNI_EDIT)
- maEditTemplateHdl.Call(maSelectedItem);
- else if (rIdent == MNI_DELETE)
- {
- std::unique_ptr<weld::MessageDialog> xQueryDlg(Application::CreateMessageDialog(GetDrawingArea(), VclMessageType::Question, VclButtonsType::YesNo,
- SfxResId(STR_QMSG_SEL_TEMPLATE_DELETE)));
- if (xQueryDlg->run() != RET_YES)
- return;
-
- maDeleteTemplateHdl.Call(maSelectedItem);
- ListView::remove(OUString::number(maSelectedItem->mnId));
- ThumbnailView::RemoveItem(maSelectedItem->mnId);
-
- CalculateItemPositions();
- }
- else if (rIdent == MNI_DEFAULT_TEMPLATE)
- {
- maDefaultTemplateHdl.Call(maSelectedItem);
- ListView::refreshDefaultColumn();
- }
-}
-
-void TemplateSearchView::setCreateContextMenuHdl(const Link<ThumbnailViewItem*,void> &rLink)
-{
- maCreateContextMenuHdl = rLink;
-}
-
-void TemplateSearchView::setOpenTemplateHdl(const Link<ThumbnailViewItem*, void> &rLink)
-{
- maOpenTemplateHdl = rLink;
-}
-
-void TemplateSearchView::setEditTemplateHdl(const Link<ThumbnailViewItem*,void> &rLink)
-{
- maEditTemplateHdl = rLink;
-}
-
-void TemplateSearchView::setDeleteTemplateHdl(const Link<ThumbnailViewItem*,void> &rLink)
-{
- maDeleteTemplateHdl = rLink;
-}
-
-void TemplateSearchView::setDefaultTemplateHdl(const Link<ThumbnailViewItem*,void> &rLink)
-{
- maDefaultTemplateHdl = rLink;
-}
-
-void TemplateSearchView::OnItemDblClicked (ThumbnailViewItem *pItem)
-{
- maOpenTemplateHdl.Call(pItem);
-}
-
-void TemplateSearchView::AppendItem(sal_uInt16 nAssocItemId, sal_uInt16 nRegionId, sal_uInt16 nIdx,
- const OUString &rTitle, const OUString &rSubtitle,
- const OUString &rPath,
- const BitmapEx &rImage)
-{
- std::unique_ptr<TemplateSearchViewItem> pItem(new TemplateSearchViewItem(*this, getNextItemId()));
- pItem->mnAssocId = nAssocItemId;
- pItem->mnDocId = nIdx;
- pItem->mnRegionId = nRegionId;
-
- if(!rImage.IsEmpty())
- pItem->maPreview1 = rImage;
- else
- pItem->maPreview1 = getDefaultThumbnail(rPath);
-
- pItem->maTitle = rTitle;
- pItem->setHelpText(rSubtitle);
- pItem->setPath(rPath);
-
- if (TemplateLocalView::IsDefaultTemplate(rPath))
- pItem->showDefaultIcon(true);
-
- bool isDefault = pItem->IsDefaultTemplate();
- OUString sId = OUString::number(pItem->mnId);
- ListView::AppendItem(sId, rTitle, rSubtitle, rPath, isDefault);
- ThumbnailView::AppendItem(std::move(pItem));
-
- CalculateItemPositions();
-}
-
-void TemplateSearchView::Clear()
-{
- ThumbnailView::Clear();
- ListView::clearListView();
-}
-
-void TemplateSearchView::setTemplateViewMode ( TemplateViewMode eMode )
-{
- mViewMode = eMode;
-}
-
-void TemplateSearchView::Show()
-{
- if ( mViewMode == TemplateViewMode::eListView)
- {
- ThumbnailView::Hide();
- ListView::ShowListView();
- }
- else
- {
- ThumbnailView::Show();
- ListView::HideListView();
- }
- syncCursor();
-}
-
-void TemplateSearchView::Hide()
-{
- ThumbnailView::Hide();
- ListView::HideListView();
-}
-
-bool TemplateSearchView::IsVisible() const
-{
- return ThumbnailView::IsVisible() || ListView::IsListViewVisible();
-}
-
-void TemplateSearchView::syncCursor()
-{
- if ( mViewMode == TemplateViewMode::eListView)
- {
- ListView::unselect_all();
- int nIndex = -1;
-
- for(auto it = mFilteredItemList.cbegin(); it != mFilteredItemList.cend() ; ++it )
- {
- if((*it)->mbSelected)
- {
- nIndex = -1;
- nIndex = ListView::get_index((*it)->mnId);
- if(nIndex >= 0)
- {
- ListView::set_cursor(nIndex);
- ListView::select(nIndex);
- break;
- }
- }
- }
- updateSelection();
- }
- else
- {
- ThumbnailView::deselectItems();
- std::vector<int> aSelRows = ListView::get_selected_rows();
- if(aSelRows.empty())
- return;
- sal_uInt16 nCursorId = ListView::get_cursor_nId();
- ThumbnailView::SelectItem(nCursorId);
- MakeItemVisible(nCursorId);
-
- for(auto it = mFilteredItemList.begin(); it != mFilteredItemList.end() ; ++it )
- {
- if((*it)->mnId == nCursorId)
- {
- mpStartSelRange = it;
- break;
- }
- }
-
- size_t nPos = GetItemPos(nCursorId);
- ThumbnailViewItem* pItem = ImplGetItem(nPos);
- const TemplateViewItem *pViewItem = dynamic_cast<const TemplateViewItem*>(pItem);
- if(pViewItem)
- maSelectedItem = dynamic_cast<TemplateViewItem*>(pItem);
- }
-}
-
-void TemplateSearchView::updateSelection()
-{
- ThumbnailView::deselectItems();
- for(auto nIndex : ListView::get_selected_rows())
- {
- ThumbnailView::SelectItem(ListView::get_nId(nIndex) );
- }
-
- sal_uInt16 nCursorId = ListView::get_cursor_nId();
- size_t nPos = GetItemPos(nCursorId);
- ThumbnailViewItem* pItem = ImplGetItem(nPos);
- const TemplateViewItem *pViewItem = dynamic_cast<const TemplateViewItem*>(pItem);
- if(pViewItem)
- maSelectedItem = dynamic_cast<TemplateViewItem*>(pItem);
- return;
-}
-
-IMPL_LINK_NOARG(TemplateSearchView, RowActivatedHdl, weld::TreeView&, bool)
-{
- maOpenTemplateHdl.Call(maSelectedItem);
- return true;
-}
-
-IMPL_LINK(TemplateSearchView, PopupMenuHdl, const CommandEvent&, rCEvt, bool)
-{
- if (rCEvt.GetCommand() != CommandEventId::ContextMenu)
- return false;
-
- if (rCEvt.IsMouseEvent())
- {
- if(ListView::get_selected_rows().empty())
- return true;
- int nIndex = ListView::get_cursor_index();
- ListView::unselect_all();
- ListView::select(nIndex);
- ListView::set_cursor(nIndex);
- Point aPosition (rCEvt.GetMousePosPixel());
- maPosition = aPosition;
- updateSelection();
- if(maSelectedItem)
- maCreateContextMenuHdl.Call(maSelectedItem);
- return true;
- }
- else
- {
- if(ListView::get_selected_rows().empty())
- return true;
- int nIndex = ListView::get_cursor_index();
- ListView::unselect_all();
- ListView::select(nIndex) ;
- ListView::set_cursor(nIndex) ;
- maPosition = Point(0,0);
- updateSelection();
- if(maSelectedItem)
- maCreateContextMenuHdl.Call(maSelectedItem);
- return true;
- }
-}
-
-IMPL_LINK_NOARG(TemplateSearchView, ListViewChangedHdl, weld::TreeView&, void)
-{
- updateSelection();
-}
-
-BitmapEx TemplateSearchView::getDefaultThumbnail( const OUString& rPath )
-{
- BitmapEx aImg;
- INetURLObject aUrl(rPath);
- OUString aExt = aUrl.getExtension();
-
- if ( ViewFilter_Application::isFilteredExtension( FILTER_APPLICATION::WRITER, aExt) )
- aImg = BitmapEx(SFX_THUMBNAIL_TEXT);
- else if ( ViewFilter_Application::isFilteredExtension( FILTER_APPLICATION::CALC, aExt) )
- aImg = BitmapEx(SFX_THUMBNAIL_SHEET);
- else if ( ViewFilter_Application::isFilteredExtension( FILTER_APPLICATION::IMPRESS, aExt) )
- aImg = BitmapEx(SFX_THUMBNAIL_PRESENTATION);
- else if ( ViewFilter_Application::isFilteredExtension( FILTER_APPLICATION::DRAW, aExt) )
- aImg = BitmapEx(SFX_THUMBNAIL_DRAWING);
-
- return aImg;
-}
-
-void TemplateSearchView::RemoveDefaultTemplateIcon(std::u16string_view rPath)
-{
- for (const std::unique_ptr<ThumbnailViewItem>& pItem : mItemList)
- {
- TemplateViewItem* pViewItem = dynamic_cast<TemplateViewItem*>(pItem.get());
- if (pViewItem && pViewItem->getPath().match(rPath))
- {
- pViewItem->showDefaultIcon(false);
- Invalidate();
- return;
- }
- }
-}
-
-IMPL_LINK(TemplateSearchView, KeyPressHdl, const KeyEvent&, rKEvt, bool)
-{
- vcl::KeyCode aKeyCode = rKEvt.GetKeyCode();
-
- if( aKeyCode == KEY_DELETE && !mFilteredItemList.empty() && !ListView::get_selected_rows().empty())
- {
- std::unique_ptr<weld::MessageDialog> xQueryDlg(Application::CreateMessageDialog(mxTreeView.get(), VclMessageType::Question, VclButtonsType::YesNo,
- SfxResId(STR_QMSG_SEL_TEMPLATE_DELETE)));
- if (xQueryDlg->run() != RET_YES)
- return true;
-
- //copy to avoid changing filtered item list during deletion
- ThumbnailValueItemList mFilteredItemListCopy = mFilteredItemList;
-
- for (ThumbnailViewItem* pItem : mFilteredItemListCopy)
- {
- if (pItem->isSelected())
- {
- maDeleteTemplateHdl.Call(pItem);
- ListView::remove(OUString::number(pItem->mnId));
- ThumbnailView::RemoveItem(pItem->mnId);
-
- CalculateItemPositions();
- }
- }
- }
-
- return false;
-}
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/doc/doctemplates.cxx b/sfx2/source/doc/doctemplates.cxx
index 2cfc845204e6..b1273c0b53c6 100644
--- a/sfx2/source/doc/doctemplates.cxx
+++ b/sfx2/source/doc/doctemplates.cxx
@@ -2737,4 +2737,12 @@ OUString DocTemplLocaleHelper::GetStandardGroupString()
return SfxResId(TEMPLATE_LONG_NAMES_ARY[0]);
}
+std::vector<OUString> DocTemplLocaleHelper::GetBuiltInGroupNames()
+{
+ std::vector<OUString> aGroups;
+ for(auto aGroupName : TEMPLATE_LONG_NAMES_ARY)
+ aGroups.push_back(SfxResId(aGroupName));
+ return aGroups;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/doc/doctemplateslocal.hxx b/sfx2/source/doc/doctemplateslocal.hxx
index 1da7110b66ba..466c847db1b5 100644
--- a/sfx2/source/doc/doctemplateslocal.hxx
+++ b/sfx2/source/doc/doctemplateslocal.hxx
@@ -60,6 +60,7 @@ public:
const css::uno::Reference< css::uno::XComponentContext >& xContext );
static OUString GetStandardGroupString();
+ static std::vector<OUString> GetBuiltInGroupNames();
// XDocumentHandler
virtual void SAL_CALL startDocument() override;
diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx
index 1a7129386329..34011c454f3a 100644
--- a/sfx2/source/doc/templatedlg.cxx
+++ b/sfx2/source/doc/templatedlg.cxx
@@ -11,8 +11,6 @@
#include <sfx2/inputdlg.hxx>
#include <sfx2/module.hxx>
-#include <templatesearchview.hxx>
-#include <templatesearchviewitem.hxx>
#include <comphelper/processfactory.hxx>
#include <comphelper/string.hxx>
@@ -54,6 +52,7 @@
#include <comphelper/dispatchcommand.hxx>
#include <sfx2/strings.hrc>
+#include <bitmaps.hlst>
constexpr OUStringLiteral TM_SETTING_MANAGER = u"TemplateManager";
constexpr OUStringLiteral TM_SETTING_LASTFOLDER = u"LastFolder";
@@ -65,6 +64,15 @@ constexpr OUStringLiteral TM_SETTING_VIEWMODE = u"ViewMode";
#define MNI_ACTION_DELETE_FOLDER "delete"
#define MNI_ACTION_REFRESH "refresh"
#define MNI_ACTION_DEFAULT "default"
+#define MNI_ACTION_DEFAULT_WRITER "default writer"
+#define MNI_ACTION_DEFAULT_CALC "default calc"
+#define MNI_ACTION_DEFAULT_IMPRESS "default impress"
+#define MNI_ACTION_DEFAULT_DRAW "default draw"
+#define MNI_ACTION_MOVE "move template"
+#define MNI_ACTION_IMPORT "import template"
+#define MNI_ACTION_EXPORT "export template"
+#define MNI_ACTION_EXTENSIONS "extensions"
+#define MNI_ALL_APPLICATIONS 0
#define MNI_WRITER 1
#define MNI_CALC 2
#define MNI_IMPRESS 3
@@ -156,31 +164,31 @@ SfxTemplateManagerDlg::SfxTemplateManagerDlg(weld::Window *pParent)
, mxCBApp(m_xBuilder->weld_combo_box("filter_application"))
, mxCBFolder(m_xBuilder->weld_combo_box("filter_folder"))
, mxOKButton(m_xBuilder->weld_button("ok"))
- , mxMoveButton(m_xBuilder->weld_button("move_btn"))
- , mxExportButton(m_xBuilder->weld_button("export_btn"))
- , mxImportButton(m_xBuilder->weld_button("import_btn"))
- , mxMoreTemplatesButton(m_xBuilder->weld_button("btnMoreTemplates"))
, mxCBXHideDlg(m_xBuilder->weld_check_button("hidedialogcb"))
, mxActionBar(m_xBuilder->weld_menu_button("action_menu"))
- , mxSearchView(new TemplateSearchView(m_xBuilder->weld_scrolled_window("scrollsearch", true),
- m_xBuilder->weld_menu("contextmenu1"),
- m_xBuilder->weld_tree_view("treesearch_list")))
, mxLocalView(new TemplateDlgLocalView(m_xBuilder->weld_scrolled_window("scrolllocal", true),
- m_xBuilder->weld_menu("contextmenu2"),
+ m_xBuilder->weld_menu("contextmenu"),
m_xBuilder->weld_tree_view("tree_list")))
- , mxTemplateDefaultMenu(m_xBuilder->weld_menu("submenu"))
- , mxSearchViewWeld(new weld::CustomWeld(*m_xBuilder, "search_view", *mxSearchView))
, mxLocalViewWeld(new weld::CustomWeld(*m_xBuilder, "template_view", *mxLocalView))
, mxListViewButton(m_xBuilder->weld_toggle_button("list_view_btn"))
, mxThumbnailViewButton(m_xBuilder->weld_toggle_button("thumbnail_view_btn"))
, mViewMode(TemplateViewMode::eThumbnailView)
{
// Create popup menus
- mxActionBar->insert_item(0, MNI_ACTION_NEW_FOLDER, SfxResId(STR_CATEGORY_NEW), nullptr, nullptr, TRISTATE_INDET);
- mxActionBar->insert_item(1, MNI_ACTION_RENAME_FOLDER, SfxResId(STR_CATEGORY_RENAME), nullptr, nullptr, TRISTATE_INDET);
- mxActionBar->insert_item(2, MNI_ACTION_DELETE_FOLDER, SfxResId(STR_CATEGORY_DELETE), nullptr, nullptr, TRISTATE_INDET);
- mxActionBar->insert_separator(3, "separator");
- mxActionBar->insert_item(4, MNI_ACTION_REFRESH, SfxResId(STR_ACTION_REFRESH), nullptr, nullptr, TRISTATE_INDET);
+ mxActionBar->append_item(MNI_ACTION_NEW_FOLDER, SfxResId(STR_CATEGORY_NEW), BMP_ACTION_NEW_CATEGORY);
+ mxActionBar->append_item(MNI_ACTION_RENAME_FOLDER, SfxResId(STR_CATEGORY_RENAME), BMP_ACTION_RENAME);
+ mxActionBar->append_item(MNI_ACTION_DELETE_FOLDER, SfxResId(STR_CATEGORY_DELETE), BMP_ACTION_DELETE_CATEGORY);
+ mxActionBar->append_separator("separator");
+ mxActionBar->append_item(MNI_ACTION_REFRESH, SfxResId(STR_ACTION_REFRESH), BMP_ACTION_REFRESH);
+ mxActionBar->append_item(MNI_ACTION_DEFAULT, SfxResId(STR_ACTION_RESET_ALL_DEAULT_TEMPLATES));
+ mxActionBar->append_item(MNI_ACTION_DEFAULT_WRITER, SfxResId(STR_ACTION_RESET_WRITER_TEMPLATE), BMP_ACTION_DEFAULT_WRITER);
+ mxActionBar->append_item(MNI_ACTION_DEFAULT_CALC, SfxResId(STR_ACTION_RESET_CALC_TEMPLATE), BMP_ACTION_DEFAULT_CALC);
+ mxActionBar->append_item(MNI_ACTION_DEFAULT_IMPRESS, SfxResId(STR_ACTION_RESET_IMPRESS_TEMPLATE), BMP_ACTION_DEFAULT_IMPRESS);
+ mxActionBar->append_item(MNI_ACTION_DEFAULT_DRAW, SfxResId(STR_ACTION_RESET_DRAW_TEMPLATE), BMP_ACTION_DEFAULT_DRAW);
+ mxActionBar->append_separator("separator2");
+ mxActionBar->append_item(MNI_ACTION_IMPORT, SfxResId(STR_ACTION_IMPORT), BMP_ACTION_IMPORT);
+ mxActionBar->append_item(MNI_ACTION_EXTENSIONS, SfxResId(STR_ACTION_EXTENSIONS), BMP_ACTION_EXTENSIONS);
+
mxActionBar->connect_selected(LINK(this,SfxTemplateManagerDlg,MenuSelectHdl));
mxLocalView->setItemMaxTextLength(TEMPLATE_ITEM_MAX_TEXT_LENGTH);
@@ -195,32 +203,17 @@ SfxTemplateManagerDlg::SfxTemplateManagerDlg(weld::Window *pParent)
mxLocalView->setEditTemplateHdl(LINK(this,SfxTemplateManagerDlg, EditTemplateHdl));
mxLocalView->setDeleteTemplateHdl(LINK(this,SfxTemplateManagerDlg, DeleteTemplateHdl));
mxLocalView->setDefaultTemplateHdl(LINK(this,SfxTemplateManagerDlg, DefaultTemplateHdl));
-
- mxSearchView->setItemMaxTextLength(TEMPLATE_ITEM_MAX_TEXT_LENGTH);
-
- mxSearchView->setItemDimensions(TEMPLATE_ITEM_MAX_WIDTH,TEMPLATE_ITEM_THUMBNAIL_MAX_HEIGHT,
- TEMPLATE_ITEM_MAX_HEIGHT_SUB-TEMPLATE_ITEM_THUMBNAIL_MAX_HEIGHT,
- TEMPLATE_ITEM_PADDING);
-
- mxSearchView->setItemStateHdl(LINK(this,SfxTemplateManagerDlg,TVItemStateHdl));
- mxSearchView->setCreateContextMenuHdl(LINK(this,SfxTemplateManagerDlg, CreateContextMenuHdl));
- mxSearchView->setOpenTemplateHdl(LINK(this,SfxTemplateManagerDlg,OpenTemplateHdl));
- mxSearchView->setEditTemplateHdl(LINK(this,SfxTemplateManagerDlg, EditTemplateHdl));
- mxSearchView->setDeleteTemplateHdl(LINK(this,SfxTemplateManagerDlg, DeleteTemplateHdl));
- mxSearchView->setDefaultTemplateHdl(LINK(this,SfxTemplateManagerDlg, DefaultTemplateHdl));
+ mxLocalView->setMoveTemplateHdl(LINK(this,SfxTemplateManagerDlg, MoveTemplateHdl));
+ mxLocalView->setExportTemplateHdl(LINK(this,SfxTemplateManagerDlg, ExportTemplateHdl));
mxLocalView->ShowTooltips(true);
- mxSearchView->ShowTooltips(true);
mxOKButton->connect_clicked(LINK(this, SfxTemplateManagerDlg, OkClickHdl));
- mxMoveButton->connect_clicked(LINK(this, SfxTemplateManagerDlg, MoveClickHdl));
- mxExportButton->connect_clicked(LINK(this, SfxTemplateManagerDlg, ExportClickHdl));
- mxImportButton->connect_clicked(LINK(this, SfxTemplateManagerDlg, ImportClickHdl));
// FIXME: rather than disabling make dispatchCommand(".uno:AdditionsDialog") work in start center
if ( !SfxModule::GetActiveModule() )
- mxMoreTemplatesButton->set_sensitive(false);
+ mxActionBar->set_item_sensitive(MNI_ACTION_EXTENSIONS, false);
else
- mxMoreTemplatesButton->connect_clicked(LINK(this, SfxTemplateManagerDlg, LinkClickHdl));
+ mxActionBar->set_item_sensitive(MNI_ACTION_EXTENSIONS, true);
mxListViewButton->connect_toggled(LINK(this, SfxTemplateManagerDlg, ListViewHdl));
mxThumbnailViewButton->connect_toggled(LINK(this, SfxTemplateManagerDlg, ThumbnailViewHdl));
@@ -231,16 +224,18 @@ SfxTemplateManagerDlg::SfxTemplateManagerDlg(weld::Window *pParent)
mxActionBar->show();
- createDefaultTemplateMenu();
-
mxLocalView->Populate();
mxLocalView->filterItems(ViewFilter_Application(FILTER_APPLICATION::NONE));
mxCBApp->set_active(0);
fillFolderComboBox();
- mxExportButton->set_sensitive(false);
- mxMoveButton->set_sensitive(false);
+ mxActionBar->set_item_visible(MNI_ACTION_EXTENSIONS, true);
+ mxActionBar->set_item_visible(MNI_ACTION_EXPORT, true);
+ mxActionBar->set_item_visible(MNI_ACTION_MOVE, true);
+ mxActionBar->set_item_visible(MNI_ACTION_RENAME_FOLDER, true);
+ mxActionBar->set_item_visible(MNI_ACTION_DELETE_FOLDER, true);
+
mxOKButton->set_label(SfxResId(STR_OPEN));
mxCBApp->connect_changed(LINK(this, SfxTemplateManagerDlg, SelectApplicationHdl));
@@ -253,7 +248,6 @@ SfxTemplateManagerDlg::SfxTemplateManagerDlg(weld::Window *pParent)
m_aUpdateDataTimer.SetTimeout(EDIT_UPDATEDATA_TIMEOUT);
mxLocalView->connect_focus_rect(LINK(this, SfxTemplateManagerDlg, FocusRectLocalHdl));
- mxSearchView->connect_focus_rect(LINK(this, SfxTemplateManagerDlg, FocusRectSearchHdl));
bMakeSelItemVisible = false;
}
@@ -265,8 +259,6 @@ SfxTemplateManagerDlg::~SfxTemplateManagerDlg()
mxLocalView->setItemStateHdl(Link<const ThumbnailViewItem*,void>());
mxLocalView->setOpenRegionHdl(Link<void*,void>());
mxLocalView->setOpenTemplateHdl(Link<ThumbnailViewItem*, void>());
- mxSearchView->setItemStateHdl(Link<const ThumbnailViewItem*,void>());
- mxSearchView->setOpenTemplateHdl(Link<ThumbnailViewItem*, void>());
}
short SfxTemplateManagerDlg::run()
@@ -274,6 +266,7 @@ short SfxTemplateManagerDlg::run()
//use application specific settings if there's no previous setting
getApplicationSpecificSettings();
readSettings();
+ updateMenuItems();
return weld::GenericDialogController::run();
}
@@ -302,28 +295,22 @@ void SfxTemplateManagerDlg::setDocumentModel(const uno::Reference<frame::XModel>
void SfxTemplateManagerDlg::setTemplateViewMode(TemplateViewMode eViewMode)
{
- mViewMode = eViewMode;
- mxLocalView->setTemplateViewMode(eViewMode);
- mxSearchView->setTemplateViewMode(eViewMode);
- if ( mViewMode == TemplateViewMode::eListView)
- {
- mxThumbnailViewButton->set_active(false);
- mxListViewButton->set_active(true);
- }
- else
- {
- mxThumbnailViewButton->set_active(true);
- mxListViewButton->set_active(false);
- }
-
- if (! mxSearchFilter->get_text().isEmpty())
+ if(eViewMode == TemplateViewMode::eThumbnailView && mViewMode != TemplateViewMode::eThumbnailView)
{
- mxSearchView->Show();
- mxLocalView->Hide();
+ mxThumbnailViewButton->set_state(TRISTATE_TRUE);
+ mxListViewButton->set_state(TRISTATE_FALSE);
+ mxLocalView->ThumbnailView::GrabFocus();
+ mViewMode = eViewMode;
+ mxLocalView->setTemplateViewMode(eViewMode);
+ mxLocalView->Show();
}
- else
+ if(eViewMode == TemplateViewMode::eListView && mViewMode != TemplateViewMode::eListView)
{
- mxSearchView->Hide();
+ mxListViewButton->set_state(TRISTATE_TRUE);
+ mxThumbnailViewButton->set_state(TRISTATE_FALSE);
+ mxLocalView->ListView::grab_focus();
+ mViewMode = eViewMode;
+ mxLocalView->setTemplateViewMode(eViewMode);
mxLocalView->Show();
}
}
@@ -357,7 +344,8 @@ void SfxTemplateManagerDlg::fillFolderComboBox()
for (size_t i = 0, n = aFolderNames.size(); i < n; ++i)
mxCBFolder->append_text(aFolderNames[i]);
mxCBFolder->set_active(0);
- mxActionBar->set_item_visible(MNI_ACTION_RENAME_FOLDER, false);
+ mxActionBar->set_item_sensitive(MNI_ACTION_RENAME_FOLDER, false);
+ mxActionBar->set_item_sensitive(MNI_ACTION_DELETE_FOLDER, false);
}
void SfxTemplateManagerDlg::getApplicationSpecificSettings()
@@ -366,7 +354,8 @@ void SfxTemplateManagerDlg::getApplicationSpecificSettings()
{
mxCBApp->set_active(0);
mxCBFolder->set_active(0);
- mxActionBar->set_item_visible(MNI_ACTION_RENAME_FOLDER, false);
+ mxActionBar->set_item_sensitive(MNI_ACTION_RENAME_FOLDER, false);
+ mxActionBar->set_item_sensitive(MNI_ACTION_DELETE_FOLDER, false);
mxLocalView->filterItems(ViewFilter_Application(getCurrentApplicationFilter()));
mxLocalView->showAllTemplates();
return;
@@ -397,7 +386,8 @@ void SfxTemplateManagerDlg::getApplicationSpecificSettings()
mxLocalView->filterItems(ViewFilter_Application(getCurrentApplicationFilter()));
mxCBFolder->set_active(0);
- mxActionBar->set_item_visible(MNI_ACTION_RENAME_FOLDER, false);
+ mxActionBar->set_item_sensitive(MNI_ACTION_RENAME_FOLDER, false);
+ mxActionBar->set_item_sensitive(MNI_ACTION_DELETE_FOLDER, false);
mxLocalView->showAllTemplates();
}
@@ -444,14 +434,17 @@ void SfxTemplateManagerDlg::readSettings ()
{
//show all categories
mxCBFolder->set_active(0);
- mxActionBar->set_item_visible(MNI_ACTION_RENAME_FOLDER, false);
+ mxActionBar->set_item_sensitive(MNI_ACTION_RENAME_FOLDER, false);
+ mxActionBar->set_item_sensitive(MNI_ACTION_DELETE_FOLDER, false);
mxLocalView->showAllTemplates();
}
else
{
mxCBFolder->set_active_text(aLastFolder);
mxLocalView->showRegion(aLastFolder);
- mxActionBar->set_item_visible(MNI_ACTION_RENAME_FOLDER, true);
+ bool bIsBuiltInRegion = mxLocalView->IsBuiltInRegion(aLastFolder);
+ mxActionBar->set_item_sensitive(MNI_ACTION_RENAME_FOLDER, !bIsBuiltInRegion);
+ mxActionBar->set_item_sensitive(MNI_ACTION_DELETE_FOLDER, !bIsBuiltInRegion);
}
if(nViewMode == static_cast<sal_Int16>(TemplateViewMode::eListView) ||
@@ -489,15 +482,9 @@ void SfxTemplateManagerDlg::writeSettings ()
IMPL_LINK_NOARG(SfxTemplateManagerDlg, SelectApplicationHdl, weld::ComboBox&, void)
{
- if (mxLocalView->IsVisible())
- {
- mxLocalView->filterItems(ViewFilter_Application(getCurrentApplicationFilter()));
- mxLocalView->showAllTemplates();
- mxCBFolder->set_active(0);
- mxActionBar->set_item_visible(MNI_ACTION_RENAME_FOLDER, false);
- }
- if (mxSearchView->IsVisible())
- SearchUpdate();
+ mxLocalView->filterItems(ViewFilter_Application(getCurrentApplicationFilter()));
+ SelectRegionHdl(*mxCBFolder);
+ updateMenuItems();
}
IMPL_LINK_NOARG(SfxTemplateManagerDlg, SelectRegionHdl, weld::ComboBox&, void)
@@ -507,15 +494,17 @@ IMPL_LINK_NOARG(SfxTemplateManagerDlg, SelectRegionHdl, weld::ComboBox&, void)
if(mxCBFolder->get_active() == 0)
{
mxLocalView->showAllTemplates();
- mxActionBar->set_item_visible(MNI_ACTION_RENAME_FOLDER, false);
+ mxActionBar->set_item_sensitive(MNI_ACTION_RENAME_FOLDER, false);
+ mxActionBar->set_item_sensitive(MNI_ACTION_DELETE_FOLDER, false);
}
else
{
mxLocalView->showRegion(sSelectedRegion);
- mxActionBar->set_item_visible(MNI_ACTION_RENAME_FOLDER, true);
+ bool bIsBuiltInRegion = mxLocalView->IsBuiltInRegion(sSelectedRegion);
+ mxActionBar->set_item_sensitive(MNI_ACTION_RENAME_FOLDER, !bIsBuiltInRegion);
+ mxActionBar->set_item_sensitive(MNI_ACTION_DELETE_FOLDER, !bIsBuiltInRegion);
}
- if (mxSearchView->IsVisible())
- SearchUpdate();
+ FilterSearch();
}
IMPL_LINK(SfxTemplateManagerDlg, TVItemStateHdl, const ThumbnailViewItem*, pItem, void)
@@ -537,32 +526,49 @@ IMPL_LINK(SfxTemplateManagerDlg, MenuSelectHdl, const OString&, rIdent, void)
else if (rIdent == MNI_ACTION_REFRESH)
{
mxLocalView->reload();
- if(mxSearchView->IsVisible())
- SearchUpdateHdl(*mxSearchFilter);
+ FilterSearch();
}
- else if (rIdent != MNI_ACTION_DEFAULT)
+ else if (rIdent == MNI_ACTION_DEFAULT)
+ {
+ DefaultTemplateMenuSelectHdl(MNI_ACTION_DEFAULT_WRITER);
+ DefaultTemplateMenuSelectHdl(MNI_ACTION_DEFAULT_CALC);
+ DefaultTemplateMenuSelectHdl(MNI_ACTION_DEFAULT_IMPRESS);
+ DefaultTemplateMenuSelectHdl(MNI_ACTION_DEFAULT_DRAW);
+ }
+ else if(rIdent == MNI_ACTION_DEFAULT_WRITER || rIdent == MNI_ACTION_DEFAULT_CALC ||
+ rIdent == MNI_ACTION_DEFAULT_IMPRESS || rIdent == MNI_ACTION_DEFAULT_DRAW )
DefaultTemplateMenuSelectHdl(rIdent);
+ else if(rIdent == MNI_ACTION_IMPORT)
+ ImportActionHdl();
+ else if(rIdent == MNI_ACTION_EXTENSIONS)
+ ExtensionsActionHdl();
}
void SfxTemplateManagerDlg::DefaultTemplateMenuSelectHdl(std::string_view rIdent)
{
- OUString aServiceName = SfxObjectShell::GetServiceNameFromFactory(OUString::fromUtf8(rIdent));
+ SvtModuleOptions aModOpt;
+ OUString aFactoryURL;
+ if (rIdent == MNI_ACTION_DEFAULT_WRITER)
+ aFactoryURL = aModOpt.GetFactoryEmptyDocumentURL( SvtModuleOptions::EFactory::WRITER);
+ else if (rIdent == MNI_ACTION_DEFAULT_CALC)
+ aFactoryURL = aModOpt.GetFactoryEmptyDocumentURL( SvtModuleOptions::EFactory::CALC);
+ else if (rIdent == MNI_ACTION_DEFAULT_IMPRESS)
+ aFactoryURL = aModOpt.GetFactoryEmptyDocumentURL( SvtModuleOptions::EFactory::IMPRESS);
+ else if (rIdent == MNI_ACTION_DEFAULT_DRAW)
+ aFactoryURL = aModOpt.GetFactoryEmptyDocumentURL( SvtModuleOptions::EFactory::DRAW);
+ else
+ return;
+ OUString aServiceName = SfxObjectShell::GetServiceNameFromFactory(aFactoryURL);
OUString sPrevDefault = SfxObjectFactory::GetStandardTemplate( aServiceName );
if(!sPrevDefault.isEmpty())
{
- if(mxSearchView->IsVisible())
- mxSearchView->RemoveDefaultTemplateIcon(sPrevDefault);
- else
- mxLocalView->RemoveDefaultTemplateIcon(sPrevDefault);
+ mxLocalView->RemoveDefaultTemplateIcon(sPrevDefault);
}
SfxObjectFactory::SetStandardTemplate( aServiceName, OUString() );
- if (mxSearchView->IsVisible())
- mxSearchView->refreshDefaultColumn();
- else
- mxLocalView->refreshDefaultColumn();
- createDefaultTemplateMenu();
+ mxLocalView->refreshDefaultColumn();
+ updateMenuItems();
}
IMPL_LINK_NOARG(SfxTemplateManagerDlg, OkClickHdl, weld::Button&, void)
@@ -571,7 +577,7 @@ IMPL_LINK_NOARG(SfxTemplateManagerDlg, OkClickHdl, weld::Button&, void)
m_xDialog->response(RET_OK);
}
-IMPL_LINK_NOARG(SfxTemplateManagerDlg, MoveClickHdl, weld::Button&, void)
+IMPL_LINK_NOARG(SfxTemplateManagerDlg, MoveTemplateHdl, void*, void)
{
// modal dialog to select templates category
SfxTemplateCategoryDialog aDlg(m_xDialog.get());
@@ -594,67 +600,72 @@ IMPL_LINK_NOARG(SfxTemplateManagerDlg, MoveClickHdl, weld::Button&, void)
}
else
nItemId = mxLocalView->getRegionId(sCategory);
- }
- if(nItemId)
- {
- if (mxSearchView->IsVisible())
- localSearchMoveTo(nItemId);
- else
+ if(nItemId)
+ {
localMoveTo(nItemId);
- }
+ }
- mxLocalView->reload();
- if (mxSearchView->IsVisible())
- SearchUpdate();
+ mxLocalView->reload();
+ FilterSearch();
+ }
}
-
-IMPL_LINK_NOARG(SfxTemplateManagerDlg, ExportClickHdl, weld::Button&, void)
+IMPL_LINK_NOARG(SfxTemplateManagerDlg, ExportTemplateHdl, void*, void)
{
OnTemplateExport();
}
-IMPL_LINK_NOARG(SfxTemplateManagerDlg, ImportClickHdl, weld::Button&, void)
+void SfxTemplateManagerDlg::ImportActionHdl()
{
- //Modal Dialog to select Category
- SfxTemplateCategoryDialog aDlg(m_xDialog.get());
- aDlg.SetCategoryLBEntries(mxLocalView->getFolderNames());
-
- if (aDlg.run() == RET_OK)
+ if(mxCBFolder->get_active() == 0)
{
- const OUString& sCategory = aDlg.GetSelectedCategory();
- bool bIsNewCategory = aDlg.IsNewCategoryCreated();
- if(bIsNewCategory)
+ //Modal Dialog to select Category
+ SfxTemplateCategoryDialog aDlg(m_xDialog.get());
+ aDlg.SetCategoryLBEntries(mxLocalView->getFolderNames());
+
+ if (aDlg.run() == RET_OK)
{
- if(mxLocalView->createRegion(sCategory))
+ const OUString& sCategory = aDlg.GetSelectedCategory();
+ bool bIsNewCategory = aDlg.IsNewCategoryCreated();
+ if(bIsNewCategory)
{
- mxCBFolder->append_text(sCategory);
- OnTemplateImportCategory(sCategory);
+ if(mxLocalView->createRegion(sCategory))
+ {
+ mxCBFolder->append_text(sCategory);
+ OnTemplateImportCategory(sCategory);
+ }
+ else
+ {
+ OUString aMsg( SfxResId(STR_CREATE_ERROR) );
+ std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_xDialog.get(),
+ VclMessageType::Warning, VclButtonsType::Ok,
+ aMsg.replaceFirst("$1", sCategory)));
+ xBox->run();
+ return;
+ }
}
else
- {
- OUString aMsg( SfxResId(STR_CREATE_ERROR) );
- std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_xDialog.get(),
- VclMessageType::Warning, VclButtonsType::Ok,
- aMsg.replaceFirst("$1", sCategory)));
- xBox->run();
- return;
- }
+ OnTemplateImportCategory(sCategory);
+
+ mxLocalView->reload();
+ mxLocalView->showAllTemplates();
+ FilterSearch();
+ mxCBApp->set_active(0);
+ mxCBFolder->set_active(0);
+ mxActionBar->set_item_sensitive(MNI_ACTION_RENAME_FOLDER, false);
+ mxActionBar->set_item_sensitive(MNI_ACTION_DELETE_FOLDER, false);
}
- else
- OnTemplateImportCategory(sCategory);
}
-
- mxLocalView->reload();
- mxLocalView->showAllTemplates();
- if (mxSearchView->IsVisible())
- SearchUpdate();
- mxCBApp->set_active(0);
- mxCBFolder->set_active(0);
- mxActionBar->set_item_visible(MNI_ACTION_RENAME_FOLDER, false);
+ else
+ {
+ const auto sCategory = mxCBFolder->get_active_text();
+ OnTemplateImportCategory(sCategory);
+ mxLocalView->reload();
+ FilterSearch();
+ }
}
-IMPL_STATIC_LINK_NOARG(SfxTemplateManagerDlg, LinkClickHdl, weld::Button&, void)
+void SfxTemplateManagerDlg::ExtensionsActionHdl()
{
uno::Sequence<beans::PropertyValue> aArgs(1);
aArgs[0].Name = "AdditionsTag";
@@ -672,13 +683,41 @@ IMPL_LINK_NOARG(SfxTemplateManagerDlg, OpenRegionHdl, void*, void)
IMPL_LINK(SfxTemplateManagerDlg, CreateContextMenuHdl, ThumbnailViewItem*, pItem, void)
{
const TemplateViewItem *pViewItem = dynamic_cast<TemplateViewItem*>(pItem);
+ bool bIsDefault = false;
+ bool bIsInternal = false;
+ std::vector<const TemplateViewItem*> aSelTemplates;
+ for(const auto& aSelTmpl : maSelTemplates)
+ {
+ const TemplateViewItem *aItem = dynamic_cast<const TemplateViewItem*>(aSelTmpl);
+ aSelTemplates.push_back(aItem);
+ }
+
+ for(const auto& aSelTmpl : aSelTemplates)
+ {
+ if(aSelTmpl->IsDefaultTemplate())
+ bIsDefault = true;
+ if(TemplateLocalView::IsInternalTemplate(aSelTmpl->getPath()))
+ {
+ bIsInternal = true;
+ if(bIsDefault)
+ break;
+ }
+ }
if (pViewItem)
{
- if (mxSearchView->IsVisible())
- mxSearchView->createContextMenu(pViewItem->IsDefaultTemplate(), TemplateLocalView::IsInternalTemplate(pViewItem->getPath()));
- else
- mxLocalView->createContextMenu(pViewItem->IsDefaultTemplate(), TemplateLocalView::IsInternalTemplate(pViewItem->getPath()));
+ bool bIsSingleSel = maSelTemplates.size() == 1;
+ OUString aDefaultImg;
+ INetURLObject aUrl(pViewItem->getPath());
+ if (ViewFilter_Application::isFilteredExtension(FILTER_APPLICATION::WRITER, aUrl.getExtension()))
+ aDefaultImg = BMP_ACTION_DEFAULT_WRITER;
+ else if (ViewFilter_Application::isFilteredExtension(FILTER_APPLICATION::CALC, aUrl.getExtension()))
+ aDefaultImg = BMP_ACTION_DEFAULT_CALC;
+ else if (ViewFilter_Application::isFilteredExtension(FILTER_APPLICATION::IMPRESS, aUrl.getExtension()))
+ aDefaultImg = BMP_ACTION_DEFAULT_IMPRESS;
+ else if (ViewFilter_Application::isFilteredExtension(FILTER_APPLICATION::DRAW, aUrl.getExtension()))
+ aDefaultImg = BMP_ACTION_DEFAULT_DRAW;
+ mxLocalView->createContextMenu(bIsDefault, bIsInternal, bIsSingleSel, aDefaultImg);
}
}
@@ -734,26 +773,19 @@ IMPL_LINK(SfxTemplateManagerDlg, EditTemplateHdl, ThumbnailViewItem*, pItem, voi
m_xDialog->response(RET_OK);
}
-IMPL_LINK(SfxTemplateManagerDlg, DeleteTemplateHdl, ThumbnailViewItem*, pItem, void)
+IMPL_LINK_NOARG(SfxTemplateManagerDlg, DeleteTemplateHdl, void*, void)
{
+ std::set<const ThumbnailViewItem*,selection_cmp_fn> aSelTemplates = maSelTemplates;
OUString aDeletedTemplate;
- if(mxSearchView->IsVisible())
- {
- TemplateSearchViewItem *pSrchItem = static_cast<TemplateSearchViewItem*>(pItem);
- if (!mxLocalView->removeTemplate(pSrchItem->mnAssocId, pSrchItem->mnRegionId))
- {
- aDeletedTemplate = pSrchItem->maTitle;
- }
- }
- else
+ for (auto const& pItem : aSelTemplates)
{
- TemplateViewItem *pViewItem = static_cast<TemplateViewItem*>(pItem);
+ const TemplateViewItem *pViewItem = static_cast<const TemplateViewItem*>(pItem);
sal_uInt16 nRegionItemId = mxLocalView->getRegionId(pViewItem->mnRegionId);
if (!mxLocalView->removeTemplate(pViewItem->mnDocId + 1, nRegionItemId))//mnId w.r.t. region is mnDocId + 1;
{
- aDeletedTemplate = pItem->maTitle;
+ aDeletedTemplate += pItem->maTitle+"\n";
}
}
@@ -779,10 +811,7 @@ IMPL_LINK(SfxTemplateManagerDlg, DefaultTemplateHdl, ThumbnailViewItem*, pItem,
OUString sPrevDefault = SfxObjectFactory::GetStandardTemplate( aServiceName );
if(!sPrevDefault.isEmpty())
{
- if(mxSearchView->IsVisible())
- mxSearchView->RemoveDefaultTemplateIcon(sPrevDefault);
- else
- mxLocalView->RemoveDefaultTemplateIcon(sPrevDefault);
+ mxLocalView->RemoveDefaultTemplateIcon(sPrevDefault);
}
SfxObjectFactory::SetStandardTemplate(aServiceName,pViewItem->getPath());
pViewItem->showDefaultIcon(true);
@@ -797,7 +826,7 @@ IMPL_LINK(SfxTemplateManagerDlg, DefaultTemplateHdl, ThumbnailViewItem*, pItem,
}
}
- createDefaultTemplateMenu();
+ updateMenuItems();
}
IMPL_LINK_NOARG(SfxTemplateManagerDlg, SearchUpdateHdl, weld::Entry&, void)
@@ -822,22 +851,12 @@ IMPL_LINK_NOARG(SfxTemplateManagerDlg, LoseFocusHdl, weld::Widget&, void)
IMPL_LINK_NOARG ( SfxTemplateManagerDlg, ListViewHdl, weld::Toggleable&, void )
{
setTemplateViewMode(TemplateViewMode::eListView);
-
- if (mxSearchFilter->get_text().isEmpty())
- mxLocalView->ListView::grab_focus();
- else
- mxSearchView->ListView::grab_focus();
}
IMPL_LINK_NOARG ( SfxTemplateManagerDlg, ThumbnailViewHdl, weld::Toggleable&, void )
{
setTemplateViewMode(TemplateViewMode::eThumbnailView);
bMakeSelItemVisible = true;
-
- if (mxSearchFilter->get_text().isEmpty())
- mxLocalView->ThumbnailView::GrabFocus();
- else
- mxSearchView->ThumbnailView::GrabFocus();
}
IMPL_LINK_NOARG(SfxTemplateManagerDlg, FocusRectLocalHdl, weld::Widget&, tools::Rectangle)
@@ -847,68 +866,43 @@ IMPL_LINK_NOARG(SfxTemplateManagerDlg, FocusRectLocalHdl, weld::Widget&, tools::
bMakeSelItemVisible = false;
return tools::Rectangle();
}
-
-IMPL_LINK_NOARG(SfxTemplateManagerDlg, FocusRectSearchHdl, weld::Widget&, tools::Rectangle)
+void SfxTemplateManagerDlg::FilterSearch()
{
- if(bMakeSelItemVisible && !maSelTemplates.empty())
- mxSearchView->MakeItemVisible((*maSelTemplates.begin())->mnId);
- bMakeSelItemVisible = false;
- return tools::Rectangle();
+ OUString aKeyword = mxSearchFilter->get_text();
+ if (!aKeyword.isEmpty())
+ {
+ mxLocalView->Clear();
+ std::vector<TemplateItemProperties> aItems =
+ mxLocalView->getFilteredItems(SearchView_Keyword(aKeyword, getCurrentApplicationFilter()));
+ mxLocalView->insertItems(aItems, mxCBFolder->get_active()==0, true);
+ mxLocalView->Invalidate();
+ }
}
-
void SfxTemplateManagerDlg::SearchUpdate()
{
OUString aKeyword = mxSearchFilter->get_text();
-
if (!aKeyword.isEmpty())
{
- mxSearchView->Clear();
-
- // if the search view is hidden, hide the folder view and display search one
- if (!mxSearchView->IsVisible())
- {
- mxLocalView->deselectItems();
- mxSearchView->Show();
- mxLocalView->Hide();
- }
-
+ mxLocalView->Clear();
std::vector<TemplateItemProperties> aItems =
mxLocalView->getFilteredItems(SearchView_Keyword(aKeyword, getCurrentApplicationFilter()));
-
- for (const TemplateItemProperties& rItem : aItems)
- {
- OUString aFolderName = mxLocalView->getRegionName(rItem.nRegionId);
-
- mxSearchView->AppendItem(rItem.nId,mxLocalView->getRegionId(rItem.nRegionId),
- rItem.nDocId,
- rItem.aName,
- aFolderName,
- rItem.aPath,
- rItem.aThumbnail);
- }
- mxSearchView->sort();
- mxSearchView->Invalidate();
+ mxLocalView->insertItems(aItems, mxCBFolder->get_active()==0, true);
+ mxLocalView->Invalidate();
}
else
{
- mxSearchView->deselectItems();
- mxSearchView->Hide();
- mxLocalView->Show();
+ mxLocalView->deselectItems();
mxLocalView->filterItems(ViewFilter_Application(getCurrentApplicationFilter()));
mxLocalView->reload();
- if(mxSearchView->IsVisible())
- SearchUpdate();
OUString sLastFolder = mxCBFolder->get_active_text();
mxLocalView->showRegion(sLastFolder);
- mxActionBar->set_item_visible(MNI_ACTION_RENAME_FOLDER, true);
+ mxActionBar->set_item_sensitive(MNI_ACTION_RENAME_FOLDER, true);
}
}
IMPL_LINK_NOARG(SfxTemplateManagerDlg, GetFocusHdl, weld::Widget&, void)
{
mxLocalView->deselectItems();
- mxSearchView->deselectItems();
-
maSelTemplates.clear();
}
@@ -949,13 +943,13 @@ void SfxTemplateManagerDlg::OnTemplateState (const ThumbnailViewItem *pItem)
if(maSelTemplates.empty())
{
- mxMoveButton->set_sensitive(false);
- mxExportButton->set_sensitive(false);
+ mxActionBar->set_item_sensitive(MNI_ACTION_MOVE, false);
+ mxActionBar->set_item_sensitive(MNI_ACTION_EXPORT, false);
}
else
{
- mxMoveButton->set_sensitive(true);
- mxExportButton->set_sensitive(true);
+ mxActionBar->set_item_sensitive(MNI_ACTION_MOVE, true);
+ mxActionBar->set_item_sensitive(MNI_ACTION_EXPORT, true);
}
}
@@ -1067,66 +1061,33 @@ void SfxTemplateManagerDlg::OnTemplateExport()
INetURLObject aPathObj(xFolderPicker->getDirectory());
aPathObj.setFinalSlash();
- if (mxSearchView->IsVisible())
- {
- sal_uInt16 i = 1;
-
- for (auto const& selTemplate : maSelTemplates)
- {
- const TemplateSearchViewItem *pItem = static_cast<const TemplateSearchViewItem*>(selTemplate);
-
- INetURLObject aItemPath(pItem->getPath());
-
- if ( 1 == i )
- aPathObj.Append(aItemPath.getName());
- else
- aPathObj.setName(aItemPath.getName());
-
- OUString aPath = aPathObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
+ // export templates from the current view
- if (!mxLocalView->exportTo(pItem->mnAssocId,pItem->mnRegionId,aPath))
- {
- if (aTemplateList.isEmpty())
- aTemplateList = pItem->maTitle;
- else
- aTemplateList += "\n" + pItem->maTitle;
- }
- ++i;
- }
-
- mxSearchView->deselectItems();
- }
- else
+ sal_uInt16 i = 1;
+ auto aSelTemplates = maSelTemplates;
+ for (auto const& selTemplate : aSelTemplates)
{
- // export templates from the current view
+ const TemplateViewItem *pItem = static_cast<const TemplateViewItem*>(selTemplate);
- sal_uInt16 i = 1;
+ INetURLObject aItemPath(pItem->getPath());
- for (auto const& selTemplate : maSelTemplates)
- {
- const TemplateViewItem *pItem = static_cast<const TemplateViewItem*>(selTemplate);
+ if ( 1 == i )
+ aPathObj.Append(aItemPath.getName());
+ else
+ aPathObj.setName(aItemPath.getName());
- INetURLObject aItemPath(pItem->getPath());
+ OUString aPath = aPathObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
- if ( 1 == i )
- aPathObj.Append(aItemPath.getName());
+ if (!mxLocalView->exportTo(pItem->mnDocId + 1, //mnId w.r.t. region = mDocId + 1
+ mxLocalView->getRegionId(pItem->mnRegionId), //pItem->mnRegionId does not store actual region Id
+ aPath))
+ {
+ if (aTemplateList.isEmpty())
+ aTemplateList = pItem->maTitle;
else
- aPathObj.setName(aItemPath.getName());
-
- OUString aPath = aPathObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
-
- if (!mxLocalView->exportTo(pItem->mnDocId + 1, //mnId w.r.t. region = mDocId + 1
- mxLocalView->getRegionId(pItem->mnRegionId), //pItem->mnRegionId does not store actual region Id
- aPath))
- {
- if (aTemplateList.isEmpty())
- aTemplateList = pItem->maTitle;
- else
- aTemplateList += "\n" + pItem->maTitle;
- }
- ++i;
+ aTemplateList += "\n" + pItem->maTitle;
}
-
+ ++i;
mxLocalView->deselectItems();
}
@@ -1158,7 +1119,7 @@ void SfxTemplateManagerDlg::OnTemplateOpen ()
void SfxTemplateManagerDlg::OnCategoryNew()
{
InputDialog dlg(m_xDialog.get(), SfxResId(STR_INPUT_NEW));
-
+ dlg.set_title(SfxResId(STR_WINDOW_TITLE_RENAME_NEW_CATEGORY));
int ret = dlg.run();
if (!ret)
@@ -1182,7 +1143,7 @@ void SfxTemplateManagerDlg::OnCategoryRename()
{
OUString sCategory = mxCBFolder->get_active_text();
InputDialog dlg(m_xDialog.get(), SfxResId(STR_INPUT_NEW));
-
+ dlg.set_title(SfxResId(STR_WINDOW_TITLE_RENAME_CATEGORY));
dlg.SetEntryText(sCategory);
int ret = dlg.run();
@@ -1213,63 +1174,82 @@ void SfxTemplateManagerDlg::OnCategoryRename()
void SfxTemplateManagerDlg::OnCategoryDelete()
{
- SfxTemplateCategoryDialog aDlg(m_xDialog.get());
- aDlg.SetCategoryLBEntries(mxLocalView->getFolderNames());
- aDlg.HideNewCategoryOption();
- aDlg.set_title(MnemonicGenerator::EraseAllMnemonicChars(SfxResId(STR_CATEGORY_DELETE)));
- aDlg.SetSelectLabelText(SfxResId(STR_CATEGORY_SELECT));
-
- if (aDlg.run() == RET_OK)
- {
- const OUString& sCategory = aDlg.GetSelectedCategory();
- std::unique_ptr<weld::MessageDialog> popupDlg(Application::CreateMessageDialog(m_xDialog.get(),
- VclMessageType::Question, VclButtonsType::YesNo,
- SfxResId(STR_QMSG_SEL_FOLDER_DELETE)));
- if (popupDlg->run() != RET_YES)
- return;
+ const auto sCategory = mxCBFolder->get_active_text();
+ std::unique_ptr<weld::MessageDialog> popupDlg(Application::CreateMessageDialog(m_xDialog.get(),
+ VclMessageType::Question, VclButtonsType::YesNo,
+ SfxResId(STR_QMSG_SEL_FOLDER_DELETE).replaceFirst("$1",sCategory)));
+ if (popupDlg->run() != RET_YES)
+ return;
- sal_Int16 nItemId = mxLocalView->getRegionId(sCategory);
+ sal_Int16 nItemId = mxLocalView->getRegionId(sCategory);
- if (!mxLocalView->removeRegion(nItemId))
- {
- OUString sMsg( SfxResId(STR_MSG_ERROR_DELETE_FOLDER) );
- std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_xDialog.get(),
- VclMessageType::Warning, VclButtonsType::Ok,
- sMsg.replaceFirst("$1",sCategory)));
- xBox->run();
- }
- else
- {
- mxCBFolder->remove_text(sCategory);
- }
+ if (!mxLocalView->removeRegion(nItemId))
+ {
+ OUString sMsg( SfxResId(STR_MSG_ERROR_DELETE_FOLDER) );
+ std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_xDialog.get(),
+ VclMessageType::Warning, VclButtonsType::Ok,
+ sMsg.replaceFirst("$1",sCategory)));
+ xBox->run();
+ }
+ else
+ {
+ mxCBFolder->remove_text(sCategory);
}
mxLocalView->reload();
mxLocalView->showAllTemplates();
mxCBApp->set_active(0);
mxCBFolder->set_active(0);
- mxActionBar->set_item_visible(MNI_ACTION_RENAME_FOLDER, false);
+ mxActionBar->set_item_sensitive(MNI_ACTION_RENAME_FOLDER, false);
+ mxActionBar->set_item_sensitive(MNI_ACTION_DELETE_FOLDER, false);
+ updateMenuItems();
}
-void SfxTemplateManagerDlg::createDefaultTemplateMenu ()
+void SfxTemplateManagerDlg::updateMenuItems ()
{
- std::vector<OUString> aList = lcl_getAllFactoryURLs();
-
- if (!aList.empty())
- {
- mxTemplateDefaultMenu->clear();
- for (auto const& elem : aList)
- {
- INetURLObject aObj(elem);
- OUString aTitle = SvFileInformationManager::GetDescription(aObj);
- mxTemplateDefaultMenu->append(elem, aTitle, SvFileInformationManager::GetImageId(aObj));
- }
+ mxActionBar->set_item_visible(MNI_ACTION_DEFAULT, false);
+ mxActionBar->set_item_visible(MNI_ACTION_DEFAULT_WRITER, false);
+ mxActionBar->set_item_visible(MNI_ACTION_DEFAULT_CALC, false);
+ mxActionBar->set_item_visible(MNI_ACTION_DEFAULT_IMPRESS, false);
+ mxActionBar->set_item_visible(MNI_ACTION_DEFAULT_DRAW, false);
+ mxActionBar->set_item_sensitive(MNI_ACTION_DEFAULT, false);
+ mxActionBar->set_item_sensitive(MNI_ACTION_DEFAULT_WRITER, false);
+ mxActionBar->set_item_sensitive(MNI_ACTION_DEFAULT_CALC, false);
+ mxActionBar->set_item_sensitive(MNI_ACTION_DEFAULT_IMPRESS, false);
+ mxActionBar->set_item_sensitive(MNI_ACTION_DEFAULT_DRAW, false);
+ SvtModuleOptions aModOpt;
+ if( mxCBApp->get_active() == MNI_WRITER)
+ {
+ mxActionBar->set_item_visible(MNI_ACTION_DEFAULT_WRITER, true);
+ if(!aModOpt.GetFactoryStandardTemplate( SvtModuleOptions::EFactory::WRITER).isEmpty())
+ mxActionBar->set_item_sensitive(MNI_ACTION_DEFAULT_WRITER, true);
+ }
+ else if( mxCBApp->get_active() == MNI_CALC )
+ {
+ mxActionBar->set_item_visible(MNI_ACTION_DEFAULT_CALC, true);
+ if(!aModOpt.GetFactoryStandardTemplate( SvtModuleOptions::EFactory::CALC).isEmpty())
+ mxActionBar->set_item_sensitive(MNI_ACTION_DEFAULT_CALC, true);
+ }
+ else if(mxCBApp->get_active() == MNI_IMPRESS)
+ {
+ mxActionBar->set_item_visible(MNI_ACTION_DEFAULT_IMPRESS, true);
+ if(!aModOpt.GetFactoryStandardTemplate( SvtModuleOptions::EFactory::IMPRESS).isEmpty())
+ mxActionBar->set_item_sensitive(MNI_ACTION_DEFAULT_IMPRESS, true);
+ }
+ else if(mxCBApp->get_active() == MNI_DRAW)
+ {
+ mxActionBar->set_item_visible(MNI_ACTION_DEFAULT_DRAW, true);
+ if(!aModOpt.GetFactoryStandardTemplate( SvtModuleOptions::EFactory::DRAW).isEmpty())
+ mxActionBar->set_item_sensitive(MNI_ACTION_DEFAULT_DRAW, true);
+ }
+ else if(mxCBApp->get_active() == MNI_ALL_APPLICATIONS)
+ {
mxActionBar->set_item_visible(MNI_ACTION_DEFAULT, true);
+ if(!lcl_getAllFactoryURLs().empty())
+ mxActionBar->set_item_sensitive(MNI_ACTION_DEFAULT, true);
}
- else
- mxActionBar->set_item_visible(MNI_ACTION_DEFAULT, false);
}
void SfxTemplateManagerDlg::localMoveTo(sal_uInt16 nItemId)
@@ -1282,38 +1262,6 @@ void SfxTemplateManagerDlg::localMoveTo(sal_uInt16 nItemId)
}
}
-void SfxTemplateManagerDlg::localSearchMoveTo(sal_uInt16 nItemId)
-{
- if (nItemId)
- {
- // Move templates to desired folder if for some reason move fails
- // try copying them.
- std::set<const ThumbnailViewItem*,selection_cmp_fn> aSelTemplates = maSelTemplates; //Copy to avoid invalidating an iterator
-
- for (auto const& selTemplate : aSelTemplates)
- {
- const TemplateSearchViewItem *pItem =
- static_cast<const TemplateSearchViewItem*>(selTemplate);
-
- if(!mxLocalView->moveTemplate(pItem,pItem->mnRegionId,nItemId))
- {
- OUString sDst = mxLocalView->getRegionItemName(nItemId);
- OUString sMsg(SfxResId(STR_MSG_ERROR_LOCAL_MOVE));
- sMsg = sMsg.replaceFirst("$1",sDst);
- std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_xDialog.get(),
- VclMessageType::Warning, VclButtonsType::Ok,
- sMsg.replaceFirst( "$2",pItem->maTitle)));
- xBox->run();
- }
- }
- }
-
- // Deselect all items and update search results
- mxSearchView->deselectItems();
-
- SearchUpdateHdl(*mxSearchFilter);
-}
-
static bool lcl_getServiceName ( const OUString &rFileURL, OUString &rName )
{
bool bRet = false;
@@ -1451,18 +1399,13 @@ SfxTemplateSelectionDlg::SfxTemplateSelectionDlg(weld::Window* pParent)
}
mxCBApp->set_sensitive(false);
- mxActionBar->hide();
- mxMoveButton->hide();
- mxExportButton->hide();
+ mxActionBar->show();
mxCBXHideDlg->show();
mxCBXHideDlg->set_active(true);
mxLocalView->setOpenTemplateHdl(LINK(this,SfxTemplateSelectionDlg, OpenTemplateHdl));
- mxSearchView->setOpenTemplateHdl(LINK(this,SfxTemplateSelectionDlg, OpenTemplateHdl));
-
- mxSearchView->SetMultiSelectionEnabled(false);
-
mxOKButton->connect_clicked(LINK(this, SfxTemplateSelectionDlg, OkClickHdl));
+ updateMenuItems();
}
SfxTemplateSelectionDlg::~SfxTemplateSelectionDlg()
diff --git a/sfx2/source/inc/templatesearchview.hxx b/sfx2/source/inc/templatesearchview.hxx
deleted file mode 100644
index c18e5af2797d..000000000000
--- a/sfx2/source/inc/templatesearchview.hxx
+++ /dev/null
@@ -1,99 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-#ifndef INCLUDED_SFX2_SOURCE_INC_TEMPLATESEARCHVIEW_HXX
-#define INCLUDED_SFX2_SOURCE_INC_TEMPLATESEARCHVIEW_HXX
-
-#include <sfx2/thumbnailview.hxx>
-#include <sfx2/listview.hxx>
-
-class TemplateViewItem;
-class PopupMenu;
-class Menu;
-
-class TemplateSearchView final : public ThumbnailView, public ListView
-{
-public:
-
- TemplateSearchView(std::unique_ptr<weld::ScrolledWindow> xWindow,
- std::unique_ptr<weld::Menu> xMenu,
- std::unique_ptr<weld::TreeView> xTreeView);
-
- void setOpenTemplateHdl (const Link<ThumbnailViewItem*, void> &rLink);
-
- void ContextMenuSelectHdl(std::string_view rIdent);
-
- void setCreateContextMenuHdl(const Link<ThumbnailViewItem*,void> &rLink);
-
- void setEditTemplateHdl(const Link<ThumbnailViewItem*,void> &rLink);
-
- void setDeleteTemplateHdl(const Link<ThumbnailViewItem*,void> &rLink);
-
- void setDefaultTemplateHdl(const Link<ThumbnailViewItem*,void> &rLink);
-
- void createContextMenu(const bool bIsDefault, const bool bIsBuiltIn);
-
- void AppendItem(sal_uInt16 nAssocItemId, sal_uInt16 nRegionId, sal_uInt16 nIdx,
- const OUString &rTitle, const OUString &rSubtitle,
- const OUString &rPath, const BitmapEx &rImage );
-
- void setTemplateViewMode ( TemplateViewMode eMode );
-
- void Show() override;
-
- void Hide() override;
-
- void Clear() override;
-
- bool IsVisible() const;
-
- void syncCursor();
-
- void updateSelection();
-
- void connect_focus_rect(const Link<weld::Widget&, tools::Rectangle>& rLink) { GetDrawingArea()->connect_focus_rect(rLink);}
-
- void MakeItemVisible( sal_uInt16 nId ) { ThumbnailView::MakeItemVisible(nId);}
-
- DECL_LINK(RowActivatedHdl, weld::TreeView&, bool);
-
- DECL_LINK(ListViewChangedHdl, weld::TreeView&, void);
-
- DECL_LINK(PopupMenuHdl, const CommandEvent&, bool);
-
- static BitmapEx getDefaultThumbnail( const OUString& rPath );
-
- void RemoveDefaultTemplateIcon(std::u16string_view rPath);
-
-private:
- virtual void OnItemDblClicked(ThumbnailViewItem *pItem) override;
-
- virtual bool MouseButtonDown( const MouseEvent& rMEvt ) override;
-
- virtual bool Command(const CommandEvent& rPos) override;
-
- virtual bool KeyInput( const KeyEvent& rKEvt ) override;
-
- DECL_LINK(KeyPressHdl, const KeyEvent&, bool);
-
- TemplateViewItem *maSelectedItem;
-
- Point maPosition;
-
- Link<ThumbnailViewItem*, void> maOpenTemplateHdl;
- Link<ThumbnailViewItem*, void> maCreateContextMenuHdl;
- Link<ThumbnailViewItem*,void> maEditTemplateHdl;
- Link<ThumbnailViewItem*,void> maDeleteTemplateHdl;
- Link<ThumbnailViewItem*,void> maDefaultTemplateHdl;
- TemplateViewMode mViewMode;
-};
-
-#endif // INCLUDED_SFX2_SOURCE_INC_TEMPLATESEARCHVIEW_HXX
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/uiconfig/ui/templatedlg.ui b/sfx2/uiconfig/ui/templatedlg.ui
index c0ccc4812fd5..51846213a9eb 100644
--- a/sfx2/uiconfig/ui/templatedlg.ui
+++ b/sfx2/uiconfig/ui/templatedlg.ui
@@ -2,39 +2,10 @@
<!-- Generated with glade 3.38.2 -->
<interface domain="sfx">
<requires lib="gtk+" version="3.20"/>
- <object class="GtkMenu" id="contextmenu1">
+ <object class="GtkMenu" id="contextmenu">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
- <object class="GtkMenu" id="contextmenu2">
- <property name="visible">True</property>
- <property name="can-focus">False</property>
- </object>
- <object class="GtkImage" id="image1">
- <property name="visible">True</property>
- <property name="can-focus">False</property>
- <property name="icon-name">sfx2/res/actiontemplates020.png</property>
- </object>
- <object class="GtkImage" id="image3">
- <property name="visible">True</property>
- <property name="can-focus">False</property>
- <property name="icon-name">sfx2/res/actiontemplates017.png</property>
- </object>
- <object class="GtkImage" id="image4">
- <property name="visible">True</property>
- <property name="can-focus">False</property>
- <property name="icon-name">sfx2/res/actionview010.png</property>
- </object>
- <object class="GtkImage" id="image5">
- <property name="visible">True</property>
- <property name="can-focus">False</property>
- <property name="icon-name">cmd/lc_additionsdialog.png</property>
- </object>
- <object class="GtkImage" id="image7">
- <property name="visible">True</property>
- <property name="can-focus">False</property>
- <property name="icon-name">open-menu-symbolic</property>
- </object>
<object class="GtkImage" id="image8">
<property name="visible">True</property>
<property name="can-focus">False</property>
@@ -48,20 +19,6 @@
<object class="GtkMenu" id="menu1">
<property name="visible">True</property>
<property name="can-focus">False</property>
- <child>
- <object class="GtkMenuItem" id="default">
- <property name="visible">True</property>
- <property name="can-focus">False</property>
- <property name="label" translatable="yes" context="colsmenu|insert">Reset Default Template</property>
- <property name="use-underline">True</property>
- <child type="submenu">
- <object class="GtkMenu" id="submenu">
- <property name="visible">True</property>
- <property name="can-focus">False</property>
- </object>
- </child>
- </object>
- </child>
</object>
<object class="GtkTreeStore" id="tree_store">
<columns>
@@ -206,14 +163,24 @@
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
- <object class="GtkToggleButton" id="thumbnail_view_btn">
+ <object class="GtkMenuButton" id="action_menu">
+ <property name="label" translatable="yes" context="templatedlg|action_menu|label">_Manage</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
- <property name="receives-default">True</property>
- <property name="tooltip-text" translatable="yes" context="templatedlg|thumbnail_view_btn|tooltip_text">Thumbnail View</property>
- <property name="image">image8</property>
- <property name="relief">none</property>
+ <property name="receives-default">False</property>
+ <property name="use-underline">True</property>
<property name="always-show-image">True</property>
+ <property name="draw-indicator">True</property>
+ <property name="popup">menu1</property>
+ <property name="use-popover">False</property>
+ <child>
+ <placeholder/>
+ </child>
+ <child internal-child="accessible">
+ <object class="AtkObject" id="action_menu-atkobject">
+ <property name="AtkObject::accessible-description" translatable="yes" context="templatedlg|extended_tip|action_menu">Provides commands to create, rename and delete categories, reset default templates, and refresh the template manager.</property>
+ </object>
+ </child>
</object>
<packing>
<property name="expand">False</property>
@@ -221,22 +188,6 @@
<property name="position">0</property>
</packing>
</child>
- <child>
- <object class="GtkToggleButton" id="list_view_btn">
- <property name="visible">True</property>
- <property name="can-focus">True</property>
- <property name="receives-default">True</property>
- <property name="tooltip-text" translatable="yes" context="templatedlg|list_view_btn|tooltip_text">List View</property>
- <property name="image">image9</property>
- <property name="relief">none</property>
- <property name="always-show-image">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
</object>
<packing>
<property name="expand">False</property>
@@ -368,37 +319,6 @@
<property name="position">0</property>
</packing>
</child>
- <child>
- <object class="GtkScrolledWindow" id="scrollsearch">
- <property name="can-focus">True</property>
- <property name="no-show-all">True</property>
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
- <property name="shadow-type">in</property>
- <child>
- <object class="GtkViewport">
- <property name="visible">True</property>
- <property name="can-focus">False</property>
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
- <child>
- <object class="GtkDrawingArea" id="search_view">
- <property name="can-focus">True</property>
- <property name="events">GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_STRUCTURE_MASK</property>
- <property name="no-show-all">True</property>
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
- </object>
- </child>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
<child>
<object class="GtkScrolledWindow">
<property name="can-focus">True</property>
@@ -516,127 +436,7 @@
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkScrolledWindow">
- <property name="can-focus">True</property>
- <property name="no-show-all">True</property>
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
- <property name="shadow-type">in</property>
- <child>
- <object class="GtkTreeView" id="treesearch_list">
- <property name="can-focus">True</property>
- <property name="no-show-all">True</property>
- <property name="has-tooltip">True</property>
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
- <property name="model">tree_store</property>
- <property name="enable-search">False</property>
- <property name="search-column">0</property>
- <property name="show-expanders">False</property>
- <child internal-child="selection">
- <object class="GtkTreeSelection">
- <property name="mode">multiple</property>
- </object>
- </child>
- <child>
- <object class="GtkTreeViewColumn">
- <child>
- <object class="GtkCellRendererPixbuf" id="cellrenderer7"/>
- <attributes>
- <attribute name="pixbuf">0</attribute>
- </attributes>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkTreeViewColumn" id="treeviewcolumn6">
- <property name="resizable">True</property>
- <property name="spacing">6</property>
- <property name="title" translatable="yes" context="templatedlg|treeviewcolumn1">Name</property>
- <property name="expand">True</property>
- <property name="clickable">True</property>
- <child>
- <object class="GtkCellRendererText" id="cellrenderer8">
- <property name="ypad">3</property>
- </object>
- <attributes>
- <attribute name="text">1</attribute>
- </attributes>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkTreeViewColumn" id="treeviewcolumn7">
- <property name="resizable">True</property>
- <property name="spacing">6</property>
- <property name="title" translatable="yes" context="templatedlg|treeviewcolumn2">Category</property>
- <property name="clickable">True</property>
- <child>
- <object class="GtkCellRendererText" id="cellrenderer9">
- <property name="ypad">3</property>
- </object>
- <attributes>
- <attribute name="text">2</attribute>
- </attributes>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkTreeViewColumn" id="treeviewcolumn8">
- <property name="resizable">True</property>
- <property name="title" translatable="yes" context="templatedlg|treeviewcolumn3">Application</property>
- <property name="clickable">True</property>
- <child>
- <object class="GtkCellRendererText" id="cellrenderer10">
- <property name="ypad">3</property>
- </object>
- <attributes>
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list