1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _SV_OUTDEV_HXX 25 #define _SV_OUTDEV_HXX 26 27 #include <tools/gen.hxx> 28 #include <tools/string.hxx> 29 #include <vcl/sv.h> 30 #include <vcl/dllapi.h> 31 #include <tools/rc.hxx> 32 #include <tools/color.hxx> 33 #include <vcl/font.hxx> 34 #include <vcl/region.hxx> 35 #include <vcl/mapmod.hxx> 36 #include <vcl/wall.hxx> 37 #include <vcl/settings.hxx> 38 #include <vcl/salnativewidgets.hxx> 39 #include <tools/poly.hxx> 40 #include <basegfx/vector/b2enums.hxx> 41 #include <com/sun/star/uno/Reference.h> 42 #include <unotools/fontdefs.hxx> 43 #include <basegfx/polygon/b2dpolypolygon.hxx> 44 #include <com/sun/star/drawing/LineCap.hpp> 45 #include <vector> 46 47 struct ImplOutDevData; 48 class ImplFontEntry; 49 struct ImplObjStack; 50 struct ImplKernPairData; 51 struct SystemGraphicsData; 52 struct SystemFontData; 53 struct SystemTextLayoutData; 54 class ImplFontCache; 55 class ImplDevFontList; 56 class ImplGetDevFontList; 57 class ImplGetDevSizeList; 58 class ImplMultiTextLineInfo; 59 class SalGraphics; 60 class Gradient; 61 class Hatch; 62 class Bitmap; 63 class BitmapReadAccess; 64 class BitmapEx; 65 class Image; 66 class TextRectInfo; 67 class FontInfo; 68 class FontMetric; 69 class GDIMetaFile; 70 class List; 71 class GfxLink; 72 class Line; 73 class LineInfo; 74 class AlphaMask; 75 class FontCharMap; 76 class SalLayout; 77 class ImplLayoutArgs; 78 class ImplFontAttributes; 79 class VirtualDevice; 80 struct SalTwoRect; 81 82 namespace com { 83 namespace sun { 84 namespace star { 85 namespace rendering { 86 class XCanvas; 87 }}}} 88 namespace basegfx { 89 class B2DHomMatrix; 90 class B2DPolygon; 91 class B2DPolyPolygon; 92 } 93 94 namespace com { 95 namespace sun { 96 namespace star { 97 namespace awt { 98 class XGraphics; 99 } } } } 100 101 typedef std::vector< Rectangle > MetricVector; 102 103 namespace vcl 104 { 105 class PDFWriterImpl; 106 class ExtOutDevData; 107 class ITextLayout; 108 } 109 110 #define OUTDEV_BUFFER_SIZE 128 111 112 113 // --------------------- 114 // - OutputDevice-Data - 115 // --------------------- 116 117 struct ImplMapRes 118 { 119 long mnMapOfsX; // Offset in X Richtung 120 long mnMapOfsY; // Offset in Y Richtung 121 long mnMapScNumX; // Skal.-faktor Zaehler X Richtung 122 long mnMapScNumY; // Skal.-faktor Zaehler Y Richtung 123 long mnMapScDenomX; // Skal.-faktor Nenner X Richtung 124 long mnMapScDenomY; // Skal.-faktor Nenner Y Richtung 125 }; 126 127 struct ImplThresholdRes 128 { 129 long mnThresLogToPixX; // Schwellenwerte fuer Berechnung 130 long mnThresLogToPixY; // mit BigInts 131 long mnThresPixToLogX; // "" 132 long mnThresPixToLogY; // "" 133 }; 134 135 // --------------- 136 // - KerningPair - 137 // --------------- 138 139 struct KerningPair 140 { 141 sal_Unicode nChar1; 142 sal_Unicode nChar2; 143 long nKern; 144 }; 145 146 // ---------------------- 147 // - OutputDevice-Types - 148 // ---------------------- 149 150 // Flags for Push() 151 #define PUSH_LINECOLOR ((sal_uInt16)0x0001) 152 #define PUSH_FILLCOLOR ((sal_uInt16)0x0002) 153 #define PUSH_FONT ((sal_uInt16)0x0004) 154 #define PUSH_TEXTCOLOR ((sal_uInt16)0x0008) 155 #define PUSH_MAPMODE ((sal_uInt16)0x0010) 156 #define PUSH_CLIPREGION ((sal_uInt16)0x0020) 157 #define PUSH_RASTEROP ((sal_uInt16)0x0040) 158 #define PUSH_TEXTFILLCOLOR ((sal_uInt16)0x0080) 159 #define PUSH_TEXTALIGN ((sal_uInt16)0x0100) 160 #define PUSH_REFPOINT ((sal_uInt16)0x0200) 161 #define PUSH_TEXTLINECOLOR ((sal_uInt16)0x0400) 162 #define PUSH_TEXTLAYOUTMODE ((sal_uInt16)0x0800) 163 #define PUSH_TEXTLANGUAGE ((sal_uInt16)0x1000) 164 #define PUSH_OVERLINECOLOR ((sal_uInt16)0x2000) 165 #define PUSH_ALLTEXT (PUSH_TEXTCOLOR | PUSH_TEXTFILLCOLOR | PUSH_TEXTLINECOLOR | PUSH_OVERLINECOLOR | PUSH_TEXTALIGN | PUSH_TEXTLAYOUTMODE | PUSH_TEXTLANGUAGE) 166 #define PUSH_ALLFONT (PUSH_ALLTEXT | PUSH_FONT) 167 #define PUSH_ALL ((sal_uInt16)0xFFFF) 168 169 // Flags for DrawText() 170 #define TEXT_DRAW_DISABLE ((sal_uInt16)0x0001) 171 #define TEXT_DRAW_MNEMONIC ((sal_uInt16)0x0002) 172 #define TEXT_DRAW_MONO ((sal_uInt16)0x0004) 173 #define TEXT_DRAW_CLIP ((sal_uInt16)0x0008) 174 #define TEXT_DRAW_LEFT ((sal_uInt16)0x0010) 175 #define TEXT_DRAW_CENTER ((sal_uInt16)0x0020) 176 #define TEXT_DRAW_RIGHT ((sal_uInt16)0x0040) 177 #define TEXT_DRAW_TOP ((sal_uInt16)0x0080) 178 #define TEXT_DRAW_VCENTER ((sal_uInt16)0x0100) 179 #define TEXT_DRAW_BOTTOM ((sal_uInt16)0x0200) 180 #define TEXT_DRAW_ENDELLIPSIS ((sal_uInt16)0x0400) 181 #define TEXT_DRAW_PATHELLIPSIS ((sal_uInt16)0x0800) 182 #define TEXT_DRAW_MULTILINE ((sal_uInt16)0x1000) 183 #define TEXT_DRAW_WORDBREAK ((sal_uInt16)0x2000) 184 #define TEXT_DRAW_NEWSELLIPSIS ((sal_uInt16)0x4000) 185 // in the long run we should make text style flags longer 186 // but at the moment we can get away with this 2 bit field for ellipsis style 187 #define TEXT_DRAW_CENTERELLIPSIS (TEXT_DRAW_ENDELLIPSIS | TEXT_DRAW_PATHELLIPSIS) 188 189 #define TEXT_DRAW_WORDBREAK_HYPHENATION (((sal_uInt16)0x8000) | TEXT_DRAW_WORDBREAK) 190 191 // Flags for CopyArea() 192 #define COPYAREA_WINDOWINVALIDATE ((sal_uInt16)0x0001) 193 194 // Flags for DrawImage() 195 #define IMAGE_DRAW_DISABLE ((sal_uInt16)0x0001) 196 #define IMAGE_DRAW_HIGHLIGHT ((sal_uInt16)0x0002) 197 #define IMAGE_DRAW_DEACTIVE ((sal_uInt16)0x0004) 198 #define IMAGE_DRAW_COLORTRANSFORM ((sal_uInt16)0x0008) 199 #define IMAGE_DRAW_SEMITRANSPARENT ((sal_uInt16)0x0010) 200 #define IMAGE_DRAW_MONOCHROME_BLACK ((sal_uInt16)0x0020) 201 #define IMAGE_DRAW_MONOCHROME_WHITE ((sal_uInt16)0x0040) 202 #define IMAGE_DRAW_3DLOOK 0 203 #define IMAGE_DRAW_BTNLOOK 0 204 205 // WaveLine 206 #define WAVE_FLAT 1 207 #define WAVE_SMALL 2 208 #define WAVE_NORMAL 3 209 210 // Grid 211 #define GRID_DOTS ((sal_uLong)0x00000001) 212 #define GRID_HORZLINES ((sal_uLong)0x00000002) 213 #define GRID_VERTLINES ((sal_uLong)0x00000004) 214 #define GRID_LINES (GRID_HORZLINES | GRID_VERTLINES) 215 216 // LayoutModes for Complex Text Layout 217 #define TEXT_LAYOUT_DEFAULT ((sal_uLong)0x00000000) 218 #define TEXT_LAYOUT_BIDI_LTR ((sal_uLong)0x00000000) 219 #define TEXT_LAYOUT_BIDI_RTL ((sal_uLong)0x00000001) 220 #define TEXT_LAYOUT_BIDI_STRONG ((sal_uLong)0x00000002) 221 #define TEXT_LAYOUT_TEXTORIGIN_LEFT ((sal_uLong)0x00000004) 222 #define TEXT_LAYOUT_TEXTORIGIN_RIGHT ((sal_uLong)0x00000008) 223 #define TEXT_LAYOUT_COMPLEX_DISABLED ((sal_uLong)0x00000100) 224 #define TEXT_LAYOUT_ENABLE_LIGATURES ((sal_uLong)0x00000200) 225 #define TEXT_LAYOUT_SUBSTITUTE_DIGITS ((sal_uLong)0x00000400) 226 227 // DrawModes 228 #define DRAWMODE_DEFAULT ((sal_uLong)0x00000000) 229 #define DRAWMODE_BLACKLINE ((sal_uLong)0x00000001) 230 #define DRAWMODE_BLACKFILL ((sal_uLong)0x00000002) 231 #define DRAWMODE_BLACKTEXT ((sal_uLong)0x00000004) 232 #define DRAWMODE_BLACKBITMAP ((sal_uLong)0x00000008) 233 #define DRAWMODE_BLACKGRADIENT ((sal_uLong)0x00000010) 234 #define DRAWMODE_GRAYLINE ((sal_uLong)0x00000020) 235 #define DRAWMODE_GRAYFILL ((sal_uLong)0x00000040) 236 #define DRAWMODE_GRAYTEXT ((sal_uLong)0x00000080) 237 #define DRAWMODE_GRAYBITMAP ((sal_uLong)0x00000100) 238 #define DRAWMODE_GRAYGRADIENT ((sal_uLong)0x00000200) 239 #define DRAWMODE_NOFILL ((sal_uLong)0x00000400) 240 #define DRAWMODE_NOBITMAP ((sal_uLong)0x00000800) 241 #define DRAWMODE_NOGRADIENT ((sal_uLong)0x00001000) 242 #define DRAWMODE_GHOSTEDLINE ((sal_uLong)0x00002000) 243 #define DRAWMODE_GHOSTEDFILL ((sal_uLong)0x00004000) 244 #define DRAWMODE_GHOSTEDTEXT ((sal_uLong)0x00008000) 245 #define DRAWMODE_GHOSTEDBITMAP ((sal_uLong)0x00010000) 246 #define DRAWMODE_GHOSTEDGRADIENT ((sal_uLong)0x00020000) 247 #define DRAWMODE_WHITELINE ((sal_uLong)0x00100000) 248 #define DRAWMODE_WHITEFILL ((sal_uLong)0x00200000) 249 #define DRAWMODE_WHITETEXT ((sal_uLong)0x00400000) 250 #define DRAWMODE_WHITEBITMAP ((sal_uLong)0x00800000) 251 #define DRAWMODE_WHITEGRADIENT ((sal_uLong)0x01000000) 252 #define DRAWMODE_SETTINGSLINE ((sal_uLong)0x02000000) 253 #define DRAWMODE_SETTINGSFILL ((sal_uLong)0x04000000) 254 #define DRAWMODE_SETTINGSTEXT ((sal_uLong)0x08000000) 255 #define DRAWMODE_SETTINGSGRADIENT ((sal_uLong)0x10000000) 256 #define DRAWMODE_NOTRANSPARENCY ((sal_uLong)0x80000000) 257 258 // Antialiasing 259 #define ANTIALIASING_DISABLE_TEXT ((sal_uInt16)0x0001) 260 #define ANTIALIASING_ENABLE_B2DDRAW ((sal_uInt16)0x0002) 261 #define ANTIALIASING_PIXELSNAPHAIRLINE ((sal_uInt16)0x0004) 262 263 // AddFontSubstitute 264 #define FONT_SUBSTITUTE_ALWAYS ((sal_uInt16)0x0001) 265 #define FONT_SUBSTITUTE_SCREENONLY ((sal_uInt16)0x0002) 266 267 #define DEFAULTFONT_FLAGS_ONLYONE ((sal_uLong)0x00000001) 268 269 enum OutDevType { OUTDEV_DONTKNOW, OUTDEV_WINDOW, OUTDEV_PRINTER, OUTDEV_VIRDEV }; 270 271 enum OutDevViewType { OUTDEV_VIEWTYPE_DONTKNOW, OUTDEV_VIEWTYPE_PRINTPREVIEW, OUTDEV_VIEWTYPE_SLIDESHOW }; 272 273 // ---------------- 274 // - OutputDevice - 275 // ---------------- 276 277 class VirtualDevice; 278 class Printer; 279 280 const char* ImplDbgCheckOutputDevice( const void* pObj ); 281 282 class VCL_DLLPUBLIC OutputDevice : public Resource 283 { 284 friend class Application; 285 friend class Bitmap; 286 friend class ImplImageBmp; 287 friend class ImplQPrinter; 288 friend class Printer; 289 friend class SalGraphicsLayout; 290 friend class System; 291 friend class VirtualDevice; 292 friend class Window; 293 friend class WorkWindow; 294 friend class vcl::PDFWriterImpl; 295 friend const char* ImplDbgCheckOutputDevice( const void* pObj ); 296 friend void ImplHandleResize( Window* pWindow, long nNewWidth, long nNewHeight ); 297 298 private: 299 mutable SalGraphics* mpGraphics; 300 mutable OutputDevice* mpPrevGraphics; 301 mutable OutputDevice* mpNextGraphics; 302 GDIMetaFile* mpMetaFile; 303 mutable ImplFontEntry* mpFontEntry; 304 mutable ImplFontCache* mpFontCache; 305 mutable ImplDevFontList* mpFontList; 306 mutable ImplGetDevFontList* mpGetDevFontList; 307 mutable ImplGetDevSizeList* mpGetDevSizeList; 308 ImplObjStack* mpObjStack; 309 ImplOutDevData* mpOutDevData; 310 List* mpUnoGraphicsList; 311 vcl::PDFWriterImpl* mpPDFWriter; 312 vcl::ExtOutDevData* mpExtOutDevData; 313 314 // TEMP TEMP TEMP 315 VirtualDevice* mpAlphaVDev; 316 317 /// Additional output pixel offset, applied in LogicToPixel (used by SetPixelOffset/GetPixelOffset) 318 long mnOutOffOrigX; 319 /// Additional output offset in _logical_ coordinates, applied in PixelToLogic (used by SetPixelOffset/GetPixelOffset) 320 long mnOutOffLogicX; 321 /// Additional output pixel offset, applied in LogicToPixel (used by SetPixelOffset/GetPixelOffset) 322 long mnOutOffOrigY; 323 /// Additional output offset in _logical_ coordinates, applied in PixelToLogic (used by SetPixelOffset/GetPixelOffset) 324 long mnOutOffLogicY; 325 /// Output offset for device output in pixel (pseudo window offset within window system's frames) 326 long mnOutOffX; 327 /// Output offset for device output in pixel (pseudo window offset within window system's frames) 328 long mnOutOffY; 329 long mnOutWidth; 330 long mnOutHeight; 331 sal_Int32 mnDPIX; 332 sal_Int32 mnDPIY; 333 /// font specific text alignment offsets in pixel units 334 mutable long mnTextOffX; 335 mutable long mnTextOffY; 336 mutable long mnEmphasisAscent; 337 mutable long mnEmphasisDescent; 338 sal_uLong mnDrawMode; 339 sal_uLong mnTextLayoutMode; 340 ImplMapRes maMapRes; 341 ImplThresholdRes maThresRes; 342 OutDevType meOutDevType; 343 OutDevViewType meOutDevViewType; 344 Region maRegion; // contains the clip region, see SetClipRegion(...) 345 Color maLineColor; 346 Color maFillColor; 347 Font maFont; 348 Color maTextColor; 349 Color maTextLineColor; 350 Color maOverlineColor; 351 TextAlign meTextAlign; 352 RasterOp meRasterOp; 353 Wallpaper maBackground; 354 AllSettings maSettings; 355 MapMode maMapMode; 356 Point maRefPoint; 357 sal_uInt16 mnAntialiasing; 358 LanguageType meTextLanguage; 359 360 /// bitfield 361 mutable bool mbMap : 1; 362 mutable bool mbMapIsDefault : 1; 363 mutable bool mbClipRegion : 1; 364 mutable bool mbBackground : 1; 365 mutable bool mbOutput : 1; 366 mutable bool mbDevOutput : 1; 367 mutable bool mbOutputClipped : 1; 368 mutable bool mbLineColor : 1; 369 mutable bool mbFillColor : 1; 370 mutable bool mbInitLineColor : 1; 371 mutable bool mbInitFillColor : 1; 372 mutable bool mbInitFont : 1; 373 mutable bool mbInitTextColor : 1; 374 mutable bool mbInitClipRegion : 1; 375 mutable bool mbClipRegionSet : 1; 376 mutable bool mbKerning : 1; 377 mutable bool mbNewFont : 1; 378 mutable bool mbTextLines : 1; 379 mutable bool mbTextSpecial : 1; 380 mutable bool mbRefPoint : 1; 381 mutable bool mbEnableRTL : 1; 382 383 public: ImplGetDPIX() const384 SAL_DLLPRIVATE sal_Int32 ImplGetDPIX() const { return mnDPIX; } ImplGetDPIY() const385 SAL_DLLPRIVATE sal_Int32 ImplGetDPIY() const { return mnDPIY; } 386 SAL_DLLPRIVATE int ImplGetGraphics() const; 387 SAL_DLLPRIVATE void ImplReleaseGraphics( sal_Bool bRelease = sal_True ); 388 SAL_DLLPRIVATE sal_Bool ImplHasMirroredGraphics(); 389 SAL_DLLPRIVATE void ImplReMirror( Point &rPoint ) const; 390 SAL_DLLPRIVATE void ImplReMirror( Rectangle &rRect ) const; 391 SAL_DLLPRIVATE void ImplReMirror( Region &rRegion ) const; 392 SAL_DLLPRIVATE void ImplInitOutDevData(); 393 SAL_DLLPRIVATE void ImplDeInitOutDevData(); 394 SAL_DLLPRIVATE void ImplInitLineColor(); 395 SAL_DLLPRIVATE void ImplInitFillColor(); 396 SAL_DLLPRIVATE bool ImplNewFont() const; 397 SAL_DLLPRIVATE void ImplInitFont() const; 398 SAL_DLLPRIVATE void ImplInitTextColor(); 399 SAL_DLLPRIVATE void ImplInitClipRegion(); 400 SAL_DLLPRIVATE bool ImplSelectClipRegion( const Region&, SalGraphics* pGraphics = NULL ); 401 SAL_DLLPRIVATE void ImplSetClipRegion( const Region* pRegion ); 402 403 SAL_DLLPRIVATE SalLayout* ImplLayout( const String&, xub_StrLen nIndex, 404 xub_StrLen nLen, const Point& rLogicPos = Point(0,0), 405 long nLogicWidth=0, const sal_Int32* pLogicDXArray=NULL, 406 bool bFilter = false ) const; 407 SAL_DLLPRIVATE ImplLayoutArgs ImplPrepareLayoutArgs( String&, 408 xub_StrLen nIndex, xub_StrLen nLen, 409 long nPixelWidth, 410 const sal_Int32* pPixelDXArray ) const; 411 SAL_DLLPRIVATE SalLayout* ImplGlyphFallbackLayout( SalLayout*, ImplLayoutArgs& ) const; 412 413 SAL_DLLPRIVATE long ImplGetTextWidth( const SalLayout& ) const; 414 static 415 SAL_DLLPRIVATE XubString ImplGetEllipsisString( const OutputDevice& rTargetDevice, const XubString& rStr, 416 long nMaxWidth, sal_uInt16 nStyle, const ::vcl::ITextLayout& _rLayout ); 417 static 418 SAL_DLLPRIVATE void ImplDrawText( OutputDevice& rTargetDevice, const Rectangle& rRect, 419 const String& rOrigStr, sal_uInt16 nStyle, 420 MetricVector* pVector, String* pDisplayText, ::vcl::ITextLayout& _rLayout ); 421 SAL_DLLPRIVATE void ImplDrawTextBackground( const SalLayout& ); 422 SAL_DLLPRIVATE void ImplDrawTextLines( SalLayout&, FontStrikeout eStrikeout, FontUnderline eUnderline, FontUnderline eOverline, sal_Bool bWordLine, sal_Bool bUnderlineAbove ); 423 SAL_DLLPRIVATE bool ImplDrawRotateText( SalLayout& ); 424 SAL_DLLPRIVATE void ImplDrawTextDirect( SalLayout&, sal_Bool bTextLines ); 425 SAL_DLLPRIVATE void ImplDrawSpecialText( SalLayout& ); 426 SAL_DLLPRIVATE void ImplDrawText( SalLayout& ); 427 SAL_DLLPRIVATE Rectangle ImplGetTextBoundRect( const SalLayout& ); 428 SAL_DLLPRIVATE void ImplDrawEmphasisMarks( SalLayout& ); 429 430 SAL_DLLPRIVATE void ImplDrawTextRect( long nBaseX, long nBaseY, long nX, long nY, long nWidth, long nHeight ); 431 432 SAL_DLLPRIVATE void ImplInitTextLineSize(); 433 SAL_DLLPRIVATE void ImplInitAboveTextLineSize(); 434 SAL_DLLPRIVATE void ImplDrawWaveLine( long nBaseX, long nBaseY, long nStartX, long nStartY, long nWidth, long nHeight, long nLineWidth, short nOrientation, const Color& rColor ); 435 SAL_DLLPRIVATE void ImplDrawWaveTextLine( long nBaseX, long nBaseY, long nX, long nY, long nWidth, FontUnderline eTextLine, Color aColor, sal_Bool bIsAbove ); 436 SAL_DLLPRIVATE void ImplDrawStraightTextLine( long nBaseX, long nBaseY, long nX, long nY, long nWidth, FontUnderline eTextLine, Color aColor, sal_Bool bIsAbove ); 437 SAL_DLLPRIVATE void ImplDrawStrikeoutLine( long nBaseX, long nBaseY, long nX, long nY, long nWidth, FontStrikeout eStrikeout, Color aColor ); 438 SAL_DLLPRIVATE void ImplDrawStrikeoutChar( long nBaseX, long nBaseY, long nX, long nY, long nWidth, FontStrikeout eStrikeout, Color aColor ); 439 SAL_DLLPRIVATE void ImplDrawTextLine( long nBaseX, long nX, long nY, long nWidth, FontStrikeout eStrikeout, FontUnderline eUnderline, FontUnderline eOverline, sal_Bool bUnderlineAbove ); 440 SAL_DLLPRIVATE void ImplDrawMnemonicLine( long nX, long nY, long nWidth ); 441 SAL_DLLPRIVATE void ImplGetEmphasisMark( PolyPolygon& rPolyPoly, sal_Bool& rPolyLine, Rectangle& rRect1, Rectangle& rRect2, long& rYOff, long& rWidth, FontEmphasisMark eEmphasis, long nHeight, short nOrient ); 442 SAL_DLLPRIVATE void ImplDrawEmphasisMark( long nBaseX, long nX, long nY, const PolyPolygon& rPolyPoly, sal_Bool bPolyLine, const Rectangle& rRect1, const Rectangle& rRect2 ); 443 static 444 SAL_DLLPRIVATE long ImplGetTextLines( ImplMultiTextLineInfo& rLineInfo, long nWidth, const XubString& rStr, sal_uInt16 nStyle, const ::vcl::ITextLayout& _rLayout ); 445 SAL_DLLPRIVATE void ImplInitFontList() const; 446 SAL_DLLPRIVATE void ImplUpdateFontData( bool bNewFontLists ); 447 SAL_DLLPRIVATE static void ImplUpdateAllFontData( bool bNewFontLists ); 448 449 SAL_DLLPRIVATE long ImplLogicXToDevicePixel( long nX ) const; 450 SAL_DLLPRIVATE long ImplLogicYToDevicePixel( long nY ) const; 451 SAL_DLLPRIVATE long ImplLogicWidthToDevicePixel( long nWidth ) const; 452 SAL_DLLPRIVATE long ImplLogicHeightToDevicePixel( long nHeight ) const; 453 SAL_DLLPRIVATE long ImplDevicePixelToLogicWidth( long nWidth ) const; 454 SAL_DLLPRIVATE long ImplDevicePixelToLogicHeight( long nHeight ) const; 455 SAL_DLLPRIVATE float ImplFloatLogicWidthToDevicePixel( float ) const; 456 SAL_DLLPRIVATE float ImplFloatLogicHeightToDevicePixel( float ) const; 457 SAL_DLLPRIVATE float ImplFloatDevicePixelToLogicWidth( float ) const; 458 SAL_DLLPRIVATE float ImplFloatDevicePixelToLogicHeight( float ) const; 459 SAL_DLLPRIVATE Point ImplLogicToDevicePixel( const Point& rLogicPt ) const; 460 SAL_DLLPRIVATE Size ImplLogicToDevicePixel( const Size& rLogicSize ) const; 461 SAL_DLLPRIVATE Rectangle ImplLogicToDevicePixel( const Rectangle& rLogicRect ) const; 462 SAL_DLLPRIVATE ::basegfx::B2DPolygon ImplLogicToDevicePixel( const ::basegfx::B2DPolygon& ) const; 463 SAL_DLLPRIVATE ::basegfx::B2DPolyPolygon ImplLogicToDevicePixel( const ::basegfx::B2DPolyPolygon& ) const; 464 SAL_DLLPRIVATE Polygon ImplLogicToDevicePixel( const Polygon& rLogicPoly ) const; 465 SAL_DLLPRIVATE PolyPolygon ImplLogicToDevicePixel( const PolyPolygon& rLogicPolyPoly ) const; 466 SAL_DLLPRIVATE LineInfo ImplLogicToDevicePixel( const LineInfo& rLineInfo ) const; 467 SAL_DLLPRIVATE Rectangle ImplDevicePixelToLogic( const Rectangle& rLogicRect ) const; 468 SAL_DLLPRIVATE Region ImplPixelToDevicePixel( const Region& rRegion ) const; 469 SAL_DLLPRIVATE void ImplInvalidateViewTransform(); 470 SAL_DLLPRIVATE basegfx::B2DHomMatrix ImplGetDeviceTransformation() const; 471 472 SAL_DLLPRIVATE void ImplDrawPolygon( const Polygon& rPoly, const PolyPolygon* pClipPolyPoly = NULL ); 473 SAL_DLLPRIVATE void ImplDrawPolyPolygon( const PolyPolygon& rPolyPoly, const PolyPolygon* pClipPolyPoly = NULL ); 474 SAL_DLLPRIVATE void ImplDrawPolyPolygon( sal_uInt16 nPoly, const PolyPolygon& rPolyPoly ); 475 SAL_DLLPRIVATE void ImplDrawLinearGradient( const Rectangle& rRect, const Gradient& rGradient, sal_Bool bMtf, const PolyPolygon* pClipPolyPoly ); 476 SAL_DLLPRIVATE void ImplDrawComplexGradient( const Rectangle& rRect, const Gradient& rGradient, sal_Bool bMtf, const PolyPolygon* pClipPolyPoly ); 477 478 SAL_DLLPRIVATE void ImplDrawHatch( const PolyPolygon& rPolyPoly, const Hatch& rHatch, sal_Bool bMtf ); 479 SAL_DLLPRIVATE void ImplCalcHatchValues( const Rectangle& rRect, long nDist, sal_uInt16 nAngle10, Point& rPt1, Point& rPt2, Size& rInc, Point& rEndPt1 ); 480 SAL_DLLPRIVATE void ImplDrawHatchLine( const Line& rLine, const PolyPolygon& rPolyPoly, Point* pPtBuffer, sal_Bool bMtf ); 481 482 SAL_DLLPRIVATE void ImplDrawWallpaper( long nX, long nY, long nWidth, long nHeight, const Wallpaper& rWallpaper ); 483 SAL_DLLPRIVATE void ImplDrawColorWallpaper( long nX, long nY, long nWidth, long nHeight, const Wallpaper& rWallpaper ); 484 SAL_DLLPRIVATE void ImplDrawBitmapWallpaper( long nX, long nY, long nWidth, long nHeight, const Wallpaper& rWallpaper ); 485 SAL_DLLPRIVATE void ImplDrawGradientWallpaper( long nX, long nY, long nWidth, long nHeight, const Wallpaper& rWallpaper ); 486 SAL_DLLPRIVATE void ImplDraw2ColorFrame( const Rectangle& rRect, const Color& rLeftTopColor, const Color& rRightBottomColor ); 487 488 SAL_DLLPRIVATE void ImplDrawOutDevDirect( const OutputDevice* pSrcDev, SalTwoRect& rPosAry ); 489 SAL_DLLPRIVATE void ImplDrawBitmap( const Point& rDestPt, const Size& rDestSize, 490 const Point& rSrcPtPixel, const Size& rSrcSizePixel, 491 const Bitmap& rBitmap, const sal_uLong nAction ); 492 SAL_DLLPRIVATE void ImplDrawBitmapEx( const Point& rDestPt, const Size& rDestSize, 493 const Point& rSrcPtPixel, const Size& rSrcSizePixel, 494 const BitmapEx& rBitmapEx, const sal_uLong nAction ); 495 SAL_DLLPRIVATE void ImplDrawMask( const Point& rDestPt, const Size& rDestSize, 496 const Point& rSrcPtPixel, const Size& rSrcSizePixel, 497 const Bitmap& rBitmap, const Color& rMaskColor, 498 const sal_uLong nAction ); 499 SAL_DLLPRIVATE void ImplDrawAlpha( const Bitmap& rBmp, const AlphaMask& rAlpha, 500 const Point& rDestPt, const Size& rDestSize, 501 const Point& rSrcPtPixel, const Size& rSrcSizePixel ); 502 SAL_DLLPRIVATE Bitmap ImplBlend( Bitmap aBmp, 503 BitmapReadAccess* pP, 504 BitmapReadAccess* pA, 505 const sal_Int32 nOffY, 506 const sal_Int32 nDstHeight, 507 const sal_Int32 nOffX, 508 const sal_Int32 nDstWidth, 509 const Rectangle& aBmpRect, 510 const Size& aOutSz, 511 const bool bHMirr, 512 const bool bVMirr, 513 const long* pMapX, 514 const long* pMapY ); 515 SAL_DLLPRIVATE Bitmap ImplBlendWithAlpha( Bitmap aBmp, 516 BitmapReadAccess* pP, 517 BitmapReadAccess* pA, 518 const Rectangle& aDstRect, 519 const sal_Int32 nOffY, 520 const sal_Int32 nDstHeight, 521 const sal_Int32 nOffX, 522 const sal_Int32 nDstWidth, 523 const long* pMapX, 524 const long* pMapY ); 525 SAL_DLLPRIVATE void ImplPrintTransparent( const Bitmap& rBmp, const Bitmap& rMask, 526 const Point& rDestPt, const Size& rDestSize, 527 const Point& rSrcPtPixel, const Size& rSrcSizePixel ); 528 SAL_DLLPRIVATE void ImplPrintMask( const Bitmap& rMask, const Color& rMaskColor, 529 const Point& rDestPt, const Size& rDestSize, 530 const Point& rSrcPtPixel, const Size& rSrcSizePixel ); 531 SAL_DLLPRIVATE void ImplDrawFrameDev( const Point& rPt, const Point& rDevPt, const Size& rDevSize, 532 const OutputDevice& rOutDev, const Region& rRegion ); 533 SAL_DLLPRIVATE void ImplGetFrameDev( const Point& rPt, const Point& rDevPt, const Size& rDevSize, 534 OutputDevice& rOutDev ); 535 SAL_DLLPRIVATE void ImplGetFrameBitmap( const Point& rPt, const Size& rSize, 536 Bitmap& rBitmap ) const; 537 538 SAL_DLLPRIVATE sal_Bool ImplIsRecordLayout() const; 539 540 void ImplAddDevFontSubstitute( const XubString& rFontName, 541 const XubString& rReplaceFontName, 542 sal_uInt16 nFlags = 0 ); 543 544 SAL_DLLPRIVATE static FontEmphasisMark ImplGetEmphasisMarkStyle( const Font& rFont ); 545 SAL_DLLPRIVATE static sal_Bool ImplIsUnderlineAbove( const Font& ); 546 547 // tells whether this output device is RTL in an LTR UI or LTR in a RTL UI 548 SAL_DLLPRIVATE bool ImplIsAntiparallel() const ; 549 550 // #i101491# 551 // Helper which holds the old line geometry creation and is extended to use AA when 552 // switched on. Advantage is that line geometry is only temporarily used for paint 553 SAL_DLLPRIVATE void ImpDrawPolyLineWithLineInfo(const Polygon& rPoly, const LineInfo& rLineInfo); 554 555 // #i101491# 556 // Helper who implements the DrawPolyPolygon functionality for basegfx::B2DPolyPolygon 557 // without MetaFile processing 558 SAL_DLLPRIVATE void ImpDrawPolyPolygonWithB2DPolyPolygon(const basegfx::B2DPolyPolygon& rB2DPolyPoly); 559 560 // #i101491# 561 // Helper who tries to use SalGDI's DrawPolyLine direct and returns it's bool. Contains no AA check. 562 SAL_DLLPRIVATE bool ImpTryDrawPolyLineDirect( 563 const basegfx::B2DPolygon& rB2DPolygon, 564 double fLineWidth = 0.0, 565 double fTransparency = 0.0, 566 basegfx::B2DLineJoin eLineJoin = basegfx::B2DLINEJOIN_NONE, 567 com::sun::star::drawing::LineCap eLineCap = com::sun::star::drawing::LineCap_BUTT); 568 569 // Helper for line geometry paint with support for graphic expansion (pattern and fat_to_area) 570 void impPaintLineGeometryWithEvtlExpand(const LineInfo& rInfo, basegfx::B2DPolyPolygon aLinePolyPolygon); 571 572 protected: 573 OutputDevice(); 574 575 private: 576 SAL_DLLPRIVATE OutputDevice( const OutputDevice& rOutDev ); 577 SAL_DLLPRIVATE OutputDevice& operator =( const OutputDevice& rOutDev ); 578 579 public: 580 virtual ~OutputDevice(); 581 GetOutDevType() const582 OutDevType GetOutDevType() const { return meOutDevType; } 583 584 /** query an <code>OutputDevice</code> whether it spports a specific operation 585 586 @return 587 true if operation supported, else false 588 */ 589 bool supportsOperation( OutDevSupportType ) const; 590 GetPDFWriter() const591 vcl::PDFWriterImpl* GetPDFWriter() const { return mpPDFWriter; } 592 SetExtOutDevData(vcl::ExtOutDevData * pExtOutDevData)593 void SetExtOutDevData( vcl::ExtOutDevData* pExtOutDevData ) { mpExtOutDevData = pExtOutDevData; } GetExtOutDevData() const594 vcl::ExtOutDevData* GetExtOutDevData() const { return mpExtOutDevData; } 595 596 void DrawTextLine( const Point& rPos, long nWidth, 597 FontStrikeout eStrikeout, 598 FontUnderline eUnderline, 599 FontUnderline eOverline, 600 sal_Bool bUnderlineAbove = sal_False ); 601 static sal_Bool IsTextUnderlineAbove( const Font& rFont ); 602 603 void DrawText( const Point& rStartPt, const XubString& rStr, 604 xub_StrLen nIndex = 0, xub_StrLen nLen = STRING_LEN, 605 MetricVector* pVector = NULL, String* pDisplayText = NULL ); 606 long GetTextWidth( const XubString& rStr, xub_StrLen nIndex = 0, 607 xub_StrLen nLen = STRING_LEN ) const; 608 long GetTextHeight() const; 609 void DrawTextArray( const Point& rStartPt, const XubString& rStr, 610 const sal_Int32* pDXAry = NULL, 611 xub_StrLen nIndex = 0, 612 xub_StrLen nLen = STRING_LEN ); 613 long GetTextArray( const XubString& rStr, sal_Int32* pDXAry = NULL, 614 xub_StrLen nIndex = 0, 615 xub_StrLen nLen = STRING_LEN ) const; 616 bool GetCaretPositions( const XubString&, sal_Int32* pCaretXArray, 617 xub_StrLen nIndex, xub_StrLen nLen, 618 sal_Int32* pDXAry = NULL, long nWidth = 0, 619 sal_Bool bCellBreaking = sal_True ) const; 620 void DrawStretchText( const Point& rStartPt, sal_uLong nWidth, 621 const XubString& rStr, 622 xub_StrLen nIndex = 0, xub_StrLen nLen = STRING_LEN ); 623 xub_StrLen GetTextBreak( const XubString& rStr, long nTextWidth, 624 xub_StrLen nIndex = 0, xub_StrLen nLen = STRING_LEN, 625 long nCharExtra = 0, sal_Bool bCellBreaking = sal_True ) const; 626 xub_StrLen GetTextBreak( const XubString& rStr, long nTextWidth, 627 sal_uInt16 nExtraChar, xub_StrLen& rExtraCharPos, 628 xub_StrLen nIndex, xub_StrLen nLen, 629 long nCharExtra = 0 ) const; 630 /** Generate MetaTextActions for the text rect 631 632 This method splits up the text rect into multiple 633 MetaTextActions, one for each line of text. This is comparable 634 to AddGradientActions(), which splits up a gradient into its 635 constituing polygons. Parameter semantics fully compatible to 636 DrawText(). 637 */ 638 void AddTextRectActions( const Rectangle& rRect, 639 const String& rOrigStr, 640 sal_uInt16 nStyle, 641 GDIMetaFile& rMtf ); 642 void DrawText( const Rectangle& rRect, 643 const XubString& rStr, sal_uInt16 nStyle = 0, 644 MetricVector* pVector = NULL, String* pDisplayText = NULL, 645 ::vcl::ITextLayout* _pTextLayout = NULL ); 646 Rectangle GetTextRect( const Rectangle& rRect, 647 const XubString& rStr, sal_uInt16 nStyle = TEXT_DRAW_WORDBREAK, 648 TextRectInfo* pInfo = NULL, 649 const ::vcl::ITextLayout* _pTextLayout = NULL ) const; 650 XubString GetEllipsisString( const XubString& rStr, long nMaxWidth, 651 sal_uInt16 nStyle = TEXT_DRAW_ENDELLIPSIS ) const; 652 void DrawCtrlText( const Point& rPos, const XubString& rStr, 653 xub_StrLen nIndex = 0, xub_StrLen nLen = STRING_LEN, 654 sal_uInt16 nStyle = TEXT_DRAW_MNEMONIC, MetricVector* pVector = NULL, String* pDisplayText = NULL ); 655 long GetCtrlTextWidth( const XubString& rStr, xub_StrLen nIndex = 0, 656 xub_StrLen nLen = STRING_LEN, 657 sal_uInt16 nStyle = TEXT_DRAW_MNEMONIC ) const; 658 static XubString GetNonMnemonicString( const XubString& rStr, xub_StrLen& rMnemonicPos ); GetNonMnemonicString(const XubString & rStr)659 static XubString GetNonMnemonicString( const XubString& rStr ) 660 { xub_StrLen nDummy; return GetNonMnemonicString( rStr, nDummy ); } 661 662 sal_Bool GetTextBoundRect( Rectangle& rRect, 663 const String& rStr, xub_StrLen nBase = 0, xub_StrLen nIndex = 0, xub_StrLen nLen = STRING_LEN, 664 sal_uLong nLayoutWidth = 0, const sal_Int32* pDXArray = NULL ) const; 665 sal_Bool GetTextOutline( PolyPolygon&, 666 const String& rStr, xub_StrLen nBase = 0, xub_StrLen nIndex = 0, 667 xub_StrLen nLen = STRING_LEN, sal_Bool bOptimize = sal_True, 668 sal_uLong nLayoutWidth = 0, const sal_Int32* pDXArray = NULL ) const; 669 sal_Bool GetTextOutlines( PolyPolyVector&, 670 const String& rStr, xub_StrLen nBase = 0, xub_StrLen nIndex = 0, 671 xub_StrLen nLen = STRING_LEN, sal_Bool bOptimize = sal_True, 672 sal_uLong nLayoutWidth = 0, const sal_Int32* pDXArray = NULL ) const; 673 sal_Bool GetTextOutlines( ::basegfx::B2DPolyPolygonVector&, 674 const String& rStr, xub_StrLen nBase = 0, xub_StrLen nIndex = 0, 675 xub_StrLen nLen = STRING_LEN, sal_Bool bOptimize = sal_True, 676 sal_uLong nLayoutWidth = 0, const sal_Int32* pDXArray = NULL ) const; 677 sal_Bool GetGlyphBoundRects( const Point& rOrigin, const String& rStr, int nIndex, 678 int nLen, int nBase, MetricVector& rVector ); 679 680 void DrawPixel( const Point& rPt ); 681 void DrawPixel( const Point& rPt, const Color& rColor ); 682 void DrawPixel( const Polygon& rPts, const Color* pColors = NULL ); 683 void DrawPixel( const Polygon& rPts, const Color& rColor ); 684 685 void DrawLine( const Point& rStartPt, const Point& rEndPt ); 686 void DrawLine( const Point& rStartPt, const Point& rEndPt, 687 const LineInfo& rLineInfo ); 688 689 /** Render the given polygon as a line stroke 690 691 The given polygon is stroked with the current LineColor, start 692 and end point are not automatically connected 693 694 @see DrawPolygon 695 @see DrawPolyPolygon 696 */ 697 void DrawPolyLine( const Polygon& rPoly ); 698 void DrawPolyLine( 699 const basegfx::B2DPolygon&, 700 double fLineWidth = 0.0, 701 basegfx::B2DLineJoin = basegfx::B2DLINEJOIN_ROUND, 702 com::sun::star::drawing::LineCap = com::sun::star::drawing::LineCap_BUTT); 703 bool TryDrawPolyLineDirect( 704 const basegfx::B2DPolygon& rB2DPolygon, 705 double fLineWidth = 0.0, 706 double fTransparency = 0.0, 707 basegfx::B2DLineJoin eLineJoin = basegfx::B2DLINEJOIN_NONE, 708 com::sun::star::drawing::LineCap eLineCap = com::sun::star::drawing::LineCap_BUTT); 709 710 /** Render the given polygon as a line stroke 711 712 The given polygon is stroked with the current LineColor, start 713 and end point are not automatically connected. The line is 714 rendered according to the specified LineInfo, e.g. supplying a 715 dash pattern, or a line thickness. 716 717 @see DrawPolygon 718 @see DrawPolyPolygon 719 */ 720 void DrawPolyLine( const Polygon& rPoly, 721 const LineInfo& rLineInfo ); 722 723 /** Render the given polygon 724 725 The given polygon is stroked with the current LineColor, and 726 filled with the current FillColor. If one of these colors are 727 transparent, the corresponding stroke or fill stays 728 invisible. Start and end point of the polygon are 729 automatically connected. 730 731 @see DrawPolyLine 732 */ 733 void DrawPolygon( const Polygon& rPoly ); 734 void DrawPolygon( const basegfx::B2DPolygon& ); 735 736 /** Render the given poly-polygon 737 738 The given poly-polygon is stroked with the current LineColor, 739 and filled with the current FillColor. If one of these colors 740 are transparent, the corresponding stroke or fill stays 741 invisible. Start and end points of the contained polygons are 742 automatically connected. 743 744 @see DrawPolyLine 745 */ 746 void DrawPolyPolygon( const PolyPolygon& rPolyPoly ); 747 void DrawPolyPolygon( const basegfx::B2DPolyPolygon& ); 748 749 void DrawRect( const Rectangle& rRect ); 750 void DrawRect( const Rectangle& rRect, 751 sal_uLong nHorzRount, sal_uLong nVertRound ); 752 void DrawEllipse( const Rectangle& rRect ); 753 void DrawArc( const Rectangle& rRect, 754 const Point& rStartPt, const Point& rEndPt ); 755 void DrawPie( const Rectangle& rRect, 756 const Point& rStartPt, const Point& rEndPt ); 757 void DrawChord( const Rectangle& rRect, 758 const Point& rStartPt, const Point& rEndPt ); 759 760 void DrawOutDev( const Point& rDestPt, const Size& rDestSize, 761 const Point& rSrcPt, const Size& rSrcSize ); 762 void DrawOutDev( const Point& rDestPt, const Size& rDestSize, 763 const Point& rSrcPt, const Size& rSrcSize, 764 const OutputDevice& rOutDev ); 765 void CopyArea( const Point& rDestPt, 766 const Point& rSrcPt, const Size& rSrcSize, 767 sal_uInt16 nFlags = 0 ); 768 769 void DrawBitmap( const Point& rDestPt, 770 const Bitmap& rBitmap ); 771 void DrawBitmap( const Point& rDestPt, const Size& rDestSize, 772 const Bitmap& rBitmap ); 773 void DrawBitmap( const Point& rDestPt, const Size& rDestSize, 774 const Point& rSrcPtPixel, const Size& rSrcSizePixel, 775 const Bitmap& rBitmap ); 776 777 void DrawBitmapEx( const Point& rDestPt, 778 const BitmapEx& rBitmapEx ); 779 void DrawBitmapEx( const Point& rDestPt, const Size& rDestSize, 780 const BitmapEx& rBitmapEx ); 781 void DrawBitmapEx( const Point& rDestPt, const Size& rDestSize, 782 const Point& rSrcPtPixel, const Size& rSrcSizePixel, 783 const BitmapEx& rBitmapEx ); 784 785 /** Draw BitampEx transformed 786 787 @param rTransformation 788 The transformation describing the target positioning of the given bitmap. Transforming 789 the unit object coordinates (0, 0, 1, 1) with this matrix is the transformation to 790 discrete coordinates 791 792 @param rBitmapEx 793 The BitmapEx to be painted 794 */ 795 void DrawTransformedBitmapEx( 796 const basegfx::B2DHomMatrix& rTransformation, 797 const BitmapEx& rBitmapEx); 798 799 void DrawMask( const Point& rDestPt, 800 const Bitmap& rBitmap, const Color& rMaskColor ); 801 void DrawMask( const Point& rDestPt, const Size& rDestSize, 802 const Bitmap& rBitmap, const Color& rMaskColor ); 803 void DrawMask( const Point& rDestPt, const Size& rDestSize, 804 const Point& rSrcPtPixel, const Size& rSrcSizePixel, 805 const Bitmap& rBitmap, const Color& rMaskColor ); 806 807 void DrawImage( const Point& rPos, 808 const Image& rImage, sal_uInt16 nStyle = 0 ); 809 void DrawImage( const Point& rPos, const Size& rSize, 810 const Image& rImage, sal_uInt16 nStyle = 0 ); 811 812 void DrawGradient( const Rectangle& rRect, const Gradient& rGradient ); 813 void DrawGradient( const PolyPolygon& rPolyPoly, const Gradient& rGradient ); 814 void AddGradientActions( const Rectangle& rRect, 815 const Gradient& rGradient, 816 GDIMetaFile& rMtf ); 817 818 #if defined(_MSC_VER) && (_MSC_VER >= 1400) 819 void DrawHatch( const PolyPolygon& rPolyPoly, const ::Hatch& rHatch ); 820 void AddHatchActions( const PolyPolygon& rPolyPoly, 821 const ::Hatch& rHatch, 822 GDIMetaFile& rMtf ); 823 #else 824 void DrawHatch( const PolyPolygon& rPolyPoly, const Hatch& rHatch ); 825 void AddHatchActions( const PolyPolygon& rPolyPoly, 826 const Hatch& rHatch, 827 GDIMetaFile& rMtf ); 828 #endif 829 830 void DrawWallpaper( const Rectangle& rRect, const Wallpaper& rWallpaper ); 831 void DrawWaveLine( const Point& rStartPos, const Point& rEndPos, sal_uInt16 nStyle ); 832 void DrawGrid( const Rectangle& rRect, const Size& rDist, sal_uLong nFlags ); 833 834 void DrawTransparent( const PolyPolygon& rPolyPoly, sal_uInt16 nTransparencePercent ); 835 void DrawTransparent( const basegfx::B2DPolyPolygon& rB2DPolyPoly, double fTransparency); 836 void DrawTransparent( const GDIMetaFile& rMtf, const Point& rPos, const Size& rSize, 837 const Gradient& rTransparenceGradient ); 838 839 /** Added return value to see if EPS could be painted directly. 840 Theoreticaly, handing over a matrix would be needed to handle 841 painting rotated EPS files (e.g. contained in Metafiles). This 842 would then need to be supported for Mac and PS printers, but 843 that's too much for now, wrote #i107046# for this */ 844 bool DrawEPS( const Point& rPt, const Size& rSz, 845 const GfxLink& rGfxLink, GDIMetaFile* pSubst = NULL ); 846 847 /// Fill the given rectangle with checkered rectangles of size nLen x nLen using the colors aStart and aEnd 848 void DrawCheckered( 849 const Point& rPos, 850 const Size& rSize, 851 sal_uInt32 nLen = 8, 852 Color aStart = Color(COL_WHITE), 853 Color aEnd = Color(COL_BLACK)); 854 855 Color GetPixel( const Point& rPt ) const; 856 Color* GetPixel( const Polygon& rPts ) const; 857 858 Bitmap GetBitmap( const Point& rSrcPt, const Size& rSize ) const; 859 860 /** Query extended bitmap (with alpha channel, if available). 861 */ 862 BitmapEx GetBitmapEx( const Point& rSrcPt, const Size& rSize ) const; 863 864 void EnableMapMode( sal_Bool bEnable = sal_True ); IsMapModeEnabled() const865 sal_Bool IsMapModeEnabled() const { return mbMap; } 866 867 // Enabling/disabling RTL only makes sense for OutputDevices that use a mirroring SalGraphisLayout 868 void EnableRTL( sal_Bool bEnable = sal_True); IsRTLEnabled() const869 sal_Bool IsRTLEnabled() const { return mbEnableRTL; } 870 871 void SetConnectMetaFile( GDIMetaFile* pMtf ); GetConnectMetaFile() const872 GDIMetaFile* GetConnectMetaFile() const { return mpMetaFile; } 873 874 void EnableOutput( sal_Bool bEnable = sal_True ); IsOutputEnabled() const875 sal_Bool IsOutputEnabled() const { return mbOutput; } IsDeviceOutput() const876 sal_Bool IsDeviceOutput() const { return mbDevOutput; } IsDeviceOutputNecessary() const877 sal_Bool IsDeviceOutputNecessary() const { return (mbOutput && mbDevOutput); } IsOutputNecessary() const878 sal_Bool IsOutputNecessary() const { return ((mbOutput && mbDevOutput) || (mpMetaFile != NULL)); } 879 880 void SetClipRegion(); 881 void SetClipRegion( const Region& rRegion ); 882 Region GetClipRegion() const; IsClipRegion() const883 sal_Bool IsClipRegion() const { return mbClipRegion; } 884 Region GetActiveClipRegion() const; 885 886 void MoveClipRegion( long nHorzMove, long nVertMove ); 887 void IntersectClipRegion( const Rectangle& rRect ); 888 void IntersectClipRegion( const Region& rRegion ); 889 890 void SetAntialiasing( sal_uInt16 nMode = 0 ); GetAntialiasing() const891 sal_uInt16 GetAntialiasing() const { return mnAntialiasing; } 892 893 void SetDrawMode( sal_uLong nDrawMode ); GetDrawMode() const894 sal_uLong GetDrawMode() const { return mnDrawMode; } 895 896 void SetLayoutMode( sal_uLong nTextLayoutMode ); GetLayoutMode() const897 sal_uLong GetLayoutMode() const { return mnTextLayoutMode; } 898 899 void SetDigitLanguage( LanguageType ); GetDigitLanguage() const900 LanguageType GetDigitLanguage() const { return meTextLanguage; } 901 902 void SetRasterOp( RasterOp eRasterOp ); GetRasterOp() const903 RasterOp GetRasterOp() const { return meRasterOp; } 904 905 /** 906 If this OutputDevice is used for displaying a Print Preview 907 the OutDevViewType should be set to 'OUTDEV_VIEWTYPE_PRINTPREVIEW'. 908 909 A View than can make painting decisions dependent on this OutDevViewType. 910 E.g. text colors need to be handled different, dependent on wether it's a PrintPreview or not. (see #106611# for more) 911 */ SetOutDevViewType(OutDevViewType eOutDevViewType)912 void SetOutDevViewType( OutDevViewType eOutDevViewType ) { meOutDevViewType=eOutDevViewType; } GetOutDevViewType() const913 OutDevViewType GetOutDevViewType() const { return meOutDevViewType; } 914 915 void SetLineColor(); 916 void SetLineColor( const Color& rColor ); GetLineColor() const917 const Color& GetLineColor() const { return maLineColor; } IsLineColor() const918 sal_Bool IsLineColor() const { return mbLineColor; } 919 920 void SetFillColor(); 921 void SetFillColor( const Color& rColor ); GetFillColor() const922 const Color& GetFillColor() const { return maFillColor; } IsFillColor() const923 sal_Bool IsFillColor() const { return mbFillColor; } 924 925 void SetBackground(); 926 void SetBackground( const Wallpaper& rBackground ); 927 GetBackground() const928 const Wallpaper& GetBackground() const { return maBackground; } IsBackground() const929 sal_Bool IsBackground() const { return mbBackground; } 930 931 void SetFont( const Font& rNewFont ); GetFont() const932 const Font& GetFont() const { return maFont; } 933 934 SystemFontData GetSysFontData( int nFallbacklevel ) const; 935 SystemTextLayoutData GetSysTextLayoutData( const Point& rStartPt, const XubString& rStr, 936 xub_StrLen nIndex = 0, xub_StrLen nLen = STRING_LEN, 937 const sal_Int32* pDXAry = NULL ) const; 938 939 void SetTextColor( const Color& rColor ); GetTextColor() const940 const Color& GetTextColor() const { return maTextColor; } 941 void SetTextFillColor(); 942 void SetTextFillColor( const Color& rColor ); 943 944 Color GetTextFillColor() const; IsTextFillColor() const945 sal_Bool IsTextFillColor() const { return !maFont.IsTransparent(); } 946 void SetTextLineColor(); 947 void SetTextLineColor( const Color& rColor ); GetTextLineColor() const948 const Color& GetTextLineColor() const { return maTextLineColor; } IsTextLineColor() const949 sal_Bool IsTextLineColor() const { return (maTextLineColor.GetTransparency() == 0); } 950 void SetOverlineColor(); 951 void SetOverlineColor( const Color& rColor ); GetOverlineColor() const952 const Color& GetOverlineColor() const { return maOverlineColor; } IsOverlineColor() const953 sal_Bool IsOverlineColor() const { return (maOverlineColor.GetTransparency() == 0); } 954 void SetTextAlign( TextAlign eAlign ); GetTextAlign() const955 TextAlign GetTextAlign() const { return maFont.GetAlign(); } 956 957 virtual void SetSettings( const AllSettings& rSettings ); GetSettings() const958 const AllSettings& GetSettings() const { return maSettings; } 959 960 SystemGraphicsData GetSystemGfxData() const; 961 ::com::sun::star::uno::Any GetSystemGfxDataAny() const; 962 963 virtual void SetMapMode(); 964 virtual void SetMapMode( const MapMode& rNewMapMode ); 965 virtual void SetRelativeMapMode( const MapMode& rNewMapMode ); GetMapMode() const966 const MapMode& GetMapMode() const { return maMapMode; } IsMapMode() const967 sal_Bool IsMapMode() const { return mbMap; } 968 969 void SetRefPoint(); 970 void SetRefPoint( const Point& rRefPoint ); GetRefPoint() const971 const Point& GetRefPoint() const { return maRefPoint; } IsRefPoint() const972 sal_Bool IsRefPoint() const { return mbRefPoint; } 973 974 // #i75163# 975 basegfx::B2DHomMatrix GetViewTransformation() const; 976 basegfx::B2DHomMatrix GetInverseViewTransformation() const; 977 978 basegfx::B2DHomMatrix GetViewTransformation( const MapMode& rMapMode ) const; 979 basegfx::B2DHomMatrix GetInverseViewTransformation( const MapMode& rMapMode ) const; 980 981 982 /** Set an offset in pixel 983 984 This method offsets every drawing operation that converts its 985 coordinates to pixel by the given value. Normally, the effect 986 can be achieved by setting a MapMode with a different 987 origin. Unfortunately, this origin is in logical coordinates 988 and can lead to rounding errors (see #102532# for details). 989 990 @attention This offset is only applied when converting to 991 pixel, i.e. some output modes such as metafile recordings 992 might be completely unaffected by this method! Use with 993 care. Furthermore, if the OutputDevice's MapMode is the 994 default (that's MAP_PIXEL), then, too, any pixel offset set is 995 ignored. This might be unintuitive for cases, but would have 996 been far more fragile to implement. What's more, the reason 997 why the pixel offset was introduced (avoiding rounding errors) 998 does not apply for MAP_PIXEL, because one can always use the 999 MapMode origin then. 1000 1001 @param rOffset 1002 The offset in pixel 1003 */ 1004 void SetPixelOffset( const Size& rOffset ); 1005 1006 /** Get the offset in pixel 1007 1008 @see OutputDevice::SetPixelOffset for details 1009 1010 @return the current offset in pixel 1011 */ 1012 Size GetPixelOffset() const; 1013 1014 Point LogicToPixel( const Point& rLogicPt ) const; 1015 Size LogicToPixel( const Size& rLogicSize ) const; 1016 Rectangle LogicToPixel( const Rectangle& rLogicRect ) const; 1017 Polygon LogicToPixel( const Polygon& rLogicPoly ) const; 1018 basegfx::B2DPolygon LogicToPixel( const basegfx::B2DPolygon& rLogicPolyPoly ) const; 1019 PolyPolygon LogicToPixel( const PolyPolygon& rLogicPolyPoly ) const; 1020 basegfx::B2DPolyPolygon LogicToPixel( const basegfx::B2DPolyPolygon& rLogicPolyPoly ) const; 1021 Region LogicToPixel( const Region& rLogicRegion )const; 1022 Point LogicToPixel( const Point& rLogicPt, 1023 const MapMode& rMapMode ) const; 1024 Size LogicToPixel( const Size& rLogicSize, 1025 const MapMode& rMapMode ) const; 1026 Rectangle LogicToPixel( const Rectangle& rLogicRect, 1027 const MapMode& rMapMode ) const; 1028 Polygon LogicToPixel( const Polygon& rLogicPoly, 1029 const MapMode& rMapMode ) const; 1030 basegfx::B2DPolygon LogicToPixel( const basegfx::B2DPolygon& rLogicPoly, 1031 const MapMode& rMapMode ) const; 1032 PolyPolygon LogicToPixel( const PolyPolygon& rLogicPolyPoly, 1033 const MapMode& rMapMode ) const; 1034 basegfx::B2DPolyPolygon LogicToPixel( const basegfx::B2DPolyPolygon& rLogicPolyPoly, 1035 const MapMode& rMapMode ) const; 1036 Region LogicToPixel( const Region& rLogicRegion, 1037 const MapMode& rMapMode ) const; 1038 Point PixelToLogic( const Point& rDevicePt ) const; 1039 Size PixelToLogic( const Size& rDeviceSize ) const; 1040 Rectangle PixelToLogic( const Rectangle& rDeviceRect ) const; 1041 Polygon PixelToLogic( const Polygon& rDevicePoly ) const; 1042 basegfx::B2DPolygon PixelToLogic( const basegfx::B2DPolygon& rDevicePoly ) const; 1043 PolyPolygon PixelToLogic( const PolyPolygon& rDevicePolyPoly ) const; 1044 basegfx::B2DPolyPolygon PixelToLogic( const basegfx::B2DPolyPolygon& rDevicePolyPoly ) const; 1045 Region PixelToLogic( const Region& rDeviceRegion ) const; 1046 Point PixelToLogic( const Point& rDevicePt, 1047 const MapMode& rMapMode ) const; 1048 Size PixelToLogic( const Size& rDeviceSize, 1049 const MapMode& rMapMode ) const; 1050 Rectangle PixelToLogic( const Rectangle& rDeviceRect, 1051 const MapMode& rMapMode ) const; 1052 Polygon PixelToLogic( const Polygon& rDevicePoly, 1053 const MapMode& rMapMode ) const; 1054 basegfx::B2DPolygon PixelToLogic( const basegfx::B2DPolygon& rDevicePoly, 1055 const MapMode& rMapMode ) const; 1056 PolyPolygon PixelToLogic( const PolyPolygon& rDevicePolyPoly, 1057 const MapMode& rMapMode ) const; 1058 basegfx::B2DPolyPolygon PixelToLogic( const basegfx::B2DPolyPolygon& rDevicePolyPoly, 1059 const MapMode& rMapMode ) const; 1060 Region PixelToLogic( const Region& rDeviceRegion, 1061 const MapMode& rMapMode ) const; 1062 1063 Point LogicToLogic( const Point& rPtSource, 1064 const MapMode* pMapModeSource, 1065 const MapMode* pMapModeDest ) const; 1066 Size LogicToLogic( const Size& rSzSource, 1067 const MapMode* pMapModeSource, 1068 const MapMode* pMapModeDest ) const; 1069 Rectangle LogicToLogic( const Rectangle& rRectSource, 1070 const MapMode* pMapModeSource, 1071 const MapMode* pMapModeDest ) const; 1072 long* LogicToLogic( long* pX, 1073 sal_uInt16 nCount, 1074 const MapMode* pMapModeSource, 1075 const MapMode* pMapModeDest ) const; 1076 static Point LogicToLogic( const Point& rPtSource, 1077 const MapMode& rMapModeSource, 1078 const MapMode& rMapModeDest ); 1079 static Size LogicToLogic( const Size& rSzSource, 1080 const MapMode& rMapModeSource, 1081 const MapMode& rMapModeDest ); 1082 static Rectangle LogicToLogic( const Rectangle& rRectSource, 1083 const MapMode& rMapModeSource, 1084 const MapMode& rMapModeDest ); 1085 static long LogicToLogic( long nLongSource, 1086 MapUnit eUnitSource, 1087 MapUnit eUnitDest ); 1088 1089 static basegfx::B2DPolygon LogicToLogic( const basegfx::B2DPolygon& rPoly, 1090 const MapMode& rMapModeSource, 1091 const MapMode& rMapModeDest ); 1092 static basegfx::B2DPolyPolygon LogicToLogic( const basegfx::B2DPolyPolygon& rPolyPoly, 1093 const MapMode& rMapModeSource, 1094 const MapMode& rMapModeDest ); 1095 1096 // create a mapping transformation from rMapModeSource to rMapModeDest (the above methods 1097 // for B2DPoly/Polygons use this internally anyways to transform the B2DPolygon) 1098 static basegfx::B2DHomMatrix LogicToLogic(const MapMode& rMapModeSource, const MapMode& rMapModeDest); 1099 GetOutputSizePixel() const1100 Size GetOutputSizePixel() const 1101 { return Size( mnOutWidth, mnOutHeight ); } GetOutputWidthPixel() const1102 long GetOutputWidthPixel() const { return mnOutWidth; } GetOutputHeightPixel() const1103 long GetOutputHeightPixel() const { return mnOutHeight; } GetOutOffXPixel() const1104 long GetOutOffXPixel() const { return mnOutOffX; } GetOutOffYPixel() const1105 long GetOutOffYPixel() const { return mnOutOffY; } 1106 GetOutputSize() const1107 Size GetOutputSize() const 1108 { return PixelToLogic( GetOutputSizePixel() ); } 1109 1110 void Erase(); Erase(const Rectangle & rRect)1111 void Erase( const Rectangle& rRect ) { DrawWallpaper( rRect, GetBackground() ); } 1112 1113 sal_Bool AddTempDevFont( const String& rFileURL, const String& rFontName ); 1114 int GetDevFontCount() const; 1115 FontInfo GetDevFont( int nDevFontIndex ) const; 1116 int GetDevFontSizeCount( const Font& ) const; 1117 Size GetDevFontSize( const Font& rFont, int nSizeIndex ) const; 1118 sal_Bool IsFontAvailable( const String& rFontName ) const; 1119 1120 FontMetric GetFontMetric() const; 1121 FontMetric GetFontMetric( const Font& rFont ) const; 1122 sal_Bool GetFontCharMap( FontCharMap& rFontCharMap ) const; 1123 1124 xub_StrLen HasGlyphs( const Font& rFont, const String& rStr, 1125 xub_StrLen nIndex = 0, xub_StrLen nLen = STRING_LEN ) const; 1126 1127 long GetMinKashida() const; 1128 long GetMinKashida( const Font& rFont ) const; 1129 1130 // i60594 1131 // validate kashida positions against the current font 1132 // returns count of invalid kashida positions 1133 xub_StrLen ValidateKashidas ( const String& rTxt, 1134 xub_StrLen nIdx, xub_StrLen nLen, 1135 xub_StrLen nKashCount, // number of suggested kashida positions (in) 1136 const xub_StrLen* pKashidaPos, // suggested kashida positions (in) 1137 xub_StrLen* pKashidaPosDropped // invalid kashida positions (out) 1138 ) const; 1139 1140 sal_uInt16 GetBitCount() const; 1141 1142 sal_Bool GetTextIsRTL( const String&, xub_StrLen nIndex, 1143 xub_StrLen nLen ) const; 1144 1145 /** Query the existence and depth of the alpha channel 1146 1147 @return 0, if no alpha channel available, and the bit depth of 1148 the alpha channel otherwise. 1149 */ 1150 sal_uInt16 GetAlphaBitCount() const; 1151 sal_uLong GetColorCount() const; 1152 1153 void Push( sal_uInt16 nFlags = PUSH_ALL ); 1154 void Pop(); 1155 // returns the curren stack depth; that is the number of Push() calls minus the number of Pop() calls 1156 // this should not normally be used since Push and Pop must always be used symmetrically 1157 // however this may be e.g. a help when debugging code in which this somehow is not the case 1158 sal_uInt32 GetGCStackDepth() const; 1159 1160 /** Query availability of alpha channel 1161 1162 @return sal_True, if this device has an alpha channel. 1163 */ 1164 sal_Bool HasAlpha(); 1165 1166 /// request XCanvas render interface for this OutputDevice 1167 ::com::sun::star::uno::Reference< 1168 ::com::sun::star::rendering::XCanvas > GetCanvas() const; 1169 1170 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics > CreateUnoGraphics(); GetUnoGraphicsList() const1171 List* GetUnoGraphicsList() const { return mpUnoGraphicsList; } CreateUnoGraphicsList()1172 List* CreateUnoGraphicsList() { mpUnoGraphicsList = new List; return mpUnoGraphicsList; } 1173 1174 static void BeginFontSubstitution(); 1175 static void EndFontSubstitution(); 1176 static void AddFontSubstitute( const XubString& rFontName, 1177 const XubString& rReplaceFontName, 1178 sal_uInt16 nFlags = 0 ); 1179 static void RemoveFontSubstitute( sal_uInt16 n ); 1180 static sal_uInt16 GetFontSubstituteCount(); 1181 static void GetFontSubstitute( sal_uInt16 n, 1182 XubString& rFontName, 1183 XubString& rReplaceFontName, 1184 sal_uInt16& rFlags ); 1185 1186 static Font GetDefaultFont( sal_uInt16 nType, 1187 LanguageType eLang, 1188 sal_uLong nFlags, 1189 const OutputDevice* pOutDev = NULL ); 1190 1191 /** helper method removing transparencies from a metafile (e.g. for printing) 1192 1193 @returns 1194 true: transparencies were removed 1195 false: output metafile is unchanged input metafile 1196 1197 @attention this is a member method, so current state can influence the result ! 1198 @attention the output metafile is prepared in pixel mode for the currentOutputDevice 1199 state. It can not be moved or rotated reliably anymore. 1200 */ 1201 bool RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf, GDIMetaFile& rOutMtf, 1202 long nMaxBmpDPIX, long nMaxBmpDPIY, 1203 bool bReduceTransparency, 1204 bool bTransparencyAutoMode, 1205 bool bDownsampleBitmaps, 1206 const Color& rBackground = Color( COL_TRANSPARENT ) 1207 ); 1208 /** Retrieve downsampled and cropped bitmap 1209 1210 @attention This method ignores negative rDstSz values, thus 1211 mirroring must happen outside this method (e.g. in DrawBitmap) 1212 */ 1213 Bitmap GetDownsampledBitmap( const Size& rDstSz, 1214 const Point& rSrcPt, const Size& rSrcSz, 1215 const Bitmap& rBmp, long nMaxBmpDPIX, long nMaxBmpDPIY ); 1216 /** Retrieve downsampled and cropped bitmapEx 1217 1218 @attention This method ignores negative rDstSz values, thus 1219 mirroring must happen outside this method (e.g. in DrawBitmapEx) 1220 */ 1221 BitmapEx GetDownsampledBitmapEx( const Size& rDstSz, 1222 const Point& rSrcPt, const Size& rSrcSz, 1223 const BitmapEx& rBmpEx, long nMaxBmpDPIX, long nMaxBmpDPIY ); 1224 1225 //------------------------------------- 1226 // Native Widget Rendering functions 1227 //------------------------------------- 1228 1229 // These all just call through to the private mpGraphics functions of the same name. 1230 1231 // Query the platform layer for control support 1232 sal_Bool IsNativeControlSupported( ControlType nType, ControlPart nPart ); 1233 1234 // Query the native control to determine if it was acted upon 1235 sal_Bool HitTestNativeControl( ControlType nType, 1236 ControlPart nPart, 1237 const Rectangle& rControlRegion, 1238 const Point& aPos, 1239 sal_Bool& rIsInside ); 1240 1241 // Request rendering of a particular control and/or part 1242 sal_Bool DrawNativeControl( ControlType nType, 1243 ControlPart nPart, 1244 const Rectangle& rControlRegion, 1245 ControlState nState, 1246 const ImplControlValue& aValue, 1247 ::rtl::OUString aCaption ); 1248 1249 // Request rendering of a caption string for a control 1250 sal_Bool DrawNativeControlText( ControlType nType, 1251 ControlPart nPart, 1252 const Rectangle& rControlRegion, 1253 ControlState nState, 1254 const ImplControlValue& aValue, 1255 ::rtl::OUString aCaption ); 1256 1257 // Query the native control's actual drawing region (including adornment) 1258 sal_Bool GetNativeControlRegion( ControlType nType, 1259 ControlPart nPart, 1260 const Rectangle& rControlRegion, 1261 ControlState nState, 1262 const ImplControlValue& aValue, 1263 ::rtl::OUString aCaption, 1264 Rectangle &rNativeBoundingRegion, 1265 Rectangle &rNativeContentRegion ); 1266 1267 }; 1268 1269 #endif // _SV_OUTDEV_HXX 1270