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

Generated by: LCOV version 1.10