LCOV - code coverage report
Current view: top level - svtools/source/filter/wmf - winmtf.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 97 103 94.2 %
Date: 2012-08-25 Functions: 42 47 89.4 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 29 50 58.0 %

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

Generated by: LCOV version 1.10