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 <string.h>
31 : : #include <vcl/bmpacc.hxx>
32 : : #include <vcl/graph.hxx>
33 : : #include <tools/poly.hxx>
34 : : #include <vcl/virdev.hxx>
35 : : #include <svtools/fltcall.hxx>
36 : : #include <math.h>
37 : :
38 : : #include "shape.hxx"
39 : :
40 : : namespace PictReaderInternal {
41 : : //! utilitary class to store a pattern, ...
42 : : class Pattern {
43 : : public:
44 : : //! constructor
45 : 27 : Pattern() {
46 : 27 : isColor = false; isRead = false;
47 : 27 : penStyle=PEN_SOLID; brushStyle = BRUSH_SOLID;
48 : 27 : nBitCount = 64;
49 : 27 : }
50 : :
51 : : //! reads black/white pattern from SvStream
52 : : sal_uLong read(SvStream &stream);
53 : : //! sets the color
54 : 0 : void setColor(Color &col) { isColor = true; color = col; }
55 : : /** returns a color which can be "used" to replace the pattern,
56 : : * created from ForeColor and BackColor, ...
57 : : *
58 : : * note: maybe, we must also use some mode PatCopy, ... to define the color
59 : : */
60 : 0 : Color getColor(Color bkColor=COL_WHITE, Color fgColor = COL_BLACK) const {
61 [ # # ]: 0 : if (isColor) return color;
62 : : // we create a gray pattern from nBitCount
63 : 0 : double alpha = nBitCount / 64.0;
64 : 0 : return Color(sal_uInt8(alpha*fgColor.GetRed()+(1.0-alpha)*bkColor.GetRed()),
65 : 0 : sal_uInt8(alpha*fgColor.GetGreen()+(1.0-alpha)*bkColor.GetGreen()),
66 : 0 : sal_uInt8(alpha*fgColor.GetBlue()+(1.0-alpha)*bkColor.GetBlue()));
67 : : }
68 : :
69 : : //! returns true if this is the default pattern
70 : 90 : bool isDefault() const { return isRead == false; }
71 : :
72 : : // MT: NOOLDSV, someone should change the code...
73 : : enum PenStyle { PEN_NULL, PEN_SOLID, PEN_DOT, PEN_DASH, PEN_DASHDOT };
74 : : enum BrushStyle { BRUSH_NULL, BRUSH_SOLID, BRUSH_HORZ, BRUSH_VERT,
75 : : BRUSH_CROSS, BRUSH_DIAGCROSS, BRUSH_UPDIAG, BRUSH_DOWNDIAG,
76 : : BRUSH_25, BRUSH_50, BRUSH_75,
77 : : BRUSH_BITMAP };
78 : : // Data
79 : : enum PenStyle penStyle;
80 : : enum BrushStyle brushStyle;
81 : : short nBitCount;
82 : :
83 : : bool isColor; // true if it is a color pattern
84 : : Color color;
85 : :
86 : : protected:
87 : : // flag to know if the pattern came from reading the picture, or if it is the default pattern
88 : : bool isRead;
89 : : };
90 : :
91 : 0 : sal_uLong Pattern::read(SvStream &stream) {
92 : : short nx,ny;
93 : : unsigned char nbyte[8];
94 : : sal_uLong nHiBytes, nLoBytes;
95 : 0 : isColor = false;
96 : :
97 : : // Anzahl der Bits im Pattern zaehlen, die auf 1 gesetzt sind:
98 : 0 : nBitCount=0;
99 [ # # ]: 0 : for (ny=0; ny<8; ny++) {
100 [ # # ]: 0 : stream >> ((char&)nbyte[ny]);
101 [ # # ]: 0 : for (nx=0; nx<8; nx++) {
102 [ # # ]: 0 : if ( (nbyte[ny] & (1<<nx)) != 0 ) nBitCount++;
103 : : }
104 : : }
105 : :
106 : : // Pattern in 2 Langworten unterbringen:
107 : 0 : nHiBytes=(((((((sal_uLong)nbyte[0])<<8)|
108 : 0 : (sal_uLong)nbyte[1])<<8)|
109 : 0 : (sal_uLong)nbyte[2])<<8)|
110 : 0 : (sal_uLong)nbyte[3];
111 : 0 : nLoBytes=(((((((sal_uLong)nbyte[4])<<8)|
112 : 0 : (sal_uLong)nbyte[5])<<8)|
113 : 0 : (sal_uLong)nbyte[6])<<8)|
114 : 0 : (sal_uLong)nbyte[7];
115 : :
116 : : // Einen PenStyle machen:
117 [ # # ]: 0 : if (nBitCount<=0) penStyle=PEN_NULL;
118 [ # # ]: 0 : else if (nBitCount<=16) penStyle=PEN_DOT;
119 [ # # ]: 0 : else if (nBitCount<=32) penStyle=PEN_DASHDOT;
120 [ # # ]: 0 : else if (nBitCount<=48) penStyle=PEN_DASH;
121 : 0 : else penStyle=PEN_SOLID;
122 : :
123 : : // Einen BrushStyle machen:
124 [ # # ][ # # ]: 0 : if (nHiBytes==0xffffffff && nLoBytes==0xffffffff) brushStyle=BRUSH_SOLID;
125 [ # # ][ # # ]: 0 : else if (nHiBytes==0xff000000 && nLoBytes==0x00000000) brushStyle=BRUSH_HORZ;
126 [ # # ][ # # ]: 0 : else if (nHiBytes==0x80808080 && nLoBytes==0x80808080) brushStyle=BRUSH_VERT;
127 [ # # ][ # # ]: 0 : else if (nHiBytes==0xff808080 && nLoBytes==0x80808080) brushStyle=BRUSH_CROSS;
128 [ # # ][ # # ]: 0 : else if (nHiBytes==0x01824428 && nLoBytes==0x10284482) brushStyle=BRUSH_DIAGCROSS;
129 [ # # ][ # # ]: 0 : else if (nHiBytes==0x80402010 && nLoBytes==0x08040201) brushStyle=BRUSH_UPDIAG;
130 [ # # ][ # # ]: 0 : else if (nHiBytes==0x01020408 && nLoBytes==0x10204080) brushStyle=BRUSH_DOWNDIAG;
131 [ # # ]: 0 : else if (nBitCount<=24) brushStyle=BRUSH_25;
132 [ # # ]: 0 : else if (nBitCount<=40) brushStyle=BRUSH_50;
133 [ # # ]: 0 : else if (nBitCount<=56) brushStyle=BRUSH_75;
134 : 0 : else brushStyle=BRUSH_SOLID;
135 : :
136 : 0 : isRead = true;
137 : :
138 : 0 : return 8;
139 : : }
140 : : }
141 : :
142 : : //============================ PictReader ==================================
143 : :
144 : : enum PictDrawingMethod {
145 : : PDM_FRAME, PDM_PAINT, PDM_ERASE, PDM_INVERT, PDM_FILL,
146 : : PDM_TEXT, PDM_UNDEFINED
147 : : };
148 : :
149 [ + - ]: 9 : class PictReader {
150 : : typedef class PictReaderInternal::Pattern Pattern;
151 : : private:
152 : :
153 : : SvStream * pPict; // Die einzulesende Pict-Datei
154 : : VirtualDevice * pVirDev; // Hier werden die Drawing-Methoden aufgerufen.
155 : : // Dabei findet ein Recording in das GDIMetaFile
156 : : // statt.
157 : : sal_uLong nOrigPos; // Anfaengliche Position in pPict
158 : : sal_uInt16 nOrigNumberFormat; // Anfaengliches Nummern-Format von pPict
159 : : sal_Bool IsVersion2; // Ob es ein Version 2 Pictfile ist.
160 : : Rectangle aBoundingRect; // Min/Max-Rechteck fuer die ganze Zeichnung
161 : :
162 : : Point aPenPosition;
163 : : Point aTextPosition;
164 : : Color aActForeColor;
165 : : Color aActBackColor;
166 : : Pattern eActPenPattern;
167 : : Pattern eActFillPattern;
168 : : Pattern eActBackPattern;
169 : : Size nActPenSize;
170 : : // Note: Postscript mode is stored by setting eActRop to ROP_1
171 : : RasterOp eActROP;
172 : : PictDrawingMethod eActMethod;
173 : : Size aActOvalSize;
174 : : Font aActFont;
175 : :
176 : : Fraction aHRes;
177 : : Fraction aVRes;
178 : :
179 : : sal_Bool Callback(sal_uInt16 nPercent);
180 : :
181 : : Point ReadPoint();
182 : :
183 : : Point ReadDeltaH(Point aBase);
184 : : Point ReadDeltaV(Point aBase);
185 : :
186 : : Point ReadUnsignedDeltaH(Point aBase);
187 : : Point ReadUnsignedDeltaV(Point aBase);
188 : :
189 : : Size ReadSize();
190 : :
191 : : Color ReadColor();
192 : :
193 : : Color ReadRGBColor();
194 : :
195 : : void ReadRectangle(Rectangle & rRect);
196 : :
197 : : sal_uLong ReadPolygon(Polygon & rPoly);
198 : :
199 : : sal_uLong ReadPixPattern(Pattern &pattern);
200 : :
201 : : Rectangle aLastRect;
202 : : sal_uLong ReadAndDrawRect(PictDrawingMethod eMethod);
203 : : sal_uLong ReadAndDrawSameRect(PictDrawingMethod eMethod);
204 : :
205 : : Rectangle aLastRoundRect;
206 : : sal_uLong ReadAndDrawRoundRect(PictDrawingMethod eMethod);
207 : : sal_uLong ReadAndDrawSameRoundRect(PictDrawingMethod eMethod);
208 : :
209 : : Rectangle aLastOval;
210 : : sal_uLong ReadAndDrawOval(PictDrawingMethod eMethod);
211 : : sal_uLong ReadAndDrawSameOval(PictDrawingMethod eMethod);
212 : :
213 : : Polygon aLastPolygon;
214 : : sal_uLong ReadAndDrawPolygon(PictDrawingMethod eMethod);
215 : : sal_uLong ReadAndDrawSamePolygon(PictDrawingMethod eMethod);
216 : :
217 : : Rectangle aLastArcRect;
218 : : sal_uLong ReadAndDrawArc(PictDrawingMethod eMethod);
219 : : sal_uLong ReadAndDrawSameArc(PictDrawingMethod eMethod);
220 : :
221 : : sal_uLong ReadAndDrawRgn(PictDrawingMethod eMethod);
222 : : sal_uLong ReadAndDrawSameRgn(PictDrawingMethod eMethod);
223 : :
224 : : // returns true, if we do not need to print the shape/text/frame
225 : 255 : bool IsInvisible(PictDrawingMethod eMethod) const {
226 [ - + ]: 255 : if (eActROP == ROP_1) return true;
227 [ + + ][ + + ]: 255 : if (eMethod==PDM_FRAME && (nActPenSize.Width() == 0 || nActPenSize.Height() == 0)) return true;
[ - + ][ + + ]
228 : 255 : return false;
229 : : }
230 : : void DrawingMethod(PictDrawingMethod eMethod);
231 : :
232 : : sal_uLong ReadAndDrawText();
233 : :
234 : : sal_uLong ReadPixMapEtc(Bitmap & rBitmap, sal_Bool bBaseAddr, sal_Bool bColorTable,
235 : : Rectangle * pSrcRect, Rectangle * pDestRect,
236 : : sal_Bool bMode, sal_Bool bMaskRgn);
237 : :
238 : : void ReadHeader();
239 : : // Liesst den Kopf der Pict-Datei, setzt IsVersion2 und aBoundingRect
240 : :
241 : : sal_uLong ReadData(sal_uInt16 nOpcode);
242 : : // Liesst die Daten eines Opcodes ein und fuehrt die Operation aus.
243 : : // Auf jeden Fall wird die Anzahl der Datenbytes zu dem Opcode
244 : : // zurueckgeliefert.
245 : :
246 : : void SetLineColor( const Color& rColor );
247 : : void SetFillColor( const Color& rColor );
248 : :
249 : : // OSNOLA: returns the text encoding which must be used for system id
250 : : static rtl_TextEncoding GetTextEncoding (sal_uInt16 fId = 0xFFFF);
251 : : public:
252 : :
253 [ + - ][ + - ]: 9 : PictReader() { aActFont.SetCharSet(GetTextEncoding()); }
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
254 : :
255 : : void ReadPict( SvStream & rStreamPict, GDIMetaFile & rGDIMetaFile );
256 : : // Liesst aus dem Stream eine Pict-Datei und fuellt das GDIMetaFile
257 : :
258 : : };
259 : :
260 : : //------------------------------------------------------------------------------------------------
261 : :
262 : : #define SETBYTE \
263 : : switch ( nPixelSize ) \
264 : : { \
265 : : case 1 : \
266 : : pAcc->SetPixel( ny, nx++, nDat >> 7 ); \
267 : : if ( nx == nWidth ) break; \
268 : : pAcc->SetPixel( ny, nx++, nDat >> 6 ); \
269 : : if ( nx == nWidth ) break; \
270 : : pAcc->SetPixel( ny, nx++, nDat >> 5 ); \
271 : : if ( nx == nWidth ) break; \
272 : : pAcc->SetPixel( ny, nx++, nDat >> 4 ); \
273 : : if ( nx == nWidth ) break; \
274 : : pAcc->SetPixel( ny, nx++, nDat >> 3 ); \
275 : : if ( nx == nWidth ) break; \
276 : : pAcc->SetPixel( ny, nx++, nDat >> 2 ); \
277 : : if ( nx == nWidth ) break; \
278 : : pAcc->SetPixel( ny, nx++, nDat >> 1 ); \
279 : : if ( nx == nWidth ) break; \
280 : : pAcc->SetPixel( ny, nx++, nDat ); \
281 : : break; \
282 : : case 2 : \
283 : : pAcc->SetPixel( ny, nx++, nDat >> 6 ); \
284 : : if ( nx == nWidth ) break; \
285 : : pAcc->SetPixel( ny, nx++, nDat >> 4 & 3); \
286 : : if ( nx == nWidth ) break; \
287 : : pAcc->SetPixel( ny, nx++, nDat >> 2 & 3 ); \
288 : : if ( nx == nWidth ) break; \
289 : : pAcc->SetPixel( ny, nx++, nDat & 3); \
290 : : break; \
291 : : case 4 : \
292 : : pAcc->SetPixel( ny, nx++, nDat >> 4 ); \
293 : : if ( nx == nWidth ) break; \
294 : : pAcc->SetPixel( ny, nx++, nDat ); \
295 : : break; \
296 : : case 8 : \
297 : : pAcc->SetPixel( ny, nx++, nDat ); \
298 : : break; \
299 : : }
300 : :
301 : : //------------------------------------------------------------------------------------------------
302 : :
303 : : #define BITMAPERROR \
304 : : { \
305 : : if ( pAcc ) \
306 : : aBitmap.ReleaseAccess( pAcc ); \
307 : : if ( pReadAcc ) \
308 : : aBitmap.ReleaseAccess( pReadAcc ); \
309 : : return 0xffffffff; \
310 : : }
311 : :
312 : : //=================== Methoden von PictReader ==============================
313 : 18 : rtl_TextEncoding PictReader::GetTextEncoding (sal_uInt16 fId) {
314 : : static bool first = true;
315 : : static rtl_TextEncoding enc = RTL_TEXTENCODING_APPLE_ROMAN;
316 [ + + ]: 18 : if (first) {
317 : 3 : rtl_TextEncoding def = osl_getThreadTextEncoding();
318 : : // we keep osl_getThreadTextEncoding only if it is a mac encoding
319 [ - + ]: 3 : switch(def) {
320 : : case RTL_TEXTENCODING_APPLE_ROMAN:
321 : : case RTL_TEXTENCODING_APPLE_ARABIC:
322 : : case RTL_TEXTENCODING_APPLE_CENTEURO:
323 : : case RTL_TEXTENCODING_APPLE_CROATIAN:
324 : : case RTL_TEXTENCODING_APPLE_CYRILLIC:
325 : : case RTL_TEXTENCODING_APPLE_DEVANAGARI:
326 : : case RTL_TEXTENCODING_APPLE_FARSI:
327 : : case RTL_TEXTENCODING_APPLE_GREEK:
328 : : case RTL_TEXTENCODING_APPLE_GUJARATI:
329 : : case RTL_TEXTENCODING_APPLE_GURMUKHI:
330 : : case RTL_TEXTENCODING_APPLE_HEBREW:
331 : : case RTL_TEXTENCODING_APPLE_ICELAND:
332 : : case RTL_TEXTENCODING_APPLE_ROMANIAN:
333 : : case RTL_TEXTENCODING_APPLE_THAI:
334 : : case RTL_TEXTENCODING_APPLE_TURKISH:
335 : : case RTL_TEXTENCODING_APPLE_UKRAINIAN:
336 : : case RTL_TEXTENCODING_APPLE_CHINSIMP:
337 : : case RTL_TEXTENCODING_APPLE_CHINTRAD:
338 : : case RTL_TEXTENCODING_APPLE_JAPANESE:
339 : : case RTL_TEXTENCODING_APPLE_KOREAN:
340 : 0 : enc = def; break;
341 : 3 : default: break;
342 : : }
343 : 3 : first = false;
344 : : }
345 [ - + ]: 18 : if (fId == 13) return RTL_TEXTENCODING_ADOBE_DINGBATS; // CHECKME
346 [ - + ]: 18 : if (fId == 23) return RTL_TEXTENCODING_ADOBE_SYMBOL;
347 : 18 : return enc;
348 : : }
349 : :
350 : 90 : void PictReader::SetLineColor( const Color& rColor )
351 : : {
352 : 90 : pVirDev->SetLineColor( rColor );
353 : 90 : }
354 : :
355 : 90 : void PictReader::SetFillColor( const Color& rColor )
356 : : {
357 : 90 : pVirDev->SetFillColor( rColor );
358 : 90 : }
359 : :
360 : 69 : sal_Bool PictReader::Callback(sal_uInt16 /*nPercent*/)
361 : : {
362 : 69 : return sal_False;
363 : : }
364 : :
365 : 4140 : Point PictReader::ReadPoint()
366 : : {
367 : : short nx,ny;
368 : :
369 [ + - ][ + - ]: 4140 : *pPict >> ny >> nx;
370 : :
371 : 4140 : return Point( (long)nx - aBoundingRect.Left(),
372 : 8280 : (long)ny - aBoundingRect.Top() );
373 : : }
374 : :
375 : 9 : Point PictReader::ReadDeltaH(Point aBase)
376 : : {
377 : : signed char ndh;
378 : :
379 [ + - ]: 9 : *pPict >> ((char&)ndh);
380 : :
381 : 9 : return Point( aBase.X() + (long)ndh, aBase.Y() );
382 : : }
383 : :
384 : 9 : Point PictReader::ReadDeltaV(Point aBase)
385 : : {
386 : : signed char ndv;
387 : :
388 [ + - ]: 9 : *pPict >> ((char&)ndv);
389 : :
390 : 9 : return Point( aBase.X(), aBase.Y() + (long)ndv );
391 : : }
392 : :
393 : 0 : Point PictReader::ReadUnsignedDeltaH(Point aBase)
394 : : {
395 : : sal_uInt8 ndh;
396 : :
397 [ # # ]: 0 : *pPict >> ndh;
398 : :
399 : 0 : return Point( aBase.X() + (long)ndh, aBase.Y() );
400 : : }
401 : :
402 : 0 : Point PictReader::ReadUnsignedDeltaV(Point aBase)
403 : : {
404 : : sal_uInt8 ndv;
405 : :
406 [ # # ]: 0 : *pPict >> ndv;
407 : :
408 : 0 : return Point( aBase.X(), aBase.Y() + (long)ndv );
409 : : }
410 : :
411 : 6 : Size PictReader::ReadSize()
412 : : {
413 : : short nx,ny;
414 : :
415 [ + - ][ + - ]: 6 : *pPict >> ny >> nx;
416 : :
417 : 6 : return Size( (long)nx, (long)ny );
418 : : }
419 : :
420 : 0 : Color PictReader::ReadColor()
421 : : {
422 : : sal_uInt32 nCol;
423 : 0 : Color aCol;
424 : :
425 [ # # ]: 0 : *pPict >> nCol;
426 [ # # # # : 0 : switch (nCol)
# # # #
# ]
427 : : {
428 : 0 : case 33: aCol=Color( COL_BLACK ); break;
429 : 0 : case 30: aCol=Color( COL_WHITE ); break;
430 : 0 : case 205: aCol=Color( COL_LIGHTRED ); break;
431 : 0 : case 341: aCol=Color( COL_LIGHTGREEN ); break;
432 : 0 : case 409: aCol=Color( COL_LIGHTBLUE ); break;
433 : 0 : case 273: aCol=Color( COL_LIGHTCYAN ); break;
434 : 0 : case 137: aCol=Color( COL_LIGHTMAGENTA ); break;
435 : 0 : case 69: aCol=Color( COL_YELLOW ); break;
436 : 0 : default: aCol=Color( COL_LIGHTGRAY );
437 : : }
438 : 0 : return aCol;
439 : : }
440 : :
441 : :
442 : 0 : Color PictReader::ReadRGBColor()
443 : : {
444 : : sal_uInt16 nR, nG, nB;
445 : :
446 [ # # ][ # # ]: 0 : *pPict >> nR >> nG >> nB;
[ # # ]
447 : 0 : return Color( (sal_uInt8) ( nR >> 8 ), (sal_uInt8) ( nG >> 8 ), (sal_uInt8) ( nB >> 8 ) );
448 : : }
449 : :
450 : :
451 : 9 : void PictReader::ReadRectangle(Rectangle & rRect)
452 : : {
453 : 9 : Point aTopLeft, aBottomRight;
454 : :
455 [ + - ]: 9 : aTopLeft=ReadPoint();
456 [ + - ]: 9 : aBottomRight=ReadPoint();
457 [ + - ]: 9 : rRect=Rectangle(aTopLeft,aBottomRight);
458 : 9 : }
459 : :
460 : :
461 : 87 : sal_uLong PictReader::ReadPolygon(Polygon & rPoly)
462 : : {
463 : : sal_uInt16 nSize,i;
464 : : sal_uLong nDataSize;
465 : :
466 [ + - ]: 87 : *pPict >> nSize;
467 [ + - ]: 87 : pPict->SeekRel(8);
468 : 87 : nDataSize=(sal_uLong)nSize;
469 : 87 : nSize=(nSize-10)/4;
470 [ + - ]: 87 : rPoly.SetSize(nSize);
471 [ + - ][ + - ]: 3990 : for (i=0; i<nSize; i++) rPoly.SetPoint(ReadPoint(),i);
[ + + ]
472 : 87 : return nDataSize;
473 : : }
474 : :
475 : 0 : sal_uLong PictReader::ReadPixPattern(PictReader::Pattern &pattern)
476 : : {
477 : : // Keine Ahnung, ob dies richtig ist, weil kein Bild gefunden, das
478 : : // PixPatterns enthaelt. Auch hier nur der Versuch, die Groesse der Daten zu
479 : : // ermitteln, und einfache StarView-Styles daraus zu machen. Gluecklicherweise
480 : : // enthaelt ein PixPattern immer auch ein normales Pattern.
481 : :
482 : : sal_uLong nDataSize;
483 : : sal_uInt16 nPatType;
484 [ # # ]: 0 : Bitmap aBMP;
485 : :
486 [ # # ]: 0 : *pPict >> nPatType;
487 [ # # ]: 0 : if (nPatType==1) {
488 [ # # ]: 0 : pattern.read(*pPict);
489 [ # # ]: 0 : nDataSize=ReadPixMapEtc(aBMP,sal_False,sal_True,NULL,NULL,sal_False,sal_False);
490 : : // CHANGEME: use average pixmap colors to update the pattern, ...
491 [ # # ]: 0 : if (nDataSize!=0xffffffff) nDataSize+=10;
492 : : }
493 [ # # ]: 0 : else if (nPatType==2) {
494 [ # # ]: 0 : pattern.read(*pPict);
495 : : // RGBColor
496 : : sal_uInt16 nR, nG, nB;
497 [ # # ][ # # ]: 0 : *pPict >> nR >> nG >> nB;
[ # # ]
498 : 0 : Color col((sal_uInt8) ( nR >> 8 ), (sal_uInt8) ( nG >> 8 ), (sal_uInt8) ( nB >> 8 ) );
499 : 0 : pattern.setColor(col);
500 : 0 : nDataSize=16;
501 : : }
502 : 0 : else nDataSize=0xffffffff;
503 : :
504 [ # # ]: 0 : return nDataSize;
505 : : }
506 : :
507 : 0 : sal_uLong PictReader::ReadAndDrawRect(PictDrawingMethod eMethod)
508 : : {
509 : 0 : ReadRectangle(aLastRect);
510 : 0 : ReadAndDrawSameRect(eMethod);
511 : 0 : return 8;
512 : : }
513 : :
514 : 0 : sal_uLong PictReader::ReadAndDrawSameRect(PictDrawingMethod eMethod)
515 : : {
516 [ # # ]: 0 : if (IsInvisible(eMethod)) return 0;
517 : 0 : DrawingMethod(eMethod);
518 : 0 : PictReaderShape::drawRectangle(pVirDev, eMethod==PDM_FRAME, aLastRect, nActPenSize);
519 : 0 : return 0;
520 : : }
521 : :
522 : 0 : sal_uLong PictReader::ReadAndDrawRoundRect(PictDrawingMethod eMethod)
523 : : {
524 : 0 : ReadRectangle(aLastRoundRect);
525 : 0 : ReadAndDrawSameRoundRect(eMethod);
526 : 0 : return 8;
527 : : }
528 : :
529 : 0 : sal_uLong PictReader::ReadAndDrawSameRoundRect(PictDrawingMethod eMethod)
530 : : {
531 [ # # ]: 0 : if (IsInvisible(eMethod)) return 0;
532 : 0 : DrawingMethod(eMethod);
533 : 0 : PictReaderShape::drawRoundRectangle(pVirDev, eMethod==PDM_FRAME, aLastRoundRect, aActOvalSize, nActPenSize);
534 : 0 : return 0;
535 : : }
536 : :
537 : 0 : sal_uLong PictReader::ReadAndDrawOval(PictDrawingMethod eMethod)
538 : : {
539 : 0 : ReadRectangle(aLastOval);
540 : 0 : ReadAndDrawSameOval(eMethod);
541 : 0 : return 8;
542 : : }
543 : :
544 : 0 : sal_uLong PictReader::ReadAndDrawSameOval(PictDrawingMethod eMethod)
545 : : {
546 [ # # ]: 0 : if (IsInvisible(eMethod)) return 0;
547 : 0 : DrawingMethod(eMethod);
548 : 0 : PictReaderShape::drawEllipse(pVirDev, eMethod==PDM_FRAME, aLastOval, nActPenSize);
549 : 0 : return 0;
550 : : }
551 : :
552 : 87 : sal_uLong PictReader::ReadAndDrawPolygon(PictDrawingMethod eMethod)
553 : : {
554 : : sal_uLong nDataSize;
555 : 87 : nDataSize=ReadPolygon(aLastPolygon);
556 : 87 : ReadAndDrawSamePolygon(eMethod);
557 : 87 : return nDataSize;
558 : : }
559 : :
560 : 87 : sal_uLong PictReader::ReadAndDrawSamePolygon(PictDrawingMethod eMethod)
561 : : {
562 [ - + ]: 87 : if (IsInvisible(eMethod)) return 0;
563 : 87 : DrawingMethod(eMethod);
564 : 87 : PictReaderShape::drawPolygon(pVirDev, eMethod==PDM_FRAME, aLastPolygon, nActPenSize);
565 : 87 : return 0;
566 : : }
567 : :
568 : :
569 : 0 : sal_uLong PictReader::ReadAndDrawArc(PictDrawingMethod eMethod)
570 : : {
571 : 0 : ReadRectangle(aLastArcRect);
572 : 0 : ReadAndDrawSameArc(eMethod);
573 : 0 : return 12;
574 : : }
575 : :
576 : 0 : sal_uLong PictReader::ReadAndDrawSameArc(PictDrawingMethod eMethod)
577 : : {
578 : : short nstartAngle, narcAngle;
579 : : double fAng1, fAng2;
580 : :
581 [ # # ][ # # ]: 0 : *pPict >> nstartAngle >> narcAngle;
582 [ # # ]: 0 : if (IsInvisible(eMethod)) return 4;
583 [ # # ]: 0 : DrawingMethod(eMethod);
584 : :
585 [ # # ]: 0 : if (narcAngle<0) {
586 : 0 : nstartAngle = nstartAngle + narcAngle;
587 : 0 : narcAngle=-narcAngle;
588 : : }
589 : 0 : fAng1=((double)nstartAngle)/180.0*3.14159265359;
590 : 0 : fAng2=((double)(nstartAngle+narcAngle))/180.0*3.14159265359;
591 [ # # ]: 0 : PictReaderShape::drawArc(pVirDev, eMethod==PDM_FRAME, aLastArcRect,fAng1,fAng2, nActPenSize);
592 : 0 : return 4;
593 : : }
594 : :
595 : 0 : sal_uLong PictReader::ReadAndDrawRgn(PictDrawingMethod eMethod)
596 : : {
597 : : sal_uInt16 nSize;
598 : :
599 [ # # ]: 0 : *pPict >> nSize;
600 : : // read the DATA
601 : : //
602 : : // a region data is a mask and is probably coded as
603 : : // - the first 8 bytes: bdbox ( which can be read by ReadRectangle )
604 : : // - then a list of line modifiers: y_i, a_0, b_0, a_1, b_1, ..., a_{n_i}, b_{n_i}, 0x7fff
605 : : // - 0x7fff
606 : : // where y_i is the increasing sequences of line coordinates
607 : : // and on each line: a0 < b0 < a1 < b1 < ... < a_{n_i} < b_{n_i}
608 : :
609 : : // it can be probably decoded as :
610 : : // M=an empty mask: ie. (0, 0, ... ) with (left_box-right_box+1) zeroes
611 : : // then for each line (y_i):
612 : : // - takes M and inverts all values in [a_0,b_0-1], in [a_1,b_1-1] ...
613 : : // - sets M = new y_i line mask
614 [ # # ]: 0 : ReadAndDrawSameRgn(eMethod);
615 : 0 : return (sal_uLong)nSize;
616 : : }
617 : :
618 : 0 : sal_uLong PictReader::ReadAndDrawSameRgn(PictDrawingMethod eMethod)
619 : : {
620 [ # # ]: 0 : if (IsInvisible(eMethod)) return 0;
621 : 0 : DrawingMethod(eMethod);
622 : : // DISPLAY: ...???...
623 : 0 : return 0;
624 : : }
625 : :
626 : 252 : void PictReader::DrawingMethod(PictDrawingMethod eMethod)
627 : : {
628 [ + + ]: 342 : if( eActMethod==eMethod ) return;
629 [ + + - - : 90 : switch (eMethod) {
- - - ]
630 : : case PDM_FRAME:
631 [ + - ]: 39 : if (eActPenPattern.isDefault())
632 : 39 : SetLineColor( aActForeColor );
633 : : else
634 [ # # ]: 0 : SetLineColor(eActPenPattern.getColor(aActBackColor, aActForeColor));
635 [ + - ]: 39 : SetFillColor( Color(COL_TRANSPARENT) );
636 : 39 : pVirDev->SetRasterOp(eActROP);
637 : 39 : break;
638 : : case PDM_PAINT:
639 [ + - ]: 51 : SetLineColor( Color(COL_TRANSPARENT) );
640 [ + - ]: 51 : if (eActPenPattern.isDefault())
641 : 51 : SetFillColor( aActForeColor );
642 : : else
643 [ # # ]: 0 : SetFillColor(eActPenPattern.getColor(aActBackColor, aActForeColor));
644 : 51 : pVirDev->SetRasterOp(eActROP);
645 : 51 : break;
646 : : case PDM_ERASE:
647 [ # # ]: 0 : SetLineColor( Color(COL_TRANSPARENT) );
648 [ # # ]: 0 : if (eActBackPattern.isDefault())
649 : 0 : SetFillColor( aActBackColor );// Osnola: previously aActForeColor
650 : : else // checkMe
651 [ # # ]: 0 : SetFillColor(eActBackPattern.getColor(COL_BLACK, aActBackColor));
652 : 0 : pVirDev->SetRasterOp(ROP_OVERPAINT);
653 : 0 : break;
654 : : case PDM_INVERT: // checkme
655 [ # # ]: 0 : SetLineColor( Color(COL_TRANSPARENT));
656 [ # # ]: 0 : SetFillColor( Color( COL_BLACK ) );
657 : 0 : pVirDev->SetRasterOp(ROP_INVERT);
658 : 0 : break;
659 : : case PDM_FILL:
660 [ # # ]: 0 : SetLineColor( Color(COL_TRANSPARENT) );
661 [ # # ]: 0 : if (eActFillPattern.isDefault())
662 : 0 : SetFillColor( aActForeColor );
663 : : else
664 [ # # ]: 0 : SetFillColor(eActFillPattern.getColor(aActBackColor, aActForeColor));
665 : 0 : pVirDev->SetRasterOp(ROP_OVERPAINT);
666 : 0 : break;
667 : : case PDM_TEXT:
668 : 0 : aActFont.SetColor(aActForeColor);
669 : 0 : aActFont.SetFillColor(aActBackColor);
670 : 0 : aActFont.SetTransparent(sal_True);
671 : 0 : pVirDev->SetFont(aActFont);
672 : 0 : pVirDev->SetRasterOp(ROP_OVERPAINT);
673 : 0 : break;
674 : : default:
675 : 0 : break; // -Wall undefined not handled...
676 : : }
677 : 90 : eActMethod=eMethod;
678 : : }
679 : :
680 : 0 : sal_uLong PictReader::ReadAndDrawText()
681 : : {
682 : : char nByteLen;
683 : : sal_uInt32 nLen, nDataLen;
684 : : sal_Char sText[256];
685 : :
686 [ # # ]: 0 : *pPict >> nByteLen; nLen=((sal_uLong)nByteLen)&0x000000ff;
687 : 0 : nDataLen = nLen + 1;
688 [ # # ]: 0 : pPict->Read( &sText, nLen );
689 : :
690 [ # # ]: 0 : if (IsInvisible(PDM_TEXT)) return nDataLen;
691 [ # # ]: 0 : DrawingMethod(PDM_TEXT);
692 : :
693 : : // Stoerende Steuerzeuichen wegnehmen:
694 [ # # ][ # # ]: 0 : while ( nLen > 0 && ( (unsigned char)sText[ nLen - 1 ] ) < 32 )
[ # # ]
695 : 0 : nLen--;
696 : 0 : sText[ nLen ] = 0;
697 [ # # ][ # # ]: 0 : String aString( (const sal_Char*)&sText, aActFont.GetCharSet());
698 [ # # ]: 0 : pVirDev->DrawText( Point( aTextPosition.X(), aTextPosition.Y() ), aString );
699 [ # # ]: 0 : return nDataLen;
700 : : }
701 : :
702 : 6 : sal_uLong PictReader::ReadPixMapEtc( Bitmap &rBitmap, sal_Bool bBaseAddr, sal_Bool bColorTable, Rectangle* pSrcRect,
703 : : Rectangle* pDestRect, sal_Bool bMode, sal_Bool bMaskRgn )
704 : : {
705 [ + - ]: 6 : Bitmap aBitmap;
706 : 6 : BitmapWriteAccess* pAcc = NULL;
707 : 6 : BitmapReadAccess* pReadAcc = NULL;
708 : : sal_uInt16 ny, nx, nColTabSize;
709 : : sal_uInt16 nRowBytes, nBndX, nBndY, nWidth, nHeight, nVersion, nPackType, nPixelType,
710 : : nPixelSize, nCmpCount, nCmpSize;
711 : : sal_uInt32 nPackSize, nPlaneBytes, nHRes, nVRes;
712 : : sal_uInt8 nDat, nRed, nGreen, nBlue, nDummy;
713 : 6 : sal_uLong i, nDataSize = 0;
714 : :
715 : : // In nDataSize wird mitgerechnet, wie gross die gesammten Daten sind.
716 : 6 : nDataSize = 0;
717 : :
718 : : // ggf. BaseAddr ueberlesen
719 [ + + ]: 6 : if ( bBaseAddr )
720 : : {
721 [ + - ]: 3 : pPict->SeekRel( 4 );
722 : 3 : nDataSize += 4;
723 : : }
724 : :
725 : : // PixMap oder Bitmap-Struktur einlesen;
726 [ + - ][ + - ]: 6 : *pPict >> nRowBytes >> nBndY >> nBndX >> nHeight >> nWidth;
[ + - ][ + - ]
[ + - ]
727 : 6 : nHeight = nHeight - nBndY;
728 : 6 : nWidth = nWidth - nBndX;
729 : :
730 [ + - ]: 6 : if ( ( nRowBytes & 0x8000 ) != 0 )
731 : : { // it is a PixMap
732 : 6 : nRowBytes &= 0x3fff;
733 [ + - ][ + - ]: 6 : *pPict >> nVersion >> nPackType >> nPackSize >> nHRes >> nVRes >> nPixelType >>
[ + - ][ + - ]
[ + - ][ + - ]
734 [ + - ][ + - ]: 6 : nPixelSize >> nCmpCount >> nCmpSize >> nPlaneBytes;
[ + - ][ + - ]
735 : :
736 [ + - ]: 6 : pPict->SeekRel( 8 );
737 : 6 : nDataSize += 46;
738 : :
739 : 6 : sal_uInt16 nDstBitCount = nPixelSize;
740 [ + + ]: 6 : if ( nDstBitCount > 8 )
741 : 3 : nDstBitCount = 24;
742 [ - + ]: 3 : else if ( nDstBitCount == 2 )
743 : 0 : nDstBitCount = 4;
744 [ + - ][ + - ]: 6 : aBitmap = Bitmap( Size( nWidth, nHeight ), nDstBitCount );
[ + - ]
745 : :
746 [ + - ][ - + ]: 6 : if ( ( pAcc = aBitmap.AcquireWriteAccess() ) == NULL )
747 [ # # ][ # # ]: 0 : BITMAPERROR;
[ # # ][ # # ]
748 : :
749 [ + + ]: 6 : if ( bColorTable )
750 : : {
751 [ + - ]: 3 : pPict->SeekRel( 6 );
752 [ + - ]: 3 : *pPict >> nColTabSize;
753 : :
754 [ - + ]: 3 : if ( ++nColTabSize > 256 )
755 [ # # ][ # # ]: 0 : BITMAPERROR;
[ # # ][ # # ]
756 : :
757 [ + - ]: 3 : pAcc->SetPaletteEntryCount( nColTabSize );
758 : :
759 [ + + ]: 771 : for ( i = 0; i < nColTabSize; i++ )
760 : : {
761 [ + - ]: 768 : pPict->SeekRel(2);
762 [ + - ][ + - ]: 768 : *pPict >> nRed >> nDummy >> nGreen >> nDummy >> nBlue >> nDummy;
[ + - ][ + - ]
[ + - ][ + - ]
763 : 768 : pAcc->SetPaletteColor( (sal_uInt16) i, BitmapColor( nRed, nGreen, nBlue ) );
764 : : }
765 : 3 : nDataSize += 8 + nColTabSize * 8;
766 : : }
767 : : }
768 : : else
769 : : {
770 : 0 : nRowBytes &= 0x3fff;
771 : 0 : nVersion = 0;
772 : 0 : nPackType = 0;
773 : 0 : nPackSize = nHRes = nVRes = nPlaneBytes = 0;
774 : 0 : nPixelType = 0;
775 : 0 : nPixelSize = nCmpCount = nCmpSize = 1;
776 : 0 : nDataSize += 10;
777 [ # # ][ # # ]: 0 : aBitmap = Bitmap( Size( nWidth, nHeight ), 1 );
[ # # ]
778 [ # # ][ # # ]: 0 : if ( ( pAcc = aBitmap.AcquireWriteAccess() ) == NULL )
779 [ # # ][ # # ]: 0 : BITMAPERROR;
[ # # ][ # # ]
780 [ # # ]: 0 : pAcc->SetPaletteEntryCount( 2 );
781 : 0 : pAcc->SetPaletteColor( 0, BitmapColor( 0xff, 0xff, 0xff ) );
782 : 0 : pAcc->SetPaletteColor( 1, BitmapColor( 0, 0, 0 ) );
783 : : }
784 : :
785 : : // ggf. Quell-Rechteck einlesen:
786 [ + - ]: 6 : if ( pSrcRect != 0)
787 : : {
788 : : sal_uInt16 nTop, nLeft, nBottom, nRight;
789 [ + - ][ + - ]: 6 : *pPict >> nTop >> nLeft >> nBottom >> nRight;
[ + - ][ + - ]
790 [ + - ]: 6 : *pSrcRect = Rectangle( (sal_uLong)nLeft, (sal_uLong)nTop, (sal_uLong)nRight, (sal_uLong)nBottom );
791 : 6 : nDataSize += 8;
792 : : }
793 : :
794 : : // ggf. Ziel-Rechteck einlesen:
795 [ + - ]: 6 : if ( pDestRect != 0 )
796 : : {
797 : 6 : Point aTL, aBR;
798 [ + - ]: 6 : aTL = ReadPoint();
799 [ + - ]: 6 : aBR = ReadPoint();
800 [ + - ]: 6 : *pDestRect = Rectangle( aTL, aBR );
801 : 6 : nDataSize += 8;
802 : : }
803 : :
804 : : // ggf. Modus einlesen (bzw. ueberspringen):
805 [ + - ]: 6 : if ( bMode )
806 : : {
807 [ + - ]: 6 : pPict->SeekRel(2);
808 : 6 : nDataSize += 2;
809 : : }
810 : :
811 : : // ggf. Region einlesen (bzw. ueberspringen):
812 [ - + ]: 6 : if ( bMaskRgn )
813 : : {
814 : : sal_uInt16 nSize;
815 [ # # ]: 0 : *pPict >> nSize;
816 [ # # ]: 0 : pPict->SeekRel( nSize - 2 );
817 : 0 : nDataSize += (sal_uLong)nSize;
818 : : }
819 : :
820 : : // aSMem << (nHRes/1665L) << (nVRes/1665L) << ((sal_uLong)0) << ((sal_uLong)0);
821 : :
822 : : // Lese und Schreibe Bitmap-Bits:
823 [ + - ][ + - ]: 6 : if ( nPixelSize == 1 || nPixelSize == 2 || nPixelSize == 4 || nPixelSize == 8 )
[ + - ][ + + ]
824 : : {
825 : : sal_uInt8 nByteCountAsByte, nFlagCounterByte;
826 : : sal_uInt16 nByteCount, nCount, nSrcBPL, nDestBPL;
827 : :
828 [ - + ]: 3 : if ( nPixelSize == 1 ) nSrcBPL = ( nWidth + 7 ) >> 3;
829 [ - + ]: 3 : else if ( nPixelSize == 2 ) nSrcBPL = ( nWidth + 3 ) >> 2;
830 [ - + ]: 3 : else if ( nPixelSize == 4 ) nSrcBPL = ( nWidth + 1 ) >> 1;
831 : 3 : else nSrcBPL = nWidth;
832 : 3 : nDestBPL = ( nSrcBPL + 3 ) & 0xfffc;
833 [ + - ][ - + ]: 3 : if ( nRowBytes < nSrcBPL || nRowBytes > nDestBPL )
834 [ # # ][ # # ]: 0 : BITMAPERROR;
[ # # ][ # # ]
835 : :
836 [ + + ]: 2958 : for ( ny = 0; ny < nHeight; ny++ )
837 : : {
838 : 2955 : nx = 0;
839 [ + - ][ - + ]: 2955 : if ( nRowBytes < 8 || nPackType == 1 )
840 : : {
841 [ # # ]: 0 : for ( i = 0; i < nRowBytes; i++ )
842 : : {
843 [ # # ]: 0 : *pPict >> nDat;
844 [ # # ]: 0 : if ( nx < nWidth )
845 [ # # # # : 0 : SETBYTE;
# ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
846 : : }
847 : 0 : nDataSize += nRowBytes;
848 : : }
849 : : else
850 : : {
851 [ + - ]: 2955 : if ( nRowBytes > 250 )
852 : : {
853 [ + - ]: 2955 : *pPict >> nByteCount;
854 : 2955 : nDataSize += 2 + (sal_uLong)nByteCount;
855 : : }
856 : : else
857 : : {
858 [ # # ]: 0 : *pPict >> nByteCountAsByte;
859 : 0 : nByteCount = ( (sal_uInt16)nByteCountAsByte ) & 0x00ff;
860 : 0 : nDataSize += 1 + (sal_uLong)nByteCount;
861 : : }
862 : :
863 [ + + ]: 168525 : while ( nByteCount )
864 : : {
865 [ + - ]: 165570 : *pPict >> nFlagCounterByte;
866 [ + + ]: 165570 : if ( ( nFlagCounterByte & 0x80 ) == 0 )
867 : : {
868 : 121911 : nCount = ( (sal_uInt16)nFlagCounterByte ) + 1;
869 [ + + ]: 358074 : for ( i = 0; i < nCount; i++ )
870 : : {
871 [ + - ]: 236163 : *pPict >> nDat;
872 [ + + ]: 236163 : if ( nx < nWidth )
873 [ - - - + : 21951 : SETBYTE;
- ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ + - ]
874 : : }
875 : 121911 : nByteCount -= 1 + nCount;
876 : : }
877 : : else
878 : : {
879 : 43659 : nCount = ( 1 - ( ( (sal_uInt16)nFlagCounterByte ) | 0xff00 ) );
880 [ + - ]: 43659 : *pPict >> nDat;
881 [ + + ]: 2040621 : for ( i = 0; i < nCount; i++ )
882 : : {
883 [ + + ]: 1996962 : if ( nx < nWidth )
884 [ - - - + : 546669 : SETBYTE;
- ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ + - ]
885 : : }
886 : 43659 : nByteCount -= 2;
887 : : }
888 : : }
889 : : }
890 : 3 : }
891 : : }
892 [ - + ]: 3 : else if ( nPixelSize == 16 )
893 : : {
894 : : sal_uInt8 nByteCountAsByte, nFlagCounterByte;
895 : : sal_uInt16 nByteCount, nCount, nD;
896 : : sal_uLong nSrcBitsPos;
897 : :
898 [ # # ]: 0 : if ( nRowBytes < 2 * nWidth )
899 [ # # ][ # # ]: 0 : BITMAPERROR;
[ # # ][ # # ]
900 : :
901 [ # # ]: 0 : for ( ny = 0; ny < nHeight; ny++ )
902 : : {
903 : 0 : nx = 0;
904 [ # # ][ # # ]: 0 : if ( nRowBytes < 8 || nPackType == 1 )
905 : : {
906 [ # # ]: 0 : for ( i = 0; i < nWidth; i++ )
907 : : {
908 [ # # ]: 0 : *pPict >> nD;
909 : 0 : nRed = (sal_uInt8)( nD >> 7 );
910 : 0 : nGreen = (sal_uInt8)( nD >> 2 );
911 : 0 : nBlue = (sal_uInt8)( nD << 3 );
912 [ # # ]: 0 : pAcc->SetPixel( ny, nx++, BitmapColor( nRed, nGreen, nBlue ) );
913 : : }
914 : 0 : nDataSize += ( (sal_uLong)nWidth ) * 2;
915 : : }
916 : : else
917 : : {
918 : 0 : nSrcBitsPos = pPict->Tell();
919 [ # # ]: 0 : if ( nRowBytes > 250 )
920 : : {
921 [ # # ]: 0 : *pPict >> nByteCount;
922 : 0 : nByteCount += 2;
923 : : }
924 : : else
925 : : {
926 [ # # ]: 0 : *pPict >> nByteCountAsByte;
927 : 0 : nByteCount = ( (sal_uInt16)nByteCountAsByte ) & 0x00ff;
928 : 0 : nByteCount++;
929 : : }
930 [ # # ]: 0 : while ( nx != nWidth )
931 : : {
932 [ # # ]: 0 : *pPict >> nFlagCounterByte;
933 [ # # ]: 0 : if ( (nFlagCounterByte & 0x80) == 0)
934 : : {
935 : 0 : nCount=((sal_uInt16)nFlagCounterByte)+1;
936 [ # # ]: 0 : if ( nCount + nx > nWidth) // SJ: the RLE decoding seems not to be correct here,
937 : 0 : nCount = nWidth - nx; // I don't want to change this until I have a bugdoc for
938 [ # # ]: 0 : for (i=0; i<nCount; i++) // this case. Have a look at 32bit, there I changed the
939 : : { // encoding, so that it is used a straight forward array
940 [ # # ]: 0 : *pPict >> nD;
941 : 0 : nRed = (sal_uInt8)( nD >> 7 );
942 : 0 : nGreen = (sal_uInt8)( nD >> 2 );
943 : 0 : nBlue = (sal_uInt8)( nD << 3 );
944 [ # # ]: 0 : pAcc->SetPixel( ny, nx++, BitmapColor( nRed, nGreen, nBlue ) );
945 : : }
946 : : }
947 : : else
948 : : {
949 : 0 : nCount=(1-(((sal_uInt16)nFlagCounterByte)|0xff00));
950 [ # # ]: 0 : if ( nCount + nx > nWidth )
951 : 0 : nCount = nWidth - nx;
952 [ # # ]: 0 : *pPict >> nD;
953 : 0 : nRed = (sal_uInt8)( nD >> 7 );
954 : 0 : nGreen = (sal_uInt8)( nD >> 2 );
955 : 0 : nBlue = (sal_uInt8)( nD << 3 );
956 [ # # ]: 0 : for (i=0; i<nCount; i++)
957 : : {
958 [ # # ]: 0 : pAcc->SetPixel( ny, nx++, BitmapColor( nRed, nGreen, nBlue ) );
959 : : }
960 : : }
961 : : }
962 : 0 : nDataSize+=(sal_uLong)nByteCount;
963 [ # # ]: 0 : pPict->Seek(nSrcBitsPos+(sal_uLong)nByteCount);
964 : : }
965 : : }
966 : : }
967 [ + - ]: 3 : else if (nPixelSize==32)
968 : : {
969 : : sal_uInt8 nByteCountAsByte, nFlagCounterByte;
970 : : sal_uInt16 nByteCount, nCount;
971 : : sal_uLong nSrcBitsPos;
972 : 3 : BitmapColor aBitmapColor;
973 [ - + ][ + - ]: 3 : if ( ( pReadAcc = aBitmap.AcquireReadAccess() ) == NULL )
974 [ # # ][ # # ]: 0 : BITMAPERROR;
[ # # ][ # # ]
975 [ - + ]: 3 : if ( nRowBytes != 4*nWidth )
976 [ # # ][ # # ]: 0 : BITMAPERROR;
[ # # ][ # # ]
977 : :
978 [ + - ][ - + ]: 3 : if ( nRowBytes < 8 || nPackType == 1 )
979 : : {
980 [ # # ]: 0 : for ( ny = 0; ny < nHeight; ny++ )
981 : : {
982 [ # # ][ # # ]: 0 : if ( nRowBytes < 8 || nPackType == 1 )
983 : : {
984 [ # # ]: 0 : for ( nx = 0; nx < nWidth; nx++ )
985 : : {
986 [ # # ][ # # ]: 0 : *pPict >> nDummy >> nRed >> nGreen >> nBlue;
[ # # ][ # # ]
987 [ # # ]: 0 : pAcc->SetPixel( ny, nx, BitmapColor( nRed, nGreen, nBlue) );
988 : : }
989 : 0 : nDataSize += ( (sal_uLong)nWidth ) * 4;
990 : : }
991 : : }
992 : : }
993 [ - + ]: 3 : else if ( nPackType == 2 )
994 : : {
995 [ # # ]: 0 : for ( ny = 0; ny < nHeight; ny++ )
996 : : {
997 [ # # ]: 0 : for ( nx = 0; nx < nWidth; nx++ )
998 : : {
999 [ # # ][ # # ]: 0 : *pPict >> nRed >> nGreen >> nBlue;
[ # # ]
1000 [ # # ]: 0 : pAcc->SetPixel( ny, nx, BitmapColor( nRed, nGreen, nBlue ) );
1001 : : }
1002 : 0 : nDataSize += ( (sal_uLong)nWidth ) * 3;
1003 : : }
1004 : : }
1005 : : else
1006 : : {
1007 [ + - ][ + - ]: 3 : if ( ( nCmpCount == 3 ) || ( nCmpCount == 4 ) )
1008 : : {
1009 [ + - ]: 3 : sal_uInt8* pScanline = new sal_uInt8[ nWidth * nCmpCount ];
1010 [ + + ]: 810 : for ( ny = 0; ny < nHeight; ny++ )
1011 : : {
1012 : 807 : nSrcBitsPos = pPict->Tell();
1013 [ + - ]: 807 : if ( nRowBytes > 250 )
1014 : : {
1015 [ + - ]: 807 : *pPict >> nByteCount;
1016 : 807 : nByteCount += 2;
1017 : : }
1018 : : else
1019 : : {
1020 [ # # ]: 0 : *pPict >> nByteCountAsByte;
1021 : 0 : nByteCount = (sal_uInt8)nByteCountAsByte;
1022 : 0 : nByteCount++;
1023 : : }
1024 : 807 : i = 0;
1025 [ + + ]: 22263 : while( i < (sal_uInt32)( nWidth * nCmpCount ) )
1026 : : {
1027 [ + - ]: 21456 : *pPict >> nFlagCounterByte;
1028 [ + + ]: 21456 : if ( ( nFlagCounterByte & 0x80 ) == 0)
1029 : : {
1030 : 5085 : nCount = ( (sal_uInt16)nFlagCounterByte ) + 1;
1031 [ + + ]: 5085 : if ( ( i + nCount ) > (sal_uInt32)( nWidth * nCmpCount ) )
1032 : 3 : nCount = (sal_uInt16)( nWidth * nCmpCount - i );
1033 [ + + ]: 28512 : while( nCount-- )
1034 : : {
1035 [ + - ]: 23427 : *pPict >> nDat;
1036 : 23427 : pScanline[ i++ ] = nDat;
1037 : : }
1038 : : }
1039 : : else
1040 : : {
1041 : 16371 : nCount = ( 1 - ( ( (sal_uInt16)nFlagCounterByte ) | 0xff00 ) );
1042 [ + + ]: 16371 : if ( ( i + nCount ) > (sal_uInt32)( nWidth * nCmpCount ) )
1043 : 513 : nCount = (sal_uInt16)( nWidth * nCmpCount - i );
1044 [ + - ]: 16371 : *pPict >> nDat;
1045 [ + + ]: 1148568 : while( nCount-- )
1046 : 1132197 : pScanline[ i++ ] = nDat;
1047 : : }
1048 : : }
1049 : 807 : sal_uInt8* pTmp = pScanline;
1050 [ + - ]: 807 : if ( nCmpCount == 4 )
1051 : 807 : pTmp += nWidth;
1052 [ + + ]: 289713 : for ( nx = 0; nx < nWidth; pTmp++ )
1053 [ + - ]: 288906 : pAcc->SetPixel( ny, nx++, BitmapColor( *pTmp, pTmp[ nWidth ], pTmp[ 2 * nWidth ] ) );
1054 : 807 : nDataSize += (sal_uLong)nByteCount;
1055 [ + - ]: 807 : pPict->Seek( nSrcBitsPos + (sal_uLong)nByteCount );
1056 : : }
1057 [ + - ]: 3 : delete[] pScanline;
1058 : : }
1059 [ + - ]: 3 : }
1060 : : }
1061 : : else
1062 [ # # ][ # # ]: 0 : BITMAPERROR;
[ # # ][ # # ]
1063 [ + + ]: 6 : if ( pReadAcc )
1064 [ + - ]: 3 : aBitmap.ReleaseAccess( pReadAcc );
1065 [ + - ]: 6 : aBitmap.ReleaseAccess( pAcc );
1066 [ + - ]: 6 : rBitmap = aBitmap;
1067 [ + - ]: 6 : return nDataSize;
1068 : : }
1069 : :
1070 : 9 : void PictReader::ReadHeader()
1071 : : {
1072 : : short y1,x1,y2,x2;
1073 : :
1074 : : sal_Char sBuf[ 2 ];
1075 : : // previous code considers pPict->Tell() as the normal starting position,
1076 : : // can we have nStartPos != 0 ?
1077 : 9 : sal_uLong nStartPos = pPict->Tell();
1078 : : // Standard:
1079 : : // a picture file begins by 512 bytes (reserved to the application) followed by the picture data
1080 : : // while clipboard, pictures stored in a document often contain only the picture data.
1081 : :
1082 : : // Special cases:
1083 : : // - some Pict v.1 use 0x00 0x11 0x01 ( instead of 0x11 0x01) to store the version op
1084 : : // (we consider here this as another standard for Pict. v.1 )
1085 : : // - some files seem to contain extra garbage data at the beginning
1086 : : // - some picture data seem to contain extra NOP opcode(0x00) between the bounding box and the version opcode
1087 : :
1088 : : // This code looks hard to find a picture header, ie. it looks at positions
1089 : : // - nStartPos+0, nStartPos+512 with potential extra NOP codes between bdbox and version (at most 9 extra NOP)
1090 : : // - 512..1024 with more strict bdbox checking and no extra NOP codes
1091 : :
1092 : : // Notes:
1093 : : // - if the header can begin at nStartPos+0 and at nStartPos+512, we try to choose the more
1094 : : // <<probable>> ( using the variable confidence)
1095 : : // - svtools/source/filter.vcl/filter/{filter.cxx,filter2.cxx} only check for standard Pict,
1096 : : // this may cause future problems
1097 : : int st;
1098 : : sal_uInt32 nOffset;
1099 : 9 : int confidence[2] = { 0, 0};
1100 [ + - ]: 21 : for ( st = 0; st < 3 + 513; st++ )
1101 : : {
1102 : 21 : int actualConfid = 20; // the actual confidence
1103 [ + - ]: 21 : pPict->ResetError();
1104 [ + + ]: 21 : if (st < 2) nOffset = nStartPos+st*512;
1105 [ + - ]: 3 : else if (st == 2) {
1106 : : // choose nStartPos+0 or nStartPos+512 even if there are a little dubious
1107 : 3 : int actPos = -1, actConf=0;
1108 [ + - ]: 3 : if (confidence[0] > 0) { actPos = 0; actConf = confidence[0]; }
1109 [ - + ][ # # ]: 3 : if (confidence[1] > 0 && confidence[1] >= actConf) actPos = 1;
1110 [ - + ]: 3 : if (actPos < 0) continue;
1111 : 3 : nOffset = nStartPos+actPos*512;
1112 : : }
1113 : : else {
1114 : 0 : nOffset = 509+st; // illogical : more logical will be nStartPos+509+st or to consider that nStartPos=0
1115 : : // a small test to check if versionOp code exists after the bdbox ( with no extra NOP codes)
1116 [ # # ]: 0 : pPict->Seek(nOffset+10);
1117 [ # # ]: 0 : pPict->Read( sBuf, 2 );
1118 [ # # ][ # # ]: 0 : if (pPict->IsEof() || pPict->GetError()) break;
[ # # ]
1119 [ # # ][ # # ]: 0 : if (sBuf[0] == 0x11 || (sBuf[0] == 0x00 && sBuf[1] == 0x11)) ; // maybe ok
[ # # ]
1120 : 0 : else continue;
1121 : : }
1122 [ + - ]: 21 : pPict->Seek(nOffset);
1123 : :
1124 : : // 2 bytes to store size ( version 1 ) ignored
1125 [ + - ]: 21 : pPict->SeekRel( 2 );
1126 [ + - ][ + - ]: 21 : *pPict >> y1 >> x1 >> y2 >> x2; // Rahmen-Rechteck des Bildes
[ + - ][ + - ]
1127 [ + - ][ - + ]: 21 : if (x1 > x2 || y1 > y2) continue; // bad bdbox
1128 [ + - ][ + + ]: 21 : if (x1 < -2048 || x2 > 2048 || y1 < -2048 || y2 > 2048 || // origin|dest is very small|large
[ + - ][ + - ]
[ + + ][ + - ]
1129 : : (x1 == x2 && y1 == y2) ) // 1 pixel pict is dubious
1130 : 15 : actualConfid-=3;
1131 [ + - ][ - + ]: 6 : else if (x2 < x1+8 || y2 < y1+8) // a little dubious
1132 : 0 : actualConfid-=1;
1133 [ - + ][ # # ]: 21 : if (st >= 3 && actualConfid != 20) continue;
1134 [ + - ]: 21 : aBoundingRect=Rectangle( x1,y1, x2, y2 );
1135 : :
1136 [ + - ][ - + ]: 21 : if (pPict->IsEof() || pPict->GetError()) continue;
[ - + ]
1137 : : // read version
1138 [ + - ]: 21 : pPict->Read( sBuf, 2 );
1139 : : // version 1 file
1140 [ - + ][ # # ]: 21 : if ( sBuf[ 0 ] == 0x11 && sBuf[ 1 ] == 0x01 ) {
1141 : : // pict v1 must be rare and we do only few tests
1142 [ # # ]: 0 : if (st < 2) { confidence[st] = --actualConfid; continue; }
1143 : 0 : IsVersion2 = sal_False; return;
1144 : : }
1145 [ + + ]: 21 : if (sBuf[0] != 0x00) continue; // unrecovable error
1146 : 18 : int numZero = 0;
1147 [ + + ][ + + ]: 72 : do
[ + + ]
1148 : : {
1149 : 72 : numZero++;
1150 [ + - ]: 72 : pPict->SeekRel(-1);
1151 [ + - ]: 72 : pPict->Read( sBuf, 2 );
1152 : : }
1153 : 72 : while ( sBuf[0] == 0x00 && numZero < 10);
1154 : 18 : actualConfid -= (numZero-1); // extra nop are dubious
1155 [ + - ][ - + ]: 18 : if (pPict->IsEof() || pPict->GetError()) continue;
[ - + ]
1156 [ + + ]: 18 : if (sBuf[0] != 0x11) continue; // not a version opcode
1157 : : // abnormal version 1 file
1158 [ - + ]: 12 : if (sBuf[1] == 0x01 ) {
1159 : : // pict v1 must be rare and we do only few tests
1160 [ # # ]: 0 : if (st < 2) { confidence[st] = --actualConfid; continue; }
1161 : 0 : IsVersion2 = sal_False; return;
1162 : : }
1163 [ - + ]: 12 : if (sBuf[1] != 0x02 ) continue; // not a version 2 file
1164 : :
1165 : 12 : IsVersion2=sal_True;
1166 : : short nExtVer, nReserved;
1167 : : // 3 Bytes ignored : end of version arg 0x02FF (ie: 0xFF), HeaderOp : 0x0C00
1168 [ + - ]: 12 : pPict->SeekRel( 3 );
1169 [ + - ][ + - ]: 12 : *pPict >> nExtVer >> nReserved;
1170 [ + - ][ - + ]: 12 : if (pPict->IsEof() || pPict->GetError()) continue;
[ - + ]
1171 : :
1172 [ + - ]: 12 : if ( nExtVer == -2 ) // extended version 2 picture
1173 : : {
1174 : : sal_Int32 nHResFixed, nVResFixed;
1175 [ + - ][ + - ]: 12 : *pPict >> nHResFixed >> nVResFixed;
1176 [ + - ][ + - ]: 12 : *pPict >> y1 >> x1 >> y2 >> x2; // reading the optimal bounding rect
[ + - ][ + - ]
1177 [ + - ][ - + ]: 12 : if (x1 > x2 || y1 > y2) continue; // bad bdbox
1178 [ + + ][ + + ]: 12 : if (st < 2 && actualConfid != 20) { confidence[st] = actualConfid; continue; }
1179 : :
1180 : 9 : double fHRes = nHResFixed;
1181 : 9 : fHRes /= 65536;
1182 : 9 : double fVRes = nVResFixed;
1183 : 9 : fVRes /= 65536;
1184 [ + - ][ + - ]: 9 : aHRes /= fHRes;
1185 [ + - ][ + - ]: 9 : aVRes /= fVRes;
1186 [ + - ]: 9 : aBoundingRect=Rectangle( x1,y1, x2, y2 );
1187 [ + - ]: 12 : pPict->SeekRel( 4 ); // 4 bytes reserved
1188 : : return;
1189 : : }
1190 [ # # ]: 0 : else if (nExtVer == -1 ) { // basic version 2 picture
1191 [ # # ][ # # ]: 0 : if (st < 2 && actualConfid != 20) { confidence[st] = actualConfid; continue; }
1192 [ # # ]: 0 : pPict->SeekRel( 16); // bdbox(4 fixed number)
1193 [ # # ]: 21 : pPict->SeekRel(4); // 4 bytes reserved
1194 : : return;
1195 : : }
1196 : : }
1197 [ # # ]: 9 : pPict->SetError(SVSTREAM_FILEFORMAT_ERROR);
1198 : : }
1199 : :
1200 : 1545 : sal_uLong PictReader::ReadData(sal_uInt16 nOpcode)
1201 : : {
1202 : : sal_uInt16 nUSHORT;
1203 : 1545 : Point aPoint;
1204 : 1545 : sal_uLong nDataSize=0;
1205 : 1545 : PictDrawingMethod shapeDMethod = PDM_UNDEFINED;
1206 [ + + + - : 1545 : switch (nOpcode & 7) {
- + ]
1207 : 144 : case 0: shapeDMethod = PDM_FRAME; break;
1208 : 1374 : case 1: shapeDMethod = PDM_PAINT; break;
1209 : 12 : case 2: shapeDMethod = PDM_ERASE; break;
1210 : 0 : case 3: shapeDMethod = PDM_INVERT; break;
1211 : 0 : case 4: shapeDMethod = PDM_FILL; break;
1212 : 15 : default: break;
1213 : : }
1214 : :
1215 [ - + - - : 1545 : switch(nOpcode) {
- - - + +
- - - - -
- - - - -
- - - - -
- - - - +
- + + + -
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
+ - - - -
- - - - -
- + - + -
- + + + ]
1216 : :
1217 : : case 0x0000: // NOP
1218 : 0 : nDataSize=0;
1219 : 0 : break;
1220 : :
1221 : : case 0x0001: { // Clip
1222 [ + - ]: 9 : Rectangle aRect;
1223 [ + - ]: 9 : *pPict >> nUSHORT;
1224 : 9 : nDataSize=nUSHORT;
1225 [ + - ]: 9 : ReadRectangle(aRect);
1226 : : // checkme: do we really want to extend the rectangle here ?
1227 : : // I do that because the clipping is often used to clean a region,
1228 : : // before drawing some text and also to draw this text.
1229 : : // So using a too small region can lead to clip the end of the text ;
1230 : : // but this can be discutable...
1231 : 9 : aRect.setWidth(aRect.getWidth()+1);
1232 : 9 : aRect.setHeight(aRect.getHeight()+1);
1233 [ + - ][ + - ]: 9 : pVirDev->SetClipRegion( Region( aRect ) );
[ + - ]
1234 : : break;
1235 : : }
1236 : : case 0x0002: // BkPat
1237 [ # # ]: 0 : nDataSize=eActBackPattern.read(*pPict);
1238 : 0 : eActMethod=PDM_UNDEFINED;
1239 : 0 : break;
1240 : :
1241 : : case 0x0003: // TxFont
1242 [ # # ]: 0 : *pPict >> nUSHORT;
1243 [ # # ][ # # ]: 0 : if (nUSHORT <= 1) aActFont.SetFamily(FAMILY_SWISS);
1244 [ # # ][ # # ]: 0 : else if (nUSHORT <= 12) aActFont.SetFamily(FAMILY_DECORATIVE);
1245 [ # # ][ # # ]: 0 : else if (nUSHORT <= 20) aActFont.SetFamily(FAMILY_ROMAN);
1246 [ # # ][ # # ]: 0 : else if (nUSHORT == 21) aActFont.SetFamily(FAMILY_SWISS);
1247 [ # # ][ # # ]: 0 : else if (nUSHORT == 22) aActFont.SetFamily(FAMILY_MODERN);
1248 [ # # ][ # # ]: 0 : else if (nUSHORT <= 1023) aActFont.SetFamily(FAMILY_SWISS);
1249 [ # # ]: 0 : else aActFont.SetFamily(FAMILY_ROMAN);
1250 [ # # ][ # # ]: 0 : aActFont.SetCharSet(GetTextEncoding(nUSHORT));
1251 : 0 : eActMethod=PDM_UNDEFINED;
1252 : 0 : nDataSize=2;
1253 : 0 : break;
1254 : :
1255 : : case 0x0004: { // TxFace
1256 : : char nFace;
1257 [ # # ]: 0 : *pPict >> nFace;
1258 [ # # ][ # # ]: 0 : if ( (nFace & 0x01)!=0 ) aActFont.SetWeight(WEIGHT_BOLD);
1259 [ # # ]: 0 : else aActFont.SetWeight(WEIGHT_NORMAL);
1260 [ # # ][ # # ]: 0 : if ( (nFace & 0x02)!=0 ) aActFont.SetItalic(ITALIC_NORMAL);
1261 [ # # ]: 0 : else aActFont.SetItalic(ITALIC_NONE);
1262 [ # # ][ # # ]: 0 : if ( (nFace & 0x04)!=0 ) aActFont.SetUnderline(UNDERLINE_SINGLE);
1263 [ # # ]: 0 : else aActFont.SetUnderline(UNDERLINE_NONE);
1264 [ # # ][ # # ]: 0 : if ( (nFace & 0x08)!=0 ) aActFont.SetOutline(sal_True);
1265 [ # # ]: 0 : else aActFont.SetOutline(sal_False);
1266 [ # # ][ # # ]: 0 : if ( (nFace & 0x10)!=0 ) aActFont.SetShadow(sal_True);
1267 [ # # ]: 0 : else aActFont.SetShadow(sal_False);
1268 : 0 : eActMethod=PDM_UNDEFINED;
1269 : 0 : nDataSize=1;
1270 : : break;
1271 : : }
1272 : : case 0x0005: // TxMode
1273 : 0 : nDataSize=2;
1274 : 0 : break;
1275 : :
1276 : : case 0x0006: // SpExtra
1277 : 0 : nDataSize=4;
1278 : 0 : break;
1279 : :
1280 : : case 0x0007: { // PnSize
1281 [ + - ]: 6 : nActPenSize=ReadSize();
1282 : 6 : eActMethod=PDM_UNDEFINED;
1283 : 6 : nDataSize=4;
1284 : 6 : break;
1285 : : }
1286 : : case 0x0008: // PnMode
1287 [ + - ]: 87 : *pPict >> nUSHORT;
1288 : : // internal code for postscript command (Quickdraw Reference Drawing B-30,B-34)
1289 [ - + ]: 87 : if (nUSHORT==23) eActROP = ROP_1;
1290 : : else {
1291 [ + + - - : 87 : switch (nUSHORT & 0x0007) {
- - - -
- ]
1292 : 42 : case 0: eActROP=ROP_OVERPAINT; break; // Copy
1293 : 45 : case 1: eActROP=ROP_OVERPAINT; break; // Or
1294 : 0 : case 2: eActROP=ROP_XOR; break; // Xor
1295 : 0 : case 3: eActROP=ROP_OVERPAINT; break; // Bic
1296 : 0 : case 4: eActROP=ROP_INVERT; break; // notCopy
1297 : 0 : case 5: eActROP=ROP_OVERPAINT; break; // notOr
1298 : 0 : case 6: eActROP=ROP_XOR; break; // notXor
1299 : 0 : case 7: eActROP=ROP_OVERPAINT; break; // notBic
1300 : : }
1301 : : }
1302 : 87 : eActMethod=PDM_UNDEFINED;
1303 : 87 : nDataSize=2;
1304 : 87 : break;
1305 : :
1306 : : case 0x0009: // PnPat
1307 [ # # ]: 0 : nDataSize=eActPenPattern.read(*pPict);
1308 : 0 : eActMethod=PDM_UNDEFINED;
1309 : 0 : break;
1310 : :
1311 : : case 0x000a: // FillPat
1312 [ # # ]: 0 : nDataSize=eActFillPattern.read(*pPict);
1313 : 0 : eActMethod=PDM_UNDEFINED;
1314 : 0 : break;
1315 : :
1316 : : case 0x000b: // OvSize
1317 [ # # ]: 0 : aActOvalSize=ReadSize();
1318 : 0 : nDataSize=4;
1319 : 0 : break;
1320 : :
1321 : : case 0x000c: // Origin
1322 : 0 : nDataSize=4;
1323 : 0 : break;
1324 : :
1325 : : case 0x000d: // TxSize
1326 : : {
1327 [ # # ]: 0 : *pPict >> nUSHORT;
1328 [ # # ]: 0 : aActFont.SetSize( Size( 0, (long)nUSHORT ) );
1329 : 0 : eActMethod=PDM_UNDEFINED;
1330 : 0 : nDataSize=2;
1331 : : }
1332 : 0 : break;
1333 : :
1334 : : case 0x000e: // FgColor
1335 [ # # ]: 0 : aActForeColor=ReadColor();
1336 : 0 : eActMethod=PDM_UNDEFINED;
1337 : 0 : nDataSize=4;
1338 : 0 : break;
1339 : :
1340 : : case 0x000f: // BkColor
1341 [ # # ]: 0 : aActBackColor=ReadColor();
1342 : 0 : nDataSize=4;
1343 : 0 : break;
1344 : :
1345 : : case 0x0010: // TxRatio
1346 : 0 : nDataSize=8;
1347 : 0 : break;
1348 : :
1349 : : case 0x0011: // VersionOp
1350 : 0 : nDataSize=1;
1351 : 0 : break;
1352 : :
1353 : : case 0x0012: // BkPixPat
1354 [ # # ]: 0 : nDataSize=ReadPixPattern(eActBackPattern);
1355 : 0 : eActMethod=PDM_UNDEFINED;
1356 : 0 : break;
1357 : :
1358 : : case 0x0013: // PnPixPat
1359 [ # # ]: 0 : nDataSize=ReadPixPattern(eActPenPattern);
1360 : 0 : eActMethod=PDM_UNDEFINED;
1361 : 0 : break;
1362 : :
1363 : : case 0x0014: // FillPixPat
1364 [ # # ]: 0 : nDataSize=ReadPixPattern(eActFillPattern);
1365 : 0 : eActMethod=PDM_UNDEFINED;
1366 : 0 : break;
1367 : :
1368 : : case 0x0015: // PnLocHFrac
1369 : 0 : nDataSize=2;
1370 : 0 : break;
1371 : :
1372 : : case 0x0016: // ChExtra
1373 : 0 : nDataSize=2;
1374 : 0 : break;
1375 : :
1376 : : case 0x0017: // Reserved (0 Bytes)
1377 : : case 0x0018: // Reserved (0 Bytes)
1378 : : case 0x0019: // Reserved (0 Bytes)
1379 : 0 : nDataSize=0;
1380 : 0 : break;
1381 : :
1382 : : case 0x001a: // RGBFgCol
1383 [ # # ]: 0 : aActForeColor=ReadRGBColor();
1384 : 0 : eActMethod=PDM_UNDEFINED;
1385 : 0 : nDataSize=6;
1386 : 0 : break;
1387 : :
1388 : : case 0x001b: // RGBBkCol
1389 [ # # ]: 0 : aActBackColor=ReadRGBColor();
1390 : 0 : eActMethod=PDM_UNDEFINED;
1391 : 0 : nDataSize=6;
1392 : 0 : break;
1393 : :
1394 : : case 0x001c: // HiliteMode
1395 : 0 : nDataSize=0;
1396 : 0 : break;
1397 : :
1398 : : case 0x001d: // HiliteColor
1399 : 0 : nDataSize=6;
1400 : 0 : break;
1401 : :
1402 : : case 0x001e: // DefHilite
1403 : 6 : nDataSize=0;
1404 : 6 : break;
1405 : :
1406 : : case 0x001f: // OpColor
1407 : 0 : nDataSize=6;
1408 : 0 : break;
1409 : :
1410 : : case 0x0020: // Line
1411 [ + - ][ + - ]: 39 : aPoint=ReadPoint(); aPenPosition=ReadPoint();
1412 : 39 : nDataSize=8;
1413 : :
1414 [ - + ]: 39 : if (IsInvisible(PDM_FRAME)) break;
1415 [ + - ]: 39 : DrawingMethod(PDM_FRAME);
1416 [ + - ]: 39 : PictReaderShape::drawLine(pVirDev, aPoint,aPenPosition, nActPenSize);
1417 : 39 : break;
1418 : :
1419 : : case 0x0021: // LineFrom
1420 [ + - ]: 120 : aPoint=aPenPosition; aPenPosition=ReadPoint();
1421 : 120 : nDataSize=4;
1422 : :
1423 [ - + ]: 120 : if (IsInvisible(PDM_FRAME)) break;
1424 [ + - ]: 120 : DrawingMethod(PDM_FRAME);
1425 [ + - ]: 120 : PictReaderShape::drawLine(pVirDev, aPoint,aPenPosition, nActPenSize);
1426 : 120 : break;
1427 : :
1428 : : case 0x0022: // ShortLine
1429 [ + - ]: 9 : aPoint=ReadPoint();
1430 [ + - ]: 9 : aPenPosition=ReadDeltaH(aPoint);
1431 [ + - ]: 9 : aPenPosition=ReadDeltaV(aPenPosition);
1432 : 9 : nDataSize=6;
1433 : :
1434 [ + - ]: 9 : if (IsInvisible(PDM_FRAME)) break;
1435 [ # # ]: 0 : DrawingMethod(PDM_FRAME);
1436 [ # # ]: 0 : PictReaderShape::drawLine(pVirDev, aPoint,aPenPosition, nActPenSize);
1437 : 0 : break;
1438 : :
1439 : : case 0x0023: // ShortLineFrom
1440 : 0 : aPoint=aPenPosition;
1441 [ # # ]: 0 : aPenPosition=ReadDeltaH(aPoint);
1442 [ # # ]: 0 : aPenPosition=ReadDeltaV(aPenPosition);
1443 : 0 : nDataSize=2;
1444 : :
1445 [ # # ]: 0 : if (IsInvisible(PDM_FRAME)) break;
1446 [ # # ]: 0 : DrawingMethod(PDM_FRAME);
1447 [ # # ]: 0 : PictReaderShape::drawLine(pVirDev, aPoint,aPenPosition, nActPenSize);
1448 : 0 : break;
1449 : :
1450 : : case 0x0024: // Reserved (n Bytes)
1451 : : case 0x0025: // Reserved (n Bytes)
1452 : : case 0x0026: // Reserved (n Bytes)
1453 : : case 0x0027: // Reserved (n Bytes)
1454 [ # # ]: 0 : *pPict >> nUSHORT;
1455 : 0 : nDataSize=2+nUSHORT;
1456 : 0 : break;
1457 : :
1458 : : case 0x0028: // LongText
1459 [ # # ]: 0 : aTextPosition=ReadPoint();
1460 [ # # ]: 0 : nDataSize=4+ReadAndDrawText();
1461 : 0 : break;
1462 : :
1463 : : case 0x0029: // DHText
1464 [ # # ]: 0 : aTextPosition=ReadUnsignedDeltaH(aTextPosition);
1465 [ # # ]: 0 : nDataSize=1+ReadAndDrawText();
1466 : 0 : break;
1467 : :
1468 : : case 0x002a: // DVText
1469 [ # # ]: 0 : aTextPosition=ReadUnsignedDeltaV(aTextPosition);
1470 [ # # ]: 0 : nDataSize=1+ReadAndDrawText();
1471 : 0 : break;
1472 : :
1473 : : case 0x002b: // DHDVText
1474 [ # # ]: 0 : aTextPosition=ReadUnsignedDeltaH(aTextPosition);
1475 [ # # ]: 0 : aTextPosition=ReadUnsignedDeltaV(aTextPosition);
1476 [ # # ]: 0 : nDataSize=2+ReadAndDrawText();
1477 : 0 : break;
1478 : :
1479 : : case 0x002c: { // fontName
1480 : : char sFName[ 256 ], nByteLen;
1481 : : sal_uInt16 nLen;
1482 [ # # ]: 0 : *pPict >> nUSHORT; nDataSize=nUSHORT+2;
1483 [ # # ]: 0 : *pPict >> nUSHORT;
1484 [ # # ][ # # ]: 0 : if (nUSHORT <= 1) aActFont.SetFamily(FAMILY_SWISS);
1485 [ # # ][ # # ]: 0 : else if (nUSHORT <= 12) aActFont.SetFamily(FAMILY_DECORATIVE);
1486 [ # # ][ # # ]: 0 : else if (nUSHORT <= 20) aActFont.SetFamily(FAMILY_ROMAN);
1487 [ # # ][ # # ]: 0 : else if (nUSHORT == 21) aActFont.SetFamily(FAMILY_SWISS);
1488 [ # # ][ # # ]: 0 : else if (nUSHORT == 22) aActFont.SetFamily(FAMILY_MODERN);
1489 [ # # ][ # # ]: 0 : else if (nUSHORT <= 1023) aActFont.SetFamily(FAMILY_SWISS);
1490 [ # # ]: 0 : else aActFont.SetFamily(FAMILY_ROMAN);
1491 [ # # ][ # # ]: 0 : aActFont.SetCharSet(GetTextEncoding(nUSHORT));
1492 [ # # ]: 0 : *pPict >> nByteLen; nLen=((sal_uInt16)nByteLen)&0x00ff;
1493 [ # # ]: 0 : pPict->Read( &sFName, nLen );
1494 : 0 : sFName[ nLen ] = 0;
1495 [ # # ][ # # ]: 0 : String aString( (const sal_Char*)&sFName, osl_getThreadTextEncoding() );
1496 [ # # ][ # # ]: 0 : aActFont.SetName( aString );
1497 : 0 : eActMethod=PDM_UNDEFINED;
1498 [ # # ]: 0 : break;
1499 : : }
1500 : : case 0x002d: // lineJustify
1501 : 0 : nDataSize=10;
1502 : 0 : break;
1503 : :
1504 : : case 0x002e: // glyphState
1505 [ # # ]: 0 : *pPict >> nUSHORT;
1506 : 0 : nDataSize=2+nUSHORT;
1507 : 0 : break;
1508 : :
1509 : : case 0x002f: // Reserved (n Bytes)
1510 [ # # ]: 0 : *pPict >> nUSHORT;
1511 : 0 : nDataSize=2+nUSHORT;
1512 : 0 : break;
1513 : :
1514 : : case 0x0030: // frameRect
1515 : : case 0x0031: // paintRect
1516 : : case 0x0032: // eraseRect
1517 : : case 0x0033: // invertRect
1518 : : case 0x0034: // fillRect
1519 [ # # ]: 0 : nDataSize=ReadAndDrawRect(shapeDMethod);
1520 : 0 : break;
1521 : :
1522 : : case 0x0035: // Reserved (8 Bytes)
1523 : : case 0x0036: // Reserved (8 Bytes)
1524 : : case 0x0037: // Reserved (8 Bytes)
1525 : 0 : nDataSize=8;
1526 : 0 : break;
1527 : :
1528 : : case 0x0038: // frameSameRect
1529 : : case 0x0039: // paintSameRect
1530 : : case 0x003a: // eraseSameRect
1531 : : case 0x003b: // invertSameRect
1532 : : case 0x003c: // fillSameRect
1533 [ # # ]: 0 : nDataSize=ReadAndDrawSameRect(shapeDMethod);
1534 : 0 : break;
1535 : :
1536 : : case 0x003d: // Reserved (0 Bytes)
1537 : : case 0x003e: // Reserved (0 Bytes)
1538 : : case 0x003f: // Reserved (0 Bytes)
1539 : 0 : nDataSize=0;
1540 : 0 : break;
1541 : :
1542 : : case 0x0040: // frameRRect
1543 : : case 0x0041: // paintRRect
1544 : : case 0x0042: // eraseRRect
1545 : : case 0x0043: // invertRRect
1546 : : case 0x0044: // fillRRect
1547 [ # # ]: 0 : nDataSize=ReadAndDrawRoundRect(shapeDMethod);
1548 : 0 : break;
1549 : :
1550 : : case 0x0045: // Reserved (8 Bytes)
1551 : : case 0x0046: // Reserved (8 Bytes)
1552 : : case 0x0047: // Reserved (8 Bytes)
1553 : 0 : nDataSize=8;
1554 : 0 : break;
1555 : :
1556 : : case 0x0048: // frameSameRRect
1557 : : case 0x0049: // paintSameRRect
1558 : : case 0x004a: // eraseSameRRect
1559 : : case 0x004b: // invertSameRRect
1560 : : case 0x004c: // fillSameRRect
1561 [ # # ]: 0 : nDataSize=ReadAndDrawSameRoundRect(shapeDMethod);
1562 : 0 : break;
1563 : :
1564 : : case 0x004d: // Reserved (0 Bytes)
1565 : : case 0x004e: // Reserved (0 Bytes)
1566 : : case 0x004f: // Reserved (0 Bytes)
1567 : 0 : nDataSize=0;
1568 : 0 : break;
1569 : :
1570 : : case 0x0050: // frameOval
1571 : : case 0x0051: // paintOval
1572 : : case 0x0052: // eraseOval
1573 : : case 0x0053: // invertOval
1574 : : case 0x0054: // fillOval
1575 [ # # ]: 0 : nDataSize=ReadAndDrawOval(shapeDMethod);
1576 : 0 : break;
1577 : :
1578 : : case 0x0055: // Reserved (8 Bytes)
1579 : : case 0x0056: // Reserved (8 Bytes)
1580 : : case 0x0057: // Reserved (8 Bytes)
1581 : 0 : nDataSize=8;
1582 : 0 : break;
1583 : :
1584 : : case 0x0058: // frameSameOval
1585 : : case 0x0059: // paintSameOval
1586 : : case 0x005a: // eraseSameOval
1587 : : case 0x005b: // invertSameOval
1588 : : case 0x005c: // fillSameOval
1589 [ # # ]: 0 : nDataSize=ReadAndDrawSameOval(shapeDMethod);
1590 : 0 : break;
1591 : :
1592 : : case 0x005d: // Reserved (0 Bytes)
1593 : : case 0x005e: // Reserved (0 Bytes)
1594 : : case 0x005f: // Reserved (0 Bytes)
1595 : 0 : nDataSize=0;
1596 : 0 : break;
1597 : :
1598 : : case 0x0060: // frameArc
1599 : : case 0x0061: // paintArc
1600 : : case 0x0062: // eraseArc
1601 : : case 0x0063: // invertArc
1602 : : case 0x0064: // fillArc
1603 [ # # ]: 0 : nDataSize=ReadAndDrawArc(shapeDMethod);
1604 : 0 : break;
1605 : :
1606 : : case 0x0065: // Reserved (12 Bytes)
1607 : : case 0x0066: // Reserved (12 Bytes)
1608 : : case 0x0067: // Reserved (12 Bytes)
1609 : 0 : nDataSize=12;
1610 : 0 : break;
1611 : :
1612 : : case 0x0068: // frameSameArc
1613 : : case 0x0069: // paintSameArc
1614 : : case 0x006a: // eraseSameArc
1615 : : case 0x006b: // invertSameArc
1616 : : case 0x006c: // fillSameArc
1617 [ # # ]: 0 : nDataSize=ReadAndDrawSameArc(shapeDMethod);
1618 : 0 : break;
1619 : :
1620 : : case 0x006d: // Reserved (4 Bytes)
1621 : : case 0x006e: // Reserved (4 Bytes)
1622 : : case 0x006f: // Reserved (4 Bytes)
1623 : 0 : nDataSize=4;
1624 : 0 : break;
1625 : :
1626 : : case 0x0070: // framePoly
1627 : : case 0x0071: // paintPoly
1628 : : case 0x0072: // erasePoly
1629 : : case 0x0073: // invertPoly
1630 : : case 0x0074: // fillPoly
1631 [ + - ]: 87 : nDataSize=ReadAndDrawPolygon(shapeDMethod);
1632 : 87 : break;
1633 : :
1634 : : case 0x0075: // Reserved (Polygon-Size)
1635 : : case 0x0076: // Reserved (Polygon-Size)
1636 : : case 0x0077: // Reserved (Polygon-Size)
1637 [ # # ]: 0 : *pPict >> nUSHORT; nDataSize=nUSHORT;
1638 : 0 : break;
1639 : :
1640 : : case 0x0078: // frameSamePoly
1641 : : case 0x0079: // paintSamePoly
1642 : : case 0x007a: // eraseSamePoly
1643 : : case 0x007b: // invertSamePoly
1644 : : case 0x007c: // fillSamePoly
1645 [ # # ]: 0 : nDataSize=ReadAndDrawSamePolygon(shapeDMethod);
1646 : 0 : break;
1647 : :
1648 : : case 0x007d: // Reserved (0 Bytes)
1649 : : case 0x007e: // Reserved (0 Bytes)
1650 : : case 0x007f: // Reserved (0 Bytes)
1651 : 0 : nDataSize=0;
1652 : 0 : break;
1653 : :
1654 : : case 0x0080: // frameRgn
1655 : : case 0x0081: // paintRgn
1656 : : case 0x0082: // eraseRgn
1657 : : case 0x0083: // invertRgn
1658 : : case 0x0084: // fillRgn
1659 [ # # ]: 0 : nDataSize=ReadAndDrawRgn(shapeDMethod);
1660 : 0 : break;
1661 : :
1662 : : case 0x0085: // Reserved (Region-Size)
1663 : : case 0x0086: // Reserved (Region-Size)
1664 : : case 0x0087: // Reserved (Region-Size)
1665 [ # # ]: 0 : *pPict >> nUSHORT; nDataSize=nUSHORT;
1666 : 0 : break;
1667 : :
1668 : : case 0x0088: // frameSameRgn
1669 : : case 0x0089: // paintSameRgn
1670 : : case 0x008a: // eraseSameRgn
1671 : : case 0x008b: // invertSameRgn
1672 : : case 0x008c: // fillSameRgn
1673 [ # # ]: 0 : nDataSize=ReadAndDrawSameRgn(shapeDMethod);
1674 : 0 : break;
1675 : :
1676 : : case 0x008d: // Reserved (0 Bytes)
1677 : : case 0x008e: // Reserved (0 Bytes)
1678 : : case 0x008f: // Reserved (0 Bytes)
1679 : 0 : nDataSize=0;
1680 : 0 : break;
1681 : :
1682 : : case 0x0090: { // BitsRect
1683 [ # # ]: 0 : Bitmap aBmp;
1684 [ # # ][ # # ]: 0 : Rectangle aSrcRect, aDestRect;
1685 [ # # ]: 0 : nDataSize=ReadPixMapEtc(aBmp, sal_False, sal_True, &aSrcRect, &aDestRect, sal_True, sal_False);
1686 [ # # ]: 0 : DrawingMethod(PDM_PAINT);
1687 [ # # ][ # # ]: 0 : pVirDev->DrawBitmap(aDestRect.TopLeft(),aDestRect.GetSize(),aBmp);
1688 [ # # ]: 0 : break;
1689 : : }
1690 : : case 0x0091: { // BitsRgn
1691 [ # # ]: 0 : Bitmap aBmp;
1692 [ # # ][ # # ]: 0 : Rectangle aSrcRect, aDestRect;
1693 [ # # ]: 0 : nDataSize=ReadPixMapEtc(aBmp, sal_False, sal_True, &aSrcRect, &aDestRect, sal_True, sal_True);
1694 [ # # ]: 0 : DrawingMethod(PDM_PAINT);
1695 [ # # ][ # # ]: 0 : pVirDev->DrawBitmap(aDestRect.TopLeft(),aDestRect.GetSize(),aBmp);
1696 [ # # ]: 0 : break;
1697 : : }
1698 : : case 0x0092: // Reserved (n Bytes)
1699 : : case 0x0093: // Reserved (n Bytes)
1700 : : case 0x0094: // Reserved (n Bytes)
1701 : : case 0x0095: // Reserved (n Bytes)
1702 : : case 0x0096: // Reserved (n Bytes)
1703 : : case 0x0097: // Reserved (n Bytes)
1704 [ # # ]: 0 : *pPict >> nUSHORT; nDataSize=2+nUSHORT;
1705 : 0 : break;
1706 : :
1707 : : case 0x0098: { // PackBitsRect
1708 [ + - ]: 3 : Bitmap aBmp;
1709 [ + - ][ + - ]: 3 : Rectangle aSrcRect, aDestRect;
1710 [ + - ]: 3 : nDataSize=ReadPixMapEtc(aBmp, sal_False, sal_True, &aSrcRect, &aDestRect, sal_True, sal_False);
1711 [ + - ]: 3 : DrawingMethod(PDM_PAINT);
1712 [ + - ][ + - ]: 3 : pVirDev->DrawBitmap(aDestRect.TopLeft(),aDestRect.GetSize(),aBmp);
1713 [ + - ]: 3 : break;
1714 : : }
1715 : : case 0x0099: { // PackBitsRgn
1716 [ # # ]: 0 : Bitmap aBmp;
1717 [ # # ][ # # ]: 0 : Rectangle aSrcRect, aDestRect;
1718 [ # # ]: 0 : nDataSize=ReadPixMapEtc(aBmp, sal_False, sal_True, &aSrcRect, &aDestRect, sal_True, sal_True);
1719 [ # # ]: 0 : DrawingMethod(PDM_PAINT);
1720 [ # # ][ # # ]: 0 : pVirDev->DrawBitmap(aDestRect.TopLeft(),aDestRect.GetSize(),aBmp);
1721 [ # # ]: 0 : break;
1722 : : }
1723 : : case 0x009a: { // DirectBitsRect
1724 [ + - ]: 3 : Bitmap aBmp;
1725 [ + - ][ + - ]: 3 : Rectangle aSrcRect, aDestRect;
1726 [ + - ]: 3 : nDataSize=ReadPixMapEtc(aBmp, sal_True, sal_False, &aSrcRect, &aDestRect, sal_True, sal_False);
1727 [ + - ]: 3 : DrawingMethod(PDM_PAINT);
1728 [ + - ][ + - ]: 3 : pVirDev->DrawBitmap(aDestRect.TopLeft(),aDestRect.GetSize(),aBmp);
1729 [ + - ]: 3 : break;
1730 : : }
1731 : : case 0x009b: { // DirectBitsRgn
1732 [ # # ]: 0 : Bitmap aBmp;
1733 [ # # ][ # # ]: 0 : Rectangle aSrcRect, aDestRect;
1734 [ # # ]: 0 : nDataSize=ReadPixMapEtc(aBmp, sal_True, sal_False, &aSrcRect, &aDestRect, sal_True, sal_True);
1735 [ # # ]: 0 : DrawingMethod(PDM_PAINT);
1736 [ # # ][ # # ]: 0 : pVirDev->DrawBitmap(aDestRect.TopLeft(),aDestRect.GetSize(),aBmp);
1737 [ # # ]: 0 : break;
1738 : : }
1739 : : case 0x009c: // Reserved (n Bytes)
1740 : : case 0x009d: // Reserved (n Bytes)
1741 : : case 0x009e: // Reserved (n Bytes)
1742 : : case 0x009f: // Reserved (n Bytes)
1743 [ # # ]: 0 : *pPict >> nUSHORT; nDataSize=2+nUSHORT;
1744 : 0 : break;
1745 : :
1746 : : case 0x00a0: // ShortComment
1747 : 12 : nDataSize=2;
1748 : 12 : break;
1749 : :
1750 : : case 0x00a1: // LongComment
1751 [ + - ][ + - ]: 1158 : pPict->SeekRel(2); *pPict >> nUSHORT; nDataSize=4+nUSHORT;
1752 : 1158 : break;
1753 : :
1754 : : default: // 0x00a2 bis 0xffff (zumeist Reserved)
1755 [ - + ][ # # ]: 6 : if (nOpcode<=0x00af) { *pPict >> nUSHORT; nDataSize=2+nUSHORT; }
1756 [ - + ]: 6 : else if (nOpcode<=0x00cf) { nDataSize=0; }
1757 [ - + ][ # # ]: 6 : else if (nOpcode<=0x00fe) { sal_uInt32 nTemp; *pPict >> nTemp ; nDataSize = nTemp; nDataSize+=4; }
1758 : : // Osnola: checkme: in the Quickdraw Ref examples ( for pict v2)
1759 : : // 0x00ff(EndOfPict) is also not followed by any data...
1760 [ - + ][ # # ]: 6 : else if (nOpcode==0x00ff) { nDataSize=IsVersion2 ? 2 : 0; } // OpEndPic
1761 [ - + ]: 6 : else if (nOpcode<=0x01ff) { nDataSize=2; }
1762 [ - + ]: 6 : else if (nOpcode<=0x0bfe) { nDataSize=4; }
1763 [ - + ]: 6 : else if (nOpcode<=0x0bff) { nDataSize=22; }
1764 [ - + ]: 6 : else if (nOpcode==0x0c00) { nDataSize=24; } // HeaderOp
1765 [ + + ]: 6 : else if (nOpcode<=0x7eff) { nDataSize=24; }
1766 [ - + ]: 3 : else if (nOpcode<=0x7fff) { nDataSize=254; }
1767 [ - + ]: 3 : else if (nOpcode<=0x80ff) { nDataSize=0; }
1768 [ + - ]: 3 : else { sal_uInt32 nTemp; *pPict >> nTemp ; nDataSize = nTemp; nDataSize+=4; }
1769 : : }
1770 : :
1771 [ - + ]: 1545 : if (nDataSize==0xffffffff) {
1772 [ # # ]: 0 : pPict->SetError(SVSTREAM_FILEFORMAT_ERROR);
1773 : 0 : return 0;
1774 : : }
1775 : 1545 : return nDataSize;
1776 : : }
1777 : :
1778 : 9 : void PictReader::ReadPict( SvStream & rStreamPict, GDIMetaFile & rGDIMetaFile )
1779 : : {
1780 : : sal_uInt16 nOpcode;
1781 : : sal_uInt8 nOneByteOpcode;
1782 : : sal_uLong nSize, nPos, nStartPos, nEndPos, nPercent, nLastPercent;
1783 : :
1784 : 9 : pPict = &rStreamPict;
1785 : 9 : nOrigPos = pPict->Tell();
1786 : 9 : nOrigNumberFormat = pPict->GetNumberFormatInt();
1787 : :
1788 : 9 : aActForeColor = Color(COL_BLACK);
1789 : 9 : aActBackColor = Color(COL_WHITE);
1790 : 9 : nActPenSize = Size(1,1);
1791 : 9 : eActROP = ROP_OVERPAINT;
1792 : 9 : eActMethod = PDM_UNDEFINED;
1793 : 9 : aActOvalSize = Size(1,1);
1794 : :
1795 [ + - ][ + - ]: 9 : aActFont.SetCharSet( GetTextEncoding());
1796 [ + - ]: 9 : aActFont.SetFamily(FAMILY_SWISS);
1797 [ + - ]: 9 : aActFont.SetSize(Size(0,12));
1798 [ + - ]: 9 : aActFont.SetAlign(ALIGN_BASELINE);
1799 : :
1800 [ + - ][ + - ]: 9 : aHRes = aVRes = Fraction( 1, 1 );
[ + - ]
1801 : :
1802 [ + - ][ + - ]: 9 : pVirDev = new VirtualDevice();
1803 [ + - ]: 9 : pVirDev->EnableOutput(sal_False);
1804 [ + - ]: 9 : rGDIMetaFile.Record(pVirDev);
1805 : :
1806 [ + - ]: 9 : pPict->SetNumberFormatInt(NUMBERFORMAT_INT_BIGENDIAN);
1807 : :
1808 : 9 : nStartPos=pPict->Tell();
1809 [ + - ][ + - ]: 9 : nEndPos=pPict->Seek(STREAM_SEEK_TO_END); pPict->Seek(nStartPos);
1810 : 9 : Callback(0); nLastPercent=0;
1811 : :
1812 [ + - ]: 9 : ReadHeader();
1813 : :
1814 : 9 : aPenPosition=Point(-aBoundingRect.Left(),-aBoundingRect.Top());
1815 : 9 : aTextPosition=aPenPosition;
1816 : :
1817 : 9 : nPos=pPict->Tell();
1818 : :
1819 : 1545 : for (;;) {
1820 : :
1821 : 1554 : nPercent=(nPos-nStartPos)*100/(nEndPos-nStartPos);
1822 [ + + ]: 1554 : if (nLastPercent+4<=nPercent) {
1823 [ - + ]: 60 : if (Callback((sal_uInt16)nPercent)==sal_True) break;
1824 : 60 : nLastPercent=nPercent;
1825 : : }
1826 : :
1827 [ + - ]: 1554 : if (IsVersion2 )
1828 [ + - ]: 1554 : *pPict >> nOpcode;
1829 : : else
1830 : : {
1831 [ # # ]: 0 : *pPict >> nOneByteOpcode;
1832 : 0 : nOpcode=(sal_uInt16)nOneByteOpcode;
1833 : : }
1834 : :
1835 [ - + ]: 1554 : if (pPict->GetError())
1836 : 0 : break;
1837 : :
1838 [ + + ]: 1554 : if (pPict->IsEof())
1839 : : {
1840 [ + - ]: 6 : pPict->SetError(SVSTREAM_FILEFORMAT_ERROR);
1841 : 6 : break;
1842 : : }
1843 : :
1844 [ + + ]: 1548 : if (nOpcode==0x00ff)
1845 : 3 : break;
1846 : :
1847 [ + - ]: 1545 : nSize=ReadData(nOpcode);
1848 : :
1849 [ + - ]: 1545 : if ( IsVersion2 )
1850 : : {
1851 [ + + ]: 1545 : if ( nSize & 1 )
1852 : 687 : nSize++;
1853 : :
1854 : 1545 : nPos+=2+nSize;
1855 : : }
1856 : : else
1857 : 0 : nPos+=1+nSize;
1858 : :
1859 [ + - ]: 1545 : pPict->Seek(nPos);
1860 : : }
1861 : :
1862 [ + - ]: 9 : rGDIMetaFile.Stop();
1863 [ + - ][ + - ]: 9 : delete pVirDev;
1864 : :
1865 [ + - ][ + - ]: 9 : rGDIMetaFile.SetPrefMapMode( MapMode( MAP_INCH, Point(), aHRes, aVRes ) );
[ + - ]
1866 [ + - ]: 9 : rGDIMetaFile.SetPrefSize( aBoundingRect.GetSize() );
1867 : :
1868 [ + - ]: 9 : pPict->SetNumberFormatInt(nOrigNumberFormat);
1869 : :
1870 [ + + ][ + - ]: 9 : if (pPict->GetError()) pPict->Seek(nOrigPos);
1871 : 9 : }
1872 : :
1873 : : //================== GraphicImport - die exportierte Funktion ================
1874 : :
1875 : : extern "C" SAL_DLLPUBLIC_EXPORT sal_Bool __LOADONCALLAPI
1876 : 9 : GraphicImport( SvStream& rIStm, Graphic & rGraphic, FilterConfigItem*, sal_Bool)
1877 : : {
1878 [ + - ]: 9 : GDIMetaFile aMTF;
1879 [ + - ]: 9 : PictReader aPictReader;
1880 : 9 : sal_Bool bRet = sal_False;
1881 : :
1882 [ + - ]: 9 : aPictReader.ReadPict( rIStm, aMTF );
1883 : :
1884 [ + + ]: 9 : if ( !rIStm.GetError() )
1885 : : {
1886 [ + - ][ + - ]: 3 : rGraphic = Graphic( aMTF );
[ + - ]
1887 : 3 : bRet = sal_True;
1888 : : }
1889 : :
1890 [ + - ][ + - ]: 9 : return bRet;
1891 : : }
1892 : :
1893 : :
1894 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|