1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
22 #include <sal/config.h>
24 #include <tools/gen.hxx>
25 #include <tools/ref.hxx>
26 #include <tools/solar.h>
27 #include <tools/color.hxx>
28 #include <tools/poly.hxx>
29 #include <vcl/bitmap.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/AddFontSubstituteFlags.hxx>
36 #include <vcl/rendercontext/AntialiasingFlags.hxx>
37 #include <vcl/rendercontext/SystemTextColorFlags.hxx>
38 #include <vcl/rendercontext/DrawGridFlags.hxx>
39 #include <vcl/rendercontext/DrawImageFlags.hxx>
40 #include <vcl/rendercontext/DrawModeFlags.hxx>
41 #include <vcl/rendercontext/DrawTextFlags.hxx>
42 #include <vcl/rendercontext/GetDefaultFontFlags.hxx>
43 #include <vcl/rendercontext/ImplMapRes.hxx>
44 #include <vcl/rendercontext/InvertFlags.hxx>
45 #include <vcl/rendercontext/RasterOp.hxx>
46 #include <vcl/rendercontext/SalLayoutFlags.hxx>
47 #include <vcl/rendercontext/State.hxx>
48 #include <vcl/mapmod.hxx>
49 #include <vcl/wall.hxx>
50 #include <vcl/metaactiontypes.hxx>
51 #include <vcl/salnativewidgets.hxx>
52 #include <vcl/settings.hxx>
53 #include <vcl/vclenum.hxx>
54 #include <vcl/vclreferencebase.hxx>
56 #include <basegfx/range/b2drectangle.hxx>
57 #include <basegfx/numeric/ftools.hxx>
58 #include <basegfx/point/b2dpoint.hxx>
59 #include <basegfx/vector/b2enums.hxx>
60 #include <basegfx/polygon/b2dpolypolygon.hxx>
62 #include <unotools/fontdefs.hxx>
63 #include <cppuhelper/weakref.hxx>
65 #include <com/sun/star/drawing/LineCap.hpp>
66 #include <com/sun/star/uno/Reference.h>
67 #include <com/sun/star/awt/DeviceInfo.hpp>
72 #include <string_view>
75 struct ImplOutDevData
;
76 class LogicalFontInstance
;
77 struct SystemGraphicsData
;
79 class ImplMultiTextLineInfo
;
83 class BitmapReadAccess
;
101 class OutDevStateStack
;
102 class SalLayoutGlyphs
;
107 class TextLayoutCommon
;
108 struct FontCapabilities
;
110 class WindowOutputDevice
;
113 class PhysicalFontCollection
;
114 class PhysicalFontFaceCollection
;
118 class ImplLayoutArgs
;
119 class TextLayoutCache
;
130 namespace com::sun::star::awt
{
134 namespace com::sun::star::rendering
{
138 namespace com::sun::star::linguistic2
{
141 namespace com::sun::star::i18n
{
142 class XBreakIterator
;
145 // OutputDevice-Types
147 enum OutDevType
{ OUTDEV_WINDOW
, OUTDEV_PRINTER
, OUTDEV_VIRDEV
, OUTDEV_PDF
};
149 enum class OutDevViewType
{ DontKnow
, PrintPreview
, SlideShow
};
153 typedef tools::SvRef
<FontCharMap
> FontCharMapRef
;
155 BmpMirrorFlags
AdjustTwoRect( SalTwoRect
& rTwoRect
, const Size
& rSizePix
);
156 void AdjustTwoRect( SalTwoRect
& rTwoRect
, const tools::Rectangle
& rValidSrcRect
);
161 typedef OutputDevice RenderContext
;
163 struct TextArrayMetrics
165 std::optional
<tools::Rectangle
> aBounds
;
170 VCL_DLLPUBLIC
void InvertFocusRect(vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
);
173 * Some things multiple-inherit from VclAbstractDialog and OutputDevice,
174 * so we need to use virtual inheritance to keep the referencing counting
177 class SAL_WARN_UNUSED VCL_DLLPUBLIC OutputDevice
: public virtual VclReferenceBase
179 friend class Printer
;
180 friend class VirtualDevice
;
181 friend class vcl::Window
;
182 friend class vcl::WindowOutputDevice
;
183 friend class WorkWindow
;
184 friend void ImplHandleResize( vcl::Window
* pWindow
, tools::Long nNewWidth
, tools::Long nNewHeight
);
187 OutputDevice(const OutputDevice
&) = delete;
188 OutputDevice
& operator=(const OutputDevice
&) = delete;
190 mutable SalGraphics
* mpGraphics
; ///< Graphics context to draw on
191 mutable VclPtr
<OutputDevice
> mpPrevGraphics
; ///< Previous output device in list
192 mutable VclPtr
<OutputDevice
> mpNextGraphics
; ///< Next output device in list
193 GDIMetaFile
* mpMetaFile
;
194 mutable rtl::Reference
<LogicalFontInstance
> mpFontInstance
;
195 rtl::Reference
<LogicalFontInstance
> mpForcedFallbackInstance
;
196 mutable std::unique_ptr
<vcl::font::PhysicalFontFaceCollection
> mpFontFaceCollection
;
197 std::vector
<vcl::State
> maOutDevStateStack
;
198 std::unique_ptr
<ImplOutDevData
> mpOutDevData
;
199 std::vector
< VCLXGraphics
* >* mpUnoGraphicsList
;
200 vcl::ExtOutDevData
* mpExtOutDevData
;
201 // The canvas interface for this output device. Is persistent after the first GetCanvas() call
202 mutable css::uno::WeakReference
< css::rendering::XCanvas
> mxCanvas
;
205 VclPtr
<VirtualDevice
> mpAlphaVDev
;
207 /// Additional output pixel offset, applied in LogicToPixel (used by SetPixelOffset/GetPixelOffset)
208 tools::Long mnOutOffOrigX
;
209 /// Additional output offset in _logical_ coordinates, applied in PixelToLogic (used by SetPixelOffset/GetPixelOffset)
210 tools::Long mnOutOffLogicX
;
211 /// Additional output pixel offset, applied in LogicToPixel (used by SetPixelOffset/GetPixelOffset)
212 tools::Long mnOutOffOrigY
;
213 /// Additional output offset in _logical_ coordinates, applied in PixelToLogic (used by SetPixelOffset/GetPixelOffset)
214 tools::Long mnOutOffLogicY
;
215 /// Output offset for device output in pixel (pseudo window offset within window system's frames)
216 tools::Long mnOutOffX
;
217 /// Output offset for device output in pixel (pseudo window offset within window system's frames)
218 tools::Long mnOutOffY
;
219 tools::Long mnOutWidth
;
220 tools::Long mnOutHeight
;
223 sal_Int32 mnDPIScalePercentage
; ///< For HiDPI displays, we want to draw elements for a percentage larger
224 /// font specific text alignment offsets in pixel units
225 mutable tools::Long mnTextOffX
;
226 mutable tools::Long mnTextOffY
;
227 mutable tools::Long mnEmphasisAscent
;
228 mutable tools::Long mnEmphasisDescent
;
229 DrawModeFlags mnDrawMode
;
230 vcl::text::ComplexTextLayoutFlags mnTextLayoutMode
;
232 const OutDevType meOutDevType
;
233 OutDevViewType meOutDevViewType
;
234 vcl::Region maRegion
; // contains the clip region, see SetClipRegion(...)
239 Color maTextLineColor
;
240 Color maOverlineColor
;
242 Wallpaper maBackground
;
243 std::optional
<AllSettings
> moSettings
;
246 AntialiasingFlags mnAntialiasing
;
247 LanguageType meTextLanguage
;
249 mutable bool mbMap
: 1;
250 mutable bool mbClipRegion
: 1;
251 mutable bool mbBackground
: 1;
252 mutable bool mbOutput
: 1;
253 mutable bool mbDevOutput
: 1;
254 mutable bool mbOutputClipped
: 1;
255 mutable bool mbLineColor
: 1;
256 mutable bool mbFillColor
: 1;
257 mutable bool mbInitLineColor
: 1;
258 mutable bool mbInitFillColor
: 1;
259 mutable bool mbInitFont
: 1;
260 mutable bool mbInitTextColor
: 1;
261 mutable bool mbInitClipRegion
: 1;
262 mutable bool mbClipRegionSet
: 1;
263 mutable bool mbNewFont
: 1;
264 mutable bool mbTextLines
: 1;
265 mutable bool mbTextSpecial
: 1;
266 mutable bool mbRefPoint
: 1;
267 mutable bool mbEnableRTL
: 1;
270 mutable std::shared_ptr
<vcl::font::PhysicalFontCollection
> mxFontCollection
;
271 mutable std::shared_ptr
<ImplFontCache
> mxFontCache
;
273 /** @name Initialization and accessor functions
278 OutputDevice(OutDevType eOutDevType
);
279 virtual ~OutputDevice() override
;
280 virtual void dispose() override
;
284 /** Get the graphic context that the output device uses to draw on.
286 If no graphics device exists, then initialize it.
288 @returns SalGraphics instance.
290 SalGraphics
const *GetGraphics() const;
291 SalGraphics
* GetGraphics();
293 void SetConnectMetaFile( GDIMetaFile
* pMtf
);
294 GDIMetaFile
* GetConnectMetaFile() const { return mpMetaFile
; }
296 virtual void SetSettings( const AllSettings
& rSettings
);
297 const AllSettings
& GetSettings() const { return *moSettings
; }
299 SystemGraphicsData
GetSystemGfxData() const;
300 OUString
GetRenderBackendName() const;
302 // Used by the canvas module. Despite the name it does not always return true if Cairo is supported.
303 bool SupportsCairo() const;
304 /// Create Surface from given cairo surface
305 cairo::SurfaceSharedPtr
CreateSurface(const cairo::CairoSurfaceSharedPtr
& rSurface
) const;
306 /// Create surface with given dimensions
307 cairo::SurfaceSharedPtr
CreateSurface(int x
, int y
, int width
, int height
) const;
308 /// Create Surface for given bitmap data
309 cairo::SurfaceSharedPtr
CreateBitmapSurface(const BitmapSystemData
& rData
, const Size
& rSize
) const;
310 /// Return native handle for underlying surface
311 css::uno::Any
GetNativeSurfaceHandle(cairo::SurfaceSharedPtr
& rSurface
, const basegfx::B2ISize
& rSize
) const;
312 SAL_DLLPRIVATE
css::uno::Any
GetSystemGfxDataAny() const;
315 void SetRefPoint( const Point
& rRefPoint
);
316 const Point
& GetRefPoint() const { return maRefPoint
; }
317 bool IsRefPoint() const { return mbRefPoint
; }
319 virtual bool IsScreenComp() const { return true; }
321 virtual sal_uInt16
GetBitCount() const;
323 Size
GetOutputSizePixel() const
324 { return Size( mnOutWidth
, mnOutHeight
); }
325 tools::Long
GetOutputWidthPixel() const { return mnOutWidth
; }
326 tools::Long
GetOutputHeightPixel() const { return mnOutHeight
; }
327 tools::Long
GetOutOffXPixel() const { return mnOutOffX
; }
328 tools::Long
GetOutOffYPixel() const { return mnOutOffY
; }
329 SAL_DLLPRIVATE
void SetOutOffXPixel(tools::Long nOutOffX
);
330 SAL_DLLPRIVATE
void SetOutOffYPixel(tools::Long nOutOffY
);
331 Point
GetOutputOffPixel() const
332 { return Point( mnOutOffX
, mnOutOffY
); }
333 tools::Rectangle
GetOutputRectPixel() const
334 { return tools::Rectangle(GetOutputOffPixel(), GetOutputSizePixel() ); }
336 Size
GetOutputSize() const
337 { return PixelToLogic( GetOutputSizePixel() ); }
339 css::uno::Reference
< css::awt::XGraphics
>
341 std::vector
< VCLXGraphics
* > *GetUnoGraphicsList() const { return mpUnoGraphicsList
; }
342 std::vector
< VCLXGraphics
* > *CreateUnoGraphicsList();
344 virtual size_t GetSyncCount() const { return 0xffffffff; }
346 /// request XCanvas render interface
347 css::uno::Reference
< css::rendering::XCanvas
> GetCanvas() const;
348 /// request XSpriteCanvas render interface
349 css::uno::Reference
< css::rendering::XSpriteCanvas
> GetSpriteCanvas() const;
353 /** Acquire a graphics device that the output device uses to draw on.
355 There is an LRU of OutputDevices that is used to get the graphics. The
356 actual creation of a SalGraphics instance is done via the SalFrame
359 However, the SalFrame instance will only return a valid SalGraphics
360 instance if it is not in use or there wasn't one in the first place. When
361 this happens, AcquireGraphics finds the least recently used OutputDevice
362 in a different frame and "steals" it (releases it then starts using it).
364 If there are no frames to steal an OutputDevice's SalGraphics instance from
365 then it blocks until the graphics is released.
367 Once it has acquired a graphics instance, then we add the OutputDevice to
370 @returns true if was able to initialize the graphics device, false otherwise.
372 virtual bool AcquireGraphics() const = 0;
374 /** Release the graphics device, and remove it from the graphics device
377 @param bRelease Determines whether to release the fonts of the
378 physically released graphics device.
380 virtual void ReleaseGraphics( bool bRelease
= true ) = 0;
384 /** @name Helper functions
390 /** Get the output device's DPI x-axis value.
392 @returns x-axis DPI value
394 SAL_DLLPRIVATE sal_Int32
GetDPIX() const { return mnDPIX
; }
396 /** Get the output device's DPI y-axis value.
398 @returns y-axis DPI value
400 SAL_DLLPRIVATE sal_Int32
GetDPIY() const { return mnDPIY
; }
402 SAL_DLLPRIVATE
void SetDPIX( sal_Int32 nDPIX
) { mnDPIX
= nDPIX
; }
403 SAL_DLLPRIVATE
void SetDPIY( sal_Int32 nDPIY
) { mnDPIY
= nDPIY
; }
405 float GetDPIScaleFactor() const
407 return mnDPIScalePercentage
/ 100.0f
;
410 sal_Int32
GetDPIScalePercentage() const
412 return mnDPIScalePercentage
;
415 OutDevType
GetOutDevType() const { return meOutDevType
; }
416 virtual bool IsVirtual() const;
418 /** Query an OutputDevice to see whether it supports a specific operation
420 @returns true if operation supported, else false
422 bool SupportsOperation( OutDevSupportType
) const;
424 void SetExtOutDevData( vcl::ExtOutDevData
* pExtOutDevData
) { mpExtOutDevData
= pExtOutDevData
; }
425 vcl::ExtOutDevData
* GetExtOutDevData() const { return mpExtOutDevData
; }
430 virtual Size
GetButtonBorderSize() { return Size(1, 1); };
431 virtual Color
GetMonochromeButtonColor() { return COL_WHITE
; }
433 /** @name Direct OutputDevice drawing functions
438 virtual void Flush() {}
440 virtual void DrawOutDev(
441 const Point
& rDestPt
, const Size
& rDestSize
,
442 const Point
& rSrcPt
, const Size
& rSrcSize
);
444 virtual void DrawOutDev(
445 const Point
& rDestPt
, const Size
& rDestSize
,
446 const Point
& rSrcPt
, const Size
& rSrcSize
,
447 const OutputDevice
& rOutDev
);
449 virtual void CopyArea(
450 const Point
& rDestPt
,
451 const Point
& rSrcPt
, const Size
& rSrcSize
,
452 bool bWindowInvalidate
= false );
456 virtual void CopyDeviceArea( SalTwoRect
& aPosAry
, bool bWindowInvalidate
);
458 virtual tools::Rectangle
GetBackgroundComponentBounds() const;
460 virtual const OutputDevice
* DrawOutDevDirectCheck(const OutputDevice
& rSrcDev
) const;
462 virtual void DrawOutDevDirectProcess(const OutputDevice
& rSrcDev
, SalTwoRect
& rPosAry
, SalGraphics
* pSrcGraphics
);
464 SAL_DLLPRIVATE
void drawOutDevDirect(const OutputDevice
& rSrcDev
, SalTwoRect
& rPosAry
);
466 SAL_DLLPRIVATE
bool is_double_buffered_window() const;
468 virtual css::uno::Reference
< css::rendering::XCanvas
> ImplGetCanvas( bool bSpriteCanvas
) const;
469 SAL_DLLPRIVATE
void ImplDisposeCanvas();
473 // not implemented; to detect misuses of DrawOutDev(...OutputDevice&);
474 SAL_DLLPRIVATE
void DrawOutDev( const Point
&, const Size
&, const Point
&, const Size
&, const Printer
&) = delete;
478 /** @name OutputDevice state functions
484 void Push( vcl::PushFlags nFlags
= vcl::PushFlags::ALL
);
486 SAL_DLLPRIVATE
void ClearStack();
488 void EnableOutput( bool bEnable
= true );
489 bool IsOutputEnabled() const { return mbOutput
; }
490 bool IsDeviceOutputNecessary() const { return (mbOutput
&& mbDevOutput
); }
492 void SetAntialiasing( AntialiasingFlags nMode
);
493 AntialiasingFlags
GetAntialiasing() const { return mnAntialiasing
; }
495 void SetDrawMode( DrawModeFlags nDrawMode
);
496 DrawModeFlags
GetDrawMode() const { return mnDrawMode
; }
498 void SetLayoutMode( vcl::text::ComplexTextLayoutFlags nTextLayoutMode
);
499 vcl::text::ComplexTextLayoutFlags
GetLayoutMode() const { return mnTextLayoutMode
; }
501 void SetDigitLanguage( LanguageType
);
502 LanguageType
GetDigitLanguage() const { return meTextLanguage
; }
504 void SetRasterOp( RasterOp eRasterOp
);
505 RasterOp
GetRasterOp() const { return meRasterOp
; }
508 If this OutputDevice is used for displaying a Print Preview
509 the OutDevViewType should be set to 'OutDevViewType::PrintPreview'.
511 A View can then make painting decisions dependent on this OutDevViewType.
512 E.g. text colors need to be handled differently, dependent on whether it's a PrintPreview or not. (see #106611# for more)
514 void SetOutDevViewType( OutDevViewType eOutDevViewType
) { meOutDevViewType
=eOutDevViewType
; }
515 OutDevViewType
GetOutDevViewType() const { return meOutDevViewType
; }
518 void SetLineColor( const Color
& rColor
);
519 const Color
& GetLineColor() const { return maLineColor
; }
520 bool IsLineColor() const { return mbLineColor
; }
523 void SetFillColor( const Color
& rColor
);
524 const Color
& GetFillColor() const { return maFillColor
; }
525 bool IsFillColor() const { return mbFillColor
; }
527 void SetBackground();
528 void SetBackground( const Wallpaper
& rBackground
);
529 virtual void SaveBackground(VirtualDevice
& rSaveDevice
,
530 const Point
& rPos
, const Size
& rSize
, const Size
& rBackgroundSize
) const;
532 const Wallpaper
& GetBackground() const { return maBackground
; }
533 virtual Color
GetBackgroundColor() const;
534 virtual Color
GetReadableFontColor(const Color
& rFontColor
, const Color
& rBgColor
) const;
535 bool IsBackground() const { return mbBackground
; }
537 void SetFont( const vcl::Font
& rNewFont
);
538 const vcl::Font
& GetFont() const { return maFont
; }
542 virtual void ImplReleaseFonts();
546 SAL_DLLPRIVATE
void InitLineColor();
548 SAL_DLLPRIVATE
void InitFillColor();
553 /** @name Clipping functions
559 vcl::Region
GetClipRegion() const;
560 void SetClipRegion();
561 void SetClipRegion( const vcl::Region
& rRegion
);
562 SAL_DLLPRIVATE
bool SelectClipRegion( const vcl::Region
&, SalGraphics
* pGraphics
= nullptr );
564 bool IsClipRegion() const { return mbClipRegion
; }
566 void MoveClipRegion( tools::Long nHorzMove
, tools::Long nVertMove
);
567 void IntersectClipRegion( const tools::Rectangle
& rRect
);
568 void IntersectClipRegion( const vcl::Region
& rRegion
);
570 virtual vcl::Region
GetActiveClipRegion() const;
571 virtual vcl::Region
GetOutputBoundsClipRegion() const;
575 virtual void InitClipRegion();
577 /** Perform actual rect clip against outdev dimensions, to generate
578 empty clips whenever one of the values is completely off the device.
580 @param aRegion region to be clipped to the device dimensions
581 @returns region clipped to the device bounds
583 virtual vcl::Region
ClipToDeviceBounds(vcl::Region aRegion
) const;
584 virtual void ClipToPaintRegion ( tools::Rectangle
& rDstRect
);
588 SAL_DLLPRIVATE
void SetDeviceClipRegion( const vcl::Region
* pRegion
);
592 virtual void DrawBorder(tools::Rectangle aBorderRect
);
595 /** @name Pixel functions
601 void DrawPixel( const Point
& rPt
);
602 void DrawPixel( const Point
& rPt
, const Color
& rColor
);
604 Color
GetPixel( const Point
& rPt
) const;
608 /** @name Rectangle functions
614 void DrawRect( const tools::Rectangle
& rRect
);
615 void DrawRect( const tools::Rectangle
& rRect
,
616 sal_uLong nHorzRount
, sal_uLong nVertRound
);
618 /// Fill the given rectangle with checkered rectangles of size nLen x nLen using the colors aStart and aEnd
623 Color aStart
= COL_WHITE
,
624 Color aEnd
= COL_BLACK
);
626 void DrawGrid( const tools::Rectangle
& rRect
, const Size
& rDist
, DrawGridFlags nFlags
);
630 /** @name Invert functions
634 void Invert( const tools::Rectangle
& rRect
, InvertFlags nFlags
= InvertFlags::NONE
);
635 void Invert( const tools::Polygon
& rPoly
, InvertFlags nFlags
= InvertFlags::NONE
);
638 /** @name Line functions
644 void DrawLine( const Point
& rStartPt
, const Point
& rEndPt
);
646 void DrawLine( const Point
& rStartPt
, const Point
& rEndPt
,
647 const LineInfo
& rLineInfo
);
650 virtual void DrawHatchLine_DrawLine(const Point
& rStartPoint
, const Point
& rEndPoint
);
654 /** Helper for line geometry paint with support for graphic expansion (pattern and fat_to_area)
656 SAL_DLLPRIVATE
void drawLine( basegfx::B2DPolyPolygon aLinePolyPolygon
, const LineInfo
& rInfo
);
660 /** @name Polyline functions
666 /** Render the given polygon as a line stroke
668 The given polygon is stroked with the current LineColor, start
669 and end point are not automatically connected
674 void DrawPolyLine( const tools::Polygon
& rPoly
);
677 const basegfx::B2DPolygon
&,
678 double fLineWidth
= 0.0,
679 basegfx::B2DLineJoin eLineJoin
= basegfx::B2DLineJoin::Round
,
680 css::drawing::LineCap eLineCap
= css::drawing::LineCap_BUTT
,
681 double fMiterMinimumAngle
= basegfx::deg2rad(15.0));
683 /** Render the given polygon as a line stroke
685 The given polygon is stroked with the current LineColor, start
686 and end point are not automatically connected. The line is
687 rendered according to the specified LineInfo, e.g. supplying a
688 dash pattern, or a line thickness.
693 void DrawPolyLine( const tools::Polygon
& rPoly
,
694 const LineInfo
& rLineInfo
);
697 // Helper who tries to use SalGDI's DrawPolyLine direct and returns it's bool.
698 bool DrawPolyLineDirect(
699 const basegfx::B2DHomMatrix
& rObjectTransform
,
700 const basegfx::B2DPolygon
& rB2DPolygon
,
701 double fLineWidth
= 0.0,
702 double fTransparency
= 0.0,
703 const std::vector
< double >* = nullptr, // MM01
704 basegfx::B2DLineJoin eLineJoin
= basegfx::B2DLineJoin::NONE
,
705 css::drawing::LineCap eLineCap
= css::drawing::LineCap_BUTT
,
706 double fMiterMinimumAngle
= basegfx::deg2rad(15.0));
711 // Helper which holds the old line geometry creation and is extended to use AA when
712 // switched on. Advantage is that line geometry is only temporarily used for paint
713 SAL_DLLPRIVATE
void drawPolyLine(const tools::Polygon
& rPoly
, const LineInfo
& rLineInfo
);
717 SAL_DLLPRIVATE
bool DrawPolyLineDirectInternal(
718 const basegfx::B2DHomMatrix
& rObjectTransform
,
719 const basegfx::B2DPolygon
& rB2DPolygon
,
720 double fLineWidth
= 0.0,
721 double fTransparency
= 0.0,
722 const std::vector
< double >* = nullptr, // MM01
723 basegfx::B2DLineJoin eLineJoin
= basegfx::B2DLineJoin::NONE
,
724 css::drawing::LineCap eLineCap
= css::drawing::LineCap_BUTT
,
725 double fMiterMinimumAngle
= basegfx::deg2rad(15.0));
727 /** @name Polygon functions
733 /** Render the given polygon
735 The given polygon is stroked with the current LineColor, and
736 filled with the current FillColor. If one of these colors are
737 transparent, the corresponding stroke or fill stays
738 invisible. Start and end point of the polygon are
739 automatically connected.
743 void DrawPolygon( const tools::Polygon
& rPoly
);
744 void DrawPolygon( const basegfx::B2DPolygon
& );
746 /** Render the given poly-polygon
748 The given poly-polygon is stroked with the current LineColor,
749 and filled with the current FillColor. If one of these colors
750 are transparent, the corresponding stroke or fill stays
751 invisible. Start and end points of the contained polygons are
752 automatically connected.
756 void DrawPolyPolygon( const tools::PolyPolygon
& rPolyPoly
);
757 void DrawPolyPolygon( const basegfx::B2DPolyPolygon
& );
761 SAL_DLLPRIVATE
void ImplDrawPolygon( const tools::Polygon
& rPoly
, const tools::PolyPolygon
* pClipPolyPoly
= nullptr );
762 SAL_DLLPRIVATE
void ImplDrawPolyPolygon( const tools::PolyPolygon
& rPolyPoly
, const tools::PolyPolygon
* pClipPolyPoly
);
763 SAL_DLLPRIVATE
void ImplDrawPolyPolygon( sal_uInt16 nPoly
, const tools::PolyPolygon
& rPolyPoly
);
765 // Helper who implements the DrawPolyPolygon functionality for basegfx::B2DPolyPolygon
766 // without MetaFile processing
767 SAL_DLLPRIVATE
void ImplDrawPolyPolygonWithB2DPolyPolygon(const basegfx::B2DPolyPolygon
& rB2DPolyPoly
);
770 SAL_DLLPRIVATE
void ImplDrawWaveLineBezier(tools::Long nStartX
, tools::Long nStartY
, tools::Long nEndX
, tools::Long nEndY
, tools::Long nWaveHeight
, double fOrientation
, tools::Long nLineWidth
);
773 /** @name Curved shape functions
779 void DrawEllipse( const tools::Rectangle
& rRect
);
782 const tools::Rectangle
& rRect
,
783 const Point
& rStartPt
, const Point
& rEndPt
);
786 const tools::Rectangle
& rRect
,
787 const Point
& rStartPt
, const Point
& rEndPt
);
790 const tools::Rectangle
& rRect
,
791 const Point
& rStartPt
, const Point
& rEndPt
);
796 /** @name Gradient functions
801 void DrawGradient( const tools::Rectangle
& rRect
, const Gradient
& rGradient
);
802 void DrawGradient( const tools::PolyPolygon
& rPolyPoly
, const Gradient
& rGradient
);
806 virtual bool UsePolyPolygonForComplexGradient() = 0;
808 virtual tools::Long
GetGradientStepCount( tools::Long nMinRect
);
812 SAL_DLLPRIVATE
void DrawLinearGradient( const tools::Rectangle
& rRect
, const Gradient
& rGradient
, const tools::PolyPolygon
* pClipPolyPoly
);
813 SAL_DLLPRIVATE
void DrawComplexGradient( const tools::Rectangle
& rRect
, const Gradient
& rGradient
, const tools::PolyPolygon
* pClipPolyPoly
);
814 SAL_DLLPRIVATE
void DrawGradientToMetafile( const tools::PolyPolygon
& rPolyPoly
, const Gradient
& rGradient
);
815 SAL_DLLPRIVATE
tools::Long
GetGradientSteps(Gradient
const& rGradient
, tools::Rectangle
const& rRect
);
816 SAL_DLLPRIVATE Color
GetSingleColorGradientFill();
820 /** @name Hatch functions
827 void DrawHatch( const tools::PolyPolygon
& rPolyPoly
, const ::Hatch
& rHatch
);
828 void AddHatchActions( const tools::PolyPolygon
& rPolyPoly
,
829 const ::Hatch
& rHatch
,
832 void DrawHatch( const tools::PolyPolygon
& rPolyPoly
, const Hatch
& rHatch
);
833 void AddHatchActions( const tools::PolyPolygon
& rPolyPoly
,
838 SAL_DLLPRIVATE
void DrawHatch( const tools::PolyPolygon
& rPolyPoly
, const Hatch
& rHatch
, bool bMtf
);
842 SAL_DLLPRIVATE
void CalcHatchValues( const tools::Rectangle
& rRect
, tools::Long nDist
, Degree10 nAngle10
, Point
& rPt1
, Point
& rPt2
, Size
& rInc
, Point
& rEndPt1
);
843 SAL_DLLPRIVATE
void DrawHatchLine( const tools::Line
& rLine
, const tools::PolyPolygon
& rPolyPoly
, Point
* pPtBuffer
, bool bMtf
);
847 /** @name Wallpaper functions
852 void DrawWallpaper( const tools::Rectangle
& rRect
, const Wallpaper
& rWallpaper
);
855 void Erase(const tools::Rectangle
& rRect
);
858 SAL_DLLPRIVATE
void DrawGradientWallpaper( tools::Long nX
, tools::Long nY
, tools::Long nWidth
, tools::Long nHeight
, const Wallpaper
& rWallpaper
);
861 SAL_DLLPRIVATE
void DrawWallpaper( tools::Long nX
, tools::Long nY
, tools::Long nWidth
, tools::Long nHeight
, const Wallpaper
& rWallpaper
);
862 SAL_DLLPRIVATE
void DrawColorWallpaper( tools::Long nX
, tools::Long nY
, tools::Long nWidth
, tools::Long nHeight
, const Wallpaper
& rWallpaper
);
863 SAL_DLLPRIVATE
void DrawBitmapWallpaper( tools::Long nX
, tools::Long nY
, tools::Long nWidth
, tools::Long nHeight
, const Wallpaper
& rWallpaper
);
867 /** @name Text functions
873 void DrawText( const Point
& rStartPt
, const OUString
& rStr
,
874 sal_Int32 nIndex
= 0, sal_Int32 nLen
= -1,
875 std::vector
< tools::Rectangle
>* pVector
= nullptr, OUString
* pDisplayText
= nullptr,
876 const SalLayoutGlyphs
* pLayoutCache
= nullptr );
878 void DrawText( const tools::Rectangle
& rRect
,
879 const OUString
& rStr
, DrawTextFlags nStyle
= DrawTextFlags::NONE
,
880 std::vector
< tools::Rectangle
>* pVector
= nullptr, OUString
* pDisplayText
= nullptr,
881 vcl::TextLayoutCommon
* _pTextLayout
= nullptr );
883 SAL_DLLPRIVATE
static void ImplDrawText( OutputDevice
& rTargetDevice
, const tools::Rectangle
& rRect
,
884 const OUString
& rOrigStr
, DrawTextFlags nStyle
,
885 std::vector
< tools::Rectangle
>* pVector
, OUString
* pDisplayText
, vcl::TextLayoutCommon
& _rLayout
);
887 SAL_DLLPRIVATE
void ImplDrawText( SalLayout
& );
889 SAL_DLLPRIVATE
void ImplDrawTextBackground( const SalLayout
& );
891 void DrawCtrlText( const Point
& rPos
, const OUString
& rStr
,
892 sal_Int32 nIndex
= 0, sal_Int32 nLen
= -1,
893 DrawTextFlags nStyle
= DrawTextFlags::Mnemonic
, std::vector
< tools::Rectangle
>* pVector
= nullptr, OUString
* pDisplayText
= nullptr,
894 const SalLayoutGlyphs
* pGlyphs
= nullptr);
896 void DrawTextLine( const Point
& rPos
, tools::Long nWidth
,
897 FontStrikeout eStrikeout
,
898 FontLineStyle eUnderline
,
899 FontLineStyle eOverline
,
900 bool bUnderlineAbove
= false );
902 SAL_DLLPRIVATE
void ImplDrawTextLine( tools::Long nBaseX
, tools::Long nX
, tools::Long nY
, double nWidth
,
903 FontStrikeout eStrikeout
, FontLineStyle eUnderline
,
904 FontLineStyle eOverline
, bool bUnderlineAbove
);
906 SAL_DLLPRIVATE
void ImplDrawTextLines( SalLayout
&, FontStrikeout eStrikeout
, FontLineStyle eUnderline
,
907 FontLineStyle eOverline
, bool bWordLine
, bool bUnderlineAbove
);
909 void DrawWaveLine( const Point
& rStartPos
, const Point
& rEndPos
, tools::Long nLineWidth
= 1, tools::Long nWaveHeight
= 3);
911 SAL_DLLPRIVATE
bool ImplDrawRotateText( SalLayout
& );
913 tools::Rectangle
GetTextRect( const tools::Rectangle
& rRect
,
914 const OUString
& rStr
, DrawTextFlags nStyle
= DrawTextFlags::WordBreak
,
915 TextRectInfo
* pInfo
= nullptr,
916 const vcl::TextLayoutCommon
* _pTextLayout
= nullptr ) const;
918 /** Return the exact bounding rectangle of rStr.
920 The text is then drawn exactly from rRect.TopLeft() to
921 rRect.BottomRight(), don't assume that rRect.TopLeft() is [0, 0].
923 Please note that you don't always want to use GetTextBoundRect(); in
924 many cases you actually want to use GetTextHeight(), because
925 GetTextBoundRect() gives you the exact bounding rectangle regardless
926 what is the baseline of the text.
928 Code snippet to get just exactly the text (no filling around that) as
929 a bitmap via a VirtualDevice (regardless what is the baseline):
932 VirtualDevice aDevice;
933 vcl::Font aFont = aDevice.GetFont();
934 aFont.SetSize(Size(0, 96));
935 aFont.SetColor(COL_BLACK);
936 aDevice.SetFont(aFont);
939 tools::Rectangle aRect;
940 aDevice.GetTextBoundRect(aRect, aText);
941 aDevice.SetOutputSize(Size(aRect.Right() + 1, aRect.Bottom() + 1));
942 aDevice.SetBackground(Wallpaper(COL_TRANSPARENT));
943 aDevice.DrawText(Point(0,0), aText);
945 // exactly only the text, regardless of the baseline
946 Bitmap aBitmap(aDevice.GetBitmap(aRect.TopLeft(), aRect.GetSize()));
949 Code snippet to get the text as a bitmap via a Virtual device that
950 contains even the filling so that the baseline is always preserved
951 (ie. the text will not jump up and down according to whether it
952 contains 'y' or not etc.)
955 VirtualDevice aDevice;
956 // + the appropriate font / device setup, see above
958 aDevice.SetOutputSize(Size(aDevice.GetTextWidth(aText), aDevice.GetTextHeight()));
959 aDevice.SetBackground(Wallpaper(COL_TRANSPARENT));
960 aDevice.DrawText(Point(0,0), aText);
962 // bitmap that contains even the space around the text,
963 // that means, preserves the baseline etc.
964 Bitmap aBitmap(aDevice.GetBitmap(Point(0, 0), aDevice.GetOutputSize()));
967 bool GetTextBoundRect( tools::Rectangle
& rRect
,
968 const OUString
& rStr
, sal_Int32 nBase
= 0, sal_Int32 nIndex
= 0, sal_Int32 nLen
= -1,
969 sal_uLong nLayoutWidth
= 0, KernArraySpan aDXArray
= KernArraySpan(),
970 std::span
<const sal_Bool
> pKashidaArray
= {},
971 const SalLayoutGlyphs
* pGlyphs
= nullptr ) const;
972 bool GetTextBoundRect( basegfx::B2DRectangle
& rRect
,
973 const OUString
& rStr
, sal_Int32 nBase
= 0, sal_Int32 nIndex
= 0, sal_Int32 nLen
= -1,
974 sal_uLong nLayoutWidth
= 0, KernArraySpan aDXArray
= KernArraySpan(),
975 std::span
<const sal_Bool
> pKashidaArray
= {},
976 const SalLayoutGlyphs
* pGlyphs
= nullptr ) const;
978 tools::Rectangle
ImplGetTextBoundRect( const SalLayout
& ) const;
980 bool GetTextOutline( tools::PolyPolygon
&,
981 const OUString
& rStr
) const;
983 bool GetTextOutlines( PolyPolyVector
&,
984 const OUString
& rStr
, sal_Int32 nBase
= 0, sal_Int32 nIndex
= 0,
986 sal_uLong nLayoutWidth
= 0, KernArraySpan aDXArray
= KernArraySpan(),
987 std::span
<const sal_Bool
> pKashidaArray
= {} ) const;
989 bool GetTextOutlines( basegfx::B2DPolyPolygonVector
&rVector
,
990 const OUString
& rStr
, sal_Int32 nBase
, sal_Int32 nIndex
= 0,
992 sal_uLong nLayoutWidth
= 0, KernArraySpan aDXArray
= KernArraySpan(),
993 std::span
<const sal_Bool
> pKashidaArray
= {} ) const;
996 OUString
GetEllipsisString( const OUString
& rStr
, tools::Long nMaxWidth
,
997 DrawTextFlags nStyle
= DrawTextFlags::EndEllipsis
) const;
999 tools::Long
GetCtrlTextWidth( const OUString
& rStr
,
1000 const SalLayoutGlyphs
* pLayoutCache
= nullptr ) const;
1002 /** Generate MetaTextActions for the text rect
1004 This method splits up the text rect into multiple
1005 MetaTextActions, one for each line of text. This is comparable
1006 to AddGradientActions(), which splits up a gradient into its
1007 constituent polygons. Parameter semantics fully compatible to
1010 void AddTextRectActions( const tools::Rectangle
& rRect
,
1011 const OUString
& rOrigStr
,
1012 DrawTextFlags nStyle
,
1013 GDIMetaFile
& rMtf
);
1015 void SetTextColor( const Color
& rColor
);
1016 virtual void SetSystemTextColor(SystemTextColorFlags nFlags
, bool bEnabled
);
1017 const Color
& GetTextColor() const { return maTextColor
; }
1019 void SetTextFillColor();
1020 void SetTextFillColor( const Color
& rColor
);
1021 Color
GetTextFillColor() const;
1022 bool IsTextFillColor() const { return !maFont
.IsTransparent(); }
1024 void SetTextLineColor();
1025 void SetTextLineColor( const Color
& rColor
);
1026 const Color
& GetTextLineColor() const { return maTextLineColor
; }
1027 bool IsTextLineColor() const { return !maTextLineColor
.IsTransparent(); }
1029 void SetOverlineColor();
1030 void SetOverlineColor( const Color
& rColor
);
1031 const Color
& GetOverlineColor() const { return maOverlineColor
; }
1032 bool IsOverlineColor() const { return !maOverlineColor
.IsTransparent(); }
1034 void SetTextAlign( TextAlign eAlign
);
1035 TextAlign
GetTextAlign() const { return maFont
.GetAlignment(); }
1037 /** Width of the text.
1039 See also GetTextBoundRect() for more explanation + code examples.
1041 tools::Long
GetTextWidth( const OUString
& rStr
, sal_Int32 nIndex
= 0, sal_Int32 nLen
= -1,
1042 vcl::text::TextLayoutCache
const* = nullptr,
1043 SalLayoutGlyphs
const*const pLayoutCache
= nullptr) const;
1044 double GetTextWidthDouble(const OUString
& rStr
, sal_Int32 nIndex
= 0, sal_Int32 nLen
= -1,
1045 vcl::text::TextLayoutCache
const* = nullptr,
1046 SalLayoutGlyphs
const* const pLayoutCache
= nullptr) const;
1048 /** Height where any character of the current font fits; in logic coordinates.
1050 See also GetTextBoundRect() for more explanation + code examples.
1052 tools::Long
GetTextHeight() const;
1053 double GetTextHeightDouble() const;
1054 float approximate_digit_width() const;
1056 void DrawTextArray( const Point
& rStartPt
, const OUString
& rStr
,
1057 KernArraySpan aKernArray
,
1058 std::span
<const sal_Bool
> pKashidaAry
,
1061 SalLayoutFlags flags
= SalLayoutFlags::NONE
,
1062 const SalLayoutGlyphs
* pLayoutCache
= nullptr);
1063 vcl::TextArrayMetrics
GetTextArray(const OUString
& rStr
, KernArray
* pDXAry
,
1064 sal_Int32 nIndex
= 0, sal_Int32 nLen
= -1,
1065 bool bCaret
= false,
1066 vcl::text::TextLayoutCache
const* = nullptr,
1067 SalLayoutGlyphs
const* const pLayoutCache
= nullptr) const;
1069 void DrawPartialTextArray(const Point
& rStartPt
, const OUString
& rStr
, KernArraySpan aKernArray
,
1070 std::span
<const sal_Bool
> pKashidaAry
, sal_Int32 nIndex
,
1071 sal_Int32 nLen
, sal_Int32 nPartIndex
, sal_Int32 nPartLen
,
1072 SalLayoutFlags flags
= SalLayoutFlags::NONE
,
1073 const SalLayoutGlyphs
* pLayoutCache
= nullptr);
1074 vcl::TextArrayMetrics
GetPartialTextArray(const OUString
& rStr
, KernArray
* pDXAry
,
1075 sal_Int32 nIndex
, sal_Int32 nLen
,
1076 sal_Int32 nPartIndex
, sal_Int32 nPartLen
,
1077 bool bCaret
= false,
1078 const vcl::text::TextLayoutCache
* = nullptr,
1079 const SalLayoutGlyphs
* pLayoutCache
= nullptr) const;
1081 SAL_DLLPRIVATE
void GetCaretPositions( const OUString
&, KernArray
& rCaretXArray
,
1082 sal_Int32 nIndex
, sal_Int32 nLen
,
1083 const SalLayoutGlyphs
* pGlyphs
= nullptr ) const;
1084 void DrawStretchText( const Point
& rStartPt
, sal_Int32 nWidth
,
1085 const OUString
& rStr
,
1086 sal_Int32 nIndex
= 0, sal_Int32 nLen
= -1);
1087 sal_Int32
GetTextBreak( const OUString
& rStr
, tools::Long nTextWidth
,
1088 sal_Int32 nIndex
, sal_Int32 nLen
= -1,
1089 tools::Long nCharExtra
= 0,
1090 vcl::text::TextLayoutCache
const* = nullptr,
1091 const SalLayoutGlyphs
* pGlyphs
= nullptr) const;
1092 sal_Int32
GetTextBreak( const OUString
& rStr
, tools::Long nTextWidth
,
1093 sal_Unicode nExtraChar
, sal_Int32
& rExtraCharPos
,
1094 sal_Int32 nIndex
, sal_Int32 nLen
,
1095 tools::Long nCharExtra
,
1096 vcl::text::TextLayoutCache
const* = nullptr,
1097 const SalLayoutGlyphs
* pGlyphs
= nullptr) const;
1098 static std::shared_ptr
<const vcl::text::TextLayoutCache
> CreateTextLayoutCache(OUString
const&);
1100 SAL_DLLPRIVATE SalLayoutFlags
GetBiDiLayoutFlags( std::u16string_view rStr
,
1101 const sal_Int32 nMinIndex
,
1102 const sal_Int32 nEndIndex
) const;
1105 SAL_DLLPRIVATE
void ImplInitTextLineSize();
1106 SAL_DLLPRIVATE
void ImplInitAboveTextLineSize();
1107 SAL_DLLPRIVATE
float approximate_char_width() const;
1109 virtual bool shouldDrawWavePixelAsRect(tools::Long nLineWidth
) const;
1110 virtual void SetWaveLineColors(Color
const& rColor
, tools::Long nLineWidth
);
1111 virtual Size
GetWaveLineSize(tools::Long nLineWidth
) const;
1114 SAL_DLLPRIVATE
void ImplInitTextColor();
1116 SAL_DLLPRIVATE
void ImplDrawTextDirect( SalLayout
&, bool bTextLines
);
1117 SAL_DLLPRIVATE
void ImplDrawSpecialText( SalLayout
& );
1118 SAL_DLLPRIVATE
void ImplDrawTextRect( tools::Long nBaseX
, tools::Long nBaseY
, tools::Long nX
, tools::Long nY
, tools::Long nWidth
, tools::Long nHeight
);
1120 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
);
1122 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
);
1123 SAL_DLLPRIVATE
void ImplDrawWaveTextLine( tools::Long nBaseX
, tools::Long nBaseY
, tools::Long nX
, tools::Long nY
, tools::Long nWidth
, FontLineStyle eTextLine
, Color aColor
, bool bIsAbove
);
1124 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
);
1125 SAL_DLLPRIVATE
void ImplDrawStrikeoutLine( tools::Long nBaseX
, tools::Long nBaseY
, tools::Long nX
, tools::Long nY
, tools::Long nWidth
, FontStrikeout eStrikeout
, Color aColor
);
1126 SAL_DLLPRIVATE
void ImplDrawStrikeoutChar( tools::Long nBaseX
, tools::Long nBaseY
, tools::Long nX
, tools::Long nY
, tools::Long nWidth
, FontStrikeout eStrikeout
, Color aColor
);
1127 SAL_DLLPRIVATE
void ImplDrawMnemonicLine( tools::Long nX
, tools::Long nY
, tools::Long nWidth
);
1129 SAL_DLLPRIVATE
bool AttemptOLEFontScaleFix(vcl::Font
& rFont
, tools::Long nHeight
) const;
1134 /** @name Font functions
1140 FontMetric
GetFontMetricFromCollection( int nDevFontIndex
) const;
1141 int GetFontFaceCollectionCount() const;
1143 bool IsFontAvailable( std::u16string_view rFontName
) const;
1145 bool AddTempDevFont( const OUString
& rFileURL
, const OUString
& rFontName
);
1146 void RefreshFontData( const bool bNewFontLists
);
1148 FontMetric
GetFontMetric() const;
1149 FontMetric
GetFontMetric( const vcl::Font
& rFont
) const;
1151 bool GetFontCharMap( FontCharMapRef
& rxFontCharMap
) const;
1152 bool GetFontCapabilities( vcl::FontCapabilities
& rFontCapabilities
) const;
1154 bool GetFontFeatures(std::vector
<vcl::font::Feature
>& rFontFeatures
) const;
1156 bool GetGlyphBoundRects( const Point
& rOrigin
, const OUString
& rStr
, int nIndex
,
1157 int nLen
, std::vector
< tools::Rectangle
>& rVector
) const;
1159 sal_Int32
HasGlyphs( const vcl::Font
& rFont
, std::u16string_view rStr
,
1160 sal_Int32 nIndex
= 0, sal_Int32 nLen
= -1 ) const;
1162 tools::Long
GetMinKashida() const;
1165 // validate kashida positions against the current font
1166 // returns count of invalid kashida positions
1168 ValidateKashidas(const OUString
& rTxt
, sal_Int32 nIdx
, sal_Int32 nLen
, sal_Int32 nPartIdx
,
1170 std::span
<const sal_Int32
> pKashidaPos
, // suggested kashida positions (in)
1171 std::vector
<sal_Int32
>* pKashidaPosDropped
// invalid kashida positions (out)
1174 // tdf#163105: Get map of valid kashida positions for a single word
1175 void GetWordKashidaPositions(const OUString
& rText
, std::vector
<bool>* pOutMap
) const;
1177 static void BeginFontSubstitution();
1178 static void EndFontSubstitution();
1179 static void AddFontSubstitute( const OUString
& rFontName
,
1180 const OUString
& rReplaceFontName
,
1181 AddFontSubstituteFlags nFlags
);
1182 static void RemoveFontsSubstitute();
1184 static vcl::Font
GetDefaultFont( DefaultFontType nType
,
1186 GetDefaultFontFlags nFlags
,
1187 const OutputDevice
* pOutDev
= nullptr );
1189 SAL_DLLPRIVATE
void ImplInitFontList() const;
1190 SAL_DLLPRIVATE
void ImplUpdateFontData();
1192 //drop font data for all outputdevices.
1193 //If bNewFontLists is true then empty lists of system fonts
1194 static void ImplClearAllFontData( bool bNewFontLists
);
1195 //fetch font data for all outputdevices
1196 //If bNewFontLists is true then fetch lists of system fonts
1197 static void ImplRefreshAllFontData( bool bNewFontLists
);
1198 //drop and fetch font data for all outputdevices
1199 //If bNewFontLists is true then drop and refetch lists of system fonts
1200 SAL_DLLPRIVATE
static void ImplUpdateAllFontData( bool bNewFontLists
);
1202 LogicalFontInstance
const* GetFontInstance() const;
1203 bool ForceFallbackFont(vcl::Font
const& rFallbackFont
);
1206 SAL_DLLPRIVATE
tools::Long
GetEmphasisAscent() const { return mnEmphasisAscent
; }
1207 SAL_DLLPRIVATE
tools::Long
GetEmphasisDescent() const { return mnEmphasisDescent
; }
1209 SAL_DLLPRIVATE
bool InitFont() const;
1210 virtual void SetFontOrientation( LogicalFontInstance
* const pFontInstance
) const;
1211 virtual tools::Long
GetFontExtLeading() const;
1213 virtual void ImplClearFontData(bool bNewFontLists
);
1214 virtual void ImplRefreshFontData(bool bNewFontLists
);
1215 SAL_DLLPRIVATE
void ReleaseFontCache();
1216 SAL_DLLPRIVATE
void ReleaseFontCollection();
1217 SAL_DLLPRIVATE
void SetFontCollectionFromSVData();
1218 SAL_DLLPRIVATE
void ResetNewFontCache();
1220 virtual bool ImplNewFont() const;
1224 typedef void ( OutputDevice::* FontUpdateHandler_t
)( bool );
1226 SAL_DLLPRIVATE
static void ImplUpdateFontDataForAllFrames( FontUpdateHandler_t pHdl
, bool bNewFontLists
);
1228 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
);
1229 SAL_DLLPRIVATE
void ImplDrawEmphasisMarks( SalLayout
& );
1233 /** @name Layout functions
1238 /// tooling method to be able to access EmphasisMark data when needed
1239 void createEmphasisMarks(
1240 FontEmphasisMark nFontEmphasisMark
,
1241 tools::Long nEmphasisHeight
,
1242 SalLayout
& rSalLayout
,
1243 const std::function
<void(const basegfx::B2DPoint
&, const basegfx::B2DPolyPolygon
&,
1244 bool, const tools::Rectangle
&, const tools::Rectangle
&)>& rCallback
) const;
1246 // tells whether this output device is RTL in an LTR UI or LTR in a RTL UI
1247 SAL_DLLPRIVATE
bool ImplIsAntiparallel() const ;
1248 void ReMirror( Point
&rPoint
) const;
1249 void ReMirror( tools::Rectangle
&rRect
) const;
1250 SAL_DLLPRIVATE
void ReMirror( vcl::Region
&rRegion
) const;
1251 SAL_DLLPRIVATE
bool ImplIsRecordLayout() const;
1252 virtual bool HasMirroredGraphics() const;
1253 std::unique_ptr
<SalLayout
> ImplLayout(
1254 const OUString
&, sal_Int32 nIndex
, sal_Int32 nLen
, const Point
& rLogicPos
= Point(0, 0),
1255 tools::Long nLogicWidth
= 0, KernArraySpan aKernArray
= KernArraySpan(),
1256 std::span
<const sal_Bool
> pKashidaArray
= {}, SalLayoutFlags flags
= SalLayoutFlags::NONE
,
1257 vcl::text::TextLayoutCache
const* = nullptr, const SalLayoutGlyphs
* pGlyphs
= nullptr,
1258 std::optional
<sal_Int32
> nDrawOriginCluster
= std::nullopt
,
1259 std::optional
<sal_Int32
> nDrawMinCharPos
= std::nullopt
,
1260 std::optional
<sal_Int32
> nDrawEndCharPos
= std::nullopt
) const;
1262 SAL_DLLPRIVATE
vcl::text::ImplLayoutArgs
ImplPrepareLayoutArgs( OUString
&, const sal_Int32 nIndex
, const sal_Int32 nLen
,
1264 SalLayoutFlags flags
= SalLayoutFlags::NONE
,
1265 vcl::text::TextLayoutCache
const* = nullptr) const;
1266 SAL_DLLPRIVATE
std::unique_ptr
<SalLayout
>
1267 ImplGlyphFallbackLayout( std::unique_ptr
<SalLayout
>,
1268 vcl::text::ImplLayoutArgs
&,
1269 const SalLayoutGlyphs
* ) const;
1270 SAL_DLLPRIVATE
std::unique_ptr
<SalLayout
>
1272 LogicalFontInstance
* pLogicalFont
, int nFallbackLevel
,
1273 vcl::text::ImplLayoutArgs
& rLayoutArgs
, const SalLayoutGlyphs
* ) const;
1276 These functions allow collecting information on how fonts are mapped when used, such as what
1277 replacements are used when a requested font is missing or which fonts are used as fallbacks
1278 when a font doesn't provide all necessary glyphs.
1279 After StartTrackingFontMappingUse() is called, VCL starts collecting font usage for all
1280 text layout calls, FinishTrackingFontMappingUse() will stop collecting and providing
1281 the collected information.
1282 Each item is a mapping from a requested font to a list of actually used fonts and the number
1283 of times this mapping was done.
1285 struct FontMappingUseItem
1287 OUString mOriginalFont
;
1288 std::vector
<OUString
> mUsedFonts
;
1291 typedef std::vector
<FontMappingUseItem
> FontMappingUseData
;
1292 static void StartTrackingFontMappingUse();
1293 static FontMappingUseData
FinishTrackingFontMappingUse();
1295 // Enabling/disabling RTL only makes sense for OutputDevices that use a mirroring SalGraphicsLayout
1296 virtual void EnableRTL( bool bEnable
= true);
1297 bool IsRTLEnabled() const { return mbEnableRTL
; }
1299 bool GetTextIsRTL( const OUString
&, sal_Int32 nIndex
, sal_Int32 nLen
) const;
1304 /** @name Bitmap functions
1310 const Point
& rDestPt
,
1311 const Bitmap
& rBitmap
);
1314 const Point
& rDestPt
,
1315 const Size
& rDestSize
,
1316 const Bitmap
& rBitmap
);
1319 const Point
& rDestPt
,
1320 const Size
& rDestSize
,
1321 const Point
& rSrcPtPixel
,
1322 const Size
& rSrcSizePixel
,
1323 const Bitmap
& rBitmap
);
1326 const Point
& rDestPt
,
1327 const Size
& rDestSize
,
1328 const Point
& rSrcPtPixel
,
1329 const Size
& rSrcSizePixel
,
1330 const Bitmap
& rBitmap
,
1331 MetaActionType nAction
);
1334 const Point
& rDestPt
,
1335 const BitmapEx
& rBitmapEx
);
1339 const Point
& rDestPt
,
1340 const Size
& rDestSize
,
1341 const BitmapEx
& rBitmapEx
);
1344 const Point
& rDestPt
,
1345 const Size
& rDestSize
,
1346 const Point
& rSrcPtPixel
,
1347 const Size
& rSrcSizePixel
,
1348 const BitmapEx
& rBitmapEx
);
1350 SAL_DLLPRIVATE
void DrawBitmapEx(
1351 const Point
& rDestPt
,
1352 const Size
& rDestSize
,
1353 const Point
& rSrcPtPixel
,
1354 const Size
& rSrcSizePixel
,
1355 const BitmapEx
& rBitmapEx
,
1356 MetaActionType nAction
);
1359 virtual void DrawImage(
1362 const Image& rImage,
1363 sal_uInt16 nStyle = 0)
1367 const Image
& rImage
,
1368 DrawImageFlags nStyle
= DrawImageFlags::NONE
);
1373 const Image
& rImage
,
1374 DrawImageFlags nStyle
= DrawImageFlags::NONE
);
1377 virtual Bitmap
GetBitmap( const Point
& rSrcPt
, const Size
& rSize
) const;
1379 /** Query extended bitmap (with alpha channel, if available).
1381 BitmapEx
GetBitmapEx( const Point
& rSrcPt
, const Size
& rSize
) const;
1384 /** Draw BitmapEx transformed
1386 @param rTransformation
1387 The transformation describing the target positioning of the given bitmap. Transforming
1388 the unit object coordinates (0, 0, 1, 1) with this matrix is the transformation to
1389 discrete coordinates
1392 The BitmapEx to be painted
1395 Optional additional alpha to use for drawing (0 to 1, 1 being no change).
1397 void DrawTransformedBitmapEx(
1398 const basegfx::B2DHomMatrix
& rTransformation
,
1399 const BitmapEx
& rBitmapEx
,
1400 double fAlpha
= 1.0);
1402 /** Return true if DrawTransformedBitmapEx() is fast.
1406 bool HasFastDrawTransformedBitmap() const;
1410 virtual void DrawDeviceBitmapEx(
1411 const Point
& rDestPt
, const Size
& rDestSize
,
1412 const Point
& rSrcPtPixel
, const Size
& rSrcSizePixel
,
1413 BitmapEx
& rBitmapEx
);
1415 virtual bool CanSubsampleBitmap() const { return true; }
1417 /** Transform and draw a bitmap directly
1419 @param aFullTransform The B2DHomMatrix used for the transformation
1420 @param rBitmapEx Reference to the bitmap to be transformed and drawn
1422 @return true if it was able to draw the bitmap, false if not
1424 virtual bool DrawTransformBitmapExDirect(
1425 const basegfx::B2DHomMatrix
& aFullTransform
,
1426 const BitmapEx
& rBitmapEx
,
1427 double fAlpha
= 1.0);
1429 /** Transform and reduce the area that needs to be drawn of the bitmap and return the new
1430 visible range and the maximum area.
1433 @param aFullTransform B2DHomMatrix used for transformation
1434 @param aVisibleRange The new visible area of the bitmap
1435 @param fMaximumArea The maximum area of the bitmap
1437 @returns true if there is an area to be drawn, otherwise nothing is left to be drawn
1440 virtual bool TransformAndReduceBitmapExToTargetRange(
1441 const basegfx::B2DHomMatrix
& aFullTransform
,
1442 basegfx::B2DRange
&aVisibleRange
,
1443 double &fMaximumArea
);
1447 SAL_DLLPRIVATE
void DrawDeviceAlphaBitmap(
1449 const AlphaMask
& rAlpha
,
1450 const Point
& rDestPt
,
1451 const Size
& rDestSize
,
1452 const Point
& rSrcPtPixel
,
1453 const Size
& rSrcSizePixel
);
1455 SAL_DLLPRIVATE
void DrawDeviceAlphaBitmapSlowPath(
1456 const Bitmap
& rBitmap
, const AlphaMask
& rAlpha
,
1457 tools::Rectangle aDstRect
, tools::Rectangle aBmpRect
,
1458 Size
const & aOutSz
, Point
const & aOutPt
);
1461 SAL_DLLPRIVATE
void BlendBitmap(
1462 const SalTwoRect
& rPosAry
,
1463 const Bitmap
& rBmp
);
1465 SAL_DLLPRIVATE Bitmap
BlendBitmap(
1467 BitmapReadAccess
const * pP
,
1468 BitmapReadAccess
const * pA
,
1469 const sal_Int32 nOffY
,
1470 const sal_Int32 nDstHeight
,
1471 const sal_Int32 nOffX
,
1472 const sal_Int32 nDstWidth
,
1473 const tools::Rectangle
& aBmpRect
,
1477 const sal_Int32
* pMapX
,
1478 const sal_Int32
* pMapY
);
1480 SAL_DLLPRIVATE Bitmap
BlendBitmapWithAlpha(
1482 BitmapReadAccess
const * pP
,
1483 BitmapReadAccess
const * pA
,
1484 const tools::Rectangle
& aDstRect
,
1485 const sal_Int32 nOffY
,
1486 const sal_Int32 nDstHeight
,
1487 const sal_Int32 nOffX
,
1488 const sal_Int32 nDstWidth
,
1489 const sal_Int32
* pMapX
,
1490 const sal_Int32
* pMapY
);
1495 /** @name Transparency functions
1501 /** helper method removing transparencies from a metafile (e.g. for printing)
1504 true: transparencies were removed
1505 false: output metafile is unchanged input metafile
1507 @attention this is a member method, so current state can influence the result !
1508 @attention the output metafile is prepared in pixel mode for the currentOutputDevice
1509 state. It can not be moved or rotated reliably anymore.
1511 bool RemoveTransparenciesFromMetaFile(
1512 const GDIMetaFile
& rInMtf
, GDIMetaFile
& rOutMtf
,
1513 tools::Long nMaxBmpDPIX
, tools::Long nMaxBmpDPIY
,
1514 bool bReduceTransparency
,
1515 bool bTransparencyAutoMode
,
1516 bool bDownsampleBitmaps
,
1517 const Color
& rBackground
= COL_TRANSPARENT
);
1519 void DrawTransparent( const tools::PolyPolygon
& rPolyPoly
, sal_uInt16 nTransparencePercent
);
1521 void DrawTransparent(
1522 const basegfx::B2DHomMatrix
& rObjectTransform
,
1523 const basegfx::B2DPolyPolygon
& rB2DPolyPoly
,
1524 double fTransparency
);
1526 void DrawTransparent(
1527 const GDIMetaFile
& rMtf
, const Point
& rPos
, const Size
& rSize
,
1528 const Gradient
& rTransparenceGradient
);
1530 void DrawTransparent(
1531 const GDIMetaFile
& rMtf
, const Point
& rPos
, const Size
& rSize
,
1532 const Point
& rMtfPos
, const Size
& rMtfSize
,
1533 const Gradient
& rTransparenceGradient
);
1537 virtual void EmulateDrawTransparent( const tools::PolyPolygon
& rPolyPoly
, sal_uInt16 nTransparencePercent
);
1539 virtual void ClipAndDrawGradientMetafile ( const Gradient
&rGradient
, const tools::PolyPolygon
&rPolyPoly
);
1543 SAL_DLLPRIVATE
bool DrawTransparentNatively( const tools::PolyPolygon
& rPolyPoly
, sal_uInt16 nTransparencePercent
);
1547 /** @name Mask functions
1553 void DrawMask( const Point
& rDestPt
,
1554 const Bitmap
& rBitmap
, const Color
& rMaskColor
);
1556 void DrawMask( const Point
& rDestPt
, const Size
& rDestSize
,
1557 const Bitmap
& rBitmap
, const Color
& rMaskColor
);
1559 SAL_DLLPRIVATE
void DrawMask( const Point
& rDestPt
, const Size
& rDestSize
,
1560 const Point
& rSrcPtPixel
, const Size
& rSrcSizePixel
,
1561 const Bitmap
& rBitmap
, const Color
& rMaskColor
);
1563 void DrawMask( const Point
& rDestPt
, const Size
& rDestSize
,
1564 const Point
& rSrcPtPixel
, const Size
& rSrcSizePixel
,
1565 const Bitmap
& rBitmap
, const Color
& rMaskColor
,
1566 MetaActionType nAction
);
1570 virtual void DrawDeviceMask (
1571 const Bitmap
& rMask
, const Color
& rMaskColor
,
1572 const Point
& rDestPt
, const Size
& rDestSize
,
1573 const Point
& rSrcPtPixel
, const Size
& rSrcSizePixel
);
1577 /** @name Map functions
1583 void EnableMapMode( bool bEnable
= true );
1584 bool IsMapModeEnabled() const { return mbMap
; }
1587 void SetMapMode( const MapMode
& rNewMapMode
);
1588 void SetRelativeMapMode( const MapMode
& rNewMapMode
);
1589 virtual void SetMetafileMapMode(const MapMode
& rNewMapMode
, bool bIsRecord
);
1590 const MapMode
& GetMapMode() const { return maMapMode
; }
1593 virtual void ImplInitMapModeObjects();
1597 basegfx::B2DHomMatrix
GetViewTransformation() const;
1598 basegfx::B2DHomMatrix
GetInverseViewTransformation() const;
1600 SAL_DLLPRIVATE
basegfx::B2DHomMatrix
GetViewTransformation( const MapMode
& rMapMode
) const;
1601 basegfx::B2DHomMatrix
GetInverseViewTransformation( const MapMode
& rMapMode
) const;
1604 /** Set an offset in pixel
1606 This method offsets every drawing operation that converts its
1607 coordinates to pixel by the given value. Normally, the effect
1608 can be achieved by setting a MapMode with a different
1609 origin. Unfortunately, this origin is in logical coordinates
1610 and can lead to rounding errors (see #102532# for details).
1612 @attention This offset is only applied when converting to
1613 pixel, i.e. some output modes such as metafile recordings
1614 might be completely unaffected by this method! Use with
1615 care. Furthermore, if the OutputDevice's MapMode is the
1616 default (that's MapUnit::MapPixel), then any pixel offset set is
1617 ignored also. This might be unintuitive for cases, but would
1618 have been far more fragile to implement. What's more, the
1619 reason why the pixel offset was introduced (avoiding rounding
1620 errors) does not apply for MapUnit::MapPixel, because one can always
1621 use the MapMode origin then.
1626 void SetPixelOffset( const Size
& rOffset
);
1628 /** Get the offset in pixel
1630 @see OutputDevice::SetPixelOffset for details
1632 @return the current offset in pixel
1634 SAL_WARN_UNUSED_RESULT Size
GetPixelOffset() const { return Size(mnOutOffOrigX
, mnOutOffOrigY
);}
1636 SAL_WARN_UNUSED_RESULT Point
LogicToPixel(const Point
& rLogicPt
) const;
1637 SAL_WARN_UNUSED_RESULT Size
LogicToPixel(const Size
& rLogicSize
) const;
1638 SAL_WARN_UNUSED_RESULT
tools::Rectangle
LogicToPixel(const tools::Rectangle
& rLogicRect
) const;
1639 SAL_WARN_UNUSED_RESULT SAL_DLLPRIVATE
tools::Polygon
LogicToPixel(const tools::Polygon
& rLogicPoly
) const;
1640 SAL_WARN_UNUSED_RESULT SAL_DLLPRIVATE
tools::PolyPolygon
LogicToPixel(const tools::PolyPolygon
& rLogicPolyPoly
) const;
1641 SAL_WARN_UNUSED_RESULT SAL_DLLPRIVATE
basegfx::B2DPolyPolygon
LogicToPixel(const basegfx::B2DPolyPolygon
& rLogicPolyPoly
) const;
1642 SAL_WARN_UNUSED_RESULT
vcl::Region
LogicToPixel(const vcl::Region
& rLogicRegion
)const;
1643 SAL_WARN_UNUSED_RESULT Point
LogicToPixel(const Point
& rLogicPt
, const MapMode
& rMapMode
) const;
1644 SAL_WARN_UNUSED_RESULT Size
LogicToPixel(const Size
& rLogicSize
, const MapMode
& rMapMode
) const;
1645 SAL_WARN_UNUSED_RESULT
tools::Rectangle
LogicToPixel(const tools::Rectangle
& rLogicRect
,
1646 const MapMode
& rMapMode
) const;
1647 SAL_WARN_UNUSED_RESULT SAL_DLLPRIVATE
tools::Polygon
LogicToPixel(const tools::Polygon
& rLogicPoly
,
1648 const MapMode
& rMapMode
) const;
1649 SAL_WARN_UNUSED_RESULT SAL_DLLPRIVATE
basegfx::B2DPolyPolygon
LogicToPixel(const basegfx::B2DPolyPolygon
& rLogicPolyPoly
,
1650 const MapMode
& rMapMode
) const;
1652 SAL_WARN_UNUSED_RESULT Point
PixelToLogic(const Point
& rDevicePt
) const;
1653 SAL_WARN_UNUSED_RESULT Size
PixelToLogic(const Size
& rDeviceSize
) const;
1654 SAL_WARN_UNUSED_RESULT
tools::Rectangle
PixelToLogic(const tools::Rectangle
& rDeviceRect
) const;
1655 SAL_WARN_UNUSED_RESULT SAL_DLLPRIVATE
tools::Polygon
PixelToLogic(const tools::Polygon
& rDevicePoly
) const;
1656 SAL_WARN_UNUSED_RESULT SAL_DLLPRIVATE
tools::PolyPolygon
PixelToLogic(const tools::PolyPolygon
& rDevicePolyPoly
) const;
1657 SAL_WARN_UNUSED_RESULT SAL_DLLPRIVATE
basegfx::B2DPolyPolygon
PixelToLogic(const basegfx::B2DPolyPolygon
& rDevicePolyPoly
) const;
1658 SAL_WARN_UNUSED_RESULT SAL_DLLPRIVATE
basegfx::B2DRectangle
PixelToLogic(const basegfx::B2DRectangle
& rDeviceRect
) const;
1659 SAL_WARN_UNUSED_RESULT
vcl::Region
PixelToLogic(const vcl::Region
& rDeviceRegion
) const;
1660 SAL_WARN_UNUSED_RESULT Point
PixelToLogic(const Point
& rDevicePt
, const MapMode
& rMapMode
) const;
1661 SAL_WARN_UNUSED_RESULT Size
PixelToLogic(const Size
& rDeviceSize
, const MapMode
& rMapMode
) const;
1662 SAL_WARN_UNUSED_RESULT
tools::Rectangle
PixelToLogic(const tools::Rectangle
& rDeviceRect
,
1663 const MapMode
& rMapMode
) const;
1664 SAL_WARN_UNUSED_RESULT SAL_DLLPRIVATE
tools::Polygon
PixelToLogic(const tools::Polygon
& rDevicePoly
,
1665 const MapMode
& rMapMode
) const;
1666 SAL_WARN_UNUSED_RESULT SAL_DLLPRIVATE
basegfx::B2DPolygon
PixelToLogic(const basegfx::B2DPolygon
& rDevicePoly
,
1667 const MapMode
& rMapMode
) const;
1668 SAL_WARN_UNUSED_RESULT SAL_DLLPRIVATE
basegfx::B2DPolyPolygon
PixelToLogic(const basegfx::B2DPolyPolygon
& rDevicePolyPoly
,
1669 const MapMode
& rMapMode
) const;
1671 SAL_WARN_UNUSED_RESULT Point
LogicToLogic(const Point
& rPtSource
,
1672 const MapMode
* pMapModeSource
,
1673 const MapMode
* pMapModeDest
) const;
1674 SAL_WARN_UNUSED_RESULT Size
LogicToLogic(const Size
& rSzSource
,
1675 const MapMode
* pMapModeSource
,
1676 const MapMode
* pMapModeDest
) const;
1677 SAL_WARN_UNUSED_RESULT
tools::Rectangle
LogicToLogic(const tools::Rectangle
& rRectSource
,
1678 const MapMode
* pMapModeSource
,
1679 const MapMode
* pMapModeDest
) const;
1680 SAL_WARN_UNUSED_RESULT
static Point
LogicToLogic(const Point
& rPtSource
,
1681 const MapMode
& rMapModeSource
,
1682 const MapMode
& rMapModeDest
);
1683 SAL_WARN_UNUSED_RESULT
static Size
LogicToLogic(const Size
& rSzSource
,
1684 const MapMode
& rMapModeSource
,
1685 const MapMode
& rMapModeDest
);
1686 SAL_WARN_UNUSED_RESULT
static tools::Rectangle
LogicToLogic(const tools::Rectangle
& rRectSource
,
1687 const MapMode
& rMapModeSource
,
1688 const MapMode
& rMapModeDest
);
1689 SAL_WARN_UNUSED_RESULT
static tools::Long
LogicToLogic(tools::Long nLongSource
,
1690 MapUnit eUnitSource
,
1693 SAL_WARN_UNUSED_RESULT
static basegfx::B2DPolygon
LogicToLogic(const basegfx::B2DPolygon
& rPoly
,
1694 const MapMode
& rMapModeSource
,
1695 const MapMode
& rMapModeDest
);
1697 // create a mapping transformation from rMapModeSource to rMapModeDest (the above methods
1698 // for B2DPoly/Polygons use this internally anyway to transform the B2DPolygon)
1699 SAL_WARN_UNUSED_RESULT
static basegfx::B2DHomMatrix
LogicToLogic(const MapMode
& rMapModeSource
,
1700 const MapMode
& rMapModeDest
);
1702 /** Convert a logical rectangle to a rectangle in physical device pixel units.
1704 @param rLogicRect Const reference to a rectangle in logical units
1706 @returns Rectangle based on physical device pixel coordinates and units.
1708 SAL_DLLPRIVATE
tools::Rectangle
ImplLogicToDevicePixel( const tools::Rectangle
& rLogicRect
) const;
1710 /** Convert a logical point to a physical point on the device.
1712 @param rLogicPt Const reference to a point in logical units.
1714 @returns Physical point on the device.
1716 SAL_DLLPRIVATE Point
ImplLogicToDevicePixel( const Point
& rLogicPt
) const;
1717 SAL_DLLPRIVATE
basegfx::B2DPoint
ImplLogicToDeviceSubPixel(const Point
& rLogicPt
) const;
1719 /** Convert a logical width to a width in units of device pixels.
1721 To get the number of device pixels, it must calculate the X-DPI of the device and
1722 the map scaling factor. If there is no mapping, then it just returns the
1723 width as nothing more needs to be done.
1725 @param nWidth Logical width
1727 @returns Width in units of device pixels.
1729 SAL_DLLPRIVATE
tools::Long
ImplLogicWidthToDevicePixel( tools::Long nWidth
) const;
1730 SAL_DLLPRIVATE
double ImplLogicWidthToDeviceSubPixel(tools::Long nWidth
) const;
1732 /** Convert a logical height to a height in units of device pixels.
1734 To get the number of device pixels, it must calculate the Y-DPI of the device and
1735 the map scaling factor. If there is no mapping, then it just returns the
1736 height as nothing more needs to be done.
1738 @param nHeight Logical height
1740 @returns Height in units of device pixels.
1742 SAL_DLLPRIVATE
tools::Long
ImplLogicHeightToDevicePixel( tools::Long nHeight
) const;
1743 SAL_DLLPRIVATE
double ImplLogicHeightToDeviceSubPixel(tools::Long nHeight
) const;
1745 SAL_DLLPRIVATE Point
SubPixelToLogic(const basegfx::B2DPoint
& rDevicePt
) const;
1747 /** Convert device pixels to a width in logical units.
1749 To get the logical width, it must calculate the X-DPI of the device and the
1752 @param nWidth Width in device pixels
1754 @returns Width in logical units.
1756 SAL_DLLPRIVATE
tools::Long
ImplDevicePixelToLogicWidth( tools::Long nWidth
) const;
1758 /** Convert device pixels to a height in logical units.
1760 To get the logical height, it must calculate the Y-DPI of the device and the
1763 @param nHeight Height in device pixels
1765 @returns Height in logical units.
1767 SAL_DLLPRIVATE
tools::Long
ImplDevicePixelToLogicHeight( tools::Long nHeight
) const;
1769 /** Convert a logical size to the size on the physical device.
1771 @param rLogicSize Const reference to a size in logical units
1773 @returns Physical size on the device.
1775 SAL_DLLPRIVATE Size
ImplLogicToDevicePixel( const Size
& rLogicSize
) const;
1777 /** Convert a rectangle in physical pixel units to a rectangle in physical pixel units and coords.
1779 @param rPixelRect Const reference to rectangle in logical units and coords.
1781 @returns Rectangle based on logical coordinates and units.
1783 SAL_DLLPRIVATE
tools::Rectangle
ImplDevicePixelToLogic( const tools::Rectangle
& rPixelRect
) const;
1785 /** Convert a logical polygon to a polygon in physical device pixel units.
1787 @param rLogicPoly Const reference to a polygon in logical units
1789 @returns Polygon based on physical device pixel coordinates and units.
1791 SAL_DLLPRIVATE
tools::Polygon
ImplLogicToDevicePixel( const tools::Polygon
& rLogicPoly
) const;
1793 /** Convert a logical B2DPolygon to a B2DPolygon in physical device pixel units.
1795 @param rLogicSize Const reference to a B2DPolygon in logical units
1797 @returns B2DPolyPolygon based on physical device pixel coordinates and units.
1799 SAL_DLLPRIVATE ::basegfx::B2DPolygon
ImplLogicToDevicePixel( const ::basegfx::B2DPolygon
& rLogicPoly
) const;
1801 /** Convert a logical polypolygon to a polypolygon in physical device pixel units.
1803 @param rLogicPolyPoly Const reference to a polypolygon in logical units
1805 @returns Polypolygon based on physical device pixel coordinates and units.
1807 SAL_DLLPRIVATE
tools::PolyPolygon
ImplLogicToDevicePixel( const tools::PolyPolygon
& rLogicPolyPoly
) const;
1809 /** Convert a line in logical units to a line in physical device pixel units.
1811 @param rLineInfo Const reference to a line in logical units
1813 @returns Line based on physical device pixel coordinates and units.
1815 SAL_DLLPRIVATE LineInfo
ImplLogicToDevicePixel( const LineInfo
& rLineInfo
) const;
1817 /** Convert a region in pixel units to a region in device pixel units and coords.
1819 @param rRegion Const reference to region.
1821 @returns vcl::Region based on device pixel coordinates and units.
1823 SAL_DLLPRIVATE
vcl::Region
ImplPixelToDevicePixel( const vcl::Region
& rRegion
) const;
1825 /** Invalidate the view transformation.
1827 @since AOO bug 75163 (OpenOffice.org 2.4.3 - OOH 680 milestone 212)
1829 SAL_DLLPRIVATE
void ImplInvalidateViewTransform();
1831 /** Get device transformation.
1833 @since AOO bug 75163 (OpenOffice.org 2.4.3 - OOH 680 milestone 212)
1835 SAL_DLLPRIVATE
basegfx::B2DHomMatrix
ImplGetDeviceTransformation() const;
1838 /** Convert a logical X coordinate to a device pixel's X coordinate.
1840 To get the device's X coordinate, it must calculate the mapping offset
1841 coordinate X position (if there is one - if not then it just adds
1842 the pseudo-window offset to the logical X coordinate), the X-DPI of
1843 the device and the mapping's X scaling factor.
1845 @param nX Logical X coordinate
1847 @returns Device's X pixel coordinate
1849 SAL_DLLPRIVATE
tools::Long
ImplLogicXToDevicePixel( tools::Long nX
) const;
1851 /** Convert a logical Y coordinate to a device pixel's Y coordinate.
1853 To get the device's Y coordinate, it must calculate the mapping offset
1854 coordinate Y position (if there is one - if not then it just adds
1855 the pseudo-window offset to the logical Y coordinate), the Y-DPI of
1856 the device and the mapping's Y scaling factor.
1858 @param nY Logical Y coordinate
1860 @returns Device's Y pixel coordinate
1862 SAL_DLLPRIVATE
tools::Long
ImplLogicYToDevicePixel( tools::Long nY
) const;
1864 SAL_DLLPRIVATE
double ImplDevicePixelToLogicWidthDouble(double nWidth
) const;
1865 SAL_DLLPRIVATE
double ImplDevicePixelToLogicHeightDouble(double nHeight
) const;
1867 /** @name Native Widget Rendering functions
1869 These all just call through to the private mpGraphics functions of the same name.
1875 /** Determine if native widgets can be enabled
1877 virtual bool CanEnableNativeWidget() const { return false; }
1879 /** Query the platform layer for control support
1881 bool IsNativeControlSupported( ControlType nType
, ControlPart nPart
) const;
1883 /** Query the native control to determine if it was acted upon
1885 SAL_DLLPRIVATE
bool HitTestNativeScrollbar(
1887 const tools::Rectangle
& rControlRegion
,
1889 bool& rIsInside
) const;
1891 /** Request rendering of a particular control and/or part
1893 bool DrawNativeControl(
1896 const tools::Rectangle
& rControlRegion
,
1897 ControlState nState
,
1898 const ImplControlValue
& aValue
,
1899 const OUString
& aCaption
,
1900 const Color
& rBackgroundColor
= COL_AUTO
);
1902 /** Query the native control's actual drawing region (including adornment)
1904 bool GetNativeControlRegion(
1907 const tools::Rectangle
& rControlRegion
,
1908 ControlState nState
,
1909 const ImplControlValue
& aValue
,
1910 tools::Rectangle
&rNativeBoundingRegion
,
1911 tools::Rectangle
&rNativeContentRegion
) const;
1914 /** @name EPS functions
1920 /** @returns boolean value to see if EPS could be painted directly.
1921 Theoretically, handing over a matrix would be needed to handle
1922 painting rotated EPS files (e.g. contained in Metafiles). This
1923 would then need to be supported for Mac and PS printers, but
1924 that's too much for now, wrote \#i107046# for this */
1926 const Point
& rPt
, const Size
& rSz
,
1927 const GfxLink
& rGfxLink
, GDIMetaFile
* pSubst
= nullptr );
1931 virtual css::awt::DeviceInfo
GetDeviceInfo() const;
1933 /** Get the vcl::Window that this OutputDevice belongs to, if any */
1934 virtual vcl::Window
* GetOwnerWindow() const { return nullptr; }
1937 SAL_DLLPRIVATE
css::awt::DeviceInfo
GetCommonDeviceInfo(Size
const& aDevSize
) const;
1941 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */