xref: /AOO41X/main/svtools/source/inc/sgvmain.hxx (revision 01aa44aa134af97080e2cf8e8bf3a0a4cd1cffe0)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SGVMAIN_HXX
25 #define _SGVMAIN_HXX
26 
27 #include <vcl/font.hxx>
28 #include <vcl/outdev.hxx>
29 #include <vcl/virdev.hxx>
30 
31 
32 #define UCHAR unsigned char
33 
34 struct PointType {
35     sal_Int16 x;
36     sal_Int16 y;
37 };
38 
39 #define SgfDpmm 40
40 
41 #define DtHdSize 256
42 class DtHdType {
43 public:
44     sal_uInt8  Reserved[256];
45     friend SvStream& operator>>(SvStream& rIStream, DtHdType& rDtHd);
46     friend void DtHdOverSeek(SvStream& rInp);
47 };
48 
49 
50 struct Seitenformat {
51     PointType Size;       // 0.00mm...819.175mm (Papiergr��e)
52     sal_Int16     RandL;      // links     Rand auf
53     sal_Int16     RandR;      // rechts    dem Papier
54     sal_Int16     RandO;      // oben      Rand auf
55     sal_Int16     RandU;      // unten     dem Papier
56     sal_uInt8      PColor;     // Future Use
57     sal_uInt8      PIntens;    // erst recht Future use
58 //    sal_Bool      BorderClip; // Objekte am Rand abschneiden (Schummel wg. Allignment unter NT)
59 };
60 
61 
62 #define PageSize 146
63 class PageType {
64 public:
65     sal_uInt32       Next;       // N�chste Seite
66     sal_uInt32       nList;      // Objektdaten, erster Record
67     sal_uInt32       ListEnd;    // Objektdaten, letzter Record
68     Seitenformat Paper;      // Papierdaten
69     sal_Bool         BorderClip; // Objekte am Rand abschneiden (Schummel wg. Allignment unter NT)
70     sal_uInt8         StdPg;      // welche Standardseite einblenden ?
71     PointType    U;          // Nullpunkt
72     sal_Int16        HlpLnH[20]; // Hilfslinien
73     sal_Int16        HlpLnV[20];
74     sal_uInt8         LnAnzH;
75     sal_uInt8         LnAnzV;
76     UCHAR        PgName[32]; // Seitenname
77     friend SvStream& operator>>(SvStream& rIStream, PageType& rPage);
78 };
79 
80 
81 enum ObjArtType {ObjStrk,ObjRect,ObjPoly,ObjCirc,ObjSpln,
82                  ObjText,ObjGrup,ObjBmap,ObjVirt,ObjTxtX,ObjMaxi};
83 
84 struct ObjLineType {
85     sal_uInt8  LFarbe;    //  [Index]
86     sal_uInt8  LBFarbe;   //  [Index]
87     sal_uInt8  LIntens;   //  [%]
88     sal_uInt8  LMuster;   //  [Index] inkl. Transparenz
89     sal_Int16 LMSize;    //  [Koeffizient/100]
90     sal_Int16 LDicke;    //  Strichst�rke
91 };
92 
93 struct ObjAreaType {
94     sal_uInt8   FFarbe;   //  [Index]
95     sal_uInt8   FBFarbe;  //  [Index]
96     sal_uInt8   FIntens;  //  [%]
97     sal_uInt8   FDummy1;  //
98     sal_Int16  FDummy2;  //
99     sal_uInt16 FMuster;  //  [Index] inkl. Invers, Transparenz
100 };
101 
102 #define ObjTextTypeSize 64
103 class ObjTextType {
104 public:
105     ObjLineType  L;        // Text-Outline (future)
106     ObjAreaType  F;        // Text innen
107     sal_uInt16       FontLo,FontHi;// z.B. 92500 (CG Times), zweigeteilt wegen DWordAllign in TextType.
108     sal_uInt16       Grad;     // 0.5..32767.5 Pt - bei 1000 Pt sollte aber schlu� sein
109     sal_uInt16       Breite;   // 1..65535%  bitte nicht mehr als 500%
110     sal_uInt8         Justify;  // 2 Bit Vert (Hi), 3 Bit Hor (Lo)
111     sal_uInt8         Kapit;    // 1..255%
112     sal_uInt16       Schnitt;  // 8 Flags
113     sal_uInt16       LnFeed;   // 1..32767% vom max. Schriftgrad der Zeile
114     sal_uInt16       Slant;    // Kursivwinkel 0.00..89.99� default 15.00�          doppelt Breit angesehen)
115     sal_uInt8         ZAbst;    // Zeichenabstand 0..255% (0=auf der Stelle; 100=normal; 200=Zeichen wird als
116     sal_sChar         ChrVPos;  // Zeichen V-Position default 0= on Baseline, 10= 5Pt drunter (-64..63�)
117     ObjLineType  ShdL;     // Schatten-Outline (neu 2.0)
118     ObjAreaType  ShdF;     // Schatten-innen   (neu 2.0)
119     PointType    ShdVers;  // Schattenversatz Max.300.00%
120     sal_Bool         ShdAbs;   // True-> Schattenversatz ist absolut statt relativ zum Schriftgrad
121     sal_Bool         NoSpc;    // True-> kein Zwischenraum (f�r BackArea)
122     ObjAreaType  BackF;    // Hintergrundfl�che
123     sal_uInt32 GetFont();
124     void   SetFont(sal_uInt32 FontID);
125 };
126 
127 class Obj0Type {           // SuperClass f�r Apple-VMT
128 public:
129     virtual void Draw(OutputDevice& rOut);
~Obj0Type()130     virtual ~Obj0Type() {}
131 };
132 
133 #define ObjkSize 20  /* eigentlich 21. Wg. Allignment ist Flags jedoch verschoben worden*/
134 class ObjkType: public Obj0Type {  // Grundkomponenten aller Stardraw-Objekte
135 public:
136     sal_uInt32     Last;
137     sal_uInt32     Next;
138     sal_uInt16     MemSize;    // in Bytes
139     PointType  ObjMin;     // XY-Minimum des Objekts
140     PointType  ObjMax;     // XY-Maximum des Objekts
141     sal_uInt8       Art;
142     sal_uInt8       Layer;
143 //    sal_uInt8       Flags;    // (Schummel f�r Allignment unter NT)
144     friend SvStream& operator>>(SvStream& rIStream, ObjkType& rObjk);
145     friend sal_Bool ObjOverSeek(SvStream& rInp, ObjkType& rObjk);
146     virtual void Draw(OutputDevice& rOut);
147 };
148 
149 
150 #define StrkSize 38
151 class StrkType: public ObjkType {
152 public:
153     sal_uInt8        Flags;     // (Schummel f�r Allignment unter NT)
154     sal_uInt8        LEnden;    // Linienenden
155     ObjLineType L;
156     PointType   Pos1;      // Anfangspunkt
157     PointType   Pos2;      // Endpunkt
158     friend SvStream& operator>>(SvStream& rIStream, StrkType& rStrk);
159     virtual void Draw(OutputDevice& rOut);
160 };
161 
162 
163 #define RectSize 52
164 class RectType: public ObjkType {
165 public:
166     sal_uInt8        Flags;    // (Schummel f�r Allignment unter NT)
167     sal_uInt8        Reserve;
168     ObjLineType L;
169     ObjAreaType F;
170     PointType   Pos1;      // LO-Ecke = Bezugspunkt
171     PointType   Pos2;      // R-Ecke
172     sal_Int16       Radius;    // Eckenradius
173     sal_uInt16      DrehWink;  //  315...<45
174     sal_uInt16      Slant;     // >270...<90
175     friend SvStream& operator>>(SvStream& rIStream, RectType& rRect);
176     virtual void Draw(OutputDevice& rOut);
177 };
178 
179 
180 #define PolySize 44
181 class PolyType: public ObjkType { // identisch mit Spline !
182 public:
183     sal_uInt8        Flags;    // (Schummel f�r Allignment unter NT)
184     sal_uInt8        LEnden;  // nur f�r Polyline
185     ObjLineType L;
186     ObjAreaType F;       // nicht f�r Polyline
187     sal_uInt8        nPoints;
188     sal_uInt8        Reserve;
189     sal_uInt32      SD_EckP; // Zeiger auf die Eckpunkte (StarDraw)
190     PointType*  EckP;    // Zeiger auf die Eckpunkte (StarView (wird nicht von Disk gelesen!))
191     friend SvStream& operator>>(SvStream& rIStream, PolyType& rPoly);
192     virtual void Draw(OutputDevice& rOut);
193 };
194 #define  PolyClosBit 0x01   // Unterarten von Poly:   0: PolyLine  1: Polygon
195 
196 
197 #define SplnSize 44
198 class SplnType: public ObjkType { // identisch mit Poly !
199 public:
200     sal_uInt8        Flags;    // (Schummel f�r Allignment unter NT)
201     sal_uInt8        LEnden;  // nur f�r nSpline
202     ObjLineType L;
203     ObjAreaType F;       // nicht f�r nSpline
204     sal_uInt8        nPoints;
205     sal_uInt8        Reserve;
206     sal_uInt32      SD_EckP; // Zeiger auf die Eckpunkte (StarDraw)
207     PointType*  EckP;    // Zeiger auf die Eckpunkte (StarView (wird nicht von Disk gelesen!))
208     friend SvStream& operator>>(SvStream& rIStream, SplnType& rSpln);
209     virtual void Draw(OutputDevice& rOut);
210 };
211 // Unterarten von Spline: siehe Poly
212 
213 
214 #define CircSize 52
215 class CircType: public ObjkType {
216 public:
217     sal_uInt8        Flags;    // (Schummel f�r Allignment unter NT)
218     sal_uInt8        LEnden;    // nur Bogen (Kr & El)
219     ObjLineType L;
220     ObjAreaType F;         // nicht f�r Bogen (Kr & El)
221     PointType   Center;    // Mittelpunkt
222     PointType   Radius;    // Radius
223     sal_uInt16      DrehWink;  // nur Ellipse
224     sal_uInt16      StartWink; // � nicht f�r Vollkreis
225     sal_uInt16      RelWink;   // � und Vollellipse
226     friend SvStream& operator>>(SvStream& rIStream, CircType& rCirc);
227     virtual void Draw(OutputDevice& rOut);
228 };
229 #define CircFull 0x00  /* Unterarten von Kreis:  0: Kreis          */
230 #define CircSect 0x01  /*                        1: Kreissektor    */
231 #define CircAbsn 0x02  /*                        2: Kreisabschnitt */
232 #define CircArc  0x03  /*                        3: Kreisbogen     */
233 
234 
235 #define TextSize 116
236 class TextType: public ObjkType {
237 public:
238     sal_uInt8        Flags;    // (Schummel f�r Allignment unter NT)
239     sal_uInt8        Reserve;   // f�r Word Allign
240     ObjTextType T;         // 64 Bytes  << DWord-Allign bei FontID erforderlich
241     PointType   Pos1;      // Bezugspunkt (ObenLinks)
242     PointType   Pos2;      //             (untenRechts)
243     sal_Int16       TopOfs;    // Von Oberkante bis Textbegin (future f�r vJustify)
244     sal_uInt16      DrehWink;  //    0...<360
245     sal_uInt16      BoxSlant;  // >270...<90 (nur Box)
246     sal_uInt16      BufSize;   // Gr��e von Buf f�r Load, Save, Copy und so
247     sal_uInt16      BufLo,BufHi;// (UCHAR*) Zeiger auf den Textbuffer << ShortArr, weil sonst DWord-Allign erforderlich
248     sal_uInt16      ExtLo,ExtHi;// (Ptr)  Text �ber mehrere Rahmen    << ShortArr, weil sonst DWord-Allign erforderlich
249     PointType   FitSize;   // Ursprungsgr��e f�r Fit2Size
250     sal_Int16       FitBreit;  // Breite zum formatieren bei Fit2Size
251     UCHAR*      Buffer;    // Diese Variable wird nicht durch Lesen von Disk gef�llt, sondern explizit!
252     friend SvStream& operator>>(SvStream& rIStream, TextType& rText);
253     virtual void Draw(OutputDevice& rOut);
254 };
255 #define TextOutlBit 0x01     /*       1=Sourcecode f�r Outliner (wird von DrawObjekt() ignoriert) */
256 #define TextFitSBit 0x02     /* Bit1: 1=Text-FitToSize, auch Outliner (2.0)       */
257 #define TextFitZBit 0x08     /* Bit3: 1=Fit2Size Zeilenweise          (2.0)       */
258 #define TextDrftBit 0x04     /* Bit2: 1=DraftDraw                     (2.0)       */
259 #define TextFitBits (TextFitSBit | TextFitZBit)
260 
261 
262 enum GrafStat {NoGraf,Pic,Pcx,Hpgl,Img,Msp,Tiff,Dxf,Lot,Usr,Sgf};
263 
264 #define BmapSize 132
265 class BmapType: public ObjkType {
266 public:
267     sal_uInt8        Flags;    // (Schummel f�r Allignment unter NT)
268     sal_uInt8        Reserve;
269     ObjAreaType F;            // Farbe und Muster der 1-Plane Bitmap
270     PointType   Pos1;
271     PointType   Pos2;
272     sal_uInt16      DrehWink;     //  315...<45   (Future)
273     sal_uInt16      Slant;        // >270...<90   (Future)
274     UCHAR       Filename[80]; //  Pfad
275     PointType   PixSize;      // Gr��e in Pixel (0 bei Vektor)
276     GrafStat    Format;       // siehe GpmDef.Pas
277     sal_uInt8        nPlanes;      // Anzahl der Bitplanes (0 bei Vektor)
278     sal_Bool        RawOut;       // als Raw ausgeben ?
279     sal_Bool        InvOut;       // invertiert ausgeben ?
280     sal_Bool        LightOut;     // aufhellen? (SD20)
281     sal_uInt8        GrfFlg;       // (SD20) 0=nSGF 1=Pcx 2=Hpgl 4=Raw $FF=Undef(f�r Fix in DrawBmp)
282 
283     INetURLObject aFltPath;     // F�r GraphicFilter
284     friend SvStream& operator>>(SvStream& rIStream, BmapType& rBmap);
285     virtual void Draw(OutputDevice& rOut);
286     void SetPaths( const INetURLObject rFltPath );
287 };
288 
289 
290 #define GrupSize 48
291 class GrupType: public ObjkType {
292 public:
293     sal_uInt8        Flags;    // (Schummel f�r Allignment unter NT)
294     UCHAR       Name[13];  // Name der Gruppe
295     sal_uInt16      SbLo,SbHi; // (Ptr) Gruppenliste << ShortArr, weil sonst DWord Allign erforderlich
296     sal_uInt16      UpLo,UpHi; // (Ptr) Vaterliste   << ShortArr, weil sonst DWord Allign erforderlich
297     sal_uInt16      ChartSize; // Speicherbedarf der Diagrammstruktur Struktur
298     sal_uInt32      ChartPtr;  // Diagrammstruktur
299     sal_uInt32 GetSubPtr();    // hier nur zum Checken, ob Sublist evtl. leer ist.
300     friend SvStream& operator>>(SvStream& rIStream, GrupType& rGrup);
301 //    virtual void Draw(OutputDevice& rOut);
302 };
303 
304 
305 void SetLine(ObjLineType& rLine, OutputDevice& rOut);
306 void SetArea(ObjAreaType& rArea, OutputDevice& rOut);
307 Color Sgv2SvFarbe(sal_uInt8 nFrb1, sal_uInt8 nFrb2, sal_uInt8 nInts);
308 void RotatePoint(PointType& P, sal_Int16 cx, sal_Int16 cy, double sn, double cs);
309 void RotatePoint(Point& P, sal_Int16 cx, sal_Int16 cy, double sn, double cs);
310 sal_Int16 iMulDiv(sal_Int16 a, sal_Int16 Mul, sal_Int16 Div);
311 sal_uInt16 MulDiv(sal_uInt16 a, sal_uInt16 Mul, sal_uInt16 Div);
312 
313 
314 class SgfFontOne {
315 public:
316     SgfFontOne* Next;        // Zeiger f�r Listenverkettung
317     sal_uInt32      IFID;
318     sal_Bool        Bold;
319     sal_Bool        Ital;
320     sal_Bool        Sans;
321     sal_Bool        Serf;
322     sal_Bool        Fixd;
323     FontFamily  SVFamil;
324     CharSet     SVChSet;
325     String      SVFName;    // z.B. "Times New Roman" = 15 Chars
326     sal_uInt16      SVWidth;    // Durchschnittliche Zeichenbreite in %
327          SgfFontOne();
328     void ReadOne( ByteString& ID, ByteString& Dsc);
329 };
330 
331 class SgfFontLst {
332 public:
333     String      FNam;   // vollst�ndiger Filename des Inifiles
334     SgfFontOne* pList;  // Listenanfang
335     SgfFontOne* Last;   // Listenende
336     sal_uInt32      LastID; // f�r schnelleren Zugriff bei Wiederholungen
337     SgfFontOne* LastLn; // f�r schnelleren Zugriff bei Wiederholungen
338     sal_Bool        Tried;
339                 SgfFontLst();
340                 ~SgfFontLst();
341     void AssignFN(const String& rFName);
342     void ReadList();
343     void RausList();
344     SgfFontOne* GetFontDesc(sal_uInt32 ID);
345 };
346 
347 #endif //_SGVMAIN_HXX
348 
349 
350