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