22#ifndef __STRUCTURES_H__
23#define __STRUCTURES_H__
25#include "structures_generated.h"
26#include "structures_private.h"
33 static const Word Write_3_0 = 0xBE31;
34 static const Word Write_3_1 = 0xBE32;
38 class PageLayout :
public PageLayoutGenerated,
44 bool readFromDevice (
void);
friend class InternalGenerator;
45 bool writeToDevice (
void);
friend class InternalParser;
48 static const Byte magic102Default = Byte (102);
49 static const Word magic512Default = Word (512);
50 static const Word pageHeightDefault = Word (Inch2Twip (11));
51 static const Word pageWidthDefault = Word (Inch2Twip (8.5));
52 static const Word pageNumberStartDefault = Word (1);
53 static const Word topMarginDefault = Word (Inch2Twip (1));
54 static const Word textHeightDefault = Word (Inch2Twip (9));
55 static const Word leftMarginDefault = Word (Inch2Twip (1.25));
56 static const Word textWidthDefault = Word (Inch2Twip (6));
57 static const Word magic256Default = Word (256);
58 static const Word headerFromTopDefault = Word (Inch2Twip (0.75));
59 static const Word footerFromTopDefault = Word (Inch2Twip (10.25 ));
60 static const Word magic720Default = Word (720);
61 static const Word zeroDefault = Word (0);
62 static const Word magic1080Default = Word (1080);
64 static const Word zero2Default = Word (0);
68 virtual ~PageLayout ();
70 PageLayout &operator= (
const PageLayout &rhs);
72 bool getIsModified (
void)
const {
return m_numModified > 0; }
74 #define PageLayoutModify(variable,value) \
76 if (m_##variable != value) \
78 if (value == variable##Default) \
82 m_##variable = value; \
86 Word getPageNumberStart (
const bool purist =
false)
const
89 return m_pageNumberStart;
91 if (m_pageNumberStart == Word (0xFFFF))
94 return m_pageNumberStart;
96 void setPageNumberStart (
const Word val) { PageLayoutModify (pageNumberStart, val); }
103 Word getBottomMargin (
void)
const
105 return getPageHeight () - getTopMargin () - getTextHeight ();
108 Word getRightMargin (
void)
const
110 return getPageWidth () - getLeftMargin () - getTextWidth ();
119 Word getPageHeight (
void)
const {
return m_pageHeight; }
120 void setPageHeight (
const Word val) { PageLayoutModify (pageHeight, val); }
122 Word getPageWidth (
void)
const {
return m_pageWidth; }
123 void setPageWidth (
const Word val) { PageLayoutModify (pageWidth, val); }
125 Word getTopMargin (
void)
const {
return m_topMargin; }
126 void setTopMargin (
const Word val) { PageLayoutModify (topMargin, val); }
128 Word getTextHeight (
void)
const {
return m_textHeight; }
129 void setTextHeight (
const Word val) { PageLayoutModify (textHeight, val); }
131 Word getLeftMargin (
void)
const {
return m_leftMargin; }
132 void setLeftMargin (
const Word val) { PageLayoutModify (leftMargin, val); }
134 Word getTextWidth (
void)
const {
return m_textWidth; }
135 void setTextWidth (
const Word val) { PageLayoutModify (textWidth, val); }
137 Word getHeaderFromTop (
void)
const {
return m_headerFromTop; }
138 void setHeaderFromTop (
const Word val) { PageLayoutModify (headerFromTop, val); }
140 Word getFooterFromTop (
void)
const {
return m_footerFromTop; }
141 void setFooterFromTop (
const Word val) { PageLayoutModify (footerFromTop, val); }
145 class Font :
public FontGenerated
150 friend class FontTable;
151 bool readFromDevice (
void);
152 bool writeToDevice (
void);
158 Roman = 0x10, Times = 0x10, Serif = 0x10,
159 Swiss = 0x20, Helvetica = 0x20, SansSerif = 0x20,
160 Modern = 0x30, Courier = 0x30, TypeWriter = 0x30,
162 Decorative = 0x50, OldEnglish = 0x50
165 Font (
const Byte *name = NULL,
const Byte family = DontCare);
168 Font &operator= (
const Font &rhs);
170 Byte *getName (
void)
const {
return m_name; }
171 Byte *setName (
const Byte *s)
174 #ifdef CHECK_INTERNAL
181 m_device->error (Error::InternalError,
"NULL fontName passed to Font::setName\n");
182 return m_name = NULL;
185 int length = strlen ((
const char *) s) + 1 ;
188 m_name =
new Byte [length];
190 m_device->error (Error::OutOfMemory,
"could not allocate memory for fontName\n");
192 strcpy ((
char *) m_name, (
const char *) s);
194 FontGenerated::m_numDataBytes =
sizeof (m_family) + length;
199 bool operator!= (
const Font &rhs)
202 return strcmp ((
const char *) this->m_name, (
const char *) rhs.m_name) != 0;
205 bool operator== (
const Font &rhs)
208 return strcmp ((
const char *) this->m_name, (
const char *) rhs.m_name) == 0;
212 Font (
const Font &rhs);
217 class FormatCharProperty :
public FormatCharPropertyGenerated
220 DWord m_afterEndCharByte;
221 FontTable *m_fontTable;
224 Word getFontCode (
void)
const
226 return ((Word) getFontCodeLow ()) | (((Word) getFontCodeHigh ()) << 6);
229 void setFontCode (
const Word code)
231 setFontCodeHigh ((code >> 6) & BitMask3);
232 setFontCodeLow (code & BitMask6);
235 friend class FormatInfoPage;
236 friend class FormatInfo;
237 friend class InternalParser;
238 friend class InternalGenerator;
239 bool readFromDevice (
void);
240 bool writeToDevice (
void);
242 void setFontTable (FontTable *fontTable) { m_fontTable = fontTable; }
244 DWord getAfterEndCharByte (
void)
const {
return m_afterEndCharByte; }
245 void setAfterEndCharByte (
const DWord b) { m_afterEndCharByte = b; }
248 DWord getEndCharByte (
void)
const {
return m_afterEndCharByte - 1; }
249 void setEndCharByte (
const DWord b) { m_afterEndCharByte = b + 1; }
252 FormatCharProperty ();
253 virtual ~FormatCharProperty ();
255 FormatCharProperty &operator= (
const FormatCharProperty &rhs);
257 const Font *getFont (
void)
const
262 void setFont (
const Font *font)
268 bool updateFont (
void);
270 bool updateFontCode (
void);
272 Byte getFontSizeHalfPoints (
void)
const {
return m_fontSize; }
273 void setFontSizeHalfPoints (
const Byte val)
276 signalHaveSetData (m_fontSize == fontSizeDefault, (2 * 8) + (1 * 8));
280 Byte getFontSize (
void)
const {
return getFontSizeHalfPoints () / 2; }
281 void setFontSize (
const Byte val) { setFontSizeHalfPoints (val * 2); }
283 bool getIsNormalPosition (
void)
const {
return getPosition () == 0; }
284 void setIsNormalPosition (
void) { setPosition (0); }
286 bool getIsSuperscript (
void)
const {
return getPosition () >= 1 && getPosition () <= 127; }
287 void setIsSuperscript (
void) { setPosition (4); }
289 bool getIsSubscript (
void)
const {
return getPosition () >= 128; }
290 void setIsSubscript (
void) { setPosition (252); }
293 bool operator== (FormatCharProperty &rhs);
297 class FormatParaPropertyTabulator :
public FormatParaPropertyTabulatorGenerated
300 friend class FormatParaPropertyGenerated;
301 friend class FormatParaProperty;
302 bool readFromDevice (
void);
303 bool writeToDevice (
void);
306 FormatParaPropertyTabulator ();
307 virtual ~FormatParaPropertyTabulator ();
309 FormatParaPropertyTabulator &operator= (
const FormatParaPropertyTabulator &rhs);
312 bool getIsNormal (
void)
const {
return m_type == 0; }
313 void setIsNormal (
const bool yes =
true) { m_type = (yes ? 0 : 3); }
315 bool getIsDecimal (
void)
const {
return m_type == 3; }
316 void setIsDecimal (
const bool yes =
true) { m_type = (yes ? 3 : 0); }
319 bool getIsDummy (
void)
const {
return m_indent == 0; }
326 static const int Left = 0;
327 static const int Centre = 1;
328 static const int Center = 1;
329 static const int Right = 2;
330 static const int Justify = 3;
334 class Align :
public Alignment {};
339 static const int Normal = 240;
340 static const int Single = 240;
341 static const int OneAndAHalf = 360;
342 static const int Double = 480;
345 class FormatParaProperty :
public FormatParaPropertyGenerated
348 DWord m_afterEndCharByte;
349 Word m_leftMargin, m_rightMargin;
351 bool m_addedTooManyTabs;
353 friend class FormatInfoPage;
354 friend class FormatInfo;
355 friend class InternalParser;
356 friend class InternalGenerator;
357 bool readFromDevice (
void);
358 bool writeToDevice (
void);
360 void setMargins (
const Word leftMargin,
const Word rightMargin)
362 m_leftMargin = leftMargin;
363 m_rightMargin = rightMargin;
366 DWord getAfterEndCharByte (
void)
const {
return m_afterEndCharByte; }
367 void setAfterEndCharByte (
const DWord b) { m_afterEndCharByte = b; }
370 DWord getEndCharByte (
void)
const {
return m_afterEndCharByte - 1; }
371 void setEndCharByte (
const DWord b) { m_afterEndCharByte = b + 1; }
374 FormatParaProperty ();
375 virtual ~FormatParaProperty ();
377 FormatParaProperty &operator= (
const FormatParaProperty &rhs);
380 Byte getAlign (
void)
const {
return getAlignment (); }
381 void setAlign (
const Byte val) { setAlignment (val); }
383 Short getLeftIndentFirstLine (
const bool purist =
false)
const
386 if (getIsObject () && !purist)
389 if (m_leftIndentFirstLine)
390 #ifdef CHECK_INTERNAL
393 m_device->debug (
"user specified leftIndentFirstLine for an object=", m_leftIndentFirstLine);
394 #ifdef CHECK_INTERNAL
403 return m_leftIndentFirstLine;
405 void setLeftIndentFirstLine (
const Word val)
407 m_leftIndentFirstLine = val;
408 signalHaveSetData (m_leftIndentFirstLine == leftIndentFirstLineDefault,
413 bool updateIndents (
void)
415 if (getIsNotNormalParagraph ())
417 m_leftIndent += m_leftMargin;
418 m_rightIndent += m_rightMargin;
424 bool getIsText (
void)
const {
return !getIsObject (); }
425 void setIsText (
const bool val) { setIsObject (!val); }
427 bool getIsNormalParagraph (
void)
const {
return !getIsNotNormalParagraph (); }
428 void setIsNormalParagraph (
const bool val =
true) { setIsNotNormalParagraph (!val); }
430 bool getIsHeader (
void)
const {
return getIsNotNormalParagraph () && getHeaderOrFooter () == 0; }
431 void setIsHeader (
const bool val)
433 setIsNormalParagraph (
false);
434 setHeaderOrFooter (val ? 0 : 1);
437 bool getIsFooter (
void)
const {
return getIsNotNormalParagraph () && getHeaderOrFooter () == 1; }
438 void setIsFooter (
const bool val)
440 setIsNormalParagraph (
false);
441 setHeaderOrFooter (val ? 1 : 0);
444 Word getNumTabulator (
void)
const {
return m_numTabulators; }
445 const FormatParaPropertyTabulator *getTabulator (
const int which)
const
447 if (which > m_numTabulators)
return NULL;
448 return m_tab [which];
451 bool addTabulator (FormatParaPropertyTabulator *fpp)
453 if (m_numTabulators >= 14)
457 m_addedTooManyTabs =
true;
461 *m_tab [m_numTabulators++] = *fpp;
464 signalHaveSetData (
false, (22 + m_numTabulators * FormatParaPropertyTabulator::s_size) * 8);
469 bool operator== (FormatParaProperty &rhs);
476 static const int NotObject = 0;
477 static const int Bitmap = 1, BMP = 1;
478 static const int WindowsMetaFile = 2, WMF = 2;
479 static const int OLE = 3;
482 class Image :
public ImageGenerated
485 Byte *m_externalImage;
486 DWord m_externalImageSize;
487 DWord m_externalImageUpto;
490 double m_originalWidth, m_originalHeight;
491 double m_displayedWidth, m_displayedHeight;
493 static int getBytesPerScanLine (
const int width,
const int bitsPerPixel,
const int padBytes);
496 bool readFromDevice (
void);
friend class InternalGenerator;
497 bool writeToDevice (
void);
friend class InternalParser;
502 Image &operator= (
const Image &rhs);
504 bool getIsWMF (
void)
const {
return m_mappingMode != 0xE3; }
505 bool getIsBMP (
void)
const {
return m_mappingMode == 0xE3; }
508 void setIsWMF (
const bool yes =
true) { yes ? m_mappingMode = 0x88 : m_mappingMode = 0xE3; }
509 void setIsBMP (
const bool yes =
true) { yes ? m_mappingMode = 0xE3 : m_mappingMode = 0x88; }
512 double getOriginalWidth (
void)
const {
return m_originalWidth; }
513 void setOriginalWidth (
const double val) { m_originalWidth = val; }
515 double getOriginalHeight (
void)
const {
return m_originalHeight; }
516 void setOriginalHeight (
const double val) { m_originalHeight = val; }
518 double getDisplayedWidth (
void)
const {
return m_displayedWidth; }
519 void setDisplayedWidth (
const double val) { m_displayedWidth = val; }
521 double getDisplayedHeight (
void)
const {
return m_displayedHeight; }
522 void setDisplayedHeight (
const double val) { m_displayedHeight = val; }
526 Byte *getExternalImage (
void)
const {
return m_externalImage; }
527 DWord getExternalImageSize (
void)
const {
return m_externalImageSize; }
529 bool setExternalImage (
const Byte *data,
const DWord size)
533 if (!m_externalImage)
535 m_externalImage =
new Byte [m_externalImageSize];
536 if (!m_externalImage)
537 ErrorAndQuit (Error::OutOfMemory,
"could not allocate memory for external image\n");
540 if (m_externalImageUpto + size > m_externalImageSize)
542 Dump (externalImageUpto);
543 m_device->debug (
"\tsize: ", size);
544 Dump (externalImageSize);
546 ErrorAndQuit (Error::InternalError,
"user overflowed setExternalImage(); attempt to write too much binary data\n");
549 memcpy (m_externalImage + m_externalImageUpto, data, size);
550 m_externalImageUpto += size;
554 bool setExternalImageSize (
const DWord externalImageSize)
556 m_externalImageSize = externalImageSize;
557 m_externalImageUpto = 0;
567 static const int Static = 1;
568 static const int Embedded = 2;
569 static const int Link = 3;
572 class OLE :
public OLEGenerated
575 Byte *m_externalObject;
576 DWord m_externalObjectSize;
577 DWord m_externalObjectUpto;
580 bool readFromDevice (
void);
friend class InternalGenerator;
581 bool writeToDevice (
void);
friend class InternalParser;
587 OLE &operator= (
const OLE &rhs);
589 Byte *getExternalObject (
void)
const {
return m_externalObject; }
590 DWord getExternalObjectSize (
void)
const {
return m_externalObjectSize; }
592 bool setExternalObject (
const Byte *data,
const DWord size)
596 if (!m_externalObject)
598 m_externalObject =
new Byte [m_externalObjectSize];
599 if (!m_externalObject)
600 ErrorAndQuit (Error::OutOfMemory,
"could not allocate memory for external object\n");
603 if (m_externalObjectUpto + size > m_externalObjectSize)
605 Dump (externalObjectUpto);
606 m_device->debug (
"\tsize: ", size);
607 Dump (externalObjectSize);
609 ErrorAndQuit (Error::InternalError,
"user overflowed setExternalObject (); attempt to write too much binary data\n");
612 memcpy (m_externalObject + m_externalObjectUpto, data, size);
613 m_externalObjectUpto += size;
617 bool setExternalObjectSize (
const DWord externalObjectSize)
619 m_externalObjectSize = externalObjectSize;
620 m_externalObjectUpto = 0;