merge the formfield patch from ooo-build
[ooovba.git] / sd / source / ui / toolpanel / controls / MasterPageContainerProviders.hxx
blob556f072115647ab0c001c6ce9b1d4bc580ab309d
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: MasterPageContainerProviders.hxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SD_TOOLPANEL_CONTROLS_MASTER_PAGE_CONTAINER_PROVIDERS_HXX
32 #define SD_TOOLPANEL_CONTROLS_MASTER_PAGE_CONTAINER_PROVIDERS_HXX
34 #include <rtl/ustring.hxx>
35 #include <sfx2/objsh.hxx>
37 class Image;
38 class SdDrawDocument;
39 class SdPage;
40 namespace sd { class PreviewRenderer; }
41 namespace sd { class DrawDocShell; }
44 namespace sd { namespace toolpanel { namespace controls {
47 /** Interface for a provider of page objects. It is used by the
48 MasterPageDescriptor to create master page objects on demand.
50 class PageObjectProvider
52 public:
53 /** Return a master page either by returning an already existing one, by
54 creating a new page, or by loading a document.
55 @param pDocument
56 The document of the MasterPageContainer. It may be used to
57 create new pages.
59 virtual SdPage* operator() (SdDrawDocument* pDocument) = 0;
61 /** An abstract value for the expected cost of providing a master page
62 object.
63 @return
64 A value of 0 represents for the lowest cost, i.e. an almost
65 immediate return. Positive values stand for higher costs.
66 Negative values are not supported.
68 virtual int GetCostIndex (void) = 0;
70 virtual bool operator== (const PageObjectProvider& rProvider) = 0;
76 class PreviewProvider
78 public:
79 /** Create a preview image in the specified width.
80 @param nWidth
81 Requested width of the preview. The calling method can cope
82 with other sizes as well but the resulting image quality is
83 better when the returned image has the requested size.
84 @param pPage
85 Page object for which a preview is requested. This may be NULL
86 when the page object is expensive to get and the PreviewProvider
87 does not need this object (NeedsPageObject() returns false.)
88 @param rRenderer
89 This PreviewRenderer may be used by the PreviewProvider to
90 create a preview image.
92 virtual Image operator() (int nWidth, SdPage* pPage, ::sd::PreviewRenderer& rRenderer) = 0;
94 /** Return a value that indicates how expensive the creation of a
95 preview image is. The higher the returned value the more expensive
96 is the preview creation. Return 0 when the preview is already
97 present and can be returned immediately.
99 virtual int GetCostIndex (void) = 0;
101 /** Return whether the page object passed is necessary to create a
102 preview.
104 virtual bool NeedsPageObject (void) = 0;
110 /** Provide previews of existing page objects by rendering them.
112 class PagePreviewProvider : public PreviewProvider
114 public:
115 PagePreviewProvider (void);
116 virtual Image operator () (int nWidth, SdPage* pPage, ::sd::PreviewRenderer& rRenderer);
117 virtual int GetCostIndex (void);
118 virtual bool NeedsPageObject (void);
119 private:
125 /** Provide master page objects for template documents for which only the
126 URL is given.
128 class TemplatePageObjectProvider : public PageObjectProvider
130 public:
131 TemplatePageObjectProvider (const ::rtl::OUString& rsURL);
132 virtual ~TemplatePageObjectProvider (void) {};
133 virtual SdPage* operator () (SdDrawDocument* pDocument);
134 virtual int GetCostIndex (void);
135 virtual bool operator== (const PageObjectProvider& rProvider);
136 private:
137 ::rtl::OUString msURL;
138 SfxObjectShellLock mxDocumentShell;
139 ::sd::DrawDocShell* LoadDocument (const ::rtl::OUString& sFileName);
145 /** Provide previews for template documents by loading the thumbnails from
146 the documents.
148 class TemplatePreviewProvider : public PreviewProvider
150 public:
151 TemplatePreviewProvider (const ::rtl::OUString& rsURL);
152 virtual ~TemplatePreviewProvider (void) {};
153 virtual Image operator() (int nWidth, SdPage* pPage, ::sd::PreviewRenderer& rRenderer);
154 virtual int GetCostIndex (void);
155 virtual bool NeedsPageObject (void);
156 private:
157 ::rtl::OUString msURL;
163 /** Create an empty default master page.
165 class DefaultPageObjectProvider : public PageObjectProvider
167 public:
168 DefaultPageObjectProvider (void);
169 virtual SdPage* operator () (SdDrawDocument* pDocument);
170 virtual int GetCostIndex (void);
171 virtual bool operator== (const PageObjectProvider& rProvider);
177 /** Used temporarily to avoid the (expensive) creation of the default page
178 too early.
180 class DefaultPagePreviewProvider : public PreviewProvider
182 public:
183 DefaultPagePreviewProvider (void);
184 virtual Image operator() (int nWidth, SdPage* pPage, ::sd::PreviewRenderer& rRenderer);
185 virtual int GetCostIndex (void);
186 virtual bool NeedsPageObject (void);
191 /** This implementation of the PageObjectProvider simply returns an already
192 existing master page object.
194 class ExistingPageProvider : public ::sd::toolpanel::controls::PageObjectProvider
196 public:
197 ExistingPageProvider (SdPage* pPage);
198 virtual SdPage* operator() (SdDrawDocument* pDocument);
199 virtual int GetCostIndex (void);
200 virtual bool operator== (const PageObjectProvider& rProvider);
201 private:
202 SdPage* mpPage;
205 } } } // end of namespace ::sd::toolpanel::controls
207 #endif