1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: PreviewRenderer.hxx,v $
10 * $Revision: 1.6.34.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SD_PREVIEW_RENDERER_HXX
32 #define SD_PREVIEW_RENDERER_HXX
34 #include "drawview.hxx"
35 #include <vcl/image.hxx>
36 #include <vcl/virdev.hxx>
37 #include <svtools/listener.hxx>
55 /** Create a new preview renderer that takes some of its inital values
56 from the given output device.
60 When <TRUE/> (the default) then a frame is painted around the
61 preview. This makes the actual preview smaller.
64 OutputDevice
* pTemplate
= NULL
,
65 const bool bPaintFrame
= true);
67 ~PreviewRenderer (void);
69 /** Render a page with the given pixel size.
70 Use this version when only the width of the preview is known to the
71 caller. The height is then calculated according to the aspect
72 ration of the given page.
76 The width of the preview in device coordinates.
77 @param sSubstitutionText
78 When the actual preview can not be created for some reason, then
79 this text is painted in an empty rectangle of the requested size
81 @param bObeyHighContrastMode
82 When <FALSE/> then the high contrast mode of the application is
83 ignored and the preview is rendered in normal mode. When
84 <TRUE/> and high contrast mode is active then the preview is
85 rendered in high contrast mode.
89 const sal_Int32 nWidth
,
90 const String
& sSubstitutionText
,
91 const bool bObeyHighContrastMode
= true);
93 /** Render a page with the given pixel size.
96 @param aPreviewPixelSize
97 The size in device coordinates of the preview.
98 @param sSubstitutionText
99 When the actual preview can not be created for some reason, then
100 this text is painted in an empty rectangle of the requested size
102 @param bObeyHighContrastMode
103 When <FALSE/> then the high contrast mode of the application is
104 ignored and the preview is rendered in normal mode. When
105 <TRUE/> and high contrast mode is active then the preview is
106 rendered in high contrast mode.
110 const Size aPreviewPixelSize
,
111 const String
& sSubstitutionText
,
112 const bool bObeyHighContrastMode
= true);
114 /** Render an image that contains the given substitution text instead of a
116 @param aPreviewPixelSize
117 The size in device coordinates of the image.
119 Image
RenderSubstitution (
120 const Size
& rPreviewPixelSize
,
121 const String
& sSubstitutionText
);
123 /** Scale the given bitmap by keeping its aspect ratio to the desired
124 width. Add a frame to it afterwards.
127 const BitmapEx
& rBitmap
,
131 virtual void Notify(SfxBroadcaster
& rBC
, const SfxHint
& rHint
);
134 ::std::auto_ptr
<VirtualDevice
> mpPreviewDevice
;
135 ::std::auto_ptr
<DrawView
> mpView
;
136 DrawDocShell
* mpDocShellOfView
;
138 const Color maFrameColor
;
139 const bool mbHasFrame
;
140 static const int snSubstitutionTextSize
;
141 // Width of the frame that is painted arround the preview.
142 static const int snFrameWidth
;
146 const Size
& rPixelSize
,
147 const bool bObeyHighContrastMode
);
149 void PaintPage (const SdPage
* pPage
);
150 void PaintSubstitutionText (const String
& rSubstitutionText
);
151 void PaintFrame (void);
153 /** Set up the map mode so that the given page is renderer into a bitmap
154 with the specified width.
156 The page for which the preview is created.
158 The size of the resulting preview bitmap. Note that this size
159 includes the frame. The actual preview is smaller accordingly.
161 void SetupOutputSize (const SdPage
& rPage
, const Size
& rPixelSize
);
163 /** When mpView is empty then create a new view and initialize it.
164 Otherwise just initialize it.
166 void ProvideView (DrawDocShell
* pDocShell
);
169 } // end of namespace ::sd