filters

structures_generated.cpp

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 /*
00023  * structures_generated - Internal MS Write file structures
00024  * This file was generated by make_structures_generated 0.51pre 2003/07/09.
00025  * ALL CHANGES MADE TO THIS FILE "WILL BE LOST IN TIME LIKE TEARS IN RAIN"!
00026  */
00027 
00028 #include <assert.h>
00029 #include <stdio.h>
00030 #include <string.h>
00031 
00032 #include "structures_generated.h"
00033 #include "structures_private.h" // for forward references to embedded structures
00034 #include "structures.h" // for forward references to embedded structures
00035 
00036 namespace MSWrite
00037 {
00038     // -------------------- BEGIN HeaderGenerated --------------------
00039     
00040     HeaderGenerated::HeaderGenerated ()
00041     {
00042         // --- set defaults for variables --
00043         m_magic = (Word) (0xBE31/*Write 3.0*/);
00044         m_zero = (Word) (0);
00045         m_magic2 = (Word) (0xAB00);
00046         memset (m_zero2, (Word) (0), 4 * sizeof (Word));
00047         // no default for m_numCharBytesPlus128
00048         // no default for m_pageParaInfo
00049         // no default for m_pageFootnoteTable
00050         // no default for m_pageSectionProperty
00051         // no default for m_pageSectionTable
00052         // no default for m_pagePageTable
00053         // no default for m_pageFontTable
00054         memset (m_zero3, (Word) (0), 33 * sizeof (Word));
00055         // no default for m_numPages
00056     }
00057     
00058     HeaderGenerated::~HeaderGenerated ()
00059     {
00060     }
00061     
00062     HeaderGenerated &HeaderGenerated::operator= (const HeaderGenerated &rhs)
00063     {
00064         if (this == &rhs)
00065             return *this;
00066         
00067         NeedsDevice::operator= (rhs);
00068         memcpy (m_data, rhs.m_data, s_size);
00069         
00070         m_magic = rhs.m_magic;
00071         m_zero = rhs.m_zero;
00072         m_magic2 = rhs.m_magic2;
00073         memcpy (m_zero2, rhs.m_zero2, 4 * sizeof (Word));
00074         m_numCharBytesPlus128 = rhs.m_numCharBytesPlus128;
00075         m_pageParaInfo = rhs.m_pageParaInfo;
00076         m_pageFootnoteTable = rhs.m_pageFootnoteTable;
00077         m_pageSectionProperty = rhs.m_pageSectionProperty;
00078         m_pageSectionTable = rhs.m_pageSectionTable;
00079         m_pagePageTable = rhs.m_pagePageTable;
00080         m_pageFontTable = rhs.m_pageFontTable;
00081         memcpy (m_zero3, rhs.m_zero3, 33 * sizeof (Word));
00082         m_numPages = rhs.m_numPages;
00083         
00084         return *this;
00085     }
00086     
00087     bool HeaderGenerated::verifyVariables (void)
00088     {
00089     CHECK_DEVICE;
00090     
00091         if (!Verify (Error::InvalidFormat, m_magic == 0xBE31 || m_magic == 0xBE32, DWord (m_magic))) return false;
00092         if (!Verify (Error::InvalidFormat, m_zero == 0, DWord (m_zero))) return false;
00093         if (!Verify (Error::InvalidFormat, m_magic2 == 0xAB00, DWord (m_magic2))) return false;
00094         for (int i = 0; i < 4; i++)
00095         {
00096                        if (!Verify (Error::InvalidFormat, m_zero2 [i] == 0, long (m_zero2))) return false;
00097         }
00098         if (!Verify (Error::InvalidFormat, m_numCharBytesPlus128 >= 128, DWord (m_numCharBytesPlus128))) return false;
00099         // m_pageParaInfo will not be checked
00100         // m_pageFootnoteTable will not be checked
00101         // m_pageSectionProperty will not be checked
00102         // m_pageSectionTable will not be checked
00103         // m_pagePageTable will not be checked
00104         // m_pageFontTable will not be checked
00105         for (int i = 0; i < 33; i++)
00106         {
00107                        if (!Verify (Error::Warn, m_zero3 [i] == 0, long (m_zero3))) return false;
00108         }
00109         if (!Verify (Error::InvalidFormat, m_numPages > 0, DWord (m_numPages))) return false;
00110         return true;
00111     }
00112     
00113     bool HeaderGenerated::readFromDevice (void)
00114     {
00115     CHECK_DEVICE;
00116     
00117         // read the data straight from the file
00118         if (!m_device->readInternal (m_data, s_size))
00119             ErrorAndQuit (Error::FileError, "could not read HeaderGenerated data");
00120         
00121         ReadWord (m_magic, m_data + 0);
00122         ReadWord (m_zero, m_data + 2);
00123         ReadWord (m_magic2, m_data + 4);
00124         for (int i = 0; i < 4; i++)
00125         {
00126             ReadWord (m_zero2 [i], m_data + 6 + i * sizeof (Word));
00127         }
00128         
00129         ReadDWord (m_numCharBytesPlus128, m_data + 14);
00130         ReadWord (m_pageParaInfo, m_data + 18);
00131         ReadWord (m_pageFootnoteTable, m_data + 20);
00132         ReadWord (m_pageSectionProperty, m_data + 22);
00133         ReadWord (m_pageSectionTable, m_data + 24);
00134         ReadWord (m_pagePageTable, m_data + 26);
00135         ReadWord (m_pageFontTable, m_data + 28);
00136         for (int i = 0; i < 33; i++)
00137         {
00138             ReadWord (m_zero3 [i], m_data + 30 + i * sizeof (Word));
00139         }
00140         
00141         ReadWord (m_numPages, m_data + 96);
00142         return verifyVariables ();
00143     }
00144     
00145     bool HeaderGenerated::writeToArray (void)
00146     {
00147     CHECK_DEVICE;
00148     
00149         WriteWord (m_magic, m_data + 0);
00150         WriteWord (m_zero, m_data + 2);
00151         WriteWord (m_magic2, m_data + 4);
00152         for (int i = 0; i < 4; i++)
00153         {
00154             WriteWord (m_zero2 [i], m_data + 6 + i * sizeof (Word));
00155         }
00156         
00157         WriteDWord (m_numCharBytesPlus128, m_data + 14);
00158         WriteWord (m_pageParaInfo, m_data + 18);
00159         WriteWord (m_pageFootnoteTable, m_data + 20);
00160         WriteWord (m_pageSectionProperty, m_data + 22);
00161         WriteWord (m_pageSectionTable, m_data + 24);
00162         WriteWord (m_pagePageTable, m_data + 26);
00163         WriteWord (m_pageFontTable, m_data + 28);
00164         for (int i = 0; i < 33; i++)
00165         {
00166             WriteWord (m_zero3 [i], m_data + 30 + i * sizeof (Word));
00167         }
00168         
00169         WriteWord (m_numPages, m_data + 96);
00170         return true;
00171     }
00172     
00173     bool HeaderGenerated::writeToDevice (void)
00174     {
00175     CHECK_DEVICE;
00176     
00177         // ensure that the variables are in range
00178         if (!verifyVariables ()) return false;
00179         
00180         // write the variables to the array
00181         if (!writeToArray ()) return false;
00182         
00183         // write the data straight to the file
00184         if (!m_device->writeInternal (m_data, s_size))
00185             ErrorAndQuit (Error::FileError, "could not write HeaderGenerated data");
00186         
00187         return true;
00188     }
00189     
00190     
00191     // -------------------- BEGIN PageLayoutGenerated --------------------
00192     
00193     PageLayoutGenerated::PageLayoutGenerated ()
00194     {
00195         // --- set defaults for variables --
00196         m_magic102 = (Byte) (102);
00197         m_magic512 = (Word) (512);
00198         m_pageHeight = (Word) (Inch2Twip (11));
00199         m_pageWidth = (Word) (Inch2Twip (8.5));
00200         m_pageNumberStart = (Word) (1);
00201         m_topMargin = (Word) (Inch2Twip (1));
00202         m_textHeight = (Word) (Inch2Twip (9));
00203         m_leftMargin = (Word) (Inch2Twip (1.25));
00204         m_textWidth = (Word) (Inch2Twip (6));
00205         m_magic256 = (Word) (256);
00206         m_headerFromTop = (Word) (Inch2Twip (0.75));
00207         m_footerFromTop = (Word) (Inch2Twip (11.0/*m_pageHeight*/ - 0.75));
00208         m_magic720 = (Word) (720);
00209         m_zero = (Word) (0);
00210         m_magic1080 = (Word) (1080);
00211         m_unknown = (Word) (0);
00212         m_zero2 = (Word) (0);
00213     }
00214     
00215     PageLayoutGenerated::~PageLayoutGenerated ()
00216     {
00217     }
00218     
00219     PageLayoutGenerated &PageLayoutGenerated::operator= (const PageLayoutGenerated &rhs)
00220     {
00221         if (this == &rhs)
00222             return *this;
00223         
00224         NeedsDevice::operator= (rhs);
00225         memcpy (m_data, rhs.m_data, s_size);
00226         
00227         m_magic102 = rhs.m_magic102;
00228         m_magic512 = rhs.m_magic512;
00229         m_pageHeight = rhs.m_pageHeight;
00230         m_pageWidth = rhs.m_pageWidth;
00231         m_pageNumberStart = rhs.m_pageNumberStart;
00232         m_topMargin = rhs.m_topMargin;
00233         m_textHeight = rhs.m_textHeight;
00234         m_leftMargin = rhs.m_leftMargin;
00235         m_textWidth = rhs.m_textWidth;
00236         m_magic256 = rhs.m_magic256;
00237         m_headerFromTop = rhs.m_headerFromTop;
00238         m_footerFromTop = rhs.m_footerFromTop;
00239         m_magic720 = rhs.m_magic720;
00240         m_zero = rhs.m_zero;
00241         m_magic1080 = rhs.m_magic1080;
00242         m_unknown = rhs.m_unknown;
00243         m_zero2 = rhs.m_zero2;
00244         
00245         return *this;
00246     }
00247     
00248     bool PageLayoutGenerated::verifyVariables (void)
00249     {
00250     CHECK_DEVICE;
00251     
00252         if (!Verify (Error::Warn, m_magic102 == 102, DWord (m_magic102))) return false;
00253         if (!Verify (Error::Warn, m_magic512 == 512, DWord (m_magic512))) return false;
00254         // m_pageHeight will not be checked
00255         // m_pageWidth will not be checked
00256         // m_pageNumberStart will not be checked
00257         // m_topMargin will not be checked
00258         // m_textHeight will not be checked
00259         // m_leftMargin will not be checked
00260         // m_textWidth will not be checked
00261         if (!Verify (Error::Warn, m_magic256 == 256, DWord (m_magic256))) return false;
00262         // m_headerFromTop will not be checked
00263         // m_footerFromTop will not be checked
00264         if (!Verify (Error::Warn, m_magic720 == 720, DWord (m_magic720))) return false;
00265         if (!Verify (Error::Warn, m_zero == 0, DWord (m_zero))) return false;
00266         if (!Verify (Error::Warn, m_magic1080 == 1080, DWord (m_magic1080))) return false;
00267         // m_unknown will not be checked
00268         if (!Verify (Error::Warn, m_zero2 == 0, DWord (m_zero2))) return false;
00269         return true;
00270     }
00271     
00272     bool PageLayoutGenerated::readFromDevice (void)
00273     {
00274     CHECK_DEVICE;
00275     
00276         // read the data straight from the file
00277         if (!m_device->readInternal (m_data, s_size))
00278             ErrorAndQuit (Error::FileError, "could not read PageLayoutGenerated data");
00279         
00280         ReadByte (m_magic102, m_data + 0);
00281         ReadWord (m_magic512, m_data + 1);
00282         ReadWord (m_pageHeight, m_data + 3);
00283         ReadWord (m_pageWidth, m_data + 5);
00284         ReadWord (m_pageNumberStart, m_data + 7);
00285         ReadWord (m_topMargin, m_data + 9);
00286         ReadWord (m_textHeight, m_data + 11);
00287         ReadWord (m_leftMargin, m_data + 13);
00288         ReadWord (m_textWidth, m_data + 15);
00289         ReadWord (m_magic256, m_data + 17);
00290         ReadWord (m_headerFromTop, m_data + 19);
00291         ReadWord (m_footerFromTop, m_data + 21);
00292         ReadWord (m_magic720, m_data + 23);
00293         ReadWord (m_zero, m_data + 25);
00294         ReadWord (m_magic1080, m_data + 27);
00295         ReadWord (m_unknown, m_data + 29);
00296         ReadWord (m_zero2, m_data + 31);
00297         return verifyVariables ();
00298     }
00299     
00300     bool PageLayoutGenerated::writeToArray (void)
00301     {
00302     CHECK_DEVICE;
00303     
00304         WriteByte (m_magic102, m_data + 0);
00305         WriteWord (m_magic512, m_data + 1);
00306         WriteWord (m_pageHeight, m_data + 3);
00307         WriteWord (m_pageWidth, m_data + 5);
00308         WriteWord (m_pageNumberStart, m_data + 7);
00309         WriteWord (m_topMargin, m_data + 9);
00310         WriteWord (m_textHeight, m_data + 11);
00311         WriteWord (m_leftMargin, m_data + 13);
00312         WriteWord (m_textWidth, m_data + 15);
00313         WriteWord (m_magic256, m_data + 17);
00314         WriteWord (m_headerFromTop, m_data + 19);
00315         WriteWord (m_footerFromTop, m_data + 21);
00316         WriteWord (m_magic720, m_data + 23);
00317         WriteWord (m_zero, m_data + 25);
00318         WriteWord (m_magic1080, m_data + 27);
00319         WriteWord (m_unknown, m_data + 29);
00320         WriteWord (m_zero2, m_data + 31);
00321         return true;
00322     }
00323     
00324     bool PageLayoutGenerated::writeToDevice (void)
00325     {
00326     CHECK_DEVICE;
00327     
00328         // ensure that the variables are in range
00329         if (!verifyVariables ()) return false;
00330         
00331         // write the variables to the array
00332         if (!writeToArray ()) return false;
00333         
00334         // write the data straight to the file
00335         if (!m_device->writeInternal (m_data, s_size))
00336             ErrorAndQuit (Error::FileError, "could not write PageLayoutGenerated data");
00337         
00338         return true;
00339     }
00340     
00341     
00342     // -------------------- BEGIN SectionDescriptorGenerated --------------------
00343     
00344     SectionDescriptorGenerated::SectionDescriptorGenerated ()
00345     {
00346         // --- set defaults for variables --
00347         // no default for m_afterEndCharByte
00348         m_undefined = (Word) (0);
00349         // no default for m_sectionPropertyLocation
00350     }
00351     
00352     SectionDescriptorGenerated::~SectionDescriptorGenerated ()
00353     {
00354     }
00355     
00356     SectionDescriptorGenerated &SectionDescriptorGenerated::operator= (const SectionDescriptorGenerated &rhs)
00357     {
00358         if (this == &rhs)
00359             return *this;
00360         
00361         NeedsDevice::operator= (rhs);
00362         memcpy (m_data, rhs.m_data, s_size);
00363         
00364         m_afterEndCharByte = rhs.m_afterEndCharByte;
00365         m_undefined = rhs.m_undefined;
00366         m_sectionPropertyLocation = rhs.m_sectionPropertyLocation;
00367         
00368         return *this;
00369     }
00370     
00371     bool SectionDescriptorGenerated::verifyVariables (void)
00372     {
00373     CHECK_DEVICE;
00374     
00375         // m_afterEndCharByte will not be checked
00376         // m_undefined will not be checked
00377         // m_sectionPropertyLocation will not be checked
00378         return true;
00379     }
00380     
00381     bool SectionDescriptorGenerated::readFromDevice (void)
00382     {
00383     CHECK_DEVICE;
00384     
00385         // read the data straight from the file
00386         if (!m_device->readInternal (m_data, s_size))
00387             ErrorAndQuit (Error::FileError, "could not read SectionDescriptorGenerated data");
00388         
00389         ReadDWord (m_afterEndCharByte, m_data + 0);
00390         ReadWord (m_undefined, m_data + 4);
00391         ReadDWord (m_sectionPropertyLocation, m_data + 6);
00392         return verifyVariables ();
00393     }
00394     
00395     bool SectionDescriptorGenerated::writeToArray (void)
00396     {
00397     CHECK_DEVICE;
00398     
00399         WriteDWord (m_afterEndCharByte, m_data + 0);
00400         WriteWord (m_undefined, m_data + 4);
00401         WriteDWord (m_sectionPropertyLocation, m_data + 6);
00402         return true;
00403     }
00404     
00405     bool SectionDescriptorGenerated::writeToDevice (void)
00406     {
00407     CHECK_DEVICE;
00408     
00409         // ensure that the variables are in range
00410         if (!verifyVariables ()) return false;
00411         
00412         // write the variables to the array
00413         if (!writeToArray ()) return false;
00414         
00415         // write the data straight to the file
00416         if (!m_device->writeInternal (m_data, s_size))
00417             ErrorAndQuit (Error::FileError, "could not write SectionDescriptorGenerated data");
00418         
00419         return true;
00420     }
00421     
00422     
00423     // -------------------- BEGIN SectionTableGenerated --------------------
00424     
00425     SectionTableGenerated::SectionTableGenerated ()
00426     {
00427         // --- set pointer(s) to NULL (prevent segfault with premature exit) ---
00428         for (int i = 0; i < 2; i++)
00429             m_sed [i] = NULL;
00430         
00431         // --- allocate memory for embedded structures ---
00432         for (int i = 0; i < 2; i++)
00433         {
00434             m_sed [i] = new SectionDescriptor;  // forward ref to structures*.cpp
00435             if (!m_sed [i]) return;
00436         }
00437         
00438         // --- set defaults for variables --
00439         m_numSectionDescriptors = (Word) (2);
00440         m_undefined = (Word) (0);
00441         // leaving constructor of m_sed to set its own defaults
00442     }
00443     
00444     SectionTableGenerated::~SectionTableGenerated ()
00445     {
00446         for (int i = 0; i < 2; i++)
00447             delete m_sed [i];
00448     }
00449     
00450     SectionTableGenerated &SectionTableGenerated::operator= (const SectionTableGenerated &rhs)
00451     {
00452         if (this == &rhs)
00453             return *this;
00454         
00455         NeedsDevice::operator= (rhs);
00456         memcpy (m_data, rhs.m_data, s_size);
00457         
00458         m_numSectionDescriptors = rhs.m_numSectionDescriptors;
00459         m_undefined = rhs.m_undefined;
00460         for (int i = 0; i < 2; i++)
00461             *m_sed [i] = *(rhs.m_sed [i]);
00462         
00463         return *this;
00464     }
00465     
00466     bool SectionTableGenerated::verifyVariables (void)
00467     {
00468     CHECK_DEVICE;
00469     
00470         // m_numSectionDescriptors will not be checked
00471         // m_undefined will not be checked
00472         for (int i = 0; i < 2; i++)
00473         {
00474             if (!m_sed [i]) {   ErrorAndQuit (Error::OutOfMemory, "could not allocate memory for sed in constructor");  }
00475         }
00476         return true;
00477     }
00478     
00479     bool SectionTableGenerated::readFromDevice (void)
00480     {
00481     CHECK_DEVICE;
00482     
00483         // read the data straight from the file
00484         if (!m_device->readInternal (m_data, s_size))
00485             ErrorAndQuit (Error::FileError, "could not read SectionTableGenerated data");
00486         
00487         ReadWord (m_numSectionDescriptors, m_data + 0);
00488         ReadWord (m_undefined, m_data + 2);
00489         for (int i = 0; i < 2; i++)
00490         {
00491             m_device->setCache (m_data + 4 + i * SectionDescriptorGenerated::s_size);
00492             m_sed [i]->setDevice (m_device);
00493             if (!m_sed [i]->readFromDevice ()) return false;
00494             m_device->setCache (NULL);
00495         }
00496         
00497         return verifyVariables ();
00498     }
00499     
00500     bool SectionTableGenerated::writeToArray (void)
00501     {
00502     CHECK_DEVICE;
00503     
00504         WriteWord (m_numSectionDescriptors, m_data + 0);
00505         WriteWord (m_undefined, m_data + 2);
00506         for (int i = 0; i < 2; i++)
00507         {
00508             m_device->setCache (m_data + 4 + i * SectionDescriptorGenerated::s_size);
00509             m_sed [i]->setDevice (m_device);
00510             if (!m_sed [i]->writeToDevice ()) return false;
00511             m_device->setCache (NULL);
00512         }
00513         
00514         return true;
00515     }
00516     
00517     bool SectionTableGenerated::writeToDevice (void)
00518     {
00519     CHECK_DEVICE;
00520     
00521         // ensure that the variables are in range
00522         if (!verifyVariables ()) return false;
00523         
00524         // write the variables to the array
00525         if (!writeToArray ()) return false;
00526         
00527         // write the data straight to the file
00528         if (!m_device->writeInternal (m_data, s_size))
00529             ErrorAndQuit (Error::FileError, "could not write SectionTableGenerated data");
00530         
00531         return true;
00532     }
00533     
00534     
00535     // -------------------- BEGIN FontGenerated --------------------
00536     
00537     FontGenerated::FontGenerated ()
00538     {
00539         // --- set defaults for variables --
00540         m_numDataBytes = (Word) (0);
00541         m_family = (Byte) (0);
00542     }
00543     
00544     FontGenerated::~FontGenerated ()
00545     {
00546     }
00547     
00548     FontGenerated &FontGenerated::operator= (const FontGenerated &rhs)
00549     {
00550         if (this == &rhs)
00551             return *this;
00552         
00553         NeedsDevice::operator= (rhs);
00554         memcpy (m_data, rhs.m_data, s_size);
00555         
00556         m_numDataBytes = rhs.m_numDataBytes;
00557         m_family = rhs.m_family;
00558         
00559         return *this;
00560     }
00561     
00562     bool FontGenerated::verifyVariables (void)
00563     {
00564     CHECK_DEVICE;
00565     
00566         // m_numDataBytes will not be checked
00567         // m_family will not be checked
00568         return true;
00569     }
00570     
00571     bool FontGenerated::readFromDevice (void)
00572     {
00573     CHECK_DEVICE;
00574     
00575         // read the data straight from the file
00576         if (!m_device->readInternal (m_data, s_size))
00577             ErrorAndQuit (Error::FileError, "could not read FontGenerated data");
00578         
00579         ReadWord (m_numDataBytes, m_data + 0);
00580         ReadByte (m_family, m_data + 2);
00581         return verifyVariables ();
00582     }
00583     
00584     bool FontGenerated::writeToArray (void)
00585     {
00586     CHECK_DEVICE;
00587     
00588         WriteWord (m_numDataBytes, m_data + 0);
00589         WriteByte (m_family, m_data + 2);
00590         return true;
00591     }
00592     
00593     bool FontGenerated::writeToDevice (void)
00594     {
00595     CHECK_DEVICE;
00596     
00597         // ensure that the variables are in range
00598         if (!verifyVariables ()) return false;
00599         
00600         // write the variables to the array
00601         if (!writeToArray ()) return false;
00602         
00603         // write the data straight to the file
00604         if (!m_device->writeInternal (m_data, s_size))
00605             ErrorAndQuit (Error::FileError, "could not write FontGenerated data");
00606         
00607         return true;
00608     }
00609     
00610     
00611     // -------------------- BEGIN FontTableGenerated --------------------
00612     
00613     FontTableGenerated::FontTableGenerated ()
00614     {
00615         // --- set defaults for variables --
00616         m_numFonts = (Word) (0);
00617     }
00618     
00619     FontTableGenerated::~FontTableGenerated ()
00620     {
00621     }
00622     
00623     FontTableGenerated &FontTableGenerated::operator= (const FontTableGenerated &rhs)
00624     {
00625         if (this == &rhs)
00626             return *this;
00627         
00628         NeedsDevice::operator= (rhs);
00629         memcpy (m_data, rhs.m_data, s_size);
00630         
00631         m_numFonts = rhs.m_numFonts;
00632         
00633         return *this;
00634     }
00635     
00636     bool FontTableGenerated::verifyVariables (void)
00637     {
00638     CHECK_DEVICE;
00639     
00640         // m_numFonts will not be checked
00641         return true;
00642     }
00643     
00644     bool FontTableGenerated::readFromDevice (void)
00645     {
00646     CHECK_DEVICE;
00647     
00648         // read the data straight from the file
00649         if (!m_device->readInternal (m_data, s_size))
00650             ErrorAndQuit (Error::FileError, "could not read FontTableGenerated data");
00651         
00652         ReadWord (m_numFonts, m_data + 0);
00653         return verifyVariables ();
00654     }
00655     
00656     bool FontTableGenerated::writeToArray (void)
00657     {
00658     CHECK_DEVICE;
00659     
00660         WriteWord (m_numFonts, m_data + 0);
00661         return true;
00662     }
00663     
00664     bool FontTableGenerated::writeToDevice (void)
00665     {
00666     CHECK_DEVICE;
00667     
00668         // ensure that the variables are in range
00669         if (!verifyVariables ()) return false;
00670         
00671         // write the variables to the array
00672         if (!writeToArray ()) return false;
00673         
00674         // write the data straight to the file
00675         if (!m_device->writeInternal (m_data, s_size))
00676             ErrorAndQuit (Error::FileError, "could not write FontTableGenerated data");
00677         
00678         return true;
00679     }
00680     
00681     
00682     // -------------------- BEGIN PagePointerGenerated --------------------
00683     
00684     PagePointerGenerated::PagePointerGenerated ()
00685     {
00686         // --- set defaults for variables --
00687         // no default for m_pageNumber
00688         // no default for m_firstCharByte
00689     }
00690     
00691     PagePointerGenerated::~PagePointerGenerated ()
00692     {
00693     }
00694     
00695     PagePointerGenerated &PagePointerGenerated::operator= (const PagePointerGenerated &rhs)
00696     {
00697         if (this == &rhs)
00698             return *this;
00699         
00700         NeedsDevice::operator= (rhs);
00701         memcpy (m_data, rhs.m_data, s_size);
00702         
00703         m_pageNumber = rhs.m_pageNumber;
00704         m_firstCharByte = rhs.m_firstCharByte;
00705         
00706         return *this;
00707     }
00708     
00709     bool PagePointerGenerated::verifyVariables (void)
00710     {
00711     CHECK_DEVICE;
00712     
00713         if (!Verify (Error::InvalidFormat, m_pageNumber > 0, DWord (m_pageNumber))) return false;
00714         // m_firstCharByte will not be checked
00715         return true;
00716     }
00717     
00718     bool PagePointerGenerated::readFromDevice (void)
00719     {
00720     CHECK_DEVICE;
00721     
00722         // read the data straight from the file
00723         if (!m_device->readInternal (m_data, s_size))
00724             ErrorAndQuit (Error::FileError, "could not read PagePointerGenerated data");
00725         
00726         ReadWord (m_pageNumber, m_data + 0);
00727         ReadDWord (m_firstCharByte, m_data + 2);
00728         return verifyVariables ();
00729     }
00730     
00731     bool PagePointerGenerated::writeToArray (void)
00732     {
00733     CHECK_DEVICE;
00734     
00735         WriteWord (m_pageNumber, m_data + 0);
00736         WriteDWord (m_firstCharByte, m_data + 2);
00737         return true;
00738     }
00739     
00740     bool PagePointerGenerated::writeToDevice (void)
00741     {
00742     CHECK_DEVICE;
00743     
00744         // ensure that the variables are in range
00745         if (!verifyVariables ()) return false;
00746         
00747         // write the variables to the array
00748         if (!writeToArray ()) return false;
00749         
00750         // write the data straight to the file
00751         if (!m_device->writeInternal (m_data, s_size))
00752             ErrorAndQuit (Error::FileError, "could not write PagePointerGenerated data");
00753         
00754         return true;
00755     }
00756     
00757     
00758     // -------------------- BEGIN PageTableGenerated --------------------
00759     
00760     PageTableGenerated::PageTableGenerated ()
00761     {
00762         // --- set defaults for variables --
00763         m_numPagePointers = (Word) (0);
00764         m_zero = (Word) (0);
00765     }
00766     
00767     PageTableGenerated::~PageTableGenerated ()
00768     {
00769     }
00770     
00771     PageTableGenerated &PageTableGenerated::operator= (const PageTableGenerated &rhs)
00772     {
00773         if (this == &rhs)
00774             return *this;
00775         
00776         NeedsDevice::operator= (rhs);
00777         memcpy (m_data, rhs.m_data, s_size);
00778         
00779         m_numPagePointers = rhs.m_numPagePointers;
00780         m_zero = rhs.m_zero;
00781         
00782         return *this;
00783     }
00784     
00785     bool PageTableGenerated::verifyVariables (void)
00786     {
00787     CHECK_DEVICE;
00788     
00789         // m_numPagePointers will not be checked
00790         if (!Verify (Error::Warn, m_zero == 0, DWord (m_zero))) return false;
00791         return true;
00792     }
00793     
00794     bool PageTableGenerated::readFromDevice (void)
00795     {
00796     CHECK_DEVICE;
00797     
00798         // read the data straight from the file
00799         if (!m_device->readInternal (m_data, s_size))
00800             ErrorAndQuit (Error::FileError, "could not read PageTableGenerated data");
00801         
00802         ReadWord (m_numPagePointers, m_data + 0);
00803         ReadWord (m_zero, m_data + 2);
00804         return verifyVariables ();
00805     }
00806     
00807     bool PageTableGenerated::writeToArray (void)
00808     {
00809     CHECK_DEVICE;
00810     
00811         WriteWord (m_numPagePointers, m_data + 0);
00812         WriteWord (m_zero, m_data + 2);
00813         return true;
00814     }
00815     
00816     bool PageTableGenerated::writeToDevice (void)
00817     {
00818     CHECK_DEVICE;
00819     
00820         // ensure that the variables are in range
00821         if (!verifyVariables ()) return false;
00822         
00823         // write the variables to the array
00824         if (!writeToArray ()) return false;
00825         
00826         // write the data straight to the file
00827         if (!m_device->writeInternal (m_data, s_size))
00828             ErrorAndQuit (Error::FileError, "could not write PageTableGenerated data");
00829         
00830         return true;
00831     }
00832     
00833     
00834     // -------------------- BEGIN FormatPointerGenerated --------------------
00835     
00836     FormatPointerGenerated::FormatPointerGenerated ()
00837     {
00838         // --- set defaults for variables --
00839         // no default for m_afterEndCharBytePlus128
00840         // no default for m_formatPropertyOffset
00841     }
00842     
00843     FormatPointerGenerated::~FormatPointerGenerated ()
00844     {
00845     }
00846     
00847     FormatPointerGenerated &FormatPointerGenerated::operator= (const FormatPointerGenerated &rhs)
00848     {
00849         if (this == &rhs)
00850             return *this;
00851         
00852         NeedsDevice::operator= (rhs);
00853         memcpy (m_data, rhs.m_data, s_size);
00854         
00855         m_afterEndCharBytePlus128 = rhs.m_afterEndCharBytePlus128;
00856         m_formatPropertyOffset = rhs.m_formatPropertyOffset;
00857         
00858         return *this;
00859     }
00860     
00861     bool FormatPointerGenerated::verifyVariables (void)
00862     {
00863     CHECK_DEVICE;
00864     
00865         if (!Verify (Error::InvalidFormat, m_afterEndCharBytePlus128 >= 128, DWord (m_afterEndCharBytePlus128))) return false;
00866         if (!Verify (Error::InvalidFormat, m_formatPropertyOffset == 0xFFFF || m_formatPropertyOffset < 123 - 1/*numDataBytes of either FormatProperty, can't have 0 byte FormatProperty*/, DWord (m_formatPropertyOffset))) return false;
00867         return true;
00868     }
00869     
00870     bool FormatPointerGenerated::readFromDevice (void)
00871     {
00872     CHECK_DEVICE;
00873     
00874         // read the data straight from the file
00875         if (!m_device->readInternal (m_data, s_size))
00876             ErrorAndQuit (Error::FileError, "could not read FormatPointerGenerated data");
00877         
00878         ReadDWord (m_afterEndCharBytePlus128, m_data + 0);
00879         ReadWord (m_formatPropertyOffset, m_data + 4);
00880         return verifyVariables ();
00881     }
00882     
00883     bool FormatPointerGenerated::writeToArray (void)
00884     {
00885     CHECK_DEVICE;
00886     
00887         WriteDWord (m_afterEndCharBytePlus128, m_data + 0);
00888         WriteWord (m_formatPropertyOffset, m_data + 4);
00889         return true;
00890     }
00891     
00892     bool FormatPointerGenerated::writeToDevice (void)
00893     {
00894     CHECK_DEVICE;
00895     
00896         // ensure that the variables are in range
00897         if (!verifyVariables ()) return false;
00898         
00899         // write the variables to the array
00900         if (!writeToArray ()) return false;
00901         
00902         // write the data straight to the file
00903         if (!m_device->writeInternal (m_data, s_size))
00904             ErrorAndQuit (Error::FileError, "could not write FormatPointerGenerated data");
00905         
00906         return true;
00907     }
00908     
00909     
00910     // -------------------- BEGIN FormatCharPropertyGenerated --------------------
00911     
00912     FormatCharPropertyGenerated::FormatCharPropertyGenerated ()
00913     {
00914         // --- set defaults in raw array (needed because it's a useThisMuch structure) ---
00915         WriteByte ((Byte) (1), m_data + 1);// unknown
00916         m_data [2] = 0;                     // isBold, isItalic, fontCodeLow
00917         WriteByte ((Byte) (24), m_data + 3);// fontSize
00918         m_data [4] = 0;                     // isUnderlined, zero, isPageNumber, zero2, fontCodeHigh, zero3, position
00919         m_data [5] = 0;
00920         m_data [6] = 0;
00921         
00922         // --- set defaults for variables --
00923         m_numDataBytes = (Byte) (0);
00924         m_unknown = (Byte) (1);
00925         m_isBold = (unsigned) (0);
00926         m_isItalic = (unsigned) (0);
00927         m_fontCodeLow = (unsigned) (0);
00928         m_fontSize = (Byte) (24);
00929         m_isUnderlined = (unsigned) (0);
00930         m_zero = (unsigned) (0);
00931         m_isPageNumber = (unsigned) (0);
00932         m_zero2 = (unsigned) (0);
00933         m_fontCodeHigh = (unsigned) (0);
00934         m_zero3 = (unsigned) (0);
00935         m_position = (Byte) (0);
00936     }
00937     
00938     FormatCharPropertyGenerated::~FormatCharPropertyGenerated ()
00939     {
00940     }
00941     
00942     FormatCharPropertyGenerated &FormatCharPropertyGenerated::operator= (const FormatCharPropertyGenerated &rhs)
00943     {
00944         if (this == &rhs)
00945             return *this;
00946         
00947         NeedsDevice::operator= (rhs);
00948         UseThisMuch::operator= (rhs);
00949         memcpy (m_data, rhs.m_data, s_size);
00950         
00951         m_numDataBytes = rhs.m_numDataBytes;
00952         m_unknown = rhs.m_unknown;
00953         m_isBold = rhs.m_isBold;
00954         m_isItalic = rhs.m_isItalic;
00955         m_fontCodeLow = rhs.m_fontCodeLow;
00956         m_fontSize = rhs.m_fontSize;
00957         m_isUnderlined = rhs.m_isUnderlined;
00958         m_zero = rhs.m_zero;
00959         m_isPageNumber = rhs.m_isPageNumber;
00960         m_zero2 = rhs.m_zero2;
00961         m_fontCodeHigh = rhs.m_fontCodeHigh;
00962         m_zero3 = rhs.m_zero3;
00963         m_position = rhs.m_position;
00964         
00965         return *this;
00966     }
00967     
00968     bool FormatCharPropertyGenerated::verifyVariables (void)
00969     {
00970     CHECK_DEVICE;
00971     
00972         if (!Verify (Error::InvalidFormat, m_numDataBytes >= 1 && m_numDataBytes <= s_size - sizeof (Byte), DWord (m_numDataBytes))) return false;
00973         if (!Verify (Error::Warn, m_unknown <= 1, DWord (m_unknown))) return false;
00974         // m_isBold will not be checked
00975         // m_isItalic will not be checked
00976         // m_fontCodeLow will not be checked
00977         // m_fontSize will not be checked
00978         // m_isUnderlined will not be checked
00979         if (!Verify (Error::Warn, m_zero == 0, DWord (m_zero))) return false;
00980         // m_isPageNumber will not be checked
00981         if (!Verify (Error::Warn, m_zero2 == 0, DWord (m_zero2))) return false;
00982         // m_fontCodeHigh will not be checked
00983         if (!Verify (Error::Warn, m_zero3 == 0, DWord (m_zero3))) return false;
00984         // m_position will not be checked
00985         return true;
00986     }
00987     
00988     bool FormatCharPropertyGenerated::readFromDevice (void)
00989     {
00990     CHECK_DEVICE;
00991     
00992         // find out how many bytes to read
00993         if (!m_device->readInternal (m_data, 1))
00994             ErrorAndQuit (Error::FileError, "could not read FormatCharPropertyGenerated numDataBytes");
00995         ReadByte (m_numDataBytes, m_data);
00996         if (!Verify (Error::InvalidFormat, m_numDataBytes >= 1 && m_numDataBytes <= s_size - sizeof (Byte), DWord (m_numDataBytes))) return false;
00997         if (!m_device->readInternal (m_data + 1, m_numDataBytes))
00998             ErrorAndQuit (Error::FileError, "could not read FormatCharPropertyGenerated data");
00999         
01000         ReadByte (m_unknown, m_data + 1);
01001         signalHaveSetData (m_unknown == Byte (1), 0/*offset*/ + 8/*size*/);
01002         ReadBitsFromByte (m_isBold, m_data [2], 0, 1);
01003         signalHaveSetData (m_isBold == bool (0), 8/*offset*/ + 1/*size*/);
01004         ReadBitsFromByte (m_isItalic, m_data [2], 1, 1);
01005         signalHaveSetData (m_isItalic == bool (0), 9/*offset*/ + 1/*size*/);
01006         ReadBitsFromByte (m_fontCodeLow, m_data [2], 2, 6);
01007         signalHaveSetData (m_fontCodeLow == unsigned (0), 10/*offset*/ + 6/*size*/);
01008         ReadByte (m_fontSize, m_data + 3);
01009         signalHaveSetData (m_fontSize == Byte (24), 16/*offset*/ + 8/*size*/);
01010         ReadBitsFromByte (m_isUnderlined, m_data [4], 0, 1);
01011         signalHaveSetData (m_isUnderlined == bool (0), 24/*offset*/ + 1/*size*/);
01012         ReadBitsFromByte (m_zero, m_data [4], 1, 5);
01013         signalHaveSetData (m_zero == unsigned (0), 25/*offset*/ + 5/*size*/);
01014         ReadBitsFromByte (m_isPageNumber, m_data [4], 6, 1);
01015         signalHaveSetData (m_isPageNumber == bool (0), 30/*offset*/ + 1/*size*/);
01016         ReadBitsFromByte (m_zero2, m_data [4], 7, 1);
01017         signalHaveSetData (m_zero2 == bool (0), 31/*offset*/ + 1/*size*/);
01018         ReadBitsFromByte (m_fontCodeHigh, m_data [5], 0, 3);
01019         signalHaveSetData (m_fontCodeHigh == unsigned (0), 32/*offset*/ + 3/*size*/);
01020         ReadBitsFromByte (m_zero3, m_data [5], 3, 5);
01021         signalHaveSetData (m_zero3 == unsigned (0), 35/*offset*/ + 5/*size*/);
01022         ReadByte (m_position, m_data + 6);
01023         signalHaveSetData (m_position == Byte (0), 40/*offset*/ + 8/*size*/);
01024         return verifyVariables ();
01025     }
01026     
01027     bool FormatCharPropertyGenerated::writeToArray (void)
01028     {
01029     CHECK_DEVICE;
01030     
01031         // set m_data to 0 to avoid problems with bit ops
01032         memset (m_data, 0, s_size);
01033         
01034         WriteByte (m_numDataBytes, m_data + 0);
01035         WriteByte (m_unknown, m_data + 1);
01036         WriteBitsToByte (m_isBold, m_data [2], 0, 1);
01037         WriteBitsToByte (m_isItalic, m_data [2], 1, 1);
01038         WriteBitsToByte (m_fontCodeLow, m_data [2], 2, 6);
01039         WriteByte (m_fontSize, m_data + 3);
01040         WriteBitsToByte (m_isUnderlined, m_data [4], 0, 1);
01041         WriteBitsToByte (m_zero, m_data [4], 1, 5);
01042         WriteBitsToByte (m_isPageNumber, m_data [4], 6, 1);
01043         WriteBitsToByte (m_zero2, m_data [4], 7, 1);
01044         WriteBitsToByte (m_fontCodeHigh, m_data [5], 0, 3);
01045         WriteBitsToByte (m_zero3, m_data [5], 3, 5);
01046         WriteByte (m_position, m_data + 6);
01047         return true;
01048     }
01049     
01050     bool FormatCharPropertyGenerated::writeToDevice (void)
01051     {
01052     CHECK_DEVICE;
01053     
01054         // sync m_numDataBytes with reality
01055         updateNumDataBytes ();
01056         
01057         // ensure that the variables are in range
01058         if (!verifyVariables ()) return false;
01059         
01060         // write the variables to the array
01061         if (!writeToArray ()) return false;
01062         
01063         // write the data straight to the file
01064         if (!m_device->writeInternal (m_data, 1 /*sizeof (m_numDataBytes)*/ + (m_numDataBytes ? m_numDataBytes : getNeedNumDataBytes ())))
01065             ErrorAndQuit (Error::FileError, "could not write FormatCharPropertyGenerated data");
01066         
01067         return true;
01068     }
01069     
01070     
01071     // -------------------- BEGIN FormatParaPropertyTabulatorGenerated --------------------
01072     
01073     FormatParaPropertyTabulatorGenerated::FormatParaPropertyTabulatorGenerated ()
01074     {
01075         // --- set defaults for variables --
01076         m_indent = (Word) (0);
01077         m_type = (Byte) (0);
01078         m_zero = (Byte) (0);
01079     }
01080     
01081     FormatParaPropertyTabulatorGenerated::~FormatParaPropertyTabulatorGenerated ()
01082     {
01083     }
01084     
01085     FormatParaPropertyTabulatorGenerated &FormatParaPropertyTabulatorGenerated::operator= (const FormatParaPropertyTabulatorGenerated &rhs)
01086     {
01087         if (this == &rhs)
01088             return *this;
01089         
01090         NeedsDevice::operator= (rhs);
01091         memcpy (m_data, rhs.m_data, s_size);
01092         
01093         m_indent = rhs.m_indent;
01094         m_type = rhs.m_type;
01095         m_zero = rhs.m_zero;
01096         
01097         return *this;
01098     }
01099     
01100     bool FormatParaPropertyTabulatorGenerated::verifyVariables (void)
01101     {
01102     CHECK_DEVICE;
01103     
01104         // m_indent will not be checked
01105         if (!Verify (Error::InvalidFormat, m_type == 0 || m_type == 3, DWord (m_type))) return false;
01106         if (!Verify (Error::Warn, m_zero == 0, DWord (m_zero))) return false;
01107         return true;
01108     }
01109     
01110     bool FormatParaPropertyTabulatorGenerated::readFromDevice (void)
01111     {
01112     CHECK_DEVICE;
01113     
01114         // read the data straight from the file
01115         if (!m_device->readInternal (m_data, s_size))
01116             ErrorAndQuit (Error::FileError, "could not read FormatParaPropertyTabulatorGenerated data");
01117         
01118         ReadWord (m_indent, m_data + 0);
01119         ReadByte (m_type, m_data + 2);
01120         ReadByte (m_zero, m_data + 3);
01121         return verifyVariables ();
01122     }
01123     
01124     bool FormatParaPropertyTabulatorGenerated::writeToArray (void)
01125     {
01126     CHECK_DEVICE;
01127     
01128         WriteWord (m_indent, m_data + 0);
01129         WriteByte (m_type, m_data + 2);
01130         WriteByte (m_zero, m_data + 3);
01131         return true;
01132     }
01133     
01134     bool FormatParaPropertyTabulatorGenerated::writeToDevice (void)
01135     {
01136     CHECK_DEVICE;
01137     
01138         // ensure that the variables are in range
01139         if (!verifyVariables ()) return false;
01140         
01141         // write the variables to the array
01142         if (!writeToArray ()) return false;
01143         
01144         // write the data straight to the file
01145         if (!m_device->writeInternal (m_data, s_size))
01146             ErrorAndQuit (Error::FileError, "could not write FormatParaPropertyTabulatorGenerated data");
01147         
01148         return true;
01149     }
01150     
01151     
01152     // -------------------- BEGIN FormatParaPropertyGenerated --------------------
01153     
01154     FormatParaPropertyGenerated::FormatParaPropertyGenerated ()
01155     {
01156         // --- set pointer(s) to NULL (prevent segfault with premature exit) ---
01157         for (int i = 0; i < 14; i++)
01158             m_tab [i] = NULL;
01159         
01160         // --- allocate memory for embedded structures ---
01161         for (int i = 0; i < 14; i++)
01162         {
01163             m_tab [i] = new FormatParaPropertyTabulator;    // forward ref to structures*.cpp
01164             if (!m_tab [i]) return;
01165         }
01166         
01167         // --- set defaults in raw array (needed because it's a useThisMuch structure) ---
01168         WriteByte ((Byte) (60), m_data + 1);// magic0_60_or_61
01169         m_data [2] = 0;                     // alignment
01170         WriteWord ((Word) (30), m_data + 3);// magic30
01171         memset (m_data + 5, 0, 6);          // rightIndent, leftIndent, leftIndentFirstLine
01172         WriteWord ((Word) (240), m_data + 11);// lineSpacing
01173         memset (m_data + 13, 0, 10);        // zero, headerOrFooter, isNotNormalParagraph, isOnFirstPage, isObject, zero2, zero3
01174         memset (m_data + 23, 0, 56);        // HACK: default embedded structures is 0
01175         
01176         // --- set defaults for variables --
01177         m_numDataBytes = (Byte) (0);
01178         m_magic0_60_or_61 = (Byte) (60);
01179         m_alignment = (Byte) (0);
01180         m_magic30 = (Word) (30);
01181         m_rightIndent = (Word) (0);
01182         m_leftIndent = (Word) (0);
01183         m_leftIndentFirstLine = (Short) (0);
01184         m_lineSpacing = (Word) (240);
01185         for (int i = 0; i < 2; i++)
01186             m_zero [i] = (Word) (0);
01187         m_headerOrFooter = (unsigned) (0);
01188         m_isNotNormalParagraph = (unsigned) (0);
01189         m_isOnFirstPage = (unsigned) (0);
01190         m_isObject = (unsigned) (0);
01191         m_zero2 = (unsigned) (0);
01192         memset (m_zero3, (Byte) (0), 5 * sizeof (Byte));
01193         // leaving constructor of m_tab to set its own defaults
01194     }
01195     
01196     FormatParaPropertyGenerated::~FormatParaPropertyGenerated ()
01197     {
01198         for (int i = 0; i < 14; i++)
01199             delete m_tab [i];
01200     }
01201     
01202     FormatParaPropertyGenerated &FormatParaPropertyGenerated::operator= (const FormatParaPropertyGenerated &rhs)
01203     {
01204         if (this == &rhs)
01205             return *this;
01206         
01207         NeedsDevice::operator= (rhs);
01208         UseThisMuch::operator= (rhs);
01209         memcpy (m_data, rhs.m_data, s_size);
01210         
01211         m_numDataBytes = rhs.m_numDataBytes;
01212         m_magic0_60_or_61 = rhs.m_magic0_60_or_61;
01213         m_alignment = rhs.m_alignment;
01214         m_magic30 = rhs.m_magic30;
01215         m_rightIndent = rhs.m_rightIndent;
01216         m_leftIndent = rhs.m_leftIndent;
01217         m_leftIndentFirstLine = rhs.m_leftIndentFirstLine;
01218         m_lineSpacing = rhs.m_lineSpacing;
01219         memcpy (m_zero, rhs.m_zero, 2 * sizeof (Word));
01220         m_headerOrFooter = rhs.m_headerOrFooter;
01221         m_isNotNormalParagraph = rhs.m_isNotNormalParagraph;
01222         m_isOnFirstPage = rhs.m_isOnFirstPage;
01223         m_isObject = rhs.m_isObject;
01224         m_zero2 = rhs.m_zero2;
01225         memcpy (m_zero3, rhs.m_zero3, 5 * sizeof (Byte));
01226         for (int i = 0; i < 14; i++)
01227             *m_tab [i] = *(rhs.m_tab [i]);
01228         
01229         return *this;
01230     }
01231     
01232     bool FormatParaPropertyGenerated::verifyVariables (void)
01233     {
01234     CHECK_DEVICE;
01235     
01236         if (!Verify (Error::InvalidFormat, m_numDataBytes >= 1 && m_numDataBytes <= s_size - sizeof (Byte), DWord (m_numDataBytes))) return false;
01237         if (!Verify (Error::Warn, m_magic0_60_or_61 == 0 || m_magic0_60_or_61 == 60 || m_magic0_60_or_61 == 61, DWord (m_magic0_60_or_61))) return false;
01238         // m_alignment will not be checked
01239         if (!Verify (Error::Warn, m_magic30 == 30, DWord (m_magic30))) return false;
01240         // m_rightIndent will not be checked
01241         // m_leftIndent will not be checked
01242         // m_leftIndentFirstLine will not be checked
01243         // m_lineSpacing will not be checked
01244         for (int i = 0; i < 2; i++)
01245         {
01246                        if (!Verify (Error::Warn, m_zero [i] == 0, long (m_zero))) return false;
01247         }
01248         // m_headerOrFooter will not be checked
01249         // m_isNotNormalParagraph will not be checked
01250         // m_isOnFirstPage will not be checked
01251         // m_isObject will not be checked
01252         if (!Verify (Error::Warn, m_zero2 == 0, DWord (m_zero2))) return false;
01253         for (int i = 0; i < 5; i++)
01254         {
01255                        if (!Verify (Error::Warn, m_zero3 [i] == 0, long (m_zero3))) return false;
01256         }
01257         for (int i = 0; i < 14; i++)
01258         {
01259             if (!m_tab [i]) {   ErrorAndQuit (Error::OutOfMemory, "could not allocate memory for tab in constructor");  }
01260         }
01261         return true;
01262     }
01263     
01264     bool FormatParaPropertyGenerated::readFromDevice (void)
01265     {
01266     CHECK_DEVICE;
01267     
01268         // find out how many bytes to read
01269         if (!m_device->readInternal (m_data, 1))
01270             ErrorAndQuit (Error::FileError, "could not read FormatParaPropertyGenerated numDataBytes");
01271         ReadByte (m_numDataBytes, m_data);
01272         if (!Verify (Error::InvalidFormat, m_numDataBytes >= 1 && m_numDataBytes <= s_size - sizeof (Byte), DWord (m_numDataBytes))) return false;
01273         if (!m_device->readInternal (m_data + 1, m_numDataBytes))
01274             ErrorAndQuit (Error::FileError, "could not read FormatParaPropertyGenerated data");
01275         
01276         ReadByte (m_magic0_60_or_61, m_data + 1);
01277         signalHaveSetData (m_magic0_60_or_61 == Byte (60), 0/*offset*/ + 8/*size*/);
01278         ReadByte (m_alignment, m_data + 2);
01279         signalHaveSetData (m_alignment == Byte (0), 8/*offset*/ + 8/*size*/);
01280         ReadWord (m_magic30, m_data + 3);
01281         signalHaveSetData (m_magic30 == Word (30), 16/*offset*/ + 16/*size*/);
01282         ReadWord (m_rightIndent, m_data + 5);
01283         signalHaveSetData (m_rightIndent == Word (0), 32/*offset*/ + 16/*size*/);
01284         ReadWord (m_leftIndent, m_data + 7);
01285         signalHaveSetData (m_leftIndent == Word (0), 48/*offset*/ + 16/*size*/);
01286         ReadShort (m_leftIndentFirstLine, m_data + 9);
01287         signalHaveSetData (m_leftIndentFirstLine == Short (0), 64/*offset*/ + 16/*size*/);
01288         ReadWord (m_lineSpacing, m_data + 11);
01289         signalHaveSetData (m_lineSpacing == Word (240), 80/*offset*/ + 16/*size*/);
01290         for (int i = 0; i < 2; i++)
01291         {
01292             ReadWord (m_zero [i], m_data + 13 + i * sizeof (Word));
01293         }
01294         
01295         ReadBitsFromByte (m_headerOrFooter, m_data [17], 0, 1);
01296         signalHaveSetData (m_headerOrFooter == bool (0), 128/*offset*/ + 1/*size*/);
01297         ReadBitsFromByte (m_isNotNormalParagraph, m_data [17], 1, 2);
01298         signalHaveSetData (m_isNotNormalParagraph == unsigned (0), 129/*offset*/ + 2/*size*/);
01299         ReadBitsFromByte (m_isOnFirstPage, m_data [17], 3, 1);
01300         signalHaveSetData (m_isOnFirstPage == bool (0), 131/*offset*/ + 1/*size*/);
01301         ReadBitsFromByte (m_isObject, m_data [17], 4, 1);
01302         signalHaveSetData (m_isObject == bool (0), 132/*offset*/ + 1/*size*/);
01303         ReadBitsFromByte (m_zero2, m_data [17], 5, 3);
01304         signalHaveSetData (m_zero2 == unsigned (0), 133/*offset*/ + 3/*size*/);
01305         memcpy (m_zero3, m_data + 18, 5 * sizeof (Byte));
01306         for (int i = 0; i < 14; i++)
01307         {
01308             m_device->setCache (m_data + 23 + i * FormatParaPropertyTabulatorGenerated::s_size);
01309             m_tab [i]->setDevice (m_device);
01310             if (!m_tab [i]->readFromDevice ()) return false;
01311             m_device->setCache (NULL);
01312         }
01313         
01314         return verifyVariables ();
01315     }
01316     
01317     bool FormatParaPropertyGenerated::writeToArray (void)
01318     {
01319     CHECK_DEVICE;
01320     
01321         // set m_data to 0 to avoid problems with bit ops
01322         memset (m_data, 0, s_size);
01323         
01324         WriteByte (m_numDataBytes, m_data + 0);
01325         WriteByte (m_magic0_60_or_61, m_data + 1);
01326         WriteByte (m_alignment, m_data + 2);
01327         WriteWord (m_magic30, m_data + 3);
01328         WriteWord (m_rightIndent, m_data + 5);
01329         WriteWord (m_leftIndent, m_data + 7);
01330         WriteShort (m_leftIndentFirstLine, m_data + 9);
01331         WriteWord (m_lineSpacing, m_data + 11);
01332         for (int i = 0; i < 2; i++)
01333         {
01334             WriteWord (m_zero [i], m_data + 13 + i * sizeof (Word));
01335         }
01336         
01337         WriteBitsToByte (m_headerOrFooter, m_data [17], 0, 1);
01338         WriteBitsToByte (m_isNotNormalParagraph, m_data [17], 1, 2);
01339         WriteBitsToByte (m_isOnFirstPage, m_data [17], 3, 1);
01340         WriteBitsToByte (m_isObject, m_data [17], 4, 1);
01341         WriteBitsToByte (m_zero2, m_data [17], 5, 3);
01342         memcpy (m_data + 18, m_zero3, 5 * sizeof (Byte));
01343         for (int i = 0; i < 14; i++)
01344         {
01345             m_device->setCache (m_data + 23 + i * FormatParaPropertyTabulatorGenerated::s_size);
01346             m_tab [i]->setDevice (m_device);
01347             if (!m_tab [i]->writeToDevice ()) return false;
01348             m_device->setCache (NULL);
01349         }
01350         
01351         return true;
01352     }
01353     
01354     bool FormatParaPropertyGenerated::writeToDevice (void)
01355     {
01356     CHECK_DEVICE;
01357     
01358         // sync m_numDataBytes with reality
01359         updateNumDataBytes ();
01360         
01361         // ensure that the variables are in range
01362         if (!verifyVariables ()) return false;
01363         
01364         // write the variables to the array
01365         if (!writeToArray ()) return false;
01366         
01367         // write the data straight to the file
01368         if (!m_device->writeInternal (m_data, 1 /*sizeof (m_numDataBytes)*/ + (m_numDataBytes ? m_numDataBytes : getNeedNumDataBytes ())))
01369             ErrorAndQuit (Error::FileError, "could not write FormatParaPropertyGenerated data");
01370         
01371         return true;
01372     }
01373     
01374     
01375     // -------------------- BEGIN FormatInfoPageGenerated --------------------
01376     
01377     FormatInfoPageGenerated::FormatInfoPageGenerated ()
01378     {
01379         // --- set defaults for variables --
01380         // no default for m_firstCharBytePlus128
01381         memset (m_packedStructs, (Byte) (0), 123 * sizeof (Byte));
01382         m_numFormatPointers = (Byte) (0);
01383     }
01384     
01385     FormatInfoPageGenerated::~FormatInfoPageGenerated ()
01386     {
01387     }
01388     
01389     FormatInfoPageGenerated &FormatInfoPageGenerated::operator= (const FormatInfoPageGenerated &rhs)
01390     {
01391         if (this == &rhs)
01392             return *this;
01393         
01394         NeedsDevice::operator= (rhs);
01395         memcpy (m_data, rhs.m_data, s_size);
01396         
01397         m_firstCharBytePlus128 = rhs.m_firstCharBytePlus128;
01398         memcpy (m_packedStructs, rhs.m_packedStructs, 123 * sizeof (Byte));
01399         m_numFormatPointers = rhs.m_numFormatPointers;
01400         
01401         return *this;
01402     }
01403     
01404     bool FormatInfoPageGenerated::verifyVariables (void)
01405     {
01406     CHECK_DEVICE;
01407     
01408         if (!Verify (Error::InvalidFormat, m_firstCharBytePlus128 >= 128, DWord (m_firstCharBytePlus128))) return false;
01409         // m_packedStructs will not be checked
01410         // m_numFormatPointers will not be checked
01411         return true;
01412     }
01413     
01414     bool FormatInfoPageGenerated::readFromDevice (void)
01415     {
01416     CHECK_DEVICE;
01417     
01418         // read the data straight from the file
01419         if (!m_device->readInternal (m_data, s_size))
01420             ErrorAndQuit (Error::FileError, "could not read FormatInfoPageGenerated data");
01421         
01422         ReadDWord (m_firstCharBytePlus128, m_data + 0);
01423         memcpy (m_packedStructs, m_data + 4, 123 * sizeof (Byte));
01424         ReadByte (m_numFormatPointers, m_data + 127);
01425         return verifyVariables ();
01426     }
01427     
01428     bool FormatInfoPageGenerated::writeToArray (void)
01429     {
01430     CHECK_DEVICE;
01431     
01432         WriteDWord (m_firstCharBytePlus128, m_data + 0);
01433         memcpy (m_data + 4, m_packedStructs, 123 * sizeof (Byte));
01434         WriteByte (m_numFormatPointers, m_data + 127);
01435         return true;
01436     }
01437     
01438     bool FormatInfoPageGenerated::writeToDevice (void)
01439     {
01440     CHECK_DEVICE;
01441     
01442         // ensure that the variables are in range
01443         if (!verifyVariables ()) return false;
01444         
01445         // write the variables to the array
01446         if (!writeToArray ()) return false;
01447         
01448         // write the data straight to the file
01449         if (!m_device->writeInternal (m_data, s_size))
01450             ErrorAndQuit (Error::FileError, "could not write FormatInfoPageGenerated data");
01451         
01452         return true;
01453     }
01454     
01455     
01456     // -------------------- BEGIN BMP_BitmapFileHeaderGenerated --------------------
01457     
01458     BMP_BitmapFileHeaderGenerated::BMP_BitmapFileHeaderGenerated ()
01459     {
01460         // --- set defaults for variables --
01461         m_magic = (Word) (Word ('B') + (Word ('M') << 8));
01462         // no default for m_totalBytes
01463         for (int i = 0; i < 2; i++)
01464             m_zero [i] = (Word) (0);
01465         // no default for m_actualImageOffset
01466     }
01467     
01468     BMP_BitmapFileHeaderGenerated::~BMP_BitmapFileHeaderGenerated ()
01469     {
01470     }
01471     
01472     BMP_BitmapFileHeaderGenerated &BMP_BitmapFileHeaderGenerated::operator= (const BMP_BitmapFileHeaderGenerated &rhs)
01473     {
01474         if (this == &rhs)
01475             return *this;
01476         
01477         NeedsDevice::operator= (rhs);
01478         memcpy (m_data, rhs.m_data, s_size);
01479         
01480         m_magic = rhs.m_magic;
01481         m_totalBytes = rhs.m_totalBytes;
01482         memcpy (m_zero, rhs.m_zero, 2 * sizeof (Word));
01483         m_actualImageOffset = rhs.m_actualImageOffset;
01484         
01485         return *this;
01486     }
01487     
01488     bool BMP_BitmapFileHeaderGenerated::verifyVariables (void)
01489     {
01490     CHECK_DEVICE;
01491     
01492         if (!Verify (Error::InvalidFormat, m_magic == Word ('B') + (Word ('M') << 8), DWord (m_magic))) return false;
01493         // m_totalBytes will not be checked
01494         for (int i = 0; i < 2; i++)
01495         {
01496                        if (!Verify (Error::Warn, m_zero [i] == 0, long (m_zero))) return false;
01497         }
01498         // m_actualImageOffset will not be checked
01499         return true;
01500     }
01501     
01502     bool BMP_BitmapFileHeaderGenerated::readFromDevice (void)
01503     {
01504     CHECK_DEVICE;
01505     
01506         // read the data straight from the file
01507         if (!m_device->readInternal (m_data, s_size))
01508             ErrorAndQuit (Error::FileError, "could not read BMP_BitmapFileHeaderGenerated data");
01509         
01510         ReadWord (m_magic, m_data + 0);
01511         ReadDWord (m_totalBytes, m_data + 2);
01512         for (int i = 0; i < 2; i++)
01513         {
01514             ReadWord (m_zero [i], m_data + 6 + i * sizeof (Word));
01515         }
01516         
01517         ReadDWord (m_actualImageOffset, m_data + 10);
01518         return verifyVariables ();
01519     }
01520     
01521     bool BMP_BitmapFileHeaderGenerated::writeToArray (void)
01522     {
01523     CHECK_DEVICE;
01524     
01525         WriteWord (m_magic, m_data + 0);
01526         WriteDWord (m_totalBytes, m_data + 2);
01527         for (int i = 0; i < 2; i++)
01528         {
01529             WriteWord (m_zero [i], m_data + 6 + i * sizeof (Word));
01530         }
01531         
01532         WriteDWord (m_actualImageOffset, m_data + 10);
01533         return true;
01534     }
01535     
01536     bool BMP_BitmapFileHeaderGenerated::writeToDevice (void)
01537     {
01538     CHECK_DEVICE;
01539     
01540         // ensure that the variables are in range
01541         if (!verifyVariables ()) return false;
01542         
01543         // write the variables to the array
01544         if (!writeToArray ()) return false;
01545         
01546         // write the data straight to the file
01547         if (!m_device->writeInternal (m_data, s_size))
01548             ErrorAndQuit (Error::FileError, "could not write BMP_BitmapFileHeaderGenerated data");
01549         
01550         return true;
01551     }
01552     
01553     
01554     // -------------------- BEGIN BMP_BitmapInfoHeaderGenerated --------------------
01555     
01556     BMP_BitmapInfoHeaderGenerated::BMP_BitmapInfoHeaderGenerated ()
01557     {
01558         // --- set defaults for variables --
01559         m_numHeaderBytes = (DWord) (s_size);
01560         // no default for m_width
01561         // no default for m_height
01562         m_numPlanes = (Word) (1);
01563         // no default for m_bitsPerPixel
01564         m_compression = (DWord) (0);
01565         m_sizeImage = (DWord) (0);
01566         m_xPixelsPerMeter = (Long) (0);
01567         m_yPixelsPerMeter = (Long) (0);
01568         m_coloursUsed = (DWord) (0);
01569         // no default for m_coloursImportant
01570     }
01571     
01572     BMP_BitmapInfoHeaderGenerated::~BMP_BitmapInfoHeaderGenerated ()
01573     {
01574     }
01575     
01576     BMP_BitmapInfoHeaderGenerated &BMP_BitmapInfoHeaderGenerated::operator= (const BMP_BitmapInfoHeaderGenerated &rhs)
01577     {
01578         if (this == &rhs)
01579             return *this;
01580         
01581         NeedsDevice::operator= (rhs);
01582         memcpy (m_data, rhs.m_data, s_size);
01583         
01584         m_numHeaderBytes = rhs.m_numHeaderBytes;
01585         m_width = rhs.m_width;
01586         m_height = rhs.m_height;
01587         m_numPlanes = rhs.m_numPlanes;
01588         m_bitsPerPixel = rhs.m_bitsPerPixel;
01589         m_compression = rhs.m_compression;
01590         m_sizeImage = rhs.m_sizeImage;
01591         m_xPixelsPerMeter = rhs.m_xPixelsPerMeter;
01592         m_yPixelsPerMeter = rhs.m_yPixelsPerMeter;
01593         m_coloursUsed = rhs.m_coloursUsed;
01594         m_coloursImportant = rhs.m_coloursImportant;
01595         
01596         return *this;
01597     }
01598     
01599     bool BMP_BitmapInfoHeaderGenerated::verifyVariables (void)
01600     {
01601     CHECK_DEVICE;
01602     
01603         if (!Verify (Error::InvalidFormat, m_numHeaderBytes == DWord (s_size), DWord (m_numHeaderBytes))) return false;
01604         // m_width will not be checked
01605         // m_height will not be checked
01606         if (!Verify (Error::InvalidFormat, m_numPlanes == 1, DWord (m_numPlanes))) return false;
01607         if (!Verify (Error::Warn, m_bitsPerPixel == 1 || m_bitsPerPixel == 4 || m_bitsPerPixel == 8 || m_bitsPerPixel == 24, DWord (m_bitsPerPixel))) return false;
01608         // m_compression will not be checked
01609         // m_sizeImage will not be checked
01610         // m_xPixelsPerMeter will not be checked
01611         // m_yPixelsPerMeter will not be checked
01612         // m_coloursUsed will not be checked
01613         // m_coloursImportant will not be checked
01614         return true;
01615     }
01616     
01617     bool BMP_BitmapInfoHeaderGenerated::readFromDevice (void)
01618     {
01619     CHECK_DEVICE;
01620     
01621         // read the data straight from the file
01622         if (!m_device->readInternal (m_data, s_size))
01623             ErrorAndQuit (Error::FileError, "could not read BMP_BitmapInfoHeaderGenerated data");
01624         
01625         ReadDWord (m_numHeaderBytes, m_data + 0);
01626         ReadLong (m_width, m_data + 4);
01627         ReadLong (m_height, m_data + 8);
01628         ReadWord (m_numPlanes, m_data + 12);
01629         ReadWord (m_bitsPerPixel, m_data + 14);
01630         ReadDWord (m_compression, m_data + 16);
01631         ReadDWord (m_sizeImage, m_data + 20);
01632         ReadLong (m_xPixelsPerMeter, m_data + 24);
01633         ReadLong (m_yPixelsPerMeter, m_data + 28);
01634         ReadDWord (m_coloursUsed, m_data + 32);
01635         ReadDWord (m_coloursImportant, m_data + 36);
01636         return verifyVariables ();
01637     }
01638     
01639     bool BMP_BitmapInfoHeaderGenerated::writeToArray (void)
01640     {
01641     CHECK_DEVICE;
01642     
01643         WriteDWord (m_numHeaderBytes, m_data + 0);
01644         WriteLong (m_width, m_data + 4);
01645         WriteLong (m_height, m_data + 8);
01646         WriteWord (m_numPlanes, m_data + 12);
01647         WriteWord (m_bitsPerPixel, m_data + 14);
01648         WriteDWord (m_compression, m_data + 16);
01649         WriteDWord (m_sizeImage, m_data + 20);
01650         WriteLong (m_xPixelsPerMeter, m_data + 24);
01651         WriteLong (m_yPixelsPerMeter, m_data + 28);
01652         WriteDWord (m_coloursUsed, m_data + 32);
01653         WriteDWord (m_coloursImportant, m_data + 36);
01654         return true;
01655     }
01656     
01657     bool BMP_BitmapInfoHeaderGenerated::writeToDevice (void)
01658     {
01659     CHECK_DEVICE;
01660     
01661         // ensure that the variables are in range
01662         if (!verifyVariables ()) return false;
01663         
01664         // write the variables to the array
01665         if (!writeToArray ()) return false;
01666         
01667         // write the data straight to the file
01668         if (!m_device->writeInternal (m_data, s_size))
01669             ErrorAndQuit (Error::FileError, "could not write BMP_BitmapInfoHeaderGenerated data");
01670         
01671         return true;
01672     }
01673     
01674     
01675     // -------------------- BEGIN BMP_BitmapColourIndexGenerated --------------------
01676     
01677     BMP_BitmapColourIndexGenerated::BMP_BitmapColourIndexGenerated ()
01678     {
01679         // --- set defaults for variables --
01680         // no default for m_blue
01681         // no default for m_green
01682         // no default for m_red
01683         m_reserved = (Byte) (0);
01684     }
01685     
01686     BMP_BitmapColourIndexGenerated::~BMP_BitmapColourIndexGenerated ()
01687     {
01688     }
01689     
01690     BMP_BitmapColourIndexGenerated &BMP_BitmapColourIndexGenerated::operator= (const BMP_BitmapColourIndexGenerated &rhs)
01691     {
01692         if (this == &rhs)
01693             return *this;
01694         
01695         NeedsDevice::operator= (rhs);
01696         memcpy (m_data, rhs.m_data, s_size);
01697         
01698         m_blue = rhs.m_blue;
01699         m_green = rhs.m_green;
01700         m_red = rhs.m_red;
01701         m_reserved = rhs.m_reserved;
01702         
01703         return *this;
01704     }
01705     
01706     bool BMP_BitmapColourIndexGenerated::verifyVariables (void)
01707     {
01708     CHECK_DEVICE;
01709     
01710         // m_blue will not be checked
01711         // m_green will not be checked
01712         // m_red will not be checked
01713         // m_reserved will not be checked
01714         return true;
01715     }
01716     
01717     bool BMP_BitmapColourIndexGenerated::readFromDevice (void)
01718     {
01719     CHECK_DEVICE;
01720     
01721         // read the data straight from the file
01722         if (!m_device->readInternal (m_data, s_size))
01723             ErrorAndQuit (Error::FileError, "could not read BMP_BitmapColourIndexGenerated data");
01724         
01725         ReadByte (m_blue, m_data + 0);
01726         ReadByte (m_green, m_data + 1);
01727         ReadByte (m_red, m_data + 2);
01728         ReadByte (m_reserved, m_data + 3);
01729         return verifyVariables ();
01730     }
01731     
01732     bool BMP_BitmapColourIndexGenerated::writeToArray (void)
01733     {
01734     CHECK_DEVICE;
01735     
01736         WriteByte (m_blue, m_data + 0);
01737         WriteByte (m_green, m_data + 1);
01738         WriteByte (m_red, m_data + 2);
01739         WriteByte (m_reserved, m_data + 3);
01740         return true;
01741     }
01742     
01743     bool BMP_BitmapColourIndexGenerated::writeToDevice (void)
01744     {
01745     CHECK_DEVICE;
01746     
01747         // ensure that the variables are in range
01748         if (!verifyVariables ()) return false;
01749         
01750         // write the variables to the array
01751         if (!writeToArray ()) return false;
01752         
01753         // write the data straight to the file
01754         if (!m_device->writeInternal (m_data, s_size))
01755             ErrorAndQuit (Error::FileError, "could not write BMP_BitmapColourIndexGenerated data");
01756         
01757         return true;
01758     }
01759     
01760     
01761     // -------------------- BEGIN BitmapHeaderGenerated --------------------
01762     
01763     BitmapHeaderGenerated::BitmapHeaderGenerated ()
01764     {
01765         // --- set defaults for variables --
01766         m_zero = (Word) (0);
01767         m_width = (Word) (0);
01768         m_height = (Word) (0);
01769         m_widthBytes = (Word) (0);
01770         m_numPlanes = (Byte) (0);
01771         m_bitsPerPixel = (Byte) (0);
01772         m_zero2 = (DWord) (0);
01773     }
01774     
01775     BitmapHeaderGenerated::~BitmapHeaderGenerated ()
01776     {
01777     }
01778     
01779     BitmapHeaderGenerated &BitmapHeaderGenerated::operator= (const BitmapHeaderGenerated &rhs)
01780     {
01781         if (this == &rhs)
01782             return *this;
01783         
01784         NeedsDevice::operator= (rhs);
01785         memcpy (m_data, rhs.m_data, s_size);
01786         
01787         m_zero = rhs.m_zero;
01788         m_width = rhs.m_width;
01789         m_height = rhs.m_height;
01790         m_widthBytes = rhs.m_widthBytes;
01791         m_numPlanes = rhs.m_numPlanes;
01792         m_bitsPerPixel = rhs.m_bitsPerPixel;
01793         m_zero2 = rhs.m_zero2;
01794         
01795         return *this;
01796     }
01797     
01798     bool BitmapHeaderGenerated::verifyVariables (void)
01799     {
01800     CHECK_DEVICE;
01801     
01802         if (!Verify (Error::InvalidFormat, m_zero == 0, DWord (m_zero))) return false;
01803         // m_width will not be checked
01804         // m_height will not be checked
01805         // m_widthBytes will not be checked
01806         if (!Verify (Error::InvalidFormat, m_numPlanes == 0 || m_numPlanes == 1, DWord (m_numPlanes))) return false;
01807         // m_bitsPerPixel will not be checked
01808         if (!Verify (Error::InvalidFormat, m_zero2 == 0, DWord (m_zero2))) return false;
01809         return true;
01810     }
01811     
01812     bool BitmapHeaderGenerated::readFromDevice (void)
01813     {
01814     CHECK_DEVICE;
01815     
01816         // read the data straight from the file
01817         if (!m_device->readInternal (m_data, s_size))
01818             ErrorAndQuit (Error::FileError, "could not read BitmapHeaderGenerated data");
01819         
01820         ReadWord (m_zero, m_data + 0);
01821         ReadWord (m_width, m_data + 2);
01822         ReadWord (m_height, m_data + 4);
01823         ReadWord (m_widthBytes, m_data + 6);
01824         ReadByte (m_numPlanes, m_data + 8);
01825         ReadByte (m_bitsPerPixel, m_data + 9);
01826         ReadDWord (m_zero2, m_data + 10);
01827         return verifyVariables ();
01828     }
01829     
01830     bool BitmapHeaderGenerated::writeToArray (void)
01831     {
01832     CHECK_DEVICE;
01833     
01834         WriteWord (m_zero, m_data + 0);
01835         WriteWord (m_width, m_data + 2);
01836         WriteWord (m_height, m_data + 4);
01837         WriteWord (m_widthBytes, m_data + 6);
01838         WriteByte (m_numPlanes, m_data + 8);
01839         WriteByte (m_bitsPerPixel, m_data + 9);
01840         WriteDWord (m_zero2, m_data + 10);
01841         return true;
01842     }
01843     
01844     bool BitmapHeaderGenerated::writeToDevice (void)
01845     {
01846     CHECK_DEVICE;
01847     
01848         // ensure that the variables are in range
01849         if (!verifyVariables ()) return false;
01850         
01851         // write the variables to the array
01852         if (!writeToArray ()) return false;
01853         
01854         // write the data straight to the file
01855         if (!m_device->writeInternal (m_data, s_size))
01856             ErrorAndQuit (Error::FileError, "could not write BitmapHeaderGenerated data");
01857         
01858         return true;
01859     }
01860     
01861     
01862     // -------------------- BEGIN WMFHeaderGenerated --------------------
01863     
01864     WMFHeaderGenerated::WMFHeaderGenerated ()
01865     {
01866         // --- set defaults for variables --
01867         m_fieldType = (Word) (1);
01868         m_headerSize = (Word) (9);
01869         m_winVersion = (Word) (0x0300);
01870         // no default for m_fileSize
01871         m_numObjects = (Word) (0);
01872         // no default for m_maxRecordSize
01873         m_zero = (Word) (0);
01874     }
01875     
01876     WMFHeaderGenerated::~WMFHeaderGenerated ()
01877     {
01878     }
01879     
01880     WMFHeaderGenerated &WMFHeaderGenerated::operator= (const WMFHeaderGenerated &rhs)
01881     {
01882         if (this == &rhs)
01883             return *this;
01884         
01885         NeedsDevice::operator= (rhs);
01886         memcpy (m_data, rhs.m_data, s_size);
01887         
01888         m_fieldType = rhs.m_fieldType;
01889         m_headerSize = rhs.m_headerSize;
01890         m_winVersion = rhs.m_winVersion;
01891         m_fileSize = rhs.m_fileSize;
01892         m_numObjects = rhs.m_numObjects;
01893         m_maxRecordSize = rhs.m_maxRecordSize;
01894         m_zero = rhs.m_zero;
01895         
01896         return *this;
01897     }
01898     
01899     bool WMFHeaderGenerated::verifyVariables (void)
01900     {
01901     CHECK_DEVICE;
01902     
01903         if (!Verify (Error::InvalidFormat, m_fieldType == 1, DWord (m_fieldType))) return false;
01904         if (!Verify (Error::InvalidFormat, m_headerSize == 9, DWord (m_headerSize))) return false;
01905         if (!Verify (Error::Warn, m_winVersion <= 0x0300, DWord (m_winVersion))) return false;
01906         // m_fileSize will not be checked
01907         // m_numObjects will not be checked
01908         // m_maxRecordSize will not be checked
01909         if (!Verify (Error::Warn, m_zero == 0, DWord (m_zero))) return false;
01910         return true;
01911     }
01912     
01913     bool WMFHeaderGenerated::readFromDevice (void)
01914     {
01915     CHECK_DEVICE;
01916     
01917         // read the data straight from the file
01918         if (!m_device->readInternal (m_data, s_size))
01919             ErrorAndQuit (Error::FileError, "could not read WMFHeaderGenerated data");
01920         
01921         ReadWord (m_fieldType, m_data + 0);
01922         ReadWord (m_headerSize, m_data + 2);
01923         ReadWord (m_winVersion, m_data + 4);
01924         ReadDWord (m_fileSize, m_data + 6);
01925         ReadWord (m_numObjects, m_data + 10);
01926         ReadDWord (m_maxRecordSize, m_data + 12);
01927         ReadWord (m_zero, m_data + 16);
01928         return verifyVariables ();
01929     }
01930     
01931     bool WMFHeaderGenerated::writeToArray (void)
01932     {
01933     CHECK_DEVICE;
01934     
01935         WriteWord (m_fieldType, m_data + 0);
01936         WriteWord (m_headerSize, m_data + 2);
01937         WriteWord (m_winVersion, m_data + 4);
01938         WriteDWord (m_fileSize, m_data + 6);
01939         WriteWord (m_numObjects, m_data + 10);
01940         WriteDWord (m_maxRecordSize, m_data + 12);
01941         WriteWord (m_zero, m_data + 16);
01942         return true;
01943     }
01944     
01945     bool WMFHeaderGenerated::writeToDevice (void)
01946     {
01947     CHECK_DEVICE;
01948     
01949         // ensure that the variables are in range
01950         if (!verifyVariables ()) return false;
01951         
01952         // write the variables to the array
01953         if (!writeToArray ()) return false;
01954         
01955         // write the data straight to the file
01956         if (!m_device->writeInternal (m_data, s_size))
01957             ErrorAndQuit (Error::FileError, "could not write WMFHeaderGenerated data");
01958         
01959         return true;
01960     }
01961     
01962     
01963     // -------------------- BEGIN ImageGenerated --------------------
01964     
01965     ImageGenerated::ImageGenerated ()
01966     {
01967         // --- set pointer(s) to NULL (prevent segfault with premature exit) ---
01968         m_bmh = NULL;
01969         
01970         // --- allocate memory for embedded structures ---
01971         m_bmh = new BitmapHeader;   // forward ref to structures*.cpp
01972         if (!m_bmh) return;
01973         
01974         // --- set defaults for variables --
01975         // no default for m_mappingMode
01976         // no default for m_MFP_width
01977         // no default for m_MFP_height
01978         m_MFP_unknown = (Word) (0);
01979         m_indent = (Word) (0);
01980         // no default for m_width
01981         // no default for m_height
01982         m_zero = (Word) (0);
01983         // leaving constructor of m_bmh to set its own defaults
01984         m_numHeaderBytes = (Word) (s_size);
01985         // no default for m_numDataBytes
01986         m_horizontalScalingRel1000 = (Word) (1000);
01987         m_verticalScalingRel1000 = (Word) (1000);
01988     }
01989     
01990     ImageGenerated::~ImageGenerated ()
01991     {
01992         delete m_bmh;
01993     }
01994     
01995     ImageGenerated &ImageGenerated::operator= (const ImageGenerated &rhs)
01996     {
01997         if (this == &rhs)
01998             return *this;
01999         
02000         NeedsDevice::operator= (rhs);
02001         memcpy (m_data, rhs.m_data, s_size);
02002         
02003         m_mappingMode = rhs.m_mappingMode;
02004         m_MFP_width = rhs.m_MFP_width;
02005         m_MFP_height = rhs.m_MFP_height;
02006         m_MFP_unknown = rhs.m_MFP_unknown;
02007         m_indent = rhs.m_indent;
02008         m_width = rhs.m_width;
02009         m_height = rhs.m_height;
02010         m_zero = rhs.m_zero;
02011         *m_bmh = *(rhs.m_bmh);
02012         m_numHeaderBytes = rhs.m_numHeaderBytes;
02013         m_numDataBytes = rhs.m_numDataBytes;
02014         m_horizontalScalingRel1000 = rhs.m_horizontalScalingRel1000;
02015         m_verticalScalingRel1000 = rhs.m_verticalScalingRel1000;
02016         
02017         return *this;
02018     }
02019     
02020     bool ImageGenerated::verifyVariables (void)
02021     {
02022     CHECK_DEVICE;
02023     
02024         if (!Verify (Error::InvalidFormat, m_mappingMode != 0xE4, DWord (m_mappingMode))) return false;
02025         // m_MFP_width will not be checked
02026         // m_MFP_height will not be checked
02027         if (!Verify (Error::Warn, m_MFP_unknown==0, DWord (m_MFP_unknown))) return false;
02028         // m_indent will not be checked
02029         // m_width will not be checked
02030         // m_height will not be checked
02031         // m_zero will not be checked
02032         if (!m_bmh) {   ErrorAndQuit (Error::OutOfMemory, "could not allocate memory for bmh in constructor");  }
02033         if (!Verify (Error::InvalidFormat, m_numHeaderBytes == s_size, DWord (m_numHeaderBytes))) return false;
02034         // m_numDataBytes will not be checked
02035         // m_horizontalScalingRel1000 will not be checked
02036         // m_verticalScalingRel1000 will not be checked
02037         return true;
02038     }
02039     
02040     bool ImageGenerated::readFromDevice (void)
02041     {
02042     CHECK_DEVICE;
02043     
02044         // read the data straight from the file
02045         if (!m_device->readInternal (m_data, s_size))
02046             ErrorAndQuit (Error::FileError, "could not read ImageGenerated data");
02047         
02048         ReadWord (m_mappingMode, m_data + 0);
02049         ReadWord (m_MFP_width, m_data + 2);
02050         ReadWord (m_MFP_height, m_data + 4);
02051         ReadWord (m_MFP_unknown, m_data + 6);
02052         ReadWord (m_indent, m_data + 8);
02053         ReadWord (m_width, m_data + 10);
02054         ReadWord (m_height, m_data + 12);
02055         ReadWord (m_zero, m_data + 14);
02056         
02057         m_device->setCache (m_data + 16);
02058         m_bmh->setDevice (m_device);
02059         if (!m_bmh->readFromDevice ()) return false;
02060         m_device->setCache (NULL);
02061         
02062         ReadWord (m_numHeaderBytes, m_data + 30);
02063         ReadDWord (m_numDataBytes, m_data + 32);
02064         ReadWord (m_horizontalScalingRel1000, m_data + 36);
02065         ReadWord (m_verticalScalingRel1000, m_data + 38);
02066         return verifyVariables ();
02067     }
02068     
02069     bool ImageGenerated::writeToArray (void)
02070     {
02071     CHECK_DEVICE;
02072     
02073         WriteWord (m_mappingMode, m_data + 0);
02074         WriteWord (m_MFP_width, m_data + 2);
02075         WriteWord (m_MFP_height, m_data + 4);
02076         WriteWord (m_MFP_unknown, m_data + 6);
02077         WriteWord (m_indent, m_data + 8);
02078         WriteWord (m_width, m_data + 10);
02079         WriteWord (m_height, m_data + 12);
02080         WriteWord (m_zero, m_data + 14);
02081         
02082         m_device->setCache (m_data + 16);
02083         m_bmh->setDevice (m_device);
02084         if (!m_bmh->writeToDevice ()) return false;
02085         m_device->setCache (NULL);
02086         
02087         WriteWord (m_numHeaderBytes, m_data + 30);
02088         WriteDWord (m_numDataBytes, m_data + 32);
02089         WriteWord (m_horizontalScalingRel1000, m_data + 36);
02090         WriteWord (m_verticalScalingRel1000, m_data + 38);
02091         return true;
02092     }
02093     
02094     bool ImageGenerated::writeToDevice (void)
02095     {
02096     CHECK_DEVICE;
02097     
02098         // ensure that the variables are in range
02099         if (!verifyVariables ()) return false;
02100         
02101         // write the variables to the array
02102         if (!writeToArray ()) return false;
02103         
02104         // write the data straight to the file
02105         if (!m_device->writeInternal (m_data, s_size))
02106             ErrorAndQuit (Error::FileError, "could not write ImageGenerated data");
02107         
02108         return true;
02109     }
02110     
02111     
02112     // -------------------- BEGIN OLEGenerated --------------------
02113     
02114     OLEGenerated::OLEGenerated ()
02115     {
02116         // --- set defaults for variables --
02117         // no default for m_mappingMode
02118         m_zero = (DWord) (0);
02119         // no default for m_objectType
02120         // no default for m_indent
02121         // no default for m_width
02122         // no default for m_height
02123         m_zero2 = (Word) (0);
02124         // no default for m_numDataBytes
02125         m_zero3 = (DWord) (0);
02126         // no default for m_objectName
02127         m_zero4 = (Word) (0);
02128         // no default for m_numHeaderBytes
02129         m_zero5 = (DWord) (0);
02130         // no default for m_widthScaledRel1000
02131         // no default for m_heightScaledRel1000
02132     }
02133     
02134     OLEGenerated::~OLEGenerated ()
02135     {
02136     }
02137     
02138     OLEGenerated &OLEGenerated::operator= (const OLEGenerated &rhs)
02139     {
02140         if (this == &rhs)
02141             return *this;
02142         
02143         NeedsDevice::operator= (rhs);
02144         memcpy (m_data, rhs.m_data, s_size);
02145         
02146         m_mappingMode = rhs.m_mappingMode;
02147         m_zero = rhs.m_zero;
02148         m_objectType = rhs.m_objectType;
02149         m_indent = rhs.m_indent;
02150         m_width = rhs.m_width;
02151         m_height = rhs.m_height;
02152         m_zero2 = rhs.m_zero2;
02153         m_numDataBytes = rhs.m_numDataBytes;
02154         m_zero3 = rhs.m_zero3;
02155         m_objectName = rhs.m_objectName;
02156         m_zero4 = rhs.m_zero4;
02157         m_numHeaderBytes = rhs.m_numHeaderBytes;
02158         m_zero5 = rhs.m_zero5;
02159         m_widthScaledRel1000 = rhs.m_widthScaledRel1000;
02160         m_heightScaledRel1000 = rhs.m_heightScaledRel1000;
02161         
02162         return *this;
02163     }
02164     
02165     bool OLEGenerated::verifyVariables (void)
02166     {
02167     CHECK_DEVICE;
02168     
02169         if (!Verify (Error::InvalidFormat, m_mappingMode == 0xE4, DWord (m_mappingMode))) return false;
02170         if (!Verify (Error::Warn, m_zero == 0, DWord (m_zero))) return false;
02171         if (!Verify (Error::InvalidFormat, m_objectType >= 1 && m_objectType <= 3, DWord (m_objectType))) return false;
02172         // m_indent will not be checked
02173         // m_width will not be checked
02174         // m_height will not be checked
02175         if (!Verify (Error::Warn, m_zero2 == 0, DWord (m_zero2))) return false;
02176         // m_numDataBytes will not be checked
02177         if (!Verify (Error::Warn, m_zero3 == 0, DWord (m_zero3))) return false;
02178         // m_objectName will not be checked
02179         if (!Verify (Error::Warn, m_zero4 == 0, DWord (m_zero4))) return false;
02180         if (!Verify (Error::InvalidFormat, m_numHeaderBytes == s_size, DWord (m_numHeaderBytes))) return false;
02181         if (!Verify (Error::Warn, m_zero5 == 0, DWord (m_zero5))) return false;
02182         // m_widthScaledRel1000 will not be checked
02183         // m_heightScaledRel1000 will not be checked
02184         return true;
02185     }
02186     
02187     bool OLEGenerated::readFromDevice (void)
02188     {
02189     CHECK_DEVICE;
02190     
02191         // read the data straight from the file
02192         if (!m_device->readInternal (m_data, s_size))
02193             ErrorAndQuit (Error::FileError, "could not read OLEGenerated data");
02194         
02195         ReadWord (m_mappingMode, m_data + 0);
02196         ReadDWord (m_zero, m_data + 2);
02197         ReadWord (m_objectType, m_data + 6);
02198         ReadWord (m_indent, m_data + 8);
02199         ReadWord (m_width, m_data + 10);
02200         ReadWord (m_height, m_data + 12);
02201         ReadWord (m_zero2, m_data + 14);
02202         ReadDWord (m_numDataBytes, m_data + 16);
02203         ReadDWord (m_zero3, m_data + 20);
02204         ReadDWord (m_objectName, m_data + 24);
02205         ReadWord (m_zero4, m_data + 28);
02206         ReadWord (m_numHeaderBytes, m_data + 30);
02207         ReadDWord (m_zero5, m_data + 32);
02208         ReadWord (m_widthScaledRel1000, m_data + 36);
02209         ReadWord (m_heightScaledRel1000, m_data + 38);
02210         return verifyVariables ();
02211     }
02212     
02213     bool OLEGenerated::writeToArray (void)
02214     {
02215     CHECK_DEVICE;
02216     
02217         WriteWord (m_mappingMode, m_data + 0);
02218         WriteDWord (m_zero, m_data + 2);
02219         WriteWord (m_objectType, m_data + 6);
02220         WriteWord (m_indent, m_data + 8);
02221         WriteWord (m_width, m_data + 10);
02222         WriteWord (m_height, m_data + 12);
02223         WriteWord (m_zero2, m_data + 14);
02224         WriteDWord (m_numDataBytes, m_data + 16);
02225         WriteDWord (m_zero3, m_data + 20);
02226         WriteDWord (m_objectName, m_data + 24);
02227         WriteWord (m_zero4, m_data + 28);
02228         WriteWord (m_numHeaderBytes, m_data + 30);
02229         WriteDWord (m_zero5, m_data + 32);
02230         WriteWord (m_widthScaledRel1000, m_data + 36);
02231         WriteWord (m_heightScaledRel1000, m_data + 38);
02232         return true;
02233     }
02234     
02235     bool OLEGenerated::writeToDevice (void)
02236     {
02237     CHECK_DEVICE;
02238     
02239         // ensure that the variables are in range
02240         if (!verifyVariables ()) return false;
02241         
02242         // write the variables to the array
02243         if (!writeToArray ()) return false;
02244         
02245         // write the data straight to the file
02246         if (!m_device->writeInternal (m_data, s_size))
02247             ErrorAndQuit (Error::FileError, "could not write OLEGenerated data");
02248         
02249         return true;
02250     }
02251     
02252     
02253 }   // namespace MSWrite    {
02254 
02255 // end of structures_generated.cpp
KDE Home | KDE Accessibility Home | Description of Access Keys