LibreOffice Module vcl (master)  1
virdev.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 #ifndef INCLUDED_VCL_VIRDEV_HXX
21 #define INCLUDED_VCL_VIRDEV_HXX
22 
23 #include <vcl/dllapi.h>
24 #include <vcl/outdev.hxx>
25 #include <vcl/salgtype.hxx>
26 #include <memory>
27 
28 class SalVirtualDevice;
29 struct SystemGraphicsData;
30 typedef struct _cairo_surface cairo_surface_t;
31 
33 {
34  friend class Application;
35  friend class ::OutputDevice;
36  friend class Printer;
38 public:
39  // reference device modes for different compatibility levels
40  enum class RefDevMode { NONE = 0,
41  Dpi600 = 1, // 600 dpi
42  MSO1 = 3,
43  PDF1 = 4,
44  Custom = 5
45  };
46 
47 private:
48  std::unique_ptr<SalVirtualDevice> mpVirDev;
51  sal_uInt16 mnBitCount;
57 
58  SAL_DLLPRIVATE void ImplInitVirDev( const OutputDevice* pOutDev, long nDX, long nDY, const SystemGraphicsData *pData = nullptr );
59  SAL_DLLPRIVATE bool InnerImplSetOutputSizePixel( const Size& rNewSize, bool bErase,
60  sal_uInt8* pBuffer );
61  SAL_DLLPRIVATE bool ImplSetOutputSizePixel( const Size& rNewSize, bool bErase,
62  sal_uInt8* pBuffer );
63 
64  VirtualDevice (const VirtualDevice &) = delete;
65  VirtualDevice & operator= (const VirtualDevice &) = delete;
66 
71  SAL_DLLPRIVATE void ImplFillOpaqueRectangle( const tools::Rectangle& rRect );
72 
73 protected:
74  virtual bool AcquireGraphics() const override;
75  virtual void ReleaseGraphics( bool bRelease = true ) override;
76 
96  explicit VirtualDevice(const OutputDevice* pCompDev, DeviceFormat eFormat,
97  DeviceFormat eAlphaFormat, OutDevType eOutDevType);
98 
99 public:
100 
114  : VirtualDevice(nullptr, eFormat, eAlphaFormat, OUTDEV_VIRDEV) {}
115 
126  explicit VirtualDevice(const OutputDevice& rCompDev,
128  : VirtualDevice(&rCompDev, eFormat, DeviceFormat::NONE, OUTDEV_VIRDEV) {}
129 
145  explicit VirtualDevice(const OutputDevice& rCompDev,
146  DeviceFormat eFormat, DeviceFormat eAlphaFormat)
147  : VirtualDevice(&rCompDev, eFormat, eAlphaFormat, OUTDEV_VIRDEV) {}
148 
153  explicit VirtualDevice(const SystemGraphicsData& rData, const Size &rSize,
154  DeviceFormat eFormat);
155 
156  virtual ~VirtualDevice() override;
157  virtual void dispose() override;
158 
159  virtual void EnableRTL( bool bEnable = true ) override;
160 
161  bool SetOutputSizePixel( const Size& rNewSize, bool bErase = true );
162  bool SetOutputSizePixelScaleOffsetAndBuffer( const Size& rNewSize,
163  const Fraction& rScale,
164  const Point& rNewOffset,
165  sal_uInt8* pBuffer);
166 
167  bool SetOutputSize( const Size& rNewSize )
168  { return SetOutputSizePixel( LogicToPixel( rNewSize ) ); }
169 
170  void SetReferenceDevice( RefDevMode );
171 
172  void Compat_ZeroExtleadBug(); // enable workaround for #i60495#
173 
174  void SetReferenceDevice( sal_Int32 i_nDPIX, sal_Int32 i_nDPIY );
175 
176  virtual sal_uInt16 GetBitCount() const override;
177 
178  bool IsVirtual() const override;
179 
180 private:
181  SAL_DLLPRIVATE void ImplSetReferenceDevice( RefDevMode, sal_Int32 i_nDPIX, sal_Int32 i_nDPIY );
182 
183 protected:
184  virtual bool UsePolyPolygonForComplexGradient() override;
185 
186  virtual long GetFontExtLeading() const override;
187 
188 };
189 
190 #endif // INCLUDED_VCL_VIRDEV_HXX
191 
192 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const DeviceFormat meFormat
Definition: virdev.hxx:53
virtual bool UsePolyPolygonForComplexGradient()=0
virtual bool IsVirtual() const
Definition: outdev.cxx:183
VclPtr< VirtualDevice > mpNext
Definition: virdev.hxx:50
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
VirtualDevice(DeviceFormat eFormat=DeviceFormat::DEFAULT, DeviceFormat eAlphaFormat=DeviceFormat::NONE)
Create a virtual device of size 1x1.
Definition: virdev.hxx:113
VirtualDevice(const OutputDevice &rCompDev, DeviceFormat eFormat, DeviceFormat eAlphaFormat)
Create a virtual device of size 1x1 with alpha channel.
Definition: virdev.hxx:145
const DeviceFormat meAlphaFormat
Definition: virdev.hxx:54
NONE
bool mbScreenComp
Definition: virdev.hxx:52
virtual void EnableRTL(bool bEnable=true)
Definition: outdev.cxx:596
VirtualDevice(const OutputDevice &rCompDev, DeviceFormat eFormat=DeviceFormat::DEFAULT)
Create a virtual device of size 1x1.
Definition: virdev.hxx:126
virtual long GetFontExtLeading() const
OutDevType
Definition: outdev.hxx:278
virtual void dispose() override
Definition: outdev.cxx:141
virtual bool AcquireGraphics() const =0
Acquire a graphics device that the output device uses to draw on.
bool SetOutputSize(const Size &rNewSize)
Definition: virdev.hxx:167
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:304
std::unique_ptr< SalVirtualDevice > mpVirDev
Definition: virdev.hxx:48
sal_uInt16 mnBitCount
Definition: virdev.hxx:51
Base class used mainly for the LibreOffice Desktop class.
Definition: svapp.hxx:238
bool mbForceZeroExtleadBug
Definition: virdev.hxx:56
virtual sal_uInt16 GetBitCount() const
Definition: outdev.cxx:305
Point LogicToPixel(const Point &rLogicPt) const
Definition: map.cxx:940
RefDevMode meRefDevMode
Definition: virdev.hxx:55
DeviceFormat
Definition: salgtype.hxx:28
VclPtr< VirtualDevice > mpPrev
Definition: virdev.hxx:49
virtual void ReleaseGraphics(bool bRelease=true)=0
Release the graphics device, and remove it from the graphics device list.
friend class VirtualDevice
Definition: outdev.hxx:307
VCL_DLLPUBLIC cairo_surface_t * get_underlying_cairo_surface(const VirtualDevice &rDevice)
unsigned char sal_uInt8
A non-visible drawable/buffer (e.g. an X11 Pixmap).
Definition: salvd.hxx:28
OutputDevice & operator=(const OutputDevice &)=delete
struct _cairo_surface cairo_surface_t
Definition: svpgdi.hxx:71