xref: /aoo41x/main/svtools/source/filter/sgvmain.cxx (revision c82f2877)
1*c82f2877SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*c82f2877SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*c82f2877SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*c82f2877SAndrew Rist  * distributed with this work for additional information
6*c82f2877SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*c82f2877SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*c82f2877SAndrew Rist  * "License"); you may not use this file except in compliance
9*c82f2877SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*c82f2877SAndrew Rist  *
11*c82f2877SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*c82f2877SAndrew Rist  *
13*c82f2877SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*c82f2877SAndrew Rist  * software distributed under the License is distributed on an
15*c82f2877SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*c82f2877SAndrew Rist  * KIND, either express or implied.  See the License for the
17*c82f2877SAndrew Rist  * specific language governing permissions and limitations
18*c82f2877SAndrew Rist  * under the License.
19*c82f2877SAndrew Rist  *
20*c82f2877SAndrew Rist  *************************************************************/
21*c82f2877SAndrew Rist 
22*c82f2877SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svtools.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <rtl/math.hxx>
28cdf0e10cSrcweir #include <osl/endian.h>
29cdf0e10cSrcweir #include <vcl/graph.hxx>
30cdf0e10cSrcweir #include <tools/poly.hxx>
31cdf0e10cSrcweir #include <svtools/filter.hxx>
32cdf0e10cSrcweir #include "sgffilt.hxx"
33cdf0e10cSrcweir #include "sgfbram.hxx"
34cdf0e10cSrcweir #include "sgvmain.hxx"
35cdf0e10cSrcweir #include "sgvspln.hxx"
36cdf0e10cSrcweir #include <unotools/ucbstreamhelper.hxx>
37cdf0e10cSrcweir 
38cdf0e10cSrcweir //#if OSL_DEBUG_LEVEL > 1
39cdf0e10cSrcweir //#include "Debug.c"
40cdf0e10cSrcweir //#endif
41cdf0e10cSrcweir 
42cdf0e10cSrcweir #define SWAPPOINT(p) {  \
43cdf0e10cSrcweir     p.x=SWAPSHORT(p.x); \
44cdf0e10cSrcweir     p.y=SWAPSHORT(p.y); }
45cdf0e10cSrcweir 
46cdf0e10cSrcweir #define SWAPPAGE(p) {                         \
47cdf0e10cSrcweir     p.Next   =SWAPLONG (p.Next   );           \
48cdf0e10cSrcweir     p.nList  =SWAPLONG (p.nList  );           \
49cdf0e10cSrcweir     p.ListEnd=SWAPLONG (p.ListEnd);           \
50cdf0e10cSrcweir     p.Paper.Size.x=SWAPSHORT(p.Paper.Size.x); \
51cdf0e10cSrcweir     p.Paper.Size.y=SWAPSHORT(p.Paper.Size.y); \
52cdf0e10cSrcweir     p.Paper.RandL =SWAPSHORT(p.Paper.RandL ); \
53cdf0e10cSrcweir     p.Paper.RandR =SWAPSHORT(p.Paper.RandR ); \
54cdf0e10cSrcweir     p.Paper.RandO =SWAPSHORT(p.Paper.RandO ); \
55cdf0e10cSrcweir     p.Paper.RandU =SWAPSHORT(p.Paper.RandU ); \
56cdf0e10cSrcweir     SWAPPOINT(p.U);                           \
57cdf0e10cSrcweir     sal_uInt16 iTemp;                             \
58cdf0e10cSrcweir     for (iTemp=0;iTemp<20;iTemp++) {          \
59cdf0e10cSrcweir         rPage.HlpLnH[iTemp]=SWAPSHORT(rPage.HlpLnH[iTemp]);       \
60cdf0e10cSrcweir         rPage.HlpLnV[iTemp]=SWAPSHORT(rPage.HlpLnV[iTemp]);      }}
61cdf0e10cSrcweir 
62cdf0e10cSrcweir #define SWAPOBJK(o) {                 \
63cdf0e10cSrcweir     o.Last    =SWAPLONG (o.Last    ); \
64cdf0e10cSrcweir     o.Next    =SWAPLONG (o.Next    ); \
65cdf0e10cSrcweir     o.MemSize =SWAPSHORT(o.MemSize ); \
66cdf0e10cSrcweir     SWAPPOINT(o.ObjMin);              \
67cdf0e10cSrcweir     SWAPPOINT(o.ObjMax);              }
68cdf0e10cSrcweir 
69cdf0e10cSrcweir #define SWAPLINE(l) {             \
70cdf0e10cSrcweir     l.LMSize=SWAPSHORT(l.LMSize); \
71cdf0e10cSrcweir     l.LDicke=SWAPSHORT(l.LDicke); }
72cdf0e10cSrcweir 
73cdf0e10cSrcweir #define SWAPAREA(a) {               \
74cdf0e10cSrcweir     a.FDummy2=SWAPSHORT(a.FDummy2); \
75cdf0e10cSrcweir     a.FMuster=SWAPSHORT(a.FMuster); }
76cdf0e10cSrcweir 
77cdf0e10cSrcweir #define SWAPTEXT(t) {               \
78cdf0e10cSrcweir     SWAPLINE(t.L);                  \
79cdf0e10cSrcweir     SWAPAREA(t.F);                  \
80cdf0e10cSrcweir     t.FontLo =SWAPSHORT(t.FontLo ); \
81cdf0e10cSrcweir     t.FontHi =SWAPSHORT(t.FontHi ); \
82cdf0e10cSrcweir     t.Grad   =SWAPSHORT(t.Grad   ); \
83cdf0e10cSrcweir     t.Breite =SWAPSHORT(t.Breite ); \
84cdf0e10cSrcweir     t.Schnitt=SWAPSHORT(t.Schnitt); \
85cdf0e10cSrcweir     t.LnFeed =SWAPSHORT(t.LnFeed ); \
86cdf0e10cSrcweir     t.Slant  =SWAPSHORT(t.Slant  ); \
87cdf0e10cSrcweir     SWAPLINE(t.ShdL);               \
88cdf0e10cSrcweir     SWAPAREA(t.ShdF);               \
89cdf0e10cSrcweir     SWAPPOINT(t.ShdVers);           \
90cdf0e10cSrcweir     SWAPAREA(t.BackF);              }
91cdf0e10cSrcweir 
92cdf0e10cSrcweir 
93cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
94cdf0e10cSrcweir //
95cdf0e10cSrcweir //  Einschraenkungen:
96cdf0e10cSrcweir //
97cdf0e10cSrcweir //  - Flaechenmuster werden den unter StarView verfuegbaren Mustern angenaehert.
98cdf0e10cSrcweir //  - Linienenden werden unter StarView immer rund dargestellt und gehen ueber
99cdf0e10cSrcweir //    den Endpunkt der Linie hinaus.
100cdf0e10cSrcweir //  - Linienmuster werden den unter StarView verfuegbaren Mustern angenaehert.
101cdf0e10cSrcweir //    Transparent/Opak wird zur Zeit noch nicht beruecksichtigt.
102cdf0e10cSrcweir //  - Keine gedrehten Ellipsen
103cdf0e10cSrcweir //
104cdf0e10cSrcweir //
105cdf0e10cSrcweir //
106cdf0e10cSrcweir //
107cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
108cdf0e10cSrcweir 
109cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
110cdf0e10cSrcweir // Fuer Fontuebersetzung ///////////////////////////////////////////////////////////////////////////
111cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
112cdf0e10cSrcweir SgfFontLst* pSgfFonts = 0;
113cdf0e10cSrcweir 
114cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
115cdf0e10cSrcweir // Fuer Kreisunterarten, Text und gedrehte Rechtecke ///////////////////////////////////////////////
116cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
RotatePoint(PointType & P,sal_Int16 cx,sal_Int16 cy,double sn,double cs)117cdf0e10cSrcweir void RotatePoint(PointType& P, sal_Int16 cx, sal_Int16 cy, double sn, double cs)
118cdf0e10cSrcweir {
119cdf0e10cSrcweir 	sal_Int16  dx,dy;
120cdf0e10cSrcweir 	double x1,y1;
121cdf0e10cSrcweir 	dx=P.x-cx;
122cdf0e10cSrcweir 	dy=P.y-cy;
123cdf0e10cSrcweir 	x1=dx*cs-dy*sn;
124cdf0e10cSrcweir 	y1=dy*cs+dx*sn;
125cdf0e10cSrcweir 	P.x=cx+sal_Int16(x1);
126cdf0e10cSrcweir 	P.y=cy+sal_Int16(y1);
127cdf0e10cSrcweir }
128cdf0e10cSrcweir 
RotatePoint(Point & P,sal_Int16 cx,sal_Int16 cy,double sn,double cs)129cdf0e10cSrcweir void RotatePoint(Point& P, sal_Int16 cx, sal_Int16 cy, double sn, double cs)
130cdf0e10cSrcweir {
131cdf0e10cSrcweir 	sal_Int16  dx,dy;
132cdf0e10cSrcweir 	double x1,y1;
133cdf0e10cSrcweir 	dx=(sal_Int16)(P.X()-cx);
134cdf0e10cSrcweir 	dy=(sal_Int16)(P.Y()-cy);
135cdf0e10cSrcweir 	x1=dx*cs-dy*sn;
136cdf0e10cSrcweir 	y1=dy*cs+dx*sn;
137cdf0e10cSrcweir 	P=Point(cx+sal_Int16(x1),cy+sal_Int16(y1));
138cdf0e10cSrcweir }
139cdf0e10cSrcweir 
iMulDiv(sal_Int16 a,sal_Int16 Mul,sal_Int16 Div)140cdf0e10cSrcweir sal_Int16 iMulDiv(sal_Int16 a, sal_Int16 Mul, sal_Int16 Div)
141cdf0e10cSrcweir {
142cdf0e10cSrcweir 	sal_Int32 Temp;
143cdf0e10cSrcweir 	Temp=sal_Int32(a)*sal_Int32(Mul)/sal_Int32(Div);
144cdf0e10cSrcweir 	return sal_Int16(Temp);
145cdf0e10cSrcweir }
146cdf0e10cSrcweir 
MulDiv(sal_uInt16 a,sal_uInt16 Mul,sal_uInt16 Div)147cdf0e10cSrcweir sal_uInt16 MulDiv(sal_uInt16 a, sal_uInt16 Mul, sal_uInt16 Div)
148cdf0e10cSrcweir {
149cdf0e10cSrcweir 	sal_uInt32 Temp;
150cdf0e10cSrcweir 	Temp=sal_uInt32(a)*sal_uInt32(Mul)/sal_uInt32(Div);
151cdf0e10cSrcweir 	return sal_uInt16(Temp);
152cdf0e10cSrcweir }
153cdf0e10cSrcweir 
154cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
155cdf0e10cSrcweir // SgfFilterSDrw ///////////////////////////////////////////////////////////////////////////////////
156cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
157cdf0e10cSrcweir 
operator >>(SvStream & rIStream,DtHdType & rDtHd)158cdf0e10cSrcweir SvStream& operator>>(SvStream& rIStream, DtHdType& rDtHd)
159cdf0e10cSrcweir {
160cdf0e10cSrcweir 	rIStream.Read((char*)&rDtHd.Reserved[0],DtHdSize);
161cdf0e10cSrcweir 	return rIStream;
162cdf0e10cSrcweir }
163cdf0e10cSrcweir 
DtHdOverSeek(SvStream & rInp)164cdf0e10cSrcweir void DtHdOverSeek(SvStream& rInp)
165cdf0e10cSrcweir {
166cdf0e10cSrcweir 	sal_uLong FPos=rInp.Tell();
167cdf0e10cSrcweir 	FPos+=(sal_uLong)DtHdSize;
168cdf0e10cSrcweir 	rInp.Seek(FPos);
169cdf0e10cSrcweir //    rInp.seekg(rInp.tellg()+(sal_uLong)DtHdSize);
170cdf0e10cSrcweir }
171cdf0e10cSrcweir 
172cdf0e10cSrcweir 
operator >>(SvStream & rIStream,PageType & rPage)173cdf0e10cSrcweir SvStream& operator>>(SvStream& rIStream, PageType& rPage)
174cdf0e10cSrcweir {
175cdf0e10cSrcweir 	rIStream.Read((char*)&rPage.Next,PageSize);
176cdf0e10cSrcweir #if defined OSL_BIGENDIAN
177cdf0e10cSrcweir 	SWAPPAGE(rPage);
178cdf0e10cSrcweir #endif
179cdf0e10cSrcweir 	return rIStream;
180cdf0e10cSrcweir }
181cdf0e10cSrcweir 
ObjkOverSeek(SvStream & rInp,ObjkType & rObjk)182cdf0e10cSrcweir void ObjkOverSeek(SvStream& rInp, ObjkType& rObjk)
183cdf0e10cSrcweir {
184cdf0e10cSrcweir 	sal_uLong Siz;
185cdf0e10cSrcweir 	Siz=(sal_uLong)rObjk.MemSize+rObjk.Last;  // ObjSize+ObjAnhSize
186cdf0e10cSrcweir 	rInp.Seek(rInp.Tell()+Siz);
187cdf0e10cSrcweir }
188cdf0e10cSrcweir 
operator >>(SvStream & rInp,ObjkType & rObjk)189cdf0e10cSrcweir SvStream& operator>>(SvStream& rInp, ObjkType& rObjk)
190cdf0e10cSrcweir {   // Die Fileposition im Stream bleibt unveraendert!
191cdf0e10cSrcweir 	sal_uLong nPos;
192cdf0e10cSrcweir 	nPos=rInp.Tell();
193cdf0e10cSrcweir 	rInp.Read((char*)&rObjk.Last,ObjkSize);
194cdf0e10cSrcweir #if defined OSL_BIGENDIAN
195cdf0e10cSrcweir 	SWAPOBJK(rObjk);
196cdf0e10cSrcweir #endif
197cdf0e10cSrcweir #ifdef InArbeit
198cdf0e10cSrcweir 	sal_uLong nPos1=rInp.Tell();
199cdf0e10cSrcweir 	if(nPos == nPos1) InfoBox( NULL, "tellg funkt nich" ).Execute();
200cdf0e10cSrcweir #endif
201cdf0e10cSrcweir 	rInp.Seek(nPos);
202cdf0e10cSrcweir #ifdef InArbeit
203cdf0e10cSrcweir 	if (rInp.Tell() != nPos) InfoBox( NULL, "seekg funkt nich" ).Execute();
204cdf0e10cSrcweir #endif
205cdf0e10cSrcweir 	return rInp;
206cdf0e10cSrcweir }
operator >>(SvStream & rInp,StrkType & rStrk)207cdf0e10cSrcweir SvStream& operator>>(SvStream& rInp, StrkType& rStrk)
208cdf0e10cSrcweir {
209cdf0e10cSrcweir 	rInp.Read((char*)&rStrk.Last,StrkSize);
210cdf0e10cSrcweir #if defined OSL_BIGENDIAN
211cdf0e10cSrcweir 	SWAPOBJK (rStrk);
212cdf0e10cSrcweir 	SWAPLINE (rStrk.L);
213cdf0e10cSrcweir 	SWAPPOINT(rStrk.Pos1);
214cdf0e10cSrcweir 	SWAPPOINT(rStrk.Pos2);
215cdf0e10cSrcweir #endif
216cdf0e10cSrcweir 	return rInp;
217cdf0e10cSrcweir }
operator >>(SvStream & rInp,RectType & rRect)218cdf0e10cSrcweir SvStream& operator>>(SvStream& rInp, RectType& rRect)
219cdf0e10cSrcweir {
220cdf0e10cSrcweir 	rInp.Read((char*)&rRect.Last,RectSize);
221cdf0e10cSrcweir #if defined OSL_BIGENDIAN
222cdf0e10cSrcweir 	SWAPOBJK (rRect);
223cdf0e10cSrcweir 	SWAPLINE (rRect.L);
224cdf0e10cSrcweir 	SWAPAREA (rRect.F);
225cdf0e10cSrcweir 	SWAPPOINT(rRect.Pos1);
226cdf0e10cSrcweir 	SWAPPOINT(rRect.Pos2);
227cdf0e10cSrcweir 	rRect.Radius  =SWAPSHORT(rRect.Radius  );
228cdf0e10cSrcweir 	rRect.DrehWink=SWAPSHORT(rRect.DrehWink);
229cdf0e10cSrcweir 	rRect.Slant   =SWAPSHORT(rRect.Slant   );
230cdf0e10cSrcweir #endif
231cdf0e10cSrcweir 	return rInp;
232cdf0e10cSrcweir }
operator >>(SvStream & rInp,PolyType & rPoly)233cdf0e10cSrcweir SvStream& operator>>(SvStream& rInp, PolyType& rPoly)
234cdf0e10cSrcweir {
235cdf0e10cSrcweir 	rInp.Read((char*)&rPoly.Last,PolySize);
236cdf0e10cSrcweir #if defined OSL_BIGENDIAN
237cdf0e10cSrcweir 	SWAPOBJK (rPoly);
238cdf0e10cSrcweir 	SWAPLINE (rPoly.L);
239cdf0e10cSrcweir 	SWAPAREA (rPoly.F);
240cdf0e10cSrcweir 	// rPoly.EckP=SWAPLONG(rPoly.EckP);
241cdf0e10cSrcweir #endif
242cdf0e10cSrcweir 	return rInp;
243cdf0e10cSrcweir }
operator >>(SvStream & rInp,SplnType & rSpln)244cdf0e10cSrcweir SvStream& operator>>(SvStream& rInp, SplnType& rSpln)
245cdf0e10cSrcweir {
246cdf0e10cSrcweir 	rInp.Read((char*)&rSpln.Last,SplnSize);
247cdf0e10cSrcweir #if defined OSL_BIGENDIAN
248cdf0e10cSrcweir 	SWAPOBJK (rSpln);
249cdf0e10cSrcweir 	SWAPLINE (rSpln.L);
250cdf0e10cSrcweir 	SWAPAREA (rSpln.F);
251cdf0e10cSrcweir 	// rSpln.EckP=SWAPLONG(rSpln.EckP);
252cdf0e10cSrcweir #endif
253cdf0e10cSrcweir 	return rInp;
254cdf0e10cSrcweir }
operator >>(SvStream & rInp,CircType & rCirc)255cdf0e10cSrcweir SvStream& operator>>(SvStream& rInp, CircType& rCirc)
256cdf0e10cSrcweir {
257cdf0e10cSrcweir 	rInp.Read((char*)&rCirc.Last,CircSize);
258cdf0e10cSrcweir #if defined OSL_BIGENDIAN
259cdf0e10cSrcweir 	SWAPOBJK (rCirc);
260cdf0e10cSrcweir 	SWAPLINE (rCirc.L);
261cdf0e10cSrcweir 	SWAPAREA (rCirc.F);
262cdf0e10cSrcweir 	SWAPPOINT(rCirc.Radius);
263cdf0e10cSrcweir 	SWAPPOINT(rCirc.Center);
264cdf0e10cSrcweir 	rCirc.DrehWink =SWAPSHORT(rCirc.DrehWink );
265cdf0e10cSrcweir 	rCirc.StartWink=SWAPSHORT(rCirc.StartWink);
266cdf0e10cSrcweir 	rCirc.RelWink  =SWAPSHORT(rCirc.RelWink  );
267cdf0e10cSrcweir #endif
268cdf0e10cSrcweir 	return rInp;
269cdf0e10cSrcweir }
operator >>(SvStream & rInp,TextType & rText)270cdf0e10cSrcweir SvStream& operator>>(SvStream& rInp, TextType& rText)
271cdf0e10cSrcweir {
272cdf0e10cSrcweir 	rInp.Read((char*)&rText.Last,TextSize);
273cdf0e10cSrcweir #if defined OSL_BIGENDIAN
274cdf0e10cSrcweir 	SWAPOBJK (rText);
275cdf0e10cSrcweir 	SWAPTEXT (rText.T);
276cdf0e10cSrcweir 	SWAPPOINT(rText.Pos1);
277cdf0e10cSrcweir 	SWAPPOINT(rText.Pos2);
278cdf0e10cSrcweir 	rText.TopOfs  =SWAPSHORT(rText.TopOfs  );
279cdf0e10cSrcweir 	rText.DrehWink=SWAPSHORT(rText.DrehWink);
280cdf0e10cSrcweir 	rText.BoxSlant=SWAPSHORT(rText.BoxSlant);
281cdf0e10cSrcweir 	rText.BufSize =SWAPSHORT(rText.BufSize );
282cdf0e10cSrcweir 	//rText.Buf     =SWAPLONG (rText.Buf     );
283cdf0e10cSrcweir 	//rText.Ext     =SWAPLONG (rText.Ext     );
284cdf0e10cSrcweir 	SWAPPOINT(rText.FitSize);
285cdf0e10cSrcweir 	rText.FitBreit=SWAPSHORT(rText.FitBreit);
286cdf0e10cSrcweir #endif
287cdf0e10cSrcweir 	rText.Buffer=NULL;
288cdf0e10cSrcweir 	return rInp;
289cdf0e10cSrcweir }
operator >>(SvStream & rInp,BmapType & rBmap)290cdf0e10cSrcweir SvStream& operator>>(SvStream& rInp, BmapType& rBmap)
291cdf0e10cSrcweir {
292cdf0e10cSrcweir 	rInp.Read((char*)&rBmap.Last,BmapSize);
293cdf0e10cSrcweir #if defined OSL_BIGENDIAN
294cdf0e10cSrcweir 	SWAPOBJK (rBmap);
295cdf0e10cSrcweir 	SWAPAREA (rBmap.F);
296cdf0e10cSrcweir 	SWAPPOINT(rBmap.Pos1);
297cdf0e10cSrcweir 	SWAPPOINT(rBmap.Pos2);
298cdf0e10cSrcweir 	rBmap.DrehWink=SWAPSHORT(rBmap.DrehWink);
299cdf0e10cSrcweir 	rBmap.Slant   =SWAPSHORT(rBmap.Slant   );
300cdf0e10cSrcweir 	SWAPPOINT(rBmap.PixSize);
301cdf0e10cSrcweir #endif
302cdf0e10cSrcweir 	return rInp;
303cdf0e10cSrcweir }
operator >>(SvStream & rInp,GrupType & rGrup)304cdf0e10cSrcweir SvStream& operator>>(SvStream& rInp, GrupType& rGrup)
305cdf0e10cSrcweir {
306cdf0e10cSrcweir 	rInp.Read((char*)&rGrup.Last,GrupSize);
307cdf0e10cSrcweir #if defined OSL_BIGENDIAN
308cdf0e10cSrcweir 	SWAPOBJK (rGrup);
309cdf0e10cSrcweir 	rGrup.SbLo     =SWAPSHORT(rGrup.SbLo     );
310cdf0e10cSrcweir 	rGrup.SbHi     =SWAPSHORT(rGrup.SbHi     );
311cdf0e10cSrcweir 	rGrup.UpLo     =SWAPSHORT(rGrup.UpLo     );
312cdf0e10cSrcweir 	rGrup.UpHi     =SWAPSHORT(rGrup.UpHi     );
313cdf0e10cSrcweir 	rGrup.ChartSize=SWAPSHORT(rGrup.ChartSize);
314cdf0e10cSrcweir 	rGrup.ChartPtr =SWAPLONG (rGrup.ChartPtr );
315cdf0e10cSrcweir #endif
316cdf0e10cSrcweir 	return rInp;
317cdf0e10cSrcweir }
318cdf0e10cSrcweir 
319cdf0e10cSrcweir 
320cdf0e10cSrcweir 
321cdf0e10cSrcweir /*************************************************************************
322cdf0e10cSrcweir |*
323cdf0e10cSrcweir |*    Sgv2SvFarbe()
324cdf0e10cSrcweir |*
325cdf0e10cSrcweir |*    Beschreibung
326cdf0e10cSrcweir |*    Ersterstellung    JOE 23.06.93
327cdf0e10cSrcweir |*    Letzte Aenderung  JOE 23.06.93
328cdf0e10cSrcweir |*
329cdf0e10cSrcweir *************************************************************************/
Sgv2SvFarbe(sal_uInt8 nFrb1,sal_uInt8 nFrb2,sal_uInt8 nInts)330cdf0e10cSrcweir Color Sgv2SvFarbe(sal_uInt8 nFrb1, sal_uInt8 nFrb2, sal_uInt8 nInts)
331cdf0e10cSrcweir {
332cdf0e10cSrcweir 	sal_uInt16 r1=0,g1=0,b1=0,r2=0,g2=0,b2=0;
333cdf0e10cSrcweir 	sal_uInt8   nInt2=100-nInts;
334cdf0e10cSrcweir 	switch(nFrb1 & 0x07) {
335cdf0e10cSrcweir 		case 0:  r1=0xFF; g1=0xFF; b1=0xFF; break;
336cdf0e10cSrcweir 		case 1:  r1=0xFF; g1=0xFF;            break;
337cdf0e10cSrcweir 		case 2:           g1=0xFF; b1=0xFF; break;
338cdf0e10cSrcweir 		case 3:           g1=0xFF;            break;
339cdf0e10cSrcweir 		case 4:  r1=0xFF;          b1=0xFF; break;
340cdf0e10cSrcweir 		case 5:  r1=0xFF;                       break;
341cdf0e10cSrcweir 		case 6:                    b1=0xFF; break;
342cdf0e10cSrcweir 		case 7:                                   break;
343cdf0e10cSrcweir 	}
344cdf0e10cSrcweir 	switch(nFrb2 & 0x07) {
345cdf0e10cSrcweir 		case 0:  r2=0xFF; g2=0xFF; b2=0xFF; break;
346cdf0e10cSrcweir 		case 1:  r2=0xFF; g2=0xFF;            break;
347cdf0e10cSrcweir 		case 2:           g2=0xFF; b2=0xFF; break;
348cdf0e10cSrcweir 		case 3:           g2=0xFF;            break;
349cdf0e10cSrcweir 		case 4:  r2=0xFF;          b2=0xFF; break;
350cdf0e10cSrcweir 		case 5:  r2=0xFF;                       break;
351cdf0e10cSrcweir 		case 6:                    b2=0xFF; break;
352cdf0e10cSrcweir 		case 7:                                   break;
353cdf0e10cSrcweir 	}
354cdf0e10cSrcweir 	r1=(sal_uInt16)((sal_uInt32)r1*nInts/100+(sal_uInt32)r2*nInt2/100);
355cdf0e10cSrcweir 	g1=(sal_uInt16)((sal_uInt32)g1*nInts/100+(sal_uInt32)g2*nInt2/100);
356cdf0e10cSrcweir 	b1=(sal_uInt16)((sal_uInt32)b1*nInts/100+(sal_uInt32)b2*nInt2/100);
357cdf0e10cSrcweir 	Color aColor( (sal_uInt8)r1, (sal_uInt8)g1, (sal_uInt8)b1 );
358cdf0e10cSrcweir 	return aColor;
359cdf0e10cSrcweir }
360cdf0e10cSrcweir 
SetLine(ObjLineType & rLine,OutputDevice & rOut)361cdf0e10cSrcweir void SetLine(ObjLineType& rLine, OutputDevice& rOut)
362cdf0e10cSrcweir {
363cdf0e10cSrcweir /* !!!
364cdf0e10cSrcweir 	PenStyle aStyle=PEN_SOLID;
365cdf0e10cSrcweir 	switch(rLine.LMuster & 0x07) {
366cdf0e10cSrcweir 		case 0: aStyle=PEN_NULL;    break;
367cdf0e10cSrcweir 		case 1: aStyle=PEN_SOLID;   break;
368cdf0e10cSrcweir         case 2: aStyle=PEN_DOT;     break;    // . . . . . . . . . . . . . .
369cdf0e10cSrcweir         case 3: aStyle=PEN_DASH;    break;    // __ __ __ __ __ __ __ __ __
370cdf0e10cSrcweir         case 4: aStyle=PEN_DASH;    break;    // ___ ___ ___ ___ ___ ___ ___
371cdf0e10cSrcweir         case 5: aStyle=PEN_DASHDOT; break;    // __ . __ . __ . __ . __ . __
372cdf0e10cSrcweir         case 6: aStyle=PEN_DASHDOT; break;    // __ _ __ _ __ _ __ _ __ _ __
373cdf0e10cSrcweir         case 7: aStyle=PEN_DASHDOT; break;    // ___ _ _ ___ _ _ ___ _ _ ___
374cdf0e10cSrcweir 	}
375cdf0e10cSrcweir 	Pen aPen(Sgv2SvFarbe(rLine.LFarbe,rLine.LBFarbe,rLine.LIntens),rLine.LDicke,aStyle);
376cdf0e10cSrcweir 	SetPen(aPen,rOut);
377cdf0e10cSrcweir */
378cdf0e10cSrcweir 	if( 0 == ( rLine.LMuster & 0x07 ) )
379cdf0e10cSrcweir 		rOut.SetLineColor();
380cdf0e10cSrcweir 	else
381cdf0e10cSrcweir 		rOut.SetLineColor( Sgv2SvFarbe(rLine.LFarbe,rLine.LBFarbe,rLine.LIntens) );
382cdf0e10cSrcweir }
383cdf0e10cSrcweir 
SetArea(ObjAreaType & rArea,OutputDevice & rOut)384cdf0e10cSrcweir void SetArea(ObjAreaType& rArea, OutputDevice& rOut)
385cdf0e10cSrcweir {
386cdf0e10cSrcweir /*
387cdf0e10cSrcweir 	BrushStyle aStyle=BRUSH_SOLID;
388cdf0e10cSrcweir 	switch(rArea.FMuster & 0x00FF) {
389cdf0e10cSrcweir 		case  0: aStyle=BRUSH_NULL;      break;
390cdf0e10cSrcweir 		case  1: aStyle=BRUSH_SOLID;     break;
391cdf0e10cSrcweir 		case  2: case  4: case  6: case  8:
392cdf0e10cSrcweir 		case 10: case 12: case 14: case 16:
393cdf0e10cSrcweir 		case 43: case 45:                   aStyle=BRUSH_VERT;      break;
394cdf0e10cSrcweir 		case  3: case  5: case  7: case  9:
395cdf0e10cSrcweir 		case 11: case 13: case 15: case 17:
396cdf0e10cSrcweir 		case 42: case 44:                   aStyle=BRUSH_HORZ;      break;
397cdf0e10cSrcweir 		case 18: case 20: case 22: case 24:
398cdf0e10cSrcweir 		case 26: case 28: case 30: case 32:
399cdf0e10cSrcweir 		case 46: case 48:                   aStyle=BRUSH_UPDIAG;    break;
400cdf0e10cSrcweir 		case 19: case 21: case 23: case 25:
401cdf0e10cSrcweir 		case 27: case 29: case 31: case 33:
402cdf0e10cSrcweir 		case 47: case 49:                   aStyle=BRUSH_DOWNDIAG;  break;
403cdf0e10cSrcweir 		case 34: case 35: case 36: case 37: aStyle=BRUSH_CROSS;     break;
404cdf0e10cSrcweir 		case 38: case 39: case 40: case 41: aStyle=BRUSH_DIAGCROSS; break;
405cdf0e10cSrcweir 		default: aStyle=BRUSH_DIAGCROSS; break;
406cdf0e10cSrcweir 	}
407cdf0e10cSrcweir 	Brush aBrush(Sgv2SvFarbe(rArea.FFarbe,rArea.FBFarbe,rArea.FIntens),aStyle);
408cdf0e10cSrcweir 	aBrush.SetTransparent((rArea.FMuster & 0x80) !=0L);
409cdf0e10cSrcweir 	SetBrush(aBrush,rOut);
410cdf0e10cSrcweir */
411cdf0e10cSrcweir 	if( 0 == ( rArea.FMuster & 0x00FF ) )
412cdf0e10cSrcweir 		rOut.SetFillColor();
413cdf0e10cSrcweir 	else
414cdf0e10cSrcweir 		rOut.SetFillColor( Sgv2SvFarbe( rArea.FFarbe,rArea.FBFarbe,rArea.FIntens ) );
415cdf0e10cSrcweir }
416cdf0e10cSrcweir 
417cdf0e10cSrcweir /*************************************************************************
418cdf0e10cSrcweir |*
419cdf0e10cSrcweir |*    ObjkType::DrawObjekt()
420cdf0e10cSrcweir |*
421cdf0e10cSrcweir |*    Beschreibung
422cdf0e10cSrcweir |*    Ersterstellung    JOE 23.06.93
423cdf0e10cSrcweir |*    Letzte Aenderung  JOE 23.06.93
424cdf0e10cSrcweir |*
425cdf0e10cSrcweir *************************************************************************/
Draw(OutputDevice &)426cdf0e10cSrcweir void ObjkType::Draw(OutputDevice&)
427cdf0e10cSrcweir {
428cdf0e10cSrcweir //    ShowSDObjk(*this);
429cdf0e10cSrcweir }
430cdf0e10cSrcweir 
Draw(OutputDevice &)431cdf0e10cSrcweir void Obj0Type::Draw(OutputDevice&) {}
432cdf0e10cSrcweir 
433cdf0e10cSrcweir /*************************************************************************
434cdf0e10cSrcweir |*
435cdf0e10cSrcweir |*    StrkType::DrawObjekt()
436cdf0e10cSrcweir |*
437cdf0e10cSrcweir |*    Beschreibung
438cdf0e10cSrcweir |*    Ersterstellung    JOE 23.06.93
439cdf0e10cSrcweir |*    Letzte Aenderung  JOE 23.06.93
440cdf0e10cSrcweir |*
441cdf0e10cSrcweir *************************************************************************/
Draw(OutputDevice & rOut)442cdf0e10cSrcweir void StrkType::Draw(OutputDevice& rOut)
443cdf0e10cSrcweir {
444cdf0e10cSrcweir 	SetLine(L,rOut);
445cdf0e10cSrcweir 	rOut.DrawLine(Point(Pos1.x,Pos1.y),Point(Pos2.x,Pos2.y)); // !!!
446cdf0e10cSrcweir }
447cdf0e10cSrcweir 
448cdf0e10cSrcweir /*************************************************************************
449cdf0e10cSrcweir |*
450cdf0e10cSrcweir |*    RectType::DrawObjekt()
451cdf0e10cSrcweir |*
452cdf0e10cSrcweir |*    Beschreibung
453cdf0e10cSrcweir |*    Ersterstellung    JOE 23.06.93
454cdf0e10cSrcweir |*    Letzte Aenderung  JOE 23.06.93
455cdf0e10cSrcweir |*
456cdf0e10cSrcweir *************************************************************************/
SgfAreaColorIntens(sal_uInt16 Muster,sal_uInt8 Col1,sal_uInt8 Col2,sal_uInt8 Int,OutputDevice & rOut)457cdf0e10cSrcweir void SgfAreaColorIntens(sal_uInt16 Muster, sal_uInt8 Col1, sal_uInt8 Col2, sal_uInt8 Int, OutputDevice& rOut)
458cdf0e10cSrcweir {
459cdf0e10cSrcweir 	ObjAreaType F;
460cdf0e10cSrcweir 	F.FMuster=Muster;
461cdf0e10cSrcweir 	F.FFarbe=Col2;
462cdf0e10cSrcweir 	F.FBFarbe=Col1;
463cdf0e10cSrcweir 	F.FIntens=Int;
464cdf0e10cSrcweir 	SetArea(F,rOut);
465cdf0e10cSrcweir }
466cdf0e10cSrcweir 
DrawSlideRect(sal_Int16 x1,sal_Int16 y1,sal_Int16 x2,sal_Int16 y2,ObjAreaType & F,OutputDevice & rOut)467cdf0e10cSrcweir void DrawSlideRect(sal_Int16 x1, sal_Int16 y1, sal_Int16 x2, sal_Int16 y2, ObjAreaType& F, OutputDevice& rOut)
468cdf0e10cSrcweir {
469cdf0e10cSrcweir 	sal_Int16 i,i0,b,b0;
470cdf0e10cSrcweir 	sal_Int16 Int1,Int2;
471cdf0e10cSrcweir 	sal_Int16 Col1,Col2;
472cdf0e10cSrcweir 	//     ClipMerk: HgdClipRec;
473cdf0e10cSrcweir 	sal_Int16 cx,cy;
474cdf0e10cSrcweir 	sal_Int16 MaxR;
475cdf0e10cSrcweir 	sal_Int32 dx,dy;
476cdf0e10cSrcweir 
477cdf0e10cSrcweir 	rOut.SetLineColor();
478cdf0e10cSrcweir 	if (x1>x2) { i=x1; x1=x2; x2=i; }
479cdf0e10cSrcweir 	if (y1>y2) { i=y1; y1=y2; y2=i; }
480cdf0e10cSrcweir 	Col1=F.FBFarbe & 0x87; Col2=F.FFarbe & 0x87;
481cdf0e10cSrcweir 	Int1=100-F.FIntens; Int2=F.FIntens;
482cdf0e10cSrcweir 	if (Int1==Int2) {
483cdf0e10cSrcweir 		SgfAreaColorIntens(F.FMuster,(sal_uInt8)Col1,(sal_uInt8)Col2,(sal_uInt8)Int2,rOut);
484cdf0e10cSrcweir 		rOut.DrawRect(Rectangle(x1,y1,x2,y2));
485cdf0e10cSrcweir 	} else {
486cdf0e10cSrcweir 		b0=Int1;
487cdf0e10cSrcweir 		switch (F.FBFarbe & 0x38) {
488cdf0e10cSrcweir 			case 0x08: { // vertikal
489cdf0e10cSrcweir 				i0=y1;
490cdf0e10cSrcweir 				i=y1;
491cdf0e10cSrcweir 				while (i<=y2) {
492cdf0e10cSrcweir 					b=Int1+sal_Int16((sal_Int32)(Int2-Int1)*(sal_Int32)(i-y1) /(sal_Int32)(y2-y1+1));
493cdf0e10cSrcweir 					if (b!=b0) {
494cdf0e10cSrcweir 						SgfAreaColorIntens(F.FMuster,(sal_uInt8)Col1,(sal_uInt8)Col2,(sal_uInt8)b0,rOut);
495cdf0e10cSrcweir 						rOut.DrawRect(Rectangle(x1,i0,x2,i-1));
496cdf0e10cSrcweir 						i0=i; b0=b;
497cdf0e10cSrcweir 					}
498cdf0e10cSrcweir 					i++;
499cdf0e10cSrcweir 				}
500cdf0e10cSrcweir 				SgfAreaColorIntens(F.FMuster,(sal_uInt8)Col1,(sal_uInt8)Col2,(sal_uInt8)Int2,rOut);
501cdf0e10cSrcweir 				rOut.DrawRect(Rectangle(x1,i0,x2,y2));
502cdf0e10cSrcweir 			} break;
503cdf0e10cSrcweir 			case 0x28: { // horizontal
504cdf0e10cSrcweir 				i0=x1;
505cdf0e10cSrcweir 				i=x1;
506cdf0e10cSrcweir 				while (i<=x2) {
507cdf0e10cSrcweir 					b=Int1+sal_Int16((sal_Int32)(Int2-Int1)*(sal_Int32)(i-x1) /(sal_Int32)(x2-x1+1));
508cdf0e10cSrcweir 					if (b!=b0) {
509cdf0e10cSrcweir 						SgfAreaColorIntens(F.FMuster,(sal_uInt8)Col1,(sal_uInt8)Col2,(sal_uInt8)b0,rOut);
510cdf0e10cSrcweir 						rOut.DrawRect(Rectangle(i0,y1,i-1,y2));
511cdf0e10cSrcweir 						i0=i; b0=b;
512cdf0e10cSrcweir 					}
513cdf0e10cSrcweir 					i++;
514cdf0e10cSrcweir 				}
515cdf0e10cSrcweir 				SgfAreaColorIntens(F.FMuster,(sal_uInt8)Col1,(sal_uInt8)Col2,(sal_uInt8)Int2,rOut);
516cdf0e10cSrcweir 				rOut.DrawRect(Rectangle(i0,y1,x2,y2));
517cdf0e10cSrcweir 			} break;
518cdf0e10cSrcweir 
519cdf0e10cSrcweir 			case 0x18: case 0x38: { // Kreis
520cdf0e10cSrcweir 				Region ClipMerk=rOut.GetClipRegion();
521cdf0e10cSrcweir 				double a;
522cdf0e10cSrcweir 
523cdf0e10cSrcweir 				rOut.SetClipRegion(Region(Rectangle(x1,y1,x2,y2)));
524cdf0e10cSrcweir 				cx=(x1+x2) /2;
525cdf0e10cSrcweir 				cy=(y1+y2) /2;
526cdf0e10cSrcweir 				dx=x2-x1+1;
527cdf0e10cSrcweir 				dy=y2-y1+1;
528cdf0e10cSrcweir 				a=sqrt((double)(dx*dx+dy*dy));
529cdf0e10cSrcweir 				MaxR=sal_Int16(a) /2 +1;
530cdf0e10cSrcweir 				b0=Int2;
531cdf0e10cSrcweir 				i0=MaxR; if (MaxR<1) MaxR=1;
532cdf0e10cSrcweir 				i=MaxR;
533cdf0e10cSrcweir 				while (i>=0) {
534cdf0e10cSrcweir 					b=Int1+sal_Int16((sal_Int32(Int2-Int1)*sal_Int32(i)) /sal_Int32(MaxR));
535cdf0e10cSrcweir 					if (b!=b0) {
536cdf0e10cSrcweir 						SgfAreaColorIntens(F.FMuster,(sal_uInt8)Col1,(sal_uInt8)Col2,(sal_uInt8)b0,rOut);
537cdf0e10cSrcweir 						//if (i0>200 || (Col1 & $80)!=0 || (Col2 & $80)!=0) {
538cdf0e10cSrcweir                         //  then begin { Fallunterscheidung fuer etwas bessere Performance }
539cdf0e10cSrcweir 						//    s2:=i0-i+2;
540cdf0e10cSrcweir 						//    SetPenSize(s2);
541cdf0e10cSrcweir 						//    s2:=s2 div 2;
542cdf0e10cSrcweir 						//    Circle(cx,cy,i0-s2,i0-s2);{}
543cdf0e10cSrcweir 						//  else
544cdf0e10cSrcweir 						rOut.DrawEllipse(Rectangle(cx-i0,cy-i0,cx+i0,cy+i0));
545cdf0e10cSrcweir 						i0=i; b0=b;
546cdf0e10cSrcweir 					}
547cdf0e10cSrcweir 					i--;
548cdf0e10cSrcweir 				}
549cdf0e10cSrcweir 				SgfAreaColorIntens(F.FMuster,(sal_uInt8)Col1,(sal_uInt8)Col2,(sal_uInt8)Int1,rOut);
550cdf0e10cSrcweir 				rOut.DrawEllipse(Rectangle(cx-i0,cy-i0,cx+i0,cy+i0));
551cdf0e10cSrcweir 				rOut.SetClipRegion(ClipMerk);
552cdf0e10cSrcweir 			} break; // Kreis
553cdf0e10cSrcweir 		}
554cdf0e10cSrcweir 	}
555cdf0e10cSrcweir }
556cdf0e10cSrcweir 
557cdf0e10cSrcweir 
Draw(OutputDevice & rOut)558cdf0e10cSrcweir void RectType::Draw(OutputDevice& rOut)
559cdf0e10cSrcweir {
560cdf0e10cSrcweir 	if (L.LMuster!=0) L.LMuster=1; // keine Linienmuster hier, nur an oder aus
561cdf0e10cSrcweir 	SetArea(F,rOut);
562cdf0e10cSrcweir 	if (DrehWink==0) {
563cdf0e10cSrcweir 	if ((F.FBFarbe & 0x38)==0 || Radius!=0) {
564cdf0e10cSrcweir 			SetLine(L,rOut);
565cdf0e10cSrcweir 			rOut.DrawRect(Rectangle(Pos1.x,Pos1.y,Pos2.x,Pos2.y),Radius,Radius);
566cdf0e10cSrcweir 		} else {
567cdf0e10cSrcweir 			DrawSlideRect(Pos1.x,Pos1.y,Pos2.x,Pos2.y,F,rOut);
568cdf0e10cSrcweir 			if (L.LMuster!=0) {
569cdf0e10cSrcweir 				SetLine(L,rOut);
570cdf0e10cSrcweir 				rOut.SetFillColor();
571cdf0e10cSrcweir 				rOut.DrawRect(Rectangle(Pos1.x,Pos1.y,Pos2.x,Pos2.y));
572cdf0e10cSrcweir 			}
573cdf0e10cSrcweir 		}
574cdf0e10cSrcweir 	} else {
575cdf0e10cSrcweir 		Point  aPts[4];
576cdf0e10cSrcweir 		sal_uInt16 i;
577cdf0e10cSrcweir 		double sn,cs;
578cdf0e10cSrcweir 		sn=sin(double(DrehWink)*3.14159265359/18000);
579cdf0e10cSrcweir 		cs=cos(double(DrehWink)*3.14159265359/18000);
580cdf0e10cSrcweir 		aPts[0]=Point(Pos1.x,Pos1.y);
581cdf0e10cSrcweir 		aPts[1]=Point(Pos2.x,Pos1.y);
582cdf0e10cSrcweir 		aPts[2]=Point(Pos2.x,Pos2.y);
583cdf0e10cSrcweir 		aPts[3]=Point(Pos1.x,Pos2.y);
584cdf0e10cSrcweir 		for (i=0;i<4;i++) {
585cdf0e10cSrcweir 			RotatePoint(aPts[i],Pos1.x,Pos1.y,sn,cs);
586cdf0e10cSrcweir 		}
587cdf0e10cSrcweir 		SetLine(L,rOut);
588cdf0e10cSrcweir 		Polygon aPoly(4,aPts);
589cdf0e10cSrcweir 		rOut.DrawPolygon(aPoly);
590cdf0e10cSrcweir 	}
591cdf0e10cSrcweir }
592cdf0e10cSrcweir 
593cdf0e10cSrcweir /*************************************************************************
594cdf0e10cSrcweir |*
595cdf0e10cSrcweir |*    PolyType::Draw()
596cdf0e10cSrcweir |*
597cdf0e10cSrcweir |*    Beschreibung
598cdf0e10cSrcweir |*    Ersterstellung    JOE 23.06.93
599cdf0e10cSrcweir |*    Letzte Aenderung  JOE 23.06.93
600cdf0e10cSrcweir |*
601cdf0e10cSrcweir *************************************************************************/
Draw(OutputDevice & rOut)602cdf0e10cSrcweir void PolyType::Draw(OutputDevice& rOut)
603cdf0e10cSrcweir {
604cdf0e10cSrcweir 	if ((Flags & PolyClosBit) !=0) SetArea(F,rOut);
605cdf0e10cSrcweir 	SetLine(L,rOut);
606cdf0e10cSrcweir 	Polygon aPoly(nPoints);
607cdf0e10cSrcweir 	sal_uInt16 i;
608cdf0e10cSrcweir 	for(i=0;i<nPoints;i++) aPoly.SetPoint(Point(EckP[i].x,EckP[i].y),i);
609cdf0e10cSrcweir 	if ((Flags & PolyClosBit) !=0) {
610cdf0e10cSrcweir 		rOut.DrawPolygon(aPoly);
611cdf0e10cSrcweir 	} else {
612cdf0e10cSrcweir 		rOut.DrawPolyLine(aPoly);
613cdf0e10cSrcweir 	}
614cdf0e10cSrcweir }
615cdf0e10cSrcweir 
616cdf0e10cSrcweir /*************************************************************************
617cdf0e10cSrcweir |*
618cdf0e10cSrcweir |*    SplnType::Draw()
619cdf0e10cSrcweir |*
620cdf0e10cSrcweir |*    Beschreibung
621cdf0e10cSrcweir |*    Ersterstellung    JOE 23.06.93
622cdf0e10cSrcweir |*    Letzte Aenderung  JOE 23.06.93
623cdf0e10cSrcweir |*
624cdf0e10cSrcweir *************************************************************************/
Draw(OutputDevice & rOut)625cdf0e10cSrcweir void SplnType::Draw(OutputDevice& rOut)
626cdf0e10cSrcweir {
627cdf0e10cSrcweir 	if ((Flags & PolyClosBit) !=0) SetArea(F,rOut);
628cdf0e10cSrcweir 	SetLine(L,rOut);
629cdf0e10cSrcweir 	Polygon aPoly(0);
630cdf0e10cSrcweir 	Polygon aSpln(nPoints);
631cdf0e10cSrcweir 	sal_uInt16 i;
632cdf0e10cSrcweir 	for(i=0;i<nPoints;i++) aSpln.SetPoint(Point(EckP[i].x,EckP[i].y),i);
633cdf0e10cSrcweir 	if ((Flags & PolyClosBit) !=0) {
634cdf0e10cSrcweir 		Spline2Poly(aSpln,sal_True,aPoly);
635cdf0e10cSrcweir 		if (aPoly.GetSize()>0) rOut.DrawPolygon(aPoly);
636cdf0e10cSrcweir 	} else {
637cdf0e10cSrcweir 		Spline2Poly(aSpln,sal_False,aPoly);
638cdf0e10cSrcweir 		if (aPoly.GetSize()>0) rOut.DrawPolyLine(aPoly);
639cdf0e10cSrcweir 	}
640cdf0e10cSrcweir }
641cdf0e10cSrcweir 
642cdf0e10cSrcweir /*************************************************************************
643cdf0e10cSrcweir |*
644cdf0e10cSrcweir |*    CircType::Draw()
645cdf0e10cSrcweir |*
646cdf0e10cSrcweir |*    Beschreibung
647cdf0e10cSrcweir |*    Ersterstellung    JOE 23.06.93
648cdf0e10cSrcweir |*    Letzte Aenderung  JOE 23.06.93
649cdf0e10cSrcweir |*
650cdf0e10cSrcweir *************************************************************************/
DrawSlideCirc(sal_Int16 cx,sal_Int16 cy,sal_Int16 rx,sal_Int16 ry,ObjAreaType & F,OutputDevice & rOut)651cdf0e10cSrcweir void DrawSlideCirc(sal_Int16 cx, sal_Int16 cy, sal_Int16 rx, sal_Int16 ry, ObjAreaType& F, OutputDevice& rOut)
652cdf0e10cSrcweir {
653cdf0e10cSrcweir 	sal_Int16 x1=cx-rx;
654cdf0e10cSrcweir 	sal_Int16 y1=cy-ry;
655cdf0e10cSrcweir 	sal_Int16 x2=cx+rx;
656cdf0e10cSrcweir 	sal_Int16 y2=cy+ry;
657cdf0e10cSrcweir 
658cdf0e10cSrcweir 	sal_Int16 i,i0,b,b0;
659cdf0e10cSrcweir 	sal_Int16 Int1,Int2;
660cdf0e10cSrcweir 	sal_Int16 Col1,Col2;
661cdf0e10cSrcweir 
662cdf0e10cSrcweir 	rOut.SetLineColor();
663cdf0e10cSrcweir 	Col1=F.FBFarbe & 0x87; Col2=F.FFarbe & 0x87;
664cdf0e10cSrcweir 	Int1=100-F.FIntens; Int2=F.FIntens;
665cdf0e10cSrcweir 	if (Int1==Int2) {
666cdf0e10cSrcweir 		SgfAreaColorIntens(F.FMuster,(sal_uInt8)Col1,(sal_uInt8)Col2,(sal_uInt8)Int2,rOut);
667cdf0e10cSrcweir 		rOut.DrawEllipse(Rectangle(x1,y1,x2,y2));
668cdf0e10cSrcweir 	} else {
669cdf0e10cSrcweir 		b0=Int1;
670cdf0e10cSrcweir 		switch (F.FBFarbe & 0x38) {
671cdf0e10cSrcweir 			case 0x08: { // vertikal
672cdf0e10cSrcweir 				Region ClipMerk=rOut.GetClipRegion();
673cdf0e10cSrcweir 				i0=y1;
674cdf0e10cSrcweir 				i=y1;
675cdf0e10cSrcweir 				while (i<=y2) {
676cdf0e10cSrcweir 					b=Int1+sal_Int16((sal_Int32)(Int2-Int1)*(sal_Int32)(i-y1) /(sal_Int32)(y2-y1+1));
677cdf0e10cSrcweir 					if (b!=b0) {
678cdf0e10cSrcweir 						SgfAreaColorIntens(F.FMuster,(sal_uInt8)Col1,(sal_uInt8)Col2,(sal_uInt8)b0,rOut);
679cdf0e10cSrcweir 						rOut.SetClipRegion(Rectangle(x1,i0,x2,i-1));
680cdf0e10cSrcweir 						rOut.DrawEllipse(Rectangle(x1,y1,x2,y2));
681cdf0e10cSrcweir 						i0=i; b0=b;
682cdf0e10cSrcweir 					}
683cdf0e10cSrcweir 					i++;
684cdf0e10cSrcweir 				}
685cdf0e10cSrcweir 				SgfAreaColorIntens(F.FMuster,(sal_uInt8)Col1,(sal_uInt8)Col2,(sal_uInt8)Int2,rOut);
686cdf0e10cSrcweir 				rOut.SetClipRegion(Rectangle(x1,i0,x2,y2));
687cdf0e10cSrcweir 				rOut.DrawEllipse(Rectangle(x1,y1,x2,y2));
688cdf0e10cSrcweir 				rOut.SetClipRegion(ClipMerk);
689cdf0e10cSrcweir 			} break;
690cdf0e10cSrcweir 			case 0x28: { // horizontal
691cdf0e10cSrcweir 				Region ClipMerk=rOut.GetClipRegion();
692cdf0e10cSrcweir 				i0=x1;
693cdf0e10cSrcweir 				i=x1;
694cdf0e10cSrcweir 				while (i<=x2) {
695cdf0e10cSrcweir 					b=Int1+sal_Int16((sal_Int32)(Int2-Int1)*(sal_Int32)(i-x1) /(sal_Int32)(x2-x1+1));
696cdf0e10cSrcweir 					if (b!=b0) {
697cdf0e10cSrcweir 						SgfAreaColorIntens(F.FMuster,(sal_uInt8)Col1,(sal_uInt8)Col2,(sal_uInt8)b0,rOut);
698cdf0e10cSrcweir 						rOut.SetClipRegion(Rectangle(i0,y1,i-1,y2));
699cdf0e10cSrcweir 						rOut.DrawEllipse(Rectangle(x1,y1,x2,y2));
700cdf0e10cSrcweir 						i0=i; b0=b;
701cdf0e10cSrcweir 					}
702cdf0e10cSrcweir 					i++;
703cdf0e10cSrcweir 				}
704cdf0e10cSrcweir 				SgfAreaColorIntens(F.FMuster,(sal_uInt8)Col1,(sal_uInt8)Col2,(sal_uInt8)Int2,rOut);
705cdf0e10cSrcweir 				rOut.SetClipRegion(Rectangle(i0,y1,x2,y2));
706cdf0e10cSrcweir 				rOut.DrawEllipse(Rectangle(x1,y1,x2,y2));
707cdf0e10cSrcweir 				rOut.SetClipRegion(ClipMerk);
708cdf0e10cSrcweir 			} break;
709cdf0e10cSrcweir 
710cdf0e10cSrcweir 			case 0x18: case 0x38: { // Kreis
711cdf0e10cSrcweir 				sal_Int16 MaxR;
712cdf0e10cSrcweir 
713cdf0e10cSrcweir 				if (rx<1) rx=1;
714cdf0e10cSrcweir 				if (ry<1) ry=1;
715cdf0e10cSrcweir 				MaxR=rx;
716cdf0e10cSrcweir 				b0=Int2;
717cdf0e10cSrcweir 				i0=MaxR; if (MaxR<1) MaxR=1;
718cdf0e10cSrcweir 				i=MaxR;
719cdf0e10cSrcweir 				while (i>=0) {
720cdf0e10cSrcweir 					b=Int1+sal_Int16((sal_Int32(Int2-Int1)*sal_Int32(i)) /sal_Int32(MaxR));
721cdf0e10cSrcweir 					if (b!=b0) {
722cdf0e10cSrcweir 						sal_Int32 temp=sal_Int32(i0)*sal_Int32(ry)/sal_Int32(rx);
723cdf0e10cSrcweir 						sal_Int16 j0=sal_Int16(temp);
724cdf0e10cSrcweir 						SgfAreaColorIntens(F.FMuster,(sal_uInt8)Col1,(sal_uInt8)Col2,(sal_uInt8)b0,rOut);
725cdf0e10cSrcweir 						rOut.DrawEllipse(Rectangle(cx-i0,cy-j0,cx+i0,cy+j0));
726cdf0e10cSrcweir 						i0=i; b0=b;
727cdf0e10cSrcweir 					}
728cdf0e10cSrcweir 					i--;
729cdf0e10cSrcweir 				}
730cdf0e10cSrcweir 				SgfAreaColorIntens(F.FMuster,(sal_uInt8)Col1,(sal_uInt8)Col2,(sal_uInt8)Int1,rOut);
731cdf0e10cSrcweir 				rOut.DrawEllipse(Rectangle(cx-i0,cy-i0,cx+i0,cy+i0));
732cdf0e10cSrcweir 			} break; // Kreis
733cdf0e10cSrcweir 		}
734cdf0e10cSrcweir 	}
735cdf0e10cSrcweir }
736cdf0e10cSrcweir 
737cdf0e10cSrcweir 
Draw(OutputDevice & rOut)738cdf0e10cSrcweir void CircType::Draw(OutputDevice& rOut)
739cdf0e10cSrcweir {
740cdf0e10cSrcweir 	Rectangle aRect(Center.x-Radius.x,Center.y-Radius.y,Center.x+Radius.x,Center.y+Radius.y);
741cdf0e10cSrcweir 
742cdf0e10cSrcweir 	if (L.LMuster!=0) L.LMuster=1; // keine Linienmuster hier, nur an oder aus
743cdf0e10cSrcweir 	SetArea(F,rOut);
744cdf0e10cSrcweir 	if ((Flags & 0x03)==CircFull) {
745cdf0e10cSrcweir 		if ((F.FBFarbe & 0x38)==0) {
746cdf0e10cSrcweir 			SetLine(L,rOut);
747cdf0e10cSrcweir 			rOut.DrawEllipse(aRect);
748cdf0e10cSrcweir 		} else {
749cdf0e10cSrcweir 			DrawSlideCirc(Center.x,Center.y,Radius.x,Radius.y,F,rOut);
750cdf0e10cSrcweir 			if (L.LMuster!=0) {
751cdf0e10cSrcweir 				SetLine(L,rOut);
752cdf0e10cSrcweir 				rOut.SetFillColor();
753cdf0e10cSrcweir 				rOut.DrawEllipse(aRect);
754cdf0e10cSrcweir 			}
755cdf0e10cSrcweir 		}
756cdf0e10cSrcweir 	} else {
757cdf0e10cSrcweir 		PointType a,b;
758cdf0e10cSrcweir 		Point  aStrt,aEnde;
759cdf0e10cSrcweir 		double sn,cs;
760cdf0e10cSrcweir 
761cdf0e10cSrcweir 		a.x=Center.x+Radius.x; a.y=Center.y; b=a;
762cdf0e10cSrcweir 		sn=sin(double(StartWink)*3.14159265359/18000);
763cdf0e10cSrcweir 		cs=cos(double(StartWink)*3.14159265359/18000);
764cdf0e10cSrcweir 		RotatePoint(a,Center.x,Center.y,sn,cs);
765cdf0e10cSrcweir 		sn=sin(double(StartWink+RelWink)*3.14159265359/18000);
766cdf0e10cSrcweir 		cs=cos(double(StartWink+RelWink)*3.14159265359/18000);
767cdf0e10cSrcweir 		RotatePoint(b,Center.x,Center.y,sn,cs);
768cdf0e10cSrcweir 		if (Radius.x!=Radius.y) {
769cdf0e10cSrcweir 		  if (Radius.x<1) Radius.x=1;
770cdf0e10cSrcweir 		  if (Radius.y<1) Radius.y=1;
771cdf0e10cSrcweir 		  a.y = a.y - Center.y;
772cdf0e10cSrcweir 		  b.y = b.y - Center.y;
773cdf0e10cSrcweir 		  a.y=iMulDiv(a.y,Radius.y,Radius.x);
774cdf0e10cSrcweir 		  b.y=iMulDiv(b.y,Radius.y,Radius.x);
775cdf0e10cSrcweir 		  a.y = a.y + Center.y;
776cdf0e10cSrcweir 		  b.y = b.y + Center.y;
777cdf0e10cSrcweir 		}
778cdf0e10cSrcweir 		aStrt=Point(a.x,a.y);
779cdf0e10cSrcweir 		aEnde=Point(b.x,b.y);
780cdf0e10cSrcweir 		SetLine(L,rOut);
781cdf0e10cSrcweir 		switch (Flags & 0x03) {
782cdf0e10cSrcweir 			case CircArc : rOut.DrawArc(aRect,aEnde,aStrt); break;
783cdf0e10cSrcweir 			case CircSect:
784cdf0e10cSrcweir 			case CircAbsn: rOut.DrawPie(aRect,aEnde,aStrt); break;
785cdf0e10cSrcweir 		}
786cdf0e10cSrcweir 	}
787cdf0e10cSrcweir }
788cdf0e10cSrcweir 
789cdf0e10cSrcweir /*************************************************************************
790cdf0e10cSrcweir |*
791cdf0e10cSrcweir |*    BmapType::Draw()
792cdf0e10cSrcweir |*
793cdf0e10cSrcweir |*    Beschreibung
794cdf0e10cSrcweir |*    Ersterstellung    JOE 23.06.93
795cdf0e10cSrcweir |*    Letzte Aenderung  JOE 23.06.93
796cdf0e10cSrcweir |*
797cdf0e10cSrcweir *************************************************************************/
798cdf0e10cSrcweir 
Draw(OutputDevice & rOut)799cdf0e10cSrcweir void BmapType::Draw(OutputDevice& rOut)
800cdf0e10cSrcweir {
801cdf0e10cSrcweir 	//ifstream aInp;
802cdf0e10cSrcweir 	unsigned char	nSgfTyp;
803cdf0e10cSrcweir 	sal_uInt16			nVersion;
804cdf0e10cSrcweir 	String			aStr(
805cdf0e10cSrcweir         reinterpret_cast< char const * >(&Filename[ 1 ]),
806cdf0e10cSrcweir         (xub_StrLen)Filename[ 0 ], RTL_TEXTENCODING_UTF8 );
807cdf0e10cSrcweir 	INetURLObject	aFNam( aStr );
808cdf0e10cSrcweir 
809cdf0e10cSrcweir 	SvStream* pInp = ::utl::UcbStreamHelper::CreateStream( aFNam.GetMainURL( INetURLObject::NO_DECODE ), STREAM_READ );
810cdf0e10cSrcweir 	if ( pInp )
811cdf0e10cSrcweir 	{
812cdf0e10cSrcweir 		nSgfTyp=CheckSgfTyp( *pInp,nVersion);
813cdf0e10cSrcweir 		switch(nSgfTyp) {
814cdf0e10cSrcweir 			case SGF_BITIMAGE: {
815cdf0e10cSrcweir 				GraphicFilter aFlt;
816cdf0e10cSrcweir 				Graphic aGrf;
817cdf0e10cSrcweir 				sal_uInt16 nRet;
818cdf0e10cSrcweir 				nRet=aFlt.ImportGraphic(aGrf,aFNam);
819cdf0e10cSrcweir 				aGrf.Draw(&rOut,Point(Pos1.x,Pos1.y),Size(Pos2.x-Pos1.x,Pos2.y-Pos1.y));
820cdf0e10cSrcweir 			} break;
821cdf0e10cSrcweir 			case SGF_SIMPVECT: {
822cdf0e10cSrcweir 				GDIMetaFile aMtf;
823cdf0e10cSrcweir 				SgfVectXofs=Pos1.x;
824cdf0e10cSrcweir 				SgfVectYofs=Pos1.y;
825cdf0e10cSrcweir 				SgfVectXmul=Pos2.x-Pos1.x;
826cdf0e10cSrcweir 				SgfVectYmul=Pos2.y-Pos1.y;
827cdf0e10cSrcweir 				SgfVectXdiv=0;
828cdf0e10cSrcweir 				SgfVectYdiv=0;
829cdf0e10cSrcweir 				SgfVectScal=sal_True;
830cdf0e10cSrcweir 				SgfVectFilter(*pInp,aMtf);
831cdf0e10cSrcweir 				SgfVectXofs=0;
832cdf0e10cSrcweir 				SgfVectYofs=0;
833cdf0e10cSrcweir 				SgfVectXmul=0;
834cdf0e10cSrcweir 				SgfVectYmul=0;
835cdf0e10cSrcweir 				SgfVectXdiv=0;
836cdf0e10cSrcweir 				SgfVectYdiv=0;
837cdf0e10cSrcweir 				SgfVectScal=sal_False;
838cdf0e10cSrcweir 				aMtf.Play(&rOut);
839cdf0e10cSrcweir 			} break;
840cdf0e10cSrcweir 		}
841cdf0e10cSrcweir 		delete pInp;
842cdf0e10cSrcweir 	}
843cdf0e10cSrcweir }
844cdf0e10cSrcweir 
845cdf0e10cSrcweir 
846cdf0e10cSrcweir /*************************************************************************
847cdf0e10cSrcweir |*
848cdf0e10cSrcweir |*    GrupType::...
849cdf0e10cSrcweir |*
850cdf0e10cSrcweir |*    Beschreibung
851cdf0e10cSrcweir |*    Ersterstellung    JOE 23.06.93
852cdf0e10cSrcweir |*    Letzte Aenderung  JOE 23.06.93
853cdf0e10cSrcweir |*
854cdf0e10cSrcweir *************************************************************************/
GetSubPtr()855cdf0e10cSrcweir sal_uInt32 GrupType::GetSubPtr()
856cdf0e10cSrcweir {
857cdf0e10cSrcweir 	return sal_uInt32(SbLo)+0x00010000*sal_uInt32(SbHi);
858cdf0e10cSrcweir }
859cdf0e10cSrcweir 
860cdf0e10cSrcweir /*************************************************************************
861cdf0e10cSrcweir |*
862cdf0e10cSrcweir |*    DrawObjkList()
863cdf0e10cSrcweir |*
864cdf0e10cSrcweir |*    Beschreibung
865cdf0e10cSrcweir |*    Ersterstellung    JOE 23.06.93
866cdf0e10cSrcweir |*    Letzte Aenderung  JOE 23.06.93
867cdf0e10cSrcweir |*
868cdf0e10cSrcweir *************************************************************************/
DrawObjkList(SvStream & rInp,OutputDevice & rOut)869cdf0e10cSrcweir void DrawObjkList( SvStream& rInp, OutputDevice& rOut )
870cdf0e10cSrcweir {
871cdf0e10cSrcweir 	ObjkType aObjk;
872cdf0e10cSrcweir 	sal_uInt16 nGrpCnt=0;
873cdf0e10cSrcweir 	sal_Bool bEnde=sal_False;
874cdf0e10cSrcweir 	do {
875cdf0e10cSrcweir 		rInp>>aObjk;
876cdf0e10cSrcweir 		if (!rInp.GetError()) {
877cdf0e10cSrcweir 			switch(aObjk.Art) {
878cdf0e10cSrcweir 				case ObjStrk: { StrkType aStrk; rInp>>aStrk; if (!rInp.GetError()) aStrk.Draw(rOut); } break;
879cdf0e10cSrcweir 				case ObjRect: { RectType aRect; rInp>>aRect; if (!rInp.GetError()) aRect.Draw(rOut); } break;
880cdf0e10cSrcweir 				case ObjCirc: { CircType aCirc; rInp>>aCirc; if (!rInp.GetError()) aCirc.Draw(rOut); } break;
881cdf0e10cSrcweir 				case ObjText: {
882cdf0e10cSrcweir 					TextType aText;
883cdf0e10cSrcweir 					rInp>>aText;
884cdf0e10cSrcweir 					if (!rInp.GetError()) {
885cdf0e10cSrcweir                         aText.Buffer=new UCHAR[aText.BufSize+1]; // Ein mehr fuer LookAhead bei CK-Trennung
886cdf0e10cSrcweir 						rInp.Read((char* )aText.Buffer,aText.BufSize);
887cdf0e10cSrcweir 						if (!rInp.GetError()) aText.Draw(rOut);
888cdf0e10cSrcweir 						delete[] aText.Buffer;
889cdf0e10cSrcweir 					}
890cdf0e10cSrcweir 				} break;
891cdf0e10cSrcweir 				case ObjBmap: {
892cdf0e10cSrcweir 					BmapType aBmap;
893cdf0e10cSrcweir 					rInp>>aBmap;
894cdf0e10cSrcweir 					if (!rInp.GetError()) {
895cdf0e10cSrcweir 						aBmap.Draw(rOut);
896cdf0e10cSrcweir 					}
897cdf0e10cSrcweir 				} break;
898cdf0e10cSrcweir 				case ObjPoly: {
899cdf0e10cSrcweir 					PolyType aPoly;
900cdf0e10cSrcweir 					rInp>>aPoly;
901cdf0e10cSrcweir 					if (!rInp.GetError()) {
902cdf0e10cSrcweir 						aPoly.EckP=new PointType[aPoly.nPoints];
903cdf0e10cSrcweir 						rInp.Read((char*)aPoly.EckP,4*aPoly.nPoints);
904cdf0e10cSrcweir #if defined OSL_BIGENDIAN
905cdf0e10cSrcweir 						for(short i=0;i<aPoly.nPoints;i++) SWAPPOINT(aPoly.EckP[i]);
906cdf0e10cSrcweir #endif
907cdf0e10cSrcweir 						if (!rInp.GetError()) aPoly.Draw(rOut);
908cdf0e10cSrcweir 						delete[] aPoly.EckP;
909cdf0e10cSrcweir 					}
910cdf0e10cSrcweir 				} break;
911cdf0e10cSrcweir 				case ObjSpln: {
912cdf0e10cSrcweir 					SplnType aSpln;
913cdf0e10cSrcweir 					rInp>>aSpln;
914cdf0e10cSrcweir 					if (!rInp.GetError()) {
915cdf0e10cSrcweir 						aSpln.EckP=new PointType[aSpln.nPoints];
916cdf0e10cSrcweir 						rInp.Read((char*)aSpln.EckP,4*aSpln.nPoints);
917cdf0e10cSrcweir #if defined OSL_BIGENDIAN
918cdf0e10cSrcweir 						for(short i=0;i<aSpln.nPoints;i++) SWAPPOINT(aSpln.EckP[i]);
919cdf0e10cSrcweir #endif
920cdf0e10cSrcweir 						if (!rInp.GetError()) aSpln.Draw(rOut);
921cdf0e10cSrcweir 						delete[] aSpln.EckP;
922cdf0e10cSrcweir 					}
923cdf0e10cSrcweir 				} break;
924cdf0e10cSrcweir 				case ObjGrup: {
925cdf0e10cSrcweir 					GrupType aGrup;
926cdf0e10cSrcweir 					rInp>>aGrup;
927cdf0e10cSrcweir 					if (!rInp.GetError()) {
928cdf0e10cSrcweir                         rInp.Seek(rInp.Tell()+aGrup.Last); // Obj-Anhaengsel
929cdf0e10cSrcweir 						if(aGrup.GetSubPtr()!=0L) nGrpCnt++;// DrawObjkList(rInp,rOut );
930cdf0e10cSrcweir 					}
931cdf0e10cSrcweir 				} break;
932cdf0e10cSrcweir 				default: {
933cdf0e10cSrcweir 					aObjk.Draw(rOut);          // Objektbezeichnung auf 2. Screen
934cdf0e10cSrcweir                     ObjkOverSeek(rInp,aObjk);  // zum naechsten Objekt
935cdf0e10cSrcweir 				}
936cdf0e10cSrcweir 			}
937cdf0e10cSrcweir 		} // if rInp
938cdf0e10cSrcweir 		if (!rInp.GetError()) {
939cdf0e10cSrcweir 			if (aObjk.Next==0L) {
940cdf0e10cSrcweir 				if (nGrpCnt==0) bEnde=sal_True;
941cdf0e10cSrcweir 				else nGrpCnt--;
942cdf0e10cSrcweir 			}
943cdf0e10cSrcweir 		} else {
944cdf0e10cSrcweir 			bEnde=sal_True;  // Lesefehler
945cdf0e10cSrcweir 		}
946cdf0e10cSrcweir 	} while (!bEnde);
947cdf0e10cSrcweir }
948cdf0e10cSrcweir 
949cdf0e10cSrcweir /*************************************************************************
950cdf0e10cSrcweir |*
951cdf0e10cSrcweir |*    SkipObjkList()
952cdf0e10cSrcweir |*
953cdf0e10cSrcweir |*    Beschreibung
954cdf0e10cSrcweir |*    Ersterstellung    JOE 23.06.93
955cdf0e10cSrcweir |*    Letzte Aenderung  JOE 23.06.93
956cdf0e10cSrcweir |*
957cdf0e10cSrcweir *************************************************************************/
SkipObjkList(SvStream & rInp)958cdf0e10cSrcweir void SkipObjkList(SvStream& rInp)
959cdf0e10cSrcweir {
960cdf0e10cSrcweir 	ObjkType aObjk;
961cdf0e10cSrcweir 	do
962cdf0e10cSrcweir 	{
963cdf0e10cSrcweir 		rInp>>aObjk;
964cdf0e10cSrcweir 		if(aObjk.Art==ObjGrup) {
965cdf0e10cSrcweir 			GrupType aGrup;
966cdf0e10cSrcweir 			rInp>>aGrup;
967cdf0e10cSrcweir             rInp.Seek(rInp.Tell()+aGrup.Last); // Obj-Anhaengsel
968cdf0e10cSrcweir 			if(aGrup.GetSubPtr()!=0L) SkipObjkList(rInp);
969cdf0e10cSrcweir 		} else {
970cdf0e10cSrcweir             ObjkOverSeek(rInp,aObjk);  // zum naechsten Objekt
971cdf0e10cSrcweir 		}
972cdf0e10cSrcweir 	} while (aObjk.Next!=0L && !rInp.GetError());
973cdf0e10cSrcweir }
974cdf0e10cSrcweir 
975cdf0e10cSrcweir /*************************************************************************
976cdf0e10cSrcweir |*
977cdf0e10cSrcweir |*    SgfFilterSDrw()
978cdf0e10cSrcweir |*
979cdf0e10cSrcweir |*    Beschreibung
980cdf0e10cSrcweir |*    Ersterstellung    JOE 23.06.93
981cdf0e10cSrcweir |*    Letzte Aenderung  JOE 23.06.93
982cdf0e10cSrcweir |*
983cdf0e10cSrcweir *************************************************************************/
SgfFilterSDrw(SvStream & rInp,SgfHeader &,SgfEntry &,GDIMetaFile & rMtf)984cdf0e10cSrcweir sal_Bool SgfFilterSDrw( SvStream& rInp, SgfHeader&, SgfEntry&, GDIMetaFile& rMtf )
985cdf0e10cSrcweir {
986cdf0e10cSrcweir 	sal_Bool          bRet = sal_False;
987cdf0e10cSrcweir 	PageType      aPage;
988cdf0e10cSrcweir 	VirtualDevice aOutDev;
989cdf0e10cSrcweir 	OutputDevice* pOutDev;
990cdf0e10cSrcweir 	sal_uLong         nStdPos;
991cdf0e10cSrcweir 	sal_uLong         nZchPos;
992cdf0e10cSrcweir 	sal_uInt16        Num;
993cdf0e10cSrcweir 
994cdf0e10cSrcweir 	pOutDev=&aOutDev;
995cdf0e10cSrcweir 	DtHdOverSeek(rInp); // DataHeader weglesen
996cdf0e10cSrcweir 
997cdf0e10cSrcweir 	nStdPos=rInp.Tell();
998cdf0e10cSrcweir 	do {                // Standardseiten weglesen
999cdf0e10cSrcweir 		rInp>>aPage;
1000cdf0e10cSrcweir 		if (aPage.nList!=0) SkipObjkList(rInp);
1001cdf0e10cSrcweir 	} while (aPage.Next!=0L && !rInp.GetError());
1002cdf0e10cSrcweir 
1003cdf0e10cSrcweir //    ShowMsg("Zeichnungseite(n)\n");
1004cdf0e10cSrcweir 	nZchPos=rInp.Tell();
1005cdf0e10cSrcweir 	rInp>>aPage;
1006cdf0e10cSrcweir 
1007cdf0e10cSrcweir 	rMtf.Record(pOutDev);
1008cdf0e10cSrcweir 	Num=aPage.StdPg;
1009cdf0e10cSrcweir 	if (Num!=0) {
1010cdf0e10cSrcweir 	  rInp.Seek(nStdPos);
1011cdf0e10cSrcweir 	  while(Num>1 && aPage.Next!=0L && !rInp.GetError()) { // Standardseite suchen
1012cdf0e10cSrcweir 		rInp>>aPage;
1013cdf0e10cSrcweir 		if (aPage.nList!=0) SkipObjkList(rInp);
1014cdf0e10cSrcweir 		Num--;
1015cdf0e10cSrcweir 	  }
1016cdf0e10cSrcweir 	  rInp>>aPage;
1017cdf0e10cSrcweir 	  if(Num==1 && aPage.nList!=0L) DrawObjkList( rInp,*pOutDev );
1018cdf0e10cSrcweir 	  rInp.Seek(nZchPos);
1019cdf0e10cSrcweir 	  nZchPos=rInp.Tell();
1020cdf0e10cSrcweir 	  rInp>>aPage;
1021cdf0e10cSrcweir 	}
1022cdf0e10cSrcweir 	if (aPage.nList!=0L) DrawObjkList(rInp,*pOutDev );
1023cdf0e10cSrcweir 
1024cdf0e10cSrcweir 	rMtf.Stop();
1025cdf0e10cSrcweir 	rMtf.WindStart();
1026cdf0e10cSrcweir 	MapMode aMap(MAP_10TH_MM,Point(),Fraction(1,4),Fraction(1,4));
1027cdf0e10cSrcweir 	rMtf.SetPrefMapMode(aMap);
1028cdf0e10cSrcweir 	rMtf.SetPrefSize(Size((sal_Int16)aPage.Paper.Size.x,(sal_Int16)aPage.Paper.Size.y));
1029cdf0e10cSrcweir 	bRet=sal_True;
1030cdf0e10cSrcweir 	return bRet;
1031cdf0e10cSrcweir }
1032cdf0e10cSrcweir 
1033cdf0e10cSrcweir 
1034cdf0e10cSrcweir 
1035cdf0e10cSrcweir /*************************************************************************
1036cdf0e10cSrcweir |*
1037cdf0e10cSrcweir |*    SgfSDrwFilter()
1038cdf0e10cSrcweir |*
1039cdf0e10cSrcweir |*    Beschreibung
1040cdf0e10cSrcweir |*    Ersterstellung    JOE 23.06.93
1041cdf0e10cSrcweir |*    Letzte Aenderung  JOE 23.06.93
1042cdf0e10cSrcweir |*
1043cdf0e10cSrcweir *************************************************************************/
SgfSDrwFilter(SvStream & rInp,GDIMetaFile & rMtf,INetURLObject aIniPath)1044cdf0e10cSrcweir sal_Bool SgfSDrwFilter(SvStream& rInp, GDIMetaFile& rMtf, INetURLObject aIniPath )
1045cdf0e10cSrcweir {
1046cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 // Recordgroessen checken. Neuer Compiler hat vielleichte anderes Alignment!
1047cdf0e10cSrcweir 	if (sizeof(ObjTextType)!=ObjTextTypeSize)  return sal_False;
1048cdf0e10cSrcweir #endif
1049cdf0e10cSrcweir 
1050cdf0e10cSrcweir 	sal_uLong     nFileStart;            // Offset des SgfHeaders. Im allgemeinen 0.
1051cdf0e10cSrcweir 	SgfHeader aHead;
1052cdf0e10cSrcweir 	SgfEntry  aEntr;
1053cdf0e10cSrcweir 	sal_uLong     nNext;
1054cdf0e10cSrcweir 	sal_Bool      bRdFlag=sal_False;         // Grafikentry gelesen ?
1055cdf0e10cSrcweir 	sal_Bool      bRet=sal_False;            // Returncode
1056cdf0e10cSrcweir 
1057cdf0e10cSrcweir 	aIniPath.Append( String::CreateFromAscii( "sgf.ini", 7 ) );
1058cdf0e10cSrcweir //	aIniPath.ToAbs();
1059cdf0e10cSrcweir 
1060cdf0e10cSrcweir 	pSgfFonts = new SgfFontLst;
1061cdf0e10cSrcweir 
1062cdf0e10cSrcweir 	pSgfFonts->AssignFN( aIniPath.GetMainURL( INetURLObject::NO_DECODE ) );
1063cdf0e10cSrcweir 	nFileStart=rInp.Tell();
1064cdf0e10cSrcweir 	rInp>>aHead;
1065cdf0e10cSrcweir 	if (aHead.ChkMagic() && aHead.Typ==SgfStarDraw && aHead.Version==SGV_VERSION) {
1066cdf0e10cSrcweir 		nNext=aHead.GetOffset();
1067cdf0e10cSrcweir 		while (nNext && !bRdFlag && !rInp.GetError()) {
1068cdf0e10cSrcweir 			rInp.Seek(nFileStart+nNext);
1069cdf0e10cSrcweir 			rInp>>aEntr;
1070cdf0e10cSrcweir 			nNext=aEntr.GetOffset();
1071cdf0e10cSrcweir 			if (aEntr.Typ==aHead.Typ) {
1072cdf0e10cSrcweir 				bRet=SgfFilterSDrw( rInp,aHead,aEntr,rMtf );
1073cdf0e10cSrcweir 			}
1074cdf0e10cSrcweir 		} // while(nNext)
1075cdf0e10cSrcweir 		if (bRdFlag) {
1076cdf0e10cSrcweir 			if (!rInp.GetError()) bRet=sal_True;  // Scheinbar Ok
1077cdf0e10cSrcweir 		}
1078cdf0e10cSrcweir 	}
1079cdf0e10cSrcweir 	delete pSgfFonts;
1080cdf0e10cSrcweir 	return(bRet);
1081cdf0e10cSrcweir }
1082cdf0e10cSrcweir 
1083cdf0e10cSrcweir /*
1084cdf0e10cSrcweir Bitmap Dither(sal_uInt8 Intens)
1085cdf0e10cSrcweir {
1086cdf0e10cSrcweir 	Bitmap aBmp;
1087cdf0e10cSrcweir 	BmpInfoHeader Info;
1088cdf0e10cSrcweir 
1089cdf0e10cSrcweir 
1090cdf0e10cSrcweir const dmatrix: array[0..7,0..7] of byte =
1091cdf0e10cSrcweir 		((  0, 48, 12, 60,  3, 51, 15, 63 ),
1092cdf0e10cSrcweir 		 ( 32, 16, 44, 28, 35, 19, 47, 31 ),
1093cdf0e10cSrcweir 		 (  8, 56,  4, 52, 11, 59,  7, 55 ),
1094cdf0e10cSrcweir 		 ( 40, 24, 36, 20, 43, 27, 39, 23 ),
1095cdf0e10cSrcweir 		 (  2, 50, 14, 62,  1, 49, 13, 61 ),
1096cdf0e10cSrcweir 		 ( 34, 18, 46, 30, 33, 17, 45, 29 ),
1097cdf0e10cSrcweir 		 ( 10, 58,  6, 54,  9, 57,  5, 53 ),
1098cdf0e10cSrcweir 		 ( 42, 26, 38, 22, 41, 25, 37, 21 ));
1099cdf0e10cSrcweir 
1100cdf0e10cSrcweir 
1101cdf0e10cSrcweir 	cmatrix: array[0..7,0..7] of byte;
1102cdf0e10cSrcweir 	dmatrixn,dmatrixi: array[0..7] of byte;
1103cdf0e10cSrcweir 
1104cdf0e10cSrcweir 
1105cdf0e10cSrcweir procedure SetColorIntens(col0,col1,bal: integer);
1106cdf0e10cSrcweir var cmatrix0: array[0..63] of byte absolute cmatrix;
1107cdf0e10cSrcweir 	dmatrix0: array[0..63] of byte absolute dmatrix;
1108cdf0e10cSrcweir 	n,i: integer;
1109cdf0e10cSrcweir 	b,bit: byte;
1110cdf0e10cSrcweir begin
1111cdf0e10cSrcweir if col0=col1 then bal:=0;
1112cdf0e10cSrcweir if bal<=32 then
1113cdf0e10cSrcweir   begin
1114cdf0e10cSrcweir   plotcolor0:=col0 and $1F; plotcolor1:=col1 and $1F;
1115cdf0e10cSrcweir   plotbal:=bal;
1116cdf0e10cSrcweir   end
1117cdf0e10cSrcweir else
1118cdf0e10cSrcweir   begin
1119cdf0e10cSrcweir   plotcolor0:=col1 and $1F; plotcolor1:=col0 and $1F;
1120cdf0e10cSrcweir   plotbal:=64-bal;
1121cdf0e10cSrcweir   end;
1122cdf0e10cSrcweir for n:=0 to 63 do
1123cdf0e10cSrcweir  if plotbal<=dmatrix0[n] then cmatrix0[n]:=col0 else cmatrix0[n]:=col1;
1124cdf0e10cSrcweir end;
1125cdf0e10cSrcweir */
1126cdf0e10cSrcweir 
1127