Fix typo
[LibreOffice.git] / include / vcl / outdev.hxx
blobeefb2c6028e4840b8d919c12166f1dc41bd58d3c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #pragma once
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/numeric/ftools.hxx>
57 #include <basegfx/point/b2dpoint.hxx>
58 #include <basegfx/vector/b2enums.hxx>
59 #include <basegfx/polygon/b2dpolypolygon.hxx>
61 #include <unotools/fontdefs.hxx>
62 #include <cppuhelper/weakref.hxx>
64 #include <com/sun/star/drawing/LineCap.hpp>
65 #include <com/sun/star/uno/Reference.h>
66 #include <com/sun/star/awt/DeviceInfo.hpp>
68 #include <memory>
69 #include <optional>
70 #include <span>
71 #include <string_view>
72 #include <vector>
74 struct ImplOutDevData;
75 class LogicalFontInstance;
76 struct SystemGraphicsData;
77 class ImplFontCache;
78 class ImplMultiTextLineInfo;
79 class SalGraphics;
80 class Gradient;
81 class Hatch;
82 class BitmapReadAccess;
83 class BitmapEx;
84 class Image;
85 class TextRectInfo;
86 class FontMetric;
87 class GDIMetaFile;
88 class GfxLink;
89 namespace tools {
90 class Line;
92 class LineInfo;
93 class AlphaMask;
94 class FontCharMap;
95 class SalLayout;
96 class VirtualDevice;
97 struct SalTwoRect;
98 class Printer;
99 class VCLXGraphics;
100 class OutDevStateStack;
101 class SalLayoutGlyphs;
103 namespace vcl
105 class ExtOutDevData;
106 class TextLayoutCommon;
107 struct FontCapabilities;
108 class Window;
109 class WindowOutputDevice;
110 namespace font {
111 struct Feature;
112 class PhysicalFontCollection;
113 class PhysicalFontFaceCollection;
116 namespace text {
117 class ImplLayoutArgs;
118 class TextLayoutCache;
122 namespace basegfx {
123 class B2DHomMatrix;
124 class B2DPolygon;
125 class B2IVector;
126 class B2ISize;
129 namespace com::sun::star::awt {
130 class XGraphics;
133 namespace com::sun::star::rendering {
134 class XCanvas;
135 class XSpriteCanvas;
137 namespace com::sun::star::linguistic2 {
138 class XHyphenator;
140 namespace com::sun::star::i18n {
141 class XBreakIterator;
144 // OutputDevice-Types
146 enum OutDevType { OUTDEV_WINDOW, OUTDEV_PRINTER, OUTDEV_VIRDEV, OUTDEV_PDF };
148 enum class OutDevViewType { DontKnow, PrintPreview, SlideShow };
150 // OutputDevice
152 typedef tools::SvRef<FontCharMap> FontCharMapRef;
154 BmpMirrorFlags AdjustTwoRect( SalTwoRect& rTwoRect, const Size& rSizePix );
155 void AdjustTwoRect( SalTwoRect& rTwoRect, const tools::Rectangle& rValidSrcRect );
157 class OutputDevice;
159 namespace vcl {
160 typedef OutputDevice RenderContext;
163 VCL_DLLPUBLIC void InvertFocusRect(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect);
166 * Some things multiple-inherit from VclAbstractDialog and OutputDevice,
167 * so we need to use virtual inheritance to keep the referencing counting
168 * OK.
170 class SAL_WARN_UNUSED VCL_DLLPUBLIC OutputDevice : public virtual VclReferenceBase
172 friend class Printer;
173 friend class VirtualDevice;
174 friend class vcl::Window;
175 friend class vcl::WindowOutputDevice;
176 friend class WorkWindow;
177 friend void ImplHandleResize( vcl::Window* pWindow, tools::Long nNewWidth, tools::Long nNewHeight );
179 private:
180 OutputDevice(const OutputDevice&) = delete;
181 OutputDevice& operator=(const OutputDevice&) = delete;
183 mutable SalGraphics* mpGraphics; ///< Graphics context to draw on
184 mutable VclPtr<OutputDevice> mpPrevGraphics; ///< Previous output device in list
185 mutable VclPtr<OutputDevice> mpNextGraphics; ///< Next output device in list
186 GDIMetaFile* mpMetaFile;
187 mutable rtl::Reference<LogicalFontInstance> mpFontInstance;
188 rtl::Reference<LogicalFontInstance> mpForcedFallbackInstance;
189 mutable std::unique_ptr<vcl::font::PhysicalFontFaceCollection> mpFontFaceCollection;
190 std::vector<vcl::State> maOutDevStateStack;
191 std::unique_ptr<ImplOutDevData> mpOutDevData;
192 std::vector< VCLXGraphics* >* mpUnoGraphicsList;
193 vcl::ExtOutDevData* mpExtOutDevData;
194 // The canvas interface for this output device. Is persistent after the first GetCanvas() call
195 mutable css::uno::WeakReference< css::rendering::XCanvas > mxCanvas;
197 // TEMP TEMP TEMP
198 VclPtr<VirtualDevice> mpAlphaVDev;
200 /// Additional output pixel offset, applied in LogicToPixel (used by SetPixelOffset/GetPixelOffset)
201 tools::Long mnOutOffOrigX;
202 /// Additional output offset in _logical_ coordinates, applied in PixelToLogic (used by SetPixelOffset/GetPixelOffset)
203 tools::Long mnOutOffLogicX;
204 /// Additional output pixel offset, applied in LogicToPixel (used by SetPixelOffset/GetPixelOffset)
205 tools::Long mnOutOffOrigY;
206 /// Additional output offset in _logical_ coordinates, applied in PixelToLogic (used by SetPixelOffset/GetPixelOffset)
207 tools::Long mnOutOffLogicY;
208 /// Output offset for device output in pixel (pseudo window offset within window system's frames)
209 tools::Long mnOutOffX;
210 /// Output offset for device output in pixel (pseudo window offset within window system's frames)
211 tools::Long mnOutOffY;
212 tools::Long mnOutWidth;
213 tools::Long mnOutHeight;
214 sal_Int32 mnDPIX;
215 sal_Int32 mnDPIY;
216 sal_Int32 mnDPIScalePercentage; ///< For HiDPI displays, we want to draw elements for a percentage larger
217 /// font specific text alignment offsets in pixel units
218 mutable tools::Long mnTextOffX;
219 mutable tools::Long mnTextOffY;
220 mutable tools::Long mnEmphasisAscent;
221 mutable tools::Long mnEmphasisDescent;
222 DrawModeFlags mnDrawMode;
223 vcl::text::ComplexTextLayoutFlags mnTextLayoutMode;
224 ImplMapRes maMapRes;
225 const OutDevType meOutDevType;
226 OutDevViewType meOutDevViewType;
227 vcl::Region maRegion; // contains the clip region, see SetClipRegion(...)
228 Color maLineColor;
229 Color maFillColor;
230 vcl::Font maFont;
231 Color maTextColor;
232 Color maTextLineColor;
233 Color maOverlineColor;
234 RasterOp meRasterOp;
235 Wallpaper maBackground;
236 std::optional<AllSettings> moSettings;
237 MapMode maMapMode;
238 Point maRefPoint;
239 AntialiasingFlags mnAntialiasing;
240 LanguageType meTextLanguage;
242 mutable bool mbMap : 1;
243 mutable bool mbClipRegion : 1;
244 mutable bool mbBackground : 1;
245 mutable bool mbOutput : 1;
246 mutable bool mbDevOutput : 1;
247 mutable bool mbOutputClipped : 1;
248 mutable bool mbLineColor : 1;
249 mutable bool mbFillColor : 1;
250 mutable bool mbInitLineColor : 1;
251 mutable bool mbInitFillColor : 1;
252 mutable bool mbInitFont : 1;
253 mutable bool mbInitTextColor : 1;
254 mutable bool mbInitClipRegion : 1;
255 mutable bool mbClipRegionSet : 1;
256 mutable bool mbNewFont : 1;
257 mutable bool mbTextLines : 1;
258 mutable bool mbTextSpecial : 1;
259 mutable bool mbRefPoint : 1;
260 mutable bool mbEnableRTL : 1;
262 protected:
263 mutable std::shared_ptr<vcl::font::PhysicalFontCollection> mxFontCollection;
264 mutable std::shared_ptr<ImplFontCache> mxFontCache;
266 /** @name Initialization and accessor functions
268 ///@{
270 protected:
271 OutputDevice(OutDevType eOutDevType);
272 virtual ~OutputDevice() override;
273 virtual void dispose() override;
275 public:
277 /** Get the graphic context that the output device uses to draw on.
279 If no graphics device exists, then initialize it.
281 @returns SalGraphics instance.
283 SalGraphics const *GetGraphics() const;
284 SalGraphics* GetGraphics();
286 void SetConnectMetaFile( GDIMetaFile* pMtf );
287 GDIMetaFile* GetConnectMetaFile() const { return mpMetaFile; }
289 virtual void SetSettings( const AllSettings& rSettings );
290 const AllSettings& GetSettings() const { return *moSettings; }
292 SystemGraphicsData GetSystemGfxData() const;
293 OUString GetRenderBackendName() const;
295 // Used by the canvas module. Despite the name it does not always return true if Cairo is supported.
296 bool SupportsCairo() const;
297 /// Create Surface from given cairo surface
298 cairo::SurfaceSharedPtr CreateSurface(const cairo::CairoSurfaceSharedPtr& rSurface) const;
299 /// Create surface with given dimensions
300 cairo::SurfaceSharedPtr CreateSurface(int x, int y, int width, int height) const;
301 /// Create Surface for given bitmap data
302 cairo::SurfaceSharedPtr CreateBitmapSurface(const BitmapSystemData& rData, const Size& rSize) const;
303 /// Return native handle for underlying surface
304 css::uno::Any GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& rSurface, const basegfx::B2ISize& rSize) const;
305 css::uno::Any GetSystemGfxDataAny() const;
307 void SetRefPoint();
308 void SetRefPoint( const Point& rRefPoint );
309 const Point& GetRefPoint() const { return maRefPoint; }
310 bool IsRefPoint() const { return mbRefPoint; }
312 virtual bool IsScreenComp() const { return true; }
314 virtual sal_uInt16 GetBitCount() const;
316 Size GetOutputSizePixel() const
317 { return Size( mnOutWidth, mnOutHeight ); }
318 tools::Long GetOutputWidthPixel() const { return mnOutWidth; }
319 tools::Long GetOutputHeightPixel() const { return mnOutHeight; }
320 tools::Long GetOutOffXPixel() const { return mnOutOffX; }
321 tools::Long GetOutOffYPixel() const { return mnOutOffY; }
322 void SetOutOffXPixel(tools::Long nOutOffX);
323 void SetOutOffYPixel(tools::Long nOutOffY);
324 Point GetOutputOffPixel() const
325 { return Point( mnOutOffX, mnOutOffY ); }
326 tools::Rectangle GetOutputRectPixel() const
327 { return tools::Rectangle(GetOutputOffPixel(), GetOutputSizePixel() ); }
329 Size GetOutputSize() const
330 { return PixelToLogic( GetOutputSizePixel() ); }
332 css::uno::Reference< css::awt::XGraphics >
333 CreateUnoGraphics();
334 std::vector< VCLXGraphics* > *GetUnoGraphicsList() const { return mpUnoGraphicsList; }
335 std::vector< VCLXGraphics* > *CreateUnoGraphicsList();
337 virtual size_t GetSyncCount() const { return 0xffffffff; }
339 /// request XCanvas render interface
340 css::uno::Reference< css::rendering::XCanvas > GetCanvas() const;
341 /// request XSpriteCanvas render interface
342 css::uno::Reference< css::rendering::XSpriteCanvas > GetSpriteCanvas() const;
344 protected:
346 /** Acquire a graphics device that the output device uses to draw on.
348 There is an LRU of OutputDevices that is used to get the graphics. The
349 actual creation of a SalGraphics instance is done via the SalFrame
350 implementation.
352 However, the SalFrame instance will only return a valid SalGraphics
353 instance if it is not in use or there wasn't one in the first place. When
354 this happens, AcquireGraphics finds the least recently used OutputDevice
355 in a different frame and "steals" it (releases it then starts using it).
357 If there are no frames to steal an OutputDevice's SalGraphics instance from
358 then it blocks until the graphics is released.
360 Once it has acquired a graphics instance, then we add the OutputDevice to
361 the LRU.
363 @returns true if was able to initialize the graphics device, false otherwise.
365 virtual bool AcquireGraphics() const = 0;
367 /** Release the graphics device, and remove it from the graphics device
368 list.
370 @param bRelease Determines whether to release the fonts of the
371 physically released graphics device.
373 virtual void ReleaseGraphics( bool bRelease = true ) = 0;
374 ///@}
377 /** @name Helper functions
379 ///@{
381 public:
383 /** Get the output device's DPI x-axis value.
385 @returns x-axis DPI value
387 SAL_DLLPRIVATE sal_Int32 GetDPIX() const { return mnDPIX; }
389 /** Get the output device's DPI y-axis value.
391 @returns y-axis DPI value
393 SAL_DLLPRIVATE sal_Int32 GetDPIY() const { return mnDPIY; }
395 SAL_DLLPRIVATE void SetDPIX( sal_Int32 nDPIX ) { mnDPIX = nDPIX; }
396 SAL_DLLPRIVATE void SetDPIY( sal_Int32 nDPIY ) { mnDPIY = nDPIY; }
398 float GetDPIScaleFactor() const
400 return mnDPIScalePercentage / 100.0f;
403 sal_Int32 GetDPIScalePercentage() const
405 return mnDPIScalePercentage;
408 OutDevType GetOutDevType() const { return meOutDevType; }
409 virtual bool IsVirtual() const;
411 /** Query an OutputDevice to see whether it supports a specific operation
413 @returns true if operation supported, else false
415 bool SupportsOperation( OutDevSupportType ) const;
417 void SetExtOutDevData( vcl::ExtOutDevData* pExtOutDevData ) { mpExtOutDevData = pExtOutDevData; }
418 vcl::ExtOutDevData* GetExtOutDevData() const { return mpExtOutDevData; }
420 ///@}
422 public:
423 virtual Size GetButtonBorderSize() { return Size(1, 1); };
424 virtual Color GetMonochromeButtonColor() { return COL_WHITE; }
426 /** @name Direct OutputDevice drawing functions
428 ///@{
430 public:
431 virtual void Flush() {}
433 virtual void DrawOutDev(
434 const Point& rDestPt, const Size& rDestSize,
435 const Point& rSrcPt, const Size& rSrcSize );
437 virtual void DrawOutDev(
438 const Point& rDestPt, const Size& rDestSize,
439 const Point& rSrcPt, const Size& rSrcSize,
440 const OutputDevice& rOutDev );
442 virtual void CopyArea(
443 const Point& rDestPt,
444 const Point& rSrcPt, const Size& rSrcSize,
445 bool bWindowInvalidate = false );
447 protected:
449 virtual void CopyDeviceArea( SalTwoRect& aPosAry, bool bWindowInvalidate);
451 virtual tools::Rectangle GetBackgroundComponentBounds() const;
453 virtual const OutputDevice* DrawOutDevDirectCheck(const OutputDevice& rSrcDev) const;
455 virtual void DrawOutDevDirectProcess(const OutputDevice& rSrcDev, SalTwoRect& rPosAry, SalGraphics* pSrcGraphics);
457 SAL_DLLPRIVATE void drawOutDevDirect(const OutputDevice& rSrcDev, SalTwoRect& rPosAry);
459 SAL_DLLPRIVATE bool is_double_buffered_window() const;
461 virtual css::uno::Reference< css::rendering::XCanvas > ImplGetCanvas( bool bSpriteCanvas ) const;
462 SAL_DLLPRIVATE void ImplDisposeCanvas();
464 private:
466 // not implemented; to detect misuses of DrawOutDev(...OutputDevice&);
467 SAL_DLLPRIVATE void DrawOutDev( const Point&, const Size&, const Point&, const Size&, const Printer&) = delete;
468 ///@}
471 /** @name OutputDevice state functions
473 ///@{
475 public:
477 void Push( vcl::PushFlags nFlags = vcl::PushFlags::ALL );
478 void Pop();
479 void ClearStack();
481 void EnableOutput( bool bEnable = true );
482 bool IsOutputEnabled() const { return mbOutput; }
483 bool IsDeviceOutputNecessary() const { return (mbOutput && mbDevOutput); }
485 void SetAntialiasing( AntialiasingFlags nMode );
486 AntialiasingFlags GetAntialiasing() const { return mnAntialiasing; }
488 void SetDrawMode( DrawModeFlags nDrawMode );
489 DrawModeFlags GetDrawMode() const { return mnDrawMode; }
491 void SetLayoutMode( vcl::text::ComplexTextLayoutFlags nTextLayoutMode );
492 vcl::text::ComplexTextLayoutFlags GetLayoutMode() const { return mnTextLayoutMode; }
494 void SetDigitLanguage( LanguageType );
495 LanguageType GetDigitLanguage() const { return meTextLanguage; }
497 void SetRasterOp( RasterOp eRasterOp );
498 RasterOp GetRasterOp() const { return meRasterOp; }
501 If this OutputDevice is used for displaying a Print Preview
502 the OutDevViewType should be set to 'OutDevViewType::PrintPreview'.
504 A View can then make painting decisions dependent on this OutDevViewType.
505 E.g. text colors need to be handled differently, dependent on whether it's a PrintPreview or not. (see #106611# for more)
507 void SetOutDevViewType( OutDevViewType eOutDevViewType ) { meOutDevViewType=eOutDevViewType; }
508 OutDevViewType GetOutDevViewType() const { return meOutDevViewType; }
510 void SetLineColor();
511 void SetLineColor( const Color& rColor );
512 const Color& GetLineColor() const { return maLineColor; }
513 bool IsLineColor() const { return mbLineColor; }
515 void SetFillColor();
516 void SetFillColor( const Color& rColor );
517 const Color& GetFillColor() const { return maFillColor; }
518 bool IsFillColor() const { return mbFillColor; }
520 void SetBackground();
521 void SetBackground( const Wallpaper& rBackground );
522 virtual void SaveBackground(VirtualDevice& rSaveDevice,
523 const Point& rPos, const Size& rSize, const Size& rBackgroundSize) const;
525 const Wallpaper& GetBackground() const { return maBackground; }
526 virtual Color GetBackgroundColor() const;
527 virtual Color GetReadableFontColor(const Color& rFontColor, const Color& rBgColor) const;
528 bool IsBackground() const { return mbBackground; }
530 void SetFont( const vcl::Font& rNewFont );
531 const vcl::Font& GetFont() const { return maFont; }
533 protected:
535 virtual void ImplReleaseFonts();
537 private:
539 SAL_DLLPRIVATE void InitLineColor();
541 SAL_DLLPRIVATE void InitFillColor();
543 ///@}
546 /** @name Clipping functions
548 ///@{
550 public:
552 vcl::Region GetClipRegion() const;
553 void SetClipRegion();
554 void SetClipRegion( const vcl::Region& rRegion );
555 bool SelectClipRegion( const vcl::Region&, SalGraphics* pGraphics = nullptr );
557 bool IsClipRegion() const { return mbClipRegion; }
559 void MoveClipRegion( tools::Long nHorzMove, tools::Long nVertMove );
560 void IntersectClipRegion( const tools::Rectangle& rRect );
561 void IntersectClipRegion( const vcl::Region& rRegion );
563 virtual vcl::Region GetActiveClipRegion() const;
564 virtual vcl::Region GetOutputBoundsClipRegion() const;
566 protected:
568 virtual void InitClipRegion();
570 /** Perform actual rect clip against outdev dimensions, to generate
571 empty clips whenever one of the values is completely off the device.
573 @param aRegion region to be clipped to the device dimensions
574 @returns region clipped to the device bounds
576 virtual vcl::Region ClipToDeviceBounds(vcl::Region aRegion) const;
577 virtual void ClipToPaintRegion ( tools::Rectangle& rDstRect );
579 private:
581 SAL_DLLPRIVATE void SetDeviceClipRegion( const vcl::Region* pRegion );
582 ///@}
584 public:
585 virtual void DrawBorder(tools::Rectangle aBorderRect);
588 /** @name Pixel functions
590 ///@{
592 public:
594 void DrawPixel( const Point& rPt );
595 void DrawPixel( const Point& rPt, const Color& rColor );
597 Color GetPixel( const Point& rPt ) const;
598 ///@}
601 /** @name Rectangle functions
603 ///@{
605 public:
607 void DrawRect( const tools::Rectangle& rRect );
608 void DrawRect( const tools::Rectangle& rRect,
609 sal_uLong nHorzRount, sal_uLong nVertRound );
611 /// Fill the given rectangle with checkered rectangles of size nLen x nLen using the colors aStart and aEnd
612 void DrawCheckered(
613 const Point& rPos,
614 const Size& rSize,
615 sal_uInt32 nLen = 8,
616 Color aStart = COL_WHITE,
617 Color aEnd = COL_BLACK);
619 void DrawGrid( const tools::Rectangle& rRect, const Size& rDist, DrawGridFlags nFlags );
621 ///@}
623 /** @name Invert functions
625 ///@{
626 public:
627 void Invert( const tools::Rectangle& rRect, InvertFlags nFlags = InvertFlags::NONE );
628 void Invert( const tools::Polygon& rPoly, InvertFlags nFlags = InvertFlags::NONE );
629 ///@}
631 /** @name Line functions
633 ///@{
635 public:
637 void DrawLine( const Point& rStartPt, const Point& rEndPt );
639 void DrawLine( const Point& rStartPt, const Point& rEndPt,
640 const LineInfo& rLineInfo );
642 protected:
643 virtual void DrawHatchLine_DrawLine(const Point& rStartPoint, const Point& rEndPoint);
645 private:
647 /** Helper for line geometry paint with support for graphic expansion (pattern and fat_to_area)
649 SAL_DLLPRIVATE void drawLine( basegfx::B2DPolyPolygon aLinePolyPolygon, const LineInfo& rInfo );
650 ///@}
653 /** @name Polyline functions
655 ///@{
657 public:
659 /** Render the given polygon as a line stroke
661 The given polygon is stroked with the current LineColor, start
662 and end point are not automatically connected
664 @see DrawPolygon
665 @see DrawPolyPolygon
667 void DrawPolyLine( const tools::Polygon& rPoly );
669 void DrawPolyLine(
670 const basegfx::B2DPolygon&,
671 double fLineWidth = 0.0,
672 basegfx::B2DLineJoin eLineJoin = basegfx::B2DLineJoin::Round,
673 css::drawing::LineCap eLineCap = css::drawing::LineCap_BUTT,
674 double fMiterMinimumAngle = basegfx::deg2rad(15.0));
676 /** Render the given polygon as a line stroke
678 The given polygon is stroked with the current LineColor, start
679 and end point are not automatically connected. The line is
680 rendered according to the specified LineInfo, e.g. supplying a
681 dash pattern, or a line thickness.
683 @see DrawPolygon
684 @see DrawPolyPolygon
686 void DrawPolyLine( const tools::Polygon& rPoly,
687 const LineInfo& rLineInfo );
689 // #i101491#
690 // Helper who tries to use SalGDI's DrawPolyLine direct and returns it's bool.
691 bool DrawPolyLineDirect(
692 const basegfx::B2DHomMatrix& rObjectTransform,
693 const basegfx::B2DPolygon& rB2DPolygon,
694 double fLineWidth = 0.0,
695 double fTransparency = 0.0,
696 const std::vector< double >* = nullptr, // MM01
697 basegfx::B2DLineJoin eLineJoin = basegfx::B2DLineJoin::NONE,
698 css::drawing::LineCap eLineCap = css::drawing::LineCap_BUTT,
699 double fMiterMinimumAngle = basegfx::deg2rad(15.0));
701 private:
703 // #i101491#
704 // Helper which holds the old line geometry creation and is extended to use AA when
705 // switched on. Advantage is that line geometry is only temporarily used for paint
706 SAL_DLLPRIVATE void drawPolyLine(const tools::Polygon& rPoly, const LineInfo& rLineInfo);
708 ///@}
710 bool DrawPolyLineDirectInternal(
711 const basegfx::B2DHomMatrix& rObjectTransform,
712 const basegfx::B2DPolygon& rB2DPolygon,
713 double fLineWidth = 0.0,
714 double fTransparency = 0.0,
715 const std::vector< double >* = nullptr, // MM01
716 basegfx::B2DLineJoin eLineJoin = basegfx::B2DLineJoin::NONE,
717 css::drawing::LineCap eLineCap = css::drawing::LineCap_BUTT,
718 double fMiterMinimumAngle = basegfx::deg2rad(15.0));
720 /** @name Polygon functions
722 ///@{
724 public:
726 /** Render the given polygon
728 The given polygon is stroked with the current LineColor, and
729 filled with the current FillColor. If one of these colors are
730 transparent, the corresponding stroke or fill stays
731 invisible. Start and end point of the polygon are
732 automatically connected.
734 @see DrawPolyLine
736 void DrawPolygon( const tools::Polygon& rPoly );
737 void DrawPolygon( const basegfx::B2DPolygon& );
739 /** Render the given poly-polygon
741 The given poly-polygon is stroked with the current LineColor,
742 and filled with the current FillColor. If one of these colors
743 are transparent, the corresponding stroke or fill stays
744 invisible. Start and end points of the contained polygons are
745 automatically connected.
747 @see DrawPolyLine
749 void DrawPolyPolygon( const tools::PolyPolygon& rPolyPoly );
750 void DrawPolyPolygon( const basegfx::B2DPolyPolygon& );
752 private:
754 SAL_DLLPRIVATE void ImplDrawPolygon( const tools::Polygon& rPoly, const tools::PolyPolygon* pClipPolyPoly = nullptr );
755 SAL_DLLPRIVATE void ImplDrawPolyPolygon( const tools::PolyPolygon& rPolyPoly, const tools::PolyPolygon* pClipPolyPoly );
756 SAL_DLLPRIVATE void ImplDrawPolyPolygon( sal_uInt16 nPoly, const tools::PolyPolygon& rPolyPoly );
757 // #i101491#
758 // Helper who implements the DrawPolyPolygon functionality for basegfx::B2DPolyPolygon
759 // without MetaFile processing
760 SAL_DLLPRIVATE void ImplDrawPolyPolygonWithB2DPolyPolygon(const basegfx::B2DPolyPolygon& rB2DPolyPoly);
761 ///@}
763 SAL_DLLPRIVATE void ImplDrawWaveLineBezier(tools::Long nStartX, tools::Long nStartY, tools::Long nEndX, tools::Long nEndY, tools::Long nWaveHeight, double fOrientation, tools::Long nLineWidth);
766 /** @name Curved shape functions
768 ///@{
770 public:
772 void DrawEllipse( const tools::Rectangle& rRect );
774 void DrawArc(
775 const tools::Rectangle& rRect,
776 const Point& rStartPt, const Point& rEndPt );
778 void DrawPie(
779 const tools::Rectangle& rRect,
780 const Point& rStartPt, const Point& rEndPt );
782 void DrawChord(
783 const tools::Rectangle& rRect,
784 const Point& rStartPt, const Point& rEndPt );
786 ///@}
789 /** @name Gradient functions
791 ///@{
793 public:
794 void DrawGradient( const tools::Rectangle& rRect, const Gradient& rGradient );
795 void DrawGradient( const tools::PolyPolygon& rPolyPoly, const Gradient& rGradient );
797 protected:
799 virtual bool UsePolyPolygonForComplexGradient() = 0;
801 virtual tools::Long GetGradientStepCount( tools::Long nMinRect );
803 private:
805 SAL_DLLPRIVATE void DrawLinearGradient( const tools::Rectangle& rRect, const Gradient& rGradient, const tools::PolyPolygon* pClipPolyPoly );
806 SAL_DLLPRIVATE void DrawComplexGradient( const tools::Rectangle& rRect, const Gradient& rGradient, const tools::PolyPolygon* pClipPolyPoly );
807 SAL_DLLPRIVATE void DrawGradientToMetafile( const tools::PolyPolygon& rPolyPoly, const Gradient& rGradient );
808 SAL_DLLPRIVATE tools::Long GetGradientSteps(Gradient const& rGradient, tools::Rectangle const& rRect);
809 SAL_DLLPRIVATE Color GetSingleColorGradientFill();
810 ///@}
813 /** @name Hatch functions
815 ///@{
817 public:
819 #ifdef _MSC_VER
820 void DrawHatch( const tools::PolyPolygon& rPolyPoly, const ::Hatch& rHatch );
821 void AddHatchActions( const tools::PolyPolygon& rPolyPoly,
822 const ::Hatch& rHatch,
823 GDIMetaFile& rMtf );
824 #else
825 void DrawHatch( const tools::PolyPolygon& rPolyPoly, const Hatch& rHatch );
826 void AddHatchActions( const tools::PolyPolygon& rPolyPoly,
827 const Hatch& rHatch,
828 GDIMetaFile& rMtf );
829 #endif
831 void DrawHatch( const tools::PolyPolygon& rPolyPoly, const Hatch& rHatch, bool bMtf );
833 private:
835 SAL_DLLPRIVATE void CalcHatchValues( const tools::Rectangle& rRect, tools::Long nDist, Degree10 nAngle10, Point& rPt1, Point& rPt2, Size& rInc, Point& rEndPt1 );
836 SAL_DLLPRIVATE void DrawHatchLine( const tools::Line& rLine, const tools::PolyPolygon& rPolyPoly, Point* pPtBuffer, bool bMtf );
837 ///@}
840 /** @name Wallpaper functions
842 ///@{
844 public:
845 void DrawWallpaper( const tools::Rectangle& rRect, const Wallpaper& rWallpaper );
847 void Erase();
848 void Erase(const tools::Rectangle& rRect);
850 protected:
851 void DrawGradientWallpaper( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, const Wallpaper& rWallpaper );
853 private:
854 SAL_DLLPRIVATE void DrawWallpaper( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, const Wallpaper& rWallpaper );
855 SAL_DLLPRIVATE void DrawColorWallpaper( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, const Wallpaper& rWallpaper );
856 SAL_DLLPRIVATE void DrawBitmapWallpaper( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, const Wallpaper& rWallpaper );
857 ///@}
860 /** @name Text functions
862 ///@{
864 public:
866 void DrawText( const Point& rStartPt, const OUString& rStr,
867 sal_Int32 nIndex = 0, sal_Int32 nLen = -1,
868 std::vector< tools::Rectangle >* pVector = nullptr, OUString* pDisplayText = nullptr,
869 const SalLayoutGlyphs* pLayoutCache = nullptr );
871 void DrawText( const tools::Rectangle& rRect,
872 const OUString& rStr, DrawTextFlags nStyle = DrawTextFlags::NONE,
873 std::vector< tools::Rectangle >* pVector = nullptr, OUString* pDisplayText = nullptr,
874 vcl::TextLayoutCommon* _pTextLayout = nullptr );
876 static void ImplDrawText( OutputDevice& rTargetDevice, const tools::Rectangle& rRect,
877 const OUString& rOrigStr, DrawTextFlags nStyle,
878 std::vector< tools::Rectangle >* pVector, OUString* pDisplayText, vcl::TextLayoutCommon& _rLayout );
880 void ImplDrawText( SalLayout& );
882 void ImplDrawTextBackground( const SalLayout& );
884 void DrawCtrlText( const Point& rPos, const OUString& rStr,
885 sal_Int32 nIndex = 0, sal_Int32 nLen = -1,
886 DrawTextFlags nStyle = DrawTextFlags::Mnemonic, std::vector< tools::Rectangle >* pVector = nullptr, OUString* pDisplayText = nullptr,
887 const SalLayoutGlyphs* pGlyphs = nullptr);
889 void DrawTextLine( const Point& rPos, tools::Long nWidth,
890 FontStrikeout eStrikeout,
891 FontLineStyle eUnderline,
892 FontLineStyle eOverline,
893 bool bUnderlineAbove = false );
895 void ImplDrawTextLine( tools::Long nBaseX, tools::Long nX, tools::Long nY, double nWidth,
896 FontStrikeout eStrikeout, FontLineStyle eUnderline,
897 FontLineStyle eOverline, bool bUnderlineAbove );
899 void ImplDrawTextLines( SalLayout&, FontStrikeout eStrikeout, FontLineStyle eUnderline,
900 FontLineStyle eOverline, bool bWordLine, bool bUnderlineAbove );
902 void DrawWaveLine( const Point& rStartPos, const Point& rEndPos, tools::Long nLineWidth = 1, tools::Long nWaveHeight = 3);
904 bool ImplDrawRotateText( SalLayout& );
906 tools::Rectangle GetTextRect( const tools::Rectangle& rRect,
907 const OUString& rStr, DrawTextFlags nStyle = DrawTextFlags::WordBreak,
908 TextRectInfo* pInfo = nullptr,
909 const vcl::TextLayoutCommon* _pTextLayout = nullptr ) const;
911 /** Return the exact bounding rectangle of rStr.
913 The text is then drawn exactly from rRect.TopLeft() to
914 rRect.BottomRight(), don't assume that rRect.TopLeft() is [0, 0].
916 Please note that you don't always want to use GetTextBoundRect(); in
917 many cases you actually want to use GetTextHeight(), because
918 GetTextBoundRect() gives you the exact bounding rectangle regardless
919 what is the baseline of the text.
921 Code snippet to get just exactly the text (no filling around that) as
922 a bitmap via a VirtualDevice (regardless what is the baseline):
924 <code>
925 VirtualDevice aDevice;
926 vcl::Font aFont = aDevice.GetFont();
927 aFont.SetSize(Size(0, 96));
928 aFont.SetColor(COL_BLACK);
929 aDevice.SetFont(aFont);
930 aDevice.Erase();
932 tools::Rectangle aRect;
933 aDevice.GetTextBoundRect(aRect, aText);
934 aDevice.SetOutputSize(Size(aRect.Right() + 1, aRect.Bottom() + 1));
935 aDevice.SetBackground(Wallpaper(COL_TRANSPARENT));
936 aDevice.DrawText(Point(0,0), aText);
938 // exactly only the text, regardless of the baseline
939 Bitmap aBitmap(aDevice.GetBitmap(aRect.TopLeft(), aRect.GetSize()));
940 </code>
942 Code snippet to get the text as a bitmap via a Virtual device that
943 contains even the filling so that the baseline is always preserved
944 (ie. the text will not jump up and down according to whether it
945 contains 'y' or not etc.)
947 <code>
948 VirtualDevice aDevice;
949 // + the appropriate font / device setup, see above
951 aDevice.SetOutputSize(Size(aDevice.GetTextWidth(aText), aDevice.GetTextHeight()));
952 aDevice.SetBackground(Wallpaper(COL_TRANSPARENT));
953 aDevice.DrawText(Point(0,0), aText);
955 // bitmap that contains even the space around the text,
956 // that means, preserves the baseline etc.
957 Bitmap aBitmap(aDevice.GetBitmap(Point(0, 0), aDevice.GetOutputSize()));
958 </code>
960 bool GetTextBoundRect( tools::Rectangle& rRect,
961 const OUString& rStr, sal_Int32 nBase = 0, sal_Int32 nIndex = 0, sal_Int32 nLen = -1,
962 sal_uLong nLayoutWidth = 0, KernArraySpan aDXArray = KernArraySpan(),
963 std::span<const sal_Bool> pKashidaArray = {},
964 const SalLayoutGlyphs* pGlyphs = nullptr ) const;
966 tools::Rectangle ImplGetTextBoundRect( const SalLayout& ) const;
968 bool GetTextOutline( tools::PolyPolygon&,
969 const OUString& rStr ) const;
971 bool GetTextOutlines( PolyPolyVector&,
972 const OUString& rStr, sal_Int32 nBase = 0, sal_Int32 nIndex = 0,
973 sal_Int32 nLen = -1,
974 sal_uLong nLayoutWidth = 0, KernArraySpan aDXArray = KernArraySpan(),
975 std::span<const sal_Bool> pKashidaArray = {} ) const;
977 bool GetTextOutlines( basegfx::B2DPolyPolygonVector &rVector,
978 const OUString& rStr, sal_Int32 nBase, sal_Int32 nIndex = 0,
979 sal_Int32 nLen = -1,
980 sal_uLong nLayoutWidth = 0, KernArraySpan aDXArray = KernArraySpan(),
981 std::span<const sal_Bool> pKashidaArray = {} ) const;
984 OUString GetEllipsisString( const OUString& rStr, tools::Long nMaxWidth,
985 DrawTextFlags nStyle = DrawTextFlags::EndEllipsis ) const;
987 tools::Long GetCtrlTextWidth( const OUString& rStr,
988 const SalLayoutGlyphs* pLayoutCache = nullptr ) const;
990 /** Generate MetaTextActions for the text rect
992 This method splits up the text rect into multiple
993 MetaTextActions, one for each line of text. This is comparable
994 to AddGradientActions(), which splits up a gradient into its
995 constituent polygons. Parameter semantics fully compatible to
996 DrawText().
998 void AddTextRectActions( const tools::Rectangle& rRect,
999 const OUString& rOrigStr,
1000 DrawTextFlags nStyle,
1001 GDIMetaFile& rMtf );
1003 void SetTextColor( const Color& rColor );
1004 virtual void SetSystemTextColor(SystemTextColorFlags nFlags, bool bEnabled);
1005 const Color& GetTextColor() const { return maTextColor; }
1007 void SetTextFillColor();
1008 void SetTextFillColor( const Color& rColor );
1009 Color GetTextFillColor() const;
1010 bool IsTextFillColor() const { return !maFont.IsTransparent(); }
1012 void SetTextLineColor();
1013 void SetTextLineColor( const Color& rColor );
1014 const Color& GetTextLineColor() const { return maTextLineColor; }
1015 bool IsTextLineColor() const { return !maTextLineColor.IsTransparent(); }
1017 void SetOverlineColor();
1018 void SetOverlineColor( const Color& rColor );
1019 const Color& GetOverlineColor() const { return maOverlineColor; }
1020 bool IsOverlineColor() const { return !maOverlineColor.IsTransparent(); }
1022 void SetTextAlign( TextAlign eAlign );
1023 TextAlign GetTextAlign() const { return maFont.GetAlignment(); }
1025 /** Width of the text.
1027 See also GetTextBoundRect() for more explanation + code examples.
1029 tools::Long GetTextWidth( const OUString& rStr, sal_Int32 nIndex = 0, sal_Int32 nLen = -1,
1030 vcl::text::TextLayoutCache const* = nullptr,
1031 SalLayoutGlyphs const*const pLayoutCache = nullptr) const;
1033 /** Height where any character of the current font fits; in logic coordinates.
1035 See also GetTextBoundRect() for more explanation + code examples.
1037 tools::Long GetTextHeight() const;
1038 float approximate_digit_width() const;
1040 void DrawTextArray( const Point& rStartPt, const OUString& rStr,
1041 KernArraySpan aKernArray,
1042 std::span<const sal_Bool> pKashidaAry,
1043 sal_Int32 nIndex,
1044 sal_Int32 nLen,
1045 SalLayoutFlags flags = SalLayoutFlags::NONE,
1046 const SalLayoutGlyphs* pLayoutCache = nullptr);
1047 tools::Long GetTextArray( const OUString& rStr, KernArray* pDXAry,
1048 sal_Int32 nIndex = 0, sal_Int32 nLen = -1, bool bCaret = false,
1049 vcl::text::TextLayoutCache const* = nullptr,
1050 SalLayoutGlyphs const*const pLayoutCache = nullptr) const;
1052 void GetCaretPositions( const OUString&, KernArray& rCaretXArray,
1053 sal_Int32 nIndex, sal_Int32 nLen,
1054 const SalLayoutGlyphs* pGlyphs = nullptr ) const;
1055 void DrawStretchText( const Point& rStartPt, sal_Int32 nWidth,
1056 const OUString& rStr,
1057 sal_Int32 nIndex = 0, sal_Int32 nLen = -1);
1058 sal_Int32 GetTextBreak( const OUString& rStr, tools::Long nTextWidth,
1059 sal_Int32 nIndex, sal_Int32 nLen = -1,
1060 tools::Long nCharExtra = 0,
1061 vcl::text::TextLayoutCache const* = nullptr,
1062 const SalLayoutGlyphs* pGlyphs = nullptr) const;
1063 sal_Int32 GetTextBreak( const OUString& rStr, tools::Long nTextWidth,
1064 sal_Unicode nExtraChar, sal_Int32& rExtraCharPos,
1065 sal_Int32 nIndex, sal_Int32 nLen,
1066 tools::Long nCharExtra,
1067 vcl::text::TextLayoutCache const* = nullptr,
1068 const SalLayoutGlyphs* pGlyphs = nullptr) const;
1069 static std::shared_ptr<const vcl::text::TextLayoutCache> CreateTextLayoutCache(OUString const&);
1071 SAL_DLLPRIVATE SalLayoutFlags GetBiDiLayoutFlags( std::u16string_view rStr,
1072 const sal_Int32 nMinIndex,
1073 const sal_Int32 nEndIndex ) const;
1075 protected:
1076 SAL_DLLPRIVATE void ImplInitTextLineSize();
1077 SAL_DLLPRIVATE void ImplInitAboveTextLineSize();
1078 SAL_DLLPRIVATE float approximate_char_width() const;
1080 virtual bool shouldDrawWavePixelAsRect(tools::Long nLineWidth) const;
1081 virtual void SetWaveLineColors(Color const& rColor, tools::Long nLineWidth);
1082 virtual Size GetWaveLineSize(tools::Long nLineWidth) const;
1084 private:
1085 SAL_DLLPRIVATE void ImplInitTextColor();
1087 SAL_DLLPRIVATE void ImplDrawTextDirect( SalLayout&, bool bTextLines);
1088 SAL_DLLPRIVATE void ImplDrawSpecialText( SalLayout& );
1089 SAL_DLLPRIVATE void ImplDrawTextRect( tools::Long nBaseX, tools::Long nBaseY, tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight );
1091 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 );
1093 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 );
1094 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 );
1095 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 );
1096 SAL_DLLPRIVATE void ImplDrawStrikeoutLine( tools::Long nBaseX, tools::Long nBaseY, tools::Long nX, tools::Long nY, tools::Long nWidth, FontStrikeout eStrikeout, Color aColor );
1097 SAL_DLLPRIVATE void ImplDrawStrikeoutChar( tools::Long nBaseX, tools::Long nBaseY, tools::Long nX, tools::Long nY, tools::Long nWidth, FontStrikeout eStrikeout, Color aColor );
1098 SAL_DLLPRIVATE void ImplDrawMnemonicLine( tools::Long nX, tools::Long nY, tools::Long nWidth );
1100 SAL_DLLPRIVATE bool AttemptOLEFontScaleFix(vcl::Font& rFont, tools::Long nHeight) const;
1102 ///@}
1105 /** @name Font functions
1107 ///@{
1109 public:
1111 FontMetric GetFontMetricFromCollection( int nDevFontIndex ) const;
1112 int GetFontFaceCollectionCount() const;
1114 bool IsFontAvailable( std::u16string_view rFontName ) const;
1116 bool AddTempDevFont( const OUString& rFileURL, const OUString& rFontName );
1117 void RefreshFontData( const bool bNewFontLists );
1119 FontMetric GetFontMetric() const;
1120 FontMetric GetFontMetric( const vcl::Font& rFont ) const;
1122 bool GetFontCharMap( FontCharMapRef& rxFontCharMap ) const;
1123 bool GetFontCapabilities( vcl::FontCapabilities& rFontCapabilities ) const;
1125 bool GetFontFeatures(std::vector<vcl::font::Feature>& rFontFeatures) const;
1127 bool GetGlyphBoundRects( const Point& rOrigin, const OUString& rStr, int nIndex,
1128 int nLen, std::vector< tools::Rectangle >& rVector ) const;
1130 sal_Int32 HasGlyphs( const vcl::Font& rFont, std::u16string_view rStr,
1131 sal_Int32 nIndex = 0, sal_Int32 nLen = -1 ) const;
1133 tools::Long GetMinKashida() const;
1135 // i60594
1136 // validate kashida positions against the current font
1137 // returns count of invalid kashida positions
1138 sal_Int32 ValidateKashidas( const OUString& rTxt, sal_Int32 nIdx, sal_Int32 nLen,
1139 sal_Int32 nKashCount, // number of suggested kashida positions (in)
1140 const sal_Int32* pKashidaPos, // suggested kashida positions (in)
1141 sal_Int32* pKashidaPosDropped // invalid kashida positions (out)
1142 ) const;
1144 static void BeginFontSubstitution();
1145 static void EndFontSubstitution();
1146 static void AddFontSubstitute( const OUString& rFontName,
1147 const OUString& rReplaceFontName,
1148 AddFontSubstituteFlags nFlags );
1149 static void RemoveFontsSubstitute();
1151 static vcl::Font GetDefaultFont( DefaultFontType nType,
1152 LanguageType eLang,
1153 GetDefaultFontFlags nFlags,
1154 const OutputDevice* pOutDev = nullptr );
1156 SAL_DLLPRIVATE void ImplInitFontList() const;
1157 SAL_DLLPRIVATE void ImplUpdateFontData();
1159 //drop font data for all outputdevices.
1160 //If bNewFontLists is true then empty lists of system fonts
1161 static void ImplClearAllFontData( bool bNewFontLists );
1162 //fetch font data for all outputdevices
1163 //If bNewFontLists is true then fetch lists of system fonts
1164 static void ImplRefreshAllFontData( bool bNewFontLists );
1165 //drop and fetch font data for all outputdevices
1166 //If bNewFontLists is true then drop and refetch lists of system fonts
1167 SAL_DLLPRIVATE static void ImplUpdateAllFontData( bool bNewFontLists );
1169 LogicalFontInstance const* GetFontInstance() const;
1170 bool ForceFallbackFont(vcl::Font const& rFallbackFont);
1172 protected:
1173 SAL_DLLPRIVATE tools::Long GetEmphasisAscent() const { return mnEmphasisAscent; }
1174 SAL_DLLPRIVATE tools::Long GetEmphasisDescent() const { return mnEmphasisDescent; }
1176 SAL_DLLPRIVATE bool InitFont() const;
1177 virtual void SetFontOrientation( LogicalFontInstance* const pFontInstance ) const;
1178 virtual tools::Long GetFontExtLeading() const;
1180 virtual void ImplClearFontData(bool bNewFontLists);
1181 virtual void ImplRefreshFontData(bool bNewFontLists);
1182 void ReleaseFontCache();
1183 void ReleaseFontCollection();
1184 void SetFontCollectionFromSVData();
1185 void ResetNewFontCache();
1187 virtual bool ImplNewFont() const;
1189 private:
1191 typedef void ( OutputDevice::* FontUpdateHandler_t )( bool );
1193 SAL_DLLPRIVATE static void ImplUpdateFontDataForAllFrames( FontUpdateHandler_t pHdl, bool bNewFontLists );
1195 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 );
1196 SAL_DLLPRIVATE void ImplDrawEmphasisMarks( SalLayout& );
1197 ///@}
1200 /** @name Layout functions
1202 ///@{
1204 public:
1206 // tells whether this output device is RTL in an LTR UI or LTR in a RTL UI
1207 SAL_DLLPRIVATE bool ImplIsAntiparallel() const ;
1208 void ReMirror( Point &rPoint ) const;
1209 void ReMirror( tools::Rectangle &rRect ) const;
1210 void ReMirror( vcl::Region &rRegion ) const;
1211 SAL_DLLPRIVATE bool ImplIsRecordLayout() const;
1212 virtual bool HasMirroredGraphics() const;
1213 std::unique_ptr<SalLayout>
1214 ImplLayout( const OUString&, sal_Int32 nIndex, sal_Int32 nLen,
1215 const Point& rLogicPos = Point(0,0), tools::Long nLogicWidth=0,
1216 KernArraySpan aKernArray = KernArraySpan(),
1217 std::span<const sal_Bool> pKashidaArray={},
1218 SalLayoutFlags flags = SalLayoutFlags::NONE,
1219 vcl::text::TextLayoutCache const* = nullptr,
1220 const SalLayoutGlyphs* pGlyphs = nullptr) const;
1222 SAL_DLLPRIVATE vcl::text::ImplLayoutArgs ImplPrepareLayoutArgs( OUString&, const sal_Int32 nIndex, const sal_Int32 nLen,
1223 double nPixelWidth,
1224 SalLayoutFlags flags = SalLayoutFlags::NONE,
1225 vcl::text::TextLayoutCache const* = nullptr) const;
1226 SAL_DLLPRIVATE std::unique_ptr<SalLayout>
1227 ImplGlyphFallbackLayout( std::unique_ptr<SalLayout>,
1228 vcl::text::ImplLayoutArgs&,
1229 const SalLayoutGlyphs* ) const;
1230 SAL_DLLPRIVATE std::unique_ptr<SalLayout>
1231 getFallbackLayout(
1232 LogicalFontInstance* pLogicalFont, int nFallbackLevel,
1233 vcl::text::ImplLayoutArgs& rLayoutArgs, const SalLayoutGlyphs* ) const;
1236 These functions allow collecting information on how fonts are mapped when used, such as what
1237 replacements are used when a requested font is missing or which fonts are used as fallbacks
1238 when a font doesn't provide all necessary glyphs.
1239 After StartTrackingFontMappingUse() is called, VCL starts collecting font usage for all
1240 text layout calls, FinishTrackingFontMappingUse() will stop collecting and providing
1241 the collected information.
1242 Each item is a mapping from a requested font to a list of actually used fonts and the number
1243 of times this mapping was done.
1245 struct FontMappingUseItem
1247 OUString mOriginalFont;
1248 std::vector<OUString> mUsedFonts;
1249 int mCount;
1251 typedef std::vector<FontMappingUseItem> FontMappingUseData;
1252 static void StartTrackingFontMappingUse();
1253 static FontMappingUseData FinishTrackingFontMappingUse();
1255 // Enabling/disabling RTL only makes sense for OutputDevices that use a mirroring SalGraphicsLayout
1256 virtual void EnableRTL( bool bEnable = true);
1257 bool IsRTLEnabled() const { return mbEnableRTL; }
1259 bool GetTextIsRTL( const OUString&, sal_Int32 nIndex, sal_Int32 nLen ) const;
1261 ///@}
1264 /** @name Bitmap functions
1266 ///@{
1268 public:
1269 void DrawBitmap(
1270 const Point& rDestPt,
1271 const Bitmap& rBitmap );
1273 void DrawBitmap(
1274 const Point& rDestPt,
1275 const Size& rDestSize,
1276 const Bitmap& rBitmap );
1278 void DrawBitmap(
1279 const Point& rDestPt,
1280 const Size& rDestSize,
1281 const Point& rSrcPtPixel,
1282 const Size& rSrcSizePixel,
1283 const Bitmap& rBitmap);
1285 void DrawBitmap(
1286 const Point& rDestPt,
1287 const Size& rDestSize,
1288 const Point& rSrcPtPixel,
1289 const Size& rSrcSizePixel,
1290 const Bitmap& rBitmap,
1291 MetaActionType nAction );
1293 void DrawBitmapEx(
1294 const Point& rDestPt,
1295 const BitmapEx& rBitmapEx );
1298 void DrawBitmapEx(
1299 const Point& rDestPt,
1300 const Size& rDestSize,
1301 const BitmapEx& rBitmapEx );
1303 void DrawBitmapEx(
1304 const Point& rDestPt,
1305 const Size& rDestSize,
1306 const Point& rSrcPtPixel,
1307 const Size& rSrcSizePixel,
1308 const BitmapEx& rBitmapEx);
1310 void DrawBitmapEx(
1311 const Point& rDestPt,
1312 const Size& rDestSize,
1313 const Point& rSrcPtPixel,
1314 const Size& rSrcSizePixel,
1315 const BitmapEx& rBitmapEx,
1316 MetaActionType nAction );
1318 /** @overload
1319 virtual void DrawImage(
1320 const Point& rPos,
1321 const Size& rSize,
1322 const Image& rImage,
1323 sal_uInt16 nStyle = 0)
1325 void DrawImage(
1326 const Point& rPos,
1327 const Image& rImage,
1328 DrawImageFlags nStyle = DrawImageFlags::NONE );
1330 void DrawImage(
1331 const Point& rPos,
1332 const Size& rSize,
1333 const Image& rImage,
1334 DrawImageFlags nStyle = DrawImageFlags::NONE );
1337 virtual Bitmap GetBitmap( const Point& rSrcPt, const Size& rSize ) const;
1339 /** Query extended bitmap (with alpha channel, if available).
1341 BitmapEx GetBitmapEx( const Point& rSrcPt, const Size& rSize ) const;
1344 /** Draw BitmapEx transformed
1346 @param rTransformation
1347 The transformation describing the target positioning of the given bitmap. Transforming
1348 the unit object coordinates (0, 0, 1, 1) with this matrix is the transformation to
1349 discrete coordinates
1351 @param rBitmapEx
1352 The BitmapEx to be painted
1354 @param fAlpha
1355 Optional additional alpha to use for drawing (0 to 1, 1 being no change).
1357 void DrawTransformedBitmapEx(
1358 const basegfx::B2DHomMatrix& rTransformation,
1359 const BitmapEx& rBitmapEx,
1360 double fAlpha = 1.0);
1362 /** Return true if DrawTransformedBitmapEx() is fast.
1364 @since 7.2
1366 bool HasFastDrawTransformedBitmap() const;
1368 protected:
1370 virtual void DrawDeviceBitmapEx(
1371 const Point& rDestPt, const Size& rDestSize,
1372 const Point& rSrcPtPixel, const Size& rSrcSizePixel,
1373 BitmapEx& rBitmapEx );
1375 virtual bool CanSubsampleBitmap() const { return true; }
1377 /** Transform and draw a bitmap directly
1379 @param aFullTransform The B2DHomMatrix used for the transformation
1380 @param rBitmapEx Reference to the bitmap to be transformed and drawn
1382 @return true if it was able to draw the bitmap, false if not
1384 virtual bool DrawTransformBitmapExDirect(
1385 const basegfx::B2DHomMatrix& aFullTransform,
1386 const BitmapEx& rBitmapEx,
1387 double fAlpha = 1.0);
1389 /** Transform and reduce the area that needs to be drawn of the bitmap and return the new
1390 visible range and the maximum area.
1393 @param aFullTransform B2DHomMatrix used for transformation
1394 @param aVisibleRange The new visible area of the bitmap
1395 @param fMaximumArea The maximum area of the bitmap
1397 @returns true if there is an area to be drawn, otherwise nothing is left to be drawn
1398 so return false
1400 virtual bool TransformAndReduceBitmapExToTargetRange(
1401 const basegfx::B2DHomMatrix& aFullTransform,
1402 basegfx::B2DRange &aVisibleRange,
1403 double &fMaximumArea);
1405 private:
1407 SAL_DLLPRIVATE void DrawDeviceAlphaBitmap(
1408 const Bitmap& rBmp,
1409 const AlphaMask& rAlpha,
1410 const Point& rDestPt,
1411 const Size& rDestSize,
1412 const Point& rSrcPtPixel,
1413 const Size& rSrcSizePixel );
1415 SAL_DLLPRIVATE void DrawDeviceAlphaBitmapSlowPath(
1416 const Bitmap& rBitmap, const AlphaMask& rAlpha,
1417 tools::Rectangle aDstRect, tools::Rectangle aBmpRect,
1418 Size const & aOutSz, Point const & aOutPt);
1421 SAL_DLLPRIVATE void BlendBitmap(
1422 const SalTwoRect& rPosAry,
1423 const Bitmap& rBmp );
1425 SAL_DLLPRIVATE Bitmap BlendBitmap(
1426 Bitmap& aBmp,
1427 BitmapReadAccess const * pP,
1428 BitmapReadAccess const * pA,
1429 const sal_Int32 nOffY,
1430 const sal_Int32 nDstHeight,
1431 const sal_Int32 nOffX,
1432 const sal_Int32 nDstWidth,
1433 const tools::Rectangle& aBmpRect,
1434 const Size& aOutSz,
1435 const bool bHMirr,
1436 const bool bVMirr,
1437 const sal_Int32* pMapX,
1438 const sal_Int32* pMapY );
1440 SAL_DLLPRIVATE Bitmap BlendBitmapWithAlpha(
1441 Bitmap& aBmp,
1442 BitmapReadAccess const * pP,
1443 BitmapReadAccess const * pA,
1444 const tools::Rectangle& aDstRect,
1445 const sal_Int32 nOffY,
1446 const sal_Int32 nDstHeight,
1447 const sal_Int32 nOffX,
1448 const sal_Int32 nDstWidth,
1449 const sal_Int32* pMapX,
1450 const sal_Int32* pMapY );
1452 ///@}
1455 /** @name Transparency functions
1457 ///@{
1459 public:
1461 /** helper method removing transparencies from a metafile (e.g. for printing)
1463 @returns
1464 true: transparencies were removed
1465 false: output metafile is unchanged input metafile
1467 @attention this is a member method, so current state can influence the result !
1468 @attention the output metafile is prepared in pixel mode for the currentOutputDevice
1469 state. It can not be moved or rotated reliably anymore.
1471 bool RemoveTransparenciesFromMetaFile(
1472 const GDIMetaFile& rInMtf, GDIMetaFile& rOutMtf,
1473 tools::Long nMaxBmpDPIX, tools::Long nMaxBmpDPIY,
1474 bool bReduceTransparency,
1475 bool bTransparencyAutoMode,
1476 bool bDownsampleBitmaps,
1477 const Color& rBackground = COL_TRANSPARENT );
1479 void DrawTransparent( const tools::PolyPolygon& rPolyPoly, sal_uInt16 nTransparencePercent );
1481 void DrawTransparent(
1482 const basegfx::B2DHomMatrix& rObjectTransform,
1483 const basegfx::B2DPolyPolygon& rB2DPolyPoly,
1484 double fTransparency);
1486 void DrawTransparent(
1487 const GDIMetaFile& rMtf, const Point& rPos, const Size& rSize,
1488 const Gradient& rTransparenceGradient );
1490 void DrawTransparent(
1491 const GDIMetaFile& rMtf, const Point& rPos, const Size& rSize,
1492 const Point& rMtfPos, const Size& rMtfSize,
1493 const Gradient& rTransparenceGradient );
1495 protected:
1497 virtual void EmulateDrawTransparent( const tools::PolyPolygon& rPolyPoly, sal_uInt16 nTransparencePercent );
1499 virtual void ClipAndDrawGradientMetafile ( const Gradient &rGradient, const tools::PolyPolygon &rPolyPoly );
1501 private:
1503 SAL_DLLPRIVATE bool DrawTransparentNatively( const tools::PolyPolygon& rPolyPoly, sal_uInt16 nTransparencePercent );
1504 ///@}
1507 /** @name Mask functions
1509 ///@{
1511 public:
1513 void DrawMask( const Point& rDestPt,
1514 const Bitmap& rBitmap, const Color& rMaskColor );
1516 void DrawMask( const Point& rDestPt, const Size& rDestSize,
1517 const Bitmap& rBitmap, const Color& rMaskColor );
1519 void DrawMask( const Point& rDestPt, const Size& rDestSize,
1520 const Point& rSrcPtPixel, const Size& rSrcSizePixel,
1521 const Bitmap& rBitmap, const Color& rMaskColor);
1523 void DrawMask( const Point& rDestPt, const Size& rDestSize,
1524 const Point& rSrcPtPixel, const Size& rSrcSizePixel,
1525 const Bitmap& rBitmap, const Color& rMaskColor,
1526 MetaActionType nAction );
1528 protected:
1530 virtual void DrawDeviceMask (
1531 const Bitmap& rMask, const Color& rMaskColor,
1532 const Point& rDestPt, const Size& rDestSize,
1533 const Point& rSrcPtPixel, const Size& rSrcSizePixel );
1534 ///@}
1537 /** @name Map functions
1539 ///@{
1541 public:
1543 void EnableMapMode( bool bEnable = true );
1544 bool IsMapModeEnabled() const { return mbMap; }
1546 void SetMapMode();
1547 void SetMapMode( const MapMode& rNewMapMode );
1548 void SetRelativeMapMode( const MapMode& rNewMapMode );
1549 virtual void SetMetafileMapMode(const MapMode& rNewMapMode, bool bIsRecord);
1550 const MapMode& GetMapMode() const { return maMapMode; }
1552 protected:
1553 virtual void ImplInitMapModeObjects();
1555 public:
1556 // #i75163#
1557 basegfx::B2DHomMatrix GetViewTransformation() const;
1558 basegfx::B2DHomMatrix GetInverseViewTransformation() const;
1560 basegfx::B2DHomMatrix GetViewTransformation( const MapMode& rMapMode ) const;
1561 basegfx::B2DHomMatrix GetInverseViewTransformation( const MapMode& rMapMode ) const;
1564 /** Set an offset in pixel
1566 This method offsets every drawing operation that converts its
1567 coordinates to pixel by the given value. Normally, the effect
1568 can be achieved by setting a MapMode with a different
1569 origin. Unfortunately, this origin is in logical coordinates
1570 and can lead to rounding errors (see #102532# for details).
1572 @attention This offset is only applied when converting to
1573 pixel, i.e. some output modes such as metafile recordings
1574 might be completely unaffected by this method! Use with
1575 care. Furthermore, if the OutputDevice's MapMode is the
1576 default (that's MapUnit::MapPixel), then any pixel offset set is
1577 ignored also. This might be unintuitive for cases, but would
1578 have been far more fragile to implement. What's more, the
1579 reason why the pixel offset was introduced (avoiding rounding
1580 errors) does not apply for MapUnit::MapPixel, because one can always
1581 use the MapMode origin then.
1583 @param rOffset
1584 The offset in pixel
1586 void SetPixelOffset( const Size& rOffset );
1588 /** Get the offset in pixel
1590 @see OutputDevice::SetPixelOffset for details
1592 @return the current offset in pixel
1594 SAL_WARN_UNUSED_RESULT Size GetPixelOffset() const { return Size(mnOutOffOrigX, mnOutOffOrigY);}
1596 SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point& rLogicPt) const;
1597 SAL_WARN_UNUSED_RESULT Size LogicToPixel(const Size& rLogicSize) const;
1598 SAL_WARN_UNUSED_RESULT tools::Rectangle LogicToPixel(const tools::Rectangle& rLogicRect) const;
1599 SAL_WARN_UNUSED_RESULT tools::Polygon LogicToPixel(const tools::Polygon& rLogicPoly) const;
1600 SAL_WARN_UNUSED_RESULT tools::PolyPolygon LogicToPixel(const tools::PolyPolygon& rLogicPolyPoly) const;
1601 SAL_WARN_UNUSED_RESULT basegfx::B2DPolyPolygon LogicToPixel(const basegfx::B2DPolyPolygon& rLogicPolyPoly) const;
1602 SAL_WARN_UNUSED_RESULT vcl::Region LogicToPixel(const vcl::Region& rLogicRegion)const;
1603 SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point& rLogicPt, const MapMode& rMapMode) const;
1604 SAL_WARN_UNUSED_RESULT Size LogicToPixel(const Size& rLogicSize, const MapMode& rMapMode) const;
1605 SAL_WARN_UNUSED_RESULT tools::Rectangle LogicToPixel(const tools::Rectangle& rLogicRect,
1606 const MapMode& rMapMode) const;
1607 SAL_WARN_UNUSED_RESULT tools::Polygon LogicToPixel(const tools::Polygon& rLogicPoly,
1608 const MapMode& rMapMode) const;
1609 SAL_WARN_UNUSED_RESULT basegfx::B2DPolyPolygon LogicToPixel(const basegfx::B2DPolyPolygon& rLogicPolyPoly,
1610 const MapMode& rMapMode) const;
1612 SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point& rDevicePt) const;
1613 SAL_WARN_UNUSED_RESULT Size PixelToLogic(const Size& rDeviceSize) const;
1614 SAL_WARN_UNUSED_RESULT tools::Rectangle PixelToLogic(const tools::Rectangle& rDeviceRect) const;
1615 SAL_WARN_UNUSED_RESULT tools::Polygon PixelToLogic(const tools::Polygon& rDevicePoly) const;
1616 SAL_WARN_UNUSED_RESULT tools::PolyPolygon PixelToLogic(const tools::PolyPolygon& rDevicePolyPoly) const;
1617 SAL_WARN_UNUSED_RESULT basegfx::B2DPolyPolygon PixelToLogic(const basegfx::B2DPolyPolygon& rDevicePolyPoly) const;
1618 SAL_WARN_UNUSED_RESULT vcl::Region PixelToLogic(const vcl::Region& rDeviceRegion) const;
1619 SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point& rDevicePt, const MapMode& rMapMode) const;
1620 SAL_WARN_UNUSED_RESULT Size PixelToLogic(const Size& rDeviceSize, const MapMode& rMapMode) const;
1621 SAL_WARN_UNUSED_RESULT tools::Rectangle PixelToLogic(const tools::Rectangle& rDeviceRect,
1622 const MapMode& rMapMode) const;
1623 SAL_WARN_UNUSED_RESULT tools::Polygon PixelToLogic(const tools::Polygon& rDevicePoly,
1624 const MapMode& rMapMode) const;
1625 SAL_WARN_UNUSED_RESULT basegfx::B2DPolygon PixelToLogic(const basegfx::B2DPolygon& rDevicePoly,
1626 const MapMode& rMapMode) const;
1627 SAL_WARN_UNUSED_RESULT basegfx::B2DPolyPolygon PixelToLogic(const basegfx::B2DPolyPolygon& rDevicePolyPoly,
1628 const MapMode& rMapMode) const;
1630 SAL_WARN_UNUSED_RESULT Point LogicToLogic(const Point& rPtSource,
1631 const MapMode* pMapModeSource,
1632 const MapMode* pMapModeDest) const;
1633 SAL_WARN_UNUSED_RESULT Size LogicToLogic(const Size& rSzSource,
1634 const MapMode* pMapModeSource,
1635 const MapMode* pMapModeDest) const;
1636 SAL_WARN_UNUSED_RESULT tools::Rectangle LogicToLogic(const tools::Rectangle& rRectSource,
1637 const MapMode* pMapModeSource,
1638 const MapMode* pMapModeDest) const;
1639 SAL_WARN_UNUSED_RESULT static Point LogicToLogic(const Point& rPtSource,
1640 const MapMode& rMapModeSource,
1641 const MapMode& rMapModeDest);
1642 SAL_WARN_UNUSED_RESULT static Size LogicToLogic(const Size& rSzSource,
1643 const MapMode& rMapModeSource,
1644 const MapMode& rMapModeDest);
1645 SAL_WARN_UNUSED_RESULT static tools::Rectangle LogicToLogic(const tools::Rectangle& rRectSource,
1646 const MapMode& rMapModeSource,
1647 const MapMode& rMapModeDest);
1648 SAL_WARN_UNUSED_RESULT static tools::Long LogicToLogic(tools::Long nLongSource,
1649 MapUnit eUnitSource,
1650 MapUnit eUnitDest);
1652 SAL_WARN_UNUSED_RESULT static basegfx::B2DPolygon LogicToLogic(const basegfx::B2DPolygon& rPoly,
1653 const MapMode& rMapModeSource,
1654 const MapMode& rMapModeDest);
1656 // create a mapping transformation from rMapModeSource to rMapModeDest (the above methods
1657 // for B2DPoly/Polygons use this internally anyway to transform the B2DPolygon)
1658 SAL_WARN_UNUSED_RESULT static basegfx::B2DHomMatrix LogicToLogic(const MapMode& rMapModeSource,
1659 const MapMode& rMapModeDest);
1661 /** Convert a logical rectangle to a rectangle in physical device pixel units.
1663 @param rLogicRect Const reference to a rectangle in logical units
1665 @returns Rectangle based on physical device pixel coordinates and units.
1667 SAL_DLLPRIVATE tools::Rectangle ImplLogicToDevicePixel( const tools::Rectangle& rLogicRect ) const;
1669 /** Convert a logical point to a physical point on the device.
1671 @param rLogicPt Const reference to a point in logical units.
1673 @returns Physical point on the device.
1675 SAL_DLLPRIVATE Point ImplLogicToDevicePixel( const Point& rLogicPt ) const;
1676 SAL_DLLPRIVATE basegfx::B2DPoint ImplLogicToDeviceSubPixel(const Point& rLogicPt) const;
1678 /** Convert a logical width to a width in units of device pixels.
1680 To get the number of device pixels, it must calculate the X-DPI of the device and
1681 the map scaling factor. If there is no mapping, then it just returns the
1682 width as nothing more needs to be done.
1684 @param nWidth Logical width
1686 @returns Width in units of device pixels.
1688 SAL_DLLPRIVATE tools::Long ImplLogicWidthToDevicePixel( tools::Long nWidth ) const;
1689 SAL_DLLPRIVATE double ImplLogicWidthToDeviceSubPixel(tools::Long nWidth) const;
1691 /** Convert a logical height to a height in units of device pixels.
1693 To get the number of device pixels, it must calculate the Y-DPI of the device and
1694 the map scaling factor. If there is no mapping, then it just returns the
1695 height as nothing more needs to be done.
1697 @param nHeight Logical height
1699 @returns Height in units of device pixels.
1701 SAL_DLLPRIVATE tools::Long ImplLogicHeightToDevicePixel( tools::Long nHeight ) const;
1702 SAL_DLLPRIVATE double ImplLogicHeightToDeviceSubPixel(tools::Long nHeight) const;
1704 SAL_DLLPRIVATE Point SubPixelToLogic(const basegfx::B2DPoint& rDevicePt) const;
1706 /** Convert device pixels to a width in logical units.
1708 To get the logical width, it must calculate the X-DPI of the device and the
1709 map scaling factor.
1711 @param nWidth Width in device pixels
1713 @returns Width in logical units.
1715 SAL_DLLPRIVATE tools::Long ImplDevicePixelToLogicWidth( tools::Long nWidth ) const;
1717 /** Convert device pixels to a height in logical units.
1719 To get the logical height, it must calculate the Y-DPI of the device and the
1720 map scaling factor.
1722 @param nHeight Height in device pixels
1724 @returns Height in logical units.
1726 SAL_DLLPRIVATE tools::Long ImplDevicePixelToLogicHeight( tools::Long nHeight ) const;
1728 /** Convert a logical size to the size on the physical device.
1730 @param rLogicSize Const reference to a size in logical units
1732 @returns Physical size on the device.
1734 SAL_DLLPRIVATE Size ImplLogicToDevicePixel( const Size& rLogicSize ) const;
1736 /** Convert a rectangle in physical pixel units to a rectangle in physical pixel units and coords.
1738 @param rPixelRect Const reference to rectangle in logical units and coords.
1740 @returns Rectangle based on logical coordinates and units.
1742 SAL_DLLPRIVATE tools::Rectangle ImplDevicePixelToLogic( const tools::Rectangle& rPixelRect ) const;
1744 /** Convert a logical polygon to a polygon in physical device pixel units.
1746 @param rLogicPoly Const reference to a polygon in logical units
1748 @returns Polygon based on physical device pixel coordinates and units.
1750 SAL_DLLPRIVATE tools::Polygon ImplLogicToDevicePixel( const tools::Polygon& rLogicPoly ) const;
1752 /** Convert a logical B2DPolygon to a B2DPolygon in physical device pixel units.
1754 @param rLogicSize Const reference to a B2DPolygon in logical units
1756 @returns B2DPolyPolygon based on physical device pixel coordinates and units.
1758 SAL_DLLPRIVATE ::basegfx::B2DPolygon ImplLogicToDevicePixel( const ::basegfx::B2DPolygon& rLogicPoly ) const;
1760 /** Convert a logical polypolygon to a polypolygon in physical device pixel units.
1762 @param rLogicPolyPoly Const reference to a polypolygon in logical units
1764 @returns Polypolygon based on physical device pixel coordinates and units.
1766 SAL_DLLPRIVATE tools::PolyPolygon ImplLogicToDevicePixel( const tools::PolyPolygon& rLogicPolyPoly ) const;
1768 /** Convert a line in logical units to a line in physical device pixel units.
1770 @param rLineInfo Const reference to a line in logical units
1772 @returns Line based on physical device pixel coordinates and units.
1774 SAL_DLLPRIVATE LineInfo ImplLogicToDevicePixel( const LineInfo& rLineInfo ) const;
1776 /** Convert a region in pixel units to a region in device pixel units and coords.
1778 @param rRegion Const reference to region.
1780 @returns vcl::Region based on device pixel coordinates and units.
1782 SAL_DLLPRIVATE vcl::Region ImplPixelToDevicePixel( const vcl::Region& rRegion ) const;
1784 /** Invalidate the view transformation.
1786 @since AOO bug 75163 (OpenOffice.org 2.4.3 - OOH 680 milestone 212)
1788 SAL_DLLPRIVATE void ImplInvalidateViewTransform();
1790 /** Get device transformation.
1792 @since AOO bug 75163 (OpenOffice.org 2.4.3 - OOH 680 milestone 212)
1794 SAL_DLLPRIVATE basegfx::B2DHomMatrix ImplGetDeviceTransformation() const;
1796 private:
1797 /** Convert a logical X coordinate to a device pixel's X coordinate.
1799 To get the device's X coordinate, it must calculate the mapping offset
1800 coordinate X position (if there is one - if not then it just adds
1801 the pseudo-window offset to the logical X coordinate), the X-DPI of
1802 the device and the mapping's X scaling factor.
1804 @param nX Logical X coordinate
1806 @returns Device's X pixel coordinate
1808 SAL_DLLPRIVATE tools::Long ImplLogicXToDevicePixel( tools::Long nX ) const;
1810 /** Convert a logical Y coordinate to a device pixel's Y coordinate.
1812 To get the device's Y coordinate, it must calculate the mapping offset
1813 coordinate Y position (if there is one - if not then it just adds
1814 the pseudo-window offset to the logical Y coordinate), the Y-DPI of
1815 the device and the mapping's Y scaling factor.
1817 @param nY Logical Y coordinate
1819 @returns Device's Y pixel coordinate
1821 SAL_DLLPRIVATE tools::Long ImplLogicYToDevicePixel( tools::Long nY ) const;
1823 /** @name Native Widget Rendering functions
1825 These all just call through to the private mpGraphics functions of the same name.
1827 ///@{
1829 public:
1831 /** Determine if native widgets can be enabled
1833 virtual bool CanEnableNativeWidget() const { return false; }
1835 /** Query the platform layer for control support
1837 bool IsNativeControlSupported( ControlType nType, ControlPart nPart ) const;
1839 /** Query the native control to determine if it was acted upon
1841 bool HitTestNativeScrollbar(
1842 ControlPart nPart,
1843 const tools::Rectangle& rControlRegion,
1844 const Point& aPos,
1845 bool& rIsInside ) const;
1847 /** Request rendering of a particular control and/or part
1849 bool DrawNativeControl(
1850 ControlType nType,
1851 ControlPart nPart,
1852 const tools::Rectangle& rControlRegion,
1853 ControlState nState,
1854 const ImplControlValue& aValue,
1855 const OUString& aCaption,
1856 const Color& rBackgroundColor = COL_AUTO );
1858 /** Query the native control's actual drawing region (including adornment)
1860 bool GetNativeControlRegion(
1861 ControlType nType,
1862 ControlPart nPart,
1863 const tools::Rectangle& rControlRegion,
1864 ControlState nState,
1865 const ImplControlValue& aValue,
1866 tools::Rectangle &rNativeBoundingRegion,
1867 tools::Rectangle &rNativeContentRegion ) const;
1868 ///@}
1870 /** @name EPS functions
1872 ///@{
1874 public:
1876 /** @returns boolean value to see if EPS could be painted directly.
1877 Theoretically, handing over a matrix would be needed to handle
1878 painting rotated EPS files (e.g. contained in Metafiles). This
1879 would then need to be supported for Mac and PS printers, but
1880 that's too much for now, wrote \#i107046# for this */
1881 bool DrawEPS(
1882 const Point& rPt, const Size& rSz,
1883 const GfxLink& rGfxLink, GDIMetaFile* pSubst = nullptr );
1884 ///@}
1886 public:
1887 virtual css::awt::DeviceInfo GetDeviceInfo() const;
1889 /** Get the vcl::Window that this OutputDevice belongs to, if any */
1890 virtual vcl::Window* GetOwnerWindow() const { return nullptr; }
1892 protected:
1893 css::awt::DeviceInfo GetCommonDeviceInfo(Size const& aDevSize) const;
1897 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */