LCOV - code coverage report
Current view: top level - filter/source/graphicfilter/ios2met - ios2met.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 1433 0.0 %
Date: 2012-08-25 Functions: 0 54 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include <vcl/graph.hxx>
      31                 :            : #include <tools/poly.hxx>
      32                 :            : #include <vcl/virdev.hxx>
      33                 :            : #include <vcl/lineinfo.hxx>
      34                 :            : #include <svtools/fltcall.hxx>
      35                 :            : 
      36                 :            : #include <math.h>
      37                 :            : 
      38                 :            : // MT: NOOLDSV, someone should change the code...
      39                 :            : enum PenStyle { PEN_NULL, PEN_SOLID, PEN_DOT, PEN_DASH, PEN_DASHDOT };
      40                 :            : 
      41                 :            : 
      42                 :            : //============================== defines ===================================
      43                 :            : 
      44                 :            : #define OOODEBUG(str,Num) //InfoBox(NULL,String(str)+String(" ")+String(Num)).Execute();
      45                 :            : 
      46                 :            : // -----------------------------Feld-Typen-------------------------------
      47                 :            : 
      48                 :            : #define BegDocumnMagic 0xA8A8 /* Begin Document */
      49                 :            : #define EndDocumnMagic 0xA8A9 /* End Document   */
      50                 :            : 
      51                 :            : #define BegResGrpMagic 0xC6A8 /* Begin Resource Group */
      52                 :            : #define EndResGrpMagic 0xC6A9 /* End Resource Group   */
      53                 :            : 
      54                 :            : #define BegColAtrMagic 0x77A8 /* Begin Color Attribute Table */
      55                 :            : #define EndColAtrMagic 0x77A9 /* End Color Attribute Table   */
      56                 :            : #define BlkColAtrMagic 0x77B0 /* Color Attribute Table       */
      57                 :            : #define MapColAtrMagic 0x77AB /* Map Color Attribute Table   */
      58                 :            : 
      59                 :            : #define BegImgObjMagic 0xFBA8 /* Begin Image Object    */
      60                 :            : #define EndImgObjMagic 0xFBA9 /* End Image Object      */
      61                 :            : #define DscImgObjMagic 0xFBA6 /* Image Data Descriptor */
      62                 :            : #define DatImgObjMagic 0xFBEE /* Image Picture Data    */
      63                 :            : 
      64                 :            : #define BegObEnv1Magic 0xC7A8 /* Begin Object Environment Group */
      65                 :            : #define EndObEnv1Magic 0xC7A9 /* End Object Environment Group   */
      66                 :            : 
      67                 :            : #define BegGrfObjMagic 0xBBA8 /* Begin Graphics Object   */
      68                 :            : #define EndGrfObjMagic 0xBBA9 /* End Graphics Object     */
      69                 :            : #define DscGrfObjMagic 0xBBA6 /* Graphics Data Descritor */
      70                 :            : #define DatGrfObjMagic 0xBBEE /* Graphics Data           */
      71                 :            : 
      72                 :            : #define MapCodFntMagic 0x8AAB /* Map Coded Font    */
      73                 :            : #define MapDatResMagic 0xC3AB /* Map Data Resource */
      74                 :            : 
      75                 :            : // -----------------------------Order-Typen-------------------------------
      76                 :            : 
      77                 :            : #define GOrdGivArc 0xC6   /* 1 Arc at given position   */
      78                 :            : #define GOrdCurArc 0x86   /* 1 Arc at current position */
      79                 :            : #define GOrdGivBzr 0xE5   /* 1 Beziercurve at given position   */
      80                 :            : #define GOrdCurBzr 0xA5   /* 1 Beziercurve at current position */
      81                 :            : #define GOrdGivBox 0xC0   /* 1 Box at given position   */
      82                 :            : #define GOrdCurBox 0x80   /* 1 Box at current position */
      83                 :            : #define GOrdGivFil 0xC5   /* 1 Fillet at given position   */
      84                 :            : #define GOrdCurFil 0x85   /* 1 Fillet at current position */
      85                 :            : #define GOrdGivCrc 0xC7   /* 1 Full arc (circle) at given position   */
      86                 :            : #define GOrdCurCrc 0x87   /* 1 Full arc (circle) at current position */
      87                 :            : #define GOrdGivLin 0xC1   /* 1 Line at given position   */
      88                 :            : #define GOrdCurLin 0x81   /* 1 Line at current position */
      89                 :            : #define GOrdGivMrk 0xC2   /* 1 Marker at given position   */
      90                 :            : #define GOrdCurMrk 0x82   /* 1 Marker at current position */
      91                 :            : #define GOrdGivArP 0xE3   /* 1 Partial arc at given position   */
      92                 :            : #define GOrdCurArP 0xA3   /* 1 Partial arc at current position */
      93                 :            : #define GOrdGivRLn 0xE1   /* 1 Relative line at given position   */
      94                 :            : #define GOrdCurRLn 0xA1   /* 1 Relative line at current position */
      95                 :            : #define GOrdGivSFl 0xE4   /* 1 Sharp fillet at given position   */
      96                 :            : #define GOrdCurSFl 0xA4   /* 1 Sharp fillet at current position */
      97                 :            : 
      98                 :            : #define GOrdGivStM 0xF1   /* 1 Character string move at given position   */
      99                 :            : #define GOrdCurStM 0xB1   /* 1 Character string move at current position */
     100                 :            : #define GOrdGivStr 0xC3   /* 1 Character string at given position   */
     101                 :            : #define GOrdCurStr 0x83   /* 1 Character string at current position */
     102                 :            : #define GOrdGivStx 0xFEF0 /* 2 Character string extended at given position   */
     103                 :            : #define GOrdCurStx 0xFEB0 /* 2 Character string extended at current position */
     104                 :            : 
     105                 :            : #define GOrdGivImg 0xD1   /* 1 Begin Image at given position   */
     106                 :            : #define GOrdCurImg 0x91   /* 1 Begin Image at current position */
     107                 :            : #define GOrdImgDat 0x92   /* 1 Image data                      */
     108                 :            : #define GOrdEndImg 0x93   /* 1 End Image                       */
     109                 :            : #define GOrdBegAra 0x68   /* 0 1 Begin area */
     110                 :            : #define GOrdEndAra 0x60   /* 1 End area     */
     111                 :            : #define GOrdBegElm 0xD2   /* 1 Begin element */
     112                 :            : #define GOrdEndElm 0x49   /* 0 1 End element */
     113                 :            : 
     114                 :            : #define GOrdBegPth 0xD0   /* 1 Begin path    */
     115                 :            : #define GOrdEndPth 0x7F   /* 0 1 End path    */
     116                 :            : #define GOrdFilPth 0xD7   /* 1 Fill path     */
     117                 :            : #define GOrdModPth 0xD8   /* 1 Modify path   */
     118                 :            : #define GOrdOutPth 0xD4   /* 1 Outline path  */
     119                 :            : #define GOrdSClPth 0xB4   /* 1 Set clip path */
     120                 :            : 
     121                 :            : #define GOrdNopNop 0x00   /* 0 0 No operation */
     122                 :            : #define GOrdRemark 0x01   /* 1 Comment */
     123                 :            : #define GOrdSegLab 0xD3   /* 1 Label */
     124                 :            : #define GOrdBitBlt 0xD6   /* 1 Bitblt */
     125                 :            : #define GOrdCalSeg 0x07   /* 1 Call Segment */
     126                 :            : #define GOrdSSgBnd 0x32   /* 1 Set segment boundary */
     127                 :            : #define GOrdSegChr 0x04   /* 1 Segment characteristics */
     128                 :            : #define GOrdCloFig 0x7D   /* 0 1 Close Figure */
     129                 :            : #define GOrdEndSym 0xFF   /* 0 0 End of symbol definition */
     130                 :            : #define GOrdEndPlg 0x3E   /* 0 1 End prolog */
     131                 :            : #define GOrdEscape 0xD5   /* 1 Escape */
     132                 :            : #define GOrdExtEsc 0xFED5 /* 2 Extended Escape */
     133                 :            : #define GOrdPolygn 0xF3   /* 2 Polygons */
     134                 :            : 
     135                 :            : #define GOrdStkPop 0x3F   /* 0 1 Pop */
     136                 :            : 
     137                 :            : #define GOrdSIvAtr 0x14   /* 1 Set individual attribute          */
     138                 :            : #define GOrdPIvAtr 0x54   /* 1 Push and set individual attribute */
     139                 :            : #define GOrdSColor 0x0A   /* 0 1 Set color          */
     140                 :            : #define GOrdPColor 0x4A   /* 0 1 Push and set color */
     141                 :            : #define GOrdSIxCol 0xA6   /* 1 Set indexed color          */
     142                 :            : #define GOrdPIxCol 0xE6   /* 1 Push and set indexed color */
     143                 :            : #define GOrdSXtCol 0x26   /* 1 Set extended color          */
     144                 :            : #define GOrdPXtCol 0x66   /* 1 Push and set extended color */
     145                 :            : #define GOrdSBgCol 0x25   /* 1 Set background color          */
     146                 :            : #define GOrdPBgCol 0x65   /* 1 Push and set background color */
     147                 :            : #define GOrdSBxCol 0xA7   /* 1 Set background indexed color          */
     148                 :            : #define GOrdPBxCol 0xE7   /* 1 Push and set background indexed color */
     149                 :            : #define GOrdSMixMd 0x0C   /* 0 1 Set mix          */
     150                 :            : #define GOrdPMixMd 0x4C   /* 0 1 Push and set mix */
     151                 :            : #define GOrdSBgMix 0x0D   /* 0 1 Set background mix          */
     152                 :            : #define GOrdPBgMix 0x4D   /* 0 1 Push and set background mix */
     153                 :            : 
     154                 :            : #define GOrdSPtSet 0x08   /* 0 1 Set pattern set          */
     155                 :            : #define GOrdPPtSet 0x48   /* 0 1 Push and set pattern set */
     156                 :            : #define GOrdSPtSym 0x28   /* 0 1 Set pattern symbol          */
     157                 :            : #define GOrdPPtSym 0x09   /* 0 1 Push and set pattern symbol */
     158                 :            : #define GOrdSPtRef 0xA0   /* 1 Set model pattern reference          */
     159                 :            : #define GOrdPPtRef 0xE0   /* 1 Push and set pattern reference point */
     160                 :            : 
     161                 :            : #define GOrdSLnEnd 0x1A   /* 0 1 Set line end          */
     162                 :            : #define GOrdPLnEnd 0x5A   /* 0 1 Push and set line end */
     163                 :            : #define GOrdSLnJoi 0x1B   /* 0 1 Set line join          */
     164                 :            : #define GOrdPLnJoi 0x5B   /* 0 1 Push and set line join */
     165                 :            : #define GOrdSLnTyp 0x18   /* 0 1 Set line type          */
     166                 :            : #define GOrdPLnTyp 0x58   /* 0 1 Push and set line type */
     167                 :            : #define GOrdSLnWdt 0x19   /* 0 1 Set line width          */
     168                 :            : #define GOrdPLnWdt 0x59   /* 0 1 Push and set line width */
     169                 :            : #define GOrdSFrLWd 0x11   /* 1 Set fractional line width          */
     170                 :            : #define GOrdPFrLWd 0x51   /* 1 Push and set fractional line width */
     171                 :            : #define GOrdSStLWd 0x15   /* 1 Set stroke line width          */
     172                 :            : #define GOrdPStLWd 0x55   /* 1 Push and set stroke line width */
     173                 :            : 
     174                 :            : #define GOrdSChDir 0x3A   /* 0 1 Set character direction          */
     175                 :            : #define GOrdPChDir 0x7A   /* 0 1 Push and set character direction */
     176                 :            : #define GOrdSChPrc 0x39   /* 0 1 Set character precision          */
     177                 :            : #define GOrdPChPrc 0x79   /* 0 1 Push and set character precision */
     178                 :            : #define GOrdSChSet 0x38   /* 0 1 Set character set          */
     179                 :            : #define GOrdPChSet 0x78   /* 0 1 Push and set character set */
     180                 :            : #define GOrdSChAng 0x34   /* 1 Set character angle          */
     181                 :            : #define GOrdPChAng 0x74   /* 1 Push and set character angle */
     182                 :            : #define GOrdSChBrx 0x05   /* 1 Set character break extra          */
     183                 :            : #define GOrdPChBrx 0x45   /* 1 Push and set character break extra */
     184                 :            : #define GOrdSChCel 0x33   /* 1 Set character cell          */
     185                 :            : #define GOrdPChCel 0x03   /* 1 Push and set character cell */
     186                 :            : #define GOrdSChXtr 0x17   /* 1 Set character extra          */
     187                 :            : #define GOrdPChXtr 0x57   /* 1 Push and set character extra */
     188                 :            : #define GOrdSChShr 0x35   /* 1 Set character shear          */
     189                 :            : #define GOrdPChShr 0x75   /* 1 Push and set character shear */
     190                 :            : #define GOrdSTxAlg 0x36   /* 0 2 Set text allingment          */
     191                 :            : #define GOrdPTxAlg 0x76   /* 0 2 Push and set text allingment */
     192                 :            : 
     193                 :            : #define GOrdSMkPrc 0x3B   /* 0 1 Set marker precision          */
     194                 :            : #define GOrdPMkPrc 0x7B   /* 0 1 Push and set marker precision */
     195                 :            : #define GOrdSMkSet 0x3C   /* 0 1 Set marker set          */
     196                 :            : #define GOrdPMkSet 0x7C   /* 0 1 Push and set marker set */
     197                 :            : #define GOrdSMkSym 0x29   /* 0 1 Set marker symbol          */
     198                 :            : #define GOrdPMkSym 0x69   /* 0 1 Push and set marker symbol */
     199                 :            : #define GOrdSMkCel 0x37   /* 1 Set marker cell          */
     200                 :            : #define GOrdPMkCel 0x77   /* 1 Push and set marker cell */
     201                 :            : 
     202                 :            : #define GOrdSArcPa 0x22   /* 1 Set arc parameters          */
     203                 :            : #define GOrdPArcPa 0x62   /* 1 Push and set arc parameters */
     204                 :            : 
     205                 :            : #define GOrdSCrPos 0x21   /* 1 Set current position          */
     206                 :            : #define GOrdPCrPos 0x61   /* 1 Push and set current position */
     207                 :            : 
     208                 :            : #define GOrdSMdTrn 0x24   /* 1 Set model transform          */
     209                 :            : #define GOrdPMdTrn 0x64   /* 1 Push and set model transform */
     210                 :            : #define GOrdSPkIdn 0x43   /* 1 Set pick identifier          */
     211                 :            : #define GOrdPPkIdn 0x23   /* 1 Push and set pick identifier */
     212                 :            : #define GOrdSVwTrn 0x31   /* 1 Set viewing transform */
     213                 :            : #define GOrdSVwWin 0x27   /* 1 Set viewing window          */
     214                 :            : #define GOrdPVwWin 0x67   /* 1 Push and set viewing window */
     215                 :            : 
     216                 :            : //============================ OS2METReader ==================================
     217                 :            : 
     218                 :            : struct OSPalette {
     219                 :            :     OSPalette * pSucc;
     220                 :            :     sal_uInt32 * p0RGB; // May be NULL!
     221                 :            :     sal_uInt16 nSize;
     222                 :            : };
     223                 :            : 
     224                 :            : struct OSArea {
     225                 :            :     OSArea * pSucc;
     226                 :            :     sal_uInt8 nFlags;
     227                 :            :     PolyPolygon aPPoly;
     228                 :            :     sal_Bool bClosed;
     229                 :            :     Color      aCol;
     230                 :            :     Color      aBgCol;
     231                 :            :     RasterOp   eMix;
     232                 :            :     RasterOp   eBgMix;
     233                 :            :     sal_Bool       bFill;
     234                 :          0 :     OSArea(){} ~OSArea(){}
     235                 :            : };
     236                 :            : 
     237                 :            : struct OSPath
     238                 :            : {
     239                 :            :     OSPath*     pSucc;
     240                 :            :     sal_uInt32  nID;
     241                 :            :     PolyPolygon aPPoly;
     242                 :            :     sal_Bool        bClosed;
     243                 :            :     sal_Bool        bStroke;
     244                 :            : 
     245                 :          0 :                 OSPath(){}
     246                 :          0 :                 ~OSPath(){}
     247                 :            : };
     248                 :            : 
     249                 :            : struct OSFont {
     250                 :            :     OSFont * pSucc;
     251                 :            :     sal_uLong nID;
     252                 :            :     Font aFont;
     253                 :          0 :     OSFont(){} ~OSFont(){}
     254                 :            : };
     255                 :            : 
     256                 :            : struct OSBitmap {
     257                 :            :     OSBitmap * pSucc;
     258                 :            :     sal_uLong nID;
     259                 :            :     Bitmap aBitmap;
     260                 :            : 
     261                 :            :     // required during reading of the bitmap:
     262                 :            :     SvStream * pBMP; // pointer to temporary Windows-BMP file or NULL
     263                 :            :     sal_uInt32 nWidth, nHeight;
     264                 :            :     sal_uInt16 nBitsPerPixel;
     265                 :            :     sal_uLong nMapPos;
     266                 :          0 :     OSBitmap(){} ~OSBitmap(){}
     267                 :            : };
     268                 :            : 
     269                 :            : struct OSAttr {
     270                 :            :     OSAttr * pSucc;
     271                 :            :     sal_uInt16 nPushOrder;
     272                 :            :     sal_uInt8 nIvAttrA, nIvAttrP; // special variables for the Order "GOrdPIvAtr"
     273                 :            : 
     274                 :            :     Color    aLinCol;
     275                 :            :     Color    aLinBgCol;
     276                 :            :     RasterOp eLinMix;
     277                 :            :     RasterOp eLinBgMix;
     278                 :            :     Color    aChrCol;
     279                 :            :     Color    aChrBgCol;
     280                 :            :     RasterOp eChrMix;
     281                 :            :     RasterOp eChrBgMix;
     282                 :            :     Color    aMrkCol;
     283                 :            :     Color    aMrkBgCol;
     284                 :            :     RasterOp eMrkMix;
     285                 :            :     RasterOp eMrkBgMix;
     286                 :            :     Color    aPatCol;
     287                 :            :     Color    aPatBgCol;
     288                 :            :     RasterOp ePatMix;
     289                 :            :     RasterOp ePatBgMix;
     290                 :            :     Color    aImgCol;
     291                 :            :     Color    aImgBgCol;
     292                 :            :     RasterOp eImgMix;
     293                 :            :     RasterOp eImgBgMix;
     294                 :            :     long     nArcP, nArcQ, nArcR, nArcS;
     295                 :            :     short    nChrAng;
     296                 :            : //  long     nChrBreakExtra;
     297                 :            :     Size     aChrCellSize;
     298                 :            : //  sal_uInt8     nChrDir;
     299                 :            : //  long     nChrExtra;
     300                 :            : //  sal_uInt8     nChrPrec;
     301                 :            :     sal_uLong    nChrSet;
     302                 :            : //  Size     aChrShear;
     303                 :            :     Point    aCurPos;
     304                 :            : //  long     nFracLinWidth;
     305                 :            : //  sal_uInt8     nLinEnd;
     306                 :            : //  sal_uInt8     nLinJoin;
     307                 :            :     PenStyle eLinStyle;
     308                 :            :     sal_uInt16   nLinWidth;
     309                 :            :     Size     aMrkCellSize;
     310                 :            :     sal_uInt8     nMrkPrec;
     311                 :            :     sal_uInt8     nMrkSet;
     312                 :            :     sal_uInt8     nMrkSymbol;
     313                 :            : //  //...    aModTransform;
     314                 :            : //  Point    aPatRef;
     315                 :            : //  sal_uInt8     nPatSet;
     316                 :            :     sal_Bool     bFill;
     317                 :            : //  sal_uLong    nPickId;
     318                 :            : //  //...    aSegBound;
     319                 :            :     sal_uInt16   nStrLinWidth;
     320                 :            : //  sal_uInt8     nTxtAlignHor,nTxtAlignVer;
     321                 :            : //  //...    aViewTransform;
     322                 :            : //  //...    aViewWindow;
     323                 :          0 :     OSAttr(){} ~OSAttr(){}
     324                 :            : };
     325                 :            : 
     326                 :            : class OS2METReader {
     327                 :            : 
     328                 :            : private:
     329                 :            : 
     330                 :            :     long ErrorCode;
     331                 :            : 
     332                 :            :     SvStream    * pOS2MET;             // Die einzulesende OS2MET-Datei
     333                 :            :     VirtualDevice * pVirDev;         // here the drawing methods are being called
     334                 :            :                                      // Dabei findet ein Recording in das GDIMetaFile
     335                 :            :                                      // statt.
     336                 :            :     sal_uLong         nOrigPos;          // Anfaengliche Position in pOS2MET
     337                 :            :     sal_uInt16        nOrigNumberFormat; // Anfaengliches Nummern-Format von pOS2MET
     338                 :            :     Rectangle aBoundingRect; // Boundingrectangle wie in Datei angegeben
     339                 :            :     Rectangle aCalcBndRect;  // selbst ermitteltes Boundingrectangle
     340                 :            :     MapMode aGlobMapMode;    // resolution of the picture
     341                 :            :     sal_Bool bCoord32;
     342                 :            : 
     343                 :            :     OSPalette  * pPaletteStack;
     344                 :            : 
     345                 :            :     LineInfo aLineInfo;
     346                 :            : 
     347                 :            :     OSArea   * pAreaStack; // Areas that are being worked on
     348                 :            : 
     349                 :            :     OSPath   * pPathStack; // Paths that are being worked on
     350                 :            :     OSPath   * pPathList;  // finished Paths
     351                 :            : 
     352                 :            :     OSFont   * pFontList;
     353                 :            : 
     354                 :            :     OSBitmap * pBitmapList;
     355                 :            : 
     356                 :            :     OSAttr   aDefAttr;
     357                 :            :     OSAttr   aAttr;
     358                 :            :     OSAttr   * pAttrStack;
     359                 :            : 
     360                 :            :     SvStream * pOrdFile;
     361                 :            : 
     362                 :            :     sal_Bool Callback(sal_uInt16 nPercent);
     363                 :            : 
     364                 :            :     void AddPointsToPath(const Polygon & rPoly);
     365                 :            :     void AddPointsToArea(const Polygon & rPoly);
     366                 :            :     void CloseFigure();
     367                 :            :     void PushAttr(sal_uInt16 nPushOrder);
     368                 :            :     void PopAttr();
     369                 :            : 
     370                 :            :     void ChangeBrush( const Color& rPatColor, const Color& rBGColor, sal_Bool bFill );
     371                 :            :     void SetPen( const Color& rColor, sal_uInt16 nStrLinWidth = 0, PenStyle ePenStyle = PEN_SOLID );
     372                 :            :     void SetRasterOp(RasterOp eROP);
     373                 :            : 
     374                 :            :     void SetPalette0RGB(sal_uInt16 nIndex, sal_uLong nCol);
     375                 :            :     sal_uInt32 GetPalette0RGB(sal_uInt32 nIndex);
     376                 :            :         // gets color from palette, or, if it doesn't exist,
     377                 :            :         // interprets nIndex as immediate RGB value.
     378                 :            :     Color GetPaletteColor(sal_uInt32 nIndex);
     379                 :            : 
     380                 :            : 
     381                 :            :     sal_Bool        IsLineInfo();
     382                 :            :     void        DrawPolyLine( const Polygon& rPolygon );
     383                 :            :     void        DrawPolygon( const Polygon& rPolygon );
     384                 :            :     void        DrawPolyPolygon( const PolyPolygon& rPolygon );
     385                 :            :     sal_uInt16      ReadBigEndianWord();
     386                 :            :     sal_uLong       ReadBigEndian3BytesLong();
     387                 :            :     sal_uLong       ReadLittleEndian3BytesLong();
     388                 :            :     long        ReadCoord(sal_Bool b32);
     389                 :            :     Point       ReadPoint( const sal_Bool bAdjustBoundRect = sal_True );
     390                 :            :     RasterOp    OS2MixToRasterOp(sal_uInt8 nMix);
     391                 :            :     void        ReadLine(sal_Bool bGivenPos, sal_uInt16 nOrderLen);
     392                 :            :     void        ReadRelLine(sal_Bool bGivenPos, sal_uInt16 nOrderLen);
     393                 :            :     void        ReadBox(sal_Bool bGivenPos);
     394                 :            :     void        ReadBitBlt();
     395                 :            :     void        ReadChrStr(sal_Bool bGivenPos, sal_Bool bMove, sal_Bool bExtra, sal_uInt16 nOrderLen);
     396                 :            :     void        ReadArc(sal_Bool bGivenPos);
     397                 :            :     void        ReadFullArc(sal_Bool bGivenPos, sal_uInt16 nOrderSize);
     398                 :            :     void        ReadPartialArc(sal_Bool bGivenPos, sal_uInt16 nOrderSize);
     399                 :            :     void        ReadPolygons();
     400                 :            :     void        ReadBezier(sal_Bool bGivenPos, sal_uInt16 nOrderLen);
     401                 :            :     void        ReadFillet(sal_Bool bGivenPos, sal_uInt16 nOrderLen);
     402                 :            :     void        ReadFilletSharp(sal_Bool bGivenPos, sal_uInt16 nOrderLen);
     403                 :            :     void        ReadMarker(sal_Bool bGivenPos, sal_uInt16 nOrderLen);
     404                 :            :     void        ReadOrder(sal_uInt16 nOrderID, sal_uInt16 nOrderLen);
     405                 :            :     void        ReadDsc(sal_uInt16 nDscID, sal_uInt16 nDscLen);
     406                 :            :     void        ReadImageData(sal_uInt16 nDataID, sal_uInt16 nDataLen);
     407                 :            :     void        ReadFont(sal_uInt16 nFieldSize);
     408                 :            :     void        ReadField(sal_uInt16 nFieldType, sal_uInt16 nFieldSize);
     409                 :            : 
     410                 :            : public:
     411                 :            : 
     412                 :            :     OS2METReader();
     413                 :            :     ~OS2METReader();
     414                 :            : 
     415                 :            :     void ReadOS2MET( SvStream & rStreamOS2MET, GDIMetaFile & rGDIMetaFile );
     416                 :            :         // Reads from the stream a OS2MET file und and fills up the GDIMetaFile
     417                 :            : 
     418                 :            : };
     419                 :            : 
     420                 :            : //=================== Methods of OS2METReader ==============================
     421                 :            : 
     422                 :          0 : sal_Bool OS2METReader::Callback(sal_uInt16 /*nPercent*/)
     423                 :            : {
     424                 :          0 :     return sal_False;
     425                 :            : }
     426                 :            : 
     427                 :          0 : OS2METReader::OS2METReader()
     428                 :            : {
     429                 :          0 : }
     430                 :            : 
     431                 :          0 : OS2METReader::~OS2METReader()
     432                 :            : {
     433                 :          0 : }
     434                 :            : 
     435                 :          0 : sal_Bool OS2METReader::IsLineInfo()
     436                 :            : {
     437                 :          0 :     return ( ! ( aLineInfo.IsDefault() || ( aLineInfo.GetStyle() == LINE_NONE ) || ( pVirDev->GetLineColor() == COL_TRANSPARENT ) ) );
     438                 :            : }
     439                 :            : 
     440                 :          0 : void OS2METReader::DrawPolyLine( const Polygon& rPolygon )
     441                 :            : {
     442                 :          0 :     if ( aLineInfo.GetStyle() == LINE_DASH || ( aLineInfo.GetWidth() > 1 ) )
     443                 :          0 :         pVirDev->DrawPolyLine( rPolygon, aLineInfo );
     444                 :            :     else
     445                 :          0 :         pVirDev->DrawPolyLine( rPolygon );
     446                 :          0 : }
     447                 :            : 
     448                 :          0 : void OS2METReader::DrawPolygon( const Polygon& rPolygon )
     449                 :            : {
     450                 :          0 :     if ( IsLineInfo() )
     451                 :            :     {
     452                 :          0 :         pVirDev->Push( PUSH_LINECOLOR );
     453                 :          0 :         pVirDev->SetLineColor( COL_TRANSPARENT );
     454                 :          0 :         pVirDev->DrawPolygon( rPolygon );
     455                 :          0 :         pVirDev->Pop();
     456                 :          0 :         pVirDev->DrawPolyLine( rPolygon, aLineInfo );
     457                 :            :     }
     458                 :            :     else
     459                 :          0 :         pVirDev->DrawPolygon( rPolygon );
     460                 :          0 : }
     461                 :            : 
     462                 :          0 : void OS2METReader::DrawPolyPolygon( const PolyPolygon& rPolyPolygon )
     463                 :            : {
     464                 :          0 :     if ( IsLineInfo() )
     465                 :            :     {
     466                 :          0 :         pVirDev->Push( PUSH_LINECOLOR );
     467                 :          0 :         pVirDev->SetLineColor( COL_TRANSPARENT );
     468                 :          0 :         pVirDev->DrawPolyPolygon( rPolyPolygon );
     469                 :          0 :         pVirDev->Pop();
     470                 :          0 :         for ( sal_uInt16 i = 0; i < rPolyPolygon.Count(); i++ )
     471                 :          0 :             pVirDev->DrawPolyLine( rPolyPolygon.GetObject( i ), aLineInfo );
     472                 :            :     }
     473                 :            :     else
     474                 :          0 :         pVirDev->DrawPolyPolygon( rPolyPolygon );
     475                 :          0 : }
     476                 :            : 
     477                 :          0 : void OS2METReader::AddPointsToArea(const Polygon & rPoly)
     478                 :            : {
     479                 :            :     sal_uInt16 nOldSize, nNewSize,i;
     480                 :            : 
     481                 :          0 :     if (pAreaStack==NULL || rPoly.GetSize()==0) return;
     482                 :          0 :     PolyPolygon * pPP=&(pAreaStack->aPPoly);
     483                 :          0 :     if (pPP->Count()==0 || pAreaStack->bClosed==sal_True) pPP->Insert(rPoly);
     484                 :            :     else {
     485                 :          0 :         Polygon aLastPoly(pPP->GetObject(pPP->Count()-1));
     486                 :          0 :         nOldSize=aLastPoly.GetSize();
     487                 :          0 :         if (aLastPoly.GetPoint(nOldSize-1)==rPoly.GetPoint(0)) nOldSize--;
     488                 :          0 :         nNewSize=nOldSize+rPoly.GetSize();
     489                 :          0 :         aLastPoly.SetSize(nNewSize);
     490                 :          0 :         for (i=nOldSize; i<nNewSize; i++) {
     491                 :          0 :             aLastPoly.SetPoint(rPoly.GetPoint(i-nOldSize),i);
     492                 :            :         }
     493                 :          0 :         pPP->Replace(aLastPoly,pPP->Count()-1);
     494                 :            :     }
     495                 :          0 :     pAreaStack->bClosed=sal_False;
     496                 :            : }
     497                 :            : 
     498                 :          0 : void OS2METReader::AddPointsToPath(const Polygon & rPoly)
     499                 :            : {
     500                 :            :     sal_uInt16 nOldSize, nNewSize,i;
     501                 :            : 
     502                 :          0 :     if (pPathStack==NULL || rPoly.GetSize()==0) return;
     503                 :          0 :     PolyPolygon * pPP=&(pPathStack->aPPoly);
     504                 :          0 :     if (pPP->Count()==0 /*|| pPathStack->bClosed==sal_True*/) pPP->Insert(rPoly);
     505                 :            :     else {
     506                 :          0 :         Polygon aLastPoly(pPP->GetObject(pPP->Count()-1));
     507                 :          0 :         nOldSize=aLastPoly.GetSize();
     508                 :          0 :         if (aLastPoly.GetPoint(nOldSize-1)!=rPoly.GetPoint(0)) pPP->Insert(rPoly);
     509                 :            :         else {
     510                 :          0 :             nOldSize--;
     511                 :          0 :             nNewSize=nOldSize+rPoly.GetSize();
     512                 :          0 :             aLastPoly.SetSize(nNewSize);
     513                 :          0 :             for (i=nOldSize; i<nNewSize; i++) {
     514                 :          0 :                 aLastPoly.SetPoint(rPoly.GetPoint(i-nOldSize),i);
     515                 :            :             }
     516                 :          0 :             pPP->Replace(aLastPoly,pPP->Count()-1);
     517                 :          0 :         }
     518                 :            :     }
     519                 :          0 :     pPathStack->bClosed=sal_False;
     520                 :            : }
     521                 :            : 
     522                 :          0 : void OS2METReader::CloseFigure()
     523                 :            : {
     524                 :          0 :     if (pAreaStack!=NULL) pAreaStack->bClosed=sal_True;
     525                 :          0 :     else if (pPathStack!=NULL) pPathStack->bClosed=sal_True;
     526                 :          0 : }
     527                 :            : 
     528                 :          0 : void OS2METReader::PushAttr(sal_uInt16 nPushOrder)
     529                 :            : {
     530                 :            :     OSAttr * p;
     531                 :          0 :     p=new OSAttr;
     532                 :          0 :     *p=aAttr;
     533                 :          0 :     p->pSucc=pAttrStack; pAttrStack=p;
     534                 :          0 :     p->nPushOrder=nPushOrder;
     535                 :          0 : }
     536                 :            : 
     537                 :          0 : void OS2METReader::PopAttr()
     538                 :            : {
     539                 :          0 :     OSAttr * p=pAttrStack;
     540                 :            : 
     541                 :          0 :     if (p==NULL) return;
     542                 :          0 :     switch (p->nPushOrder) {
     543                 :            : 
     544                 :            :         case GOrdPIvAtr:
     545                 :          0 :             switch (p->nIvAttrA) {
     546                 :          0 :                 case 1: switch (p->nIvAttrP) {
     547                 :          0 :                     case 1: aAttr.aLinCol=p->aLinCol; break;
     548                 :          0 :                     case 2: aAttr.aChrCol=p->aChrCol; break;
     549                 :          0 :                     case 3: aAttr.aMrkCol=p->aMrkCol; break;
     550                 :          0 :                     case 4: aAttr.aPatCol=p->aPatCol; break;
     551                 :          0 :                     case 5: aAttr.aImgCol=p->aImgCol; break;
     552                 :          0 :                 } break;
     553                 :          0 :                 case 2: switch (p->nIvAttrP) {
     554                 :          0 :                     case 1: aAttr.aLinBgCol=p->aLinBgCol; break;
     555                 :          0 :                     case 2: aAttr.aChrBgCol=p->aChrBgCol; break;
     556                 :          0 :                     case 3: aAttr.aMrkBgCol=p->aMrkBgCol; break;
     557                 :          0 :                     case 4: aAttr.aPatBgCol=p->aPatBgCol; break;
     558                 :          0 :                     case 5: aAttr.aImgBgCol=p->aImgBgCol; break;
     559                 :          0 :                 } break;
     560                 :          0 :                 case 3: switch (p->nIvAttrP) {
     561                 :          0 :                     case 1: aAttr.eLinMix=p->eLinMix; break;
     562                 :          0 :                     case 2: aAttr.eChrMix=p->eChrMix; break;
     563                 :          0 :                     case 3: aAttr.eMrkMix=p->eMrkMix; break;
     564                 :          0 :                     case 4: aAttr.ePatMix=p->ePatMix; break;
     565                 :          0 :                     case 5: aAttr.eImgMix=p->eImgMix; break;
     566                 :          0 :                 } break;
     567                 :          0 :                 case 4: switch (p->nIvAttrP) {
     568                 :          0 :                     case 1: aAttr.eLinBgMix=p->eLinBgMix; break;
     569                 :          0 :                     case 2: aAttr.eChrBgMix=p->eChrBgMix; break;
     570                 :          0 :                     case 3: aAttr.eMrkBgMix=p->eMrkBgMix; break;
     571                 :          0 :                     case 4: aAttr.ePatBgMix=p->ePatBgMix; break;
     572                 :          0 :                     case 5: aAttr.eImgBgMix=p->eImgBgMix; break;
     573                 :          0 :                 } break;
     574                 :            :             }
     575                 :          0 :             break;
     576                 :            : 
     577                 :          0 :         case GOrdPLnTyp: aAttr.eLinStyle=p->eLinStyle; break;
     578                 :            : 
     579                 :          0 :         case GOrdPLnWdt: aAttr.nLinWidth=p->nLinWidth; break;
     580                 :            : 
     581                 :          0 :         case GOrdPStLWd: aAttr.nStrLinWidth=p->nStrLinWidth; break;
     582                 :            : 
     583                 :          0 :         case GOrdPChSet: aAttr.nChrSet=p->nChrSet; break;
     584                 :            : 
     585                 :          0 :         case GOrdPChAng: aAttr.nChrAng=p->nChrAng; break;
     586                 :            : 
     587                 :            :         case GOrdPMixMd:
     588                 :          0 :             aAttr.eLinMix=p->eLinMix;
     589                 :          0 :             aAttr.eChrMix=p->eChrMix;
     590                 :          0 :             aAttr.eMrkMix=p->eMrkMix;
     591                 :          0 :             aAttr.ePatMix=p->ePatMix;
     592                 :          0 :             aAttr.eImgMix=p->eImgMix;
     593                 :          0 :             break;
     594                 :            : 
     595                 :            :         case GOrdPBgMix:
     596                 :          0 :             aAttr.eLinBgMix=p->eLinBgMix;
     597                 :          0 :             aAttr.eChrBgMix=p->eChrBgMix;
     598                 :          0 :             aAttr.eMrkBgMix=p->eMrkBgMix;
     599                 :          0 :             aAttr.ePatBgMix=p->ePatBgMix;
     600                 :          0 :             aAttr.eImgBgMix=p->eImgBgMix;
     601                 :          0 :             break;
     602                 :            : 
     603                 :          0 :         case GOrdPPtSym: aAttr.bFill = p->bFill; break;
     604                 :            : 
     605                 :            :         case GOrdPColor:
     606                 :            :         case GOrdPIxCol:
     607                 :            :         case GOrdPXtCol:
     608                 :          0 :             aAttr.aLinCol=p->aLinCol;
     609                 :          0 :             aAttr.aChrCol=p->aChrCol;
     610                 :          0 :             aAttr.aMrkCol=p->aMrkCol;
     611                 :          0 :             aAttr.aPatCol=p->aPatCol;
     612                 :          0 :             aAttr.aImgCol=p->aImgCol;
     613                 :          0 :             break;
     614                 :            : 
     615                 :            :         case GOrdPBgCol:
     616                 :            :         case GOrdPBxCol:
     617                 :          0 :             aAttr.aLinBgCol=p->aLinBgCol;
     618                 :          0 :             aAttr.aChrBgCol=p->aChrBgCol;
     619                 :          0 :             aAttr.aMrkBgCol=p->aMrkBgCol;
     620                 :          0 :             aAttr.aPatBgCol=p->aPatBgCol;
     621                 :          0 :             aAttr.aImgBgCol=p->aImgBgCol;
     622                 :          0 :             break;
     623                 :            : 
     624                 :          0 :         case GOrdPMkPrc: aAttr.nMrkPrec=aDefAttr.nMrkPrec; break;
     625                 :            : 
     626                 :          0 :         case GOrdPMkSet: aAttr.nMrkSet=aDefAttr.nMrkSet; break;
     627                 :            : 
     628                 :          0 :         case GOrdPMkSym: aAttr.nMrkSymbol=aDefAttr.nMrkSymbol; break;
     629                 :            : 
     630                 :          0 :         case GOrdPMkCel: aAttr.aMrkCellSize=aDefAttr.aMrkCellSize; break;
     631                 :            : 
     632                 :            :         case GOrdPArcPa:
     633                 :          0 :             aAttr.nArcP=p->nArcP; aAttr.nArcQ=p->nArcQ;
     634                 :          0 :             aAttr.nArcR=p->nArcR; aAttr.nArcS=p->nArcS;
     635                 :          0 :             break;
     636                 :            : 
     637                 :            :         case GOrdPCrPos:
     638                 :          0 :             aAttr.aCurPos=p->aCurPos;
     639                 :          0 :             break;
     640                 :            :     }
     641                 :          0 :     pAttrStack=p->pSucc;
     642                 :          0 :     delete p;
     643                 :            : }
     644                 :            : 
     645                 :          0 : void OS2METReader::ChangeBrush(const Color& rPatColor, const Color& /*rBGColor*/, sal_Bool bFill )
     646                 :            : {
     647                 :          0 :     Color aColor;
     648                 :            : 
     649                 :          0 :     if( bFill )
     650                 :          0 :         aColor = rPatColor;
     651                 :            :     else
     652                 :          0 :         aColor = Color( COL_TRANSPARENT );
     653                 :            : 
     654                 :          0 :     if( pVirDev->GetFillColor() != aColor )
     655                 :          0 :         pVirDev->SetFillColor( aColor );
     656                 :          0 : }
     657                 :            : 
     658                 :          0 : void OS2METReader::SetPen( const Color& rColor, sal_uInt16 nLineWidth, PenStyle ePenStyle )
     659                 :            : {
     660                 :          0 :     LineStyle eLineStyle( LINE_SOLID );
     661                 :            : 
     662                 :          0 :     if ( pVirDev->GetLineColor() != rColor )
     663                 :          0 :         pVirDev->SetLineColor( rColor );
     664                 :          0 :     aLineInfo.SetWidth( nLineWidth );
     665                 :            : 
     666                 :          0 :     sal_uInt16 nDotCount = 0;
     667                 :          0 :     sal_uInt16 nDashCount = 0;
     668                 :          0 :     switch ( ePenStyle )
     669                 :            :     {
     670                 :            :         case PEN_NULL :
     671                 :          0 :             eLineStyle = LINE_NONE;
     672                 :          0 :         break;
     673                 :            :         case PEN_DASHDOT :
     674                 :          0 :             nDashCount++;
     675                 :            :         case PEN_DOT :
     676                 :          0 :             nDotCount++;
     677                 :          0 :             nDashCount--;
     678                 :            :         case PEN_DASH :
     679                 :          0 :             nDashCount++;
     680                 :          0 :             aLineInfo.SetDotCount( nDotCount );
     681                 :          0 :             aLineInfo.SetDashCount( nDashCount );
     682                 :          0 :             aLineInfo.SetDistance( nLineWidth );
     683                 :          0 :             aLineInfo.SetDotLen( nLineWidth );
     684                 :          0 :             aLineInfo.SetDashLen( nLineWidth << 2 );
     685                 :          0 :             eLineStyle = LINE_DASH;
     686                 :          0 :         break;
     687                 :            :         case PEN_SOLID:
     688                 :          0 :         break;  // -Wall not handled...
     689                 :            :     }
     690                 :          0 :     aLineInfo.SetStyle( eLineStyle );
     691                 :          0 : }
     692                 :            : 
     693                 :          0 : void OS2METReader::SetRasterOp(RasterOp eROP)
     694                 :            : {
     695                 :          0 :     if (pVirDev->GetRasterOp()!=eROP) pVirDev->SetRasterOp(eROP);
     696                 :          0 : }
     697                 :            : 
     698                 :            : 
     699                 :          0 : void OS2METReader::SetPalette0RGB(sal_uInt16 nIndex, sal_uLong nCol)
     700                 :            : {
     701                 :          0 :     if (pPaletteStack==NULL) {
     702                 :          0 :         pPaletteStack=new OSPalette;
     703                 :          0 :         pPaletteStack->pSucc=NULL;
     704                 :          0 :         pPaletteStack->p0RGB=NULL;
     705                 :          0 :         pPaletteStack->nSize=0;
     706                 :            :     }
     707                 :          0 :     if (pPaletteStack->p0RGB==NULL || nIndex>=pPaletteStack->nSize) {
     708                 :          0 :         sal_uInt32 * pOld0RGB=pPaletteStack->p0RGB;
     709                 :          0 :         sal_uInt16 i,nOldSize=pPaletteStack->nSize;
     710                 :          0 :         if (pOld0RGB==NULL) nOldSize=0;
     711                 :          0 :         pPaletteStack->nSize=2*(nIndex+1);
     712                 :          0 :         if (pPaletteStack->nSize<256) pPaletteStack->nSize=256;
     713                 :          0 :         pPaletteStack->p0RGB = new sal_uInt32[pPaletteStack->nSize];
     714                 :          0 :         for (i=0; i<pPaletteStack->nSize; i++) {
     715                 :          0 :             if (i<nOldSize) pPaletteStack->p0RGB[i]=pOld0RGB[i];
     716                 :          0 :             else if (i==0) pPaletteStack->p0RGB[i]=0x00ffffff;
     717                 :          0 :             else pPaletteStack->p0RGB[i]=0;
     718                 :            :         }
     719                 :          0 :         if (pOld0RGB!=NULL) delete[] pOld0RGB;
     720                 :            :     }
     721                 :          0 :     pPaletteStack->p0RGB[nIndex]=nCol;
     722                 :          0 : }
     723                 :            : 
     724                 :          0 : sal_uInt32 OS2METReader::GetPalette0RGB(sal_uInt32 nIndex)
     725                 :            : {
     726                 :          0 :     if (pPaletteStack!=NULL && pPaletteStack->p0RGB!=NULL &&
     727                 :          0 :         pPaletteStack->nSize>nIndex) nIndex=pPaletteStack->p0RGB[nIndex];
     728                 :          0 :     return nIndex;
     729                 :            : }
     730                 :            : 
     731                 :          0 : Color OS2METReader::GetPaletteColor(sal_uInt32 nIndex)
     732                 :            : {
     733                 :          0 :     nIndex=GetPalette0RGB(nIndex);
     734                 :          0 :     return Color(sal::static_int_cast< sal_uInt8 >((nIndex>>16)&0xff),
     735                 :          0 :                  sal::static_int_cast< sal_uInt8 >((nIndex>>8)&0xff),
     736                 :          0 :                  sal::static_int_cast< sal_uInt8 >(nIndex&0xff));
     737                 :            : }
     738                 :            : 
     739                 :            : 
     740                 :          0 : sal_uInt16 OS2METReader::ReadBigEndianWord()
     741                 :            : {
     742                 :            :     sal_uInt8 nLo,nHi;
     743                 :          0 :     *pOS2MET >> nHi >> nLo;
     744                 :          0 :     return (((sal_uInt16)nHi)<<8)|(((sal_uInt16)nLo)&0x00ff);
     745                 :            : }
     746                 :            : 
     747                 :          0 : sal_uLong OS2METReader::ReadBigEndian3BytesLong()
     748                 :            : {
     749                 :            :     sal_uInt16 nLo;
     750                 :            :     sal_uInt8 nHi;
     751                 :          0 :     *pOS2MET >> nHi;
     752                 :          0 :     nLo=ReadBigEndianWord();
     753                 :          0 :     return ((((sal_uLong)nHi)<<16)&0x00ff0000)|((sal_uLong)nLo);
     754                 :            : }
     755                 :            : 
     756                 :          0 : sal_uLong OS2METReader::ReadLittleEndian3BytesLong()
     757                 :            : {
     758                 :            :     sal_uInt8 nHi,nMed,nLo;
     759                 :            : 
     760                 :          0 :     *pOS2MET >> nLo >> nMed >> nHi;
     761                 :          0 :     return ((((sal_uLong)nHi)&0xff)<<16)|((((sal_uLong)nMed)&0xff)<<8)|(((sal_uLong)nLo)&0xff);
     762                 :            : }
     763                 :            : 
     764                 :          0 : long OS2METReader::ReadCoord(sal_Bool b32)
     765                 :            : {
     766                 :            :     sal_Int32 l;
     767                 :            : 
     768                 :          0 :     if (b32) *pOS2MET >> l;
     769                 :          0 :     else  { short s;*pOS2MET >> s; l=(sal_Int32)s; }
     770                 :          0 :     return l;
     771                 :            : }
     772                 :            : 
     773                 :          0 : Point OS2METReader::ReadPoint( const sal_Bool bAdjustBoundRect )
     774                 :            : {
     775                 :            :     long x,y;
     776                 :            : 
     777                 :          0 :     x=ReadCoord(bCoord32);
     778                 :          0 :     y=ReadCoord(bCoord32);
     779                 :          0 :     x=x-aBoundingRect.Left();
     780                 :          0 :     y=aBoundingRect.Bottom()-y;
     781                 :            : 
     782                 :          0 :     if ( bAdjustBoundRect )
     783                 :          0 :         aCalcBndRect.Union(Rectangle(x,y,x+1,y+1));
     784                 :            : 
     785                 :          0 :     return Point(x,y);
     786                 :            : }
     787                 :            : 
     788                 :          0 : RasterOp OS2METReader::OS2MixToRasterOp(sal_uInt8 nMix)
     789                 :            : {
     790                 :          0 :     switch (nMix) {
     791                 :          0 :         case 0x0c: return ROP_INVERT;
     792                 :          0 :         case 0x04: return ROP_XOR;
     793                 :          0 :         case 0x0b: return ROP_XOR;
     794                 :          0 :         default:   return ROP_OVERPAINT;
     795                 :            :     }
     796                 :            : }
     797                 :            : 
     798                 :          0 : void OS2METReader::ReadLine(sal_Bool bGivenPos, sal_uInt16 nOrderLen)
     799                 :            : {
     800                 :            :     sal_uInt16 i,nPolySize;
     801                 :            : 
     802                 :          0 :     if (bCoord32) nPolySize=nOrderLen/8; else nPolySize=nOrderLen/4;
     803                 :          0 :     if (!bGivenPos) nPolySize++;
     804                 :          0 :     if (nPolySize==0) return;
     805                 :          0 :     Polygon aPolygon(nPolySize);
     806                 :          0 :     for (i=0; i<nPolySize; i++) {
     807                 :          0 :         if (i==0 && !bGivenPos) aPolygon.SetPoint(aAttr.aCurPos,i);
     808                 :          0 :         else aPolygon.SetPoint(ReadPoint(),i);
     809                 :            :     }
     810                 :          0 :     aAttr.aCurPos=aPolygon.GetPoint(nPolySize-1);
     811                 :          0 :     if (pAreaStack!=NULL) AddPointsToArea(aPolygon);
     812                 :          0 :     else if (pPathStack!=NULL) AddPointsToPath(aPolygon);
     813                 :            :     else
     814                 :            :     {
     815                 :          0 :         SetPen( aAttr.aLinCol, aAttr.nStrLinWidth, aAttr.eLinStyle );
     816                 :          0 :         SetRasterOp(aAttr.eLinMix);
     817                 :          0 :         DrawPolyLine( aPolygon );
     818                 :          0 :     }
     819                 :            : }
     820                 :            : 
     821                 :          0 : void OS2METReader::ReadRelLine(sal_Bool bGivenPos, sal_uInt16 nOrderLen)
     822                 :            : {
     823                 :            :     sal_uInt16 i,nPolySize;
     824                 :          0 :     Point aP0;
     825                 :            : 
     826                 :            : 
     827                 :          0 :     if (bGivenPos) {
     828                 :          0 :         aP0=ReadPoint();
     829                 :          0 :         if (bCoord32) nOrderLen-=8; else nOrderLen-=4;
     830                 :            :     }
     831                 :          0 :     else aP0=aAttr.aCurPos;
     832                 :          0 :     nPolySize=nOrderLen/2;
     833                 :          0 :     if (nPolySize==0) return;
     834                 :          0 :     Polygon aPolygon(nPolySize);
     835                 :          0 :     for (i=0; i<nPolySize; i++) {
     836                 :            : #if defined SOLARIS && defined PPC
     837                 :            :         sal_uInt8 nunsignedbyte;
     838                 :            :         *pOS2MET >> nunsignedbyte; aP0.X()+=(sal_Int8)nunsignedbyte;
     839                 :            :         *pOS2MET >> nunsignedbyte; aP0.Y()+=(sal_Int8)nunsignedbyte;
     840                 :            : #else
     841                 :            :         sal_Int8 nsignedbyte;
     842                 :          0 :         *pOS2MET >> nsignedbyte; aP0.X()+=(long)nsignedbyte;
     843                 :          0 :         *pOS2MET >> nsignedbyte; aP0.Y()-=(long)nsignedbyte;
     844                 :            : #endif
     845                 :          0 :         aCalcBndRect.Union(Rectangle(aP0,Size(1,1)));
     846                 :          0 :         aPolygon.SetPoint(aP0,i);
     847                 :            :     }
     848                 :          0 :     aAttr.aCurPos=aPolygon.GetPoint(nPolySize-1);
     849                 :          0 :     if (pAreaStack!=NULL) AddPointsToArea(aPolygon);
     850                 :          0 :     else if (pPathStack!=NULL) AddPointsToPath(aPolygon);
     851                 :            :     else
     852                 :            :     {
     853                 :          0 :         SetPen( aAttr.aLinCol, aAttr.nStrLinWidth, aAttr.eLinStyle );
     854                 :          0 :         SetRasterOp(aAttr.eLinMix);
     855                 :          0 :         DrawPolyLine( aPolygon );
     856                 :          0 :     }
     857                 :            : }
     858                 :            : 
     859                 :          0 : void OS2METReader::ReadBox(sal_Bool bGivenPos)
     860                 :            : {
     861                 :            :     sal_uInt8       nFlags;
     862                 :          0 :     Point       P0;
     863                 :            :     long        nHRound,nVRound;
     864                 :            : 
     865                 :          0 :     *pOS2MET >> nFlags;
     866                 :          0 :     pOS2MET->SeekRel(1);
     867                 :            : 
     868                 :          0 :     if ( bGivenPos )
     869                 :          0 :         P0 = ReadPoint();
     870                 :            :     else
     871                 :          0 :         P0 = aAttr.aCurPos;
     872                 :            : 
     873                 :          0 :     aAttr.aCurPos=ReadPoint();
     874                 :          0 :     nHRound=ReadCoord(bCoord32);
     875                 :          0 :     nVRound=ReadCoord(bCoord32);
     876                 :            : 
     877                 :          0 :     Rectangle aBoxRect( P0, aAttr.aCurPos );
     878                 :            : 
     879                 :          0 :     if ( pAreaStack )
     880                 :          0 :         AddPointsToArea( Polygon( aBoxRect ) );
     881                 :          0 :     else if ( pPathStack )
     882                 :          0 :         AddPointsToPath( Polygon( aBoxRect ) );
     883                 :            :     else
     884                 :            :     {
     885                 :          0 :         if ( nFlags & 0x20 )
     886                 :          0 :             SetPen( aAttr.aLinCol, aAttr.nStrLinWidth, aAttr.eLinStyle );
     887                 :            :         else
     888                 :          0 :             SetPen( COL_TRANSPARENT );
     889                 :            : 
     890                 :          0 :         if ( nFlags & 0x40 )
     891                 :            :         {
     892                 :          0 :             ChangeBrush(aAttr.aPatCol,aAttr.aPatBgCol,aAttr.bFill);
     893                 :          0 :             SetRasterOp(aAttr.ePatMix);
     894                 :            :         }
     895                 :            :         else
     896                 :            :         {
     897                 :          0 :             ChangeBrush( Color( COL_TRANSPARENT ), Color( COL_TRANSPARENT ), sal_False );
     898                 :          0 :             SetRasterOp(aAttr.eLinMix);
     899                 :            :         }
     900                 :            : 
     901                 :          0 :         if ( IsLineInfo() )
     902                 :            :         {
     903                 :          0 :             Polygon aPolygon( aBoxRect, nHRound, nVRound );
     904                 :          0 :             if ( nFlags & 0x40 )
     905                 :            :             {
     906                 :          0 :                 pVirDev->Push( PUSH_LINECOLOR );
     907                 :          0 :                 pVirDev->SetLineColor( COL_TRANSPARENT );
     908                 :          0 :                 pVirDev->DrawRect( aBoxRect, nHRound, nVRound );
     909                 :          0 :                 pVirDev->Pop();
     910                 :            :             }
     911                 :          0 :             pVirDev->DrawPolyLine( aPolygon, aLineInfo );
     912                 :            :         }
     913                 :            :         else
     914                 :          0 :             pVirDev->DrawRect( aBoxRect, nHRound, nVRound );
     915                 :            :     }
     916                 :          0 : }
     917                 :            : 
     918                 :          0 : void OS2METReader::ReadBitBlt()
     919                 :            : {
     920                 :          0 :     Point aP1,aP2;
     921                 :          0 :     Size aSize;
     922                 :            :     sal_uInt32 nID;
     923                 :            :     OSBitmap * pB;
     924                 :            :     long nt;
     925                 :            : 
     926                 :          0 :     pOS2MET->SeekRel(4);
     927                 :          0 :     *pOS2MET >> nID;
     928                 :          0 :     pOS2MET->SeekRel(4);
     929                 :          0 :     aP1=ReadPoint(); aP2=ReadPoint();
     930                 :          0 :     if (aP1.X() > aP2.X()) { nt=aP1.X(); aP1.X()=aP2.X(); aP2.X()=nt; }
     931                 :          0 :     if (aP1.Y() > aP2.Y()) { nt=aP1.Y(); aP1.Y()=aP2.Y(); aP2.Y()=nt; }
     932                 :          0 :     aSize=Size(aP2.X()-aP1.X(),aP2.Y()-aP1.Y());
     933                 :            : 
     934                 :          0 :     pB=pBitmapList;
     935                 :          0 :     while (pB!=NULL && pB->nID!=nID) pB=pB->pSucc;
     936                 :          0 :     if (pB!=NULL) {
     937                 :          0 :         SetRasterOp(aAttr.ePatMix);
     938                 :          0 :         pVirDev->DrawBitmap(aP1,aSize,pB->aBitmap);
     939                 :            :     }
     940                 :          0 : }
     941                 :            : 
     942                 :          0 : void OS2METReader::ReadChrStr(sal_Bool bGivenPos, sal_Bool bMove, sal_Bool bExtra, sal_uInt16 nOrderLen)
     943                 :            : {
     944                 :          0 :     Point aP0;
     945                 :            :     sal_uInt16 i, nLen;
     946                 :            :     char * pChr;
     947                 :            :     OSFont * pF;
     948                 :          0 :     Font aFont;
     949                 :          0 :     Size aSize;
     950                 :            : 
     951                 :          0 :     pF = pFontList;
     952                 :          0 :     while (pF!=NULL && pF->nID!=aAttr.nChrSet) pF=pF->pSucc;
     953                 :          0 :     if (pF!=NULL)
     954                 :          0 :         aFont = pF->aFont;
     955                 :          0 :     aFont.SetColor(aAttr.aChrCol);
     956                 :          0 :     aFont.SetSize(Size(0,aAttr.aChrCellSize.Height()));
     957                 :          0 :     if ( aAttr.nChrAng != 0 )
     958                 :          0 :         aFont.SetOrientation(aAttr.nChrAng);
     959                 :            : 
     960                 :          0 :     if (bGivenPos)
     961                 :          0 :         aP0 = ReadPoint();
     962                 :            :     else
     963                 :          0 :         aP0 = aAttr.aCurPos;
     964                 :          0 :     if (bExtra)
     965                 :            :     {
     966                 :          0 :         pOS2MET->SeekRel(2);
     967                 :          0 :         ReadPoint( sal_False );
     968                 :          0 :         ReadPoint( sal_False );
     969                 :          0 :         *pOS2MET >> nLen;
     970                 :            :     }
     971                 :            :     else
     972                 :            :     {
     973                 :          0 :         if ( !bGivenPos )
     974                 :          0 :             nLen = nOrderLen;
     975                 :          0 :         else if ( bCoord32 )
     976                 :          0 :             nLen = nOrderLen-8;
     977                 :            :         else
     978                 :          0 :             nLen = nOrderLen-4;
     979                 :            :     }
     980                 :          0 :     pChr = new char[nLen+1];
     981                 :          0 :     for (i=0; i<nLen; i++)
     982                 :          0 :         *pOS2MET >> pChr[i];
     983                 :          0 :     pChr[nLen] = 0;
     984                 :          0 :     String aStr( (const sal_Char*)pChr, osl_getThreadTextEncoding() );
     985                 :          0 :     SetRasterOp(aAttr.eChrMix);
     986                 :          0 :     if (pVirDev->GetFont()!=aFont)
     987                 :          0 :         pVirDev->SetFont(aFont);
     988                 :          0 :     pVirDev->DrawText(aP0,aStr);
     989                 :            : 
     990                 :          0 :     aSize = Size( pVirDev->GetTextWidth(aStr), pVirDev->GetTextHeight() );
     991                 :          0 :     if ( aAttr.nChrAng == 0 )
     992                 :            :     {
     993                 :          0 :         aCalcBndRect.Union(Rectangle( Point(aP0.X(),aP0.Y()-aSize.Height()),
     994                 :          0 :                                       Size(aSize.Width(),aSize.Height()*2)));
     995                 :          0 :         if (bMove)
     996                 :          0 :             aAttr.aCurPos = Point( aP0.X() + aSize.Width(), aP0.Y());
     997                 :            :     }
     998                 :            :     else
     999                 :            :     {
    1000                 :          0 :         Polygon aDummyPoly(4);
    1001                 :            : 
    1002                 :          0 :         aDummyPoly.SetPoint( Point( aP0.X(), aP0.Y() ), 0);                                 // TOP LEFT
    1003                 :          0 :         aDummyPoly.SetPoint( Point( aP0.X(), aP0.Y() - aSize.Height() ), 1);                // BOTTOM LEFT
    1004                 :          0 :         aDummyPoly.SetPoint( Point( aP0.X() + aSize.Width(), aP0.Y() ), 2);                 // TOP RIGHT
    1005                 :          0 :         aDummyPoly.SetPoint( Point( aP0.X() + aSize.Width(), aP0.Y() - aSize.Height() ), 3);// BOTTOM RIGHT
    1006                 :          0 :         aDummyPoly.Rotate( aP0, (short)aAttr.nChrAng );
    1007                 :          0 :         if ( bMove )
    1008                 :          0 :             aAttr.aCurPos = aDummyPoly.GetPoint( 0 );
    1009                 :          0 :         aCalcBndRect.Union( Rectangle( aDummyPoly.GetPoint( 0 ), aDummyPoly.GetPoint( 3 ) ) );
    1010                 :          0 :         aCalcBndRect.Union( Rectangle( aDummyPoly.GetPoint( 1 ), aDummyPoly.GetPoint( 2 ) ) );
    1011                 :            :     }
    1012                 :          0 :     delete[] pChr;
    1013                 :          0 : }
    1014                 :            : 
    1015                 :          0 : void OS2METReader::ReadArc(sal_Bool bGivenPos)
    1016                 :            : {
    1017                 :          0 :     Point aP1, aP2, aP3;
    1018                 :            :     double x1,y1,x2,y2,x3,y3,p,q,cx,cy,ncx,ncy,r,rx,ry,w1,w3;
    1019                 :          0 :     if (bGivenPos) aP1=ReadPoint(); else aP1=aAttr.aCurPos;
    1020                 :          0 :     aP2=ReadPoint(); aP3=ReadPoint();
    1021                 :          0 :     aAttr.aCurPos=aP3;
    1022                 :          0 :     SetPen( aAttr.aLinCol, aAttr.nStrLinWidth, aAttr.eLinStyle );
    1023                 :          0 :     SetRasterOp(aAttr.eLinMix);
    1024                 :            :     // OK, gegeben sind 3 Punkte der Ellipse, und das Verhaeltnis
    1025                 :            :     // Breite zu Hoehe (als p zu q):
    1026                 :          0 :     x1=aP1.X(); y1=aP1.Y();
    1027                 :          0 :     x2=aP2.X(); y2=aP2.Y();
    1028                 :          0 :     x3=aP3.X(); y3=aP3.Y();
    1029                 :          0 :     p=aAttr.nArcP;q=aAttr.nArcQ;
    1030                 :            :     // Berechnet wird der Mittelpunkt cx,cy der Ellipse:
    1031                 :          0 :     ncy=2*p*p*((y3-y1)*(x2-x1)-(y1-y2)*(x1-x3));
    1032                 :          0 :     ncx=2*q*q*(x2-x1);
    1033                 :          0 :     if ( (ncx<0.001 && ncx>-0.001) || (ncy<0.001 && ncy>-0.001) ) {
    1034                 :            :         // Berechnung nicht moeglich, Punkte liegen auf einer Linie
    1035                 :          0 :         pVirDev->DrawLine(aP1,aP2);
    1036                 :          0 :         pVirDev->DrawLine(aP2,aP3);
    1037                 :          0 :         return;
    1038                 :            :     }
    1039                 :            :     cy=( q*q*((x3*x3-x1*x1)*(x2-x1)+(x2*x2-x1*x1)*(x1-x3)) +
    1040                 :          0 :          p*p*((y3*y3-y1*y1)*(x2-x1)+(y2*y2-y1*y1)*(x1-x3)) ) / ncy;
    1041                 :          0 :     cx=( q*q*(x2*x2-x1*x1)+p*p*(y2*y2-y1*y1)+cy*2*p*p*(y1-y2) ) / ncx;
    1042                 :            :     // now we still need the radius in x and y direction:
    1043                 :          0 :     r=sqrt(q*q*(x1-cx)*(x1-cx)+p*p*(y1-cy)*(y1-cy));
    1044                 :          0 :     rx=r/q; ry=r/p;
    1045                 :            :     // Jetzt stellt sich "nur noch" die Frage, wie Start- und Endpunkt
    1046                 :            :     // gewaehlt werden muessen, damit Punkt Nr. 2 innerhalb des
    1047                 :            :     // gezeichneten Bogens liegt:
    1048                 :          0 :     w1=fmod((atan2(x1-cx,y1-cy)-atan2(x2-cx,y2-cy)),6.28318530718); if (w1<0) w1+=6.28318530718;
    1049                 :          0 :     w3=fmod((atan2(x3-cx,y3-cy)-atan2(x2-cx,y2-cy)),6.28318530718); if (w3<0) w3+=6.28318530718;
    1050                 :          0 :     if (w3<w1) {
    1051                 :            :         pVirDev->DrawArc(Rectangle((long)(cx-rx),(long)(cy-ry),
    1052                 :          0 :                                    (long)(cx+rx),(long)(cy+ry)),aP1,aP3);
    1053                 :            :     }
    1054                 :            :     else {
    1055                 :            :         pVirDev->DrawArc(Rectangle((long)(cx-rx),(long)(cy-ry),
    1056                 :          0 :                                    (long)(cx+rx),(long)(cy+ry)),aP3,aP1);
    1057                 :            :     }
    1058                 :            : }
    1059                 :            : 
    1060                 :          0 : void OS2METReader::ReadFullArc(sal_Bool bGivenPos, sal_uInt16 nOrderSize)
    1061                 :            : {
    1062                 :          0 :     Point aCenter;
    1063                 :            :     long nP,nQ,nR,nS;
    1064                 :          0 :     Rectangle aRect;
    1065                 :            :     sal_uInt32 nMul; sal_uInt16 nMulS;
    1066                 :            : 
    1067                 :          0 :     if (bGivenPos) {
    1068                 :          0 :         aCenter=ReadPoint();
    1069                 :          0 :         if (bCoord32) nOrderSize-=8; else nOrderSize-=4;
    1070                 :            :     }
    1071                 :          0 :     else aCenter=aAttr.aCurPos;
    1072                 :            : 
    1073                 :          0 :     nP=aAttr.nArcP; nQ=aAttr.nArcQ; nR=aAttr.nArcR; nS=aAttr.nArcS;
    1074                 :          0 :     if (nP<0) nP=-nP;
    1075                 :          0 :     if (nQ<0) nQ=-nQ;
    1076                 :          0 :     if (nR<0) nR=-nR;
    1077                 :          0 :     if (nS<0) nS=-nS;
    1078                 :          0 :     if (nOrderSize>=4) *pOS2MET >> nMul;
    1079                 :          0 :     else { *pOS2MET >> nMulS; nMul=((sal_uLong)nMulS)<<8; }
    1080                 :          0 :     if (nMul!=0x00010000) {
    1081                 :          0 :         nP=(nP*nMul)>>16;
    1082                 :          0 :         nQ=(nQ*nMul)>>16;
    1083                 :          0 :         nR=(nR*nMul)>>16;
    1084                 :          0 :         nS=(nS*nMul)>>16;
    1085                 :            :     }
    1086                 :            : 
    1087                 :          0 :     aRect=Rectangle(aCenter.X()-nP,aCenter.Y()-nQ,
    1088                 :          0 :                     aCenter.X()+nP,aCenter.Y()+nQ);
    1089                 :          0 :     aCalcBndRect.Union(aRect);
    1090                 :            : 
    1091                 :          0 :     if (pAreaStack!=NULL) {
    1092                 :          0 :         ChangeBrush(aAttr.aPatCol,aAttr.aPatBgCol,aAttr.bFill);
    1093                 :          0 :         SetRasterOp(aAttr.ePatMix);
    1094                 :          0 :         if ((pAreaStack->nFlags&0x40)!=0)
    1095                 :          0 :             SetPen( aAttr.aLinCol, aAttr.nStrLinWidth, aAttr.eLinStyle );
    1096                 :            :         else
    1097                 :          0 :             SetPen( COL_TRANSPARENT, 0, PEN_NULL );
    1098                 :            :     }
    1099                 :            :     else
    1100                 :            :     {
    1101                 :          0 :         SetPen( aAttr.aLinCol, aAttr.nStrLinWidth, aAttr.eLinStyle );
    1102                 :          0 :         ChangeBrush(Color( COL_TRANSPARENT ),Color( COL_TRANSPARENT ),sal_False);
    1103                 :          0 :         SetRasterOp(aAttr.eLinMix);
    1104                 :            :     }
    1105                 :          0 :     pVirDev->DrawEllipse(aRect);
    1106                 :          0 : }
    1107                 :            : 
    1108                 :          0 : void OS2METReader::ReadPartialArc(sal_Bool bGivenPos, sal_uInt16 nOrderSize)
    1109                 :            : {
    1110                 :          0 :     Point aP0, aCenter,aPStart,aPEnd;
    1111                 :            :     sal_Int32 nP,nQ,nR,nS,nStart, nSweep;
    1112                 :          0 :     Rectangle aRect;
    1113                 :            :     sal_uInt32 nMul; sal_uInt16 nMulS;
    1114                 :            :     double fStart, fEnd;
    1115                 :            : 
    1116                 :          0 :     if (bGivenPos) {
    1117                 :          0 :         aP0=ReadPoint();
    1118                 :          0 :         if (bCoord32) nOrderSize-=8; else nOrderSize-=4;
    1119                 :            :     }
    1120                 :          0 :     else aP0=aAttr.aCurPos;
    1121                 :          0 :     aCenter=ReadPoint();
    1122                 :            : 
    1123                 :          0 :     nP=aAttr.nArcP; nQ=aAttr.nArcQ; nR=aAttr.nArcR; nS=aAttr.nArcS;
    1124                 :          0 :     if (nP<0) nP=-nP;
    1125                 :          0 :     if (nQ<0) nQ=-nQ;
    1126                 :          0 :     if (nR<0) nR=-nR;
    1127                 :          0 :     if (nS<0) nS=-nS;
    1128                 :          0 :     if (nOrderSize>=12) *pOS2MET >> nMul;
    1129                 :          0 :     else { *pOS2MET >> nMulS; nMul=((sal_uLong)nMulS)<<8; }
    1130                 :          0 :     if (nMul!=0x00010000) {
    1131                 :          0 :         nP=(nP*nMul)>>16;
    1132                 :          0 :         nQ=(nQ*nMul)>>16;
    1133                 :          0 :         nR=(nR*nMul)>>16;
    1134                 :          0 :         nS=(nS*nMul)>>16;
    1135                 :            :     }
    1136                 :            : 
    1137                 :          0 :     *pOS2MET >> nStart >> nSweep;
    1138                 :          0 :     fStart=((double)nStart)/65536.0/180.0*3.14159265359;
    1139                 :          0 :     fEnd=fStart+((double)nSweep)/65536.0/180.0*3.14159265359;
    1140                 :          0 :     aPStart=Point(aCenter.X()+(sal_Int32)( cos(fStart)*nP),
    1141                 :          0 :                   aCenter.Y()+(sal_Int32)(-sin(fStart)*nQ));
    1142                 :          0 :     aPEnd=  Point(aCenter.X()+(sal_Int32)( cos(fEnd)*nP),
    1143                 :          0 :                   aCenter.Y()+(sal_Int32)(-sin(fEnd)*nQ));
    1144                 :            : 
    1145                 :          0 :     aRect=Rectangle(aCenter.X()-nP,aCenter.Y()-nQ,
    1146                 :          0 :                     aCenter.X()+nP,aCenter.Y()+nQ);
    1147                 :          0 :     aCalcBndRect.Union(aRect);
    1148                 :            : 
    1149                 :          0 :     SetPen( aAttr.aLinCol, aAttr.nStrLinWidth, aAttr.eLinStyle );
    1150                 :          0 :     SetRasterOp(aAttr.eLinMix);
    1151                 :            : 
    1152                 :          0 :     pVirDev->DrawLine(aP0,aPStart);
    1153                 :          0 :     pVirDev->DrawArc(aRect,aPStart,aPEnd);
    1154                 :          0 :     aAttr.aCurPos=aPEnd;
    1155                 :          0 : }
    1156                 :            : 
    1157                 :          0 : void OS2METReader::ReadPolygons()
    1158                 :            : {
    1159                 :            :     sal_uInt32 i,j,nNumPolys, nNumPoints;
    1160                 :          0 :     PolyPolygon aPolyPoly;
    1161                 :          0 :     Polygon aPoly;
    1162                 :          0 :     Point aPoint;
    1163                 :            :     sal_uInt8 nFlags;
    1164                 :            : 
    1165                 :          0 :     *pOS2MET >> nFlags >> nNumPolys;
    1166                 :          0 :     for (i=0; i<nNumPolys; i++) {
    1167                 :          0 :         *pOS2MET >> nNumPoints;
    1168                 :          0 :         if (i==0) nNumPoints++;
    1169                 :          0 :         aPoly.SetSize((short)nNumPoints);
    1170                 :          0 :         for (j=0; j<nNumPoints; j++) {
    1171                 :          0 :             if (i==0 && j==0) aPoint=aAttr.aCurPos;
    1172                 :          0 :             else aPoint=ReadPoint();
    1173                 :          0 :             aPoly.SetPoint(aPoint,(short)j);
    1174                 :          0 :             if (i==nNumPolys-1 && j==nNumPoints-1) aAttr.aCurPos=aPoint;
    1175                 :            :         }
    1176                 :          0 :         aPolyPoly.Insert(aPoly);
    1177                 :            :     }
    1178                 :            : 
    1179                 :          0 :     ChangeBrush(aAttr.aPatCol,aAttr.aPatBgCol,aAttr.bFill);
    1180                 :          0 :     SetRasterOp(aAttr.ePatMix);
    1181                 :          0 :     if ((nFlags&0x01)!=0)
    1182                 :          0 :         SetPen( aAttr.aLinCol, aAttr.nStrLinWidth, aAttr.eLinStyle );
    1183                 :            :     else
    1184                 :          0 :         SetPen( COL_TRANSPARENT, 0, PEN_NULL );
    1185                 :          0 :     DrawPolyPolygon( aPolyPoly );
    1186                 :          0 : }
    1187                 :            : 
    1188                 :          0 : void OS2METReader::ReadBezier(sal_Bool bGivenPos, sal_uInt16 nOrderLen)
    1189                 :            : {
    1190                 :          0 :     sal_uInt16 i, nNumPoints = nOrderLen / ( bCoord32 ? 8 : 4 );
    1191                 :            : 
    1192                 :          0 :     if( !bGivenPos )
    1193                 :          0 :         nNumPoints++;
    1194                 :            : 
    1195                 :          0 :     if( !nNumPoints )
    1196                 :          0 :         return;
    1197                 :            : 
    1198                 :          0 :     Polygon aPolygon( nNumPoints );
    1199                 :            : 
    1200                 :          0 :     for( i=0; i < nNumPoints; i++ )
    1201                 :            :     {
    1202                 :          0 :         if( i==0 && !bGivenPos)
    1203                 :          0 :             aPolygon.SetPoint( aAttr.aCurPos, i );
    1204                 :            :         else
    1205                 :          0 :             aPolygon.SetPoint( ReadPoint(), i );
    1206                 :            :     }
    1207                 :            : 
    1208                 :          0 :     if( !( nNumPoints % 4 ) )
    1209                 :            :     {
    1210                 :            :         // create bezier polygon
    1211                 :          0 :         const sal_uInt16    nSegPoints = 25;
    1212                 :          0 :         const sal_uInt16    nSegments = aPolygon.GetSize() >> 2;
    1213                 :          0 :         Polygon         aBezPoly( nSegments * nSegPoints );
    1214                 :            : 
    1215                 :            :         sal_uInt16 nSeg, nBezPos, nStartPos;
    1216                 :          0 :         for( nSeg = 0, nBezPos = 0, nStartPos = 0; nSeg < nSegments; nSeg++, nStartPos += 4 )
    1217                 :            :         {
    1218                 :          0 :             const Polygon aSegPoly( aPolygon[ nStartPos ], aPolygon[ nStartPos + 1 ],
    1219                 :          0 :                                     aPolygon[ nStartPos + 3 ], aPolygon[ nStartPos + 2 ],
    1220                 :          0 :                                     nSegPoints );
    1221                 :            : 
    1222                 :          0 :             for( sal_uInt16 nSegPos = 0; nSegPos < nSegPoints; )
    1223                 :          0 :                 aBezPoly[ nBezPos++ ] = aSegPoly[ nSegPos++ ];
    1224                 :          0 :         }
    1225                 :            : 
    1226                 :          0 :         nNumPoints = nBezPos;
    1227                 :            : 
    1228                 :          0 :         if( nNumPoints != aBezPoly.GetSize() )
    1229                 :          0 :             aBezPoly.SetSize( nNumPoints );
    1230                 :            : 
    1231                 :          0 :         aPolygon = aBezPoly;
    1232                 :            :     }
    1233                 :            : 
    1234                 :          0 :     aAttr.aCurPos = aPolygon[ nNumPoints - 1 ];
    1235                 :            : 
    1236                 :          0 :     if (pAreaStack!=NULL)
    1237                 :          0 :         AddPointsToArea(aPolygon);
    1238                 :          0 :     else if (pPathStack!=NULL)
    1239                 :          0 :         AddPointsToPath(aPolygon);
    1240                 :            :     else
    1241                 :            :     {
    1242                 :          0 :         SetPen( aAttr.aLinCol, aAttr.nStrLinWidth, aAttr.eLinStyle );
    1243                 :          0 :         SetRasterOp(aAttr.eLinMix);
    1244                 :          0 :         DrawPolyLine( aPolygon );
    1245                 :          0 :     }
    1246                 :            : }
    1247                 :            : 
    1248                 :          0 : void OS2METReader::ReadFillet(sal_Bool bGivenPos, sal_uInt16 nOrderLen)
    1249                 :            : {
    1250                 :            :     sal_uInt16 i,nNumPoints;
    1251                 :            : 
    1252                 :          0 :     if (bCoord32) nNumPoints=nOrderLen/8; else nNumPoints=nOrderLen/4;
    1253                 :          0 :     if (!bGivenPos) nNumPoints++;
    1254                 :          0 :     if (nNumPoints==0) return;
    1255                 :          0 :     Polygon aPolygon(nNumPoints);
    1256                 :          0 :     for (i=0; i<nNumPoints; i++) {
    1257                 :          0 :         if (i==0 && !bGivenPos) aPolygon.SetPoint(aAttr.aCurPos,i);
    1258                 :          0 :         else aPolygon.SetPoint(ReadPoint(),i);
    1259                 :            :     }
    1260                 :          0 :     aAttr.aCurPos=aPolygon.GetPoint(nNumPoints-1);
    1261                 :          0 :     if (pAreaStack!=NULL) AddPointsToArea(aPolygon);
    1262                 :          0 :     else if (pPathStack!=NULL) AddPointsToPath(aPolygon);
    1263                 :            :     else {
    1264                 :          0 :         SetPen( aAttr.aLinCol, aAttr.nStrLinWidth, aAttr.eLinStyle );
    1265                 :          0 :         SetRasterOp(aAttr.eLinMix);
    1266                 :          0 :         DrawPolyLine( aPolygon );
    1267                 :          0 :     }
    1268                 :            : }
    1269                 :            : 
    1270                 :          0 : void OS2METReader::ReadFilletSharp(sal_Bool bGivenPos, sal_uInt16 nOrderLen)
    1271                 :            : {
    1272                 :            :     sal_uInt16 i,nNumPoints;
    1273                 :            : 
    1274                 :          0 :     if (bGivenPos) {
    1275                 :          0 :         aAttr.aCurPos=ReadPoint();
    1276                 :          0 :         if (bCoord32) nOrderLen-=8; else nOrderLen-=4;
    1277                 :            :     }
    1278                 :          0 :     if (bCoord32) nNumPoints=1+nOrderLen/10;
    1279                 :          0 :     else nNumPoints=1+nOrderLen/6;
    1280                 :          0 :     Polygon aPolygon(nNumPoints);
    1281                 :          0 :     aPolygon.SetPoint(aAttr.aCurPos,0);
    1282                 :          0 :     for (i=1; i<nNumPoints; i++) aPolygon.SetPoint(ReadPoint(),i);
    1283                 :          0 :     aAttr.aCurPos=aPolygon.GetPoint(nNumPoints-1);
    1284                 :          0 :     if (pAreaStack!=NULL) AddPointsToArea(aPolygon);
    1285                 :          0 :     else if (pPathStack!=NULL) AddPointsToPath(aPolygon);
    1286                 :            :     else
    1287                 :            :     {
    1288                 :          0 :         SetPen( aAttr.aLinCol, aAttr.nStrLinWidth, aAttr.eLinStyle );
    1289                 :          0 :         SetRasterOp(aAttr.eLinMix);
    1290                 :          0 :         DrawPolyLine( aPolygon );
    1291                 :          0 :     }
    1292                 :          0 : }
    1293                 :            : 
    1294                 :          0 : void OS2METReader::ReadMarker(sal_Bool bGivenPos, sal_uInt16 nOrderLen)
    1295                 :            : {
    1296                 :            :     sal_uInt16 i,nNumPoints;
    1297                 :            :     long x,y;
    1298                 :            : 
    1299                 :          0 :     SetPen( aAttr.aMrkCol );
    1300                 :          0 :     SetRasterOp(aAttr.eMrkMix);
    1301                 :          0 :     if (aAttr.nMrkSymbol>=5 && aAttr.nMrkSymbol<=9)
    1302                 :            :     {
    1303                 :          0 :         ChangeBrush(aAttr.aMrkCol,aAttr.aMrkCol,sal_True);
    1304                 :            :     }
    1305                 :            :     else
    1306                 :            :     {
    1307                 :          0 :         ChangeBrush(Color(COL_TRANSPARENT),Color(COL_TRANSPARENT),sal_False);
    1308                 :            :     }
    1309                 :          0 :     if (bCoord32) nNumPoints=nOrderLen/8; else nNumPoints=nOrderLen/4;
    1310                 :          0 :     if (!bGivenPos) nNumPoints++;
    1311                 :          0 :     for (i=0; i<nNumPoints; i++) {
    1312                 :          0 :         if (i!=0 || bGivenPos) aAttr.aCurPos=ReadPoint();
    1313                 :          0 :         x=aAttr.aCurPos.X(); y=aAttr.aCurPos.Y();
    1314                 :          0 :         aCalcBndRect.Union(Rectangle(x-5,y-5,x+5,y+5));
    1315                 :          0 :         switch (aAttr.nMrkSymbol) {
    1316                 :            :             case  2:   // PLUS
    1317                 :          0 :                 pVirDev->DrawLine(Point(x-4,y),Point(x+4,y));
    1318                 :          0 :                 pVirDev->DrawLine(Point(x,y-4),Point(x,y+4));
    1319                 :          0 :                 break;
    1320                 :            :             case  3:   // DIAMOND
    1321                 :            :             case  7: { // SOLIDDIAMOND
    1322                 :          0 :                 Polygon aPoly(4);
    1323                 :          0 :                 aPoly.SetPoint(Point(x,y+4),0);
    1324                 :          0 :                 aPoly.SetPoint(Point(x+4,y),1);
    1325                 :          0 :                 aPoly.SetPoint(Point(x,y-4),2);
    1326                 :          0 :                 aPoly.SetPoint(Point(x-4,y),3);
    1327                 :          0 :                 pVirDev->DrawPolygon(aPoly);
    1328                 :          0 :                 break;
    1329                 :            :             }
    1330                 :            :             case  4:   // SQARE
    1331                 :            :             case  8: { // SOLIDSUARE
    1332                 :          0 :                 Polygon aPoly(4);
    1333                 :          0 :                 aPoly.SetPoint(Point(x+4,y+4),0);
    1334                 :          0 :                 aPoly.SetPoint(Point(x+4,y-4),1);
    1335                 :          0 :                 aPoly.SetPoint(Point(x-4,y-4),2);
    1336                 :          0 :                 aPoly.SetPoint(Point(x-4,y+4),3);
    1337                 :          0 :                 pVirDev->DrawPolygon(aPoly);
    1338                 :          0 :                 break;
    1339                 :            :             }
    1340                 :            :             case  5: { // SIXPOINTSTAR
    1341                 :          0 :                 Polygon aPoly(12);
    1342                 :          0 :                 aPoly.SetPoint(Point(x  ,y-4),0);
    1343                 :          0 :                 aPoly.SetPoint(Point(x+2,y-2),1);
    1344                 :          0 :                 aPoly.SetPoint(Point(x+4,y-2),2);
    1345                 :          0 :                 aPoly.SetPoint(Point(x+2,y  ),3);
    1346                 :          0 :                 aPoly.SetPoint(Point(x+4,y+2),4);
    1347                 :          0 :                 aPoly.SetPoint(Point(x+2,y+2),5);
    1348                 :          0 :                 aPoly.SetPoint(Point(x  ,y+4),6);
    1349                 :          0 :                 aPoly.SetPoint(Point(x-2,y+2),7);
    1350                 :          0 :                 aPoly.SetPoint(Point(x-4,y+2),8);
    1351                 :          0 :                 aPoly.SetPoint(Point(x-2,y  ),9);
    1352                 :          0 :                 aPoly.SetPoint(Point(x-4,y-2),10);
    1353                 :          0 :                 aPoly.SetPoint(Point(x-2,y-2),11);
    1354                 :          0 :                 pVirDev->DrawPolygon(aPoly);
    1355                 :          0 :                 break;
    1356                 :            :             }
    1357                 :            :             case  6: { // EIGHTPOINTSTAR
    1358                 :          0 :                 Polygon aPoly(16);
    1359                 :          0 :                 aPoly.SetPoint(Point(x  ,y-4),0);
    1360                 :          0 :                 aPoly.SetPoint(Point(x+1,y-2),1);
    1361                 :          0 :                 aPoly.SetPoint(Point(x+3,y-3),2);
    1362                 :          0 :                 aPoly.SetPoint(Point(x+2,y-1),3);
    1363                 :          0 :                 aPoly.SetPoint(Point(x+4,y  ),4);
    1364                 :          0 :                 aPoly.SetPoint(Point(x+2,y+1),5);
    1365                 :          0 :                 aPoly.SetPoint(Point(x+3,y+3),6);
    1366                 :          0 :                 aPoly.SetPoint(Point(x+1,y+2),7);
    1367                 :          0 :                 aPoly.SetPoint(Point(x  ,y+4),8);
    1368                 :          0 :                 aPoly.SetPoint(Point(x-1,y+2),9);
    1369                 :          0 :                 aPoly.SetPoint(Point(x-3,y+3),10);
    1370                 :          0 :                 aPoly.SetPoint(Point(x-2,y+1),11);
    1371                 :          0 :                 aPoly.SetPoint(Point(x-4,y  ),12);
    1372                 :          0 :                 aPoly.SetPoint(Point(x-2,y-1),13);
    1373                 :          0 :                 aPoly.SetPoint(Point(x-3,y-3),14);
    1374                 :          0 :                 aPoly.SetPoint(Point(x-1,y-2),15);
    1375                 :          0 :                 pVirDev->DrawPolygon(aPoly);
    1376                 :          0 :                 break;
    1377                 :            :             }
    1378                 :            :             case  9:   // DOT
    1379                 :          0 :                 pVirDev->DrawEllipse(Rectangle(x-1,y-1,x+1,y+1));
    1380                 :          0 :                 break;
    1381                 :            :             case 10:   // SMALLCIRCLE
    1382                 :          0 :                 pVirDev->DrawEllipse(Rectangle(x-2,y-2,x+2,y+2));
    1383                 :          0 :                 break;
    1384                 :            :             case 64:   // BLANK
    1385                 :          0 :                 break;
    1386                 :            :             default:   // (=1) CROSS
    1387                 :          0 :                 pVirDev->DrawLine(Point(x-4,y-4),Point(x+4,y+4));
    1388                 :          0 :                 pVirDev->DrawLine(Point(x-4,y+4),Point(x+4,y-4));
    1389                 :          0 :                 break;
    1390                 :            :         }
    1391                 :            :     }
    1392                 :          0 : }
    1393                 :            : 
    1394                 :          0 : void OS2METReader::ReadOrder(sal_uInt16 nOrderID, sal_uInt16 nOrderLen)
    1395                 :            : {
    1396                 :          0 :     switch (nOrderID) {
    1397                 :            : 
    1398                 :          0 :         case GOrdGivArc: ReadArc(sal_True); break;
    1399                 :          0 :         case GOrdCurArc: ReadArc(sal_False); break;
    1400                 :            : 
    1401                 :          0 :         case GOrdGivBzr: ReadBezier(sal_True,nOrderLen); break;
    1402                 :          0 :         case GOrdCurBzr: ReadBezier(sal_False,nOrderLen); break;
    1403                 :            : 
    1404                 :          0 :         case GOrdGivBox: ReadBox(sal_True); break;
    1405                 :          0 :         case GOrdCurBox: ReadBox(sal_False); break;
    1406                 :            : 
    1407                 :          0 :         case GOrdGivFil: ReadFillet(sal_True,nOrderLen); break;
    1408                 :          0 :         case GOrdCurFil: ReadFillet(sal_False,nOrderLen); break;
    1409                 :            : 
    1410                 :          0 :         case GOrdGivCrc: ReadFullArc(sal_True,nOrderLen); break;
    1411                 :          0 :         case GOrdCurCrc: ReadFullArc(sal_False,nOrderLen); break;
    1412                 :            : 
    1413                 :          0 :         case GOrdGivLin: ReadLine(sal_True, nOrderLen); break;
    1414                 :          0 :         case GOrdCurLin: ReadLine(sal_False, nOrderLen); break;
    1415                 :            : 
    1416                 :          0 :         case GOrdGivMrk: ReadMarker(sal_True, nOrderLen); break;
    1417                 :          0 :         case GOrdCurMrk: ReadMarker(sal_False, nOrderLen); break;
    1418                 :            : 
    1419                 :          0 :         case GOrdGivArP: ReadPartialArc(sal_True,nOrderLen); break;
    1420                 :          0 :         case GOrdCurArP: ReadPartialArc(sal_False,nOrderLen); break;
    1421                 :            : 
    1422                 :          0 :         case GOrdGivRLn: ReadRelLine(sal_True,nOrderLen); break;
    1423                 :          0 :         case GOrdCurRLn: ReadRelLine(sal_False,nOrderLen); break;
    1424                 :            : 
    1425                 :          0 :         case GOrdGivSFl: ReadFilletSharp(sal_True,nOrderLen); break;
    1426                 :          0 :         case GOrdCurSFl: ReadFilletSharp(sal_False,nOrderLen); break;
    1427                 :            : 
    1428                 :          0 :         case GOrdGivStM: ReadChrStr(sal_True , sal_True , sal_False, nOrderLen); break;
    1429                 :          0 :         case GOrdCurStM: ReadChrStr(sal_False, sal_True , sal_False, nOrderLen); break;
    1430                 :          0 :         case GOrdGivStr: ReadChrStr(sal_True , sal_False, sal_False, nOrderLen); break;
    1431                 :          0 :         case GOrdCurStr: ReadChrStr(sal_False, sal_False, sal_False, nOrderLen); break;
    1432                 :          0 :         case GOrdGivStx: ReadChrStr(sal_True , sal_False, sal_True , nOrderLen); break;
    1433                 :          0 :         case GOrdCurStx: ReadChrStr(sal_False, sal_False, sal_True , nOrderLen); break;
    1434                 :            : 
    1435                 :            :         case GOrdGivImg: OOODEBUG("GOrdGivImg",0);
    1436                 :          0 :             break;
    1437                 :            :         case GOrdCurImg: OOODEBUG("GOrdCurImg",0);
    1438                 :          0 :             break;
    1439                 :            :         case GOrdImgDat: OOODEBUG("GOrdImgDat",0);
    1440                 :          0 :             break;
    1441                 :            :         case GOrdEndImg: OOODEBUG("GOrdEndImg",0);
    1442                 :          0 :             break;
    1443                 :            : 
    1444                 :            :         case GOrdBegAra: {
    1445                 :          0 :             OSArea * p=new OSArea;
    1446                 :          0 :             p->bClosed=sal_False;
    1447                 :          0 :             p->pSucc=pAreaStack; pAreaStack=p;
    1448                 :          0 :             *pOS2MET >> (p->nFlags);
    1449                 :          0 :             p->aCol=aAttr.aPatCol;
    1450                 :          0 :             p->aBgCol=aAttr.aPatBgCol;
    1451                 :          0 :             p->eMix=aAttr.ePatMix;
    1452                 :          0 :             p->eBgMix=aAttr.ePatBgMix;
    1453                 :          0 :             p->bFill=aAttr.bFill;
    1454                 :          0 :             break;
    1455                 :            :         }
    1456                 :            :         case GOrdEndAra:
    1457                 :            :         {
    1458                 :          0 :             OSArea * p=pAreaStack;
    1459                 :          0 :             if ( p )
    1460                 :            :             {
    1461                 :          0 :                 pAreaStack = p->pSucc;
    1462                 :          0 :                 if ( pPathStack )
    1463                 :            :                 {
    1464                 :          0 :                     for ( sal_uInt16 i=0; i<p->aPPoly.Count(); i++ )
    1465                 :            :                     {
    1466                 :          0 :                         AddPointsToPath( p->aPPoly.GetObject( i ) );
    1467                 :          0 :                         CloseFigure();
    1468                 :            :                     }
    1469                 :            :                 }
    1470                 :            :                 else
    1471                 :            :                 {
    1472                 :          0 :                     if ( ( p->nFlags & 0x40 ) == 0 )
    1473                 :          0 :                         SetPen( COL_TRANSPARENT, 0, PEN_NULL );
    1474                 :            :                     else
    1475                 :          0 :                         SetPen( aAttr.aLinCol, aAttr.nStrLinWidth, aAttr.eLinStyle );
    1476                 :            : 
    1477                 :          0 :                     ChangeBrush(p->aCol,p->aBgCol,p->bFill);
    1478                 :          0 :                     SetRasterOp(p->eMix);
    1479                 :          0 :                     DrawPolyPolygon( p->aPPoly );
    1480                 :            :                 }
    1481                 :          0 :                 delete p;
    1482                 :            :             }
    1483                 :            :         }
    1484                 :          0 :         break;
    1485                 :            : 
    1486                 :            :         case GOrdBegElm:// OOODEBUG("GOrdBegElm",0);
    1487                 :          0 :             break;
    1488                 :            :         case GOrdEndElm:// OOODEBUG("GOrdEndElm",0);
    1489                 :          0 :             break;
    1490                 :            : 
    1491                 :            :         case GOrdBegPth: {
    1492                 :          0 :             OSPath * p=new OSPath;
    1493                 :          0 :             p->pSucc=pPathStack; pPathStack=p;
    1494                 :          0 :             pOS2MET->SeekRel(2);
    1495                 :          0 :             *pOS2MET >> p->nID;
    1496                 :          0 :             p->bClosed=sal_False;
    1497                 :          0 :             p->bStroke=sal_False;
    1498                 :          0 :             break;
    1499                 :            :         }
    1500                 :            :         case GOrdEndPth: {
    1501                 :            :             OSPath * p, * pprev, * psucc;
    1502                 :          0 :             if (pPathStack==NULL) break;
    1503                 :          0 :             p=pPathList; pprev=NULL;
    1504                 :          0 :             while (p!=NULL) {
    1505                 :          0 :                 psucc=p->pSucc;
    1506                 :          0 :                 if (p->nID==pPathStack->nID) {
    1507                 :          0 :                     if (pprev==NULL) pPathList=psucc; else pprev->pSucc=psucc;
    1508                 :          0 :                     delete p;
    1509                 :            :                 }
    1510                 :          0 :                 else pprev=p;
    1511                 :          0 :                 p=psucc;
    1512                 :            :             }
    1513                 :          0 :             p=pPathStack;
    1514                 :          0 :             pPathStack=p->pSucc;
    1515                 :          0 :             p->pSucc=pPathList; pPathList=p;
    1516                 :          0 :             break;
    1517                 :            :         }
    1518                 :            :         case GOrdFilPth:
    1519                 :            :         {
    1520                 :            :             sal_uInt32 nID;
    1521                 :            :             sal_uInt16  nDummy;
    1522                 :          0 :             OSPath* p = pPathList;
    1523                 :            : 
    1524                 :          0 :             *pOS2MET >> nDummy
    1525                 :          0 :                      >> nID;
    1526                 :            : 
    1527                 :          0 :             if ( ! ( nDummy & 0x20 ) )  // #30933# i do not know the exact meaning of this bit,
    1528                 :            :             {                           // but if set it seems to be better not to fill this path
    1529                 :          0 :                 while( p && p->nID != nID )
    1530                 :          0 :                     p = p->pSucc;
    1531                 :            : 
    1532                 :          0 :                 if( p )
    1533                 :            :                 {
    1534                 :          0 :                     if( p->bStroke )
    1535                 :            :                     {
    1536                 :          0 :                         SetPen( aAttr.aPatCol, aAttr.nStrLinWidth, PEN_SOLID );
    1537                 :          0 :                         ChangeBrush(Color(COL_TRANSPARENT),Color(COL_TRANSPARENT),sal_False);
    1538                 :          0 :                         SetRasterOp( aAttr.ePatMix );
    1539                 :          0 :                         if ( IsLineInfo() )
    1540                 :            :                         {
    1541                 :          0 :                             for ( sal_uInt16 i = 0; i < p->aPPoly.Count(); i++ )
    1542                 :          0 :                                 pVirDev->DrawPolyLine( p->aPPoly.GetObject( i ), aLineInfo );
    1543                 :            :                         }
    1544                 :            :                         else
    1545                 :          0 :                             pVirDev->DrawPolyPolygon( p->aPPoly );
    1546                 :            :                     }
    1547                 :            :                     else
    1548                 :            :                     {
    1549                 :          0 :                         SetPen( COL_TRANSPARENT, 0, PEN_NULL );
    1550                 :          0 :                         ChangeBrush( aAttr.aPatCol, aAttr.aPatBgCol, aAttr.bFill );
    1551                 :          0 :                         SetRasterOp( aAttr.ePatMix );
    1552                 :          0 :                         pVirDev->DrawPolyPolygon( p->aPPoly );
    1553                 :            :                     }
    1554                 :            :                 }
    1555                 :            :             }
    1556                 :            :         }
    1557                 :          0 :         break;
    1558                 :            : 
    1559                 :            :         case GOrdModPth:
    1560                 :            :         {
    1561                 :          0 :             OSPath* p = pPathList;
    1562                 :            : 
    1563                 :          0 :             while( p && p->nID != 1 )
    1564                 :          0 :                 p = p->pSucc;
    1565                 :            : 
    1566                 :          0 :             if( p )
    1567                 :          0 :                 p->bStroke = sal_True;
    1568                 :            :         }
    1569                 :          0 :         break;
    1570                 :            : 
    1571                 :            :         case GOrdOutPth:
    1572                 :            :         {
    1573                 :            :             sal_uInt32 nID;
    1574                 :            :             sal_uInt16  i,nC;
    1575                 :          0 :             OSPath* p=pPathList;
    1576                 :          0 :             pOS2MET->SeekRel(2);
    1577                 :          0 :             *pOS2MET >> nID;
    1578                 :          0 :             while (p!=NULL && p->nID!=nID)
    1579                 :          0 :                 p=p->pSucc;
    1580                 :            : 
    1581                 :          0 :             if( p!=NULL )
    1582                 :            :             {
    1583                 :          0 :                 SetPen( aAttr.aLinCol, aAttr.nStrLinWidth, aAttr.eLinStyle );
    1584                 :          0 :                 SetRasterOp(aAttr.eLinMix);
    1585                 :          0 :                 ChangeBrush(Color(COL_TRANSPARENT),Color(COL_TRANSPARENT),sal_False);
    1586                 :          0 :                 nC=p->aPPoly.Count();
    1587                 :          0 :                 for (i=0; i<nC; i++)
    1588                 :            :                 {
    1589                 :          0 :                     if (i+1<nC || p->bClosed==sal_True)
    1590                 :          0 :                         DrawPolygon( p->aPPoly.GetObject( i ) );
    1591                 :            :                     else
    1592                 :          0 :                         DrawPolyLine( p->aPPoly.GetObject( i ) );
    1593                 :            :                 }
    1594                 :            :             }
    1595                 :            :             break;
    1596                 :            :         }
    1597                 :            :         case GOrdSClPth: {  OOODEBUG("GOrdSClPth",0);
    1598                 :            :             sal_uInt32 nID;
    1599                 :          0 :             OSPath * p=pPathList;
    1600                 :          0 :             pOS2MET->SeekRel(2);
    1601                 :          0 :             *pOS2MET >> nID;
    1602                 :          0 :             if (nID==0) p=NULL;
    1603                 :          0 :             while (p!=NULL && p->nID!=nID) p=p->pSucc;
    1604                 :          0 :             if (p!=NULL) pVirDev->SetClipRegion(Region(p->aPPoly));
    1605                 :          0 :             else pVirDev->SetClipRegion();
    1606                 :            :             break;
    1607                 :            :         }
    1608                 :            :         case GOrdNopNop:
    1609                 :          0 :             break;
    1610                 :            :         case GOrdRemark: //OOODEBUG("GOrdRemark",0);
    1611                 :          0 :             break;
    1612                 :            :         case GOrdSegLab: OOODEBUG("GOrdSegLab",0);
    1613                 :          0 :             break;
    1614                 :            : 
    1615                 :          0 :         case GOrdBitBlt: ReadBitBlt(); break;
    1616                 :            : 
    1617                 :            :         case GOrdCalSeg: OOODEBUG("GOrdCalSeg",0);
    1618                 :          0 :             break;
    1619                 :            :         case GOrdSSgBnd: OOODEBUG("GOrdSSgBnd",0);
    1620                 :          0 :             break;
    1621                 :            :         case GOrdSegChr: OOODEBUG("GOrdSegChr",0);
    1622                 :          0 :             break;
    1623                 :            :         case GOrdCloFig:
    1624                 :          0 :             CloseFigure();
    1625                 :          0 :             break;
    1626                 :            :         case GOrdEndSym: OOODEBUG("GOrdEndSym",0);
    1627                 :          0 :             break;
    1628                 :            :         case GOrdEndPlg: OOODEBUG("GOrdEndPlg",0);
    1629                 :          0 :             break;
    1630                 :            :         case GOrdEscape: OOODEBUG("GOrdEscape",0);
    1631                 :          0 :             break;
    1632                 :            :         case GOrdExtEsc: OOODEBUG("GOrdExtEsc",0);
    1633                 :          0 :             break;
    1634                 :            : 
    1635                 :          0 :         case GOrdPolygn: ReadPolygons(); break;
    1636                 :            : 
    1637                 :          0 :         case GOrdStkPop: PopAttr(); break;
    1638                 :            : 
    1639                 :          0 :         case GOrdPIvAtr: PushAttr(nOrderID);
    1640                 :            :         case GOrdSIvAtr: {
    1641                 :            :             sal_uInt8 nA, nP, nFlags, nMix;
    1642                 :            :             sal_uLong nVal;
    1643                 :          0 :             Color aCol;
    1644                 :            :             RasterOp eROP;
    1645                 :          0 :             *pOS2MET >> nA >> nP >> nFlags;
    1646                 :          0 :             if (nOrderID==GOrdPIvAtr) {
    1647                 :          0 :                 pAttrStack->nIvAttrA=nA;
    1648                 :          0 :                 pAttrStack->nIvAttrP=nP;
    1649                 :            :             }
    1650                 :          0 :             if (nA<=2) {
    1651                 :          0 :                 if ((nFlags&0x80)!=0) {
    1652                 :          0 :                     if (nA==1) switch (nP) {
    1653                 :          0 :                         case 1: aAttr.aLinCol=aDefAttr.aLinCol; break;
    1654                 :          0 :                         case 2: aAttr.aChrCol=aDefAttr.aChrCol; break;
    1655                 :          0 :                         case 3: aAttr.aMrkCol=aDefAttr.aMrkCol; break;
    1656                 :          0 :                         case 4: aAttr.aPatCol=aDefAttr.aPatCol; break;
    1657                 :          0 :                         case 5: aAttr.aImgCol=aDefAttr.aImgCol; break;
    1658                 :            :                     }
    1659                 :          0 :                     else switch (nP) {
    1660                 :          0 :                         case 1: aAttr.aLinBgCol=aDefAttr.aLinBgCol; break;
    1661                 :          0 :                         case 2: aAttr.aChrBgCol=aDefAttr.aChrBgCol; break;
    1662                 :          0 :                         case 3: aAttr.aMrkBgCol=aDefAttr.aMrkBgCol; break;
    1663                 :          0 :                         case 4: aAttr.aPatBgCol=aDefAttr.aPatBgCol; break;
    1664                 :          0 :                         case 5: aAttr.aImgBgCol=aDefAttr.aImgBgCol; break;
    1665                 :            :                     }
    1666                 :            :                 }
    1667                 :            :                 else {
    1668                 :          0 :                     nVal=ReadLittleEndian3BytesLong();
    1669                 :          0 :                     if      ((nFlags&0x40)!=0 && nVal==1) aCol=Color(COL_BLACK);
    1670                 :          0 :                     else if ((nFlags&0x40)!=0 && nVal==2) aCol=Color(COL_WHITE);
    1671                 :          0 :                     else if ((nFlags&0x40)!=0 && nVal==4) aCol=Color(COL_WHITE);
    1672                 :          0 :                     else if ((nFlags&0x40)!=0 && nVal==5) aCol=Color(COL_BLACK);
    1673                 :          0 :                     else aCol=GetPaletteColor(nVal);
    1674                 :          0 :                     if (nA==1) switch (nP) {
    1675                 :          0 :                         case 1: aAttr.aLinCol=aCol; break;
    1676                 :          0 :                         case 2: aAttr.aChrCol=aCol; break;
    1677                 :          0 :                         case 3: aAttr.aMrkCol=aCol; break;
    1678                 :          0 :                         case 4: aAttr.aPatCol=aCol; break;
    1679                 :          0 :                         case 5: aAttr.aImgCol=aCol; break;
    1680                 :            :                     }
    1681                 :          0 :                     else switch (nP) {
    1682                 :          0 :                         case 1: aAttr.aLinBgCol=aCol; break;
    1683                 :          0 :                         case 2: aAttr.aChrBgCol=aCol; break;
    1684                 :          0 :                         case 3: aAttr.aMrkBgCol=aCol; break;
    1685                 :          0 :                         case 4: aAttr.aPatBgCol=aCol; break;
    1686                 :          0 :                         case 5: aAttr.aImgBgCol=aCol; break;
    1687                 :            :                     }
    1688                 :            :                 }
    1689                 :            :             }
    1690                 :            :             else {
    1691                 :          0 :                 *pOS2MET >> nMix;
    1692                 :          0 :                 if (nMix==0) {
    1693                 :          0 :                     if (nA==1) switch (nP) {
    1694                 :          0 :                         case 1: aAttr.eLinMix=aDefAttr.eLinMix; break;
    1695                 :          0 :                         case 2: aAttr.eChrMix=aDefAttr.eChrMix; break;
    1696                 :          0 :                         case 3: aAttr.eMrkMix=aDefAttr.eMrkMix; break;
    1697                 :          0 :                         case 4: aAttr.ePatMix=aDefAttr.ePatMix; break;
    1698                 :          0 :                         case 5: aAttr.eImgMix=aDefAttr.eImgMix; break;
    1699                 :            :                     }
    1700                 :          0 :                     else switch (nP) {
    1701                 :          0 :                         case 1: aAttr.eLinBgMix=aDefAttr.eLinBgMix; break;
    1702                 :          0 :                         case 2: aAttr.eChrBgMix=aDefAttr.eChrBgMix; break;
    1703                 :          0 :                         case 3: aAttr.eMrkBgMix=aDefAttr.eMrkBgMix; break;
    1704                 :          0 :                         case 4: aAttr.ePatBgMix=aDefAttr.ePatBgMix; break;
    1705                 :          0 :                         case 5: aAttr.eImgBgMix=aDefAttr.eImgBgMix; break;
    1706                 :            :                     }
    1707                 :            :                 }
    1708                 :            :                 else {
    1709                 :          0 :                     eROP=OS2MixToRasterOp(nMix);
    1710                 :          0 :                     if (nA==1) switch (nP) {
    1711                 :          0 :                         case 1: aAttr.eLinMix=eROP; break;
    1712                 :          0 :                         case 2: aAttr.eChrMix=eROP; break;
    1713                 :          0 :                         case 3: aAttr.eMrkMix=eROP; break;
    1714                 :          0 :                         case 4: aAttr.ePatMix=eROP; break;
    1715                 :          0 :                         case 5: aAttr.eImgMix=eROP; break;
    1716                 :            :                     }
    1717                 :          0 :                     else switch (nP) {
    1718                 :          0 :                         case 1: aAttr.eLinBgMix=eROP; break;
    1719                 :          0 :                         case 2: aAttr.eChrBgMix=eROP; break;
    1720                 :          0 :                         case 3: aAttr.eMrkBgMix=eROP; break;
    1721                 :          0 :                         case 4: aAttr.ePatBgMix=eROP; break;
    1722                 :          0 :                         case 5: aAttr.eImgBgMix=eROP; break;
    1723                 :            :                     }
    1724                 :            :                 }
    1725                 :            :             }
    1726                 :            :             break;
    1727                 :            :         }
    1728                 :          0 :         case GOrdPIxCol: PushAttr(nOrderID);
    1729                 :            :         case GOrdSIxCol: {
    1730                 :            :             sal_uInt8 nFlags;
    1731                 :            :             sal_uLong nVal;
    1732                 :          0 :             Color aCol;
    1733                 :          0 :             *pOS2MET >> nFlags;
    1734                 :          0 :             if ((nFlags&0x80)!=0) {
    1735                 :          0 :                 aAttr.aLinCol=aDefAttr.aLinCol;
    1736                 :          0 :                 aAttr.aChrCol=aDefAttr.aChrCol;
    1737                 :          0 :                 aAttr.aMrkCol=aDefAttr.aMrkCol;
    1738                 :          0 :                 aAttr.aPatCol=aDefAttr.aPatCol;
    1739                 :          0 :                 aAttr.aImgCol=aDefAttr.aImgCol;
    1740                 :            :             }
    1741                 :            :             else {
    1742                 :          0 :                 nVal=ReadLittleEndian3BytesLong();
    1743                 :          0 :                 if      ((nFlags&0x40)!=0 && nVal==1) aCol=Color(COL_BLACK);
    1744                 :          0 :                 else if ((nFlags&0x40)!=0 && nVal==2) aCol=Color(COL_WHITE);
    1745                 :          0 :                 else if ((nFlags&0x40)!=0 && nVal==4) aCol=Color(COL_WHITE);
    1746                 :          0 :                 else if ((nFlags&0x40)!=0 && nVal==5) aCol=Color(COL_BLACK);
    1747                 :          0 :                 else aCol=GetPaletteColor(nVal);
    1748                 :            :                 aAttr.aLinCol = aAttr.aChrCol = aAttr.aMrkCol = aAttr.aPatCol =
    1749                 :          0 :                 aAttr.aImgCol = aCol;
    1750                 :            :             }
    1751                 :            :             break;
    1752                 :            :         }
    1753                 :            : 
    1754                 :            :         case GOrdPColor:
    1755                 :          0 :         case GOrdPXtCol: PushAttr(nOrderID);
    1756                 :            :         case GOrdSColor:
    1757                 :            :         case GOrdSXtCol: {
    1758                 :            :             sal_uInt8 nbyte;
    1759                 :            :             sal_uInt16 nVal;
    1760                 :          0 :             Color aCol;
    1761                 :          0 :             if (nOrderID==GOrdPColor || nOrderID==GOrdSColor) {
    1762                 :          0 :                 *pOS2MET >> nbyte; nVal=((sal_uInt16)nbyte)|0xff00;
    1763                 :            :             }
    1764                 :          0 :             else *pOS2MET >> nVal;
    1765                 :          0 :             if (nVal==0x0000 || nVal==0xff00)  {
    1766                 :          0 :                 aAttr.aLinCol=aDefAttr.aLinCol;
    1767                 :          0 :                 aAttr.aChrCol=aDefAttr.aChrCol;
    1768                 :          0 :                 aAttr.aMrkCol=aDefAttr.aMrkCol;
    1769                 :          0 :                 aAttr.aPatCol=aDefAttr.aPatCol;
    1770                 :          0 :                 aAttr.aImgCol=aDefAttr.aImgCol;
    1771                 :            :             }
    1772                 :            :             else {
    1773                 :          0 :                 if      (nVal==0x0007) aCol=Color(COL_WHITE);
    1774                 :          0 :                 else if (nVal==0x0008) aCol=Color(COL_BLACK);
    1775                 :          0 :                 else if (nVal==0xff08) aCol=GetPaletteColor(1);
    1776                 :          0 :                 else aCol=GetPaletteColor(((sal_uLong)nVal) & 0x000000ff);
    1777                 :            :                 aAttr.aLinCol = aAttr.aChrCol = aAttr.aMrkCol = aAttr.aPatCol =
    1778                 :          0 :                 aAttr.aImgCol = aCol;
    1779                 :            :             }
    1780                 :            :             break;
    1781                 :            :         }
    1782                 :            : 
    1783                 :          0 :         case GOrdPBgCol: PushAttr(nOrderID);
    1784                 :            :         case GOrdSBgCol: {
    1785                 :            :             sal_uInt16 nVal;
    1786                 :          0 :             Color aCol;
    1787                 :          0 :             *pOS2MET >> nVal;
    1788                 :          0 :             if (nVal==0x0000 || nVal==0xff00)  {
    1789                 :          0 :                 aAttr.aLinBgCol=aDefAttr.aLinBgCol;
    1790                 :          0 :                 aAttr.aChrBgCol=aDefAttr.aChrBgCol;
    1791                 :          0 :                 aAttr.aMrkBgCol=aDefAttr.aMrkBgCol;
    1792                 :          0 :                 aAttr.aPatBgCol=aDefAttr.aPatBgCol;
    1793                 :          0 :                 aAttr.aImgBgCol=aDefAttr.aImgBgCol;
    1794                 :            :             }
    1795                 :            :             else {
    1796                 :          0 :                 if      (nVal==0x0007) aCol=Color(COL_WHITE);
    1797                 :          0 :                 else if (nVal==0x0008) aCol=Color(COL_BLACK);
    1798                 :          0 :                 else if (nVal==0xff08) aCol=GetPaletteColor(0);
    1799                 :          0 :                 else aCol=GetPaletteColor(((sal_uLong)nVal) & 0x000000ff);
    1800                 :            :                 aAttr.aLinBgCol = aAttr.aChrBgCol = aAttr.aMrkBgCol =
    1801                 :          0 :                 aAttr.aPatBgCol = aAttr.aImgBgCol = aCol;
    1802                 :            :             }
    1803                 :            :             break;
    1804                 :            :         }
    1805                 :          0 :         case GOrdPBxCol: PushAttr(nOrderID);
    1806                 :            :         case GOrdSBxCol: {
    1807                 :            :             sal_uInt8 nFlags;
    1808                 :            :             sal_uLong nVal;
    1809                 :          0 :             Color aCol;
    1810                 :          0 :             *pOS2MET >> nFlags;
    1811                 :          0 :             if ((nFlags&0x80)!=0) {
    1812                 :          0 :                 aAttr.aLinBgCol=aDefAttr.aLinBgCol;
    1813                 :          0 :                 aAttr.aChrBgCol=aDefAttr.aChrBgCol;
    1814                 :          0 :                 aAttr.aMrkBgCol=aDefAttr.aMrkBgCol;
    1815                 :          0 :                 aAttr.aPatBgCol=aDefAttr.aPatBgCol;
    1816                 :          0 :                 aAttr.aImgBgCol=aDefAttr.aImgBgCol;
    1817                 :            :             }
    1818                 :            :             else {
    1819                 :          0 :                 nVal=ReadLittleEndian3BytesLong();
    1820                 :          0 :                 if      ((nFlags&0x40)!=0 && nVal==1) aCol=Color(COL_BLACK);
    1821                 :          0 :                 else if ((nFlags&0x40)!=0 && nVal==2) aCol=Color(COL_WHITE);
    1822                 :          0 :                 else if ((nFlags&0x40)!=0 && nVal==4) aCol=Color(COL_WHITE);
    1823                 :          0 :                 else if ((nFlags&0x40)!=0 && nVal==5) aCol=Color(COL_BLACK);
    1824                 :          0 :                 else aCol=GetPaletteColor(nVal);
    1825                 :            :                 aAttr.aLinBgCol = aAttr.aChrBgCol = aAttr.aMrkBgCol =
    1826                 :          0 :                 aAttr.aPatBgCol = aAttr.aImgBgCol = aCol;
    1827                 :            :             }
    1828                 :            :             break;
    1829                 :            :         }
    1830                 :            : 
    1831                 :          0 :         case GOrdPMixMd: PushAttr(nOrderID);
    1832                 :            :         case GOrdSMixMd: {
    1833                 :            :             sal_uInt8 nMix;
    1834                 :          0 :             *pOS2MET >> nMix;
    1835                 :          0 :             if (nMix==0) {
    1836                 :          0 :                 aAttr.eLinMix=aDefAttr.eLinMix;
    1837                 :          0 :                 aAttr.eChrMix=aDefAttr.eChrMix;
    1838                 :          0 :                 aAttr.eMrkMix=aDefAttr.eMrkMix;
    1839                 :          0 :                 aAttr.ePatMix=aDefAttr.ePatMix;
    1840                 :          0 :                 aAttr.eImgMix=aDefAttr.eImgMix;
    1841                 :            :             }
    1842                 :            :             else {
    1843                 :            :                 aAttr.eLinMix = aAttr.eChrMix = aAttr.eMrkMix =
    1844                 :          0 :                 aAttr.ePatMix = aAttr.eImgMix = OS2MixToRasterOp(nMix);
    1845                 :            :             }
    1846                 :            :             break;
    1847                 :            :         }
    1848                 :          0 :         case GOrdPBgMix: PushAttr(nOrderID);
    1849                 :            :         case GOrdSBgMix: {
    1850                 :            :             sal_uInt8 nMix;
    1851                 :          0 :             *pOS2MET >> nMix;
    1852                 :          0 :             if (nMix==0) {
    1853                 :          0 :                 aAttr.eLinBgMix=aDefAttr.eLinBgMix;
    1854                 :          0 :                 aAttr.eChrBgMix=aDefAttr.eChrBgMix;
    1855                 :          0 :                 aAttr.eMrkBgMix=aDefAttr.eMrkBgMix;
    1856                 :          0 :                 aAttr.ePatBgMix=aDefAttr.ePatBgMix;
    1857                 :          0 :                 aAttr.eImgBgMix=aDefAttr.eImgBgMix;
    1858                 :            :             }
    1859                 :            :             else {
    1860                 :            :                 aAttr.eLinBgMix = aAttr.eChrBgMix = aAttr.eMrkBgMix =
    1861                 :          0 :                 aAttr.ePatBgMix = aAttr.eImgBgMix = OS2MixToRasterOp(nMix);
    1862                 :            :             }
    1863                 :            :             break;
    1864                 :            :         }
    1865                 :          0 :         case GOrdPPtSet: PushAttr(nOrderID);
    1866                 :            :         case GOrdSPtSet: OOODEBUG("GOrdSPtSet",0);
    1867                 :          0 :             break;
    1868                 :            : 
    1869                 :          0 :         case GOrdPPtSym: PushAttr(nOrderID);
    1870                 :            :         case GOrdSPtSym: {
    1871                 :            :             sal_uInt8 nPatt;
    1872                 :          0 :             *pOS2MET >> nPatt;
    1873                 :          0 :             aAttr.bFill = ( nPatt != 0x0f );
    1874                 :            :             break;
    1875                 :            :         }
    1876                 :            : 
    1877                 :          0 :         case GOrdPPtRef: PushAttr(nOrderID);
    1878                 :            :         case GOrdSPtRef: OOODEBUG("GOrdSPtRef",0);
    1879                 :          0 :             break;
    1880                 :            : 
    1881                 :          0 :         case GOrdPLnEnd: PushAttr(nOrderID);
    1882                 :            :         case GOrdSLnEnd:
    1883                 :          0 :             break;
    1884                 :            : 
    1885                 :          0 :         case GOrdPLnJoi: PushAttr(nOrderID);
    1886                 :            :         case GOrdSLnJoi:
    1887                 :          0 :             break;
    1888                 :            : 
    1889                 :          0 :         case GOrdPLnTyp: PushAttr(nOrderID);
    1890                 :            :         case GOrdSLnTyp: {
    1891                 :            :             sal_uInt8 nType;
    1892                 :          0 :             *pOS2MET >> nType;
    1893                 :          0 :             switch (nType) {
    1894                 :          0 :                 case 0:         aAttr.eLinStyle=aDefAttr.eLinStyle; break;
    1895                 :          0 :                 case 1: case 4: aAttr.eLinStyle=PEN_DOT; break;
    1896                 :          0 :                 case 2: case 5: aAttr.eLinStyle=PEN_DASH; break;
    1897                 :          0 :                 case 3: case 6: aAttr.eLinStyle=PEN_DASHDOT; break;
    1898                 :          0 :                 case 8:         aAttr.eLinStyle=PEN_NULL; break;
    1899                 :          0 :                 default:        aAttr.eLinStyle=PEN_SOLID;
    1900                 :            :             }
    1901                 :            :             break;
    1902                 :            :         }
    1903                 :          0 :         case GOrdPLnWdt: PushAttr(nOrderID);
    1904                 :            :         case GOrdSLnWdt: {
    1905                 :            :             sal_uInt8 nbyte;
    1906                 :          0 :             *pOS2MET >> nbyte;
    1907                 :          0 :             if (nbyte==0) aAttr.nLinWidth=aDefAttr.nLinWidth;
    1908                 :          0 :             else aAttr.nLinWidth=(sal_uInt16)nbyte-1;
    1909                 :            :             break;
    1910                 :            :         }
    1911                 :          0 :         case GOrdPFrLWd: PushAttr(nOrderID);
    1912                 :            :         case GOrdSFrLWd:
    1913                 :          0 :             break;
    1914                 :            : 
    1915                 :          0 :         case GOrdPStLWd: PushAttr(nOrderID);
    1916                 :            :         case GOrdSStLWd :
    1917                 :            :         {
    1918                 :            :             sal_uInt8 nFlags;
    1919                 :            : 
    1920                 :          0 :             *pOS2MET >> nFlags;
    1921                 :          0 :             if ( nFlags & 0x80 )
    1922                 :          0 :                 aAttr.nStrLinWidth = aDefAttr.nStrLinWidth;
    1923                 :            :             else
    1924                 :            :             {
    1925                 :          0 :                 pOS2MET->SeekRel( 1 );
    1926                 :          0 :                 long nWd = ReadCoord( bCoord32 );
    1927                 :          0 :                 if ( nWd < 0 )
    1928                 :          0 :                     nWd = -nWd;
    1929                 :          0 :                 aAttr.nStrLinWidth = (sal_uInt16)nWd;
    1930                 :            :             }
    1931                 :            :             break;
    1932                 :            :         }
    1933                 :          0 :         case GOrdPChDir: PushAttr(nOrderID);
    1934                 :            :         case GOrdSChDir:
    1935                 :          0 :             break;
    1936                 :            : 
    1937                 :          0 :         case GOrdPChPrc: PushAttr(nOrderID);
    1938                 :            :         case GOrdSChPrc:
    1939                 :          0 :             break;
    1940                 :            : 
    1941                 :          0 :         case GOrdPChSet: PushAttr(nOrderID);
    1942                 :            :         case GOrdSChSet: {
    1943                 :          0 :             sal_uInt8 nbyte; *pOS2MET >> nbyte;
    1944                 :          0 :             aAttr.nChrSet=((sal_uLong)nbyte)&0xff;
    1945                 :            :             break;
    1946                 :            :         }
    1947                 :          0 :         case GOrdPChAng: PushAttr(nOrderID);
    1948                 :            :         case GOrdSChAng: {
    1949                 :            :             long nX,nY;
    1950                 :          0 :             nX=ReadCoord(bCoord32); nY=ReadCoord(bCoord32);
    1951                 :          0 :             if (nX>=0 && nY==0) aAttr.nChrAng=0;
    1952                 :            :             else {
    1953                 :          0 :                 aAttr.nChrAng=(short)(atan2((double)nY,(double)nX)/3.1415926539*1800.0);
    1954                 :          0 :                 while (aAttr.nChrAng<0) aAttr.nChrAng+=3600;
    1955                 :          0 :                 aAttr.nChrAng%=3600;
    1956                 :            :             }
    1957                 :          0 :             break;
    1958                 :            :         }
    1959                 :          0 :         case GOrdPChBrx: PushAttr(nOrderID);
    1960                 :            :         case GOrdSChBrx:
    1961                 :          0 :             break;
    1962                 :            : 
    1963                 :          0 :         case GOrdPChCel: PushAttr(nOrderID);
    1964                 :            :         case GOrdSChCel: {
    1965                 :            :             sal_uInt8 nbyte;
    1966                 :          0 :             sal_uInt16 nLen=nOrderLen;
    1967                 :          0 :             aAttr.aChrCellSize.Width()=ReadCoord(bCoord32);
    1968                 :          0 :             aAttr.aChrCellSize.Height()=ReadCoord(bCoord32);
    1969                 :          0 :             if (bCoord32) nLen-=8; else nLen-=4;
    1970                 :          0 :             if (nLen>=4) {
    1971                 :          0 :                 pOS2MET->SeekRel(4); nLen-=4;
    1972                 :            :             }
    1973                 :          0 :             if (nLen>=2) {
    1974                 :          0 :                 *pOS2MET >> nbyte;
    1975                 :          0 :                 if ((nbyte&0x80)==0 && aAttr.aChrCellSize==Size(0,0))
    1976                 :          0 :                     aAttr.aChrCellSize=aDefAttr.aChrCellSize;
    1977                 :            :             }
    1978                 :            :             break;
    1979                 :            :         }
    1980                 :          0 :         case GOrdPChXtr: PushAttr(nOrderID);
    1981                 :            :         case GOrdSChXtr:
    1982                 :          0 :             break;
    1983                 :            : 
    1984                 :          0 :         case GOrdPChShr: PushAttr(nOrderID);
    1985                 :            :         case GOrdSChShr:
    1986                 :          0 :             break;
    1987                 :            : 
    1988                 :          0 :         case GOrdPTxAlg: PushAttr(nOrderID);
    1989                 :            :         case GOrdSTxAlg: OOODEBUG("GOrdSTxAlg",0);
    1990                 :          0 :             break;
    1991                 :            : 
    1992                 :          0 :         case GOrdPMkPrc: PushAttr(nOrderID);
    1993                 :            :         case GOrdSMkPrc: {
    1994                 :            :             sal_uInt8 nbyte;
    1995                 :          0 :             *pOS2MET >> nbyte;
    1996                 :          0 :             if (nbyte==0) aAttr.nMrkPrec=aDefAttr.nMrkPrec;
    1997                 :          0 :             else aAttr.nMrkPrec=nbyte;
    1998                 :            :             break;
    1999                 :            :         }
    2000                 :            : 
    2001                 :          0 :         case GOrdPMkSet: PushAttr(nOrderID);
    2002                 :            :         case GOrdSMkSet: {
    2003                 :            :             sal_uInt8 nbyte;
    2004                 :          0 :             *pOS2MET >> nbyte;
    2005                 :          0 :             if (nbyte==0) aAttr.nMrkSet=aDefAttr.nMrkSet;
    2006                 :          0 :             else aAttr.nMrkSet=nbyte;
    2007                 :            :             break;
    2008                 :            :         }
    2009                 :            : 
    2010                 :          0 :         case GOrdPMkSym: PushAttr(nOrderID);
    2011                 :            :         case GOrdSMkSym: {
    2012                 :            :             sal_uInt8 nbyte;
    2013                 :          0 :             *pOS2MET >> nbyte;
    2014                 :          0 :             if (nbyte==0) aAttr.nMrkSymbol=aDefAttr.nMrkSymbol;
    2015                 :          0 :             else aAttr.nMrkSymbol=nbyte;
    2016                 :            :             break;
    2017                 :            :         }
    2018                 :            : 
    2019                 :          0 :         case GOrdPMkCel: PushAttr(nOrderID);
    2020                 :            :         case GOrdSMkCel: {
    2021                 :            :             sal_uInt8 nbyte;
    2022                 :          0 :             sal_uInt16 nLen=nOrderLen;
    2023                 :          0 :             aAttr.aMrkCellSize.Width()=ReadCoord(bCoord32);
    2024                 :          0 :             aAttr.aMrkCellSize.Height()=ReadCoord(bCoord32);
    2025                 :          0 :             if (bCoord32) nLen-=8; else nLen-=4;
    2026                 :          0 :             if (nLen>=2) {
    2027                 :          0 :                 *pOS2MET >> nbyte;
    2028                 :          0 :                 if ((nbyte&0x80)==0 && aAttr.aMrkCellSize==Size(0,0))
    2029                 :          0 :                     aAttr.aMrkCellSize=aDefAttr.aMrkCellSize;
    2030                 :            :             }
    2031                 :            :             break;
    2032                 :            :         }
    2033                 :            : 
    2034                 :          0 :         case GOrdPArcPa: PushAttr(nOrderID);
    2035                 :            :         case GOrdSArcPa:
    2036                 :          0 :             aAttr.nArcP=ReadCoord(bCoord32);
    2037                 :          0 :             aAttr.nArcQ=ReadCoord(bCoord32);
    2038                 :          0 :             aAttr.nArcR=ReadCoord(bCoord32);
    2039                 :          0 :             aAttr.nArcS=ReadCoord(bCoord32);
    2040                 :          0 :             break;
    2041                 :            : 
    2042                 :          0 :         case GOrdPCrPos: PushAttr(nOrderID);
    2043                 :            :         case GOrdSCrPos:
    2044                 :          0 :             aAttr.aCurPos=ReadPoint();
    2045                 :          0 :             break;
    2046                 :            : 
    2047                 :          0 :         case GOrdPMdTrn: PushAttr(nOrderID);
    2048                 :            :         case GOrdSMdTrn: OOODEBUG("GOrdSMdTrn",0);
    2049                 :          0 :             break;
    2050                 :            : 
    2051                 :          0 :         case GOrdPPkIdn: PushAttr(nOrderID);
    2052                 :            :         case GOrdSPkIdn: OOODEBUG("GOrdSPkIdn",0);
    2053                 :          0 :             break;
    2054                 :            : 
    2055                 :            :         case GOrdSVwTrn: OOODEBUG("GOrdSVwTrn",0);
    2056                 :          0 :             break;
    2057                 :            : 
    2058                 :          0 :         case GOrdPVwWin: PushAttr(nOrderID);
    2059                 :            :         case GOrdSVwWin: OOODEBUG("GOrdSVwWin",0);
    2060                 :          0 :             break;
    2061                 :            :         default: OOODEBUG("Order unbekannt:",nOrderID);
    2062                 :            :     }
    2063                 :          0 : }
    2064                 :            : 
    2065                 :          0 : void OS2METReader::ReadDsc(sal_uInt16 nDscID, sal_uInt16 /*nDscLen*/)
    2066                 :            : {
    2067                 :          0 :     switch (nDscID) {
    2068                 :            :         case 0x00f7: { // 'Specify GVM Subset'
    2069                 :            :             sal_uInt8 nbyte;
    2070                 :          0 :             pOS2MET->SeekRel(6);
    2071                 :          0 :             *pOS2MET >> nbyte;
    2072                 :          0 :             if      (nbyte==0x05) bCoord32=sal_True;
    2073                 :          0 :             else if (nbyte==0x04) bCoord32=sal_False;
    2074                 :            :             else {
    2075                 :          0 :                 pOS2MET->SetError(SVSTREAM_FILEFORMAT_ERROR);
    2076                 :          0 :                 ErrorCode=1;
    2077                 :            :             }
    2078                 :            :             break;
    2079                 :            :         }
    2080                 :            :         case 0x00f6:
    2081                 :            :         {
    2082                 :            :             // 'Set Picture Descriptor'
    2083                 :            :             sal_Bool b32;
    2084                 :            :             sal_uInt8 nbyte,nUnitType;
    2085                 :            :             long x1,y1,x2,y2,nt,xr,yr;
    2086                 :            : 
    2087                 :          0 :             pOS2MET->SeekRel(2);
    2088                 :          0 :             *pOS2MET >> nbyte;
    2089                 :            : 
    2090                 :          0 :             if (nbyte==0x05)
    2091                 :          0 :                 b32=sal_True;
    2092                 :          0 :             else if(nbyte==0x04)
    2093                 :          0 :                 b32=sal_False;
    2094                 :            :             else
    2095                 :            :             {
    2096                 :          0 :                 b32 = sal_False;   // -Wall added the case.
    2097                 :          0 :                 pOS2MET->SetError(SVSTREAM_FILEFORMAT_ERROR);
    2098                 :          0 :                 ErrorCode=2;
    2099                 :            :             }
    2100                 :            : 
    2101                 :          0 :             *pOS2MET >> nUnitType;
    2102                 :            : 
    2103                 :          0 :             xr=ReadCoord(b32);
    2104                 :          0 :             yr=ReadCoord(b32);
    2105                 :            : 
    2106                 :          0 :             ReadCoord(b32);
    2107                 :            : 
    2108                 :          0 :             if (nUnitType==0x00 && xr>0 && yr>0)
    2109                 :          0 :                 aGlobMapMode=MapMode(MAP_INCH,Point(0,0),Fraction(10,xr),Fraction(10,yr));
    2110                 :          0 :             else if (nUnitType==0x01 && xr>0 && yr>0)
    2111                 :          0 :                 aGlobMapMode=MapMode(MAP_CM,Point(0,0),Fraction(10,xr),Fraction(10,yr));
    2112                 :            :             else
    2113                 :          0 :                 aGlobMapMode=MapMode();
    2114                 :            : 
    2115                 :          0 :             x1=ReadCoord(b32);
    2116                 :          0 :             x2=ReadCoord(b32);
    2117                 :          0 :             y1=ReadCoord(b32);
    2118                 :          0 :             y2=ReadCoord(b32);
    2119                 :            : 
    2120                 :          0 :             if (x1>x2)
    2121                 :            :             {
    2122                 :          0 :                 nt=x1;
    2123                 :          0 :                 x1=x2;
    2124                 :          0 :                 x2=nt;
    2125                 :            :             }
    2126                 :            : 
    2127                 :          0 :             if (y1>y2)
    2128                 :            :             {
    2129                 :          0 :                 nt=y1;
    2130                 :          0 :                 y1=y2;
    2131                 :          0 :                 y2=nt;
    2132                 :            :             }
    2133                 :            : 
    2134                 :          0 :             aBoundingRect.Left() = x1;
    2135                 :          0 :             aBoundingRect.Right() = x2;
    2136                 :          0 :             aBoundingRect.Top() = y1;
    2137                 :          0 :             aBoundingRect.Bottom() = y2;
    2138                 :            : 
    2139                 :            :             // no output beside this bounding rect
    2140                 :          0 :             pVirDev->IntersectClipRegion( Rectangle( Point(), aBoundingRect.GetSize() ) );
    2141                 :            : 
    2142                 :            :             break;
    2143                 :            :         }
    2144                 :            :         case 0x0021: // 'Set Current Defaults'
    2145                 :          0 :             break;
    2146                 :            :     }
    2147                 :          0 : }
    2148                 :            : 
    2149                 :          0 : void OS2METReader::ReadImageData(sal_uInt16 nDataID, sal_uInt16 nDataLen)
    2150                 :            : {
    2151                 :          0 :     OSBitmap * p=pBitmapList; if (p==NULL) return;
    2152                 :            : 
    2153                 :          0 :     switch (nDataID) {
    2154                 :            : 
    2155                 :            :         case 0x0070:   // Begin Segment
    2156                 :          0 :             break;
    2157                 :            : 
    2158                 :            :         case 0x0091:   // Begin Image Content
    2159                 :          0 :             break;
    2160                 :            : 
    2161                 :            :         case 0x0094:   // Image Size
    2162                 :          0 :             pOS2MET->SeekRel(5);
    2163                 :          0 :             p->nHeight=ReadBigEndianWord();
    2164                 :          0 :             p->nWidth=ReadBigEndianWord();
    2165                 :          0 :             break;
    2166                 :            : 
    2167                 :            :         case 0x0095:   // Image Encoding
    2168                 :          0 :             break;
    2169                 :            : 
    2170                 :            :         case 0x0096: { // Image IDE-Size
    2171                 :            :             sal_uInt8 nbyte;
    2172                 :          0 :             *pOS2MET >> nbyte; p->nBitsPerPixel=nbyte;
    2173                 :            :             break;
    2174                 :            :         }
    2175                 :            : 
    2176                 :            :         case 0x0097:   // Image LUT-ID
    2177                 :          0 :             break;
    2178                 :            : 
    2179                 :            :         case 0x009b:   // IDE Structure
    2180                 :          0 :             break;
    2181                 :            : 
    2182                 :            :         case 0xfe92: { // Image Data
    2183                 :            :             // Spaetestens jetzt brauchen wir die temporaere BMP-Datei
    2184                 :            :             // und darin mindestens den Header + Palette.
    2185                 :          0 :             if (p->pBMP==NULL) {
    2186                 :          0 :                 p->pBMP=new SvMemoryStream();
    2187                 :          0 :                 p->pBMP->SetNumberFormatInt(NUMBERFORMAT_INT_LITTLEENDIAN);
    2188                 :          0 :                 if (p->nWidth==0 || p->nHeight==0 || p->nBitsPerPixel==0) {
    2189                 :          0 :                     pOS2MET->SetError(SVSTREAM_FILEFORMAT_ERROR);
    2190                 :          0 :                     ErrorCode=3;
    2191                 :          0 :                     return;
    2192                 :            :                 }
    2193                 :            :                 // write (Windows-)BITMAPINFOHEADER:
    2194                 :          0 :                 *(p->pBMP) << ((sal_uInt32)40) << p->nWidth << p->nHeight;
    2195                 :          0 :                 *(p->pBMP) << ((sal_uInt16)1) << p->nBitsPerPixel;
    2196                 :          0 :                 *(p->pBMP) << ((sal_uInt32)0) << ((sal_uInt32)0) << ((sal_uInt32)0) << ((sal_uInt32)0);
    2197                 :          0 :                 *(p->pBMP) << ((sal_uInt32)0) << ((sal_uInt32)0);
    2198                 :            :                 // write color table:
    2199                 :          0 :                 if (p->nBitsPerPixel<=8) {
    2200                 :          0 :                     sal_uInt16 i, nColTabSize=1<<(p->nBitsPerPixel);
    2201                 :          0 :                     for (i=0; i<nColTabSize; i++) *(p->pBMP) << GetPalette0RGB(i);
    2202                 :            :                 }
    2203                 :            :             }
    2204                 :            :             // OK, nun werden die Map-Daten ruebergeschoben. Leider haben OS2 und
    2205                 :            :             // BMP eine unterschiedliche Reihenfolge von RGB bei 24-Bit.
    2206                 :          0 :             sal_uInt8 * pBuf=new sal_uInt8[nDataLen];
    2207                 :          0 :             pOS2MET->Read(pBuf,nDataLen);
    2208                 :          0 :             if (p->nBitsPerPixel==24) {
    2209                 :            :                 sal_uLong i, j, nAlign, nBytesPerLine;
    2210                 :            :                 sal_uInt8 nTemp;
    2211                 :          0 :                 nBytesPerLine=(p->nWidth*3+3)&0xfffffffc;
    2212                 :          0 :                 nAlign=p->nMapPos-(p->nMapPos % nBytesPerLine);
    2213                 :          0 :                 i=0;
    2214                 :          0 :                 while (nAlign+i+2<p->nMapPos+nDataLen) {
    2215                 :          0 :                     if (nAlign+i>=p->nMapPos) {
    2216                 :          0 :                         j=nAlign+i-p->nMapPos;
    2217                 :          0 :                         nTemp=pBuf[j]; pBuf[j]=pBuf[j+2]; pBuf[j+2]=nTemp;
    2218                 :            :                     }
    2219                 :          0 :                     i+=3; if (i+2>=nBytesPerLine) {
    2220                 :          0 :                         nAlign+=nBytesPerLine;
    2221                 :          0 :                         i=0;
    2222                 :            :                     }
    2223                 :            :                 }
    2224                 :            :             }
    2225                 :          0 :             p->pBMP->Write(pBuf,nDataLen);
    2226                 :          0 :             p->nMapPos+=nDataLen;
    2227                 :          0 :             delete[] pBuf;
    2228                 :          0 :             break;
    2229                 :            :         }
    2230                 :            :         case 0x0093:   // End Image Content
    2231                 :          0 :             break;
    2232                 :            : 
    2233                 :            :         case 0x0071:   // End Segment
    2234                 :          0 :             break;
    2235                 :            :     }
    2236                 :            : }
    2237                 :            : 
    2238                 :          0 : void OS2METReader::ReadFont(sal_uInt16 nFieldSize)
    2239                 :            : {
    2240                 :            :     sal_uLong nPos, nMaxPos;
    2241                 :            :     sal_uInt16 nLen;
    2242                 :            :     sal_uInt8 nByte, nTripType, nTripType2;
    2243                 :          0 :     OSFont * pF=new OSFont;
    2244                 :          0 :     pF->pSucc=pFontList; pFontList=pF;
    2245                 :          0 :     pF->nID=0;
    2246                 :          0 :     pF->aFont.SetTransparent(sal_True);
    2247                 :          0 :     pF->aFont.SetAlign(ALIGN_BASELINE);
    2248                 :            : 
    2249                 :          0 :     nPos=pOS2MET->Tell();
    2250                 :          0 :     nMaxPos=nPos+(sal_uLong)nFieldSize;
    2251                 :          0 :     pOS2MET->SeekRel(2); nPos+=2;
    2252                 :          0 :     while (nPos<nMaxPos && pOS2MET->GetError()==0) {
    2253                 :          0 :         *pOS2MET >> nByte; nLen =((sal_uInt16)nByte) & 0x00ff;
    2254                 :          0 :         *pOS2MET >> nTripType;
    2255                 :          0 :         switch (nTripType) {
    2256                 :            :             case 0x02:
    2257                 :          0 :                 *pOS2MET >> nTripType2;
    2258                 :          0 :                 switch (nTripType2) {
    2259                 :            :                     case 0x84:   // Font name
    2260                 :          0 :                         break;
    2261                 :            :                     case 0x08: { // Font Typeface
    2262                 :            :                         char str[33];
    2263                 :          0 :                         pOS2MET->SeekRel(1);
    2264                 :          0 :                         pOS2MET->Read( &str, 32 );
    2265                 :          0 :                         str[ 32 ] = 0;
    2266                 :          0 :                         String aStr( (const sal_Char*)str, osl_getThreadTextEncoding() );
    2267                 :          0 :                         if ( aStr.CompareIgnoreCaseToAscii( "Helv" ) == COMPARE_EQUAL )
    2268                 :          0 :                             aStr = rtl::OUString("Helvetica");
    2269                 :          0 :                         pF->aFont.SetName( aStr );
    2270                 :          0 :                         break;
    2271                 :            :                     }
    2272                 :            :                 }
    2273                 :          0 :                 break;
    2274                 :            :             case 0x24:   // Icid
    2275                 :          0 :                 *pOS2MET >> nTripType2;
    2276                 :          0 :                 switch (nTripType2) {
    2277                 :            :                     case 0x05:   //Icid
    2278                 :          0 :                         *pOS2MET >> nByte;
    2279                 :          0 :                         pF->nID=((sal_uLong)nByte)&0xff;
    2280                 :          0 :                         break;
    2281                 :            :                 }
    2282                 :          0 :                 break;
    2283                 :            :             case 0x20:   // Font Binary GCID
    2284                 :          0 :                 break;
    2285                 :            :             case 0x1f: { // Font Attributes
    2286                 :            :                 FontWeight eWeight;
    2287                 :            :                 sal_uInt8 nbyte;
    2288                 :          0 :                 *pOS2MET >> nbyte;
    2289                 :          0 :                 switch (nbyte) {
    2290                 :          0 :                     case 1:  eWeight=WEIGHT_THIN;       break;
    2291                 :          0 :                     case 2:  eWeight=WEIGHT_ULTRALIGHT; break;
    2292                 :          0 :                     case 3:  eWeight=WEIGHT_LIGHT;      break;
    2293                 :          0 :                     case 4:  eWeight=WEIGHT_SEMILIGHT;  break;
    2294                 :          0 :                     case 5:  eWeight=WEIGHT_NORMAL;     break;
    2295                 :          0 :                     case 6:  eWeight=WEIGHT_SEMIBOLD;   break;
    2296                 :          0 :                     case 7:  eWeight=WEIGHT_BOLD;       break;
    2297                 :          0 :                     case 8:  eWeight=WEIGHT_ULTRABOLD;  break;
    2298                 :          0 :                     case 9:  eWeight=WEIGHT_BLACK;      break;
    2299                 :          0 :                     default: eWeight=WEIGHT_DONTKNOW;
    2300                 :            :                 }
    2301                 :          0 :                 pF->aFont.SetWeight(eWeight);
    2302                 :            :                 break;
    2303                 :            :             }
    2304                 :            :         }
    2305                 :          0 :         nPos+=nLen; pOS2MET->Seek(nPos);
    2306                 :            :     }
    2307                 :          0 : }
    2308                 :            : 
    2309                 :          0 : void OS2METReader::ReadField(sal_uInt16 nFieldType, sal_uInt16 nFieldSize)
    2310                 :            : {
    2311                 :          0 :     switch (nFieldType) {
    2312                 :            :         case BegDocumnMagic:
    2313                 :          0 :             break;
    2314                 :            :         case EndDocumnMagic:
    2315                 :          0 :             break;
    2316                 :            :         case BegResGrpMagic:
    2317                 :          0 :             break;
    2318                 :            :         case EndResGrpMagic:
    2319                 :          0 :             break;
    2320                 :            :         case BegColAtrMagic:
    2321                 :          0 :             break;
    2322                 :            :         case EndColAtrMagic:
    2323                 :          0 :             break;
    2324                 :            :         case BlkColAtrMagic: {
    2325                 :            :             sal_uLong nPos, nMaxPos;
    2326                 :            :             sal_uInt8 nbyte;
    2327                 :            :             sal_uLong nCol;
    2328                 :            :             sal_uInt16 nStartIndex, nEndIndex, i, nElemLen, nBytesPerCol;
    2329                 :            : 
    2330                 :          0 :             nPos=pOS2MET->Tell();
    2331                 :          0 :             nMaxPos=nPos+(sal_uLong)nFieldSize;
    2332                 :          0 :             pOS2MET->SeekRel(3); nPos+=3;
    2333                 :          0 :             while (nPos<nMaxPos && pOS2MET->GetError()==0) {
    2334                 :          0 :                 *pOS2MET >> nbyte; nElemLen=((sal_uInt16)nbyte) & 0x00ff;
    2335                 :          0 :                 if (nElemLen>11) {
    2336                 :          0 :                     pOS2MET->SeekRel(4);
    2337                 :          0 :                     nStartIndex=ReadBigEndianWord();
    2338                 :          0 :                     pOS2MET->SeekRel(3);
    2339                 :          0 :                     *pOS2MET >> nbyte; nBytesPerCol=((sal_uInt16)nbyte) & 0x00ff;
    2340                 :          0 :                     nEndIndex=nStartIndex+(nElemLen-11)/nBytesPerCol;
    2341                 :          0 :                     for (i=nStartIndex; i<nEndIndex; i++) {
    2342                 :          0 :                         if (nBytesPerCol > 3) pOS2MET->SeekRel(nBytesPerCol-3);
    2343                 :          0 :                         nCol=ReadBigEndian3BytesLong();
    2344                 :          0 :                         SetPalette0RGB(i,nCol);
    2345                 :            :                     }
    2346                 :            :                 }
    2347                 :          0 :                 else if (nElemLen<10) {
    2348                 :          0 :                     pOS2MET->SetError(SVSTREAM_FILEFORMAT_ERROR);
    2349                 :          0 :                     ErrorCode=4;
    2350                 :            :                 }
    2351                 :          0 :                 nPos+=(sal_uLong)nElemLen;
    2352                 :          0 :                 pOS2MET->Seek(nPos);
    2353                 :            :             }
    2354                 :            :             break;
    2355                 :            :         }
    2356                 :            :         case MapColAtrMagic:
    2357                 :          0 :             break;
    2358                 :            :         case BegImgObjMagic: {
    2359                 :            :             // neue Bitmap schonmal herstellen: (wird spaeter gefuellt)
    2360                 :          0 :             OSBitmap * pB=new OSBitmap;
    2361                 :          0 :             pB->pSucc=pBitmapList; pBitmapList=pB;
    2362                 :          0 :             pB->pBMP=NULL; pB->nWidth=0; pB->nHeight=0; pB->nBitsPerPixel=0;
    2363                 :          0 :             pB->nMapPos=0;
    2364                 :            :             // determine ID of the bitmap:
    2365                 :            :             sal_uInt8 i,nbyte,nbyte2;
    2366                 :          0 :             pB->nID=0;
    2367                 :          0 :             for (i=0; i<4; i++) {
    2368                 :          0 :                 *pOS2MET >> nbyte >> nbyte2;
    2369                 :          0 :                 nbyte=((nbyte-0x30)<<4)|(nbyte2-0x30);
    2370                 :          0 :                 pB->nID=(pB->nID>>8)|(((sal_uLong)nbyte)<<24);
    2371                 :            :             }
    2372                 :            :             // neue Palette auf den Paletten-Stack bringen: (wird spaeter gefuellt)
    2373                 :          0 :             OSPalette * pP=new OSPalette;
    2374                 :          0 :             pP->pSucc=pPaletteStack; pPaletteStack=pP;
    2375                 :          0 :             pP->p0RGB=NULL; pP->nSize=0;
    2376                 :            :             break;
    2377                 :            :         }
    2378                 :            :         case EndImgObjMagic: {
    2379                 :            :             // Temporaere Windows-BMP-Datei auslesen:
    2380                 :          0 :             if (pBitmapList==NULL || pBitmapList->pBMP==NULL ||
    2381                 :          0 :                 pBitmapList->pBMP->GetError()!=0) {
    2382                 :          0 :                 pOS2MET->SetError(SVSTREAM_FILEFORMAT_ERROR);
    2383                 :          0 :                 ErrorCode=5;
    2384                 :          0 :                 return;
    2385                 :            :             }
    2386                 :          0 :             pBitmapList->pBMP->Seek(0);
    2387                 :            : 
    2388                 :          0 :             pBitmapList->aBitmap.Read( *( pBitmapList->pBMP ), sal_False );
    2389                 :            : 
    2390                 :          0 :             if (pBitmapList->pBMP->GetError()!=0) {
    2391                 :          0 :                 pOS2MET->SetError(SVSTREAM_FILEFORMAT_ERROR);
    2392                 :          0 :                 ErrorCode=6;
    2393                 :            :             }
    2394                 :          0 :             delete pBitmapList->pBMP; pBitmapList->pBMP=NULL;
    2395                 :            :             // kill palette from stack:
    2396                 :          0 :             OSPalette * pP=pPaletteStack;
    2397                 :          0 :             if (pP!=NULL) {
    2398                 :          0 :                 pPaletteStack=pP->pSucc;
    2399                 :          0 :                 if (pP->p0RGB!=NULL) delete[] pP->p0RGB;
    2400                 :          0 :                 delete pP;
    2401                 :            :             }
    2402                 :          0 :             break;
    2403                 :            :         }
    2404                 :            :         case DscImgObjMagic:
    2405                 :          0 :             break;
    2406                 :            :         case DatImgObjMagic: {
    2407                 :            :             sal_uInt16 nDataID, nDataLen;
    2408                 :            :             sal_uInt8 nbyte;
    2409                 :            :             sal_uLong nPos, nMaxPos;
    2410                 :            : 
    2411                 :          0 :             nPos=pOS2MET->Tell();
    2412                 :          0 :             nMaxPos=nPos+(sal_uLong)nFieldSize;
    2413                 :          0 :             while (nPos<nMaxPos && pOS2MET->GetError()==0) {
    2414                 :          0 :                 *pOS2MET >> nbyte; nDataID=((sal_uInt16)nbyte)&0x00ff;
    2415                 :          0 :                 if (nDataID==0x00fe) {
    2416                 :          0 :                     *pOS2MET >> nbyte;
    2417                 :          0 :                     nDataID=(nDataID<<8)|(((sal_uInt16)nbyte)&0x00ff);
    2418                 :          0 :                     nDataLen=ReadBigEndianWord();
    2419                 :          0 :                     nPos+=4;
    2420                 :            :                 }
    2421                 :            :                 else {
    2422                 :          0 :                     *pOS2MET >> nbyte; nDataLen=((sal_uInt16)nbyte)&0x00ff;
    2423                 :          0 :                     nPos+=2;
    2424                 :            :                 }
    2425                 :          0 :                 ReadImageData(nDataID, nDataLen);
    2426                 :          0 :                 nPos+=(sal_uLong)nDataLen;
    2427                 :          0 :                 pOS2MET->Seek(nPos);
    2428                 :            :             }
    2429                 :            :             break;
    2430                 :            :         }
    2431                 :            : 
    2432                 :            :         case BegObEnv1Magic:
    2433                 :          0 :             break;
    2434                 :            :         case EndObEnv1Magic:
    2435                 :          0 :             break;
    2436                 :            :         case BegGrfObjMagic:
    2437                 :          0 :             break;
    2438                 :            :         case EndGrfObjMagic: {
    2439                 :            :             SvStream * pSave;
    2440                 :            :             sal_uLong nPos, nMaxPos;
    2441                 :            :             sal_uInt16 nOrderID, nOrderLen;
    2442                 :            :             sal_uInt8 nbyte;
    2443                 :            : 
    2444                 :          0 :             if (pOrdFile==NULL) break;
    2445                 :            : 
    2446                 :            :             // in pOrdFile wurden alle "DatGrfObj"-Felder gesammelt, so
    2447                 :            :             // dass die darin enthaltnen "Orders" zusammenhangend und nicht durch
    2448                 :            :             // "Fields" segmentiert sind. Um sie aus dem MemoryStream auszulesen,
    2449                 :            :             // ohne grosse Umstaende deswegen zu haben (frueher wurden die "Orders"
    2450                 :            :             // direkt aus pOS2MET gelesen), hier ein kleiner Trick:
    2451                 :          0 :             pSave=pOS2MET;
    2452                 :          0 :             pOS2MET=pOrdFile; //(!)
    2453                 :          0 :             nMaxPos=pOS2MET->Tell();
    2454                 :          0 :             pOS2MET->Seek(0);
    2455                 :            : 
    2456                 :            :             // "Segment header":
    2457                 :          0 :             *pOS2MET >> nbyte;
    2458                 :          0 :             if (nbyte==0x70) { // header exists
    2459                 :          0 :                 pOS2MET->SeekRel(15); // but we don't need it
    2460                 :            :             }
    2461                 :          0 :             else pOS2MET->SeekRel(-1); // no header, go back one byte
    2462                 :            : 
    2463                 :            :             // loop through Order:
    2464                 :          0 :             while (pOS2MET->Tell()<nMaxPos && pOS2MET->GetError()==0) {
    2465                 :          0 :                 *pOS2MET >> nbyte; nOrderID=((sal_uInt16)nbyte) & 0x00ff;
    2466                 :          0 :                 if (nOrderID==0x00fe) {
    2467                 :          0 :                     *pOS2MET >> nbyte;
    2468                 :          0 :                     nOrderID=(nOrderID << 8) | (((sal_uInt16)nbyte) & 0x00ff);
    2469                 :            :                 }
    2470                 :          0 :                 if (nOrderID>0x00ff || nOrderID==GOrdPolygn) {
    2471                 :            :                     // ooo: Laut OS2-Doku sollte die Orderlaenge nun als Big-Endian-Word
    2472                 :            :                     // gegeben sein (Zitat: "Highorder byte precedes loworder byte").
    2473                 :            :                     // Tatsaechlich gibt es aber Dateien, die die Laenge als
    2474                 :            :                     // Little-Endian-Word angeben (zu mindestens fuer nOrderID==GOrdPolygn).
    2475                 :            :                     // Also werfen wir eine Muenze oder was ?
    2476                 :          0 :                     *pOS2MET >> nbyte; nOrderLen=(sal_uInt16)nbyte&0x00ff;
    2477                 :          0 :                     *pOS2MET >> nbyte; if (nbyte!=0) nOrderLen=nOrderLen<<8|(((sal_uInt16)nbyte)&0x00ff);
    2478                 :            :                 }
    2479                 :          0 :                 else if (nOrderID==GOrdSTxAlg || nOrderID==GOrdPTxAlg) nOrderLen=2;
    2480                 :          0 :                 else if ((nOrderID&0xff88)==0x0008) nOrderLen=1;
    2481                 :          0 :                 else if (nOrderID==0x0000 || nOrderID==0x00ff) nOrderLen=0;
    2482                 :          0 :                 else { *pOS2MET >> nbyte; nOrderLen=((sal_uInt16)nbyte) & 0x00ff; }
    2483                 :          0 :                 nPos=pOS2MET->Tell();
    2484                 :          0 :                 ReadOrder(nOrderID, nOrderLen);
    2485                 :          0 :                 if (nPos+nOrderLen < pOS2MET->Tell()) {
    2486                 :            :                     OOODEBUG("Order shorter than he assumes! OrderID:",nOrderID);
    2487                 :            :                     OOODEBUG("...und zwar bei Position (Parameteranfang):",nPos);
    2488                 :            :                 }
    2489                 :          0 :                 else if (nPos+nOrderLen != pOS2MET->Tell()) {
    2490                 :            :                     OOODEBUG(String(nOrderID)+String(" Order nicht alles gelesen! bei:"),nPos);
    2491                 :            :                 }
    2492                 :          0 :                 pOS2MET->Seek(nPos+nOrderLen);
    2493                 :            :             }
    2494                 :            : 
    2495                 :          0 :             pOS2MET=pSave;
    2496                 :          0 :             if (pOrdFile->GetError()) {
    2497                 :          0 :                 pOS2MET->SetError(SVSTREAM_FILEFORMAT_ERROR);
    2498                 :          0 :                 ErrorCode=10;
    2499                 :            :             }
    2500                 :          0 :             delete pOrdFile; pOrdFile=NULL;
    2501                 :            :             break;
    2502                 :            :         }
    2503                 :            :         case DscGrfObjMagic: {
    2504                 :            :             sal_uLong nPos, nMaxPos;
    2505                 :            :             sal_uInt16 nDscID, nDscLen;
    2506                 :            :             sal_uInt8 nbyte;
    2507                 :            : 
    2508                 :          0 :             nMaxPos=pOS2MET->Tell()+(sal_uLong)nFieldSize;
    2509                 :          0 :             while (pOS2MET->Tell()<nMaxPos && pOS2MET->GetError()==0) {
    2510                 :          0 :                 *pOS2MET >> nbyte; nDscID =((sal_uInt16)nbyte) & 0x00ff;
    2511                 :          0 :                 *pOS2MET >> nbyte; nDscLen=((sal_uInt16)nbyte) & 0x00ff;
    2512                 :          0 :                 nPos=pOS2MET->Tell();
    2513                 :          0 :                 ReadDsc(nDscID, nDscLen);
    2514                 :          0 :                 pOS2MET->Seek(nPos+nDscLen);
    2515                 :            :             }
    2516                 :            :             break;
    2517                 :            :         }
    2518                 :            :         case DatGrfObjMagic: {
    2519                 :          0 :             if (pOrdFile==NULL) {
    2520                 :          0 :                 pOrdFile = new SvMemoryStream;
    2521                 :          0 :                 pOrdFile->SetNumberFormatInt(NUMBERFORMAT_INT_LITTLEENDIAN);
    2522                 :            :             }
    2523                 :          0 :             sal_uInt8 * pBuf; pBuf = new sal_uInt8[nFieldSize];
    2524                 :          0 :             pOS2MET->Read(pBuf,nFieldSize);
    2525                 :          0 :             pOrdFile->Write(pBuf,nFieldSize);
    2526                 :          0 :             delete[] pBuf;
    2527                 :          0 :             break;
    2528                 :            :         }
    2529                 :            :         case MapCodFntMagic:
    2530                 :          0 :             ReadFont(nFieldSize);
    2531                 :          0 :             break;
    2532                 :            : 
    2533                 :            :         case MapDatResMagic:
    2534                 :          0 :             break;
    2535                 :            :     }
    2536                 :            : }
    2537                 :            : 
    2538                 :          0 : void OS2METReader::ReadOS2MET( SvStream & rStreamOS2MET, GDIMetaFile & rGDIMetaFile )
    2539                 :            : {
    2540                 :            :     sal_uInt16 nFieldSize;
    2541                 :            :     sal_uInt16 nFieldType;
    2542                 :            :     sal_uLong nPos, nStartPos, nEndPos, nPercent, nLastPercent;
    2543                 :            :     sal_uInt8 nMagicByte;
    2544                 :            : 
    2545                 :          0 :     ErrorCode=0;
    2546                 :            : 
    2547                 :          0 :     pOS2MET             = &rStreamOS2MET;
    2548                 :          0 :     nOrigPos            = pOS2MET->Tell();
    2549                 :          0 :     nOrigNumberFormat   = pOS2MET->GetNumberFormatInt();
    2550                 :            : 
    2551                 :          0 :     bCoord32 = sal_True;
    2552                 :          0 :     pPaletteStack=NULL;
    2553                 :          0 :     pAreaStack=NULL;
    2554                 :          0 :     pPathStack=NULL;
    2555                 :          0 :     pPathList=NULL;
    2556                 :          0 :     pFontList=NULL;
    2557                 :          0 :     pBitmapList=NULL;
    2558                 :          0 :     pAttrStack=NULL;
    2559                 :            : 
    2560                 :          0 :     aDefAttr.aLinCol     =Color(COL_BLACK);
    2561                 :          0 :     aDefAttr.aLinBgCol   =Color(COL_WHITE);
    2562                 :          0 :     aDefAttr.eLinMix     =ROP_OVERPAINT;
    2563                 :          0 :     aDefAttr.eLinBgMix   =ROP_OVERPAINT;
    2564                 :          0 :     aDefAttr.aChrCol     =Color(COL_BLACK);
    2565                 :          0 :     aDefAttr.aChrBgCol   =Color(COL_WHITE);
    2566                 :          0 :     aDefAttr.eChrMix     =ROP_OVERPAINT;
    2567                 :          0 :     aDefAttr.eChrBgMix   =ROP_OVERPAINT;
    2568                 :          0 :     aDefAttr.aMrkCol     =Color(COL_BLACK);
    2569                 :          0 :     aDefAttr.aMrkBgCol   =Color(COL_WHITE);
    2570                 :          0 :     aDefAttr.eMrkMix     =ROP_OVERPAINT;
    2571                 :          0 :     aDefAttr.eMrkBgMix   =ROP_OVERPAINT;
    2572                 :          0 :     aDefAttr.aPatCol     =Color(COL_BLACK);
    2573                 :          0 :     aDefAttr.aPatBgCol   =Color(COL_WHITE);
    2574                 :          0 :     aDefAttr.ePatMix     =ROP_OVERPAINT;
    2575                 :          0 :     aDefAttr.ePatBgMix   =ROP_OVERPAINT;
    2576                 :          0 :     aDefAttr.aImgCol     =Color(COL_BLACK);
    2577                 :          0 :     aDefAttr.aImgBgCol   =Color(COL_WHITE);
    2578                 :          0 :     aDefAttr.eImgMix     =ROP_OVERPAINT;
    2579                 :          0 :     aDefAttr.eImgBgMix   =ROP_OVERPAINT;
    2580                 :          0 :     aDefAttr.nArcP       =1;
    2581                 :          0 :     aDefAttr.nArcQ       =1;
    2582                 :          0 :     aDefAttr.nArcR       =0;
    2583                 :          0 :     aDefAttr.nArcS       =0;
    2584                 :          0 :     aDefAttr.nChrAng     =0;
    2585                 :          0 :     aDefAttr.aChrCellSize=Size(12,12);
    2586                 :          0 :     aDefAttr.nChrSet     =0;
    2587                 :          0 :     aDefAttr.aCurPos     =Point(0,0);
    2588                 :          0 :     aDefAttr.eLinStyle   =PEN_SOLID;
    2589                 :          0 :     aDefAttr.nLinWidth   =0;
    2590                 :          0 :     aDefAttr.aMrkCellSize=Size(10,10);
    2591                 :          0 :     aDefAttr.nMrkPrec    =0x01;
    2592                 :          0 :     aDefAttr.nMrkSet     =0xff;
    2593                 :          0 :     aDefAttr.nMrkSymbol  =0x01;
    2594                 :          0 :     aDefAttr.bFill       =sal_True;
    2595                 :          0 :     aDefAttr.nStrLinWidth=0;
    2596                 :            : 
    2597                 :          0 :     aAttr=aDefAttr;
    2598                 :            : 
    2599                 :          0 :     pOrdFile=NULL;
    2600                 :            : 
    2601                 :          0 :     pVirDev = new VirtualDevice();
    2602                 :          0 :     pVirDev->EnableOutput(sal_False);
    2603                 :          0 :     rGDIMetaFile.Record(pVirDev);
    2604                 :            : 
    2605                 :          0 :     pOS2MET->SetNumberFormatInt(NUMBERFORMAT_INT_LITTLEENDIAN);
    2606                 :            : 
    2607                 :          0 :     nStartPos=pOS2MET->Tell();
    2608                 :          0 :     nEndPos=pOS2MET->Seek(STREAM_SEEK_TO_END); pOS2MET->Seek(nStartPos);
    2609                 :          0 :     Callback(0); nLastPercent=0;
    2610                 :            : 
    2611                 :          0 :     nPos=pOS2MET->Tell();
    2612                 :          0 :     if ( nStartPos == nEndPos )
    2613                 :            :     {
    2614                 :          0 :         nEndPos = 100;
    2615                 :          0 :         nStartPos = 0;
    2616                 :            :     }
    2617                 :            : 
    2618                 :          0 :     for (;;) {
    2619                 :            : 
    2620                 :          0 :         nPercent=(nPos-nStartPos)*100/(nEndPos-nStartPos);
    2621                 :          0 :         if (nLastPercent+4<=nPercent) {
    2622                 :          0 :             if (Callback((sal_uInt16)nPercent)==sal_True) break;
    2623                 :          0 :             nLastPercent=nPercent;
    2624                 :            :         }
    2625                 :            : 
    2626                 :          0 :         nFieldSize=ReadBigEndianWord();
    2627                 :            : 
    2628                 :          0 :         *pOS2MET >> nMagicByte;
    2629                 :          0 :         if (nMagicByte!=0xd3) {
    2630                 :          0 :             pOS2MET->SetError(SVSTREAM_FILEFORMAT_ERROR);
    2631                 :          0 :             ErrorCode=7;
    2632                 :          0 :             break;
    2633                 :            :         }
    2634                 :          0 :         *pOS2MET >> nFieldType;
    2635                 :            : 
    2636                 :          0 :         pOS2MET->SeekRel(3);
    2637                 :          0 :         nPos+=8; nFieldSize-=8;
    2638                 :            : 
    2639                 :          0 :         if (pOS2MET->GetError()) break;
    2640                 :          0 :         if (pOS2MET->IsEof()) {
    2641                 :          0 :             pOS2MET->SetError(SVSTREAM_FILEFORMAT_ERROR);
    2642                 :          0 :             ErrorCode=8;
    2643                 :          0 :             break;
    2644                 :            :         }
    2645                 :            : 
    2646                 :          0 :         if (nFieldType==EndDocumnMagic) break;
    2647                 :            : 
    2648                 :          0 :         ReadField(nFieldType, nFieldSize);
    2649                 :            : 
    2650                 :          0 :         nPos+=(sal_uLong)nFieldSize;
    2651                 :          0 :         if (pOS2MET->Tell()>nPos)  {
    2652                 :          0 :             pOS2MET->SetError(SVSTREAM_FILEFORMAT_ERROR);
    2653                 :          0 :             ErrorCode=9;
    2654                 :          0 :             break;
    2655                 :            :         }
    2656                 :          0 :         pOS2MET->Seek(nPos);
    2657                 :            :     }
    2658                 :            : 
    2659                 :          0 :     rGDIMetaFile.Stop();
    2660                 :          0 :     delete pVirDev;
    2661                 :            : 
    2662                 :          0 :     rGDIMetaFile.SetPrefMapMode( aGlobMapMode );
    2663                 :            : 
    2664                 :          0 :     if( aBoundingRect.GetWidth() && aBoundingRect.GetHeight() )
    2665                 :          0 :         rGDIMetaFile.SetPrefSize( aBoundingRect.GetSize() );
    2666                 :            :     else
    2667                 :            :     {
    2668                 :          0 :         if( aCalcBndRect.Left() || aCalcBndRect.Top() )
    2669                 :          0 :             rGDIMetaFile.Move( -aCalcBndRect.Left(), -aCalcBndRect.Top() );
    2670                 :            : 
    2671                 :          0 :         rGDIMetaFile.SetPrefSize( aCalcBndRect.GetSize() );
    2672                 :            :     }
    2673                 :            : 
    2674                 :          0 :     if (pOrdFile!=NULL) delete pOrdFile;
    2675                 :            : 
    2676                 :          0 :     while (pAreaStack!=NULL) {
    2677                 :          0 :         OSArea * p=pAreaStack;
    2678                 :          0 :         pAreaStack=p->pSucc;
    2679                 :          0 :         delete p;
    2680                 :            :     }
    2681                 :            : 
    2682                 :          0 :     while (pPathStack!=NULL) {
    2683                 :          0 :         OSPath * p=pPathStack;
    2684                 :          0 :         pPathStack=p->pSucc;
    2685                 :          0 :         delete p;
    2686                 :            :     }
    2687                 :            : 
    2688                 :          0 :     while (pPathList!=NULL) {
    2689                 :          0 :         OSPath * p=pPathList;
    2690                 :          0 :         pPathList=p->pSucc;
    2691                 :          0 :         delete p;
    2692                 :            :     }
    2693                 :            : 
    2694                 :          0 :     while (pFontList!=NULL) {
    2695                 :          0 :         OSFont * p=pFontList;
    2696                 :          0 :         pFontList=p->pSucc;
    2697                 :          0 :         delete p;
    2698                 :            :     }
    2699                 :            : 
    2700                 :          0 :     while (pBitmapList!=NULL) {
    2701                 :          0 :         OSBitmap * p=pBitmapList;
    2702                 :          0 :         pBitmapList=p->pSucc;
    2703                 :          0 :         if (p->pBMP!=NULL) delete p->pBMP;
    2704                 :          0 :         delete p;
    2705                 :            :     }
    2706                 :            : 
    2707                 :          0 :     while (pAttrStack!=NULL) {
    2708                 :          0 :         OSAttr * p=pAttrStack;
    2709                 :          0 :         pAttrStack=p->pSucc;
    2710                 :          0 :         delete p;
    2711                 :            :     }
    2712                 :            : 
    2713                 :          0 :     while (pPaletteStack!=NULL) {
    2714                 :          0 :         OSPalette * p=pPaletteStack;
    2715                 :          0 :         pPaletteStack=p->pSucc;
    2716                 :          0 :         if (p->p0RGB!=NULL) delete[] p->p0RGB;
    2717                 :          0 :         delete p;
    2718                 :            :     }
    2719                 :            : 
    2720                 :          0 :     pOS2MET->SetNumberFormatInt(nOrigNumberFormat);
    2721                 :            : 
    2722                 :          0 :     if (pOS2MET->GetError()) {
    2723                 :            :         OOODEBUG("Fehler Nr.:",ErrorCode);
    2724                 :          0 :         pOS2MET->Seek(nOrigPos);
    2725                 :            :     }
    2726                 :          0 : }
    2727                 :            : 
    2728                 :            : //================== GraphicImport - die exportierte Funktion ================
    2729                 :            : 
    2730                 :            : extern "C" SAL_DLLPUBLIC_EXPORT sal_Bool __LOADONCALLAPI
    2731                 :          0 : GraphicImport(SvStream & rStream, Graphic & rGraphic, FilterConfigItem*, sal_Bool)
    2732                 :            : {
    2733                 :          0 :     OS2METReader    aOS2METReader;
    2734                 :          0 :     GDIMetaFile     aMTF;
    2735                 :          0 :     sal_Bool            bRet = sal_False;
    2736                 :            : 
    2737                 :          0 :     aOS2METReader.ReadOS2MET( rStream, aMTF );
    2738                 :            : 
    2739                 :          0 :     if ( !rStream.GetError() )
    2740                 :            :     {
    2741                 :          0 :         rGraphic=Graphic( aMTF );
    2742                 :          0 :         bRet = sal_True;
    2743                 :            :     }
    2744                 :            : 
    2745                 :          0 :     return bRet;
    2746                 :            : }
    2747                 :            : 
    2748                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10