1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: MasterPageDescriptor.hxx,v $
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_DESCRIPTOR_HXX
32 #define SD_TOOLPANEL_CONTROLS_MASTER_PAGE_DESCRIPTOR_HXX
34 #include "MasterPageContainer.hxx"
35 #include <boost/shared_ptr.hpp>
37 namespace sd
{ namespace toolpanel
{ namespace controls
{
39 class PageObjectProvider
;
40 class PreviewProvider
;
42 class MasterPageDescriptor
;
43 typedef ::boost::shared_ptr
<MasterPageDescriptor
> SharedMasterPageDescriptor
;
45 /** A collection of data that is stored for every master page in the
48 class MasterPageDescriptor
51 MasterPageDescriptor (
52 MasterPageContainer::Origin eOrigin
,
53 const sal_Int32 nTemplateIndex
,
55 const String
& rPageName
,
56 const String
& rStyleName
,
57 const bool bIsPrecious
,
58 const ::boost::shared_ptr
<PageObjectProvider
>& rpPageObjectProvider
,
59 const ::boost::shared_ptr
<PreviewProvider
>& rpPreviewProvider
);
60 MasterPageDescriptor (const MasterPageDescriptor
& rDescriptor
);
61 ~MasterPageDescriptor (void);
63 void SetToken (MasterPageContainer::Token aToken
);
65 /** Update the called MasterPageDescriptor object with values from the
66 given one. Only those values are updated that have default values
67 in the called object and that have non-default values in the given
70 Returns a list of event types for which event notifications have
71 to be sent to listeners. The list may be empty or NULL.
73 ::std::auto_ptr
<std::vector
<MasterPageContainerChangeEvent::EventType
> >
75 const MasterPageDescriptor
& rDescriptor
);
77 /** This convenience method returns either a small or a large preview,
78 depending on the given size specifier.
79 Note that the previews are not created when they are not present.
81 The returned preview may be empty.
83 Image
GetPreview (MasterPageContainer::PreviewSize ePreviewSize
);
85 /** Use the PreviewProvider to get access to a preview of the master
88 Note that this is only done, when either bForce is <TRUE/> or
89 the PreviewProvider::GetCostIndex() returns 0.
91 The small preview is created by scaling the large one, not by
92 calling PreviewProvider::operator() a second time.
94 It is the responsibility of the caller to call UpdatePageObject()
95 before calling this method when the PreviewProvider can only work
96 when the master page object is present, i.e. its NeedsPageObject()
97 method returns <TRUE/>.
100 When this is zero or positive then the preview is created only
101 when the preview provider has a cost equal to or smaller than
102 this threshold. A negative value forces the preview to be
103 created, regardless of the cost.
105 Size of the small preview.
107 Size of the large preview.
109 A PreviewRenderer object that may be used to create a preview.
111 When the previews are successfully provided then <TRUE/> is
115 sal_Int32 nCostThreshold
,
116 const Size
& rSmallSize
,
117 const Size
& rLargeSize
,
118 ::sd::PreviewRenderer
& rRenderer
);
120 /** Use the PageObjectProvider to get access to the master page object.
122 Note that this is only done, when either bForce is <TRUE/> or the
123 PreviewProvider::GetCostIndex() returns 0.
125 @param nCostThreshold
126 When this is zero or positive then the page object is created
127 only when the page object provider has a cost equal to or
128 smaller than this threshold. A negative value forces the
129 page object be created, regardless of the cost.
131 This document of the MasterPageContainer may be used to create
132 a page object with or store one in.
134 When the master page object is successfully provided then
137 bool UpdatePageObject (
138 sal_Int32 nCostThreshold
,
139 SdDrawDocument
* pDocument
);
141 enum URLClassification
{
144 URLCLASS_PRESENTATION
,
147 URLCLASS_UNDETERMINED
150 URLClassification
GetURLClassification (void);
152 /** The Token under which the MasterPageContainer gives access to the
155 MasterPageContainer::Token maToken
;
157 /** A rough specification of the origin of the master page.
159 MasterPageContainer::Origin meOrigin
;
161 /** The URL is not empty for master pages loaded from a template
164 ::rtl::OUString msURL
;
166 /** Taken from the title of the template file.
168 ::rtl::OUString msPageName
;
170 /** Taken from the master page object.
172 ::rtl::OUString msStyleName
;
174 const bool mbIsPrecious
;
176 /** The actual master page.
178 SdPage
* mpMasterPage
;
180 /** A slide that uses the master page.
184 /** A small (the default size) preview of the master page. May be
185 empty. When this smaller preview is not empty then the larger one
188 Image maSmallPreview
;
190 /** A large preview of the master page. May be empty. When this larger
191 preview is not empty then the smaller one is not empty, too.
193 Image maLargePreview
;
195 /** The prewview provider. May be empty. May be replaced during the
196 lifetime of a MasterPageDescriptor object.
198 ::boost::shared_ptr
<PreviewProvider
> mpPreviewProvider
;
200 /** The master page provider. May be empty. May be replaced during
201 the lifetime of a MasterPageDescriptor object.
203 ::boost::shared_ptr
<PageObjectProvider
> mpPageObjectProvider
;
205 /** This index represents the order in which templates are provided via
206 the TemplateScanner. It defines the order in which the entries in
207 the AllMasterPagesSelector are displayed. The default value is -1.
209 sal_Int32 mnTemplateIndex
;
211 URLClassification meURLClassification
;
213 sal_Int32 mnUseCount
;
215 class URLComparator
{ public:
216 ::rtl::OUString msURL
;
217 URLComparator (const ::rtl::OUString
& sURL
);
218 bool operator() (const SharedMasterPageDescriptor
& rDescriptor
);
220 class PageNameComparator
{ public:
221 ::rtl::OUString msPageName
;
222 PageNameComparator (const ::rtl::OUString
& sPageName
);
223 bool operator() (const SharedMasterPageDescriptor
& rDescriptor
);
225 class StyleNameComparator
{ public:
226 ::rtl::OUString msStyleName
;
227 StyleNameComparator (const ::rtl::OUString
& sStyleName
);
228 bool operator() (const SharedMasterPageDescriptor
& rDescriptor
);
230 class PageObjectComparator
{ public:
231 const SdPage
* mpMasterPage
;
232 PageObjectComparator (const SdPage
* pPageObject
);
233 bool operator() (const SharedMasterPageDescriptor
& rDescriptor
);
235 class AllComparator
{ public:
236 AllComparator(const SharedMasterPageDescriptor
& rDescriptor
);
237 bool operator() (const SharedMasterPageDescriptor
& rDescriptor
);
239 SharedMasterPageDescriptor mpDescriptor
;
246 } } } // end of namespace ::sd::toolpanel::controls