Branch libreoffice-5-0-4
[LibreOffice.git] / vcl / source / filter / sgvmain.hxx
blob521a21a100f77bea47f0c622a2ab44ab96d17964
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_VCL_SOURCE_FILTER_SGVMAIN_HXX
21 #define INCLUDED_VCL_SOURCE_FILTER_SGVMAIN_HXX
23 #include <vcl/font.hxx>
24 #include <vcl/outdev.hxx>
25 #include <vcl/virdev.hxx>
27 #define UCHAR unsigned char
29 struct PointType {
30 sal_Int16 x;
31 sal_Int16 y;
32 PointType()
33 : x(0)
34 , y(0)
39 #define SgfDpmm 40
41 #define DtHdSize 256
42 class DtHdType {
43 public:
44 sal_uInt8 Reserved[256];
45 friend SvStream& ReadDtHdType(SvStream& rIStream, DtHdType& rDtHd);
46 friend void DtHdOverSeek(SvStream& rInp);
49 struct Seitenformat {
50 PointType Size; // 0.00mm...819.175mm (papersize)
51 sal_Int16 RandL; // left border on
52 sal_Int16 RandR; // right paper
53 sal_Int16 RandO; // upper border on
54 sal_Int16 RandU; // lower paper
55 sal_uInt8 PColor; // future use
56 sal_uInt8 PIntens; // future use
59 #define PageSize 146
60 class PageType {
61 public:
62 sal_uInt32 Next; // next page
63 sal_uInt32 nList; // objectdata, first record
64 sal_uInt32 ListEnd; // objectdata, last record
65 Seitenformat Paper; // data of paper
66 bool BorderClip; // clip objects at border (cheat due to alignment in NT)
67 sal_uInt8 StdPg; // insert which standardpage ?
68 PointType U; // origin
69 sal_Int16 HlpLnH[20]; // guides
70 sal_Int16 HlpLnV[20];
71 sal_uInt8 LnAnzH;
72 sal_uInt8 LnAnzV;
73 UCHAR PgName[32]; // page name
74 friend SvStream& ReadPageType(SvStream& rIStream, PageType& rPage);
75 PageType();
78 enum ObjArtType {ObjStrk,ObjRect,ObjPoly,ObjCirc,ObjSpln,
79 ObjText,ObjGrup,ObjBmap,ObjVirt,ObjTxtX,ObjMaxi};
81 struct ObjLineType {
82 sal_uInt8 LFarbe; // [Index]
83 sal_uInt8 LBFarbe; // [Index]
84 sal_uInt8 LIntens; // [%]
85 sal_uInt8 LMuster; // [Index] including transparency
86 sal_Int16 LMSize; // [coefficient/100]
87 sal_Int16 LDicke; // line thickness
90 struct ObjAreaType {
91 sal_uInt8 FFarbe; // [Index]
92 sal_uInt8 FBFarbe; // [Index]
93 sal_uInt8 FIntens; // [%]
94 // Despite the "Dummy" in the name, and not being used anywhere in
95 // the code, these two fields are *essential*. These structs are
96 // 1:1 mappings of actual on-disk/wire file format structures...
97 // So don't clean the "unused dummy" fields away. (Actually it
98 // might well be that many other fields around here are never used
99 // in our code either.)
100 sal_uInt8 FDummy1;
101 sal_Int16 FDummy2;
102 sal_uInt16 FMuster; // [Index] incl. Invers, transparency
104 ObjAreaType()
105 : FFarbe(0)
106 , FBFarbe(0)
107 , FIntens(0)
108 , FDummy1(0)
109 , FDummy2(0)
110 , FMuster(0)
115 #define ObjTextTypeSize 64
116 class ObjTextType {
117 public:
118 ObjLineType L; // text outline (future)
119 ObjAreaType F; // inner text
120 sal_uInt16 FontLo,FontHi; // e.g. 92500 (CG Times), split due to DWordAllign in TextType.
121 sal_uInt16 Grad; // 0.5..32767.5 pt - we should stop at 1000 pt
122 sal_uInt16 Breite; // 1..65535% please not more as 500%
123 sal_uInt8 Justify; // 2 bit vertical (Hi), 3 bit horizontal (Lo)
124 sal_uInt8 Kapit; // 1..255%
125 sal_uInt16 Schnitt; // 8 flags
126 sal_uInt16 LnFeed; // 1..32767% of max font size of the line
127 sal_uInt16 Slant; // slant angle 0.00..89.99deg default 15.00deg viewed double width)
128 sal_uInt8 ZAbst; // character spacing 0..255% (0=on the line; 100=normal; 200=Zeichen wird als
129 signed char ChrVPos; // vertical position of char. Default 0=on baseline, 10=5Pt below (-64..63")
130 ObjLineType ShdL; // shadow outline (new 2.0)
131 ObjAreaType ShdF; // shadow inside (new 2.0)
132 PointType ShdVers; // shadow offset max. 300.00%
133 bool ShdAbs; // True-> shadow offset is absolute instead of relative to font size
134 bool NoSpc; // True-> no space (for background area)
135 ObjAreaType BackF; // background area
136 sal_uInt32 GetFont();
137 void SetFont(sal_uInt32 FontID);
140 class Obj0Type { // SuperClass for Apple-VMT
141 public:
142 virtual void Draw(OutputDevice& rOut);
143 virtual ~Obj0Type() {}
146 #define ObjkSize 20 /* should be 21. due to alignment we shifted the flag */
147 class ObjkType: public Obj0Type { // basic componenents of all Stardraw objects
148 public:
149 sal_uInt32 Last;
150 sal_uInt32 Next;
151 sal_uInt16 MemSize; // in bytes
152 PointType ObjMin; // XY minimum of the object
153 PointType ObjMax; // XY maximum of the object
154 sal_uInt8 Art;
155 sal_uInt8 Layer;
156 ObjkType()
157 : Last(0)
158 , Next(0)
159 , MemSize(0)
160 , Art(0)
161 , Layer(0)
164 friend SvStream& ReadObjkType(SvStream& rIStream, ObjkType& rObjk);
165 friend bool ObjOverSeek(SvStream& rInp, ObjkType& rObjk);
166 virtual void Draw(OutputDevice& rOut) SAL_OVERRIDE;
169 #define StrkSize 38
170 class StrkType: public ObjkType {
171 public:
172 sal_uInt8 Flags; // (cheat due to alignment in NT)
173 sal_uInt8 LEnden; // line ends
174 ObjLineType L;
175 PointType Pos1; // start point
176 PointType Pos2; // end point
177 friend SvStream& ReadStrkType(SvStream& rIStream, StrkType& rStrk);
178 virtual void Draw(OutputDevice& rOut) SAL_OVERRIDE;
181 #define RectSize 52
182 class RectType: public ObjkType {
183 public:
184 sal_uInt8 Flags; // (cheat due to alignment in NT)
185 sal_uInt8 Reserve;
186 ObjLineType L;
187 ObjAreaType F;
188 PointType Pos1; // lower left corner = reference point
189 PointType Pos2; // right corner
190 sal_Int16 Radius; // radius of corner
191 sal_uInt16 RotationAngle; // 315...<45
192 sal_uInt16 Slant; // >270...<90
193 friend SvStream& ReadRectType(SvStream& rIStream, RectType& rRect);
194 virtual void Draw(OutputDevice& rOut) SAL_OVERRIDE;
197 #define PolySize 44
198 class PolyType: public ObjkType { // identical to spline !
199 public:
200 sal_uInt8 Flags; // (cheat due to alignment in NT)
201 sal_uInt8 LEnden; // only for polyline
202 ObjLineType L;
203 ObjAreaType F; // not for polyline
204 sal_uInt8 nPoints;
205 sal_uInt8 Reserve;
206 sal_uInt32 SD_EckP; // pointer to corner point (StarDraw)
207 PointType* EckP; // pointer to corner points (StarView (is not read from disk!))
208 friend SvStream& ReadPolyType(SvStream& rIStream, PolyType& rPoly);
209 virtual void Draw(OutputDevice& rOut) SAL_OVERRIDE;
211 #define PolyClosBit 0x01 // kinds of Poly: 0: polyLine 1: polygon
213 #define SplnSize 44
214 class SplnType: public ObjkType { // identical to Poly !
215 public:
216 sal_uInt8 Flags; // (cheat due to alignment in NT)
217 sal_uInt8 LEnden; // only for nSpline
218 ObjLineType L;
219 ObjAreaType F; // not for nSpline
220 sal_uInt8 nPoints;
221 sal_uInt8 Reserve;
222 sal_uInt32 SD_EckP; // pointer to corner points (StarDraw)
223 PointType* EckP; // pointer to corner points (StarView (is not read from disk!))
224 friend SvStream& ReadSplnType(SvStream& rIStream, SplnType& rSpln);
225 virtual void Draw(OutputDevice& rOut) SAL_OVERRIDE;
227 // kinds of Spline: see Poly
229 #define CircSize 52
230 class CircType: public ObjkType {
231 public:
232 sal_uInt8 Flags; // (cheat due to alignment in NT)
233 sal_uInt8 LEnden; // only arcs (circle & ellips)
234 ObjLineType L;
235 ObjAreaType F; // not for arcs (circly & ellips)
236 PointType Center; // center
237 PointType Radius; // radius
238 sal_uInt16 RotationAngle; // only ellipses
239 sal_uInt16 StartAngle; // and not for full circles
240 sal_uInt16 RelAngle; // and full ellipses
241 friend SvStream& ReadCircType(SvStream& rIStream, CircType& rCirc);
242 virtual void Draw(OutputDevice& rOut) SAL_OVERRIDE;
244 #define CircFull 0x00 /* kinds of circle: 0: full circle */
245 #define CircSect 0x01 /* 1: circle sector */
246 #define CircAbsn 0x02 /* 2: circle segment */
247 #define CircArc 0x03 /* 3: circle arc */
249 #define TextSize 116
250 class TextType: public ObjkType {
251 public:
252 sal_uInt8 Flags; // (cheat due to alignment in NT)
253 sal_uInt8 Reserve; // for Word Allign
254 ObjTextType T; // 64 bytes << DWord-Allign needed for FontID
255 PointType Pos1; // reference point (upper left)
256 PointType Pos2; // (lower right)
257 sal_Int16 TopOfs; // from upper side to start of text (future for vJustify)
258 sal_uInt16 RotationAngle; // 0...<360
259 sal_uInt16 BoxSlant; // >270...<90 (only Box)
260 sal_uInt16 BufSize; // size of buffer for Load, Save, Copy etc.
261 sal_uInt16 BufLo,BufHi; // (UCHAR*) pointer to Textbuffer << ShortArr, otherwise DWord-Allign needed
262 sal_uInt16 ExtLo,ExtHi; // (Ptr) text over more frames << ShortArr, otherwise DWord-Allign needed
263 PointType FitSize; // size of origin for Fit2Size
264 sal_Int16 FitBreit; // width to format for Fit2Size
265 UCHAR* Buffer; // this variable is not set by reading from disk, but explicit!
266 friend SvStream& ReadTextType(SvStream& rIStream, TextType& rText);
267 virtual void Draw(OutputDevice& rOut) SAL_OVERRIDE;
269 #define TextOutlBit 0x01 /* 1=Sourcecode for outliner (ignored byDrawObjekt()) */
270 #define TextFitSBit 0x02 /* Bit1: 1=Text-Fit2Size, also outliner (2.0) */
271 #define TextFitZBit 0x08 /* Bit3: 1=Fit2Size line by line (2.0) */
272 #define TextFitBits (TextFitSBit | TextFitZBit)
274 enum GrafStat {NoGraf,Pic,Pcx,Hpgl,Img,Msp,Tiff,Dxf,Lot,Usr,Sgf};
276 #define BmapSize 132
277 class BmapType: public ObjkType {
278 public:
279 sal_uInt8 Flags; // (cheat due to alignment in NT)
280 sal_uInt8 Reserve;
281 ObjAreaType F; // colour and pattern of first plane bitmap
282 PointType Pos1;
283 PointType Pos2;
284 sal_uInt16 RotationAngle;// 315...<45 (future)
285 sal_uInt16 Slant; // >270...<90 (future)
286 UCHAR Filename[80]; // path
287 PointType PixSize; // size in Pixel (0 for vector)
288 GrafStat Format; // see: GpmDef.Pas
289 sal_uInt8 nPlanes; // number of bitplanes (0 for vector)
290 bool RawOut; // output as raw ?
291 bool InvOut; // output inverted ?
292 bool LightOut; // brighten? (SD20)
293 sal_uInt8 GrfFlg; // (SD20) 0=nSGF 1=Pcx 2=HPGL 4=Raw $FF=Undef (to fix DrawBmp)
294 INetURLObject aFltPath; // for GraphicFilter
296 BmapType()
297 : Flags(0)
298 , Reserve(0)
299 , RotationAngle(0)
300 , Slant(0)
301 , Format(NoGraf)
302 , nPlanes(0)
303 , RawOut(false)
304 , InvOut(false)
305 , LightOut(false)
306 , GrfFlg(0)
308 memset(Filename, 0, sizeof(Filename));
311 friend SvStream& ReadBmapType(SvStream& rIStream, BmapType& rBmap);
312 virtual void Draw(OutputDevice& rOut) SAL_OVERRIDE;
313 void SetPaths( const INetURLObject& rFltPath );
316 #define GrupSize 48
317 class GrupType: public ObjkType {
318 public:
319 sal_uInt8 Flags; // (cheat due to alignment in NT)
320 UCHAR Name[13]; // name of group
321 sal_uInt16 SbLo,SbHi; // (Ptr) group list << ShortArr, as otherwise DWord alignment needed
322 sal_uInt16 UpLo,UpHi; // (Ptr) parent list << ShortArr, as otherwise DWord alignment needed
323 sal_uInt16 ChartSize; // required amount of memory for structure of diagram structure
324 sal_uInt32 ChartPtr; // diagram structure
325 sal_uInt32 GetSubPtr(); // only to check if Sublist is empty
326 friend SvStream& ReadGrupType(SvStream& rIStream, GrupType& rGrup);
329 void SetLine(ObjLineType& rLine, OutputDevice& rOut);
330 void SetArea(ObjAreaType& rArea, OutputDevice& rOut);
331 Color Sgv2SvFarbe(sal_uInt8 nFrb1, sal_uInt8 nFrb2, sal_uInt8 nInts);
332 void RotatePoint(PointType& P, sal_Int16 cx, sal_Int16 cy, double sn, double cs);
333 void RotatePoint(Point& P, sal_Int16 cx, sal_Int16 cy, double sn, double cs);
334 sal_Int16 iMulDiv(sal_Int16 a, sal_Int16 Mul, sal_Int16 Div);
335 sal_uInt16 MulDiv(sal_uInt16 a, sal_uInt16 Mul, sal_uInt16 Div);
337 class SgfFontOne {
338 public:
339 SgfFontOne* Next; // pointer to list
340 sal_uInt32 IFID;
341 bool Bold;
342 bool Ital;
343 bool Sans;
344 bool Serf;
345 bool Fixd;
346 FontFamily SVFamil;
347 rtl_TextEncoding SVChSet;
348 OUString SVFName; // e.g. "Times New Roman" = 15 chars
349 sal_uInt16 SVWidth; // average character width in %
350 SgfFontOne();
351 void ReadOne(const OString& rID, OString& rDsc);
354 class SgfFontLst {
355 public:
356 OUString FNam; // complete filename of the Ini-file
357 SgfFontOne* pList; // start of list
358 SgfFontOne* Last; // end of list
359 sal_uInt32 LastID; // for faster access during repeats
360 SgfFontOne* LastLn; // for faster access during repeats
361 bool Tried;
362 SgfFontLst();
363 ~SgfFontLst();
364 void AssignFN(const OUString& rFName);
365 void ReadList();
366 void RausList();
367 SgfFontOne* GetFontDesc(sal_uInt32 ID);
370 #endif // INCLUDED_VCL_SOURCE_FILTER_SGVMAIN_HXX
372 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */