bump product version to 6.3.0.0.beta1
[LibreOffice.git] / sd / source / ui / sidebar / MasterPageDescriptor.hxx
blobc20ced5b8a214e9f7b808cf2cd9601605a495042
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SD_SOURCE_UI_SIDEBAR_MASTERPAGEDESCRIPTOR_HXX
21 #define INCLUDED_SD_SOURCE_UI_SIDEBAR_MASTERPAGEDESCRIPTOR_HXX
23 #include "MasterPageContainer.hxx"
24 #include <memory>
26 namespace sd { class PreviewRenderer; }
27 class SdDrawDocument;
29 namespace sd { namespace sidebar {
31 class PageObjectProvider;
32 class PreviewProvider;
34 class MasterPageDescriptor;
35 typedef std::shared_ptr<MasterPageDescriptor> SharedMasterPageDescriptor;
37 /** A collection of data that is stored for every master page in the
38 MasterpageContainer.
40 class MasterPageDescriptor
42 public:
43 MasterPageDescriptor (
44 MasterPageContainer::Origin eOrigin,
45 const sal_Int32 nTemplateIndex,
46 const OUString& rURL,
47 const OUString& rPageName,
48 const OUString& rStyleName,
49 const bool bIsPrecious,
50 const std::shared_ptr<PageObjectProvider>& rpPageObjectProvider,
51 const std::shared_ptr<PreviewProvider>& rpPreviewProvider);
53 void SetToken (MasterPageContainer::Token aToken);
55 /** Update the called MasterPageDescriptor object with values from the
56 given one. Only those values are updated that have default values
57 in the called object and that have non-default values in the given
58 one.
59 @return
60 Returns a list of event types for which event notifications have
61 to be sent to listeners. The list may be empty or NULL.
63 ::std::unique_ptr<std::vector<MasterPageContainerChangeEvent::EventType> >
64 Update (
65 const MasterPageDescriptor& rDescriptor);
67 /** This convenience method returns either a small or a large preview,
68 depending on the given size specifier.
69 Note that the previews are not created when they are not present.
70 @return
71 The returned preview may be empty.
73 const Image& GetPreview (MasterPageContainer::PreviewSize ePreviewSize) const;
75 /** Use the PreviewProvider to get access to a preview of the master
76 page.
78 Note that this is only done, when either bForce is <TRUE/> or
79 the PreviewProvider::GetCostIndex() returns 0.
81 The small preview is created by scaling the large one, not by
82 calling PreviewProvider::operator() a second time.
84 It is the responsibility of the caller to call UpdatePageObject()
85 before calling this method when the PreviewProvider can only work
86 when the master page object is present, i.e. its NeedsPageObject()
87 method returns <TRUE/>.
89 @param nCostThreshold
90 When this is zero or positive then the preview is created only
91 when the preview provider has a cost equal to or smaller than
92 this threshold. A negative value forces the preview to be
93 created, regardless of the cost.
94 @param rSmallSize
95 Size of the small preview.
96 @param rLargeSize
97 Size of the large preview.
98 @param rRenderer
99 A PreviewRenderer object that may be used to create a preview.
100 @return
101 When the previews are successfully provided then <TRUE/> is
102 returned.
104 bool UpdatePreview (
105 sal_Int32 nCostThreshold,
106 const Size& rSmallSize,
107 const Size& rLargeSize,
108 ::sd::PreviewRenderer& rRenderer);
110 /** Use the PageObjectProvider to get access to the master page object.
112 Note that this is only done, when either bForce is <TRUE/> or the
113 PreviewProvider::GetCostIndex() returns 0.
115 @param nCostThreshold
116 When this is zero or positive then the page object is created
117 only when the page object provider has a cost equal to or
118 smaller than this threshold. A negative value forces the
119 page object be created, regardless of the cost.
120 @param pDocument
121 This document of the MasterPageContainer may be used to create
122 a page object with or store one in.
123 @return
124 When the master page object is successfully provided then
125 1 is returned, on no change then a 0 is provided,
126 on a masterpage-error a -1 is provided.
128 int UpdatePageObject (
129 sal_Int32 nCostThreshold,
130 SdDrawDocument* pDocument);
132 enum URLClassification {
133 URLCLASS_USER,
134 URLCLASS_LAYOUT,
135 URLCLASS_PRESENTATION,
136 URLCLASS_OTHER,
137 URLCLASS_UNKNOWN,
138 URLCLASS_UNDETERMINED
141 URLClassification GetURLClassification();
143 /** The Token under which the MasterPageContainer gives access to the
144 object.
146 MasterPageContainer::Token maToken;
148 /** A rough specification of the origin of the master page.
150 MasterPageContainer::Origin meOrigin;
152 /** The URL is not empty for master pages loaded from a template
153 document.
155 OUString msURL;
157 /** Taken from the title of the template file.
159 OUString msPageName;
161 /** Taken from the master page object.
163 OUString msStyleName;
165 const bool mbIsPrecious;
167 /** The actual master page.
169 SdPage* mpMasterPage;
171 /** A slide that uses the master page.
173 SdPage* mpSlide;
175 /** A small (the default size) preview of the master page. May be
176 empty. When this smaller preview is not empty then the larger one
177 is not empty, too.
179 Image maSmallPreview;
181 /** A large preview of the master page. May be empty. When this larger
182 preview is not empty then the smaller one is not empty, too.
184 Image maLargePreview;
186 /** The preview provider. May be empty. May be replaced during the
187 lifetime of a MasterPageDescriptor object.
189 std::shared_ptr<PreviewProvider> mpPreviewProvider;
191 /** The master page provider. May be empty. May be replaced during
192 the lifetime of a MasterPageDescriptor object.
194 std::shared_ptr<PageObjectProvider> mpPageObjectProvider;
196 /** This index represents the order in which templates are provided via
197 the TemplateScanner. It defines the order in which the entries in
198 the AllMasterPagesSelector are displayed. The default value is -1.
200 sal_Int32 mnTemplateIndex;
202 URLClassification meURLClassification;
204 sal_Int32 mnUseCount;
206 class URLComparator { public:
207 OUString const msURL;
208 explicit URLComparator (const OUString& sURL);
209 bool operator() (const SharedMasterPageDescriptor& rDescriptor);
211 class StyleNameComparator { public:
212 OUString const msStyleName;
213 explicit StyleNameComparator (const OUString& sStyleName);
214 bool operator() (const SharedMasterPageDescriptor& rDescriptor);
216 class PageObjectComparator { public:
217 const SdPage* mpMasterPage;
218 explicit PageObjectComparator (const SdPage* pPageObject);
219 bool operator() (const SharedMasterPageDescriptor& rDescriptor);
221 class AllComparator { public:
222 explicit AllComparator(const SharedMasterPageDescriptor& rDescriptor);
223 bool operator() (const SharedMasterPageDescriptor& rDescriptor);
224 private:
225 SharedMasterPageDescriptor const mpDescriptor;
230 } } // end of namespace sd::sidebar
232 #endif
234 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */