1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
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
43 // Display template items depending on the generator application
44 class ViewFilter_Application
48 ViewFilter_Application (FILTER_APPLICATION 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;
61 FILTER_APPLICATION mApp
;
64 class ViewFilter_Keyword
68 ViewFilter_Keyword (const OUString
&rKeyword
)
72 bool operator () (const ThumbnailViewItem
*pItem
);
79 class SFX2_DLLPUBLIC TemplateAbstractView
: public ThumbnailView
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
);
130 DECL_LINK(ShowRootRegionHdl
, void*);
132 virtual void OnItemDblClicked(ThumbnailViewItem
*pItem
);
134 virtual void Paint( const Rectangle
& rRect
);
138 sal_uInt16 mnCurRegionId
;
139 OUString maCurRegionName
;
141 PushButton maAllButton
;
144 Link maOpenRegionHdl
;
145 Link maOpenTemplateHdl
;
148 #endif // INCLUDED_SFX2_TEMPLATEABSTRACTVIEW_HXX
150 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */