Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / include / sfx2 / templateabstractview.hxx
blob404b9823d81e0f7d206fe1764979b398b9081153
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #ifndef INCLUDED_SFX2_TEMPLATEABSTRACTVIEW_HXX
11 #define INCLUDED_SFX2_TEMPLATEABSTRACTVIEW_HXX
13 #include <sfx2/templateproperties.hxx>
14 #include <sfx2/thumbnailview.hxx>
15 #include <vcl/button.hxx>
16 #include <vcl/fixed.hxx>
18 //template thumbnail item defines
19 #define TEMPLATE_ITEM_MAX_WIDTH 160
20 #define TEMPLATE_ITEM_MAX_HEIGHT 148
21 #define TEMPLATE_ITEM_PADDING 5
22 #define TEMPLATE_ITEM_MAX_TEXT_LENGTH 20
23 #define TEMPLATE_ITEM_THUMBNAIL_MAX_HEIGHT 96
25 //template thumbnail height with a subtitle
26 #define TEMPLATE_ITEM_MAX_HEIGHT_SUB 160
28 //template thumbnail image defines
29 #define TEMPLATE_THUMBNAIL_MAX_HEIGHT TEMPLATE_ITEM_THUMBNAIL_MAX_HEIGHT - 2*TEMPLATE_ITEM_PADDING
30 #define TEMPLATE_THUMBNAIL_MAX_WIDTH TEMPLATE_ITEM_MAX_WIDTH - 2*TEMPLATE_ITEM_PADDING
32 class SfxDocumentTemplates;
33 class TemplateViewItem;
34 class TemplateContainerItem;
36 enum class FILTER_APPLICATION
38 NONE,
39 WRITER,
40 CALC,
41 IMPRESS,
42 DRAW
45 // Display template items depending on the generator application
46 class ViewFilter_Application
48 public:
50 ViewFilter_Application (FILTER_APPLICATION App)
51 : mApp(App)
54 virtual ~ViewFilter_Application () {}
56 bool operator () (const ThumbnailViewItem *pItem);
58 static bool isFilteredExtension(FILTER_APPLICATION filter, const OUString &rExt);
59 bool isValid (const OUString& rPath) const;
61 protected:
63 FILTER_APPLICATION mApp;
66 class SFX2_DLLPUBLIC TemplateAbstractView : public ThumbnailView
68 public:
70 TemplateAbstractView(vcl::Window *pParent, WinBits nWinStyle, bool bDisableTransientChildren);
71 TemplateAbstractView(vcl::Window* pParent);
73 virtual ~TemplateAbstractView();
74 virtual void dispose() override;
76 void insertItem (const TemplateItemProperties &rTemplate);
78 // Fill view with new item list
79 void insertItems (const std::vector<TemplateItemProperties> &rTemplates, bool isRegionSelected = true, bool bShowCategoryInTooltip = false);
81 // Fill view with template folders thumbnails
82 virtual void Populate () { }
84 virtual void reload () { }
86 virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
88 virtual void RequestHelp( const HelpEvent& rHEvt ) override;
90 virtual void Command( const CommandEvent& rCEvt ) override;
92 virtual void KeyInput( const KeyEvent& rKEvt ) override;
94 virtual void showAllTemplates () = 0;
96 virtual void showRegion (TemplateContainerItem *pItem) = 0;
98 virtual sal_uInt16 createRegion (const OUString &rName) = 0;
100 sal_uInt16 getCurRegionId () const { return mnCurRegionId;}
102 const OUString& getCurRegionName () const { return maCurRegionName;}
104 // Check if the root region is visible or not.
105 bool isNonRootRegionVisible () const { return mnCurRegionId > 0;}
107 void setOpenRegionHdl(const Link<void*,void> &rLink);
109 void setCreateContextMenuHdl(const Link<ThumbnailViewItem*,void> &rLink);
111 void setOpenTemplateHdl(const Link<ThumbnailViewItem*,void> &rLink);
113 void setEditTemplateHdl(const Link<ThumbnailViewItem*,void> &rLink);
115 void setDeleteTemplateHdl(const Link<ThumbnailViewItem*,void> &rLink);
117 void setDefaultTemplateHdl(const Link<ThumbnailViewItem*,void> &rLink);
119 void updateThumbnailDimensions(long itemMaxSize);
121 long getThumbnailWidth() const { return mnThumbnailWidth;}
122 long getThumbnailHeight() const {return mnThumbnailHeight;}
124 void RemoveDefaultTemplateIcon( const OUString& rPath);
126 static BitmapEx scaleImg (const BitmapEx &rImg, long width, long height);
128 static BitmapEx getDefaultThumbnail( const OUString& rPath );
130 static BitmapEx fetchThumbnail (const OUString &msURL, long width, long height);
132 protected:
134 virtual void OnItemDblClicked(ThumbnailViewItem *pItem) override;
136 public:
137 static bool IsDefaultTemplate(const OUString& rPath);
139 protected:
141 sal_uInt16 mnCurRegionId;
142 OUString maCurRegionName;
144 TemplateViewItem *maSelectedItem;
146 long mnThumbnailWidth;
147 long mnThumbnailHeight;
149 Point maPosition;
151 Link<void*,void> maOpenRegionHdl;
152 Link<ThumbnailViewItem*,void> maCreateContextMenuHdl;
153 Link<ThumbnailViewItem*,void> maOpenTemplateHdl;
154 Link<ThumbnailViewItem*,void> maEditTemplateHdl;
155 Link<ThumbnailViewItem*,void> maDeleteTemplateHdl;
156 Link<ThumbnailViewItem*,void> maDefaultTemplateHdl;
159 #endif // INCLUDED_SFX2_TEMPLATEABSTRACTVIEW_HXX
161 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */