LCOV - code coverage report
Current view: top level - svtools/source/filter/wmf - emfwr.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 330 681 48.5 %
Date: 2012-08-25 Functions: 18 22 81.8 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 291 1084 26.8 %

           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                 :            : 
      30                 :            : #include "emfwr.hxx"
      31                 :            : #include <rtl/strbuf.hxx>
      32                 :            : #include <tools/helpers.hxx>
      33                 :            : #include <basegfx/polygon/b2dpolygon.hxx>
      34                 :            : #include <basegfx/polygon/b2dpolypolygon.hxx>
      35                 :            : #include <vcl/lineinfo.hxx>
      36                 :            : #include <vcl/rendergraphicrasterizer.hxx>
      37                 :            : 
      38                 :            : // -----------
      39                 :            : // - Defines -
      40                 :            : // -----------
      41                 :            : 
      42                 :            : #define WIN_EMR_HEADER                      1
      43                 :            : #define WIN_EMR_POLYBEZIER                  2
      44                 :            : #define WIN_EMR_POLYGON                     3
      45                 :            : #define WIN_EMR_POLYLINE                    4
      46                 :            : #define WIN_EMR_POLYBEZIERTO                5
      47                 :            : #define WIN_EMR_POLYLINETO                  6
      48                 :            : #define WIN_EMR_POLYPOLYLINE                7
      49                 :            : #define WIN_EMR_POLYPOLYGON                 8
      50                 :            : #define WIN_EMR_SETWINDOWEXTEX              9
      51                 :            : #define WIN_EMR_SETWINDOWORGEX              10
      52                 :            : #define WIN_EMR_SETVIEWPORTEXTEX            11
      53                 :            : #define WIN_EMR_SETVIEWPORTORGEX            12
      54                 :            : #define WIN_EMR_SETBRUSHORGEX               13
      55                 :            : #define WIN_EMR_EOF                         14
      56                 :            : #define WIN_EMR_SETPIXELV                   15
      57                 :            : #define WIN_EMR_SETMAPPERFLAGS              16
      58                 :            : #define WIN_EMR_SETMAPMODE                  17
      59                 :            : #define WIN_EMR_SETBKMODE                   18
      60                 :            : #define WIN_EMR_SETPOLYFILLMODE             19
      61                 :            : #define WIN_EMR_SETROP2                     20
      62                 :            : #define WIN_EMR_SETSTRETCHBLTMODE           21
      63                 :            : #define WIN_EMR_SETTEXTALIGN                22
      64                 :            : #define WIN_EMR_SETCOLORADJUSTMENT          23
      65                 :            : #define WIN_EMR_SETTEXTCOLOR                24
      66                 :            : #define WIN_EMR_SETBKCOLOR                  25
      67                 :            : #define WIN_EMR_OFFSETCLIPRGN               26
      68                 :            : #define WIN_EMR_MOVETOEX                    27
      69                 :            : #define WIN_EMR_SETMETARGN                  28
      70                 :            : #define WIN_EMR_EXCLUDECLIPRECT             29
      71                 :            : #define WIN_EMR_INTERSECTCLIPRECT           30
      72                 :            : #define WIN_EMR_SCALEVIEWPORTEXTEX          31
      73                 :            : #define WIN_EMR_SCALEWINDOWEXTEX            32
      74                 :            : #define WIN_EMR_SAVEDC                      33
      75                 :            : #define WIN_EMR_RESTOREDC                   34
      76                 :            : #define WIN_EMR_SETWORLDTRANSFORM           35
      77                 :            : #define WIN_EMR_MODIFYWORLDTRANSFORM        36
      78                 :            : #define WIN_EMR_SELECTOBJECT                37
      79                 :            : #define WIN_EMR_CREATEPEN                   38
      80                 :            : #define WIN_EMR_CREATEBRUSHINDIRECT         39
      81                 :            : #define WIN_EMR_DELETEOBJECT                40
      82                 :            : #define WIN_EMR_ANGLEARC                    41
      83                 :            : #define WIN_EMR_ELLIPSE                     42
      84                 :            : #define WIN_EMR_RECTANGLE                   43
      85                 :            : #define WIN_EMR_ROUNDRECT                   44
      86                 :            : #define WIN_EMR_ARC                         45
      87                 :            : #define WIN_EMR_CHORD                       46
      88                 :            : #define WIN_EMR_PIE                         47
      89                 :            : #define WIN_EMR_SELECTPALETTE               48
      90                 :            : #define WIN_EMR_CREATEPALETTE               49
      91                 :            : #define WIN_EMR_SETPALETTEENTRIES           50
      92                 :            : #define WIN_EMR_RESIZEPALETTE               51
      93                 :            : #define WIN_EMR_REALIZEPALETTE              52
      94                 :            : #define WIN_EMR_EXTFLOODFILL                53
      95                 :            : #define WIN_EMR_LINETO                      54
      96                 :            : #define WIN_EMR_ARCTO                       55
      97                 :            : #define WIN_EMR_POLYDRAW                    56
      98                 :            : #define WIN_EMR_SETARCDIRECTION             57
      99                 :            : #define WIN_EMR_SETMITERLIMIT               58
     100                 :            : #define WIN_EMR_BEGINPATH                   59
     101                 :            : #define WIN_EMR_ENDPATH                     60
     102                 :            : #define WIN_EMR_CLOSEFIGURE                 61
     103                 :            : #define WIN_EMR_FILLPATH                    62
     104                 :            : #define WIN_EMR_STROKEANDFILLPATH           63
     105                 :            : #define WIN_EMR_STROKEPATH                  64
     106                 :            : #define WIN_EMR_FLATTENPATH                 65
     107                 :            : #define WIN_EMR_WIDENPATH                   66
     108                 :            : #define WIN_EMR_SELECTCLIPPATH              67
     109                 :            : #define WIN_EMR_ABORTPATH                   68
     110                 :            : 
     111                 :            : #define WIN_EMR_GDICOMMENT                  70
     112                 :            : #define WIN_EMR_FILLRGN                     71
     113                 :            : #define WIN_EMR_FRAMERGN                    72
     114                 :            : #define WIN_EMR_INVERTRGN                   73
     115                 :            : #define WIN_EMR_PAINTRGN                    74
     116                 :            : #define WIN_EMR_EXTSELECTCLIPRGN            75
     117                 :            : #define WIN_EMR_BITBLT                      76
     118                 :            : #define WIN_EMR_STRETCHBLT                  77
     119                 :            : #define WIN_EMR_MASKBLT                     78
     120                 :            : #define WIN_EMR_PLGBLT                      79
     121                 :            : #define WIN_EMR_SETDIBITSTODEVICE           80
     122                 :            : #define WIN_EMR_STRETCHDIBITS               81
     123                 :            : #define WIN_EMR_EXTCREATEFONTINDIRECTW      82
     124                 :            : #define WIN_EMR_EXTTEXTOUTA                 83
     125                 :            : #define WIN_EMR_EXTTEXTOUTW                 84
     126                 :            : #define WIN_EMR_POLYBEZIER16                85
     127                 :            : #define WIN_EMR_POLYGON16                   86
     128                 :            : #define WIN_EMR_POLYLINE16                  87
     129                 :            : #define WIN_EMR_POLYBEZIERTO16              88
     130                 :            : #define WIN_EMR_POLYLINETO16                89
     131                 :            : #define WIN_EMR_POLYPOLYLINE16              90
     132                 :            : #define WIN_EMR_POLYPOLYGON16               91
     133                 :            : #define WIN_EMR_POLYDRAW16                  92
     134                 :            : #define WIN_EMR_CREATEMONOBRUSH             93
     135                 :            : #define WIN_EMR_CREATEDIBPATTERNBRUSHPT     94
     136                 :            : #define WIN_EMR_EXTCREATEPEN                95
     137                 :            : #define WIN_EMR_POLYTEXTOUTA                96
     138                 :            : #define WIN_EMR_POLYTEXTOUTW                97
     139                 :            : 
     140                 :            : #define WIN_SRCCOPY                         0x00CC0020L
     141                 :            : #define WIN_SRCPAINT                        0x00EE0086L
     142                 :            : #define WIN_SRCAND                          0x008800C6L
     143                 :            : #define WIN_SRCINVERT                       0x00660046L
     144                 :            : 
     145                 :            : #define HANDLE_INVALID                      0xffffffff
     146                 :            : #define MAXHANDLES                          65000
     147                 :            : 
     148                 :            : #define LINE_SELECT                         0x00000001
     149                 :            : #define FILL_SELECT                         0x00000002
     150                 :            : #define TEXT_SELECT                         0x00000004
     151                 :            : 
     152                 :            : /* Text Alignment Options */
     153                 :            : #define TA_NOUPDATECP                       0
     154                 :            : #define TA_UPDATECP                         1
     155                 :            : 
     156                 :            : #define TA_LEFT                             0
     157                 :            : #define TA_RIGHT                            2
     158                 :            : #define TA_CENTER                           6
     159                 :            : 
     160                 :            : #define TA_TOP                              0
     161                 :            : #define TA_BOTTOM                           8
     162                 :            : #define TA_BASELINE                         24
     163                 :            : #define TA_RTLREADING                       256
     164                 :            : #define TA_MASK     (TA_BASELINE+TA_CENTER+TA_UPDATECP+TA_RTLREADING)
     165                 :            : 
     166                 :            : #define MM_ANISOTROPIC                      8
     167                 :            : 
     168                 :            : // -------------
     169                 :            : // - EMFWriter -
     170                 :            : // -------------
     171                 :            : 
     172                 :         90 : sal_Bool EMFWriter::WriteEMF( const GDIMetaFile& rMtf, FilterConfigItem* pFilterConfigItem )
     173                 :            : {
     174                 :         90 :     const sal_uLong nHeaderPos = m_rStm.Tell();
     175                 :            : 
     176         [ +  - ]:         90 :     mpHandlesUsed = new sal_Bool[ MAXHANDLES ];
     177                 :         90 :     memset( mpHandlesUsed, 0, MAXHANDLES * sizeof( sal_Bool ) );
     178                 :         90 :     mnHorTextAlign = mnHandleCount = mnLastPercent = mnRecordPos = mnRecordCount = 0;
     179                 :         90 :     mnLineHandle = mnFillHandle = mnTextHandle = HANDLE_INVALID;
     180                 :         90 :     mbRecordOpen = sal_False;
     181                 :            : 
     182         [ +  - ]:         90 :     maVDev.EnableOutput( sal_False );
     183         [ +  - ]:         90 :     maVDev.SetMapMode( rMtf.GetPrefMapMode() );
     184                 :         90 :     mpFilterConfigItem = pFilterConfigItem;
     185                 :            : 
     186                 :            :     // don't work with pixel as destination map mode -> higher resolution preferrable
     187         [ +  - ]:         90 :     maDestMapMode.SetMapUnit( MAP_100TH_MM );
     188                 :            : 
     189         [ +  - ]:         90 :     const Size aMtfSizePix( maVDev.LogicToPixel( rMtf.GetPrefSize(), rMtf.GetPrefMapMode() ) );
     190 [ +  - ][ +  - ]:         90 :     const Size aMtfSizeLog( maVDev.LogicToLogic( rMtf.GetPrefSize(), rMtf.GetPrefMapMode(), MAP_100TH_MM ) );
                 [ +  - ]
     191                 :            : 
     192                 :            :     // seek over header
     193                 :            :     // use [MS-EMF 2.2.11] HeaderExtension2 Object, otherwise resulting EMF cannot be converted with GetWinMetaFileBits()
     194         [ +  - ]:         90 :     m_rStm.SeekRel( 108 );
     195                 :            : 
     196                 :            :     // write initial values
     197                 :            : 
     198                 :            :     // set 100th mm map mode in EMF
     199         [ +  - ]:         90 :     ImplBeginRecord( WIN_EMR_SETMAPMODE );
     200         [ +  - ]:         90 :     m_rStm << (sal_Int32) MM_ANISOTROPIC;
     201         [ +  - ]:         90 :     ImplEndRecord();
     202                 :            : 
     203         [ +  - ]:         90 :     ImplBeginRecord( WIN_EMR_SETVIEWPORTEXTEX );
     204 [ +  - ][ +  - ]:         90 :     m_rStm << (sal_Int32) maVDev.ImplGetDPIX() << (sal_Int32) maVDev.ImplGetDPIY();
     205         [ +  - ]:         90 :     ImplEndRecord();
     206                 :            : 
     207         [ +  - ]:         90 :     ImplBeginRecord( WIN_EMR_SETWINDOWEXTEX );
     208 [ +  - ][ +  - ]:         90 :     m_rStm << (sal_Int32) 2540 << (sal_Int32) 2540;
     209         [ +  - ]:         90 :     ImplEndRecord();
     210                 :            : 
     211         [ +  - ]:         90 :     ImplBeginRecord( WIN_EMR_SETVIEWPORTORGEX );
     212 [ +  - ][ +  - ]:         90 :     m_rStm << (sal_Int32) 0 << (sal_Int32) 0;
     213         [ +  - ]:         90 :     ImplEndRecord();
     214                 :            : 
     215         [ +  - ]:         90 :     ImplBeginRecord( WIN_EMR_SETWINDOWORGEX );
     216 [ +  - ][ +  - ]:         90 :     m_rStm << (sal_Int32) 0 << (sal_Int32) 0;
     217         [ +  - ]:         90 :     ImplEndRecord();
     218                 :            : 
     219         [ +  - ]:         90 :     ImplWriteRasterOp( ROP_OVERPAINT );
     220                 :            : 
     221         [ +  - ]:         90 :     ImplBeginRecord( WIN_EMR_SETBKMODE );
     222         [ +  - ]:         90 :     m_rStm << (sal_uInt32) 1; // TRANSPARENT
     223         [ +  - ]:         90 :     ImplEndRecord();
     224                 :            : 
     225                 :            :     // write emf data
     226         [ +  - ]:         90 :     ImplWrite( rMtf );
     227                 :            : 
     228         [ +  - ]:         90 :     ImplBeginRecord( WIN_EMR_EOF );
     229         [ +  - ]:         90 :     m_rStm<< (sal_uInt32)0      // nPalEntries
     230         [ +  - ]:         90 :             << (sal_uInt32)0x10     // offPalEntries
     231         [ +  - ]:         90 :             << (sal_uInt32)0x14;    // nSizeLast
     232         [ +  - ]:         90 :     ImplEndRecord();
     233                 :            : 
     234                 :            : 
     235                 :            :     // write header
     236         [ +  - ]:         90 :     const sal_uLong nEndPos = m_rStm.Tell(); m_rStm.Seek( nHeaderPos );
     237                 :            : 
     238 [ +  - ][ +  - ]:         90 :     m_rStm << (sal_uInt32) 0x00000001 << (sal_uInt32) 108   //use [MS-EMF 2.2.11] HeaderExtension2 Object
     239 [ +  - ][ +  - ]:        180 :              << (sal_Int32) 0 << (sal_Int32) 0 << (sal_Int32) ( aMtfSizePix.Width() - 1 ) << (sal_Int32) ( aMtfSizePix.Height() - 1 )
         [ +  - ][ +  - ]
     240 [ +  - ][ +  - ]:        180 :              << (sal_Int32) 0 << (sal_Int32) 0 << (sal_Int32) ( aMtfSizeLog.Width() - 1 ) << (sal_Int32) ( aMtfSizeLog.Height() - 1 )
         [ +  - ][ +  - ]
     241 [ +  - ][ +  - ]:         90 :              << (sal_uInt32) 0x464d4520 << (sal_uInt32) 0x10000 << (sal_uInt32) ( nEndPos - nHeaderPos )
                 [ +  - ]
     242 [ +  - ][ +  - ]:         90 :              << (sal_uInt32) mnRecordCount << (sal_uInt16) ( mnHandleCount + 1 ) << (sal_uInt16) 0 << (sal_uInt32) 0 << (sal_uInt32) 0 << (sal_uInt32) 0
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     243 [ +  - ][ +  - ]:        180 :              << (sal_Int32) aMtfSizePix.Width() << (sal_Int32) aMtfSizePix.Height()
     244 [ +  - ][ +  - ]:        180 :              << (sal_Int32) ( aMtfSizeLog.Width() / 100 ) << (sal_Int32) ( aMtfSizeLog.Height() / 100 )
     245 [ +  - ][ +  - ]:         90 :              << (sal_uInt32) 0 << (sal_uInt32) 0 << (sal_uInt32) 0
                 [ +  - ]
     246 [ +  - ][ +  - ]:        180 :              << (sal_Int32) (  aMtfSizeLog.Width() * 10 ) << (sal_Int32) ( aMtfSizeLog.Height() * 10 ); //use [MS-EMF 2.2.11] HeaderExtension2 Object
     247                 :            : 
     248         [ +  - ]:         90 :     m_rStm.Seek( nEndPos );
     249         [ +  - ]:         90 :     delete[] mpHandlesUsed;
     250                 :            : 
     251                 :         90 :     return( m_rStm.GetError() == ERRCODE_NONE );
     252                 :            : }
     253                 :            : 
     254                 :            : // -----------------------------------------------------------------------------
     255                 :            : 
     256                 :       1107 : sal_uLong EMFWriter::ImplAcquireHandle()
     257                 :            : {
     258                 :       1107 :     sal_uLong nHandle = HANDLE_INVALID;
     259                 :            : 
     260 [ +  - ][ +  + ]:       2385 :     for( sal_uLong i = 0; i < MAXHANDLES && ( HANDLE_INVALID == nHandle ); i++ )
                 [ +  + ]
     261                 :            :     {
     262         [ +  + ]:       1278 :         if( !mpHandlesUsed[ i ] )
     263                 :            :         {
     264                 :       1107 :             mpHandlesUsed[ i ] = sal_True;
     265                 :            : 
     266         [ +  + ]:       1107 :             if( ( nHandle = i ) == mnHandleCount )
     267                 :        153 :                 mnHandleCount++;
     268                 :            :         }
     269                 :            :     }
     270                 :            : 
     271                 :            :     DBG_ASSERT( nHandle != HANDLE_INVALID, "No more handles available" );
     272         [ +  - ]:       1107 :     return( nHandle != HANDLE_INVALID ? nHandle + 1 : HANDLE_INVALID );
     273                 :            : }
     274                 :            : 
     275                 :            : // -----------------------------------------------------------------------------
     276                 :            : 
     277                 :        954 : void EMFWriter::ImplReleaseHandle( sal_uLong nHandle )
     278                 :            : {
     279                 :            :     DBG_ASSERT( nHandle && ( nHandle < MAXHANDLES ), "Handle out of range" );
     280                 :        954 :     mpHandlesUsed[ nHandle - 1 ] = sal_False;
     281                 :        954 : }
     282                 :            : 
     283                 :            : // -----------------------------------------------------------------------------
     284                 :            : 
     285                 :      11388 : void EMFWriter::ImplBeginRecord( sal_uInt32 nType )
     286                 :            : {
     287                 :            :     DBG_ASSERT( !mbRecordOpen, "Another record is already opened!" );
     288                 :            : 
     289         [ +  - ]:      11388 :     if( !mbRecordOpen )
     290                 :            :     {
     291                 :      11388 :         mbRecordOpen = sal_True;
     292                 :      11388 :         mnRecordPos = m_rStm.Tell();
     293                 :            : 
     294                 :      11388 :         m_rStm << nType;
     295                 :      11388 :         m_rStm.SeekRel( 4 );
     296                 :            :     }
     297                 :      11388 : }
     298                 :            : 
     299                 :            : // -----------------------------------------------------------------------------
     300                 :            : 
     301                 :      11388 : void EMFWriter::ImplEndRecord()
     302                 :            : {
     303                 :            :     DBG_ASSERT( mbRecordOpen, "Record was not opened!" );
     304                 :            : 
     305         [ +  - ]:      11388 :     if( mbRecordOpen )
     306                 :            :     {
     307                 :      11388 :         sal_Int32 nFillBytes, nActPos = m_rStm.Tell();
     308                 :      11388 :         m_rStm.Seek( mnRecordPos + 4 );
     309                 :      11388 :         nFillBytes = nActPos - mnRecordPos;
     310                 :      11388 :         nFillBytes += 3;    // each record has to be dword aligned
     311                 :      11388 :         nFillBytes ^= 3;
     312                 :      11388 :         nFillBytes &= 3;
     313                 :      11388 :         m_rStm << (sal_uInt32)( ( nActPos - mnRecordPos ) + nFillBytes );
     314                 :      11388 :         m_rStm.Seek( nActPos );
     315         [ -  + ]:      11388 :         while( nFillBytes-- )
     316                 :          0 :             m_rStm << (sal_uInt8)0;
     317                 :      11388 :         mnRecordCount++;
     318                 :      11388 :         mbRecordOpen = sal_False;
     319                 :            :     }
     320                 :      11388 : }
     321                 :            : 
     322                 :            : // -----------------------------------------------------------------------------
     323                 :            : 
     324                 :       1107 : sal_Bool EMFWriter::ImplPrepareHandleSelect( sal_uInt32& rHandle, sal_uLong nSelectType )
     325                 :            : {
     326         [ +  + ]:       1107 :     if( rHandle != HANDLE_INVALID )
     327                 :            :     {
     328                 :        954 :         sal_uInt32 nStockObject = 0x80000000;
     329                 :            : 
     330         [ +  + ]:        954 :         if( LINE_SELECT == nSelectType )
     331                 :         24 :             nStockObject |= 0x00000007;
     332         [ +  + ]:        930 :         else if( FILL_SELECT == nSelectType )
     333                 :         24 :             nStockObject |= 0x00000001;
     334         [ +  - ]:        906 :         else if( TEXT_SELECT == nSelectType )
     335                 :        906 :             nStockObject |= 0x0000000a;
     336                 :            : 
     337                 :            :         // select stock object first
     338                 :        954 :         ImplBeginRecord( WIN_EMR_SELECTOBJECT );
     339                 :        954 :         m_rStm << nStockObject;
     340                 :        954 :         ImplEndRecord();
     341                 :            : 
     342                 :            :         // destroy handle of created object
     343                 :        954 :         ImplBeginRecord( WIN_EMR_DELETEOBJECT );
     344                 :        954 :         m_rStm << rHandle;
     345                 :        954 :         ImplEndRecord();
     346                 :            : 
     347                 :            :         // mark handle as free
     348                 :        954 :         ImplReleaseHandle( rHandle );
     349                 :            :     }
     350                 :            : 
     351                 :       1107 :     rHandle = ImplAcquireHandle();
     352                 :            : 
     353                 :       1107 :     return( HANDLE_INVALID != rHandle );
     354                 :            : }
     355                 :            : 
     356                 :            : // -----------------------------------------------------------------------------
     357                 :            : 
     358                 :         57 : void EMFWriter::ImplCheckLineAttr()
     359                 :            : {
     360 [ +  - ][ +  - ]:         57 :     if( mbLineChanged && ImplPrepareHandleSelect( mnLineHandle, LINE_SELECT ) )
                 [ +  - ]
     361                 :            :     {
     362         [ -  + ]:         57 :         sal_uInt32 nStyle = maVDev.IsLineColor() ? 0 : 5;
     363                 :         57 :         sal_uInt32 nWidth = 0, nHeight = 0;
     364                 :            : 
     365                 :         57 :         ImplBeginRecord( WIN_EMR_CREATEPEN );
     366                 :         57 :         m_rStm << mnLineHandle << nStyle << nWidth << nHeight;
     367                 :         57 :         ImplWriteColor( maVDev.GetLineColor() );
     368                 :         57 :         ImplEndRecord();
     369                 :            : 
     370                 :         57 :         ImplBeginRecord( WIN_EMR_SELECTOBJECT );
     371                 :         57 :         m_rStm << mnLineHandle;
     372                 :         57 :         ImplEndRecord();
     373                 :            :     }
     374                 :         57 : }
     375                 :            : 
     376                 :            : // -----------------------------------------------------------------------------
     377                 :            : 
     378                 :         57 : void EMFWriter::ImplCheckFillAttr()
     379                 :            : {
     380 [ +  - ][ +  - ]:         57 :     if( mbFillChanged && ImplPrepareHandleSelect( mnFillHandle, FILL_SELECT ) )
                 [ +  - ]
     381                 :            :     {
     382                 :         57 :         sal_uInt32 nStyle = maVDev.IsFillColor() ? 0 : 1;
     383                 :         57 :         sal_uInt32 nPatternStyle = 0;
     384                 :            : 
     385                 :         57 :         ImplBeginRecord( WIN_EMR_CREATEBRUSHINDIRECT );
     386                 :         57 :         m_rStm << mnFillHandle << nStyle;
     387                 :         57 :         ImplWriteColor( maVDev.GetFillColor() );
     388                 :         57 :         m_rStm << nPatternStyle;
     389                 :         57 :         ImplEndRecord();
     390                 :            : 
     391                 :         57 :         ImplBeginRecord( WIN_EMR_SELECTOBJECT );
     392                 :         57 :         m_rStm << mnFillHandle;
     393                 :         57 :         ImplEndRecord();
     394                 :            :     }
     395                 :         57 : }
     396                 :            : 
     397                 :            : // -----------------------------------------------------------------------------
     398                 :            : 
     399                 :        993 : void EMFWriter::ImplCheckTextAttr()
     400                 :            : {
     401 [ +  - ][ +  - ]:        993 :     if( mbTextChanged && ImplPrepareHandleSelect( mnTextHandle, TEXT_SELECT ) )
                 [ +  - ]
     402                 :            :     {
     403                 :        993 :         const Font&     rFont = maVDev.GetFont();
     404 [ +  - ][ +  - ]:        993 :         String          aFontName( rFont.GetName() );
     405                 :            :         sal_Int32       nWeight;
     406                 :            :         sal_uInt16      i;
     407                 :            :         sal_uInt8       nPitchAndFamily;
     408                 :            : 
     409         [ +  - ]:        993 :         ImplBeginRecord( WIN_EMR_EXTCREATEFONTINDIRECTW );
     410         [ +  - ]:        993 :         m_rStm << mnTextHandle;
     411 [ +  - ][ +  - ]:        993 :         ImplWriteExtent( -rFont.GetSize().Height() );
     412 [ +  - ][ +  - ]:        993 :         ImplWriteExtent( rFont.GetSize().Width() );
     413 [ +  - ][ +  - ]:        993 :         m_rStm << (sal_Int32) rFont.GetOrientation() << (sal_Int32) rFont.GetOrientation();
         [ +  - ][ +  - ]
     414                 :            : 
     415 [ +  - ][ -  -  :        993 :         switch( rFont.GetWeight() )
          -  -  +  -  -  
             -  -  -  - ]
     416                 :            :         {
     417                 :          0 :             case WEIGHT_THIN:       nWeight = 100; break;
     418                 :          0 :             case WEIGHT_ULTRALIGHT: nWeight = 200; break;
     419                 :          0 :             case WEIGHT_LIGHT:      nWeight = 300; break;
     420                 :          0 :             case WEIGHT_SEMILIGHT:  nWeight = 300; break;
     421                 :        993 :             case WEIGHT_NORMAL:     nWeight = 400; break;
     422                 :          0 :             case WEIGHT_MEDIUM:     nWeight = 500; break;
     423                 :          0 :             case WEIGHT_SEMIBOLD:   nWeight = 600; break;
     424                 :          0 :             case WEIGHT_BOLD:       nWeight = 700; break;
     425                 :          0 :             case WEIGHT_ULTRABOLD:  nWeight = 800; break;
     426                 :          0 :             case WEIGHT_BLACK:      nWeight = 900; break;
     427                 :          0 :             default:                nWeight = 0; break;
     428                 :            :         }
     429                 :            : 
     430         [ +  - ]:        993 :         m_rStm << nWeight;
     431 [ +  - ][ +  - ]:        993 :         m_rStm << (sal_uInt8) ( ( ITALIC_NONE == rFont.GetItalic() ) ? 0 : 1 );
     432 [ +  - ][ +  - ]:        993 :         m_rStm << (sal_uInt8) ( ( UNDERLINE_NONE == rFont.GetUnderline() ) ? 0 : 1 );
     433 [ +  - ][ +  - ]:        993 :         m_rStm << (sal_uInt8) ( ( STRIKEOUT_NONE == rFont.GetStrikeout() ) ? 0 : 1 );
     434 [ +  - ][ -  + ]:        993 :         m_rStm << (sal_uInt8) ( ( RTL_TEXTENCODING_SYMBOL == rFont.GetCharSet() ) ? 2 : 0 );
                 [ +  - ]
     435 [ +  - ][ +  - ]:        993 :         m_rStm << (sal_uInt8) 0 << (sal_uInt8) 0 << (sal_uInt8) 0;
                 [ +  - ]
     436                 :            : 
     437         [ +  - ]:        993 :         switch( rFont.GetPitch() )
              [ -  -  + ]
     438                 :            :         {
     439                 :          0 :             case PITCH_FIXED:    nPitchAndFamily = 0x01; break;
     440                 :          0 :             case PITCH_VARIABLE: nPitchAndFamily = 0x02; break;
     441                 :        993 :             default:             nPitchAndFamily = 0x00; break;
     442                 :            :         }
     443                 :            : 
     444 [ +  - ][ -  -  :        993 :         switch( rFont.GetFamily() )
             +  -  -  + ]
     445                 :            :         {
     446                 :          0 :             case FAMILY_DECORATIVE: nPitchAndFamily |= 0x50; break;
     447                 :          0 :             case FAMILY_MODERN:     nPitchAndFamily |= 0x30; break;
     448                 :        639 :             case FAMILY_ROMAN:      nPitchAndFamily |= 0x10; break;
     449                 :          0 :             case FAMILY_SCRIPT:     nPitchAndFamily |= 0x40; break;
     450                 :          0 :             case FAMILY_SWISS:      nPitchAndFamily |= 0x20; break;
     451                 :        354 :             default: break;
     452                 :            :         }
     453                 :            : 
     454         [ +  - ]:        993 :         m_rStm << nPitchAndFamily;
     455                 :            : 
     456         [ +  + ]:      32769 :         for( i = 0; i < 32; i++ )
     457 [ +  + ][ +  - ]:      31776 :             m_rStm << (sal_Unicode) ( ( i < aFontName.Len() ) ? aFontName.GetChar( i ) : 0 );
     458                 :            : 
     459                 :            :         // dummy elfFullName
     460         [ +  + ]:      64545 :         for( i = 0; i < 64; i++ )
     461         [ +  - ]:      63552 :             m_rStm << (sal_Unicode) 0;
     462                 :            : 
     463                 :            :         // dummy elfStyle
     464         [ +  + ]:      32769 :         for( i = 0; i < 32; i++ )
     465         [ +  - ]:      31776 :             m_rStm << (sal_Unicode) 0;
     466                 :            : 
     467                 :            :         // dummy elfVersion, elfStyleSize, elfMatch, elfReserved
     468 [ +  - ][ +  - ]:        993 :         m_rStm << (sal_uInt32) 0 << (sal_uInt32) 0 << (sal_uInt32) 0 << (sal_uInt32) 0 ;
         [ +  - ][ +  - ]
     469                 :            : 
     470                 :            :         // dummy elfVendorId
     471         [ +  - ]:        993 :         m_rStm << (sal_uInt32) 0;
     472                 :            : 
     473                 :            :         // dummy elfCulture
     474         [ +  - ]:        993 :         m_rStm << (sal_uInt32) 0;
     475                 :            : 
     476                 :            :         // dummy elfPanose
     477 [ +  - ][ +  - ]:        993 :         m_rStm << (sal_uInt8) 0 << (sal_uInt8) 0 << (sal_uInt8) 0 << (sal_uInt8) 0 << (sal_uInt8) 0 << (sal_uInt8) 0 << (sal_uInt8) 0 << (sal_uInt8) 0 << (sal_uInt8) 0 << (sal_uInt8) 0;
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     478                 :            : 
     479                 :            :         // fill record to get a record size divideable by 4
     480         [ +  - ]:        993 :         m_rStm << (sal_uInt16) 0;
     481                 :            : 
     482         [ +  - ]:        993 :         ImplEndRecord();
     483                 :            : 
     484                 :            :         // TextAlign
     485                 :            :         sal_uInt32 nTextAlign;
     486                 :            : 
     487         [ +  - ]:        993 :         switch( rFont.GetAlign() )
              [ -  -  + ]
     488                 :            :         {
     489                 :          0 :             case ALIGN_TOP:    nTextAlign = TA_TOP; break;
     490                 :          0 :             case ALIGN_BOTTOM: nTextAlign = TA_BOTTOM; break;
     491                 :        993 :             default:           nTextAlign = TA_BASELINE; break;
     492                 :            :         }
     493                 :        993 :         nTextAlign |= mnHorTextAlign;
     494                 :            : 
     495         [ +  - ]:        993 :         ImplBeginRecord( WIN_EMR_SETTEXTALIGN );
     496         [ +  - ]:        993 :         m_rStm << nTextAlign;
     497         [ +  - ]:        993 :         ImplEndRecord();
     498                 :            : 
     499                 :            :         // Text color
     500         [ +  - ]:        993 :         ImplBeginRecord( WIN_EMR_SETTEXTCOLOR );
     501         [ +  - ]:        993 :         ImplWriteColor( maVDev.GetTextColor() );
     502         [ +  - ]:        993 :         ImplEndRecord();
     503                 :            : 
     504         [ +  - ]:        993 :         ImplBeginRecord( WIN_EMR_SELECTOBJECT );
     505         [ +  - ]:        993 :         m_rStm << mnTextHandle;
     506 [ +  - ][ +  - ]:        993 :         ImplEndRecord();
     507                 :            :     }
     508                 :        993 : }
     509                 :            : 
     510                 :            : // -----------------------------------------------------------------------------
     511                 :            : 
     512                 :       1107 : void EMFWriter::ImplWriteColor( const Color& rColor )
     513                 :            : {
     514                 :       1107 :     sal_uInt32 nCol = rColor.GetRed();
     515                 :            : 
     516                 :       1107 :     nCol |= ( (sal_uInt32) rColor.GetGreen() ) << 8;
     517                 :       1107 :     nCol |= ( (sal_uInt32) rColor.GetBlue() ) << 16;
     518                 :            : 
     519                 :       1107 :     m_rStm << nCol;
     520                 :       1107 : }
     521                 :            : 
     522                 :            : // -----------------------------------------------------------------------------
     523                 :            : 
     524                 :       1227 : void EMFWriter::ImplWriteRasterOp( RasterOp eRop )
     525                 :            : {
     526                 :            :     sal_uInt32 nROP2;
     527                 :            : 
     528      [ -  -  + ]:       1227 :     switch( eRop )
     529                 :            :     {
     530                 :          0 :         case ROP_INVERT: nROP2 = 6; break;
     531                 :          0 :         case ROP_XOR:    nROP2 = 7; break;
     532                 :       1227 :         default:         nROP2 = 13;break;
     533                 :            :     }
     534                 :            : 
     535                 :       1227 :     ImplBeginRecord( WIN_EMR_SETROP2 );
     536                 :       1227 :     m_rStm << nROP2;
     537                 :       1227 :     ImplEndRecord();
     538                 :       1227 : }
     539                 :            : 
     540                 :            : // -----------------------------------------------------------------------------
     541                 :            : 
     542                 :       3108 : void EMFWriter::ImplWriteExtent( long nExtent )
     543                 :            : {
     544         [ +  - ]:       3108 :     nExtent = maVDev.LogicToLogic( Size( nExtent, 0 ), maVDev.GetMapMode(), maDestMapMode ).Width();
     545                 :       3108 :     m_rStm << (sal_Int32) nExtent;
     546                 :       3108 : }
     547                 :            : 
     548                 :            : // -----------------------------------------------------------------------------
     549                 :            : 
     550                 :       1005 : void EMFWriter::ImplWritePoint( const Point& rPoint )
     551                 :            : {
     552         [ +  - ]:       1005 :     const Point aPoint( maVDev.LogicToLogic( rPoint, maVDev.GetMapMode(), maDestMapMode ));
     553 [ +  - ][ +  - ]:       1005 :      m_rStm << (sal_Int32) aPoint.X() << (sal_Int32) aPoint.Y();
     554                 :       1005 : }
     555                 :            : 
     556                 :            : // -----------------------------------------------------------------------------
     557                 :            : 
     558                 :         12 : void EMFWriter::ImplWriteSize( const Size& rSize)
     559                 :            : {
     560         [ +  - ]:         12 :     const Size aSize( maVDev.LogicToLogic( rSize, maVDev.GetMapMode(), maDestMapMode ));
     561 [ +  - ][ +  - ]:         12 :      m_rStm << (sal_Int32) aSize.Width() << (sal_Int32) aSize.Height();
     562                 :         12 : }
     563                 :            : 
     564                 :            : // -----------------------------------------------------------------------------
     565                 :            : 
     566                 :       1149 : void EMFWriter::ImplWriteRect( const Rectangle& rRect )
     567                 :            : {
     568         [ +  - ]:       1149 :     const Rectangle aRect( maVDev.LogicToLogic ( rRect, maVDev.GetMapMode(), maDestMapMode ));
     569                 :            :     m_rStm
     570         [ +  - ]:       1149 :         << static_cast<sal_Int32>(aRect.Left())
     571         [ +  - ]:       2298 :         << static_cast<sal_Int32>(aRect.Top())
     572         [ +  - ]:       2298 :         << static_cast<sal_Int32>(aRect.Right())
     573         [ +  - ]:       2298 :         << static_cast<sal_Int32>(aRect.Bottom());
     574                 :       1149 : }
     575                 :            : 
     576                 :            : // -----------------------------------------------------------------------------
     577                 :            : 
     578                 :          0 : void EMFWriter::ImplWritePolygonRecord( const Polygon& rPoly, sal_Bool bClose )
     579                 :            : {
     580         [ #  # ]:          0 :     if( rPoly.GetSize() )
     581                 :            :     {
     582         [ #  # ]:          0 :         if( rPoly.HasFlags() )
     583         [ #  # ]:          0 :             ImplWritePath( rPoly, bClose );
     584                 :            :         else
     585                 :            :         {
     586         [ #  # ]:          0 :             if( bClose )
     587                 :          0 :                 ImplCheckFillAttr();
     588                 :            : 
     589                 :          0 :             ImplCheckLineAttr();
     590                 :            : 
     591         [ #  # ]:          0 :             ImplBeginRecord( bClose ? WIN_EMR_POLYGON : WIN_EMR_POLYLINE );
     592         [ #  # ]:          0 :             ImplWriteRect( rPoly.GetBoundRect() );
     593                 :          0 :             m_rStm << (sal_uInt32) rPoly.GetSize();
     594                 :            : 
     595         [ #  # ]:          0 :             for( sal_uInt16 i = 0; i < rPoly.GetSize(); i++ )
     596                 :          0 :                 ImplWritePoint( rPoly[ i ] );
     597                 :            : 
     598                 :          0 :             ImplEndRecord();
     599                 :            :         }
     600                 :            :     }
     601                 :          0 : }
     602                 :            : 
     603                 :            : // -----------------------------------------------------------------------------
     604                 :            : 
     605                 :          0 : void EMFWriter::ImplWritePolyPolygonRecord( const PolyPolygon& rPolyPoly )
     606                 :            : {
     607                 :          0 :     sal_uInt16 n, i, nPolyCount = rPolyPoly.Count();
     608                 :            : 
     609         [ #  # ]:          0 :     if( nPolyCount )
     610                 :            :     {
     611         [ #  # ]:          0 :         if( 1 == nPolyCount )
     612                 :          0 :             ImplWritePolygonRecord( rPolyPoly[ 0 ], sal_True );
     613                 :            :         else
     614                 :            :         {
     615                 :          0 :             sal_Bool    bHasFlags = sal_False;
     616                 :          0 :             sal_uInt32  nTotalPoints = 0;
     617                 :            : 
     618         [ #  # ]:          0 :             for( i = 0; i < nPolyCount; i++ )
     619                 :            :             {
     620                 :          0 :                 nTotalPoints += rPolyPoly[ i ].GetSize();
     621         [ #  # ]:          0 :                 if ( rPolyPoly[ i ].HasFlags() )
     622                 :          0 :                     bHasFlags = sal_True;
     623                 :            :             }
     624         [ #  # ]:          0 :             if( nTotalPoints )
     625                 :            :             {
     626         [ #  # ]:          0 :                 if ( bHasFlags )
     627                 :          0 :                     ImplWritePath( rPolyPoly, sal_True );
     628                 :            :                 else
     629                 :            :                 {
     630                 :          0 :                     ImplCheckFillAttr();
     631                 :          0 :                     ImplCheckLineAttr();
     632                 :            : 
     633                 :          0 :                     ImplBeginRecord( WIN_EMR_POLYPOLYGON );
     634         [ #  # ]:          0 :                     ImplWriteRect( rPolyPoly.GetBoundRect() );
     635                 :          0 :                     m_rStm << (sal_uInt32)nPolyCount << nTotalPoints;
     636                 :            : 
     637         [ #  # ]:          0 :                     for( i = 0; i < nPolyCount; i++ )
     638                 :          0 :                         m_rStm << (sal_uInt32)rPolyPoly[ i ].GetSize();
     639                 :            : 
     640         [ #  # ]:          0 :                     for( i = 0; i < nPolyCount; i++ )
     641                 :            :                     {
     642                 :          0 :                         const Polygon& rPoly = rPolyPoly[ i ];
     643                 :            : 
     644         [ #  # ]:          0 :                         for( n = 0; n < rPoly.GetSize(); n++ )
     645                 :          0 :                             ImplWritePoint( rPoly[ n ] );
     646                 :            :                     }
     647                 :          0 :                     ImplEndRecord();
     648                 :            :                 }
     649                 :            :             }
     650                 :            :         }
     651                 :            :     }
     652                 :          0 : }
     653                 :            : 
     654                 :            : // -----------------------------------------------------------------------------
     655                 :            : 
     656                 :          0 : void EMFWriter::ImplWritePath( const PolyPolygon& rPolyPoly, sal_Bool bClosed )
     657                 :            : {
     658         [ #  # ]:          0 :     if ( bClosed )
     659                 :          0 :         ImplCheckFillAttr();
     660                 :          0 :     ImplCheckLineAttr();
     661                 :            : 
     662                 :          0 :     ImplBeginRecord( WIN_EMR_BEGINPATH );
     663                 :          0 :     ImplEndRecord();
     664                 :            : 
     665                 :          0 :     sal_uInt16 i, n, o, nPolyCount = rPolyPoly.Count();
     666         [ #  # ]:          0 :     for ( i = 0; i < nPolyCount; i++ )
     667                 :            :     {
     668                 :          0 :         n = 0;
     669                 :          0 :         const Polygon& rPoly = rPolyPoly[ i ];
     670         [ #  # ]:          0 :         while ( n < rPoly.GetSize() )
     671                 :            :         {
     672         [ #  # ]:          0 :             if( n == 0 )
     673                 :            :             {
     674                 :          0 :                 ImplBeginRecord( WIN_EMR_MOVETOEX );
     675                 :          0 :                 ImplWritePoint( rPoly[ 0 ] );
     676                 :          0 :                 ImplEndRecord();
     677                 :          0 :                 n++;
     678                 :          0 :                 continue;
     679                 :            :             }
     680                 :            : 
     681                 :          0 :             sal_uInt16 nBezPoints = 0;
     682                 :            : 
     683 [ #  # ][ #  # ]:          0 :             while ( ( ( nBezPoints + n + 2 ) < rPoly.GetSize() ) && ( rPoly.GetFlags( nBezPoints + n ) == POLY_CONTROL ) )
                 [ #  # ]
     684                 :          0 :                 nBezPoints += 3;
     685                 :            : 
     686         [ #  # ]:          0 :             if ( nBezPoints )
     687                 :            :             {
     688         [ #  # ]:          0 :                 ImplBeginRecord( WIN_EMR_POLYBEZIERTO );
     689         [ #  # ]:          0 :                 Polygon aNewPoly( nBezPoints + 1 );
     690 [ #  # ][ #  # ]:          0 :                 aNewPoly[ 0 ] = rPoly[ n - 1 ];
     691         [ #  # ]:          0 :                 for ( o = 0; o < nBezPoints; o++ )
     692 [ #  # ][ #  # ]:          0 :                     aNewPoly[ o + 1 ] = rPoly[ n + o ];
     693 [ #  # ][ #  # ]:          0 :                 ImplWriteRect( aNewPoly.GetBoundRect() );
     694         [ #  # ]:          0 :                 m_rStm << (sal_uInt32)nBezPoints;
     695 [ #  # ][ #  # ]:          0 :                 for( o = 1; o < aNewPoly.GetSize(); o++ )
     696 [ #  # ][ #  # ]:          0 :                     ImplWritePoint( aNewPoly[ o ] );
     697         [ #  # ]:          0 :                 ImplEndRecord();
     698         [ #  # ]:          0 :                 n = n + nBezPoints;
     699                 :            :             }
     700                 :            :             else
     701                 :            :             {
     702                 :          0 :                 sal_uInt16 nPoints = 1;
     703 [ #  # ][ #  # ]:          0 :                 while( ( nPoints + n ) < rPoly.GetSize() && ( rPoly.GetFlags( nPoints + n ) != POLY_CONTROL ) )
                 [ #  # ]
     704                 :          0 :                     nPoints++;
     705                 :            : 
     706         [ #  # ]:          0 :                 if ( nPoints > 1 )
     707                 :            :                 {
     708         [ #  # ]:          0 :                     ImplBeginRecord( WIN_EMR_POLYLINETO );
     709         [ #  # ]:          0 :                     Polygon aNewPoly( nPoints + 1 );
     710 [ #  # ][ #  # ]:          0 :                     aNewPoly[ 0 ] = rPoly[ n - 1];
     711         [ #  # ]:          0 :                     for ( o = 1; o <= nPoints; o++ )
     712 [ #  # ][ #  # ]:          0 :                         aNewPoly[ o ] = rPoly[ n - 1 + o ];
     713 [ #  # ][ #  # ]:          0 :                     ImplWriteRect( aNewPoly.GetBoundRect() );
     714         [ #  # ]:          0 :                     m_rStm << (sal_uInt32)( nPoints );
     715 [ #  # ][ #  # ]:          0 :                     for( o = 1; o < aNewPoly.GetSize(); o++ )
     716 [ #  # ][ #  # ]:          0 :                         ImplWritePoint( aNewPoly[ o ] );
     717 [ #  # ][ #  # ]:          0 :                     ImplEndRecord();
     718                 :            :                 }
     719                 :            :                 else
     720                 :            :                 {
     721                 :          0 :                     ImplBeginRecord( WIN_EMR_LINETO );
     722                 :          0 :                     ImplWritePoint( rPoly[ n ] );
     723                 :          0 :                     ImplEndRecord();
     724                 :            :                 }
     725                 :          0 :                 n = n + nPoints;
     726                 :            :             }
     727 [ #  # ][ #  # ]:          0 :             if ( bClosed && ( n == rPoly.GetSize() ) )
                 [ #  # ]
     728                 :            :             {
     729                 :          0 :                 ImplBeginRecord( WIN_EMR_CLOSEFIGURE );
     730                 :          0 :                 ImplEndRecord();
     731                 :            :             }
     732                 :            :         }
     733                 :            :     }
     734                 :          0 :     ImplBeginRecord( WIN_EMR_ENDPATH );
     735                 :          0 :     ImplEndRecord();
     736         [ #  # ]:          0 :     ImplBeginRecord( bClosed ? WIN_EMR_FILLPATH : WIN_EMR_STROKEPATH );
     737         [ #  # ]:          0 :     ImplWriteRect( rPolyPoly.GetBoundRect() );
     738                 :          0 :     ImplEndRecord();
     739                 :          0 : }
     740                 :            : 
     741                 :            : // -----------------------------------------------------------------------------
     742                 :            : 
     743                 :         12 : void EMFWriter::ImplWriteBmpRecord( const Bitmap& rBmp, const Point& rPt,
     744                 :            :                                     const Size& rSz, sal_uInt32 nROP )
     745                 :            : {
     746         [ +  - ]:         12 :     if( !!rBmp )
     747                 :            :     {
     748         [ +  - ]:         12 :         SvMemoryStream  aMemStm( 65535, 65535 );
     749         [ +  - ]:         12 :         const Size      aBmpSizePixel( rBmp.GetSizePixel() );
     750                 :            : 
     751         [ +  - ]:         12 :         ImplBeginRecord( WIN_EMR_STRETCHDIBITS );
     752 [ +  - ][ +  - ]:         12 :         ImplWriteRect( Rectangle( rPt, rSz ) );
     753         [ +  - ]:         12 :         ImplWritePoint( rPt );
     754 [ +  - ][ +  - ]:         12 :         m_rStm << (sal_Int32) 0 << (sal_Int32) 0 << (sal_Int32) aBmpSizePixel.Width() << (sal_Int32) aBmpSizePixel.Height();
         [ +  - ][ +  - ]
     755                 :            : 
     756                 :            :         // write offset positions and sizes later
     757                 :         12 :         const sal_uLong nOffPos = m_rStm.Tell();
     758         [ +  - ]:         12 :         m_rStm.SeekRel( 16 );
     759                 :            : 
     760 [ -  + ][ #  # ]:         12 :         m_rStm << (sal_uInt32) 0 << sal_Int32( ( ROP_XOR == maVDev.GetRasterOp() && WIN_SRCCOPY == nROP ) ? WIN_SRCINVERT : nROP );
         [ +  - ][ +  - ]
     761         [ +  - ]:         12 :         ImplWriteSize( rSz );
     762                 :            : 
     763         [ +  - ]:         12 :         rBmp.Write( aMemStm, sal_True, sal_False );
     764                 :            : 
     765                 :         12 :         sal_uInt32  nDIBSize = aMemStm.Tell(), nHeaderSize, nCompression, nColsUsed, nPalCount, nImageSize;
     766                 :            :         sal_uInt16  nBitCount;
     767                 :            : 
     768                 :            :         // get DIB parameters
     769         [ +  - ]:         12 :         aMemStm.Seek( 0 );
     770         [ +  - ]:         12 :         aMemStm >> nHeaderSize;
     771         [ +  - ]:         12 :         aMemStm.SeekRel( 10 );
     772 [ +  - ][ +  - ]:         12 :         aMemStm >> nBitCount >> nCompression >> nImageSize;
                 [ +  - ]
     773         [ +  - ]:         12 :         aMemStm.SeekRel( 8 );
     774         [ +  - ]:         12 :         aMemStm >> nColsUsed;
     775                 :            : 
     776                 :            :         nPalCount = ( nBitCount <= 8 ) ? ( nColsUsed ? nColsUsed : ( 1 << (sal_uInt32) nBitCount ) ) :
     777 [ +  + ][ -  + ]:         12 :                                          ( ( 3 == nCompression ) ? 12 : 0 );
                 [ -  + ]
     778                 :            : 
     779 [ +  - ][ +  - ]:         12 :         m_rStm.Write( aMemStm.GetData(), nDIBSize );
     780                 :            : 
     781                 :         12 :         const sal_uLong nEndPos = m_rStm.Tell();
     782         [ +  - ]:         12 :         m_rStm.Seek( nOffPos );
     783 [ +  - ][ +  - ]:         12 :         m_rStm << (sal_uInt32) 80 << (sal_uInt32)( nHeaderSize + ( nPalCount << 2 ) );
     784 [ +  - ][ +  - ]:         12 :         m_rStm << (sal_uInt32)( 80 + ( nHeaderSize + ( nPalCount << 2 ) ) ) << nImageSize;
     785         [ +  - ]:         12 :         m_rStm.Seek( nEndPos );
     786                 :            : 
     787 [ +  - ][ +  - ]:         12 :         ImplEndRecord();
     788                 :            :     }
     789                 :         12 : }
     790                 :            : 
     791                 :            : // -----------------------------------------------------------------------------
     792                 :            : 
     793                 :        993 : void EMFWriter::ImplWriteTextRecord( const Point& rPos, const String rText, const sal_Int32* pDXArray, sal_uInt32 nWidth )
     794                 :            : {
     795                 :        993 :     xub_StrLen nLen = rText.Len(), i;
     796                 :            : 
     797         [ +  - ]:        993 :     if( nLen )
     798                 :            :     {
     799                 :            :         sal_uInt32  nNormWidth;
     800                 :            :         sal_Int32*  pOwnArray;
     801                 :            :         sal_Int32*  pDX;
     802                 :            : 
     803                 :            :         // get text sizes
     804         [ -  + ]:        993 :         if( pDXArray )
     805                 :            :         {
     806                 :          0 :             pOwnArray = NULL;
     807                 :          0 :             nNormWidth = maVDev.GetTextWidth( rText );
     808                 :          0 :             pDX = (sal_Int32*) pDXArray;
     809                 :            :         }
     810                 :            :         else
     811                 :            :         {
     812                 :        993 :             pOwnArray = new sal_Int32[ nLen ];
     813                 :        993 :             nNormWidth = maVDev.GetTextArray( rText, pOwnArray );
     814                 :        993 :             pDX = pOwnArray;
     815                 :            :         }
     816                 :            : 
     817         [ +  + ]:        993 :         if( nLen > 1 )
     818                 :            :         {
     819 [ +  - ][ +  - ]:         63 :             nNormWidth = pDX[ nLen - 2 ] + maVDev.GetTextWidth( rtl::OUString(rText.GetChar( nLen - 1 )) );
                 [ +  - ]
     820                 :            : 
     821 [ +  - ][ +  + ]:         63 :             if( nWidth && nNormWidth && ( nWidth != nNormWidth ) )
                 [ +  - ]
     822                 :            :             {
     823                 :         60 :                 const double fFactor = (double) nWidth / nNormWidth;
     824                 :            : 
     825         [ +  + ]:        180 :                 for( i = 0; i < ( nLen - 1 ); i++ )
     826                 :        120 :                     pDX[ i ] = FRound( pDX[ i ] * fFactor );
     827                 :            :             }
     828                 :            :         }
     829                 :            : 
     830                 :            :         // write text record
     831                 :        993 :         ImplBeginRecord( WIN_EMR_EXTTEXTOUTW );
     832                 :            : 
     833 [ +  - ][ +  - ]:        993 :         ImplWriteRect( Rectangle( rPos, Size( nNormWidth, maVDev.GetTextHeight() ) ) );
     834                 :        993 :         m_rStm << (sal_uInt32)1;
     835                 :        993 :         m_rStm << (sal_Int32) 0 << (sal_Int32) 0;
     836                 :        993 :         ImplWritePoint( rPos );
     837                 :        993 :         m_rStm << (sal_uInt32) nLen << (sal_uInt32) 76 << (sal_uInt32) 2;
     838                 :        993 :         m_rStm << (sal_Int32) 0 << (sal_Int32) 0 << (sal_Int32) 0 << (sal_Int32) 0;
     839         [ +  + ]:        993 :         m_rStm << (sal_uInt32) ( 76 + ( nLen << 1 ) + ( (nLen & 1 ) ? 2 : 0 ) );
     840                 :            : 
     841                 :            :         // write text
     842         [ +  + ]:       2115 :         for( i = 0; i < nLen; i++ )
     843                 :       1122 :             m_rStm << (sal_Unicode)rText.GetChar( i );
     844                 :            : 
     845                 :            :         // padding word
     846         [ +  + ]:        993 :         if( nLen & 1 )
     847                 :        978 :             m_rStm << (sal_uInt16) 0;
     848                 :            : 
     849                 :            :         // write DX array
     850                 :        993 :         ImplWriteExtent( pDX[ 0 ] );
     851                 :            : 
     852         [ +  + ]:        993 :         if( nLen > 1 )
     853                 :            :         {
     854         [ +  + ]:        129 :             for( i = 1; i < ( nLen - 1 ); i++ )
     855                 :         66 :                 ImplWriteExtent( pDX[ i ] - pDX[ i - 1 ] );
     856                 :            : 
     857                 :         63 :             ImplWriteExtent( pDX[ nLen - 2 ] / ( nLen - 1 ) );
     858                 :            :         }
     859                 :            : 
     860                 :        993 :         ImplEndRecord();
     861         [ +  - ]:        993 :         delete[] pOwnArray;
     862                 :            :     }
     863                 :        993 : }
     864                 :            : 
     865                 :            : // -----------------------------------------------------------------------------
     866                 :            : 
     867                 :          0 : void EMFWriter::Impl_handleLineInfoPolyPolygons(const LineInfo& rInfo, const basegfx::B2DPolygon& rLinePolygon)
     868                 :            : {
     869         [ #  # ]:          0 :     if(rLinePolygon.count())
     870                 :            :     {
     871         [ #  # ]:          0 :         basegfx::B2DPolyPolygon aLinePolyPolygon(rLinePolygon);
     872         [ #  # ]:          0 :         basegfx::B2DPolyPolygon aFillPolyPolygon;
     873                 :            : 
     874         [ #  # ]:          0 :         rInfo.applyToB2DPolyPolygon(aLinePolyPolygon, aFillPolyPolygon);
     875                 :            : 
     876 [ #  # ][ #  # ]:          0 :         if(aLinePolyPolygon.count())
     877                 :            :         {
     878 [ #  # ][ #  # ]:          0 :             for(sal_uInt32 a(0); a < aLinePolyPolygon.count(); a++)
     879                 :            :             {
     880         [ #  # ]:          0 :                 const basegfx::B2DPolygon aCandidate(aLinePolyPolygon.getB2DPolygon(a));
     881 [ #  # ][ #  # ]:          0 :                 ImplWritePolygonRecord( Polygon(aCandidate), sal_False );
                 [ #  # ]
     882         [ #  # ]:          0 :             }
     883                 :            :         }
     884                 :            : 
     885 [ #  # ][ #  # ]:          0 :         if(aFillPolyPolygon.count())
     886                 :            :         {
     887                 :          0 :             const Color aOldLineColor(maVDev.GetLineColor());
     888                 :          0 :             const Color aOldFillColor(maVDev.GetFillColor());
     889                 :            : 
     890         [ #  # ]:          0 :             maVDev.SetLineColor();
     891         [ #  # ]:          0 :             maVDev.SetFillColor(aOldLineColor);
     892                 :            : 
     893 [ #  # ][ #  # ]:          0 :             for(sal_uInt32 a(0); a < aFillPolyPolygon.count(); a++)
     894                 :            :             {
     895 [ #  # ][ #  # ]:          0 :                 const Polygon aPolygon(aFillPolyPolygon.getB2DPolygon(a));
                 [ #  # ]
     896 [ #  # ][ #  # ]:          0 :                 ImplWritePolyPolygonRecord(PolyPolygon(Polygon(aPolygon)));
         [ #  # ][ #  # ]
                 [ #  # ]
     897         [ #  # ]:          0 :             }
     898                 :            : 
     899         [ #  # ]:          0 :             maVDev.SetLineColor(aOldLineColor);
     900         [ #  # ]:          0 :             maVDev.SetFillColor(aOldFillColor);
     901 [ #  # ][ #  # ]:          0 :         }
     902                 :            :     }
     903                 :          0 : }
     904                 :            : 
     905                 :            : // -----------------------------------------------------------------------------
     906                 :            : 
     907                 :         90 : void EMFWriter::ImplWrite( const GDIMetaFile& rMtf )
     908                 :            : {
     909         [ +  + ]:       8268 :     for( size_t j = 0, nActionCount = rMtf.GetActionSize(); j < nActionCount; j++ )
     910                 :            :     {
     911                 :       8178 :         const MetaAction*   pAction = rMtf.GetAction( j );
     912                 :       8178 :         const sal_uInt16        nType = pAction->GetType();
     913                 :            : 
     914   [ -  -  -  +  :       8178 :         switch( nType )
          -  -  -  -  -  
          -  -  -  -  -  
          -  -  -  +  -  
          -  -  -  -  +  
          +  +  +  +  -  
          -  +  +  -  +  
                -  -  + ]
     915                 :            :         {
     916                 :            :             case( META_PIXEL_ACTION ):
     917                 :            :             {
     918                 :          0 :                 const MetaPixelAction* pA = (const MetaPixelAction*) pAction;
     919                 :            : 
     920                 :          0 :                 ImplCheckLineAttr();
     921                 :          0 :                 ImplBeginRecord( WIN_EMR_SETPIXELV );
     922                 :          0 :                 ImplWritePoint( pA->GetPoint() );
     923                 :          0 :                 ImplWriteColor( pA->GetColor() );
     924                 :          0 :                 ImplEndRecord();
     925                 :            :             }
     926                 :          0 :             break;
     927                 :            : 
     928                 :            :             case( META_POINT_ACTION ):
     929                 :            :             {
     930         [ #  # ]:          0 :                 if( maVDev.IsLineColor() )
     931                 :            :                 {
     932                 :          0 :                     const MetaPointAction* pA = (const MetaPointAction*) pAction;
     933                 :            : 
     934                 :          0 :                     ImplCheckLineAttr();
     935                 :          0 :                     ImplBeginRecord( WIN_EMR_SETPIXELV );
     936                 :          0 :                     ImplWritePoint( pA->GetPoint() );
     937                 :          0 :                     ImplWriteColor( maVDev.GetLineColor() );
     938                 :          0 :                     ImplEndRecord();
     939                 :            :                 }
     940                 :            :             }
     941                 :          0 :             break;
     942                 :            : 
     943                 :            :             case( META_LINE_ACTION ):
     944                 :            :             {
     945         [ #  # ]:          0 :                 if( maVDev.IsLineColor() )
     946                 :            :                 {
     947                 :          0 :                     const MetaLineAction* pA = (const MetaLineAction*) pAction;
     948                 :            : 
     949         [ #  # ]:          0 :                     if(pA->GetLineInfo().IsDefault())
     950                 :            :                     {
     951                 :          0 :                         ImplCheckLineAttr();
     952                 :            : 
     953                 :          0 :                         ImplBeginRecord( WIN_EMR_MOVETOEX );
     954                 :          0 :                         ImplWritePoint( pA->GetStartPoint() );
     955                 :          0 :                         ImplEndRecord();
     956                 :            : 
     957                 :          0 :                         ImplBeginRecord( WIN_EMR_LINETO );
     958                 :          0 :                         ImplWritePoint( pA->GetEndPoint() );
     959                 :          0 :                         ImplEndRecord();
     960                 :            : 
     961                 :          0 :                         ImplBeginRecord( WIN_EMR_SETPIXELV );
     962                 :          0 :                         ImplWritePoint( pA->GetEndPoint() );
     963                 :          0 :                         ImplWriteColor( maVDev.GetLineColor() );
     964                 :          0 :                         ImplEndRecord();
     965                 :            :                     }
     966                 :            :                     else
     967                 :            :                     {
     968                 :            :                         // LineInfo used; handle Dash/Dot and fat lines
     969         [ #  # ]:          0 :                         basegfx::B2DPolygon aPolygon;
     970         [ #  # ]:          0 :                         aPolygon.append(basegfx::B2DPoint(pA->GetStartPoint().X(), pA->GetStartPoint().Y()));
     971         [ #  # ]:          0 :                         aPolygon.append(basegfx::B2DPoint(pA->GetEndPoint().X(), pA->GetEndPoint().Y()));
     972 [ #  # ][ #  # ]:          0 :                         Impl_handleLineInfoPolyPolygons(pA->GetLineInfo(), aPolygon);
     973                 :            :                     }
     974                 :            :                 }
     975                 :            :             }
     976                 :          0 :             break;
     977                 :            : 
     978                 :            :             case( META_RECT_ACTION ):
     979                 :            :             {
     980 [ +  - ][ +  - ]:         57 :                 if( maVDev.IsLineColor() || maVDev.IsFillColor() )
                 [ +  - ]
     981                 :            :                 {
     982                 :         57 :                     const MetaRectAction* pA = (const MetaRectAction*) pAction;
     983                 :            : 
     984                 :         57 :                     ImplCheckFillAttr();
     985                 :         57 :                     ImplCheckLineAttr();
     986                 :            : 
     987                 :         57 :                     ImplBeginRecord( WIN_EMR_RECTANGLE );
     988                 :         57 :                     ImplWriteRect( pA->GetRect() );
     989                 :         57 :                     ImplEndRecord();
     990                 :            :                 }
     991                 :            :             }
     992                 :         57 :             break;
     993                 :            : 
     994                 :            :             case( META_ROUNDRECT_ACTION ):
     995                 :            :             {
     996 [ #  # ][ #  # ]:          0 :                 if( maVDev.IsLineColor() || maVDev.IsFillColor() )
                 [ #  # ]
     997                 :            :                 {
     998                 :          0 :                     const MetaRoundRectAction* pA = (const MetaRoundRectAction*) pAction;
     999                 :            : 
    1000                 :          0 :                     ImplCheckFillAttr();
    1001                 :          0 :                     ImplCheckLineAttr();
    1002                 :            : 
    1003                 :          0 :                     ImplBeginRecord( WIN_EMR_ROUNDRECT );
    1004                 :          0 :                     ImplWriteRect( pA->GetRect() );
    1005         [ #  # ]:          0 :                     ImplWriteSize( Size( pA->GetHorzRound(), pA->GetVertRound() ) );
    1006                 :          0 :                     ImplEndRecord();
    1007                 :            :                 }
    1008                 :            :             }
    1009                 :          0 :             break;
    1010                 :            : 
    1011                 :            :             case( META_ELLIPSE_ACTION ):
    1012                 :            :             {
    1013 [ #  # ][ #  # ]:          0 :                 if( maVDev.IsLineColor() || maVDev.IsFillColor() )
                 [ #  # ]
    1014                 :            :                 {
    1015                 :          0 :                     const MetaEllipseAction* pA = (const MetaEllipseAction*) pAction;
    1016                 :            : 
    1017                 :          0 :                     ImplCheckFillAttr();
    1018                 :          0 :                     ImplCheckLineAttr();
    1019                 :            : 
    1020                 :          0 :                     ImplBeginRecord( WIN_EMR_ELLIPSE );
    1021                 :          0 :                     ImplWriteRect( pA->GetRect() );
    1022                 :          0 :                     ImplEndRecord();
    1023                 :            :                 }
    1024                 :            :             }
    1025                 :          0 :             break;
    1026                 :            : 
    1027                 :            :             case( META_ARC_ACTION ):
    1028                 :            :             case( META_PIE_ACTION ):
    1029                 :            :             case( META_CHORD_ACTION ):
    1030                 :            :             case( META_POLYGON_ACTION ):
    1031                 :            :             {
    1032 [ #  # ][ #  # ]:          0 :                 if( maVDev.IsLineColor() || maVDev.IsFillColor() )
                 [ #  # ]
    1033                 :            :                 {
    1034         [ #  # ]:          0 :                     Polygon aPoly;
    1035                 :            : 
    1036   [ #  #  #  #  :          0 :                     switch( nType )
                      # ]
    1037                 :            :                     {
    1038                 :            :                         case( META_ARC_ACTION ):
    1039                 :            :                         {
    1040                 :          0 :                             const MetaArcAction* pA = (const MetaArcAction*) pAction;
    1041 [ #  # ][ #  # ]:          0 :                             aPoly = Polygon( pA->GetRect(), pA->GetStartPoint(), pA->GetEndPoint(), POLY_ARC );
                 [ #  # ]
    1042                 :            :                         }
    1043                 :          0 :                         break;
    1044                 :            : 
    1045                 :            :                         case( META_PIE_ACTION ):
    1046                 :            :                         {
    1047                 :          0 :                             const MetaPieAction* pA = (const MetaPieAction*) pAction;
    1048 [ #  # ][ #  # ]:          0 :                             aPoly = Polygon( pA->GetRect(), pA->GetStartPoint(), pA->GetEndPoint(), POLY_PIE );
                 [ #  # ]
    1049                 :            :                         }
    1050                 :          0 :                         break;
    1051                 :            : 
    1052                 :            :                         case( META_CHORD_ACTION ):
    1053                 :            :                         {
    1054                 :          0 :                             const MetaChordAction* pA = (const MetaChordAction*) pAction;
    1055 [ #  # ][ #  # ]:          0 :                             aPoly = Polygon( pA->GetRect(), pA->GetStartPoint(), pA->GetEndPoint(), POLY_CHORD );
                 [ #  # ]
    1056                 :            :                         }
    1057                 :          0 :                         break;
    1058                 :            : 
    1059                 :            :                         case( META_POLYGON_ACTION ):
    1060         [ #  # ]:          0 :                             aPoly = ( (const MetaPolygonAction*) pAction )->GetPolygon();
    1061                 :          0 :                         break;
    1062                 :            :                     }
    1063                 :            : 
    1064 [ #  # ][ #  # ]:          0 :                     ImplWritePolygonRecord( aPoly, nType != META_ARC_ACTION );
    1065                 :            :                 }
    1066                 :            :             }
    1067                 :          0 :             break;
    1068                 :            : 
    1069                 :            :             case( META_POLYLINE_ACTION ):
    1070                 :            :             {
    1071         [ #  # ]:          0 :                 if( maVDev.IsLineColor() )
    1072                 :            :                 {
    1073                 :          0 :                     const MetaPolyLineAction*   pA = (const MetaPolyLineAction*) pAction;
    1074                 :          0 :                     const Polygon&              rPoly = pA->GetPolygon();
    1075                 :            : 
    1076         [ #  # ]:          0 :                     if( rPoly.GetSize() )
    1077                 :            :                     {
    1078         [ #  # ]:          0 :                         if(pA->GetLineInfo().IsDefault())
    1079                 :            :                         {
    1080                 :          0 :                             ImplWritePolygonRecord( rPoly, sal_False );
    1081                 :            :                         }
    1082                 :            :                         else
    1083                 :            :                         {
    1084                 :            :                             // LineInfo used; handle Dash/Dot and fat lines
    1085         [ #  # ]:          0 :                             Impl_handleLineInfoPolyPolygons(pA->GetLineInfo(), rPoly.getB2DPolygon());
    1086                 :            :                         }
    1087                 :            :                     }
    1088                 :            :                 }
    1089                 :            :             }
    1090                 :          0 :             break;
    1091                 :            : 
    1092                 :            :             case( META_POLYPOLYGON_ACTION ):
    1093                 :            :             {
    1094 [ #  # ][ #  # ]:          0 :                 if( maVDev.IsLineColor() || maVDev.IsFillColor() )
                 [ #  # ]
    1095                 :          0 :                     ImplWritePolyPolygonRecord( ( (const MetaPolyPolygonAction*) pAction )->GetPolyPolygon() );
    1096                 :            :             }
    1097                 :          0 :             break;
    1098                 :            : 
    1099                 :            :             case( META_GRADIENT_ACTION ):
    1100                 :            :             {
    1101                 :          0 :                 const MetaGradientAction*   pA = (const MetaGradientAction*) pAction;
    1102         [ #  # ]:          0 :                 GDIMetaFile                 aTmpMtf;
    1103                 :            : 
    1104         [ #  # ]:          0 :                 maVDev.AddGradientActions( pA->GetRect(), pA->GetGradient(), aTmpMtf );
    1105 [ #  # ][ #  # ]:          0 :                 ImplWrite( aTmpMtf );
    1106                 :            :             }
    1107                 :          0 :             break;
    1108                 :            : 
    1109                 :            :             case META_HATCH_ACTION:
    1110                 :            :             {
    1111                 :          0 :                 const MetaHatchAction*  pA = (const MetaHatchAction*) pAction;
    1112         [ #  # ]:          0 :                 GDIMetaFile             aTmpMtf;
    1113                 :            : 
    1114         [ #  # ]:          0 :                 maVDev.AddHatchActions( pA->GetPolyPolygon(), pA->GetHatch(), aTmpMtf );
    1115 [ #  # ][ #  # ]:          0 :                 ImplWrite( aTmpMtf );
    1116                 :            :             }
    1117                 :          0 :             break;
    1118                 :            : 
    1119                 :            :             case META_TRANSPARENT_ACTION:
    1120                 :            :             {
    1121                 :          0 :                 ImplCheckFillAttr();
    1122                 :          0 :                 ImplCheckLineAttr();
    1123                 :          0 :                 ImplWritePolyPolygonRecord( ( (MetaTransparentAction*) pAction )->GetPolyPolygon() );
    1124                 :            :             }
    1125                 :          0 :             break;
    1126                 :            : 
    1127                 :            :             case META_FLOATTRANSPARENT_ACTION:
    1128                 :            :             {
    1129                 :          0 :                 const MetaFloatTransparentAction* pA = (const MetaFloatTransparentAction*) pAction;
    1130                 :            : 
    1131         [ #  # ]:          0 :                 GDIMetaFile     aTmpMtf( pA->GetGDIMetaFile() );
    1132                 :          0 :                 Point           aSrcPt( aTmpMtf.GetPrefMapMode().GetOrigin() );
    1133                 :          0 :                 const Size      aSrcSize( aTmpMtf.GetPrefSize() );
    1134                 :          0 :                 const Point     aDestPt( pA->GetPoint() );
    1135                 :          0 :                 const Size      aDestSize( pA->GetSize() );
    1136         [ #  # ]:          0 :                 const double    fScaleX = aSrcSize.Width() ? (double) aDestSize.Width() / aSrcSize.Width() : 1.0;
    1137         [ #  # ]:          0 :                 const double    fScaleY = aSrcSize.Height() ? (double) aDestSize.Height() / aSrcSize.Height() : 1.0;
    1138                 :            :                 long            nMoveX, nMoveY;
    1139                 :            : 
    1140 [ #  # ][ #  # ]:          0 :                 if( fScaleX != 1.0 || fScaleY != 1.0 )
    1141                 :            :                 {
    1142         [ #  # ]:          0 :                     aTmpMtf.Scale( fScaleX, fScaleY );
    1143                 :          0 :                     aSrcPt.X() = FRound( aSrcPt.X() * fScaleX ), aSrcPt.Y() = FRound( aSrcPt.Y() * fScaleY );
    1144                 :            :                 }
    1145                 :            : 
    1146                 :          0 :                 nMoveX = aDestPt.X() - aSrcPt.X(), nMoveY = aDestPt.Y() - aSrcPt.Y();
    1147                 :            : 
    1148 [ #  # ][ #  # ]:          0 :                 if( nMoveX || nMoveY )
    1149         [ #  # ]:          0 :                     aTmpMtf.Move( nMoveX, nMoveY );
    1150                 :            : 
    1151         [ #  # ]:          0 :                 ImplCheckFillAttr();
    1152         [ #  # ]:          0 :                 ImplCheckLineAttr();
    1153         [ #  # ]:          0 :                 ImplCheckTextAttr();
    1154 [ #  # ][ #  # ]:          0 :                 ImplWrite( aTmpMtf );
    1155                 :            :             }
    1156                 :          0 :             break;
    1157                 :            : 
    1158                 :            :             case( META_EPS_ACTION ):
    1159                 :            :             {
    1160                 :          0 :                 const MetaEPSAction*    pA = (const MetaEPSAction*) pAction;
    1161         [ #  # ]:          0 :                 const GDIMetaFile       aSubstitute( pA->GetSubstitute() );
    1162                 :            : 
    1163 [ #  # ][ #  # ]:          0 :                 for( size_t i = 0, nCount = aSubstitute.GetActionSize(); i < nCount; i++ )
    1164                 :            :                 {
    1165         [ #  # ]:          0 :                     const MetaAction* pSubstAct = aSubstitute.GetAction( i );
    1166         [ #  # ]:          0 :                     if( pSubstAct->GetType() == META_BMPSCALE_ACTION )
    1167                 :            :                     {
    1168         [ #  # ]:          0 :                         maVDev.Push( PUSH_ALL );
    1169         [ #  # ]:          0 :                         ImplBeginRecord( WIN_EMR_SAVEDC );
    1170         [ #  # ]:          0 :                         ImplEndRecord();
    1171                 :            : 
    1172         [ #  # ]:          0 :                         MapMode aMapMode( aSubstitute.GetPrefMapMode() );
    1173         [ #  # ]:          0 :                         Size aOutSize( maVDev.LogicToLogic( pA->GetSize(), maVDev.GetMapMode(), aMapMode ) );
    1174 [ #  # ][ #  # ]:          0 :                         aMapMode.SetScaleX( Fraction( aOutSize.Width(), aSubstitute.GetPrefSize().Width() ) );
    1175 [ #  # ][ #  # ]:          0 :                         aMapMode.SetScaleY( Fraction( aOutSize.Height(), aSubstitute.GetPrefSize().Height() ) );
    1176 [ #  # ][ #  # ]:          0 :                         aMapMode.SetOrigin( maVDev.LogicToLogic( pA->GetPoint(), maVDev.GetMapMode(), aMapMode ) );
    1177         [ #  # ]:          0 :                         maVDev.SetMapMode( aMapMode );
    1178         [ #  # ]:          0 :                         ImplWrite( aSubstitute );
    1179                 :            : 
    1180         [ #  # ]:          0 :                         maVDev.Pop();
    1181         [ #  # ]:          0 :                         ImplBeginRecord( WIN_EMR_RESTOREDC );
    1182         [ #  # ]:          0 :                         m_rStm << (sal_Int32) -1;
    1183         [ #  # ]:          0 :                         ImplEndRecord();
    1184         [ #  # ]:          0 :                         break;
    1185                 :            :                     }
    1186         [ #  # ]:          0 :                 }
    1187                 :            :             }
    1188                 :          0 :             break;
    1189                 :            : 
    1190                 :            :             case META_BMP_ACTION:
    1191                 :            :             {
    1192                 :          0 :                 const MetaBmpAction* pA = (const MetaBmpAction *) pAction;
    1193 [ #  # ][ #  # ]:          0 :                 ImplWriteBmpRecord( pA->GetBitmap(), pA->GetPoint(), maVDev.PixelToLogic( pA->GetBitmap().GetSizePixel() ), WIN_SRCCOPY );
    1194                 :            :             }
    1195                 :          0 :             break;
    1196                 :            : 
    1197                 :            :             case META_BMPSCALE_ACTION:
    1198                 :            :             {
    1199                 :          0 :                 const MetaBmpScaleAction* pA = (const MetaBmpScaleAction*) pAction;
    1200                 :          0 :                 ImplWriteBmpRecord( pA->GetBitmap(), pA->GetPoint(), pA->GetSize(), WIN_SRCCOPY );
    1201                 :            :             }
    1202                 :          0 :             break;
    1203                 :            : 
    1204                 :            :             case META_BMPSCALEPART_ACTION:
    1205                 :            :             {
    1206                 :          0 :                 const MetaBmpScalePartAction*   pA = (const MetaBmpScalePartAction*) pAction;
    1207         [ #  # ]:          0 :                 Bitmap                          aTmp( pA->GetBitmap() );
    1208                 :            : 
    1209 [ #  # ][ #  # ]:          0 :                 if( aTmp.Crop( Rectangle( pA->GetSrcPoint(), pA->GetSrcSize() ) ) )
                 [ #  # ]
    1210 [ #  # ][ #  # ]:          0 :                     ImplWriteBmpRecord( aTmp, pA->GetDestPoint(), pA->GetDestSize(), WIN_SRCCOPY );
    1211                 :            :             }
    1212                 :          0 :             break;
    1213                 :            : 
    1214                 :            :             case META_BMPEX_ACTION:
    1215                 :            :             {
    1216                 :          6 :                 const MetaBmpExAction*  pA = (const MetaBmpExAction *) pAction;
    1217         [ +  - ]:          6 :                 Bitmap                  aBmp( pA->GetBitmapEx().GetBitmap() );
    1218         [ +  - ]:          6 :                 Bitmap                  aMsk( pA->GetBitmapEx().GetMask() );
    1219                 :            : 
    1220         [ +  - ]:          6 :                 if( !!aMsk )
    1221                 :            :                 {
    1222         [ +  - ]:          6 :                     aBmp.Replace( aMsk, COL_WHITE );
    1223         [ +  - ]:          6 :                     aMsk.Invert();
    1224 [ +  - ][ +  - ]:          6 :                     ImplWriteBmpRecord( aMsk, pA->GetPoint(), maVDev.PixelToLogic( aMsk.GetSizePixel() ), WIN_SRCPAINT );
                 [ +  - ]
    1225 [ +  - ][ +  - ]:          6 :                     ImplWriteBmpRecord( aBmp, pA->GetPoint(), maVDev.PixelToLogic( aBmp.GetSizePixel() ), WIN_SRCAND );
                 [ +  - ]
    1226                 :            :                 }
    1227                 :            :                 else
    1228 [ #  # ][ #  # ]:          6 :                     ImplWriteBmpRecord( aBmp, pA->GetPoint(), aBmp.GetSizePixel(), WIN_SRCCOPY );
         [ +  - ][ +  - ]
    1229                 :            :             }
    1230                 :          6 :             break;
    1231                 :            : 
    1232                 :            :             case META_BMPEXSCALE_ACTION:
    1233                 :            :             {
    1234                 :          0 :                 const MetaBmpExScaleAction* pA = (const MetaBmpExScaleAction*) pAction;
    1235         [ #  # ]:          0 :                 Bitmap                      aBmp( pA->GetBitmapEx().GetBitmap() );
    1236         [ #  # ]:          0 :                 Bitmap                      aMsk( pA->GetBitmapEx().GetMask() );
    1237                 :            : 
    1238         [ #  # ]:          0 :                 if( !!aMsk )
    1239                 :            :                 {
    1240         [ #  # ]:          0 :                     aBmp.Replace( aMsk, COL_WHITE );
    1241         [ #  # ]:          0 :                     aMsk.Invert();
    1242         [ #  # ]:          0 :                     ImplWriteBmpRecord( aMsk, pA->GetPoint(), pA->GetSize(), WIN_SRCPAINT );
    1243         [ #  # ]:          0 :                     ImplWriteBmpRecord( aBmp, pA->GetPoint(), pA->GetSize(), WIN_SRCAND );
    1244                 :            :                 }
    1245                 :            :                 else
    1246 [ #  # ][ #  # ]:          0 :                     ImplWriteBmpRecord( aBmp, pA->GetPoint(), pA->GetSize(), WIN_SRCCOPY );
                 [ #  # ]
    1247                 :            :             }
    1248                 :          0 :             break;
    1249                 :            : 
    1250                 :            :             case META_BMPEXSCALEPART_ACTION:
    1251                 :            :             {
    1252                 :          0 :                 const MetaBmpExScalePartAction* pA = (const MetaBmpExScalePartAction*) pAction;
    1253         [ #  # ]:          0 :                 BitmapEx                        aBmpEx( pA->GetBitmapEx() );
    1254 [ #  # ][ #  # ]:          0 :                 aBmpEx.Crop( Rectangle( pA->GetSrcPoint(), pA->GetSrcSize() ) );
    1255         [ #  # ]:          0 :                 Bitmap                          aBmp( aBmpEx.GetBitmap() );
    1256         [ #  # ]:          0 :                 Bitmap                          aMsk( aBmpEx.GetMask() );
    1257                 :            : 
    1258         [ #  # ]:          0 :                 if( !!aMsk )
    1259                 :            :                 {
    1260         [ #  # ]:          0 :                     aBmp.Replace( aMsk, COL_WHITE );
    1261         [ #  # ]:          0 :                     aMsk.Invert();
    1262         [ #  # ]:          0 :                     ImplWriteBmpRecord( aMsk, pA->GetDestPoint(), pA->GetDestSize(), WIN_SRCPAINT );
    1263         [ #  # ]:          0 :                     ImplWriteBmpRecord( aBmp, pA->GetDestPoint(), pA->GetDestSize(), WIN_SRCAND );
    1264                 :            :                 }
    1265                 :            :                 else
    1266 [ #  # ][ #  # ]:          0 :                     ImplWriteBmpRecord( aBmp, pA->GetDestPoint(), pA->GetDestSize(), WIN_SRCCOPY );
         [ #  # ][ #  # ]
    1267                 :            :             }
    1268                 :          0 :             break;
    1269                 :            : 
    1270                 :            :             case META_TEXT_ACTION:
    1271                 :            :             {
    1272                 :          0 :                 const MetaTextAction*   pA = (const MetaTextAction*) pAction;
    1273 [ #  # ][ #  # ]:          0 :                 const String            aText( pA->GetText(), pA->GetIndex(), pA->GetLen() );
                 [ #  # ]
    1274                 :            : 
    1275         [ #  # ]:          0 :                 ImplCheckTextAttr();
    1276 [ #  # ][ #  # ]:          0 :                 ImplWriteTextRecord( pA->GetPoint(), aText, NULL, 0 );
         [ #  # ][ #  # ]
    1277                 :            :             }
    1278                 :          0 :             break;
    1279                 :            : 
    1280                 :            :             case META_TEXTRECT_ACTION:
    1281                 :            :             {
    1282                 :          0 :                 const MetaTextRectAction*   pA = (const MetaTextRectAction*) pAction;
    1283         [ #  # ]:          0 :                 const String                aText( pA->GetText() );
    1284                 :            : 
    1285         [ #  # ]:          0 :                 ImplCheckTextAttr();
    1286 [ #  # ][ #  # ]:          0 :                 ImplWriteTextRecord( pA->GetRect().TopLeft(), aText, NULL, 0 );
         [ #  # ][ #  # ]
    1287                 :            :             }
    1288                 :          0 :             break;
    1289                 :            : 
    1290                 :            :             case META_TEXTARRAY_ACTION:
    1291                 :            :             {
    1292                 :          0 :                 const MetaTextArrayAction*  pA = (const MetaTextArrayAction*) pAction;
    1293 [ #  # ][ #  # ]:          0 :                 const String                aText( pA->GetText(), pA->GetIndex(), pA->GetLen() );
                 [ #  # ]
    1294                 :            : 
    1295         [ #  # ]:          0 :                 ImplCheckTextAttr();
    1296 [ #  # ][ #  # ]:          0 :                 ImplWriteTextRecord( pA->GetPoint(), aText, pA->GetDXArray(), 0 );
         [ #  # ][ #  # ]
    1297                 :            :             }
    1298                 :          0 :             break;
    1299                 :            : 
    1300                 :            :             case META_STRETCHTEXT_ACTION:
    1301                 :            :             {
    1302                 :        993 :                 const MetaStretchTextAction*    pA = (const MetaStretchTextAction*) pAction;
    1303 [ +  - ][ +  - ]:        993 :                 const String                    aText( pA->GetText(), pA->GetIndex(), pA->GetLen() );
                 [ +  - ]
    1304                 :            : 
    1305         [ +  - ]:        993 :                 ImplCheckTextAttr();
    1306 [ +  - ][ +  - ]:        993 :                 ImplWriteTextRecord( pA->GetPoint(), aText, NULL, pA->GetWidth() );
         [ +  - ][ +  - ]
    1307                 :            :             }
    1308                 :        993 :             break;
    1309                 :            : 
    1310                 :            :             case( META_LINECOLOR_ACTION ):
    1311                 :            :             {
    1312                 :         57 :                 ( (MetaAction*) pAction )->Execute( &maVDev );
    1313                 :         57 :                 mbLineChanged = sal_True;
    1314                 :            :             }
    1315                 :         57 :             break;
    1316                 :            : 
    1317                 :            :             case( META_FILLCOLOR_ACTION ):
    1318                 :            :             {
    1319                 :         57 :                 ( (MetaAction*) pAction )->Execute( &maVDev );
    1320                 :         57 :                 mbFillChanged = sal_True;
    1321                 :            :             }
    1322                 :         57 :             break;
    1323                 :            : 
    1324                 :            :             case( META_TEXTCOLOR_ACTION ):
    1325                 :            :             case( META_TEXTLINECOLOR_ACTION ):
    1326                 :            :             case( META_TEXTFILLCOLOR_ACTION ):
    1327                 :            :             case( META_TEXTALIGN_ACTION ):
    1328                 :            :             case( META_FONT_ACTION ):
    1329                 :            :             {
    1330                 :       4209 :                 ( (MetaAction*) pAction )->Execute( &maVDev );
    1331                 :       4209 :                 mbTextChanged = sal_True;
    1332                 :            :             }
    1333                 :       4209 :             break;
    1334                 :            : 
    1335                 :            :             case( META_ISECTRECTCLIPREGION_ACTION ):
    1336                 :            :             {
    1337                 :         87 :                 ( (MetaAction*) pAction )->Execute( &maVDev );
    1338                 :            : 
    1339                 :         87 :                 ImplBeginRecord( WIN_EMR_INTERSECTCLIPRECT );
    1340                 :         87 :                 ImplWriteRect( ( (MetaISectRectClipRegionAction*) pAction )->GetRect() );
    1341                 :         87 :                 ImplEndRecord();
    1342                 :            :             }
    1343                 :         87 :             break;
    1344                 :            : 
    1345                 :            :             case( META_CLIPREGION_ACTION ):
    1346                 :            :             case( META_ISECTREGIONCLIPREGION_ACTION ):
    1347                 :            :             case( META_MOVECLIPREGION_ACTION ):
    1348                 :            :             {
    1349                 :          0 :                 ( (MetaAction*) pAction )->Execute( &maVDev );
    1350                 :            :             }
    1351                 :          0 :             break;
    1352                 :            : 
    1353                 :            :             case( META_REFPOINT_ACTION ):
    1354                 :            :             case( META_MAPMODE_ACTION ):
    1355                 :          0 :                 ( (MetaAction*) pAction )->Execute( &maVDev );
    1356                 :          0 :             break;
    1357                 :            : 
    1358                 :            :             case( META_PUSH_ACTION ):
    1359                 :            :             {
    1360                 :       1137 :                 ( (MetaAction*) pAction )->Execute( &maVDev );
    1361                 :            : 
    1362                 :       1137 :                 ImplBeginRecord( WIN_EMR_SAVEDC );
    1363                 :       1137 :                 ImplEndRecord();
    1364                 :            :             }
    1365                 :       1137 :             break;
    1366                 :            : 
    1367                 :            :             case( META_POP_ACTION ):
    1368                 :            :             {
    1369                 :       1137 :                 ( (MetaAction*) pAction )->Execute( &maVDev );
    1370                 :            : 
    1371                 :       1137 :                 ImplBeginRecord( WIN_EMR_RESTOREDC );
    1372                 :       1137 :                 m_rStm << (sal_Int32) -1;
    1373                 :       1137 :                 ImplEndRecord();
    1374                 :            : 
    1375                 :       1137 :                 ImplWriteRasterOp( maVDev.GetRasterOp() );
    1376                 :       1137 :                 mbLineChanged = mbFillChanged = mbTextChanged = sal_True;
    1377                 :            :             }
    1378                 :       1137 :             break;
    1379                 :            : 
    1380                 :            :             case( META_RASTEROP_ACTION ):
    1381                 :            :             {
    1382                 :          0 :                 ( (MetaAction*) pAction )->Execute( &maVDev );
    1383                 :          0 :                 ImplWriteRasterOp( ( (MetaRasterOpAction*) pAction )->GetRasterOp() );
    1384                 :            :             }
    1385                 :          0 :             break;
    1386                 :            : 
    1387                 :            :             case( META_LAYOUTMODE_ACTION ):
    1388                 :            :             {
    1389                 :        174 :                 sal_uInt32 nLayoutMode = ( (MetaLayoutModeAction*) pAction )->GetLayoutMode();
    1390                 :        174 :                 mnHorTextAlign = 0;
    1391         [ -  + ]:        174 :                 if (nLayoutMode & TEXT_LAYOUT_BIDI_RTL)
    1392                 :            :                 {
    1393                 :          0 :                     mnHorTextAlign = TA_RIGHT | TA_RTLREADING;
    1394                 :            :                 }
    1395         [ -  + ]:        174 :                 if (nLayoutMode & TEXT_LAYOUT_TEXTORIGIN_RIGHT)
    1396                 :          0 :                     mnHorTextAlign |= TA_RIGHT;
    1397         [ -  + ]:        174 :                 else if (nLayoutMode & TEXT_LAYOUT_TEXTORIGIN_LEFT)
    1398                 :          0 :                     mnHorTextAlign &= ~TA_RIGHT;
    1399                 :        174 :                 break;
    1400                 :            :             }
    1401                 :            : 
    1402                 :            :             case( META_MASK_ACTION ):
    1403                 :            :             case( META_MASKSCALE_ACTION ):
    1404                 :            :             case( META_MASKSCALEPART_ACTION ):
    1405                 :            :             case( META_WALLPAPER_ACTION ):
    1406                 :            :             case( META_TEXTLINE_ACTION ):
    1407                 :            :             case( META_COMMENT_ACTION ):
    1408                 :            :             case( META_GRADIENTEX_ACTION ):
    1409                 :            :             {
    1410                 :            :                 // !!! >>> we don't want to support these actions
    1411                 :            :             }
    1412                 :          0 :             break;
    1413                 :            : 
    1414                 :            :             case( META_RENDERGRAPHIC_ACTION ):
    1415                 :            :             {
    1416                 :          0 :                 const MetaRenderGraphicAction*          pA = (const MetaRenderGraphicAction*) pAction;
    1417         [ #  # ]:          0 :                 const ::vcl::RenderGraphicRasterizer    aRasterizer( pA->GetRenderGraphic() );
    1418 [ #  # ][ #  # ]:          0 :                 const BitmapEx                          aBmpEx( aRasterizer.Rasterize( maVDev.LogicToPixel( pA->GetSize() ) ) );
                 [ #  # ]
    1419         [ #  # ]:          0 :                 Bitmap                                  aBmp( aBmpEx.GetBitmap() );
    1420         [ #  # ]:          0 :                 Bitmap                                  aMsk( aBmpEx.GetMask() );
    1421                 :            : 
    1422         [ #  # ]:          0 :                 if( !!aMsk )
    1423                 :            :                 {
    1424         [ #  # ]:          0 :                     aBmp.Replace( aMsk, COL_WHITE );
    1425         [ #  # ]:          0 :                     aMsk.Invert();
    1426         [ #  # ]:          0 :                     ImplWriteBmpRecord( aMsk, pA->GetPoint(), pA->GetSize(), WIN_SRCPAINT );
    1427         [ #  # ]:          0 :                     ImplWriteBmpRecord( aBmp, pA->GetPoint(), pA->GetSize(), WIN_SRCAND );
    1428                 :            :                 }
    1429                 :            :                 else
    1430 [ #  # ][ #  # ]:          0 :                     ImplWriteBmpRecord( aBmp, pA->GetPoint(), pA->GetSize(), WIN_SRCCOPY );
         [ #  # ][ #  # ]
                 [ #  # ]
    1431                 :            :             }
    1432                 :          0 :             break;
    1433                 :            : 
    1434                 :            :             default:
    1435                 :            :                 OSL_FAIL(rtl::OStringBuffer(RTL_CONSTASCII_STRINGPARAM(
    1436                 :            :                     "EMFWriter::ImplWriteActions: unsupported MetaAction #" )).
    1437                 :            :                      append(static_cast<sal_Int32>(nType)).getStr());
    1438                 :        264 :             break;
    1439                 :            :         }
    1440                 :            :     }
    1441                 :         90 : }
    1442                 :            : 
    1443                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10