LCOV - code coverage report
Current view: top level - vcl/source/filter/wmf - winmtf.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 108 110 98.2 %
Date: 2014-11-03 Functions: 45 46 97.8 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : #ifndef INCLUDED_VCL_SOURCE_FILTER_WMF_WINMTF_HXX
      21             : #define INCLUDED_VCL_SOURCE_FILTER_WMF_WINMTF_HXX
      22             : 
      23             : #include <sot/object.hxx>
      24             : #include <boost/shared_ptr.hpp>
      25             : #include <vcl/graph.hxx>
      26             : #include <basegfx/tools/b2dclipstate.hxx>
      27             : #include <vcl/font.hxx>
      28             : #include <vcl/bmpacc.hxx>
      29             : #include <vcl/lineinfo.hxx>
      30             : #include <vcl/fltcall.hxx>
      31             : 
      32             : #define ERROR                   0
      33             : #define NULLREGION              1
      34             : #define SIMPLEREGION            2
      35             : #define COMPLEXREGION           3
      36             : 
      37             : #define RGN_AND                 1
      38             : #define RGN_OR                  2
      39             : #define RGN_XOR                 3
      40             : #define RGN_DIFF                4
      41             : #define RGN_COPY                5
      42             : 
      43             : enum class BkMode
      44             : {
      45             :     NONE         = 0,
      46             :     TRANSPARENT  = 1,
      47             :     OPAQUE       = 2,
      48             :     LAST         = 2
      49             : };
      50             : 
      51             : /* xform stuff */
      52             : #define MWT_IDENTITY            1
      53             : #define MWT_LEFTMULTIPLY        2
      54             : #define MWT_RIGHTMULTIPLY       3
      55             : #define MWT_SET                 4
      56             : 
      57             : #define ENHMETA_STOCK_OBJECT    0x80000000
      58             : 
      59             : /* Stock Logical Objects */
      60             : #define WHITE_BRUSH             0
      61             : #define LTGRAY_BRUSH            1
      62             : #define GRAY_BRUSH              2
      63             : #define DKGRAY_BRUSH            3
      64             : #define BLACK_BRUSH             4
      65             : #define NULL_BRUSH              5
      66             : #define HOLLOW_BRUSH            NULL_BRUSH
      67             : #define WHITE_PEN               6
      68             : #define BLACK_PEN               7
      69             : #define NULL_PEN                8
      70             : #define OEM_FIXED_FONT          10
      71             : #define ANSI_FIXED_FONT         11
      72             : #define ANSI_VAR_FONT           12
      73             : #define SYSTEM_FONT             13
      74             : #define DEVICE_DEFAULT_FONT     14
      75             : #define DEFAULT_PALETTE         15
      76             : #define SYSTEM_FIXED_FONT       16
      77             : 
      78             : #define R2_BLACK                1
      79             : #define R2_NOTMERGEPEN          2
      80             : #define R2_MASKNOTPEN           3
      81             : #define R2_NOTCOPYPEN           4
      82             : #define R2_MASKPENNOT           5
      83             : #define R2_NOT                  6
      84             : #define R2_XORPEN               7
      85             : #define R2_NOTMASKPEN           8
      86             : #define R2_MASKPEN              9
      87             : #define R2_NOTXORPEN            10
      88             : #define R2_NOP                  11
      89             : #define R2_MERGENOTPEN          12
      90             : #define R2_COPYPEN              13
      91             : #define R2_MERGEPENNOT          14
      92             : #define R2_MERGEPEN             15
      93             : #define R2_WHITE                16
      94             : 
      95             : /* Mapping modes */
      96             : #define MM_TEXT                 1
      97             : #define MM_LOMETRIC             2
      98             : #define MM_HIMETRIC             3
      99             : #define MM_LOENGLISH            4
     100             : #define MM_HIENGLISH            5
     101             : #define MM_TWIPS                6
     102             : #define MM_ISOTROPIC            7
     103             : #define MM_ANISOTROPIC          8
     104             : 
     105             : /* Graphics modes */
     106             : #define GM_COMPATIBLE           1
     107             : #define GM_ADVANCED             2
     108             : #define GM_LAST                 2
     109             : 
     110             : /* StretchBlt() modes */
     111             : #define BLACKONWHITE            1
     112             : #define WHITEONBLACK            2
     113             : #define COLORONCOLOR            3
     114             : #define HALFTONE                4
     115             : #define MAXSTRETCHBLTMODE       4
     116             : #define STRETCH_ANDSCANS        BLACKONWHITE
     117             : #define STRETCH_ORSCANS         WHITEONBLACK
     118             : #define STRETCH_DELETESCANS     COLORONCOLOR
     119             : #define STRETCH_HALFTONE        HALFTONE
     120             : 
     121             : #define LF_FACESIZE             32
     122             : 
     123        2100 : struct LOGFONTW
     124             : {
     125             :     sal_Int32       lfHeight;
     126             :     sal_Int32       lfWidth;
     127             :     sal_Int32       lfEscapement;
     128             :     sal_Int32       lfOrientation;
     129             :     sal_Int32       lfWeight;
     130             :     sal_uInt8       lfItalic;
     131             :     sal_uInt8       lfUnderline;
     132             :     sal_uInt8       lfStrikeOut;
     133             :     sal_uInt8       lfCharSet;
     134             :     sal_uInt8       lfOutPrecision;
     135             :     sal_uInt8       lfClipPrecision;
     136             :     sal_uInt8       lfQuality;
     137             :     sal_uInt8       lfPitchAndFamily;
     138             :     OUString        alfFaceName;
     139             : };
     140             : struct WMF_EXTERNALHEADER;
     141             : 
     142             : #define TA_NOUPDATECP           0x0000
     143             : #define TA_UPDATECP             0x0001
     144             : #define TA_LEFT                 0x0000
     145             : #define TA_RIGHT                0x0002
     146             : #define TA_CENTER               0x0006
     147             : #define TA_RIGHT_CENTER  (TA_RIGHT | TA_CENTER)
     148             : #define TA_TOP                  0x0000
     149             : #define TA_BOTTOM               0x0008
     150             : #define TA_BASELINE             0x0018
     151             : 
     152             : #define SRCCOPY                 0x00CC0020L
     153             : #define SRCPAINT                0x00EE0086L
     154             : #define SRCAND                  0x008800C6L
     155             : #define SRCINVERT               0x00660046L
     156             : #define SRCERASE                0x00440328L
     157             : #define NOTSRCCOPY              0x00330008L
     158             : #define NOTSRCERASE             0x001100A6L
     159             : #define MERGECOPY               0x00C000CAL
     160             : #define MERGEPAINT              0x00BB0226L
     161             : #define PATCOPY                 0x00F00021L
     162             : #define PATPAINT                0x00FB0A09L
     163             : #define PATINVERT               0x005A0049L
     164             : #define DSTINVERT               0x00550009L
     165             : #define BLACKNESS               0x00000042L
     166             : #define WHITENESS               0x00FF0062L
     167             : 
     168             : #define PS_SOLID                0
     169             : #define PS_DASH                 1
     170             : #define PS_DOT                  2
     171             : #define PS_DASHDOT              3
     172             : #define PS_DASHDOTDOT           4
     173             : #define PS_NULL                 5
     174             : #define PS_INSIDEFRAME          6
     175             : #define PS_USERSTYLE            7
     176             : #define PS_ALTERNATE            8
     177             : #define PS_STYLE_MASK           15
     178             : 
     179             : #define PS_ENDCAP_ROUND     0x000
     180             : #define PS_ENDCAP_SQUARE    0x100
     181             : #define PS_ENDCAP_FLAT      0x200
     182             : #define PS_ENDCAP_MASK      0xF00
     183             : 
     184             : #define PS_JOIN_ROUND       0x0000
     185             : #define PS_JOIN_BEVEL       0x1000
     186             : #define PS_JOIN_MITER       0x2000
     187             : #define PS_JOIN_MASK        0xF000
     188             : 
     189             : #define PS_COSMETIC         0x00000
     190             : #define PS_GEOMETRIC        0x10000
     191             : #define PS_TYPE_MASK        0xF0000
     192             : 
     193             : #define ANSI_CHARSET            0
     194             : #define DEFAULT_CHARSET         1
     195             : #define SYMBOL_CHARSET          2
     196             : #define SHIFTJIS_CHARSET        128
     197             : #define HANGEUL_CHARSET         129
     198             : #define GB2312_CHARSET          134
     199             : #define CHINESEBIG5_CHARSET     136
     200             : #define OEM_CHARSET             255
     201             : /*WINVER >= 0x0400*/
     202             : #define JOHAB_CHARSET           130
     203             : #define HEBREW_CHARSET          177
     204             : #define ARABIC_CHARSET          178
     205             : #define GREEK_CHARSET           161
     206             : #define TURKISH_CHARSET         162
     207             : #define VIETNAMESE_CHARSET      163
     208             : #define THAI_CHARSET            222
     209             : #define EASTEUROPE_CHARSET      238
     210             : #define RUSSIAN_CHARSET         204
     211             : #define MAC_CHARSET             77
     212             : #define BALTIC_CHARSET          186
     213             : 
     214             : #define ETO_OPAQUE              0x0002
     215             : #define ETO_CLIPPED             0x0004
     216             : /*WINVER >= 0x0400*/
     217             : #define ETO_GLYPH_INDEX         0x0010
     218             : #define ETO_RTLREADING          0x0080
     219             : #define ETO_NUMERICSLOCAL       0x0400
     220             : #define ETO_NUMERICSLATIN       0x0800
     221             : #define ETO_IGNORELANGUAGE      0x1000
     222             : /*_WIN32_WINNT >= 0x0500*/
     223             : #define ETO_PDY                 0x2000
     224             : 
     225             : #define DEFAULT_PITCH           0x00
     226             : #define FIXED_PITCH             0x01
     227             : #define VARIABLE_PITCH          0x02
     228             : 
     229             : /* Font Families */
     230             : #define FF_DONTCARE             0x00
     231             : #define FF_ROMAN                0x10
     232             : #define FF_SWISS                0x20
     233             : #define FF_MODERN               0x30
     234             : #define FF_SCRIPT               0x40
     235             : #define FF_DECORATIVE           0x50
     236             : 
     237             : #define FW_DONTCARE             0
     238             : #define FW_THIN                 100
     239             : #define FW_EXTRALIGHT           200
     240             : #define FW_LIGHT                300
     241             : #define FW_NORMAL               400
     242             : #define FW_MEDIUM               500
     243             : #define FW_SEMIBOLD             600
     244             : #define FW_BOLD                 700
     245             : #define FW_EXTRABOLD            800
     246             : #define FW_HEAVY                900
     247             : #define FW_ULTRALIGHT           200
     248             : #define FW_REGULAR              400
     249             : #define FW_DEMIBOLD             600
     250             : #define FW_ULTRABOLD            800
     251             : #define FW_BLACK                900
     252             : 
     253             : #define BS_SOLID                0
     254             : #define BS_NULL                 1
     255             : #define BS_HOLLOW               1
     256             : #define BS_HATCHED              2
     257             : #define BS_PATTERN              3
     258             : #define BS_INDEXED              4
     259             : #define BS_DIBPATTERN           5
     260             : #define BS_DIBPATTERNPT         6
     261             : #define BS_PATTERN8X8           7
     262             : #define BS_DIBPATTERN8X8        8
     263             : #define BS_MONOPATTERN          9
     264             : 
     265             : #define W_HS_HORIZONTAL         0
     266             : #define W_HS_VERTICAL           1
     267             : #define W_HS_FDIAGONAL          2
     268             : #define W_HS_BDIAGONAL          3
     269             : #define W_HS_CROSS              4
     270             : #define W_HS_DIAGCROSS          5
     271             : 
     272             : #define RDH_RECTANGLES  1
     273             : 
     274             : #define W_MFCOMMENT             15
     275             : 
     276             : #define PRIVATE_ESCAPE_UNICODE  2
     277             : 
     278             : //Scalar constants
     279             : 
     280             : #define UNDOCUMENTED_WIN_RCL_RELATION 32
     281             : #define MS_FIXPOINT_BITCOUNT_28_4 4
     282             : #define HUNDREDTH_MILLIMETERS_PER_MILLIINCH 2.54
     283             : #define MILLIINCH_PER_TWIPS   1.44
     284             : 
     285             : //============================ WMFReader ==================================
     286             : 
     287        4581 : class WinMtfClipPath
     288             : {
     289             :     basegfx::tools::B2DClipState maClip;
     290             : 
     291             : public :
     292        2127 :     WinMtfClipPath(): maClip() {};
     293             : 
     294             :     void        setClipPath( const tools::PolyPolygon& rPolyPolygon, sal_Int32 nClippingMode );
     295             :     void        intersectClipRect( const Rectangle& rRect );
     296             :     void        excludeClipRect( const Rectangle& rRect );
     297             :     void        moveClipRegion( const Size& rSize );
     298             : 
     299        1603 :     bool        isEmpty() const { return maClip.isCleared(); }
     300             : 
     301             :     basegfx::B2DPolyPolygon getClipPath() const;
     302             : 
     303        1622 :     bool        operator==( const WinMtfClipPath& rPath ) const
     304             :                 {
     305        1622 :                     return maClip == rPath.maClip;
     306             :                 };
     307             : };
     308             : 
     309        5457 : class WinMtfPathObj : public tools::PolyPolygon
     310             : {
     311             :     bool    bClosed;
     312             : 
     313             : public:
     314             : 
     315        2127 :     WinMtfPathObj() :
     316        2127 :         bClosed(true)
     317        2127 :     {}
     318             : 
     319         130 :     void        Init()
     320             :     {
     321         130 :         Clear();
     322         130 :         bClosed = true;
     323         130 :     }
     324             : 
     325             :     void        ClosePath();
     326             :     void        AddPoint( const Point& rPoint );
     327             :     void        AddPolygon( const Polygon& rPoly );
     328             :     void        AddPolyLine( const Polygon& rPoly );
     329             :     void        AddPolyPolygon( const tools::PolyPolygon& rPolyPolygon );
     330             : };
     331             : 
     332        1050 : struct WinMtfFontStyle
     333             : {
     334             :     vcl::Font    aFont;
     335             : 
     336             :     WinMtfFontStyle( LOGFONTW& rLogFont );
     337             : };
     338             : 
     339             : 
     340             : typedef enum
     341             : {
     342             :     FillStyleSolid,
     343             :     FillStylePattern
     344             : } WinMtfFillStyleType;
     345             : 
     346       11216 : struct WinMtfFillStyle
     347             : {
     348             :     Color               aFillColor;
     349             :     bool                bTransparent;
     350             :     WinMtfFillStyleType aType;
     351             :     Bitmap              aBmp;
     352             : 
     353        2591 :     WinMtfFillStyle()
     354             :         : aFillColor(Color(COL_BLACK))
     355             :         , bTransparent(false)
     356        2591 :         , aType(FillStyleSolid)
     357        2591 :     {}
     358             : 
     359        3643 :     WinMtfFillStyle(const Color& rColor, bool bTrans = false)
     360             :         : aFillColor(rColor)
     361             :         , bTransparent(bTrans)
     362        3643 :         , aType(FillStyleSolid)
     363        3643 :     {}
     364             : 
     365           2 :     WinMtfFillStyle(Bitmap& rBmp)
     366             :         : bTransparent(false)
     367             :         , aType(FillStylePattern)
     368           2 :         , aBmp(rBmp)
     369           2 :     {}
     370             : 
     371        6497 :     bool operator==( const WinMtfFillStyle& rStyle )
     372             :     {
     373        6497 :         return aFillColor == rStyle.aFillColor
     374        4736 :             && bTransparent == rStyle.bTransparent
     375       11227 :             && aType == rStyle.aType;
     376             :     }
     377             : 
     378             :     bool operator==(WinMtfFillStyle* pStyle)
     379             :     {
     380             :         return aFillColor == pStyle->aFillColor
     381             :             && bTransparent == pStyle->bTransparent
     382             :             && aType == pStyle->aType;
     383             :     }
     384             : 
     385        5099 :     WinMtfFillStyle& operator=(const WinMtfFillStyle& rStyle)
     386             :     {
     387        5099 :         aFillColor = rStyle.aFillColor;
     388        5099 :         bTransparent = rStyle.bTransparent;
     389        5099 :         aBmp = rStyle.aBmp;
     390        5099 :         aType = rStyle.aType;
     391        5099 :         return *this;
     392             :     }
     393             : 
     394        5953 :     WinMtfFillStyle& operator=(WinMtfFillStyle* pStyle)
     395             :     {
     396        5953 :         aFillColor = pStyle->aFillColor;
     397        5953 :         bTransparent = pStyle->bTransparent;
     398        5953 :         aBmp = pStyle->aBmp;
     399        5953 :         aType = pStyle->aType;
     400        5953 :         return *this;
     401             :     }
     402             : };
     403             : 
     404        9312 : struct WinMtfLineStyle
     405             : {
     406             :     Color       aLineColor;
     407             :     LineInfo    aLineInfo;
     408             :     bool        bTransparent;
     409             : 
     410        2591 :     WinMtfLineStyle()
     411             :         : aLineColor  (COL_BLACK)
     412        2591 :         , bTransparent(false)
     413        2591 :     {}
     414             : 
     415        5346 :     WinMtfLineStyle(const Color& rColor, bool bTrans = false)
     416             :         : aLineColor  (rColor)
     417        5346 :         , bTransparent(bTrans)
     418        5346 :     {}
     419             : 
     420        1375 :     WinMtfLineStyle( const Color& rColor, const LineInfo& rStyle, bool bTrans = false)
     421             :         : aLineColor  (rColor)
     422             :         , aLineInfo   (rStyle)
     423        1375 :         , bTransparent(bTrans)
     424        1375 :     {}
     425             : 
     426        6591 :     bool operator==( const WinMtfLineStyle& rStyle )
     427             :     {
     428        6591 :         return aLineColor == rStyle.aLineColor
     429        2814 :             && bTransparent == rStyle.bTransparent
     430        9399 :             && aLineInfo == rStyle.aLineInfo;
     431             :     }
     432             : 
     433             :     bool operator==(WinMtfLineStyle* pStyle)
     434             :     {
     435             :         return aLineColor == pStyle->aLineColor
     436             :             && bTransparent == pStyle->bTransparent
     437             :             && aLineInfo == pStyle->aLineInfo;
     438             :     }
     439             : 
     440        7113 :     WinMtfLineStyle& operator=( const WinMtfLineStyle& rStyle )
     441             :     {
     442        7113 :         aLineColor = rStyle.aLineColor;
     443        7113 :         bTransparent = rStyle.bTransparent;
     444        7113 :         aLineInfo = rStyle.aLineInfo;
     445        7113 :         return *this;
     446             :     }
     447             : 
     448        8301 :     WinMtfLineStyle& operator=( WinMtfLineStyle* pStyle )
     449             :     {
     450        8301 :         aLineColor = pStyle->aLineColor;
     451        8301 :         bTransparent = pStyle->bTransparent;
     452        8301 :         aLineInfo = pStyle->aLineInfo;
     453        8301 :         return *this;
     454             :     }
     455             : };
     456             : 
     457             : struct XForm
     458             : {
     459             :     float   eM11;
     460             :     float   eM12;
     461             :     float   eM21;
     462             :     float   eM22;
     463             :     float   eDx;
     464             :     float   eDy;
     465             : 
     466        4603 :     XForm()
     467             :         : eM11(1.0f)
     468             :         , eM12(0.0f)
     469             :         , eM21(0.0f)
     470             :         , eM22(1.0f)
     471             :         , eDx(0.0f)
     472        4603 :         , eDy(0.0f)
     473        4603 :     {}
     474             : };
     475             : 
     476        3416 : struct SaveStruct
     477             : {
     478             :     BkMode              nBkMode;
     479             :     sal_uInt32          nMapMode, nGfxMode;
     480             :     ComplexTextLayoutMode nTextLayoutMode;
     481             :     sal_Int32           nWinOrgX, nWinOrgY, nWinExtX, nWinExtY;
     482             :     sal_Int32           nDevOrgX, nDevOrgY, nDevWidth, nDevHeight;
     483             : 
     484             :     WinMtfLineStyle     aLineStyle;
     485             :     WinMtfFillStyle     aFillStyle;
     486             : 
     487             :     vcl::Font           aFont;
     488             :     Color               aBkColor;
     489             :     Color               aTextColor;
     490             :     sal_uInt32          nTextAlign;
     491             :     RasterOp            eRasterOp;
     492             : 
     493             :     Point               aActPos;
     494             :     WinMtfPathObj       aPathObj;
     495             :     WinMtfClipPath      aClipPath;
     496             :     XForm               aXForm;
     497             : 
     498             :     bool            bRecordPath;
     499             :     bool            bFillStyleSelected;
     500             : };
     501             : 
     502             : typedef boost::shared_ptr<SaveStruct> SaveStructPtr;
     503             : 
     504        2490 : struct BSaveStruct
     505             : {
     506             :     Bitmap          aBmp;
     507             :     Rectangle       aOutRect;
     508             :     sal_uInt32      nWinRop;
     509             :     WinMtfFillStyle aStyle;
     510             : 
     511        2490 :     BSaveStruct(const Bitmap& rBmp, const Rectangle& rOutRect,
     512             :                 sal_uInt32 nRop, WinMtfFillStyle& rStyle)
     513             :         : aBmp(rBmp)
     514             :         , aOutRect(rOutRect)
     515             :         , nWinRop(nRop)
     516        2490 :         , aStyle (rStyle)
     517        2490 :     {}
     518             : };
     519             : 
     520             : typedef ::std::vector< BSaveStruct* > BSaveStructList_impl;
     521             : 
     522             : enum GDIObjectType
     523             : {
     524             :     GDI_DUMMY = 0,
     525             :     GDI_PEN = 1,
     526             :     GDI_BRUSH = 2,
     527             :     GDI_FONT = 3,
     528             :     GDI_PALETTE = 4,
     529             :     GDI_BITMAP = 5,
     530             :     GDI_REGION = 6
     531             : };
     532             : 
     533             : struct GDIObj
     534             : {
     535             :     void*           pStyle;
     536             :     GDIObjectType   eType;
     537             : 
     538        6810 :     GDIObj()
     539             :         : pStyle (NULL)
     540        6810 :         , eType  (GDI_DUMMY)
     541        6810 :     {}
     542             : 
     543        4630 :     GDIObj(GDIObjectType eT, void* pS)
     544             :     {
     545        4630 :         pStyle = pS;
     546        4630 :         eType = eT;
     547        4630 :     }
     548             : 
     549        4260 :     void Set(GDIObjectType eT, void* pS)
     550             :     {
     551        4260 :         pStyle = pS;
     552        4260 :         eType = eT;
     553        4260 :     }
     554             : 
     555       11440 :     void Delete()
     556             :     {
     557       11440 :         if (pStyle == NULL)
     558       13990 :             return;
     559             : 
     560        8890 :         switch (eType)
     561             :         {
     562             :             case GDI_PEN :
     563        4197 :                 delete (WinMtfLineStyle*)pStyle;
     564        4197 :             break;
     565             :             case GDI_BRUSH :
     566        3643 :                 delete (WinMtfFillStyle*)pStyle;
     567        3643 :             break;
     568             :             case GDI_FONT :
     569        1050 :                 delete (WinMtfFontStyle*)pStyle;
     570        1050 :             break;
     571             : 
     572             :             default:
     573             :                 OSL_FAIL( "unsupported style deleted" );
     574           0 :                 break;
     575             :         }
     576        8890 :         pStyle = NULL;
     577             :     }
     578             : 
     579       11440 :     ~GDIObj()
     580             :     {
     581       11440 :         Delete();
     582       11440 :     }
     583             : };
     584             : 
     585             : class WinMtfOutput
     586             : {
     587             :     WinMtfPathObj       aPathObj;
     588             :     WinMtfClipPath      aClipPath;
     589             : 
     590             :     WinMtfLineStyle     maLatestLineStyle;
     591             :     WinMtfLineStyle     maLineStyle;
     592             :     WinMtfFillStyle     maLatestFillStyle;
     593             :     WinMtfFillStyle     maFillStyle;
     594             :     vcl::Font           maLatestFont;
     595             :     vcl::Font           maFont;
     596             :     sal_uInt32          mnLatestTextAlign;
     597             :     sal_uInt32          mnTextAlign;
     598             :     Color               maLatestTextColor;
     599             :     Color               maTextColor;
     600             :     Color               maLatestBkColor;
     601             :     Color               maBkColor;
     602             :     ComplexTextLayoutMode  mnLatestTextLayoutMode;
     603             :     ComplexTextLayoutMode  mnTextLayoutMode;
     604             :     BkMode              mnLatestBkMode;
     605             :     BkMode              mnBkMode;
     606             :     RasterOp            meLatestRasterOp;
     607             :     RasterOp            meRasterOp;
     608             : 
     609             :     std::vector< GDIObj* > vGDIObj;
     610             : 
     611             :     Point               maActPos;
     612             : 
     613             :     sal_uInt32          mnRop;
     614             :     bool            mbNopMode;
     615             :     bool            mbFillStyleSelected;
     616             :     bool            mbClipNeedsUpdate;
     617             :     bool            mbComplexClip;
     618             : 
     619             :     std::vector< SaveStructPtr > vSaveStack;
     620             : 
     621             :     sal_uInt32          mnGfxMode;
     622             :     sal_uInt32          mnMapMode;
     623             : 
     624             :     XForm               maXForm;
     625             :     sal_Int32           mnDevOrgX, mnDevOrgY;
     626             :     sal_Int32           mnDevWidth, mnDevHeight;
     627             :     sal_Int32           mnWinOrgX, mnWinOrgY;       // aktuel window origin
     628             :     sal_Int32           mnWinExtX, mnWinExtY;       // aktuel window extend
     629             :     bool            mbIsMapWinSet;
     630             :     bool            mbIsMapDevSet;
     631             : 
     632             :     sal_Int32           mnPixX, mnPixY;             // Reference Device in pixel
     633             :     sal_Int32           mnMillX, mnMillY;           // Reference Device in Mill
     634             :     Rectangle           mrclFrame;                  // rectangle in logical units 1/100th mm
     635             :     Rectangle           mrclBounds;
     636             : 
     637             :     GDIMetaFile*        mpGDIMetaFile;
     638             : 
     639             :     void                UpdateLineStyle();
     640             :     void                UpdateFillStyle();
     641             : 
     642             :     Point               ImplMap( const Point& rPt );
     643             :     Point               ImplScale( const Point& rPt );
     644             :     Size                ImplMap( const Size& rSize, bool bDoWorldTransform = true);
     645             :     Rectangle           ImplMap( const Rectangle& rRectangle );
     646             :     void                ImplMap( vcl::Font& rFont );
     647             :     Polygon&            ImplMap( Polygon& rPolygon );
     648             :     tools::PolyPolygon&        ImplMap( tools::PolyPolygon& rPolyPolygon );
     649             :     Polygon&            ImplScale( Polygon& rPolygon );
     650             :     tools::PolyPolygon&        ImplScale( tools::PolyPolygon& rPolyPolygon );
     651             :     void                ImplResizeObjectArry( sal_uInt32 nNewEntry );
     652             :     void                ImplSetNonPersistentLineColorTransparenz();
     653             :     void                ImplDrawClippedPolyPolygon( const tools::PolyPolygon& rPolyPoly );
     654             :     void                ImplDrawBitmap( const Point& rPos, const Size& rSize, const BitmapEx& rBitmap );
     655             : 
     656             : public:
     657             : 
     658             :     void                SetDevByWin(); //Hack to set varying defaults for incompletely defined files.
     659             :     void                SetDevOrg( const Point& rPoint );
     660             :     void                SetDevOrgOffset( sal_Int32 nXAdd, sal_Int32 nYAdd );
     661             :     void                SetDevExt( const Size& rSize ,bool regular = true);
     662             :     void                ScaleDevExt( double fX, double fY );
     663             : 
     664             :     void                SetWinOrg( const Point& rPoint , bool bIsEMF = false);
     665             :     void                SetWinOrgOffset( sal_Int32 nX, sal_Int32 nY );
     666             :     void                SetWinExt( const Size& rSize , bool bIsEMF = false);
     667             :     void                ScaleWinExt( double fX, double fY );
     668             : 
     669             :     void                SetrclBounds( const Rectangle& rRect );
     670             :     void                SetrclFrame( const Rectangle& rRect );
     671             :     void                SetRefPix( const Size& rSize );
     672             :     void                SetRefMill( const Size& rSize );
     673             : 
     674             :     sal_uInt32          GetMapMode() const { return mnMapMode; };
     675             :     void                SetMapMode( sal_uInt32 mnMapMode );
     676             :     void                SetWorldTransform( const XForm& rXForm );
     677             :     const XForm&        GetWorldTransform() const { return maXForm; }
     678             :     void                ModifyWorldTransform( const XForm& rXForm, sal_uInt32 nMode );
     679             : 
     680             :     void                Push();
     681             :     void                Pop();
     682             : 
     683             :     sal_uInt32          SetRasterOp( sal_uInt32 nRasterOp );
     684             :     void                StrokeAndFillPath( bool bStroke, bool bFill );
     685             : 
     686        9210 :     void                SetGfxMode( sal_Int32 nGfxMode ){ mnGfxMode = nGfxMode; };
     687        3070 :     sal_Int32           GetGfxMode() const { return mnGfxMode; };
     688             :     void                SetBkMode( BkMode nMode );
     689             :     void                SetBkColor( const Color& rColor );
     690             :     void                SetTextColor( const Color& rColor );
     691             :     void                SetTextAlign( sal_uInt32 nAlign );
     692             :     void                CreateObject( GDIObjectType, void* pStyle = NULL );
     693             :     void                CreateObject( sal_Int32 nIndex, GDIObjectType, void* pStyle = NULL );
     694             :     void                DeleteObject( sal_Int32 nIndex );
     695             :     void                SelectObject( sal_Int32 nIndex );
     696         306 :     rtl_TextEncoding    GetCharSet(){ return maFont.GetCharSet(); };
     697        2490 :     WinMtfFillStyle&    GetFillStyle () { return maFillStyle; }
     698           0 :     const vcl::Font&    GetFont() const { return maFont;}
     699             :     void                SetTextLayoutMode( ComplexTextLayoutMode nLayoutMode );
     700             : 
     701         130 :     void                ClearPath(){ aPathObj.Init(); };
     702          60 :     void                ClosePath(){ aPathObj.ClosePath(); };
     703          34 :     const tools::PolyPolygon&  GetPathObj(){ return aPathObj; };
     704             : 
     705             :     void                MoveTo( const Point& rPoint, bool bRecordPath = false );
     706             :     void                LineTo( const Point& rPoint, bool bRecordPath = false );
     707             :     void                DrawPixel( const Point& rSource, const Color& rColor );
     708             :     void                DrawRect( const Rectangle& rRect, bool bEdge = true );
     709             :     void                DrawRoundRect( const Rectangle& rRect, const Size& rSize );
     710             :     void                DrawEllipse( const Rectangle& rRect );
     711             :     void                DrawArc(
     712             :                             const Rectangle& rRect,
     713             :                             const Point& rStartAngle,
     714             :                             const Point& rEndAngle,
     715             :                             bool bDrawTo = false
     716             :                         );
     717             :     void                DrawPie(
     718             :                             const Rectangle& rRect,
     719             :                             const Point& rStartAngle,
     720             :                             const Point& rEndAngle
     721             :                         );
     722             :     void                DrawChord(
     723             :                             const Rectangle& rRect,
     724             :                             const Point& rStartAngle,
     725             :                             const Point& rEndAngle
     726             :                         );
     727             :     void                DrawPolygon( Polygon& rPolygon, bool bRecordPath = false );
     728         302 :     void                DrawPolygon( Polygon& rPolygon, bool /*bDrawTo*/, bool bRecordPath)
     729             :                         {
     730             :                             //For ReadAndDrawPolygon template compatibility
     731         302 :                             DrawPolygon(rPolygon, bRecordPath);
     732         302 :                         }
     733             :     void                DrawPolyPolygon( tools::PolyPolygon& rPolyPolygon, bool bRecordPath = false );
     734             :     void                DrawPolyLine(
     735             :                             Polygon& rPolygon,
     736             :                             bool bDrawTo = false,
     737             :                             bool bRecordPath = false
     738             :                         );
     739             :     void                DrawPolyBezier(
     740             :                             Polygon& rPolygin,
     741             :                             bool bDrawTo = false,
     742             :                             bool bRecordPath = false
     743             :                         );
     744             :     void                DrawText( Point& rPosition,
     745             :                                   OUString& rString,
     746             :                                   long* pDXArry = NULL,
     747             :                                   bool bRecordPath = false,
     748             :                                   sal_Int32 nGraphicsMode = GM_COMPATIBLE);
     749             : 
     750             :     void                ResolveBitmapActions( BSaveStructList_impl& rSaveList );
     751             : 
     752             :     void                IntersectClipRect( const Rectangle& rRect );
     753             :     void                ExcludeClipRect( const Rectangle& rRect );
     754             :     void                MoveClipRegion( const Size& rSize );
     755             :     void                SetClipPath(
     756             :                             const tools::PolyPolygon& rPolyPoly,
     757             :                             sal_Int32 nClippingMode,
     758             :                             bool bIsMapped
     759             :                         );
     760             :     void                UpdateClipRegion();
     761             :     void                AddFromGDIMetaFile( GDIMetaFile& rGDIMetaFile );
     762             : 
     763             :     void                PassEMFPlus( void* pBuffer, sal_uInt32 nLength );
     764             :     void                PassEMFPlusHeaderInfo();
     765             : 
     766             :                         WinMtfOutput( GDIMetaFile& rGDIMetaFile );
     767             :     virtual             ~WinMtfOutput();
     768             : };
     769             : 
     770             : class WinMtf
     771             : {
     772             : protected:
     773             : 
     774             :     WinMtfOutput*           pOut;
     775             :     SvStream*               pWMF;               // the WMF/EMF file to be read
     776             : 
     777             :     sal_uInt32              nStartPos, nEndPos;
     778             :     BSaveStructList_impl    aBmpSaveList;
     779             : 
     780             :     FilterConfigItem*   pFilterConfigItem;
     781             : 
     782             :     com::sun::star::uno::Reference< com::sun::star::task::XStatusIndicator > xStatusIndicator;
     783             : 
     784             :     // assures aSampledBrush is the actual brush of the GDIMetaFile
     785             : 
     786             :     Color               ReadColor();
     787             :     void                Callback( sal_uInt16 nPercent );
     788             : 
     789             :                         WinMtf(
     790             :                             WinMtfOutput* pOut,
     791             :                             SvStream& rStreamWMF,
     792             :                             FilterConfigItem* pConfigItem = NULL
     793             :                         );
     794             :                         ~WinMtf();
     795             : };
     796             : 
     797             : class EnhWMFReader : public WinMtf
     798             : {
     799             :     bool        bRecordPath;
     800             :     sal_Int32   nRecordCount;
     801             :     bool        bEMFPlus;
     802             : 
     803             :     bool        ReadHeader();
     804             :                     // reads and converts the rectangle
     805             :     Rectangle       ReadRectangle( sal_Int32, sal_Int32, sal_Int32, sal_Int32 );
     806             : 
     807             : public:
     808             :     EnhWMFReader(SvStream& rStreamWMF, GDIMetaFile& rGDIMetaFile, FilterConfigItem* pConfigItem = NULL);
     809             :     ~EnhWMFReader();
     810             : 
     811             :     bool ReadEnhWMF();
     812             :     void ReadEMFPlusComment(sal_uInt32 length, bool& bHaveDC);
     813             : private:
     814             :     template <class T> void ReadAndDrawPolyPolygon();
     815             :     template <class T> void ReadAndDrawPolyLine();
     816             :     template <class T> Polygon ReadPolygon(sal_uInt32 nStartIndex, sal_uInt32 nPoints);
     817             :     template <class T, class Drawer> void ReadAndDrawPolygon(Drawer drawer, const bool skipFirst);
     818             : 
     819             :     Rectangle ReadRectangle();
     820             : };
     821             : 
     822             : class WMFReader : public WinMtf
     823             : {
     824             : private:
     825             : 
     826             :     sal_uInt16      nUnitsPerInch;
     827             :     sal_uInt32      nRecSize;
     828             : 
     829             :     // embedded EMF data
     830             :     SvMemoryStream* pEMFStream;
     831             : 
     832             :     // total number of comment records containing EMF data
     833             :     sal_uInt32      nEMFRecCount;
     834             : 
     835             :     // number of EMF records read
     836             :     sal_uInt32      nEMFRec;
     837             : 
     838             :     // total size of embedded EMF data
     839             :     sal_uInt32      nEMFSize;
     840             : 
     841             :     sal_uInt32      nSkipActions;
     842             :     sal_uInt32      nCurrentAction;
     843             :     sal_uInt32      nUnicodeEscapeAction;
     844             : 
     845             :     WMF_EXTERNALHEADER* pExternalHeader;
     846             : 
     847             :     // reads header of the WMF-Datei
     848             :     bool        ReadHeader();
     849             : 
     850             :     // reads parameters of the record with the functionnumber nFunction.
     851             :     void            ReadRecordParams( sal_uInt16 nFunction );
     852             : 
     853             :     Point           ReadPoint();                // reads and converts a point (first X then Y)
     854             :     Point           ReadYX();                   // reads and converts a point (first Y then X)
     855             :     Rectangle       ReadRectangle();            // reads and converts a rectangle
     856             :     Size            ReadYXExt();
     857             :     bool        GetPlaceableBound( Rectangle& rSize, SvStream* pStrm );
     858             : 
     859             : public:
     860             : 
     861             :     WMFReader(SvStream& rStreamWMF, GDIMetaFile& rGDIMetaFile,
     862             :               FilterConfigItem* pConfigItem = NULL,
     863             :               WMF_EXTERNALHEADER* pExtHeader = NULL);
     864             :     ~WMFReader();
     865             : 
     866             :     // read WMF file from stream and fill the GDIMetaFile
     867             :     void ReadWMF();
     868             : };
     869             : 
     870             : #endif
     871             : 
     872             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10