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 
109  : VirtualDevice(nullptr, eFormat, DeviceFormat::NONE, OUTDEV_VIRDEV) {}
110 
121  explicit VirtualDevice(const OutputDevice& rCompDev,
123  : VirtualDevice(&rCompDev, eFormat, DeviceFormat::NONE, OUTDEV_VIRDEV) {}
124 
140  explicit VirtualDevice(const OutputDevice& rCompDev,
141  DeviceFormat eFormat, DeviceFormat eAlphaFormat)
142  : VirtualDevice(&rCompDev, eFormat, eAlphaFormat, OUTDEV_VIRDEV) {}
143 
148  explicit VirtualDevice(const SystemGraphicsData& rData, const Size &rSize,
149  DeviceFormat eFormat);
150 
151  virtual ~VirtualDevice() override;
152  virtual void dispose() override;
153 
154  virtual void EnableRTL( bool bEnable = true ) override;
155 
156  bool SetOutputSizePixel( const Size& rNewSize, bool bErase = true );
157  bool SetOutputSizePixelScaleOffsetAndBuffer( const Size& rNewSize,
158  const Fraction& rScale,
159  const Point& rNewOffset,
160  sal_uInt8* pBuffer);
161 
162  bool SetOutputSize( const Size& rNewSize )
163  { return SetOutputSizePixel( LogicToPixel( rNewSize ) ); }
164 
165  void SetReferenceDevice( RefDevMode );
166 
167  void Compat_ZeroExtleadBug(); // enable workaround for #i60495#
168 
169  void SetReferenceDevice( sal_Int32 i_nDPIX, sal_Int32 i_nDPIY );
170 
171  virtual sal_uInt16 GetBitCount() const override;
172 
173  bool IsVirtual() const override;
174 
175 private:
176  SAL_DLLPRIVATE void ImplSetReferenceDevice( RefDevMode, sal_Int32 i_nDPIX, sal_Int32 i_nDPIY );
177 
178 protected:
179  virtual bool UsePolyPolygonForComplexGradient() override;
180 
181  virtual long GetFontExtLeading() const override;
182 
183 };
184 
185 #endif // INCLUDED_VCL_VIRDEV_HXX
186 
187 /* 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)
Create a virtual device of size 1x1.
Definition: virdev.hxx:108
VirtualDevice(const OutputDevice &rCompDev, DeviceFormat eFormat, DeviceFormat eAlphaFormat)
Create a virtual device of size 1x1 with alpha channel.
Definition: virdev.hxx:140
const DeviceFormat meAlphaFormat
Definition: virdev.hxx:54
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:121
NONE
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:162
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:70