bump product version to 5.0.4.1
[LibreOffice.git] / sd / source / ui / inc / PreviewRenderer.hxx
blob7784b00630c7145c54bf4dbe9563ef974c87bdae
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_INC_PREVIEWRENDERER_HXX
21 #define INCLUDED_SD_SOURCE_UI_INC_PREVIEWRENDERER_HXX
23 #include "drawview.hxx"
24 #include <vcl/image.hxx>
25 #include <vcl/virdev.hxx>
26 #include <svl/listener.hxx>
27 #include <memory>
29 class OutputDevice;
30 class SdPage;
31 class VirtualDevice;
33 namespace sd {
35 class DrawDocShell;
36 class DrawView;
38 class PreviewRenderer
39 : public SfxListener
41 public:
42 /** Create a new preview renderer that takes some of its initial values
43 from the given output device.
44 @param pTemplate
45 May be NULL.
46 @param bPaintFrame
47 When <TRUE/> (the default) then a frame is painted around the
48 preview. This makes the actual preview smaller.
50 PreviewRenderer (
51 OutputDevice* pTemplate = NULL,
52 const bool bPaintFrame = true);
54 virtual ~PreviewRenderer();
56 /** Render a page with the given pixel size.
57 Use this version when only the width of the preview is known to the
58 caller. The height is then calculated according to the aspect
59 ration of the given page.
60 @param pPage
61 The page to render.
62 @param nWidth
63 The width of the preview in device coordinates.
64 @param sSubstitutionText
65 When the actual preview can not be created for some reason, then
66 this text is painted in an empty rectangle of the requested size
67 instead.
68 @param bObeyHighContrastMode
69 When <FALSE/> then the high contrast mode of the application is
70 ignored and the preview is rendered in normal mode. When
71 <TRUE/> and high contrast mode is active then the preview is
72 rendered in high contrast mode.
73 @param bDisplayPresentationObjects
74 When <FALSE/> then the PresObj place holders are not displayed
75 in the returned preview.
77 Image RenderPage (
78 const SdPage* pPage,
79 const sal_Int32 nWidth,
80 const OUString& sSubstitutionText,
81 const bool bObeyHighContrastMode = true,
82 const bool bDisplayPresentationObjects = true);
84 /** Render a page with the given pixel size.
85 @param pPage
86 The page to render.
87 @param aPreviewPixelSize
88 The size in device coordinates of the preview.
89 @param sSubstitutionText
90 When the actual preview can not be created for some reason, then
91 this text is painted in an empty rectangle of the requested size
92 instead.
93 @param bObeyHighContrastMode
94 When <FALSE/> then the high contrast mode of the application is
95 ignored and the preview is rendered in normal mode. When
96 <TRUE/> and high contrast mode is active then the preview is
97 rendered in high contrast mode.
98 @param bDisplayPresentationObjects
99 When <FALSE/> then the PresObj place holders are not displayed
100 in the returned preview.
102 Image RenderPage (
103 const SdPage* pPage,
104 const Size aPreviewPixelSize,
105 const OUString& sSubstitutionText,
106 const bool bObeyHighContrastMode = true,
107 const bool bDisplayPresentationObjects = true);
109 /** Render an image that contains the given substitution text instead of a
110 slide preview.
111 @param aPreviewPixelSize
112 The size in device coordinates of the image.
114 Image RenderSubstitution (
115 const Size& rPreviewPixelSize,
116 const OUString& sSubstitutionText);
118 /** Scale the given bitmap by keeping its aspect ratio to the desired
119 width. Add a frame to it afterwards.
121 Image ScaleBitmap (
122 const BitmapEx& rBitmap,
123 int nWidth);
125 protected:
126 virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) SAL_OVERRIDE;
128 private:
129 ScopedVclPtr<VirtualDevice> mpPreviewDevice;
130 ::std::unique_ptr<DrawView> mpView;
131 DrawDocShell* mpDocShellOfView;
132 const Color maFrameColor;
133 const bool mbHasFrame;
134 static const int snSubstitutionTextSize;
135 // Width of the frame that is painted around the preview.
136 static const int snFrameWidth;
138 bool Initialize (
139 const SdPage* pPage,
140 const Size& rPixelSize,
141 const bool bObeyHighContrastMode);
142 void Cleanup();
143 void PaintPage (
144 const SdPage* pPage,
145 const bool bDisplayPresentationObjects);
146 void PaintSubstitutionText (const OUString& rSubstitutionText);
147 void PaintFrame();
149 /** Set up the map mode so that the given page is renderer into a bitmap
150 with the specified width.
151 @param rPage
152 The page for which the preview is created.
153 @param rPixelSize
154 The size of the resulting preview bitmap. Note that this size
155 includes the frame. The actual preview is smaller accordingly.
157 void SetupOutputSize (const SdPage& rPage, const Size& rPixelSize);
159 /** When mpView is empty then create a new view and initialize it.
160 Otherwise just initialize it.
162 void ProvideView (DrawDocShell* pDocShell);
165 } // end of namespace ::sd
167 #endif
169 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */