LibreOffice Module sd (master) 1
PreviewRenderer.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#pragma once
21
22#include <vcl/image.hxx>
23#include <memory>
24
25#include <svl/lstner.hxx>
26
27class SdPage;
28class VirtualDevice;
29
30namespace sd {
31
32class DrawDocShell;
33class DrawView;
34
35class PreviewRenderer final
36 : public SfxListener
37{
38public:
45 PreviewRenderer(const bool bPaintFrame = true);
46
47 virtual ~PreviewRenderer() override;
48
61 const SdPage* pPage,
62 const sal_Int32 nWidth);
63
79 const SdPage* pPage,
80 const Size aPreviewPixelSize,
81 const bool bObeyHighContrastMode,
82 const bool bDisplayPresentationObjects = true);
83
90 const Size& rPreviewPixelSize,
91 const OUString& sSubstitutionText);
92
97 const BitmapEx& rBitmap,
98 int nWidth);
99
100protected:
101 virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override;
102
103private:
105 ::std::unique_ptr<DrawView> mpView;
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;
112
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();
122
131 void SetupOutputSize (const SdPage& rPage, const Size& rPixelSize);
132
136 void ProvideView (DrawDocShell* pDocShell);
137};
138
139} // end of namespace ::sd
140
141/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
static const int snSubstitutionTextSize
void ProvideView(DrawDocShell *pDocShell)
When mpView is empty then create a new view and initialize it.
Image RenderSubstitution(const Size &rPreviewPixelSize, const OUString &sSubstitutionText)
Render an image that contains the given substitution text instead of a slide preview.
virtual ~PreviewRenderer() override
::std::unique_ptr< DrawView > mpView
Image ScaleBitmap(const BitmapEx &rBitmap, int nWidth)
Scale the given bitmap by keeping its aspect ratio to the desired width.
ScopedVclPtr< VirtualDevice > mpPreviewDevice
Image RenderPage(const SdPage *pPage, const sal_Int32 nWidth)
Render a page with the given pixel size.
static const int snFrameWidth
void SetupOutputSize(const SdPage &rPage, const Size &rPixelSize)
Set up the map mode so that the given page is renderer into a bitmap with the specified width.
DrawDocShell * mpDocShellOfView
void PaintPage(const SdPage *pPage, const bool bDisplayPresentationObjects)
bool Initialize(const SdPage *pPage, const Size &rPixelSize, const bool bObeyHighContrastMode)
void PaintSubstitutionText(const OUString &rSubstitutionText)
PreviewRenderer(const bool bPaintFrame=true)
Create a new preview renderer that takes some of its initial values from the given output device.