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_OUTDEV_HXX
21 #define INCLUDED_VCL_OUTDEV_HXX
22 
23 #include <tools/gen.hxx>
24 #include <tools/ref.hxx>
25 #include <tools/solar.h>
26 #include <tools/color.hxx>
27 #include <tools/poly.hxx>
28 #include <o3tl/typed_flags_set.hxx>
29 #include <vcl/bitmap.hxx>
30 #include <vcl/cairo.hxx>
31 #include <vcl/devicecoordinate.hxx>
32 #include <vcl/dllapi.h>
33 #include <vcl/font.hxx>
34 #include <vcl/region.hxx>
35 #include <vcl/mapmod.hxx>
36 #include <vcl/wall.hxx>
37 #include <vcl/metaactiontypes.hxx>
38 #include <vcl/salnativewidgets.hxx>
39 #include <vcl/outdevstate.hxx>
40 #include <vcl/outdevmap.hxx>
41 #include <vcl/vclreferencebase.hxx>
42 
43 #include <basegfx/numeric/ftools.hxx>
44 #include <basegfx/vector/b2enums.hxx>
45 #include <basegfx/polygon/b2dpolypolygon.hxx>
46 
47 #include <unotools/fontdefs.hxx>
48 
49 #include <com/sun/star/drawing/LineCap.hpp>
50 #include <com/sun/star/uno/Reference.h>
51 
52 #include <memory>
53 #include <vector>
54 
55 struct ImplOutDevData;
56 class LogicalFontInstance;
57 struct SystemGraphicsData;
58 struct SystemFontData;
59 struct SystemTextLayoutData;
60 class ImplFontCache;
61 class PhysicalFontCollection;
62 class ImplDeviceFontList;
63 class ImplDeviceFontSizeList;
64 class ImplMultiTextLineInfo;
65 class SalGraphics;
66 class Gradient;
67 class Hatch;
68 class AllSettings;
69 class BitmapReadAccess;
70 class BitmapEx;
71 class Image;
72 class TextRectInfo;
73 class FontMetric;
74 class GDIMetaFile;
75 class GfxLink;
76 namespace tools {
77     class Line;
78 }
79 class LineInfo;
80 class AlphaMask;
81 class FontCharMap;
82 class SalLayout;
83 class ImplLayoutArgs;
84 class VirtualDevice;
85 struct SalTwoRect;
86 class Printer;
87 class VCLXGraphics;
88 class OutDevStateStack;
89 class SalLayoutGlyphs;
90 
91 namespace vcl
92 {
93     class ExtOutDevData;
94     class ITextLayout;
95     struct FontCapabilities;
96     class TextLayoutCache;
97     class Window;
98     namespace font {
99         struct Feature;
100     }
101 }
102 
103 namespace basegfx {
104     class B2DHomMatrix;
105     class B2DPolygon;
106     class B2IVector;
107     typedef B2IVector B2ISize;
108 }
109 
110 namespace com { namespace sun { namespace star { namespace awt {
111     class XGraphics;
112 } } } }
113 
114 #if defined UNX
115 #define GLYPH_FONT_HEIGHT   128
116 #else
117 #define GLYPH_FONT_HEIGHT   256
118 #endif
119 
120 // Text Layout options
121 enum class SalLayoutFlags
122 {
123     NONE                    = 0x0000,
124     BiDiRtl                 = 0x0001,
125     BiDiStrong              = 0x0002,
126     RightAlign              = 0x0004,
127     DisableKerning          = 0x0010,
128     KerningAsian            = 0x0020,
129     Vertical                = 0x0040,
130     KashidaJustification    = 0x0800,
131     ForFallback             = 0x2000,
132     GlyphItemsOnly          = 0x4000,
133 };
134 namespace o3tl
135 {
136     template<> struct typed_flags<SalLayoutFlags> : is_typed_flags<SalLayoutFlags, 0x6877> {};
137 }
138 
139 typedef std::vector< tools::Rectangle > MetricVector;
140 
141 // OutputDevice-Types
142 
143 // Flags for DrawText()
144 enum class DrawTextFlags
145 {
146     NONE                  = 0x00000000,
147     Disable               = 0x00000001,
148     Mnemonic              = 0x00000002,
149     Mono                  = 0x00000004,
150     Clip                  = 0x00000008,
151     Left                  = 0x00000010,
152     Center                = 0x00000020,
153     Right                 = 0x00000040,
154     Top                   = 0x00000080,
155     VCenter               = 0x00000100,
156     Bottom                = 0x00000200,
157     EndEllipsis           = 0x00000400,
158     PathEllipsis          = 0x00000800,
159     MultiLine             = 0x00001000,
160     WordBreak             = 0x00002000,
161     NewsEllipsis          = 0x00004000,
162     WordBreakHyphenation  = 0x00008000 | WordBreak,
163     CenterEllipsis        = 0x00010000,
164     HideMnemonic          = 0x00020000,
165 };
166 namespace o3tl
167 {
168     template<> struct typed_flags<DrawTextFlags> : is_typed_flags<DrawTextFlags, 0x3ffff> {};
169 }
170 
171 // Flags for DrawImage(), these must match the definitions in css::awt::ImageDrawMode
172 enum class DrawImageFlags
173 {
174     NONE                 = 0x0000,
175     Disable              = 0x0001,
176     Highlight            = 0x0002,
177     Deactive             = 0x0004,
178     ColorTransform       = 0x0008,
179     SemiTransparent      = 0x0010,
180 };
181 namespace o3tl
182 {
183     template<> struct typed_flags<DrawImageFlags> : is_typed_flags<DrawImageFlags, 0x001f> {};
184 }
185 
186 // Flags for DrawGrid()
187 enum class DrawGridFlags
188 {
189     NONE                 = 0x0000,
190     Dots                 = 0x0001,
191     HorzLines            = 0x0002,
192     VertLines            = 0x0004
193 };
194 namespace o3tl
195 {
196     template<> struct typed_flags<DrawGridFlags> : is_typed_flags<DrawGridFlags, 0x0007> {};
197 }
198 
199 // DrawModes
200 enum class DrawModeFlags : sal_uInt32
201 {
202     Default                = 0x00000000,
203     BlackLine              = 0x00000001,
204     BlackFill              = 0x00000002,
205     BlackText              = 0x00000004,
206     BlackBitmap            = 0x00000008,
207     BlackGradient          = 0x00000010,
208     GrayLine               = 0x00000020,
209     GrayFill               = 0x00000040,
210     GrayText               = 0x00000080,
211     GrayBitmap             = 0x00000100,
212     GrayGradient           = 0x00000200,
213     NoFill                 = 0x00000400,
214     WhiteLine              = 0x00000800,
215     WhiteFill              = 0x00001000,
216     WhiteText              = 0x00002000,
217     WhiteBitmap            = 0x00004000,
218     WhiteGradient          = 0x00008000,
219     SettingsLine           = 0x00010000,
220     SettingsFill           = 0x00020000,
221     SettingsText           = 0x00040000,
222     SettingsGradient       = 0x00080000,
223     NoTransparency         = 0x00100000,
224 };
225 namespace o3tl
226 {
227     template<> struct typed_flags<DrawModeFlags> : is_typed_flags<DrawModeFlags, 0x1fffff> {};
228 }
229 
230 // Antialiasing
231 enum class AntialiasingFlags
232 {
233     NONE                = 0x0000,
234     DisableText         = 0x0001,
235     EnableB2dDraw       = 0x0002,
236     PixelSnapHairline  = 0x0004,
237 };
238 namespace o3tl
239 {
240     template<> struct typed_flags<AntialiasingFlags> : is_typed_flags<AntialiasingFlags, 0x07> {};
241 }
242 
243 // AddFontSubstitute() flags
244 enum class AddFontSubstituteFlags
245 {
246     NONE            = 0x00,
247     ALWAYS          = 0x01,
248     ScreenOnly      = 0x02,
249 };
250 namespace o3tl
251 {
252     template<> struct typed_flags<AddFontSubstituteFlags> : is_typed_flags<AddFontSubstituteFlags, 0x03> {};
253 }
254 
255 // GetDefaultFont() flags
256 enum class GetDefaultFontFlags
257 {
258     NONE          = 0x0000,
259     OnlyOne       = 0x0001,
260 };
261 namespace o3tl
262 {
263     template<> struct typed_flags<GetDefaultFontFlags> : is_typed_flags<GetDefaultFontFlags, 0x01> {};
264 }
265 
266 // Flags for Invert()
267 enum class InvertFlags
268 {
269     NONE                    = 0x0000,
270     N50                     = 0x0001,
271     TrackFrame              = 0x0002
272 };
273 namespace o3tl
274 {
275     template<> struct typed_flags<InvertFlags> : is_typed_flags<InvertFlags, 0x0003> {};
276 }
277 
278 enum OutDevType { OUTDEV_WINDOW, OUTDEV_PRINTER, OUTDEV_VIRDEV, OUTDEV_PDF };
279 
280 enum class OutDevViewType { DontKnow, PrintPreview, SlideShow };
281 
282 // OutputDevice
283 
284 typedef tools::SvRef<FontCharMap> FontCharMapRef;
285 
286 BmpMirrorFlags AdjustTwoRect( SalTwoRect& rTwoRect, const Size& rSizePix );
287 void AdjustTwoRect( SalTwoRect& rTwoRect, const tools::Rectangle& rValidSrcRect );
288 
289 class OutputDevice;
290 
291 namespace vcl {
292     typedef OutputDevice RenderContext;
293 }
294 
295 VCL_DLLPUBLIC void DrawFocusRect(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect);
296 
297 typedef struct _cairo_surface cairo_surface_t;
298 
299 /**
300 * Some things multiple-inherit from VclAbstractDialog and OutputDevice,
301 * so we need to use virtual inheritance to keep the referencing counting
302 * OK.
303 */
304 class VCL_DLLPUBLIC OutputDevice : public virtual VclReferenceBase
305 {
306     friend class Printer;
307     friend class VirtualDevice;
308     friend class vcl::Window;
309     friend class WorkWindow;
310     friend void ImplHandleResize( vcl::Window* pWindow, long nNewWidth, long nNewHeight );
311 
312 private:
313     OutputDevice(const OutputDevice&) = delete;
314     OutputDevice& operator=(const OutputDevice&) = delete;
315 
316     mutable SalGraphics*            mpGraphics;         ///< Graphics context to draw on
317     mutable VclPtr<OutputDevice>    mpPrevGraphics;     ///< Previous output device in list
318     mutable VclPtr<OutputDevice>    mpNextGraphics;     ///< Next output device in list
319     GDIMetaFile*                    mpMetaFile;
320     mutable rtl::Reference<LogicalFontInstance> mpFontInstance;
321     mutable std::shared_ptr<ImplFontCache> mxFontCache;
322     mutable std::shared_ptr<PhysicalFontCollection> mxFontCollection;
323     mutable std::unique_ptr<ImplDeviceFontList>     mpDeviceFontList;
324     mutable std::unique_ptr<ImplDeviceFontSizeList> mpDeviceFontSizeList;
325     std::vector<OutDevState>        maOutDevStateStack;
326     std::unique_ptr<ImplOutDevData> mpOutDevData;
327     std::vector< VCLXGraphics* >*   mpUnoGraphicsList;
328     vcl::ExtOutDevData*             mpExtOutDevData;
329 
330     // TEMP TEMP TEMP
331     VclPtr<VirtualDevice>           mpAlphaVDev;
332 
333     /// Additional output pixel offset, applied in LogicToPixel (used by SetPixelOffset/GetPixelOffset)
334     long                            mnOutOffOrigX;
335     /// Additional output offset in _logical_ coordinates, applied in PixelToLogic (used by SetPixelOffset/GetPixelOffset)
336     long                            mnOutOffLogicX;
337     /// Additional output pixel offset, applied in LogicToPixel (used by SetPixelOffset/GetPixelOffset)
338     long                            mnOutOffOrigY;
339     /// Additional output offset in _logical_ coordinates, applied in PixelToLogic (used by SetPixelOffset/GetPixelOffset)
340     long                            mnOutOffLogicY;
341     /// Output offset for device output in pixel (pseudo window offset within window system's frames)
342     long                            mnOutOffX;
343     /// Output offset for device output in pixel (pseudo window offset within window system's frames)
344     long                            mnOutOffY;
345     long                            mnOutWidth;
346     long                            mnOutHeight;
347     sal_Int32                       mnDPIX;
348     sal_Int32                       mnDPIY;
349     sal_Int32                       mnDPIScalePercentage; ///< For HiDPI displays, we want to draw elements for a percentage larger
350     /// font specific text alignment offsets in pixel units
351     mutable long                    mnTextOffX;
352     mutable long                    mnTextOffY;
353     mutable long                    mnEmphasisAscent;
354     mutable long                    mnEmphasisDescent;
355     DrawModeFlags                   mnDrawMode;
356     ComplexTextLayoutFlags           mnTextLayoutMode;
357     ImplMapRes                      maMapRes;
358     ImplThresholdRes                maThresRes;
359     const OutDevType                meOutDevType;
360     OutDevViewType                  meOutDevViewType;
361     vcl::Region                     maRegion;           // contains the clip region, see SetClipRegion(...)
362     Color                           maLineColor;
363     Color                           maFillColor;
364     vcl::Font                       maFont;
365     Color                           maTextColor;
366     Color                           maTextLineColor;
367     Color                           maOverlineColor;
368     RasterOp                        meRasterOp;
369     Wallpaper                       maBackground;
370     std::unique_ptr<AllSettings>    mxSettings;
371     MapMode                         maMapMode;
372     Point                           maRefPoint;
373     AntialiasingFlags               mnAntialiasing;
374     LanguageType                    meTextLanguage;
375 
376     mutable bool                    mbMap : 1;
377     mutable bool                    mbClipRegion : 1;
378     mutable bool                    mbBackground : 1;
379     mutable bool                    mbOutput : 1;
380     mutable bool                    mbDevOutput : 1;
381     mutable bool                    mbOutputClipped : 1;
382     mutable bool                    mbLineColor : 1;
383     mutable bool                    mbFillColor : 1;
384     mutable bool                    mbInitLineColor : 1;
385     mutable bool                    mbInitFillColor : 1;
386     mutable bool                    mbInitFont : 1;
387     mutable bool                    mbInitTextColor : 1;
388     mutable bool                    mbInitClipRegion : 1;
389     mutable bool                    mbClipRegionSet : 1;
390     mutable bool                    mbNewFont : 1;
391     mutable bool                    mbTextLines : 1;
392     mutable bool                    mbTextSpecial : 1;
393     mutable bool                    mbRefPoint : 1;
394     mutable bool                    mbEnableRTL : 1;
395 
396     /** @name Initialization and accessor functions
397      */
398     ///@{
399 
400 protected:
401                                 OutputDevice(OutDevType eOutDevType);
402     virtual                     ~OutputDevice() override;
403     virtual void                dispose() override;
404 
405 public:
406 
407     /** Get the graphic context that the output device uses to draw on.
408 
409      If no graphics device exists, then initialize it.
410 
411      @returns SalGraphics instance.
412      */
413     SalGraphics const           *GetGraphics() const;
414     SalGraphics*                GetGraphics();
415 
416     void                        SetConnectMetaFile( GDIMetaFile* pMtf );
GetConnectMetaFile() const417     GDIMetaFile*                GetConnectMetaFile() const { return mpMetaFile; }
418 
419     virtual void                SetSettings( const AllSettings& rSettings );
GetSettings() const420     const AllSettings&          GetSettings() const { return *mxSettings; }
421 
422     SystemGraphicsData          GetSystemGfxData() const;
423     bool                        SupportsCairo() const;
424     /// Create Surface from given cairo surface
425     cairo::SurfaceSharedPtr     CreateSurface(const cairo::CairoSurfaceSharedPtr& rSurface) const;
426     /// Create surface with given dimensions
427     cairo::SurfaceSharedPtr     CreateSurface(int x, int y, int width, int height) const;
428     /// Create Surface for given bitmap data
429     cairo::SurfaceSharedPtr     CreateBitmapSurface(const BitmapSystemData& rData, const Size& rSize) const;
430     /// Return native handle for underlying surface
431     css::uno::Any               GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& rSurface, const basegfx::B2ISize& rSize) const;
432     css::uno::Any               GetSystemGfxDataAny() const;
433 
434     void                        SetRefPoint();
435     void                        SetRefPoint( const Point& rRefPoint );
GetRefPoint() const436     const Point&                GetRefPoint() const { return maRefPoint; }
IsRefPoint() const437     bool                        IsRefPoint() const { return mbRefPoint; }
438 
439     virtual sal_uInt16          GetBitCount() const;
440 
GetOutputSizePixel() const441     Size                        GetOutputSizePixel() const
442                                     { return Size( mnOutWidth, mnOutHeight ); }
GetOutputWidthPixel() const443     long                        GetOutputWidthPixel() const { return mnOutWidth; }
GetOutputHeightPixel() const444     long                        GetOutputHeightPixel() const { return mnOutHeight; }
GetOutOffXPixel() const445     long                        GetOutOffXPixel() const { return mnOutOffX; }
GetOutOffYPixel() const446     long                        GetOutOffYPixel() const { return mnOutOffY; }
447     void                        SetOutOffXPixel(long nOutOffX);
448     void                        SetOutOffYPixel(long nOutOffY);
449 
GetOutputSize() const450     Size                        GetOutputSize() const
451                                     { return PixelToLogic( GetOutputSizePixel() ); }
452 
453     css::uno::Reference< css::awt::XGraphics >
454                                 CreateUnoGraphics();
GetUnoGraphicsList() const455     std::vector< VCLXGraphics* > *GetUnoGraphicsList() const  { return mpUnoGraphicsList; }
456     std::vector< VCLXGraphics* > *CreateUnoGraphicsList();
457 
458 protected:
459 
460     /** Acquire a graphics device that the output device uses to draw on.
461 
462      There is an LRU of OutputDevices that is used to get the graphics. The
463      actual creation of a SalGraphics instance is done via the SalFrame
464      implementation.
465 
466      However, the SalFrame instance will only return a valid SalGraphics
467      instance if it is not in use or there wasn't one in the first place. When
468      this happens, AcquireGraphics finds the least recently used OutputDevice
469      in a different frame and "steals" it (releases it then starts using it).
470 
471      If there are no frames to steal an OutputDevice's SalGraphics instance from
472      then it blocks until the graphics is released.
473 
474      Once it has acquired a graphics instance, then we add the OutputDevice to
475      the LRU.
476 
477      @returns true if was able to initialize the graphics device, false otherwise.
478      */
479     virtual bool                AcquireGraphics() const = 0;
480 
481     /** Release the graphics device, and remove it from the graphics device
482      list.
483 
484      @param         bRelease    Determines whether to release the fonts of the
485                                 physically released graphics device.
486      */
487     virtual void                ReleaseGraphics( bool bRelease = true ) = 0;
488     ///@}
489 
490 
491     /** @name Helper functions
492      */
493     ///@{
494 
495 public:
496 
497     /** Get the output device's DPI x-axis value.
498 
499      @returns x-axis DPI value
500      */
GetDPIX() const501     SAL_DLLPRIVATE sal_Int32    GetDPIX() const { return mnDPIX; }
502 
503     /** Get the output device's DPI y-axis value.
504 
505      @returns y-axis DPI value
506      */
GetDPIY() const507     SAL_DLLPRIVATE sal_Int32    GetDPIY() const { return mnDPIY; }
508 
SetDPIX(sal_Int32 nDPIX)509     SAL_DLLPRIVATE void         SetDPIX( sal_Int32 nDPIX ) { mnDPIX = nDPIX; }
SetDPIY(sal_Int32 nDPIY)510     SAL_DLLPRIVATE void         SetDPIY( sal_Int32 nDPIY ) { mnDPIY = nDPIY; }
511 
GetDPIScaleFactor() const512     float GetDPIScaleFactor() const
513     {
514         return mnDPIScalePercentage / 100.0f;
515     }
516 
GetDPIScalePercentage() const517     sal_Int32 GetDPIScalePercentage() const
518     {
519         return mnDPIScalePercentage;
520     }
521 
GetOutDevType() const522     OutDevType                  GetOutDevType() const { return meOutDevType; }
523     virtual bool IsVirtual() const;
524 
525     /** Query an OutputDevice to see whether it supports a specific operation
526 
527      @returns true if operation supported, else false
528     */
529     bool                        SupportsOperation( OutDevSupportType ) const;
530 
SetExtOutDevData(vcl::ExtOutDevData * pExtOutDevData)531     void                        SetExtOutDevData( vcl::ExtOutDevData* pExtOutDevData ) { mpExtOutDevData = pExtOutDevData; }
GetExtOutDevData() const532     vcl::ExtOutDevData*         GetExtOutDevData() const { return mpExtOutDevData; }
533 
534     ///@}
535 
536 
537     /** @name Direct OutputDevice drawing functions
538      */
539     ///@{
540 
541 public:
Flush()542     virtual void                Flush() {}
543 
544     virtual void                DrawOutDev(
545                                     const Point& rDestPt, const Size& rDestSize,
546                                     const Point& rSrcPt,  const Size& rSrcSize );
547 
548     virtual void                DrawOutDev(
549                                     const Point& rDestPt, const Size& rDestSize,
550                                     const Point& rSrcPt,  const Size& rSrcSize,
551                                     const OutputDevice& rOutDev );
552 
553     virtual void                CopyArea(
554                                     const Point& rDestPt,
555                                     const Point& rSrcPt,  const Size& rSrcSize,
556                                     bool bWindowInvalidate = false );
557 
558 protected:
559 
560     virtual void                CopyDeviceArea( SalTwoRect& aPosAry, bool bWindowInvalidate);
561 
562     SAL_DLLPRIVATE void         drawOutDevDirect ( const OutputDevice* pSrcDev, SalTwoRect& rPosAry );
563 
564     SAL_DLLPRIVATE bool         is_double_buffered_window() const;
565 
566 private:
567 
568     // not implemented; to detect misuses of DrawOutDev(...OutputDevice&);
569     SAL_DLLPRIVATE void         DrawOutDev( const Point&, const Size&, const Point&,  const Size&, const Printer&) = delete;
570     ///@}
571 
572 
573     /** @name OutputDevice state functions
574      */
575     ///@{
576 
577 public:
578 
579     void                        Push( PushFlags nFlags = PushFlags::ALL );
580     void                        Pop();
581 
582     // returns the current stack depth; that is the number of Push() calls minus the number of Pop() calls
583     // this should not normally be used since Push and Pop must always be used symmetrically
584     // however this may be e.g. a help when debugging code in which this somehow is not the case
585     sal_uInt32                  GetGCStackDepth() const;
586 
587     void                        EnableOutput( bool bEnable = true );
IsOutputEnabled() const588     bool                        IsOutputEnabled() const { return mbOutput; }
IsDeviceOutputNecessary() const589     bool                        IsDeviceOutputNecessary() const { return (mbOutput && mbDevOutput); }
590 
591     void                        SetAntialiasing( AntialiasingFlags nMode );
GetAntialiasing() const592     AntialiasingFlags           GetAntialiasing() const { return mnAntialiasing; }
593 
594     void                        SetDrawMode( DrawModeFlags nDrawMode );
GetDrawMode() const595     DrawModeFlags               GetDrawMode() const { return mnDrawMode; }
596 
597     void                        SetLayoutMode( ComplexTextLayoutFlags nTextLayoutMode );
GetLayoutMode() const598     ComplexTextLayoutFlags       GetLayoutMode() const { return mnTextLayoutMode; }
599 
600     void                        SetDigitLanguage( LanguageType );
GetDigitLanguage() const601     LanguageType                GetDigitLanguage() const { return meTextLanguage; }
602 
603     void                        SetRasterOp( RasterOp eRasterOp );
GetRasterOp() const604     RasterOp                    GetRasterOp() const { return meRasterOp; }
605 
606     /**
607     If this OutputDevice is used for displaying a Print Preview
608     the OutDevViewType should be set to 'OutDevViewType::PrintPreview'.
609 
610     A View can then make painting decisions dependent on this OutDevViewType.
611     E.g. text colors need to be handled differently, dependent on whether it's a PrintPreview or not. (see #106611# for more)
612     */
SetOutDevViewType(OutDevViewType eOutDevViewType)613     void                        SetOutDevViewType( OutDevViewType eOutDevViewType ) { meOutDevViewType=eOutDevViewType; }
GetOutDevViewType() const614     OutDevViewType              GetOutDevViewType() const { return meOutDevViewType; }
615 
616     void                        SetLineColor();
617     void                        SetLineColor( const Color& rColor );
GetLineColor() const618     const Color&                GetLineColor() const { return maLineColor; }
IsLineColor() const619     bool                        IsLineColor() const { return mbLineColor; }
620 
621     void                        SetFillColor();
622     void                        SetFillColor( const Color& rColor );
GetFillColor() const623     const Color&                GetFillColor() const { return maFillColor; }
IsFillColor() const624     bool                        IsFillColor() const { return mbFillColor; }
625 
626     void                        SetBackground();
627     void                        SetBackground( const Wallpaper& rBackground );
628     virtual void                SaveBackground(VirtualDevice& rSaveDevice,
629                                                const Point& rPos, const Size& rSize, const Size& rBackgroundSize) const;
630 
GetBackground() const631     const Wallpaper&            GetBackground() const { return maBackground; }
632     virtual Color               GetBackgroundColor() const;
633     virtual Color               GetReadableFontColor(const Color& rFontColor, const Color& rBgColor) const;
IsBackground() const634     bool                        IsBackground() const { return mbBackground; }
635 
636     void                        SetFont( const vcl::Font& rNewFont );
GetFont() const637     const vcl::Font&            GetFont() const { return maFont; }
638 
639 protected:
640 
641     virtual void                ImplReleaseFonts();
642 
643 private:
644 
645     SAL_DLLPRIVATE void         InitLineColor();
646 
647     SAL_DLLPRIVATE void         InitFillColor();
648 
649     ///@}
650 
651 
652     /** @name Clipping functions
653      */
654     ///@{
655 
656 public:
657 
658     vcl::Region                 GetClipRegion() const;
659     void                        SetClipRegion();
660     void                        SetClipRegion( const vcl::Region& rRegion );
661     bool                        SelectClipRegion( const vcl::Region&, SalGraphics* pGraphics = nullptr );
662 
IsClipRegion() const663     bool                        IsClipRegion() const { return mbClipRegion; }
664 
665     void                        MoveClipRegion( long nHorzMove, long nVertMove );
666     void                        IntersectClipRegion( const tools::Rectangle& rRect );
667     void                        IntersectClipRegion( const vcl::Region& rRegion );
668 
669     virtual vcl::Region         GetActiveClipRegion() const;
670 
671 protected:
672 
673     virtual void                InitClipRegion();
674 
675     /** Perform actual rect clip against outdev dimensions, to generate
676         empty clips whenever one of the values is completely off the device.
677 
678         @param aRegion      region to be clipped to the device dimensions
679         @returns            region clipped to the device bounds
680      **/
681     virtual vcl::Region         ClipToDeviceBounds(vcl::Region aRegion) const;
682     virtual void                ClipToPaintRegion    ( tools::Rectangle& rDstRect );
683 
684 private:
685 
686     SAL_DLLPRIVATE void         SetDeviceClipRegion( const vcl::Region* pRegion );
687     ///@}
688 
689 
690     /** @name Pixel functions
691      */
692     ///@{
693 
694 public:
695 
696     void                        DrawPixel( const Point& rPt );
697     void                        DrawPixel( const Point& rPt, const Color& rColor );
698 
699     Color                       GetPixel( const Point& rPt ) const;
700     ///@}
701 
702 
703     /** @name Rectangle functions
704      */
705     ///@{
706 
707 public:
708 
709     void                        DrawRect( const tools::Rectangle& rRect );
710     void                        DrawRect( const tools::Rectangle& rRect,
711                                           sal_uLong nHorzRount, sal_uLong nVertRound );
712 
713     /// Fill the given rectangle with checkered rectangles of size nLen x nLen using the colors aStart and aEnd
714     void                        DrawCheckered(
715                                     const Point& rPos,
716                                     const Size& rSize,
717                                     sal_uInt32 nLen = 8,
718                                     Color aStart = COL_WHITE,
719                                     Color aEnd = COL_BLACK);
720 
721     void                        DrawGrid( const tools::Rectangle& rRect, const Size& rDist, DrawGridFlags nFlags );
722 
723     ///@}
724 
725     /** @name Invert functions
726      */
727     ///@{
728 public:
729     void Invert( const tools::Rectangle& rRect, InvertFlags nFlags = InvertFlags::NONE );
730     void Invert( const tools::Polygon& rPoly, InvertFlags nFlags = InvertFlags::NONE );
731     ///@}
732 
733     /** @name Line functions
734      */
735     ///@{
736 
737 public:
738 
739     void                        DrawLine( const Point& rStartPt, const Point& rEndPt );
740 
741     void                        DrawLine( const Point& rStartPt, const Point& rEndPt,
742                                           const LineInfo& rLineInfo );
743 
744 protected:
745     virtual void DrawHatchLine_DrawLine(const Point& rStartPoint, const Point& rEndPoint);
746 
747 private:
748 
749     /** Helper for line geometry paint with support for graphic expansion (pattern and fat_to_area)
750      */
751     SAL_DLLPRIVATE void         drawLine( basegfx::B2DPolyPolygon aLinePolyPolygon, const LineInfo& rInfo );
752     ///@}
753 
754 
755     /** @name Polyline functions
756      */
757     ///@{
758 
759 public:
760 
761     /** Render the given polygon as a line stroke
762 
763         The given polygon is stroked with the current LineColor, start
764         and end point are not automatically connected
765 
766         @see DrawPolygon
767         @see DrawPolyPolygon
768      */
769     void                        DrawPolyLine( const tools::Polygon& rPoly );
770 
771     void                        DrawPolyLine(
772                                     const basegfx::B2DPolygon&,
773                                     double fLineWidth = 0.0,
774                                     basegfx::B2DLineJoin eLineJoin = basegfx::B2DLineJoin::Round,
775                                     css::drawing::LineCap eLineCap = css::drawing::LineCap_BUTT,
776                                     double fMiterMinimumAngle = basegfx::deg2rad(15.0));
777 
778     /** Render the given polygon as a line stroke
779 
780         The given polygon is stroked with the current LineColor, start
781         and end point are not automatically connected. The line is
782         rendered according to the specified LineInfo, e.g. supplying a
783         dash pattern, or a line thickness.
784 
785         @see DrawPolygon
786         @see DrawPolyPolygon
787      */
788     void                        DrawPolyLine( const tools::Polygon& rPoly,
789                                               const LineInfo& rLineInfo );
790 
791     // #i101491#
792     // Helper who tries to use SalGDI's DrawPolyLine direct and returns it's bool.
793     bool                        DrawPolyLineDirect(
794                                     const basegfx::B2DHomMatrix& rObjectTransform,
795                                     const basegfx::B2DPolygon& rB2DPolygon,
796                                     double fLineWidth = 0.0,
797                                     double fTransparency = 0.0,
798                                     basegfx::B2DLineJoin eLineJoin = basegfx::B2DLineJoin::NONE,
799                                     css::drawing::LineCap eLineCap = css::drawing::LineCap_BUTT,
800                                     double fMiterMinimumAngle = basegfx::deg2rad(15.0),
801                                     bool bBypassAACheck = false);
802 
803 private:
804 
805     // #i101491#
806     // Helper which holds the old line geometry creation and is extended to use AA when
807     // switched on. Advantage is that line geometry is only temporarily used for paint
808     SAL_DLLPRIVATE void         drawPolyLine(const tools::Polygon& rPoly, const LineInfo& rLineInfo);
809 
810     ///@}
811 
812 
813     /** @name Polygon functions
814      */
815     ///@{
816 
817 public:
818 
819     /** Render the given polygon
820 
821         The given polygon is stroked with the current LineColor, and
822         filled with the current FillColor. If one of these colors are
823         transparent, the corresponding stroke or fill stays
824         invisible. Start and end point of the polygon are
825         automatically connected.
826 
827         @see DrawPolyLine
828      */
829     void                        DrawPolygon( const tools::Polygon& rPoly );
830     void                        DrawPolygon( const basegfx::B2DPolygon& );
831 
832     /** Render the given poly-polygon
833 
834         The given poly-polygon is stroked with the current LineColor,
835         and filled with the current FillColor. If one of these colors
836         are transparent, the corresponding stroke or fill stays
837         invisible. Start and end points of the contained polygons are
838         automatically connected.
839 
840         @see DrawPolyLine
841      */
842     void                        DrawPolyPolygon( const tools::PolyPolygon& rPolyPoly );
843     void                        DrawPolyPolygon( const basegfx::B2DPolyPolygon& );
844 
845 private:
846 
847     SAL_DLLPRIVATE void         ImplDrawPolygon( const tools::Polygon& rPoly, const tools::PolyPolygon* pClipPolyPoly = nullptr );
848     SAL_DLLPRIVATE void         ImplDrawPolyPolygon( const tools::PolyPolygon& rPolyPoly, const tools::PolyPolygon* pClipPolyPoly );
849     SAL_DLLPRIVATE void         ImplDrawPolyPolygon( sal_uInt16 nPoly, const tools::PolyPolygon& rPolyPoly );
850     // #i101491#
851     // Helper who implements the DrawPolyPolygon functionality for basegfx::B2DPolyPolygon
852     // without MetaFile processing
853     SAL_DLLPRIVATE void         ImplDrawPolyPolygonWithB2DPolyPolygon(const basegfx::B2DPolyPolygon& rB2DPolyPoly);
854     ///@}
855 
856 
857     /** @name Curved shape functions
858      */
859     ///@{
860 
861 public:
862 
863     void                        DrawEllipse( const tools::Rectangle& rRect );
864 
865     void                        DrawArc(
866                                     const tools::Rectangle& rRect,
867                                     const Point& rStartPt, const Point& rEndPt );
868 
869     void                        DrawPie(
870                                     const tools::Rectangle& rRect,
871                                     const Point& rStartPt, const Point& rEndPt );
872 
873     void                        DrawChord(
874                                     const tools::Rectangle& rRect,
875                                     const Point& rStartPt, const Point& rEndPt );
876 
877     ///@}
878 
879 
880     /** @name Gradient functions
881      */
882     ///@{
883 
884 public:
885     void                        DrawGradient( const tools::Rectangle& rRect, const Gradient& rGradient );
886     void                        DrawGradient( const tools::PolyPolygon& rPolyPoly, const Gradient& rGradient );
887 
888     void                        AddGradientActions(
889                                     const tools::Rectangle& rRect,
890                                     const Gradient& rGradient,
891                                     GDIMetaFile& rMtf );
892 
893 protected:
894 
895     virtual bool                UsePolyPolygonForComplexGradient() = 0;
896 
897     virtual long                GetGradientStepCount( long nMinRect );
898 
899 private:
900 
901     SAL_DLLPRIVATE void         DrawLinearGradient( const tools::Rectangle& rRect, const Gradient& rGradient, const tools::PolyPolygon* pClipPolyPoly );
902     SAL_DLLPRIVATE void         DrawComplexGradient( const tools::Rectangle& rRect, const Gradient& rGradient, const tools::PolyPolygon* pClipPolyPoly );
903 
904     SAL_DLLPRIVATE void         DrawGradientToMetafile( const tools::PolyPolygon& rPolyPoly, const Gradient& rGradient );
905     SAL_DLLPRIVATE void         DrawLinearGradientToMetafile( const tools::Rectangle& rRect, const Gradient& rGradient );
906     SAL_DLLPRIVATE void         DrawComplexGradientToMetafile( const tools::Rectangle& rRect, const Gradient& rGradient );
907 
908     SAL_DLLPRIVATE long         GetGradientSteps( const Gradient& rGradient, const tools::Rectangle& rRect, bool bMtf, bool bComplex=false );
909 
910     SAL_DLLPRIVATE Color        GetSingleColorGradientFill();
911     SAL_DLLPRIVATE void         SetGrayscaleColors( Gradient &rGradient );
912     ///@}
913 
914 
915     /** @name Hatch functions
916      */
917     ///@{
918 
919 public:
920 
921 #ifdef _MSC_VER
922     void                        DrawHatch( const tools::PolyPolygon& rPolyPoly, const ::Hatch& rHatch );
923     void                        AddHatchActions( const tools::PolyPolygon& rPolyPoly,
924                                                  const ::Hatch& rHatch,
925                                                  GDIMetaFile& rMtf );
926 #else
927     void                        DrawHatch( const tools::PolyPolygon& rPolyPoly, const Hatch& rHatch );
928     void                        AddHatchActions( const tools::PolyPolygon& rPolyPoly,
929                                                  const Hatch& rHatch,
930                                                  GDIMetaFile& rMtf );
931 #endif
932 
933     void                        DrawHatch( const tools::PolyPolygon& rPolyPoly, const Hatch& rHatch, bool bMtf );
934 
935 private:
936 
937     SAL_DLLPRIVATE void         CalcHatchValues( const tools::Rectangle& rRect, long nDist, sal_uInt16 nAngle10, Point& rPt1, Point& rPt2, Size& rInc, Point& rEndPt1 );
938     SAL_DLLPRIVATE void         DrawHatchLine( const tools::Line& rLine, const tools::PolyPolygon& rPolyPoly, Point* pPtBuffer, bool bMtf );
939     ///@}
940 
941 
942     /** @name Wallpaper functions
943      */
944     ///@{
945 
946 public:
947     void                        DrawWallpaper( const tools::Rectangle& rRect, const Wallpaper& rWallpaper );
948 
949     void                        Erase();
Erase(const tools::Rectangle & rRect)950     void                        Erase( const tools::Rectangle& rRect ) { DrawWallpaper( rRect, GetBackground() ); }
951 
952 protected:
953     void                        DrawGradientWallpaper( long nX, long nY, long nWidth, long nHeight, const Wallpaper& rWallpaper );
954 
955 private:
956     SAL_DLLPRIVATE void         DrawWallpaper( long nX, long nY, long nWidth, long nHeight, const Wallpaper& rWallpaper );
957     SAL_DLLPRIVATE void         DrawColorWallpaper( long nX, long nY, long nWidth, long nHeight, const Wallpaper& rWallpaper );
958     SAL_DLLPRIVATE void         DrawBitmapWallpaper( long nX, long nY, long nWidth, long nHeight, const Wallpaper& rWallpaper );
959     ///@}
960 
961 
962     /** @name Text functions
963      */
964     ///@{
965 
966 public:
967 
968     void                        DrawText( const Point& rStartPt, const OUString& rStr,
969                                           sal_Int32 nIndex = 0, sal_Int32 nLen = -1,
970                                           MetricVector* pVector = nullptr, OUString* pDisplayText = nullptr,
971                                           const SalLayoutGlyphs* pLayoutCache = nullptr );
972 
973     void                        DrawText( const tools::Rectangle& rRect,
974                                           const OUString& rStr, DrawTextFlags nStyle = DrawTextFlags::NONE,
975                                           MetricVector* pVector = nullptr, OUString* pDisplayText = nullptr,
976                                           vcl::ITextLayout* _pTextLayout = nullptr );
977 
978     static void                 ImplDrawText( OutputDevice& rTargetDevice, const tools::Rectangle& rRect,
979                                               const OUString& rOrigStr, DrawTextFlags nStyle,
980                                               MetricVector* pVector, OUString* pDisplayText, vcl::ITextLayout& _rLayout );
981 
982     void                        ImplDrawText( SalLayout& );
983 
984     void                        ImplDrawTextBackground( const SalLayout& );
985 
986     void                        DrawCtrlText( const Point& rPos, const OUString& rStr,
987                                               sal_Int32 nIndex = 0, sal_Int32 nLen = -1,
988                                               DrawTextFlags nStyle = DrawTextFlags::Mnemonic, MetricVector* pVector = nullptr, OUString* pDisplayText = nullptr,
989                                               const SalLayoutGlyphs* pGlyphs = nullptr);
990 
991     void                        DrawTextLine( const Point& rPos, long nWidth,
992                                               FontStrikeout eStrikeout,
993                                               FontLineStyle eUnderline,
994                                               FontLineStyle eOverline,
995                                               bool bUnderlineAbove = false );
996 
997     void                        ImplDrawTextLine( long nBaseX, long nX, long nY, DeviceCoordinate nWidth,
998                                                   FontStrikeout eStrikeout, FontLineStyle eUnderline,
999                                                   FontLineStyle eOverline, bool bUnderlineAbove );
1000 
1001     void                        ImplDrawTextLines( SalLayout&, FontStrikeout eStrikeout, FontLineStyle eUnderline,
1002                                                    FontLineStyle eOverline, bool bWordLine, bool bUnderlineAbove );
1003 
1004     void                        DrawWaveLine( const Point& rStartPos, const Point& rEndPos, long nLineWidth = 1 );
1005 
1006     bool                        ImplDrawRotateText( SalLayout& );
1007 
1008     tools::Rectangle                   GetTextRect( const tools::Rectangle& rRect,
1009                                              const OUString& rStr, DrawTextFlags nStyle = DrawTextFlags::WordBreak,
1010                                              TextRectInfo* pInfo = nullptr,
1011                                              const vcl::ITextLayout* _pTextLayout = nullptr ) const;
1012 
1013     /** Return the exact bounding rectangle of rStr.
1014 
1015         The text is then drawn exactly from rRect.TopLeft() to
1016         rRect.BottomRight(), don't assume that rRect.TopLeft() is [0, 0].
1017 
1018         Please note that you don't always want to use GetTextBoundRect(); in
1019         many cases you actually want to use GetTextHeight(), because
1020         GetTextBoundRect() gives you the exact bounding rectangle regardless
1021         what is the baseline of the text.
1022 
1023         Code snippet to get just exactly the text (no filling around that) as
1024         a bitmap via a VirtualDevice (regardless what is the baseline):
1025 
1026         <code>
1027         VirtualDevice aDevice;
1028         vcl::Font aFont = aDevice.GetFont();
1029         aFont.SetSize(Size(0, 96));
1030         aFont.SetColor(COL_BLACK);
1031         aDevice.SetFont(aFont);
1032         aDevice.Erase();
1033 
1034         tools::Rectangle aRect;
1035         aDevice.GetTextBoundRect(aRect, aText);
1036         aDevice.SetOutputSize(Size(aRect.BottomRight().X() + 1, aRect.BottomRight().Y() + 1));
1037         aDevice.SetBackground(Wallpaper(COL_TRANSPARENT));
1038         aDevice.DrawText(Point(0,0), aText);
1039 
1040         // exactly only the text, regardless of the baseline
1041         Bitmap aBitmap(aDevice.GetBitmap(aRect.TopLeft(), aRect.GetSize()));
1042         </code>
1043 
1044         Code snippet to get the text as a bitmap via a Virtual device that
1045         contains even the filling so that the baseline is always preserved
1046         (ie. the text will not jump up and down according to whether it
1047         contains 'y' or not etc.)
1048 
1049         <code>
1050         VirtualDevice aDevice;
1051         // + the appropriate font / device setup, see above
1052 
1053         aDevice.SetOutputSize(Size(aDevice.GetTextWidth(aText), aDevice.GetTextHeight()));
1054         aDevice.SetBackground(Wallpaper(COL_TRANSPARENT));
1055         aDevice.DrawText(Point(0,0), aText);
1056 
1057         // bitmap that contains even the space around the text,
1058         // that means, preserves the baseline etc.
1059         Bitmap aBitmap(aDevice.GetBitmap(Point(0, 0), aDevice.GetOutputSize()));
1060         </code>
1061     */
1062     bool                        GetTextBoundRect( tools::Rectangle& rRect,
1063                                                   const OUString& rStr, sal_Int32 nBase = 0, sal_Int32 nIndex = 0, sal_Int32 nLen = -1,
1064                                                   sal_uLong nLayoutWidth = 0, const long* pDXArray = nullptr,
1065                                                   const SalLayoutGlyphs* pGlyphs = nullptr ) const;
1066 
1067     tools::Rectangle                   ImplGetTextBoundRect( const SalLayout& );
1068 
1069     bool                        GetTextOutline( tools::PolyPolygon&,
1070                                                 const OUString& rStr,
1071                                                 sal_Int32 nLen = -1,
1072                                                 sal_uLong nLayoutWidth = 0, const long* pDXArray = nullptr ) const;
1073 
1074     bool                        GetTextOutlines( PolyPolyVector&,
1075                                                  const OUString& rStr, sal_Int32 nBase = 0, sal_Int32 nIndex = 0,
1076                                                  sal_Int32 nLen = -1,
1077                                                  sal_uLong nLayoutWidth = 0, const long* pDXArray = nullptr ) const;
1078 
1079     bool                        GetTextOutlines( basegfx::B2DPolyPolygonVector &rVector,
1080                                                  const OUString& rStr, sal_Int32 nBase, sal_Int32 nIndex = 0,
1081                                                  sal_Int32 nLen = -1,
1082                                                  sal_uLong nLayoutWidth = 0, const long* pDXArray = nullptr ) const;
1083 
1084 
1085     OUString                    GetEllipsisString( const OUString& rStr, long nMaxWidth,
1086                                                    DrawTextFlags nStyle = DrawTextFlags::EndEllipsis ) const;
1087 
1088     long                        GetCtrlTextWidth( const OUString& rStr,
1089                                                   const SalLayoutGlyphs* pLayoutCache = nullptr ) const;
1090 
1091     static OUString             GetNonMnemonicString( const OUString& rStr, sal_Int32& rMnemonicPos );
1092 
GetNonMnemonicString(const OUString & rStr)1093     static OUString             GetNonMnemonicString( const OUString& rStr )
1094                                             { sal_Int32 nDummy; return GetNonMnemonicString( rStr, nDummy ); }
1095 
1096     /** Generate MetaTextActions for the text rect
1097 
1098         This method splits up the text rect into multiple
1099         MetaTextActions, one for each line of text. This is comparable
1100         to AddGradientActions(), which splits up a gradient into its
1101         constituent polygons. Parameter semantics fully compatible to
1102         DrawText().
1103      */
1104     void                        AddTextRectActions( const tools::Rectangle& rRect,
1105                                                     const OUString&  rOrigStr,
1106                                                     DrawTextFlags    nStyle,
1107                                                     GDIMetaFile&     rMtf );
1108 
1109     void                        SetTextColor( const Color& rColor );
GetTextColor() const1110     const Color&                GetTextColor() const { return maTextColor; }
1111 
1112     void                        SetTextFillColor();
1113     void                        SetTextFillColor( const Color& rColor );
1114     Color                       GetTextFillColor() const;
IsTextFillColor() const1115     bool                        IsTextFillColor() const { return !maFont.IsTransparent(); }
1116 
1117     void                        SetTextLineColor();
1118     void                        SetTextLineColor( const Color& rColor );
GetTextLineColor() const1119     const Color&                GetTextLineColor() const { return maTextLineColor; }
IsTextLineColor() const1120     bool                        IsTextLineColor() const { return (maTextLineColor.GetTransparency() == 0); }
1121 
1122     void                        SetOverlineColor();
1123     void                        SetOverlineColor( const Color& rColor );
GetOverlineColor() const1124     const Color&                GetOverlineColor() const { return maOverlineColor; }
IsOverlineColor() const1125     bool                        IsOverlineColor() const { return (maOverlineColor.GetTransparency() == 0); }
1126 
1127     void                        SetTextAlign( TextAlign eAlign );
GetTextAlign() const1128     TextAlign                   GetTextAlign() const { return maFont.GetAlignment(); }
1129 
1130     /** Width of the text.
1131 
1132         See also GetTextBoundRect() for more explanation + code examples.
1133     */
1134     long                        GetTextWidth( const OUString& rStr, sal_Int32 nIndex = 0, sal_Int32 nLen = -1,
1135                                   vcl::TextLayoutCache const* = nullptr,
1136                                   SalLayoutGlyphs const*const pLayoutCache = nullptr) const;
1137 
1138     /** Height where any character of the current font fits; in logic coordinates.
1139 
1140         See also GetTextBoundRect() for more explanation + code examples.
1141     */
1142     long                        GetTextHeight() const;
1143     float                       approximate_char_width() const;
1144     float                       approximate_digit_width() const;
1145 
1146     void                        DrawTextArray( const Point& rStartPt, const OUString& rStr,
1147                                                const long* pDXAry,
1148                                                sal_Int32 nIndex = 0,
1149                                                sal_Int32 nLen = -1,
1150                                                SalLayoutFlags flags = SalLayoutFlags::NONE,
1151                                                const SalLayoutGlyphs* pLayoutCache = nullptr);
1152     long                        GetTextArray( const OUString& rStr, long* pDXAry,
1153                                               sal_Int32 nIndex = 0, sal_Int32 nLen = -1,
1154                                               vcl::TextLayoutCache const* = nullptr,
1155                                               SalLayoutGlyphs const*const pLayoutCache = nullptr) const;
1156 
1157     void                        GetCaretPositions( const OUString&, long* pCaretXArray,
1158                                               sal_Int32 nIndex, sal_Int32 nLen,
1159                                               const SalLayoutGlyphs* pGlyphs = nullptr ) const;
1160     void                        DrawStretchText( const Point& rStartPt, sal_uLong nWidth,
1161                                                  const OUString& rStr,
1162                                                  sal_Int32 nIndex = 0, sal_Int32 nLen = -1);
1163     sal_Int32                   GetTextBreak( const OUString& rStr, long nTextWidth,
1164                                               sal_Int32 nIndex, sal_Int32 nLen = -1,
1165                                               long nCharExtra = 0,
1166                                               vcl::TextLayoutCache const* = nullptr,
1167                                               const SalLayoutGlyphs* pGlyphs = nullptr) const;
1168     sal_Int32                   GetTextBreak( const OUString& rStr, long nTextWidth,
1169                                               sal_Unicode nExtraChar, sal_Int32& rExtraCharPos,
1170                                               sal_Int32 nIndex, sal_Int32 nLen,
1171                                               long nCharExtra,
1172                                               vcl::TextLayoutCache const* = nullptr) const;
1173     static std::shared_ptr<vcl::TextLayoutCache> CreateTextLayoutCache(OUString const&);
1174 
1175 protected:
1176     SAL_DLLPRIVATE void         ImplInitTextLineSize();
1177     SAL_DLLPRIVATE void         ImplInitAboveTextLineSize();
1178     static
1179     SAL_DLLPRIVATE long         ImplGetTextLines( ImplMultiTextLineInfo& rLineInfo, long nWidth, const OUString& rStr, DrawTextFlags nStyle, const vcl::ITextLayout& _rLayout );
1180 private:
1181     SAL_DLLPRIVATE void         ImplInitTextColor();
1182 
1183     SAL_DLLPRIVATE void         ImplDrawTextDirect( SalLayout&, bool bTextLines);
1184     SAL_DLLPRIVATE void         ImplDrawSpecialText( SalLayout& );
1185     SAL_DLLPRIVATE void         ImplDrawTextRect( long nBaseX, long nBaseY, long nX, long nY, long nWidth, long nHeight );
1186 
1187     SAL_DLLPRIVATE static void  ImplDrawWavePixel( long nOriginX, long nOriginY, long nCurX, long nCurY, short nOrientation, SalGraphics* pGraphics, OutputDevice const * pOutDev,
1188                                                    bool bDrawPixAsRect, long nPixWidth, long nPixHeight );
1189     SAL_DLLPRIVATE void         ImplDrawWaveLine( long nBaseX, long nBaseY, long nStartX, long nStartY, long nWidth, long nHeight, long nLineWidth, short nOrientation, const Color& rColor );
1190     SAL_DLLPRIVATE void         ImplDrawWaveTextLine( long nBaseX, long nBaseY, long nX, long nY, long nWidth, FontLineStyle eTextLine, Color aColor, bool bIsAbove );
1191     SAL_DLLPRIVATE void         ImplDrawStraightTextLine( long nBaseX, long nBaseY, long nX, long nY, long nWidth, FontLineStyle eTextLine, Color aColor, bool bIsAbove );
1192     SAL_DLLPRIVATE void         ImplDrawStrikeoutLine( long nBaseX, long nBaseY, long nX, long nY, long nWidth, FontStrikeout eStrikeout, Color aColor );
1193     SAL_DLLPRIVATE void         ImplDrawStrikeoutChar( long nBaseX, long nBaseY, long nX, long nY, long nWidth, FontStrikeout eStrikeout, Color aColor );
1194     SAL_DLLPRIVATE void         ImplDrawMnemonicLine( long nX, long nY, long nWidth );
1195 
1196 
1197     ///@}
1198 
1199 
1200     /** @name Font functions
1201      */
1202     ///@{
1203 
1204 public:
1205 
1206     FontMetric                  GetDevFont( int nDevFontIndex ) const;
1207     int                         GetDevFontCount() const;
1208 
1209     bool                        IsFontAvailable( const OUString& rFontName ) const;
1210 
1211     Size                        GetDevFontSize( const vcl::Font& rFont, int nSizeIndex ) const;
1212     int                         GetDevFontSizeCount( const vcl::Font& ) const;
1213 
1214     bool                        AddTempDevFont( const OUString& rFileURL, const OUString& rFontName );
1215     void                        RefreshFontData( const bool bNewFontLists );
1216 
1217     FontMetric                  GetFontMetric() const;
1218     FontMetric                  GetFontMetric( const vcl::Font& rFont ) const;
1219 
1220     bool                        GetFontCharMap( FontCharMapRef& rxFontCharMap ) const;
1221     bool                        GetFontCapabilities( vcl::FontCapabilities& rFontCapabilities ) const;
1222 
1223     bool GetFontFeatures(std::vector<vcl::font::Feature>& rFontFeatures) const;
1224 
1225 
1226     /** Retrieve detailed font information in platform independent structure
1227 
1228         @param  nFallbacklevel      Fallback font level (0 = best matching font)
1229 
1230         @return SystemFontData
1231      */
1232     SystemFontData              GetSysFontData( int nFallbacklevel ) const;
1233 
1234     SAL_DLLPRIVATE void         ImplGetEmphasisMark( tools::PolyPolygon& rPolyPoly, bool& rPolyLine, tools::Rectangle& rRect1, tools::Rectangle& rRect2,
1235                                                      long& rYOff, long& rWidth, FontEmphasisMark eEmphasis, long nHeight );
1236     SAL_DLLPRIVATE static FontEmphasisMark
1237                                 ImplGetEmphasisMarkStyle( const vcl::Font& rFont );
1238 
1239     bool                        GetGlyphBoundRects( const Point& rOrigin, const OUString& rStr, int nIndex,
1240                                                     int nLen, MetricVector& rVector );
1241 
1242     sal_Int32                   HasGlyphs( const vcl::Font& rFont, const OUString& rStr,
1243                                            sal_Int32 nIndex = 0, sal_Int32 nLen = -1 ) const;
1244 
1245     long                        GetMinKashida() const;
1246 
1247     // i60594
1248     // validate kashida positions against the current font
1249     // returns count of invalid kashida positions
1250     sal_Int32                   ValidateKashidas( const OUString& rTxt, sal_Int32 nIdx, sal_Int32 nLen,
1251                                                   sal_Int32 nKashCount, // number of suggested kashida positions (in)
1252                                                   const sal_Int32* pKashidaPos, // suggested kashida positions (in)
1253                                                   sal_Int32* pKashidaPosDropped // invalid kashida positions (out)
1254                                                 ) const;
1255 
1256     static void                 BeginFontSubstitution();
1257     static void                 EndFontSubstitution();
1258     static void                 AddFontSubstitute( const OUString& rFontName,
1259                                                    const OUString& rReplaceFontName,
1260                                                    AddFontSubstituteFlags nFlags );
1261     static void                 RemoveFontsSubstitute();
1262 
1263     static vcl::Font            GetDefaultFont( DefaultFontType nType,
1264                                                 LanguageType eLang,
1265                                                 GetDefaultFontFlags nFlags,
1266                                                 const OutputDevice* pOutDev = nullptr );
1267 
1268     SAL_DLLPRIVATE void         ImplInitFontList() const;
1269     SAL_DLLPRIVATE void         ImplUpdateFontData();
1270 
1271     //drop font data for all outputdevices.
1272     //If bNewFontLists is true then empty lists of system fonts
1273     SAL_DLLPRIVATE static void  ImplClearAllFontData( bool bNewFontLists );
1274     //fetch font data for all outputdevices
1275     //If bNewFontLists is true then fetch lists of system fonts
1276     SAL_DLLPRIVATE static void  ImplRefreshAllFontData( bool bNewFontLists );
1277     //drop and fetch font data for all outputdevices
1278     //If bNewFontLists is true then drop and refetch lists of system fonts
1279     SAL_DLLPRIVATE static void  ImplUpdateAllFontData( bool bNewFontLists );
1280 
1281     // Lock font updates for all output devices
1282     static void LockFontUpdates(bool bLock);
1283 
1284 protected:
1285     SAL_DLLPRIVATE const LogicalFontInstance* GetFontInstance() const;
GetEmphasisAscent() const1286     SAL_DLLPRIVATE long GetEmphasisAscent() const { return mnEmphasisAscent; }
GetEmphasisDescent() const1287     SAL_DLLPRIVATE long GetEmphasisDescent() const { return mnEmphasisDescent; }
1288 
1289     SAL_DLLPRIVATE bool InitFont() const;
1290     virtual void                SetFontOrientation( LogicalFontInstance* const pFontInstance ) const;
1291     virtual long                GetFontExtLeading() const;
1292 
1293     virtual void ImplClearFontData(bool bNewFontLists);
1294     virtual void ImplRefreshFontData(bool bNewFontLists);
1295     void ReleaseFontCache();
1296     void ReleaseFontCollection();
1297     void SetFontCollectionFromSVData();
1298     void ResetNewFontCache();
1299 
1300 private:
1301 
1302     typedef void ( OutputDevice::* FontUpdateHandler_t )( bool );
1303 
1304     SAL_DLLPRIVATE bool         ImplNewFont() const;
1305 
1306     SAL_DLLPRIVATE static void  ImplUpdateFontDataForAllFrames( FontUpdateHandler_t pHdl, bool bNewFontLists );
1307 
1308     static
1309     SAL_DLLPRIVATE OUString     ImplGetEllipsisString( const OutputDevice& rTargetDevice, const OUString& rStr,
1310                                                        long nMaxWidth, DrawTextFlags nStyle, const vcl::ITextLayout& _rLayout );
1311 
1312     SAL_DLLPRIVATE void         ImplDrawEmphasisMark( long nBaseX, long nX, long nY, const tools::PolyPolygon& rPolyPoly, bool bPolyLine, const tools::Rectangle& rRect1, const tools::Rectangle& rRect2 );
1313     SAL_DLLPRIVATE void         ImplDrawEmphasisMarks( SalLayout& );
1314     ///@}
1315 
1316 
1317     /** @name Layout functions
1318      */
1319     ///@{
1320 
1321 public:
1322 
1323     SystemTextLayoutData        GetSysTextLayoutData( const Point& rStartPt, const OUString& rStr,
1324                                                       sal_Int32 nIndex, sal_Int32 nLen,
1325                                                       const long* pDXAry ) const;
1326 
1327     // tells whether this output device is RTL in an LTR UI or LTR in a RTL UI
1328     SAL_DLLPRIVATE bool         ImplIsAntiparallel() const ;
1329     SAL_DLLPRIVATE void         ReMirror( Point &rPoint ) const;
1330     SAL_DLLPRIVATE void         ReMirror( tools::Rectangle &rRect ) const;
1331     SAL_DLLPRIVATE void         ReMirror( vcl::Region &rRegion ) const;
1332     SAL_DLLPRIVATE bool         ImplIsRecordLayout() const;
1333     virtual bool                HasMirroredGraphics() const;
1334     std::unique_ptr<SalLayout>
1335                                 ImplLayout( const OUString&, sal_Int32 nIndex, sal_Int32 nLen,
1336                                             const Point& rLogicPos = Point(0,0), long nLogicWidth=0,
1337                                             const long* pLogicDXArray=nullptr, SalLayoutFlags flags = SalLayoutFlags::NONE,
1338                                             vcl::TextLayoutCache const* = nullptr,
1339                                             const SalLayoutGlyphs* pGlyphs = nullptr) const;
1340     SAL_DLLPRIVATE ImplLayoutArgs ImplPrepareLayoutArgs( OUString&, const sal_Int32 nIndex, const sal_Int32 nLen,
1341                                                          DeviceCoordinate nPixelWidth, const DeviceCoordinate* pPixelDXArray,
1342                                                          SalLayoutFlags flags = SalLayoutFlags::NONE,
1343                                                          vcl::TextLayoutCache const* = nullptr) const;
1344     SAL_DLLPRIVATE std::unique_ptr<SalLayout>
1345                                 ImplGlyphFallbackLayout( std::unique_ptr<SalLayout>, ImplLayoutArgs& ) const;
1346     SAL_DLLPRIVATE std::unique_ptr<SalLayout>
1347                                 getFallbackLayout(
1348                                     LogicalFontInstance* pLogicalFont, int nFallbackLevel,
1349                                     ImplLayoutArgs& rLayoutArgs) const;
1350 
1351 
1352     // Enabling/disabling RTL only makes sense for OutputDevices that use a mirroring SalGraphisLayout
1353     virtual void                EnableRTL( bool bEnable = true);
IsRTLEnabled() const1354     bool                        IsRTLEnabled() const { return mbEnableRTL; }
1355 
1356     bool                        GetTextIsRTL( const OUString&, sal_Int32 nIndex, sal_Int32 nLen ) const;
1357 
1358     ///@}
1359 
1360 
1361     /** @name Bitmap functions
1362      */
1363     ///@{
1364 
1365 public:
1366 
1367     /** @overload
1368         void DrawBitmap(
1369                 const Point& rDestPt,
1370                 const Size& rDestSize,
1371                 const Point& rSrcPtPixel,
1372                 const Size& rSecSizePixel,
1373                 const Bitmap& rBitmap,
1374                 MetaActionType nAction = MetaActionType::BMPSCALEPART)
1375       */
1376     void                        DrawBitmap(
1377                                     const Point& rDestPt,
1378                                     const Bitmap& rBitmap );
1379 
1380     /** @overload
1381         void DrawBitmap(
1382                 const Point& rDestPt,
1383                 const Size& rDestSize,
1384                 const Point& rSrcPtPixel,
1385                 const Size& rSecSizePixel,
1386                 const Bitmap& rBitmap,
1387                 MetaActionType nAction = MetaActionType::BMPSCALEPART)
1388       */
1389     void                        DrawBitmap(
1390                                     const Point& rDestPt,
1391                                     const Size& rDestSize,
1392                                     const Bitmap& rBitmap );
1393 
1394     void                        DrawBitmap(
1395                                     const Point& rDestPt,
1396                                     const Size& rDestSize,
1397                                     const Point& rSrcPtPixel,
1398                                     const Size& rSrcSizePixel,
1399                                     const Bitmap& rBitmap,
1400                                     MetaActionType nAction = MetaActionType::BMPSCALEPART );
1401 
1402     /** @overload
1403         void DrawBitmapEx(
1404                 const Point& rDestPt,
1405                 const Size& rDestSize,
1406                 const Point& rSrcPtPixel,
1407                 const Size& rSecSizePixel,
1408                 const BitmapEx& rBitmapEx,
1409                 MetaActionType nAction = MetaActionType::BMPEXSCALEPART)
1410      */
1411     void                        DrawBitmapEx(
1412                                     const Point& rDestPt,
1413                                     const BitmapEx& rBitmapEx );
1414 
1415 
1416     /** @overload
1417         void DrawBitmapEx(
1418                 const Point& rDestPt,
1419                 const Size& rDestSize,
1420                 const Point& rSrcPtPixel,
1421                 const Size& rSecSizePixel,
1422                 const BitmapEx& rBitmapEx,
1423                 MetaActionType nAction = MetaActionType::BMPEXSCALEPART)
1424      */
1425     void                        DrawBitmapEx(
1426                                     const Point& rDestPt,
1427                                     const Size& rDestSize,
1428                                     const BitmapEx& rBitmapEx );
1429 
1430     void                        DrawBitmapEx(
1431                                     const Point& rDestPt,
1432                                     const Size& rDestSize,
1433                                     const Point& rSrcPtPixel,
1434                                     const Size& rSrcSizePixel,
1435                                     const BitmapEx& rBitmapEx,
1436                                     MetaActionType nAction = MetaActionType::BMPEXSCALEPART );
1437 
1438     /** @overload
1439         virtual void DrawImage(
1440                         const Point& rPos,
1441                         const Size& rSize,
1442                         const Image& rImage,
1443                         sal_uInt16 nStyle = 0)
1444      */
1445     void                        DrawImage(
1446                                     const Point& rPos,
1447                                     const Image& rImage,
1448                                     DrawImageFlags nStyle = DrawImageFlags::NONE );
1449 
1450     void                        DrawImage(
1451                                     const Point& rPos,
1452                                     const Size& rSize,
1453                                     const Image& rImage,
1454                                     DrawImageFlags nStyle = DrawImageFlags::NONE );
1455 
1456 
1457     virtual Bitmap              GetBitmap( const Point& rSrcPt, const Size& rSize ) const;
1458 
1459     /** Query extended bitmap (with alpha channel, if available).
1460      */
1461     BitmapEx                    GetBitmapEx( const Point& rSrcPt, const Size& rSize ) const;
1462 
1463 
1464     /** Draw BitmapEx transformed
1465 
1466         @param rTransformation
1467         The transformation describing the target positioning of the given bitmap. Transforming
1468         the unit object coordinates (0, 0, 1, 1) with this matrix is the transformation to
1469         discrete coordinates
1470 
1471         @param rBitmapEx
1472         The BitmapEx to be painted
1473     */
1474     void                        DrawTransformedBitmapEx(
1475                                     const basegfx::B2DHomMatrix& rTransformation,
1476                                     const BitmapEx& rBitmapEx);
1477 
1478     void                        DrawShadowBitmapEx(
1479                                     const BitmapEx& rBitmapEx,
1480                                     ::Color aShadowColor);
1481 protected:
1482 
1483     virtual void                DrawDeviceBitmap(
1484                                     const Point& rDestPt, const Size& rDestSize,
1485                                     const Point& rSrcPtPixel, const Size& rSrcSizePixel,
1486                                     BitmapEx& rBitmapEx );
1487 
1488     virtual void                ScaleBitmap ( Bitmap &rBmp, SalTwoRect &rPosAry );
1489 
1490     /** Transform and draw a bitmap directly
1491 
1492      @param     aFullTransform      The B2DHomMatrix used for the transformation
1493      @param     rBitmapEx           Reference to the bitmap to be transformed and drawn
1494 
1495      @return true if it was able to draw the bitmap, false if not
1496      */
1497     virtual bool                DrawTransformBitmapExDirect(
1498                                     const basegfx::B2DHomMatrix& aFullTransform,
1499                                     const BitmapEx& rBitmapEx);
1500 
1501     /** Transform and reduce the area that needs to be drawn of the bitmap and return the new
1502         visible range and the maximum area.
1503 
1504 
1505       @param     aFullTransform      B2DHomMatrix used for transformation
1506       @param     aVisibleRange       The new visible area of the bitmap
1507       @param     fMaximumArea        The maximum area of the bitmap
1508 
1509       @returns true if there is an area to be drawn, otherwise nothing is left to be drawn
1510         so return false
1511       */
1512     virtual bool                TransformAndReduceBitmapExToTargetRange(
1513                                     const basegfx::B2DHomMatrix& aFullTransform,
1514                                     basegfx::B2DRange &aVisibleRange,
1515                                     double &fMaximumArea);
1516 
1517 private:
1518 
1519     SAL_DLLPRIVATE void         DrawDeviceAlphaBitmap(
1520                                     const Bitmap& rBmp,
1521                                     const AlphaMask& rAlpha,
1522                                     const Point& rDestPt,
1523                                     const Size& rDestSize,
1524                                     const Point& rSrcPtPixel,
1525                                     const Size& rSrcSizePixel );
1526 
1527     SAL_DLLPRIVATE void DrawDeviceAlphaBitmapSlowPath(
1528                                 const Bitmap& rBitmap, const AlphaMask& rAlpha,
1529                                 tools::Rectangle aDstRect, tools::Rectangle aBmpRect,
1530                                 Size const & aOutSz, Point const & aOutPt);
1531 
1532 
1533     SAL_DLLPRIVATE void         BlendBitmap(
1534                                     const SalTwoRect&   rPosAry,
1535                                     const Bitmap&       rBmp );
1536 
1537     SAL_DLLPRIVATE Bitmap       BlendBitmap(
1538                                     Bitmap&             aBmp,
1539                                     BitmapReadAccess const * pP,
1540                                     BitmapReadAccess const * pA,
1541                                     const sal_Int32     nOffY,
1542                                     const sal_Int32     nDstHeight,
1543                                     const sal_Int32     nOffX,
1544                                     const sal_Int32     nDstWidth,
1545                                     const tools::Rectangle&    aBmpRect,
1546                                     const Size&         aOutSz,
1547                                     const bool          bHMirr,
1548                                     const bool          bVMirr,
1549                                     const long*         pMapX,
1550                                     const long*         pMapY );
1551 
1552     SAL_DLLPRIVATE Bitmap       BlendBitmapWithAlpha(
1553                                     Bitmap&             aBmp,
1554                                     BitmapReadAccess const *   pP,
1555                                     BitmapReadAccess const *   pA,
1556                                     const tools::Rectangle&    aDstRect,
1557                                     const sal_Int32     nOffY,
1558                                     const sal_Int32     nDstHeight,
1559                                     const sal_Int32     nOffX,
1560                                     const sal_Int32     nDstWidth,
1561                                     const long*         pMapX,
1562                                     const long*         pMapY );
1563 
1564     /** Retrieve downsampled and cropped bitmap
1565 
1566         @attention This method ignores negative rDstSz values, thus
1567         mirroring must happen outside this method (e.g. in DrawBitmap)
1568      */
1569     SAL_DLLPRIVATE Bitmap       GetDownsampledBitmap(
1570                                     const Size& rDstSz,
1571                                     const Point& rSrcPt,
1572                                     const Size& rSrcSz,
1573                                     const Bitmap& rBmp,
1574                                     long nMaxBmpDPIX,
1575                                     long nMaxBmpDPIY );
1576 
1577     ///@}
1578 
1579 
1580     /** @name Transparency functions
1581      */
1582     ///@{
1583 
1584 public:
1585 
1586     /** helper method removing transparencies from a metafile (e.g. for printing)
1587 
1588         @returns
1589         true: transparencies were removed
1590         false: output metafile is unchanged input metafile
1591 
1592         @attention this is a member method, so current state can influence the result !
1593         @attention the output metafile is prepared in pixel mode for the currentOutputDevice
1594                    state. It can not be moved or rotated reliably anymore.
1595     */
1596     bool                        RemoveTransparenciesFromMetaFile(
1597                                     const GDIMetaFile& rInMtf, GDIMetaFile& rOutMtf,
1598                                     long nMaxBmpDPIX, long nMaxBmpDPIY,
1599                                     bool bReduceTransparency,
1600                                     bool bTransparencyAutoMode,
1601                                     bool bDownsampleBitmaps,
1602                                     const Color& rBackground = COL_TRANSPARENT );
1603 
1604     SAL_DLLPRIVATE void         ImplPrintTransparent (
1605                                     const Bitmap& rBmp, const Bitmap& rMask,
1606                                     const Point& rDestPt, const Size& rDestSize,
1607                                     const Point& rSrcPtPixel, const Size& rSrcSizePixel );
1608 
1609     SAL_DLLPRIVATE Color        ImplDrawModeToColor  ( const Color& rColor ) const;
1610 
1611 
1612     void                        DrawTransparent( const tools::PolyPolygon& rPolyPoly, sal_uInt16 nTransparencePercent );
1613 
1614     void                        DrawTransparent(
1615                                     const basegfx::B2DHomMatrix& rObjectTransform,
1616                                     const basegfx::B2DPolyPolygon& rB2DPolyPoly,
1617                                     double fTransparency);
1618 
1619     void                        DrawTransparent(
1620                                         const GDIMetaFile& rMtf, const Point& rPos, const Size& rSize,
1621                                         const Gradient& rTransparenceGradient );
1622 
1623 protected:
1624 
1625     virtual void                EmulateDrawTransparent( const tools::PolyPolygon& rPolyPoly, sal_uInt16 nTransparencePercent );
1626     void                        DrawInvisiblePolygon( const tools::PolyPolygon& rPolyPoly );
1627 
1628     virtual void                ClipAndDrawGradientMetafile ( const Gradient &rGradient, const tools::PolyPolygon &rPolyPoly );
1629 
1630 private:
1631 
1632     SAL_DLLPRIVATE bool         DrawTransparentNatively( const tools::PolyPolygon& rPolyPoly, sal_uInt16 nTransparencePercent );
1633     ///@}
1634 
1635 
1636     /** @name Mask functions
1637      */
1638     ///@{
1639 
1640 public:
1641 
1642     void                        DrawMask( const Point& rDestPt,
1643                                           const Bitmap& rBitmap, const Color& rMaskColor );
1644 
1645     void                        DrawMask( const Point& rDestPt, const Size& rDestSize,
1646                                           const Bitmap& rBitmap, const Color& rMaskColor );
1647 
1648     void                        DrawMask( const Point& rDestPt, const Size& rDestSize,
1649                                           const Point& rSrcPtPixel, const Size& rSrcSizePixel,
1650                                           const Bitmap& rBitmap, const Color& rMaskColor,
1651                                           MetaActionType nAction );
1652 
1653 protected:
1654 
1655     virtual void                DrawDeviceMask (
1656                                          const Bitmap& rMask, const Color& rMaskColor,
1657                                          const Point& rDestPt, const Size& rDestSize,
1658                                          const Point& rSrcPtPixel, const Size& rSrcSizePixel );
1659     ///@}
1660 
1661 
1662     /** @name Map functions
1663      */
1664     ///@{
1665 
1666 public:
1667 
1668     void                        EnableMapMode( bool bEnable = true );
IsMapModeEnabled() const1669     bool                        IsMapModeEnabled() const { return mbMap; }
1670 
1671     void                        SetMapMode();
1672     virtual void                SetMapMode( const MapMode& rNewMapMode );
1673     void                        SetRelativeMapMode( const MapMode& rNewMapMode );
GetMapMode() const1674     const MapMode&              GetMapMode() const { return maMapMode; }
1675 
1676      // #i75163#
1677     basegfx::B2DHomMatrix       GetViewTransformation() const;
1678     basegfx::B2DHomMatrix       GetInverseViewTransformation() const;
1679 
1680     basegfx::B2DHomMatrix       GetViewTransformation( const MapMode& rMapMode ) const;
1681     basegfx::B2DHomMatrix       GetInverseViewTransformation( const MapMode& rMapMode ) const;
1682 
1683 
1684     /** Set an offset in pixel
1685 
1686         This method offsets every drawing operation that converts its
1687         coordinates to pixel by the given value. Normally, the effect
1688         can be achieved by setting a MapMode with a different
1689         origin. Unfortunately, this origin is in logical coordinates
1690         and can lead to rounding errors (see #102532# for details).
1691 
1692         @attention This offset is only applied when converting to
1693         pixel, i.e. some output modes such as metafile recordings
1694         might be completely unaffected by this method! Use with
1695         care. Furthermore, if the OutputDevice's MapMode is the
1696         default (that's MapUnit::MapPixel), then any pixel offset set is
1697         ignored also. This might be unintuitive for cases, but would
1698         have been far more fragile to implement. What's more, the
1699         reason why the pixel offset was introduced (avoiding rounding
1700         errors) does not apply for MapUnit::MapPixel, because one can always
1701         use the MapMode origin then.
1702 
1703         @param rOffset
1704         The offset in pixel
1705      */
1706     void                        SetPixelOffset( const Size& rOffset );
1707 
1708     /** Get the offset in pixel
1709 
1710         @see OutputDevice::SetPixelOffset for details
1711 
1712         @return the current offset in pixel
1713      */
GetPixelOffset() const1714     Size                        GetPixelOffset() const { return Size(mnOutOffOrigX, mnOutOffOrigY);}
1715 
1716     Point                       LogicToPixel( const Point& rLogicPt ) const;
1717     Size                        LogicToPixel( const Size& rLogicSize ) const;
1718     tools::Rectangle                   LogicToPixel( const tools::Rectangle& rLogicRect ) const;
1719     tools::Polygon              LogicToPixel( const tools::Polygon& rLogicPoly ) const;
1720     tools::PolyPolygon          LogicToPixel( const tools::PolyPolygon& rLogicPolyPoly ) const;
1721     basegfx::B2DPolyPolygon     LogicToPixel( const basegfx::B2DPolyPolygon& rLogicPolyPoly ) const;
1722     vcl::Region                 LogicToPixel( const vcl::Region& rLogicRegion )const;
1723     Point                       LogicToPixel( const Point& rLogicPt,
1724                                               const MapMode& rMapMode ) const;
1725     Size                        LogicToPixel( const Size& rLogicSize,
1726                                               const MapMode& rMapMode ) const;
1727     tools::Rectangle                   LogicToPixel( const tools::Rectangle& rLogicRect,
1728                                               const MapMode& rMapMode ) const;
1729     tools::Polygon              LogicToPixel( const tools::Polygon& rLogicPoly,
1730                                               const MapMode& rMapMode ) const;
1731     basegfx::B2DPolyPolygon     LogicToPixel( const basegfx::B2DPolyPolygon& rLogicPolyPoly,
1732                                               const MapMode& rMapMode ) const;
1733 
1734     Point                       PixelToLogic( const Point& rDevicePt ) const;
1735     Size                        PixelToLogic( const Size& rDeviceSize ) const;
1736     tools::Rectangle                   PixelToLogic( const tools::Rectangle& rDeviceRect ) const;
1737     tools::Polygon              PixelToLogic( const tools::Polygon& rDevicePoly ) const;
1738     tools::PolyPolygon          PixelToLogic( const tools::PolyPolygon& rDevicePolyPoly ) const;
1739     basegfx::B2DPolyPolygon     PixelToLogic( const basegfx::B2DPolyPolygon& rDevicePolyPoly ) const;
1740     vcl::Region                 PixelToLogic( const vcl::Region& rDeviceRegion ) const;
1741     Point                       PixelToLogic( const Point& rDevicePt,
1742                                               const MapMode& rMapMode ) const;
1743     Size                        PixelToLogic( const Size& rDeviceSize,
1744                                               const MapMode& rMapMode ) const;
1745     tools::Rectangle                   PixelToLogic( const tools::Rectangle& rDeviceRect,
1746                                               const MapMode& rMapMode ) const;
1747     tools::Polygon              PixelToLogic( const tools::Polygon& rDevicePoly,
1748                                               const MapMode& rMapMode ) const;
1749     basegfx::B2DPolygon         PixelToLogic( const basegfx::B2DPolygon& rDevicePoly,
1750                                               const MapMode& rMapMode ) const;
1751     basegfx::B2DPolyPolygon     PixelToLogic( const basegfx::B2DPolyPolygon& rDevicePolyPoly,
1752                                               const MapMode& rMapMode ) const;
1753 
1754     Point                       LogicToLogic( const Point&      rPtSource,
1755                                               const MapMode*    pMapModeSource,
1756                                               const MapMode*    pMapModeDest ) const;
1757     Size                        LogicToLogic( const Size&       rSzSource,
1758                                               const MapMode*    pMapModeSource,
1759                                               const MapMode*    pMapModeDest ) const;
1760     tools::Rectangle                   LogicToLogic( const tools::Rectangle&  rRectSource,
1761                                               const MapMode*    pMapModeSource,
1762                                               const MapMode*    pMapModeDest ) const;
1763     static Point                LogicToLogic( const Point&      rPtSource,
1764                                               const MapMode&    rMapModeSource,
1765                                               const MapMode&    rMapModeDest );
1766     static Size                 LogicToLogic( const Size&       rSzSource,
1767                                               const MapMode&    rMapModeSource,
1768                                               const MapMode&    rMapModeDest );
1769     static tools::Rectangle            LogicToLogic( const tools::Rectangle&  rRectSource,
1770                                               const MapMode&    rMapModeSource,
1771                                               const MapMode&    rMapModeDest );
1772     static long                 LogicToLogic( long              nLongSource,
1773                                               MapUnit           eUnitSource,
1774                                               MapUnit           eUnitDest );
1775 
1776     static basegfx::B2DPolygon  LogicToLogic( const basegfx::B2DPolygon& rPoly,
1777                                               const MapMode&    rMapModeSource,
1778                                               const MapMode&    rMapModeDest );
1779 
1780     // create a mapping transformation from rMapModeSource to rMapModeDest (the above methods
1781     // for B2DPoly/Polygons use this internally anyway to transform the B2DPolygon)
1782     static basegfx::B2DHomMatrix LogicToLogic(const MapMode& rMapModeSource, const MapMode& rMapModeDest);
1783 
1784     /** Convert a logical rectangle to a rectangle in physical device pixel units.
1785 
1786      @param         rLogicRect  Const reference to a rectangle in logical units
1787 
1788      @returns Rectangle based on physical device pixel coordinates and units.
1789      */
1790     SAL_DLLPRIVATE tools::Rectangle    ImplLogicToDevicePixel( const tools::Rectangle& rLogicRect ) const;
1791 
1792     /** Convert a logical point to a physical point on the device.
1793 
1794      @param         rLogicPt    Const reference to a point in logical units.
1795 
1796      @returns Physical point on the device.
1797      */
1798     SAL_DLLPRIVATE Point        ImplLogicToDevicePixel( const Point& rLogicPt ) const;
1799 
1800     /** Convert a logical width to a width in units of device pixels.
1801 
1802      To get the number of device pixels, it must calculate the X-DPI of the device and
1803      the map scaling factor. If there is no mapping, then it just returns the
1804      width as nothing more needs to be done.
1805 
1806      @param         nWidth      Logical width
1807 
1808      @returns Width in units of device pixels.
1809      */
1810     SAL_DLLPRIVATE long         ImplLogicWidthToDevicePixel( long nWidth ) const;
1811 
1812     SAL_DLLPRIVATE DeviceCoordinate LogicWidthToDeviceCoordinate( long nWidth ) const;
1813 
1814     /** Convert a logical X coordinate to a device pixel's X coordinate.
1815 
1816      To get the device's X coordinate, it must calculate the mapping offset
1817      coordinate X position (if there is one - if not then it just adds
1818      the pseudo-window offset to the logical X coordinate), the X-DPI of
1819      the device and the mapping's X scaling factor.
1820 
1821      @param         nX          Logical X coordinate
1822 
1823      @returns Device's X pixel coordinate
1824      */
1825     SAL_DLLPRIVATE long         ImplLogicXToDevicePixel( long nX ) const;
1826 
1827     /** Convert a logical Y coordinate to a device pixel's Y coordinate.
1828 
1829      To get the device's Y coordinate, it must calculate the mapping offset
1830      coordinate Y position (if there is one - if not then it just adds
1831      the pseudo-window offset to the logical Y coordinate), the Y-DPI of
1832      the device and the mapping's Y scaling factor.
1833 
1834      @param         nY          Logical Y coordinate
1835 
1836      @returns Device's Y pixel coordinate
1837      */
1838     SAL_DLLPRIVATE long         ImplLogicYToDevicePixel( long nY ) const;
1839 
1840     /** Convert a logical height to a height in units of device pixels.
1841 
1842      To get the number of device pixels, it must calculate the Y-DPI of the device and
1843      the map scaling factor. If there is no mapping, then it just returns the
1844      height as nothing more needs to be done.
1845 
1846      @param         nHeight     Logical height
1847 
1848      @returns Height in units of device pixels.
1849      */
1850     SAL_DLLPRIVATE long         ImplLogicHeightToDevicePixel( long nHeight ) const;
1851 
1852     /** Convert device pixels to a width in logical units.
1853 
1854      To get the logical width, it must calculate the X-DPI of the device and the
1855      map scaling factor.
1856 
1857      @param         nWidth      Width in device pixels
1858 
1859      @returns Width in logical units.
1860      */
1861     SAL_DLLPRIVATE long         ImplDevicePixelToLogicWidth( long nWidth ) const;
1862 
1863     /** Convert device pixels to a height in logical units.
1864 
1865      To get the logical height, it must calculate the Y-DPI of the device and the
1866      map scaling factor.
1867 
1868      @param         nHeight     Height in device pixels
1869 
1870      @returns Height in logical units.
1871      */
1872     SAL_DLLPRIVATE long         ImplDevicePixelToLogicHeight( long nHeight ) const;
1873 
1874     /** Convert logical height to device pixels, with exact sub-pixel value.
1875 
1876      To get the \em exact pixel height, it must calculate the Y-DPI of the device and the
1877      map scaling factor.
1878 
1879      @param         fLogicHeight     Exact height in logical units.
1880 
1881      @returns Exact height in pixels - returns as a float to provide for subpixel value.
1882      */
1883     SAL_DLLPRIVATE float        ImplFloatLogicHeightToDevicePixel( float fLogicHeight ) const;
1884 
1885     /** Convert a logical size to the size on the physical device.
1886 
1887      @param         rLogicSize  Const reference to a size in logical units
1888 
1889      @returns Physical size on the device.
1890      */
1891     SAL_DLLPRIVATE Size         ImplLogicToDevicePixel( const Size& rLogicSize ) const;
1892 
1893     /** Convert a rectangle in physical pixel units to a rectangle in physical pixel units and coords.
1894 
1895      @param         rPixelRect  Const reference to rectangle in logical units and coords.
1896 
1897      @returns Rectangle based on logical coordinates and units.
1898      */
1899     SAL_DLLPRIVATE tools::Rectangle    ImplDevicePixelToLogic( const tools::Rectangle& rPixelRect ) const;
1900 
1901     /** Convert a logical polygon to a polygon in physical device pixel units.
1902 
1903      @param         rLogicPoly  Const reference to a polygon in logical units
1904 
1905      @returns Polygon based on physical device pixel coordinates and units.
1906      */
1907     SAL_DLLPRIVATE tools::Polygon ImplLogicToDevicePixel( const tools::Polygon& rLogicPoly ) const;
1908 
1909     /** Convert a logical polypolygon to a polypolygon in physical device pixel units.
1910 
1911      @param         rLogicPolyPoly  Const reference to a polypolygon in logical units
1912 
1913      @returns Polypolygon based on physical device pixel coordinates and units.
1914      */
1915     SAL_DLLPRIVATE tools::PolyPolygon  ImplLogicToDevicePixel( const tools::PolyPolygon& rLogicPolyPoly ) const;
1916 
1917     /** Convert a line in logical units to a line in physical device pixel units.
1918 
1919      @param         rLineInfo   Const reference to a line in logical units
1920 
1921      @returns Line based on physical device pixel coordinates and units.
1922      */
1923     SAL_DLLPRIVATE LineInfo     ImplLogicToDevicePixel( const LineInfo& rLineInfo ) const;
1924 
1925     /** Convert a region in pixel units to a region in device pixel units and coords.
1926 
1927      @param         rRegion  Const reference to region.
1928 
1929      @returns vcl::Region based on device pixel coordinates and units.
1930      */
1931     SAL_DLLPRIVATE vcl::Region       ImplPixelToDevicePixel( const vcl::Region& rRegion ) const;
1932 
1933     /** Invalidate the view transformation.
1934 
1935      @since AOO bug 75163 (OpenOffice.org 2.4.3 - OOH 680 milestone 212)
1936      */
1937     SAL_DLLPRIVATE void         ImplInvalidateViewTransform();
1938 
1939     /** Get device transformation.
1940 
1941      @since AOO bug 75163 (OpenOffice.org 2.4.3 - OOH 680 milestone 212)
1942      */
1943     SAL_DLLPRIVATE basegfx::B2DHomMatrix ImplGetDeviceTransformation() const;
1944     ///@}
1945 
1946 
1947     /** @name Native Widget Rendering functions
1948 
1949         These all just call through to the private mpGraphics functions of the same name.
1950      */
1951     ///@{
1952 
1953 public:
1954 
1955     /** Query the platform layer for control support
1956      */
1957     bool                        IsNativeControlSupported( ControlType nType, ControlPart nPart ) const;
1958 
1959     /** Query the native control to determine if it was acted upon
1960      */
1961     bool                        HitTestNativeScrollbar(
1962                                     ControlPart nPart,
1963                                     const tools::Rectangle& rControlRegion,
1964                                     const Point& aPos,
1965                                     bool& rIsInside ) const;
1966 
1967     /** Request rendering of a particular control and/or part
1968      */
1969     bool                        DrawNativeControl(
1970                                     ControlType nType,
1971                                     ControlPart nPart,
1972                                     const tools::Rectangle& rControlRegion,
1973                                     ControlState nState,
1974                                     const ImplControlValue& aValue,
1975                                     const OUString& aCaption );
1976 
1977     /** Query the native control's actual drawing region (including adornment)
1978      */
1979     bool                        GetNativeControlRegion(
1980                                     ControlType nType,
1981                                     ControlPart nPart,
1982                                     const tools::Rectangle& rControlRegion,
1983                                     ControlState nState,
1984                                     const ImplControlValue& aValue,
1985                                     tools::Rectangle &rNativeBoundingRegion,
1986                                     tools::Rectangle &rNativeContentRegion ) const;
1987     ///@}
1988 
1989     /** @name EPS functions
1990      */
1991     ///@{
1992 
1993 public:
1994 
1995     /** @returns boolean value to see if EPS could be painted directly.
1996         Theoretically, handing over a matrix would be needed to handle
1997         painting rotated EPS files (e.g. contained in Metafiles). This
1998         would then need to be supported for Mac and PS printers, but
1999         that's too much for now, wrote \#i107046# for this */
2000     bool                        DrawEPS(
2001                                     const Point& rPt, const Size& rSz,
2002                                     const GfxLink& rGfxLink, GDIMetaFile* pSubst = nullptr );
2003     ///@}
2004 };
2005 
2006 #endif // INCLUDED_VCL_OUTDEV_HXX
2007 
2008 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
2009