update dev300-m58
[ooovba.git] / svtools / source / filter.vcl / filter / sgfbram.cxx
blob9b79c5921446bab7dcfe56ca51ca5f32aae982da
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: sgfbram.cxx,v $
10 * $Revision: 1.10 $
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_svtools.hxx"
34 #include <string.h>
35 #include <osl/endian.h>
36 #include <tools/stream.hxx>
37 #include <vcl/gdimtf.hxx>
38 #include <tools/color.hxx>
39 #include <vcl/virdev.hxx>
40 #include "sgffilt.hxx"
41 #include "sgfbram.hxx"
43 #if defined( WIN ) && defined( MSC )
44 #pragma code_seg( "SVTOOLS_FILTER4", "SVTOOLS_CODE" )
45 #endif
47 /*************************************************************************
49 |* operator>>( SvStream&, SgfHeader& )
51 |* Beschreibung
52 |* Ersterstellung JOE 23.06.93
53 |* Letzte Aenderung JOE 23.06.93
55 *************************************************************************/
56 SvStream& operator>>(SvStream& rIStream, SgfHeader& rHead)
58 rIStream.Read((char*)&rHead.Magic,SgfHeaderSize);
59 #if defined OSL_BIGENDIAN
60 rHead.Magic =SWAPSHORT(rHead.Magic );
61 rHead.Version=SWAPSHORT(rHead.Version);
62 rHead.Typ =SWAPSHORT(rHead.Typ );
63 rHead.Xsize =SWAPSHORT(rHead.Xsize );
64 rHead.Ysize =SWAPSHORT(rHead.Ysize );
65 rHead.Xoffs =SWAPSHORT(rHead.Xoffs );
66 rHead.Yoffs =SWAPSHORT(rHead.Yoffs );
67 rHead.Planes =SWAPSHORT(rHead.Planes );
68 rHead.SwGrCol=SWAPSHORT(rHead.SwGrCol);
69 rHead.OfsLo =SWAPSHORT(rHead.OfsLo );
70 rHead.OfsHi =SWAPSHORT(rHead.OfsHi );
71 #endif
72 return rIStream;
76 /*************************************************************************
78 |* SgfHeader::ChkMagic()
80 |* Beschreibung
81 |* Ersterstellung JOE 23.06.93
82 |* Letzte Aenderung JOE 23.06.93
84 *************************************************************************/
85 BOOL SgfHeader::ChkMagic()
86 { return Magic=='J'*256+'J'; }
88 UINT32 SgfHeader::GetOffset()
89 { return UINT32(OfsLo)+0x00010000*UINT32(OfsHi); }
92 /*************************************************************************
94 |* operator>>( SvStream&, SgfEntry& )
96 |* Beschreibung
97 |* Ersterstellung JOE 23.06.93
98 |* Letzte Aenderung JOE 23.06.93
100 *************************************************************************/
101 SvStream& operator>>(SvStream& rIStream, SgfEntry& rEntr)
103 rIStream.Read((char*)&rEntr.Typ,SgfEntrySize);
104 #if defined OSL_BIGENDIAN
105 rEntr.Typ =SWAPSHORT(rEntr.Typ );
106 rEntr.iFrei=SWAPSHORT(rEntr.iFrei);
107 rEntr.lFreiLo=SWAPSHORT (rEntr.lFreiLo);
108 rEntr.lFreiHi=SWAPSHORT (rEntr.lFreiHi);
109 rEntr.OfsLo=SWAPSHORT(rEntr.OfsLo);
110 rEntr.OfsHi=SWAPSHORT(rEntr.OfsHi);
111 #endif
112 return rIStream;
115 UINT32 SgfEntry::GetOffset()
116 { return UINT32(OfsLo)+0x00010000*UINT32(OfsHi); }
119 /*************************************************************************
121 |* operator>>( SvStream&, SgfVector& )
123 |* Beschreibung
124 |* Ersterstellung JOE 23.06.93
125 |* Letzte Aenderung JOE 23.06.93
127 *************************************************************************/
128 SvStream& operator>>(SvStream& rIStream, SgfVector& rVect)
130 rIStream.Read((char*)&rVect,sizeof(rVect));
131 #if defined OSL_BIGENDIAN
132 rVect.Flag =SWAPSHORT(rVect.Flag );
133 rVect.x =SWAPSHORT(rVect.x );
134 rVect.y =SWAPSHORT(rVect.y );
135 rVect.OfsLo=SWAPLONG (rVect.OfsLo);
136 rVect.OfsHi=SWAPLONG (rVect.OfsHi);
137 #endif
138 return rIStream;
142 /*************************************************************************
144 |* operator<<( SvStream&, BmpFileHeader& )
146 |* Beschreibung
147 |* Ersterstellung JOE 23.06.93
148 |* Letzte Aenderung JOE 23.06.93
150 *************************************************************************/
151 SvStream& operator<<(SvStream& rOStream, BmpFileHeader& rHead)
153 #if defined OSL_BIGENDIAN
154 rHead.Typ =SWAPSHORT(rHead.Typ );
155 rHead.SizeLo =SWAPSHORT(rHead.SizeLo );
156 rHead.SizeHi =SWAPSHORT(rHead.SizeHi );
157 rHead.Reserve1=SWAPSHORT(rHead.Reserve1);
158 rHead.Reserve2=SWAPSHORT(rHead.Reserve2);
159 rHead.OfsLo =SWAPSHORT(rHead.OfsLo );
160 rHead.OfsHi =SWAPSHORT(rHead.OfsHi );
161 #endif
162 rOStream.Write((char*)&rHead,sizeof(rHead));
163 #if defined OSL_BIGENDIAN
164 rHead.Typ =SWAPSHORT(rHead.Typ );
165 rHead.SizeLo =SWAPSHORT(rHead.SizeLo );
166 rHead.SizeHi =SWAPSHORT(rHead.SizeHi );
167 rHead.Reserve1=SWAPSHORT(rHead.Reserve1);
168 rHead.Reserve2=SWAPSHORT(rHead.Reserve2);
169 rHead.OfsLo =SWAPSHORT(rHead.OfsLo );
170 rHead.OfsHi =SWAPSHORT(rHead.OfsHi );
171 #endif
172 return rOStream;
175 void BmpFileHeader::SetSize(UINT32 Size)
177 SizeLo=UINT16(Size & 0x0000FFFF);
178 SizeHi=UINT16((Size & 0xFFFF0000)>>16);
181 void BmpFileHeader::SetOfs(UINT32 Ofs)
183 OfsLo=UINT16(Ofs & 0x0000FFFF);
184 OfsHi=UINT16((Ofs & 0xFFFF0000)>>16);
187 UINT32 BmpFileHeader::GetOfs()
189 return UINT32(OfsLo)+0x00010000*UINT32(OfsHi);
192 /*************************************************************************
194 |* operator<<( SvStream&, BmpInfoHeader& )
196 |* Beschreibung
197 |* Ersterstellung JOE 23.06.93
198 |* Letzte Aenderung JOE 23.06.93
200 *************************************************************************/
201 SvStream& operator<<(SvStream& rOStream, BmpInfoHeader& rInfo)
203 #if defined OSL_BIGENDIAN
204 rInfo.Size =SWAPLONG (rInfo.Size );
205 rInfo.Width =SWAPLONG (rInfo.Width );
206 rInfo.Hight =SWAPLONG (rInfo.Hight );
207 rInfo.Planes =SWAPSHORT(rInfo.Planes );
208 rInfo.PixBits =SWAPSHORT(rInfo.PixBits );
209 rInfo.Compress=SWAPLONG (rInfo.Compress);
210 rInfo.ImgSize =SWAPLONG (rInfo.ImgSize );
211 rInfo.xDpmm =SWAPLONG (rInfo.xDpmm );
212 rInfo.yDpmm =SWAPLONG (rInfo.yDpmm );
213 rInfo.ColUsed =SWAPLONG (rInfo.ColUsed );
214 rInfo.ColMust =SWAPLONG (rInfo.ColMust );
215 #endif
216 rOStream.Write((char*)&rInfo,sizeof(rInfo));
217 #if defined OSL_BIGENDIAN
218 rInfo.Size =SWAPLONG (rInfo.Size );
219 rInfo.Width =SWAPLONG (rInfo.Width );
220 rInfo.Hight =SWAPLONG (rInfo.Hight );
221 rInfo.Planes =SWAPSHORT(rInfo.Planes );
222 rInfo.PixBits =SWAPSHORT(rInfo.PixBits );
223 rInfo.Compress=SWAPLONG (rInfo.Compress);
224 rInfo.ImgSize =SWAPLONG (rInfo.ImgSize );
225 rInfo.xDpmm =SWAPLONG (rInfo.xDpmm );
226 rInfo.yDpmm =SWAPLONG (rInfo.yDpmm );
227 rInfo.ColUsed =SWAPLONG (rInfo.ColUsed );
228 rInfo.ColMust =SWAPLONG (rInfo.ColMust );
229 #endif
230 return rOStream;
234 /*************************************************************************
236 |* operator<<( SvStream&, RGBQuad& )
238 |* Beschreibung
239 |* Ersterstellung JOE 23.06.93
240 |* Letzte Aenderung JOE 23.06.93
242 *************************************************************************/
243 SvStream& operator<<(SvStream& rOStream, const RGBQuad& rQuad)
245 rOStream.Write((char*)&rQuad,sizeof(rQuad));
246 return rOStream;
250 ////////////////////////////////////////////////////////////////////////////////////////////////////
251 // PcxExpand ///////////////////////////////////////////////////////////////////////////////////////
252 ////////////////////////////////////////////////////////////////////////////////////////////////////
254 class PcxExpand
256 private:
257 USHORT Count;
258 BYTE Data;
259 public:
260 PcxExpand() { Count=0; }
261 BYTE GetByte(SvStream& rInp);
264 BYTE PcxExpand::GetByte(SvStream& rInp)
266 if (Count>0) {
267 Count--;
268 } else {
269 rInp.Read((char*)&Data,1);
270 if ((Data & 0xC0) == 0xC0) {
271 Count=(Data & 0x3F) -1;
272 rInp.Read((char*)&Data,1);
275 return Data;
278 ////////////////////////////////////////////////////////////////////////////////////////////////////
279 // SgfBMapFilter ///////////////////////////////////////////////////////////////////////////////////
280 ////////////////////////////////////////////////////////////////////////////////////////////////////
283 /*************************************************************************
285 |* SgfFilterBmp()
287 |* Beschreibung
288 |* Ersterstellung JOE 23.06.93
289 |* Letzte Aenderung JOE 23.06.93
291 *************************************************************************/
292 BOOL SgfFilterBMap(SvStream& rInp, SvStream& rOut, SgfHeader& rHead, SgfEntry&)
294 BmpFileHeader aBmpHead;
295 BmpInfoHeader aBmpInfo;
296 USHORT nWdtInp=(rHead.Xsize+7)/8; // Breite der Input-Bitmap in Bytes
297 USHORT nWdtOut; // Breite der Output-Bitmap in Bytes
298 USHORT nColors; // Anzahl der Farben (1,16,256)
299 USHORT nColBits; // Anzahl der Bits/Pixel (2, 4, 8)
300 USHORT i,j,k; // Spaltenzaehler, Zeilenzaehler, Planezaehler
301 USHORT a,b; // Hilfsvariable
302 BYTE pl1 = 0,pl2= 0; // Masken fuer die Planes
303 BYTE* pBuf=NULL; // Buffer fuer eine Pixelzeile
304 PcxExpand aPcx;
305 ULONG nOfs;
306 BYTE cRGB[4];
308 if (rHead.Planes<=1) nColBits=1; else nColBits=4; if (rHead.Typ==4) nColBits=8;
309 nColors=1<<nColBits;
310 nWdtOut=((rHead.Xsize*nColBits+31)/32)*4;
311 aBmpHead.Typ='B'+'M'*256;
312 aBmpHead.SetOfs(sizeof(aBmpHead)+sizeof(aBmpInfo)+nColors*4);
313 aBmpHead.SetSize(aBmpHead.GetOfs()+nWdtOut*rHead.Ysize);
314 aBmpHead.Reserve1=0;
315 aBmpHead.Reserve2=0;
316 aBmpInfo.Size=sizeof(aBmpInfo);
317 aBmpInfo.Width=rHead.Xsize;
318 aBmpInfo.Hight=rHead.Ysize;
319 aBmpInfo.Planes=1;
320 aBmpInfo.PixBits=nColBits;
321 aBmpInfo.Compress=0;
322 aBmpInfo.ImgSize=0;
323 aBmpInfo.xDpmm=0;
324 aBmpInfo.yDpmm=0;
325 aBmpInfo.ColUsed=0;
326 aBmpInfo.ColMust=0;
327 pBuf=new BYTE[nWdtOut];
328 if (!pBuf) return FALSE; // Fehler: kein Speichel da
329 rOut<<aBmpHead<<aBmpInfo;
330 memset(pBuf,0,nWdtOut); // Buffer mit Nullen fuellen
332 if (nColors==2)
335 rOut<<RGBQuad(0x00,0x00,0x00); // Schwarz
336 rOut<<RGBQuad(0xFF,0xFF,0xFF); // Weiss
337 nOfs=rOut.Tell();
338 for (j=0;j<rHead.Ysize;j++)
339 rOut.Write((char*)pBuf,nWdtOut); // Datei erstmal komplett mit Nullen fuellen
340 for (j=0;j<rHead.Ysize;j++) {
341 for(i=0;i<nWdtInp;i++) {
342 pBuf[i]=aPcx.GetByte(rInp);
344 for(i=nWdtInp;i<nWdtOut;i++) pBuf[i]=0; // noch bis zu 3 Bytes
345 rOut.Seek(nOfs+((ULONG)rHead.Ysize-j-1L)*(ULONG)nWdtOut); // rueckwaerts schreiben!
346 rOut.Write((char*)pBuf,nWdtOut);
348 } else if (nColors==16) {
349 rOut<<RGBQuad(0x00,0x00,0x00); // Schwarz
350 rOut<<RGBQuad(0x24,0x24,0x24); // Grau 80%
351 rOut<<RGBQuad(0x49,0x49,0x49); // Grau 60%
352 rOut<<RGBQuad(0x92,0x92,0x92); // Grau 40%
353 rOut<<RGBQuad(0x6D,0x6D,0x6D); // Grau 30%
354 rOut<<RGBQuad(0xB6,0xB6,0xB6); // Grau 20%
355 rOut<<RGBQuad(0xDA,0xDA,0xDA); // Grau 10%
356 rOut<<RGBQuad(0xFF,0xFF,0xFF); // Weiss
357 rOut<<RGBQuad(0x00,0x00,0x00); // Schwarz
358 rOut<<RGBQuad(0xFF,0x00,0x00); // Rot
359 rOut<<RGBQuad(0x00,0x00,0xFF); // Blau
360 rOut<<RGBQuad(0xFF,0x00,0xFF); // Magenta
361 rOut<<RGBQuad(0x00,0xFF,0x00); // Gruen
362 rOut<<RGBQuad(0xFF,0xFF,0x00); // Gelb
363 rOut<<RGBQuad(0x00,0xFF,0xFF); // Cyan
364 rOut<<RGBQuad(0xFF,0xFF,0xFF); // Weiss
366 nOfs=rOut.Tell();
367 for (j=0;j<rHead.Ysize;j++)
368 rOut.Write((char*)pBuf,nWdtOut); // Datei erstmal komplett mit Nullen fuellen
369 for (j=0;j<rHead.Ysize;j++) {
370 memset(pBuf,0,nWdtOut);
371 for(k=0;k<4;k++) {
372 if (k==0) {
373 pl1=0x10; pl2=0x01;
374 } else {
375 pl1<<=1; pl2<<=1;
377 for(i=0;i<nWdtInp;i++) {
378 a=i*4;
379 b=aPcx.GetByte(rInp);
380 if (b & 0x80) pBuf[a ]|=pl1;
381 if (b & 0x40) pBuf[a ]|=pl2;
382 if (b & 0x20) pBuf[a+1]|=pl1;
383 if (b & 0x10) pBuf[a+1]|=pl2;
384 if (b & 0x08) pBuf[a+2]|=pl1;
385 if (b & 0x04) pBuf[a+2]|=pl2;
386 if (b & 0x02) pBuf[a+3]|=pl1;
387 if (b & 0x01) pBuf[a+3]|=pl2;
390 for(i=nWdtInp*4;i<nWdtOut;i++) pBuf[i]=0; // noch bis zu 3 Bytes
391 rOut.Seek(nOfs+((ULONG)rHead.Ysize-j-1L)*(ULONG)nWdtOut); // rueckwaerts schreiben!
392 rOut.Write((char*)pBuf,nWdtOut);
394 } else if (nColors==256) {
395 cRGB[3]=0; // der 4. Paletteneintrag fuer BMP
396 for (i=0;i<256;i++) { // Palette kopieren
397 rInp.Read((char*)cRGB,3);
398 pl1=cRGB[0]; // Rot mit Blau tauschen
399 cRGB[0]=cRGB[2];
400 cRGB[2]=pl1;
401 rOut.Write((char*)cRGB,4);
404 nOfs=rOut.Tell();
405 for (j=0;j<rHead.Ysize;j++)
406 rOut.Write((char*)pBuf,nWdtOut); // Datei erstmal komplett mit Nullen fuellen
407 for (j=0;j<rHead.Ysize;j++) {
408 for(i=0;i<rHead.Xsize;i++)
409 pBuf[i]=aPcx.GetByte(rInp);
410 for(i=rHead.Xsize;i<nWdtOut;i++) pBuf[i]=0; // noch bis zu 3 Bytes
411 rOut.Seek(nOfs+((ULONG)rHead.Ysize-j-1L)*(ULONG)nWdtOut); // rueckwaerts schreiben!
412 rOut.Write((char*)pBuf,nWdtOut);
415 delete[] pBuf;
416 return TRUE;
420 /*************************************************************************
422 |* SgfBMapFilter()
424 |* Beschreibung
425 |* Ersterstellung JOE 23.06.93
426 |* Letzte Aenderung JOE 23.06.93
428 *************************************************************************/
429 BOOL SgfBMapFilter(SvStream& rInp, SvStream& rOut)
431 ULONG nFileStart; // Offset des SgfHeaders. Im allgemeinen 0.
432 SgfHeader aHead;
433 SgfEntry aEntr;
434 ULONG nNext;
435 BOOL bRdFlag=FALSE; // Grafikentry gelesen ?
436 BOOL bRet=FALSE; // Returncode
438 nFileStart=rInp.Tell();
439 rInp>>aHead;
440 if (aHead.ChkMagic() && (aHead.Typ==SgfBitImag0 || aHead.Typ==SgfBitImag1 ||
441 aHead.Typ==SgfBitImag2 || aHead.Typ==SgfBitImgMo)) {
442 nNext=aHead.GetOffset();
443 while (nNext && !bRdFlag && !rInp.GetError() && !rOut.GetError()) {
444 rInp.Seek(nFileStart+nNext);
445 rInp>>aEntr;
446 nNext=aEntr.GetOffset();
447 if (aEntr.Typ==aHead.Typ) {
448 bRdFlag=TRUE;
449 switch(aEntr.Typ) {
450 case SgfBitImag0:
451 case SgfBitImag1:
452 case SgfBitImag2:
453 case SgfBitImgMo: bRet=SgfFilterBMap(rInp,rOut,aHead,aEntr); break;
456 } // while(nNext)
458 if (rInp.GetError()) bRet=FALSE;
459 return(bRet);
463 ////////////////////////////////////////////////////////////////////////////////////////////////////
464 // SgfVectFilter ///////////////////////////////////////////////////////////////////////////////////
465 ////////////////////////////////////////////////////////////////////////////////////////////////////
467 // Fuer StarDraw Embedded SGF-Vector
468 long SgfVectXofs=0;
469 long SgfVectYofs=0;
470 long SgfVectXmul=0;
471 long SgfVectYmul=0;
472 long SgfVectXdiv=0;
473 long SgfVectYdiv=0;
474 BOOL SgfVectScal=FALSE;
476 ////////////////////////////////////////////////////////////
477 // Hpgl2SvFarbe ////////////////////////////////////////////
478 ////////////////////////////////////////////////////////////
480 Color Hpgl2SvFarbe( BYTE nFarb )
482 ULONG nColor = COL_BLACK;
484 switch (nFarb & 0x07) {
485 case 0: nColor=COL_WHITE; break;
486 case 1: nColor=COL_YELLOW; break;
487 case 2: nColor=COL_LIGHTMAGENTA; break;
488 case 3: nColor=COL_LIGHTRED; break;
489 case 4: nColor=COL_LIGHTCYAN; break;
490 case 5: nColor=COL_LIGHTGREEN; break;
491 case 6: nColor=COL_LIGHTBLUE; break;
492 case 7: nColor=COL_BLACK; break;
494 Color aColor( nColor );
495 return aColor;
498 /*************************************************************************
500 |* SgfFilterVect()
502 |* Beschreibung
503 |* Ersterstellung JOE 23.06.93
504 |* Letzte Aenderung JOE 23.06.93
506 *************************************************************************/
507 BOOL SgfFilterVect(SvStream& rInp, SgfHeader& rHead, SgfEntry&, GDIMetaFile& rMtf)
509 VirtualDevice aOutDev;
510 SgfVector aVect;
511 BYTE nFarb;
512 BYTE nFrb0=7;
513 BYTE nLTyp;
514 BYTE nOTyp;
515 BOOL bEoDt=FALSE;
516 BOOL bPDwn=FALSE;
517 Point aP0(0,0);
518 Point aP1(0,0);
519 String Msg;
520 USHORT RecNr=0;
522 rMtf.Record(&aOutDev);
523 aOutDev.SetLineColor(Color(COL_BLACK));
524 aOutDev.SetFillColor(Color(COL_BLACK));
526 while (!bEoDt && !rInp.GetError()) {
527 rInp>>aVect; RecNr++;
528 nFarb=(BYTE) (aVect.Flag & 0x000F);
529 nLTyp=(BYTE)((aVect.Flag & 0x00F0) >>4);
530 nOTyp=(BYTE)((aVect.Flag & 0x0F00) >>8);
531 bEoDt=(aVect.Flag & 0x4000) !=0;
532 bPDwn=(aVect.Flag & 0x8000) !=0;
534 long x=aVect.x-rHead.Xoffs;
535 long y=rHead.Ysize-(aVect.y-rHead.Yoffs);
536 if (SgfVectScal) {
537 if (SgfVectXdiv==0) SgfVectXdiv=rHead.Xsize;
538 if (SgfVectYdiv==0) SgfVectYdiv=rHead.Ysize;
539 if (SgfVectXdiv==0) SgfVectXdiv=1;
540 if (SgfVectYdiv==0) SgfVectYdiv=1;
541 x=SgfVectXofs+ x *SgfVectXmul /SgfVectXdiv;
542 y=SgfVectYofs+ y *SgfVectXmul /SgfVectYdiv;
544 aP1=Point(x,y);
545 if (!bEoDt && !rInp.GetError()) {
546 if (bPDwn && nLTyp<=6) {
547 switch(nOTyp) {
548 case 1: if (nFarb!=nFrb0) {
549 switch(rHead.SwGrCol) {
550 case SgfVectFarb: aOutDev.SetLineColor(Hpgl2SvFarbe(nFarb)); break;
551 case SgfVectGray: break;
552 case SgfVectWdth: break;
555 aOutDev.DrawLine(aP0,aP1); break; // Linie
556 case 2: break; // Kreis
557 case 3: break; // Text
558 case 5: aOutDev.DrawRect(Rectangle(aP0,aP1)); break; // Rechteck (solid)
561 aP0=aP1;
562 nFrb0=nFarb;
565 rMtf.Stop();
566 rMtf.WindStart();
567 MapMode aMap( MAP_10TH_MM, Point(),
568 Fraction( 1, 4 ), Fraction( 1, 4 ) );
569 rMtf.SetPrefMapMode( aMap );
570 rMtf.SetPrefSize( Size( (short)rHead.Xsize, (short)rHead.Ysize ) );
571 return TRUE;
575 /*************************************************************************
577 |* SgfVectFilter()
579 |* Beschreibung
580 |* Ersterstellung JOE 23.06.93
581 |* Letzte Aenderung JOE 23.06.93
583 *************************************************************************/
584 BOOL SgfVectFilter(SvStream& rInp, GDIMetaFile& rMtf)
586 ULONG nFileStart; // Offset des SgfHeaders. Im allgemeinen 0.
587 SgfHeader aHead;
588 SgfEntry aEntr;
589 ULONG nNext;
590 BOOL bRdFlag=FALSE; // Grafikentry gelesen ?
591 BOOL bRet=FALSE; // Returncode
593 nFileStart=rInp.Tell();
594 rInp>>aHead;
595 if (aHead.ChkMagic() && aHead.Typ==SGF_SIMPVECT) {
596 nNext=aHead.GetOffset();
597 while (nNext && !bRdFlag && !rInp.GetError()) {
598 rInp.Seek(nFileStart+nNext);
599 rInp>>aEntr;
600 nNext=aEntr.GetOffset();
601 if (aEntr.Typ==aHead.Typ) {
602 bRet=SgfFilterVect(rInp,aHead,aEntr,rMtf);
604 } // while(nNext)
605 if (bRdFlag) {
606 if (!rInp.GetError()) bRet=TRUE; // Scheinbar Ok
609 return(bRet);
613 /*************************************************************************
615 |* SgfFilterPScr()
617 |* Beschreibung
618 |* Ersterstellung JOE 23.06.93
619 |* Letzte Aenderung JOE 23.06.93
621 *************************************************************************/
622 BOOL SgfFilterPScr(SvStream&, SgfHeader&, SgfEntry&)
624 return FALSE; // PostSrcipt wird noch nicht unterstuetzt !
628 /*************************************************************************
630 |* CheckSgfTyp()
632 |* Beschreibung Feststellen, um was fuer ein SGF/SGV es sich handelt.
633 |* Ersterstellung JOE 23.06.93
634 |* Letzte Aenderung JOE 23.06.93
636 *************************************************************************/
637 BYTE CheckSgfTyp(SvStream& rInp, USHORT& nVersion)
639 #if OSL_DEBUG_LEVEL > 1 // Recordgroessen checken. Neuer Compiler hat vielleichte anderes Allignment!
640 if (sizeof(SgfHeader)!=SgfHeaderSize ||
641 sizeof(SgfEntry) !=SgfEntrySize ||
642 sizeof(SgfVector)!=SgfVectorSize ||
643 sizeof(BmpFileHeader)!=BmpFileHeaderSize ||
644 sizeof(BmpInfoHeader)!=BmpInfoHeaderSize ||
645 sizeof(RGBQuad )!=RGBQuadSize ) return SGF_DONTKNOW;
646 #endif
648 ULONG nPos;
649 SgfHeader aHead;
650 nVersion=0;
651 nPos=rInp.Tell();
652 rInp>>aHead;
653 rInp.Seek(nPos);
654 if (aHead.ChkMagic()) {
655 nVersion=aHead.Version;
656 switch(aHead.Typ) {
657 case SgfBitImag0:
658 case SgfBitImag1:
659 case SgfBitImag2:
660 case SgfBitImgMo: return SGF_BITIMAGE;
661 case SgfSimpVect: return SGF_SIMPVECT;
662 case SgfPostScrp: return SGF_POSTSCRP;
663 case SgfStarDraw: return SGF_STARDRAW;
664 default : return SGF_DONTKNOW;
666 } else {
667 return SGF_DONTKNOW;