bump product version to 6.3.0.0.beta1
[LibreOffice.git] / sd / source / ui / sidebar / MasterPageContainerProviders.hxx
blob9ca123b1af0cbf6a7e6033a7fb53ffcfacda097f
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_MASTERPAGECONTAINERPROVIDERS_HXX
21 #define INCLUDED_SD_SOURCE_UI_SIDEBAR_MASTERPAGECONTAINERPROVIDERS_HXX
23 #include <rtl/ustring.hxx>
24 #include <sfx2/objsh.hxx>
26 class Image;
27 class SdDrawDocument;
28 class SdPage;
29 namespace sd { class PreviewRenderer; }
30 namespace sd { class DrawDocShell; }
32 namespace sd { namespace sidebar {
34 /** Interface for a provider of page objects. It is used by the
35 MasterPageDescriptor to create master page objects on demand.
37 class PageObjectProvider
39 public:
40 /** Return a master page either by returning an already existing one, by
41 creating a new page, or by loading a document.
42 @param pDocument
43 The document of the MasterPageContainer. It may be used to
44 create new pages.
46 virtual SdPage* operator() (SdDrawDocument* pDocument) = 0;
48 /** An abstract value for the expected cost of providing a master page
49 object.
50 @return
51 A value of 0 represents for the lowest cost, i.e. an almost
52 immediate return. Positive values stand for higher costs.
53 Negative values are not supported.
55 virtual int GetCostIndex() = 0;
57 protected:
58 ~PageObjectProvider() {}
61 class PreviewProvider
63 public:
64 /** Create a preview image in the specified width.
65 @param nWidth
66 Requested width of the preview. The calling method can cope
67 with other sizes as well but the resulting image quality is
68 better when the returned image has the requested size.
69 @param pPage
70 Page object for which a preview is requested. This may be NULL
71 when the page object is expensive to get and the PreviewProvider
72 does not need this object (NeedsPageObject() returns false.)
73 @param rRenderer
74 This PreviewRenderer may be used by the PreviewProvider to
75 create a preview image.
77 virtual Image operator() (int nWidth, SdPage* pPage, ::sd::PreviewRenderer& rRenderer) = 0;
79 /** Return a value that indicates how expensive the creation of a
80 preview image is. The higher the returned value the more expensive
81 is the preview creation. Return 0 when the preview is already
82 present and can be returned immediately.
84 virtual int GetCostIndex() = 0;
86 /** Return whether the page object passed is necessary to create a
87 preview.
89 virtual bool NeedsPageObject() = 0;
91 protected:
92 ~PreviewProvider() {}
95 /** Provide previews of existing page objects by rendering them.
97 class PagePreviewProvider : public PreviewProvider
99 public:
100 PagePreviewProvider();
101 virtual ~PagePreviewProvider() {}
102 virtual Image operator () (int nWidth, SdPage* pPage, ::sd::PreviewRenderer& rRenderer) override;
103 virtual int GetCostIndex() override;
104 virtual bool NeedsPageObject() override;
105 private:
108 /** Provide master page objects for template documents for which only the
109 URL is given.
111 class TemplatePageObjectProvider : public PageObjectProvider
113 public:
114 explicit TemplatePageObjectProvider (const OUString& rsURL);
115 virtual ~TemplatePageObjectProvider() {};
116 virtual SdPage* operator () (SdDrawDocument* pDocument) override;
117 virtual int GetCostIndex() override;
118 private:
119 OUString const msURL;
120 SfxObjectShellLock mxDocumentShell;
121 ::sd::DrawDocShell* LoadDocument (const OUString& sFileName);
124 /** Provide previews for template documents by loading the thumbnails from
125 the documents.
127 class TemplatePreviewProvider : public PreviewProvider
129 public:
130 explicit TemplatePreviewProvider (const OUString& rsURL);
131 virtual ~TemplatePreviewProvider() {};
132 virtual Image operator() (int nWidth, SdPage* pPage, ::sd::PreviewRenderer& rRenderer) override;
133 virtual int GetCostIndex() override;
134 virtual bool NeedsPageObject() override;
135 private:
136 OUString const msURL;
139 /** Create an empty default master page.
141 class DefaultPageObjectProvider : public PageObjectProvider
143 public:
144 DefaultPageObjectProvider();
145 virtual ~DefaultPageObjectProvider() {}
146 virtual SdPage* operator () (SdDrawDocument* pDocument) override;
147 virtual int GetCostIndex() override;
150 /** This implementation of the PageObjectProvider simply returns an already
151 existing master page object.
153 class ExistingPageProvider : public PageObjectProvider
155 public:
156 explicit ExistingPageProvider (SdPage* pPage);
157 virtual ~ExistingPageProvider() {}
158 virtual SdPage* operator() (SdDrawDocument* pDocument) override;
159 virtual int GetCostIndex() override;
160 private:
161 SdPage* const mpPage;
164 } } // end of namespace sd::sidebar
166 #endif
168 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */