Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / emfio / inc / mtftools.hxx
blobf5638af59ecbc93601c16d629804777a6167d9cf
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 .
19 #pragma once
21 #include <config_options.h>
22 #include <basegfx/utils/b2dclipstate.hxx>
23 #include <tools/poly.hxx>
24 #include <vcl/font.hxx>
25 #include <vcl/bitmapex.hxx>
26 #include <vcl/lineinfo.hxx>
27 #include <vcl/rendercontext/State.hxx>
28 #include <vcl/metaact.hxx>
29 #include <rtl/ref.hxx>
31 #include "emfiodllapi.h"
33 namespace emfio
35 /* [MS-EMF] - v20210625 - pages 43, 107 */
36 enum class RegionMode : sal_uInt32
38 RGN_AND = 0x01,
39 RGN_OR = 0x02,
40 RGN_XOR = 0x03,
41 RGN_DIFF = 0x04,
42 RGN_COPY = 0x05
45 /* [MS-EMF] - v20210625 - pages 40, 198 */
46 enum class BackgroundMode : sal_uInt32
48 NONE = 0,
49 Transparent = 1,
50 OPAQUE = 2,
53 /* [MS-EMF] - v20210625 - pages 40, 210 */
54 /* xform stuff */
55 enum class ModifyWorldTransformMode : sal_uInt32
57 MWT_IDENTITY = 0x01,
58 MWT_LEFTMULTIPLY = 0x02,
59 MWT_RIGHTMULTIPLY = 0x03,
60 MWT_SET = 0x04
63 constexpr sal_uInt32 ENHMETA_STOCK_OBJECT = 0x80000000;
65 /* [MS-EMF] - v20210625 - pages 44, 45, 182 */
66 /* Stock Logical Objects */
67 enum class StockObject : sal_uInt32
69 WHITE_BRUSH = 0,
70 LTGRAY_BRUSH = 1,
71 GRAY_BRUSH = 2,
72 DKGRAY_BRUSH = 3,
73 BLACK_BRUSH = 4,
74 NULL_BRUSH = 5,
75 WHITE_PEN = 6,
76 BLACK_PEN = 7,
77 NULL_PEN = 8,
78 ANSI_FIXED_FONT = 11,
79 ANSI_VAR_FONT = 12,
80 SYSTEM_FIXED_FONT = 16
83 /* Note: This enum is incomplete compared to the specification */
84 /* [MS-WMF] - v20210625 - pages 25-26 */
85 enum class WMFRasterOp : sal_uInt16
87 NONE = 0,
88 Black = 1,
89 Not = 6,
90 XorPen = 7,
91 Nop = 11,
92 CopyPen = 13
95 /* Note: We have MapMode elsewhere, so we use MappingMode instead */
96 /* [MS-EMF] - v20210625 - pages 38-50, 202 */
97 /* Mapping modes */
98 enum MappingMode : sal_uInt32
100 MM_TEXT = 0x01,
101 MM_LOMETRIC = 0x02,
102 MM_HIMETRIC = 0x03,
103 MM_LOENGLISH = 0x04,
104 MM_HIENGLISH = 0x05,
105 MM_TWIPS = 0x06,
106 MM_ISOTROPIC = 0x07,
107 MM_ANISOTROPIC = 0x08
110 /* Note: No type is specified, but 32-bit unsigned is used to provide
111 * to match the number of bits in the binary literal, and also the
112 * previous definition of SetGfxMode() and GetGfxMode() functions */
113 /* [MS-EMF] - v20210625 - pages 35 */
114 /* Graphics modes */
115 enum class GraphicsMode : sal_uInt32
117 GM_COMPATIBLE = 0x00000001,
118 GM_ADVANCED = 0x00000002
121 /* [MS-WMF] - v20210625 - pages 46 */
122 /* StretchBlt() modes */
123 enum class StretchMode : sal_uInt16
125 BLACKONWHITE = 0x0001,
126 WHITEONBLACK = 0x0002,
127 COLORONCOLOR = 0x0003,
128 HALFTONE = 0x0004,
129 STRETCH_ANDSCANS = BLACKONWHITE,
130 STRETCH_ORSCANS = WHITEONBLACK,
131 STRETCH_DELETESCANS = COLORONCOLOR
134 constexpr sal_Int32 LF_FACESIZE = 32;
136 struct LOGFONTW
138 sal_Int32 lfHeight;
139 sal_Int32 lfWidth;
140 sal_Int32 lfEscapement;
141 sal_Int32 lfOrientation;
142 sal_Int32 lfWeight;
143 sal_uInt8 lfItalic;
144 sal_uInt8 lfUnderline;
145 sal_uInt8 lfStrikeOut;
146 sal_uInt8 lfCharSet;
147 sal_uInt8 lfOutPrecision;
148 sal_uInt8 lfClipPrecision;
149 sal_uInt8 lfQuality;
150 sal_uInt8 lfPitchAndFamily;
151 OUString alfFaceName;
152 LOGFONTW()
153 : lfHeight(0)
154 , lfWidth(0)
155 , lfEscapement(0)
156 , lfOrientation(0)
157 , lfWeight(0)
158 , lfItalic(0)
159 , lfUnderline(0)
160 , lfStrikeOut(0)
161 , lfCharSet(0)
162 , lfOutPrecision(0)
163 , lfClipPrecision(0)
164 , lfQuality(0)
165 , lfPitchAndFamily(0)
170 /* [MS-WMF] - v20210625 - pages 153 */
171 enum TextAlignmentMode : sal_uInt16
173 TA_NOUPDATECP = 0x0000,
174 TA_UPDATECP = 0x0001,
175 TA_LEFT = 0x0000,
176 TA_RIGHT = 0x0002,
177 TA_CENTER = 0x0006,
178 TA_RIGHT_CENTER = (TA_RIGHT | TA_CENTER),
179 TA_TOP = 0x0000,
180 TA_BOTTOM = 0x0008,
181 // In [MS-WMF] 2.1.2.3, TA_BASELINE value is wrong.
182 // It is 0x0018 and it should be 0x0010.
183 TA_BASELINE = 0x0010,
184 TA_RTLREADING = 0x0100
187 /* Note: This enum is incomplete compared to the specification */
188 /* [MS-EMF] - v20210625 - pages 47-50, 126 */
189 /* Ternary raster operations */
190 enum TernaryRasterOperation : sal_uInt32
192 SRCCOPY = 0x00CC0020L,
193 SRCPAINT = 0x00EE0086L,
194 SRCAND = 0x008800C6L,
195 SRCINVERT = 0x00660046L,
196 SRCERASE = 0x00440328L,
197 PATCOPY = 0x00F00021L,
198 PATINVERT = 0x005A0049L,
199 BLACKNESS = 0x00000042L,
200 WHITENESS = 0x00FF0062L
203 /* [MS-EMF] - v20210625 - pages 40, 41, 65 */
204 enum PenStyle : sal_uInt32
206 PS_COSMETIC = 0x00000000,
207 PS_SOLID = 0x00000000,
208 PS_DASH = 0x00000001,
209 PS_DOT = 0x00000002,
210 PS_DASHDOT = 0x00000003,
211 PS_DASHDOTDOT = 0x00000004,
212 PS_NULL = 0x00000005,
213 PS_INSIDEFRAME = 0x00000006,
214 PS_USERSTYLE = 0x00000007,
215 PS_ALTERNATE = 0x00000008,
216 PS_STYLE_MASK = 0x0000000F,
218 PS_ENDCAP_ROUND = 0x00000000,
219 PS_ENDCAP_SQUARE = 0x00000100,
220 PS_ENDCAP_FLAT = 0x00000200,
221 PS_ENDCAP_STYLE_MASK = 0x00000F00,
223 PS_JOIN_ROUND = 0x00000000,
224 PS_JOIN_BEVEL = 0x00001000,
225 PS_JOIN_MITER = 0x00002000,
226 PS_JOIN_STYLE_MASK = 0x0000F000,
228 PS_GEOMETRIC = 0x00010000
231 /* [MS-WMF] - v20210625 - pages 30, 82 */
232 /* Character Sets */
233 enum CharacterSet : sal_uInt8
235 ANSI_CHARSET = 0x00000000,
236 DEFAULT_CHARSET = 0x00000001,
237 SYMBOL_CHARSET = 0x00000002,
238 SHIFTJIS_CHARSET = 0x00000080,
239 HANGUL_CHARSET = 0x00000081,
240 GB2312_CHARSET = 0x00000086,
241 CHINESEBIG5_CHARSET = 0x00000088,
242 OEM_CHARSET = 0x000000FF,
243 /* WINVER >= 0x0400 */
244 MAC_CHARSET = 0x0000004D,
245 JOHAB_CHARSET = 0x00000082,
246 GREEK_CHARSET = 0x000000A1,
247 TURKISH_CHARSET = 0x000000A2,
248 VIETNAMESE_CHARSET = 0x000000A3,
249 HEBREW_CHARSET = 0x000000B1,
250 ARABIC_CHARSET = 0x000000B2,
251 BALTIC_CHARSET = 0x000000BA,
252 RUSSIAN_CHARSET = 0x000000CC,
253 THAI_CHARSET = 0x000000DE,
254 EASTEUROPE_CHARSET = 0x000000EE
257 /* Note: This enum is incomplete compared to the specification */
258 /* [MS-EMF] - v20210625 - pages 32, 283 */
259 enum ExtTextOutOptions : sal_uInt32
261 ETO_OPAQUE = 0x0002,
262 ETO_CLIPPED = 0x0004,
263 /* WINVER >= 0x0400 */
264 ETO_GLYPH_INDEX = 0x0010,
265 ETO_RTLREADING = 0x0080,
266 /* _WIN32_WINNT >= 0x0500 */
267 ETO_NO_RECT = 0x0100,
268 ETO_PDY = 0x2000
271 /* [MS-WMF] - v20210625 - pages 44, 96 */
272 /* This is packed into a byte as 2 bits */
273 enum PitchFont : sal_uInt8
275 DEFAULT_PITCH = 0,
276 FIXED_PITCH = 1,
277 VARIABLE_PITCH = 2
280 /* [MS-WMF] - v20210625 - pages 33, */
281 enum FamilyFont : sal_uInt8
283 FF_DONTCARE = 0x00,
284 FF_ROMAN = 0x01,
285 FF_SWISS = 0x02,
286 FF_MODERN = 0x03,
287 FF_SCRIPT = 0x04,
288 FF_DECORATIVE = 0x05
291 enum WeightFont
293 FW_THIN = 100,
294 FW_EXTRALIGHT = 200,
295 FW_LIGHT = 300,
296 FW_NORMAL = 400,
297 FW_MEDIUM = 500,
298 FW_SEMIBOLD = 600,
299 FW_BOLD = 700,
300 FW_EXTRABOLD = 800,
301 FW_ULTRALIGHT = 200,
302 FW_ULTRABOLD = 800,
303 FW_BLACK = 900
306 /* [MS-WMF] - v20210625 - pages 29, 30, 182 */
307 enum class BrushStyle : sal_uInt16
309 BS_SOLID = 0,
310 BS_NULL = 1,
311 BS_HOLLOW = 1,
312 BS_HATCHED = 2,
313 BS_PATTERN = 3,
314 BS_INDEXED = 4,
315 BS_DIBPATTERN = 5,
316 BS_DIBPATTERNPT = 6,
317 BS_PATTERN8X8 = 7,
318 BS_DIBPATTERN8X8 = 8,
319 BS_MONOPATTERN = 9
322 constexpr sal_Int32 RDH_RECTANGLES = 1;
323 constexpr sal_Int32 W_MFCOMMENT = 15;
324 constexpr sal_Int32 PRIVATE_ESCAPE_UNICODE = 2;
326 //Scalar constants
327 constexpr sal_Int32 UNDOCUMENTED_WIN_RCL_RELATION = 32;
328 constexpr sal_Int32 MS_FIXPOINT_BITCOUNT_28_4 = 4;
331 //============================ WmfReader ==================================
333 namespace emfio
335 class WinMtfClipPath
337 basegfx::utils::B2DClipState maClip;
339 public:
340 WinMtfClipPath() : maClip() {};
342 void setClipPath(const basegfx::B2DPolyPolygon&, RegionMode nClippingMode);
343 void intersectClip(const basegfx::B2DPolyPolygon& rPolyPolygon);
344 void excludeClip(const basegfx::B2DPolyPolygon& rPolyPolygon);
345 void moveClipRegion(const Size& rSize);
346 void setDefaultClipPath();
348 bool isEmpty() const { return maClip.isCleared(); }
350 basegfx::utils::B2DClipState const & getClip() const { return maClip; }
351 basegfx::B2DPolyPolygon const & getClipPath() const;
353 bool operator==(const WinMtfClipPath& rPath) const
355 return maClip == rPath.maClip;
359 class WinMtfPathObj : public tools::PolyPolygon
361 bool bClosed;
363 public:
365 WinMtfPathObj() :
366 bClosed(true)
369 void Init()
371 Clear();
372 bClosed = true;
375 void ClosePath();
376 void AddPoint(const Point& rPoint);
377 void AddPolygon(const tools::Polygon& rPoly);
378 void AddPolyLine(const tools::Polygon& rPoly);
379 void AddPolyPolygon(const tools::PolyPolygon& rPolyPolygon);
382 struct EMFIO_DLLPUBLIC GDIObj
384 GDIObj() = default;
385 GDIObj(GDIObj const &) = default;
386 virtual ~GDIObj() = default; // Polymorphic base class
387 GDIObj & operator =(GDIObj const &) = default;
390 struct EMFIO_DLLPUBLIC WinMtfFontStyle final : GDIObj
392 vcl::Font aFont;
394 explicit WinMtfFontStyle(LOGFONTW const & rLogFont);
397 enum class WinMtfFillStyleType
399 Solid, Pattern
402 struct WinMtfFillStyle final : GDIObj
404 Color aFillColor;
405 bool bTransparent;
406 WinMtfFillStyleType aType;
407 Bitmap aBmp;
409 WinMtfFillStyle()
410 : aFillColor(COL_BLACK)
411 , bTransparent(false)
412 , aType(WinMtfFillStyleType::Solid)
415 WinMtfFillStyle(const Color& rColor, bool bTrans = false)
416 : aFillColor(rColor)
417 , bTransparent(bTrans)
418 , aType(WinMtfFillStyleType::Solid)
421 explicit WinMtfFillStyle(Bitmap const & rBmp)
422 : bTransparent(false)
423 , aType(WinMtfFillStyleType::Pattern)
424 , aBmp(rBmp)
427 bool operator==(const WinMtfFillStyle& rStyle) const
429 return aFillColor == rStyle.aFillColor
430 && bTransparent == rStyle.bTransparent
431 && aType == rStyle.aType;
436 struct WinMtfPalette final : GDIObj
438 std::vector< Color > aPaletteColors;
440 WinMtfPalette()
441 : aPaletteColors(std::vector< Color >{})
444 WinMtfPalette(const std::vector< Color > rPaletteColors)
445 : aPaletteColors(rPaletteColors)
451 struct WinMtfLineStyle final : GDIObj
453 Color aLineColor;
454 LineInfo aLineInfo;
455 bool bTransparent;
457 WinMtfLineStyle()
458 : aLineColor(COL_BLACK)
459 , bTransparent(false)
462 WinMtfLineStyle(const Color& rColor, bool bTrans = false)
463 : aLineColor(rColor)
464 , bTransparent(bTrans)
467 WinMtfLineStyle(const Color& rColor, const sal_uInt32 nStyle, const sal_Int32 nPenWidth)
468 : aLineColor(rColor)
470 // According to documentation: nStyle = PS_COSMETIC = 0x0 - line with a width of one logical unit and a style that is a solid color
471 // tdf#140271 Based on observed behaviour the line width is not constant with PS_COSMETIC
473 // Width 0 means default width for LineInfo (HairLine) with 1 pixel wide
474 aLineInfo.SetWidth(nPenWidth);
475 switch (nStyle & PS_STYLE_MASK)
477 case PS_DASHDOTDOT:
478 aLineInfo.SetStyle(LineStyle::Dash);
479 aLineInfo.SetDashCount(1);
480 aLineInfo.SetDotCount(2);
481 break;
482 case PS_DASHDOT:
483 aLineInfo.SetStyle(LineStyle::Dash);
484 aLineInfo.SetDashCount(1);
485 aLineInfo.SetDotCount(1);
486 break;
487 case PS_DOT:
488 aLineInfo.SetStyle(LineStyle::Dash);
489 aLineInfo.SetDashCount(0);
490 aLineInfo.SetDotCount(1);
491 break;
492 case PS_DASH:
493 aLineInfo.SetStyle(LineStyle::Dash);
494 aLineInfo.SetDashCount(1);
495 aLineInfo.SetDotCount(0);
496 break;
497 case PS_NULL:
498 aLineInfo.SetStyle(LineStyle::NONE);
499 break;
500 case PS_INSIDEFRAME: // TODO Implement PS_INSIDEFRAME
501 case PS_SOLID:
502 default:
503 aLineInfo.SetStyle(LineStyle::Solid);
505 if (nPenWidth)
506 switch (nStyle & PS_ENDCAP_STYLE_MASK)
508 case PS_ENDCAP_ROUND:
509 aLineInfo.SetLineCap(css::drawing::LineCap_ROUND);
510 break;
511 case PS_ENDCAP_SQUARE:
512 aLineInfo.SetLineCap(css::drawing::LineCap_SQUARE);
513 break;
514 case PS_ENDCAP_FLAT:
515 default:
516 aLineInfo.SetLineCap(css::drawing::LineCap_BUTT);
518 else
519 aLineInfo.SetLineCap(css::drawing::LineCap_BUTT);
520 switch (nStyle & PS_JOIN_STYLE_MASK)
522 case PS_JOIN_ROUND:
523 aLineInfo.SetLineJoin(basegfx::B2DLineJoin::Round);
524 break;
525 case PS_JOIN_BEVEL:
526 aLineInfo.SetLineJoin(basegfx::B2DLineJoin::Bevel);
527 break;
528 // Undocumented but based on experiments with MS Paint and MS Word,
529 // the default Join Style is PS_JOIN_MITER
530 case PS_JOIN_MITER:
531 default:
532 aLineInfo.SetLineJoin(basegfx::B2DLineJoin::Miter);
534 bTransparent = aLineInfo.GetStyle() == LineStyle::NONE;
537 bool operator==(const WinMtfLineStyle& rStyle) const
539 return aLineColor == rStyle.aLineColor
540 && bTransparent == rStyle.bTransparent
541 && aLineInfo == rStyle.aLineInfo;
545 struct XForm
547 float eM11;
548 float eM12;
549 float eM21;
550 float eM22;
551 float eDx;
552 float eDy;
554 XForm()
555 : eM11(1.0f)
556 , eM12(0.0f)
557 , eM21(0.0f)
558 , eM22(1.0f)
559 , eDx(0.0f)
560 , eDy(0.0f)
564 SvStream& operator >> (SvStream& rInStream, XForm& rXForm);
566 struct SaveStruct
568 BackgroundMode nBkMode;
569 MappingMode eMapMode;
570 GraphicsMode eGfxMode;
571 vcl::text::ComplexTextLayoutFlags nTextLayoutMode;
572 sal_Int32 nWinOrgX, nWinOrgY, nWinExtX, nWinExtY;
573 sal_Int32 nDevOrgX, nDevOrgY, nDevWidth, nDevHeight;
575 WinMtfLineStyle aLineStyle;
576 WinMtfFillStyle aFillStyle;
578 vcl::Font aFont;
579 Color aBkColor;
580 Color aTextColor;
581 sal_uInt32 nTextAlign;
582 RasterOp eRasterOp;
584 Point aActPos;
585 WinMtfPathObj maPathObj;
586 WinMtfClipPath maClipPath;
587 XForm aXForm;
589 bool bClockWiseArcDirection;
590 bool bFillStyleSelected;
593 struct BSaveStruct
595 BitmapEx aBmpEx;
596 tools::Rectangle aOutRect;
597 sal_uInt32 nWinRop;
598 bool m_bForceAlpha = false;
600 BSaveStruct(const Bitmap& rBmp, const tools::Rectangle& rOutRect, sal_uInt32 nRop)
601 : aBmpEx(rBmp)
602 , aOutRect(rOutRect)
603 , nWinRop(nRop)
606 BSaveStruct(const BitmapEx& rBmpEx, const tools::Rectangle& rOutRect, sal_uInt32 nRop,
607 bool bForceAlpha = false)
608 : aBmpEx(rBmpEx)
609 , aOutRect(rOutRect)
610 , nWinRop(nRop)
611 , m_bForceAlpha(bForceAlpha)
615 // tdf#127471 implement detection and correction of wrongly scaled
616 // fonts in own-written, old (before this fix) EMF/WMF files
617 class ScaledFontDetectCorrectHelper
619 private:
620 rtl::Reference<MetaFontAction> maCurrentMetaFontAction;
621 std::vector<double> maAlternativeFontScales;
622 std::vector<std::pair<rtl::Reference<MetaFontAction>, double>> maPositiveIdentifiedCases;
623 std::vector<std::pair<rtl::Reference<MetaFontAction>, double>> maNegativeIdentifiedCases;
625 public:
626 ScaledFontDetectCorrectHelper();
627 void endCurrentMetaFontAction();
628 void newCurrentMetaFontAction(const rtl::Reference<MetaFontAction>& rNewMetaFontAction);
629 void evaluateAlternativeFontScale(OUString const & rText, tools::Long nImportedTextLength);
630 void applyAlternativeFontScale();
633 class MtfTools
635 MtfTools(MtfTools const &) = delete;
636 MtfTools& operator =(MtfTools const &) = delete;
638 protected:
639 WinMtfPathObj maPathObj;
640 WinMtfClipPath maClipPath;
642 WinMtfLineStyle maLatestLineStyle;
643 WinMtfLineStyle maLineStyle;
644 WinMtfLineStyle maNopLineStyle;
645 WinMtfFillStyle maLatestFillStyle;
646 WinMtfFillStyle maFillStyle;
647 WinMtfFillStyle maNopFillStyle;
648 WinMtfPalette maPalette;
650 vcl::Font maLatestFont;
651 vcl::Font maFont;
652 sal_uInt32 mnLatestTextAlign;
653 sal_uInt32 mnTextAlign;
654 Color maLatestTextColor;
655 Color maTextColor;
656 Color maLatestBkColor;
657 Color maBkColor;
658 vcl::text::ComplexTextLayoutFlags mnLatestTextLayoutMode;
659 vcl::text::ComplexTextLayoutFlags mnTextLayoutMode;
660 BackgroundMode mnLatestBkMode;
661 BackgroundMode mnBkMode;
662 RasterOp meLatestRasterOp;
663 RasterOp meRasterOp;
665 std::vector< std::unique_ptr<GDIObj> > mvGDIObj;
666 Point maActPos;
667 WMFRasterOp mnRop;
668 std::vector< std::shared_ptr<SaveStruct> > mvSaveStack;
670 GraphicsMode meGfxMode;
671 MappingMode meMapMode;
673 XForm maXForm;
674 sal_Int32 mnDevOrgX;
675 sal_Int32 mnDevOrgY;
676 sal_Int32 mnDevWidth;
677 sal_Int32 mnDevHeight;
678 sal_Int32 mnWinOrgX;
679 sal_Int32 mnWinOrgY;
680 sal_Int32 mnWinExtX;
681 sal_Int32 mnWinExtY;
683 sal_Int32 mnPixX; // Reference Device in pixel
684 sal_Int32 mnPixY; // Reference Device in pixel
685 sal_Int32 mnMillX; // Reference Device in Mill
686 sal_Int32 mnMillY; // Reference Device in Mill
687 tools::Rectangle mrclFrame;
688 tools::Rectangle mrclBounds;
690 GDIMetaFile* mpGDIMetaFile;
692 SvStream* mpInputStream; // the WMF/EMF file to be read
693 sal_uInt32 mnStartPos;
694 sal_uInt32 mnEndPos;
695 std::vector<BSaveStruct> maBmpSaveList;
697 // tdf#127471 always try to detect - only used with ScaledText
698 ScaledFontDetectCorrectHelper maScaledFontHelper;
700 bool mbNopMode : 1;
701 bool mbClockWiseArcDirection : 1;
702 bool mbFillStyleSelected : 1;
703 bool mbClipNeedsUpdate : 1;
704 bool mbComplexClip : 1;
705 bool mbIsMapWinSet : 1;
706 bool mbIsMapDevSet : 1;
708 void UpdateLineStyle();
709 void UpdateFillStyle();
711 Point ImplMap(const Point& rPt);
712 Point ImplScale(const Point& rPt);
713 Size ImplMap(const Size& rSize, bool bDoWorldTransform = true);
714 tools::Rectangle ImplMap(const tools::Rectangle& rRectangle);
715 void ImplMap(vcl::Font& rFont);
716 tools::Polygon& ImplMap(tools::Polygon& rPolygon);
717 tools::PolyPolygon& ImplMap(tools::PolyPolygon& rPolyPolygon);
718 void ImplScale(tools::Polygon& rPolygon);
719 tools::PolyPolygon& ImplScale(tools::PolyPolygon& rPolyPolygon);
720 void ImplResizeObjectArry(sal_uInt32 nNewEntry);
721 void ImplSetNonPersistentLineColorTransparenz();
722 void ImplDrawClippedPolyPolygon(const tools::PolyPolygon& rPolyPoly);
723 void ImplDrawBitmap(const Point& rPos, const Size& rSize, const BitmapEx& rBitmap);
725 public:
727 void SetDevByWin(); //Hack to set varying defaults for incompletely defined files.
728 void SetDevOrg(const Point& rPoint);
729 void SetDevOrgOffset(sal_Int32 nXAdd, sal_Int32 nYAdd);
730 void SetDevExt(const Size& rSize, bool regular = true);
731 void ScaleDevExt(double fX, double fY);
733 void SetWinOrg(const Point& rPoint, bool bIsEMF = false);
734 Point GetWinOrg() { return Point(mnWinOrgX, mnWinOrgY); }
735 void SetWinOrgOffset(sal_Int32 nX, sal_Int32 nY);
736 void SetWinExt(const Size& rSize, bool bIsEMF = false);
737 void ScaleWinExt(double fX, double fY);
739 void SetrclBounds(const tools::Rectangle& rRect);
740 void SetrclFrame(const tools::Rectangle& rRect);
741 void SetRefPix(const Size& rSize);
742 void SetRefMill(const Size& rSize);
744 void SetMapMode(MappingMode mnMapMode);
745 void SetWorldTransform(const XForm& rXForm);
746 void ModifyWorldTransform(const XForm& rXForm, ModifyWorldTransformMode nMode);
748 void Push();
749 void Pop( const sal_Int32 nSavedDC = -1 );
751 WMFRasterOp SetRasterOp(WMFRasterOp nRasterOp);
752 void StrokeAndFillPath(bool bStroke, bool bFill);
754 void SetArcDirection(bool bCounterClockWise);
755 bool IsArcDirectionClockWise() { return mbClockWiseArcDirection; };
756 void SetGfxMode(GraphicsMode nGfxMode) { meGfxMode = nGfxMode; };
757 GraphicsMode GetGfxMode() const { return meGfxMode; };
758 void SetBkMode(BackgroundMode nMode);
759 void SetBkColor(const Color& rColor);
760 void SetTextColor(const Color& rColor);
761 void SetTextAlign(sal_uInt32 nAlign);
763 void CreateObject(std::unique_ptr<GDIObj> pObject);
764 void CreateObjectIndexed(sal_uInt32 nIndex, std::unique_ptr<GDIObj> pObject);
765 void CreateObject();
767 void DeleteObject(sal_uInt32 nIndex);
768 void SelectObject(sal_uInt32 nIndex);
769 rtl_TextEncoding GetCharSet() const { return maFont.GetCharSet(); };
770 const vcl::Font& GetFont() const { return maFont; }
771 void SetTextLayoutMode(vcl::text::ComplexTextLayoutFlags nLayoutMode);
773 void ClearPath() { maPathObj.Init(); };
774 void ClosePath() { maPathObj.ClosePath(); };
775 const tools::PolyPolygon& GetPathObj() const { return maPathObj; };
777 void MoveTo(const Point& rPoint, bool bRecordPath = false);
778 void LineTo(const Point& rPoint, bool bRecordPath = false);
779 void DrawPixel(const Point& rSource, const Color& rColor);
780 void DrawRect(const tools::Rectangle& rRect, bool bEdge = true);
781 void DrawRectWithBGColor(const tools::Rectangle& rRect);
782 void DrawRoundRect(const tools::Rectangle& rRect, const Size& rSize);
783 void DrawEllipse(const tools::Rectangle& rRect);
784 void DrawArc(
785 const tools::Rectangle& rRect,
786 const Point& rStartAngle,
787 const Point& rEndAngle,
788 bool bDrawTo = false
790 void DrawPie(
791 const tools::Rectangle& rRect,
792 const Point& rStartAngle,
793 const Point& rEndAngle
795 void DrawChord(
796 const tools::Rectangle& rRect,
797 const Point& rStartAngle,
798 const Point& rEndAngle
800 void DrawPolygon(tools::Polygon rPolygon, bool bRecordPath);
801 void DrawPolyPolygon(tools::PolyPolygon& rPolyPolygon, bool bRecordPath = false);
802 void DrawPolyLine(tools::Polygon rPolygon,
803 bool bDrawTo = false,
804 bool bRecordPath = false
806 void DrawPolyBezier(tools::Polygon rPolygon,
807 bool bDrawTo,
808 bool bRecordPath
810 void DrawText(Point& rPosition,
811 OUString const & rString,
812 KernArray* pDXArry = nullptr,
813 tools::Long* pDYArry = nullptr,
814 bool bRecordPath = false,
815 GraphicsMode nGraphicsMode = GraphicsMode::GM_COMPATIBLE);
817 void ResolveBitmapActions(std::vector<BSaveStruct>& rSaveList);
819 void IntersectClipRect(const tools::Rectangle& rRect);
820 void ExcludeClipRect(const tools::Rectangle& rRect);
821 void MoveClipRegion(const Size& rSize);
822 void SetClipPath(
823 const tools::PolyPolygon& rPolyPoly,
824 RegionMode nClippingMode,
825 bool bIsMapped
827 void SetDefaultClipPath();
828 void UpdateClipRegion();
829 void AddFromGDIMetaFile(GDIMetaFile& rGDIMetaFile);
831 void PassEMFPlus(void const * pBuffer, sal_uInt32 nLength);
832 void PassEMFPlusHeaderInfo();
834 Color ReadColor();
836 explicit MtfTools(GDIMetaFile& rGDIMetaFile, SvStream& rStreamWMF);
837 ~MtfTools() COVERITY_NOEXCEPT_FALSE;
841 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */