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 INCLUDED_SD_SOURCE_UI_INC_PREVIEWRENDERER_HXX
21 #define INCLUDED_SD_SOURCE_UI_INC_PREVIEWRENDERER_HXX
23 #include <vcl/image.hxx>
26 #include <svl/lstner.hxx>
40 /** Create a new preview renderer that takes some of its initial values
41 from the given output device.
43 When <TRUE/> (the default) then a frame is painted around the
44 preview. This makes the actual preview smaller.
46 PreviewRenderer(const bool bPaintFrame
= true);
48 virtual ~PreviewRenderer() override
;
50 /** Render a page with the given pixel size.
51 Use this version when only the width of the preview is known to the
52 caller. The height is then calculated according to the aspect
53 ratio of the given page.
57 The width of the preview in device coordinates.
58 The high contrast mode of the application is
59 ignored and the preview is rendered in normal mode.
63 const sal_Int32 nWidth
);
65 /** Render a page with the given pixel size.
68 @param aPreviewPixelSize
69 The size in device coordinates of the preview.
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 Size aPreviewPixelSize
,
82 const bool bObeyHighContrastMode
,
83 const bool bDisplayPresentationObjects
= true);
85 /** Render an image that contains the given substitution text instead of a
87 @param aPreviewPixelSize
88 The size in device coordinates of the image.
90 Image
RenderSubstitution (
91 const Size
& rPreviewPixelSize
,
92 const OUString
& sSubstitutionText
);
94 /** Scale the given bitmap by keeping its aspect ratio to the desired
95 width. Add a frame to it afterwards.
98 const BitmapEx
& rBitmap
,
102 virtual void Notify(SfxBroadcaster
& rBC
, const SfxHint
& rHint
) override
;
105 ScopedVclPtr
<VirtualDevice
> mpPreviewDevice
;
106 ::std::unique_ptr
<DrawView
> mpView
;
107 DrawDocShell
* mpDocShellOfView
;
108 const Color maFrameColor
;
109 const bool mbHasFrame
;
110 static const int snSubstitutionTextSize
;
111 // Width of the frame that is painted around the preview.
112 static const int snFrameWidth
;
116 const Size
& rPixelSize
,
117 const bool bObeyHighContrastMode
);
120 const bool bDisplayPresentationObjects
);
121 void PaintSubstitutionText (const OUString
& rSubstitutionText
);
124 /** Set up the map mode so that the given page is renderer into a bitmap
125 with the specified width.
127 The page for which the preview is created.
129 The size of the resulting preview bitmap. Note that this size
130 includes the frame. The actual preview is smaller accordingly.
132 void SetupOutputSize (const SdPage
& rPage
, const Size
& rPixelSize
);
134 /** When mpView is empty then create a new view and initialize it.
135 Otherwise just initialize it.
137 void ProvideView (DrawDocShell
* pDocShell
);
140 } // end of namespace ::sd
144 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */