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_DESCRIPTOR_HXX
30 : : #define SD_TOOLPANEL_CONTROLS_MASTER_PAGE_DESCRIPTOR_HXX
31 : :
32 : : #include "MasterPageContainer.hxx"
33 : : #include <boost/shared_ptr.hpp>
34 : :
35 : : namespace sd { namespace toolpanel { namespace controls {
36 : :
37 : : class PageObjectProvider;
38 : : class PreviewProvider;
39 : :
40 : : class MasterPageDescriptor;
41 : : typedef ::boost::shared_ptr<MasterPageDescriptor> SharedMasterPageDescriptor;
42 : :
43 : : /** A collection of data that is stored for every master page in the
44 : : MasterpageContainer.
45 : : */
46 : : class MasterPageDescriptor
47 : : {
48 : : public:
49 : : MasterPageDescriptor (
50 : : MasterPageContainer::Origin eOrigin,
51 : : const sal_Int32 nTemplateIndex,
52 : : const String& rURL,
53 : : const String& rPageName,
54 : : const String& rStyleName,
55 : : const bool bIsPrecious,
56 : : const ::boost::shared_ptr<PageObjectProvider>& rpPageObjectProvider,
57 : : const ::boost::shared_ptr<PreviewProvider>& rpPreviewProvider);
58 : : MasterPageDescriptor (const MasterPageDescriptor& rDescriptor);
59 : : ~MasterPageDescriptor (void);
60 : :
61 : : void SetToken (MasterPageContainer::Token aToken);
62 : :
63 : : /** Update the called MasterPageDescriptor object with values from the
64 : : given one. Only those values are updated that have default values
65 : : in the called object and that have non-default values in the given
66 : : one.
67 : : @return
68 : : Returns a list of event types for which event notifications have
69 : : to be sent to listeners. The list may be empty or NULL.
70 : : */
71 : : ::std::auto_ptr<std::vector<MasterPageContainerChangeEvent::EventType> >
72 : : Update (
73 : : const MasterPageDescriptor& rDescriptor);
74 : :
75 : : /** This convenience method returns either a small or a large preview,
76 : : depending on the given size specifier.
77 : : Note that the previews are not created when they are not present.
78 : : @return
79 : : The returned preview may be empty.
80 : : */
81 : : Image GetPreview (MasterPageContainer::PreviewSize ePreviewSize) const;
82 : :
83 : : /** Use the PreviewProvider to get access to a preview of the master
84 : : page.
85 : :
86 : : Note that this is only done, when either bForce is <TRUE/> or
87 : : the PreviewProvider::GetCostIndex() returns 0.
88 : :
89 : : The small preview is created by scaling the large one, not by
90 : : calling PreviewProvider::operator() a second time.
91 : :
92 : : It is the responsibility of the caller to call UpdatePageObject()
93 : : before calling this method when the PreviewProvider can only work
94 : : when the master page object is present, i.e. its NeedsPageObject()
95 : : method returns <TRUE/>.
96 : :
97 : : @param nCostThreshold
98 : : When this is zero or positive then the preview is created only
99 : : when the preview provider has a cost equal to or smaller than
100 : : this threshold. A negative value forces the preview to be
101 : : created, regardless of the cost.
102 : : @param rSmallSize
103 : : Size of the small preview.
104 : : @param rLargeSize
105 : : Size of the large preview.
106 : : @param rRenderer
107 : : A PreviewRenderer object that may be used to create a preview.
108 : : @return
109 : : When the previews are successfully provided then <TRUE/> is
110 : : returned.
111 : : */
112 : : bool UpdatePreview (
113 : : sal_Int32 nCostThreshold,
114 : : const Size& rSmallSize,
115 : : const Size& rLargeSize,
116 : : ::sd::PreviewRenderer& rRenderer);
117 : :
118 : : /** Use the PageObjectProvider to get access to the master page object.
119 : :
120 : : Note that this is only done, when either bForce is <TRUE/> or the
121 : : PreviewProvider::GetCostIndex() returns 0.
122 : :
123 : : @param nCostThreshold
124 : : When this is zero or positive then the page object is created
125 : : only when the page object provider has a cost equal to or
126 : : smaller than this threshold. A negative value forces the
127 : : page object be created, regardless of the cost.
128 : : @param pDocument
129 : : This document of the MasterPageContainer may be used to create
130 : : a page object with or store one in.
131 : : @return
132 : : When the master page object is successfully provided then
133 : : <TRUE/> is returned.
134 : : */
135 : : bool UpdatePageObject (
136 : : sal_Int32 nCostThreshold,
137 : : SdDrawDocument* pDocument);
138 : :
139 : : enum URLClassification {
140 : : URLCLASS_USER,
141 : : URLCLASS_LAYOUT,
142 : : URLCLASS_PRESENTATION,
143 : : URLCLASS_OTHER,
144 : : URLCLASS_UNKNOWN,
145 : : URLCLASS_UNDETERMINED
146 : : };
147 : :
148 : : URLClassification GetURLClassification (void);
149 : :
150 : : /** The Token under which the MasterPageContainer gives access to the
151 : : object.
152 : : */
153 : : MasterPageContainer::Token maToken;
154 : :
155 : : /** A rough specification of the origin of the master page.
156 : : */
157 : : MasterPageContainer::Origin meOrigin;
158 : :
159 : : /** The URL is not empty for master pages loaded from a template
160 : : document.
161 : : */
162 : : ::rtl::OUString msURL;
163 : :
164 : : /** Taken from the title of the template file.
165 : : */
166 : : ::rtl::OUString msPageName;
167 : :
168 : : /** Taken from the master page object.
169 : : */
170 : : ::rtl::OUString msStyleName;
171 : :
172 : : const bool mbIsPrecious;
173 : :
174 : : /** The actual master page.
175 : : */
176 : : SdPage* mpMasterPage;
177 : :
178 : : /** A slide that uses the master page.
179 : : */
180 : : SdPage* mpSlide;
181 : :
182 : : /** A small (the default size) preview of the master page. May be
183 : : empty. When this smaller preview is not empty then the larger one
184 : : is not empty, too.
185 : : */
186 : : Image maSmallPreview;
187 : :
188 : : /** A large preview of the master page. May be empty. When this larger
189 : : preview is not empty then the smaller one is not empty, too.
190 : : */
191 : : Image maLargePreview;
192 : :
193 : : /** The prewview provider. May be empty. May be replaced during the
194 : : lifetime of a MasterPageDescriptor object.
195 : : */
196 : : ::boost::shared_ptr<PreviewProvider> mpPreviewProvider;
197 : :
198 : : /** The master page provider. May be empty. May be replaced during
199 : : the lifetime of a MasterPageDescriptor object.
200 : : */
201 : : ::boost::shared_ptr<PageObjectProvider> mpPageObjectProvider;
202 : :
203 : : /** This index represents the order in which templates are provided via
204 : : the TemplateScanner. It defines the order in which the entries in
205 : : the AllMasterPagesSelector are displayed. The default value is -1.
206 : : */
207 : : sal_Int32 mnTemplateIndex;
208 : :
209 : : URLClassification meURLClassification;
210 : :
211 : : sal_Int32 mnUseCount;
212 : :
213 : 0 : class URLComparator { public:
214 : : ::rtl::OUString msURL;
215 : : URLComparator (const ::rtl::OUString& sURL);
216 : : bool operator() (const SharedMasterPageDescriptor& rDescriptor);
217 : : };
218 : 0 : class StyleNameComparator { public:
219 : : ::rtl::OUString msStyleName;
220 : : StyleNameComparator (const ::rtl::OUString& sStyleName);
221 : : bool operator() (const SharedMasterPageDescriptor& rDescriptor);
222 : : };
223 : : class PageObjectComparator { public:
224 : : const SdPage* mpMasterPage;
225 : : PageObjectComparator (const SdPage* pPageObject);
226 : : bool operator() (const SharedMasterPageDescriptor& rDescriptor);
227 : : };
228 : 0 : class AllComparator { public:
229 : : AllComparator(const SharedMasterPageDescriptor& rDescriptor);
230 : : bool operator() (const SharedMasterPageDescriptor& rDescriptor);
231 : : private:
232 : : SharedMasterPageDescriptor mpDescriptor;
233 : : };
234 : :
235 : :
236 : : };
237 : :
238 : :
239 : : } } } // end of namespace ::sd::toolpanel::controls
240 : :
241 : : #endif
242 : :
243 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|