Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef SD_TOOLPANEL_CONTROLS_MASTER_PAGE_CONTAINER_PROVIDERS_HXX
30 : : #define SD_TOOLPANEL_CONTROLS_MASTER_PAGE_CONTAINER_PROVIDERS_HXX
31 : :
32 : : #include <rtl/ustring.hxx>
33 : : #include <sfx2/objsh.hxx>
34 : :
35 : : class Image;
36 : : class SdDrawDocument;
37 : : class SdPage;
38 : : namespace sd { class PreviewRenderer; }
39 : : namespace sd { class DrawDocShell; }
40 : :
41 : :
42 : : namespace sd { namespace toolpanel { namespace controls {
43 : :
44 : :
45 : : /** Interface for a provider of page objects. It is used by the
46 : : MasterPageDescriptor to create master page objects on demand.
47 : : */
48 : 0 : class PageObjectProvider
49 : : {
50 : : public:
51 : : /** Return a master page either by returning an already existing one, by
52 : : creating a new page, or by loading a document.
53 : : @param pDocument
54 : : The document of the MasterPageContainer. It may be used to
55 : : create new pages.
56 : : */
57 : : virtual SdPage* operator() (SdDrawDocument* pDocument) = 0;
58 : :
59 : : /** An abstract value for the expected cost of providing a master page
60 : : object.
61 : : @return
62 : : A value of 0 represents for the lowest cost, i.e. an almost
63 : : immediate return. Positive values stand for higher costs.
64 : : Negative values are not supported.
65 : : */
66 : : virtual int GetCostIndex (void) = 0;
67 : :
68 : : virtual bool operator== (const PageObjectProvider& rProvider) = 0;
69 : :
70 : : protected:
71 : 0 : ~PageObjectProvider() {}
72 : : };
73 : :
74 : :
75 : :
76 : :
77 : 0 : class PreviewProvider
78 : : {
79 : : public:
80 : : /** Create a preview image in the specified width.
81 : : @param nWidth
82 : : Requested width of the preview. The calling method can cope
83 : : with other sizes as well but the resulting image quality is
84 : : better when the returned image has the requested size.
85 : : @param pPage
86 : : Page object for which a preview is requested. This may be NULL
87 : : when the page object is expensive to get and the PreviewProvider
88 : : does not need this object (NeedsPageObject() returns false.)
89 : : @param rRenderer
90 : : This PreviewRenderer may be used by the PreviewProvider to
91 : : create a preview image.
92 : : */
93 : : virtual Image operator() (int nWidth, SdPage* pPage, ::sd::PreviewRenderer& rRenderer) = 0;
94 : :
95 : : /** Return a value that indicates how expensive the creation of a
96 : : preview image is. The higher the returned value the more expensive
97 : : is the preview creation. Return 0 when the preview is already
98 : : present and can be returned immediately.
99 : : */
100 : : virtual int GetCostIndex (void) = 0;
101 : :
102 : : /** Return whether the page object passed is necessary to create a
103 : : preview.
104 : : */
105 : : virtual bool NeedsPageObject (void) = 0;
106 : :
107 : : protected:
108 : 0 : ~PreviewProvider() {}
109 : : };
110 : :
111 : :
112 : :
113 : :
114 : : /** Provide previews of existing page objects by rendering them.
115 : : */
116 : : class PagePreviewProvider : public PreviewProvider
117 : : {
118 : : public:
119 : : PagePreviewProvider (void);
120 [ # # ]: 0 : virtual ~PagePreviewProvider() {}
121 : : virtual Image operator () (int nWidth, SdPage* pPage, ::sd::PreviewRenderer& rRenderer);
122 : : virtual int GetCostIndex (void);
123 : : virtual bool NeedsPageObject (void);
124 : : private:
125 : : };
126 : :
127 : :
128 : :
129 : :
130 : : /** Provide master page objects for template documents for which only the
131 : : URL is given.
132 : : */
133 : : class TemplatePageObjectProvider : public PageObjectProvider
134 : : {
135 : : public:
136 : : TemplatePageObjectProvider (const ::rtl::OUString& rsURL);
137 [ # # ][ # # ]: 0 : virtual ~TemplatePageObjectProvider (void) {};
138 : : virtual SdPage* operator () (SdDrawDocument* pDocument);
139 : : virtual int GetCostIndex (void);
140 : : virtual bool operator== (const PageObjectProvider& rProvider);
141 : : private:
142 : : ::rtl::OUString msURL;
143 : : SfxObjectShellLock mxDocumentShell;
144 : : ::sd::DrawDocShell* LoadDocument (const ::rtl::OUString& sFileName);
145 : : };
146 : :
147 : :
148 : :
149 : :
150 : : /** Provide previews for template documents by loading the thumbnails from
151 : : the documents.
152 : : */
153 : : class TemplatePreviewProvider : public PreviewProvider
154 : : {
155 : : public:
156 : : TemplatePreviewProvider (const ::rtl::OUString& rsURL);
157 [ # # ]: 0 : virtual ~TemplatePreviewProvider (void) {};
158 : : virtual Image operator() (int nWidth, SdPage* pPage, ::sd::PreviewRenderer& rRenderer);
159 : : virtual int GetCostIndex (void);
160 : : virtual bool NeedsPageObject (void);
161 : : private:
162 : : ::rtl::OUString msURL;
163 : : };
164 : :
165 : :
166 : :
167 : :
168 : : /** Create an empty default master page.
169 : : */
170 : : class DefaultPageObjectProvider : public PageObjectProvider
171 : : {
172 : : public:
173 : : DefaultPageObjectProvider (void);
174 [ # # ]: 0 : virtual ~DefaultPageObjectProvider() {}
175 : : virtual SdPage* operator () (SdDrawDocument* pDocument);
176 : : virtual int GetCostIndex (void);
177 : : virtual bool operator== (const PageObjectProvider& rProvider);
178 : : };
179 : :
180 : :
181 : :
182 : : /** This implementation of the PageObjectProvider simply returns an already
183 : : existing master page object.
184 : : */
185 : : class ExistingPageProvider : public ::sd::toolpanel::controls::PageObjectProvider
186 : : {
187 : : public:
188 : : ExistingPageProvider (SdPage* pPage);
189 [ # # ]: 0 : virtual ~ExistingPageProvider() {}
190 : : virtual SdPage* operator() (SdDrawDocument* pDocument);
191 : : virtual int GetCostIndex (void);
192 : : virtual bool operator== (const PageObjectProvider& rProvider);
193 : : private:
194 : : SdPage* mpPage;
195 : : };
196 : :
197 : : } } } // end of namespace ::sd::toolpanel::controls
198 : :
199 : : #endif
200 : :
201 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|