summaryrefslogtreecommitdiff
path: root/svtools/source/inc/sgvmain.hxx
blob: 6f69908865c51bf537fb1487424be80058b5d764 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * Copyright 2000, 2010 Oracle and/or its affiliates.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/

#ifndef _SGVMAIN_HXX
#define _SGVMAIN_HXX

#include <vcl/font.hxx>
#include <vcl/outdev.hxx>
#include <vcl/virdev.hxx>


#define UCHAR unsigned char

struct PointType {
    INT16 x;
    INT16 y;
};

#define SgfDpmm 40

#define DtHdSize 256
class DtHdType {
public:
    BYTE  Reserved[256];
    friend SvStream& operator>>(SvStream& rIStream, DtHdType& rDtHd);
    friend void DtHdOverSeek(SvStream& rInp);
};


struct Seitenformat {
    PointType Size;       // 0.00mm...819.175mm (Papiergr��e)
    INT16     RandL;      // links     Rand auf
    INT16     RandR;      // rechts    dem Papier
    INT16     RandO;      // oben      Rand auf
    INT16     RandU;      // unten     dem Papier
    BYTE      PColor;     // Future Use
    BYTE      PIntens;    // erst recht Future use
//    BOOL      BorderClip; // Objekte am Rand abschneiden (Schummel wg. Allignment unter NT)
};


#define PageSize 146
class PageType {
public:
    UINT32       Next;       // N�chste Seite
    UINT32       nList;      // Objektdaten, erster Record
    UINT32       ListEnd;    // Objektdaten, letzter Record
    Seitenformat Paper;      // Papierdaten
    BOOL         BorderClip; // Objekte am Rand abschneiden (Schummel wg. Allignment unter NT)
    BYTE         StdPg;      // welche Standardseite einblenden ?
    PointType    U;          // Nullpunkt
    INT16        HlpLnH[20]; // Hilfslinien
    INT16        HlpLnV[20];
    BYTE         LnAnzH;
    BYTE         LnAnzV;
    UCHAR        PgName[32]; // Seitenname
    friend SvStream& operator>>(SvStream& rIStream, PageType& rPage);
};


enum ObjArtType {ObjStrk,ObjRect,ObjPoly,ObjCirc,ObjSpln,
                 ObjText,ObjGrup,ObjBmap,ObjVirt,ObjTxtX,ObjMaxi};

struct ObjLineType {
    BYTE  LFarbe;    //  [Index]
    BYTE  LBFarbe;   //  [Index]
    BYTE  LIntens;   //  [%]
    BYTE  LMuster;   //  [Index] inkl. Transparenz
    INT16 LMSize;    //  [Koeffizient/100]
    INT16 LDicke;    //  Strichst�rke
};

struct ObjAreaType {
    BYTE   FFarbe;   //  [Index]
    BYTE   FBFarbe;  //  [Index]
    BYTE   FIntens;  //  [%]
    BYTE   FDummy1;  //
    INT16  FDummy2;  //
    UINT16 FMuster;  //  [Index] inkl. Invers, Transparenz
};

#define ObjTextTypeSize 64
class ObjTextType {
public:
    ObjLineType  L;        // Text-Outline (future)
    ObjAreaType  F;        // Text innen
    UINT16       FontLo,FontHi;// z.B. 92500 (CG Times), zweigeteilt wegen DWordAllign in TextType.
    UINT16       Grad;     // 0.5..32767.5 Pt - bei 1000 Pt sollte aber schlu� sein
    UINT16       Breite;   // 1..65535%  bitte nicht mehr als 500%
    BYTE         Justify;  // 2 Bit Vert (Hi), 3 Bit Hor (Lo)
    BYTE         Kapit;    // 1..255%
    UINT16       Schnitt;  // 8 Flags
    UINT16       LnFeed;   // 1..32767% vom max. Schriftgrad der Zeile
    UINT16       Slant;    // Kursivwinkel 0.00..89.99� default 15.00�          doppelt Breit angesehen)
    BYTE         ZAbst;    // Zeichenabstand 0..255% (0=auf der Stelle; 100=normal; 200=Zeichen wird als
    INT8         ChrVPos;  // Zeichen V-Position default 0= on Baseline, 10= 5Pt drunter (-64..63�)
    ObjLineType  ShdL;     // Schatten-Outline (neu 2.0)
    ObjAreaType  ShdF;     // Schatten-innen   (neu 2.0)
    PointType    ShdVers;  // Schattenversatz Max.300.00%
    BOOL         ShdAbs;   // True-> Schattenversatz ist absolut statt relativ zum Schriftgrad
    BOOL         NoSpc;    // True-> kein Zwischenraum (f�r BackArea)
    ObjAreaType  BackF;    // Hintergrundfl�che
    UINT32 GetFont();
    void   SetFont(UINT32 FontID);
};

class Obj0Type {           // SuperClass f�r Apple-VMT
public:
    virtual void Draw(OutputDevice& rOut);
    virtual ~Obj0Type() {}
};

#define ObjkSize 20  /* eigentlich 21. Wg. Allignment ist Flags jedoch verschoben worden*/
class ObjkType: public Obj0Type {  // Grundkomponenten aller Stardraw-Objekte
public:
    UINT32     Last;
    UINT32     Next;
    UINT16     MemSize;    // in Bytes
    PointType  ObjMin;     // XY-Minimum des Objekts
    PointType  ObjMax;     // XY-Maximum des Objekts
    BYTE       Art;
    BYTE       Layer;
//    BYTE       Flags;    // (Schummel f�r Allignment unter NT)
    friend SvStream& operator>>(SvStream& rIStream, ObjkType& rObjk);
    friend BOOL ObjOverSeek(SvStream& rInp, ObjkType& rObjk);
    virtual void Draw(OutputDevice& rOut);
};


#define StrkSize 38
class StrkType: public ObjkType {
public:
    BYTE        Flags;     // (Schummel f�r Allignment unter NT)
    BYTE        LEnden;    // Linienenden
    ObjLineType L;
    PointType   Pos1;      // Anfangspunkt
    PointType   Pos2;      // Endpunkt
    friend SvStream& operator>>(SvStream& rIStream, StrkType& rStrk);
    virtual void Draw(OutputDevice& rOut);
};


#define RectSize 52
class RectType: public ObjkType {
public:
    BYTE        Flags;    // (Schummel f�r Allignment unter NT)
    BYTE        Reserve;
    ObjLineType L;
    ObjAreaType F;
    PointType   Pos1;      // LO-Ecke = Bezugspunkt
    PointType   Pos2;      // R-Ecke
    INT16       Radius;    // Eckenradius
    UINT16      DrehWink;  //  315...<45
    UINT16      Slant;     // >270...<90
    friend SvStream& operator>>(SvStream& rIStream, RectType& rRect);
    virtual void Draw(OutputDevice& rOut);
};


#define PolySize 44
class PolyType: public ObjkType { // identisch mit Spline !
public:
    BYTE        Flags;    // (Schummel f�r Allignment unter NT)
    BYTE        LEnden;  // nur f�r Polyline
    ObjLineType L;
    ObjAreaType F;       // nicht f�r Polyline
    BYTE        nPoints;
    BYTE        Reserve;
    UINT32      SD_EckP; // Zeiger auf die Eckpunkte (StarDraw)
    PointType*  EckP;    // Zeiger auf die Eckpunkte (StarView (wird nicht von Disk gelesen!))
    friend SvStream& operator>>(SvStream& rIStream, PolyType& rPoly);
    virtual void Draw(OutputDevice& rOut);
};
#define  PolyClosBit 0x01   // Unterarten von Poly:   0: PolyLine  1: Polygon


#define SplnSize 44
class SplnType: public ObjkType { // identisch mit Poly !
public:
    BYTE        Flags;    // (Schummel f�r Allignment unter NT)
    BYTE        LEnden;  // nur f�r nSpline
    ObjLineType L;
    ObjAreaType F;       // nicht f�r nSpline
    BYTE        nPoints;
    BYTE        Reserve;
    UINT32      SD_EckP; // Zeiger auf die Eckpunkte (StarDraw)
    PointType*  EckP;    // Zeiger auf die Eckpunkte (StarView (wird nicht von Disk gelesen!))
    friend SvStream& operator>>(SvStream& rIStream, SplnType& rSpln);
    virtual void Draw(OutputDevice& rOut);
};
// Unterarten von Spline: siehe Poly


#define CircSize 52
class CircType: public ObjkType {
public:
    BYTE        Flags;    // (Schummel f�r Allignment unter NT)
    BYTE        LEnden;    // nur Bogen (Kr & El)
    ObjLineType L;
    ObjAreaType F;         // nicht f�r Bogen (Kr & El)
    PointType   Center;    // Mittelpunkt
    PointType   Radius;    // Radius
    UINT16      DrehWink;  // nur Ellipse
    UINT16      StartWink; // � nicht f�r Vollkreis
    UINT16      RelWink;   // � und Vollellipse
    friend SvStream& operator>>(SvStream& rIStream, CircType& rCirc);
    virtual void Draw(OutputDevice& rOut);
};
#define CircFull 0x00  /* Unterarten von Kreis:  0: Kreis          */
#define CircSect 0x01  /*                        1: Kreissektor    */
#define CircAbsn 0x02  /*                        2: Kreisabschnitt */
#define CircArc  0x03  /*                        3: Kreisbogen     */


#define TextSize 116
class TextType: public ObjkType {
public:
    BYTE        Flags;    // (Schummel f�r Allignment unter NT)
    BYTE        Reserve;   // f�r Word Allign
    ObjTextType T;         // 64 Bytes  << DWord-Allign bei FontID erforderlich
    PointType   Pos1;      // Bezugspunkt (ObenLinks)
    PointType   Pos2;      //             (untenRechts)
    INT16       TopOfs;    // Von Oberkante bis Textbegin (future f�r vJustify)
    UINT16      DrehWink;  //    0...<360
    UINT16      BoxSlant;  // >270...<90 (nur Box)
    UINT16      BufSize;   // Gr��e von Buf f�r Load, Save, Copy und so
    UINT16      BufLo,BufHi;// (UCHAR*) Zeiger auf den Textbuffer << ShortArr, weil sonst DWord-Allign erforderlich
    UINT16      ExtLo,ExtHi;// (Ptr)  Text �ber mehrere Rahmen    << ShortArr, weil sonst DWord-Allign erforderlich
    PointType   FitSize;   // Ursprungsgr��e f�r Fit2Size
    INT16       FitBreit;  // Breite zum formatieren bei Fit2Size
    UCHAR*      Buffer;    // Diese Variable wird nicht durch Lesen von Disk gef�llt, sondern explizit!
    friend SvStream& operator>>(SvStream& rIStream, TextType& rText);
    virtual void Draw(OutputDevice& rOut);
};
#define TextOutlBit 0x01     /*       1=Sourcecode f�r Outliner (wird von DrawObjekt() ignoriert) */
#define TextFitSBit 0x02     /* Bit1: 1=Text-FitToSize, auch Outliner (2.0)       */
#define TextFitZBit 0x08     /* Bit3: 1=Fit2Size Zeilenweise          (2.0)       */
#define TextDrftBit 0x04     /* Bit2: 1=DraftDraw                     (2.0)       */
#define TextFitBits (TextFitSBit | TextFitZBit)


enum GrafStat {NoGraf,Pic,Pcx,Hpgl,Img,Msp,Tiff,Dxf,Lot,Usr,Sgf};

