Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sd / source / ui / inc / PreviewRenderer.hxx
blob90822014760b7962e3c489b97e30afcbe45151c0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #pragma once
22 #include <vcl/image.hxx>
23 #include <memory>
25 #include <svl/lstner.hxx>
27 class SdPage;
28 class VirtualDevice;
30 namespace sd {
32 class DrawDocShell;
33 class DrawView;
35 class PreviewRenderer final
36 : public SfxListener
38 public:
39 /** Create a new preview renderer that takes some of its initial values
40 from the given output device.
41 @param bPaintFrame
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.
53 @param pPage
54 The page to render.
55 @param nWidth
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.
60 Image RenderPage (
61 const SdPage* pPage,
62 const sal_Int32 nWidth);
64 /** Render a page with the given pixel size.
65 @param pPage
66 The page to render.
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.
78 Image RenderPage (
79 const SdPage* pPage,
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
85 slide preview.
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.
96 Image ScaleBitmap (
97 const BitmapEx& rBitmap,
98 int nWidth);
100 protected:
101 virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override;
103 private:
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;
113 bool Initialize (
114 const SdPage* pPage,
115 const Size& rPixelSize,
116 const bool bObeyHighContrastMode);
117 void PaintPage (
118 const SdPage* pPage,
119 const bool bDisplayPresentationObjects);
120 void PaintSubstitutionText (const OUString& rSubstitutionText);
121 void PaintFrame();
123 /** Set up the map mode so that the given page is renderer into a bitmap
124 with the specified width.
125 @param rPage
126 The page for which the preview is created.
127 @param rPixelSize
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: */