filters
structures_private.h
00001 /* This file is part of the LibMSWrite Library 00002 Copyright (C) 2001-2003 Clarence Dang <clarencedang@users.sourceforge.net> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License Version 2 as published by the Free Software Foundation. 00007 00008 This library is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00011 Library General Public License Version 2 for more details. 00012 00013 You should have received a copy of the GNU Library General Public License 00014 Version 2 along with this library; see the file COPYING.LIB. If not, 00015 write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00016 * Boston, MA 02110-1301, USA. 00017 00018 LibMSWrite Project Website: 00019 http://sourceforge.net/projects/libmswrite/ 00020 */ 00021 00022 #ifndef __STRUCTURES_PRIVATE_H__ 00023 #define __STRUCTURES_PRIVATE_H__ 00024 00025 #include "structures_generated.h" 00026 #include "list.h" 00027 00028 namespace MSWrite 00029 { 00030 class Header : public HeaderGenerated 00031 { 00032 private: 00033 DWord m_numCharBytes; 00034 Word m_pageCharInfo; 00035 00036 bool readFromDevice (void); friend class InternalParser; 00037 bool writeToDevice (void); friend class InternalGenerator; 00038 00039 public: 00040 Header (); 00041 virtual ~Header (); 00042 00043 Header &operator= (const Header &rhs); 00044 00045 Word getFormat (void) const { return getMagic (); } 00046 void setFormat (const Word f) { setMagic (f); } 00047 00048 DWord getNumCharBytes (void) const { return m_numCharBytes; } 00049 void setNumCharBytes (const DWord w) { m_numCharBytes = w; } 00050 00051 Word getNumPageCharInfo (void) const { return m_pageParaInfo - m_pageCharInfo; } 00052 Word getNumPageParaInfo (void) const { return m_pageFootnoteTable - m_pageParaInfo; } 00053 Word getNumPageFootnoteTable (void) const { return m_pageSectionProperty - m_pageFootnoteTable; } 00054 Word getNumPageSectionProperty (void) const { return m_pageSectionTable - m_pageSectionProperty; } 00055 Word getNumPageSectionTable (void) const { return m_pagePageTable - m_pageSectionTable; } 00056 Word getNumPagePageTable (void) const { return m_pageFontTable - m_pagePageTable; } 00057 Word getNumPageFontTable (void) const { return m_numPages - m_pageFontTable; } 00058 00059 Word getPageCharInfo (void) const { return m_pageCharInfo; } 00060 }; 00061 00062 class NeedsHeader 00063 { 00064 protected: 00065 Header *m_header; 00066 00067 public: 00068 NeedsHeader (Header *header = NULL) 00069 { 00070 setHeader (header); 00071 } 00072 00073 virtual ~NeedsHeader () 00074 { 00075 } 00076 00077 NeedsHeader &operator= (const NeedsHeader &rhs) 00078 { 00079 if (this == &rhs) 00080 return *this; 00081 00082 m_header = rhs.m_header; 00083 00084 return *this; 00085 } 00086 00087 void setHeader (Header *header) { m_header = header; } 00088 }; 00089 00090 00091 class SectionDescriptor : public SectionDescriptorGenerated 00092 { 00093 public: 00094 SectionDescriptor (); 00095 virtual ~SectionDescriptor (); 00096 00097 SectionDescriptor &operator= (const SectionDescriptor &rhs); 00098 }; 00099 00100 00101 class SectionTable : public SectionTableGenerated, public NeedsHeader 00102 { 00103 public: 00104 SectionTable (); 00105 virtual ~SectionTable (); 00106 00107 SectionTable &operator= (const SectionTable &rhs); 00108 00109 private: 00110 bool readFromDevice (void); friend class InternalParser; 00111 bool writeToDevice (const bool needed); friend class InternalGenerator; 00112 }; 00113 00114 00115 class Font; // from structures.h 00116 class FontTable : public FontTableGenerated, public NeedsHeader 00117 { 00118 private: 00119 List <Font> m_fontList; 00120 00121 bool readFromDevice (void); friend class InternalParser; 00122 bool writeToDevice (void); friend class InternalGenerator; 00123 00124 public: 00125 FontTable (); 00126 virtual ~FontTable (); 00127 00128 FontTable &operator= (const FontTable &rhs); 00129 00130 Font *getFont (const DWord fontCode) const; 00131 DWord findFont (const Font *want) const; 00132 DWord addFont (const Font *input); 00133 }; 00134 00135 00136 class PagePointer : public PagePointerGenerated 00137 { 00138 private: 00139 friend class PageTable; 00140 bool readFromDevice (void); 00141 bool writeToDevice (void); 00142 00143 public: 00144 PagePointer (); 00145 virtual ~PagePointer (); 00146 00147 PagePointer &operator= (const PagePointer &rhs); 00148 }; 00149 00150 00151 class PageTable : public PageTableGenerated, public NeedsHeader 00152 { 00153 private: 00154 List <PagePointer> m_pagePointerList; 00155 Word m_pageNumberStart; // for consistency checking 00156 00157 friend class InternalParser; 00158 friend class InternalGenerator; 00159 bool readFromDevice (void); 00160 bool writeToDevice (void); 00161 00162 // call before readFromDevice () 00163 void setPageNumberStart (const Word s) { m_pageNumberStart = s; } 00164 00165 List <PagePointer>::Iterator m_pageTableIterator; 00166 00167 public: 00168 PageTable (); 00169 virtual ~PageTable (); 00170 00171 PageTable &operator= (const PageTable &rhs); 00172 00173 PagePointer *begin (void) 00174 { 00175 m_pageTableIterator = m_pagePointerList.begin (); 00176 return &(*m_pageTableIterator); 00177 } 00178 00179 PagePointer *next (void) 00180 { 00181 m_pageTableIterator = m_pageTableIterator.next (); 00182 return &(*m_pageTableIterator); 00183 } 00184 00185 bool end (void) /*const*/ 00186 { 00187 return m_pageTableIterator == m_pagePointerList.end (); 00188 } 00189 00190 bool add (const PagePointer *newone) 00191 { 00192 return m_pagePointerList.addToBack (*newone); 00193 } 00194 }; 00195 00196 00197 class FormatPointer : public FormatPointerGenerated 00198 { 00199 private: 00200 DWord m_afterEndCharByte; 00201 00202 friend class FormatInfoPage; 00203 bool readFromDevice (void); 00204 bool writeToDevice (void); 00205 00206 // 00207 // for exporting 00208 // 00209 const void *m_formatProperty; 00210 00211 const void *getFormatProperty (void) const { return m_formatProperty; } 00212 void setFormatProperty (const void *val) { m_formatProperty = val; } 00213 00214 public: 00215 FormatPointer (); 00216 virtual ~FormatPointer (); 00217 00218 FormatPointer &operator= (const FormatPointer &rhs); 00219 00220 DWord getAfterEndCharByte (void) const { return m_afterEndCharByte; } 00221 void setAfterEndCharByte (const DWord val) { m_afterEndCharByte = val; } 00222 }; 00223 00224 00225 enum FormatInfoPageTypes 00226 { 00227 CharType, 00228 ParaType 00229 }; 00230 00231 class FormatCharProperty; // from structures.h 00232 class FormatParaProperty; // from structures.h 00233 class FormatInfoPage : public FormatInfoPageGenerated, public NeedsHeader 00234 { 00235 private: 00236 DWord m_firstCharByte; // FormatInfoPageGenerated::m_firstCharBytePlus128 - 128 00237 enum FormatInfoPageTypes m_type; // CharInfo or ParaInfo? 00238 00239 00240 // 00241 // uncompressed data 00242 // 00243 00244 // list of FormatPointers (what byte it covers upto and which FormatProperty) 00245 FormatPointer *m_formatPointer; 00246 00247 // FormatProperty (which one? It depends on m_type) 00248 FormatCharProperty *m_formatCharProperty; 00249 FontTable *m_fontTable; // for CharProperty 00250 FormatParaProperty *m_formatParaProperty; 00251 Word m_leftMargin, m_rightMargin; // for ParaProperty 00252 00253 00254 // 00255 // Iterator helpers 00256 // 00257 int m_formatPointerUpto; // [import] which formatPointer we are up to 00258 DWord m_nextCharByte; // [import] for consistency checking 00259 int m_lastPropertyOffset; // [import] lazy optimisation (don't reload Property if FormatPointer points to last Property) 00260 int m_formatPointerPos, m_formatPropertyPos; // [export] 00261 int m_numProperty; // [export] 00262 00263 00264 friend class FormatInfo; // libmswrite.h 00265 bool readFromDevice (void); 00266 bool writeToDevice (void); 00267 bool writeToArray (void); 00268 00269 // TODO operator= 00270 FormatInfoPage &operator= (const FormatInfoPage &rhs); 00271 00272 public: 00273 FormatInfoPage (); 00274 virtual ~FormatInfoPage (); 00275 00276 void setMargins (const Word leftMargin, const Word rightMargin) 00277 { 00278 m_leftMargin = leftMargin, m_rightMargin = rightMargin; 00279 } 00280 void setFontTable (FontTable *fontTable) 00281 { 00282 m_fontTable = fontTable; 00283 } 00284 00285 void setType (const enum FormatInfoPageTypes t) { m_type = t; } 00286 00287 DWord getFirstCharByte (void) const { return m_firstCharByte; } 00288 void setFirstCharByte (const DWord val) { m_firstCharByte = val; } 00289 00290 DWord getNextCharByte (void) const { return m_nextCharByte; } 00291 00292 // my version of iterators is a lot simpler now, isn't it? :) 00293 void *begin (void); 00294 void *next (void); 00295 bool end (void) const; 00296 00297 bool add (const void *property); 00298 }; 00299 00300 00301 class BMP_BitmapFileHeader : public BMP_BitmapFileHeaderGenerated 00302 { 00303 public: 00304 BMP_BitmapFileHeader (); 00305 virtual ~BMP_BitmapFileHeader (); 00306 00307 BMP_BitmapFileHeader &operator= (const BMP_BitmapFileHeader &rhs); 00308 00309 bool readFromDevice (void); 00310 bool writeToDevice (void); 00311 }; 00312 00313 00314 class BMP_BitmapInfoHeader : public BMP_BitmapInfoHeaderGenerated 00315 { 00316 public: 00317 BMP_BitmapInfoHeader (); 00318 virtual ~BMP_BitmapInfoHeader (); 00319 00320 BMP_BitmapInfoHeader &operator= (const BMP_BitmapInfoHeader &rhs); 00321 00322 bool readFromDevice (void); 00323 bool writeToDevice (void); 00324 }; 00325 00326 00327 class BMP_BitmapColourIndex : public BMP_BitmapColourIndexGenerated 00328 { 00329 public: 00330 BMP_BitmapColourIndex (); 00331 virtual ~BMP_BitmapColourIndex (); 00332 00333 BMP_BitmapColourIndex &operator= (const BMP_BitmapColourIndex &rhs); 00334 }; 00335 00336 00337 class BitmapHeader : public BitmapHeaderGenerated 00338 { 00339 //private: 00340 // friend class ImageGenerated; 00341 public: 00342 BitmapHeader (); 00343 virtual ~BitmapHeader (); 00344 00345 BitmapHeader &operator= (const BitmapHeader &rhs); 00346 00347 bool readFromDevice (void); 00348 bool writeToDevice (void); 00349 }; 00350 00351 00352 class WMFHeader : public WMFHeaderGenerated 00353 { 00354 //private: 00355 // friend class Image; 00356 public: 00357 WMFHeader (); 00358 virtual ~WMFHeader (); 00359 00360 WMFHeader &operator= (const WMFHeader &rhs); 00361 00362 bool readFromDevice (void); 00363 bool writeToDevice (void); 00364 }; 00365 00366 } // namespace MSWrite { 00367 00368 #endif // __STRUCTURES_PRIVATE_H__ 00369 00370 // end of structures_private.h