Coverage Report

Created: 2026-04-09 11:41

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