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