xref: /trunk/main/sd/source/ui/sidebar/MasterPageDescriptor.hxx (revision 914d351e5f5b84e4342a86d6ab8d4aca7308b9bd)
1*02c50d82SAndre Fischer /**************************************************************
2*02c50d82SAndre Fischer  *
3*02c50d82SAndre Fischer  * Licensed to the Apache Software Foundation (ASF) under one
4*02c50d82SAndre Fischer  * or more contributor license agreements.  See the NOTICE file
5*02c50d82SAndre Fischer  * distributed with this work for additional information
6*02c50d82SAndre Fischer  * regarding copyright ownership.  The ASF licenses this file
7*02c50d82SAndre Fischer  * to you under the Apache License, Version 2.0 (the
8*02c50d82SAndre Fischer  * "License"); you may not use this file except in compliance
9*02c50d82SAndre Fischer  * with the License.  You may obtain a copy of the License at
10*02c50d82SAndre Fischer  *
11*02c50d82SAndre Fischer  *   http://www.apache.org/licenses/LICENSE-2.0
12*02c50d82SAndre Fischer  *
13*02c50d82SAndre Fischer  * Unless required by applicable law or agreed to in writing,
14*02c50d82SAndre Fischer  * software distributed under the License is distributed on an
15*02c50d82SAndre Fischer  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*02c50d82SAndre Fischer  * KIND, either express or implied.  See the License for the
17*02c50d82SAndre Fischer  * specific language governing permissions and limitations
18*02c50d82SAndre Fischer  * under the License.
19*02c50d82SAndre Fischer  *
20*02c50d82SAndre Fischer  *************************************************************/
21*02c50d82SAndre Fischer 
22*02c50d82SAndre Fischer #ifndef SD_SIDEBAR_PANELS_MASTER_PAGE_DESCRIPTOR_HXX
23*02c50d82SAndre Fischer #define SD_SIDEBAR_PANELS_MASTER_PAGE_DESCRIPTOR_HXX
24*02c50d82SAndre Fischer 
25*02c50d82SAndre Fischer #include "MasterPageContainer.hxx"
26*02c50d82SAndre Fischer #include <boost/shared_ptr.hpp>
27*02c50d82SAndre Fischer 
28*02c50d82SAndre Fischer namespace sd { namespace sidebar {
29*02c50d82SAndre Fischer 
30*02c50d82SAndre Fischer class PageObjectProvider;
31*02c50d82SAndre Fischer class PreviewProvider;
32*02c50d82SAndre Fischer 
33*02c50d82SAndre Fischer class MasterPageDescriptor;
34*02c50d82SAndre Fischer typedef ::boost::shared_ptr<MasterPageDescriptor> SharedMasterPageDescriptor;
35*02c50d82SAndre Fischer 
36*02c50d82SAndre Fischer /** A collection of data that is stored for every master page in the
37*02c50d82SAndre Fischer     MasterpageContainer.
38*02c50d82SAndre Fischer */
39*02c50d82SAndre Fischer class MasterPageDescriptor
40*02c50d82SAndre Fischer {
41*02c50d82SAndre Fischer public:
42*02c50d82SAndre Fischer     MasterPageDescriptor (
43*02c50d82SAndre Fischer         MasterPageContainer::Origin eOrigin,
44*02c50d82SAndre Fischer         const sal_Int32 nTemplateIndex,
45*02c50d82SAndre Fischer         const String& rURL,
46*02c50d82SAndre Fischer         const String& rPageName,
47*02c50d82SAndre Fischer         const String& rStyleName,
48*02c50d82SAndre Fischer         const bool bIsPrecious,
49*02c50d82SAndre Fischer         const ::boost::shared_ptr<PageObjectProvider>& rpPageObjectProvider,
50*02c50d82SAndre Fischer         const ::boost::shared_ptr<PreviewProvider>& rpPreviewProvider);
51*02c50d82SAndre Fischer     MasterPageDescriptor (const MasterPageDescriptor& rDescriptor);
52*02c50d82SAndre Fischer     ~MasterPageDescriptor (void);
53*02c50d82SAndre Fischer 
54*02c50d82SAndre Fischer     void SetToken (MasterPageContainer::Token aToken);
55*02c50d82SAndre Fischer 
56*02c50d82SAndre Fischer     /** Update the called MasterPageDescriptor object with values from the
57*02c50d82SAndre Fischer         given one.  Only those values are updated that have default values
58*02c50d82SAndre Fischer         in the called object and that have non-default values in the given
59*02c50d82SAndre Fischer         one.
60*02c50d82SAndre Fischer         @return
61*02c50d82SAndre Fischer             Returns a list of event types for which event notifications have
62*02c50d82SAndre Fischer             to be sent to listeners.  The list may be empty or NULL.
63*02c50d82SAndre Fischer     */
64*02c50d82SAndre Fischer     ::std::auto_ptr<std::vector<MasterPageContainerChangeEvent::EventType> >
65*02c50d82SAndre Fischer         Update (
66*02c50d82SAndre Fischer             const MasterPageDescriptor& rDescriptor);
67*02c50d82SAndre Fischer 
68*02c50d82SAndre Fischer     /** This convenience method returns either a small or a large preview,
69*02c50d82SAndre Fischer         depending on the given size specifier.
70*02c50d82SAndre Fischer         Note that the previews are not created when they are not present.
71*02c50d82SAndre Fischer         @return
72*02c50d82SAndre Fischer             The returned preview may be empty.
73*02c50d82SAndre Fischer     */
74*02c50d82SAndre Fischer     Image GetPreview (MasterPageContainer::PreviewSize ePreviewSize);
75*02c50d82SAndre Fischer 
76*02c50d82SAndre Fischer     /** Use the PreviewProvider to get access to a preview of the master
77*02c50d82SAndre Fischer         page.
78*02c50d82SAndre Fischer 
79*02c50d82SAndre Fischer         Note that this is only done, when either bForce is <TRUE/> or
80*02c50d82SAndre Fischer         the PreviewProvider::GetCostIndex() returns 0.
81*02c50d82SAndre Fischer 
82*02c50d82SAndre Fischer         The small preview is created by scaling the large one, not by
83*02c50d82SAndre Fischer         calling PreviewProvider::operator() a second time.
84*02c50d82SAndre Fischer 
85*02c50d82SAndre Fischer         It is the responsibility of the caller to call UpdatePageObject()
86*02c50d82SAndre Fischer         before calling this method  when the PreviewProvider can only work
87*02c50d82SAndre Fischer         when the master page object is present, i.e. its NeedsPageObject()
88*02c50d82SAndre Fischer         method returns <TRUE/>.
89*02c50d82SAndre Fischer 
90*02c50d82SAndre Fischer         @param nCostThreshold
91*02c50d82SAndre Fischer             When this is zero or positive then the preview is created only
92*02c50d82SAndre Fischer             when the preview provider has a cost equal to or smaller than
93*02c50d82SAndre Fischer             this threshold.  A negative value forces the preview to be
94*02c50d82SAndre Fischer             created, regardless of the cost.
95*02c50d82SAndre Fischer         @param rSmallSize
96*02c50d82SAndre Fischer             Size of the small preview.
97*02c50d82SAndre Fischer         @param rLargeSize
98*02c50d82SAndre Fischer             Size of the large preview.
99*02c50d82SAndre Fischer         @param rRenderer
100*02c50d82SAndre Fischer             A PreviewRenderer object that may be used to create a preview.
101*02c50d82SAndre Fischer         @return
102*02c50d82SAndre Fischer             When the previews are successfully provided then <TRUE/> is
103*02c50d82SAndre Fischer             returned.
104*02c50d82SAndre Fischer     */
105*02c50d82SAndre Fischer     bool UpdatePreview (
106*02c50d82SAndre Fischer         sal_Int32 nCostThreshold,
107*02c50d82SAndre Fischer         const Size& rSmallSize,
108*02c50d82SAndre Fischer         const Size& rLargeSize,
109*02c50d82SAndre Fischer         ::sd::PreviewRenderer& rRenderer);
110*02c50d82SAndre Fischer 
111*02c50d82SAndre Fischer     /** Use the PageObjectProvider to get access to the master page object.
112*02c50d82SAndre Fischer 
113*02c50d82SAndre Fischer         Note that this is only done, when either bForce is <TRUE/> or the
114*02c50d82SAndre Fischer         PreviewProvider::GetCostIndex() returns 0.
115*02c50d82SAndre Fischer 
116*02c50d82SAndre Fischer         @param nCostThreshold
117*02c50d82SAndre Fischer             When this is zero or positive then the page object is created
118*02c50d82SAndre Fischer             only when the page object provider has a cost equal to or
119*02c50d82SAndre Fischer             smaller than this threshold.  A negative value forces the
120*02c50d82SAndre Fischer             page object be created, regardless of the cost.
121*02c50d82SAndre Fischer         @param pDocument
122*02c50d82SAndre Fischer             This document of the MasterPageContainer may be used to create
123*02c50d82SAndre Fischer             a page object with or store one in.
124*02c50d82SAndre Fischer         @return
125*02c50d82SAndre Fischer             When the master page object is successfully provided then
126*02c50d82SAndre Fischer             <TRUE/> is returned.
127*02c50d82SAndre Fischer     */
128*02c50d82SAndre Fischer     bool UpdatePageObject (
129*02c50d82SAndre Fischer         sal_Int32 nCostThreshold,
130*02c50d82SAndre Fischer         SdDrawDocument* pDocument);
131*02c50d82SAndre Fischer 
132*02c50d82SAndre Fischer     enum URLClassification {
133*02c50d82SAndre Fischer         URLCLASS_USER,
134*02c50d82SAndre Fischer         URLCLASS_LAYOUT,
135*02c50d82SAndre Fischer         URLCLASS_PRESENTATION,
136*02c50d82SAndre Fischer         URLCLASS_OTHER,
137*02c50d82SAndre Fischer         URLCLASS_UNKNOWN,
138*02c50d82SAndre Fischer         URLCLASS_UNDETERMINED
139*02c50d82SAndre Fischer     };
140*02c50d82SAndre Fischer 
141*02c50d82SAndre Fischer     URLClassification GetURLClassification (void);
142*02c50d82SAndre Fischer 
143*02c50d82SAndre Fischer     /** The Token under which the MasterPageContainer gives access to the
144*02c50d82SAndre Fischer         object.
145*02c50d82SAndre Fischer     */
146*02c50d82SAndre Fischer     MasterPageContainer::Token maToken;
147*02c50d82SAndre Fischer 
148*02c50d82SAndre Fischer     /** A rough specification of the origin of the master page.
149*02c50d82SAndre Fischer     */
150*02c50d82SAndre Fischer     MasterPageContainer::Origin meOrigin;
151*02c50d82SAndre Fischer 
152*02c50d82SAndre Fischer     /** The URL is not empty for master pages loaded from a template
153*02c50d82SAndre Fischer         document.
154*02c50d82SAndre Fischer     */
155*02c50d82SAndre Fischer     ::rtl::OUString msURL;
156*02c50d82SAndre Fischer 
157*02c50d82SAndre Fischer     /** Taken from the title of the template file.
158*02c50d82SAndre Fischer     */
159*02c50d82SAndre Fischer     ::rtl::OUString msPageName;
160*02c50d82SAndre Fischer 
161*02c50d82SAndre Fischer     /** Taken from the master page object.
162*02c50d82SAndre Fischer     */
163*02c50d82SAndre Fischer     ::rtl::OUString msStyleName;
164*02c50d82SAndre Fischer 
165*02c50d82SAndre Fischer     const bool mbIsPrecious;
166*02c50d82SAndre Fischer 
167*02c50d82SAndre Fischer     /** The actual master page.
168*02c50d82SAndre Fischer     */
169*02c50d82SAndre Fischer     SdPage* mpMasterPage;
170*02c50d82SAndre Fischer 
171*02c50d82SAndre Fischer     /** A slide that uses the master page.
172*02c50d82SAndre Fischer     */
173*02c50d82SAndre Fischer     SdPage* mpSlide;
174*02c50d82SAndre Fischer 
175*02c50d82SAndre Fischer     /** A small (the default size) preview of the master page.  May be
176*02c50d82SAndre Fischer         empty.  When this smaller preview is not empty then the larger one
177*02c50d82SAndre Fischer         is not empty, too.
178*02c50d82SAndre Fischer     */
179*02c50d82SAndre Fischer     Image maSmallPreview;
180*02c50d82SAndre Fischer 
181*02c50d82SAndre Fischer     /** A large preview of the master page.  May be empty.  When this larger
182*02c50d82SAndre Fischer         preview is not empty then the smaller one is not empty, too.
183*02c50d82SAndre Fischer     */
184*02c50d82SAndre Fischer     Image maLargePreview;
185*02c50d82SAndre Fischer 
186*02c50d82SAndre Fischer     /** The prewview provider. May be empty.  May be replaced during the
187*02c50d82SAndre Fischer         lifetime of a MasterPageDescriptor object.
188*02c50d82SAndre Fischer     */
189*02c50d82SAndre Fischer     ::boost::shared_ptr<PreviewProvider> mpPreviewProvider;
190*02c50d82SAndre Fischer 
191*02c50d82SAndre Fischer     /** The master page provider.  May be empty.  May be replaced during
192*02c50d82SAndre Fischer         the lifetime of a MasterPageDescriptor object.
193*02c50d82SAndre Fischer     */
194*02c50d82SAndre Fischer     ::boost::shared_ptr<PageObjectProvider> mpPageObjectProvider;
195*02c50d82SAndre Fischer 
196*02c50d82SAndre Fischer     /** This index represents the order in which templates are provided via
197*02c50d82SAndre Fischer         the TemplateScanner.  It defines the order in which the entries in
198*02c50d82SAndre Fischer         the AllMasterPagesSelector are displayed.  The default value is -1.
199*02c50d82SAndre Fischer     */
200*02c50d82SAndre Fischer     sal_Int32 mnTemplateIndex;
201*02c50d82SAndre Fischer 
202*02c50d82SAndre Fischer     URLClassification meURLClassification;
203*02c50d82SAndre Fischer 
204*02c50d82SAndre Fischer     sal_Int32 mnUseCount;
205*02c50d82SAndre Fischer 
206*02c50d82SAndre Fischer     class URLComparator { public:
207*02c50d82SAndre Fischer         ::rtl::OUString msURL;
208*02c50d82SAndre Fischer         URLComparator (const ::rtl::OUString& sURL);
209*02c50d82SAndre Fischer         bool operator() (const SharedMasterPageDescriptor& rDescriptor);
210*02c50d82SAndre Fischer     };
211*02c50d82SAndre Fischer     class StyleNameComparator { public:
212*02c50d82SAndre Fischer         ::rtl::OUString msStyleName;
213*02c50d82SAndre Fischer         StyleNameComparator (const ::rtl::OUString& sStyleName);
214*02c50d82SAndre Fischer         bool operator() (const SharedMasterPageDescriptor& rDescriptor);
215*02c50d82SAndre Fischer     };
216*02c50d82SAndre Fischer     class PageObjectComparator { public:
217*02c50d82SAndre Fischer         const SdPage* mpMasterPage;
218*02c50d82SAndre Fischer         PageObjectComparator (const SdPage* pPageObject);
219*02c50d82SAndre Fischer         bool operator() (const SharedMasterPageDescriptor& rDescriptor);
220*02c50d82SAndre Fischer     };
221*02c50d82SAndre Fischer     class AllComparator { public:
222*02c50d82SAndre Fischer         AllComparator(const SharedMasterPageDescriptor& rDescriptor);
223*02c50d82SAndre Fischer         bool operator() (const SharedMasterPageDescriptor& rDescriptor);
224*02c50d82SAndre Fischer     private:
225*02c50d82SAndre Fischer         SharedMasterPageDescriptor mpDescriptor;
226*02c50d82SAndre Fischer     };
227*02c50d82SAndre Fischer 
228*02c50d82SAndre Fischer 
229*02c50d82SAndre Fischer };
230*02c50d82SAndre Fischer 
231*02c50d82SAndre Fischer 
232*02c50d82SAndre Fischer } } // end of namespace sd::sidebar
233*02c50d82SAndre Fischer 
234*02c50d82SAndre Fischer #endif
235