xref: /AOO41X/main/sd/source/ui/sidebar/MasterPageContainerProviders.hxx (revision ca62e2c2083b5d0995f1245bad6c2edfb455fbec)
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_CONTAINER_PROVIDERS_HXX
23*02c50d82SAndre Fischer #define SD_SIDEBAR_PANELS_MASTER_PAGE_CONTAINER_PROVIDERS_HXX
24*02c50d82SAndre Fischer 
25*02c50d82SAndre Fischer #include <rtl/ustring.hxx>
26*02c50d82SAndre Fischer #include <sfx2/objsh.hxx>
27*02c50d82SAndre Fischer 
28*02c50d82SAndre Fischer class Image;
29*02c50d82SAndre Fischer class SdDrawDocument;
30*02c50d82SAndre Fischer class SdPage;
31*02c50d82SAndre Fischer namespace sd { class PreviewRenderer; }
32*02c50d82SAndre Fischer namespace sd { class DrawDocShell; }
33*02c50d82SAndre Fischer 
34*02c50d82SAndre Fischer 
35*02c50d82SAndre Fischer namespace sd { namespace sidebar {
36*02c50d82SAndre Fischer 
37*02c50d82SAndre Fischer 
38*02c50d82SAndre Fischer /** Interface for a provider of page objects.  It is used by the
39*02c50d82SAndre Fischer     MasterPageDescriptor to create master page objects on demand.
40*02c50d82SAndre Fischer */
41*02c50d82SAndre Fischer class PageObjectProvider
42*02c50d82SAndre Fischer {
43*02c50d82SAndre Fischer public:
44*02c50d82SAndre Fischer     /** Return a master page either by returning an already existing one, by
45*02c50d82SAndre Fischer         creating a new page, or by loading a document.
46*02c50d82SAndre Fischer         @param pDocument
47*02c50d82SAndre Fischer             The document of the MasterPageContainer.  It may be used to
48*02c50d82SAndre Fischer             create new pages.
49*02c50d82SAndre Fischer     */
50*02c50d82SAndre Fischer     virtual SdPage* operator() (SdDrawDocument* pDocument) = 0;
51*02c50d82SAndre Fischer 
52*02c50d82SAndre Fischer     /** An abstract value for the expected cost of providing a master page
53*02c50d82SAndre Fischer         object.
54*02c50d82SAndre Fischer         @return
55*02c50d82SAndre Fischer             A value of 0 represents for the lowest cost, i.e. an almost
56*02c50d82SAndre Fischer             immediate return.  Positive values stand for higher costs.
57*02c50d82SAndre Fischer             Negative values are not supported.
58*02c50d82SAndre Fischer     */
59*02c50d82SAndre Fischer     virtual int GetCostIndex (void) = 0;
60*02c50d82SAndre Fischer 
61*02c50d82SAndre Fischer     virtual bool operator== (const PageObjectProvider& rProvider) = 0;
62*02c50d82SAndre Fischer };
63*02c50d82SAndre Fischer 
64*02c50d82SAndre Fischer 
65*02c50d82SAndre Fischer 
66*02c50d82SAndre Fischer 
67*02c50d82SAndre Fischer class PreviewProvider
68*02c50d82SAndre Fischer {
69*02c50d82SAndre Fischer public:
70*02c50d82SAndre Fischer     /** Create a preview image in the specified width.
71*02c50d82SAndre Fischer         @param nWidth
72*02c50d82SAndre Fischer             Requested width of the preview.  The calling method can cope
73*02c50d82SAndre Fischer             with other sizes as well but the resulting image quality is
74*02c50d82SAndre Fischer             better when the returned image has the requested size.
75*02c50d82SAndre Fischer         @param pPage
76*02c50d82SAndre Fischer             Page object for which a preview is requested.  This may be NULL
77*02c50d82SAndre Fischer             when the page object is expensive to get and the PreviewProvider
78*02c50d82SAndre Fischer             does not need this object (NeedsPageObject() returns false.)
79*02c50d82SAndre Fischer         @param rRenderer
80*02c50d82SAndre Fischer             This PreviewRenderer may be used by the PreviewProvider to
81*02c50d82SAndre Fischer             create a preview image.
82*02c50d82SAndre Fischer     */
83*02c50d82SAndre Fischer     virtual Image operator() (int nWidth, SdPage* pPage, ::sd::PreviewRenderer& rRenderer) = 0;
84*02c50d82SAndre Fischer 
85*02c50d82SAndre Fischer     /** Return a value that indicates how expensive the creation of a
86*02c50d82SAndre Fischer         preview image is.  The higher the returned value the more expensive
87*02c50d82SAndre Fischer         is the preview creation.  Return 0 when the preview is already
88*02c50d82SAndre Fischer         present and can be returned immediately.
89*02c50d82SAndre Fischer     */
90*02c50d82SAndre Fischer     virtual int GetCostIndex (void) = 0;
91*02c50d82SAndre Fischer 
92*02c50d82SAndre Fischer     /** Return whether the page object passed is necessary to create a
93*02c50d82SAndre Fischer         preview.
94*02c50d82SAndre Fischer     */
95*02c50d82SAndre Fischer     virtual bool NeedsPageObject (void) = 0;
96*02c50d82SAndre Fischer };
97*02c50d82SAndre Fischer 
98*02c50d82SAndre Fischer 
99*02c50d82SAndre Fischer 
100*02c50d82SAndre Fischer 
101*02c50d82SAndre Fischer /** Provide previews of existing page objects by rendering them.
102*02c50d82SAndre Fischer */
103*02c50d82SAndre Fischer class PagePreviewProvider : public PreviewProvider
104*02c50d82SAndre Fischer {
105*02c50d82SAndre Fischer public:
106*02c50d82SAndre Fischer     PagePreviewProvider (void);
107*02c50d82SAndre Fischer     virtual Image operator () (int nWidth, SdPage* pPage, ::sd::PreviewRenderer& rRenderer);
108*02c50d82SAndre Fischer     virtual int GetCostIndex (void);
109*02c50d82SAndre Fischer     virtual bool NeedsPageObject (void);
110*02c50d82SAndre Fischer private:
111*02c50d82SAndre Fischer };
112*02c50d82SAndre Fischer 
113*02c50d82SAndre Fischer 
114*02c50d82SAndre Fischer 
115*02c50d82SAndre Fischer 
116*02c50d82SAndre Fischer /** Provide master page objects for template documents for which only the
117*02c50d82SAndre Fischer     URL is given.
118*02c50d82SAndre Fischer */
119*02c50d82SAndre Fischer class TemplatePageObjectProvider : public PageObjectProvider
120*02c50d82SAndre Fischer {
121*02c50d82SAndre Fischer public:
122*02c50d82SAndre Fischer     TemplatePageObjectProvider (const ::rtl::OUString& rsURL);
~TemplatePageObjectProvider(void)123*02c50d82SAndre Fischer     virtual ~TemplatePageObjectProvider (void) {};
124*02c50d82SAndre Fischer     virtual SdPage* operator () (SdDrawDocument* pDocument);
125*02c50d82SAndre Fischer     virtual int GetCostIndex (void);
126*02c50d82SAndre Fischer     virtual bool operator== (const PageObjectProvider& rProvider);
127*02c50d82SAndre Fischer private:
128*02c50d82SAndre Fischer     ::rtl::OUString msURL;
129*02c50d82SAndre Fischer     SfxObjectShellLock mxDocumentShell;
130*02c50d82SAndre Fischer     ::sd::DrawDocShell* LoadDocument (const ::rtl::OUString& sFileName);
131*02c50d82SAndre Fischer };
132*02c50d82SAndre Fischer 
133*02c50d82SAndre Fischer 
134*02c50d82SAndre Fischer 
135*02c50d82SAndre Fischer 
136*02c50d82SAndre Fischer /** Provide previews for template documents by loading the thumbnails from
137*02c50d82SAndre Fischer     the documents.
138*02c50d82SAndre Fischer */
139*02c50d82SAndre Fischer class TemplatePreviewProvider : public PreviewProvider
140*02c50d82SAndre Fischer {
141*02c50d82SAndre Fischer public:
142*02c50d82SAndre Fischer     TemplatePreviewProvider (const ::rtl::OUString& rsURL);
~TemplatePreviewProvider(void)143*02c50d82SAndre Fischer     virtual ~TemplatePreviewProvider (void) {};
144*02c50d82SAndre Fischer     virtual Image operator() (int nWidth, SdPage* pPage, ::sd::PreviewRenderer& rRenderer);
145*02c50d82SAndre Fischer     virtual int GetCostIndex (void);
146*02c50d82SAndre Fischer     virtual bool NeedsPageObject (void);
147*02c50d82SAndre Fischer private:
148*02c50d82SAndre Fischer     ::rtl::OUString msURL;
149*02c50d82SAndre Fischer };
150*02c50d82SAndre Fischer 
151*02c50d82SAndre Fischer 
152*02c50d82SAndre Fischer 
153*02c50d82SAndre Fischer 
154*02c50d82SAndre Fischer /** Create an empty default master page.
155*02c50d82SAndre Fischer */
156*02c50d82SAndre Fischer class DefaultPageObjectProvider : public PageObjectProvider
157*02c50d82SAndre Fischer {
158*02c50d82SAndre Fischer public:
159*02c50d82SAndre Fischer     DefaultPageObjectProvider (void);
160*02c50d82SAndre Fischer     virtual SdPage* operator () (SdDrawDocument* pDocument);
161*02c50d82SAndre Fischer     virtual int GetCostIndex (void);
162*02c50d82SAndre Fischer     virtual bool operator== (const PageObjectProvider& rProvider);
163*02c50d82SAndre Fischer };
164*02c50d82SAndre Fischer 
165*02c50d82SAndre Fischer 
166*02c50d82SAndre Fischer 
167*02c50d82SAndre Fischer /** This implementation of the PageObjectProvider simply returns an already
168*02c50d82SAndre Fischer     existing master page object.
169*02c50d82SAndre Fischer */
170*02c50d82SAndre Fischer class ExistingPageProvider : public PageObjectProvider
171*02c50d82SAndre Fischer {
172*02c50d82SAndre Fischer public:
173*02c50d82SAndre Fischer     ExistingPageProvider (SdPage* pPage);
174*02c50d82SAndre Fischer     virtual SdPage* operator() (SdDrawDocument* pDocument);
175*02c50d82SAndre Fischer     virtual int GetCostIndex (void);
176*02c50d82SAndre Fischer     virtual bool operator== (const PageObjectProvider& rProvider);
177*02c50d82SAndre Fischer private:
178*02c50d82SAndre Fischer     SdPage* mpPage;
179*02c50d82SAndre Fischer };
180*02c50d82SAndre Fischer 
181*02c50d82SAndre Fischer } } // end of namespace sd::sidebar
182*02c50d82SAndre Fischer 
183*02c50d82SAndre Fischer #endif
184