1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <rtl/math.hxx>
22 #include <osl/endian.h>
23 #include <vcl/graph.hxx>
24 #include <tools/poly.hxx>
25 #include <vcl/graphicfilter.hxx>
26 #include "sgffilt.hxx"
27 #include "sgfbram.hxx"
28 #include "sgvmain.hxx"
29 #include "sgvspln.hxx"
30 #include <unotools/ucbstreamhelper.hxx>
32 #if defined OSL_BIGENDIAN
34 #define SWAPPOINT(p) { \
35 p.x=OSL_SWAPWORD(p.x); \
36 p.y=OSL_SWAPWORD(p.y); }
38 #define SWAPPAGE(p) { \
39 p.Next =OSL_SWAPDWORD (p.Next ); \
40 p.nList =OSL_SWAPDWORD (p.nList ); \
41 p.ListEnd=OSL_SWAPDWORD (p.ListEnd); \
42 p.Paper.Size.x=OSL_SWAPWORD(p.Paper.Size.x); \
43 p.Paper.Size.y=OSL_SWAPWORD(p.Paper.Size.y); \
44 p.Paper.RandL =OSL_SWAPWORD(p.Paper.RandL ); \
45 p.Paper.RandR =OSL_SWAPWORD(p.Paper.RandR ); \
46 p.Paper.RandO =OSL_SWAPWORD(p.Paper.RandO ); \
47 p.Paper.RandU =OSL_SWAPWORD(p.Paper.RandU ); \
50 for (iTemp=0;iTemp<20;iTemp++) { \
51 rPage.HlpLnH[iTemp]=OSL_SWAPWORD(rPage.HlpLnH[iTemp]); \
52 rPage.HlpLnV[iTemp]=OSL_SWAPWORD(rPage.HlpLnV[iTemp]); }}
54 #define SWAPOBJK(o) { \
55 o.Last =OSL_SWAPDWORD (o.Last ); \
56 o.Next =OSL_SWAPDWORD (o.Next ); \
57 o.MemSize =OSL_SWAPWORD(o.MemSize ); \
58 SWAPPOINT(o.ObjMin); \
59 SWAPPOINT(o.ObjMax); }
61 #define SWAPLINE(l) { \
62 l.LMSize=OSL_SWAPWORD(l.LMSize); \
63 l.LDicke=OSL_SWAPWORD(l.LDicke); }
65 #define SWAPAREA(a) { \
66 a.FDummy2=OSL_SWAPWORD(a.FDummy2); \
67 a.FMuster=OSL_SWAPWORD(a.FMuster); }
69 #define SWAPTEXT(t) { \
72 t.FontLo =OSL_SWAPWORD(t.FontLo ); \
73 t.FontHi =OSL_SWAPWORD(t.FontHi ); \
74 t.Grad =OSL_SWAPWORD(t.Grad ); \
75 t.Breite =OSL_SWAPWORD(t.Breite ); \
76 t.Schnitt=OSL_SWAPWORD(t.Schnitt); \
77 t.LnFeed =OSL_SWAPWORD(t.LnFeed ); \
78 t.Slant =OSL_SWAPWORD(t.Slant ); \
81 SWAPPOINT(t.ShdVers); \
86 ////////////////////////////////////////////////////////////////////////////////////////////////////
90 // - Flaechenmuster werden den unter StarView verfuegbaren Mustern angenaehert.
91 // - Linienenden werden unter StarView immer rund dargestellt und gehen ueber
92 // den Endpunkt der Linie hinaus.
93 // - Linienmuster werden den unter StarView verfuegbaren Mustern angenaehert.
94 // Transparent/Opak wird zur Zeit noch nicht beruecksichtigt.
95 // - Keine gedrehten Ellipsen
100 ////////////////////////////////////////////////////////////////////////////////////////////////////
102 ////////////////////////////////////////////////////////////////////////////////////////////////////
103 // Fuer Fontuebersetzung ///////////////////////////////////////////////////////////////////////////
104 ////////////////////////////////////////////////////////////////////////////////////////////////////
105 SgfFontLst
* pSgfFonts
= 0;
107 ////////////////////////////////////////////////////////////////////////////////////////////////////
108 // Fuer Kreisunterarten, Text und gedrehte Rechtecke ///////////////////////////////////////////////
109 ////////////////////////////////////////////////////////////////////////////////////////////////////
110 void RotatePoint(PointType
& P
, sal_Int16 cx
, sal_Int16 cy
, double sn
, double cs
)
118 P
.x
=cx
+sal_Int16(x1
);
119 P
.y
=cy
+sal_Int16(y1
);
122 void RotatePoint(Point
& P
, sal_Int16 cx
, sal_Int16 cy
, double sn
, double cs
)
126 dx
=(sal_Int16
)(P
.X()-cx
);
127 dy
=(sal_Int16
)(P
.Y()-cy
);
130 P
=Point(cx
+sal_Int16(x1
),cy
+sal_Int16(y1
));
133 sal_Int16
iMulDiv(sal_Int16 a
, sal_Int16 Mul
, sal_Int16 Div
)
136 Temp
=sal_Int32(a
)*sal_Int32(Mul
)/sal_Int32(Div
);
137 return sal_Int16(Temp
);
140 sal_uInt16
MulDiv(sal_uInt16 a
, sal_uInt16 Mul
, sal_uInt16 Div
)
143 Temp
=sal_uInt32(a
)*sal_uInt32(Mul
)/sal_uInt32(Div
);
144 return sal_uInt16(Temp
);
147 ////////////////////////////////////////////////////////////////////////////////////////////////////
148 // SgfFilterSDrw ///////////////////////////////////////////////////////////////////////////////////
149 ////////////////////////////////////////////////////////////////////////////////////////////////////
151 SvStream
& operator>>(SvStream
& rIStream
, DtHdType
& rDtHd
)
153 rIStream
.Read((char*)&rDtHd
.Reserved
[0],DtHdSize
);
157 void DtHdOverSeek(SvStream
& rInp
)
159 sal_uLong FPos
=rInp
.Tell();
160 FPos
+=(sal_uLong
)DtHdSize
;
165 SvStream
& operator>>(SvStream
& rIStream
, PageType
& rPage
)
167 rIStream
.Read((char*)&rPage
.Next
,PageSize
);
168 #if defined OSL_BIGENDIAN
174 void ObjkOverSeek(SvStream
& rInp
, ObjkType
& rObjk
)
177 Siz
=(sal_uLong
)rObjk
.MemSize
+rObjk
.Last
; // ObjSize+ObjAnhSize
178 rInp
.Seek(rInp
.Tell()+Siz
);
181 SvStream
& operator>>(SvStream
& rInp
, ObjkType
& rObjk
)
182 { // Die Fileposition im Stream bleibt unveraendert!
185 rInp
.Read((char*)&rObjk
.Last
,ObjkSize
);
186 #if defined OSL_BIGENDIAN
190 sal_uLong nPos1
=rInp
.Tell();
191 if(nPos
== nPos1
) InfoBox( NULL
, "tellg funkt nich" ).Execute();
195 if (rInp
.Tell() != nPos
) InfoBox( NULL
, "seekg funkt nich" ).Execute();
199 SvStream
& operator>>(SvStream
& rInp
, StrkType
& rStrk
)
201 rInp
.Read((char*)&rStrk
.Last
,StrkSize
);
202 #if defined OSL_BIGENDIAN
205 SWAPPOINT(rStrk
.Pos1
);
206 SWAPPOINT(rStrk
.Pos2
);
210 SvStream
& operator>>(SvStream
& rInp
, RectType
& rRect
)
212 rInp
.Read((char*)&rRect
.Last
,RectSize
);
213 #if defined OSL_BIGENDIAN
217 SWAPPOINT(rRect
.Pos1
);
218 SWAPPOINT(rRect
.Pos2
);
219 rRect
.Radius
=OSL_SWAPWORD(rRect
.Radius
);
220 rRect
.DrehWink
=OSL_SWAPWORD(rRect
.DrehWink
);
221 rRect
.Slant
=OSL_SWAPWORD(rRect
.Slant
);
225 SvStream
& operator>>(SvStream
& rInp
, PolyType
& rPoly
)
227 rInp
.Read((char*)&rPoly
.Last
,PolySize
);
228 #if defined OSL_BIGENDIAN
235 SvStream
& operator>>(SvStream
& rInp
, SplnType
& rSpln
)
237 rInp
.Read((char*)&rSpln
.Last
,SplnSize
);
238 #if defined OSL_BIGENDIAN
245 SvStream
& operator>>(SvStream
& rInp
, CircType
& rCirc
)
247 rInp
.Read((char*)&rCirc
.Last
,CircSize
);
248 #if defined OSL_BIGENDIAN
252 SWAPPOINT(rCirc
.Radius
);
253 SWAPPOINT(rCirc
.Center
);
254 rCirc
.DrehWink
=OSL_SWAPWORD(rCirc
.DrehWink
);
255 rCirc
.StartWink
=OSL_SWAPWORD(rCirc
.StartWink
);
256 rCirc
.RelWink
=OSL_SWAPWORD(rCirc
.RelWink
);
260 SvStream
& operator>>(SvStream
& rInp
, TextType
& rText
)
262 rInp
.Read((char*)&rText
.Last
,TextSize
);
263 #if defined OSL_BIGENDIAN
266 SWAPPOINT(rText
.Pos1
);
267 SWAPPOINT(rText
.Pos2
);
268 rText
.TopOfs
=OSL_SWAPWORD(rText
.TopOfs
);
269 rText
.DrehWink
=OSL_SWAPWORD(rText
.DrehWink
);
270 rText
.BoxSlant
=OSL_SWAPWORD(rText
.BoxSlant
);
271 rText
.BufSize
=OSL_SWAPWORD(rText
.BufSize
);
272 SWAPPOINT(rText
.FitSize
);
273 rText
.FitBreit
=OSL_SWAPWORD(rText
.FitBreit
);
278 SvStream
& operator>>(SvStream
& rInp
, BmapType
& rBmap
)
280 rInp
.Read((char*)&rBmap
.Last
,BmapSize
);
281 #if defined OSL_BIGENDIAN
284 SWAPPOINT(rBmap
.Pos1
);
285 SWAPPOINT(rBmap
.Pos2
);
286 rBmap
.DrehWink
=OSL_SWAPWORD(rBmap
.DrehWink
);
287 rBmap
.Slant
=OSL_SWAPWORD(rBmap
.Slant
);
288 SWAPPOINT(rBmap
.PixSize
);
292 SvStream
& operator>>(SvStream
& rInp
, GrupType
& rGrup
)
294 rInp
.Read((char*)&rGrup
.Last
,GrupSize
);
295 #if defined OSL_BIGENDIAN
297 rGrup
.SbLo
=OSL_SWAPWORD(rGrup
.SbLo
);
298 rGrup
.SbHi
=OSL_SWAPWORD(rGrup
.SbHi
);
299 rGrup
.UpLo
=OSL_SWAPWORD(rGrup
.UpLo
);
300 rGrup
.UpHi
=OSL_SWAPWORD(rGrup
.UpHi
);
301 rGrup
.ChartSize
=OSL_SWAPWORD(rGrup
.ChartSize
);
302 rGrup
.ChartPtr
=OSL_SWAPDWORD (rGrup
.ChartPtr
);
309 /*************************************************************************
313 *************************************************************************/
314 Color
Sgv2SvFarbe(sal_uInt8 nFrb1
, sal_uInt8 nFrb2
, sal_uInt8 nInts
)
316 sal_uInt16 r1
=0,g1
=0,b1
=0,r2
=0,g2
=0,b2
=0;
317 sal_uInt8 nInt2
=100-nInts
;
318 switch(nFrb1
& 0x07) {
319 case 0: r1
=0xFF; g1
=0xFF; b1
=0xFF; break;
320 case 1: r1
=0xFF; g1
=0xFF; break;
321 case 2: g1
=0xFF; b1
=0xFF; break;
322 case 3: g1
=0xFF; break;
323 case 4: r1
=0xFF; b1
=0xFF; break;
324 case 5: r1
=0xFF; break;
325 case 6: b1
=0xFF; break;
328 switch(nFrb2
& 0x07) {
329 case 0: r2
=0xFF; g2
=0xFF; b2
=0xFF; break;
330 case 1: r2
=0xFF; g2
=0xFF; break;
331 case 2: g2
=0xFF; b2
=0xFF; break;
332 case 3: g2
=0xFF; break;
333 case 4: r2
=0xFF; b2
=0xFF; break;
334 case 5: r2
=0xFF; break;
335 case 6: b2
=0xFF; break;
338 r1
=(sal_uInt16
)((sal_uInt32
)r1
*nInts
/100+(sal_uInt32
)r2
*nInt2
/100);
339 g1
=(sal_uInt16
)((sal_uInt32
)g1
*nInts
/100+(sal_uInt32
)g2
*nInt2
/100);
340 b1
=(sal_uInt16
)((sal_uInt32
)b1
*nInts
/100+(sal_uInt32
)b2
*nInt2
/100);
341 Color
aColor( (sal_uInt8
)r1
, (sal_uInt8
)g1
, (sal_uInt8
)b1
);
345 void SetLine(ObjLineType
& rLine
, OutputDevice
& rOut
)
347 if( 0 == ( rLine
.LMuster
& 0x07 ) )
350 rOut
.SetLineColor( Sgv2SvFarbe(rLine
.LFarbe
,rLine
.LBFarbe
,rLine
.LIntens
) );
353 void SetArea(ObjAreaType
& rArea
, OutputDevice
& rOut
)
355 if( 0 == ( rArea
.FMuster
& 0x00FF ) )
358 rOut
.SetFillColor( Sgv2SvFarbe( rArea
.FFarbe
,rArea
.FBFarbe
,rArea
.FIntens
) );
361 /*************************************************************************
363 |* ObjkType::DrawObjekt()
365 *************************************************************************/
366 void ObjkType::Draw(OutputDevice
&)
370 void Obj0Type::Draw(OutputDevice
&) {}
372 /*************************************************************************
374 |* StrkType::DrawObjekt()
376 *************************************************************************/
377 void StrkType::Draw(OutputDevice
& rOut
)
380 rOut
.DrawLine(Point(Pos1
.x
,Pos1
.y
),Point(Pos2
.x
,Pos2
.y
)); // !!!
383 /*************************************************************************
385 |* RectType::DrawObjekt()
387 *************************************************************************/
388 void SgfAreaColorIntens(sal_uInt16 Muster
, sal_uInt8 Col1
, sal_uInt8 Col2
, sal_uInt8 Int
, OutputDevice
& rOut
)
398 void DrawSlideRect(sal_Int16 x1
, sal_Int16 y1
, sal_Int16 x2
, sal_Int16 y2
, ObjAreaType
& F
, OutputDevice
& rOut
)
403 // ClipMerk: HgdClipRec;
409 if (x1
>x2
) { i
=x1
; x1
=x2
; x2
=i
; }
410 if (y1
>y2
) { i
=y1
; y1
=y2
; y2
=i
; }
411 Col1
=F
.FBFarbe
& 0x87; Col2
=F
.FFarbe
& 0x87;
412 Int1
=100-F
.FIntens
; Int2
=F
.FIntens
;
414 SgfAreaColorIntens(F
.FMuster
,(sal_uInt8
)Col1
,(sal_uInt8
)Col2
,(sal_uInt8
)Int2
,rOut
);
415 rOut
.DrawRect(Rectangle(x1
,y1
,x2
,y2
));
418 switch (F
.FBFarbe
& 0x38) {
419 case 0x08: { // vertikal
423 b
=Int1
+sal_Int16((sal_Int32
)(Int2
-Int1
)*(sal_Int32
)(i
-y1
) /(sal_Int32
)(y2
-y1
+1));
425 SgfAreaColorIntens(F
.FMuster
,(sal_uInt8
)Col1
,(sal_uInt8
)Col2
,(sal_uInt8
)b0
,rOut
);
426 rOut
.DrawRect(Rectangle(x1
,i0
,x2
,i
-1));
431 SgfAreaColorIntens(F
.FMuster
,(sal_uInt8
)Col1
,(sal_uInt8
)Col2
,(sal_uInt8
)Int2
,rOut
);
432 rOut
.DrawRect(Rectangle(x1
,i0
,x2
,y2
));
434 case 0x28: { // horizontal
438 b
=Int1
+sal_Int16((sal_Int32
)(Int2
-Int1
)*(sal_Int32
)(i
-x1
) /(sal_Int32
)(x2
-x1
+1));
440 SgfAreaColorIntens(F
.FMuster
,(sal_uInt8
)Col1
,(sal_uInt8
)Col2
,(sal_uInt8
)b0
,rOut
);
441 rOut
.DrawRect(Rectangle(i0
,y1
,i
-1,y2
));
446 SgfAreaColorIntens(F
.FMuster
,(sal_uInt8
)Col1
,(sal_uInt8
)Col2
,(sal_uInt8
)Int2
,rOut
);
447 rOut
.DrawRect(Rectangle(i0
,y1
,x2
,y2
));
450 case 0x18: case 0x38: { // Kreis
451 Region ClipMerk
=rOut
.GetClipRegion();
454 rOut
.SetClipRegion(Region(Rectangle(x1
,y1
,x2
,y2
)));
459 a
=sqrt((double)(dx
*dx
+dy
*dy
));
460 MaxR
=sal_Int16(a
) /2 +1;
462 i0
=MaxR
; if (MaxR
<1) MaxR
=1;
465 b
=Int1
+sal_Int16((sal_Int32(Int2
-Int1
)*sal_Int32(i
)) /sal_Int32(MaxR
));
467 SgfAreaColorIntens(F
.FMuster
,(sal_uInt8
)Col1
,(sal_uInt8
)Col2
,(sal_uInt8
)b0
,rOut
);
468 rOut
.DrawEllipse(Rectangle(cx
-i0
,cy
-i0
,cx
+i0
,cy
+i0
));
473 SgfAreaColorIntens(F
.FMuster
,(sal_uInt8
)Col1
,(sal_uInt8
)Col2
,(sal_uInt8
)Int1
,rOut
);
474 rOut
.DrawEllipse(Rectangle(cx
-i0
,cy
-i0
,cx
+i0
,cy
+i0
));
475 rOut
.SetClipRegion(ClipMerk
);
482 void RectType::Draw(OutputDevice
& rOut
)
484 if (L
.LMuster
!=0) L
.LMuster
=1; // keine Linienmuster hier, nur an oder aus
487 if ((F
.FBFarbe
& 0x38)==0 || Radius
!=0) {
489 rOut
.DrawRect(Rectangle(Pos1
.x
,Pos1
.y
,Pos2
.x
,Pos2
.y
),Radius
,Radius
);
491 DrawSlideRect(Pos1
.x
,Pos1
.y
,Pos2
.x
,Pos2
.y
,F
,rOut
);
495 rOut
.DrawRect(Rectangle(Pos1
.x
,Pos1
.y
,Pos2
.x
,Pos2
.y
));
502 sn
=sin(double(DrehWink
)*3.14159265359/18000);
503 cs
=cos(double(DrehWink
)*3.14159265359/18000);
504 aPts
[0]=Point(Pos1
.x
,Pos1
.y
);
505 aPts
[1]=Point(Pos2
.x
,Pos1
.y
);
506 aPts
[2]=Point(Pos2
.x
,Pos2
.y
);
507 aPts
[3]=Point(Pos1
.x
,Pos2
.y
);
509 RotatePoint(aPts
[i
],Pos1
.x
,Pos1
.y
,sn
,cs
);
512 Polygon
aPoly(4,aPts
);
513 rOut
.DrawPolygon(aPoly
);
517 /*************************************************************************
521 *************************************************************************/
522 void PolyType::Draw(OutputDevice
& rOut
)
524 if ((Flags
& PolyClosBit
) !=0) SetArea(F
,rOut
);
526 Polygon
aPoly(nPoints
);
528 for(i
=0;i
<nPoints
;i
++) aPoly
.SetPoint(Point(EckP
[i
].x
,EckP
[i
].y
),i
);
529 if ((Flags
& PolyClosBit
) !=0) {
530 rOut
.DrawPolygon(aPoly
);
532 rOut
.DrawPolyLine(aPoly
);
536 /*************************************************************************
540 *************************************************************************/
541 void SplnType::Draw(OutputDevice
& rOut
)
543 if ((Flags
& PolyClosBit
) !=0) SetArea(F
,rOut
);
546 Polygon
aSpln(nPoints
);
548 for(i
=0;i
<nPoints
;i
++) aSpln
.SetPoint(Point(EckP
[i
].x
,EckP
[i
].y
),i
);
549 if ((Flags
& PolyClosBit
) !=0) {
550 Spline2Poly(aSpln
,sal_True
,aPoly
);
551 if (aPoly
.GetSize()>0) rOut
.DrawPolygon(aPoly
);
553 Spline2Poly(aSpln
,sal_False
,aPoly
);
554 if (aPoly
.GetSize()>0) rOut
.DrawPolyLine(aPoly
);
558 /*************************************************************************
562 *************************************************************************/
563 void DrawSlideCirc(sal_Int16 cx
, sal_Int16 cy
, sal_Int16 rx
, sal_Int16 ry
, ObjAreaType
& F
, OutputDevice
& rOut
)
575 Col1
=F
.FBFarbe
& 0x87; Col2
=F
.FFarbe
& 0x87;
576 Int1
=100-F
.FIntens
; Int2
=F
.FIntens
;
578 SgfAreaColorIntens(F
.FMuster
,(sal_uInt8
)Col1
,(sal_uInt8
)Col2
,(sal_uInt8
)Int2
,rOut
);
579 rOut
.DrawEllipse(Rectangle(x1
,y1
,x2
,y2
));
582 switch (F
.FBFarbe
& 0x38) {
583 case 0x08: { // vertikal
584 Region ClipMerk
=rOut
.GetClipRegion();
588 b
=Int1
+sal_Int16((sal_Int32
)(Int2
-Int1
)*(sal_Int32
)(i
-y1
) /(sal_Int32
)(y2
-y1
+1));
590 SgfAreaColorIntens(F
.FMuster
,(sal_uInt8
)Col1
,(sal_uInt8
)Col2
,(sal_uInt8
)b0
,rOut
);
591 rOut
.SetClipRegion(Region(Rectangle(x1
,i0
,x2
,i
-1)));
592 rOut
.DrawEllipse(Rectangle(x1
,y1
,x2
,y2
));
597 SgfAreaColorIntens(F
.FMuster
,(sal_uInt8
)Col1
,(sal_uInt8
)Col2
,(sal_uInt8
)Int2
,rOut
);
598 rOut
.SetClipRegion(Region(Rectangle(x1
,i0
,x2
,y2
)));
599 rOut
.DrawEllipse(Rectangle(x1
,y1
,x2
,y2
));
600 rOut
.SetClipRegion(ClipMerk
);
602 case 0x28: { // horizontal
603 Region ClipMerk
=rOut
.GetClipRegion();
607 b
=Int1
+sal_Int16((sal_Int32
)(Int2
-Int1
)*(sal_Int32
)(i
-x1
) /(sal_Int32
)(x2
-x1
+1));
609 SgfAreaColorIntens(F
.FMuster
,(sal_uInt8
)Col1
,(sal_uInt8
)Col2
,(sal_uInt8
)b0
,rOut
);
610 rOut
.SetClipRegion(Region(Rectangle(i0
,y1
,i
-1,y2
)));
611 rOut
.DrawEllipse(Rectangle(x1
,y1
,x2
,y2
));
616 SgfAreaColorIntens(F
.FMuster
,(sal_uInt8
)Col1
,(sal_uInt8
)Col2
,(sal_uInt8
)Int2
,rOut
);
617 rOut
.SetClipRegion(Region(Rectangle(i0
,y1
,x2
,y2
)));
618 rOut
.DrawEllipse(Rectangle(x1
,y1
,x2
,y2
));
619 rOut
.SetClipRegion(ClipMerk
);
622 case 0x18: case 0x38: { // Kreis
629 i0
=MaxR
; if (MaxR
<1) MaxR
=1;
632 b
=Int1
+sal_Int16((sal_Int32(Int2
-Int1
)*sal_Int32(i
)) /sal_Int32(MaxR
));
634 sal_Int32 temp
=sal_Int32(i0
)*sal_Int32(ry
)/sal_Int32(rx
);
635 sal_Int16 j0
=sal_Int16(temp
);
636 SgfAreaColorIntens(F
.FMuster
,(sal_uInt8
)Col1
,(sal_uInt8
)Col2
,(sal_uInt8
)b0
,rOut
);
637 rOut
.DrawEllipse(Rectangle(cx
-i0
,cy
-j0
,cx
+i0
,cy
+j0
));
642 SgfAreaColorIntens(F
.FMuster
,(sal_uInt8
)Col1
,(sal_uInt8
)Col2
,(sal_uInt8
)Int1
,rOut
);
643 rOut
.DrawEllipse(Rectangle(cx
-i0
,cy
-i0
,cx
+i0
,cy
+i0
));
650 void CircType::Draw(OutputDevice
& rOut
)
652 Rectangle
aRect(Center
.x
-Radius
.x
,Center
.y
-Radius
.y
,Center
.x
+Radius
.x
,Center
.y
+Radius
.y
);
654 if (L
.LMuster
!=0) L
.LMuster
=1; // keine Linienmuster hier, nur an oder aus
656 if ((Flags
& 0x03)==CircFull
) {
657 if ((F
.FBFarbe
& 0x38)==0) {
659 rOut
.DrawEllipse(aRect
);
661 DrawSlideCirc(Center
.x
,Center
.y
,Radius
.x
,Radius
.y
,F
,rOut
);
665 rOut
.DrawEllipse(aRect
);
673 a
.x
=Center
.x
+Radius
.x
; a
.y
=Center
.y
; b
=a
;
674 sn
=sin(double(StartWink
)*3.14159265359/18000);
675 cs
=cos(double(StartWink
)*3.14159265359/18000);
676 RotatePoint(a
,Center
.x
,Center
.y
,sn
,cs
);
677 sn
=sin(double(StartWink
+RelWink
)*3.14159265359/18000);
678 cs
=cos(double(StartWink
+RelWink
)*3.14159265359/18000);
679 RotatePoint(b
,Center
.x
,Center
.y
,sn
,cs
);
680 if (Radius
.x
!=Radius
.y
) {
681 if (Radius
.x
<1) Radius
.x
=1;
682 if (Radius
.y
<1) Radius
.y
=1;
683 a
.y
= a
.y
- Center
.y
;
684 b
.y
= b
.y
- Center
.y
;
685 a
.y
=iMulDiv(a
.y
,Radius
.y
,Radius
.x
);
686 b
.y
=iMulDiv(b
.y
,Radius
.y
,Radius
.x
);
687 a
.y
= a
.y
+ Center
.y
;
688 b
.y
= b
.y
+ Center
.y
;
690 aStrt
=Point(a
.x
,a
.y
);
691 aEnde
=Point(b
.x
,b
.y
);
693 switch (Flags
& 0x03) {
694 case CircArc
: rOut
.DrawArc(aRect
,aEnde
,aStrt
); break;
696 case CircAbsn
: rOut
.DrawPie(aRect
,aEnde
,aStrt
); break;
701 /*************************************************************************
705 *************************************************************************/
707 void BmapType::Draw(OutputDevice
& rOut
)
710 unsigned char nSgfTyp
;
713 reinterpret_cast< char const * >(&Filename
[ 1 ]),
714 (xub_StrLen
)Filename
[ 0 ], RTL_TEXTENCODING_UTF8
);
715 INetURLObject
aFNam( aStr
);
717 SvStream
* pInp
= ::utl::UcbStreamHelper::CreateStream( aFNam
.GetMainURL( INetURLObject::NO_DECODE
), STREAM_READ
);
720 nSgfTyp
=CheckSgfTyp( *pInp
,nVersion
);
725 aFlt
.ImportGraphic(aGrf
,aFNam
);
726 aGrf
.Draw(&rOut
,Point(Pos1
.x
,Pos1
.y
),Size(Pos2
.x
-Pos1
.x
,Pos2
.y
-Pos1
.y
));
732 SgfVectXmul
=Pos2
.x
-Pos1
.x
;
733 SgfVectYmul
=Pos2
.y
-Pos1
.y
;
736 SgfVectScal
=sal_True
;
737 SgfVectFilter(*pInp
,aMtf
);
744 SgfVectScal
=sal_False
;
753 /*************************************************************************
757 *************************************************************************/
758 sal_uInt32
GrupType::GetSubPtr()
760 return sal_uInt32(SbLo
)+0x00010000*sal_uInt32(SbHi
);
763 /*************************************************************************
767 *************************************************************************/
768 void DrawObjkList( SvStream
& rInp
, OutputDevice
& rOut
)
771 sal_uInt16 nGrpCnt
=0;
772 sal_Bool bEnde
=sal_False
;
775 if (!rInp
.GetError()) {
777 case ObjStrk
: { StrkType aStrk
; rInp
>>aStrk
; if (!rInp
.GetError()) aStrk
.Draw(rOut
); } break;
778 case ObjRect
: { RectType aRect
; rInp
>>aRect
; if (!rInp
.GetError()) aRect
.Draw(rOut
); } break;
779 case ObjCirc
: { CircType aCirc
; rInp
>>aCirc
; if (!rInp
.GetError()) aCirc
.Draw(rOut
); } break;
783 if (!rInp
.GetError()) {
784 aText
.Buffer
=new UCHAR
[aText
.BufSize
+1]; // Ein mehr fuer LookAhead bei CK-Trennung
785 rInp
.Read((char* )aText
.Buffer
,aText
.BufSize
);
786 if (!rInp
.GetError()) aText
.Draw(rOut
);
787 delete[] aText
.Buffer
;
793 if (!rInp
.GetError()) {
800 if (!rInp
.GetError()) {
801 aPoly
.EckP
=new PointType
[aPoly
.nPoints
];
802 rInp
.Read((char*)aPoly
.EckP
,4*aPoly
.nPoints
);
803 #if defined OSL_BIGENDIAN
804 for(short i
=0;i
<aPoly
.nPoints
;i
++) SWAPPOINT(aPoly
.EckP
[i
]);
806 if (!rInp
.GetError()) aPoly
.Draw(rOut
);
813 if (!rInp
.GetError()) {
814 aSpln
.EckP
=new PointType
[aSpln
.nPoints
];
815 rInp
.Read((char*)aSpln
.EckP
,4*aSpln
.nPoints
);
816 #if defined OSL_BIGENDIAN
817 for(short i
=0;i
<aSpln
.nPoints
;i
++) SWAPPOINT(aSpln
.EckP
[i
]);
819 if (!rInp
.GetError()) aSpln
.Draw(rOut
);
826 if (!rInp
.GetError()) {
827 rInp
.Seek(rInp
.Tell()+aGrup
.Last
); // Obj-Anhaengsel
828 if(aGrup
.GetSubPtr()!=0L) nGrpCnt
++;// DrawObjkList(rInp,rOut );
832 aObjk
.Draw(rOut
); // Objektbezeichnung auf 2. Screen
833 ObjkOverSeek(rInp
,aObjk
); // zum naechsten Objekt
837 if (!rInp
.GetError()) {
838 if (aObjk
.Next
==0L) {
839 if (nGrpCnt
==0) bEnde
=sal_True
;
843 bEnde
=sal_True
; // Lesefehler
848 /*************************************************************************
852 *************************************************************************/
853 void SkipObjkList(SvStream
& rInp
)
859 if(aObjk
.Art
==ObjGrup
) {
862 rInp
.Seek(rInp
.Tell()+aGrup
.Last
); // Obj-Anhaengsel
863 if(aGrup
.GetSubPtr()!=0L) SkipObjkList(rInp
);
865 ObjkOverSeek(rInp
,aObjk
); // zum naechsten Objekt
867 } while (aObjk
.Next
!=0L && !rInp
.GetError());
870 /*************************************************************************
874 *************************************************************************/
875 sal_Bool
SgfFilterSDrw( SvStream
& rInp
, SgfHeader
&, SgfEntry
&, GDIMetaFile
& rMtf
)
877 sal_Bool bRet
= sal_False
;
879 VirtualDevice aOutDev
;
880 OutputDevice
* pOutDev
;
886 DtHdOverSeek(rInp
); // DataHeader weglesen
889 do { // Standardseiten weglesen
891 if (aPage
.nList
!=0) SkipObjkList(rInp
);
892 } while (aPage
.Next
!=0L && !rInp
.GetError());
894 // ShowMsg("Zeichnungseite(n)\n");
898 rMtf
.Record(pOutDev
);
902 while(Num
>1 && aPage
.Next
!=0L && !rInp
.GetError()) { // Standardseite suchen
904 if (aPage
.nList
!=0) SkipObjkList(rInp
);
908 if(Num
==1 && aPage
.nList
!=0L) DrawObjkList( rInp
,*pOutDev
);
913 if (aPage
.nList
!=0L) DrawObjkList(rInp
,*pOutDev
);
917 MapMode
aMap(MAP_10TH_MM
,Point(),Fraction(1,4),Fraction(1,4));
918 rMtf
.SetPrefMapMode(aMap
);
919 rMtf
.SetPrefSize(Size((sal_Int16
)aPage
.Paper
.Size
.x
,(sal_Int16
)aPage
.Paper
.Size
.y
));
926 /*************************************************************************
930 *************************************************************************/
931 sal_Bool
SgfSDrwFilter(SvStream
& rInp
, GDIMetaFile
& rMtf
, INetURLObject aIniPath
)
933 #if OSL_DEBUG_LEVEL > 1 // Recordgroessen checken. Neuer Compiler hat vielleichte anderes Alignment!
934 if (sizeof(ObjTextType
)!=ObjTextTypeSize
) return sal_False
;
937 sal_uLong nFileStart
; // Offset des SgfHeaders. Im allgemeinen 0.
941 sal_Bool bRdFlag
=sal_False
; // Grafikentry gelesen ?
942 sal_Bool bRet
=sal_False
; // Returncode
944 aIniPath
.Append(OUString("sgf.ini"));
946 pSgfFonts
= new SgfFontLst
;
948 pSgfFonts
->AssignFN( aIniPath
.GetMainURL( INetURLObject::NO_DECODE
) );
949 nFileStart
=rInp
.Tell();
951 if (aHead
.ChkMagic() && aHead
.Typ
==SgfStarDraw
&& aHead
.Version
==SGV_VERSION
) {
952 nNext
=aHead
.GetOffset();
953 while (nNext
&& !bRdFlag
&& !rInp
.GetError()) {
954 rInp
.Seek(nFileStart
+nNext
);
956 nNext
=aEntr
.GetOffset();
957 if (aEntr
.Typ
==aHead
.Typ
) {
958 bRet
=SgfFilterSDrw( rInp
,aHead
,aEntr
,rMtf
);
962 if (!rInp
.GetError()) bRet
=sal_True
; // Scheinbar Ok
969 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */