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
84 const sal_Int32 nWidth
,
85 const String
& sSubstitutionText
);
87 /** Render a page with the given pixel size.
90 @param aPreviewPixelSize
91 The size in device coordinates of the preview.
92 @param sSubstitutionText
93 When the actual preview can not be created for some reason, then
94 this text is painted in an empty rectangle of the requested size
99 const Size aPreviewPixelSize
,
100 const String
& sSubstitutionText
);
102 /** Render an image that contains the given substitution text instead of a
104 @param aPreviewPixelSize
105 The size in device coordinates of the image.
107 Image
RenderSubstitution (
108 const Size
& rPreviewPixelSize
,
109 const String
& sSubstitutionText
);
111 /** Scale the given bitmap by keeping its aspect ratio to the desired
112 width. Add a frame to it afterwards.
115 const BitmapEx
& rBitmap
,
119 virtual void Notify(SfxBroadcaster
& rBC
, const SfxHint
& rHint
);
122 ::std::auto_ptr
<VirtualDevice
> mpPreviewDevice
;
123 ::std::auto_ptr
<DrawView
> mpView
;
124 DrawDocShell
* mpDocShellOfView
;
126 const Color maFrameColor
;
127 const bool mbHasFrame
;
128 static const int snSubstitutionTextSize
;
129 // Width of the frame that is painted arround the preview.
130 static const int snFrameWidth
;
134 const Size
& rPixelSize
);
136 void PaintPage (const SdPage
* pPage
);
137 void PaintSubstitutionText (const String
& rSubstitutionText
);
138 void PaintFrame (void);
140 /** Set up the map mode so that the given page is renderer into a bitmap
141 with the specified width.
143 The page for which the preview is created.
145 The size of the resulting preview bitmap. Note that this size
146 includes the frame. The actual preview is smaller accordingly.
148 void SetupOutputSize (const SdPage
& rPage
, const Size
& rPixelSize
);
150 /** When mpView is empty then create a new view and initialize it.
151 Otherwise just initialize it.
153 void ProvideView (DrawDocShell
* pDocShell
);
156 } // end of namespace ::sd