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 .
22 #include <vcl/image.hxx>
25 #include <svl/lstner.hxx>
35 class PreviewRenderer final
39 /** Create a new preview renderer that takes some of its initial values
40 from the given output device.
42 When <TRUE/> (the default) then a frame is painted around the
43 preview. This makes the actual preview smaller.
45 PreviewRenderer(const bool bPaintFrame
= true);
47 virtual ~PreviewRenderer() override
;
49 /** Render a page with the given pixel size.
50 Use this version when only the width of the preview is known to the
51 caller. The height is then calculated according to the aspect
52 ratio of the given page.
56 The width of the preview in device coordinates.
57 The high contrast mode of the application is
58 ignored and the preview is rendered in normal mode.
62 const sal_Int32 nWidth
);
64 /** Render a page with the given pixel size.
67 @param aPreviewPixelSize
68 The size in device coordinates of the preview.
69 @param bObeyHighContrastMode
70 When <FALSE/> then the high contrast mode of the application is
71 ignored and the preview is rendered in normal mode. When
72 <TRUE/> and high contrast mode is active then the preview is
73 rendered in high contrast mode.
74 @param bDisplayPresentationObjects
75 When <FALSE/> then the PresObj place holders are not displayed
76 in the returned preview.
80 const Size aPreviewPixelSize
,
81 const bool bObeyHighContrastMode
,
82 const bool bDisplayPresentationObjects
= true);
84 /** Render an image that contains the given substitution text instead of a
86 @param aPreviewPixelSize
87 The size in device coordinates of the image.
89 Image
RenderSubstitution (
90 const Size
& rPreviewPixelSize
,
91 const OUString
& sSubstitutionText
);
93 /** Scale the given bitmap by keeping its aspect ratio to the desired
94 width. Add a frame to it afterwards.
97 const BitmapEx
& rBitmap
,
101 virtual void Notify(SfxBroadcaster
& rBC
, const SfxHint
& rHint
) override
;
104 ScopedVclPtr
<VirtualDevice
> mpPreviewDevice
;
105 ::std::unique_ptr
<DrawView
> mpView
;
106 DrawDocShell
* mpDocShellOfView
;
107 const Color maFrameColor
;
108 const bool mbHasFrame
;
109 static const int snSubstitutionTextSize
;
110 // Width of the frame that is painted around the preview.
111 static const int snFrameWidth
;
115 const Size
& rPixelSize
,
116 const bool bObeyHighContrastMode
);
119 const bool bDisplayPresentationObjects
);
120 void PaintSubstitutionText (const OUString
& rSubstitutionText
);
123 /** Set up the map mode so that the given page is renderer into a bitmap
124 with the specified width.
126 The page for which the preview is created.
128 The size of the resulting preview bitmap. Note that this size
129 includes the frame. The actual preview is smaller accordingly.
131 void SetupOutputSize (const SdPage
& rPage
, const Size
& rPixelSize
);
133 /** When mpView is empty then create a new view and initialize it.
134 Otherwise just initialize it.
136 void ProvideView (DrawDocShell
* pDocShell
);
139 } // end of namespace ::sd
141 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */