22#ifndef __LIBMSWRITE_H__
23#define __LIBMSWRITE_H__
25#include "structures.h"
26#include "structures_private.h"
37 bool m_hasHeaderOnFirstPage;
38 bool m_hasFooterOnFirstPage;
44 m_hasHeader = m_hasFooter =
false;
45 m_hasHeaderOnFirstPage = m_hasFooterOnFirstPage =
false;
48 Word getNumObjects (
void)
const {
return m_numObjects; }
49 void setNumObjects (
const Word numObjects) { m_numObjects = numObjects; }
51 bool getHasHeader (
void)
const {
return m_hasHeader; }
52 void setHasHeader (
const bool hasHeader) { m_hasHeader = hasHeader; }
54 bool getHasFooter (
void)
const {
return m_hasFooter; }
55 void setHasFooter (
const bool hasFooter) { m_hasFooter = hasFooter; }
57 bool getHasHeaderOnFirstPage (
void)
const {
return m_hasHeaderOnFirstPage; }
58 void setHasHeaderOnFirstPage (
const bool hasHeaderOnFirstPage) { m_hasHeader = hasHeaderOnFirstPage; }
60 bool getHasFooterOnFirstPage (
void)
const {
return m_hasFooterOnFirstPage; }
61 void setHasFooterOnFirstPage (
const bool hasFooterOnFirstPage) { m_hasFooterOnFirstPage = hasFooterOnFirstPage; }
67 class FormatInfo :
public NeedsDevice,
public NeedsHeader
70 List <FormatInfoPage> m_formatInfoPageList;
71 List <FormatInfoPage>::Iterator m_formatInfoPageIterator;
74 enum FormatInfoPageTypes m_type;
76 friend class InternalParser;
77 friend class InternalGenerator;
78 Word m_leftMargin, m_rightMargin;
79 FontTable *m_fontTable;
80 void setMargins (
const Word leftMargin,
const Word rightMargin)
82 m_leftMargin = leftMargin, m_rightMargin = rightMargin;
84 void setFontTable (FontTable *fontTable) { m_fontTable = fontTable; }
86 FormatInfo &operator= (
const FormatInfo &rhs);
89 virtual ~FormatInfo ();
91 void setType (
const enum FormatInfoPageTypes t) { m_type = t; }
93 bool readFromDevice (
void);
94 bool writeToDevice (
const void *defaultProperty);
100 bool add (
const void *property,
const bool force =
false);
108 Generator *m_generator;
111 Parser (Generator *generator = NULL)
113 setGenerator (generator);
120 void setGenerator (Generator *generator)
122 m_generator = generator;
125 virtual bool parse (
void) = 0;
133 virtual ~Generator ();
140 virtual bool writeDocumentBegin (
const Word format,
const PageLayout *pageLayout) = 0;
141 virtual bool writeDocumentEnd (
const Word format,
const PageLayout *pageLayout) = 0;
148 virtual bool writeFooterBegin (
void) {
return true; }
149 virtual bool writeFooterEnd(
void) {
return true; }
151 virtual bool writeHeaderBegin (
void) {
return true; }
152 virtual bool writeHeaderEnd (
void) {
return true; }
154 virtual bool writeBodyBegin (
void) = 0;
155 virtual bool writeBodyEnd (
void) = 0;
162 virtual bool writeParaInfoBegin (
const FormatParaProperty * ,
164 const Image * = NULL) {
return true; }
165 virtual bool writeParaInfoEnd (
const FormatParaProperty * ,
167 const Image * = NULL) {
return true; }
174 virtual bool writeCharInfoBegin (
const FormatCharProperty * ) {
return true; }
175 virtual bool writeCharInfoEnd (
const FormatCharProperty * ,
176 const bool =
false) {
return true; }
184 virtual bool writeBinary (
const Byte * ,
const DWord ) {
return true; }
198 bool processText (
const Byte *
string,
bool willReachEndOfParagraph);
199 virtual bool writeText (
const Byte *
string) = 0;
207 virtual bool writePageNew (
const int = 0)
211 virtual bool writePageBreak (
void)
213 return writeText ((
const Byte *)
"\xc");
215 virtual bool writePageNumber (
void)
217 return writeText ((
const Byte *)
"\x1");
219 virtual bool writeCarriageReturn (
void)
221 return writeText ((
const Byte *)
"\xd");
223 virtual bool writeNewLine (
const bool =
true)
225 return writeText ((
const Byte *)
"\n");
227 virtual bool writeOptionalHyphen (
void)
229 return writeText ((
const Byte *)
"-");
238 virtual void sigProgress (
const int ) {}
242 class InternalParser :
public Parser,
public NeedsDevice
246 SectionTable *m_sectionTable;
247 PageLayout *m_pageLayout;
248 PageTable *m_pageTable;
249 FontTable *m_fontTable;
250 FormatInfo *m_paragraphInfo, *m_characterInfo;
257 virtual ~InternalParser ();
263 class InternalGenerator :
public Generator,
public NeedsDevice
267 SectionTable *m_sectionTable;
268 PageLayout *m_pageLayout;
269 PageTable *m_pageTable;
270 FontTable *m_fontTable;
271 FormatInfo *m_paragraphInfo, *m_characterInfo;
276 bool seekNextPage (
void);
279 InternalGenerator ();
280 virtual ~InternalGenerator ();
282 bool writeDocumentBegin (
const Word format,
const PageLayout *pageLayout);
283 bool writeDocumentEnd (
const Word format,
const PageLayout *pageLayout);
285 bool writeFooterBegin (
void)
290 bool writeFooterEnd(
void)
296 bool writeHeaderBegin (
void)
301 bool writeHeaderEnd (
void)
307 bool writeBodyBegin (
void)
313 bool writeBodyEnd (
void)
325 bool writeParaInfoBegin (
const FormatParaProperty *paraProperty,
326 const OLE *oleHeader = NULL,
327 const Image *imageHeader = NULL);
328 bool writeParaInfoEnd (
const FormatParaProperty *paraProperty,
329 const OLE *oleHeader = NULL,
330 const Image *imageHeader = NULL);
332 bool writeCharInfoBegin (
const FormatCharProperty *charProperty);
333 bool writeCharInfoEnd (
const FormatCharProperty *charProperty,
334 const bool endOfParagraph =
false);
337 bool writeBinary (
const Byte *buffer,
const DWord length);
340 bool writeText (
const Byte *
string);
343 bool writePageNew (
const int pageNumberClaimed = 0);
345 bool writePageBreak (
void)
347 return writeText ((
const Byte *)
"\xC");
349 bool writePageNumber (
void)
351 return writeText ((
const Byte *)
"\x1");
353 bool writeCarriageReturn (
void)
356 return writeText ((
const Byte *)
"\xD");
358 bool writeNewLine (
const bool)
360 return writeText ((
const Byte *)
"\n");
362 bool writeOptionalHyphen (
void)
364 return writeText ((
const Byte *)
"\x1F");
367 void sigProgress (
const int)