Branch libreoffice-5-0-4
[LibreOffice.git] / include / vcl / outdev.hxx
blobdbd57e6ad3398c5620c04b9f76fd80398be0449f
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 #ifndef INCLUDED_VCL_OUTDEV_HXX
21 #define INCLUDED_VCL_OUTDEV_HXX
23 #include <tools/gen.hxx>
24 #include <tools/solar.h>
25 #include <tools/rc.hxx>
26 #include <tools/color.hxx>
27 #include <tools/poly.hxx>
28 #include <o3tl/typed_flags_set.hxx>
30 #include <vcl/cairo.hxx>
31 #include <vcl/devicecoordinate.hxx>
32 #include <vcl/dllapi.h>
33 #include <vcl/font.hxx>
34 #include <vcl/region.hxx>
35 #include <vcl/mapmod.hxx>
36 #include <vcl/wall.hxx>
37 #include <vcl/metaact.hxx>
38 #include <vcl/metaactiontypes.hxx>
39 #include <vcl/salnativewidgets.hxx>
40 #include <vcl/outdevstate.hxx>
41 #include <vcl/outdevmap.hxx>
43 #include <basegfx/vector/b2enums.hxx>
44 #include <basegfx/polygon/b2dpolypolygon.hxx>
46 #include <unotools/fontdefs.hxx>
48 #ifdef check
49 # //some problem with MacOSX and a check define
50 # undef check
51 #endif
52 #include <boost/intrusive_ptr.hpp>
54 #include <com/sun/star/drawing/LineCap.hpp>
55 #include <com/sun/star/uno/Reference.h>
57 #include <memory>
58 #include <vector>
60 struct ImplOutDevData;
61 class ImplFontEntry;
62 class OutDevState;
63 struct SystemGraphicsData;
64 struct SystemFontData;
65 struct SystemTextLayoutData;
66 class ImplFontCache;
67 class PhysicalFontCollection;
68 class ImplGetDevFontList;
69 class ImplGetDevSizeList;
70 class ImplMultiTextLineInfo;
71 class SalGraphics;
72 class Gradient;
73 class Hatch;
74 class AllSettings;
75 class Bitmap;
76 class BitmapReadAccess;
77 class BitmapEx;
78 class Image;
79 class TextRectInfo;
80 class FontMetric;
81 class GDIMetaFile;
82 class GfxLink;
83 class Line;
84 class LineInfo;
85 class AlphaMask;
86 class FontCharMap;
87 class SalLayout;
88 class ImplLayoutArgs;
89 class ImplFontAttributes;
90 class VirtualDevice;
91 struct SalTwoRect;
92 class VirtualDevice;
93 class Printer;
94 class FontSelectPattern;
95 class ImplFontMetricData;
96 class VCLXGraphics;
97 class OutDevStateStack;
98 struct BitmapSystemData;
100 namespace vcl
102 class PDFWriterImpl;
103 class ExtOutDevData;
104 class ITextLayout;
105 struct FontCapabilities;
106 class TextLayoutCache;
107 class Window;
108 class FontInfo;
111 namespace com { namespace sun { namespace star { namespace rendering {
112 class XCanvas;
113 }}}}
115 namespace basegfx {
116 class B2DHomMatrix;
117 class B2DPolygon;
118 class B2DPolyPolygon;
119 class B2IVector;
120 typedef B2IVector B2ISize;
123 namespace com { namespace sun { namespace star { namespace awt {
124 class XGraphics;
125 } } } }
127 #if defined UNX
128 #define GLYPH_FONT_HEIGHT 128
129 #else
130 #define GLYPH_FONT_HEIGHT 256
131 #endif
133 // Text Layout options
134 enum class SalLayoutFlags
136 NONE = 0x0000,
137 BiDiRtl = 0x0001,
138 BiDiStrong = 0x0002,
139 RightAlign = 0x0004,
140 KerningPairs = 0x0010,
141 KerningAsian = 0x0020,
142 Vertical = 0x0040,
143 ComplexDisabled = 0x0100,
144 EnableLigatures = 0x0200,
145 SubstituteDigits = 0x0400,
146 KashidaJustification = 0x0800,
147 DisableGlyphProcessing = 0x1000,
148 ForFallback = 0x2000,
149 DrawBullet = 0x4000,
151 namespace o3tl
153 template<> struct typed_flags<SalLayoutFlags> : is_typed_flags<SalLayoutFlags, 0x7f77> {};
156 typedef std::vector< Rectangle > MetricVector;
158 // OutputDevice-Types
160 // Flags for DrawText()
161 enum class DrawTextFlags
163 NONE = 0x0000,
164 Disable = 0x0001,
165 Mnemonic = 0x0002,
166 Mono = 0x0004,
167 Clip = 0x0008,
168 Left = 0x0010,
169 Center = 0x0020,
170 Right = 0x0040,
171 Top = 0x0080,
172 VCenter = 0x0100,
173 Bottom = 0x0200,
174 EndEllipsis = 0x0400,
175 PathEllipsis = 0x0800,
176 MultiLine = 0x1000,
177 WordBreak = 0x2000,
178 NewsEllipsis = 0x4000,
179 // in the long run we should make text style flags longer
180 // but at the moment we can get away with this 2 bit field for ellipsis style
181 CenterEllipsis = EndEllipsis | PathEllipsis,
182 WordBreakHyphenation = 0x8000 | WordBreak,
184 namespace o3tl
186 template<> struct typed_flags<DrawTextFlags> : is_typed_flags<DrawTextFlags, 0xffff> {};
189 // Flags for DrawImage(), these must match the definitions in css::awt::ImageDrawMode
190 enum class DrawImageFlags
192 NONE = 0x0000,
193 Disable = 0x0001,
194 Highlight = 0x0002,
195 Deactive = 0x0004,
196 ColorTransform = 0x0008,
197 SemiTransparent = 0x0010,
199 namespace o3tl
201 template<> struct typed_flags<DrawImageFlags> : is_typed_flags<DrawImageFlags, 0x001f> {};
204 // Flags for DrawGrid()
205 enum class DrawGridFlags
207 NONE = 0x0000,
208 Dots = 0x0001,
209 HorzLines = 0x0002,
210 VertLines = 0x0004,
211 Lines = HorzLines | VertLines,
213 namespace o3tl
215 template<> struct typed_flags<DrawGridFlags> : is_typed_flags<DrawGridFlags, 0x0007> {};
218 // DrawModes
219 enum class DrawModeFlags : sal_uLong
221 Default = 0x00000000,
222 BlackLine = 0x00000001,
223 BlackFill = 0x00000002,
224 BlackText = 0x00000004,
225 BlackBitmap = 0x00000008,
226 BlackGradient = 0x00000010,
227 GrayLine = 0x00000020,
228 GrayFill = 0x00000040,
229 GrayText = 0x00000080,
230 GrayBitmap = 0x00000100,
231 GrayGradient = 0x00000200,
232 NoFill = 0x00000400,
233 NoBitmap = 0x00000800,
234 NoGradient = 0x00001000,
235 GhostedLine = 0x00002000,
236 GhostedFill = 0x00004000,
237 GhostedText = 0x00008000,
238 GhostedBitmap = 0x00010000,
239 GhostedGradient = 0x00020000,
240 WhiteLine = 0x00100000,
241 WhiteFill = 0x00200000,
242 WhiteText = 0x00400000,
243 WhiteBitmap = 0x00800000,
244 WhiteGradient = 0x01000000,
245 SettingsLine = 0x02000000,
246 SettingsFill = 0x04000000,
247 SettingsText = 0x08000000,
248 SettingsGradient = 0x10000000,
249 NoTransparency = 0x80000000,
251 namespace o3tl
253 template<> struct typed_flags<DrawModeFlags> : is_typed_flags<DrawModeFlags, 0x9ff3ffff> {};
256 // Antialiasing
257 enum class AntialiasingFlags
259 NONE = 0x0000,
260 DisableText = 0x0001,
261 EnableB2dDraw = 0x0002,
262 PixelSnapHairline = 0x0004,
264 namespace o3tl
266 template<> struct typed_flags<AntialiasingFlags> : is_typed_flags<AntialiasingFlags, 0x07> {};
269 // AddFontSubstitute() flags
270 enum class AddFontSubstituteFlags
272 NONE = 0x00,
273 ALWAYS = 0x01,
274 ScreenOnly = 0x02,
276 namespace o3tl
278 template<> struct typed_flags<AddFontSubstituteFlags> : is_typed_flags<AddFontSubstituteFlags, 0x03> {};
281 // GetDefaultFont() flags
282 enum GetDefaultFontFlags
284 NONE = 0x0000,
285 OnlyOne = 0x0001,
287 namespace o3tl
289 template<> struct typed_flags<GetDefaultFontFlags> : is_typed_flags<GetDefaultFontFlags, 0x01> {};
292 // Flags for Invert()
293 #define INVERT_HIGHLIGHT ((sal_uInt16)0x0001)
294 #define INVERT_50 ((sal_uInt16)0x0002)
296 enum OutDevType { OUTDEV_DONTKNOW, OUTDEV_WINDOW, OUTDEV_PRINTER, OUTDEV_VIRDEV };
298 enum OutDevViewType { OUTDEV_VIEWTYPE_DONTKNOW, OUTDEV_VIEWTYPE_PRINTPREVIEW, OUTDEV_VIEWTYPE_SLIDESHOW };
300 // OutputDevice
302 typedef boost::intrusive_ptr< FontCharMap > FontCharMapPtr;
304 BmpMirrorFlags AdjustTwoRect( SalTwoRect& rTwoRect, const Size& rSizePix );
305 void AdjustTwoRect( SalTwoRect& rTwoRect, const Rectangle& rValidSrcRect );
307 extern const sal_uLong nVCLRLut[ 6 ];
308 extern const sal_uLong nVCLGLut[ 6 ];
309 extern const sal_uLong nVCLBLut[ 6 ];
310 extern const sal_uLong nVCLDitherLut[ 256 ];
311 extern const sal_uLong nVCLLut[ 256 ];
313 class OutputDevice;
315 namespace vcl {
316 typedef OutputDevice RenderContext;
319 class VCL_DLLPUBLIC OutputDevice
321 friend class Printer;
322 friend class VirtualDevice;
323 friend class vcl::Window;
324 friend class WorkWindow;
325 friend class vcl::PDFWriterImpl;
326 friend void ImplHandleResize( vcl::Window* pWindow, long nNewWidth, long nNewHeight );
328 // All of this will need to be replicated in Window
329 // or a shared base-class as/when we can break the
330 // OutputDevice -> Window inheritance.
331 private:
332 mutable int mnRefCnt; // reference count
334 template<typename T> friend class ::rtl::Reference;
335 template<typename T> friend class ::VclPtr;
337 inline void acquire() const
339 assert(mnRefCnt>0);
340 mnRefCnt++;
343 inline void release() const
345 assert(mnRefCnt>0);
346 if (!--mnRefCnt)
347 delete this;
350 private:
351 OutputDevice(const OutputDevice&) SAL_DELETED_FUNCTION;
352 OutputDevice& operator=(const OutputDevice&) SAL_DELETED_FUNCTION;
354 mutable SalGraphics* mpGraphics; ///< Graphics context to draw on
355 mutable VclPtr<OutputDevice> mpPrevGraphics; ///< Previous output device in list
356 mutable VclPtr<OutputDevice> mpNextGraphics; ///< Next output device in list
357 GDIMetaFile* mpMetaFile;
358 mutable ImplFontEntry* mpFontEntry;
359 mutable ImplFontCache* mpFontCache;
360 mutable PhysicalFontCollection* mpFontCollection;
361 mutable ImplGetDevFontList* mpGetDevFontList;
362 mutable ImplGetDevSizeList* mpGetDevSizeList;
363 OutDevStateStack* mpOutDevStateStack;
364 ImplOutDevData* mpOutDevData;
365 std::vector< VCLXGraphics* >* mpUnoGraphicsList;
366 vcl::PDFWriterImpl* mpPDFWriter;
367 vcl::ExtOutDevData* mpExtOutDevData;
369 // TEMP TEMP TEMP
370 VclPtr<VirtualDevice> mpAlphaVDev;
372 /// Additional output pixel offset, applied in LogicToPixel (used by SetPixelOffset/GetPixelOffset)
373 long mnOutOffOrigX;
374 /// Additional output offset in _logical_ coordinates, applied in PixelToLogic (used by SetPixelOffset/GetPixelOffset)
375 long mnOutOffLogicX;
376 /// Additional output pixel offset, applied in LogicToPixel (used by SetPixelOffset/GetPixelOffset)
377 long mnOutOffOrigY;
378 /// Additional output offset in _logical_ coordinates, applied in PixelToLogic (used by SetPixelOffset/GetPixelOffset)
379 long mnOutOffLogicY;
380 /// Output offset for device output in pixel (pseudo window offset within window system's frames)
381 long mnOutOffX;
382 /// Output offset for device output in pixel (pseudo window offset within window system's frames)
383 long mnOutOffY;
384 long mnOutWidth;
385 long mnOutHeight;
386 sal_Int32 mnDPIX;
387 sal_Int32 mnDPIY;
388 sal_Int32 mnDPIScaleFactor; ///< For Hi-DPI displays, we want to draw everything mnDPIScaleFactor-times larger
389 /// font specific text alignment offsets in pixel units
390 mutable long mnTextOffX;
391 mutable long mnTextOffY;
392 mutable long mnEmphasisAscent;
393 mutable long mnEmphasisDescent;
394 DrawModeFlags mnDrawMode;
395 ComplexTextLayoutMode mnTextLayoutMode;
396 ImplMapRes maMapRes;
397 ImplThresholdRes maThresRes;
398 OutDevType meOutDevType;
399 OutDevViewType meOutDevViewType;
400 vcl::Region maRegion; // contains the clip region, see SetClipRegion(...)
401 Color maLineColor;
402 Color maFillColor;
403 vcl::Font maFont;
404 Color maTextColor;
405 Color maTextLineColor;
406 Color maOverlineColor;
407 TextAlign meTextAlign;
408 RasterOp meRasterOp;
409 Wallpaper maBackground;
410 std::unique_ptr<AllSettings> mxSettings;
411 MapMode maMapMode;
412 Point maRefPoint;
413 AntialiasingFlags mnAntialiasing;
414 LanguageType meTextLanguage;
416 /// bitfield
417 mutable bool mbMap : 1;
418 mutable bool mbMapIsDefault : 1;
419 mutable bool mbClipRegion : 1;
420 mutable bool mbBackground : 1;
421 mutable bool mbOutput : 1;
422 mutable bool mbDevOutput : 1;
423 mutable bool mbOutputClipped : 1;
424 mutable bool mbLineColor : 1;
425 mutable bool mbFillColor : 1;
426 mutable bool mbInitLineColor : 1;
427 mutable bool mbInitFillColor : 1;
428 mutable bool mbInitFont : 1;
429 mutable bool mbInitTextColor : 1;
430 mutable bool mbInitClipRegion : 1;
431 mutable bool mbClipRegionSet : 1;
432 mutable bool mbKerning : 1;
433 mutable bool mbNewFont : 1;
434 mutable bool mbTextLines : 1;
435 mutable bool mbTextBackground : 1;
436 mutable bool mbTextSpecial : 1;
437 mutable bool mbRefPoint : 1;
438 mutable bool mbEnableRTL : 1;
439 mutable bool mbDisposed : 1;
441 /** @name Initialization and accessor functions
443 ///@{
445 protected:
446 OutputDevice();
447 public:
448 virtual ~OutputDevice();
450 protected:
451 /// release all references to other objects.
452 virtual void dispose();
454 public:
455 /// call the dispose() method if we have not already been disposed.
456 void disposeOnce();
457 bool isDisposed() const { return mbDisposed; }
459 public:
461 /** Get the graphic context that the output device uses to draw on.
463 If no graphics device exists, then initialize it.
465 @returns SalGraphics instance.
467 SalGraphics const *GetGraphics() const;
468 SalGraphics* GetGraphics();
470 void SetConnectMetaFile( GDIMetaFile* pMtf );
471 GDIMetaFile* GetConnectMetaFile() const { return mpMetaFile; }
473 virtual void SetSettings( const AllSettings& rSettings );
474 const AllSettings& GetSettings() const { return *mxSettings; }
476 SystemGraphicsData GetSystemGfxData() const;
477 bool SupportsCairo() const;
478 /// Create Surface from given cairo surface
479 cairo::SurfaceSharedPtr CreateSurface(const cairo::CairoSurfaceSharedPtr& rSurface) const;
480 /// Create surface with given dimensions
481 cairo::SurfaceSharedPtr CreateSurface(int x, int y, int width, int height) const;
482 /// Create Surface for given bitmap data
483 cairo::SurfaceSharedPtr CreateBitmapSurface(const BitmapSystemData& rData, const Size& rSize) const;
484 /// Return native handle for underlying surface
485 css::uno::Any GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& rSurface, const ::basegfx::B2ISize& rSize) const;
486 css::uno::Any GetSystemGfxDataAny() const;
488 void SetRefPoint();
489 void SetRefPoint( const Point& rRefPoint );
490 const Point& GetRefPoint() const { return maRefPoint; }
491 bool IsRefPoint() const { return mbRefPoint; }
493 virtual sal_uInt16 GetBitCount() const;
495 Size GetOutputSizePixel() const
496 { return Size( mnOutWidth, mnOutHeight ); }
497 long GetOutputWidthPixel() const { return mnOutWidth; }
498 long GetOutputHeightPixel() const { return mnOutHeight; }
499 long GetOutOffXPixel() const { return mnOutOffX; }
500 long GetOutOffYPixel() const { return mnOutOffY; }
501 void SetOutOffXPixel(long nOutOffX);
502 void SetOutOffYPixel(long nOutOffY);
504 Size GetOutputSize() const
505 { return PixelToLogic( GetOutputSizePixel() ); }
507 sal_uLong GetColorCount() const;
510 /// request XCanvas render interface for this OutputDevice
511 css::uno::Reference< css::rendering::XCanvas >
512 GetCanvas() const;
514 css::uno::Reference< css::awt::XGraphics >
515 CreateUnoGraphics();
516 std::vector< VCLXGraphics* > *GetUnoGraphicsList() const { return mpUnoGraphicsList; }
517 std::vector< VCLXGraphics* > *CreateUnoGraphicsList();
519 protected:
521 /** Acquire a graphics device that the output device uses to draw on.
523 There is an LRU of OutputDevices that is used to get the graphics. The
524 actual creation of a SalGraphics instance is done via the SalFrame
525 implementation.
527 However, the SalFrame instance will only return a valid SalGraphics
528 instance if it is not in use or there wasn't one in the first place. When
529 this happens, AcquireGraphics finds the least recently used OutputDevice
530 in a different frame and "steals" it (releases it then starts using it).
532 If there are no frames to steal an OutputDevice's SalGraphics instance from
533 then it blocks until the graphics is released.
535 Once it has acquired a graphics instance, then we add the OutputDevice to
536 the LRU.
538 @returns true if was able to initialize the graphics device, false otherwise.
540 virtual bool AcquireGraphics() const = 0;
542 /** Release the graphics device, and remove it from the graphics device
543 list.
545 @param bRelease Determines whether to release the fonts of the
546 physically released graphics device.
548 virtual void ReleaseGraphics( bool bRelease = true ) = 0;
549 ///@}
552 /** @name Helper functions
554 ///@{
556 public:
558 /** Get the output device's DPI x-axis value.
560 @returns x-axis DPI value
562 SAL_DLLPRIVATE sal_Int32 GetDPIX() const { return mnDPIX; }
564 /** Get the output device's DPI y-axis value.
566 @returns y-axis DPI value
568 SAL_DLLPRIVATE sal_Int32 GetDPIY() const { return mnDPIY; }
570 SAL_DLLPRIVATE void SetDPIX( sal_Int32 nDPIX ) { mnDPIX = nDPIX; }
571 SAL_DLLPRIVATE void SetDPIY( sal_Int32 nDPIY ) { mnDPIY = nDPIY; }
573 sal_Int32 GetDPIScaleFactor() const { return mnDPIScaleFactor; }
575 OutDevType GetOutDevType() const { return meOutDevType; }
577 /** Query an OutputDevice to see whether it supports a specific operation
579 @returns true if operation supported, else false
581 bool SupportsOperation( OutDevSupportType ) const;
583 vcl::PDFWriterImpl* GetPDFWriter() const { return mpPDFWriter; }
585 void SetExtOutDevData( vcl::ExtOutDevData* pExtOutDevData ) { mpExtOutDevData = pExtOutDevData; }
586 vcl::ExtOutDevData* GetExtOutDevData() const { return mpExtOutDevData; }
588 ///@}
591 /** @Name Direct OutputDevice drawing functions
593 ///@{
595 public:
597 virtual void DrawOutDev(
598 const Point& rDestPt, const Size& rDestSize,
599 const Point& rSrcPt, const Size& rSrcSize );
601 virtual void DrawOutDev(
602 const Point& rDestPt, const Size& rDestSize,
603 const Point& rSrcPt, const Size& rSrcSize,
604 const OutputDevice& rOutDev );
606 virtual void CopyArea(
607 const Point& rDestPt,
608 const Point& rSrcPt, const Size& rSrcSize,
609 bool bWindowInvalidate = false );
612 * Instantiate across a paint operation to defer flushing
613 * to the end.
615 * NB. holding a handle avoids problems with
616 * the underlying SalGraphics and it's implementation
617 * changing.
619 class PaintScope {
620 void *pHandle;
621 public:
622 PaintScope(OutputDevice *);
623 ~PaintScope();
624 void flush();
627 protected:
629 virtual void CopyDeviceArea( SalTwoRect& aPosAry, bool bWindowInvalidate = false);
631 SAL_DLLPRIVATE void drawOutDevDirect ( const OutputDevice* pSrcDev, SalTwoRect& rPosAry );
633 SAL_DLLPRIVATE bool is_double_buffered_window() const;
635 private:
637 // not implemented; to detect misuses of DrawOutDev(...OutputDevice&);
638 SAL_DLLPRIVATE void DrawOutDev( const Point&, const Size&, const Point&, const Size&, const Printer&) SAL_DELETED_FUNCTION;
639 ///@}
642 /** @name OutputDevice state functions
644 ///@{
646 public:
648 void Push( PushFlags nFlags = PushFlags::ALL );
649 void Pop();
651 // returns the current stack depth; that is the number of Push() calls minus the number of Pop() calls
652 // this should not normally be used since Push and Pop must always be used symmetrically
653 // however this may be e.g. a help when debugging code in which this somehow is not the case
654 sal_uInt32 GetGCStackDepth() const;
656 void EnableOutput( bool bEnable = true );
657 bool IsOutputEnabled() const { return mbOutput; }
658 bool IsDeviceOutput() const { return mbDevOutput; }
659 bool IsDeviceOutputNecessary() const { return (mbOutput && mbDevOutput); }
660 bool IsOutputNecessary() const { return ((mbOutput && mbDevOutput) || (mpMetaFile != NULL)); }
662 void SetAntialiasing( AntialiasingFlags nMode = AntialiasingFlags::NONE );
663 AntialiasingFlags GetAntialiasing() const { return mnAntialiasing; }
665 void SetDrawMode( DrawModeFlags nDrawMode );
666 DrawModeFlags GetDrawMode() const { return mnDrawMode; }
668 void SetLayoutMode( ComplexTextLayoutMode nTextLayoutMode );
669 ComplexTextLayoutMode GetLayoutMode() const { return mnTextLayoutMode; }
671 void SetDigitLanguage( LanguageType );
672 LanguageType GetDigitLanguage() const { return meTextLanguage; }
674 void SetRasterOp( RasterOp eRasterOp );
675 RasterOp GetRasterOp() const { return meRasterOp; }
678 If this OutputDevice is used for displaying a Print Preview
679 the OutDevViewType should be set to 'OUTDEV_VIEWTYPE_PRINTPREVIEW'.
681 A View can then make painting decisions dependent on this OutDevViewType.
682 E.g. text colors need to be handled differently, dependent on whether it's a PrintPreview or not. (see #106611# for more)
684 void SetOutDevViewType( OutDevViewType eOutDevViewType ) { meOutDevViewType=eOutDevViewType; }
685 OutDevViewType GetOutDevViewType() const { return meOutDevViewType; }
687 void SetLineColor();
688 void SetLineColor( const Color& rColor );
689 const Color& GetLineColor() const { return maLineColor; }
690 bool IsLineColor() const { return mbLineColor; }
692 void SetFillColor();
693 void SetFillColor( const Color& rColor );
694 const Color& GetFillColor() const { return maFillColor; }
695 bool IsFillColor() const { return mbFillColor; }
697 void SetBackground();
698 void SetBackground( const Wallpaper& rBackground );
700 const Wallpaper& GetBackground() const { return maBackground; }
701 bool IsBackground() const { return mbBackground; }
703 void SetFont( const vcl::Font& rNewFont );
704 const vcl::Font& GetFont() const { return maFont; }
706 protected:
708 virtual void ImplReleaseFonts();
710 private:
712 SAL_DLLPRIVATE void InitLineColor();
714 SAL_DLLPRIVATE void InitFillColor();
716 ///@}
719 /** @name Clipping functions
721 ///@{
723 public:
725 vcl::Region GetClipRegion() const;
726 void SetClipRegion();
727 void SetClipRegion( const vcl::Region& rRegion );
728 bool SelectClipRegion( const vcl::Region&, SalGraphics* pGraphics = NULL );
730 bool IsClipRegion() const { return mbClipRegion; }
732 void MoveClipRegion( long nHorzMove, long nVertMove );
733 void IntersectClipRegion( const Rectangle& rRect );
734 void IntersectClipRegion( const vcl::Region& rRegion );
736 virtual vcl::Region GetActiveClipRegion() const;
738 protected:
740 virtual void InitClipRegion();
741 virtual void ClipToPaintRegion ( Rectangle& rDstRect );
743 private:
745 SAL_DLLPRIVATE void SetDeviceClipRegion( const vcl::Region* pRegion );
746 ///@}
749 /** @name Pixel functions
751 ///@{
753 public:
755 void DrawPixel( const Point& rPt );
756 void DrawPixel( const Point& rPt, const Color& rColor );
757 void DrawPixel( const Polygon& rPts, const Color* pColors = NULL );
758 void DrawPixel( const Polygon& rPts, const Color& rColor );
760 Color GetPixel( const Point& rPt ) const;
761 ///@}
764 /** @name Rectangle functions
766 ///@{
768 public:
770 void DrawRect( const Rectangle& rRect );
771 void DrawRect( const Rectangle& rRect,
772 sal_uLong nHorzRount, sal_uLong nVertRound );
774 /// Fill the given rectangle with checkered rectangles of size nLen x nLen using the colors aStart and aEnd
775 void DrawCheckered(
776 const Point& rPos,
777 const Size& rSize,
778 sal_uInt32 nLen = 8,
779 Color aStart = Color(COL_WHITE),
780 Color aEnd = Color(COL_BLACK));
782 void DrawGrid( const Rectangle& rRect, const Size& rDist, DrawGridFlags nFlags );
784 ///@}
786 /** @name Invert functions
788 ///@{
789 public:
790 void Invert( const Rectangle& rRect, sal_uInt16 nFlags = 0 );
791 void Invert( const Polygon& rPoly, sal_uInt16 nFlags = 0 );
792 ///@}
794 /** @name Line functions
796 ///@{
798 public:
800 void DrawLine( const Point& rStartPt, const Point& rEndPt );
802 void DrawLine( const Point& rStartPt, const Point& rEndPt,
803 const LineInfo& rLineInfo );
805 private:
807 /** Helper for line geometry paint with support for graphic expansion (pattern and fat_to_area)
809 SAL_DLLPRIVATE void drawLine( basegfx::B2DPolyPolygon aLinePolyPolygon, const LineInfo& rInfo );
810 ///@}
813 /** @name Polyline functions
815 ///@{
817 public:
819 /** Render the given polygon as a line stroke
821 The given polygon is stroked with the current LineColor, start
822 and end point are not automatically connected
824 @see DrawPolygon
825 @see DrawPolyPolygon
827 void DrawPolyLine( const Polygon& rPoly );
829 void DrawPolyLine(
830 const basegfx::B2DPolygon&,
831 double fLineWidth = 0.0,
832 basegfx::B2DLineJoin eLineJoin = basegfx::B2DLINEJOIN_ROUND,
833 css::drawing::LineCap eLineCap = css::drawing::LineCap_BUTT);
835 /** Render the given polygon as a line stroke
837 The given polygon is stroked with the current LineColor, start
838 and end point are not automatically connected. The line is
839 rendered according to the specified LineInfo, e.g. supplying a
840 dash pattern, or a line thickness.
842 @see DrawPolygon
843 @see DrawPolyPolygon
845 void DrawPolyLine( const Polygon& rPoly,
846 const LineInfo& rLineInfo );
848 // #i101491#
849 // Helper who tries to use SalGDI's DrawPolyLine direct and returns it's bool.
850 bool DrawPolyLineDirect(
851 const basegfx::B2DPolygon& rB2DPolygon,
852 double fLineWidth = 0.0,
853 double fTransparency = 0.0,
854 basegfx::B2DLineJoin eLineJoin = basegfx::B2DLINEJOIN_NONE,
855 css::drawing::LineCap eLineCap = css::drawing::LineCap_BUTT,
856 bool bBypassAACheck = false );
857 private:
859 // #i101491#
860 // Helper which holds the old line geometry creation and is extended to use AA when
861 // switched on. Advantage is that line geometry is only temporarily used for paint
862 SAL_DLLPRIVATE void drawPolyLine(const Polygon& rPoly, const LineInfo& rLineInfo);
864 ///@}
867 /** @name Polygon functions
869 ///@{
871 public:
873 /** Render the given polygon
875 The given polygon is stroked with the current LineColor, and
876 filled with the current FillColor. If one of these colors are
877 transparent, the corresponding stroke or fill stays
878 invisible. Start and end point of the polygon are
879 automatically connected.
881 @see DrawPolyLine
883 void DrawPolygon( const Polygon& rPoly );
884 void DrawPolygon( const basegfx::B2DPolygon& );
886 /** Render the given poly-polygon
888 The given poly-polygon is stroked with the current LineColor,
889 and filled with the current FillColor. If one of these colors
890 are transparent, the corresponding stroke or fill stays
891 invisible. Start and end points of the contained polygons are
892 automatically connected.
894 @see DrawPolyLine
896 void DrawPolyPolygon( const tools::PolyPolygon& rPolyPoly );
897 void DrawPolyPolygon( const basegfx::B2DPolyPolygon& );
899 private:
901 SAL_DLLPRIVATE void ImplDrawPolygon( const Polygon& rPoly, const tools::PolyPolygon* pClipPolyPoly = NULL );
902 SAL_DLLPRIVATE void ImplDrawPolyPolygon( const tools::PolyPolygon& rPolyPoly, const tools::PolyPolygon* pClipPolyPoly = NULL );
903 SAL_DLLPRIVATE void ImplDrawPolyPolygon( sal_uInt16 nPoly, const tools::PolyPolygon& rPolyPoly );
904 // #i101491#
905 // Helper who implements the DrawPolyPolygon functionality for basegfx::B2DPolyPolygon
906 // without MetaFile processing
907 SAL_DLLPRIVATE void ImplDrawPolyPolygonWithB2DPolyPolygon(const basegfx::B2DPolyPolygon& rB2DPolyPoly);
908 ///@}
911 /** @name Curved shape functions
913 ///@{
915 public:
917 void DrawEllipse( const Rectangle& rRect );
919 void DrawArc(
920 const Rectangle& rRect,
921 const Point& rStartPt, const Point& rEndPt );
923 void DrawPie(
924 const Rectangle& rRect,
925 const Point& rStartPt, const Point& rEndPt );
927 void DrawChord(
928 const Rectangle& rRect,
929 const Point& rStartPt, const Point& rEndPt );
931 ///@}
934 /** @name Gradient functions
936 ///@{
938 public:
939 void DrawGradient( const Rectangle& rRect, const Gradient& rGradient );
940 void DrawGradient( const tools::PolyPolygon& rPolyPoly, const Gradient& rGradient );
942 void AddGradientActions(
943 const Rectangle& rRect,
944 const Gradient& rGradient,
945 GDIMetaFile& rMtf );
947 protected:
949 virtual bool UsePolyPolygonForComplexGradient() = 0;
951 virtual long GetGradientStepCount( long nMinRect );
953 private:
955 SAL_DLLPRIVATE void DrawLinearGradient( const Rectangle& rRect, const Gradient& rGradient, const tools::PolyPolygon* pClipPolyPoly );
956 SAL_DLLPRIVATE void DrawComplexGradient( const Rectangle& rRect, const Gradient& rGradient, const tools::PolyPolygon* pClipPolyPoly );
958 SAL_DLLPRIVATE void DrawGradientToMetafile( const tools::PolyPolygon& rPolyPoly, const Gradient& rGradient );
959 SAL_DLLPRIVATE void DrawLinearGradientToMetafile( const Rectangle& rRect, const Gradient& rGradient );
960 SAL_DLLPRIVATE void DrawComplexGradientToMetafile( const Rectangle& rRect, const Gradient& rGradient );
962 SAL_DLLPRIVATE long GetGradientSteps( const Gradient& rGradient, const Rectangle& rRect, bool bMtf, bool bComplex=false );
964 SAL_DLLPRIVATE Color GetSingleColorGradientFill();
965 SAL_DLLPRIVATE void SetGrayscaleColors( Gradient &rGradient );
966 ///@}
969 /** @name Hatch functions
971 ///@{
973 public:
975 #ifdef _MSC_VER
976 void DrawHatch( const tools::PolyPolygon& rPolyPoly, const ::Hatch& rHatch );
977 void AddHatchActions( const tools::PolyPolygon& rPolyPoly,
978 const ::Hatch& rHatch,
979 GDIMetaFile& rMtf );
980 #else
981 void DrawHatch( const tools::PolyPolygon& rPolyPoly, const Hatch& rHatch );
982 void AddHatchActions( const tools::PolyPolygon& rPolyPoly,
983 const Hatch& rHatch,
984 GDIMetaFile& rMtf );
985 #endif
987 void DrawHatch( const tools::PolyPolygon& rPolyPoly, const Hatch& rHatch, bool bMtf );
989 private:
991 SAL_DLLPRIVATE void CalcHatchValues( const Rectangle& rRect, long nDist, sal_uInt16 nAngle10, Point& rPt1, Point& rPt2, Size& rInc, Point& rEndPt1 );
992 SAL_DLLPRIVATE void DrawHatchLine( const Line& rLine, const tools::PolyPolygon& rPolyPoly, Point* pPtBuffer, bool bMtf );
993 ///@}
996 /** @name Wallpaper functions
998 ///@{
1000 public:
1001 void DrawWallpaper( const Rectangle& rRect, const Wallpaper& rWallpaper );
1003 virtual void Erase();
1004 virtual void Erase( const Rectangle& rRect ) { DrawWallpaper( rRect, GetBackground() ); }
1006 protected:
1007 virtual void DrawGradientWallpaper( long nX, long nY, long nWidth, long nHeight, const Wallpaper& rWallpaper );
1009 private:
1010 SAL_DLLPRIVATE void DrawWallpaper( long nX, long nY, long nWidth, long nHeight, const Wallpaper& rWallpaper );
1011 SAL_DLLPRIVATE void DrawColorWallpaper( long nX, long nY, long nWidth, long nHeight, const Wallpaper& rWallpaper );
1012 SAL_DLLPRIVATE void DrawBitmapWallpaper( long nX, long nY, long nWidth, long nHeight, const Wallpaper& rWallpaper );
1013 ///@}
1016 /** @name Text functions
1018 ///@{
1020 public:
1022 void DrawText( const Point& rStartPt, const OUString& rStr,
1023 sal_Int32 nIndex = 0, sal_Int32 nLen = -1,
1024 MetricVector* pVector = NULL, OUString* pDisplayText = NULL );
1026 void DrawText( const Rectangle& rRect,
1027 const OUString& rStr, DrawTextFlags nStyle = DrawTextFlags::NONE,
1028 MetricVector* pVector = NULL, OUString* pDisplayText = NULL,
1029 vcl::ITextLayout* _pTextLayout = NULL );
1031 static void ImplDrawText( OutputDevice& rTargetDevice, const Rectangle& rRect,
1032 const OUString& rOrigStr, DrawTextFlags nStyle,
1033 MetricVector* pVector, OUString* pDisplayText, vcl::ITextLayout& _rLayout );
1035 void ImplDrawText( SalLayout& );
1037 void ImplDrawTextBackground( const SalLayout& );
1039 void DrawCtrlText( const Point& rPos, const OUString& rStr,
1040 sal_Int32 nIndex = 0, sal_Int32 nLen = -1,
1041 DrawTextFlags nStyle = DrawTextFlags::Mnemonic, MetricVector* pVector = NULL, OUString* pDisplayText = NULL );
1043 void DrawTextLine( const Point& rPos, long nWidth,
1044 FontStrikeout eStrikeout,
1045 FontUnderline eUnderline,
1046 FontUnderline eOverline,
1047 bool bUnderlineAbove = false );
1049 void ImplDrawTextLine( long nBaseX, long nX, long nY, DeviceCoordinate nWidth,
1050 FontStrikeout eStrikeout, FontUnderline eUnderline,
1051 FontUnderline eOverline, bool bUnderlineAbove );
1053 void ImplDrawTextLines( SalLayout&, FontStrikeout eStrikeout, FontUnderline eUnderline,
1054 FontUnderline eOverline, bool bWordLine, bool bUnderlineAbove );
1056 void DrawWaveLine( const Point& rStartPos, const Point& rEndPos );
1058 bool ImplDrawRotateText( SalLayout& );
1060 Rectangle GetTextRect( const Rectangle& rRect,
1061 const OUString& rStr, DrawTextFlags nStyle = DrawTextFlags::WordBreak,
1062 TextRectInfo* pInfo = NULL,
1063 const vcl::ITextLayout* _pTextLayout = NULL ) const;
1065 /** Return the exact bounding rectangle of rStr.
1067 The text is then drawn exactly from rRect.TopLeft() to
1068 rRect.BottomRight(), don't assume that rRect.TopLeft() is [0, 0].
1070 Please note that you don't always want to use GetTextBoundRect(); in
1071 many cases you actually want to use GetTextHeight(), because
1072 GetTextBoundRect() gives you the exact bounding rectangle regardless
1073 what is the baseline of the text.
1075 Code snippet to get just exactly the text (no filling around that) as
1076 a bitmap via a VirtualDevice (regardless what is the baseline):
1078 <code>
1079 VirtualDevice aDevice;
1080 vcl::Font aFont = aDevice.GetFont();
1081 aFont.SetSize(Size(0, 96));
1082 aFont.SetColor(COL_BLACK);
1083 aDevice.SetFont(aFont);
1084 aDevice.Erase();
1086 ::Rectangle aRect;
1087 aDevice.GetTextBoundRect(aRect, aText);
1088 aDevice.SetOutputSize(Size(aRect.BottomRight().X() + 1, aRect.BottomRight().Y() + 1));
1089 aDevice.SetBackground(Wallpaper(COL_TRANSPARENT));
1090 aDevice.DrawText(Point(0,0), aText);
1092 // exactly only the text, regardless of the baseline
1093 Bitmap aBitmap(aDevice.GetBitmap(aRect.TopLeft(), aRect.GetSize()));
1094 </code>
1096 Code snippet to get the text as a bitmap via a Virtual device that
1097 contains even the filling so that the baseline is always preserved
1098 (ie. the text will not jump up and down according to whether it
1099 contains 'y' or not etc.)
1101 <code>
1102 VirtualDevice aDevice;
1103 // + the appropriate font / device setup, see above
1105 aDevice.SetOutputSize(Size(aDevice.GetTextWidth(aText), aDevice.GetTextHeight()));
1106 aDevice.SetBackground(Wallpaper(COL_TRANSPARENT));
1107 aDevice.DrawText(Point(0,0), aText);
1109 // bitmap that contains even the space around the text,
1110 // that means, preserves the baseline etc.
1111 Bitmap aBitmap(aDevice.GetBitmap(Point(0, 0), aDevice.GetOutputSize()));
1112 </code>
1114 bool GetTextBoundRect( Rectangle& rRect,
1115 const OUString& rStr, sal_Int32 nBase = 0, sal_Int32 nIndex = 0, sal_Int32 nLen = -1,
1116 sal_uLong nLayoutWidth = 0, const long* pDXArray = NULL ) const;
1118 Rectangle ImplGetTextBoundRect( const SalLayout& );
1120 bool GetTextOutline( tools::PolyPolygon&,
1121 const OUString& rStr, sal_Int32 nBase = 0, sal_Int32 nIndex = 0,
1122 sal_Int32 nLen = -1, bool bOptimize = true,
1123 sal_uLong nLayoutWidth = 0, const long* pDXArray = NULL ) const;
1125 bool GetTextOutlines( PolyPolyVector&,
1126 const OUString& rStr, sal_Int32 nBase = 0, sal_Int32 nIndex = 0,
1127 sal_Int32 nLen = -1, bool bOptimize = true,
1128 sal_uLong nLayoutWidth = 0, const long* pDXArray = NULL ) const;
1130 bool GetTextOutlines( ::basegfx::B2DPolyPolygonVector &rVector,
1131 const OUString& rStr, sal_Int32 nBase = 0, sal_Int32 nIndex = 0,
1132 sal_Int32 nLen = -1, bool bOptimize = true,
1133 sal_uLong nLayoutWidth = 0, const long* pDXArray = NULL ) const;
1136 OUString GetEllipsisString( const OUString& rStr, long nMaxWidth,
1137 DrawTextFlags nStyle = DrawTextFlags::EndEllipsis ) const;
1139 long GetCtrlTextWidth( const OUString& rStr, sal_Int32 nIndex = 0,
1140 sal_Int32 nLen = -1,
1141 DrawTextFlags nStyle = DrawTextFlags::Mnemonic ) const;
1143 static OUString GetNonMnemonicString( const OUString& rStr, sal_Int32& rMnemonicPos );
1145 static OUString GetNonMnemonicString( const OUString& rStr )
1146 { sal_Int32 nDummy; return GetNonMnemonicString( rStr, nDummy ); }
1148 /** Generate MetaTextActions for the text rect
1150 This method splits up the text rect into multiple
1151 MetaTextActions, one for each line of text. This is comparable
1152 to AddGradientActions(), which splits up a gradient into its
1153 constituent polygons. Parameter semantics fully compatible to
1154 DrawText().
1156 void AddTextRectActions( const Rectangle& rRect,
1157 const OUString& rOrigStr,
1158 DrawTextFlags nStyle,
1159 GDIMetaFile& rMtf );
1161 void SetTextColor( const Color& rColor );
1162 const Color& GetTextColor() const { return maTextColor; }
1164 void SetTextFillColor();
1165 void SetTextFillColor( const Color& rColor );
1166 Color GetTextFillColor() const;
1167 bool IsTextFillColor() const { return !maFont.IsTransparent(); }
1169 void SetTextLineColor();
1170 void SetTextLineColor( const Color& rColor );
1171 const Color& GetTextLineColor() const { return maTextLineColor; }
1172 bool IsTextLineColor() const { return (maTextLineColor.GetTransparency() == 0); }
1174 void SetOverlineColor();
1175 void SetOverlineColor( const Color& rColor );
1176 const Color& GetOverlineColor() const { return maOverlineColor; }
1177 bool IsOverlineColor() const { return (maOverlineColor.GetTransparency() == 0); }
1179 void SetTextAlign( TextAlign eAlign );
1180 TextAlign GetTextAlign() const { return maFont.GetAlign(); }
1182 /** Width of the text.
1184 See also GetTextBoundRect() for more explanation + code examples.
1186 long GetTextWidth( const OUString& rStr, sal_Int32 nIndex = 0, sal_Int32 nLen = -1,
1187 vcl::TextLayoutCache const* = nullptr) const;
1189 /** Height where any character of the current font fits; in logic coordinates.
1191 See also GetTextBoundRect() for more explanation + code examples.
1193 long GetTextHeight() const;
1194 float approximate_char_width() const;
1196 void DrawTextArray( const Point& rStartPt, const OUString& rStr,
1197 const long* pDXAry = NULL,
1198 sal_Int32 nIndex = 0,
1199 sal_Int32 nLen = -1,
1200 SalLayoutFlags flags = SalLayoutFlags::NONE);
1201 long GetTextArray( const OUString& rStr, long* pDXAry = NULL,
1202 sal_Int32 nIndex = 0, sal_Int32 nLen = -1,
1203 vcl::TextLayoutCache const* = nullptr) const;
1205 bool GetCaretPositions( const OUString&, long* pCaretXArray,
1206 sal_Int32 nIndex, sal_Int32 nLen,
1207 long* pDXAry = NULL, long nWidth = 0,
1208 bool bCellBreaking = true ) const;
1209 void DrawStretchText( const Point& rStartPt, sal_uLong nWidth,
1210 const OUString& rStr,
1211 sal_Int32 nIndex = 0, sal_Int32 nLen = -1);
1212 sal_Int32 GetTextBreak( const OUString& rStr, long nTextWidth,
1213 sal_Int32 nIndex = 0, sal_Int32 nLen = -1,
1214 long nCharExtra = 0,
1215 vcl::TextLayoutCache const* = nullptr) const;
1216 sal_Int32 GetTextBreak( const OUString& rStr, long nTextWidth,
1217 sal_Unicode nExtraChar, sal_Int32& rExtraCharPos,
1218 sal_Int32 nIndex, sal_Int32 nLen,
1219 long nCharExtra = 0,
1220 vcl::TextLayoutCache const* = nullptr) const;
1221 std::shared_ptr<vcl::TextLayoutCache> CreateTextLayoutCache(OUString const&) const;
1223 private:
1224 SAL_DLLPRIVATE void ImplInitTextColor();
1226 SAL_DLLPRIVATE void ImplInitTextLineSize();
1227 SAL_DLLPRIVATE void ImplInitAboveTextLineSize();
1230 SAL_DLLPRIVATE bool ImplDrawTextDirect( SalLayout&, bool bTextLines, sal_uInt32 flags = 0 );
1231 SAL_DLLPRIVATE void ImplDrawSpecialText( SalLayout& );
1232 SAL_DLLPRIVATE void ImplDrawTextRect( long nBaseX, long nBaseY, long nX, long nY, long nWidth, long nHeight );
1234 SAL_DLLPRIVATE void ImplDrawWavePixel( long nOriginX, long nOriginY, long nCurX, long nCurY, short nOrientation, SalGraphics* pGraphics, OutputDevice* pOutDev,
1235 bool bDrawPixAsRect, long nPixWidth, long nPixHeight );
1236 SAL_DLLPRIVATE void ImplDrawWaveLine( long nBaseX, long nBaseY, long nStartX, long nStartY, long nWidth, long nHeight, long nLineWidth, short nOrientation, const Color& rColor );
1237 SAL_DLLPRIVATE void ImplDrawWaveTextLine( long nBaseX, long nBaseY, long nX, long nY, long nWidth, FontUnderline eTextLine, Color aColor, bool bIsAbove );
1238 SAL_DLLPRIVATE void ImplDrawStraightTextLine( long nBaseX, long nBaseY, long nX, long nY, long nWidth, FontUnderline eTextLine, Color aColor, bool bIsAbove );
1239 SAL_DLLPRIVATE void ImplDrawStrikeoutLine( long nBaseX, long nBaseY, long nX, long nY, long nWidth, FontStrikeout eStrikeout, Color aColor );
1240 SAL_DLLPRIVATE void ImplDrawStrikeoutChar( long nBaseX, long nBaseY, long nX, long nY, long nWidth, FontStrikeout eStrikeout, Color aColor );
1241 SAL_DLLPRIVATE void ImplDrawMnemonicLine( long nX, long nY, long nWidth );
1243 SAL_DLLPRIVATE static bool ImplIsUnderlineAbove( const vcl::Font& );
1245 static
1246 SAL_DLLPRIVATE long ImplGetTextLines( ImplMultiTextLineInfo& rLineInfo, long nWidth, const OUString& rStr, DrawTextFlags nStyle, const vcl::ITextLayout& _rLayout );
1247 ///@}
1250 /** @name Font functions
1252 ///@{
1254 public:
1256 vcl::FontInfo GetDevFont( int nDevFontIndex ) const;
1257 int GetDevFontCount() const;
1259 bool IsFontAvailable( const OUString& rFontName ) const;
1261 Size GetDevFontSize( const vcl::Font& rFont, int nSizeIndex ) const;
1262 int GetDevFontSizeCount( const vcl::Font& ) const;
1264 bool AddTempDevFont( const OUString& rFileURL, const OUString& rFontName );
1266 FontMetric GetFontMetric() const;
1267 FontMetric GetFontMetric( const vcl::Font& rFont ) const;
1269 bool GetFontCharMap( FontCharMapPtr& rFontCharMap ) const;
1270 bool GetFontCapabilities( vcl::FontCapabilities& rFontCapabilities ) const;
1272 /** Retrieve detailed font information in platform independent structure
1274 @param nFallbacklevel Fallback font level (0 = best matching font)
1276 @return SystemFontData
1278 SystemFontData GetSysFontData( int nFallbacklevel ) const;
1280 SAL_DLLPRIVATE void ImplGetEmphasisMark( tools::PolyPolygon& rPolyPoly, bool& rPolyLine, Rectangle& rRect1, Rectangle& rRect2,
1281 long& rYOff, long& rWidth, FontEmphasisMark eEmphasis, long nHeight, short nOrient );
1282 SAL_DLLPRIVATE static FontEmphasisMark
1283 ImplGetEmphasisMarkStyle( const vcl::Font& rFont );
1285 bool GetGlyphBoundRects( const Point& rOrigin, const OUString& rStr, int nIndex,
1286 int nLen, int nBase, MetricVector& rVector );
1288 sal_Int32 HasGlyphs( const vcl::Font& rFont, const OUString& rStr,
1289 sal_Int32 nIndex = 0, sal_Int32 nLen = -1 ) const;
1291 long GetMinKashida() const;
1293 // i60594
1294 // validate kashida positions against the current font
1295 // returns count of invalid kashida positions
1296 sal_Int32 ValidateKashidas( const OUString& rTxt, sal_Int32 nIdx, sal_Int32 nLen,
1297 sal_Int32 nKashCount, // number of suggested kashida positions (in)
1298 const sal_Int32* pKashidaPos, // suggested kashida positions (in)
1299 sal_Int32* pKashidaPosDropped // invalid kashida positions (out)
1300 ) const;
1302 static void BeginFontSubstitution();
1303 static void EndFontSubstitution();
1304 static void AddFontSubstitute( const OUString& rFontName,
1305 const OUString& rReplaceFontName,
1306 AddFontSubstituteFlags nFlags = AddFontSubstituteFlags::NONE );
1307 static void RemoveFontSubstitute( sal_uInt16 n );
1308 static sal_uInt16 GetFontSubstituteCount();
1310 static vcl::Font GetDefaultFont( DefaultFontType nType,
1311 LanguageType eLang,
1312 GetDefaultFontFlags nFlags,
1313 const OutputDevice* pOutDev = NULL );
1315 SAL_DLLPRIVATE void ImplInitFontList() const;
1316 SAL_DLLPRIVATE void ImplUpdateFontData( bool bNewFontLists );
1318 //drop font data for all outputdevices.
1319 //If bNewFontLists is true then empty lists of system fonts
1320 SAL_DLLPRIVATE static void ImplClearAllFontData( bool bNewFontLists );
1321 //fetch font data for all outputdevices
1322 //If bNewFontLists is true then fetch lists of system fonts
1323 SAL_DLLPRIVATE static void ImplRefreshAllFontData( bool bNewFontLists );
1324 //drop and fetch font data for all outputdevices
1325 //If bNewFontLists is true then drop and refetch lists of system fonts
1326 SAL_DLLPRIVATE static void ImplUpdateAllFontData( bool bNewFontLists );
1328 protected:
1330 virtual void InitFont() const;
1331 virtual void SetFontOrientation( ImplFontEntry* const pFontEntry ) const;
1332 virtual long GetFontExtLeading() const;
1335 private:
1337 typedef void ( OutputDevice::* FontUpdateHandler_t )( bool );
1339 SAL_DLLPRIVATE bool ImplNewFont() const;
1341 SAL_DLLPRIVATE void ImplClearFontData( bool bNewFontLists );
1342 SAL_DLLPRIVATE void ImplRefreshFontData( bool bNewFontLists );
1343 SAL_DLLPRIVATE static void ImplUpdateFontDataForAllFrames( FontUpdateHandler_t pHdl, bool bNewFontLists );
1345 static
1346 SAL_DLLPRIVATE OUString ImplGetEllipsisString( const OutputDevice& rTargetDevice, const OUString& rStr,
1347 long nMaxWidth, DrawTextFlags nStyle, const vcl::ITextLayout& _rLayout );
1349 SAL_DLLPRIVATE void ImplDrawEmphasisMark( long nBaseX, long nX, long nY, const tools::PolyPolygon& rPolyPoly, bool bPolyLine, const Rectangle& rRect1, const Rectangle& rRect2 );
1350 SAL_DLLPRIVATE void ImplDrawEmphasisMarks( SalLayout& );
1351 ///@}
1354 /** @name Layout functions
1356 ///@{
1358 public:
1360 SystemTextLayoutData GetSysTextLayoutData( const Point& rStartPt, const OUString& rStr,
1361 sal_Int32 nIndex = 0, sal_Int32 nLen = -1,
1362 const long* pDXAry = NULL ) const;
1364 SAL_DLLPRIVATE bool ImplIsAntiparallel() const ;
1365 SAL_DLLPRIVATE void ReMirror( Point &rPoint ) const;
1366 SAL_DLLPRIVATE void ReMirror( Rectangle &rRect ) const;
1367 SAL_DLLPRIVATE void ReMirror( vcl::Region &rRegion ) const;
1368 SAL_DLLPRIVATE bool ImplIsRecordLayout() const;
1369 virtual bool HasMirroredGraphics() const;
1370 SAL_DLLPRIVATE SalLayout* ImplLayout( const OUString&, sal_Int32 nIndex, sal_Int32 nLen,
1371 const Point& rLogicPos = Point(0,0), long nLogicWidth=0,
1372 const long* pLogicDXArray=NULL, SalLayoutFlags flags = SalLayoutFlags::NONE,
1373 vcl::TextLayoutCache const* = nullptr) const;
1374 SAL_DLLPRIVATE ImplLayoutArgs ImplPrepareLayoutArgs( OUString&, const sal_Int32 nIndex, const sal_Int32 nLen,
1375 DeviceCoordinate nPixelWidth, const DeviceCoordinate* pPixelDXArray,
1376 SalLayoutFlags flags = SalLayoutFlags::NONE,
1377 vcl::TextLayoutCache const* = nullptr) const;
1378 SAL_DLLPRIVATE SalLayout* ImplGlyphFallbackLayout( SalLayout*, ImplLayoutArgs& ) const;
1379 // tells whether this output device is RTL in an LTR UI or LTR in a RTL UI
1380 SAL_DLLPRIVATE SalLayout* getFallbackFont(ImplFontEntry &rFallbackFont,
1381 FontSelectPattern &rFontSelData, int nFallbackLevel,
1382 ImplLayoutArgs& rLayoutArgs) const;
1385 // Enabling/disabling RTL only makes sense for OutputDevices that use a mirroring SalGraphisLayout
1386 virtual void EnableRTL( bool bEnable = true);
1387 bool IsRTLEnabled() const { return mbEnableRTL; }
1389 bool GetTextIsRTL( const OUString&, sal_Int32 nIndex, sal_Int32 nLen ) const;
1391 ///@}
1394 /** @name Bitmap functions
1396 ///@{
1398 public:
1400 /** @overload
1401 void DrawBitmap(
1402 const Point& rDestPt,
1403 const Size& rDestSize,
1404 const Point& rSrcPtPixel,
1405 const Size& rSecSizePixel,
1406 const Bitmap& rBitmap,
1407 MetaActionType nAction = MetaActionType::BMPSCALEPART)
1409 void DrawBitmap(
1410 const Point& rDestPt,
1411 const Bitmap& rBitmap );
1413 /** @overload
1414 void DrawBitmap(
1415 const Point& rDestPt,
1416 const Size& rDestSize,
1417 const Point& rSrcPtPixel,
1418 const Size& rSecSizePixel,
1419 const Bitmap& rBitmap,
1420 MetaActionType nAction = MetaActionType::BMPSCALEPART)
1422 void DrawBitmap(
1423 const Point& rDestPt,
1424 const Size& rDestSize,
1425 const Bitmap& rBitmap );
1427 void DrawBitmap(
1428 const Point& rDestPt,
1429 const Size& rDestSize,
1430 const Point& rSrcPtPixel,
1431 const Size& rSrcSizePixel,
1432 const Bitmap& rBitmap,
1433 MetaActionType nAction = MetaActionType::BMPSCALEPART );
1435 /** @overload
1436 void DrawBitmapEx(
1437 const Point& rDestPt,
1438 const Size& rDestSize,
1439 const Point& rSrcPtPixel,
1440 const Size& rSecSizePixel,
1441 const BitmapEx& rBitmapEx,
1442 MetaActionType nAction = MetaActionType::BMPEXSCALEPART)
1444 void DrawBitmapEx(
1445 const Point& rDestPt,
1446 const BitmapEx& rBitmapEx );
1449 /** @overload
1450 void DrawBitmapEx(
1451 const Point& rDestPt,
1452 const Size& rDestSize,
1453 const Point& rSrcPtPixel,
1454 const Size& rSecSizePixel,
1455 const BitmapEx& rBitmapEx,
1456 MetaActionType nAction = MetaActionType::BMPEXSCALEPART)
1458 void DrawBitmapEx(
1459 const Point& rDestPt,
1460 const Size& rDestSize,
1461 const BitmapEx& rBitmapEx );
1463 void DrawBitmapEx(
1464 const Point& rDestPt,
1465 const Size& rDestSize,
1466 const Point& rSrcPtPixel,
1467 const Size& rSrcSizePixel,
1468 const BitmapEx& rBitmapEx,
1469 MetaActionType nAction = MetaActionType::BMPEXSCALEPART );
1471 /** @overload
1472 virtual void DrawImage(
1473 const Point& rPos,
1474 const Size& rSize,
1475 const Image& rImage,
1476 sal_uInt16 nStyle = 0)
1478 virtual void DrawImage(
1479 const Point& rPos,
1480 const Image& rImage,
1481 DrawImageFlags nStyle = DrawImageFlags::NONE );
1483 virtual void DrawImage(
1484 const Point& rPos,
1485 const Size& rSize,
1486 const Image& rImage,
1487 DrawImageFlags nStyle = DrawImageFlags::NONE );
1490 virtual Bitmap GetBitmap( const Point& rSrcPt, const Size& rSize ) const;
1492 /** Query extended bitmap (with alpha channel, if available).
1494 BitmapEx GetBitmapEx( const Point& rSrcPt, const Size& rSize ) const;
1497 /** Draw BitmapEx transformed
1499 @param rTransformation
1500 The transformation describing the target positioning of the given bitmap. Transforming
1501 the unit object coordinates (0, 0, 1, 1) with this matrix is the transformation to
1502 discrete coordinates
1504 @param rBitmapEx
1505 The BitmapEx to be painted
1507 void DrawTransformedBitmapEx(
1508 const basegfx::B2DHomMatrix& rTransformation,
1509 const BitmapEx& rBitmapEx);
1512 protected:
1514 virtual void DrawDeviceBitmap(
1515 const Point& rDestPt, const Size& rDestSize,
1516 const Point& rSrcPtPixel, const Size& rSrcSizePixel,
1517 BitmapEx& rBitmapEx );
1519 virtual void ScaleBitmap ( Bitmap &rBmp, SalTwoRect &rPosAry );
1521 /** Transform and draw a bitmap directly
1523 @param aFullTransform The B2DHomMatrix used for the transformation
1524 @param rBitmapEx Reference to the bitmap to be transformed and drawn
1526 @return true if it was able to draw the bitmap, false if not
1528 virtual bool DrawTransformBitmapExDirect(
1529 const basegfx::B2DHomMatrix& aFullTransform,
1530 const BitmapEx& rBitmapEx);
1532 /** Transform and reduce the area that needs to be drawn of the bitmap and return the new
1533 visible range and the maximum area.
1536 @param aFullTransform B2DHomMatrix used for transformation
1537 @param aVisibleRange The new visible area of the bitmap
1538 @param fMaximumArea The maximum area of the bitmap
1540 @returns true if there is an area to be drawn, otherwise nothing is left to be drawn
1541 so return false
1543 virtual bool TransformAndReduceBitmapExToTargetRange(
1544 const basegfx::B2DHomMatrix& aFullTransform,
1545 basegfx::B2DRange &aVisibleRange,
1546 double &fMaximumArea);
1548 private:
1550 SAL_DLLPRIVATE void DrawDeviceAlphaBitmap(
1551 const Bitmap& rBmp,
1552 const AlphaMask& rAlpha,
1553 const Point& rDestPt,
1554 const Size& rDestSize,
1555 const Point& rSrcPtPixel,
1556 const Size& rSrcSizePixel );
1558 SAL_DLLPRIVATE void DrawDeviceAlphaBitmapSlowPath(
1559 const Bitmap& rBitmap, const AlphaMask& rAlpha,
1560 Rectangle aDstRect, Rectangle aBmpRect,
1561 Size& aOutSz, Point& aOutPt);
1564 SAL_DLLPRIVATE bool BlendBitmap(
1565 const SalTwoRect& rPosAry,
1566 const Bitmap& rBmp );
1568 SAL_DLLPRIVATE Bitmap BlendBitmap(
1569 Bitmap& aBmp,
1570 BitmapReadAccess* pP,
1571 BitmapReadAccess* pA,
1572 const sal_Int32 nOffY,
1573 const sal_Int32 nDstHeight,
1574 const sal_Int32 nOffX,
1575 const sal_Int32 nDstWidth,
1576 const Rectangle& aBmpRect,
1577 const Size& aOutSz,
1578 const bool bHMirr,
1579 const bool bVMirr,
1580 const long* pMapX,
1581 const long* pMapY );
1583 SAL_DLLPRIVATE Bitmap BlendBitmapWithAlpha(
1584 Bitmap& aBmp,
1585 BitmapReadAccess* pP,
1586 BitmapReadAccess* pA,
1587 const Rectangle& aDstRect,
1588 const sal_Int32 nOffY,
1589 const sal_Int32 nDstHeight,
1590 const sal_Int32 nOffX,
1591 const sal_Int32 nDstWidth,
1592 const long* pMapX,
1593 const long* pMapY );
1595 /** Retrieve downsampled and cropped bitmap
1597 @attention This method ignores negative rDstSz values, thus
1598 mirroring must happen outside this method (e.g. in DrawBitmap)
1600 SAL_DLLPRIVATE Bitmap GetDownsampledBitmap(
1601 const Size& rDstSz,
1602 const Point& rSrcPt,
1603 const Size& rSrcSz,
1604 const Bitmap& rBmp,
1605 long nMaxBmpDPIX,
1606 long nMaxBmpDPIY );
1608 ///@}
1611 /** @name Transparency functions
1613 ///@{
1615 public:
1617 /** Query availability of alpha channel
1619 @return sal_True, if this device has an alpha channel.
1621 bool HasAlpha();
1624 /** helper method removing transparencies from a metafile (e.g. for printing)
1626 @returns
1627 true: transparencies were removed
1628 false: output metafile is unchanged input metafile
1630 @attention this is a member method, so current state can influence the result !
1631 @attention the output metafile is prepared in pixel mode for the currentOutputDevice
1632 state. It can not be moved or rotated reliably anymore.
1634 bool RemoveTransparenciesFromMetaFile(
1635 const GDIMetaFile& rInMtf, GDIMetaFile& rOutMtf,
1636 long nMaxBmpDPIX, long nMaxBmpDPIY,
1637 bool bReduceTransparency,
1638 bool bTransparencyAutoMode,
1639 bool bDownsampleBitmaps,
1640 const Color& rBackground = Color( COL_TRANSPARENT ) );
1642 SAL_DLLPRIVATE void ImplPrintTransparent (
1643 const Bitmap& rBmp, const Bitmap& rMask,
1644 const Point& rDestPt, const Size& rDestSize,
1645 const Point& rSrcPtPixel, const Size& rSrcSizePixel );
1647 SAL_DLLPRIVATE Color ImplDrawModeToColor ( const Color& rColor ) const;
1650 /** Query the existence and depth of the alpha channel
1652 @return 0, if no alpha channel available, and the bit depth of
1653 the alpha channel otherwise.
1655 virtual sal_uInt16 GetAlphaBitCount() const;
1658 void DrawTransparent( const tools::PolyPolygon& rPolyPoly, sal_uInt16 nTransparencePercent );
1659 void DrawTransparent( const basegfx::B2DPolyPolygon& rB2DPolyPoly, double fTransparency);
1660 void DrawTransparent(
1661 const GDIMetaFile& rMtf, const Point& rPos, const Size& rSize,
1662 const Gradient& rTransparenceGradient );
1664 protected:
1666 virtual void EmulateDrawTransparent( const tools::PolyPolygon& rPolyPoly, sal_uInt16 nTransparencePercent );
1667 void DrawInvisiblePolygon( const tools::PolyPolygon& rPolyPoly );
1669 virtual void ClipAndDrawGradientMetafile ( const Gradient &rGradient, const tools::PolyPolygon &rPolyPoly );
1671 private:
1673 SAL_DLLPRIVATE bool DrawTransparentNatively( const tools::PolyPolygon& rPolyPoly, sal_uInt16 nTransparencePercent );
1674 ///@}
1677 /** @name Mask functions
1679 ///@{
1681 public:
1683 void DrawMask( const Point& rDestPt,
1684 const Bitmap& rBitmap, const Color& rMaskColor );
1686 void DrawMask( const Point& rDestPt, const Size& rDestSize,
1687 const Bitmap& rBitmap, const Color& rMaskColor );
1689 void DrawMask( const Point& rDestPt, const Size& rDestSize,
1690 const Point& rSrcPtPixel, const Size& rSrcSizePixel,
1691 const Bitmap& rBitmap, const Color& rMaskColor,
1692 MetaActionType nAction );
1694 protected:
1696 virtual void DrawDeviceMask (
1697 const Bitmap& rMask, const Color& rMaskColor,
1698 const Point& rDestPt, const Size& rDestSize,
1699 const Point& rSrcPtPixel, const Size& rSrcSizePixel );
1700 ///@}
1703 /** @name Map functions
1705 ///@{
1707 public:
1709 void EnableMapMode( bool bEnable = true );
1710 bool IsMapModeEnabled() const { return mbMap; }
1712 void SetMapMode();
1713 virtual void SetMapMode( const MapMode& rNewMapMode );
1714 void SetRelativeMapMode( const MapMode& rNewMapMode );
1715 const MapMode& GetMapMode() const { return maMapMode; }
1717 // #i75163#
1718 basegfx::B2DHomMatrix GetViewTransformation() const;
1719 basegfx::B2DHomMatrix GetInverseViewTransformation() const;
1721 basegfx::B2DHomMatrix GetViewTransformation( const MapMode& rMapMode ) const;
1722 basegfx::B2DHomMatrix GetInverseViewTransformation( const MapMode& rMapMode ) const;
1725 /** Set an offset in pixel
1727 This method offsets every drawing operation that converts its
1728 coordinates to pixel by the given value. Normally, the effect
1729 can be achieved by setting a MapMode with a different
1730 origin. Unfortunately, this origin is in logical coordinates
1731 and can lead to rounding errors (see #102532# for details).
1733 @attention This offset is only applied when converting to
1734 pixel, i.e. some output modes such as metafile recordings
1735 might be completely unaffected by this method! Use with
1736 care. Furthermore, if the OutputDevice's MapMode is the
1737 default (that's MAP_PIXEL), then any pixel offset set is
1738 ignored also. This might be unintuitive for cases, but would
1739 have been far more fragile to implement. What's more, the
1740 reason why the pixel offset was introduced (avoiding rounding
1741 errors) does not apply for MAP_PIXEL, because one can always
1742 use the MapMode origin then.
1744 @param rOffset
1745 The offset in pixel
1747 void SetPixelOffset( const Size& rOffset );
1749 /** Get the offset in pixel
1751 @see OutputDevice::SetPixelOffset for details
1753 @return the current offset in pixel
1755 Size GetPixelOffset() const { return Size(mnOutOffOrigX, mnOutOffOrigY);}
1757 Point LogicToPixel( const Point& rLogicPt ) const;
1758 Size LogicToPixel( const Size& rLogicSize ) const;
1759 Rectangle LogicToPixel( const Rectangle& rLogicRect ) const;
1760 Polygon LogicToPixel( const Polygon& rLogicPoly ) const;
1761 tools::PolyPolygon LogicToPixel( const tools::PolyPolygon& rLogicPolyPoly ) const;
1762 basegfx::B2DPolyPolygon LogicToPixel( const basegfx::B2DPolyPolygon& rLogicPolyPoly ) const;
1763 vcl::Region LogicToPixel( const vcl::Region& rLogicRegion )const;
1764 Point LogicToPixel( const Point& rLogicPt,
1765 const MapMode& rMapMode ) const;
1766 Size LogicToPixel( const Size& rLogicSize,
1767 const MapMode& rMapMode ) const;
1768 Rectangle LogicToPixel( const Rectangle& rLogicRect,
1769 const MapMode& rMapMode ) const;
1770 Polygon LogicToPixel( const Polygon& rLogicPoly,
1771 const MapMode& rMapMode ) const;
1772 basegfx::B2DPolygon LogicToPixel( const basegfx::B2DPolygon& rLogicPoly,
1773 const MapMode& rMapMode ) const;
1774 tools::PolyPolygon LogicToPixel( const tools::PolyPolygon& rLogicPolyPoly,
1775 const MapMode& rMapMode ) const;
1776 basegfx::B2DPolyPolygon LogicToPixel( const basegfx::B2DPolyPolygon& rLogicPolyPoly,
1777 const MapMode& rMapMode ) const;
1778 vcl::Region LogicToPixel( const vcl::Region& rLogicRegion,
1779 const MapMode& rMapMode ) const;
1780 basegfx::B2DPolygon LogicToPixel( const basegfx::B2DPolygon& rLogicPoly ) const;
1782 Point PixelToLogic( const Point& rDevicePt ) const;
1783 Size PixelToLogic( const Size& rDeviceSize ) const;
1784 Rectangle PixelToLogic( const Rectangle& rDeviceRect ) const;
1785 Polygon PixelToLogic( const Polygon& rDevicePoly ) const;
1786 tools::PolyPolygon PixelToLogic( const tools::PolyPolygon& rDevicePolyPoly ) const;
1787 basegfx::B2DPolyPolygon PixelToLogic( const basegfx::B2DPolyPolygon& rDevicePolyPoly ) const;
1788 vcl::Region PixelToLogic( const vcl::Region& rDeviceRegion ) const;
1789 Point PixelToLogic( const Point& rDevicePt,
1790 const MapMode& rMapMode ) const;
1791 Size PixelToLogic( const Size& rDeviceSize,
1792 const MapMode& rMapMode ) const;
1793 Rectangle PixelToLogic( const Rectangle& rDeviceRect,
1794 const MapMode& rMapMode ) const;
1795 Polygon PixelToLogic( const Polygon& rDevicePoly,
1796 const MapMode& rMapMode ) const;
1797 basegfx::B2DPolygon PixelToLogic( const basegfx::B2DPolygon& rDevicePoly,
1798 const MapMode& rMapMode ) const;
1799 tools::PolyPolygon PixelToLogic( const tools::PolyPolygon& rDevicePolyPoly,
1800 const MapMode& rMapMode ) const;
1801 basegfx::B2DPolyPolygon PixelToLogic( const basegfx::B2DPolyPolygon& rDevicePolyPoly,
1802 const MapMode& rMapMode ) const;
1803 vcl::Region PixelToLogic( const vcl::Region& rDeviceRegion,
1804 const MapMode& rMapMode ) const;
1806 Point LogicToLogic( const Point& rPtSource,
1807 const MapMode* pMapModeSource,
1808 const MapMode* pMapModeDest ) const;
1809 Size LogicToLogic( const Size& rSzSource,
1810 const MapMode* pMapModeSource,
1811 const MapMode* pMapModeDest ) const;
1812 Rectangle LogicToLogic( const Rectangle& rRectSource,
1813 const MapMode* pMapModeSource,
1814 const MapMode* pMapModeDest ) const;
1815 static Point LogicToLogic( const Point& rPtSource,
1816 const MapMode& rMapModeSource,
1817 const MapMode& rMapModeDest );
1818 static Size LogicToLogic( const Size& rSzSource,
1819 const MapMode& rMapModeSource,
1820 const MapMode& rMapModeDest );
1821 static Rectangle LogicToLogic( const Rectangle& rRectSource,
1822 const MapMode& rMapModeSource,
1823 const MapMode& rMapModeDest );
1824 static long LogicToLogic( long nLongSource,
1825 MapUnit eUnitSource,
1826 MapUnit eUnitDest );
1828 static basegfx::B2DPolygon LogicToLogic( const basegfx::B2DPolygon& rPoly,
1829 const MapMode& rMapModeSource,
1830 const MapMode& rMapModeDest );
1831 static basegfx::B2DPolyPolygon LogicToLogic( const basegfx::B2DPolyPolygon& rPolyPoly,
1832 const MapMode& rMapModeSource,
1833 const MapMode& rMapModeDest );
1835 // create a mapping transformation from rMapModeSource to rMapModeDest (the above methods
1836 // for B2DPoly/Polygons use this internally anyway to transform the B2DPolygon)
1837 static basegfx::B2DHomMatrix LogicToLogic(const MapMode& rMapModeSource, const MapMode& rMapModeDest);
1839 /** Convert a logical rectangle to a rectangle in physical device pixel units.
1841 @param rLogicSize Const reference to a rectangle in logical units
1843 @returns Rectangle based on physical device pixel coordinates and units.
1845 SAL_DLLPRIVATE Rectangle ImplLogicToDevicePixel( const Rectangle& rLogicRect ) const;
1847 /** Convert a logical point to a physical point on the device.
1849 @param rLogicPt Const reference to a point in logical units.
1851 @returns Physical point on the device.
1853 SAL_DLLPRIVATE Point ImplLogicToDevicePixel( const Point& rLogicPt ) const;
1855 /** Convert a logical width to a width in units of device pixels.
1857 To get the number of device pixels, it must calculate the X-DPI of the device and
1858 the map scaling factor. If there is no mapping, then it just returns the
1859 width as nothing more needs to be done.
1861 @param nWidth Logical width
1863 @returns Width in units of device pixels.
1865 SAL_DLLPRIVATE long ImplLogicWidthToDevicePixel( long nWidth ) const;
1867 SAL_DLLPRIVATE DeviceCoordinate LogicWidthToDeviceCoordinate( long nWidth ) const;
1868 SAL_DLLPRIVATE DeviceCoordinate LogicHeightToDeviceCoordinate( long nHeight ) const;
1870 protected:
1872 * Notification about some rectangle of the output device got invalidated.
1874 * @param pRectangle If 0, that means the whole area, otherwise the area in logic coordinates.
1876 virtual void LogicInvalidate(const Rectangle* /*pRectangle*/) { }
1878 private:
1880 /** Convert a logical X coordinate to a device pixel's X coordinate.
1882 To get the device's X coordinate, it must calculate the mapping offset
1883 coordinate X position (if there is one - if not then it just adds
1884 the pseudo-window offset to the logical X coordinate), the X-DPI of
1885 the device and the mapping's X scaling factor.
1887 @param nX Logical X coordinate
1889 @returns Device's X pixel coordinate
1891 SAL_DLLPRIVATE long ImplLogicXToDevicePixel( long nX ) const;
1893 /** Convert a logical Y coordinate to a device pixel's Y coordinate.
1895 To get the device's Y coordinate, it must calculate the mapping offset
1896 coordinate Y position (if there is one - if not then it just adds
1897 the pseudo-window offset to the logical Y coordinate), the Y-DPI of
1898 the device and the mapping's Y scaling factor.
1900 @param nY Logical Y coordinate
1902 @returns Device's Y pixel coordinate
1904 SAL_DLLPRIVATE long ImplLogicYToDevicePixel( long nY ) const;
1906 /** Convert a logical height to a height in units of device pixels.
1908 To get the number of device pixels, it must calculate the Y-DPI of the device and
1909 the map scaling factor. If there is no mapping, then it just returns the
1910 height as nothing more needs to be done.
1912 @param nHeight Logical height
1914 @returns Height in units of device pixels.
1916 SAL_DLLPRIVATE long ImplLogicHeightToDevicePixel( long nHeight ) const;
1918 /** Convert device pixels to a width in logical units.
1920 To get the logical width, it must calculate the X-DPI of the device and the
1921 map scaling factor.
1923 @param nWidth Width in device pixels
1925 @returns Width in logical units.
1927 SAL_DLLPRIVATE long ImplDevicePixelToLogicWidth( long nWidth ) const;
1929 /** Convert device pixels to a height in logical units.
1931 To get the logical height, it must calculate the Y-DPI of the device and the
1932 map scaling factor.
1934 @param nHeight Height in device pixels
1936 @returns Height in logical units.
1938 SAL_DLLPRIVATE long ImplDevicePixelToLogicHeight( long nHeight ) const;
1940 /** Convert logical height to device pixels, with exact sub-pixel value.
1942 To get the \em exact pixel height, it must calculate the Y-DPI of the device and the
1943 map scaling factor.
1945 @param nHeight Exact height in logical units.
1947 @returns Exact height in pixels - returns as a float to provide for subpixel value.
1949 SAL_DLLPRIVATE float ImplFloatLogicHeightToDevicePixel( float ) const;
1951 /** Convert a logical size to the size on the physical device.
1953 @param rLogicSize Const reference to a size in logical units
1955 @returns Physical size on the device.
1957 SAL_DLLPRIVATE Size ImplLogicToDevicePixel( const Size& rLogicSize ) const;
1959 /** Convert a rectangle in physical pixel units to a rectangle in physical pixel units and coords.
1961 @param rPixelRect Const reference to rectangle in logical units and coords.
1963 @returns Rectangle based on logical coordinates and units.
1965 SAL_DLLPRIVATE Rectangle ImplDevicePixelToLogic( const Rectangle& rPixelRect ) const;
1967 /** Convert a logical B2DPolygon to a B2DPolygon in physical device pixel units.
1969 @param rLogicSize Const reference to a B2DPolygon in logical units
1971 @returns B2DPolyPolygon based on physical device pixel coordinates and units.
1973 SAL_DLLPRIVATE ::basegfx::B2DPolygon ImplLogicToDevicePixel( const ::basegfx::B2DPolygon& rLogicPoly ) const;
1975 /** Convert a logical B2DPolyPolygon to a B2DPolyPolygon in physical device pixel units.
1977 @param rLogicPolyPoly Const reference to a B2DPolyPolygon in logical units
1979 @returns B2DPolyPolygon based on physical device pixel coordinates and units.
1981 SAL_DLLPRIVATE ::basegfx::B2DPolyPolygon ImplLogicToDevicePixel( const ::basegfx::B2DPolyPolygon& rLogicPolyPoly ) const;
1983 /** Convert a logical polygon to a polygon in physical device pixel units.
1985 @param rLogicPoly Const reference to a polygon in logical units
1987 @returns Polygon based on physical device pixel coordinates and units.
1989 SAL_DLLPRIVATE Polygon ImplLogicToDevicePixel( const Polygon& rLogicPoly ) const;
1991 /** Convert a logical polypolygon to a polypolygon in physical device pixel units.
1993 @param rLogicPolyPoly Const reference to a polypolygon in logical units
1995 @returns Polypolygon based on physical device pixel coordinates and units.
1997 SAL_DLLPRIVATE tools::PolyPolygon ImplLogicToDevicePixel( const tools::PolyPolygon& rLogicPolyPoly ) const;
1999 /** Convert a line in logical units to a line in physical device pixel units.
2001 @param rLineInfo Const refernece to a line in logical units
2003 @returns Line based on physical device pixel coordinates and units.
2005 SAL_DLLPRIVATE LineInfo ImplLogicToDevicePixel( const LineInfo& rLineInfo ) const;
2007 /** Convert a region in pixel units to a region in device pixel units and coords.
2009 @param rPixelRect Const reference to region.
2011 @returns vcl::Region based on device pixel coordinates and units.
2013 SAL_DLLPRIVATE vcl::Region ImplPixelToDevicePixel( const vcl::Region& rRegion ) const;
2015 /** Invalidate the view transformation.
2017 @since AOO bug 75163 (OpenOffice.org 2.4.3 - OOH 680 milestone 212)
2019 SAL_DLLPRIVATE void ImplInvalidateViewTransform();
2021 /** Get device transformation.
2023 @since AOO bug 75163 (OpenOffice.org 2.4.3 - OOH 680 milestone 212)
2025 SAL_DLLPRIVATE basegfx::B2DHomMatrix ImplGetDeviceTransformation() const;
2026 ///@}
2029 /** @name Native Widget Rendering functions
2031 These all just call through to the private mpGraphics functions of the same name.
2033 ///@{
2035 public:
2037 /** Query the platform layer for control support
2039 bool IsNativeControlSupported( ControlType nType, ControlPart nPart ) const;
2041 /** Query the native control to determine if it was acted upon
2043 bool HitTestNativeControl(
2044 ControlType nType,
2045 ControlPart nPart,
2046 const Rectangle& rControlRegion,
2047 const Point& aPos,
2048 bool& rIsInside ) const;
2050 /** Request rendering of a particular control and/or part
2052 bool DrawNativeControl(
2053 ControlType nType,
2054 ControlPart nPart,
2055 const Rectangle& rControlRegion,
2056 ControlState nState,
2057 const ImplControlValue& aValue,
2058 const OUString& aCaption );
2060 /** Query the native control's actual drawing region (including adornment)
2062 bool GetNativeControlRegion(
2063 ControlType nType,
2064 ControlPart nPart,
2065 const Rectangle& rControlRegion,
2066 ControlState nState,
2067 const ImplControlValue& aValue,
2068 const OUString& aCaption,
2069 Rectangle &rNativeBoundingRegion,
2070 Rectangle &rNativeContentRegion ) const;
2071 ///@}
2073 /** @name EPS functions
2075 ///@{
2077 public:
2079 /** @returns boolean value to see if EPS could be painted directly.
2080 Theoreticaly, handing over a matrix would be needed to handle
2081 painting rotated EPS files (e.g. contained in Metafiles). This
2082 would then need to be supported for Mac and PS printers, but
2083 that's too much for now, wrote \#i107046# for this */
2084 bool DrawEPS(
2085 const Point& rPt, const Size& rSz,
2086 const GfxLink& rGfxLink, GDIMetaFile* pSubst = NULL );
2087 ///@}
2090 #endif // INCLUDED_VCL_OUTDEV_HXX
2092 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */