1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 SD_PREVIEW_RENDERER_HXX
21 #define SD_PREVIEW_RENDERER_HXX
23 #include "drawview.hxx"
24 #include <vcl/image.hxx>
25 #include <vcl/virdev.hxx>
26 #include <svl/listener.hxx>
44 /** Create a new preview renderer that takes some of its initial values
45 from the given output device.
49 When <TRUE/> (the default) then a frame is painted around the
50 preview. This makes the actual preview smaller.
53 OutputDevice
* pTemplate
= NULL
,
54 const bool bPaintFrame
= true);
56 ~PreviewRenderer (void);
58 /** Render a page with the given pixel size.
59 Use this version when only the width of the preview is known to the
60 caller. The height is then calculated according to the aspect
61 ration of the given page.
65 The width of the preview in device coordinates.
66 @param sSubstitutionText
67 When the actual preview can not be created for some reason, then
68 this text is painted in an empty rectangle of the requested size
70 @param bObeyHighContrastMode
71 When <FALSE/> then the high contrast mode of the application is
72 ignored and the preview is rendered in normal mode. When
73 <TRUE/> and high contrast mode is active then the preview is
74 rendered in high contrast mode.
75 @param bDisplayPresentationObjects
76 When <FALSE/> then the PresObj place holders are not displayed
77 in the returned preview.
81 const sal_Int32 nWidth
,
82 const String
& sSubstitutionText
,
83 const bool bObeyHighContrastMode
= true,
84 const bool bDisplayPresentationObjects
= true);
86 /** Render a page with the given pixel size.
89 @param aPreviewPixelSize
90 The size in device coordinates of the preview.
91 @param sSubstitutionText
92 When the actual preview can not be created for some reason, then
93 this text is painted in an empty rectangle of the requested size
95 @param bObeyHighContrastMode
96 When <FALSE/> then the high contrast mode of the application is
97 ignored and the preview is rendered in normal mode. When
98 <TRUE/> and high contrast mode is active then the preview is
99 rendered in high contrast mode.
100 @param bDisplayPresentationObjects
101 When <FALSE/> then the PresObj place holders are not displayed
102 in the returned preview.
106 const Size aPreviewPixelSize
,
107 const String
& sSubstitutionText
,
108 const bool bObeyHighContrastMode
= true,
109 const bool bDisplayPresentationObjects
= true);
111 /** Render an image that contains the given substitution text instead of a
113 @param aPreviewPixelSize
114 The size in device coordinates of the image.
116 Image
RenderSubstitution (
117 const Size
& rPreviewPixelSize
,
118 const String
& sSubstitutionText
);
120 /** Scale the given bitmap by keeping its aspect ratio to the desired
121 width. Add a frame to it afterwards.
124 const BitmapEx
& rBitmap
,
128 virtual void Notify(SfxBroadcaster
& rBC
, const SfxHint
& rHint
);
131 ::std::auto_ptr
<VirtualDevice
> mpPreviewDevice
;
132 ::std::auto_ptr
<DrawView
> mpView
;
133 DrawDocShell
* mpDocShellOfView
;
134 const Color maFrameColor
;
135 const bool mbHasFrame
;
136 static const int snSubstitutionTextSize
;
137 // Width of the frame that is painted arround the preview.
138 static const int snFrameWidth
;
142 const Size
& rPixelSize
,
143 const bool bObeyHighContrastMode
);
147 const bool bDisplayPresentationObjects
);
148 void PaintSubstitutionText (const String
& rSubstitutionText
);
149 void PaintFrame (void);
151 /** Set up the map mode so that the given page is renderer into a bitmap
152 with the specified width.
154 The page for which the preview is created.
156 The size of the resulting preview bitmap. Note that this size
157 includes the frame. The actual preview is smaller accordingly.
159 void SetupOutputSize (const SdPage
& rPage
, const Size
& rPixelSize
);
161 /** When mpView is empty then create a new view and initialize it.
162 Otherwise just initialize it.
164 void ProvideView (DrawDocShell
* pDocShell
);
167 } // end of namespace ::sd
171 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */