summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/sfx2/saveastemplatedlg.hxx68
-rw-r--r--include/sfx2/templateabstractview.hxx32
-rw-r--r--include/sfx2/templatedlg.hxx92
-rw-r--r--include/sfx2/templatelocalview.hxx26
-rw-r--r--include/sfx2/templateremoteview.hxx6
-rw-r--r--sfx2/Library_sfx.mk1
-rw-r--r--sfx2/UIConfig_sfx.mk2
-rw-r--r--sfx2/source/control/templateabstractview.cxx135
-rw-r--r--sfx2/source/control/templatedefaultview.cxx14
-rw-r--r--sfx2/source/control/templatelocalview.cxx387
-rw-r--r--sfx2/source/control/templateremoteview.cxx15
-rw-r--r--sfx2/source/control/templatesearchview.cxx91
-rw-r--r--sfx2/source/dialog/backingwindow.cxx2
-rw-r--r--sfx2/source/doc/doc.hrc14
-rw-r--r--sfx2/source/doc/doc.src53
-rw-r--r--sfx2/source/doc/objserv.cxx6
-rw-r--r--sfx2/source/doc/saveastemplatedlg.cxx169
-rw-r--r--sfx2/source/doc/templatedlg.cxx1133
-rw-r--r--sfx2/source/inc/templatesearchview.hxx25
-rw-r--r--sfx2/uiconfig/ui/saveastemplatedlg.ui147
-rw-r--r--sfx2/uiconfig/ui/templatecategorydlg.ui147
-rw-r--r--sfx2/uiconfig/ui/templatedlg.ui578
22 files changed, 1770 insertions, 1373 deletions
diff --git a/include/sfx2/saveastemplatedlg.hxx b/include/sfx2/saveastemplatedlg.hxx
new file mode 100644
index 000000000000..691d4f0e48ea
--- /dev/null
+++ b/include/sfx2/saveastemplatedlg.hxx
@@ -0,0 +1,68 @@
+/* -*- 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_INC_SAVEASTEMPLATEDLG_HXX
+#define INCLUDED_SFX2_INC_SAVEASTEMPLATEDLG_HXX
+
+#include <sal/config.h>
+#include <sfx2/dllapi.h>
+
+#include <vcl/dialog.hxx>
+#include <vcl/button.hxx>
+
+class Edit;
+class ListBox;
+class SfxDocumentTemplates;
+
+// class SfxSaveAsTemplateDialog -------------------------------------------------------------------
+
+class SFX2_DLLPUBLIC SfxSaveAsTemplateDialog : public ModalDialog
+{
+
+private:
+ VclPtr<ListBox> mpLBCategory;
+ VclPtr<Edit> mpTemplateNameEdit;
+ VclPtr<PushButton> mpOKButton;
+
+ OUString msSelectedCategory;
+ OUString msTemplateName;
+ sal_uInt16 mnRegionPos;
+
+ std::vector<OUString> msCategories;
+
+ SfxDocumentTemplates *mpDocTemplates;
+
+ css::uno::Reference< css::frame::XModel > m_xModel;
+
+public:
+ DECL_LINK_TYPED(OkClickHdl, Button*, void);
+ DECL_LINK_TYPED(TemplateNameEditHdl, Edit&, void);
+ DECL_LINK_TYPED(SelectCategoryHdl, ListBox&, void);
+
+ void setDocumentModel (const css::uno::Reference<css::frame::XModel> &rModel);
+
+ void initialize();
+ void SetCategoryLBEntries(std::vector<OUString> names);
+
+ /*Check whether template name is unique or not in a region*/
+ bool IsTemplateNameUnique();
+
+ bool SaveTemplate();
+
+public:
+
+ explicit SfxSaveAsTemplateDialog(vcl::Window *parent = nullptr);
+
+ virtual ~SfxSaveAsTemplateDialog();
+ virtual void dispose() override;
+};
+
+#endif // INCLUDED_SFX2_INC_SAVEASTEMPLATEDLG_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/sfx2/templateabstractview.hxx b/include/sfx2/templateabstractview.hxx
index 81d0a96f4e80..2d6ad72f8cec 100644
--- a/include/sfx2/templateabstractview.hxx
+++ b/include/sfx2/templateabstractview.hxx
@@ -30,6 +30,7 @@
#define TEMPLATE_THUMBNAIL_MAX_WIDTH TEMPLATE_ITEM_MAX_WIDTH - 2*TEMPLATE_ITEM_PADDING
class SfxDocumentTemplates;
+class TemplateViewItem;
enum class FILTER_APPLICATION
{
@@ -81,18 +82,14 @@ public:
virtual void reload () { }
- virtual void showRootRegion () = 0;
+ virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
+
+ virtual void showAllTemplates () = 0;
virtual void showRegion (ThumbnailViewItem *pItem) = 0;
virtual sal_uInt16 createRegion (const OUString &rName) = 0;
- // Return if we can have regions inside the current region
- virtual bool isNestedRegionAllowed () const = 0;
-
- // Return if we can import templates to the current region
- virtual bool isImportAllowed () const = 0;
-
sal_uInt16 getCurRegionId () const { return mnCurRegionId;}
const OUString& getCurRegionName () const { return maCurRegionName;}
@@ -102,8 +99,16 @@ public:
void setOpenRegionHdl(const Link<void*,void> &rLink);
+ void setRightClickHdl(const Link<ThumbnailViewItem*,void> &rLink);
+
void setOpenTemplateHdl(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 updateThumbnailDimensions(long itemMaxSize);
long getThumbnailWidth() const { return mnThumbnailWidth;}
@@ -117,25 +122,26 @@ public:
protected:
- DECL_LINK_TYPED(ShowRootRegionHdl, Button*, void);
-
virtual void OnItemDblClicked(ThumbnailViewItem *pItem) override;
- virtual void Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect) override;
-
protected:
sal_uInt16 mnCurRegionId;
OUString maCurRegionName;
+ TemplateViewItem *maSelectedItem;
+
long mnThumbnailWidth;
long mnThumbnailHeight;
- VclPtr<PushButton> maAllButton;
- VclPtr<FixedText> maFTName;
+ Point maPosition;
Link<void*,void> maOpenRegionHdl;
+ Link<ThumbnailViewItem*,void> maRightClickHdl;
Link<ThumbnailViewItem*,void> maOpenTemplateHdl;
+ Link<ThumbnailViewItem*,void> maEditTemplateHdl;
+ Link<ThumbnailViewItem*,void> maDeleteTemplateHdl;
+ Link<ThumbnailViewItem*,void> maDefaultTemplateHdl;
};
#endif // INCLUDED_SFX2_TEMPLATEABSTRACTVIEW_HXX
diff --git a/include/sfx2/templatedlg.hxx b/include/sfx2/templatedlg.hxx
index 74d7e0953976..12793ff9319c 100644
--- a/include/sfx2/templatedlg.hxx
+++ b/include/sfx2/templatedlg.hxx
@@ -17,8 +17,6 @@
#include <vcl/dialog.hxx>
#include <vcl/button.hxx>
-#include <vcl/tabctrl.hxx>
-#include <vcl/tabpage.hxx>
#include <com/sun/star/frame/XDesktop2.hpp>
#include <sfx2/templateabstractview.hxx>
@@ -52,55 +50,55 @@ public:
virtual ~SfxTemplateManagerDlg();
virtual void dispose() override;
- void setSaveMode();
-
void setDocumentModel (const css::uno::Reference<css::frame::XModel> &rModel);
- DECL_LINK_TYPED(ActivatePageHdl, TabControl*, void);
-
private:
void readSettings ();
void writeSettings ();
- DECL_LINK_TYPED(TBXViewHdl, ToolBox*, void);
- DECL_LINK_TYPED(TBXActionHdl, ToolBox*, void);
- DECL_LINK_TYPED(TBXTemplateHdl, ToolBox*, void);
+ void fillFolderComboBox();
+
DECL_LINK_TYPED(TBXDropdownHdl, ToolBox*, void);
+ DECL_LINK_TYPED(SelectApplicationHdl, ListBox&, void);
+ DECL_LINK_TYPED(SelectRegionHdl, ListBox&, void);
+
DECL_LINK_TYPED(OkClickHdl, Button*, void);
+ DECL_LINK_TYPED(MoveClickHdl, Button*, void);
+ DECL_LINK_TYPED(ExportClickHdl, Button*, void);
+ DECL_LINK_TYPED(ImportClickHdl, Button*, void);
+ DECL_LINK_TYPED(LinkClickHdl, Button*, void);
DECL_LINK_TYPED(TVItemStateHdl, const ThumbnailViewItem*, void);
DECL_LINK_TYPED(MenuSelectHdl, Menu*, bool);
- DECL_LINK_TYPED(MoveMenuSelectHdl, Menu*, bool);
DECL_LINK_TYPED(RepositoryMenuSelectHdl, Menu*, bool);
DECL_LINK_TYPED(DefaultTemplateMenuSelectHdl, Menu*, bool);
DECL_LINK_TYPED(OpenRegionHdl, void*, void);
+ DECL_LINK_TYPED(RightClickHdl, ThumbnailViewItem*, void);
DECL_LINK_TYPED(OpenTemplateHdl, ThumbnailViewItem*, void);
+ DECL_LINK_TYPED(EditTemplateHdl, ThumbnailViewItem*, void);
+ DECL_LINK_TYPED(DeleteTemplateHdl, ThumbnailViewItem*, void);
+ DECL_LINK_TYPED(DefaultTemplateHdl, ThumbnailViewItem*, void);
DECL_LINK_TYPED(SearchUpdateHdl, Edit&, void);
- void OnTemplateImport ();
- void OnTemplateSearch ();
+ void OnTemplateImportCategory(OUString sCategory);
static void OnTemplateLink ();
void OnTemplateOpen ();
- void OnTemplateEdit ();
- void OnTemplateDelete ();
- void OnTemplateAsDefault ();
void OnTemplateExport ();
void OnTemplateState (const ThumbnailViewItem *pItem);
- void OnFolderNew ();
- void OnFolderDelete ();
+ void OnCategoryNew ();
+ void OnCategoryDelete();
void OnRegionState (const ThumbnailViewItem *pItem);
void OnRepositoryDelete ();
- void OnTemplateSaveAs ();
void createRepositoryMenu ();
@@ -138,18 +136,22 @@ private:
void syncRepositories () const;
- /// Return filter according to the currently selected tab page.
- FILTER_APPLICATION getCurrentFilter();
+ /// Return filter according to the currently selected application filter.
+ FILTER_APPLICATION getCurrentApplicationFilter();
private:
- VclPtr<TabControl> mpTabControl;
+ VclPtr<Edit> mpSearchFilter;
+ VclPtr<ListBox> mpCBApp;
+ VclPtr<ListBox> mpCBFolder;
- VclPtr<Edit> mpSearchEdit;
VclPtr<PushButton> mpOKButton;
+ VclPtr<PushButton> mpMoveButton;
+ VclPtr<PushButton> mpExportButton;
+ VclPtr<PushButton> mpImportButton;
+ VclPtr<PushButton> mpLinkButton;
VclPtr<ToolBox> mpViewBar;
VclPtr<ToolBox> mpActionBar;
- VclPtr<ToolBox> mpTemplateBar;
VclPtr<TemplateSearchView> mpSearchView;
VclPtr<TemplateAbstractView> mpCurView;
VclPtr<TemplateLocalView> mpLocalView;
@@ -159,9 +161,7 @@ private:
PopupMenu *mpTemplateDefaultMenu;
std::set<const ThumbnailViewItem*,selection_cmp_fn> maSelTemplates;
- std::set<const ThumbnailViewItem*,selection_cmp_fn> maSelFolders;
- bool mbIsSaveMode; ///< Flag that indicates if we are in save mode or not.
css::uno::Reference< css::frame::XModel > m_xModel;
css::uno::Reference< css::frame::XDesktop2 > mxDesktop;
@@ -169,6 +169,48 @@ private:
std::vector<TemplateRepository*> maRepositories; ///< Stores the remote repositories for templates
};
+// class SfxTemplateCategoryDialog -------------------------------------------------------------------
+
+class SFX2_DLLPUBLIC SfxTemplateCategoryDialog : public ModalDialog
+{
+private:
+ VclPtr<ListBox> mpLBCategory;
+ VclPtr<FixedText> mpSelectLabel;
+ VclPtr<Edit> mpNewCategoryEdit;
+ VclPtr<FixedText> mpCreateLabel;
+ VclPtr<PushButton> mpOKButton;
+
+ OUString msSelectedCategory;
+ bool mbIsNewCategory;
+
+public:
+ DECL_LINK_TYPED(NewCategoryEditHdl, Edit&, void);
+ DECL_LINK_TYPED(SelectCategoryHdl, ListBox&, void);
+
+ void SetCategoryLBEntries(std::vector<OUString> names);
+
+ void HideNewCategoryOption();
+
+ inline OUString GetSelectedCategory() const {
+ return msSelectedCategory;
+ };
+
+ inline void SetSelectLabelText(OUString sText) const {
+ mpSelectLabel->SetText(sText);
+ };
+
+ inline bool IsNewCategoryCreated() const {
+ return mbIsNewCategory;
+ }
+
+public:
+
+ explicit SfxTemplateCategoryDialog(vcl::Window *parent = nullptr);
+
+ virtual ~SfxTemplateCategoryDialog();
+ virtual void dispose() override;
+};
+
#endif // INCLUDED_SFX2_INC_TEMPLATEDLG_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/sfx2/templatelocalview.hxx b/include/sfx2/templatelocalview.hxx
index 60c0780620b1..49e0c8e4796a 100644
--- a/include/sfx2/templatelocalview.hxx
+++ b/include/sfx2/templatelocalview.hxx
@@ -17,6 +17,7 @@
class SfxDocumentTemplates;
class TemplateContainerItem;
+class PopupMenu;
namespace com {
namespace sun { namespace star { namespace frame {
@@ -40,16 +41,24 @@ public:
virtual void reload () override;
- virtual void showRootRegion () override;
+ virtual void showAllTemplates () override;
virtual void showRegion (ThumbnailViewItem *pItem) override;
void showRegion (const OUString &rName);
+ void createContextMenu();
+
+ DECL_LINK_TYPED(ContextMenuSelectHdl, Menu*, bool);
+
sal_uInt16 getCurRegionItemId () const;
+ ThumbnailViewItem* getRegion(OUString sStr);
+
sal_uInt16 getRegionId (size_t pos) const;
+ sal_uInt16 getRegionId (OUString sRegionName) const;
+
OUString getRegionName(const sal_uInt16 nRegionId) const;
OUString getRegionItemName(const sal_uInt16 nItemId) const;
@@ -61,10 +70,6 @@ public:
virtual sal_uInt16 createRegion (const OUString &rName) override;
- virtual bool isNestedRegionAllowed () const override;
-
- virtual bool isImportAllowed () const override;
-
bool removeRegion (const sal_uInt16 nItemId);
bool removeTemplate (const sal_uInt16 nItemId, const sal_uInt16 nSrcItemId);
@@ -83,22 +88,13 @@ public:
bool exportTo (const sal_uInt16 nItemId, const sal_uInt16 nRegionItemId, const OUString &rName);
- bool saveTemplateAs (sal_uInt16 nItemId,
- css::uno::Reference<css::frame::XModel> &rModel,
- const OUString &rName);
-
- bool saveTemplateAs (TemplateContainerItem *pDstItem,
- css::uno::Reference<css::frame::XModel> &rModel,
- const OUString &rName);
-
- bool isTemplateNameUnique (const sal_uInt16 nRegionItemId, const OUString &rName) const;
-
virtual bool renameItem(ThumbnailViewItem* pItem, const OUString& sNewTitle) override;
private:
SfxDocumentTemplates *mpDocTemplates;
std::vector<TemplateContainerItem* > maRegions;
+ std::vector<TemplateItemProperties > maAllTemplates;
};
#endif // INCLUDED_SFX2_TEMPLATELOCALVIEW_HXX
diff --git a/include/sfx2/templateremoteview.hxx b/include/sfx2/templateremoteview.hxx
index 0ae34bc7aee4..854a6c5a639b 100644
--- a/include/sfx2/templateremoteview.hxx
+++ b/include/sfx2/templateremoteview.hxx
@@ -23,7 +23,7 @@ public:
TemplateRemoteView (vcl::Window *pParent, WinBits nWinStyle, bool bDisableTransientChildren);
- virtual void showRootRegion () override;
+ virtual void showAllTemplates () override;
virtual void showRegion (ThumbnailViewItem *pItem) override;
@@ -31,10 +31,6 @@ public:
virtual sal_uInt16 createRegion (const OUString &rName) override;
- virtual bool isNestedRegionAllowed () const override;
-
- virtual bool isImportAllowed () const override;
-
private:
css::uno::Reference< css::ucb::XCommandEnvironment > m_xCmdEnv;
diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk
index 820c17c18d2a..9aca9d7f058c 100644
--- a/sfx2/Library_sfx.mk
+++ b/sfx2/Library_sfx.mk
@@ -233,6 +233,7 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\
sfx2/source/doc/syspath \
sfx2/source/doc/zoomitem \
sfx2/source/doc/templatedlg \
+ sfx2/source/doc/saveastemplatedlg \
sfx2/source/explorer/nochaos \
sfx2/source/inet/inettbc \
sfx2/source/notebookbar/SfxNotebookBar \
diff --git a/sfx2/UIConfig_sfx.mk b/sfx2/UIConfig_sfx.mk
index 5e90b5af6590..a7f532dce520 100644
--- a/sfx2/UIConfig_sfx.mk
+++ b/sfx2/UIConfig_sfx.mk
@@ -44,6 +44,8 @@ $(eval $(call gb_UIConfig_add_uifiles,sfx,\
sfx2/uiconfig/ui/singletabdialog \
sfx2/uiconfig/ui/startcenter \
sfx2/uiconfig/ui/templatedlg \
+ sfx2/uiconfig/ui/saveastemplatedlg \
+ sfx2/uiconfig/ui/templatecategorydlg \
sfx2/uiconfig/ui/versionsofdialog \
sfx2/uiconfig/ui/versioncommentdialog \
sfx2/uiconfig/ui/versionscmis \
diff --git a/sfx2/source/control/templateabstractview.cxx b/sfx2/source/control/templateabstractview.cxx
index b202fb614299..ff39a2562ebf 100644
--- a/sfx2/source/control/templateabstractview.cxx
+++ b/sfx2/source/control/templateabstractview.cxx
@@ -10,9 +10,9 @@
#include <sfx2/templateabstractview.hxx>
#include <comphelper/processfactory.hxx>
-#include <sfx2/sfxresid.hxx>
#include <sfx2/templatecontaineritem.hxx>
#include <sfx2/templateviewitem.hxx>
+#include <sfx2/sfxresid.hxx>
#include <tools/urlobj.hxx>
#include <unotools/ucbstreamhelper.hxx>
#include <vcl/pngread.hxx>
@@ -71,80 +71,27 @@ bool ViewFilter_Application::operator () (const ThumbnailViewItem *pItem)
if (pTempItem)
return isValid(pTempItem->getPath());
- TemplateContainerItem *pContainerItem = const_cast<TemplateContainerItem*>(dynamic_cast<const TemplateContainerItem*>(pItem));
- if (pContainerItem)
- {
- std::vector<TemplateItemProperties> &rTemplates = pContainerItem->maTemplates;
-
- size_t nVisCount = 0;
-
- // Clear thumbnails
- pContainerItem->maPreview1.Clear();
- pContainerItem->maPreview2.Clear();
- pContainerItem->maPreview3.Clear();
- pContainerItem->maPreview4.Clear();
-
- for (size_t i = 0, n = rTemplates.size(); i < n && pContainerItem->HasMissingPreview(); ++i)
- {
- if (isValid(rTemplates[i].aPath))
- {
- ++nVisCount;
- if ( pContainerItem->maPreview1.IsEmpty( ) )
- {
- pContainerItem->maPreview1 = TemplateAbstractView::scaleImg(rTemplates[i].aThumbnail,
- TEMPLATE_THUMBNAIL_MAX_WIDTH*0.75,
- TEMPLATE_THUMBNAIL_MAX_HEIGHT*0.75);
- }
- else if ( pContainerItem->maPreview2.IsEmpty() )
- {
- pContainerItem->maPreview2 = TemplateAbstractView::scaleImg(rTemplates[i].aThumbnail,
- TEMPLATE_THUMBNAIL_MAX_WIDTH*0.75,
- TEMPLATE_THUMBNAIL_MAX_HEIGHT*0.75);
- }
- else if ( pContainerItem->maPreview3.IsEmpty() )
- {
- pContainerItem->maPreview3 = TemplateAbstractView::scaleImg(rTemplates[i].aThumbnail,
- TEMPLATE_THUMBNAIL_MAX_WIDTH*0.75,
- TEMPLATE_THUMBNAIL_MAX_HEIGHT*0.75);
- }
- else if ( pContainerItem->maPreview4.IsEmpty() )
- {
- pContainerItem->maPreview4 = TemplateAbstractView::scaleImg(rTemplates[i].aThumbnail,
- TEMPLATE_THUMBNAIL_MAX_WIDTH*0.75,
- TEMPLATE_THUMBNAIL_MAX_HEIGHT*0.75);
- }
- }
- }
- }
return true;
}
TemplateAbstractView::TemplateAbstractView (vcl::Window *pParent, WinBits nWinStyle, bool bDisableTransientChildren)
: ThumbnailView(pParent,nWinStyle,bDisableTransientChildren),
mnCurRegionId(0),
+ maSelectedItem(nullptr),
mnThumbnailWidth(TEMPLATE_THUMBNAIL_MAX_WIDTH),
mnThumbnailHeight(TEMPLATE_THUMBNAIL_MAX_HEIGHT),
- maAllButton(VclPtr<PushButton>::Create(this, SfxResId(BTN_ALL_TEMPLATES))),
- maFTName(VclPtr<FixedText>::Create(this, SfxResId(FT_NAME)))
+ maPosition(0,0)
{
- maAllButton->Hide();
- maAllButton->SetStyle(maAllButton->GetStyle() | WB_FLATBUTTON);
- maAllButton->SetClickHdl(LINK(this,TemplateAbstractView,ShowRootRegionHdl));
- maFTName->Hide();
}
TemplateAbstractView::TemplateAbstractView(vcl::Window *pParent)
: ThumbnailView(pParent),
mnCurRegionId(0),
+ maSelectedItem(nullptr),
mnThumbnailWidth(TEMPLATE_THUMBNAIL_MAX_WIDTH),
mnThumbnailHeight(TEMPLATE_THUMBNAIL_MAX_HEIGHT),
- maAllButton(VclPtr<PushButton>::Create(this, SfxResId(BTN_ALL_TEMPLATES))),
- maFTName(VclPtr<FixedText>::Create(this, SfxResId(FT_NAME)))
+ maPosition(0,0)
{
- maAllButton->Hide();
- maAllButton->SetStyle(maAllButton->GetStyle() | WB_FLATBUTTON);
- maAllButton->SetClickHdl(LINK(this,TemplateAbstractView,ShowRootRegionHdl));
- maFTName->Hide();
}
TemplateAbstractView::~TemplateAbstractView()
@@ -154,8 +101,6 @@ TemplateAbstractView::~TemplateAbstractView()
void TemplateAbstractView::dispose()
{
- maAllButton.disposeAndClear();
- maFTName.disposeAndClear();
ThumbnailView::dispose();
}
@@ -187,7 +132,6 @@ void TemplateAbstractView::insertItems(const std::vector<TemplateItemProperties>
std::vector<ThumbnailViewItem*> aItems(rTemplates.size());
for (size_t i = 0, n = rTemplates.size(); i < n; ++i )
{
- //TODO: CHECK IF THE ITEM IS A FOLDER OR NOT
const TemplateItemProperties *pCur = &rTemplates[i];
TemplateViewItem *pChild = new TemplateViewItem(*this, pCur->nId);
@@ -215,16 +159,58 @@ void TemplateAbstractView::updateThumbnailDimensions(long itemMaxSize)
mnThumbnailHeight = itemMaxSize;
}
+
+void TemplateAbstractView::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ if (rMEvt.IsRight())
+ {
+ size_t nPos = ImplGetItem(rMEvt.GetPosPixel());
+ Point aPosition (rMEvt.GetPosPixel());
+ maPosition = aPosition;
+ ThumbnailViewItem* pItem = ImplGetItem(nPos);
+ const TemplateViewItem *pViewItem = dynamic_cast<const TemplateViewItem*>(pItem);
+
+ if(pViewItem)
+ {
+ maSelectedItem = dynamic_cast<TemplateViewItem*>(pItem);
+ maRightClickHdl.Call(pItem);
+ }
+ }
+
+ ThumbnailView::MouseButtonDown(rMEvt);
+}
+
+
void TemplateAbstractView::setOpenRegionHdl(const Link<void*,void> &rLink)
{
maOpenRegionHdl = rLink;
}
+void TemplateAbstractView::setRightClickHdl(const Link<ThumbnailViewItem*,void> &rLink)
+{
+ maRightClickHdl = rLink;
+}
+
void TemplateAbstractView::setOpenTemplateHdl(const Link<ThumbnailViewItem*,void> &rLink)
{
maOpenTemplateHdl = rLink;
}
+void TemplateAbstractView::setEditTemplateHdl(const Link<ThumbnailViewItem*,void> &rLink)
+{
+ maEditTemplateHdl = rLink;
+}
+
+void TemplateAbstractView::setDeleteTemplateHdl(const Link<ThumbnailViewItem*,void> &rLink)
+{
+ maDeleteTemplateHdl = rLink;
+}
+
+void TemplateAbstractView::setDefaultTemplateHdl(const Link<ThumbnailViewItem*,void> &rLink)
+{
+ maDefaultTemplateHdl = rLink;
+}
+
BitmapEx TemplateAbstractView::scaleImg (const BitmapEx &rImg, long width, long height)
{
BitmapEx aImg = rImg;
@@ -271,11 +257,6 @@ BitmapEx TemplateAbstractView::fetchThumbnail (const OUString &msURL, long width
return TemplateAbstractView::scaleImg(ThumbnailView::readThumbnail(msURL), width, height);
}
-IMPL_LINK_NOARG_TYPED(TemplateAbstractView, ShowRootRegionHdl, Button*, void)
-{
- showRootRegion();
-}
-
void TemplateAbstractView::OnItemDblClicked (ThumbnailViewItem *pItem)
{
//Check if the item is a TemplateContainerItem (Folder) or a TemplateViewItem (File)
@@ -284,10 +265,8 @@ void TemplateAbstractView::OnItemDblClicked (ThumbnailViewItem *pItem)
if ( pContainerItem )
{
// Fill templates
-
mnCurRegionId = pContainerItem->mnRegionId+1;
maCurRegionName = pContainerItem->maTitle;
- maFTName->SetText(maCurRegionName);
showRegion(pItem);
}
else
@@ -296,24 +275,4 @@ void TemplateAbstractView::OnItemDblClicked (ThumbnailViewItem *pItem)
}
}
-void TemplateAbstractView::Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect)
-{
- ThumbnailView::Paint(rRenderContext, rRect);
-
- Rectangle aRect(rRect.TopLeft(),
- Point(rRect.BottomRight().X(),
- mnHeaderHeight));
-
- drawinglayer::primitive2d::Primitive2DContainer aSeq(1);
- aSeq[0] = drawinglayer::primitive2d::Primitive2DReference(
- new PolyPolygonColorPrimitive2D(B2DPolyPolygon(::tools::Polygon(aRect).getB2DPolygon()),
- maFillColor.getBColor()));
-
- const drawinglayer::geometry::ViewInformation2D aNewViewInfos;
- std::unique_ptr<drawinglayer::processor2d::BaseProcessor2D> pProcessor(
- drawinglayer::processor2d::createBaseProcessor2DFromOutputDevice(rRenderContext, aNewViewInfos));
-
- pProcessor->process(aSeq);
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/control/templatedefaultview.cxx b/sfx2/source/control/templatedefaultview.cxx
index aad2187e7401..63c2e7148166 100644
--- a/sfx2/source/control/templatedefaultview.cxx
+++ b/sfx2/source/control/templatedefaultview.cxx
@@ -19,7 +19,7 @@ VCL_BUILDER_FACTORY(TemplateDefaultView)
TemplateDefaultView::TemplateDefaultView( Window* pParent)
: TemplateLocalView(pParent)
, mnTextHeight(30)
- , mnItemPadding(5)
+ , mnItemPadding(5)//TODO:: Change padding to 10. It looks really crowded and occupied.
{
Rectangle aScreen = Application::GetScreenPosSizePixel(Application::GetDisplayBuiltInScreen());
mnItemMaxSize = std::min(aScreen.GetWidth(),aScreen.GetHeight()) > 800 ? 256 : 192;
@@ -32,18 +32,6 @@ TemplateDefaultView::TemplateDefaultView( Window* pParent)
maHighlightColor = Color(officecfg::Office::Common::Help::StartCenter::StartCenterThumbnailsHighlightColor::get());
maHighlightTextColor = Color(officecfg::Office::Common::Help::StartCenter::StartCenterThumbnailsHighlightTextColor::get());
mfHighlightTransparence = 0.25;
-
-
- maAllButton->SetControlForeground(maTextColor);
- maFTName->SetControlForeground(maTextColor);
-
- // TODO - convert the TemplateAbstractView to .ui (instead of fixed layout
- // of the button and the fixed text), and do the following:
- // const float fMultiplier = 1.4;
- // vcl::Font aFont(maAllButton->GetSettings().GetStyleSettings().GetPushButtonFont());
- // aFont.SetSize(Size(0, aFont.GetSize().Height() * fMultiplier));
- // maAllButton->SetControlFont(aFont);
- // maFTName->SetControlFont(aFont);
}
void TemplateDefaultView::reload()
diff --git a/sfx2/source/control/templatelocalview.cxx b/sfx2/source/control/templatelocalview.cxx
index 5481475403d6..7e84c5e26366 100644
--- a/sfx2/source/control/templatelocalview.cxx
+++ b/sfx2/source/control/templatelocalview.cxx
@@ -10,7 +10,10 @@
#include <sfx2/templatelocalview.hxx>
#include <comphelper/processfactory.hxx>
+#include <comphelper/string.hxx>
#include <sfx2/doctempl.hxx>
+#include <sfx2/inputdlg.hxx>
+#include <sfx2/sfxresid.hxx>
#include <sfx2/templatecontaineritem.hxx>
#include <sfx2/templateviewitem.hxx>
#include <svl/inettype.hxx>
@@ -27,11 +30,17 @@
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include "../doc/doc.hrc"
+
+#define MNI_OPEN 1
+#define MNI_EDIT 2
+#define MNI_DEFAULT_TEMPLATE 3
+#define MNI_DELETE 4
+#define MNI_RENAME 5
+
using namespace ::com::sun::star;
using namespace ::com::sun::star::frame;
-static void lcl_updateThumbnails (TemplateContainerItem *pItem);
-
TemplateLocalView::TemplateLocalView ( vcl::Window* pParent)
: TemplateAbstractView(pParent),
mpDocTemplates(new SfxDocumentTemplates)
@@ -52,6 +61,8 @@ void TemplateLocalView::dispose()
maRegions.clear();
+ maAllTemplates.clear();
+
delete mpDocTemplates;
TemplateAbstractView::dispose();
}
@@ -63,6 +74,8 @@ void TemplateLocalView::Populate ()
maRegions.clear();
+ maAllTemplates.clear();
+
sal_uInt16 nCount = mpDocTemplates->GetRegionCount();
for (sal_uInt16 i = 0; i < nCount; ++i)
{
@@ -91,10 +104,9 @@ void TemplateLocalView::Populate ()
getThumbnailHeight());
pItem->maTemplates.push_back(aProperties);
+ maAllTemplates.push_back(aProperties);
}
- lcl_updateThumbnails(pItem);
-
maRegions.push_back(pItem);
}
}
@@ -120,44 +132,25 @@ void TemplateLocalView::reload ()
}
}
else
- showRootRegion();
+ showAllTemplates();
+
+ //No items should be selected by default
+ deselectItems();
}
-void TemplateLocalView::showRootRegion()
+void TemplateLocalView::showAllTemplates()
{
- mnHeaderHeight = 0;
mnCurRegionId = 0;
maCurRegionName.clear();
- // Clone root region items so they don't get invalidated when we open another region
- std::vector<ThumbnailViewItem*> items(maRegions.size());
- for (int i = 0, n = maRegions.size(); i < n; ++i)
- {
- TemplateContainerItem *pCur = maRegions[i];
- TemplateContainerItem *pItem = new TemplateContainerItem(*this, pCur->mnId);
- pItem->mnRegionId = pCur->mnRegionId;
- pItem->maTitle = pCur->maTitle;
- pItem->maTemplates = pCur->maTemplates;
-
- items[i] = pItem;
- }
-
- maAllButton->Show(false);
- maFTName->Show(false);
-
- updateItems(items);
-
+ insertItems(maAllTemplates);
maOpenRegionHdl.Call(nullptr);
}
void TemplateLocalView::showRegion(ThumbnailViewItem *pItem)
{
- mnHeaderHeight = maAllButton->GetSizePixel().getHeight() + maAllButton->GetPosPixel().Y() * 2;
-
mnCurRegionId = static_cast<TemplateContainerItem*>(pItem)->mnRegionId+1;
maCurRegionName = pItem->maTitle;
- maAllButton->Show();
- maFTName->Show();
insertItems(reinterpret_cast<TemplateContainerItem*>(pItem)->maTemplates);
@@ -170,13 +163,81 @@ void TemplateLocalView::showRegion(const OUString &rName)
{
if (pRegion->maTitle == rName)
{
- maFTName->SetText(rName);
showRegion(pRegion);
break;
}
}
}
+ThumbnailViewItem* TemplateLocalView::getRegion(OUString rName)
+{
+ for (TemplateContainerItem* pRegion : maRegions)
+ if (pRegion->maTitle == rName)
+ return pRegion;
+
+ return nullptr;
+}
+
+void TemplateLocalView::createContextMenu()
+{
+ std::unique_ptr<PopupMenu> pItemMenu(new PopupMenu);
+ pItemMenu->InsertItem(MNI_OPEN,SfxResId(STR_OPEN).toString());
+ pItemMenu->InsertItem(MNI_EDIT,SfxResId(STR_EDIT_TEMPLATE).toString());
+ pItemMenu->InsertItem(MNI_DEFAULT_TEMPLATE,SfxResId(STR_DEFAULT_TEMPLATE).toString());
+ pItemMenu->InsertSeparator();
+ pItemMenu->InsertItem(MNI_DELETE,SfxResId(STR_DELETE).toString());
+ pItemMenu->InsertItem(MNI_RENAME,SfxResId(STR_RENAME).toString());
+ pItemMenu->InsertSeparator();
+ deselectItems();
+ maSelectedItem->setSelection(true);
+ pItemMenu->SetSelectHdl(LINK(this, TemplateLocalView, ContextMenuSelectHdl));
+ pItemMenu->Execute(this, Rectangle(maPosition,Size(1,1)), PopupMenuFlags::ExecuteDown);
+ Invalidate();
+}
+
+IMPL_LINK_TYPED(TemplateLocalView, ContextMenuSelectHdl, Menu*, pMenu, bool)
+{
+ sal_uInt16 nMenuId = pMenu->GetCurItemId();
+
+ switch(nMenuId)
+ {
+ case MNI_OPEN:
+ maOpenTemplateHdl.Call(maSelectedItem);
+ break;
+ case MNI_EDIT:
+ maEditTemplateHdl.Call(maSelectedItem);
+ break;
+ case MNI_DELETE:
+ maDeleteTemplateHdl.Call(maSelectedItem);
+ break;
+ case MNI_RENAME:
+ {
+ ScopedVclPtrInstance< InputDialog > m_pTitleEditDlg( SfxResId(STR_RENAME_TEMPLATE).toString(), this);
+ OUString sOldTitle = maSelectedItem->getHelpText();
+ m_pTitleEditDlg->SetEntryText( sOldTitle );
+ m_pTitleEditDlg->HideHelpBtn();
+
+ if(!m_pTitleEditDlg->Execute())
+ break;
+ OUString sNewTitle = comphelper::string::strip( m_pTitleEditDlg->GetEntryText(), ' ');
+
+ if ( !sNewTitle.isEmpty() && sNewTitle != sOldTitle )
+ {
+ maSelectedItem->setTitle(sNewTitle);
+ maSelectedItem->setEditTitle(true);
+ }
+ }
+ break;
+ case MNI_DEFAULT_TEMPLATE:
+ maDefaultTemplateHdl.Call(maSelectedItem);
+ break;
+ default:
+ break;
+ }
+
+ return false;
+}
+
sal_uInt16 TemplateLocalView::getCurRegionItemId() const
{
for (TemplateContainerItem* pRegion : maRegions)
@@ -195,6 +256,17 @@ sal_uInt16 TemplateLocalView::getRegionId(size_t pos) const
return maRegions[pos]->mnId;
}
+sal_uInt16 TemplateLocalView::getRegionId(OUString sRegion) const
+{
+ for (TemplateContainerItem* pRegion : maRegions)
+ {
+ if (pRegion->maTitle == sRegion)
+ return pRegion->mnId;
+ }
+
+ return 0;
+}
+
OUString TemplateLocalView::getRegionName(const sal_uInt16 nRegionId) const
{
return mpDocTemplates->GetRegionName(nRegionId);
@@ -279,16 +351,6 @@ sal_uInt16 TemplateLocalView::createRegion(const OUString &rName)
return pItem->mnId;
}
-bool TemplateLocalView::isNestedRegionAllowed() const
-{
- return !mnCurRegionId;
-}
-
-bool TemplateLocalView::isImportAllowed() const
-{
- return mnCurRegionId;
-}
-
bool TemplateLocalView::removeRegion(const sal_uInt16 nItemId)
{
sal_uInt16 nRegionId = USHRT_MAX;
@@ -364,10 +426,7 @@ bool TemplateLocalView::removeTemplate (const sal_uInt16 nItemId, const sal_uInt
}
}
- lcl_updateThumbnails(pItem);
-
CalculateItemPositions();
-
break;
}
}
@@ -446,9 +505,6 @@ bool TemplateLocalView::moveTemplate (const ThumbnailViewItem *pItem, const sal_
}
}
- lcl_updateThumbnails(pSrc);
- lcl_updateThumbnails(pTarget);
-
CalculateItemPositions();
Invalidate();
@@ -461,12 +517,8 @@ bool TemplateLocalView::moveTemplate (const ThumbnailViewItem *pItem, const sal_
bool TemplateLocalView::moveTemplates(const std::set<const ThumbnailViewItem*, selection_cmp_fn> &rItems,
const sal_uInt16 nTargetItem)
{
- assert(mnCurRegionId); // Only allowed in non root regions
-
bool ret = true;
- sal_uInt16 nSrcRegionId = mnCurRegionId-1;
-
TemplateContainerItem *pTarget = nullptr;
TemplateContainerItem *pSrc = nullptr;
@@ -474,11 +526,9 @@ bool TemplateLocalView::moveTemplates(const std::set<const ThumbnailViewItem*, s
{
if (pRegion->mnId == nTargetItem)
pTarget = static_cast<TemplateContainerItem*>(pRegion);
- else if (pRegion->mnRegionId == nSrcRegionId)
- pSrc = static_cast<TemplateContainerItem*>(pRegion);
}
- if (pTarget && pSrc)
+ if (pTarget)
{
bool refresh = false;
@@ -490,59 +540,69 @@ bool TemplateLocalView::moveTemplates(const std::set<const ThumbnailViewItem*, s
for ( aSelIter = rItems.begin(); aSelIter != rItems.end(); ++aSelIter, ++nTargetIdx )
{
const TemplateViewItem *pViewItem = static_cast<const TemplateViewItem*>(*aSelIter);
+ sal_uInt16 nSrcRegionId = pViewItem->mnRegionId;
- bool bCopy = !mpDocTemplates->Move(nTargetRegion,nTargetIdx,nSrcRegionId,pViewItem->mnDocId);
+ for (TemplateContainerItem* pRegion : maRegions)
+ {
+ if (pRegion->mnRegionId == nSrcRegionId)
+ pSrc = static_cast<TemplateContainerItem*>(pRegion);
+ }
- if (bCopy)
+ if(pSrc)
{
- if (!mpDocTemplates->Copy(nTargetRegion,nTargetIdx,nSrcRegionId,pViewItem->mnDocId))
+ bool bCopy = !mpDocTemplates->Move(nTargetRegion,nTargetIdx,nSrcRegionId,pViewItem->mnDocId);
+
+ if (bCopy)
{
- ret = false;
- continue;
+ if (!mpDocTemplates->Copy(nTargetRegion,nTargetIdx,nSrcRegionId,pViewItem->mnDocId))
+ {
+ ret = false;
+ continue;
+ }
}
- }
-
- // move template to destination
- TemplateItemProperties aTemplateItem;
- aTemplateItem.nId = nTargetIdx + 1;
- aTemplateItem.nDocId = nTargetIdx;
- aTemplateItem.nRegionId = nTargetRegion;
- aTemplateItem.aName = pViewItem->maTitle;
- aTemplateItem.aPath = mpDocTemplates->GetPath(nTargetRegion,nTargetIdx);
- aTemplateItem.aThumbnail = pViewItem->maPreview1;
+ // move template to destination
- pTarget->maTemplates.push_back(aTemplateItem);
+ TemplateItemProperties aTemplateItem;
+ aTemplateItem.nId = nTargetIdx + 1;
+ aTemplateItem.nDocId = nTargetIdx;
+ aTemplateItem.nRegionId = nTargetRegion;
+ aTemplateItem.aName = pViewItem->maTitle;
+ aTemplateItem.aPath = mpDocTemplates->GetPath(nTargetRegion,nTargetIdx);
+ aTemplateItem.aThumbnail = pViewItem->maPreview1;
- if (!bCopy)
- {
- // remove template from region cached data
+ pTarget->maTemplates.push_back(aTemplateItem);
- std::vector<TemplateItemProperties>::iterator pPropIter;
- for (pPropIter = pSrc->maTemplates.begin(); pPropIter != pSrc->maTemplates.end();)
+ if (!bCopy)
{
- if (pPropIter->nDocId == pViewItem->mnDocId)
+ // remove template from region cached data
+
+ std::vector<TemplateItemProperties>::iterator pPropIter;
+ for (pPropIter = pSrc->maTemplates.begin(); pPropIter != pSrc->maTemplates.end();)
{
- pPropIter = pSrc->maTemplates.erase(pPropIter);
- aItemIds.push_back(pViewItem->mnId);
+ if (pPropIter->nDocId == pViewItem->mnDocId)
+ {
+ pPropIter = pSrc->maTemplates.erase(pPropIter);
+ aItemIds.push_back(pViewItem->mnId);
+ }
+ else
+ {
+ // Keep region document id synchronized with SfxDocumentTemplates
+ if (pPropIter->nDocId > pViewItem->mnDocId)
+ --pPropIter->nDocId;
+
+ ++pPropIter;
+ }
}
- else
- {
- // Keep region document id synchronized with SfxDocumentTemplates
- if (pPropIter->nDocId > pViewItem->mnDocId)
- --pPropIter->nDocId;
- ++pPropIter;
+ // Keep view document id synchronized with SfxDocumentTemplates
+ std::vector<ThumbnailViewItem*>::iterator pItemIter = mItemList.begin();
+ for (; pItemIter != mItemList.end(); ++pItemIter)
+ {
+ if (static_cast<TemplateViewItem*>(*pItemIter)->mnDocId > pViewItem->mnDocId)
+ --static_cast<TemplateViewItem*>(*pItemIter)->mnDocId;
}
}
-
- // Keep view document id synchronized with SfxDocumentTemplates
- std::vector<ThumbnailViewItem*>::iterator pItemIter = mItemList.begin();
- for (; pItemIter != mItemList.end(); ++pItemIter)
- {
- if (static_cast<TemplateViewItem*>(*pItemIter)->mnDocId > pViewItem->mnDocId)
- --static_cast<TemplateViewItem*>(*pItemIter)->mnDocId;
- }
}
refresh = true;
@@ -554,9 +614,6 @@ bool TemplateLocalView::moveTemplates(const std::set<const ThumbnailViewItem*, s
if (refresh)
{
- lcl_updateThumbnails(pSrc);
- lcl_updateThumbnails(pTarget);
-
CalculateItemPositions();
Invalidate();
}
@@ -604,8 +661,6 @@ bool TemplateLocalView::copyFrom(const sal_uInt16 nRegionItemId, const BitmapEx
pItem->maTemplates.push_back(aTemplate);
- lcl_updateThumbnails(pItem);
-
return true;
}
@@ -680,8 +735,6 @@ bool TemplateLocalView::copyFrom (TemplateContainerItem *pItem, const OUString &
pItem->maTemplates.push_back(aTemplate);
- lcl_updateThumbnails(pItem);
-
CalculateItemPositions();
return true;
@@ -715,107 +768,6 @@ bool TemplateLocalView::exportTo(const sal_uInt16 nItemId, const sal_uInt16 nReg
return false;
}
-bool TemplateLocalView::saveTemplateAs (sal_uInt16 nItemId,
- css::uno::Reference<css::frame::XModel> &rModel,
- const OUString &rName)
-{
-
- for (TemplateContainerItem* pRegion : maRegions)
- {
- if (pRegion->mnId == nItemId)
- {
- uno::Reference< frame::XStorable > xStorable(rModel, uno::UNO_QUERY_THROW );
-
- uno::Reference< frame::XDocumentTemplates > xTemplates(
- frame::DocumentTemplates::create(comphelper::getProcessComponentContext()) );
-
- if (!xTemplates->storeTemplate(mpDocTemplates->GetRegionName(pRegion->mnRegionId),rName, xStorable ))
- return false;
-
- sal_uInt16 nDocId = pRegion->maTemplates.size();
-
- OUString aURL = mpDocTemplates->GetTemplateTargetURLFromComponent(mpDocTemplates->GetRegionName(pRegion->mnRegionId),rName);
-
- if(!mpDocTemplates->InsertTemplate(pRegion->mnRegionId,nDocId,rName,aURL))
- return false;
-
-
- TemplateItemProperties aTemplate;
- aTemplate.aIsFolder = false;
- aTemplate.nId = getNextItemId();
- aTemplate.nDocId = nDocId;
- aTemplate.nRegionId = pRegion->mnRegionId;
- aTemplate.aName = rName;
- aTemplate.aThumbnail = TemplateAbstractView::fetchThumbnail(aURL,
- TEMPLATE_THUMBNAIL_MAX_WIDTH,
- TEMPLATE_THUMBNAIL_MAX_HEIGHT);
- aTemplate.aPath = aURL;
-
- pRegion->maTemplates.push_back(aTemplate);
-
- insertItem(aTemplate);
-
- return true;
- }
- }
-
- return false;
-}
-
-bool TemplateLocalView::saveTemplateAs(TemplateContainerItem *pDstItem,
- css::uno::Reference<css::frame::XModel> &rModel,
- const OUString &rName)
-{
- uno::Reference< frame::XStorable > xStorable(rModel, uno::UNO_QUERY_THROW );
-
- uno::Reference< frame::XDocumentTemplates > xTemplates(
- frame::DocumentTemplates::create(comphelper::getProcessComponentContext()) );
-
- if (!xTemplates->storeTemplate(mpDocTemplates->GetRegionName(pDstItem->mnRegionId),rName, xStorable ))
- return false;
-
- sal_uInt16 nDocId = pDstItem->maTemplates.size();
- OUString aURL = mpDocTemplates->GetTemplateTargetURLFromComponent(mpDocTemplates->GetRegionName(pDstItem->mnRegionId),rName);
-
- if(!mpDocTemplates->InsertTemplate(pDstItem->mnRegionId,nDocId,rName,aURL))
- return false;
-
- TemplateItemProperties aTemplate;
- aTemplate.aIsFolder = false;
- aTemplate.nId = pDstItem->maTemplates.empty() ? 1 : pDstItem->maTemplates.back().nId+1;
- aTemplate.nDocId = nDocId;
- aTemplate.nRegionId = pDstItem->mnRegionId;
- aTemplate.aName = rName;
- aTemplate.aThumbnail = TemplateAbstractView::fetchThumbnail(aURL,
- TEMPLATE_THUMBNAIL_MAX_WIDTH,
- TEMPLATE_THUMBNAIL_MAX_HEIGHT);
- aTemplate.aPath = aURL;
-
- pDstItem->maTemplates.push_back(aTemplate);
-
- return true;
-}
-
-bool TemplateLocalView::isTemplateNameUnique(const sal_uInt16 nRegionItemId, const OUString &rName) const
-{
- for (const TemplateContainerItem* pRegItem : maRegions)
- {
- if (pRegItem->mnId == nRegionItemId)
- {
- std::vector<TemplateItemProperties>::const_iterator aIter;
- for (aIter = pRegItem->maTemplates.begin(); aIter != pRegItem->maTemplates.end(); ++aIter)
- {
- if (aIter->aName == rName)
- return false;
- }
-
- break;
- }
- }
-
- return true;
-}
-
bool TemplateLocalView::renameItem(ThumbnailViewItem* pItem, const OUString& sNewTitle)
{
sal_uInt16 nRegionId = 0;
@@ -834,41 +786,4 @@ bool TemplateLocalView::renameItem(ThumbnailViewItem* pItem, const OUString& sNe
return mpDocTemplates->SetName( sNewTitle, nRegionId, nDocId );
}
-static void lcl_updateThumbnails (TemplateContainerItem *pItem)
-{
- pItem->maPreview1.Clear();
- pItem->maPreview2.Clear();
- pItem->maPreview3.Clear();
- pItem->maPreview4.Clear();
-
- // Update folder thumbnails
- for (size_t i = 0, n = pItem->maTemplates.size(); i < n && pItem->HasMissingPreview(); ++i)
- {
- if ( pItem->maPreview1.IsEmpty( ) )
- {
- pItem->maPreview1 = TemplateAbstractView::scaleImg(pItem->maTemplates[i].aThumbnail,
- TEMPLATE_THUMBNAIL_MAX_WIDTH*0.75,
- TEMPLATE_THUMBNAIL_MAX_HEIGHT*0.75);
- }
- else if ( pItem->maPreview2.IsEmpty() )
- {
- pItem->maPreview2 = TemplateAbstractView::scaleImg(pItem->maTemplates[i].aThumbnail,
- TEMPLATE_THUMBNAIL_MAX_WIDTH*0.75,
- TEMPLATE_THUMBNAIL_MAX_HEIGHT*0.75);
- }
- else if ( pItem->maPreview3.IsEmpty() )
- {
- pItem->maPreview3 = TemplateAbstractView::scaleImg(pItem->maTemplates[i].aThumbnail,
- TEMPLATE_THUMBNAIL_MAX_WIDTH*0.75,
- TEMPLATE_THUMBNAIL_MAX_HEIGHT*0.75);
- }
- else if ( pItem->maPreview4.IsEmpty() )
- {
- pItem->maPreview4 = TemplateAbstractView::scaleImg(pItem->maTemplates[i].aThumbnail,
- TEMPLATE_THUMBNAIL_MAX_WIDTH*0.75,
- TEMPLATE_THUMBNAIL_MAX_HEIGHT*0.75);
- }
- }
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/control/templateremoteview.cxx b/sfx2/source/control/templateremoteview.cxx
index 07aaef278cae..1e9409a7f37d 100644
--- a/sfx2/source/control/templateremoteview.cxx
+++ b/sfx2/source/control/templateremoteview.cxx
@@ -60,12 +60,12 @@ VCL_BUILDER_DECL_FACTORY(TemplateRemoteView)
rRet = VclPtr<TemplateRemoteView>::Create(pParent, WB_VSCROLL, false);
}
-void TemplateRemoteView::showRootRegion()
+void TemplateRemoteView::showRegion(ThumbnailViewItem * /*pItem*/)
{
//TODO:
}
-void TemplateRemoteView::showRegion(ThumbnailViewItem * /*pItem*/)
+void TemplateRemoteView::showAllTemplates()
{
//TODO:
}
@@ -83,7 +83,6 @@ bool TemplateRemoteView::loadRepository (TemplateRepository* pItem)
mnCurRegionId = pItem->mnId;
maCurRegionName = pItem->maTitle;
- maFTName->SetText(maCurRegionName);
OUString aURL = pItem->getURL();
@@ -172,14 +171,4 @@ sal_uInt16 TemplateRemoteView::createRegion(const OUString &/*rName*/)
return 0;
}
-bool TemplateRemoteView::isNestedRegionAllowed() const
-{
- return true;
-}
-
-bool TemplateRemoteView::isImportAllowed() const
-{
- return true;
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/control/templatesearchview.cxx b/sfx2/source/control/templatesearchview.cxx
index fa6a00997660..15e0857bad10 100644
--- a/sfx2/source/control/templatesearchview.cxx
+++ b/sfx2/source/control/templatesearchview.cxx
@@ -9,21 +9,110 @@
#include "templatesearchview.hxx"
#include "templatesearchviewitem.hxx"
+#include <sfx2/sfxresid.hxx>
+
+#include "../doc/doc.hrc"
#include <vcl/builderfactory.hxx>
+#define MNI_OPEN 1
+#define MNI_EDIT 2
+#define MNI_DEFAULT_TEMPLATE 3
+#define MNI_DELETE 4
+
TemplateSearchView::TemplateSearchView (vcl::Window *pParent, WinBits nWinStyle)
- : ThumbnailView(pParent,nWinStyle)
+ : ThumbnailView(pParent,nWinStyle),
+ maSelectedItem(nullptr),
+ maPosition(0,0)
{
}
VCL_BUILDER_FACTORY(TemplateSearchView)
+void TemplateSearchView::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ if (rMEvt.IsRight())
+ {
+ size_t nPos = ImplGetItem(rMEvt.GetPosPixel());
+ Point aPosition (rMEvt.GetPosPixel());
+ maPosition = aPosition;
+ ThumbnailViewItem* pItem = ImplGetItem(nPos);
+ const TemplateViewItem *pViewItem = dynamic_cast<const TemplateViewItem*>(pItem);
+
+ if(pViewItem)
+ {
+ maSelectedItem = dynamic_cast<TemplateViewItem*>(pItem);
+ maRightClickHdl.Call(pItem);
+ }
+ }
+
+ ThumbnailView::MouseButtonDown(rMEvt);
+}
+
+void TemplateSearchView::createContextMenu()
+{
+ std::unique_ptr<PopupMenu> pItemMenu(new PopupMenu);
+ pItemMenu->InsertItem(MNI_OPEN,SfxResId(STR_OPEN).toString());
+ pItemMenu->InsertItem(MNI_EDIT,SfxResId(STR_EDIT_TEMPLATE).toString());
+ pItemMenu->InsertItem(MNI_DEFAULT_TEMPLATE,SfxResId(STR_DEFAULT_TEMPLATE).toString());
+ pItemMenu->InsertSeparator();
+ pItemMenu->InsertItem(MNI_DELETE,SfxResId(STR_DELETE).toString());
+ maSelectedItem->setSelection(true);
+ pItemMenu->SetSelectHdl(LINK(this, TemplateSearchView, ContextMenuSelectHdl));
+ pItemMenu->Execute(this, Rectangle(maPosition,Size(1,1)), PopupMenuFlags::ExecuteDown);
+ Invalidate();
+}
+
+IMPL_LINK_TYPED(TemplateSearchView, ContextMenuSelectHdl, Menu*, pMenu, bool)
+{
+ sal_uInt16 nMenuId = pMenu->GetCurItemId();
+
+ switch(nMenuId)
+ {
+ case MNI_OPEN:
+ maOpenTemplateHdl.Call(maSelectedItem);
+ break;
+ case MNI_EDIT:
+ maEditTemplateHdl.Call(maSelectedItem);
+ break;
+ case MNI_DELETE:
+ maDeleteTemplateHdl.Call(maSelectedItem);
+ break;
+ case MNI_DEFAULT_TEMPLATE:
+ maDefaultTemplateHdl.Call(maSelectedItem);
+ break;
+ default:
+ break;
+ }
+
+ return false;
+}
+
+void TemplateSearchView::setRightClickHdl(const Link<ThumbnailViewItem*,void> &rLink)
+{
+ maRightClickHdl = 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);
diff --git a/sfx2/source/dialog/backingwindow.cxx b/sfx2/source/dialog/backingwindow.cxx
index c3ef829332bf..61f280c49f74 100644
--- a/sfx2/source/dialog/backingwindow.cxx
+++ b/sfx2/source/dialog/backingwindow.cxx
@@ -338,8 +338,8 @@ void BackingWindow::initializeLocalView()
{
mbLocalViewInitialized = true;
mpLocalView->Populate();
- mpLocalView->showRootRegion();
mpLocalView->filterItems(ViewFilter_Application(FILTER_APPLICATION::NONE));
+ mpLocalView->showAllTemplates();
}
}
diff --git a/sfx2/source/doc/doc.hrc b/sfx2/source/doc/doc.hrc
index a51fdc2bd101..a8abbe57e261 100644
--- a/sfx2/source/doc/doc.hrc
+++ b/sfx2/source/doc/doc.hrc
@@ -111,6 +111,20 @@
#define IMG_ACTION_SORT (RID_SFX_DOC_START+149)
#define IMG_ACTION_REFRESH (RID_SFX_DOC_START+150)
+#define STR_OPEN (RID_SFX_DOC_START+151)
+#define STR_EDIT_TEMPLATE (RID_SFX_DOC_START+152)
+#define STR_DEFAULT_TEMPLATE (RID_SFX_DOC_START+153)
+#define STR_RENAME (RID_SFX_DOC_START+154)
+#define STR_DELETE (RID_SFX_DOC_START+155)
+#define STR_PROPERTIES (RID_SFX_DOC_START+156)
+#define STR_RENAME_TEMPLATE (RID_SFX_DOC_START+157)
+
+#define STR_CATEGORY_NEW (RID_SFX_DOC_START+158)
+#define STR_CATEGORY_SELECT (RID_SFX_DOC_START+100)
+#define STR_CATEGORY_DELETE (RID_SFX_DOC_START+101)
+#define STR_CREATE_ERROR (RID_SFX_DOC_START+103)
+#define STR_ERROR_SAVEAS (RID_SFX_DOC_START+105)
+
// please update to the last id
#define ACT_SFX_DOC_END IMG_ACTION_REFRESH
#if ACT_SFX_DOC_END > RID_SFX_DOC_END
diff --git a/sfx2/source/doc/doc.src b/sfx2/source/doc/doc.src
index 6d14650d878a..cab02ce0e62f 100644
--- a/sfx2/source/doc/doc.src
+++ b/sfx2/source/doc/doc.src
@@ -48,10 +48,34 @@ String STR_CLOSEDOC_ANDRETURN
{
Text [ en-US ] = "~Close & Return to " ;
};
-String STR_EDIT
+String STR_OPEN
+{
+ Text [ en-US ] = "Open" ;
+};
+String STR_EDIT_TEMPLATE
{
Text [ en-US ] = "Edit" ;
};
+String STR_DEFAULT_TEMPLATE
+{
+ Text [ en-US ] = "Set As Default" ;
+};
+String STR_DELETE
+{
+ Text [ en-US ] = "Delete" ;
+};
+String STR_RENAME
+{
+ Text [ en-US ] = "Rename" ;
+};
+String STR_PROPERTIES
+{
+ Text [ en-US ] = "Properties" ;
+};
+String STR_RENAME_TEMPLATE
+{
+ Text [ en-US ] = "Enter New Name: " ;
+};
String STR_AUTOMATICVERSION
{
Text [ en-US ] = "Automatically saved version" ;
@@ -211,9 +235,34 @@ String STR_MOVE_NEW
Text [ en-US ] = "New folder";
};
+String STR_CATEGORY_NEW
+{
+ Text [ en-US ] = "New Category";
+};
+
+String STR_CATEGORY_DELETE
+{
+ Text [ en-US ] = "Delete Category";
+};
+
+String STR_CATEGORY_SELECT
+{
+ Text [ en-US ] = "Select Category";
+};
+
+String STR_CREATE_ERROR
+{
+ Text [ en-US ] = "Cannot create category: $1";
+};
+
+String STR_ERROR_SAVEAS
+{
+ Text [ en-US ] = "Cannot save template: $1";
+};
+
String STR_INPUT_NEW
{
- Text [ en-US ] = "Enter folder name:";
+ Text [ en-US ] = "Enter category name:";
};
String STR_REPOSITORY_LOCAL
diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx
index fb31aef69bb4..aa7f9132f299 100644
--- a/sfx2/source/doc/objserv.cxx
+++ b/sfx2/source/doc/objserv.cxx
@@ -99,7 +99,7 @@
#include "helpid.hrc"
#include "guisaveas.hxx"
-#include <sfx2/templatedlg.hxx>
+#include <sfx2/saveastemplatedlg.hxx>
#include <memory>
#include <cppuhelper/implbase.hxx>
@@ -848,11 +848,9 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
case SID_DOCTEMPLATE:
{
// save as document templates
- ScopedVclPtrInstance< SfxTemplateManagerDlg > aDlg;
+ ScopedVclPtrInstance<SfxSaveAsTemplateDialog> aDlg;
aDlg->setDocumentModel(GetModel());
- aDlg->setSaveMode();
aDlg->Execute();
-
break;
}
diff --git a/sfx2/source/doc/saveastemplatedlg.cxx b/sfx2/source/doc/saveastemplatedlg.cxx
new file mode 100644
index 000000000000..d219a7f51d29
--- /dev/null
+++ b/sfx2/source/doc/saveastemplatedlg.cxx
@@ -0,0 +1,169 @@
+/* -*- 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 <sfx2/saveastemplatedlg.hxx>
+
+#include <comphelper/processfactory.hxx>
+#include <comphelper/string.hxx>
+#include <sfx2/sfxresid.hxx>
+#include <sfx2/doctempl.hxx>
+#include <vcl/edit.hxx>
+#include <vcl/layout.hxx>
+#include <vcl/lstbox.hxx>
+
+#include <com/sun/star/frame/DocumentTemplates.hpp>
+
+#include "doc.hrc"
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::frame;
+
+// Class SfxSaveAsTemplateDialog --------------------------------------------------
+
+SfxSaveAsTemplateDialog::SfxSaveAsTemplateDialog( vcl::Window* pParent):
+ ModalDialog(pParent, "SaveAsTemplateDialog", "sfx/ui/saveastemplatedlg.ui"),
+ msSelectedCategory(OUString()),
+ msTemplateName(OUString()),
+ mnRegionPos(0),
+ mpDocTemplates(new SfxDocumentTemplates)
+{
+ get(mpLBCategory, "categorylb");
+ get(mpTemplateNameEdit, "name_entry");
+ get(mpOKButton, "ok");
+
+ initialize();
+ SetCategoryLBEntries(msCategories);
+
+ mpTemplateNameEdit->SetModifyHdl(LINK(this, SfxSaveAsTemplateDialog, TemplateNameEditHdl));
+ mpLBCategory->SetSelectHdl(LINK(this, SfxSaveAsTemplateDialog, SelectCategoryHdl));
+ mpOKButton->SetClickHdl(LINK(this, SfxSaveAsTemplateDialog, OkClickHdl));
+
+ mpOKButton->Disable();
+ mpOKButton->SetText(SfxResId(STR_SAVEDOC).toString());
+}
+
+SfxSaveAsTemplateDialog::~SfxSaveAsTemplateDialog()
+{
+ disposeOnce();
+}
+
+void SfxSaveAsTemplateDialog::dispose()
+{
+ mpLBCategory.clear();
+ mpTemplateNameEdit.clear();
+ mpOKButton.clear();
+
+ ModalDialog::dispose();
+}
+
+void SfxSaveAsTemplateDialog::setDocumentModel(const uno::Reference<frame::XModel> &rModel)
+{
+ m_xModel = rModel;
+}
+
+IMPL_LINK_NOARG_TYPED(SfxSaveAsTemplateDialog, OkClickHdl, Button*, void)
+{
+ ScopedVclPtrInstance< MessageDialog > aQueryDlg(this, OUString(), VCL_MESSAGE_QUESTION, VCL_BUTTONS_YES_NO);
+
+ if(!IsTemplateNameUnique())
+ {
+ OUString sQueryMsg(SfxResId(STR_QMSG_TEMPLATE_OVERWRITE).toString());
+ sQueryMsg = sQueryMsg.replaceFirst("$1",msTemplateName);
+ aQueryDlg->set_primary_text(sQueryMsg.replaceFirst("$2", msSelectedCategory));
+
+ if( aQueryDlg->Execute() == RET_NO )
+ return;
+ }
+
+ if(SaveTemplate())
+ Close();
+ else
+ {
+ OUString sText( SfxResId(STR_ERROR_SAVEAS).toString() );
+ ScopedVclPtrInstance<MessageDialog>::Create(this, sText.replaceFirst("$1", msTemplateName))->Execute();
+ }
+}
+
+IMPL_LINK_NOARG_TYPED(SfxSaveAsTemplateDialog, TemplateNameEditHdl, Edit&, void)
+{
+ msTemplateName = comphelper::string::strip(mpTemplateNameEdit->GetText(), ' ');
+ SelectCategoryHdl(*mpLBCategory);
+}
+
+IMPL_LINK_NOARG_TYPED(SfxSaveAsTemplateDialog, SelectCategoryHdl, ListBox&, void)
+{
+ if(mpLBCategory->GetSelectEntryPos() == 0)
+ {
+ msSelectedCategory = OUString();
+ mpOKButton->Disable();
+ }
+ else
+ {
+ msSelectedCategory = mpLBCategory->GetSelectEntry();
+ mpOKButton->Enable(!msTemplateName.isEmpty());
+ }
+}
+
+void SfxSaveAsTemplateDialog::initialize()
+{
+ sal_uInt16 nCount = mpDocTemplates->GetRegionCount();
+ for (sal_uInt16 i = 0; i < nCount; ++i)
+ {
+ OUString sCategoryName(mpDocTemplates->GetFullRegionName(i));
+ msCategories.push_back(sCategoryName);
+ }
+}
+
+void SfxSaveAsTemplateDialog::SetCategoryLBEntries(std::vector<OUString> aFolderNames)
+{
+ mpLBCategory->InsertEntry(OUString("None"), 0);
+ if (!aFolderNames.empty())
+ {
+ for (size_t i = 0, n = aFolderNames.size(); i < n; ++i)
+ mpLBCategory->InsertEntry(aFolderNames[i], i+1);
+ }
+ mpLBCategory->SelectEntryPos(0);
+}
+
+bool SfxSaveAsTemplateDialog::IsTemplateNameUnique()
+{
+ std::vector<OUString>::iterator it;
+ it=find(msCategories.begin(), msCategories.end(), msSelectedCategory);
+ mnRegionPos = std::distance(msCategories.begin(), it);
+
+ sal_uInt16 nEntries = mpDocTemplates->GetCount(mnRegionPos);
+ for(sal_uInt16 i = 0; i < nEntries; i++)
+ {
+ OUString aName = mpDocTemplates->GetName(mnRegionPos, i);
+ if(aName == msTemplateName)
+ return false;
+ }
+
+ return true;
+}
+
+bool SfxSaveAsTemplateDialog::SaveTemplate()
+{
+ uno::Reference< frame::XStorable > xStorable(m_xModel, uno::UNO_QUERY_THROW );
+
+ uno::Reference< frame::XDocumentTemplates > xTemplates(frame::DocumentTemplates::create(comphelper::getProcessComponentContext()) );
+
+ if (!xTemplates->storeTemplate( msSelectedCategory, msTemplateName, xStorable ))
+ return false;
+
+ sal_uInt16 nDocId = mpDocTemplates->GetCount(mnRegionPos);
+ OUString sURL = mpDocTemplates->GetTemplateTargetURLFromComponent(msSelectedCategory, msTemplateName);
+
+ if(!mpDocTemplates->InsertTemplate( mnRegionPos, nDocId, msTemplateName, sURL))
+ return false;
+
+ return true;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx
index 6ef03a886e31..da92be39d575 100644
--- a/sfx2/source/doc/templatedlg.cxx
+++ b/sfx2/source/doc/templatedlg.cxx
@@ -14,6 +14,7 @@
#include "templatesearchviewitem.hxx"
#include <comphelper/processfactory.hxx>
+#include <comphelper/string.hxx>
#include <comphelper/storagehelper.hxx>
#include <officecfg/Office/Common.hxx>
#include <sfx2/app.hxx>
@@ -62,38 +63,24 @@
const char TM_SETTING_MANAGER[] = "TemplateManager";
const char TM_SETTING_LASTFOLDER[] = "LastFolder";
-const char TM_SETTING_FILTER[] = "SelectedFilter";
+const char TM_SETTING_LASTAPPLICATION[] = "LastApplication";
const char SERVICENAME_CFGREADACCESS[] = "com.sun.star.configuration.ConfigurationAccess";
const char VIEWBAR_REPOSITORY[] = "repository";
-const char VIEWBAR_IMPORT[] = "import";
-const char VIEWBAR_DELETE[] = "delete";
-const char VIEWBAR_SAVE[] = "save";
-const char VIEWBAR_NEW_FOLDER[] = "new_folder";
-const char TEMPLATEBAR_SAVE[] = "template_save";
-const char TEMPLATEBAR_OPEN[] = "open";
-const char TEMPLATEBAR_EDIT[] = "edit";
-const char TEMPLATEBAR_DEFAULT[] = "default";
-const char TEMPLATEBAR_MOVE[] = "move";
-const char TEMPLATEBAR_EXPORT[] = "export";
-const char TEMPLATEBAR_DELETE[] = "template_delete";
-const char ACTIONBAR_SEARCH[] = "search";
const char ACTIONBAR_ACTION[] = "action_menu";
-const char ACTIONBAR_TEMPLATE[] = "template_link";
-const char FILTER_DOCS[] = "filter_docs";
-const char FILTER_SHEETS[] = "filter_sheets";
-const char FILTER_PRESENTATIONS[] = "filter_presentations";
-const char FILTER_DRAWINGS[] = "filter_draws";
-
-#define MNI_ACTION_SORT_NAME 1
-#define MNI_ACTION_REFRESH 2
+
+#define MNI_ACTION_NEW_FOLDER 1
+#define MNI_ACTION_DELETE_FOLDER 2
+#define MNI_ACTION_REFRESH 3
#define MNI_ACTION_DEFAULT 3
-#define MNI_MOVE_NEW 1
-#define MNI_MOVE_FOLDER_BASE 2
#define MNI_REPOSITORY_LOCAL 1
#define MNI_REPOSITORY_NEW 2
#define MNI_REPOSITORY_BASE 3
+#define MNI_WRITER 1
+#define MNI_CALC 2
+#define MNI_IMPRESS 3
+#define MNI_DRAW 4
using namespace ::com::sun::star;
using namespace ::com::sun::star::beans;
@@ -108,17 +95,6 @@ static bool lcl_getServiceName (const OUString &rFileURL, OUString &rName );
static std::vector<OUString> lcl_getAllFactoryURLs ();
-// Sort by name in ascending order
-class SortView_Name
-{
-public:
-
- bool operator() (const ThumbnailViewItem *pItem1, const ThumbnailViewItem *pItem2)
- {
- return (pItem1->maTitle.compareTo(pItem2->maTitle) < 0);
- }
-};
-
class SearchView_Keyword
{
public:
@@ -175,36 +151,32 @@ static bool cmpSelectionItems (const ThumbnailViewItem *pItem1, const ThumbnailV
SfxTemplateManagerDlg::SfxTemplateManagerDlg(vcl::Window *parent)
: ModalDialog(parent, "TemplateDialog", "sfx/ui/templatedlg.ui"),
maSelTemplates(cmpSelectionItems),
- maSelFolders(cmpSelectionItems),
- mbIsSaveMode(false),
mxDesktop( Desktop::create(comphelper::getProcessComponentContext()) ),
mbIsSynced(false),
maRepositories()
{
- get(mpTabControl, "tab_control");
- get(mpSearchEdit, "search_edit");
+ get(mpSearchFilter, "search_filter");
+ get(mpCBApp, "filter_application");
+ get(mpCBFolder, "filter_folder");
get(mpViewBar, "action_view");
get(mpActionBar, "action_action");
- get(mpTemplateBar, "action_templates");
get(mpLocalView, "template_view");
get(mpSearchView, "search_view");
get(mpRemoteView, "remote_view");
get(mpOKButton, "ok");
-
- TabPage *pTabPage = mpTabControl->GetTabPage(mpTabControl->GetPageId("filter_docs"));
- pTabPage->Show();
- mpTabControl->SetTabPage(mpTabControl->GetPageId("filter_sheets"), pTabPage);
- pTabPage->Show();
- mpTabControl->SetTabPage(mpTabControl->GetPageId("filter_presentations"), pTabPage);
- pTabPage->Show();
- mpTabControl->SetTabPage(mpTabControl->GetPageId("filter_draws"), pTabPage);
- pTabPage->Show();
+ get(mpMoveButton, "move_btn");
+ get(mpExportButton, "export_btn");
+ get(mpImportButton, "import_btn");
+ get(mpLinkButton, "online_link");
// Create popup menus
mpActionMenu = new PopupMenu;
- mpActionMenu->InsertItem(MNI_ACTION_SORT_NAME,
- SfxResId(STR_ACTION_SORT_NAME).toString(),
- Image(SfxResId(IMG_ACTION_SORT)));
+ mpActionMenu->InsertItem(MNI_ACTION_NEW_FOLDER,
+ SfxResId(STR_CATEGORY_NEW).toString(),
+ Image(SfxResId(IMG_ACTION_REFRESH)));
+ mpActionMenu->InsertItem(MNI_ACTION_DELETE_FOLDER,
+ SfxResId(STR_CATEGORY_DELETE).toString());
+ mpActionMenu->InsertSeparator();
mpActionMenu->InsertItem(MNI_ACTION_REFRESH,
SfxResId(STR_ACTION_REFRESH).toString(),
Image(SfxResId(IMG_ACTION_REFRESH)));
@@ -220,22 +192,14 @@ SfxTemplateManagerDlg::SfxTemplateManagerDlg(vcl::Window *parent)
// Set toolbox styles
mpViewBar->SetButtonType(ButtonType::SYMBOLTEXT);
- mpTemplateBar->SetButtonType(ButtonType::SYMBOLTEXT);
// Set toolbox button bits
mpViewBar->SetItemBits(mpViewBar->GetItemId(VIEWBAR_REPOSITORY), ToolBoxItemBits::DROPDOWNONLY);
mpActionBar->SetItemBits(mpActionBar->GetItemId(ACTIONBAR_ACTION), ToolBoxItemBits::DROPDOWNONLY);
- mpTemplateBar->SetItemBits(mpTemplateBar->GetItemId(TEMPLATEBAR_MOVE), ToolBoxItemBits::DROPDOWNONLY);
// Set toolbox handlers
- mpViewBar->SetSelectHdl(LINK(this,SfxTemplateManagerDlg,TBXViewHdl));
mpViewBar->SetDropdownClickHdl(LINK(this,SfxTemplateManagerDlg,TBXDropdownHdl));
- mpActionBar->SetSelectHdl(LINK(this,SfxTemplateManagerDlg,TBXActionHdl));
mpActionBar->SetDropdownClickHdl(LINK(this,SfxTemplateManagerDlg,TBXDropdownHdl));
- mpTemplateBar->SetSelectHdl(LINK(this,SfxTemplateManagerDlg,TBXTemplateHdl));
- mpTemplateBar->SetDropdownClickHdl(LINK(this,SfxTemplateManagerDlg,TBXDropdownHdl));
- mpSearchEdit->SetUpdateDataHdl(LINK(this,SfxTemplateManagerDlg,SearchUpdateHdl));
- mpSearchEdit->EnableUpdateData();
mpLocalView->SetStyle(mpLocalView->GetStyle() | WB_VSCROLL);
mpLocalView->setItemMaxTextLength(TEMPLATE_ITEM_MAX_TEXT_LENGTH);
@@ -245,8 +209,12 @@ SfxTemplateManagerDlg::SfxTemplateManagerDlg(vcl::Window *parent)
TEMPLATE_ITEM_PADDING);
mpLocalView->setItemStateHdl(LINK(this,SfxTemplateManagerDlg,TVItemStateHdl));
- mpLocalView->setOpenRegionHdl(LINK(this,SfxTemplateManagerDlg,OpenRegionHdl));
- mpLocalView->setOpenTemplateHdl(LINK(this,SfxTemplateManagerDlg,OpenTemplateHdl));
+ mpLocalView->setRightClickHdl(LINK(this,SfxTemplateManagerDlg, RightClickHdl));
+ mpLocalView->setOpenRegionHdl(LINK(this,SfxTemplateManagerDlg, OpenRegionHdl));
+ mpLocalView->setOpenTemplateHdl(LINK(this,SfxTemplateManagerDlg, OpenTemplateHdl));
+ mpLocalView->setEditTemplateHdl(LINK(this,SfxTemplateManagerDlg, EditTemplateHdl));
+ mpLocalView->setDeleteTemplateHdl(LINK(this,SfxTemplateManagerDlg, DeleteTemplateHdl));
+ mpLocalView->setDefaultTemplateHdl(LINK(this,SfxTemplateManagerDlg, DefaultTemplateHdl));
// Set online view position and dimensions
mpRemoteView->setItemMaxTextLength(TEMPLATE_ITEM_MAX_TEXT_LENGTH);
@@ -266,11 +234,20 @@ SfxTemplateManagerDlg::SfxTemplateManagerDlg(vcl::Window *parent)
TEMPLATE_ITEM_PADDING);
mpSearchView->setItemStateHdl(LINK(this,SfxTemplateManagerDlg,TVItemStateHdl));
+ mpSearchView->setRightClickHdl(LINK(this,SfxTemplateManagerDlg, RightClickHdl));
mpSearchView->setOpenTemplateHdl(LINK(this,SfxTemplateManagerDlg,OpenTemplateHdl));
-
- mpTabControl->SetActivatePageHdl(LINK(this, SfxTemplateManagerDlg, ActivatePageHdl));
+ mpSearchView->setEditTemplateHdl(LINK(this,SfxTemplateManagerDlg, EditTemplateHdl));
+ mpSearchView->setDeleteTemplateHdl(LINK(this,SfxTemplateManagerDlg, DeleteTemplateHdl));
+ mpSearchView->setDefaultTemplateHdl(LINK(this,SfxTemplateManagerDlg, DefaultTemplateHdl));
mpOKButton->SetClickHdl(LINK(this, SfxTemplateManagerDlg, OkClickHdl));
+ mpMoveButton->SetClickHdl(LINK(this, SfxTemplateManagerDlg, MoveClickHdl));
+ mpExportButton->SetClickHdl(LINK(this, SfxTemplateManagerDlg, ExportClickHdl));
+ mpImportButton->SetClickHdl(LINK(this, SfxTemplateManagerDlg, ImportClickHdl));
+ mpLinkButton->SetClickHdl(LINK(this, SfxTemplateManagerDlg, LinkClickHdl));
+
+ mpSearchFilter->SetUpdateDataHdl(LINK(this, SfxTemplateManagerDlg, SearchUpdateHdl));
+ mpSearchFilter->EnableUpdateData();
SvtMiscOptions aMiscOptions;
if ( !aMiscOptions.IsExperimentalMode() )
@@ -282,7 +259,6 @@ SfxTemplateManagerDlg::SfxTemplateManagerDlg(vcl::Window *parent)
mpViewBar->Show();
mpActionBar->Show();
-
switchMainView(true);
loadRepositories();
@@ -290,18 +266,20 @@ SfxTemplateManagerDlg::SfxTemplateManagerDlg(vcl::Window *parent)
createRepositoryMenu();
createDefaultTemplateMenu();
- //setSaveMode(); //Uncomment this line to put templates dialog into Save As mode
-
mpLocalView->Populate();
- mpCurView->filterItems(ViewFilter_Application(FILTER_APPLICATION::WRITER));
+ mpCurView->filterItems(ViewFilter_Application(FILTER_APPLICATION::NONE));
- readSettings();
+ mpCBApp->SelectEntryPos(0);
+ fillFolderComboBox();
- if(!mbIsSaveMode)
- mpOKButton->Disable();
+ mpExportButton->Disable();
+ mpMoveButton->Disable();
+ mpOKButton->SetText(SfxResId(STR_OPEN).toString());
- if(mbIsSaveMode)
- mpOKButton->SetText( SfxResId(STR_SAVEDOC).toString() );
+ mpCBApp->SetSelectHdl(LINK(this, SfxTemplateManagerDlg, SelectApplicationHdl));
+ mpCBFolder->SetSelectHdl(LINK(this, SfxTemplateManagerDlg, SelectRegionHdl));
+
+ readSettings();
mpLocalView->Show();
}
@@ -332,11 +310,16 @@ void SfxTemplateManagerDlg::dispose()
mpSearchView->setItemStateHdl(Link<const ThumbnailViewItem*,void>());
mpSearchView->setOpenTemplateHdl(Link<ThumbnailViewItem*, void>());
- mpTabControl.clear();
- mpSearchEdit.clear();
+ mpOKButton.clear();
+ mpMoveButton.clear();
+ mpExportButton.clear();
+ mpImportButton.clear();
+ mpLinkButton.clear();
+ mpSearchFilter.clear();
+ mpCBApp.clear();
+ mpCBFolder.clear();
mpViewBar.clear();
mpActionBar.clear();
- mpTemplateBar.clear();
mpSearchView.clear();
mpCurView.clear();
mpLocalView.clear();
@@ -344,99 +327,81 @@ void SfxTemplateManagerDlg::dispose()
ModalDialog::dispose();
}
-void SfxTemplateManagerDlg::setSaveMode()
-{
- mbIsSaveMode = true;
-
- // FIXME We used to call just mpTabControl->Clear() here; but that worked
- // only with .src dialogs, as the tab pages could have existed even
- // without TabControl containing them. This is not possible with .ui
- // definitions any more (and rightly so!), so leave just one tab here for
- // now, until we do a bigger rework of the templates dialog.
- while (mpTabControl->GetPageCount() > 1)
- mpTabControl->RemovePage(mpTabControl->GetPageId(1));
-
- mpCurView->filterItems(ViewFilter_Application(FILTER_APPLICATION::NONE));
-
- mpViewBar->ShowItem(VIEWBAR_SAVE);
- mpViewBar->HideItem(VIEWBAR_IMPORT);
- mpViewBar->HideItem(VIEWBAR_REPOSITORY);
-
- mpTemplateBar->ShowItem(TEMPLATEBAR_SAVE);
- mpTemplateBar->ShowItem(TEMPLATEBAR_DEFAULT);
- mpTemplateBar->HideItem(TEMPLATEBAR_OPEN);
- mpTemplateBar->HideItem(TEMPLATEBAR_EDIT);
- mpTemplateBar->HideItem(TEMPLATEBAR_MOVE);
- mpTemplateBar->HideItem(TEMPLATEBAR_EXPORT);
- mpTemplateBar->HideItem(TEMPLATEBAR_DELETE);
-}
-
void SfxTemplateManagerDlg::setDocumentModel(const uno::Reference<frame::XModel> &rModel)
{
m_xModel = rModel;
}
-FILTER_APPLICATION SfxTemplateManagerDlg::getCurrentFilter()
+FILTER_APPLICATION SfxTemplateManagerDlg::getCurrentApplicationFilter()
{
- const sal_uInt16 nCurPageId = mpTabControl->GetCurPageId();
+ const sal_Int16 nCurAppId = mpCBApp->GetSelectEntryPos();
- if (nCurPageId == mpTabControl->GetPageId(FILTER_DOCS))
+ if (nCurAppId == MNI_WRITER)
return FILTER_APPLICATION::WRITER;
- else if (nCurPageId == mpTabControl->GetPageId(FILTER_PRESENTATIONS))
+ else if (nCurAppId == MNI_IMPRESS)
return FILTER_APPLICATION::IMPRESS;
- else if (nCurPageId == mpTabControl->GetPageId(FILTER_SHEETS))
+ else if (nCurAppId == MNI_CALC)
return FILTER_APPLICATION::CALC;
- else if (nCurPageId == mpTabControl->GetPageId(FILTER_DRAWINGS))
+ else if (nCurAppId == MNI_DRAW)
return FILTER_APPLICATION::DRAW;
return FILTER_APPLICATION::NONE;
}
-IMPL_LINK_NOARG_TYPED(SfxTemplateManagerDlg, ActivatePageHdl, TabControl*, void)
+void SfxTemplateManagerDlg::fillFolderComboBox()
{
- mpCurView->filterItems(ViewFilter_Application(getCurrentFilter()));
- mpCurView->showRootRegion(); // fdo#60586 show the root region of the applied filter
+ std::vector<OUString> aFolderNames = mpLocalView->getFolderNames();
- if (mpSearchView->IsVisible())
- SearchUpdateHdl(*mpSearchEdit);
+ if (!aFolderNames.empty())
+ {
+ for (size_t i = 0, n = aFolderNames.size(); i < n; ++i)
+ mpCBFolder->InsertEntry(aFolderNames[i], i+1);
+ }
+ mpCBFolder->SelectEntryPos(0);
}
void SfxTemplateManagerDlg::readSettings ()
{
OUString aLastFolder;
- sal_uInt16 nPageId = 0;
SvtViewOptions aViewSettings( E_DIALOG, TM_SETTING_MANAGER );
if ( aViewSettings.Exists() )
{
sal_uInt16 nTmp = 0;
aViewSettings.GetUserItem(TM_SETTING_LASTFOLDER) >>= aLastFolder;
- aViewSettings.GetUserItem(TM_SETTING_FILTER) >>= nTmp;
- FILTER_APPLICATION nFilter = static_cast<FILTER_APPLICATION>(nTmp);
- switch (nFilter)
+ aViewSettings.GetUserItem(TM_SETTING_LASTAPPLICATION) >>= nTmp;
+ switch (nTmp)
{
- case FILTER_APPLICATION::WRITER:
- nPageId = mpTabControl->GetPageId(FILTER_DOCS);
+ case MNI_WRITER:
+ mpCBApp->SelectEntryPos(MNI_WRITER);
break;
- case FILTER_APPLICATION::IMPRESS:
- nPageId = mpTabControl->GetPageId(FILTER_PRESENTATIONS);
+ case MNI_CALC:
+ mpCBApp->SelectEntryPos(MNI_CALC);
break;
- case FILTER_APPLICATION::CALC:
- nPageId = mpTabControl->GetPageId(FILTER_SHEETS);
+ case MNI_IMPRESS:
+ mpCBApp->SelectEntryPos(MNI_IMPRESS);
break;
- case FILTER_APPLICATION::DRAW:
- nPageId = mpTabControl->GetPageId(FILTER_DRAWINGS);
+ case MNI_DRAW:
+ mpCBApp->SelectEntryPos(MNI_DRAW);
break;
- default: break;
+ default:
+ mpCBApp->SelectEntryPos(0);
}
}
- if (!aLastFolder.getLength())
- mpLocalView->showRootRegion();
+ mpCurView->filterItems(ViewFilter_Application(getCurrentApplicationFilter()));
+
+ if (aLastFolder.isEmpty())
+ {
+ //show all categories
+ mpCBFolder->SelectEntryPos(0);
+ mpLocalView->showAllTemplates();
+ }
else
+ {
+ mpCBFolder->SelectEntry(aLastFolder);
mpLocalView->showRegion(aLastFolder);
-
- mpTabControl->SelectTabPage(nPageId);
+ }
}
void SfxTemplateManagerDlg::writeSettings ()
@@ -450,7 +415,7 @@ void SfxTemplateManagerDlg::writeSettings ()
Sequence< NamedValue > aSettings
{
{ TM_SETTING_LASTFOLDER, css::uno::makeAny(aLastFolder) },
- { TM_SETTING_FILTER, css::uno::makeAny(sal_uInt16(getCurrentFilter())) }
+ { TM_SETTING_LASTAPPLICATION, css::uno::makeAny(sal_uInt16(mpCBApp->GetSelectEntryPos())) }
};
// write
@@ -458,49 +423,32 @@ void SfxTemplateManagerDlg::writeSettings ()
aViewSettings.SetUserData(aSettings);
}
-IMPL_LINK_NOARG_TYPED(SfxTemplateManagerDlg,TBXViewHdl, ToolBox *, void)
+IMPL_LINK_NOARG_TYPED(SfxTemplateManagerDlg, SelectApplicationHdl, ListBox&, void)
{
- const sal_uInt16 nCurItemId = mpViewBar->GetCurItemId();
-
- if (nCurItemId == mpViewBar->GetItemId(VIEWBAR_IMPORT))
- OnTemplateImport();
- else if (nCurItemId == mpViewBar->GetItemId(VIEWBAR_DELETE))
+ if(mpCurView == mpLocalView && mpCurView->IsVisible())
{
- if (mpCurView == mpLocalView)
- OnFolderDelete();
- else
- OnRepositoryDelete();
+ mpCurView->filterItems(ViewFilter_Application(getCurrentApplicationFilter()));
+ mpCurView->showAllTemplates();
+ mpCBFolder->SelectEntryPos(0);
}
- else if (nCurItemId == mpViewBar->GetItemId(VIEWBAR_NEW_FOLDER))
- OnFolderNew();
- else if (nCurItemId == mpViewBar->GetItemId(VIEWBAR_SAVE))
- OnTemplateSaveAs();
-}
-IMPL_LINK_NOARG_TYPED(SfxTemplateManagerDlg, TBXActionHdl, ToolBox *, void)
-{
- const sal_uInt16 nCurItemId = mpActionBar->GetCurItemId();
-
- if (nCurItemId == mpActionBar->GetItemId(ACTIONBAR_SEARCH))
- OnTemplateSearch();
- else if (nCurItemId == mpActionBar->GetItemId(ACTIONBAR_TEMPLATE))
- OnTemplateLink();
+ if(mpSearchView->IsVisible())
+ SearchUpdateHdl(*mpSearchFilter);
}
-IMPL_LINK_NOARG_TYPED(SfxTemplateManagerDlg, TBXTemplateHdl, ToolBox *, void)
+IMPL_LINK_NOARG_TYPED(SfxTemplateManagerDlg, SelectRegionHdl, ListBox&, void)
{
- const sal_uInt16 nCurItemId = mpTemplateBar->GetCurItemId();
-
- if (nCurItemId == mpTemplateBar->GetItemId(TEMPLATEBAR_OPEN))
- OnTemplateOpen();
- else if (nCurItemId == mpTemplateBar->GetItemId(TEMPLATEBAR_EDIT))
- OnTemplateEdit();
- else if (nCurItemId == mpTemplateBar->GetItemId(TEMPLATEBAR_DELETE))
- OnTemplateDelete();
- else if (nCurItemId == mpTemplateBar->GetItemId(TEMPLATEBAR_DEFAULT))
- OnTemplateAsDefault();
- else if (nCurItemId == mpTemplateBar->GetItemId(TEMPLATEBAR_EXPORT))
- OnTemplateExport();
+ if(mpCurView == mpLocalView)
+ {
+ const OUString sSelectedRegion = mpCBFolder->GetSelectEntry();
+ if(mpCBFolder->GetSelectEntryPos() == 0)
+ mpLocalView->showAllTemplates();
+ else
+ mpLocalView->showRegion(sSelectedRegion);
+ }
+
+ if(mpSearchView->IsVisible())
+ SearchUpdateHdl(*mpSearchFilter);
}
IMPL_LINK_TYPED(SfxTemplateManagerDlg, TBXDropdownHdl, ToolBox*, pBox, void)
@@ -517,33 +465,6 @@ IMPL_LINK_TYPED(SfxTemplateManagerDlg, TBXDropdownHdl, ToolBox*, pBox, void)
pBox->EndSelection();
pBox->Invalidate();
}
- else if (pBox == mpTemplateBar && nCurItemId == mpTemplateBar->GetItemId(TEMPLATEBAR_MOVE))
- {
- pBox->SetItemDown( nCurItemId, true );
-
- std::vector<OUString> aNames = mpLocalView->getFolderNames();
-
- PopupMenu *pMoveMenu = new PopupMenu;
- pMoveMenu->SetSelectHdl(LINK(this,SfxTemplateManagerDlg,MoveMenuSelectHdl));
-
- if (!aNames.empty())
- {
- for (size_t i = 0, n = aNames.size(); i < n; ++i)
- pMoveMenu->InsertItem(MNI_MOVE_FOLDER_BASE+i,aNames[i]);
- }
-
- pMoveMenu->InsertSeparator();
-
- pMoveMenu->InsertItem(MNI_MOVE_NEW, SfxResId(STR_MOVE_NEW));
-
- pMoveMenu->Execute(pBox, pBox->GetItemRect(nCurItemId), PopupMenuFlags::ExecuteDown);
-
- delete pMoveMenu;
-
- pBox->SetItemDown( nCurItemId, false );
- pBox->EndSelection();
- pBox->Invalidate();
- }
else if (pBox == mpViewBar && nCurItemId == mpViewBar->GetItemId(VIEWBAR_REPOSITORY))
{
pBox->SetItemDown( nCurItemId, true );
@@ -558,11 +479,9 @@ IMPL_LINK_TYPED(SfxTemplateManagerDlg, TBXDropdownHdl, ToolBox*, pBox, void)
IMPL_LINK_TYPED(SfxTemplateManagerDlg, TVItemStateHdl, const ThumbnailViewItem*, pItem, void)
{
- const TemplateContainerItem *pCntItem = dynamic_cast<const TemplateContainerItem*>(pItem);
+ const TemplateViewItem *pViewItem = dynamic_cast<const TemplateViewItem*>(pItem);
- if (pCntItem)
- OnRegionState(pItem);
- else
+ if (pViewItem)
OnTemplateState(pItem);
}
@@ -572,8 +491,11 @@ IMPL_LINK_TYPED(SfxTemplateManagerDlg, MenuSelectHdl, Menu*, pMenu, bool)
switch(nMenuId)
{
- case MNI_ACTION_SORT_NAME:
- mpLocalView->sortItems(SortView_Name());
+ case MNI_ACTION_NEW_FOLDER:
+ OnCategoryNew();
+ break;
+ case MNI_ACTION_DELETE_FOLDER:
+ OnCategoryDelete();
break;
case MNI_ACTION_REFRESH:
mpCurView->reload();
@@ -585,28 +507,6 @@ IMPL_LINK_TYPED(SfxTemplateManagerDlg, MenuSelectHdl, Menu*, pMenu, bool)
return false;
}
-IMPL_LINK_TYPED(SfxTemplateManagerDlg, MoveMenuSelectHdl, Menu*, pMenu, bool)
-{
- sal_uInt16 nMenuId = pMenu->GetCurItemId();
-
- if (mpSearchView->IsVisible())
- {
- // Check if we are searching the local or remote templates
- if (mpCurView == mpLocalView)
- localSearchMoveTo(nMenuId);
- }
- else
- {
- // Check if we are displaying the local or remote templates
- if (mpCurView == mpLocalView)
- localMoveTo(nMenuId);
- else
- remoteMoveTo(nMenuId);
- }
-
- return false;
-}
-
IMPL_LINK_TYPED(SfxTemplateManagerDlg, RepositoryMenuSelectHdl, Menu*, pMenu, bool)
{
sal_uInt16 nMenuId = pMenu->GetCurItemId();
@@ -672,64 +572,232 @@ IMPL_LINK_TYPED(SfxTemplateManagerDlg, DefaultTemplateMenuSelectHdl, Menu*, pMen
IMPL_LINK_NOARG_TYPED(SfxTemplateManagerDlg, OkClickHdl, Button*, void)
{
- if(!mbIsSaveMode)
- {
- OnTemplateOpen();
- EndDialog(RET_OK);
- }
- else
- OnTemplateSaveAs();
+ OnTemplateOpen();
+ EndDialog(RET_OK);
}
-IMPL_LINK_NOARG_TYPED(SfxTemplateManagerDlg, OpenRegionHdl, void*, void)
+IMPL_LINK_NOARG_TYPED(SfxTemplateManagerDlg, MoveClickHdl, Button*, void)
{
- maSelFolders.clear();
- maSelTemplates.clear();
+ // modal dialog to select templates category
+ ScopedVclPtrInstance<SfxTemplateCategoryDialog> aDlg;
+ aDlg->SetCategoryLBEntries(mpLocalView->getFolderNames());
- mpViewBar->ShowItem(VIEWBAR_NEW_FOLDER, mpCurView->isNestedRegionAllowed());
+ size_t nItemId = 0;
- if (!mbIsSaveMode)
+ if(aDlg->Execute() == RET_OK)
{
- mpViewBar->ShowItem(VIEWBAR_IMPORT, mpCurView->isImportAllowed());
- mpOKButton->Disable();
+ OUString sCategory = aDlg->GetSelectedCategory();
+ bool bIsNewCategory = aDlg->IsNewCategoryCreated();
+ if(bIsNewCategory)
+ {
+ if (!sCategory.isEmpty())
+ nItemId = mpLocalView->createRegion(sCategory);
+ }
+ else
+ {
+ nItemId = mpLocalView->getRegionId(sCategory);
+ }
}
- mpTemplateBar->Hide();
+ if(nItemId)
+ {
+ if (mpSearchView->IsVisible())
+ {
+ // Check if we are searching the local or remote templates
+ if (mpCurView == mpLocalView)
+ localSearchMoveTo(nItemId);
+ }
+ else
+ {
+ // Check if we are displaying the local or remote templates
+ if (mpCurView == mpLocalView)
+ localMoveTo(nItemId);
+ else
+ remoteMoveTo(nItemId);
+ }
+ }
+
+ mpLocalView->reload();
+}
+
+IMPL_LINK_NOARG_TYPED(SfxTemplateManagerDlg, ExportClickHdl, Button*, void)
+{
+ OnTemplateExport();
+}
+
+IMPL_LINK_NOARG_TYPED(SfxTemplateManagerDlg, ImportClickHdl, Button*, void)
+{
+ //Modal Dialog to select Category
+ ScopedVclPtrInstance<SfxTemplateCategoryDialog> aDlg;
+ aDlg->SetCategoryLBEntries(mpLocalView->getFolderNames());
+
+ if(aDlg->Execute() == RET_OK)
+ {
+ OUString sCategory = aDlg->GetSelectedCategory();
+ bool bIsNewCategory = aDlg->IsNewCategoryCreated();
+ if(bIsNewCategory)
+ {
+ if(mpCurView->createRegion(sCategory))
+ {
+ mpCBFolder->InsertEntry(sCategory);
+ OnTemplateImportCategory(sCategory);
+ }
+ else
+ {
+ OUString aMsg( SfxResId(STR_CREATE_ERROR).toString() );
+ ScopedVclPtrInstance<MessageDialog>::Create(this, aMsg.replaceFirst("$1", sCategory))->Execute();
+ return;
+ }
+ }
+ else
+ OnTemplateImportCategory(sCategory);
+ }
+
+ mpLocalView->reload();
+ mpLocalView->showAllTemplates();
+ mpCBApp->SelectEntryPos(0);
+ mpCBFolder->SelectEntryPos(0);
+}
+
+IMPL_LINK_NOARG_TYPED(SfxTemplateManagerDlg, LinkClickHdl, Button*, void)
+{
+ OnTemplateLink();
+}
+
+IMPL_LINK_NOARG_TYPED(SfxTemplateManagerDlg, OpenRegionHdl, void*, void)
+{
+ maSelTemplates.clear();
+
+ mpOKButton->Disable();
+
mpViewBar->Show();
mpActionBar->Show();
}
+IMPL_LINK_TYPED(SfxTemplateManagerDlg, RightClickHdl, ThumbnailViewItem*, pItem, void)
+{
+ const TemplateViewItem *pViewItem = dynamic_cast<TemplateViewItem*>(pItem);
+
+ if (pViewItem)
+ {
+ if(mpCurView == mpLocalView)
+ {
+ if(mpSearchView->IsVisible())
+ mpSearchView->createContextMenu();
+ else
+ mpLocalView->createContextMenu();
+ }
+ }
+}
+
+
IMPL_LINK_TYPED(SfxTemplateManagerDlg, OpenTemplateHdl, ThumbnailViewItem*, pItem, void)
{
- if (!mbIsSaveMode)
+ uno::Sequence< PropertyValue > aArgs(4);
+ aArgs[0].Name = "AsTemplate";
+ aArgs[0].Value <<= true;
+ aArgs[1].Name = "MacroExecutionMode";
+ aArgs[1].Value <<= MacroExecMode::USE_CONFIG;
+ aArgs[2].Name = "UpdateDocMode";
+ aArgs[2].Value <<= UpdateDocMode::ACCORDING_TO_CONFIG;
+ aArgs[3].Name = "InteractionHandler";
+ aArgs[3].Value <<= task::InteractionHandler::createWithParent( ::comphelper::getProcessComponentContext(), nullptr );
+
+ TemplateViewItem *pTemplateItem = static_cast<TemplateViewItem*>(pItem);
+
+ try
+ {
+ mxDesktop->loadComponentFromURL(pTemplateItem->getPath(),"_default", 0, aArgs );
+ }
+ catch( const uno::Exception& )
{
- uno::Sequence< PropertyValue > aArgs(4);
- aArgs[0].Name = "AsTemplate";
- aArgs[0].Value <<= true;
- aArgs[1].Name = "MacroExecutionMode";
- aArgs[1].Value <<= MacroExecMode::USE_CONFIG;
- aArgs[2].Name = "UpdateDocMode";
- aArgs[2].Value <<= UpdateDocMode::ACCORDING_TO_CONFIG;
- aArgs[3].Name = "InteractionHandler";
- aArgs[3].Value <<= task::InteractionHandler::createWithParent( ::comphelper::getProcessComponentContext(), nullptr );
-
- TemplateViewItem *pTemplateItem = static_cast<TemplateViewItem*>(pItem);
+ }
- try
+ Close();
+}
+
+IMPL_LINK_TYPED(SfxTemplateManagerDlg, EditTemplateHdl, ThumbnailViewItem*, pItem, void)
+{
+ uno::Sequence< PropertyValue > aArgs(3);
+ aArgs[0].Name = "AsTemplate";
+ aArgs[0].Value <<= false;
+ aArgs[1].Name = "MacroExecutionMode";
+ aArgs[1].Value <<= MacroExecMode::USE_CONFIG;
+ aArgs[2].Name = "UpdateDocMode";
+ aArgs[2].Value <<= UpdateDocMode::ACCORDING_TO_CONFIG;
+
+ uno::Reference< XStorable > xStorable;
+ TemplateViewItem *pViewItem = static_cast<TemplateViewItem*>(pItem);
+
+ try
+ {
+ xStorable.set( mxDesktop->loadComponentFromURL(pViewItem->getPath(),"_default", 0, aArgs ),
+ uno::UNO_QUERY );
+ }
+ catch( const uno::Exception& )
+ {
+ }
+
+ Close();
+}
+
+IMPL_LINK_TYPED(SfxTemplateManagerDlg, DeleteTemplateHdl, ThumbnailViewItem*, pItem, void)
+{
+ ScopedVclPtrInstance< MessageDialog > aQueryDlg(this, SfxResId(STR_QMSG_SEL_TEMPLATE_DELETE), VCL_MESSAGE_QUESTION, VCL_BUTTONS_YES_NO);
+
+ if ( aQueryDlg->Execute() != RET_YES )
+ return;
+
+ OUString aDeletedTemplate;
+
+ if(mpSearchView->IsVisible())
+ {
+ TemplateSearchViewItem *pSrchItem = static_cast<TemplateSearchViewItem*>(pItem);
+
+ if (!mpLocalView->removeTemplate((pSrchItem)->mnAssocId, pSrchItem->mnRegionId))
{
- mxDesktop->loadComponentFromURL(pTemplateItem->getPath(),"_default", 0, aArgs );
+ aDeletedTemplate = (pSrchItem)->maTitle;
}
- catch( const uno::Exception& )
+ }
+ else
+ {
+ TemplateViewItem *pViewItem = static_cast<TemplateViewItem*>(pItem);
+ sal_uInt16 nRegionItemId = mpLocalView->getRegionId(pViewItem->mnRegionId);
+
+ if (!mpLocalView->removeTemplate((pViewItem)->mnId,nRegionItemId))
{
+ aDeletedTemplate = (pItem)->maTitle;
}
+ }
- Close();
+ if (!aDeletedTemplate.isEmpty())
+ {
+ OUString aMsg( SfxResId(STR_MSG_ERROR_DELETE_TEMPLATE).toString() );
+ ScopedVclPtrInstance<MessageDialog>::Create(this, aMsg.replaceFirst("$1",aDeletedTemplate))->Execute();
+ }
+
+ mpLocalView->reload();
+
+ if(mpSearchView->IsVisible())
+ SearchUpdateHdl(*mpSearchFilter);
+}
+
+IMPL_LINK_TYPED(SfxTemplateManagerDlg, DefaultTemplateHdl, ThumbnailViewItem*, pItem, void)
+{
+ TemplateViewItem *pViewItem = static_cast<TemplateViewItem*>(pItem);
+
+ OUString aServiceName;
+ if (lcl_getServiceName(pViewItem->getPath(),aServiceName))
+ {
+ SfxObjectFactory::SetStandardTemplate(aServiceName,pViewItem->getPath());
+
+ createDefaultTemplateMenu();
}
}
IMPL_LINK_NOARG_TYPED(SfxTemplateManagerDlg, SearchUpdateHdl, Edit&, void)
{
- OUString aKeyword = mpSearchEdit->GetText();
+ OUString aKeyword = mpSearchFilter->GetText();
if (!aKeyword.isEmpty())
{
@@ -743,17 +811,14 @@ IMPL_LINK_NOARG_TYPED(SfxTemplateManagerDlg, SearchUpdateHdl, Edit&, void)
mpCurView->Hide();
}
- bool bDisplayFolder = !mpCurView->isNonRootRegionVisible();
-
std::vector<TemplateItemProperties> aItems =
- mpLocalView->getFilteredItems(SearchView_Keyword(aKeyword, getCurrentFilter()));
+ mpLocalView->getFilteredItems(SearchView_Keyword(aKeyword, getCurrentApplicationFilter()));
for (TemplateItemProperties& rItem : aItems)
{
OUString aFolderName;
- if (bDisplayFolder)
- aFolderName = mpLocalView->getRegionName(rItem.nRegionId);
+ aFolderName = mpLocalView->getRegionName(rItem.nRegionId);
mpSearchView->AppendItem(rItem.nId,mpLocalView->getRegionId(rItem.nRegionId),
rItem.nDocId,
@@ -770,36 +835,12 @@ IMPL_LINK_NOARG_TYPED(SfxTemplateManagerDlg, SearchUpdateHdl, Edit&, void)
mpSearchView->deselectItems();
mpSearchView->Hide();
mpCurView->Show();
- }
-}
-
-void SfxTemplateManagerDlg::OnRegionState (const ThumbnailViewItem *pItem)
-{
- if (pItem->isSelected())
- {
- if (maSelFolders.empty() && !mbIsSaveMode)
+ mpCurView->filterItems(ViewFilter_Application(getCurrentApplicationFilter()));
+ if(mpCurView == mpLocalView)
{
- mpViewBar->ShowItem(VIEWBAR_IMPORT);
- mpViewBar->ShowItem(VIEWBAR_DELETE);
- mpViewBar->HideItem(VIEWBAR_NEW_FOLDER);
+ OUString sLastFolder = mpCBFolder->GetSelectEntry();
+ mpLocalView->showRegion(sLastFolder);
}
-
- maSelFolders.insert(pItem);
- if(mbIsSaveMode)
- mpOKButton->Enable();
- }
- else
- {
- maSelFolders.erase(pItem);
-
- if (maSelFolders.empty() && !mbIsSaveMode)
- {
- mpViewBar->HideItem(VIEWBAR_IMPORT);
- mpViewBar->HideItem(VIEWBAR_DELETE);
- mpViewBar->ShowItem(VIEWBAR_NEW_FOLDER);
- }
- if(!mbIsSaveMode)
- mpOKButton->Disable();
}
}
@@ -811,25 +852,11 @@ void SfxTemplateManagerDlg::OnTemplateState (const ThumbnailViewItem *pItem)
{
if (maSelTemplates.empty())
{
- mpViewBar->Show(false);
- mpTemplateBar->Show();
mpOKButton->Enable();
}
else if (maSelTemplates.size() != 1 || !bInSelection)
{
- if (!mbIsSaveMode)
- {
- mpTemplateBar->HideItem(TEMPLATEBAR_OPEN);
- mpTemplateBar->HideItem(TEMPLATEBAR_EDIT);
- mpTemplateBar->HideItem(TEMPLATEBAR_DEFAULT);
- }
- else
- {
- mpTemplateBar->HideItem(TEMPLATEBAR_SAVE);
- mpTemplateBar->HideItem(TEMPLATEBAR_DEFAULT);
- }
- if( !mbIsSaveMode )
- mpOKButton->Disable();
+ mpOKButton->Disable();
}
if (!bInSelection)
@@ -843,31 +870,28 @@ void SfxTemplateManagerDlg::OnTemplateState (const ThumbnailViewItem *pItem)
if (maSelTemplates.empty())
{
- mpTemplateBar->Show(false);
- mpViewBar->Show();
- if(!mbIsSaveMode)
- mpOKButton->Disable();
+ mpOKButton->Disable();
}
else if (maSelTemplates.size() == 1)
{
- if (!mbIsSaveMode)
- {
- mpTemplateBar->ShowItem(TEMPLATEBAR_OPEN);
- mpTemplateBar->ShowItem(TEMPLATEBAR_EDIT);
- mpTemplateBar->ShowItem(TEMPLATEBAR_DEFAULT);
- }
- else
- {
- mpTemplateBar->ShowItem(TEMPLATEBAR_SAVE);
- mpTemplateBar->ShowItem(TEMPLATEBAR_DEFAULT);
- }
mpOKButton->Enable();
}
}
}
+
+ if(maSelTemplates.empty())
+ {
+ mpMoveButton->Disable();
+ mpExportButton->Disable();
+ }
+ else
+ {
+ mpMoveButton->Enable();
+ mpExportButton->Enable();
+ }
}
-void SfxTemplateManagerDlg::OnTemplateImport ()
+void SfxTemplateManagerDlg::OnTemplateImportCategory(OUString sCategory)
{
sal_Int16 nDialogType =
css::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE;
@@ -931,41 +955,15 @@ void SfxTemplateManagerDlg::OnTemplateImport ()
if (aFiles.hasElements())
{
- if (!maSelFolders.empty())
- {
- //Import to the selected regions
- std::set<const ThumbnailViewItem*,selection_cmp_fn>::const_iterator pIter;
- for (pIter = maSelFolders.begin(); pIter != maSelFolders.end(); ++pIter)
- {
- OUString aTemplateList;
- TemplateContainerItem *pFolder = const_cast<TemplateContainerItem*>(static_cast<const TemplateContainerItem*>(*pIter));
-
- for (size_t i = 0, n = aFiles.getLength(); i < n; ++i)
- {
- if(!mpLocalView->copyFrom(pFolder,aFiles[i]))
- {
- if (aTemplateList.isEmpty())
- aTemplateList = aFiles[i];
- else
- aTemplateList = aTemplateList + "\n" + aFiles[i];
- }
- }
-
- if (!aTemplateList.isEmpty())
- {
- OUString aMsg(SfxResId(STR_MSG_ERROR_IMPORT).toString());
- aMsg = aMsg.replaceFirst("$1",pFolder->maTitle);
- ScopedVclPtrInstance<MessageDialog>::Create(this, aMsg.replaceFirst("$2",aTemplateList))->Execute();
- }
- }
- }
- else
+ //Import to the selected regions
+ TemplateContainerItem* pContItem = const_cast<TemplateContainerItem*>(static_cast<const TemplateContainerItem*>(mpLocalView->getRegion(sCategory)));
+ if(pContItem)
{
- //Import to current region
OUString aTemplateList;
+
for (size_t i = 0, n = aFiles.getLength(); i < n; ++i)
{
- if(!mpLocalView->copyFrom(aFiles[i]))
+ if(!mpLocalView->copyFrom(pContItem,aFiles[i]))
{
if (aTemplateList.isEmpty())
aTemplateList = aFiles[i];
@@ -977,12 +975,10 @@ void SfxTemplateManagerDlg::OnTemplateImport ()
if (!aTemplateList.isEmpty())
{
OUString aMsg(SfxResId(STR_MSG_ERROR_IMPORT).toString());
- aMsg = aMsg.replaceFirst("$1",mpLocalView->getCurRegionName());
+ aMsg = aMsg.replaceFirst("$1",pContItem->maTitle);
ScopedVclPtrInstance<MessageDialog>::Create(this, aMsg.replaceFirst("$2",aTemplateList))->Execute();
}
}
-
- mpLocalView->Invalidate(InvalidateFlags::NoErase);
}
}
}
@@ -1036,7 +1032,6 @@ void SfxTemplateManagerDlg::OnTemplateExport()
// export templates from the current view
sal_uInt16 i = 1;
- sal_uInt16 nRegionItemId = mpLocalView->getCurRegionItemId();
std::set<const ThumbnailViewItem*,selection_cmp_fn>::const_iterator pIter = maSelTemplates.begin();
for (pIter = maSelTemplates.begin(); pIter != maSelTemplates.end(); ++pIter, ++i)
@@ -1052,7 +1047,9 @@ void SfxTemplateManagerDlg::OnTemplateExport()
OUString aPath = aPathObj.GetMainURL( INetURLObject::NO_DECODE );
- if (!mpLocalView->exportTo(pItem->mnId,nRegionItemId,aPath))
+ if (!mpLocalView->exportTo(pItem->mnId,
+ mpLocalView->getRegionId(pItem->mnRegionId), //pItem->mnRegionId does not store actual region Id
+ aPath))
{
if (aTemplateList.isEmpty())
aTemplateList = pItem->maTitle;
@@ -1072,30 +1069,6 @@ void SfxTemplateManagerDlg::OnTemplateExport()
}
}
-void SfxTemplateManagerDlg::OnTemplateSearch ()
-{
- bool bVisible = mpSearchEdit->IsVisible();
-
- mpActionBar->SetItemState(mpActionBar->GetItemId(ACTIONBAR_SEARCH),
- bVisible? TRISTATE_FALSE: TRISTATE_TRUE);
-
- // fdo#74782 We are switching views. No matter to which state,
- // deselect and hide our current SearchView items.
- mpSearchView->deselectItems();
- mpSearchView->Hide();
-
- // Hide search view
- if (bVisible)
- {
- mpCurView->Show();
- }
-
- mpSearchEdit->Show(!bVisible);
- mpSearchEdit->SetText(OUString());
- if (!bVisible)
- mpSearchEdit->GrabFocus();
-}
-
void SfxTemplateManagerDlg::OnTemplateLink ()
{
OUString sNode("TemplateRepositoryURL");
@@ -1136,109 +1109,7 @@ void SfxTemplateManagerDlg::OnTemplateOpen ()
OpenTemplateHdl(pItem);
}
-void SfxTemplateManagerDlg::OnTemplateEdit ()
-{
- uno::Sequence< PropertyValue > aArgs(3);
- aArgs[0].Name = "AsTemplate";
- aArgs[0].Value <<= false;
- aArgs[1].Name = "MacroExecutionMode";
- aArgs[1].Value <<= MacroExecMode::USE_CONFIG;
- aArgs[2].Name = "UpdateDocMode";
- aArgs[2].Value <<= UpdateDocMode::ACCORDING_TO_CONFIG;
-
- uno::Reference< XStorable > xStorable;
- std::set<const ThumbnailViewItem*,selection_cmp_fn> aSelTemplates(
- maSelTemplates); // Avoids invalid iterators from LoseFocus
- std::set<const ThumbnailViewItem*,selection_cmp_fn>::const_iterator pIter;
- for (pIter = aSelTemplates.begin(); pIter != aSelTemplates.end(); ++pIter)
- {
- const TemplateViewItem *pItem = static_cast<const TemplateViewItem*>(*pIter);
-
- try
- {
- xStorable.set( mxDesktop->loadComponentFromURL(pItem->getPath(),"_default", 0, aArgs ),
- uno::UNO_QUERY );
- }
- catch( const uno::Exception& )
- {
- }
- }
-
- Close();
-}
-
-void SfxTemplateManagerDlg::OnTemplateDelete ()
-{
- ScopedVclPtrInstance< MessageDialog > aQueryDlg(this, SfxResId(STR_QMSG_SEL_TEMPLATE_DELETE), VCL_MESSAGE_QUESTION, VCL_BUTTONS_YES_NO);
-
- if ( aQueryDlg->Execute() != RET_YES )
- return;
-
- OUString aTemplateList;
-
- if (mpSearchView->IsVisible())
- {
- std::set<const ThumbnailViewItem*,selection_cmp_fn> aSelTemplates = maSelTemplates; //Avoids invalid iterators
-
- std::set<const ThumbnailViewItem*,selection_cmp_fn>::const_iterator pIter;
- for (pIter = aSelTemplates.begin(); pIter != aSelTemplates.end(); ++pIter)
- {
- const TemplateSearchViewItem *pItem =
- static_cast<const TemplateSearchViewItem*>(*pIter);
-
- if (!mpLocalView->removeTemplate(pItem->mnAssocId,pItem->mnRegionId))
- {
- if (aTemplateList.isEmpty())
- aTemplateList = pItem->maTitle;
- else
- aTemplateList = aTemplateList + "\n" + pItem->maTitle;
- }
- else
- mpSearchView->RemoveItem(pItem->mnId);
- }
- }
- else
- {
- sal_uInt16 nRegionItemId = mpLocalView->getCurRegionItemId();
- std::set<const ThumbnailViewItem*,selection_cmp_fn> aSelTemplates = maSelTemplates; //Avoid invalid iterators
-
- std::set<const ThumbnailViewItem*,selection_cmp_fn>::const_iterator pIter;
- for (pIter = aSelTemplates.begin(); pIter != aSelTemplates.end(); ++pIter)
- {
- if (!mpLocalView->removeTemplate((*pIter)->mnId,nRegionItemId))
- {
- if (aTemplateList.isEmpty())
- aTemplateList = (*pIter)->maTitle;
- else
- aTemplateList = aTemplateList + "\n" + (*pIter)->maTitle;
- }
- }
- }
-
- if (!aTemplateList.isEmpty())
- {
- OUString aMsg( SfxResId(STR_MSG_ERROR_DELETE_TEMPLATE).toString() );
- ScopedVclPtrInstance<MessageDialog>::Create(this, aMsg.replaceFirst("$1",aTemplateList))->Execute();
- }
-}
-
-void SfxTemplateManagerDlg::OnTemplateAsDefault ()
-{
- if (!maSelTemplates.empty())
- {
- const TemplateViewItem *pItem = static_cast<const TemplateViewItem*>(*(maSelTemplates.begin()));
-
- OUString aServiceName;
- if (lcl_getServiceName(pItem->getPath(),aServiceName))
- {
- SfxObjectFactory::SetStandardTemplate(aServiceName,pItem->getPath());
-
- createDefaultTemplateMenu();
- }
- }
-}
-
-void SfxTemplateManagerDlg::OnFolderNew()
+void SfxTemplateManagerDlg::OnCategoryNew()
{
ScopedVclPtrInstance< InputDialog > dlg(SfxResId(STR_INPUT_NEW).toString(),this);
@@ -1248,42 +1119,51 @@ void SfxTemplateManagerDlg::OnFolderNew()
{
OUString aName = dlg->GetEntryText();
- mpCurView->createRegion(aName);
+ if(mpCurView->createRegion(aName))
+ mpCBFolder->InsertEntry(aName);
+ else
+ {
+ OUString aMsg( SfxResId(STR_CREATE_ERROR).toString() );
+ ScopedVclPtrInstance<MessageDialog>::Create(this, aMsg.replaceFirst("$1", aName))->Execute();
+ }
}
}
-void SfxTemplateManagerDlg::OnFolderDelete()
+void SfxTemplateManagerDlg::OnCategoryDelete()
{
- ScopedVclPtrInstance< MessageDialog > aQueryDlg(this, SfxResId(STR_QMSG_SEL_FOLDER_DELETE), VCL_MESSAGE_QUESTION, VCL_BUTTONS_YES_NO);
+ ScopedVclPtrInstance< SfxTemplateCategoryDialog > aDlg;
+ aDlg->SetCategoryLBEntries(mpLocalView->getFolderNames());
+ aDlg->HideNewCategoryOption();
+ aDlg->SetText(SfxResId(STR_CATEGORY_DELETE).toString());
+ aDlg->SetSelectLabelText(SfxResId(STR_CATEGORY_SELECT).toString());
- if ( aQueryDlg->Execute() != RET_YES )
- return;
+ if(aDlg->Execute() == RET_OK)
+ {
+ OUString sCategory = aDlg->GetSelectedCategory();
+ aDlg->Close();
+ ScopedVclPtrInstance< MessageDialog > popupDlg(this, SfxResId(STR_QMSG_SEL_FOLDER_DELETE),
+ VCL_MESSAGE_QUESTION, VCL_BUTTONS_YES_NO);
- OUString aFolderList;
+ if ( popupDlg->Execute() != RET_YES )
+ return;
- std::set<const ThumbnailViewItem*,selection_cmp_fn>::const_iterator pIter;
- std::set<const ThumbnailViewItem*,selection_cmp_fn> aSelFolders = maSelFolders; //Copy to avoid invalidating an iterator
+ sal_Int16 nItemId = mpLocalView->getRegionId(sCategory);
- for (pIter = aSelFolders.begin(); pIter != aSelFolders.end(); ++pIter)
- {
- if (!mpLocalView->removeRegion((*pIter)->mnId))
+ if (!mpLocalView->removeRegion(nItemId))
{
- if (aFolderList.isEmpty())
- aFolderList = (*pIter)->maTitle;
- else
- aFolderList = aFolderList + "\n" + (*pIter)->maTitle;
-
- ++pIter;
- if (pIter == aSelFolders.end())
- break;
+ OUString sMsg( SfxResId(STR_MSG_ERROR_DELETE_FOLDER).toString() );
+ ScopedVclPtrInstance<MessageDialog>::Create(this, sMsg.replaceFirst("$1",sCategory))->Execute();
+ }
+ else
+ {
+ mpCBFolder->RemoveEntry(sCategory);
}
}
- if (!aFolderList.isEmpty())
- {
- OUString aMsg( SfxResId(STR_MSG_ERROR_DELETE_FOLDER).toString() );
- ScopedVclPtrInstance<MessageDialog>::Create(this, aMsg.replaceFirst("$1",aFolderList))->Execute();
- }
+ mpLocalView->reload();
+ mpLocalView->showAllTemplates();
+ mpCBApp->SelectEntryPos(0);
+ mpCBFolder->SelectEntryPos(0);
}
void SfxTemplateManagerDlg::OnRepositoryDelete()
@@ -1297,80 +1177,6 @@ void SfxTemplateManagerDlg::OnRepositoryDelete()
}
}
-void SfxTemplateManagerDlg::OnTemplateSaveAs()
-{
- assert(m_xModel.is());
-
- if (!mpLocalView->isNonRootRegionVisible() && maSelFolders.empty())
- {
- ScopedVclPtrInstance<MessageDialog>::Create(this, SfxResId(STR_MSG_ERROR_SELECT_FOLDER))->Execute();
- return;
- }
-
- ScopedVclPtrInstance< InputDialog > aDlg(SfxResId(STR_INPUT_TEMPLATE_NEW).toString(),this);
-
- if (aDlg->Execute())
- {
- OUString aName = aDlg->GetEntryText();
-
- if (!aName.isEmpty())
- {
- OUString aFolderList;
- OUString aQMsg(SfxResId(STR_QMSG_TEMPLATE_OVERWRITE).toString());
- ScopedVclPtrInstance< MessageDialog > aQueryDlg(this, OUString(), VCL_MESSAGE_QUESTION, VCL_BUTTONS_YES_NO);
-
- if (mpLocalView->isNonRootRegionVisible())
- {
- sal_uInt16 nRegionItemId = mpLocalView->getRegionId(mpLocalView->getCurRegionId()-1);
-
- if (!mpLocalView->isTemplateNameUnique(nRegionItemId,aName))
- {
- aQMsg = aQMsg.replaceFirst("$1",aName);
- aQueryDlg->set_primary_text(aQMsg.replaceFirst("$2",mpLocalView->getCurRegionName()));
-
- if (aQueryDlg->Execute() == RET_NO)
- return;
- }
-
- if (!mpLocalView->saveTemplateAs(nRegionItemId,m_xModel,aName))
- aFolderList = mpLocalView->getCurRegionName();
- }
- else
- {
- std::set<const ThumbnailViewItem*,selection_cmp_fn>::const_iterator pIter;
- for (pIter = maSelFolders.begin(); pIter != maSelFolders.end(); ++pIter)
- {
- TemplateContainerItem *pItem = const_cast<TemplateContainerItem*>(static_cast<const TemplateContainerItem*>(*pIter));
-
- if (!mpLocalView->isTemplateNameUnique(pItem->mnId,aName))
- {
- OUString aDQMsg = aQMsg.replaceFirst("$1",aName);
- aQueryDlg->set_primary_text(aDQMsg.replaceFirst("$2",pItem->maTitle));
-
- if (aQueryDlg->Execute() == RET_NO)
- continue;
- }
-
- if (!mpLocalView->saveTemplateAs(pItem,m_xModel,aName))
- {
- if (aFolderList.isEmpty())
- aFolderList = (*pIter)->maTitle;
- else
- aFolderList = aFolderList + "\n" + (*pIter)->maTitle;
- }
- }
- }
-
- if (!aFolderList.isEmpty())
- {
- }
-
- // After save file, just close the dialog
- Close();
- }
- }
-}
-
void SfxTemplateManagerDlg::createRepositoryMenu()
{
mpRepositoryMenu->Clear();
@@ -1415,53 +1221,19 @@ void SfxTemplateManagerDlg::switchMainView(bool bDisplayLocal)
{
mpCurView = mpLocalView.get();
- mpViewBar->HideItem(VIEWBAR_DELETE);
-
- // Enable deleting and exporting items from the filesystem
- mpTemplateBar->ShowItem(TEMPLATEBAR_EXPORT);
- mpTemplateBar->ShowItem(TEMPLATEBAR_DELETE);
-
mpRemoteView->Hide();
mpLocalView->Show();
}
else
{
mpCurView = mpRemoteView.get();
-
- mpViewBar->ShowItem(VIEWBAR_DELETE);
-
- // Disable deleting and exporting items from remote repositories
- mpTemplateBar->HideItem(TEMPLATEBAR_EXPORT);
- mpTemplateBar->HideItem(TEMPLATEBAR_DELETE);
-
mpLocalView->Hide();
mpRemoteView->Show();
}
}
-void SfxTemplateManagerDlg::localMoveTo(sal_uInt16 nMenuId)
+void SfxTemplateManagerDlg::localMoveTo(sal_uInt16 nItemId)
{
- sal_uInt16 nItemId = 0;
-
- if (nMenuId == MNI_MOVE_NEW)
- {
- ScopedVclPtrInstance< InputDialog > dlg(SfxResId(STR_INPUT_NEW).toString(),this);
-
- int ret = dlg->Execute();
-
- if (ret)
- {
- OUString aName = dlg->GetEntryText();
-
- if (!aName.isEmpty())
- nItemId = mpLocalView->createRegion(aName);
- }
- }
- else
- {
- nItemId = mpLocalView->getRegionId(nMenuId-MNI_MOVE_FOLDER_BASE);
- }
-
if (nItemId)
{
// Move templates to desired folder if for some reason move fails
@@ -1487,29 +1259,8 @@ void SfxTemplateManagerDlg::localMoveTo(sal_uInt16 nMenuId)
}
}
-void SfxTemplateManagerDlg::remoteMoveTo(const sal_uInt16 nMenuId)
+void SfxTemplateManagerDlg::remoteMoveTo(const sal_uInt16 nItemId)
{
- sal_uInt16 nItemId = 0;
-
- if (nMenuId == MNI_MOVE_NEW)
- {
- ScopedVclPtrInstance< InputDialog > dlg(SfxResId(STR_INPUT_NEW).toString(),this);
-
- int ret = dlg->Execute();
-
- if (ret)
- {
- OUString aName = dlg->GetEntryText();
-
- if (!aName.isEmpty())
- nItemId = mpLocalView->createRegion(aName);
- }
- }
- else
- {
- nItemId = mpLocalView->getRegionId(nMenuId-MNI_MOVE_FOLDER_BASE);
- }
-
if (nItemId)
{
OUString aTemplateList;
@@ -1541,29 +1292,8 @@ void SfxTemplateManagerDlg::remoteMoveTo(const sal_uInt16 nMenuId)
}
}
-void SfxTemplateManagerDlg::localSearchMoveTo(sal_uInt16 nMenuId)
+void SfxTemplateManagerDlg::localSearchMoveTo(sal_uInt16 nItemId)
{
- sal_uInt16 nItemId = 0;
-
- if (nMenuId == MNI_MOVE_NEW)
- {
- ScopedVclPtrInstance< InputDialog > dlg(SfxResId(STR_INPUT_NEW).toString(),this);
-
- int ret = dlg->Execute();
-
- if (ret)
- {
- OUString aName = dlg->GetEntryText();
-
- if (!aName.isEmpty())
- nItemId = mpLocalView->createRegion(aName);
- }
- }
- else
- {
- nItemId = mpLocalView->getRegionId(nMenuId-MNI_MOVE_FOLDER_BASE);
- }
-
if (nItemId)
{
OUString aTemplateList;
@@ -1599,7 +1329,7 @@ void SfxTemplateManagerDlg::localSearchMoveTo(sal_uInt16 nMenuId)
// Deselect all items and update search results
mpSearchView->deselectItems();
- SearchUpdateHdl(*mpSearchEdit);
+ SearchUpdateHdl(*mpSearchFilter);
}
void SfxTemplateManagerDlg::loadRepositories()
@@ -1735,4 +1465,89 @@ static std::vector<OUString> lcl_getAllFactoryURLs ()
return aList;
}
+
+// Class SfxTemplateCategoryDialog --------------------------------------------------
+
+SfxTemplateCategoryDialog::SfxTemplateCategoryDialog( vcl::Window* pParent):
+ ModalDialog(pParent, "TemplatesCategoryDialog", "sfx/ui/templatecategorydlg.ui"),
+ msSelectedCategory(OUString()),
+ mbIsNewCategory(false)
+{
+ get(mpLBCategory, "categorylb");
+ get(mpNewCategoryEdit, "category_entry");
+ get(mpOKButton, "ok");
+ get(mpSelectLabel, "select_label");
+ get(mpCreateLabel, "create_label");
+
+ mpNewCategoryEdit->SetModifyHdl(LINK(this, SfxTemplateCategoryDialog, NewCategoryEditHdl));
+ mpLBCategory->SetSelectHdl(LINK(this, SfxTemplateCategoryDialog, SelectCategoryHdl));
+
+ mpOKButton->Disable();
+}
+
+SfxTemplateCategoryDialog::~SfxTemplateCategoryDialog()
+{
+ disposeOnce();
+}
+
+void SfxTemplateCategoryDialog::dispose()
+{
+ mpLBCategory.clear();
+ mpNewCategoryEdit.clear();
+ mpOKButton.clear();
+
+ ModalDialog::dispose();
+}
+
+IMPL_LINK_NOARG_TYPED(SfxTemplateCategoryDialog, NewCategoryEditHdl, Edit&, void)
+{
+ OUString sParam = comphelper::string::strip(mpNewCategoryEdit->GetText(), ' ');
+ mpLBCategory->Enable(sParam.isEmpty());
+ if(!sParam.isEmpty())
+ {
+ msSelectedCategory = sParam;
+ mbIsNewCategory = true;
+ mpOKButton->Enable();
+ }
+ else
+ {
+ SelectCategoryHdl(*mpLBCategory);
+ mbIsNewCategory = false;
+ }
+}
+
+IMPL_LINK_NOARG_TYPED(SfxTemplateCategoryDialog, SelectCategoryHdl, ListBox&, void)
+{
+ if(mpLBCategory->GetSelectEntryPos() == 0)
+ {
+ msSelectedCategory = OUString();
+ mpOKButton->Disable();
+ }
+ else
+ {
+ msSelectedCategory = mpLBCategory->GetSelectEntry();
+ mpOKButton->Enable();
+ }
+
+ mbIsNewCategory = false;
+}
+
+void SfxTemplateCategoryDialog::SetCategoryLBEntries(std::vector<OUString> aFolderNames)
+{
+ mpLBCategory->InsertEntry(OUString("None"), 0);
+ if (!aFolderNames.empty())
+ {
+ for (size_t i = 0, n = aFolderNames.size(); i < n; ++i)
+ mpLBCategory->InsertEntry(aFolderNames[i], i+1);
+ }
+ mpLBCategory->SelectEntryPos(0);
+}
+
+void SfxTemplateCategoryDialog::HideNewCategoryOption()
+{
+ mpCreateLabel->Hide();
+ mpNewCategoryEdit->Hide();
+}
+
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/inc/templatesearchview.hxx b/sfx2/source/inc/templatesearchview.hxx
index c45026ebb57d..30b1223c944a 100644
--- a/sfx2/source/inc/templatesearchview.hxx
+++ b/sfx2/source/inc/templatesearchview.hxx
@@ -12,6 +12,9 @@
#include <sfx2/thumbnailview.hxx>
+class TemplateViewItem;
+class PopupMenu;
+
class TemplateSearchView : public ThumbnailView
{
public:
@@ -20,6 +23,18 @@ public:
void setOpenTemplateHdl (const Link<ThumbnailViewItem*, void> &rLink);
+ DECL_LINK_TYPED(ContextMenuSelectHdl, Menu*, bool);
+
+ void setRightClickHdl(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();
+
void AppendItem(sal_uInt16 nAssocItemId, sal_uInt16 nRegionId, sal_uInt16 nIdx,
const OUString &rTitle, const OUString &rSubtitle,
const OUString &rPath, const BitmapEx &rImage );
@@ -27,8 +42,18 @@ public:
protected:
virtual void OnItemDblClicked(ThumbnailViewItem *pItem) override;
+ virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
+
protected:
+ TemplateViewItem *maSelectedItem;
+
+ Point maPosition;
+
Link<ThumbnailViewItem*, void> maOpenTemplateHdl;
+ Link<ThumbnailViewItem*, void> maRightClickHdl;
+ Link<ThumbnailViewItem*,void> maEditTemplateHdl;
+ Link<ThumbnailViewItem*,void> maDeleteTemplateHdl;
+ Link<ThumbnailViewItem*,void> maDefaultTemplateHdl;
};
#endif // INCLUDED_SFX2_SOURCE_INC_TEMPLATESEARCHVIEW_HXX
diff --git a/sfx2/uiconfig/ui/saveastemplatedlg.ui b/sfx2/uiconfig/ui/saveastemplatedlg.ui
new file mode 100644
index 000000000000..49e68329408e
--- /dev/null
+++ b/sfx2/uiconfig/ui/saveastemplatedlg.ui
@@ -0,0 +1,147 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.18.3 -->
+<interface>
+ <requires lib="gtk+" version="3.6"/>
+ <requires lib="LibreOffice" version="1.0"/>
+ <object class="GtkDialog" id="SaveAsTemplateDialog">
+ <property name="can_focus">False</property>
+ <property name="border_width">6</property>
+ <property name="title" translatable="yes">Save As Template</property>
+ <property name="modal">True</property>
+ <property name="type_hint">normal</property>
+ <child internal-child="vbox">
+ <object class="GtkBox" id="dialog-vbox1">
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">2</property>
+ <child internal-child="action_area">
+ <object class="GtkButtonBox" id="dialog-action_area1">
+ <property name="can_focus">False</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="help">
+ <property name="label">gtk-help</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ <property name="secondary">True</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="ok">
+ <property name="label">gtk-ok</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="has_default">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="cancel">
+ <property name="label">gtk-cancel</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">end</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkGrid" id="grid1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_bottom">6</property>
+ <property name="row_spacing">12</property>
+ <property name="column_spacing">12</property>
+ <child>
+ <object class="GtkLabel" id="create_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Enter Template Name</property>
+ <attributes>
+ <attribute name="weight" value="normal"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="name_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="select_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Select Template Category</property>
+ <attributes>
+ <attribute name="weight" value="normal"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox" id="categorylb">
+ <property name="width_request">250</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="0">help</action-widget>
+ <action-widget response="0">ok</action-widget>
+ <action-widget response="0">cancel</action-widget>
+ </action-widgets>
+ </object>
+</interface>
diff --git a/sfx2/uiconfig/ui/templatecategorydlg.ui b/sfx2/uiconfig/ui/templatecategorydlg.ui
new file mode 100644
index 000000000000..57eae1f43e25
--- /dev/null
+++ b/sfx2/uiconfig/ui/templatecategorydlg.ui
@@ -0,0 +1,147 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.18.3 -->
+<interface>
+ <requires lib="gtk+" version="3.6"/>
+ <requires lib="LibreOffice" version="1.0"/>
+ <object class="GtkDialog" id="TemplatesCategoryDialog">
+ <property name="can_focus">False</property>
+ <property name="border_width">6</property>
+ <property name="title" translatable="yes">Select Category</property>
+ <property name="modal">True</property>
+ <property name="type_hint">normal</property>
+ <child internal-child="vbox">
+ <object class="GtkBox" id="dialog-vbox1">
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">2</property>
+ <child internal-child="action_area">
+ <object class="GtkButtonBox" id="dialog-action_area1">
+ <property name="can_focus">False</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="help">
+ <property name="label">gtk-help</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ <property name="secondary">True</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="ok">
+ <property name="label">gtk-ok</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="has_default">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="cancel">
+ <property name="label">gtk-cancel</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">end</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkGrid" id="grid1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_bottom">6</property>
+ <property name="row_spacing">12</property>
+ <property name="column_spacing">12</property>
+ <child>
+ <object class="GtkLabel" id="select_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Select from Existing Category</property>
+ <attributes>
+ <attribute name="weight" value="normal"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox" id="categorylb">
+ <property name="width_request">250</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="create_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">or Create a New Category</property>
+ <attributes>
+ <attribute name="weight" value="normal"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="category_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="0">help</action-widget>
+ <action-widget response="0">ok</action-widget>
+ <action-widget response="0">cancel</action-widget>
+ </action-widgets>
+ </object>
+</interface>
diff --git a/sfx2/uiconfig/ui/templatedlg.ui b/sfx2/uiconfig/ui/templatedlg.ui
index 566996bd2037..385b833019bc 100644
--- a/sfx2/uiconfig/ui/templatedlg.ui
+++ b/sfx2/uiconfig/ui/templatedlg.ui
@@ -1,8 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.20.0 -->
+<!-- Generated with glade 3.18.3 -->
<interface>
<requires lib="gtk+" version="3.6"/>
<requires lib="LibreOffice" version="1.0"/>
+ <object class="GtkImage" id="image1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="pixbuf">sfx2/imglst/actiontemplates020.png</property>
+ </object>
+ <object class="GtkImage" id="image3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="pixbuf">sfx2/imglst/actiontemplates017.png</property>
+ </object>
+ <object class="GtkImage" id="image4">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="pixbuf">sfx2/imglst/actionview010.png</property>
+ </object>
+ <object class="GtkListStore" id="applist">
+ <columns>
+ <!-- column-name gchararray1 -->
+ <column type="gchararray"/>
+ </columns>
+ <data>
+ <row>
+ <col id="0" translatable="yes">All Applications</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes">Documents</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes">Spreadsheets</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes">Presentations</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes">Drawings</col>
+ </row>
+ </data>
+ </object>
+
+ <object class="GtkListStore" id="folderlist">
+ <columns>
+ <!-- column-name gchararray1 -->
+ <column type="gchararray"/>
+ </columns>
+ <data>
+ <row>
+ <col id="0" translatable="yes">All Categories</col>
+ </row>
+ </data>
+ </object>
<object class="GtkDialog" id="TemplateDialog">
<property name="width_request">800</property>
<property name="height_request">600</property>
@@ -79,205 +129,53 @@
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
- <object class="GtkNotebook" id="tab_control">
+ <object class="GtkBox" id="filter_box">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_top">6</property>
+ <property name="margin_bottom">6</property>
+ <property name="spacing">36</property>
<child>
- <object class="GtkBox" id="box2">
+ <object class="GtkEntry" id="search_filter">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="placeholder_text" translatable="yes">Search...</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="box5">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
- <property name="orientation">vertical</property>
- <property name="spacing">6</property>
+ <property name="spacing">12</property>
<child>
- <object class="GtkBox" id="box3">
+ <object class="GtkBox" id="box6">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="hexpand">True</property>
- <property name="spacing">6</property>
+ <property name="spacing">12</property>
<child>
- <object class="GtkToolbar" id="action_view">
+ <object class="GtkComboBox" id="filter_application">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="hexpand">True</property>
- <child>
- <object class="GtkToolButton" id="repository">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="action_name">repository</property>
- <property name="label" translatable="yes">Repository</property>
- <property name="use_underline">True</property>
- <property name="icon_name">sfx2/imglst/actionview026.png</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
- </child>
- <child>
- <object class="GtkToolButton" id="import">
- <property name="can_focus">False</property>
- <property name="action_name">import</property>
- <property name="label" translatable="yes">Import</property>
- <property name="use_underline">True</property>
- <property name="icon_name">sfx2/imglst/actionview010.png</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
- </child>
- <child>
- <object class="GtkToolButton" id="delete">
- <property name="can_focus">False</property>
- <property name="action_name">delete</property>
- <property name="label" translatable="yes">Delete</property>
- <property name="use_underline">True</property>
- <property name="icon_name">sfx2/imglst/actionview025.png</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
- </child>
- <child>
- <object class="GtkToolButton" id="save">
- <property name="can_focus">False</property>
- <property name="action_name">save</property>
- <property name="label" translatable="yes">Save</property>
- <property name="use_underline">True</property>
- <property name="icon_name">sfx2/imglst/actionview028.png</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
- </child>
- <child>
- <object class="GtkToolButton" id="new_folder">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="action_name">new_folder</property>
- <property name="label" translatable="yes">New Folder</property>
- <property name="use_underline">True</property>
- <property name="icon_name">sfx2/imglst/actionview029.png</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
- </child>
+ <property name="resize_mode">queue</property>
+ <property name="model">applist</property>
</object>
<packing>
<property name="expand">False</property>
- <property name="fill">True</property>
+ <property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
- <object class="GtkToolbar" id="action_templates">
+ <object class="GtkComboBox" id="filter_folder">
+ <property name="width_request">250</property>
+ <property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="hexpand">True</property>
- <child>
- <object class="GtkToolButton" id="template_save">
- <property name="can_focus">False</property>
- <property name="action_name">template_save</property>
- <property name="label" translatable="yes">Save</property>
- <property name="use_underline">True</property>
- <property name="icon_name">sfx2/imglst/actionview028.png</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
- </child>
- <child>
- <object class="GtkToolButton" id="open">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="action_name">open</property>
- <property name="label" translatable="yes">Open</property>
- <property name="use_underline">True</property>
- <property name="icon_name">sfx2/imglst/actionview030.png</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
- </child>
- <child>
- <object class="GtkToolButton" id="edit">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="action_name">edit</property>
- <property name="label" translatable="yes">Edit</property>
- <property name="use_underline">True</property>
- <property name="icon_name">sfx2/imglst/actiontemplates019.png</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
- </child>
- <child>
- <object class="GtkToolButton" id="default">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="action_name">default</property>
- <property name="label" translatable="yes">Set as Default</property>
- <property name="use_underline">True</property>
- <property name="icon_name">sfx2/imglst/actiontemplates015.png</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
- </child>
- <child>
- <object class="GtkToolButton" id="move">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="action_name">move</property>
- <property name="label" translatable="yes">Move to Folder</property>
- <property name="use_underline">True</property>
- <property name="icon_name">sfx2/imglst/actiontemplates017.png</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
- </child>
- <child>
- <object class="GtkToolButton" id="export">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="action_name">export</property>
- <property name="label" translatable="yes">Export</property>
- <property name="use_underline">True</property>
- <property name="icon_name">sfx2/imglst/actiontemplates020.png</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
- </child>
- <child>
- <object class="GtkToolButton" id="template_delete">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="action_name">template_delete</property>
- <property name="label" translatable="yes">Delete</property>
- <property name="use_underline">True</property>
- <property name="icon_name">sfx2/imglst/actiontemplates018.png</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
- </child>
+ <property name="model">folderlist</property>
</object>
<packing>
<property name="expand">False</property>
@@ -285,59 +183,129 @@
<property name="position">1</property>
</packing>
</child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Filter</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">end</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">end</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="thumbnailview_box">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_top">6</property>
+ <property name="margin_bottom">6</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="sfxlo-TemplateLocalView" id="template_view">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="sfxlo-TemplateSearchView" id="search_view">
+ <property name="can_focus">True</property>
+ <property name="no_show_all">True</property>
+ <property name="margin">0</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="sfxlo-TemplateRemoteView" id="remote_view">
+ <property name="can_focus">True</property>
+ <property name="no_show_all">True</property>
+ <property name="margin">0</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">4</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="box2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_top">6</property>
+ <property name="margin_bottom">6</property>
+ <child>
+ <object class="GtkBox" id="box3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkToolbar" id="action_view">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
<child>
- <object class="GtkToolbar" id="action_action">
+ <object class="GtkToolButton" id="repository">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="halign">end</property>
- <property name="hexpand">True</property>
- <child>
- <object class="GtkToolButton" id="search">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="action_name">search</property>
- <property name="label" translatable="yes">Search</property>
- <property name="use_underline">True</property>
- <property name="icon_name">sfx2/imglst/actionaction012.png</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
- </child>
- <child>
- <object class="GtkToolButton" id="action_menu">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="action_name">action_menu</property>
- <property name="label" translatable="yes">Action Menu</property>
- <property name="use_underline">True</property>
- <property name="icon_name">sfx2/imglst/actionaction013.png</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
- </child>
- <child>
- <object class="GtkToolButton" id="template_link">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="action_name">template_link</property>
- <property name="label" translatable="yes">Get more templates for %PRODUCTNAME</property>
- <property name="use_underline">True</property>
- <property name="icon_name">sfx2/imglst/actionview010.png</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
- </child>
+ <property name="action_name">repository</property>
+ <property name="label" translatable="yes">Repository</property>
+ <property name="use_underline">True</property>
+ <property name="icon_name">sfx2/imglst/actionview026.png</property>
</object>
<packing>
<property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">2</property>
+ <property name="homogeneous">True</property>
</packing>
</child>
</object>
@@ -348,10 +316,25 @@
</packing>
</child>
<child>
- <object class="GtkEntry" id="search_edit">
- <property name="can_focus">True</property>
+ <object class="GtkToolbar" id="action_action">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">end</property>
<property name="hexpand">True</property>
- <property name="invisible_char">●</property>
+ <child>
+ <object class="GtkToolButton" id="action_menu">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="action_name">action_menu</property>
+ <property name="label" translatable="yes">Action Menu</property>
+ <property name="use_underline">True</property>
+ <property name="icon_name">sfx2/imglst/actionaction013.png</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="homogeneous">True</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">False</property>
@@ -360,11 +343,15 @@
</packing>
</child>
<child>
- <object class="sfxlo-TemplateLocalView" id="template_view">
+ <object class="GtkButton" id="online_link">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Browse Templates Online</property>
+ <property name="image">image5</property>
+ <property name="relief">none</property>
+ <property name="yalign">0.49000000953674316</property>
+ <property name="always_show_image">True</property>
</object>
<packing>
<property name="expand">False</property>
@@ -372,93 +359,83 @@
<property name="position">2</property>
</packing>
</child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="bottom_action_box">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">end</property>
<child>
- <object class="sfxlo-TemplateSearchView" id="search_view">
+ <object class="GtkButton" id="move_btn">
+ <property name="label" translatable="yes">Move</property>
+ <property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="no_show_all">True</property>
- <property name="margin">0</property>
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Move Templates</property>
+ <property name="image">image3</property>
+ <property name="relief">none</property>
+ <property name="yalign">0.50999999046325684</property>
+ <property name="always_show_image">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">3</property>
+ <property name="position">0</property>
</packing>
</child>
<child>
- <object class="sfxlo-TemplateRemoteView" id="remote_view">
+ <object class="GtkButton" id="export_btn">
+ <property name="label" translatable="yes">Export</property>
+ <property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="no_show_all">True</property>
- <property name="margin">0</property>
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Export Templates</property>
+ <property name="image">image1</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">4</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="import_btn">
+ <property name="label" translatable="yes">Import</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Import Templates</property>
+ <property name="image">image4</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">3</property>
</packing>
</child>
- </object>
- </child>
- <child type="tab">
- <object class="GtkLabel" id="filter_docs">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Documents</property>
- </object>
- <packing>
- <property name="tab_fill">False</property>
- </packing>
- </child>
- <child>
- <placeholder/>
- </child>
- <child type="tab">
- <object class="GtkLabel" id="filter_sheets">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Spreadsheets</property>
</object>
<packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
<property name="position">1</property>
- <property name="tab_fill">False</property>
- </packing>
- </child>
- <child>
- <placeholder/>
- </child>
- <child type="tab">
- <object class="GtkLabel" id="filter_presentations">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Presentations</property>
- </object>
- <packing>
- <property name="position">2</property>
- <property name="tab_fill">False</property>
- </packing>
- </child>
- <child>
- <placeholder/>
- </child>
- <child type="tab">
- <object class="GtkLabel" id="filter_draws">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Drawings</property>
- </object>
- <packing>
- <property name="position">3</property>
- <property name="tab_fill">False</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">0</property>
+ <property name="pack_type">end</property>
+ <property name="position">3</property>
</packing>
</child>
</object>
@@ -476,4 +453,9 @@
<action-widget response="0">cancel</action-widget>
</action-widgets>
</object>
+ <object class="GtkImage" id="image5">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="pixbuf">cmd/lc_webhtml.png</property>
+ </object>
</interface>