bump product version to 4.2.0.1
[LibreOffice.git] / include / sfx2 / templateabstractview.hxx
blobfc2df865e95423ebb1d278c63924a015b1e4b870
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;
34 enum FILTER_APPLICATION
36 FILTER_APP_NONE,
37 FILTER_APP_WRITER,
38 FILTER_APP_CALC,
39 FILTER_APP_IMPRESS,
40 FILTER_APP_DRAW
43 // Display template items depending on the generator application
44 class ViewFilter_Application
46 public:
48 ViewFilter_Application (FILTER_APPLICATION App)
49 : mApp(App)
52 virtual ~ViewFilter_Application () {}
54 virtual bool operator () (const ThumbnailViewItem *pItem);
56 static bool isFilteredExtension(FILTER_APPLICATION filter, const OUString &rExt);
57 bool isValid (const OUString& rPath) const;
59 protected:
61 FILTER_APPLICATION mApp;
64 class ViewFilter_Keyword
66 public:
68 ViewFilter_Keyword (const OUString &rKeyword)
69 : maKeyword(rKeyword)
72 bool operator () (const ThumbnailViewItem *pItem);
74 private:
76 OUString maKeyword;
79 class SFX2_DLLPUBLIC TemplateAbstractView : public ThumbnailView
81 public:
83 TemplateAbstractView (Window *pParent, WinBits nWinStyle, bool bDisableTransientChildren);
84 TemplateAbstractView ( Window* pParent, const ResId& rResId, bool bDisableTransientChildren = false );
85 TemplateAbstractView ( Window* pParent );
87 virtual ~TemplateAbstractView ();
89 void insertItem (const TemplateItemProperties &rTemplate);
91 // Fill view with new item list
92 void insertItems (const std::vector<TemplateItemProperties> &rTemplates);
94 // Fill view with template folders thumbnails
95 virtual void Populate () { }
97 virtual void reload () { }
99 virtual void showRootRegion () = 0;
101 virtual void showRegion (ThumbnailViewItem *pItem) = 0;
103 virtual sal_uInt16 createRegion (const OUString &rName) = 0;
105 // Return if we can have regions inside the current region
106 virtual bool isNestedRegionAllowed () const = 0;
108 // Return if we can import templates to the current region
109 virtual bool isImportAllowed () const = 0;
111 sal_uInt16 getCurRegionId () const;
113 const OUString& getCurRegionName () const;
115 // Check if the root region is visible or not.
116 bool isNonRootRegionVisible () const;
118 void setOpenRegionHdl(const Link &rLink);
120 void setOpenTemplateHdl (const Link &rLink);
122 static BitmapEx scaleImg (const BitmapEx &rImg, long width, long height);
124 static BitmapEx getDefaultThumbnail( const OUString& rPath );
126 static BitmapEx fetchThumbnail (const OUString &msURL, long width, long height);
128 protected:
130 DECL_LINK(ShowRootRegionHdl, void*);
132 virtual void OnItemDblClicked(ThumbnailViewItem *pItem);
134 virtual void Paint( const Rectangle& rRect );
136 protected:
138 sal_uInt16 mnCurRegionId;
139 OUString maCurRegionName;
141 PushButton maAllButton;
142 FixedText maFTName;
144 Link maOpenRegionHdl;
145 Link maOpenTemplateHdl;
148 #endif // INCLUDED_SFX2_TEMPLATEABSTRACTVIEW_HXX
150 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */