1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: sgvmain.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svtools.hxx"
34 #include <rtl/math.hxx>
35 #include <osl/endian.h>
36 #include <vcl/graph.hxx>
37 #include <tools/poly.hxx>
38 #include <svtools/filter.hxx>
39 #include "sgffilt.hxx"
40 #include "sgfbram.hxx"
41 #include "sgvmain.hxx"
42 #include "sgvspln.hxx"
43 #include <unotools/ucbstreamhelper.hxx>
45 //#if OSL_DEBUG_LEVEL > 1
49 #define SWAPPOINT(p) { \
53 #define SWAPPAGE(p) { \
54 p.Next =SWAPLONG (p.Next ); \
55 p.nList =SWAPLONG (p.nList ); \
56 p.ListEnd=SWAPLONG (p.ListEnd); \
57 p.Paper.Size.x=SWAPSHORT(p.Paper.Size.x); \
58 p.Paper.Size.y=SWAPSHORT(p.Paper.Size.y); \
59 p.Paper.RandL =SWAPSHORT(p.Paper.RandL ); \
60 p.Paper.RandR =SWAPSHORT(p.Paper.RandR ); \
61 p.Paper.RandO =SWAPSHORT(p.Paper.RandO ); \
62 p.Paper.RandU =SWAPSHORT(p.Paper.RandU ); \
65 for (iTemp=0;iTemp<20;iTemp++) { \
66 rPage.HlpLnH[iTemp]=SWAPSHORT(rPage.HlpLnH[iTemp]); \
67 rPage.HlpLnV[iTemp]=SWAPSHORT(rPage.HlpLnV[iTemp]); }}
69 #define SWAPOBJK(o) { \
70 o.Last =SWAPLONG (o.Last ); \
71 o.Next =SWAPLONG (o.Next ); \
72 o.MemSize =SWAPSHORT(o.MemSize ); \
73 SWAPPOINT(o.ObjMin); \
74 SWAPPOINT(o.ObjMax); }
76 #define SWAPLINE(l) { \
77 l.LMSize=SWAPSHORT(l.LMSize); \
78 l.LDicke=SWAPSHORT(l.LDicke); }
80 #define SWAPAREA(a) { \
81 a.FDummy2=SWAPSHORT(a.FDummy2); \
82 a.FMuster=SWAPSHORT(a.FMuster); }
84 #define SWAPTEXT(t) { \
87 t.FontLo =SWAPSHORT(t.FontLo ); \
88 t.FontHi =SWAPSHORT(t.FontHi ); \
89 t.Grad =SWAPSHORT(t.Grad ); \
90 t.Breite =SWAPSHORT(t.Breite ); \
91 t.Schnitt=SWAPSHORT(t.Schnitt); \
92 t.LnFeed =SWAPSHORT(t.LnFeed ); \
93 t.Slant =SWAPSHORT(t.Slant ); \
96 SWAPPOINT(t.ShdVers); \
100 ////////////////////////////////////////////////////////////////////////////////////////////////////
104 // - Flaechenmuster werden den unter StarView verfuegbaren Mustern angenaehert.
105 // - Linienenden werden unter StarView immer rund dargestellt und gehen ueber
106 // den Endpunkt der Linie hinaus.
107 // - Linienmuster werden den unter StarView verfuegbaren Mustern angenaehert.
108 // Transparent/Opak wird zur Zeit noch nicht beruecksichtigt.
109 // - Keine gedrehten Ellipsen
114 ////////////////////////////////////////////////////////////////////////////////////////////////////
116 #if defined( WIN ) && defined( MSC )
117 #pragma code_seg( "svtools", "AUTO_CODE" )
120 ////////////////////////////////////////////////////////////////////////////////////////////////////
121 // Fuer Fontuebersetzung ///////////////////////////////////////////////////////////////////////////
122 ////////////////////////////////////////////////////////////////////////////////////////////////////
123 SgfFontLst
* pSgfFonts
= 0;
125 #if defined( WIN ) && defined( MSC )
126 #pragma code_seg( "SVTOOLS_FILTER3", "SVTOOLS_CODE" )
127 static void AntiMscBug() {}
130 ////////////////////////////////////////////////////////////////////////////////////////////////////
131 // Fuer Kreisunterarten, Text und gedrehte Rechtecke ///////////////////////////////////////////////
132 ////////////////////////////////////////////////////////////////////////////////////////////////////
133 void RotatePoint(PointType
& P
, INT16 cx
, INT16 cy
, double sn
, double cs
)
145 void RotatePoint(Point
& P
, INT16 cx
, INT16 cy
, double sn
, double cs
)
149 dx
=(INT16
)(P
.X()-cx
);
150 dy
=(INT16
)(P
.Y()-cy
);
153 P
=Point(cx
+INT16(x1
),cy
+INT16(y1
));
156 INT16
iMulDiv(INT16 a
, INT16 Mul
, INT16 Div
)
159 Temp
=INT32(a
)*INT32(Mul
)/INT32(Div
);
163 UINT16
MulDiv(UINT16 a
, UINT16 Mul
, UINT16 Div
)
166 Temp
=UINT32(a
)*UINT32(Mul
)/UINT32(Div
);
170 ////////////////////////////////////////////////////////////////////////////////////////////////////
171 // SgfFilterSDrw ///////////////////////////////////////////////////////////////////////////////////
172 ////////////////////////////////////////////////////////////////////////////////////////////////////
174 SvStream
& operator>>(SvStream
& rIStream
, DtHdType
& rDtHd
)
176 rIStream
.Read((char*)&rDtHd
.Reserved
[0],DtHdSize
);
180 void DtHdOverSeek(SvStream
& rInp
)
182 ULONG FPos
=rInp
.Tell();
183 FPos
+=(ULONG
)DtHdSize
;
185 // rInp.seekg(rInp.tellg()+(ULONG)DtHdSize);
189 SvStream
& operator>>(SvStream
& rIStream
, PageType
& rPage
)
191 rIStream
.Read((char*)&rPage
.Next
,PageSize
);
192 #if defined OSL_BIGENDIAN
198 void ObjkOverSeek(SvStream
& rInp
, ObjkType
& rObjk
)
201 Siz
=(ULONG
)rObjk
.MemSize
+rObjk
.Last
; // ObjSize+ObjAnhSize
202 rInp
.Seek(rInp
.Tell()+Siz
);
205 SvStream
& operator>>(SvStream
& rInp
, ObjkType
& rObjk
)
206 { // Die Fileposition im Stream bleibt unveraendert!
209 rInp
.Read((char*)&rObjk
.Last
,ObjkSize
);
210 #if defined OSL_BIGENDIAN
214 ULONG nPos1
=rInp
.Tell();
215 if(nPos
== nPos1
) InfoBox( NULL
, "tellg funkt nich" ).Execute();
219 if (rInp
.Tell() != nPos
) InfoBox( NULL
, "seekg funkt nich" ).Execute();
223 SvStream
& operator>>(SvStream
& rInp
, StrkType
& rStrk
)
225 rInp
.Read((char*)&rStrk
.Last
,StrkSize
);
226 #if defined OSL_BIGENDIAN
229 SWAPPOINT(rStrk
.Pos1
);
230 SWAPPOINT(rStrk
.Pos2
);
234 SvStream
& operator>>(SvStream
& rInp
, RectType
& rRect
)
236 rInp
.Read((char*)&rRect
.Last
,RectSize
);
237 #if defined OSL_BIGENDIAN
241 SWAPPOINT(rRect
.Pos1
);
242 SWAPPOINT(rRect
.Pos2
);
243 rRect
.Radius
=SWAPSHORT(rRect
.Radius
);
244 rRect
.DrehWink
=SWAPSHORT(rRect
.DrehWink
);
245 rRect
.Slant
=SWAPSHORT(rRect
.Slant
);
249 SvStream
& operator>>(SvStream
& rInp
, PolyType
& rPoly
)
251 rInp
.Read((char*)&rPoly
.Last
,PolySize
);
252 #if defined OSL_BIGENDIAN
256 // rPoly.EckP=SWAPLONG(rPoly.EckP);
260 SvStream
& operator>>(SvStream
& rInp
, SplnType
& rSpln
)
262 rInp
.Read((char*)&rSpln
.Last
,SplnSize
);
263 #if defined OSL_BIGENDIAN
267 // rSpln.EckP=SWAPLONG(rSpln.EckP);
271 SvStream
& operator>>(SvStream
& rInp
, CircType
& rCirc
)
273 rInp
.Read((char*)&rCirc
.Last
,CircSize
);
274 #if defined OSL_BIGENDIAN
278 SWAPPOINT(rCirc
.Radius
);
279 SWAPPOINT(rCirc
.Center
);
280 rCirc
.DrehWink
=SWAPSHORT(rCirc
.DrehWink
);
281 rCirc
.StartWink
=SWAPSHORT(rCirc
.StartWink
);
282 rCirc
.RelWink
=SWAPSHORT(rCirc
.RelWink
);
286 SvStream
& operator>>(SvStream
& rInp
, TextType
& rText
)
288 rInp
.Read((char*)&rText
.Last
,TextSize
);
289 #if defined OSL_BIGENDIAN
292 SWAPPOINT(rText
.Pos1
);
293 SWAPPOINT(rText
.Pos2
);
294 rText
.TopOfs
=SWAPSHORT(rText
.TopOfs
);
295 rText
.DrehWink
=SWAPSHORT(rText
.DrehWink
);
296 rText
.BoxSlant
=SWAPSHORT(rText
.BoxSlant
);
297 rText
.BufSize
=SWAPSHORT(rText
.BufSize
);
298 //rText.Buf =SWAPLONG (rText.Buf );
299 //rText.Ext =SWAPLONG (rText.Ext );
300 SWAPPOINT(rText
.FitSize
);
301 rText
.FitBreit
=SWAPSHORT(rText
.FitBreit
);
306 SvStream
& operator>>(SvStream
& rInp
, BmapType
& rBmap
)
308 rInp
.Read((char*)&rBmap
.Last
,BmapSize
);
309 #if defined OSL_BIGENDIAN
312 SWAPPOINT(rBmap
.Pos1
);
313 SWAPPOINT(rBmap
.Pos2
);
314 rBmap
.DrehWink
=SWAPSHORT(rBmap
.DrehWink
);
315 rBmap
.Slant
=SWAPSHORT(rBmap
.Slant
);
316 SWAPPOINT(rBmap
.PixSize
);
320 SvStream
& operator>>(SvStream
& rInp
, GrupType
& rGrup
)
322 rInp
.Read((char*)&rGrup
.Last
,GrupSize
);
323 #if defined OSL_BIGENDIAN
325 rGrup
.SbLo
=SWAPSHORT(rGrup
.SbLo
);
326 rGrup
.SbHi
=SWAPSHORT(rGrup
.SbHi
);
327 rGrup
.UpLo
=SWAPSHORT(rGrup
.UpLo
);
328 rGrup
.UpHi
=SWAPSHORT(rGrup
.UpHi
);
329 rGrup
.ChartSize
=SWAPSHORT(rGrup
.ChartSize
);
330 rGrup
.ChartPtr
=SWAPLONG (rGrup
.ChartPtr
);
337 /*************************************************************************
342 |* Ersterstellung JOE 23.06.93
343 |* Letzte Aenderung JOE 23.06.93
345 *************************************************************************/
346 Color
Sgv2SvFarbe(BYTE nFrb1
, BYTE nFrb2
, BYTE nInts
)
348 UINT16 r1
=0,g1
=0,b1
=0,r2
=0,g2
=0,b2
=0;
349 BYTE nInt2
=100-nInts
;
350 switch(nFrb1
& 0x07) {
351 case 0: r1
=0xFF; g1
=0xFF; b1
=0xFF; break;
352 case 1: r1
=0xFF; g1
=0xFF; break;
353 case 2: g1
=0xFF; b1
=0xFF; break;
354 case 3: g1
=0xFF; break;
355 case 4: r1
=0xFF; b1
=0xFF; break;
356 case 5: r1
=0xFF; break;
357 case 6: b1
=0xFF; break;
360 switch(nFrb2
& 0x07) {
361 case 0: r2
=0xFF; g2
=0xFF; b2
=0xFF; break;
362 case 1: r2
=0xFF; g2
=0xFF; break;
363 case 2: g2
=0xFF; b2
=0xFF; break;
364 case 3: g2
=0xFF; break;
365 case 4: r2
=0xFF; b2
=0xFF; break;
366 case 5: r2
=0xFF; break;
367 case 6: b2
=0xFF; break;
370 r1
=(UINT16
)((UINT32
)r1
*nInts
/100+(UINT32
)r2
*nInt2
/100);
371 g1
=(UINT16
)((UINT32
)g1
*nInts
/100+(UINT32
)g2
*nInt2
/100);
372 b1
=(UINT16
)((UINT32
)b1
*nInts
/100+(UINT32
)b2
*nInt2
/100);
373 Color
aColor( (sal_uInt8
)r1
, (sal_uInt8
)g1
, (sal_uInt8
)b1
);
377 void SetLine(ObjLineType
& rLine
, OutputDevice
& rOut
)
380 PenStyle aStyle=PEN_SOLID;
381 switch(rLine.LMuster & 0x07) {
382 case 0: aStyle=PEN_NULL; break;
383 case 1: aStyle=PEN_SOLID; break;
384 case 2: aStyle=PEN_DOT; break; // . . . . . . . . . . . . . .
385 case 3: aStyle=PEN_DASH; break; // __ __ __ __ __ __ __ __ __
386 case 4: aStyle=PEN_DASH; break; // ___ ___ ___ ___ ___ ___ ___
387 case 5: aStyle=PEN_DASHDOT; break; // __ . __ . __ . __ . __ . __
388 case 6: aStyle=PEN_DASHDOT; break; // __ _ __ _ __ _ __ _ __ _ __
389 case 7: aStyle=PEN_DASHDOT; break; // ___ _ _ ___ _ _ ___ _ _ ___
391 Pen aPen(Sgv2SvFarbe(rLine.LFarbe,rLine.LBFarbe,rLine.LIntens),rLine.LDicke,aStyle);
394 if( 0 == ( rLine
.LMuster
& 0x07 ) )
397 rOut
.SetLineColor( Sgv2SvFarbe(rLine
.LFarbe
,rLine
.LBFarbe
,rLine
.LIntens
) );
400 void SetArea(ObjAreaType
& rArea
, OutputDevice
& rOut
)
403 BrushStyle aStyle=BRUSH_SOLID;
404 switch(rArea.FMuster & 0x00FF) {
405 case 0: aStyle=BRUSH_NULL; break;
406 case 1: aStyle=BRUSH_SOLID; break;
407 case 2: case 4: case 6: case 8:
408 case 10: case 12: case 14: case 16:
409 case 43: case 45: aStyle=BRUSH_VERT; break;
410 case 3: case 5: case 7: case 9:
411 case 11: case 13: case 15: case 17:
412 case 42: case 44: aStyle=BRUSH_HORZ; break;
413 case 18: case 20: case 22: case 24:
414 case 26: case 28: case 30: case 32:
415 case 46: case 48: aStyle=BRUSH_UPDIAG; break;
416 case 19: case 21: case 23: case 25:
417 case 27: case 29: case 31: case 33:
418 case 47: case 49: aStyle=BRUSH_DOWNDIAG; break;
419 case 34: case 35: case 36: case 37: aStyle=BRUSH_CROSS; break;
420 case 38: case 39: case 40: case 41: aStyle=BRUSH_DIAGCROSS; break;
421 default: aStyle=BRUSH_DIAGCROSS; break;
423 Brush aBrush(Sgv2SvFarbe(rArea.FFarbe,rArea.FBFarbe,rArea.FIntens),aStyle);
424 aBrush.SetTransparent((rArea.FMuster & 0x80) !=0L);
425 SetBrush(aBrush,rOut);
427 if( 0 == ( rArea
.FMuster
& 0x00FF ) )
430 rOut
.SetFillColor( Sgv2SvFarbe( rArea
.FFarbe
,rArea
.FBFarbe
,rArea
.FIntens
) );
433 /*************************************************************************
435 |* ObjkType::DrawObjekt()
438 |* Ersterstellung JOE 23.06.93
439 |* Letzte Aenderung JOE 23.06.93
441 *************************************************************************/
442 void ObjkType::Draw(OutputDevice
&)
444 // ShowSDObjk(*this);
447 void Obj0Type::Draw(OutputDevice
&) {}
449 /*************************************************************************
451 |* StrkType::DrawObjekt()
454 |* Ersterstellung JOE 23.06.93
455 |* Letzte Aenderung JOE 23.06.93
457 *************************************************************************/
458 void StrkType::Draw(OutputDevice
& rOut
)
461 rOut
.DrawLine(Point(Pos1
.x
,Pos1
.y
),Point(Pos2
.x
,Pos2
.y
)); // !!!
464 /*************************************************************************
466 |* RectType::DrawObjekt()
469 |* Ersterstellung JOE 23.06.93
470 |* Letzte Aenderung JOE 23.06.93
472 *************************************************************************/
473 void SgfAreaColorIntens(UINT16 Muster
, BYTE Col1
, BYTE Col2
, BYTE Int
, OutputDevice
& rOut
)
483 void DrawSlideRect(INT16 x1
, INT16 y1
, INT16 x2
, INT16 y2
, ObjAreaType
& F
, OutputDevice
& rOut
)
488 // ClipMerk: HgdClipRec;
494 if (x1
>x2
) { i
=x1
; x1
=x2
; x2
=i
; }
495 if (y1
>y2
) { i
=y1
; y1
=y2
; y2
=i
; }
496 Col1
=F
.FBFarbe
& 0x87; Col2
=F
.FFarbe
& 0x87;
497 Int1
=100-F
.FIntens
; Int2
=F
.FIntens
;
499 SgfAreaColorIntens(F
.FMuster
,(BYTE
)Col1
,(BYTE
)Col2
,(BYTE
)Int2
,rOut
);
500 rOut
.DrawRect(Rectangle(x1
,y1
,x2
,y2
));
503 switch (F
.FBFarbe
& 0x38) {
504 case 0x08: { // vertikal
508 b
=Int1
+INT16((INT32
)(Int2
-Int1
)*(INT32
)(i
-y1
) /(INT32
)(y2
-y1
+1));
510 SgfAreaColorIntens(F
.FMuster
,(BYTE
)Col1
,(BYTE
)Col2
,(BYTE
)b0
,rOut
);
511 rOut
.DrawRect(Rectangle(x1
,i0
,x2
,i
-1));
516 SgfAreaColorIntens(F
.FMuster
,(BYTE
)Col1
,(BYTE
)Col2
,(BYTE
)Int2
,rOut
);
517 rOut
.DrawRect(Rectangle(x1
,i0
,x2
,y2
));
519 case 0x28: { // horizontal
523 b
=Int1
+INT16((INT32
)(Int2
-Int1
)*(INT32
)(i
-x1
) /(INT32
)(x2
-x1
+1));
525 SgfAreaColorIntens(F
.FMuster
,(BYTE
)Col1
,(BYTE
)Col2
,(BYTE
)b0
,rOut
);
526 rOut
.DrawRect(Rectangle(i0
,y1
,i
-1,y2
));
531 SgfAreaColorIntens(F
.FMuster
,(BYTE
)Col1
,(BYTE
)Col2
,(BYTE
)Int2
,rOut
);
532 rOut
.DrawRect(Rectangle(i0
,y1
,x2
,y2
));
535 case 0x18: case 0x38: { // Kreis
536 Region ClipMerk
=rOut
.GetClipRegion();
539 rOut
.SetClipRegion(Region(Rectangle(x1
,y1
,x2
,y2
)));
544 a
=sqrt((double)(dx
*dx
+dy
*dy
));
547 i0
=MaxR
; if (MaxR
<1) MaxR
=1;
550 b
=Int1
+INT16((INT32(Int2
-Int1
)*INT32(i
)) /INT32(MaxR
));
552 SgfAreaColorIntens(F
.FMuster
,(BYTE
)Col1
,(BYTE
)Col2
,(BYTE
)b0
,rOut
);
553 //if (i0>200 || (Col1 & $80)!=0 || (Col2 & $80)!=0) {
554 // then begin { Fallunterscheidung fuer etwas bessere Performance }
558 // Circle(cx,cy,i0-s2,i0-s2);{}
560 rOut
.DrawEllipse(Rectangle(cx
-i0
,cy
-i0
,cx
+i0
,cy
+i0
));
565 SgfAreaColorIntens(F
.FMuster
,(BYTE
)Col1
,(BYTE
)Col2
,(BYTE
)Int1
,rOut
);
566 rOut
.DrawEllipse(Rectangle(cx
-i0
,cy
-i0
,cx
+i0
,cy
+i0
));
567 rOut
.SetClipRegion(ClipMerk
);
574 void RectType::Draw(OutputDevice
& rOut
)
576 if (L
.LMuster
!=0) L
.LMuster
=1; // keine Linienmuster hier, nur an oder aus
579 if ((F
.FBFarbe
& 0x38)==0 || Radius
!=0) {
581 rOut
.DrawRect(Rectangle(Pos1
.x
,Pos1
.y
,Pos2
.x
,Pos2
.y
),Radius
,Radius
);
583 DrawSlideRect(Pos1
.x
,Pos1
.y
,Pos2
.x
,Pos2
.y
,F
,rOut
);
587 rOut
.DrawRect(Rectangle(Pos1
.x
,Pos1
.y
,Pos2
.x
,Pos2
.y
));
594 sn
=sin(double(DrehWink
)*3.14159265359/18000);
595 cs
=cos(double(DrehWink
)*3.14159265359/18000);
596 aPts
[0]=Point(Pos1
.x
,Pos1
.y
);
597 aPts
[1]=Point(Pos2
.x
,Pos1
.y
);
598 aPts
[2]=Point(Pos2
.x
,Pos2
.y
);
599 aPts
[3]=Point(Pos1
.x
,Pos2
.y
);
601 RotatePoint(aPts
[i
],Pos1
.x
,Pos1
.y
,sn
,cs
);
604 Polygon
aPoly(4,aPts
);
605 rOut
.DrawPolygon(aPoly
);
609 /*************************************************************************
614 |* Ersterstellung JOE 23.06.93
615 |* Letzte Aenderung JOE 23.06.93
617 *************************************************************************/
618 void PolyType::Draw(OutputDevice
& rOut
)
620 if ((Flags
& PolyClosBit
) !=0) SetArea(F
,rOut
);
622 Polygon
aPoly(nPoints
);
624 for(i
=0;i
<nPoints
;i
++) aPoly
.SetPoint(Point(EckP
[i
].x
,EckP
[i
].y
),i
);
625 if ((Flags
& PolyClosBit
) !=0) {
626 rOut
.DrawPolygon(aPoly
);
628 rOut
.DrawPolyLine(aPoly
);
632 /*************************************************************************
637 |* Ersterstellung JOE 23.06.93
638 |* Letzte Aenderung JOE 23.06.93
640 *************************************************************************/
641 void SplnType::Draw(OutputDevice
& rOut
)
643 if ((Flags
& PolyClosBit
) !=0) SetArea(F
,rOut
);
646 Polygon
aSpln(nPoints
);
648 for(i
=0;i
<nPoints
;i
++) aSpln
.SetPoint(Point(EckP
[i
].x
,EckP
[i
].y
),i
);
649 if ((Flags
& PolyClosBit
) !=0) {
650 Spline2Poly(aSpln
,TRUE
,aPoly
);
651 if (aPoly
.GetSize()>0) rOut
.DrawPolygon(aPoly
);
653 Spline2Poly(aSpln
,FALSE
,aPoly
);
654 if (aPoly
.GetSize()>0) rOut
.DrawPolyLine(aPoly
);
658 /*************************************************************************
663 |* Ersterstellung JOE 23.06.93
664 |* Letzte Aenderung JOE 23.06.93
666 *************************************************************************/
667 void DrawSlideCirc(INT16 cx
, INT16 cy
, INT16 rx
, INT16 ry
, ObjAreaType
& F
, OutputDevice
& rOut
)
679 Col1
=F
.FBFarbe
& 0x87; Col2
=F
.FFarbe
& 0x87;
680 Int1
=100-F
.FIntens
; Int2
=F
.FIntens
;
682 SgfAreaColorIntens(F
.FMuster
,(BYTE
)Col1
,(BYTE
)Col2
,(BYTE
)Int2
,rOut
);
683 rOut
.DrawEllipse(Rectangle(x1
,y1
,x2
,y2
));
686 switch (F
.FBFarbe
& 0x38) {
687 case 0x08: { // vertikal
688 Region ClipMerk
=rOut
.GetClipRegion();
692 b
=Int1
+INT16((INT32
)(Int2
-Int1
)*(INT32
)(i
-y1
) /(INT32
)(y2
-y1
+1));
694 SgfAreaColorIntens(F
.FMuster
,(BYTE
)Col1
,(BYTE
)Col2
,(BYTE
)b0
,rOut
);
695 rOut
.SetClipRegion(Rectangle(x1
,i0
,x2
,i
-1));
696 rOut
.DrawEllipse(Rectangle(x1
,y1
,x2
,y2
));
701 SgfAreaColorIntens(F
.FMuster
,(BYTE
)Col1
,(BYTE
)Col2
,(BYTE
)Int2
,rOut
);
702 rOut
.SetClipRegion(Rectangle(x1
,i0
,x2
,y2
));
703 rOut
.DrawEllipse(Rectangle(x1
,y1
,x2
,y2
));
704 rOut
.SetClipRegion(ClipMerk
);
706 case 0x28: { // horizontal
707 Region ClipMerk
=rOut
.GetClipRegion();
711 b
=Int1
+INT16((INT32
)(Int2
-Int1
)*(INT32
)(i
-x1
) /(INT32
)(x2
-x1
+1));
713 SgfAreaColorIntens(F
.FMuster
,(BYTE
)Col1
,(BYTE
)Col2
,(BYTE
)b0
,rOut
);
714 rOut
.SetClipRegion(Rectangle(i0
,y1
,i
-1,y2
));
715 rOut
.DrawEllipse(Rectangle(x1
,y1
,x2
,y2
));
720 SgfAreaColorIntens(F
.FMuster
,(BYTE
)Col1
,(BYTE
)Col2
,(BYTE
)Int2
,rOut
);
721 rOut
.SetClipRegion(Rectangle(i0
,y1
,x2
,y2
));
722 rOut
.DrawEllipse(Rectangle(x1
,y1
,x2
,y2
));
723 rOut
.SetClipRegion(ClipMerk
);
726 case 0x18: case 0x38: { // Kreis
733 i0
=MaxR
; if (MaxR
<1) MaxR
=1;
736 b
=Int1
+INT16((INT32(Int2
-Int1
)*INT32(i
)) /INT32(MaxR
));
738 INT32 temp
=INT32(i0
)*INT32(ry
)/INT32(rx
);
739 INT16 j0
=INT16(temp
);
740 SgfAreaColorIntens(F
.FMuster
,(BYTE
)Col1
,(BYTE
)Col2
,(BYTE
)b0
,rOut
);
741 rOut
.DrawEllipse(Rectangle(cx
-i0
,cy
-j0
,cx
+i0
,cy
+j0
));
746 SgfAreaColorIntens(F
.FMuster
,(BYTE
)Col1
,(BYTE
)Col2
,(BYTE
)Int1
,rOut
);
747 rOut
.DrawEllipse(Rectangle(cx
-i0
,cy
-i0
,cx
+i0
,cy
+i0
));
754 void CircType::Draw(OutputDevice
& rOut
)
756 Rectangle
aRect(Center
.x
-Radius
.x
,Center
.y
-Radius
.y
,Center
.x
+Radius
.x
,Center
.y
+Radius
.y
);
758 if (L
.LMuster
!=0) L
.LMuster
=1; // keine Linienmuster hier, nur an oder aus
760 if ((Flags
& 0x03)==CircFull
) {
761 if ((F
.FBFarbe
& 0x38)==0) {
763 rOut
.DrawEllipse(aRect
);
765 DrawSlideCirc(Center
.x
,Center
.y
,Radius
.x
,Radius
.y
,F
,rOut
);
769 rOut
.DrawEllipse(aRect
);
777 a
.x
=Center
.x
+Radius
.x
; a
.y
=Center
.y
; b
=a
;
778 sn
=sin(double(StartWink
)*3.14159265359/18000);
779 cs
=cos(double(StartWink
)*3.14159265359/18000);
780 RotatePoint(a
,Center
.x
,Center
.y
,sn
,cs
);
781 sn
=sin(double(StartWink
+RelWink
)*3.14159265359/18000);
782 cs
=cos(double(StartWink
+RelWink
)*3.14159265359/18000);
783 RotatePoint(b
,Center
.x
,Center
.y
,sn
,cs
);
784 if (Radius
.x
!=Radius
.y
) {
785 if (Radius
.x
<1) Radius
.x
=1;
786 if (Radius
.y
<1) Radius
.y
=1;
787 a
.y
= a
.y
- Center
.y
;
788 b
.y
= b
.y
- Center
.y
;
789 a
.y
=iMulDiv(a
.y
,Radius
.y
,Radius
.x
);
790 b
.y
=iMulDiv(b
.y
,Radius
.y
,Radius
.x
);
791 a
.y
= a
.y
+ Center
.y
;
792 b
.y
= b
.y
+ Center
.y
;
794 aStrt
=Point(a
.x
,a
.y
);
795 aEnde
=Point(b
.x
,b
.y
);
797 switch (Flags
& 0x03) {
798 case CircArc
: rOut
.DrawArc(aRect
,aEnde
,aStrt
); break;
800 case CircAbsn
: rOut
.DrawPie(aRect
,aEnde
,aStrt
); break;
805 /*************************************************************************
810 |* Ersterstellung JOE 23.06.93
811 |* Letzte Aenderung JOE 23.06.93
813 *************************************************************************/
815 void BmapType::Draw(OutputDevice
& rOut
)
818 unsigned char nSgfTyp
;
821 reinterpret_cast< char const * >(&Filename
[ 1 ]),
822 (xub_StrLen
)Filename
[ 0 ], RTL_TEXTENCODING_UTF8
);
823 INetURLObject
aFNam( aStr
);
825 SvStream
* pInp
= ::utl::UcbStreamHelper::CreateStream( aFNam
.GetMainURL( INetURLObject::NO_DECODE
), STREAM_READ
);
828 nSgfTyp
=CheckSgfTyp( *pInp
,nVersion
);
834 nRet
=aFlt
.ImportGraphic(aGrf
,aFNam
);
835 aGrf
.Draw(&rOut
,Point(Pos1
.x
,Pos1
.y
),Size(Pos2
.x
-Pos1
.x
,Pos2
.y
-Pos1
.y
));
841 SgfVectXmul
=Pos2
.x
-Pos1
.x
;
842 SgfVectYmul
=Pos2
.y
-Pos1
.y
;
846 SgfVectFilter(*pInp
,aMtf
);
862 /*************************************************************************
867 |* Ersterstellung JOE 23.06.93
868 |* Letzte Aenderung JOE 23.06.93
870 *************************************************************************/
871 UINT32
GrupType::GetSubPtr()
873 return UINT32(SbLo
)+0x00010000*UINT32(SbHi
);
876 /*************************************************************************
881 |* Ersterstellung JOE 23.06.93
882 |* Letzte Aenderung JOE 23.06.93
884 *************************************************************************/
885 void DrawObjkList( SvStream
& rInp
, OutputDevice
& rOut
)
892 if (!rInp
.GetError()) {
894 case ObjStrk
: { StrkType aStrk
; rInp
>>aStrk
; if (!rInp
.GetError()) aStrk
.Draw(rOut
); } break;
895 case ObjRect
: { RectType aRect
; rInp
>>aRect
; if (!rInp
.GetError()) aRect
.Draw(rOut
); } break;
896 case ObjCirc
: { CircType aCirc
; rInp
>>aCirc
; if (!rInp
.GetError()) aCirc
.Draw(rOut
); } break;
900 if (!rInp
.GetError()) {
901 aText
.Buffer
=new UCHAR
[aText
.BufSize
+1]; // Ein mehr fuer LookAhead bei CK-Trennung
902 rInp
.Read((char* )aText
.Buffer
,aText
.BufSize
);
903 if (!rInp
.GetError()) aText
.Draw(rOut
);
904 delete[] aText
.Buffer
;
910 if (!rInp
.GetError()) {
917 if (!rInp
.GetError()) {
918 aPoly
.EckP
=new PointType
[aPoly
.nPoints
];
919 rInp
.Read((char*)aPoly
.EckP
,4*aPoly
.nPoints
);
920 #if defined OSL_BIGENDIAN
921 for(short i
=0;i
<aPoly
.nPoints
;i
++) SWAPPOINT(aPoly
.EckP
[i
]);
923 if (!rInp
.GetError()) aPoly
.Draw(rOut
);
930 if (!rInp
.GetError()) {
931 aSpln
.EckP
=new PointType
[aSpln
.nPoints
];
932 rInp
.Read((char*)aSpln
.EckP
,4*aSpln
.nPoints
);
933 #if defined OSL_BIGENDIAN
934 for(short i
=0;i
<aSpln
.nPoints
;i
++) SWAPPOINT(aSpln
.EckP
[i
]);
936 if (!rInp
.GetError()) aSpln
.Draw(rOut
);
943 if (!rInp
.GetError()) {
944 rInp
.Seek(rInp
.Tell()+aGrup
.Last
); // Obj-Anhaengsel
945 if(aGrup
.GetSubPtr()!=0L) nGrpCnt
++;// DrawObjkList(rInp,rOut );
949 aObjk
.Draw(rOut
); // Objektbezeichnung auf 2. Screen
950 ObjkOverSeek(rInp
,aObjk
); // zum naechsten Objekt
954 if (!rInp
.GetError()) {
955 if (aObjk
.Next
==0L) {
956 if (nGrpCnt
==0) bEnde
=TRUE
;
960 bEnde
=TRUE
; // Lesefehler
965 /*************************************************************************
970 |* Ersterstellung JOE 23.06.93
971 |* Letzte Aenderung JOE 23.06.93
973 *************************************************************************/
974 void SkipObjkList(SvStream
& rInp
)
980 if(aObjk
.Art
==ObjGrup
) {
983 rInp
.Seek(rInp
.Tell()+aGrup
.Last
); // Obj-Anhaengsel
984 if(aGrup
.GetSubPtr()!=0L) SkipObjkList(rInp
);
986 ObjkOverSeek(rInp
,aObjk
); // zum naechsten Objekt
988 } while (aObjk
.Next
!=0L && !rInp
.GetError());
991 /*************************************************************************
996 |* Ersterstellung JOE 23.06.93
997 |* Letzte Aenderung JOE 23.06.93
999 *************************************************************************/
1000 BOOL
SgfFilterSDrw( SvStream
& rInp
, SgfHeader
&, SgfEntry
&, GDIMetaFile
& rMtf
)
1004 VirtualDevice aOutDev
;
1005 OutputDevice
* pOutDev
;
1011 DtHdOverSeek(rInp
); // DataHeader weglesen
1013 nStdPos
=rInp
.Tell();
1014 do { // Standardseiten weglesen
1016 if (aPage
.nList
!=0) SkipObjkList(rInp
);
1017 } while (aPage
.Next
!=0L && !rInp
.GetError());
1019 // ShowMsg("Zeichnungseite(n)\n");
1020 nZchPos
=rInp
.Tell();
1023 rMtf
.Record(pOutDev
);
1027 while(Num
>1 && aPage
.Next
!=0L && !rInp
.GetError()) { // Standardseite suchen
1029 if (aPage
.nList
!=0) SkipObjkList(rInp
);
1033 if(Num
==1 && aPage
.nList
!=0L) DrawObjkList( rInp
,*pOutDev
);
1035 nZchPos
=rInp
.Tell();
1038 if (aPage
.nList
!=0L) DrawObjkList(rInp
,*pOutDev
);
1042 MapMode
aMap(MAP_10TH_MM
,Point(),Fraction(1,4),Fraction(1,4));
1043 rMtf
.SetPrefMapMode(aMap
);
1044 rMtf
.SetPrefSize(Size((INT16
)aPage
.Paper
.Size
.x
,(INT16
)aPage
.Paper
.Size
.y
));
1051 /*************************************************************************
1056 |* Ersterstellung JOE 23.06.93
1057 |* Letzte Aenderung JOE 23.06.93
1059 *************************************************************************/
1060 BOOL
SgfSDrwFilter(SvStream
& rInp
, GDIMetaFile
& rMtf
, INetURLObject aIniPath
)
1062 #if OSL_DEBUG_LEVEL > 1 // Recordgroessen checken. Neuer Compiler hat vielleichte anderes Alignment!
1063 if (sizeof(ObjTextType
)!=ObjTextTypeSize
) return FALSE
;
1066 ULONG nFileStart
; // Offset des SgfHeaders. Im allgemeinen 0.
1070 BOOL bRdFlag
=FALSE
; // Grafikentry gelesen ?
1071 BOOL bRet
=FALSE
; // Returncode
1073 aIniPath
.Append( String::CreateFromAscii( "sgf.ini", 7 ) );
1074 // aIniPath.ToAbs();
1076 pSgfFonts
= new SgfFontLst
;
1078 pSgfFonts
->AssignFN( aIniPath
.GetMainURL( INetURLObject::NO_DECODE
) );
1079 nFileStart
=rInp
.Tell();
1081 if (aHead
.ChkMagic() && aHead
.Typ
==SgfStarDraw
&& aHead
.Version
==SGV_VERSION
) {
1082 nNext
=aHead
.GetOffset();
1083 while (nNext
&& !bRdFlag
&& !rInp
.GetError()) {
1084 rInp
.Seek(nFileStart
+nNext
);
1086 nNext
=aEntr
.GetOffset();
1087 if (aEntr
.Typ
==aHead
.Typ
) {
1088 bRet
=SgfFilterSDrw( rInp
,aHead
,aEntr
,rMtf
);
1092 if (!rInp
.GetError()) bRet
=TRUE
; // Scheinbar Ok
1100 Bitmap Dither(BYTE Intens)
1106 const dmatrix: array[0..7,0..7] of byte =
1107 (( 0, 48, 12, 60, 3, 51, 15, 63 ),
1108 ( 32, 16, 44, 28, 35, 19, 47, 31 ),
1109 ( 8, 56, 4, 52, 11, 59, 7, 55 ),
1110 ( 40, 24, 36, 20, 43, 27, 39, 23 ),
1111 ( 2, 50, 14, 62, 1, 49, 13, 61 ),
1112 ( 34, 18, 46, 30, 33, 17, 45, 29 ),
1113 ( 10, 58, 6, 54, 9, 57, 5, 53 ),
1114 ( 42, 26, 38, 22, 41, 25, 37, 21 ));
1117 cmatrix: array[0..7,0..7] of byte;
1118 dmatrixn,dmatrixi: array[0..7] of byte;
1121 procedure SetColorIntens(col0,col1,bal: integer);
1122 var cmatrix0: array[0..63] of byte absolute cmatrix;
1123 dmatrix0: array[0..63] of byte absolute dmatrix;
1127 if col0=col1 then bal:=0;
1130 plotcolor0:=col0 and $1F; plotcolor1:=col1 and $1F;
1135 plotcolor0:=col1 and $1F; plotcolor1:=col0 and $1F;
1139 if plotbal<=dmatrix0[n] then cmatrix0[n]:=col0 else cmatrix0[n]:=col1;
1143 #if defined( WIN ) && defined( MSC )
1144 #pragma code_seg( "svtools", "AUTO_CODE" )