#define BmapSize 132
class BmapType: public ObjkType {
public:
    BYTE        Flags;    // (Schummel f�r Allignment unter NT)
    BYTE        Reserve;
    ObjAreaType F;            // Farbe und Muster der 1-Plane Bitmap
    PointType   Pos1;
    PointType   Pos2;
    UINT16      DrehWink;     //  315...<45   (Future)
    UINT16      Slant;        // >270...<90   (Future)
    UCHAR       Filename[80]; //  Pfad
    PointType   PixSize;      // Gr��e in Pixel (0 bei Vektor)
    GrafStat    Format;       // siehe GpmDef.Pas
    BYTE        nPlanes;      // Anzahl der Bitplanes (0 bei Vektor)
    BOOL        RawOut;       // als Raw ausgeben ?
    BOOL        InvOut;       // invertiert ausgeben ?
    BOOL        LightOut;     // aufhellen? (SD20)
    BYTE        GrfFlg;       // (SD20) 0=nSGF 1=Pcx 2=Hpgl 4=Raw $FF=Undef(f�r Fix in DrawBmp)

    INetURLObject aFltPath;     // F�r GraphicFilter
    friend SvStream& operator>>(SvStream& rIStream, BmapType& rBmap);
    virtual void Draw(OutputDevice& rOut);
    void SetPaths( const INetURLObject rFltPath );
};


#define GrupSize 48
class GrupType: public ObjkType {
public:
    BYTE        Flags;    // (Schummel f�r Allignment unter NT)
    UCHAR       Name[13];  // Name der Gruppe
    UINT16      SbLo,SbHi; // (Ptr) Gruppenliste << ShortArr, weil sonst DWord Allign erforderlich
    UINT16      UpLo,UpHi; // (Ptr) Vaterliste   << ShortArr, weil sonst DWord Allign erforderlich
    UINT16      ChartSize; // Speicherbedarf der Diagrammstruktur Struktur
    UINT32      ChartPtr;  // Diagrammstruktur
    UINT32 GetSubPtr();    // hier nur zum Checken, ob Sublist evtl. leer ist.
    friend SvStream& operator>>(SvStream& rIStream, GrupType& rGrup);
//    virtual void Draw(OutputDevice& rOut);
};


void SetLine(ObjLineType& rLine, OutputDevice& rOut);
void SetArea(ObjAreaType& rArea, OutputDevice& rOut);
Color Sgv2SvFarbe(BYTE nFrb1, BYTE nFrb2, BYTE nInts);
void RotatePoint(PointType& P, INT16 cx, INT16 cy, double sn, double cs);
void RotatePoint(Point& P, INT16 cx, INT16 cy, double sn, double cs);
INT16 iMulDiv(INT16 a, INT16 Mul, INT16 Div);
UINT16 MulDiv(UINT16 a, UINT16 Mul, UINT16 Div);


class SgfFontOne {
public:
    SgfFontOne* Next;        // Zeiger f�r Listenverkettung
    UINT32      IFID;
    BOOL        Bold;
    BOOL        Ital;
    BOOL        Sans;
    BOOL        Serf;
    BOOL        Fixd;
    FontFamily  SVFamil;
    CharSet     SVChSet;
    String      SVFName;    // z.B. "Times New Roman" = 15 Chars
    USHORT      SVWidth;    // Durchschnittliche Zeichenbreite in %
         SgfFontOne();
    void ReadOne( ByteString& ID, ByteString& Dsc);
};

class SgfFontLst {
public:
    String      FNam;   // vollst�ndiger Filename des Inifiles
    SgfFontOne* pList;  // Listenanfang
    SgfFontOne* Last;   // Listenende
    UINT32      LastID; // f�r schnelleren Zugriff bei Wiederholungen
    SgfFontOne* LastLn; // f�r schnelleren Zugriff bei Wiederholungen
    BOOL        Tried;
                SgfFontLst();
                ~SgfFontLst();
    void AssignFN(const String& rFName);
    void ReadList();
    void RausList();
    SgfFontOne* GetFontDesc(UINT32 ID);
};

#endif //_SGVMAIN_HXX