Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / vcl / virdev.hxx
blobcf7c82140392da8c3c9b302c1898e9511b3c2500
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 #ifndef INCLUDED_VCL_VIRDEV_HXX
21 #define INCLUDED_VCL_VIRDEV_HXX
23 #include <vcl/dllapi.h>
24 #include <vcl/salgtype.hxx>
25 #include <vcl/outdev.hxx>
28 class SalVirtualDevice;
29 struct SystemGraphicsData;
31 class VCL_DLLPUBLIC VirtualDevice : public OutputDevice
33 friend class Application;
34 friend class ::OutputDevice;
35 friend class Printer;
36 public:
37 // reference device modes for different compatibility levels
38 enum class RefDevMode { NONE = 0,
39 Dpi600 = 1, // 600 dpi
40 MSO1 = 3,
41 PDF1 = 4,
42 Custom = 5
45 private:
46 SalVirtualDevice* mpVirDev;
47 VclPtr<VirtualDevice> mpPrev;
48 VclPtr<VirtualDevice> mpNext;
49 sal_uInt16 mnBitCount;
50 bool mbScreenComp;
51 DeviceFormat meFormat;
52 DeviceFormat meAlphaFormat;
53 RefDevMode meRefDevMode;
54 bool mbForceZeroExtleadBug;
56 SAL_DLLPRIVATE void ImplInitVirDev( const OutputDevice* pOutDev, long nDX, long nDY, DeviceFormat eFormat, const SystemGraphicsData *pData = nullptr );
57 SAL_DLLPRIVATE bool InnerImplSetOutputSizePixel( const Size& rNewSize, bool bErase,
58 sal_uInt8* pBuffer );
59 SAL_DLLPRIVATE bool ImplSetOutputSizePixel( const Size& rNewSize, bool bErase,
60 sal_uInt8* pBuffer );
62 VirtualDevice (const VirtualDevice &) = delete;
63 VirtualDevice & operator= (const VirtualDevice &) = delete;
65 /** Used for alpha VDev, to set areas to opaque
67 @since \#i32109#
69 SAL_DLLPRIVATE void ImplFillOpaqueRectangle( const tools::Rectangle& rRect );
71 protected:
72 virtual bool AcquireGraphics() const override;
73 virtual void ReleaseGraphics( bool bRelease = true ) override;
75 public:
77 /** Create a virtual device of size 1x1
79 @param eFormat
80 Device format of the generated virtual device. Use DeviceFormat::DEFAULT here, to
81 indicate: take default screen depth. Only DeviceFormat::BITMASK
82 is the other possibility to denote a binary mask.
84 explicit VirtualDevice(DeviceFormat eFormat = DeviceFormat::DEFAULT);
86 /** Create a virtual device of size 1x1
88 @param rCompDev
89 The generated vdev will be compatible to this device.
91 @param eFormat
92 Device format of the generated virtual device. Use DeviceFormat::DEFAULT here, to
93 indicate: take default screen depth. Only DeviceFormat::BITMASK
94 is the other possibility to denote a binary mask.
96 explicit VirtualDevice(const OutputDevice& rCompDev,
97 DeviceFormat eFormat = DeviceFormat::DEFAULT);
99 /** Create a virtual device of size 1x1 with alpha channel
101 @param rCompDev
102 The generated vdev will be compatible to this device.
104 @param eFormat
105 Device format of the generated virtual device. Use DeviceFormat::DEFAULT here, to
106 indicate: take default screen depth. Only DeviceFormat::BITMASK
107 is the other possibility to denote a binary mask.
109 @param eAlphaFormat
110 Device format of the generated virtual device. Use DeviceFormat::DEFAULT here, to
111 indicate: take default screen depth. Only DeviceFormat::BITMASK
112 is the other possibility to denote a binary mask.
114 explicit VirtualDevice( const OutputDevice& rCompDev,
115 DeviceFormat eFormat, DeviceFormat eAlphaFormat);
117 /** Create a virtual device using an existing system dependent device or graphics context
118 Any rendering will happen directly on the context and not on any intermediate bitmap.
119 Note: This might not be supported on all platforms !
121 explicit VirtualDevice(const SystemGraphicsData *pData, const Size &rSize,
122 DeviceFormat eFormat);
124 virtual ~VirtualDevice() override;
125 virtual void dispose() override;
127 virtual void EnableRTL( bool bEnable = true ) override;
129 bool SetOutputSizePixel( const Size& rNewSize, bool bErase = true );
130 bool SetOutputSizePixelScaleOffsetAndBuffer( const Size& rNewSize,
131 const Fraction& rScale,
132 const Point& rNewOffset,
133 sal_uInt8* pBuffer);
135 bool SetOutputSize( const Size& rNewSize )
136 { return SetOutputSizePixel( LogicToPixel( rNewSize ) ); }
138 void SetReferenceDevice( RefDevMode );
140 void Compat_ZeroExtleadBug(); // enable workaround for #i60495#
142 void SetReferenceDevice( sal_Int32 i_nDPIX, sal_Int32 i_nDPIY );
144 virtual sal_uInt16 GetBitCount() const override;
146 private:
147 SAL_DLLPRIVATE void ImplSetReferenceDevice( RefDevMode, sal_Int32 i_nDPIX, sal_Int32 i_nDPIY );
149 protected:
150 virtual bool UsePolyPolygonForComplexGradient() override;
152 virtual long GetFontExtLeading() const override;
156 #endif // INCLUDED_VCL_VIRDEV_HXX
158 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */