1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ios2met.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_goodies.hxx"
34 #include <vcl/graph.hxx>
35 #include <tools/poly.hxx>
36 #include <vcl/virdev.hxx>
37 #include <vcl/lineinfo.hxx>
38 #include <svtools/fltcall.hxx>
42 // MT: NOOLDSV, someone should change the code...
43 enum PenStyle
{ PEN_NULL
, PEN_SOLID
, PEN_DOT
, PEN_DASH
, PEN_DASHDOT
};
46 //============================== defines ===================================
48 #define OOODEBUG(str,Num) //InfoBox(NULL,String(str)+String(" ")+String(Num)).Execute();
50 // -----------------------------Feld-Typen-------------------------------
52 #define BegDocumnMagic 0xA8A8 /* Begin Document */
53 #define EndDocumnMagic 0xA8A9 /* End Document */
55 #define BegResGrpMagic 0xC6A8 /* Begin Resource Group */
56 #define EndResGrpMagic 0xC6A9 /* End Resource Group */
58 #define BegColAtrMagic 0x77A8 /* Begin Color Attribute Table */
59 #define EndColAtrMagic 0x77A9 /* End Color Attribute Table */
60 #define BlkColAtrMagic 0x77B0 /* Color Attribute Table */
61 #define MapColAtrMagic 0x77AB /* Map Color Attribute Table */
63 #define BegImgObjMagic 0xFBA8 /* Begin Image Object */
64 #define EndImgObjMagic 0xFBA9 /* End Image Object */
65 #define DscImgObjMagic 0xFBA6 /* Image Data Descriptor */
66 #define DatImgObjMagic 0xFBEE /* Image Picture Data */
68 #define BegObEnv1Magic 0xC7A8 /* Begin Object Environment Group */
69 #define EndObEnv1Magic 0xC7A9 /* End Object Environment Group */
71 #define BegGrfObjMagic 0xBBA8 /* Begin Graphics Object */
72 #define EndGrfObjMagic 0xBBA9 /* End Graphics Object */
73 #define DscGrfObjMagic 0xBBA6 /* Graphics Data Descritor */
74 #define DatGrfObjMagic 0xBBEE /* Graphics Data */
76 #define MapCodFntMagic 0x8AAB /* Map Coded Font */
77 #define MapDatResMagic 0xC3AB /* Map Data Resource */
79 // -----------------------------Order-Typen-------------------------------
81 #define GOrdGivArc 0xC6 /* 1 Arc at given position */
82 #define GOrdCurArc 0x86 /* 1 Arc at current position */
83 #define GOrdGivBzr 0xE5 /* 1 Beziercurve at given position */
84 #define GOrdCurBzr 0xA5 /* 1 Beziercurve at current position */
85 #define GOrdGivBox 0xC0 /* 1 Box at given position */
86 #define GOrdCurBox 0x80 /* 1 Box at current position */
87 #define GOrdGivFil 0xC5 /* 1 Fillet at given position */
88 #define GOrdCurFil 0x85 /* 1 Fillet at current position */
89 #define GOrdGivCrc 0xC7 /* 1 Full arc (circle) at given position */
90 #define GOrdCurCrc 0x87 /* 1 Full arc (circle) at current position */
91 #define GOrdGivLin 0xC1 /* 1 Line at given position */
92 #define GOrdCurLin 0x81 /* 1 Line at current position */
93 #define GOrdGivMrk 0xC2 /* 1 Marker at given position */
94 #define GOrdCurMrk 0x82 /* 1 Marker at current position */
95 #define GOrdGivArP 0xE3 /* 1 Partial arc at given position */
96 #define GOrdCurArP 0xA3 /* 1 Partial arc at current position */
97 #define GOrdGivRLn 0xE1 /* 1 Relative line at given position */
98 #define GOrdCurRLn 0xA1 /* 1 Relative line at current position */
99 #define GOrdGivSFl 0xE4 /* 1 Sharp fillet at given position */
100 #define GOrdCurSFl 0xA4 /* 1 Sharp fillet at current position */
102 #define GOrdGivStM 0xF1 /* 1 Character string move at given position */
103 #define GOrdCurStM 0xB1 /* 1 Character string move at current position */
104 #define GOrdGivStr 0xC3 /* 1 Character string at given position */
105 #define GOrdCurStr 0x83 /* 1 Character string at current position */
106 #define GOrdGivStx 0xFEF0 /* 2 Character string extended at given position */
107 #define GOrdCurStx 0xFEB0 /* 2 Character string extended at current position */
109 #define GOrdGivImg 0xD1 /* 1 Begin Image at given position */
110 #define GOrdCurImg 0x91 /* 1 Begin Image at current position */
111 #define GOrdImgDat 0x92 /* 1 Image data */
112 #define GOrdEndImg 0x93 /* 1 End Image */
113 #define GOrdBegAra 0x68 /* 0 1 Begin area */
114 #define GOrdEndAra 0x60 /* 1 End area */
115 #define GOrdBegElm 0xD2 /* 1 Begin element */
116 #define GOrdEndElm 0x49 /* 0 1 End element */
118 #define GOrdBegPth 0xD0 /* 1 Begin path */
119 #define GOrdEndPth 0x7F /* 0 1 End path */
120 #define GOrdFilPth 0xD7 /* 1 Fill path */
121 #define GOrdModPth 0xD8 /* 1 Modify path */
122 #define GOrdOutPth 0xD4 /* 1 Outline path */
123 #define GOrdSClPth 0xB4 /* 1 Set clip path */
125 #define GOrdNopNop 0x00 /* 0 0 No operation */
126 #define GOrdRemark 0x01 /* 1 Comment */
127 #define GOrdSegLab 0xD3 /* 1 Label */
128 #define GOrdBitBlt 0xD6 /* 1 Bitblt */
129 #define GOrdCalSeg 0x07 /* 1 Call Segment */
130 #define GOrdSSgBnd 0x32 /* 1 Set segment boundary */
131 #define GOrdSegChr 0x04 /* 1 Segment characteristics */
132 #define GOrdCloFig 0x7D /* 0 1 Close Figure */
133 #define GOrdEndSym 0xFF /* 0 0 End of symbol definition */
134 #define GOrdEndPlg 0x3E /* 0 1 End prolog */
135 #define GOrdEscape 0xD5 /* 1 Escape */
136 #define GOrdExtEsc 0xFED5 /* 2 Extended Escape */
137 #define GOrdPolygn 0xF3 /* 2 Polygons */
139 #define GOrdStkPop 0x3F /* 0 1 Pop */
141 #define GOrdSIvAtr 0x14 /* 1 Set individual attribute */
142 #define GOrdPIvAtr 0x54 /* 1 Push and set individual attribute */
143 #define GOrdSColor 0x0A /* 0 1 Set color */
144 #define GOrdPColor 0x4A /* 0 1 Push and set color */
145 #define GOrdSIxCol 0xA6 /* 1 Set indexed color */
146 #define GOrdPIxCol 0xE6 /* 1 Push and set indexed color */
147 #define GOrdSXtCol 0x26 /* 1 Set extended color */
148 #define GOrdPXtCol 0x66 /* 1 Push and set extended color */
149 #define GOrdSBgCol 0x25 /* 1 Set background color */
150 #define GOrdPBgCol 0x65 /* 1 Push and set background color */
151 #define GOrdSBxCol 0xA7 /* 1 Set background indexed color */
152 #define GOrdPBxCol 0xE7 /* 1 Push and set background indexed color */
153 #define GOrdSMixMd 0x0C /* 0 1 Set mix */
154 #define GOrdPMixMd 0x4C /* 0 1 Push and set mix */
155 #define GOrdSBgMix 0x0D /* 0 1 Set background mix */
156 #define GOrdPBgMix 0x4D /* 0 1 Push and set background mix */
158 #define GOrdSPtSet 0x08 /* 0 1 Set pattern set */
159 #define GOrdPPtSet 0x48 /* 0 1 Push and set pattern set */
160 #define GOrdSPtSym 0x28 /* 0 1 Set pattern symbol */
161 #define GOrdPPtSym 0x09 /* 0 1 Push and set pattern symbol */
162 #define GOrdSPtRef 0xA0 /* 1 Set model pattern reference */
163 #define GOrdPPtRef 0xE0 /* 1 Push and set pattern reference point */
165 #define GOrdSLnEnd 0x1A /* 0 1 Set line end */
166 #define GOrdPLnEnd 0x5A /* 0 1 Push and set line end */
167 #define GOrdSLnJoi 0x1B /* 0 1 Set line join */
168 #define GOrdPLnJoi 0x5B /* 0 1 Push and set line join */
169 #define GOrdSLnTyp 0x18 /* 0 1 Set line type */
170 #define GOrdPLnTyp 0x58 /* 0 1 Push and set line type */
171 #define GOrdSLnWdt 0x19 /* 0 1 Set line width */
172 #define GOrdPLnWdt 0x59 /* 0 1 Push and set line width */
173 #define GOrdSFrLWd 0x11 /* 1 Set fractional line width */
174 #define GOrdPFrLWd 0x51 /* 1 Push and set fractional line width */
175 #define GOrdSStLWd 0x15 /* 1 Set stroke line width */
176 #define GOrdPStLWd 0x55 /* 1 Push and set stroke line width */
178 #define GOrdSChDir 0x3A /* 0 1 Set character direction */
179 #define GOrdPChDir 0x7A /* 0 1 Push and set character direction */
180 #define GOrdSChPrc 0x39 /* 0 1 Set character precision */
181 #define GOrdPChPrc 0x79 /* 0 1 Push and set character precision */
182 #define GOrdSChSet 0x38 /* 0 1 Set character set */
183 #define GOrdPChSet 0x78 /* 0 1 Push and set character set */
184 #define GOrdSChAng 0x34 /* 1 Set character angle */
185 #define GOrdPChAng 0x74 /* 1 Push and set character angle */
186 #define GOrdSChBrx 0x05 /* 1 Set character break extra */
187 #define GOrdPChBrx 0x45 /* 1 Push and set character break extra */
188 #define GOrdSChCel 0x33 /* 1 Set character cell */
189 #define GOrdPChCel 0x03 /* 1 Push and set character cell */
190 #define GOrdSChXtr 0x17 /* 1 Set character extra */
191 #define GOrdPChXtr 0x57 /* 1 Push and set character extra */
192 #define GOrdSChShr 0x35 /* 1 Set character shear */
193 #define GOrdPChShr 0x75 /* 1 Push and set character shear */
194 #define GOrdSTxAlg 0x36 /* 0 2 Set text allingment */
195 #define GOrdPTxAlg 0x76 /* 0 2 Push and set text allingment */
197 #define GOrdSMkPrc 0x3B /* 0 1 Set marker precision */
198 #define GOrdPMkPrc 0x7B /* 0 1 Push and set marker precision */
199 #define GOrdSMkSet 0x3C /* 0 1 Set marker set */
200 #define GOrdPMkSet 0x7C /* 0 1 Push and set marker set */
201 #define GOrdSMkSym 0x29 /* 0 1 Set marker symbol */
202 #define GOrdPMkSym 0x69 /* 0 1 Push and set marker symbol */
203 #define GOrdSMkCel 0x37 /* 1 Set marker cell */
204 #define GOrdPMkCel 0x77 /* 1 Push and set marker cell */
206 #define GOrdSArcPa 0x22 /* 1 Set arc parameters */
207 #define GOrdPArcPa 0x62 /* 1 Push and set arc parameters */
209 #define GOrdSCrPos 0x21 /* 1 Set current position */
210 #define GOrdPCrPos 0x61 /* 1 Push and set current position */
212 #define GOrdSMdTrn 0x24 /* 1 Set model transform */
213 #define GOrdPMdTrn 0x64 /* 1 Push and set model transform */
214 #define GOrdSPkIdn 0x43 /* 1 Set pick identifier */
215 #define GOrdPPkIdn 0x23 /* 1 Push and set pick identifier */
216 #define GOrdSVwTrn 0x31 /* 1 Set viewing transform */
217 #define GOrdSVwWin 0x27 /* 1 Set viewing window */
218 #define GOrdPVwWin 0x67 /* 1 Push and set viewing window */
220 //============================ OS2METReader ==================================
224 sal_uInt32
* p0RGB
; // Darf auch NULL sein!
238 OSArea(){} ~OSArea(){}
257 OSFont(){} ~OSFont(){}
265 // Waehrend des Lesens der Bitmap benoetigt:
266 SvStream
* pBMP
; // Zeiger auf temporaere Windows-BMP-Datei oder NULL
267 sal_uInt32 nWidth
, nHeight
;
268 USHORT nBitsPerPixel
;
270 OSBitmap(){} ~OSBitmap(){}
276 BYTE nIvAttrA
, nIvAttrP
; // Spezialvariablen fuer den Order "GOrdPIvAtr"
298 long nArcP
, nArcQ
, nArcR
, nArcS
;
300 // long nChrBreakExtra;
308 // long nFracLinWidth;
317 // //... aModTransform;
324 // BYTE nTxtAlignHor,nTxtAlignVer;
325 // //... aViewTransform;
326 // //... aViewWindow;
327 OSAttr(){} ~OSAttr(){}
336 SvStream
* pOS2MET
; // Die einzulesende OS2MET-Datei
337 VirtualDevice
* pVirDev
; // Hier werden die Drawing-Methoden aufgerufen.
338 // Dabei findet ein Recording in das GDIMetaFile
340 ULONG nOrigPos
; // Anfaengliche Position in pOS2MET
341 UINT16 nOrigNumberFormat
; // Anfaengliches Nummern-Format von pOS2MET
342 Rectangle aBoundingRect
; // Boundingrectangle wie in Datei angegeben
343 Rectangle aCalcBndRect
; // selbst ermitteltes Boundingrectangle
344 MapMode aGlobMapMode
; // Aufloesung des Bildes
347 OSPalette
* pPaletteStack
;
351 OSArea
* pAreaStack
; // Areas, die in Arbeit sind
353 OSPath
* pPathStack
; // Paths, die in Arbeit sind
354 OSPath
* pPathList
; // Vollendete Paths
358 OSBitmap
* pBitmapList
;
366 BOOL
Callback(USHORT nPercent
);
368 void AddPointsToPath(const Polygon
& rPoly
);
369 void AddPointsToArea(const Polygon
& rPoly
);
371 void PushAttr(USHORT nPushOrder
);
374 void ChangeBrush( const Color
& rPatColor
, const Color
& rBGColor
, BOOL bFill
);
375 void SetPen( const Color
& rColor
, USHORT nStrLinWidth
= 0, PenStyle ePenStyle
= PEN_SOLID
);
376 void SetRasterOp(RasterOp eROP
);
378 void SetPalette0RGB(USHORT nIndex
, ULONG nCol
);
379 sal_uInt32
GetPalette0RGB(sal_uInt32 nIndex
);
380 // Holt Farbe aus der Palette, oder, wenn nicht vorhanden,
381 // interpretiert nIndex als direkten RGB-Wert.
382 Color
GetPaletteColor(sal_uInt32 nIndex
);
386 void DrawPolyLine( const Polygon
& rPolygon
);
387 void DrawPolygon( const Polygon
& rPolygon
);
388 void DrawPolyPolygon( const PolyPolygon
& rPolygon
);
389 USHORT
ReadBigEndianWord();
390 ULONG
ReadBigEndian3BytesLong();
391 ULONG
ReadLittleEndian3BytesLong();
392 long ReadCoord(BOOL b32
);
393 Point
ReadPoint( const BOOL bAdjustBoundRect
= TRUE
);
394 RasterOp
OS2MixToRasterOp(BYTE nMix
);
395 void ReadLine(BOOL bGivenPos
, USHORT nOrderLen
);
396 void ReadRelLine(BOOL bGivenPos
, USHORT nOrderLen
);
397 void ReadBox(BOOL bGivenPos
);
399 void ReadChrStr(BOOL bGivenPos
, BOOL bMove
, BOOL bExtra
, USHORT nOrderLen
);
400 void ReadArc(BOOL bGivenPos
);
401 void ReadFullArc(BOOL bGivenPos
, USHORT nOrderSize
);
402 void ReadPartialArc(BOOL bGivenPos
, USHORT nOrderSize
);
404 void ReadBezier(BOOL bGivenPos
, USHORT nOrderLen
);
405 void ReadFillet(BOOL bGivenPos
, USHORT nOrderLen
);
406 void ReadFilletSharp(BOOL bGivenPos
, USHORT nOrderLen
);
407 void ReadMarker(BOOL bGivenPos
, USHORT nOrderLen
);
408 void ReadOrder(USHORT nOrderID
, USHORT nOrderLen
);
409 void ReadDsc(USHORT nDscID
, USHORT nDscLen
);
410 void ReadImageData(USHORT nDataID
, USHORT nDataLen
);
411 void ReadFont(USHORT nFieldSize
);
412 void ReadField(USHORT nFieldType
, USHORT nFieldSize
);
419 void ReadOS2MET( SvStream
& rStreamOS2MET
, GDIMetaFile
& rGDIMetaFile
);
420 // Liesst aus dem Stream eine OS2MET-Datei und fuellt das GDIMetaFile
424 //=================== Methoden von OS2METReader ==============================
426 BOOL
OS2METReader::Callback(USHORT
/*nPercent*/)
429 if (pCallback!=NULL) {
430 if (((*pCallback)(pCallerData,nPercent))==TRUE) {
431 pOS2MET->SetError(SVSTREAM_FILEFORMAT_ERROR);
439 OS2METReader::OS2METReader()
443 OS2METReader::~OS2METReader()
447 BOOL
OS2METReader::IsLineInfo()
449 return ( ! ( aLineInfo
.IsDefault() || ( aLineInfo
.GetStyle() == LINE_NONE
) || ( pVirDev
->GetLineColor() == COL_TRANSPARENT
) ) );
452 void OS2METReader::DrawPolyLine( const Polygon
& rPolygon
)
454 if ( aLineInfo
.GetStyle() == LINE_DASH
|| ( aLineInfo
.GetWidth() > 1 ) )
455 pVirDev
->DrawPolyLine( rPolygon
, aLineInfo
);
457 pVirDev
->DrawPolyLine( rPolygon
);
460 void OS2METReader::DrawPolygon( const Polygon
& rPolygon
)
464 pVirDev
->Push( PUSH_LINECOLOR
);
465 pVirDev
->SetLineColor( COL_TRANSPARENT
);
466 pVirDev
->DrawPolygon( rPolygon
);
468 pVirDev
->DrawPolyLine( rPolygon
, aLineInfo
);
471 pVirDev
->DrawPolygon( rPolygon
);
474 void OS2METReader::DrawPolyPolygon( const PolyPolygon
& rPolyPolygon
)
478 pVirDev
->Push( PUSH_LINECOLOR
);
479 pVirDev
->SetLineColor( COL_TRANSPARENT
);
480 pVirDev
->DrawPolyPolygon( rPolyPolygon
);
482 for ( USHORT i
= 0; i
< rPolyPolygon
.Count(); i
++ )
483 pVirDev
->DrawPolyLine( rPolyPolygon
.GetObject( i
), aLineInfo
);
486 pVirDev
->DrawPolyPolygon( rPolyPolygon
);
489 void OS2METReader::AddPointsToArea(const Polygon
& rPoly
)
491 USHORT nOldSize
, nNewSize
,i
;
493 if (pAreaStack
==NULL
|| rPoly
.GetSize()==0) return;
494 PolyPolygon
* pPP
=&(pAreaStack
->aPPoly
);
495 if (pPP
->Count()==0 || pAreaStack
->bClosed
==TRUE
) pPP
->Insert(rPoly
);
497 Polygon
aLastPoly(pPP
->GetObject(pPP
->Count()-1));
498 nOldSize
=aLastPoly
.GetSize();
499 if (aLastPoly
.GetPoint(nOldSize
-1)==rPoly
.GetPoint(0)) nOldSize
--;
500 nNewSize
=nOldSize
+rPoly
.GetSize();
501 aLastPoly
.SetSize(nNewSize
);
502 for (i
=nOldSize
; i
<nNewSize
; i
++) {
503 aLastPoly
.SetPoint(rPoly
.GetPoint(i
-nOldSize
),i
);
505 pPP
->Replace(aLastPoly
,pPP
->Count()-1);
507 pAreaStack
->bClosed
=FALSE
;
510 void OS2METReader::AddPointsToPath(const Polygon
& rPoly
)
512 USHORT nOldSize
, nNewSize
,i
;
514 if (pPathStack
==NULL
|| rPoly
.GetSize()==0) return;
515 PolyPolygon
* pPP
=&(pPathStack
->aPPoly
);
516 if (pPP
->Count()==0 /*|| pPathStack->bClosed==TRUE*/) pPP
->Insert(rPoly
);
518 Polygon
aLastPoly(pPP
->GetObject(pPP
->Count()-1));
519 nOldSize
=aLastPoly
.GetSize();
520 if (aLastPoly
.GetPoint(nOldSize
-1)!=rPoly
.GetPoint(0)) pPP
->Insert(rPoly
);
523 nNewSize
=nOldSize
+rPoly
.GetSize();
524 aLastPoly
.SetSize(nNewSize
);
525 for (i
=nOldSize
; i
<nNewSize
; i
++) {
526 aLastPoly
.SetPoint(rPoly
.GetPoint(i
-nOldSize
),i
);
528 pPP
->Replace(aLastPoly
,pPP
->Count()-1);
531 pPathStack
->bClosed
=FALSE
;
534 void OS2METReader::CloseFigure()
536 if (pAreaStack
!=NULL
) pAreaStack
->bClosed
=TRUE
;
537 else if (pPathStack
!=NULL
) pPathStack
->bClosed
=TRUE
;
540 void OS2METReader::PushAttr(USHORT nPushOrder
)
545 p
->pSucc
=pAttrStack
; pAttrStack
=p
;
546 p
->nPushOrder
=nPushOrder
;
549 void OS2METReader::PopAttr()
551 OSAttr
* p
=pAttrStack
;
554 switch (p
->nPushOrder
) {
557 switch (p
->nIvAttrA
) {
558 case 1: switch (p
->nIvAttrP
) {
559 case 1: aAttr
.aLinCol
=p
->aLinCol
; break;
560 case 2: aAttr
.aChrCol
=p
->aChrCol
; break;
561 case 3: aAttr
.aMrkCol
=p
->aMrkCol
; break;
562 case 4: aAttr
.aPatCol
=p
->aPatCol
; break;
563 case 5: aAttr
.aImgCol
=p
->aImgCol
; break;
565 case 2: switch (p
->nIvAttrP
) {
566 case 1: aAttr
.aLinBgCol
=p
->aLinBgCol
; break;
567 case 2: aAttr
.aChrBgCol
=p
->aChrBgCol
; break;
568 case 3: aAttr
.aMrkBgCol
=p
->aMrkBgCol
; break;
569 case 4: aAttr
.aPatBgCol
=p
->aPatBgCol
; break;
570 case 5: aAttr
.aImgBgCol
=p
->aImgBgCol
; break;
572 case 3: switch (p
->nIvAttrP
) {
573 case 1: aAttr
.eLinMix
=p
->eLinMix
; break;
574 case 2: aAttr
.eChrMix
=p
->eChrMix
; break;
575 case 3: aAttr
.eMrkMix
=p
->eMrkMix
; break;
576 case 4: aAttr
.ePatMix
=p
->ePatMix
; break;
577 case 5: aAttr
.eImgMix
=p
->eImgMix
; break;
579 case 4: switch (p
->nIvAttrP
) {
580 case 1: aAttr
.eLinBgMix
=p
->eLinBgMix
; break;
581 case 2: aAttr
.eChrBgMix
=p
->eChrBgMix
; break;
582 case 3: aAttr
.eMrkBgMix
=p
->eMrkBgMix
; break;
583 case 4: aAttr
.ePatBgMix
=p
->ePatBgMix
; break;
584 case 5: aAttr
.eImgBgMix
=p
->eImgBgMix
; break;
589 case GOrdPLnTyp
: aAttr
.eLinStyle
=p
->eLinStyle
; break;
591 case GOrdPLnWdt
: aAttr
.nLinWidth
=p
->nLinWidth
; break;
593 case GOrdPStLWd
: aAttr
.nStrLinWidth
=p
->nStrLinWidth
; break;
595 case GOrdPChSet
: aAttr
.nChrSet
=p
->nChrSet
; break;
597 case GOrdPChAng
: aAttr
.nChrAng
=p
->nChrAng
; break;
600 aAttr
.eLinMix
=p
->eLinMix
;
601 aAttr
.eChrMix
=p
->eChrMix
;
602 aAttr
.eMrkMix
=p
->eMrkMix
;
603 aAttr
.ePatMix
=p
->ePatMix
;
604 aAttr
.eImgMix
=p
->eImgMix
;
608 aAttr
.eLinBgMix
=p
->eLinBgMix
;
609 aAttr
.eChrBgMix
=p
->eChrBgMix
;
610 aAttr
.eMrkBgMix
=p
->eMrkBgMix
;
611 aAttr
.ePatBgMix
=p
->ePatBgMix
;
612 aAttr
.eImgBgMix
=p
->eImgBgMix
;
615 case GOrdPPtSym
: aAttr
.bFill
= p
->bFill
; break;
620 aAttr
.aLinCol
=p
->aLinCol
;
621 aAttr
.aChrCol
=p
->aChrCol
;
622 aAttr
.aMrkCol
=p
->aMrkCol
;
623 aAttr
.aPatCol
=p
->aPatCol
;
624 aAttr
.aImgCol
=p
->aImgCol
;
629 aAttr
.aLinBgCol
=p
->aLinBgCol
;
630 aAttr
.aChrBgCol
=p
->aChrBgCol
;
631 aAttr
.aMrkBgCol
=p
->aMrkBgCol
;
632 aAttr
.aPatBgCol
=p
->aPatBgCol
;
633 aAttr
.aImgBgCol
=p
->aImgBgCol
;
636 case GOrdPMkPrc
: aAttr
.nMrkPrec
=aDefAttr
.nMrkPrec
; break;
638 case GOrdPMkSet
: aAttr
.nMrkSet
=aDefAttr
.nMrkSet
; break;
640 case GOrdPMkSym
: aAttr
.nMrkSymbol
=aDefAttr
.nMrkSymbol
; break;
642 case GOrdPMkCel
: aAttr
.aMrkCellSize
=aDefAttr
.aMrkCellSize
; break;
645 aAttr
.nArcP
=p
->nArcP
; aAttr
.nArcQ
=p
->nArcQ
;
646 aAttr
.nArcR
=p
->nArcR
; aAttr
.nArcS
=p
->nArcS
;
650 aAttr
.aCurPos
=p
->aCurPos
;
657 void OS2METReader::ChangeBrush(const Color
& rPatColor
, const Color
& /*rBGColor*/, BOOL bFill
)
664 aColor
= Color( COL_TRANSPARENT
);
666 if( pVirDev
->GetFillColor() != aColor
)
667 pVirDev
->SetFillColor( aColor
);
670 void OS2METReader::SetPen( const Color
& rColor
, USHORT nLineWidth
, PenStyle ePenStyle
)
672 LineStyle
eLineStyle( LINE_SOLID
);
674 if ( pVirDev
->GetLineColor() != rColor
)
675 pVirDev
->SetLineColor( rColor
);
676 aLineInfo
.SetWidth( nLineWidth
);
678 USHORT nDotCount
= 0;
679 USHORT nDashCount
= 0;
683 eLineStyle
= LINE_NONE
;
692 aLineInfo
.SetDotCount( nDotCount
);
693 aLineInfo
.SetDashCount( nDashCount
);
694 aLineInfo
.SetDistance( nLineWidth
);
695 aLineInfo
.SetDotLen( nLineWidth
);
696 aLineInfo
.SetDashLen( nLineWidth
<< 2 );
697 eLineStyle
= LINE_DASH
;
700 break; // -Wall not handled...
702 aLineInfo
.SetStyle( eLineStyle
);
705 void OS2METReader::SetRasterOp(RasterOp eROP
)
707 if (pVirDev
->GetRasterOp()!=eROP
) pVirDev
->SetRasterOp(eROP
);
711 void OS2METReader::SetPalette0RGB(USHORT nIndex
, ULONG nCol
)
713 if (pPaletteStack
==NULL
) {
714 pPaletteStack
=new OSPalette
;
715 pPaletteStack
->pSucc
=NULL
;
716 pPaletteStack
->p0RGB
=NULL
;
717 pPaletteStack
->nSize
=0;
719 if (pPaletteStack
->p0RGB
==NULL
|| nIndex
>=pPaletteStack
->nSize
) {
720 sal_uInt32
* pOld0RGB
=pPaletteStack
->p0RGB
;
721 USHORT i
,nOldSize
=pPaletteStack
->nSize
;
722 if (pOld0RGB
==NULL
) nOldSize
=0;
723 pPaletteStack
->nSize
=2*(nIndex
+1);
724 if (pPaletteStack
->nSize
<256) pPaletteStack
->nSize
=256;
725 pPaletteStack
->p0RGB
= new sal_uInt32
[pPaletteStack
->nSize
];
726 for (i
=0; i
<pPaletteStack
->nSize
; i
++) {
727 if (i
<nOldSize
) pPaletteStack
->p0RGB
[i
]=pOld0RGB
[i
];
728 else if (i
==0) pPaletteStack
->p0RGB
[i
]=0x00ffffff;
729 else pPaletteStack
->p0RGB
[i
]=0;
731 if (pOld0RGB
!=NULL
) delete[] pOld0RGB
;
733 pPaletteStack
->p0RGB
[nIndex
]=nCol
;
736 sal_uInt32
OS2METReader::GetPalette0RGB(sal_uInt32 nIndex
)
738 if (pPaletteStack
!=NULL
&& pPaletteStack
->p0RGB
!=NULL
&&
739 pPaletteStack
->nSize
>nIndex
) nIndex
=pPaletteStack
->p0RGB
[nIndex
];
743 Color
OS2METReader::GetPaletteColor(sal_uInt32 nIndex
)
745 nIndex
=GetPalette0RGB(nIndex
);
746 return Color(sal::static_int_cast
< UINT8
>((nIndex
>>16)&0xff),
747 sal::static_int_cast
< UINT8
>((nIndex
>>8)&0xff),
748 sal::static_int_cast
< UINT8
>(nIndex
&0xff));
752 USHORT
OS2METReader::ReadBigEndianWord()
755 *pOS2MET
>> nHi
>> nLo
;
756 return (((USHORT
)nHi
)<<8)|(((USHORT
)nLo
)&0x00ff);
759 ULONG
OS2METReader::ReadBigEndian3BytesLong()
764 nLo
=ReadBigEndianWord();
765 return ((((ULONG
)nHi
)<<16)&0x00ff0000)|((ULONG
)nLo
);
768 ULONG
OS2METReader::ReadLittleEndian3BytesLong()
772 *pOS2MET
>> nLo
>> nMed
>> nHi
;
773 return ((((ULONG
)nHi
)&0xff)<<16)|((((ULONG
)nMed
)&0xff)<<8)|(((ULONG
)nLo
)&0xff);
776 long OS2METReader::ReadCoord(BOOL b32
)
781 if (b32
) *pOS2MET
>> l
;
782 else { *pOS2MET
>> s
; l
=(long)s
; }
786 Point
OS2METReader::ReadPoint( const BOOL bAdjustBoundRect
)
790 x
=ReadCoord(bCoord32
);
791 y
=ReadCoord(bCoord32
);
792 x
=x
-aBoundingRect
.Left();
793 y
=aBoundingRect
.Bottom()-y
;
795 if ( bAdjustBoundRect
)
796 aCalcBndRect
.Union(Rectangle(x
,y
,x
+1,y
+1));
801 RasterOp
OS2METReader::OS2MixToRasterOp(BYTE nMix
)
804 case 0x0c: return ROP_INVERT
;
805 case 0x04: return ROP_XOR
;
806 case 0x0b: return ROP_XOR
;
807 default: return ROP_OVERPAINT
;
811 void OS2METReader::ReadLine(BOOL bGivenPos
, USHORT nOrderLen
)
815 if (bCoord32
) nPolySize
=nOrderLen
/8; else nPolySize
=nOrderLen
/4;
816 if (!bGivenPos
) nPolySize
++;
817 if (nPolySize
==0) return;
818 Polygon
aPolygon(nPolySize
);
819 for (i
=0; i
<nPolySize
; i
++) {
820 if (i
==0 && !bGivenPos
) aPolygon
.SetPoint(aAttr
.aCurPos
,i
);
821 else aPolygon
.SetPoint(ReadPoint(),i
);
823 aAttr
.aCurPos
=aPolygon
.GetPoint(nPolySize
-1);
824 if (pAreaStack
!=NULL
) AddPointsToArea(aPolygon
);
825 else if (pPathStack
!=NULL
) AddPointsToPath(aPolygon
);
828 SetPen( aAttr
.aLinCol
, aAttr
.nStrLinWidth
, aAttr
.eLinStyle
);
829 SetRasterOp(aAttr
.eLinMix
);
830 DrawPolyLine( aPolygon
);
834 void OS2METReader::ReadRelLine(BOOL bGivenPos
, USHORT nOrderLen
)
842 if (bCoord32
) nOrderLen
-=8; else nOrderLen
-=4;
844 else aP0
=aAttr
.aCurPos
;
845 nPolySize
=nOrderLen
/2;
846 if (nPolySize
==0) return;
847 Polygon
aPolygon(nPolySize
);
848 for (i
=0; i
<nPolySize
; i
++) {
849 #if (defined SOLARIS && defined PPC) || defined IRIX
851 *pOS2MET
>> nunsignedbyte
; aP0
.X()+=(INT8
)nunsignedbyte
;
852 *pOS2MET
>> nunsignedbyte
; aP0
.Y()+=(INT8
)nunsignedbyte
;
855 *pOS2MET
>> nsignedbyte
; aP0
.X()+=(long)nsignedbyte
;
856 *pOS2MET
>> nsignedbyte
; aP0
.Y()-=(long)nsignedbyte
;
858 aCalcBndRect
.Union(Rectangle(aP0
,Size(1,1)));
859 aPolygon
.SetPoint(aP0
,i
);
861 aAttr
.aCurPos
=aPolygon
.GetPoint(nPolySize
-1);
862 if (pAreaStack
!=NULL
) AddPointsToArea(aPolygon
);
863 else if (pPathStack
!=NULL
) AddPointsToPath(aPolygon
);
866 SetPen( aAttr
.aLinCol
, aAttr
.nStrLinWidth
, aAttr
.eLinStyle
);
867 SetRasterOp(aAttr
.eLinMix
);
868 DrawPolyLine( aPolygon
);
872 void OS2METReader::ReadBox(BOOL bGivenPos
)
876 long nHRound
,nVRound
;
886 aAttr
.aCurPos
=ReadPoint();
887 nHRound
=ReadCoord(bCoord32
);
888 nVRound
=ReadCoord(bCoord32
);
890 Rectangle
aBoxRect( P0
, aAttr
.aCurPos
);
893 AddPointsToArea( Polygon( aBoxRect
) );
894 else if ( pPathStack
)
895 AddPointsToPath( Polygon( aBoxRect
) );
899 SetPen( aAttr
.aLinCol
, aAttr
.nStrLinWidth
, aAttr
.eLinStyle
);
901 SetPen( COL_TRANSPARENT
);
905 ChangeBrush(aAttr
.aPatCol
,aAttr
.aPatBgCol
,aAttr
.bFill
);
906 SetRasterOp(aAttr
.ePatMix
);
910 ChangeBrush( Color( COL_TRANSPARENT
), Color( COL_TRANSPARENT
), FALSE
);
911 SetRasterOp(aAttr
.eLinMix
);
916 Polygon
aPolygon( aBoxRect
, nHRound
, nVRound
);
919 pVirDev
->Push( PUSH_LINECOLOR
);
920 pVirDev
->SetLineColor( COL_TRANSPARENT
);
921 pVirDev
->DrawRect( aBoxRect
, nHRound
, nVRound
);
924 pVirDev
->DrawPolyLine( aPolygon
, aLineInfo
);
927 pVirDev
->DrawRect( aBoxRect
, nHRound
, nVRound
);
931 void OS2METReader::ReadBitBlt()
942 aP1
=ReadPoint(); aP2
=ReadPoint();
943 if (aP1
.X() > aP2
.X()) { nt
=aP1
.X(); aP1
.X()=aP2
.X(); aP2
.X()=nt
; }
944 if (aP1
.Y() > aP2
.Y()) { nt
=aP1
.Y(); aP1
.Y()=aP2
.Y(); aP2
.Y()=nt
; }
945 aSize
=Size(aP2
.X()-aP1
.X(),aP2
.Y()-aP1
.Y());
948 while (pB
!=NULL
&& pB
->nID
!=nID
) pB
=pB
->pSucc
;
950 SetRasterOp(aAttr
.ePatMix
);
951 pVirDev
->DrawBitmap(aP1
,aSize
,pB
->aBitmap
);
955 void OS2METReader::ReadChrStr(BOOL bGivenPos
, BOOL bMove
, BOOL bExtra
, USHORT nOrderLen
)
965 while (pF
!=NULL
&& pF
->nID
!=aAttr
.nChrSet
) pF
=pF
->pSucc
;
968 aFont
.SetColor(aAttr
.aChrCol
);
969 aFont
.SetSize(Size(0,aAttr
.aChrCellSize
.Height()));
970 if ( aAttr
.nChrAng
!= 0 )
971 aFont
.SetOrientation(aAttr
.nChrAng
);
993 pChr
= new char[nLen
+1];
994 for (i
=0; i
<nLen
; i
++)
997 String
aStr( (const sal_Char
*)pChr
, gsl_getSystemTextEncoding() );
998 SetRasterOp(aAttr
.eChrMix
);
999 if (pVirDev
->GetFont()!=aFont
)
1000 pVirDev
->SetFont(aFont
);
1001 pVirDev
->DrawText(aP0
,aStr
);
1003 aSize
= Size( pVirDev
->GetTextWidth(aStr
), pVirDev
->GetTextHeight() );
1004 if ( aAttr
.nChrAng
== 0 )
1006 aCalcBndRect
.Union(Rectangle( Point(aP0
.X(),aP0
.Y()-aSize
.Height()),
1007 Size(aSize
.Width(),aSize
.Height()*2)));
1009 aAttr
.aCurPos
= Point( aP0
.X() + aSize
.Width(), aP0
.Y());
1013 Polygon
aDummyPoly(4);
1015 aDummyPoly
.SetPoint( Point( aP0
.X(), aP0
.Y() ), 0); // TOP LEFT
1016 aDummyPoly
.SetPoint( Point( aP0
.X(), aP0
.Y() - aSize
.Height() ), 1); // BOTTOM LEFT
1017 aDummyPoly
.SetPoint( Point( aP0
.X() + aSize
.Width(), aP0
.Y() ), 2); // TOP RIGHT
1018 aDummyPoly
.SetPoint( Point( aP0
.X() + aSize
.Width(), aP0
.Y() - aSize
.Height() ), 3);// BOTTOM RIGHT
1019 aDummyPoly
.Rotate( aP0
, (short)aAttr
.nChrAng
);
1021 aAttr
.aCurPos
= aDummyPoly
.GetPoint( 0 );
1022 aCalcBndRect
.Union( Rectangle( aDummyPoly
.GetPoint( 0 ), aDummyPoly
.GetPoint( 3 ) ) );
1023 aCalcBndRect
.Union( Rectangle( aDummyPoly
.GetPoint( 1 ), aDummyPoly
.GetPoint( 2 ) ) );
1028 void OS2METReader::ReadArc(BOOL bGivenPos
)
1030 Point aP1
, aP2
, aP3
;
1031 double x1
,y1
,x2
,y2
,x3
,y3
,p
,q
,cx
,cy
,ncx
,ncy
,r
,rx
,ry
,w1
,w3
;
1032 if (bGivenPos
) aP1
=ReadPoint(); else aP1
=aAttr
.aCurPos
;
1033 aP2
=ReadPoint(); aP3
=ReadPoint();
1035 SetPen( aAttr
.aLinCol
, aAttr
.nStrLinWidth
, aAttr
.eLinStyle
);
1036 SetRasterOp(aAttr
.eLinMix
);
1037 // OK, gegeben sind 3 Punkte der Ellipse, und das Verhaeltnis
1038 // Breite zu Hoehe (als p zu q):
1039 x1
=aP1
.X(); y1
=aP1
.Y();
1040 x2
=aP2
.X(); y2
=aP2
.Y();
1041 x3
=aP3
.X(); y3
=aP3
.Y();
1042 p
=aAttr
.nArcP
;q
=aAttr
.nArcQ
;
1043 // Berechnet wird der Mittelpunkt cx,cy der Ellipse:
1044 ncy
=2*p
*p
*((y3
-y1
)*(x2
-x1
)-(y1
-y2
)*(x1
-x3
));
1046 if ( (ncx
<0.001 && ncx
>-0.001) || (ncy
<0.001 && ncy
>-0.001) ) {
1047 // Berechnung nicht moeglich, Punkte liegen auf einer Linie
1048 pVirDev
->DrawLine(aP1
,aP2
);
1049 pVirDev
->DrawLine(aP2
,aP3
);
1052 cy
=( q
*q
*((x3
*x3
-x1
*x1
)*(x2
-x1
)+(x2
*x2
-x1
*x1
)*(x1
-x3
)) +
1053 p
*p
*((y3
*y3
-y1
*y1
)*(x2
-x1
)+(y2
*y2
-y1
*y1
)*(x1
-x3
)) ) / ncy
;
1054 cx
=( q
*q
*(x2
*x2
-x1
*x1
)+p
*p
*(y2
*y2
-y1
*y1
)+cy
*2*p
*p
*(y1
-y2
) ) / ncx
;
1055 // Nun brauchen wir noch den Radius in x und y Richtung:
1056 r
=sqrt(q
*q
*(x1
-cx
)*(x1
-cx
)+p
*p
*(y1
-cy
)*(y1
-cy
));
1058 // Jetzt stellt sich "nur noch" die Frage, wie Start- und Endpunkt
1059 // gewaehlt werden muessen, damit Punkt Nr. 2 innerhalb des
1060 // gezeichneten Bogens liegt:
1061 w1
=fmod((atan2(x1
-cx
,y1
-cy
)-atan2(x2
-cx
,y2
-cy
)),6.28318530718); if (w1
<0) w1
+=6.28318530718;
1062 w3
=fmod((atan2(x3
-cx
,y3
-cy
)-atan2(x2
-cx
,y2
-cy
)),6.28318530718); if (w3
<0) w3
+=6.28318530718;
1064 pVirDev
->DrawArc(Rectangle((long)(cx
-rx
),(long)(cy
-ry
),
1065 (long)(cx
+rx
),(long)(cy
+ry
)),aP1
,aP3
);
1068 pVirDev
->DrawArc(Rectangle((long)(cx
-rx
),(long)(cy
-ry
),
1069 (long)(cx
+rx
),(long)(cy
+ry
)),aP3
,aP1
);
1073 void OS2METReader::ReadFullArc(BOOL bGivenPos
, USHORT nOrderSize
)
1078 sal_uInt32 nMul
; USHORT nMulS
;
1081 aCenter
=ReadPoint();
1082 if (bCoord32
) nOrderSize
-=8; else nOrderSize
-=4;
1084 else aCenter
=aAttr
.aCurPos
;
1086 nP
=aAttr
.nArcP
; nQ
=aAttr
.nArcQ
; nR
=aAttr
.nArcR
; nS
=aAttr
.nArcS
;
1091 if (nOrderSize
>=4) *pOS2MET
>> nMul
;
1092 else { *pOS2MET
>> nMulS
; nMul
=((ULONG
)nMulS
)<<8; }
1093 if (nMul
!=0x00010000) {
1100 aRect
=Rectangle(aCenter
.X()-nP
,aCenter
.Y()-nQ
,
1101 aCenter
.X()+nP
,aCenter
.Y()+nQ
);
1102 aCalcBndRect
.Union(aRect
);
1104 if (pAreaStack
!=NULL
) {
1105 ChangeBrush(aAttr
.aPatCol
,aAttr
.aPatBgCol
,aAttr
.bFill
);
1106 SetRasterOp(aAttr
.ePatMix
);
1107 if ((pAreaStack
->nFlags
&0x40)!=0)
1108 SetPen( aAttr
.aLinCol
, aAttr
.nStrLinWidth
, aAttr
.eLinStyle
);
1110 SetPen( COL_TRANSPARENT
, 0, PEN_NULL
);
1114 SetPen( aAttr
.aLinCol
, aAttr
.nStrLinWidth
, aAttr
.eLinStyle
);
1115 ChangeBrush(Color( COL_TRANSPARENT
),Color( COL_TRANSPARENT
),FALSE
);
1116 SetRasterOp(aAttr
.eLinMix
);
1118 pVirDev
->DrawEllipse(aRect
);
1121 void OS2METReader::ReadPartialArc(BOOL bGivenPos
, USHORT nOrderSize
)
1123 Point aP0
, aCenter
,aPStart
,aPEnd
;
1124 long nP
,nQ
,nR
,nS
,nStart
, nSweep
;
1126 sal_uInt32 nMul
; USHORT nMulS
;
1127 double fStart
, fEnd
;
1131 if (bCoord32
) nOrderSize
-=8; else nOrderSize
-=4;
1133 else aP0
=aAttr
.aCurPos
;
1134 aCenter
=ReadPoint();
1136 nP
=aAttr
.nArcP
; nQ
=aAttr
.nArcQ
; nR
=aAttr
.nArcR
; nS
=aAttr
.nArcS
;
1141 if (nOrderSize
>=12) *pOS2MET
>> nMul
;
1142 else { *pOS2MET
>> nMulS
; nMul
=((ULONG
)nMulS
)<<8; }
1143 if (nMul
!=0x00010000) {
1150 *pOS2MET
>> nStart
>> nSweep
;
1151 fStart
=((double)nStart
)/65536.0/180.0*3.14159265359;
1152 fEnd
=fStart
+((double)nSweep
)/65536.0/180.0*3.14159265359;
1153 aPStart
=Point(aCenter
.X()+(long)( cos(fStart
)*nP
),
1154 aCenter
.Y()+(long)(-sin(fStart
)*nQ
));
1155 aPEnd
= Point(aCenter
.X()+(long)( cos(fEnd
)*nP
),
1156 aCenter
.Y()+(long)(-sin(fEnd
)*nQ
));
1158 aRect
=Rectangle(aCenter
.X()-nP
,aCenter
.Y()-nQ
,
1159 aCenter
.X()+nP
,aCenter
.Y()+nQ
);
1160 aCalcBndRect
.Union(aRect
);
1162 SetPen( aAttr
.aLinCol
, aAttr
.nStrLinWidth
, aAttr
.eLinStyle
);
1163 SetRasterOp(aAttr
.eLinMix
);
1165 pVirDev
->DrawLine(aP0
,aPStart
);
1166 pVirDev
->DrawArc(aRect
,aPStart
,aPEnd
);
1167 aAttr
.aCurPos
=aPEnd
;
1170 void OS2METReader::ReadPolygons()
1172 sal_uInt32 i
,j
,nNumPolys
, nNumPoints
;
1173 PolyPolygon aPolyPoly
;
1178 *pOS2MET
>> nFlags
>> nNumPolys
;
1179 for (i
=0; i
<nNumPolys
; i
++) {
1180 *pOS2MET
>> nNumPoints
;
1181 if (i
==0) nNumPoints
++;
1182 aPoly
.SetSize((short)nNumPoints
);
1183 for (j
=0; j
<nNumPoints
; j
++) {
1184 if (i
==0 && j
==0) aPoint
=aAttr
.aCurPos
;
1185 else aPoint
=ReadPoint();
1186 aPoly
.SetPoint(aPoint
,(short)j
);
1187 if (i
==nNumPolys
-1 && j
==nNumPoints
-1) aAttr
.aCurPos
=aPoint
;
1189 aPolyPoly
.Insert(aPoly
);
1192 ChangeBrush(aAttr
.aPatCol
,aAttr
.aPatBgCol
,aAttr
.bFill
);
1193 SetRasterOp(aAttr
.ePatMix
);
1194 if ((nFlags
&0x01)!=0)
1195 SetPen( aAttr
.aLinCol
, aAttr
.nStrLinWidth
, aAttr
.eLinStyle
);
1197 SetPen( COL_TRANSPARENT
, 0, PEN_NULL
);
1198 DrawPolyPolygon( aPolyPoly
);
1201 void OS2METReader::ReadBezier(BOOL bGivenPos
, USHORT nOrderLen
)
1203 USHORT i
, nNumPoints
= nOrderLen
/ ( bCoord32
? 8 : 4 );
1211 Polygon
aPolygon( nNumPoints
);
1213 for( i
=0; i
< nNumPoints
; i
++ )
1215 if( i
==0 && !bGivenPos
)
1216 aPolygon
.SetPoint( aAttr
.aCurPos
, i
);
1218 aPolygon
.SetPoint( ReadPoint(), i
);
1221 if( !( nNumPoints
% 4 ) )
1223 // create bezier polygon
1224 const USHORT nSegPoints
= 25;
1225 const USHORT nSegments
= aPolygon
.GetSize() >> 2;
1226 Polygon
aBezPoly( nSegments
* nSegPoints
);
1228 USHORT nSeg
, nBezPos
, nStartPos
;
1229 for( nSeg
= 0, nBezPos
= 0, nStartPos
= 0; nSeg
< nSegments
; nSeg
++, nStartPos
+= 4 )
1231 const Polygon
aSegPoly( aPolygon
[ nStartPos
], aPolygon
[ nStartPos
+ 1 ],
1232 aPolygon
[ nStartPos
+ 3 ], aPolygon
[ nStartPos
+ 2 ],
1235 for( USHORT nSegPos
= 0; nSegPos
< nSegPoints
; )
1236 aBezPoly
[ nBezPos
++ ] = aSegPoly
[ nSegPos
++ ];
1239 nNumPoints
= nBezPos
;
1241 if( nNumPoints
!= aBezPoly
.GetSize() )
1242 aBezPoly
.SetSize( nNumPoints
);
1244 aPolygon
= aBezPoly
;
1247 aAttr
.aCurPos
= aPolygon
[ nNumPoints
- 1 ];
1249 if (pAreaStack
!=NULL
)
1250 AddPointsToArea(aPolygon
);
1251 else if (pPathStack
!=NULL
)
1252 AddPointsToPath(aPolygon
);
1255 SetPen( aAttr
.aLinCol
, aAttr
.nStrLinWidth
, aAttr
.eLinStyle
);
1256 SetRasterOp(aAttr
.eLinMix
);
1257 DrawPolyLine( aPolygon
);
1261 void OS2METReader::ReadFillet(BOOL bGivenPos
, USHORT nOrderLen
)
1263 USHORT i
,nNumPoints
;
1265 if (bCoord32
) nNumPoints
=nOrderLen
/8; else nNumPoints
=nOrderLen
/4;
1266 if (!bGivenPos
) nNumPoints
++;
1267 if (nNumPoints
==0) return;
1268 Polygon
aPolygon(nNumPoints
);
1269 for (i
=0; i
<nNumPoints
; i
++) {
1270 if (i
==0 && !bGivenPos
) aPolygon
.SetPoint(aAttr
.aCurPos
,i
);
1271 else aPolygon
.SetPoint(ReadPoint(),i
);
1273 aAttr
.aCurPos
=aPolygon
.GetPoint(nNumPoints
-1);
1274 if (pAreaStack
!=NULL
) AddPointsToArea(aPolygon
);
1275 else if (pPathStack
!=NULL
) AddPointsToPath(aPolygon
);
1277 SetPen( aAttr
.aLinCol
, aAttr
.nStrLinWidth
, aAttr
.eLinStyle
);
1278 SetRasterOp(aAttr
.eLinMix
);
1279 DrawPolyLine( aPolygon
);
1283 void OS2METReader::ReadFilletSharp(BOOL bGivenPos
, USHORT nOrderLen
)
1285 USHORT i
,nNumPoints
;
1288 aAttr
.aCurPos
=ReadPoint();
1289 if (bCoord32
) nOrderLen
-=8; else nOrderLen
-=4;
1291 if (bCoord32
) nNumPoints
=1+nOrderLen
/10;
1292 else nNumPoints
=1+nOrderLen
/6;
1293 Polygon
aPolygon(nNumPoints
);
1294 aPolygon
.SetPoint(aAttr
.aCurPos
,0);
1295 for (i
=1; i
<nNumPoints
; i
++) aPolygon
.SetPoint(ReadPoint(),i
);
1296 aAttr
.aCurPos
=aPolygon
.GetPoint(nNumPoints
-1);
1297 if (pAreaStack
!=NULL
) AddPointsToArea(aPolygon
);
1298 else if (pPathStack
!=NULL
) AddPointsToPath(aPolygon
);
1301 SetPen( aAttr
.aLinCol
, aAttr
.nStrLinWidth
, aAttr
.eLinStyle
);
1302 SetRasterOp(aAttr
.eLinMix
);
1303 DrawPolyLine( aPolygon
);
1307 void OS2METReader::ReadMarker(BOOL bGivenPos
, USHORT nOrderLen
)
1309 USHORT i
,nNumPoints
;
1312 SetPen( aAttr
.aMrkCol
);
1313 SetRasterOp(aAttr
.eMrkMix
);
1314 if (aAttr
.nMrkSymbol
>=5 && aAttr
.nMrkSymbol
<=9)
1316 ChangeBrush(aAttr
.aMrkCol
,aAttr
.aMrkCol
,TRUE
);
1320 ChangeBrush(Color(COL_TRANSPARENT
),Color(COL_TRANSPARENT
),FALSE
);
1322 if (bCoord32
) nNumPoints
=nOrderLen
/8; else nNumPoints
=nOrderLen
/4;
1323 if (!bGivenPos
) nNumPoints
++;
1324 for (i
=0; i
<nNumPoints
; i
++) {
1325 if (i
!=0 || bGivenPos
) aAttr
.aCurPos
=ReadPoint();
1326 x
=aAttr
.aCurPos
.X(); y
=aAttr
.aCurPos
.Y();
1327 aCalcBndRect
.Union(Rectangle(x
-5,y
-5,x
+5,y
+5));
1328 switch (aAttr
.nMrkSymbol
) {
1330 pVirDev
->DrawLine(Point(x
-4,y
),Point(x
+4,y
));
1331 pVirDev
->DrawLine(Point(x
,y
-4),Point(x
,y
+4));
1334 case 7: { // SOLIDDIAMOND
1336 aPoly
.SetPoint(Point(x
,y
+4),0);
1337 aPoly
.SetPoint(Point(x
+4,y
),1);
1338 aPoly
.SetPoint(Point(x
,y
-4),2);
1339 aPoly
.SetPoint(Point(x
-4,y
),3);
1340 pVirDev
->DrawPolygon(aPoly
);
1344 case 8: { // SOLIDSUARE
1346 aPoly
.SetPoint(Point(x
+4,y
+4),0);
1347 aPoly
.SetPoint(Point(x
+4,y
-4),1);
1348 aPoly
.SetPoint(Point(x
-4,y
-4),2);
1349 aPoly
.SetPoint(Point(x
-4,y
+4),3);
1350 pVirDev
->DrawPolygon(aPoly
);
1353 case 5: { // SIXPOINTSTAR
1355 aPoly
.SetPoint(Point(x
,y
-4),0);
1356 aPoly
.SetPoint(Point(x
+2,y
-2),1);
1357 aPoly
.SetPoint(Point(x
+4,y
-2),2);
1358 aPoly
.SetPoint(Point(x
+2,y
),3);
1359 aPoly
.SetPoint(Point(x
+4,y
+2),4);
1360 aPoly
.SetPoint(Point(x
+2,y
+2),5);
1361 aPoly
.SetPoint(Point(x
,y
+4),6);
1362 aPoly
.SetPoint(Point(x
-2,y
+2),7);
1363 aPoly
.SetPoint(Point(x
-4,y
+2),8);
1364 aPoly
.SetPoint(Point(x
-2,y
),9);
1365 aPoly
.SetPoint(Point(x
-4,y
-2),10);
1366 aPoly
.SetPoint(Point(x
-2,y
-2),11);
1367 pVirDev
->DrawPolygon(aPoly
);
1370 case 6: { // EIGHTPOINTSTAR
1372 aPoly
.SetPoint(Point(x
,y
-4),0);
1373 aPoly
.SetPoint(Point(x
+1,y
-2),1);
1374 aPoly
.SetPoint(Point(x
+3,y
-3),2);
1375 aPoly
.SetPoint(Point(x
+2,y
-1),3);
1376 aPoly
.SetPoint(Point(x
+4,y
),4);
1377 aPoly
.SetPoint(Point(x
+2,y
+1),5);
1378 aPoly
.SetPoint(Point(x
+3,y
+3),6);
1379 aPoly
.SetPoint(Point(x
+1,y
+2),7);
1380 aPoly
.SetPoint(Point(x
,y
+4),8);
1381 aPoly
.SetPoint(Point(x
-1,y
+2),9);
1382 aPoly
.SetPoint(Point(x
-3,y
+3),10);
1383 aPoly
.SetPoint(Point(x
-2,y
+1),11);
1384 aPoly
.SetPoint(Point(x
-4,y
),12);
1385 aPoly
.SetPoint(Point(x
-2,y
-1),13);
1386 aPoly
.SetPoint(Point(x
-3,y
-3),14);
1387 aPoly
.SetPoint(Point(x
-1,y
-2),15);
1388 pVirDev
->DrawPolygon(aPoly
);
1392 pVirDev
->DrawEllipse(Rectangle(x
-1,y
-1,x
+1,y
+1));
1394 case 10: // SMALLCIRCLE
1395 pVirDev
->DrawEllipse(Rectangle(x
-2,y
-2,x
+2,y
+2));
1399 default: // (=1) CROSS
1400 pVirDev
->DrawLine(Point(x
-4,y
-4),Point(x
+4,y
+4));
1401 pVirDev
->DrawLine(Point(x
-4,y
+4),Point(x
+4,y
-4));
1407 void OS2METReader::ReadOrder(USHORT nOrderID
, USHORT nOrderLen
)
1411 case GOrdGivArc
: ReadArc(TRUE
); break;
1412 case GOrdCurArc
: ReadArc(FALSE
); break;
1414 case GOrdGivBzr
: ReadBezier(TRUE
,nOrderLen
); break;
1415 case GOrdCurBzr
: ReadBezier(FALSE
,nOrderLen
); break;
1417 case GOrdGivBox
: ReadBox(TRUE
); break;
1418 case GOrdCurBox
: ReadBox(FALSE
); break;
1420 case GOrdGivFil
: ReadFillet(TRUE
,nOrderLen
); break;
1421 case GOrdCurFil
: ReadFillet(FALSE
,nOrderLen
); break;
1423 case GOrdGivCrc
: ReadFullArc(TRUE
,nOrderLen
); break;
1424 case GOrdCurCrc
: ReadFullArc(FALSE
,nOrderLen
); break;
1426 case GOrdGivLin
: ReadLine(TRUE
, nOrderLen
); break;
1427 case GOrdCurLin
: ReadLine(FALSE
, nOrderLen
); break;
1429 case GOrdGivMrk
: ReadMarker(TRUE
, nOrderLen
); break;
1430 case GOrdCurMrk
: ReadMarker(FALSE
, nOrderLen
); break;
1432 case GOrdGivArP
: ReadPartialArc(TRUE
,nOrderLen
); break;
1433 case GOrdCurArP
: ReadPartialArc(FALSE
,nOrderLen
); break;
1435 case GOrdGivRLn
: ReadRelLine(TRUE
,nOrderLen
); break;
1436 case GOrdCurRLn
: ReadRelLine(FALSE
,nOrderLen
); break;
1438 case GOrdGivSFl
: ReadFilletSharp(TRUE
,nOrderLen
); break;
1439 case GOrdCurSFl
: ReadFilletSharp(FALSE
,nOrderLen
); break;
1441 case GOrdGivStM
: ReadChrStr(TRUE
, TRUE
, FALSE
, nOrderLen
); break;
1442 case GOrdCurStM
: ReadChrStr(FALSE
, TRUE
, FALSE
, nOrderLen
); break;
1443 case GOrdGivStr
: ReadChrStr(TRUE
, FALSE
, FALSE
, nOrderLen
); break;
1444 case GOrdCurStr
: ReadChrStr(FALSE
, FALSE
, FALSE
, nOrderLen
); break;
1445 case GOrdGivStx
: ReadChrStr(TRUE
, FALSE
, TRUE
, nOrderLen
); break;
1446 case GOrdCurStx
: ReadChrStr(FALSE
, FALSE
, TRUE
, nOrderLen
); break;
1448 case GOrdGivImg
: OOODEBUG("GOrdGivImg",0);
1450 case GOrdCurImg
: OOODEBUG("GOrdCurImg",0);
1452 case GOrdImgDat
: OOODEBUG("GOrdImgDat",0);
1454 case GOrdEndImg
: OOODEBUG("GOrdEndImg",0);
1458 OSArea
* p
=new OSArea
;
1460 p
->pSucc
=pAreaStack
; pAreaStack
=p
;
1461 *pOS2MET
>> (p
->nFlags
);
1462 p
->aCol
=aAttr
.aPatCol
;
1463 p
->aBgCol
=aAttr
.aPatBgCol
;
1464 p
->eMix
=aAttr
.ePatMix
;
1465 p
->eBgMix
=aAttr
.ePatBgMix
;
1466 p
->bFill
=aAttr
.bFill
;
1471 OSArea
* p
=pAreaStack
;
1474 pAreaStack
= p
->pSucc
;
1477 for ( USHORT i
=0; i
<p
->aPPoly
.Count(); i
++ )
1479 AddPointsToPath( p
->aPPoly
.GetObject( i
) );
1485 if ( ( p
->nFlags
& 0x40 ) == 0 )
1486 SetPen( COL_TRANSPARENT
, 0, PEN_NULL
);
1488 SetPen( aAttr
.aLinCol
, aAttr
.nStrLinWidth
, aAttr
.eLinStyle
);
1490 ChangeBrush(p
->aCol
,p
->aBgCol
,p
->bFill
);
1491 SetRasterOp(p
->eMix
);
1492 DrawPolyPolygon( p
->aPPoly
);
1499 case GOrdBegElm
:// OOODEBUG("GOrdBegElm",0);
1501 case GOrdEndElm
:// OOODEBUG("GOrdEndElm",0);
1505 OSPath
* p
=new OSPath
;
1506 p
->pSucc
=pPathStack
; pPathStack
=p
;
1507 pOS2MET
->SeekRel(2);
1514 OSPath
* p
, * pprev
, * psucc
;
1515 if (pPathStack
==NULL
) break;
1516 p
=pPathList
; pprev
=NULL
;
1519 if (p
->nID
==pPathStack
->nID
) {
1520 if (pprev
==NULL
) pPathList
=psucc
; else pprev
->pSucc
=psucc
;
1527 pPathStack
=p
->pSucc
;
1528 p
->pSucc
=pPathList
; pPathList
=p
;
1535 OSPath
* p
= pPathList
;
1540 if ( ! ( nDummy
& 0x20 ) ) // #30933# i do not know the exact meaning of this bit,
1541 { // but if set it seems to be better not to fill this path
1542 while( p
&& p
->nID
!= nID
)
1549 SetPen( aAttr
.aPatCol
, aAttr
.nStrLinWidth
, PEN_SOLID
);
1550 ChangeBrush(Color(COL_TRANSPARENT
),Color(COL_TRANSPARENT
),FALSE
);
1551 SetRasterOp( aAttr
.ePatMix
);
1554 for ( USHORT i
= 0; i
< p
->aPPoly
.Count(); i
++ )
1555 pVirDev
->DrawPolyLine( p
->aPPoly
.GetObject( i
), aLineInfo
);
1558 pVirDev
->DrawPolyPolygon( p
->aPPoly
);
1562 SetPen( COL_TRANSPARENT
, 0, PEN_NULL
);
1563 ChangeBrush( aAttr
.aPatCol
, aAttr
.aPatBgCol
, aAttr
.bFill
);
1564 SetRasterOp( aAttr
.ePatMix
);
1565 pVirDev
->DrawPolyPolygon( p
->aPPoly
);
1574 OSPath
* p
= pPathList
;
1576 while( p
&& p
->nID
!= 1 )
1588 OSPath
* p
=pPathList
;
1589 pOS2MET
->SeekRel(2);
1591 while (p
!=NULL
&& p
->nID
!=nID
)
1596 SetPen( aAttr
.aLinCol
, aAttr
.nStrLinWidth
, aAttr
.eLinStyle
);
1597 SetRasterOp(aAttr
.eLinMix
);
1598 ChangeBrush(Color(COL_TRANSPARENT
),Color(COL_TRANSPARENT
),FALSE
);
1599 nC
=p
->aPPoly
.Count();
1600 for (i
=0; i
<nC
; i
++)
1602 if (i
+1<nC
|| p
->bClosed
==TRUE
)
1603 DrawPolygon( p
->aPPoly
.GetObject( i
) );
1605 DrawPolyLine( p
->aPPoly
.GetObject( i
) );
1610 case GOrdSClPth
: { OOODEBUG("GOrdSClPth",0);
1612 OSPath
* p
=pPathList
;
1613 pOS2MET
->SeekRel(2);
1616 while (p
!=NULL
&& p
->nID
!=nID
) p
=p
->pSucc
;
1617 if (p
!=NULL
) pVirDev
->SetClipRegion(Region(p
->aPPoly
));
1618 else pVirDev
->SetClipRegion();
1623 case GOrdRemark
: //OOODEBUG("GOrdRemark",0);
1625 case GOrdSegLab
: OOODEBUG("GOrdSegLab",0);
1628 case GOrdBitBlt
: ReadBitBlt(); break;
1630 case GOrdCalSeg
: OOODEBUG("GOrdCalSeg",0);
1632 case GOrdSSgBnd
: OOODEBUG("GOrdSSgBnd",0);
1634 case GOrdSegChr
: OOODEBUG("GOrdSegChr",0);
1639 case GOrdEndSym
: OOODEBUG("GOrdEndSym",0);
1641 case GOrdEndPlg
: OOODEBUG("GOrdEndPlg",0);
1643 case GOrdEscape
: OOODEBUG("GOrdEscape",0);
1645 case GOrdExtEsc
: OOODEBUG("GOrdExtEsc",0);
1648 case GOrdPolygn
: ReadPolygons(); break;
1650 case GOrdStkPop
: PopAttr(); break;
1652 case GOrdPIvAtr
: PushAttr(nOrderID
);
1654 BYTE nA
, nP
, nFlags
, nMix
;
1658 *pOS2MET
>> nA
>> nP
>> nFlags
;
1659 if (nOrderID
==GOrdPIvAtr
) {
1660 pAttrStack
->nIvAttrA
=nA
;
1661 pAttrStack
->nIvAttrP
=nP
;
1664 if ((nFlags
&0x80)!=0) {
1665 if (nA
==1) switch (nP
) {
1666 case 1: aAttr
.aLinCol
=aDefAttr
.aLinCol
; break;
1667 case 2: aAttr
.aChrCol
=aDefAttr
.aChrCol
; break;
1668 case 3: aAttr
.aMrkCol
=aDefAttr
.aMrkCol
; break;
1669 case 4: aAttr
.aPatCol
=aDefAttr
.aPatCol
; break;
1670 case 5: aAttr
.aImgCol
=aDefAttr
.aImgCol
; break;
1673 case 1: aAttr
.aLinBgCol
=aDefAttr
.aLinBgCol
; break;
1674 case 2: aAttr
.aChrBgCol
=aDefAttr
.aChrBgCol
; break;
1675 case 3: aAttr
.aMrkBgCol
=aDefAttr
.aMrkBgCol
; break;
1676 case 4: aAttr
.aPatBgCol
=aDefAttr
.aPatBgCol
; break;
1677 case 5: aAttr
.aImgBgCol
=aDefAttr
.aImgBgCol
; break;
1681 nVal
=ReadLittleEndian3BytesLong();
1682 if ((nFlags
&0x40)!=0 && nVal
==1) aCol
=Color(COL_BLACK
);
1683 else if ((nFlags
&0x40)!=0 && nVal
==2) aCol
=Color(COL_WHITE
);
1684 else if ((nFlags
&0x40)!=0 && nVal
==4) aCol
=Color(COL_WHITE
);
1685 else if ((nFlags
&0x40)!=0 && nVal
==5) aCol
=Color(COL_BLACK
);
1686 else aCol
=GetPaletteColor(nVal
);
1687 if (nA
==1) switch (nP
) {
1688 case 1: aAttr
.aLinCol
=aCol
; break;
1689 case 2: aAttr
.aChrCol
=aCol
; break;
1690 case 3: aAttr
.aMrkCol
=aCol
; break;
1691 case 4: aAttr
.aPatCol
=aCol
; break;
1692 case 5: aAttr
.aImgCol
=aCol
; break;
1695 case 1: aAttr
.aLinBgCol
=aCol
; break;
1696 case 2: aAttr
.aChrBgCol
=aCol
; break;
1697 case 3: aAttr
.aMrkBgCol
=aCol
; break;
1698 case 4: aAttr
.aPatBgCol
=aCol
; break;
1699 case 5: aAttr
.aImgBgCol
=aCol
; break;
1706 if (nA
==1) switch (nP
) {
1707 case 1: aAttr
.eLinMix
=aDefAttr
.eLinMix
; break;
1708 case 2: aAttr
.eChrMix
=aDefAttr
.eChrMix
; break;
1709 case 3: aAttr
.eMrkMix
=aDefAttr
.eMrkMix
; break;
1710 case 4: aAttr
.ePatMix
=aDefAttr
.ePatMix
; break;
1711 case 5: aAttr
.eImgMix
=aDefAttr
.eImgMix
; break;
1714 case 1: aAttr
.eLinBgMix
=aDefAttr
.eLinBgMix
; break;
1715 case 2: aAttr
.eChrBgMix
=aDefAttr
.eChrBgMix
; break;
1716 case 3: aAttr
.eMrkBgMix
=aDefAttr
.eMrkBgMix
; break;
1717 case 4: aAttr
.ePatBgMix
=aDefAttr
.ePatBgMix
; break;
1718 case 5: aAttr
.eImgBgMix
=aDefAttr
.eImgBgMix
; break;
1722 eROP
=OS2MixToRasterOp(nMix
);
1723 if (nA
==1) switch (nP
) {
1724 case 1: aAttr
.eLinMix
=eROP
; break;
1725 case 2: aAttr
.eChrMix
=eROP
; break;
1726 case 3: aAttr
.eMrkMix
=eROP
; break;
1727 case 4: aAttr
.ePatMix
=eROP
; break;
1728 case 5: aAttr
.eImgMix
=eROP
; break;
1731 case 1: aAttr
.eLinBgMix
=eROP
; break;
1732 case 2: aAttr
.eChrBgMix
=eROP
; break;
1733 case 3: aAttr
.eMrkBgMix
=eROP
; break;
1734 case 4: aAttr
.ePatBgMix
=eROP
; break;
1735 case 5: aAttr
.eImgBgMix
=eROP
; break;
1741 case GOrdPIxCol
: PushAttr(nOrderID
);
1747 if ((nFlags
&0x80)!=0) {
1748 aAttr
.aLinCol
=aDefAttr
.aLinCol
;
1749 aAttr
.aChrCol
=aDefAttr
.aChrCol
;
1750 aAttr
.aMrkCol
=aDefAttr
.aMrkCol
;
1751 aAttr
.aPatCol
=aDefAttr
.aPatCol
;
1752 aAttr
.aImgCol
=aDefAttr
.aImgCol
;
1755 nVal
=ReadLittleEndian3BytesLong();
1756 if ((nFlags
&0x40)!=0 && nVal
==1) aCol
=Color(COL_BLACK
);
1757 else if ((nFlags
&0x40)!=0 && nVal
==2) aCol
=Color(COL_WHITE
);
1758 else if ((nFlags
&0x40)!=0 && nVal
==4) aCol
=Color(COL_WHITE
);
1759 else if ((nFlags
&0x40)!=0 && nVal
==5) aCol
=Color(COL_BLACK
);
1760 else aCol
=GetPaletteColor(nVal
);
1761 aAttr
.aLinCol
= aAttr
.aChrCol
= aAttr
.aMrkCol
= aAttr
.aPatCol
=
1762 aAttr
.aImgCol
= aCol
;
1768 case GOrdPXtCol
: PushAttr(nOrderID
);
1774 if (nOrderID
==GOrdPColor
|| nOrderID
==GOrdSColor
) {
1775 *pOS2MET
>> nbyte
; nVal
=((USHORT
)nbyte
)|0xff00;
1777 else *pOS2MET
>> nVal
;
1778 if (nVal
==0x0000 || nVal
==0xff00) {
1779 aAttr
.aLinCol
=aDefAttr
.aLinCol
;
1780 aAttr
.aChrCol
=aDefAttr
.aChrCol
;
1781 aAttr
.aMrkCol
=aDefAttr
.aMrkCol
;
1782 aAttr
.aPatCol
=aDefAttr
.aPatCol
;
1783 aAttr
.aImgCol
=aDefAttr
.aImgCol
;
1786 if (nVal
==0x0007) aCol
=Color(COL_WHITE
);
1787 else if (nVal
==0x0008) aCol
=Color(COL_BLACK
);
1788 else if (nVal
==0xff08) aCol
=GetPaletteColor(1);
1789 else aCol
=GetPaletteColor(((ULONG
)nVal
) & 0x000000ff);
1790 aAttr
.aLinCol
= aAttr
.aChrCol
= aAttr
.aMrkCol
= aAttr
.aPatCol
=
1791 aAttr
.aImgCol
= aCol
;
1796 case GOrdPBgCol
: PushAttr(nOrderID
);
1801 if (nVal
==0x0000 || nVal
==0xff00) {
1802 aAttr
.aLinBgCol
=aDefAttr
.aLinBgCol
;
1803 aAttr
.aChrBgCol
=aDefAttr
.aChrBgCol
;
1804 aAttr
.aMrkBgCol
=aDefAttr
.aMrkBgCol
;
1805 aAttr
.aPatBgCol
=aDefAttr
.aPatBgCol
;
1806 aAttr
.aImgBgCol
=aDefAttr
.aImgBgCol
;
1809 if (nVal
==0x0007) aCol
=Color(COL_WHITE
);
1810 else if (nVal
==0x0008) aCol
=Color(COL_BLACK
);
1811 else if (nVal
==0xff08) aCol
=GetPaletteColor(0);
1812 else aCol
=GetPaletteColor(((ULONG
)nVal
) & 0x000000ff);
1813 aAttr
.aLinBgCol
= aAttr
.aChrBgCol
= aAttr
.aMrkBgCol
=
1814 aAttr
.aPatBgCol
= aAttr
.aImgBgCol
= aCol
;
1818 case GOrdPBxCol
: PushAttr(nOrderID
);
1824 if ((nFlags
&0x80)!=0) {
1825 aAttr
.aLinBgCol
=aDefAttr
.aLinBgCol
;
1826 aAttr
.aChrBgCol
=aDefAttr
.aChrBgCol
;
1827 aAttr
.aMrkBgCol
=aDefAttr
.aMrkBgCol
;
1828 aAttr
.aPatBgCol
=aDefAttr
.aPatBgCol
;
1829 aAttr
.aImgBgCol
=aDefAttr
.aImgBgCol
;
1832 nVal
=ReadLittleEndian3BytesLong();
1833 if ((nFlags
&0x40)!=0 && nVal
==1) aCol
=Color(COL_BLACK
);
1834 else if ((nFlags
&0x40)!=0 && nVal
==2) aCol
=Color(COL_WHITE
);
1835 else if ((nFlags
&0x40)!=0 && nVal
==4) aCol
=Color(COL_WHITE
);
1836 else if ((nFlags
&0x40)!=0 && nVal
==5) aCol
=Color(COL_BLACK
);
1837 else aCol
=GetPaletteColor(nVal
);
1838 aAttr
.aLinBgCol
= aAttr
.aChrBgCol
= aAttr
.aMrkBgCol
=
1839 aAttr
.aPatBgCol
= aAttr
.aImgBgCol
= aCol
;
1844 case GOrdPMixMd
: PushAttr(nOrderID
);
1849 aAttr
.eLinMix
=aDefAttr
.eLinMix
;
1850 aAttr
.eChrMix
=aDefAttr
.eChrMix
;
1851 aAttr
.eMrkMix
=aDefAttr
.eMrkMix
;
1852 aAttr
.ePatMix
=aDefAttr
.ePatMix
;
1853 aAttr
.eImgMix
=aDefAttr
.eImgMix
;
1856 aAttr
.eLinMix
= aAttr
.eChrMix
= aAttr
.eMrkMix
=
1857 aAttr
.ePatMix
= aAttr
.eImgMix
= OS2MixToRasterOp(nMix
);
1861 case GOrdPBgMix
: PushAttr(nOrderID
);
1866 aAttr
.eLinBgMix
=aDefAttr
.eLinBgMix
;
1867 aAttr
.eChrBgMix
=aDefAttr
.eChrBgMix
;
1868 aAttr
.eMrkBgMix
=aDefAttr
.eMrkBgMix
;
1869 aAttr
.ePatBgMix
=aDefAttr
.ePatBgMix
;
1870 aAttr
.eImgBgMix
=aDefAttr
.eImgBgMix
;
1873 aAttr
.eLinBgMix
= aAttr
.eChrBgMix
= aAttr
.eMrkBgMix
=
1874 aAttr
.ePatBgMix
= aAttr
.eImgBgMix
= OS2MixToRasterOp(nMix
);
1878 case GOrdPPtSet
: PushAttr(nOrderID
);
1879 case GOrdSPtSet
: OOODEBUG("GOrdSPtSet",0);
1882 case GOrdPPtSym
: PushAttr(nOrderID
);
1886 aAttr
.bFill
= ( nPatt
!= 0x0f );
1890 case GOrdPPtRef
: PushAttr(nOrderID
);
1891 case GOrdSPtRef
: OOODEBUG("GOrdSPtRef",0);
1894 case GOrdPLnEnd
: PushAttr(nOrderID
);
1898 case GOrdPLnJoi
: PushAttr(nOrderID
);
1902 case GOrdPLnTyp
: PushAttr(nOrderID
);
1907 case 0: aAttr
.eLinStyle
=aDefAttr
.eLinStyle
; break;
1908 case 1: case 4: aAttr
.eLinStyle
=PEN_DOT
; break;
1909 case 2: case 5: aAttr
.eLinStyle
=PEN_DASH
; break;
1910 case 3: case 6: aAttr
.eLinStyle
=PEN_DASHDOT
; break;
1911 case 8: aAttr
.eLinStyle
=PEN_NULL
; break;
1912 default: aAttr
.eLinStyle
=PEN_SOLID
;
1916 case GOrdPLnWdt
: PushAttr(nOrderID
);
1920 if (nbyte
==0) aAttr
.nLinWidth
=aDefAttr
.nLinWidth
;
1921 else aAttr
.nLinWidth
=(USHORT
)nbyte
-1;
1924 case GOrdPFrLWd
: PushAttr(nOrderID
);
1928 case GOrdPStLWd
: PushAttr(nOrderID
);
1935 if ( nFlags
& 0x80 )
1936 aAttr
.nStrLinWidth
= aDefAttr
.nStrLinWidth
;
1939 pOS2MET
->SeekRel( 1 );
1940 nWd
= ReadCoord( bCoord32
);
1943 aAttr
.nStrLinWidth
= (USHORT
)nWd
;
1947 case GOrdPChDir
: PushAttr(nOrderID
);
1951 case GOrdPChPrc
: PushAttr(nOrderID
);
1955 case GOrdPChSet
: PushAttr(nOrderID
);
1957 BYTE nbyte
; *pOS2MET
>> nbyte
;
1958 aAttr
.nChrSet
=((ULONG
)nbyte
)&0xff;
1961 case GOrdPChAng
: PushAttr(nOrderID
);
1964 nX
=ReadCoord(bCoord32
); nY
=ReadCoord(bCoord32
);
1965 if (nX
>=0 && nY
==0) aAttr
.nChrAng
=0;
1967 aAttr
.nChrAng
=(short)(atan2((double)nY
,(double)nX
)/3.1415926539*1800.0);
1968 while (aAttr
.nChrAng
<0) aAttr
.nChrAng
+=3600;
1969 aAttr
.nChrAng
%=3600;
1973 case GOrdPChBrx
: PushAttr(nOrderID
);
1977 case GOrdPChCel
: PushAttr(nOrderID
);
1980 USHORT nLen
=nOrderLen
;
1981 aAttr
.aChrCellSize
.Width()=ReadCoord(bCoord32
);
1982 aAttr
.aChrCellSize
.Height()=ReadCoord(bCoord32
);
1983 if (bCoord32
) nLen
-=8; else nLen
-=4;
1985 pOS2MET
->SeekRel(4); nLen
-=4;
1989 if ((nbyte
&0x80)==0 && aAttr
.aChrCellSize
==Size(0,0))
1990 aAttr
.aChrCellSize
=aDefAttr
.aChrCellSize
;
1994 case GOrdPChXtr
: PushAttr(nOrderID
);
1998 case GOrdPChShr
: PushAttr(nOrderID
);
2002 case GOrdPTxAlg
: PushAttr(nOrderID
);
2003 case GOrdSTxAlg
: OOODEBUG("GOrdSTxAlg",0);
2006 case GOrdPMkPrc
: PushAttr(nOrderID
);
2010 if (nbyte
==0) aAttr
.nMrkPrec
=aDefAttr
.nMrkPrec
;
2011 else aAttr
.nMrkPrec
=nbyte
;
2015 case GOrdPMkSet
: PushAttr(nOrderID
);
2019 if (nbyte
==0) aAttr
.nMrkSet
=aDefAttr
.nMrkSet
;
2020 else aAttr
.nMrkSet
=nbyte
;
2024 case GOrdPMkSym
: PushAttr(nOrderID
);
2028 if (nbyte
==0) aAttr
.nMrkSymbol
=aDefAttr
.nMrkSymbol
;
2029 else aAttr
.nMrkSymbol
=nbyte
;
2033 case GOrdPMkCel
: PushAttr(nOrderID
);
2036 USHORT nLen
=nOrderLen
;
2037 aAttr
.aMrkCellSize
.Width()=ReadCoord(bCoord32
);
2038 aAttr
.aMrkCellSize
.Height()=ReadCoord(bCoord32
);
2039 if (bCoord32
) nLen
-=8; else nLen
-=4;
2042 if ((nbyte
&0x80)==0 && aAttr
.aMrkCellSize
==Size(0,0))
2043 aAttr
.aMrkCellSize
=aDefAttr
.aMrkCellSize
;
2048 case GOrdPArcPa
: PushAttr(nOrderID
);
2050 aAttr
.nArcP
=ReadCoord(bCoord32
);
2051 aAttr
.nArcQ
=ReadCoord(bCoord32
);
2052 aAttr
.nArcR
=ReadCoord(bCoord32
);
2053 aAttr
.nArcS
=ReadCoord(bCoord32
);
2056 case GOrdPCrPos
: PushAttr(nOrderID
);
2058 aAttr
.aCurPos
=ReadPoint();
2061 case GOrdPMdTrn
: PushAttr(nOrderID
);
2062 case GOrdSMdTrn
: OOODEBUG("GOrdSMdTrn",0);
2065 case GOrdPPkIdn
: PushAttr(nOrderID
);
2066 case GOrdSPkIdn
: OOODEBUG("GOrdSPkIdn",0);
2069 case GOrdSVwTrn
: OOODEBUG("GOrdSVwTrn",0);
2072 case GOrdPVwWin
: PushAttr(nOrderID
);
2073 case GOrdSVwWin
: OOODEBUG("GOrdSVwWin",0);
2075 default: OOODEBUG("Order unbekannt:",nOrderID
);
2079 void OS2METReader::ReadDsc(USHORT nDscID
, USHORT
/*nDscLen*/)
2082 case 0x00f7: { // 'Specify GVM Subset'
2084 pOS2MET
->SeekRel(6);
2086 if (nbyte
==0x05) bCoord32
=TRUE
;
2087 else if (nbyte
==0x04) bCoord32
=FALSE
;
2089 pOS2MET
->SetError(SVSTREAM_FILEFORMAT_ERROR
);
2096 // 'Set Picture Descriptor'
2098 BYTE nbyte
,nUnitType
;
2099 long x1
,y1
,x2
,y2
,nt
,xr
,yr
;
2101 pOS2MET
->SeekRel(2);
2106 else if(nbyte
==0x04)
2110 b32
= FALSE
; // -Wall added the case.
2111 pOS2MET
->SetError(SVSTREAM_FILEFORMAT_ERROR
);
2115 *pOS2MET
>> nUnitType
;
2122 if (nUnitType
==0x00 && xr
>0 && yr
>0)
2123 aGlobMapMode
=MapMode(MAP_INCH
,Point(0,0),Fraction(10,xr
),Fraction(10,yr
));
2124 else if (nUnitType
==0x01 && xr
>0 && yr
>0)
2125 aGlobMapMode
=MapMode(MAP_CM
,Point(0,0),Fraction(10,xr
),Fraction(10,yr
));
2127 aGlobMapMode
=MapMode();
2148 aBoundingRect
.Left() = x1
;
2149 aBoundingRect
.Right() = x2
;
2150 aBoundingRect
.Top() = y1
;
2151 aBoundingRect
.Bottom() = y2
;
2153 // no output beside this bounding rect
2154 pVirDev
->IntersectClipRegion( Rectangle( Point(), aBoundingRect
.GetSize() ) );
2158 case 0x0021: // 'Set Current Defaults'
2163 void OS2METReader::ReadImageData(USHORT nDataID
, USHORT nDataLen
)
2165 OSBitmap
* p
=pBitmapList
; if (p
==NULL
) return; // Nanu ?
2169 case 0x0070: // Begin Segment
2172 case 0x0091: // Begin Image Content
2175 case 0x0094: // Image Size
2176 pOS2MET
->SeekRel(5);
2177 p
->nHeight
=ReadBigEndianWord();
2178 p
->nWidth
=ReadBigEndianWord();
2181 case 0x0095: // Image Encoding
2184 case 0x0096: { // Image IDE-Size
2186 *pOS2MET
>> nbyte
; p
->nBitsPerPixel
=nbyte
;
2190 case 0x0097: // Image LUT-ID
2193 case 0x009b: // IDE Structure
2196 case 0xfe92: { // Image Data
2197 // Spaetestens jetzt brauchen wir die temporaere BMP-Datei
2198 // und darin mindestens den Header + Palette.
2199 if (p
->pBMP
==NULL
) {
2200 p
->pBMP
=new SvMemoryStream();
2201 p
->pBMP
->SetNumberFormatInt(NUMBERFORMAT_INT_LITTLEENDIAN
);
2202 if (p
->nWidth
==0 || p
->nHeight
==0 || p
->nBitsPerPixel
==0) {
2203 pOS2MET
->SetError(SVSTREAM_FILEFORMAT_ERROR
);
2207 // Schreibe (Windows-)BITMAPINFOHEADER:
2208 *(p
->pBMP
) << ((sal_uInt32
)40) << p
->nWidth
<< p
->nHeight
;
2209 *(p
->pBMP
) << ((USHORT
)1) << p
->nBitsPerPixel
;
2210 *(p
->pBMP
) << ((sal_uInt32
)0) << ((sal_uInt32
)0) << ((sal_uInt32
)0) << ((sal_uInt32
)0);
2211 *(p
->pBMP
) << ((sal_uInt32
)0) << ((sal_uInt32
)0);
2212 // Schreibe Farbtabelle:
2213 if (p
->nBitsPerPixel
<=8) {
2214 USHORT i
, nColTabSize
=1<<(p
->nBitsPerPixel
);
2215 for (i
=0; i
<nColTabSize
; i
++) *(p
->pBMP
) << GetPalette0RGB(i
);
2218 // OK, nun werden die Map-Daten ruebergeschoben. Leider haben OS2 und
2219 // BMP eine unterschiedliche Reihenfolge von RGB bei 24-Bit.
2220 BYTE
* pBuf
=new BYTE
[nDataLen
];
2221 pOS2MET
->Read(pBuf
,nDataLen
);
2222 if (p
->nBitsPerPixel
==24) {
2223 ULONG i
, j
, nAlign
, nBytesPerLine
;
2225 nBytesPerLine
=(p
->nWidth
*3+3)&0xfffffffc;
2226 nAlign
=p
->nMapPos
-(p
->nMapPos
% nBytesPerLine
);
2228 while (nAlign
+i
+2<p
->nMapPos
+nDataLen
) {
2229 if (nAlign
+i
>=p
->nMapPos
) {
2230 j
=nAlign
+i
-p
->nMapPos
;
2231 nTemp
=pBuf
[j
]; pBuf
[j
]=pBuf
[j
+2]; pBuf
[j
+2]=nTemp
;
2233 i
+=3; if (i
+2>=nBytesPerLine
) {
2234 nAlign
+=nBytesPerLine
;
2239 p
->pBMP
->Write(pBuf
,nDataLen
);
2240 p
->nMapPos
+=nDataLen
;
2244 case 0x0093: // End Image Content
2247 case 0x0071: // End Segment
2252 void OS2METReader::ReadFont(USHORT nFieldSize
)
2254 ULONG nPos
, nMaxPos
;
2256 BYTE nByte
, nTripType
, nTripType2
;
2257 OSFont
* pF
=new OSFont
;
2258 pF
->pSucc
=pFontList
; pFontList
=pF
;
2260 pF
->aFont
.SetTransparent(TRUE
);
2261 pF
->aFont
.SetAlign(ALIGN_BASELINE
);
2263 nPos
=pOS2MET
->Tell();
2264 nMaxPos
=nPos
+(ULONG
)nFieldSize
;
2265 pOS2MET
->SeekRel(2); nPos
+=2;
2266 while (nPos
<nMaxPos
&& pOS2MET
->GetError()==0) {
2267 *pOS2MET
>> nByte
; nLen
=((USHORT
)nByte
) & 0x00ff;
2268 *pOS2MET
>> nTripType
;
2269 switch (nTripType
) {
2271 *pOS2MET
>> nTripType2
;
2272 switch (nTripType2
) {
2273 case 0x84: // Font name
2275 case 0x08: { // Font Typeface
2277 pOS2MET
->SeekRel(1);
2278 pOS2MET
->Read( &str
, 32 );
2280 String
aStr( (const sal_Char
*)str
, gsl_getSystemTextEncoding() );
2281 if ( aStr
.CompareIgnoreCaseToAscii( "Helv" ) == COMPARE_EQUAL
)
2282 aStr
= String::CreateFromAscii( "Helvetica" );
2283 pF
->aFont
.SetName( aStr
);
2289 *pOS2MET
>> nTripType2
;
2290 switch (nTripType2
) {
2293 pF
->nID
=((ULONG
)nByte
)&0xff;
2297 case 0x20: // Font Binary GCID
2299 case 0x1f: { // Font Attributes
2304 case 1: eWeight
=WEIGHT_THIN
; break;
2305 case 2: eWeight
=WEIGHT_ULTRALIGHT
; break;
2306 case 3: eWeight
=WEIGHT_LIGHT
; break;
2307 case 4: eWeight
=WEIGHT_SEMILIGHT
; break;
2308 case 5: eWeight
=WEIGHT_NORMAL
; break;
2309 case 6: eWeight
=WEIGHT_SEMIBOLD
; break;
2310 case 7: eWeight
=WEIGHT_BOLD
; break;
2311 case 8: eWeight
=WEIGHT_ULTRABOLD
; break;
2312 case 9: eWeight
=WEIGHT_BLACK
; break;
2313 default: eWeight
=WEIGHT_DONTKNOW
;
2315 pF
->aFont
.SetWeight(eWeight
);
2319 nPos
+=nLen
; pOS2MET
->Seek(nPos
);
2323 void OS2METReader::ReadField(USHORT nFieldType
, USHORT nFieldSize
)
2325 switch (nFieldType
) {
2326 case BegDocumnMagic
:
2328 case EndDocumnMagic
:
2330 case BegResGrpMagic
:
2332 case EndResGrpMagic
:
2334 case BegColAtrMagic
:
2336 case EndColAtrMagic
:
2338 case BlkColAtrMagic
: {
2339 ULONG nPos
, nMaxPos
;
2342 USHORT nStartIndex
, nEndIndex
, i
, nElemLen
, nBytesPerCol
;
2344 nPos
=pOS2MET
->Tell();
2345 nMaxPos
=nPos
+(ULONG
)nFieldSize
;
2346 pOS2MET
->SeekRel(3); nPos
+=3;
2347 while (nPos
<nMaxPos
&& pOS2MET
->GetError()==0) {
2348 *pOS2MET
>> nbyte
; nElemLen
=((USHORT
)nbyte
) & 0x00ff;
2350 pOS2MET
->SeekRel(4);
2351 nStartIndex
=ReadBigEndianWord();
2352 pOS2MET
->SeekRel(3);
2353 *pOS2MET
>> nbyte
; nBytesPerCol
=((USHORT
)nbyte
) & 0x00ff;
2354 nEndIndex
=nStartIndex
+(nElemLen
-11)/nBytesPerCol
;
2355 for (i
=nStartIndex
; i
<nEndIndex
; i
++) {
2356 if (nBytesPerCol
> 3) pOS2MET
->SeekRel(nBytesPerCol
-3);
2357 nCol
=ReadBigEndian3BytesLong();
2358 SetPalette0RGB(i
,nCol
);
2361 else if (nElemLen
<10) {
2362 pOS2MET
->SetError(SVSTREAM_FILEFORMAT_ERROR
);
2365 nPos
+=(ULONG
)nElemLen
;
2366 pOS2MET
->Seek(nPos
);
2370 case MapColAtrMagic
:
2372 case BegImgObjMagic
: {
2373 // neue Bitmap schonmal herstellen: (wird spaeter gefuellt)
2374 OSBitmap
* pB
=new OSBitmap
;
2375 pB
->pSucc
=pBitmapList
; pBitmapList
=pB
;
2376 pB
->pBMP
=NULL
; pB
->nWidth
=0; pB
->nHeight
=0; pB
->nBitsPerPixel
=0;
2378 // ID der Bitmap ermitteln:
2379 BYTE i
,nbyte
,nbyte2
;
2381 for (i
=0; i
<4; i
++) {
2382 *pOS2MET
>> nbyte
>> nbyte2
;
2383 nbyte
=((nbyte
-0x30)<<4)|(nbyte2
-0x30);
2384 pB
->nID
=(pB
->nID
>>8)|(((ULONG
)nbyte
)<<24);
2386 // neue Palette auf den Paletten-Stack bringen: (wird spaeter gefuellt)
2387 OSPalette
* pP
=new OSPalette
;
2388 pP
->pSucc
=pPaletteStack
; pPaletteStack
=pP
;
2389 pP
->p0RGB
=NULL
; pP
->nSize
=0;
2392 case EndImgObjMagic
: {
2393 // Temporaere Windows-BMP-Datei auslesen:
2394 if (pBitmapList
==NULL
|| pBitmapList
->pBMP
==NULL
||
2395 pBitmapList
->pBMP
->GetError()!=0) {
2396 pOS2MET
->SetError(SVSTREAM_FILEFORMAT_ERROR
);
2400 pBitmapList
->pBMP
->Seek(0);
2402 pBitmapList
->aBitmap
.Read( *( pBitmapList
->pBMP
), FALSE
);
2404 if (pBitmapList
->pBMP
->GetError()!=0) {
2405 pOS2MET
->SetError(SVSTREAM_FILEFORMAT_ERROR
);
2408 delete pBitmapList
->pBMP
; pBitmapList
->pBMP
=NULL
;
2409 // Palette vom Stack killen:
2410 OSPalette
* pP
=pPaletteStack
;
2412 pPaletteStack
=pP
->pSucc
;
2413 if (pP
->p0RGB
!=NULL
) delete[] pP
->p0RGB
;
2418 case DscImgObjMagic
:
2420 case DatImgObjMagic
: {
2421 USHORT nDataID
, nDataLen
;
2423 ULONG nPos
, nMaxPos
;
2425 nPos
=pOS2MET
->Tell();
2426 nMaxPos
=nPos
+(ULONG
)nFieldSize
;
2427 while (nPos
<nMaxPos
&& pOS2MET
->GetError()==0) {
2428 *pOS2MET
>> nbyte
; nDataID
=((USHORT
)nbyte
)&0x00ff;
2429 if (nDataID
==0x00fe) {
2431 nDataID
=(nDataID
<<8)|(((USHORT
)nbyte
)&0x00ff);
2432 nDataLen
=ReadBigEndianWord();
2436 *pOS2MET
>> nbyte
; nDataLen
=((USHORT
)nbyte
)&0x00ff;
2439 ReadImageData(nDataID
, nDataLen
);
2440 nPos
+=(ULONG
)nDataLen
;
2441 pOS2MET
->Seek(nPos
);
2446 case BegObEnv1Magic
:
2448 case EndObEnv1Magic
:
2450 case BegGrfObjMagic
:
2452 case EndGrfObjMagic
: {
2454 ULONG nPos
, nMaxPos
;
2455 USHORT nOrderID
, nOrderLen
;
2458 if (pOrdFile
==NULL
) break;
2460 // in pOrdFile wurden alle "DatGrfObj"-Felder gesammelt, so
2461 // dass die darin enthaltnen "Orders" zusammenhangend und nicht durch
2462 // "Fields" segmentiert sind. Um sie aus dem MemoryStream auszulesen,
2463 // ohne grosse Umstaende deswegen zu haben (frueher wurden die "Orders"
2464 // direkt aus pOS2MET gelesen), hier ein kleiner Trick:
2466 pOS2MET
=pOrdFile
; //(!)
2467 nMaxPos
=pOS2MET
->Tell();
2472 if (nbyte
==0x70) { // Header vorhanden
2473 pOS2MET
->SeekRel(15); // brauchen wir aber nicht
2475 else pOS2MET
->SeekRel(-1); // Kein Header, Byte zurueck
2477 // Schleife ueber Order:
2478 while (pOS2MET
->Tell()<nMaxPos
&& pOS2MET
->GetError()==0) {
2479 *pOS2MET
>> nbyte
; nOrderID
=((USHORT
)nbyte
) & 0x00ff;
2480 if (nOrderID
==0x00fe) {
2482 nOrderID
=(nOrderID
<< 8) | (((USHORT
)nbyte
) & 0x00ff);
2484 if (nOrderID
>0x00ff || nOrderID
==GOrdPolygn
) {
2485 // ooo: Laut OS2-Doku sollte die Orderlaenge nun als Big-Endian-Word
2486 // gegeben sein (Zitat: "Highorder byte precedes loworder byte").
2487 // Tatsaechlich gibt es aber Dateien, die die Laenge als
2488 // Little-Endian-Word angeben (zu mindestens fuer nOrderID==GOrdPolygn).
2489 // Also werfen wir eine Muenze oder was ?
2490 *pOS2MET
>> nbyte
; nOrderLen
=(USHORT
)nbyte
&0x00ff;
2491 *pOS2MET
>> nbyte
; if (nbyte
!=0) nOrderLen
=nOrderLen
<<8|(((USHORT
)nbyte
)&0x00ff);
2493 else if (nOrderID
==GOrdSTxAlg
|| nOrderID
==GOrdPTxAlg
) nOrderLen
=2;
2494 else if ((nOrderID
&0xff88)==0x0008) nOrderLen
=1;
2495 else if (nOrderID
==0x0000 || nOrderID
==0x00ff) nOrderLen
=0;
2496 else { *pOS2MET
>> nbyte
; nOrderLen
=((USHORT
)nbyte
) & 0x00ff; }
2497 nPos
=pOS2MET
->Tell();
2498 ReadOrder(nOrderID
, nOrderLen
);
2499 if (nPos
+nOrderLen
< pOS2MET
->Tell()) {
2500 OOODEBUG("Order kuerzer als er denkt! OrderID:",nOrderID
);
2501 OOODEBUG("...und zwar bei Position (Parameteranfang):",nPos
);
2503 else if (nPos
+nOrderLen
!= pOS2MET
->Tell()) {
2504 OOODEBUG(String(nOrderID
)+String(" Order nicht alles gelesen! bei:"),nPos
);
2506 pOS2MET
->Seek(nPos
+nOrderLen
);
2510 if (pOrdFile
->GetError()) {
2511 pOS2MET
->SetError(SVSTREAM_FILEFORMAT_ERROR
);
2514 delete pOrdFile
; pOrdFile
=NULL
;
2517 case DscGrfObjMagic
: {
2518 ULONG nPos
, nMaxPos
;
2519 USHORT nDscID
, nDscLen
;
2522 nMaxPos
=pOS2MET
->Tell()+(ULONG
)nFieldSize
;
2523 while (pOS2MET
->Tell()<nMaxPos
&& pOS2MET
->GetError()==0) {
2524 *pOS2MET
>> nbyte
; nDscID
=((USHORT
)nbyte
) & 0x00ff;
2525 *pOS2MET
>> nbyte
; nDscLen
=((USHORT
)nbyte
) & 0x00ff;
2526 nPos
=pOS2MET
->Tell();
2527 ReadDsc(nDscID
, nDscLen
);
2528 pOS2MET
->Seek(nPos
+nDscLen
);
2532 case DatGrfObjMagic
: {
2533 if (pOrdFile
==NULL
) {
2534 pOrdFile
= new SvMemoryStream
;
2535 pOrdFile
->SetNumberFormatInt(NUMBERFORMAT_INT_LITTLEENDIAN
);
2537 BYTE
* pBuf
; pBuf
= new BYTE
[nFieldSize
];
2538 pOS2MET
->Read(pBuf
,nFieldSize
);
2539 pOrdFile
->Write(pBuf
,nFieldSize
);
2543 case MapCodFntMagic
:
2544 ReadFont(nFieldSize
);
2547 case MapDatResMagic
:
2552 void OS2METReader::ReadOS2MET( SvStream
& rStreamOS2MET
, GDIMetaFile
& rGDIMetaFile
)
2556 ULONG nPos
, nStartPos
, nEndPos
, nPercent
, nLastPercent
;
2561 pOS2MET
= &rStreamOS2MET
;
2562 nOrigPos
= pOS2MET
->Tell();
2563 nOrigNumberFormat
= pOS2MET
->GetNumberFormatInt();
2574 aDefAttr
.aLinCol
=Color(COL_BLACK
);
2575 aDefAttr
.aLinBgCol
=Color(COL_WHITE
);
2576 aDefAttr
.eLinMix
=ROP_OVERPAINT
;
2577 aDefAttr
.eLinBgMix
=ROP_OVERPAINT
;
2578 aDefAttr
.aChrCol
=Color(COL_BLACK
);
2579 aDefAttr
.aChrBgCol
=Color(COL_WHITE
);
2580 aDefAttr
.eChrMix
=ROP_OVERPAINT
;
2581 aDefAttr
.eChrBgMix
=ROP_OVERPAINT
;
2582 aDefAttr
.aMrkCol
=Color(COL_BLACK
);
2583 aDefAttr
.aMrkBgCol
=Color(COL_WHITE
);
2584 aDefAttr
.eMrkMix
=ROP_OVERPAINT
;
2585 aDefAttr
.eMrkBgMix
=ROP_OVERPAINT
;
2586 aDefAttr
.aPatCol
=Color(COL_BLACK
);
2587 aDefAttr
.aPatBgCol
=Color(COL_WHITE
);
2588 aDefAttr
.ePatMix
=ROP_OVERPAINT
;
2589 aDefAttr
.ePatBgMix
=ROP_OVERPAINT
;
2590 aDefAttr
.aImgCol
=Color(COL_BLACK
);
2591 aDefAttr
.aImgBgCol
=Color(COL_WHITE
);
2592 aDefAttr
.eImgMix
=ROP_OVERPAINT
;
2593 aDefAttr
.eImgBgMix
=ROP_OVERPAINT
;
2598 aDefAttr
.nChrAng
=0;
2599 aDefAttr
.aChrCellSize
=Size(12,12);
2600 aDefAttr
.nChrSet
=0;
2601 aDefAttr
.aCurPos
=Point(0,0);
2602 aDefAttr
.eLinStyle
=PEN_SOLID
;
2603 aDefAttr
.nLinWidth
=0;
2604 aDefAttr
.aMrkCellSize
=Size(10,10);
2605 aDefAttr
.nMrkPrec
=0x01;
2606 aDefAttr
.nMrkSet
=0xff;
2607 aDefAttr
.nMrkSymbol
=0x01;
2608 aDefAttr
.bFill
=TRUE
;
2609 aDefAttr
.nStrLinWidth
=0;
2615 pVirDev
= new VirtualDevice();
2616 pVirDev
->EnableOutput(FALSE
);
2617 rGDIMetaFile
.Record(pVirDev
);
2619 pOS2MET
->SetNumberFormatInt(NUMBERFORMAT_INT_LITTLEENDIAN
);
2621 nStartPos
=pOS2MET
->Tell();
2622 nEndPos
=pOS2MET
->Seek(STREAM_SEEK_TO_END
); pOS2MET
->Seek(nStartPos
);
2623 Callback(0); nLastPercent
=0;
2625 nPos
=pOS2MET
->Tell();
2626 if ( nStartPos
== nEndPos
)
2634 nPercent
=(nPos
-nStartPos
)*100/(nEndPos
-nStartPos
);
2635 if (nLastPercent
+4<=nPercent
) {
2636 if (Callback((USHORT
)nPercent
)==TRUE
) break;
2637 nLastPercent
=nPercent
;
2640 nFieldSize
=ReadBigEndianWord();
2642 *pOS2MET
>> nMagicByte
;
2643 if (nMagicByte
!=0xd3) {
2644 pOS2MET
->SetError(SVSTREAM_FILEFORMAT_ERROR
);
2648 *pOS2MET
>> nFieldType
;
2650 pOS2MET
->SeekRel(3);
2651 nPos
+=8; nFieldSize
-=8;
2653 if (pOS2MET
->GetError()) break;
2654 if (pOS2MET
->IsEof()) {
2655 pOS2MET
->SetError(SVSTREAM_FILEFORMAT_ERROR
);
2660 if (nFieldType
==EndDocumnMagic
) break;
2662 ReadField(nFieldType
, nFieldSize
);
2664 nPos
+=(ULONG
)nFieldSize
;
2665 if (pOS2MET
->Tell()>nPos
) {
2666 pOS2MET
->SetError(SVSTREAM_FILEFORMAT_ERROR
);
2670 pOS2MET
->Seek(nPos
);
2673 rGDIMetaFile
.Stop();
2676 rGDIMetaFile
.SetPrefMapMode( aGlobMapMode
);
2678 if( aBoundingRect
.GetWidth() && aBoundingRect
.GetHeight() )
2679 rGDIMetaFile
.SetPrefSize( aBoundingRect
.GetSize() );
2682 if( aCalcBndRect
.Left() || aCalcBndRect
.Top() )
2683 rGDIMetaFile
.Move( -aCalcBndRect
.Left(), -aCalcBndRect
.Top() );
2685 rGDIMetaFile
.SetPrefSize( aCalcBndRect
.GetSize() );
2688 if (pOrdFile
!=NULL
) delete pOrdFile
;
2690 while (pAreaStack
!=NULL
) {
2691 OSArea
* p
=pAreaStack
;
2692 pAreaStack
=p
->pSucc
;
2696 while (pPathStack
!=NULL
) {
2697 OSPath
* p
=pPathStack
;
2698 pPathStack
=p
->pSucc
;
2702 while (pPathList
!=NULL
) {
2703 OSPath
* p
=pPathList
;
2708 while (pFontList
!=NULL
) {
2709 OSFont
* p
=pFontList
;
2714 while (pBitmapList
!=NULL
) {
2715 OSBitmap
* p
=pBitmapList
;
2716 pBitmapList
=p
->pSucc
;
2717 if (p
->pBMP
!=NULL
) delete p
->pBMP
;
2721 while (pAttrStack
!=NULL
) {
2722 OSAttr
* p
=pAttrStack
;
2723 pAttrStack
=p
->pSucc
;
2727 while (pPaletteStack
!=NULL
) {
2728 OSPalette
* p
=pPaletteStack
;
2729 pPaletteStack
=p
->pSucc
;
2730 if (p
->p0RGB
!=NULL
) delete[] p
->p0RGB
;
2734 pOS2MET
->SetNumberFormatInt(nOrigNumberFormat
);
2736 if (pOS2MET
->GetError()) {
2737 OOODEBUG("Fehler Nr.:",ErrorCode
);
2738 pOS2MET
->Seek(nOrigPos
);
2742 //================== GraphicImport - die exportierte Funktion ================
2744 extern "C" BOOL __LOADONCALLAPI
GraphicImport(SvStream
& rStream
, Graphic
& rGraphic
, FilterConfigItem
*, BOOL
)
2746 OS2METReader aOS2METReader
;
2750 aOS2METReader
.ReadOS2MET( rStream
, aMTF
);
2752 if ( !rStream
.GetError() )
2754 rGraphic
=Graphic( aMTF
);
2761 //================== ein bischen Muell fuer Windows ==========================
2767 static HINSTANCE hDLLInst
= 0; // HANDLE der DLL
2769 extern "C" int CALLBACK
LibMain( HINSTANCE hDLL
, WORD
, WORD nHeap
, LPSTR
)
2781 extern "C" int CALLBACK
WEP( int )