1 /* This file is part of the wvWare 2 project
2    Copyright (C) 2001 Werner Trobin <trobin@kde.org>
3 
4    This library is free software; you can redistribute it and/or
5    modify it under the terms of the GNU Library General Public
6    License version 2 as published by the Free Software Foundation.
7 
8    This library is distributed in the hope that it will be useful,
9    but WITHOUT ANY WARRANTY; without even the implied warranty of
10    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11    Library General Public License for more details.
12 
13    You should have received a copy of the GNU Library General Public License
14    along with this library; see the file COPYING.LIB.  If not, write to
15    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16    Boston, MA 02111-1307, USA.
17 */
18 
19 // This code is generated from the Microsoft HTML specification of the
20 // WinWord format. Do NOT edit this code, but fix the spec or the script
21 // generating the sources. If you want to add some additional code, some
22 // includes or any other stuff, please add it to the template file!
23 // For information about the script and the "hidden features" please read
24 // the comments at the begin of the script.
25 
26 // If you find bugs or strange behavior please contact Werner Trobin
27 // <trobin@kde.org>
28 
29 #include <word95_generated.h>
30 #include <olestream.h>
31 #include <string.h>  // memset(), memcpy()
32 #include "wvlog.h"
33 
34 namespace wvWare {
35 
36 namespace Word95 {
37 
38 
39 // DTTM implementation
40 
DTTM()41 DTTM::DTTM() {
42     clear();
43 }
44 
DTTM(OLEStreamReader * stream,bool preservePos)45 DTTM::DTTM(OLEStreamReader *stream, bool preservePos) {
46     clear();
47     read(stream, preservePos);
48 }
49 
DTTM(const U8 * ptr)50 DTTM::DTTM(const U8 *ptr) {
51     clear();
52     readPtr(ptr);
53 }
54 
read(OLEStreamReader * stream,bool preservePos)55 bool DTTM::read(OLEStreamReader *stream, bool preservePos) {
56 
57     U16 shifterU16;
58 
59     if(preservePos)
60         stream->push();
61 
62     shifterU16=stream->readU16();
63     mint=shifterU16;
64     shifterU16>>=6;
65     hr=shifterU16;
66     shifterU16>>=5;
67     dom=shifterU16;
68     shifterU16=stream->readU16();
69     mon=shifterU16;
70     shifterU16>>=4;
71     yr=shifterU16;
72     shifterU16>>=9;
73     wdy=shifterU16;
74 
75     if(preservePos)
76         stream->pop();
77     return true;
78 }
79 
readPtr(const U8 * ptr)80 void DTTM::readPtr(const U8 *ptr) {
81 
82     U16 shifterU16;
83 
84     shifterU16=readU16(ptr);
85     ptr+=sizeof(U16);
86     mint=shifterU16;
87     shifterU16>>=6;
88     hr=shifterU16;
89     shifterU16>>=5;
90     dom=shifterU16;
91     shifterU16=readU16(ptr);
92     ptr+=sizeof(U16);
93     mon=shifterU16;
94     shifterU16>>=4;
95     yr=shifterU16;
96     shifterU16>>=9;
97     wdy=shifterU16;
98 }
99 
write(OLEStreamWriter * stream,bool preservePos) const100 bool DTTM::write(OLEStreamWriter *stream, bool preservePos) const {
101 
102     U16 shifterU16;
103 
104     if(preservePos)
105         stream->push();
106 
107     shifterU16=mint;
108     shifterU16|=hr << 6;
109     shifterU16|=dom << 11;
110     stream->write(shifterU16);
111     shifterU16=mon;
112     shifterU16|=yr << 4;
113     shifterU16|=wdy << 13;
114     stream->write(shifterU16);
115 
116     if(preservePos)
117         stream->pop();
118     return true;
119 }
120 
clear()121 void DTTM::clear() {
122     mint=0;
123     hr=0;
124     dom=0;
125     mon=0;
126     yr=0;
127     wdy=0;
128 }
129 
dump() const130 void DTTM::dump() const
131 {
132     wvlog << "Dumping DTTM:" << std::endl;
133     wvlog << toString().c_str() << std::endl;
134     wvlog << "\nDumping DTTM done." << std::endl;
135 }
136 
toString() const137 std::string DTTM::toString() const
138 {
139     std::string s( "DTTM:" );
140     s += "\nmint=";
141     s += uint2string( mint );
142     s += "\nhr=";
143     s += uint2string( hr );
144     s += "\ndom=";
145     s += uint2string( dom );
146     s += "\nmon=";
147     s += uint2string( mon );
148     s += "\nyr=";
149     s += uint2string( yr );
150     s += "\nwdy=";
151     s += uint2string( wdy );
152     s += "\nDTTM Done.";
153     return s;
154 }
155 
operator ==(const DTTM & lhs,const DTTM & rhs)156 bool operator==(const DTTM &lhs, const DTTM &rhs) {
157 
158     return lhs.mint==rhs.mint &&
159            lhs.hr==rhs.hr &&
160            lhs.dom==rhs.dom &&
161            lhs.mon==rhs.mon &&
162            lhs.yr==rhs.yr &&
163            lhs.wdy==rhs.wdy;
164 }
165 
operator !=(const DTTM & lhs,const DTTM & rhs)166 bool operator!=(const DTTM &lhs, const DTTM &rhs) {
167     return !(lhs==rhs);
168 }
169 
170 
171 // PRM2 implementation
172 
PRM2()173 PRM2::PRM2() {
174     clear();
175 }
176 
PRM2(OLEStreamReader * stream,bool preservePos)177 PRM2::PRM2(OLEStreamReader *stream, bool preservePos) {
178     clear();
179     read(stream, preservePos);
180 }
181 
read(OLEStreamReader * stream,bool preservePos)182 bool PRM2::read(OLEStreamReader *stream, bool preservePos) {
183 
184     U16 shifterU16;
185 
186     if(preservePos)
187         stream->push();
188 
189     shifterU16=stream->readU16();
190     fComplex=shifterU16;
191     shifterU16>>=1;
192     igrpprl=shifterU16;
193 
194     if(preservePos)
195         stream->pop();
196     return true;
197 }
198 
write(OLEStreamWriter * stream,bool preservePos) const199 bool PRM2::write(OLEStreamWriter *stream, bool preservePos) const {
200 
201     U16 shifterU16;
202 
203     if(preservePos)
204         stream->push();
205 
206     shifterU16=fComplex;
207     shifterU16|=igrpprl << 1;
208     stream->write(shifterU16);
209 
210     if(preservePos)
211         stream->pop();
212     return true;
213 }
214 
clear()215 void PRM2::clear() {
216     fComplex=0;
217     igrpprl=0;
218 }
219 
operator ==(const PRM2 & lhs,const PRM2 & rhs)220 bool operator==(const PRM2 &lhs, const PRM2 &rhs) {
221 
222     return lhs.fComplex==rhs.fComplex &&
223            lhs.igrpprl==rhs.igrpprl;
224 }
225 
operator !=(const PRM2 & lhs,const PRM2 & rhs)226 bool operator!=(const PRM2 &lhs, const PRM2 &rhs) {
227     return !(lhs==rhs);
228 }
229 
230 
231 // PRM implementation
232 
233 const unsigned int PRM::sizeOf = 2;
234 
PRM()235 PRM::PRM() {
236     clear();
237 }
238 
PRM(OLEStreamReader * stream,bool preservePos)239 PRM::PRM(OLEStreamReader *stream, bool preservePos) {
240     clear();
241     read(stream, preservePos);
242 }
243 
PRM(const U8 * ptr)244 PRM::PRM(const U8 *ptr) {
245     clear();
246     readPtr(ptr);
247 }
248 
read(OLEStreamReader * stream,bool preservePos)249 bool PRM::read(OLEStreamReader *stream, bool preservePos) {
250 
251     U8 shifterU8;
252 
253     if(preservePos)
254         stream->push();
255 
256     shifterU8=stream->readU8();
257     fComplex=shifterU8;
258     shifterU8>>=1;
259     sprm=shifterU8;
260     val=stream->readU8();
261 
262     if(preservePos)
263         stream->pop();
264     return true;
265 }
266 
readPtr(const U8 * ptr)267 void PRM::readPtr(const U8 *ptr) {
268 
269     U8 shifterU8;
270 
271     shifterU8=readU8(ptr);
272     ptr+=sizeof(U8);
273     fComplex=shifterU8;
274     shifterU8>>=1;
275     sprm=shifterU8;
276     val=readU8(ptr);
277     ptr+=sizeof(U8);
278 }
279 
write(OLEStreamWriter * stream,bool preservePos) const280 bool PRM::write(OLEStreamWriter *stream, bool preservePos) const {
281 
282     U8 shifterU8;
283 
284     if(preservePos)
285         stream->push();
286 
287     shifterU8=fComplex;
288     shifterU8|=sprm << 1;
289     stream->write(shifterU8);
290     stream->write(val);
291 
292     if(preservePos)
293         stream->pop();
294     return true;
295 }
296 
clear()297 void PRM::clear() {
298     fComplex=0;
299     sprm=0;
300     val=0;
301 }
302 
operator ==(const PRM & lhs,const PRM & rhs)303 bool operator==(const PRM &lhs, const PRM &rhs) {
304 
305     return lhs.fComplex==rhs.fComplex &&
306            lhs.sprm==rhs.sprm &&
307            lhs.val==rhs.val;
308 }
309 
operator !=(const PRM & lhs,const PRM & rhs)310 bool operator!=(const PRM &lhs, const PRM &rhs) {
311     return !(lhs==rhs);
312 }
313 
314 
315 // SHD implementation
316 
SHD()317 SHD::SHD() {
318     clear();
319 }
320 
SHD(OLEStreamReader * stream,bool preservePos)321 SHD::SHD(OLEStreamReader *stream, bool preservePos) {
322     clear();
323     read(stream, preservePos);
324 }
325 
SHD(const U8 * ptr)326 SHD::SHD(const U8 *ptr) {
327     clear();
328     readPtr(ptr);
329 }
330 
read(OLEStreamReader * stream,bool preservePos)331 bool SHD::read(OLEStreamReader *stream, bool preservePos) {
332 
333     U16 shifterU16;
334 
335     if(preservePos)
336         stream->push();
337 
338     shifterU16=stream->readU16();
339     icoFore=shifterU16;
340     shifterU16>>=5;
341     icoBack=shifterU16;
342     shifterU16>>=5;
343     ipat=shifterU16;
344 
345     if(preservePos)
346         stream->pop();
347     return true;
348 }
349 
readPtr(const U8 * ptr)350 void SHD::readPtr(const U8 *ptr) {
351 
352     U16 shifterU16;
353 
354     shifterU16=readU16(ptr);
355     ptr+=sizeof(U16);
356     icoFore=shifterU16;
357     shifterU16>>=5;
358     icoBack=shifterU16;
359     shifterU16>>=5;
360     ipat=shifterU16;
361 }
362 
write(OLEStreamWriter * stream,bool preservePos) const363 bool SHD::write(OLEStreamWriter *stream, bool preservePos) const {
364 
365     U16 shifterU16;
366 
367     if(preservePos)
368         stream->push();
369 
370     shifterU16=icoFore;
371     shifterU16|=icoBack << 5;
372     shifterU16|=ipat << 10;
373     stream->write(shifterU16);
374 
375     if(preservePos)
376         stream->pop();
377     return true;
378 }
379 
clear()380 void SHD::clear() {
381     icoFore=0;
382     icoBack=0;
383     ipat=0;
384 }
385 
dump() const386 void SHD::dump() const
387 {
388     wvlog << "Dumping SHD:" << std::endl;
389     wvlog << toString().c_str() << std::endl;
390     wvlog << "\nDumping SHD done." << std::endl;
391 }
392 
toString() const393 std::string SHD::toString() const
394 {
395     std::string s( "SHD:" );
396     s += "\nicoFore=";
397     s += uint2string( icoFore );
398     s += "\nicoBack=";
399     s += uint2string( icoBack );
400     s += "\nipat=";
401     s += uint2string( ipat );
402     s += "\nSHD Done.";
403     return s;
404 }
405 
operator ==(const SHD & lhs,const SHD & rhs)406 bool operator==(const SHD &lhs, const SHD &rhs) {
407 
408     return lhs.icoFore==rhs.icoFore &&
409            lhs.icoBack==rhs.icoBack &&
410            lhs.ipat==rhs.ipat;
411 }
412 
operator !=(const SHD & lhs,const SHD & rhs)413 bool operator!=(const SHD &lhs, const SHD &rhs) {
414     return !(lhs==rhs);
415 }
416 
417 
418 // PHE implementation
419 
420 const unsigned int PHE::sizeOf = 6;
421 
PHE()422 PHE::PHE() {
423     clear();
424 }
425 
PHE(OLEStreamReader * stream,bool preservePos)426 PHE::PHE(OLEStreamReader *stream, bool preservePos) {
427     clear();
428     read(stream, preservePos);
429 }
430 
PHE(const U8 * ptr)431 PHE::PHE(const U8 *ptr) {
432     clear();
433     readPtr(ptr);
434 }
435 
read(OLEStreamReader * stream,bool preservePos)436 bool PHE::read(OLEStreamReader *stream, bool preservePos) {
437 
438     U16 shifterU16;
439 
440     if(preservePos)
441         stream->push();
442 
443     shifterU16=stream->readU16();
444     fSpare=shifterU16;
445     shifterU16>>=1;
446     fUnk=shifterU16;
447     shifterU16>>=1;
448     fDiffLines=shifterU16;
449     shifterU16>>=1;
450     unused0_3=shifterU16;
451     shifterU16>>=5;
452     clMac=shifterU16;
453     dxaCol=stream->readU16();
454     dylLine_dylHeight=stream->readU16();
455 
456     if(preservePos)
457         stream->pop();
458     return true;
459 }
460 
readPtr(const U8 * ptr)461 void PHE::readPtr(const U8 *ptr) {
462 
463     U16 shifterU16;
464 
465     shifterU16=readU16(ptr);
466     ptr+=sizeof(U16);
467     fSpare=shifterU16;
468     shifterU16>>=1;
469     fUnk=shifterU16;
470     shifterU16>>=1;
471     fDiffLines=shifterU16;
472     shifterU16>>=1;
473     unused0_3=shifterU16;
474     shifterU16>>=5;
475     clMac=shifterU16;
476     dxaCol=readU16(ptr);
477     ptr+=sizeof(U16);
478     dylLine_dylHeight=readU16(ptr);
479     ptr+=sizeof(U16);
480 }
481 
write(OLEStreamWriter * stream,bool preservePos) const482 bool PHE::write(OLEStreamWriter *stream, bool preservePos) const {
483 
484     U16 shifterU16;
485 
486     if(preservePos)
487         stream->push();
488 
489     shifterU16=fSpare;
490     shifterU16|=fUnk << 1;
491     shifterU16|=fDiffLines << 2;
492     shifterU16|=unused0_3 << 3;
493     shifterU16|=clMac << 8;
494     stream->write(shifterU16);
495     stream->write(dxaCol);
496     stream->write(dylLine_dylHeight);
497 
498     if(preservePos)
499         stream->pop();
500     return true;
501 }
502 
clear()503 void PHE::clear() {
504     fSpare=0;
505     fUnk=0;
506     fDiffLines=0;
507     unused0_3=0;
508     clMac=0;
509     dxaCol=0;
510     dylLine_dylHeight=0;
511 }
512 
dump() const513 void PHE::dump() const
514 {
515     wvlog << "Dumping PHE:" << std::endl;
516     wvlog << toString().c_str() << std::endl;
517     wvlog << "\nDumping PHE done." << std::endl;
518 }
519 
toString() const520 std::string PHE::toString() const
521 {
522     std::string s( "PHE:" );
523     s += "\nfSpare=";
524     s += uint2string( fSpare );
525     s += "\nfUnk=";
526     s += uint2string( fUnk );
527     s += "\nfDiffLines=";
528     s += uint2string( fDiffLines );
529     s += "\nunused0_3=";
530     s += uint2string( unused0_3 );
531     s += "\nclMac=";
532     s += uint2string( clMac );
533     s += "\ndxaCol=";
534     s += uint2string( dxaCol );
535     s += "\ndylLine_dylHeight=";
536     s += uint2string( dylLine_dylHeight );
537     s += "\nPHE Done.";
538     return s;
539 }
540 
operator ==(const PHE & lhs,const PHE & rhs)541 bool operator==(const PHE &lhs, const PHE &rhs) {
542 
543     return lhs.fSpare==rhs.fSpare &&
544            lhs.fUnk==rhs.fUnk &&
545            lhs.fDiffLines==rhs.fDiffLines &&
546            lhs.unused0_3==rhs.unused0_3 &&
547            lhs.clMac==rhs.clMac &&
548            lhs.dxaCol==rhs.dxaCol &&
549            lhs.dylLine_dylHeight==rhs.dylLine_dylHeight;
550 }
551 
operator !=(const PHE & lhs,const PHE & rhs)552 bool operator!=(const PHE &lhs, const PHE &rhs) {
553     return !(lhs==rhs);
554 }
555 
556 
557 // BRC implementation
558 
559 const unsigned int BRC::sizeOf = 2;
560 
BRC()561 BRC::BRC() {
562     clear();
563 }
564 
BRC(OLEStreamReader * stream,bool preservePos)565 BRC::BRC(OLEStreamReader *stream, bool preservePos) {
566     clear();
567     read(stream, preservePos);
568 }
569 
BRC(const U8 * ptr)570 BRC::BRC(const U8 *ptr) {
571     clear();
572     readPtr(ptr);
573 }
574 
read(OLEStreamReader * stream,bool preservePos)575 bool BRC::read(OLEStreamReader *stream, bool preservePos) {
576 
577     U16 shifterU16;
578 
579     if(preservePos)
580         stream->push();
581 
582     shifterU16=stream->readU16();
583     dxpLineWidth=shifterU16;
584     shifterU16>>=3;
585     brcType=shifterU16;
586     shifterU16>>=2;
587     fShadow=shifterU16;
588     shifterU16>>=1;
589     ico=shifterU16;
590     shifterU16>>=5;
591     dxpSpace=shifterU16;
592 
593     if(preservePos)
594         stream->pop();
595     return true;
596 }
597 
readPtr(const U8 * ptr)598 void BRC::readPtr(const U8 *ptr) {
599 
600     U16 shifterU16;
601 
602     shifterU16=readU16(ptr);
603     ptr+=sizeof(U16);
604     dxpLineWidth=shifterU16;
605     shifterU16>>=3;
606     brcType=shifterU16;
607     shifterU16>>=2;
608     fShadow=shifterU16;
609     shifterU16>>=1;
610     ico=shifterU16;
611     shifterU16>>=5;
612     dxpSpace=shifterU16;
613 }
614 
write(OLEStreamWriter * stream,bool preservePos) const615 bool BRC::write(OLEStreamWriter *stream, bool preservePos) const {
616 
617     U16 shifterU16;
618 
619     if(preservePos)
620         stream->push();
621 
622     shifterU16=dxpLineWidth;
623     shifterU16|=brcType << 3;
624     shifterU16|=fShadow << 5;
625     shifterU16|=ico << 6;
626     shifterU16|=dxpSpace << 11;
627     stream->write(shifterU16);
628 
629     if(preservePos)
630         stream->pop();
631     return true;
632 }
633 
clear()634 void BRC::clear() {
635     dxpLineWidth=0;
636     brcType=0;
637     fShadow=0;
638     ico=0;
639     dxpSpace=0;
640 }
641 
dump() const642 void BRC::dump() const
643 {
644     wvlog << "Dumping BRC:" << std::endl;
645     wvlog << toString().c_str() << std::endl;
646     wvlog << "\nDumping BRC done." << std::endl;
647 }
648 
toString() const649 std::string BRC::toString() const
650 {
651     std::string s( "BRC:" );
652     s += "\ndxpLineWidth=";
653     s += uint2string( dxpLineWidth );
654     s += "\nbrcType=";
655     s += uint2string( brcType );
656     s += "\nfShadow=";
657     s += uint2string( fShadow );
658     s += "\nico=";
659     s += uint2string( ico );
660     s += "\ndxpSpace=";
661     s += uint2string( dxpSpace );
662     s += "\nBRC Done.";
663     return s;
664 }
665 
operator ==(const BRC & lhs,const BRC & rhs)666 bool operator==(const BRC &lhs, const BRC &rhs) {
667 
668     return lhs.dxpLineWidth==rhs.dxpLineWidth &&
669            lhs.brcType==rhs.brcType &&
670            lhs.fShadow==rhs.fShadow &&
671            lhs.ico==rhs.ico &&
672            lhs.dxpSpace==rhs.dxpSpace;
673 }
674 
operator !=(const BRC & lhs,const BRC & rhs)675 bool operator!=(const BRC &lhs, const BRC &rhs) {
676     return !(lhs==rhs);
677 }
678 
679 
680 // TLP implementation
681 
TLP()682 TLP::TLP() {
683     clear();
684 }
685 
TLP(OLEStreamReader * stream,bool preservePos)686 TLP::TLP(OLEStreamReader *stream, bool preservePos) {
687     clear();
688     read(stream, preservePos);
689 }
690 
TLP(const U8 * ptr)691 TLP::TLP(const U8 *ptr) {
692     clear();
693     readPtr(ptr);
694 }
695 
read(OLEStreamReader * stream,bool preservePos)696 bool TLP::read(OLEStreamReader *stream, bool preservePos) {
697 
698     U16 shifterU16;
699 
700     if(preservePos)
701         stream->push();
702 
703     itl=stream->readU16();
704     shifterU16=stream->readU16();
705     fBorders=shifterU16;
706     shifterU16>>=1;
707     fShading=shifterU16;
708     shifterU16>>=1;
709     fFont=shifterU16;
710     shifterU16>>=1;
711     fColor=shifterU16;
712     shifterU16>>=1;
713     fBestFit=shifterU16;
714     shifterU16>>=1;
715     fHdrRows=shifterU16;
716     shifterU16>>=1;
717     fLastRow=shifterU16;
718     shifterU16>>=1;
719     fHdrCols=shifterU16;
720     shifterU16>>=1;
721     fLastCol=shifterU16;
722     shifterU16>>=1;
723     unused2_9=shifterU16;
724 
725     if(preservePos)
726         stream->pop();
727     return true;
728 }
729 
readPtr(const U8 * ptr)730 void TLP::readPtr(const U8 *ptr) {
731 
732     U16 shifterU16;
733 
734     itl=readU16(ptr);
735     ptr+=sizeof(U16);
736     shifterU16=readU16(ptr);
737     ptr+=sizeof(U16);
738     fBorders=shifterU16;
739     shifterU16>>=1;
740     fShading=shifterU16;
741     shifterU16>>=1;
742     fFont=shifterU16;
743     shifterU16>>=1;
744     fColor=shifterU16;
745     shifterU16>>=1;
746     fBestFit=shifterU16;
747     shifterU16>>=1;
748     fHdrRows=shifterU16;
749     shifterU16>>=1;
750     fLastRow=shifterU16;
751     shifterU16>>=1;
752     fHdrCols=shifterU16;
753     shifterU16>>=1;
754     fLastCol=shifterU16;
755     shifterU16>>=1;
756     unused2_9=shifterU16;
757 }
758 
write(OLEStreamWriter * stream,bool preservePos) const759 bool TLP::write(OLEStreamWriter *stream, bool preservePos) const {
760 
761     U16 shifterU16;
762 
763     if(preservePos)
764         stream->push();
765 
766     stream->write(itl);
767     shifterU16=fBorders;
768     shifterU16|=fShading << 1;
769     shifterU16|=fFont << 2;
770     shifterU16|=fColor << 3;
771     shifterU16|=fBestFit << 4;
772     shifterU16|=fHdrRows << 5;
773     shifterU16|=fLastRow << 6;
774     shifterU16|=fHdrCols << 7;
775     shifterU16|=fLastCol << 8;
776     shifterU16|=unused2_9 << 9;
777     stream->write(shifterU16);
778 
779     if(preservePos)
780         stream->pop();
781     return true;
782 }
783 
clear()784 void TLP::clear() {
785     itl=0;
786     fBorders=0;
787     fShading=0;
788     fFont=0;
789     fColor=0;
790     fBestFit=0;
791     fHdrRows=0;
792     fLastRow=0;
793     fHdrCols=0;
794     fLastCol=0;
795     unused2_9=0;
796 }
797 
dump() const798 void TLP::dump() const
799 {
800     wvlog << "Dumping TLP:" << std::endl;
801     wvlog << toString().c_str() << std::endl;
802     wvlog << "\nDumping TLP done." << std::endl;
803 }
804 
toString() const805 std::string TLP::toString() const
806 {
807     std::string s( "TLP:" );
808     s += "\nitl=";
809     s += uint2string( itl );
810     s += "\nfBorders=";
811     s += uint2string( fBorders );
812     s += "\nfShading=";
813     s += uint2string( fShading );
814     s += "\nfFont=";
815     s += uint2string( fFont );
816     s += "\nfColor=";
817     s += uint2string( fColor );
818     s += "\nfBestFit=";
819     s += uint2string( fBestFit );
820     s += "\nfHdrRows=";
821     s += uint2string( fHdrRows );
822     s += "\nfLastRow=";
823     s += uint2string( fLastRow );
824     s += "\nfHdrCols=";
825     s += uint2string( fHdrCols );
826     s += "\nfLastCol=";
827     s += uint2string( fLastCol );
828     s += "\nunused2_9=";
829     s += uint2string( unused2_9 );
830     s += "\nTLP Done.";
831     return s;
832 }
833 
operator ==(const TLP & lhs,const TLP & rhs)834 bool operator==(const TLP &lhs, const TLP &rhs) {
835 
836     return lhs.itl==rhs.itl &&
837            lhs.fBorders==rhs.fBorders &&
838            lhs.fShading==rhs.fShading &&
839            lhs.fFont==rhs.fFont &&
840            lhs.fColor==rhs.fColor &&
841            lhs.fBestFit==rhs.fBestFit &&
842            lhs.fHdrRows==rhs.fHdrRows &&
843            lhs.fLastRow==rhs.fLastRow &&
844            lhs.fHdrCols==rhs.fHdrCols &&
845            lhs.fLastCol==rhs.fLastCol &&
846            lhs.unused2_9==rhs.unused2_9;
847 }
848 
operator !=(const TLP & lhs,const TLP & rhs)849 bool operator!=(const TLP &lhs, const TLP &rhs) {
850     return !(lhs==rhs);
851 }
852 
853 
854 // TC implementation
855 
856 const unsigned int TC::sizeOf = 10;
857 
TC()858 TC::TC() {
859     clear();
860 }
861 
TC(OLEStreamReader * stream,bool preservePos)862 TC::TC(OLEStreamReader *stream, bool preservePos) {
863     clear();
864     read(stream, preservePos);
865 }
866 
TC(const U8 * ptr)867 TC::TC(const U8 *ptr) {
868     clear();
869     readPtr(ptr);
870 }
871 
read(OLEStreamReader * stream,bool preservePos)872 bool TC::read(OLEStreamReader *stream, bool preservePos) {
873 
874     U16 shifterU16;
875 
876     if(preservePos)
877         stream->push();
878 
879     shifterU16=stream->readU16();
880     fFirstMerged=shifterU16;
881     shifterU16>>=1;
882     fMerged=shifterU16;
883     shifterU16>>=1;
884     fUnused=shifterU16;
885     brcTop.read(stream, false);
886     brcLeft.read(stream, false);
887     brcBottom.read(stream, false);
888     brcRight.read(stream, false);
889 
890     if(preservePos)
891         stream->pop();
892     return true;
893 }
894 
readPtr(const U8 * ptr)895 void TC::readPtr(const U8 *ptr) {
896 
897     U16 shifterU16;
898 
899     shifterU16=readU16(ptr);
900     ptr+=sizeof(U16);
901     fFirstMerged=shifterU16;
902     shifterU16>>=1;
903     fMerged=shifterU16;
904     shifterU16>>=1;
905     fUnused=shifterU16;
906     brcTop.readPtr(ptr);
907     ptr+=BRC::sizeOf;
908     brcLeft.readPtr(ptr);
909     ptr+=BRC::sizeOf;
910     brcBottom.readPtr(ptr);
911     ptr+=BRC::sizeOf;
912     brcRight.readPtr(ptr);
913     ptr+=BRC::sizeOf;
914 }
915 
write(OLEStreamWriter * stream,bool preservePos) const916 bool TC::write(OLEStreamWriter *stream, bool preservePos) const {
917 
918     U16 shifterU16;
919 
920     if(preservePos)
921         stream->push();
922 
923     shifterU16=fFirstMerged;
924     shifterU16|=fMerged << 1;
925     shifterU16|=fUnused << 2;
926     stream->write(shifterU16);
927     brcTop.write(stream, false);
928     brcLeft.write(stream, false);
929     brcBottom.write(stream, false);
930     brcRight.write(stream, false);
931 
932     if(preservePos)
933         stream->pop();
934     return true;
935 }
936 
clear()937 void TC::clear() {
938     fFirstMerged=0;
939     fMerged=0;
940     fUnused=0;
941     brcTop.clear();
942     brcLeft.clear();
943     brcBottom.clear();
944     brcRight.clear();
945 }
946 
dump() const947 void TC::dump() const
948 {
949     wvlog << "Dumping TC:" << std::endl;
950     wvlog << toString().c_str() << std::endl;
951     wvlog << "\nDumping TC done." << std::endl;
952 }
953 
toString() const954 std::string TC::toString() const
955 {
956     std::string s( "TC:" );
957     s += "\nfFirstMerged=";
958     s += uint2string( fFirstMerged );
959     s += "\nfMerged=";
960     s += uint2string( fMerged );
961     s += "\nfUnused=";
962     s += uint2string( fUnused );
963     s += "\nbrcTop=";
964     s += "\n{" + brcTop.toString() + "}\n";
965     s += "\nbrcLeft=";
966     s += "\n{" + brcLeft.toString() + "}\n";
967     s += "\nbrcBottom=";
968     s += "\n{" + brcBottom.toString() + "}\n";
969     s += "\nbrcRight=";
970     s += "\n{" + brcRight.toString() + "}\n";
971     s += "\nTC Done.";
972     return s;
973 }
974 
operator ==(const TC & lhs,const TC & rhs)975 bool operator==(const TC &lhs, const TC &rhs) {
976 
977     return lhs.fFirstMerged==rhs.fFirstMerged &&
978            lhs.fMerged==rhs.fMerged &&
979            lhs.fUnused==rhs.fUnused &&
980            lhs.brcTop==rhs.brcTop &&
981            lhs.brcLeft==rhs.brcLeft &&
982            lhs.brcBottom==rhs.brcBottom &&
983            lhs.brcRight==rhs.brcRight;
984 }
985 
operator !=(const TC & lhs,const TC & rhs)986 bool operator!=(const TC &lhs, const TC &rhs) {
987     return !(lhs==rhs);
988 }
989 
990 
991 // DPHEAD implementation
992 
DPHEAD()993 DPHEAD::DPHEAD() {
994     clear();
995 }
996 
DPHEAD(OLEStreamReader * stream,bool preservePos)997 DPHEAD::DPHEAD(OLEStreamReader *stream, bool preservePos) {
998     clear();
999     read(stream, preservePos);
1000 }
1001 
read(OLEStreamReader * stream,bool preservePos)1002 bool DPHEAD::read(OLEStreamReader *stream, bool preservePos) {
1003 
1004     if(preservePos)
1005         stream->push();
1006 
1007     dpk=stream->readU16();
1008     cb=stream->readU16();
1009     xa=stream->readU16();
1010     ya=stream->readU16();
1011     dxa=stream->readU16();
1012     dya=stream->readU16();
1013 
1014     if(preservePos)
1015         stream->pop();
1016     return true;
1017 }
1018 
write(OLEStreamWriter * stream,bool preservePos) const1019 bool DPHEAD::write(OLEStreamWriter *stream, bool preservePos) const {
1020 
1021     if(preservePos)
1022         stream->push();
1023 
1024     stream->write(dpk);
1025     stream->write(cb);
1026     stream->write(xa);
1027     stream->write(ya);
1028     stream->write(dxa);
1029     stream->write(dya);
1030 
1031     if(preservePos)
1032         stream->pop();
1033     return true;
1034 }
1035 
clear()1036 void DPHEAD::clear() {
1037     dpk=0;
1038     cb=0;
1039     xa=0;
1040     ya=0;
1041     dxa=0;
1042     dya=0;
1043 }
1044 
operator ==(const DPHEAD & lhs,const DPHEAD & rhs)1045 bool operator==(const DPHEAD &lhs, const DPHEAD &rhs) {
1046 
1047     return lhs.dpk==rhs.dpk &&
1048            lhs.cb==rhs.cb &&
1049            lhs.xa==rhs.xa &&
1050            lhs.ya==rhs.ya &&
1051            lhs.dxa==rhs.dxa &&
1052            lhs.dya==rhs.dya;
1053 }
1054 
operator !=(const DPHEAD & lhs,const DPHEAD & rhs)1055 bool operator!=(const DPHEAD &lhs, const DPHEAD &rhs) {
1056     return !(lhs==rhs);
1057 }
1058 
1059 
1060 // DPTXBX implementation
1061 
DPTXBX()1062 DPTXBX::DPTXBX() {
1063     clear();
1064 }
1065 
DPTXBX(OLEStreamReader * stream,bool preservePos)1066 DPTXBX::DPTXBX(OLEStreamReader *stream, bool preservePos) {
1067     clear();
1068     read(stream, preservePos);
1069 }
1070 
read(OLEStreamReader * stream,bool preservePos)1071 bool DPTXBX::read(OLEStreamReader *stream, bool preservePos) {
1072 
1073     U16 shifterU16;
1074 
1075     if(preservePos)
1076         stream->push();
1077 
1078     dphead.read(stream, false);
1079     lnpc=stream->readU32();
1080     lnpw=stream->readU16();
1081     lnps=stream->readU16();
1082     dlpcFg=stream->readU32();
1083     dlpcBg=stream->readU32();
1084     flpp=stream->readU16();
1085     shdwpi=stream->readU16();
1086     xaOffset=stream->readU16();
1087     yaOffset=stream->readU16();
1088     shifterU16=stream->readU16();
1089     fRoundCorners=shifterU16;
1090     shifterU16>>=1;
1091     zaShape=shifterU16;
1092     dzaInternalMargin=stream->readU16();
1093 
1094     if(preservePos)
1095         stream->pop();
1096     return true;
1097 }
1098 
write(OLEStreamWriter * stream,bool preservePos) const1099 bool DPTXBX::write(OLEStreamWriter *stream, bool preservePos) const {
1100 
1101     U16 shifterU16;
1102 
1103     if(preservePos)
1104         stream->push();
1105 
1106     dphead.write(stream, false);
1107     stream->write(lnpc);
1108     stream->write(lnpw);
1109     stream->write(lnps);
1110     stream->write(dlpcFg);
1111     stream->write(dlpcBg);
1112     stream->write(flpp);
1113     stream->write(shdwpi);
1114     stream->write(xaOffset);
1115     stream->write(yaOffset);
1116     shifterU16=fRoundCorners;
1117     shifterU16|=zaShape << 1;
1118     stream->write(shifterU16);
1119     stream->write(dzaInternalMargin);
1120 
1121     if(preservePos)
1122         stream->pop();
1123     return true;
1124 }
1125 
clear()1126 void DPTXBX::clear() {
1127     dphead.clear();
1128     lnpc=0;
1129     lnpw=0;
1130     lnps=0;
1131     dlpcFg=0;
1132     dlpcBg=0;
1133     flpp=0;
1134     shdwpi=0;
1135     xaOffset=0;
1136     yaOffset=0;
1137     fRoundCorners=0;
1138     zaShape=0;
1139     dzaInternalMargin=0;
1140 }
1141 
operator ==(const DPTXBX & lhs,const DPTXBX & rhs)1142 bool operator==(const DPTXBX &lhs, const DPTXBX &rhs) {
1143 
1144     return lhs.dphead==rhs.dphead &&
1145            lhs.lnpc==rhs.lnpc &&
1146            lhs.lnpw==rhs.lnpw &&
1147            lhs.lnps==rhs.lnps &&
1148            lhs.dlpcFg==rhs.dlpcFg &&
1149            lhs.dlpcBg==rhs.dlpcBg &&
1150            lhs.flpp==rhs.flpp &&
1151            lhs.shdwpi==rhs.shdwpi &&
1152            lhs.xaOffset==rhs.xaOffset &&
1153            lhs.yaOffset==rhs.yaOffset &&
1154            lhs.fRoundCorners==rhs.fRoundCorners &&
1155            lhs.zaShape==rhs.zaShape &&
1156            lhs.dzaInternalMargin==rhs.dzaInternalMargin;
1157 }
1158 
operator !=(const DPTXBX & lhs,const DPTXBX & rhs)1159 bool operator!=(const DPTXBX &lhs, const DPTXBX &rhs) {
1160     return !(lhs==rhs);
1161 }
1162 
1163 
1164 // DPPOLYLINE implementation
1165 
DPPOLYLINE()1166 DPPOLYLINE::DPPOLYLINE() {
1167     clearInternal();
1168 }
1169 
DPPOLYLINE(OLEStreamReader * stream,bool preservePos)1170 DPPOLYLINE::DPPOLYLINE(OLEStreamReader *stream, bool preservePos) {
1171     clearInternal();
1172     read(stream, preservePos);
1173 }
1174 
DPPOLYLINE(const DPPOLYLINE & rhs)1175 DPPOLYLINE::DPPOLYLINE(const DPPOLYLINE &rhs) {
1176     dphead=rhs.dphead;
1177     lnpc=rhs.lnpc;
1178     lnpw=rhs.lnpw;
1179     lnps=rhs.lnps;
1180     dlpcFg=rhs.dlpcFg;
1181     dlpcBg=rhs.dlpcBg;
1182     flpp=rhs.flpp;
1183     eppsStart=rhs.eppsStart;
1184     eppwStart=rhs.eppwStart;
1185     epplStart=rhs.epplStart;
1186     unused30_6=rhs.unused30_6;
1187     eppsEnd=rhs.eppsEnd;
1188     eppwEnd=rhs.eppwEnd;
1189     epplEnd=rhs.epplEnd;
1190     unused32_6=rhs.unused32_6;
1191     shdwpi=rhs.shdwpi;
1192     xaOffset=rhs.xaOffset;
1193     yaOffset=rhs.yaOffset;
1194     fPolygon=rhs.fPolygon;
1195     cpt=rhs.cpt;
1196     xaFirst=rhs.xaFirst;
1197     yaFirst=rhs.yaFirst;
1198     xaEnd=rhs.xaEnd;
1199     yaEnd=rhs.yaEnd;
1200     rgpta=rhs.rgpta;
1201 }
1202 
~DPPOLYLINE()1203 DPPOLYLINE::~DPPOLYLINE() {
1204     delete [] rgpta;
1205 }
1206 
operator =(const DPPOLYLINE & rhs)1207 DPPOLYLINE &DPPOLYLINE::operator=(const DPPOLYLINE &rhs) {
1208 
1209     // Check for assignment to self
1210     if(this==&rhs)
1211         return *this;
1212 
1213     dphead=rhs.dphead;
1214     lnpc=rhs.lnpc;
1215     lnpw=rhs.lnpw;
1216     lnps=rhs.lnps;
1217     dlpcFg=rhs.dlpcFg;
1218     dlpcBg=rhs.dlpcBg;
1219     flpp=rhs.flpp;
1220     eppsStart=rhs.eppsStart;
1221     eppwStart=rhs.eppwStart;
1222     epplStart=rhs.epplStart;
1223     unused30_6=rhs.unused30_6;
1224     eppsEnd=rhs.eppsEnd;
1225     eppwEnd=rhs.eppwEnd;
1226     epplEnd=rhs.epplEnd;
1227     unused32_6=rhs.unused32_6;
1228     shdwpi=rhs.shdwpi;
1229     xaOffset=rhs.xaOffset;
1230     yaOffset=rhs.yaOffset;
1231     fPolygon=rhs.fPolygon;
1232     cpt=rhs.cpt;
1233     xaFirst=rhs.xaFirst;
1234     yaFirst=rhs.yaFirst;
1235     xaEnd=rhs.xaEnd;
1236     yaEnd=rhs.yaEnd;
1237     rgpta=rhs.rgpta;
1238 
1239     return *this;
1240 }
1241 
read(OLEStreamReader * stream,bool preservePos)1242 bool DPPOLYLINE::read(OLEStreamReader *stream, bool preservePos) {
1243 
1244     U16 shifterU16;
1245 
1246     if(preservePos)
1247         stream->push();
1248 
1249     dphead.read(stream, false);
1250     lnpc=stream->readU32();
1251     lnpw=stream->readU16();
1252     lnps=stream->readU16();
1253     dlpcFg=stream->readU32();
1254     dlpcBg=stream->readU32();
1255     flpp=stream->readU16();
1256     shifterU16=stream->readU16();
1257     eppsStart=shifterU16;
1258     shifterU16>>=2;
1259     eppwStart=shifterU16;
1260     shifterU16>>=2;
1261     epplStart=shifterU16;
1262     shifterU16>>=2;
1263     unused30_6=shifterU16;
1264     shifterU16=stream->readU16();
1265     eppsEnd=shifterU16;
1266     shifterU16>>=2;
1267     eppwEnd=shifterU16;
1268     shifterU16>>=2;
1269     epplEnd=shifterU16;
1270     shifterU16>>=2;
1271     unused32_6=shifterU16;
1272     shdwpi=stream->readU16();
1273     xaOffset=stream->readU16();
1274     yaOffset=stream->readU16();
1275     shifterU16=stream->readU16();
1276     fPolygon=shifterU16;
1277     shifterU16>>=1;
1278     cpt=shifterU16;
1279     xaFirst=stream->readU16();
1280     yaFirst=stream->readU16();
1281     xaEnd=stream->readU16();
1282     yaEnd=stream->readU16();
1283     // Attention: I don't know how to read rgpta - U16[]
1284 #ifdef __GNUC__
1285 #warning "Couldn't generate reading code for DPPOLYLINE::rgpta"
1286 #endif
1287 
1288     if(preservePos)
1289         stream->pop();
1290     return true;
1291 }
1292 
write(OLEStreamWriter * stream,bool preservePos) const1293 bool DPPOLYLINE::write(OLEStreamWriter *stream, bool preservePos) const {
1294 
1295     U16 shifterU16;
1296 
1297     if(preservePos)
1298         stream->push();
1299 
1300     dphead.write(stream, false);
1301     stream->write(lnpc);
1302     stream->write(lnpw);
1303     stream->write(lnps);
1304     stream->write(dlpcFg);
1305     stream->write(dlpcBg);
1306     stream->write(flpp);
1307     shifterU16=eppsStart;
1308     shifterU16|=eppwStart << 2;
1309     shifterU16|=epplStart << 4;
1310     shifterU16|=unused30_6 << 6;
1311     stream->write(shifterU16);
1312     shifterU16=eppsEnd;
1313     shifterU16|=eppwEnd << 2;
1314     shifterU16|=epplEnd << 4;
1315     shifterU16|=unused32_6 << 6;
1316     stream->write(shifterU16);
1317     stream->write(shdwpi);
1318     stream->write(xaOffset);
1319     stream->write(yaOffset);
1320     shifterU16=fPolygon;
1321     shifterU16|=cpt << 1;
1322     stream->write(shifterU16);
1323     stream->write(xaFirst);
1324     stream->write(yaFirst);
1325     stream->write(xaEnd);
1326     stream->write(yaEnd);
1327     // Attention: I don't know how to write rgpta - U16[]
1328 #ifdef __GNUC__
1329 #warning "Couldn't generate writing code for DPPOLYLINE::rgpta"
1330 #endif
1331 
1332     if(preservePos)
1333         stream->pop();
1334     return true;
1335 }
1336 
clear()1337 void DPPOLYLINE::clear() {
1338     delete [] rgpta;
1339     clearInternal();
1340 }
1341 
clearInternal()1342 void DPPOLYLINE::clearInternal() {
1343     dphead.clear();
1344     lnpc=0;
1345     lnpw=0;
1346     lnps=0;
1347     dlpcFg=0;
1348     dlpcBg=0;
1349     flpp=0;
1350     eppsStart=0;
1351     eppwStart=0;
1352     epplStart=0;
1353     unused30_6=0;
1354     eppsEnd=0;
1355     eppwEnd=0;
1356     epplEnd=0;
1357     unused32_6=0;
1358     shdwpi=0;
1359     xaOffset=0;
1360     yaOffset=0;
1361     fPolygon=0;
1362     cpt=0;
1363     xaFirst=0;
1364     yaFirst=0;
1365     xaEnd=0;
1366     yaEnd=0;
1367     rgpta=0;
1368 }
1369 
operator ==(const DPPOLYLINE & lhs,const DPPOLYLINE & rhs)1370 bool operator==(const DPPOLYLINE &lhs, const DPPOLYLINE &rhs) {
1371     // Attention: I don't know how to compare rgpta - U16[]
1372 #ifdef __GNUC__
1373 #warning "Can't compare DPPOLYLINE::rgpta items"
1374 #endif
1375 
1376     return lhs.dphead==rhs.dphead &&
1377            lhs.lnpc==rhs.lnpc &&
1378            lhs.lnpw==rhs.lnpw &&
1379            lhs.lnps==rhs.lnps &&
1380            lhs.dlpcFg==rhs.dlpcFg &&
1381            lhs.dlpcBg==rhs.dlpcBg &&
1382            lhs.flpp==rhs.flpp &&
1383            lhs.eppsStart==rhs.eppsStart &&
1384            lhs.eppwStart==rhs.eppwStart &&
1385            lhs.epplStart==rhs.epplStart &&
1386            lhs.unused30_6==rhs.unused30_6 &&
1387            lhs.eppsEnd==rhs.eppsEnd &&
1388            lhs.eppwEnd==rhs.eppwEnd &&
1389            lhs.epplEnd==rhs.epplEnd &&
1390            lhs.unused32_6==rhs.unused32_6 &&
1391            lhs.shdwpi==rhs.shdwpi &&
1392            lhs.xaOffset==rhs.xaOffset &&
1393            lhs.yaOffset==rhs.yaOffset &&
1394            lhs.fPolygon==rhs.fPolygon &&
1395            lhs.cpt==rhs.cpt &&
1396            lhs.xaFirst==rhs.xaFirst &&
1397            lhs.yaFirst==rhs.yaFirst &&
1398            lhs.xaEnd==rhs.xaEnd &&
1399            lhs.yaEnd==rhs.yaEnd;
1400 }
1401 
operator !=(const DPPOLYLINE & lhs,const DPPOLYLINE & rhs)1402 bool operator!=(const DPPOLYLINE &lhs, const DPPOLYLINE &rhs) {
1403     return !(lhs==rhs);
1404 }
1405 
1406 
1407 // TAP implementation
1408 
TAP()1409 TAP::TAP() : Shared() {
1410     clearInternal();
1411 }
1412 
TAP(OLEStreamReader * stream,bool preservePos)1413 TAP::TAP(OLEStreamReader *stream, bool preservePos) : Shared() {
1414     clearInternal();
1415     read(stream, preservePos);
1416 }
1417 
TAP(const TAP & rhs)1418 TAP::TAP(const TAP &rhs) : Shared() {
1419     jc=rhs.jc;
1420     dxaGapHalf=rhs.dxaGapHalf;
1421     dyaRowHeight=rhs.dyaRowHeight;
1422     fCantSplit=rhs.fCantSplit;
1423     fTableHeader=rhs.fTableHeader;
1424     tlp=rhs.tlp;
1425     fCaFull=rhs.fCaFull;
1426     fFirstRow=rhs.fFirstRow;
1427     fLastRow=rhs.fLastRow;
1428     fOutline=rhs.fOutline;
1429     unused12_4=rhs.unused12_4;
1430     itcMac=rhs.itcMac;
1431     dxaAdjust=rhs.dxaAdjust;
1432     rgdxaCenter=new U16[itcMac + 1];
1433     memcpy(rgdxaCenter, rhs.rgdxaCenter, sizeof(U16)*(itcMac + 1));
1434     rgtc=new TC[itcMac];
1435     memcpy(rgtc, rhs.rgtc, sizeof(TC)*(itcMac));
1436     rgshd=new SHD[itcMac];
1437     memcpy(rgshd, rhs.rgshd, sizeof(SHD)*(itcMac));
1438     memcpy(&rgbrcTable, &rhs.rgbrcTable, sizeof(rgbrcTable));
1439 }
1440 
~TAP()1441 TAP::~TAP() {
1442     delete [] rgdxaCenter;
1443     delete [] rgtc;
1444     delete [] rgshd;
1445 }
1446 
operator =(const TAP & rhs)1447 TAP &TAP::operator=(const TAP &rhs) {
1448 
1449     // Check for assignment to self
1450     if(this==&rhs)
1451         return *this;
1452 
1453     jc=rhs.jc;
1454     dxaGapHalf=rhs.dxaGapHalf;
1455     dyaRowHeight=rhs.dyaRowHeight;
1456     fCantSplit=rhs.fCantSplit;
1457     fTableHeader=rhs.fTableHeader;
1458     tlp=rhs.tlp;
1459     fCaFull=rhs.fCaFull;
1460     fFirstRow=rhs.fFirstRow;
1461     fLastRow=rhs.fLastRow;
1462     fOutline=rhs.fOutline;
1463     unused12_4=rhs.unused12_4;
1464     itcMac=rhs.itcMac;
1465     dxaAdjust=rhs.dxaAdjust;
1466     delete [] rgdxaCenter;
1467     rgdxaCenter=new U16[itcMac + 1];
1468     memcpy(rgdxaCenter, rhs.rgdxaCenter, sizeof(U16)*(itcMac + 1));
1469     delete [] rgtc;
1470     rgtc=new TC[itcMac];
1471     memcpy(rgtc, rhs.rgtc, sizeof(TC)*(itcMac));
1472     delete [] rgshd;
1473     rgshd=new SHD[itcMac];
1474     memcpy(rgshd, rhs.rgshd, sizeof(SHD)*(itcMac));
1475     memcpy(&rgbrcTable, &rhs.rgbrcTable, sizeof(rgbrcTable));
1476 
1477     return *this;
1478 }
1479 
read(OLEStreamReader * stream,bool preservePos)1480 bool TAP::read(OLEStreamReader *stream, bool preservePos) {
1481 
1482     U16 shifterU16;
1483 
1484     if(preservePos)
1485         stream->push();
1486 
1487     jc=stream->readU16();
1488     dxaGapHalf=stream->readU16();
1489     dyaRowHeight=stream->readU16();
1490     fCantSplit=stream->readU8();
1491     fTableHeader=stream->readU8();
1492     tlp.read(stream, false);
1493     shifterU16=stream->readU16();
1494     fCaFull=shifterU16;
1495     shifterU16>>=1;
1496     fFirstRow=shifterU16;
1497     shifterU16>>=1;
1498     fLastRow=shifterU16;
1499     shifterU16>>=1;
1500     fOutline=shifterU16;
1501     shifterU16>>=1;
1502     unused12_4=shifterU16;
1503     itcMac=stream->readU16();
1504     dxaAdjust=stream->readU16();
1505     rgdxaCenter=new U16[itcMac + 1];
1506     for(int _i=0; _i<(itcMac + 1); ++_i)
1507         rgdxaCenter[_i]=stream->readU16();
1508     rgtc=new TC[itcMac];
1509     for(int _i=0; _i<(itcMac); ++_i)
1510         rgtc[_i].read(stream, false);
1511     rgshd=new SHD[itcMac];
1512     for(int _i=0; _i<(itcMac); ++_i)
1513         rgshd[_i].read(stream, false);
1514     for(int _i=0; _i<(6); ++_i)
1515         rgbrcTable[_i].read(stream, false);
1516 
1517     if(preservePos)
1518         stream->pop();
1519     return true;
1520 }
1521 
write(OLEStreamWriter * stream,bool preservePos) const1522 bool TAP::write(OLEStreamWriter *stream, bool preservePos) const {
1523 
1524     U16 shifterU16;
1525 
1526     if(preservePos)
1527         stream->push();
1528 
1529     stream->write(jc);
1530     stream->write(dxaGapHalf);
1531     stream->write(dyaRowHeight);
1532     stream->write(fCantSplit);
1533     stream->write(fTableHeader);
1534     tlp.write(stream, false);
1535     shifterU16=fCaFull;
1536     shifterU16|=fFirstRow << 1;
1537     shifterU16|=fLastRow << 2;
1538     shifterU16|=fOutline << 3;
1539     shifterU16|=unused12_4 << 4;
1540     stream->write(shifterU16);
1541     stream->write(itcMac);
1542     stream->write(dxaAdjust);
1543     for(int _i=0; _i<(itcMac + 1); ++_i)
1544         stream->write(rgdxaCenter[_i]);
1545     for(int _i=0; _i<(itcMac); ++_i)
1546         rgtc[_i].write(stream, false);
1547     for(int _i=0; _i<(itcMac); ++_i)
1548         rgshd[_i].write(stream, false);
1549     for(int _i=0; _i<(6); ++_i)
1550         rgbrcTable[_i].write(stream, false);
1551 
1552     if(preservePos)
1553         stream->pop();
1554     return true;
1555 }
1556 
clear()1557 void TAP::clear() {
1558     delete [] rgdxaCenter;
1559     delete [] rgtc;
1560     delete [] rgshd;
1561     clearInternal();
1562 }
1563 
dump() const1564 void TAP::dump() const
1565 {
1566     wvlog << "Dumping TAP:" << std::endl;
1567     wvlog << toString().c_str() << std::endl;
1568     wvlog << "\nDumping TAP done." << std::endl;
1569 }
1570 
toString() const1571 std::string TAP::toString() const
1572 {
1573     std::string s( "TAP:" );
1574     s += "\njc=";
1575     s += uint2string( jc );
1576     s += "\ndxaGapHalf=";
1577     s += uint2string( dxaGapHalf );
1578     s += "\ndyaRowHeight=";
1579     s += uint2string( dyaRowHeight );
1580     s += "\nfCantSplit=";
1581     s += uint2string( fCantSplit );
1582     s += "\nfTableHeader=";
1583     s += uint2string( fTableHeader );
1584     s += "\ntlp=";
1585     s += "\n{" + tlp.toString() + "}\n";
1586     s += "\nfCaFull=";
1587     s += uint2string( fCaFull );
1588     s += "\nfFirstRow=";
1589     s += uint2string( fFirstRow );
1590     s += "\nfLastRow=";
1591     s += uint2string( fLastRow );
1592     s += "\nfOutline=";
1593     s += uint2string( fOutline );
1594     s += "\nunused12_4=";
1595     s += uint2string( unused12_4 );
1596     s += "\nitcMac=";
1597     s += uint2string( itcMac );
1598     s += "\ndxaAdjust=";
1599     s += uint2string( dxaAdjust );
1600     for(int _i=0; _i<(itcMac + 1); ++_i) {
1601         s += "\nrgdxaCenter[" + int2string( _i ) + "]=";
1602     s += uint2string( rgdxaCenter[_i] );
1603     }
1604     for(int _i=0; _i<(itcMac); ++_i) {
1605         s += "\nrgtc[" + int2string( _i ) + "]=";
1606     s += "\n{" + rgtc[_i].toString() + "}\n";
1607     }
1608     for(int _i=0; _i<(itcMac); ++_i) {
1609         s += "\nrgshd[" + int2string( _i ) + "]=";
1610     s += "\n{" + rgshd[_i].toString() + "}\n";
1611     }
1612     for(int _i=0; _i<(6); ++_i) {
1613         s += "\nrgbrcTable[" + int2string( _i ) + "]=";
1614     s += "\n{" + rgbrcTable[_i].toString() + "}\n";
1615     }
1616     s += "\nTAP Done.";
1617     return s;
1618 }
1619 
clearInternal()1620 void TAP::clearInternal() {
1621     jc=0;
1622     dxaGapHalf=0;
1623     dyaRowHeight=0;
1624     fCantSplit=0;
1625     fTableHeader=0;
1626     tlp.clear();
1627     fCaFull=0;
1628     fFirstRow=0;
1629     fLastRow=0;
1630     fOutline=0;
1631     unused12_4=0;
1632     itcMac=0;
1633     dxaAdjust=0;
1634     rgdxaCenter=0;
1635     rgtc=0;
1636     rgshd=0;
1637     for(int _i=0; _i<(6); ++_i)
1638         rgbrcTable[_i].clear();
1639 }
1640 
operator ==(const TAP & lhs,const TAP & rhs)1641 bool operator==(const TAP &lhs, const TAP &rhs) {
1642 
1643     if((lhs.itcMac)!=(rhs.itcMac))
1644         return false;
1645     for(int _i=0; _i<(lhs.itcMac); ++_i) {
1646         if(lhs.rgdxaCenter[_i]!=rhs.rgdxaCenter[_i])
1647             return false;
1648     }
1649 
1650     if((lhs.itcMac)!=(rhs.itcMac))
1651         return false;
1652     for(int _i=0; _i<(lhs.itcMac); ++_i) {
1653         if(lhs.rgtc[_i]!=rhs.rgtc[_i])
1654             return false;
1655     }
1656 
1657     if((lhs.itcMac)!=(rhs.itcMac))
1658         return false;
1659     for(int _i=0; _i<(lhs.itcMac); ++_i) {
1660         if(lhs.rgshd[_i]!=rhs.rgshd[_i])
1661             return false;
1662     }
1663 
1664     for(int _i=0; _i<(6); ++_i) {
1665         if(lhs.rgbrcTable[_i]!=rhs.rgbrcTable[_i])
1666             return false;
1667     }
1668 
1669     return lhs.jc==rhs.jc &&
1670            lhs.dxaGapHalf==rhs.dxaGapHalf &&
1671            lhs.dyaRowHeight==rhs.dyaRowHeight &&
1672            lhs.fCantSplit==rhs.fCantSplit &&
1673            lhs.fTableHeader==rhs.fTableHeader &&
1674            lhs.tlp==rhs.tlp &&
1675            lhs.fCaFull==rhs.fCaFull &&
1676            lhs.fFirstRow==rhs.fFirstRow &&
1677            lhs.fLastRow==rhs.fLastRow &&
1678            lhs.fOutline==rhs.fOutline &&
1679            lhs.unused12_4==rhs.unused12_4 &&
1680            lhs.itcMac==rhs.itcMac &&
1681            lhs.dxaAdjust==rhs.dxaAdjust;
1682 }
1683 
operator !=(const TAP & lhs,const TAP & rhs)1684 bool operator!=(const TAP &lhs, const TAP &rhs) {
1685     return !(lhs==rhs);
1686 }
1687 
1688 
1689 // ANLD implementation
1690 
ANLD()1691 ANLD::ANLD() {
1692     clear();
1693 }
1694 
ANLD(OLEStreamReader * stream,bool preservePos)1695 ANLD::ANLD(OLEStreamReader *stream, bool preservePos) {
1696     clear();
1697     read(stream, preservePos);
1698 }
1699 
ANLD(const U8 * ptr)1700 ANLD::ANLD(const U8 *ptr) {
1701     clear();
1702     readPtr(ptr);
1703 }
1704 
read(OLEStreamReader * stream,bool preservePos)1705 bool ANLD::read(OLEStreamReader *stream, bool preservePos) {
1706 
1707     U8 shifterU8;
1708 
1709     if(preservePos)
1710         stream->push();
1711 
1712     nfc=stream->readU8();
1713     cxchTextBefore=stream->readU8();
1714     cxchTextAfter=stream->readU8();
1715     shifterU8=stream->readU8();
1716     jc=shifterU8;
1717     shifterU8>>=2;
1718     fPrev=shifterU8;
1719     shifterU8>>=1;
1720     fHang=shifterU8;
1721     shifterU8>>=1;
1722     fSetBold=shifterU8;
1723     shifterU8>>=1;
1724     fSetItalic=shifterU8;
1725     shifterU8>>=1;
1726     fSetSmallCaps=shifterU8;
1727     shifterU8>>=1;
1728     fSetCaps=shifterU8;
1729     shifterU8=stream->readU8();
1730     fSetStrike=shifterU8;
1731     shifterU8>>=1;
1732     fSetKul=shifterU8;
1733     shifterU8>>=1;
1734     fPrevSpace=shifterU8;
1735     shifterU8>>=1;
1736     fBold=shifterU8;
1737     shifterU8>>=1;
1738     fItalic=shifterU8;
1739     shifterU8>>=1;
1740     fSmallCaps=shifterU8;
1741     shifterU8>>=1;
1742     fCaps=shifterU8;
1743     shifterU8>>=1;
1744     fStrike=shifterU8;
1745     shifterU8=stream->readU8();
1746     kul=shifterU8;
1747     shifterU8>>=3;
1748     ico=shifterU8;
1749     ftc=stream->readS16();
1750     hps=stream->readU16();
1751     iStartAt=stream->readU16();
1752     dxaIndent=stream->readU16();
1753     dxaSpace=stream->readU16();
1754     fNumber1=stream->readU8();
1755     fNumberAcross=stream->readU8();
1756     fRestartHdn=stream->readU8();
1757     fSpareX=stream->readU8();
1758     for(int _i=0; _i<(32); ++_i)
1759         rgchAnld[_i]=stream->readU8();
1760 
1761     if(preservePos)
1762         stream->pop();
1763     return true;
1764 }
1765 
readPtr(const U8 * ptr)1766 void ANLD::readPtr(const U8 *ptr) {
1767 
1768     U8 shifterU8;
1769 
1770     nfc=readU8(ptr);
1771     ptr+=sizeof(U8);
1772     cxchTextBefore=readU8(ptr);
1773     ptr+=sizeof(U8);
1774     cxchTextAfter=readU8(ptr);
1775     ptr+=sizeof(U8);
1776     shifterU8=readU8(ptr);
1777     ptr+=sizeof(U8);
1778     jc=shifterU8;
1779     shifterU8>>=2;
1780     fPrev=shifterU8;
1781     shifterU8>>=1;
1782     fHang=shifterU8;
1783     shifterU8>>=1;
1784     fSetBold=shifterU8;
1785     shifterU8>>=1;
1786     fSetItalic=shifterU8;
1787     shifterU8>>=1;
1788     fSetSmallCaps=shifterU8;
1789     shifterU8>>=1;
1790     fSetCaps=shifterU8;
1791     shifterU8=readU8(ptr);
1792     ptr+=sizeof(U8);
1793     fSetStrike=shifterU8;
1794     shifterU8>>=1;
1795     fSetKul=shifterU8;
1796     shifterU8>>=1;
1797     fPrevSpace=shifterU8;
1798     shifterU8>>=1;
1799     fBold=shifterU8;
1800     shifterU8>>=1;
1801     fItalic=shifterU8;
1802     shifterU8>>=1;
1803     fSmallCaps=shifterU8;
1804     shifterU8>>=1;
1805     fCaps=shifterU8;
1806     shifterU8>>=1;
1807     fStrike=shifterU8;
1808     shifterU8=readU8(ptr);
1809     ptr+=sizeof(U8);
1810     kul=shifterU8;
1811     shifterU8>>=3;
1812     ico=shifterU8;
1813     ftc=readS16(ptr);
1814     ptr+=sizeof(S16);
1815     hps=readU16(ptr);
1816     ptr+=sizeof(U16);
1817     iStartAt=readU16(ptr);
1818     ptr+=sizeof(U16);
1819     dxaIndent=readU16(ptr);
1820     ptr+=sizeof(U16);
1821     dxaSpace=readU16(ptr);
1822     ptr+=sizeof(U16);
1823     fNumber1=readU8(ptr);
1824     ptr+=sizeof(U8);
1825     fNumberAcross=readU8(ptr);
1826     ptr+=sizeof(U8);
1827     fRestartHdn=readU8(ptr);
1828     ptr+=sizeof(U8);
1829     fSpareX=readU8(ptr);
1830     ptr+=sizeof(U8);
1831     for(int _i=0; _i<(32); ++_i) {
1832         rgchAnld[_i]=readU8(ptr);
1833         ptr+=sizeof(U8);
1834     }
1835 }
1836 
write(OLEStreamWriter * stream,bool preservePos) const1837 bool ANLD::write(OLEStreamWriter *stream, bool preservePos) const {
1838 
1839     U8 shifterU8;
1840 
1841     if(preservePos)
1842         stream->push();
1843 
1844     stream->write(nfc);
1845     stream->write(cxchTextBefore);
1846     stream->write(cxchTextAfter);
1847     shifterU8=jc;
1848     shifterU8|=fPrev << 2;
1849     shifterU8|=fHang << 3;
1850     shifterU8|=fSetBold << 4;
1851     shifterU8|=fSetItalic << 5;
1852     shifterU8|=fSetSmallCaps << 6;
1853     shifterU8|=fSetCaps << 7;
1854     stream->write(shifterU8);
1855     shifterU8=fSetStrike;
1856     shifterU8|=fSetKul << 1;
1857     shifterU8|=fPrevSpace << 2;
1858     shifterU8|=fBold << 3;
1859     shifterU8|=fItalic << 4;
1860     shifterU8|=fSmallCaps << 5;
1861     shifterU8|=fCaps << 6;
1862     shifterU8|=fStrike << 7;
1863     stream->write(shifterU8);
1864     shifterU8=kul;
1865     shifterU8|=ico << 3;
1866     stream->write(shifterU8);
1867     stream->write(ftc);
1868     stream->write(hps);
1869     stream->write(iStartAt);
1870     stream->write(dxaIndent);
1871     stream->write(dxaSpace);
1872     stream->write(fNumber1);
1873     stream->write(fNumberAcross);
1874     stream->write(fRestartHdn);
1875     stream->write(fSpareX);
1876     for(int _i=0; _i<(32); ++_i)
1877         stream->write(rgchAnld[_i]);
1878 
1879     if(preservePos)
1880         stream->pop();
1881     return true;
1882 }
1883 
clear()1884 void ANLD::clear() {
1885     nfc=0;
1886     cxchTextBefore=0;
1887     cxchTextAfter=0;
1888     jc=0;
1889     fPrev=0;
1890     fHang=0;
1891     fSetBold=0;
1892     fSetItalic=0;
1893     fSetSmallCaps=0;
1894     fSetCaps=0;
1895     fSetStrike=0;
1896     fSetKul=0;
1897     fPrevSpace=0;
1898     fBold=0;
1899     fItalic=0;
1900     fSmallCaps=0;
1901     fCaps=0;
1902     fStrike=0;
1903     kul=0;
1904     ico=0;
1905     ftc=0;
1906     hps=0;
1907     iStartAt=0;
1908     dxaIndent=0;
1909     dxaSpace=0;
1910     fNumber1=0;
1911     fNumberAcross=0;
1912     fRestartHdn=0;
1913     fSpareX=0;
1914     for(int _i=0; _i<(32); ++_i)
1915         rgchAnld[_i]=0;
1916 }
1917 
dump() const1918 void ANLD::dump() const
1919 {
1920     wvlog << "Dumping ANLD:" << std::endl;
1921     wvlog << toString().c_str() << std::endl;
1922     wvlog << "\nDumping ANLD done." << std::endl;
1923 }
1924 
toString() const1925 std::string ANLD::toString() const
1926 {
1927     std::string s( "ANLD:" );
1928     s += "\nnfc=";
1929     s += uint2string( nfc );
1930     s += "\ncxchTextBefore=";
1931     s += uint2string( cxchTextBefore );
1932     s += "\ncxchTextAfter=";
1933     s += uint2string( cxchTextAfter );
1934     s += "\njc=";
1935     s += uint2string( jc );
1936     s += "\nfPrev=";
1937     s += uint2string( fPrev );
1938     s += "\nfHang=";
1939     s += uint2string( fHang );
1940     s += "\nfSetBold=";
1941     s += uint2string( fSetBold );
1942     s += "\nfSetItalic=";
1943     s += uint2string( fSetItalic );
1944     s += "\nfSetSmallCaps=";
1945     s += uint2string( fSetSmallCaps );
1946     s += "\nfSetCaps=";
1947     s += uint2string( fSetCaps );
1948     s += "\nfSetStrike=";
1949     s += uint2string( fSetStrike );
1950     s += "\nfSetKul=";
1951     s += uint2string( fSetKul );
1952     s += "\nfPrevSpace=";
1953     s += uint2string( fPrevSpace );
1954     s += "\nfBold=";
1955     s += uint2string( fBold );
1956     s += "\nfItalic=";
1957     s += uint2string( fItalic );
1958     s += "\nfSmallCaps=";
1959     s += uint2string( fSmallCaps );
1960     s += "\nfCaps=";
1961     s += uint2string( fCaps );
1962     s += "\nfStrike=";
1963     s += uint2string( fStrike );
1964     s += "\nkul=";
1965     s += uint2string( kul );
1966     s += "\nico=";
1967     s += uint2string( ico );
1968     s += "\nftc=";
1969     s += int2string( ftc );
1970     s += "\nhps=";
1971     s += uint2string( hps );
1972     s += "\niStartAt=";
1973     s += uint2string( iStartAt );
1974     s += "\ndxaIndent=";
1975     s += uint2string( dxaIndent );
1976     s += "\ndxaSpace=";
1977     s += uint2string( dxaSpace );
1978     s += "\nfNumber1=";
1979     s += uint2string( fNumber1 );
1980     s += "\nfNumberAcross=";
1981     s += uint2string( fNumberAcross );
1982     s += "\nfRestartHdn=";
1983     s += uint2string( fRestartHdn );
1984     s += "\nfSpareX=";
1985     s += uint2string( fSpareX );
1986     for(int _i=0; _i<(32); ++_i) {
1987         s += "\nrgchAnld[" + int2string( _i ) + "]=";
1988     s += uint2string( rgchAnld[_i] );
1989     }
1990     s += "\nANLD Done.";
1991     return s;
1992 }
1993 
operator ==(const ANLD & lhs,const ANLD & rhs)1994 bool operator==(const ANLD &lhs, const ANLD &rhs) {
1995 
1996     for(int _i=0; _i<(32); ++_i) {
1997         if(lhs.rgchAnld[_i]!=rhs.rgchAnld[_i])
1998             return false;
1999     }
2000 
2001     return lhs.nfc==rhs.nfc &&
2002            lhs.cxchTextBefore==rhs.cxchTextBefore &&
2003            lhs.cxchTextAfter==rhs.cxchTextAfter &&
2004            lhs.jc==rhs.jc &&
2005            lhs.fPrev==rhs.fPrev &&
2006            lhs.fHang==rhs.fHang &&
2007            lhs.fSetBold==rhs.fSetBold &&
2008            lhs.fSetItalic==rhs.fSetItalic &&
2009            lhs.fSetSmallCaps==rhs.fSetSmallCaps &&
2010            lhs.fSetCaps==rhs.fSetCaps &&
2011            lhs.fSetStrike==rhs.fSetStrike &&
2012            lhs.fSetKul==rhs.fSetKul &&
2013            lhs.fPrevSpace==rhs.fPrevSpace &&
2014            lhs.fBold==rhs.fBold &&
2015            lhs.fItalic==rhs.fItalic &&
2016            lhs.fSmallCaps==rhs.fSmallCaps &&
2017            lhs.fCaps==rhs.fCaps &&
2018            lhs.fStrike==rhs.fStrike &&
2019            lhs.kul==rhs.kul &&
2020            lhs.ico==rhs.ico &&
2021            lhs.ftc==rhs.ftc &&
2022            lhs.hps==rhs.hps &&
2023            lhs.iStartAt==rhs.iStartAt &&
2024            lhs.dxaIndent==rhs.dxaIndent &&
2025            lhs.dxaSpace==rhs.dxaSpace &&
2026            lhs.fNumber1==rhs.fNumber1 &&
2027            lhs.fNumberAcross==rhs.fNumberAcross &&
2028            lhs.fRestartHdn==rhs.fRestartHdn &&
2029            lhs.fSpareX==rhs.fSpareX;
2030 }
2031 
operator !=(const ANLD & lhs,const ANLD & rhs)2032 bool operator!=(const ANLD &lhs, const ANLD &rhs) {
2033     return !(lhs==rhs);
2034 }
2035 
2036 
2037 // ANLV implementation
2038 
2039 const unsigned int ANLV::sizeOf = 16;
2040 
ANLV()2041 ANLV::ANLV() {
2042     clear();
2043 }
2044 
ANLV(OLEStreamReader * stream,bool preservePos)2045 ANLV::ANLV(OLEStreamReader *stream, bool preservePos) {
2046     clear();
2047     read(stream, preservePos);
2048 }
2049 
ANLV(const U8 * ptr)2050 ANLV::ANLV(const U8 *ptr) {
2051     clear();
2052     readPtr(ptr);
2053 }
2054 
read(OLEStreamReader * stream,bool preservePos)2055 bool ANLV::read(OLEStreamReader *stream, bool preservePos) {
2056 
2057     U8 shifterU8;
2058 
2059     if(preservePos)
2060         stream->push();
2061 
2062     nfc=stream->readU8();
2063     cxchTextBefore=stream->readU8();
2064     cxchTextAfter=stream->readU8();
2065     shifterU8=stream->readU8();
2066     jc=shifterU8;
2067     shifterU8>>=2;
2068     fPrev=shifterU8;
2069     shifterU8>>=1;
2070     fHang=shifterU8;
2071     shifterU8>>=1;
2072     fSetBold=shifterU8;
2073     shifterU8>>=1;
2074     fSetItalic=shifterU8;
2075     shifterU8>>=1;
2076     fSetSmallCaps=shifterU8;
2077     shifterU8>>=1;
2078     fSetCaps=shifterU8;
2079     shifterU8=stream->readU8();
2080     fSetStrike=shifterU8;
2081     shifterU8>>=1;
2082     fSetKul=shifterU8;
2083     shifterU8>>=1;
2084     fPrevSpace=shifterU8;
2085     shifterU8>>=1;
2086     fBold=shifterU8;
2087     shifterU8>>=1;
2088     fItalic=shifterU8;
2089     shifterU8>>=1;
2090     fSmallCaps=shifterU8;
2091     shifterU8>>=1;
2092     fCaps=shifterU8;
2093     shifterU8>>=1;
2094     fStrike=shifterU8;
2095     shifterU8=stream->readU8();
2096     kul=shifterU8;
2097     shifterU8>>=3;
2098     ico=shifterU8;
2099     ftc=stream->readS16();
2100     hps=stream->readU16();
2101     iStartAt=stream->readU16();
2102     dxaIndent=stream->readU16();
2103     dxaSpace=stream->readU16();
2104 
2105     if(preservePos)
2106         stream->pop();
2107     return true;
2108 }
2109 
readPtr(const U8 * ptr)2110 void ANLV::readPtr(const U8 *ptr) {
2111 
2112     U8 shifterU8;
2113 
2114     nfc=readU8(ptr);
2115     ptr+=sizeof(U8);
2116     cxchTextBefore=readU8(ptr);
2117     ptr+=sizeof(U8);
2118     cxchTextAfter=readU8(ptr);
2119     ptr+=sizeof(U8);
2120     shifterU8=readU8(ptr);
2121     ptr+=sizeof(U8);
2122     jc=shifterU8;
2123     shifterU8>>=2;
2124     fPrev=shifterU8;
2125     shifterU8>>=1;
2126     fHang=shifterU8;
2127     shifterU8>>=1;
2128     fSetBold=shifterU8;
2129     shifterU8>>=1;
2130     fSetItalic=shifterU8;
2131     shifterU8>>=1;
2132     fSetSmallCaps=shifterU8;
2133     shifterU8>>=1;
2134     fSetCaps=shifterU8;
2135     shifterU8=readU8(ptr);
2136     ptr+=sizeof(U8);
2137     fSetStrike=shifterU8;
2138     shifterU8>>=1;
2139     fSetKul=shifterU8;
2140     shifterU8>>=1;
2141     fPrevSpace=shifterU8;
2142     shifterU8>>=1;
2143     fBold=shifterU8;
2144     shifterU8>>=1;
2145     fItalic=shifterU8;
2146     shifterU8>>=1;
2147     fSmallCaps=shifterU8;
2148     shifterU8>>=1;
2149     fCaps=shifterU8;
2150     shifterU8>>=1;
2151     fStrike=shifterU8;
2152     shifterU8=readU8(ptr);
2153     ptr+=sizeof(U8);
2154     kul=shifterU8;
2155     shifterU8>>=3;
2156     ico=shifterU8;
2157     ftc=readS16(ptr);
2158     ptr+=sizeof(S16);
2159     hps=readU16(ptr);
2160     ptr+=sizeof(U16);
2161     iStartAt=readU16(ptr);
2162     ptr+=sizeof(U16);
2163     dxaIndent=readU16(ptr);
2164     ptr+=sizeof(U16);
2165     dxaSpace=readU16(ptr);
2166     ptr+=sizeof(U16);
2167 }
2168 
write(OLEStreamWriter * stream,bool preservePos) const2169 bool ANLV::write(OLEStreamWriter *stream, bool preservePos) const {
2170 
2171     U8 shifterU8;
2172 
2173     if(preservePos)
2174         stream->push();
2175 
2176     stream->write(nfc);
2177     stream->write(cxchTextBefore);
2178     stream->write(cxchTextAfter);
2179     shifterU8=jc;
2180     shifterU8|=fPrev << 2;
2181     shifterU8|=fHang << 3;
2182     shifterU8|=fSetBold << 4;
2183     shifterU8|=fSetItalic << 5;
2184     shifterU8|=fSetSmallCaps << 6;
2185     shifterU8|=fSetCaps << 7;
2186     stream->write(shifterU8);
2187     shifterU8=fSetStrike;
2188     shifterU8|=fSetKul << 1;
2189     shifterU8|=fPrevSpace << 2;
2190     shifterU8|=fBold << 3;
2191     shifterU8|=fItalic << 4;
2192     shifterU8|=fSmallCaps << 5;
2193     shifterU8|=fCaps << 6;
2194     shifterU8|=fStrike << 7;
2195     stream->write(shifterU8);
2196     shifterU8=kul;
2197     shifterU8|=ico << 3;
2198     stream->write(shifterU8);
2199     stream->write(ftc);
2200     stream->write(hps);
2201     stream->write(iStartAt);
2202     stream->write(dxaIndent);
2203     stream->write(dxaSpace);
2204 
2205     if(preservePos)
2206         stream->pop();
2207     return true;
2208 }
2209 
clear()2210 void ANLV::clear() {
2211     nfc=0;
2212     cxchTextBefore=0;
2213     cxchTextAfter=0;
2214     jc=0;
2215     fPrev=0;
2216     fHang=0;
2217     fSetBold=0;
2218     fSetItalic=0;
2219     fSetSmallCaps=0;
2220     fSetCaps=0;
2221     fSetStrike=0;
2222     fSetKul=0;
2223     fPrevSpace=0;
2224     fBold=0;
2225     fItalic=0;
2226     fSmallCaps=0;
2227     fCaps=0;
2228     fStrike=0;
2229     kul=0;
2230     ico=0;
2231     ftc=0;
2232     hps=0;
2233     iStartAt=0;
2234     dxaIndent=0;
2235     dxaSpace=0;
2236 }
2237 
dump() const2238 void ANLV::dump() const
2239 {
2240     wvlog << "Dumping ANLV:" << std::endl;
2241     wvlog << toString().c_str() << std::endl;
2242     wvlog << "\nDumping ANLV done." << std::endl;
2243 }
2244 
toString() const2245 std::string ANLV::toString() const
2246 {
2247     std::string s( "ANLV:" );
2248     s += "\nnfc=";
2249     s += uint2string( nfc );
2250     s += "\ncxchTextBefore=";
2251     s += uint2string( cxchTextBefore );
2252     s += "\ncxchTextAfter=";
2253     s += uint2string( cxchTextAfter );
2254     s += "\njc=";
2255     s += uint2string( jc );
2256     s += "\nfPrev=";
2257     s += uint2string( fPrev );
2258     s += "\nfHang=";
2259     s += uint2string( fHang );
2260     s += "\nfSetBold=";
2261     s += uint2string( fSetBold );
2262     s += "\nfSetItalic=";
2263     s += uint2string( fSetItalic );
2264     s += "\nfSetSmallCaps=";
2265     s += uint2string( fSetSmallCaps );
2266     s += "\nfSetCaps=";
2267     s += uint2string( fSetCaps );
2268     s += "\nfSetStrike=";
2269     s += uint2string( fSetStrike );
2270     s += "\nfSetKul=";
2271     s += uint2string( fSetKul );
2272     s += "\nfPrevSpace=";
2273     s += uint2string( fPrevSpace );
2274     s += "\nfBold=";
2275     s += uint2string( fBold );
2276     s += "\nfItalic=";
2277     s += uint2string( fItalic );
2278     s += "\nfSmallCaps=";
2279     s += uint2string( fSmallCaps );
2280     s += "\nfCaps=";
2281     s += uint2string( fCaps );
2282     s += "\nfStrike=";
2283     s += uint2string( fStrike );
2284     s += "\nkul=";
2285     s += uint2string( kul );
2286     s += "\nico=";
2287     s += uint2string( ico );
2288     s += "\nftc=";
2289     s += int2string( ftc );
2290     s += "\nhps=";
2291     s += uint2string( hps );
2292     s += "\niStartAt=";
2293     s += uint2string( iStartAt );
2294     s += "\ndxaIndent=";
2295     s += uint2string( dxaIndent );
2296     s += "\ndxaSpace=";
2297     s += uint2string( dxaSpace );
2298     s += "\nANLV Done.";
2299     return s;
2300 }
2301 
operator ==(const ANLV & lhs,const ANLV & rhs)2302 bool operator==(const ANLV &lhs, const ANLV &rhs) {
2303 
2304     return lhs.nfc==rhs.nfc &&
2305            lhs.cxchTextBefore==rhs.cxchTextBefore &&
2306            lhs.cxchTextAfter==rhs.cxchTextAfter &&
2307            lhs.jc==rhs.jc &&
2308            lhs.fPrev==rhs.fPrev &&
2309            lhs.fHang==rhs.fHang &&
2310            lhs.fSetBold==rhs.fSetBold &&
2311            lhs.fSetItalic==rhs.fSetItalic &&
2312            lhs.fSetSmallCaps==rhs.fSetSmallCaps &&
2313            lhs.fSetCaps==rhs.fSetCaps &&
2314            lhs.fSetStrike==rhs.fSetStrike &&
2315            lhs.fSetKul==rhs.fSetKul &&
2316            lhs.fPrevSpace==rhs.fPrevSpace &&
2317            lhs.fBold==rhs.fBold &&
2318            lhs.fItalic==rhs.fItalic &&
2319            lhs.fSmallCaps==rhs.fSmallCaps &&
2320            lhs.fCaps==rhs.fCaps &&
2321            lhs.fStrike==rhs.fStrike &&
2322            lhs.kul==rhs.kul &&
2323            lhs.ico==rhs.ico &&
2324            lhs.ftc==rhs.ftc &&
2325            lhs.hps==rhs.hps &&
2326            lhs.iStartAt==rhs.iStartAt &&
2327            lhs.dxaIndent==rhs.dxaIndent &&
2328            lhs.dxaSpace==rhs.dxaSpace;
2329 }
2330 
operator !=(const ANLV & lhs,const ANLV & rhs)2331 bool operator!=(const ANLV &lhs, const ANLV &rhs) {
2332     return !(lhs==rhs);
2333 }
2334 
2335 
2336 // BKF implementation
2337 
BKF()2338 BKF::BKF() {
2339     clear();
2340 }
2341 
BKF(OLEStreamReader * stream,bool preservePos)2342 BKF::BKF(OLEStreamReader *stream, bool preservePos) {
2343     clear();
2344     read(stream, preservePos);
2345 }
2346 
read(OLEStreamReader * stream,bool preservePos)2347 bool BKF::read(OLEStreamReader *stream, bool preservePos) {
2348 
2349     U16 shifterU16;
2350 
2351     if(preservePos)
2352         stream->push();
2353 
2354     ibkl=stream->readS16();
2355     shifterU16=stream->readU16();
2356     itcFirst=shifterU16;
2357     shifterU16>>=7;
2358     fPub=shifterU16;
2359     shifterU16>>=1;
2360     itcLim=shifterU16;
2361     shifterU16>>=7;
2362     fCol=shifterU16;
2363 
2364     if(preservePos)
2365         stream->pop();
2366     return true;
2367 }
2368 
write(OLEStreamWriter * stream,bool preservePos) const2369 bool BKF::write(OLEStreamWriter *stream, bool preservePos) const {
2370 
2371     U16 shifterU16;
2372 
2373     if(preservePos)
2374         stream->push();
2375 
2376     stream->write(ibkl);
2377     shifterU16=itcFirst;
2378     shifterU16|=fPub << 7;
2379     shifterU16|=itcLim << 8;
2380     shifterU16|=fCol << 15;
2381     stream->write(shifterU16);
2382 
2383     if(preservePos)
2384         stream->pop();
2385     return true;
2386 }
2387 
clear()2388 void BKF::clear() {
2389     ibkl=0;
2390     itcFirst=0;
2391     fPub=0;
2392     itcLim=0;
2393     fCol=0;
2394 }
2395 
operator ==(const BKF & lhs,const BKF & rhs)2396 bool operator==(const BKF &lhs, const BKF &rhs) {
2397 
2398     return lhs.ibkl==rhs.ibkl &&
2399            lhs.itcFirst==rhs.itcFirst &&
2400            lhs.fPub==rhs.fPub &&
2401            lhs.itcLim==rhs.itcLim &&
2402            lhs.fCol==rhs.fCol;
2403 }
2404 
operator !=(const BKF & lhs,const BKF & rhs)2405 bool operator!=(const BKF &lhs, const BKF &rhs) {
2406     return !(lhs==rhs);
2407 }
2408 
2409 
2410 // BKL implementation
2411 
BKL()2412 BKL::BKL() {
2413     clear();
2414 }
2415 
BKL(OLEStreamReader * stream,bool preservePos)2416 BKL::BKL(OLEStreamReader *stream, bool preservePos) {
2417     clear();
2418     read(stream, preservePos);
2419 }
2420 
read(OLEStreamReader * stream,bool preservePos)2421 bool BKL::read(OLEStreamReader *stream, bool preservePos) {
2422 
2423     if(preservePos)
2424         stream->push();
2425 
2426     ibkf=stream->readS16();
2427 
2428     if(preservePos)
2429         stream->pop();
2430     return true;
2431 }
2432 
write(OLEStreamWriter * stream,bool preservePos) const2433 bool BKL::write(OLEStreamWriter *stream, bool preservePos) const {
2434 
2435     if(preservePos)
2436         stream->push();
2437 
2438     stream->write(ibkf);
2439 
2440     if(preservePos)
2441         stream->pop();
2442     return true;
2443 }
2444 
clear()2445 void BKL::clear() {
2446     ibkf=0;
2447 }
2448 
operator ==(const BKL & lhs,const BKL & rhs)2449 bool operator==(const BKL &lhs, const BKL &rhs) {
2450 
2451     return lhs.ibkf==rhs.ibkf;
2452 }
2453 
operator !=(const BKL & lhs,const BKL & rhs)2454 bool operator!=(const BKL &lhs, const BKL &rhs) {
2455     return !(lhs==rhs);
2456 }
2457 
2458 
2459 // BRC10 implementation
2460 
BRC10()2461 BRC10::BRC10() {
2462     clear();
2463 }
2464 
BRC10(OLEStreamReader * stream,bool preservePos)2465 BRC10::BRC10(OLEStreamReader *stream, bool preservePos) {
2466     clear();
2467     read(stream, preservePos);
2468 }
2469 
read(OLEStreamReader * stream,bool preservePos)2470 bool BRC10::read(OLEStreamReader *stream, bool preservePos) {
2471 
2472     U16 shifterU16;
2473 
2474     if(preservePos)
2475         stream->push();
2476 
2477     shifterU16=stream->readU16();
2478     dxpLine2Width=shifterU16;
2479     shifterU16>>=3;
2480     dxpSpaceBetween=shifterU16;
2481     shifterU16>>=3;
2482     dxpLine1Width=shifterU16;
2483     shifterU16>>=3;
2484     dxpSpace=shifterU16;
2485     shifterU16>>=5;
2486     fShadow=shifterU16;
2487     shifterU16>>=1;
2488     fSpare=shifterU16;
2489 
2490     if(preservePos)
2491         stream->pop();
2492     return true;
2493 }
2494 
write(OLEStreamWriter * stream,bool preservePos) const2495 bool BRC10::write(OLEStreamWriter *stream, bool preservePos) const {
2496 
2497     U16 shifterU16;
2498 
2499     if(preservePos)
2500         stream->push();
2501 
2502     shifterU16=dxpLine2Width;
2503     shifterU16|=dxpSpaceBetween << 3;
2504     shifterU16|=dxpLine1Width << 6;
2505     shifterU16|=dxpSpace << 9;
2506     shifterU16|=fShadow << 14;
2507     shifterU16|=fSpare << 15;
2508     stream->write(shifterU16);
2509 
2510     if(preservePos)
2511         stream->pop();
2512     return true;
2513 }
2514 
clear()2515 void BRC10::clear() {
2516     dxpLine2Width=0;
2517     dxpSpaceBetween=0;
2518     dxpLine1Width=0;
2519     dxpSpace=0;
2520     fShadow=0;
2521     fSpare=0;
2522 }
2523 
operator ==(const BRC10 & lhs,const BRC10 & rhs)2524 bool operator==(const BRC10 &lhs, const BRC10 &rhs) {
2525 
2526     return lhs.dxpLine2Width==rhs.dxpLine2Width &&
2527            lhs.dxpSpaceBetween==rhs.dxpSpaceBetween &&
2528            lhs.dxpLine1Width==rhs.dxpLine1Width &&
2529            lhs.dxpSpace==rhs.dxpSpace &&
2530            lhs.fShadow==rhs.fShadow &&
2531            lhs.fSpare==rhs.fSpare;
2532 }
2533 
operator !=(const BRC10 & lhs,const BRC10 & rhs)2534 bool operator!=(const BRC10 &lhs, const BRC10 &rhs) {
2535     return !(lhs==rhs);
2536 }
2537 
2538 
2539 // BTE implementation
2540 
2541 const unsigned int BTE::sizeOf = 2;
2542 
BTE()2543 BTE::BTE() {
2544     clear();
2545 }
2546 
BTE(OLEStreamReader * stream,bool preservePos)2547 BTE::BTE(OLEStreamReader *stream, bool preservePos) {
2548     clear();
2549     read(stream, preservePos);
2550 }
2551 
read(OLEStreamReader * stream,bool preservePos)2552 bool BTE::read(OLEStreamReader *stream, bool preservePos) {
2553 
2554     if(preservePos)
2555         stream->push();
2556 
2557     pn=stream->readU16();
2558 
2559     if(preservePos)
2560         stream->pop();
2561     return true;
2562 }
2563 
write(OLEStreamWriter * stream,bool preservePos) const2564 bool BTE::write(OLEStreamWriter *stream, bool preservePos) const {
2565 
2566     if(preservePos)
2567         stream->push();
2568 
2569     stream->write(pn);
2570 
2571     if(preservePos)
2572         stream->pop();
2573     return true;
2574 }
2575 
clear()2576 void BTE::clear() {
2577     pn=0;
2578 }
2579 
operator ==(const BTE & lhs,const BTE & rhs)2580 bool operator==(const BTE &lhs, const BTE &rhs) {
2581 
2582     return lhs.pn==rhs.pn;
2583 }
2584 
operator !=(const BTE & lhs,const BTE & rhs)2585 bool operator!=(const BTE &lhs, const BTE &rhs) {
2586     return !(lhs==rhs);
2587 }
2588 
2589 
2590 // CHP implementation
2591 
CHP()2592 CHP::CHP() : Shared() {
2593     clear();
2594 }
2595 
CHP(OLEStreamReader * stream,bool preservePos)2596 CHP::CHP(OLEStreamReader *stream, bool preservePos) : Shared() {
2597     clear();
2598     read(stream, preservePos);
2599 }
2600 
read(OLEStreamReader * stream,bool preservePos)2601 bool CHP::read(OLEStreamReader *stream, bool preservePos) {
2602 
2603     U8 shifterU8;
2604 
2605     if(preservePos)
2606         stream->push();
2607 
2608     shifterU8=stream->readU8();
2609     fBold=shifterU8;
2610     shifterU8>>=1;
2611     fItalic=shifterU8;
2612     shifterU8>>=1;
2613     fRMarkDel=shifterU8;
2614     shifterU8>>=1;
2615     fOutline=shifterU8;
2616     shifterU8>>=1;
2617     fFldVanish=shifterU8;
2618     shifterU8>>=1;
2619     fSmallCaps=shifterU8;
2620     shifterU8>>=1;
2621     fCaps=shifterU8;
2622     shifterU8>>=1;
2623     fVanish=shifterU8;
2624     shifterU8=stream->readU8();
2625     fRMark=shifterU8;
2626     shifterU8>>=1;
2627     fSpec=shifterU8;
2628     shifterU8>>=1;
2629     fStrike=shifterU8;
2630     shifterU8>>=1;
2631     fObj=shifterU8;
2632     shifterU8>>=1;
2633     fShadow=shifterU8;
2634     shifterU8>>=1;
2635     fLowerCase=shifterU8;
2636     shifterU8>>=1;
2637     fData=shifterU8;
2638     shifterU8>>=1;
2639     fOle2=shifterU8;
2640     unused2=stream->readU16();
2641     ftc=stream->readU16();
2642     hps=stream->readU16();
2643     dxaSpace=stream->readU16();
2644     shifterU8=stream->readU8();
2645     iss=shifterU8;
2646     shifterU8>>=3;
2647     unused10_3=shifterU8;
2648     shifterU8>>=3;
2649     fSysVanish=shifterU8;
2650     shifterU8>>=1;
2651     unused10_7=shifterU8;
2652     shifterU8=stream->readU8();
2653     ico=shifterU8;
2654     shifterU8>>=5;
2655     kul=shifterU8;
2656     hpsPos=stream->readS16();
2657     lid=stream->readU16();
2658     fcPic_fcObj_lTagObj=stream->readU32();
2659     ibstRMark=stream->readU16();
2660     dttmRMark.read(stream, false);
2661     unused26=stream->readU16();
2662     istd=stream->readU16();
2663     ftcSym=stream->readU16();
2664     chSym=stream->readU8();
2665     fChsDiff=stream->readU8();
2666     idslRMReason=stream->readU16();
2667     ysr=stream->readU8();
2668     chYsr=stream->readU8();
2669     chse=stream->readU16();
2670     hpsKern=stream->readU16();
2671 
2672     if(preservePos)
2673         stream->pop();
2674     return true;
2675 }
2676 
write(OLEStreamWriter * stream,bool preservePos) const2677 bool CHP::write(OLEStreamWriter *stream, bool preservePos) const {
2678 
2679     U8 shifterU8;
2680 
2681     if(preservePos)
2682         stream->push();
2683 
2684     shifterU8=fBold;
2685     shifterU8|=fItalic << 1;
2686     shifterU8|=fRMarkDel << 2;
2687     shifterU8|=fOutline << 3;
2688     shifterU8|=fFldVanish << 4;
2689     shifterU8|=fSmallCaps << 5;
2690     shifterU8|=fCaps << 6;
2691     shifterU8|=fVanish << 7;
2692     stream->write(shifterU8);
2693     shifterU8=fRMark;
2694     shifterU8|=fSpec << 1;
2695     shifterU8|=fStrike << 2;
2696     shifterU8|=fObj << 3;
2697     shifterU8|=fShadow << 4;
2698     shifterU8|=fLowerCase << 5;
2699     shifterU8|=fData << 6;
2700     shifterU8|=fOle2 << 7;
2701     stream->write(shifterU8);
2702     stream->write(unused2);
2703     stream->write(ftc);
2704     stream->write(hps);
2705     stream->write(dxaSpace);
2706     shifterU8=iss;
2707     shifterU8|=unused10_3 << 3;
2708     shifterU8|=fSysVanish << 6;
2709     shifterU8|=unused10_7 << 7;
2710     stream->write(shifterU8);
2711     shifterU8=ico;
2712     shifterU8|=kul << 5;
2713     stream->write(shifterU8);
2714     stream->write(hpsPos);
2715     stream->write(lid);
2716     stream->write(fcPic_fcObj_lTagObj);
2717     stream->write(ibstRMark);
2718     dttmRMark.write(stream, false);
2719     stream->write(unused26);
2720     stream->write(istd);
2721     stream->write(ftcSym);
2722     stream->write(chSym);
2723     stream->write(fChsDiff);
2724     stream->write(idslRMReason);
2725     stream->write(ysr);
2726     stream->write(chYsr);
2727     stream->write(chse);
2728     stream->write(hpsKern);
2729 
2730     if(preservePos)
2731         stream->pop();
2732     return true;
2733 }
2734 
clear()2735 void CHP::clear() {
2736     fBold=0;
2737     fItalic=0;
2738     fRMarkDel=0;
2739     fOutline=0;
2740     fFldVanish=0;
2741     fSmallCaps=0;
2742     fCaps=0;
2743     fVanish=0;
2744     fRMark=0;
2745     fSpec=0;
2746     fStrike=0;
2747     fObj=0;
2748     fShadow=0;
2749     fLowerCase=0;
2750     fData=0;
2751     fOle2=0;
2752     unused2=0;
2753     ftc=0;
2754     hps=0;
2755     dxaSpace=0;
2756     iss=0;
2757     unused10_3=0;
2758     fSysVanish=0;
2759     unused10_7=0;
2760     ico=0;
2761     kul=0;
2762     hpsPos=0;
2763     lid=0;
2764     fcPic_fcObj_lTagObj=0;
2765     ibstRMark=0;
2766     dttmRMark.clear();
2767     unused26=0;
2768     istd=0;
2769     ftcSym=0;
2770     chSym=0;
2771     fChsDiff=0;
2772     idslRMReason=0;
2773     ysr=0;
2774     chYsr=0;
2775     chse=0;
2776     hpsKern=0;
2777 }
2778 
dump() const2779 void CHP::dump() const
2780 {
2781     wvlog << "Dumping CHP:" << std::endl;
2782     wvlog << toString().c_str() << std::endl;
2783     wvlog << "\nDumping CHP done." << std::endl;
2784 }
2785 
toString() const2786 std::string CHP::toString() const
2787 {
2788     std::string s( "CHP:" );
2789     s += "\nfBold=";
2790     s += uint2string( fBold );
2791     s += "\nfItalic=";
2792     s += uint2string( fItalic );
2793     s += "\nfRMarkDel=";
2794     s += uint2string( fRMarkDel );
2795     s += "\nfOutline=";
2796     s += uint2string( fOutline );
2797     s += "\nfFldVanish=";
2798     s += uint2string( fFldVanish );
2799     s += "\nfSmallCaps=";
2800     s += uint2string( fSmallCaps );
2801     s += "\nfCaps=";
2802     s += uint2string( fCaps );
2803     s += "\nfVanish=";
2804     s += uint2string( fVanish );
2805     s += "\nfRMark=";
2806     s += uint2string( fRMark );
2807     s += "\nfSpec=";
2808     s += uint2string( fSpec );
2809     s += "\nfStrike=";
2810     s += uint2string( fStrike );
2811     s += "\nfObj=";
2812     s += uint2string( fObj );
2813     s += "\nfShadow=";
2814     s += uint2string( fShadow );
2815     s += "\nfLowerCase=";
2816     s += uint2string( fLowerCase );
2817     s += "\nfData=";
2818     s += uint2string( fData );
2819     s += "\nfOle2=";
2820     s += uint2string( fOle2 );
2821     s += "\nunused2=";
2822     s += uint2string( unused2 );
2823     s += "\nftc=";
2824     s += uint2string( ftc );
2825     s += "\nhps=";
2826     s += uint2string( hps );
2827     s += "\ndxaSpace=";
2828     s += uint2string( dxaSpace );
2829     s += "\niss=";
2830     s += uint2string( iss );
2831     s += "\nunused10_3=";
2832     s += uint2string( unused10_3 );
2833     s += "\nfSysVanish=";
2834     s += uint2string( fSysVanish );
2835     s += "\nunused10_7=";
2836     s += uint2string( unused10_7 );
2837     s += "\nico=";
2838     s += uint2string( ico );
2839     s += "\nkul=";
2840     s += uint2string( kul );
2841     s += "\nhpsPos=";
2842     s += int2string( hpsPos );
2843     s += "\nlid=";
2844     s += uint2string( lid );
2845     s += "\nfcPic_fcObj_lTagObj=";
2846     s += uint2string( fcPic_fcObj_lTagObj );
2847     s += "\nibstRMark=";
2848     s += uint2string( ibstRMark );
2849     s += "\ndttmRMark=";
2850     s += "\n{" + dttmRMark.toString() + "}\n";
2851     s += "\nunused26=";
2852     s += uint2string( unused26 );
2853     s += "\nistd=";
2854     s += uint2string( istd );
2855     s += "\nftcSym=";
2856     s += uint2string( ftcSym );
2857     s += "\nchSym=";
2858     s += uint2string( chSym );
2859     s += "\nfChsDiff=";
2860     s += uint2string( fChsDiff );
2861     s += "\nidslRMReason=";
2862     s += uint2string( idslRMReason );
2863     s += "\nysr=";
2864     s += uint2string( ysr );
2865     s += "\nchYsr=";
2866     s += uint2string( chYsr );
2867     s += "\nchse=";
2868     s += uint2string( chse );
2869     s += "\nhpsKern=";
2870     s += uint2string( hpsKern );
2871     s += "\nCHP Done.";
2872     return s;
2873 }
2874 
operator ==(const CHP & lhs,const CHP & rhs)2875 bool operator==(const CHP &lhs, const CHP &rhs) {
2876 
2877     return lhs.fBold==rhs.fBold &&
2878            lhs.fItalic==rhs.fItalic &&
2879            lhs.fRMarkDel==rhs.fRMarkDel &&
2880            lhs.fOutline==rhs.fOutline &&
2881            lhs.fFldVanish==rhs.fFldVanish &&
2882            lhs.fSmallCaps==rhs.fSmallCaps &&
2883            lhs.fCaps==rhs.fCaps &&
2884            lhs.fVanish==rhs.fVanish &&
2885            lhs.fRMark==rhs.fRMark &&
2886            lhs.fSpec==rhs.fSpec &&
2887            lhs.fStrike==rhs.fStrike &&
2888            lhs.fObj==rhs.fObj &&
2889            lhs.fShadow==rhs.fShadow &&
2890            lhs.fLowerCase==rhs.fLowerCase &&
2891            lhs.fData==rhs.fData &&
2892            lhs.fOle2==rhs.fOle2 &&
2893            lhs.unused2==rhs.unused2 &&
2894            lhs.ftc==rhs.ftc &&
2895            lhs.hps==rhs.hps &&
2896            lhs.dxaSpace==rhs.dxaSpace &&
2897            lhs.iss==rhs.iss &&
2898            lhs.unused10_3==rhs.unused10_3 &&
2899            lhs.fSysVanish==rhs.fSysVanish &&
2900            lhs.unused10_7==rhs.unused10_7 &&
2901            lhs.ico==rhs.ico &&
2902            lhs.kul==rhs.kul &&
2903            lhs.hpsPos==rhs.hpsPos &&
2904            lhs.lid==rhs.lid &&
2905            lhs.fcPic_fcObj_lTagObj==rhs.fcPic_fcObj_lTagObj &&
2906            lhs.ibstRMark==rhs.ibstRMark &&
2907            lhs.dttmRMark==rhs.dttmRMark &&
2908            lhs.unused26==rhs.unused26 &&
2909            lhs.istd==rhs.istd &&
2910            lhs.ftcSym==rhs.ftcSym &&
2911            lhs.chSym==rhs.chSym &&
2912            lhs.fChsDiff==rhs.fChsDiff &&
2913            lhs.idslRMReason==rhs.idslRMReason &&
2914            lhs.ysr==rhs.ysr &&
2915            lhs.chYsr==rhs.chYsr &&
2916            lhs.chse==rhs.chse &&
2917            lhs.hpsKern==rhs.hpsKern;
2918 }
2919 
operator !=(const CHP & lhs,const CHP & rhs)2920 bool operator!=(const CHP &lhs, const CHP &rhs) {
2921     return !(lhs==rhs);
2922 }
2923 
2924 
2925 // DCS implementation
2926 
DCS()2927 DCS::DCS() {
2928     clear();
2929 }
2930 
DCS(OLEStreamReader * stream,bool preservePos)2931 DCS::DCS(OLEStreamReader *stream, bool preservePos) {
2932     clear();
2933     read(stream, preservePos);
2934 }
2935 
DCS(const U8 * ptr)2936 DCS::DCS(const U8 *ptr) {
2937     clear();
2938     readPtr(ptr);
2939 }
2940 
read(OLEStreamReader * stream,bool preservePos)2941 bool DCS::read(OLEStreamReader *stream, bool preservePos) {
2942 
2943     U8 shifterU8;
2944 
2945     if(preservePos)
2946         stream->push();
2947 
2948     shifterU8=stream->readU8();
2949     fdct=shifterU8;
2950     shifterU8>>=3;
2951     lines=shifterU8;
2952     unused1=stream->readU8();
2953 
2954     if(preservePos)
2955         stream->pop();
2956     return true;
2957 }
2958 
readPtr(const U8 * ptr)2959 void DCS::readPtr(const U8 *ptr) {
2960 
2961     U8 shifterU8;
2962 
2963     shifterU8=readU8(ptr);
2964     ptr+=sizeof(U8);
2965     fdct=shifterU8;
2966     shifterU8>>=3;
2967     lines=shifterU8;
2968     unused1=readU8(ptr);
2969     ptr+=sizeof(U8);
2970 }
2971 
write(OLEStreamWriter * stream,bool preservePos) const2972 bool DCS::write(OLEStreamWriter *stream, bool preservePos) const {
2973 
2974     U8 shifterU8;
2975 
2976     if(preservePos)
2977         stream->push();
2978 
2979     shifterU8=fdct;
2980     shifterU8|=lines << 3;
2981     stream->write(shifterU8);
2982     stream->write(unused1);
2983 
2984     if(preservePos)
2985         stream->pop();
2986     return true;
2987 }
2988 
clear()2989 void DCS::clear() {
2990     fdct=0;
2991     lines=0;
2992     unused1=0;
2993 }
2994 
dump() const2995 void DCS::dump() const
2996 {
2997     wvlog << "Dumping DCS:" << std::endl;
2998     wvlog << toString().c_str() << std::endl;
2999     wvlog << "\nDumping DCS done." << std::endl;
3000 }
3001 
toString() const3002 std::string DCS::toString() const
3003 {
3004     std::string s( "DCS:" );
3005     s += "\nfdct=";
3006     s += uint2string( fdct );
3007     s += "\nlines=";
3008     s += uint2string( lines );
3009     s += "\nunused1=";
3010     s += uint2string( unused1 );
3011     s += "\nDCS Done.";
3012     return s;
3013 }
3014 
operator ==(const DCS & lhs,const DCS & rhs)3015 bool operator==(const DCS &lhs, const DCS &rhs) {
3016 
3017     return lhs.fdct==rhs.fdct &&
3018            lhs.lines==rhs.lines &&
3019            lhs.unused1==rhs.unused1;
3020 }
3021 
operator !=(const DCS & lhs,const DCS & rhs)3022 bool operator!=(const DCS &lhs, const DCS &rhs) {
3023     return !(lhs==rhs);
3024 }
3025 
3026 
3027 // DO implementation
3028 
DO()3029 DO::DO() {
3030     clear();
3031 }
3032 
DO(OLEStreamReader * stream,bool preservePos)3033 DO::DO(OLEStreamReader *stream, bool preservePos) {
3034     clear();
3035     read(stream, preservePos);
3036 }
3037 
read(OLEStreamReader * stream,bool preservePos)3038 bool DO::read(OLEStreamReader *stream, bool preservePos) {
3039 
3040     U16 shifterU16;
3041 
3042     if(preservePos)
3043         stream->push();
3044 
3045     fc=stream->readU32();
3046     dok=stream->readU16();
3047     cb=stream->readU16();
3048     bx=stream->readU8();
3049     by=stream->readU8();
3050     dhgt=stream->readU16();
3051     shifterU16=stream->readU16();
3052     fAnchorLock=shifterU16;
3053     shifterU16>>=1;
3054     unused8=shifterU16;
3055     rgdp=stream->readU8();
3056 
3057     if(preservePos)
3058         stream->pop();
3059     return true;
3060 }
3061 
write(OLEStreamWriter * stream,bool preservePos) const3062 bool DO::write(OLEStreamWriter *stream, bool preservePos) const {
3063 
3064     U16 shifterU16;
3065 
3066     if(preservePos)
3067         stream->push();
3068 
3069     stream->write(fc);
3070     stream->write(dok);
3071     stream->write(cb);
3072     stream->write(bx);
3073     stream->write(by);
3074     stream->write(dhgt);
3075     shifterU16=fAnchorLock;
3076     shifterU16|=unused8 << 1;
3077     stream->write(shifterU16);
3078     stream->write(rgdp);
3079 
3080     if(preservePos)
3081         stream->pop();
3082     return true;
3083 }
3084 
clear()3085 void DO::clear() {
3086     fc=0;
3087     dok=0;
3088     cb=0;
3089     bx=0;
3090     by=0;
3091     dhgt=0;
3092     fAnchorLock=0;
3093     unused8=0;
3094     rgdp=0;
3095 }
3096 
operator ==(const DO & lhs,const DO & rhs)3097 bool operator==(const DO &lhs, const DO &rhs) {
3098 
3099     return lhs.fc==rhs.fc &&
3100            lhs.dok==rhs.dok &&
3101            lhs.cb==rhs.cb &&
3102            lhs.bx==rhs.bx &&
3103            lhs.by==rhs.by &&
3104            lhs.dhgt==rhs.dhgt &&
3105            lhs.fAnchorLock==rhs.fAnchorLock &&
3106            lhs.unused8==rhs.unused8 &&
3107            lhs.rgdp==rhs.rgdp;
3108 }
3109 
operator !=(const DO & lhs,const DO & rhs)3110 bool operator!=(const DO &lhs, const DO &rhs) {
3111     return !(lhs==rhs);
3112 }
3113 
3114 
3115 // DOP implementation
3116 
DOP()3117 DOP::DOP() {
3118     clear();
3119 }
3120 
DOP(OLEStreamReader * stream,bool preservePos)3121 DOP::DOP(OLEStreamReader *stream, bool preservePos) {
3122     clear();
3123     read(stream, preservePos);
3124 }
3125 
read(OLEStreamReader * stream,bool preservePos)3126 bool DOP::read(OLEStreamReader *stream, bool preservePos) {
3127 
3128     U8 shifterU8;
3129     U16 shifterU16;
3130 
3131     if(preservePos)
3132         stream->push();
3133 
3134     shifterU16=stream->readU16();
3135     fFacingPages=shifterU16;
3136     shifterU16>>=1;
3137     fWidowControl=shifterU16;
3138     shifterU16>>=1;
3139     fPMHMainDoc=shifterU16;
3140     shifterU16>>=1;
3141     grfSuppression=shifterU16;
3142     shifterU16>>=2;
3143     fpc=shifterU16;
3144     shifterU16>>=2;
3145     unused0_7=shifterU16;
3146     shifterU16>>=1;
3147     grpfIhdt=shifterU16;
3148     shifterU16=stream->readU16();
3149     rncFtn=shifterU16;
3150     shifterU16>>=2;
3151     nFtn=shifterU16;
3152     shifterU8=stream->readU8();
3153     fOutlineDirtySave=shifterU8;
3154     shifterU8>>=1;
3155     unused4_1=shifterU8;
3156     shifterU8=stream->readU8();
3157     fOnlyMacPics=shifterU8;
3158     shifterU8>>=1;
3159     fOnlyWinPics=shifterU8;
3160     shifterU8>>=1;
3161     fLabelDoc=shifterU8;
3162     shifterU8>>=1;
3163     fHyphCapitals=shifterU8;
3164     shifterU8>>=1;
3165     fAutoHyphen=shifterU8;
3166     shifterU8>>=1;
3167     fFormNoFields=shifterU8;
3168     shifterU8>>=1;
3169     fLinkStyles=shifterU8;
3170     shifterU8>>=1;
3171     fRevMarking=shifterU8;
3172     shifterU8=stream->readU8();
3173     fBackup=shifterU8;
3174     shifterU8>>=1;
3175     fExactCWords=shifterU8;
3176     shifterU8>>=1;
3177     fPagHidden=shifterU8;
3178     shifterU8>>=1;
3179     fPagResults=shifterU8;
3180     shifterU8>>=1;
3181     fLockAtn=shifterU8;
3182     shifterU8>>=1;
3183     fMirrorMargins=shifterU8;
3184     shifterU8>>=1;
3185     fReadOnlyRecommended=shifterU8;
3186     shifterU8>>=1;
3187     fDfltTrueType=shifterU8;
3188     shifterU8=stream->readU8();
3189     fPagSuppressTopSpacing=shifterU8;
3190     shifterU8>>=1;
3191     fProtEnabled=shifterU8;
3192     shifterU8>>=1;
3193     fDispFormFldSel=shifterU8;
3194     shifterU8>>=1;
3195     fRMView=shifterU8;
3196     shifterU8>>=1;
3197     fRMPrint=shifterU8;
3198     shifterU8>>=1;
3199     fWriteReservation=shifterU8;
3200     shifterU8>>=1;
3201     fLockRev=shifterU8;
3202     shifterU8>>=1;
3203     fEmbedFonts=shifterU8;
3204     shifterU16=stream->readU16();
3205     copts_fNoTabForInd=shifterU16;
3206     shifterU16>>=1;
3207     copts_fNoSpaceRaiseLower=shifterU16;
3208     shifterU16>>=1;
3209     copts_fSuppressSpbfAfterPageBreak=shifterU16;
3210     shifterU16>>=1;
3211     copts_fWrapTrailSpaces=shifterU16;
3212     shifterU16>>=1;
3213     copts_fMapPrintTextColor=shifterU16;
3214     shifterU16>>=1;
3215     copts_fNoColumnBalance=shifterU16;
3216     shifterU16>>=1;
3217     copts_fConvMailMergeEsc=shifterU16;
3218     shifterU16>>=1;
3219     copts_fSupressTopSpacing=shifterU16;
3220     shifterU16>>=1;
3221     copts_fOrigWordTableRules=shifterU16;
3222     shifterU16>>=1;
3223     copts_fTransparentMetafiles=shifterU16;
3224     shifterU16>>=1;
3225     copts_fShowBreaksInFrames=shifterU16;
3226     shifterU16>>=1;
3227     copts_fSwapBordersFacingPgs=shifterU16;
3228     shifterU16>>=1;
3229     unused8_12=shifterU16;
3230     dxaTab=stream->readU16();
3231     wSpare=stream->readU16();
3232     dxaHotZ=stream->readU16();
3233     cConsecHypLim=stream->readU16();
3234     wSpare2=stream->readU16();
3235     dttmCreated.read(stream, false);
3236     dttmRevised.read(stream, false);
3237     dttmLastPrint.read(stream, false);
3238     nRevision=stream->readU16();
3239     tmEdited=stream->readU32();
3240     cWords=stream->readU32();
3241     cCh=stream->readU32();
3242     cPg=stream->readU16();
3243     cParas=stream->readU32();
3244     shifterU16=stream->readU16();
3245     rncEdn=shifterU16;
3246     shifterU16>>=2;
3247     nEdn=shifterU16;
3248     shifterU16=stream->readU16();
3249     epc=shifterU16;
3250     shifterU16>>=2;
3251     nfcFtnRef=shifterU16;
3252     shifterU16>>=4;
3253     nfcEdnRef=shifterU16;
3254     shifterU16>>=4;
3255     fPrintFormData=shifterU16;
3256     shifterU16>>=1;
3257     fSaveFormData=shifterU16;
3258     shifterU16>>=1;
3259     fShadeFormData=shifterU16;
3260     shifterU16>>=1;
3261     unused54_13=shifterU16;
3262     shifterU16>>=2;
3263     fWCFtnEdn=shifterU16;
3264     cLines=stream->readU32();
3265     cWordsFtnEnd=stream->readU32();
3266     cChFtnEdn=stream->readU32();
3267     cPgFtnEdn=stream->readU16();
3268     cParasFtnEdn=stream->readU32();
3269     cLinesFtnEdn=stream->readU32();
3270     lKeyProtDoc=stream->readU32();
3271     shifterU16=stream->readU16();
3272     wvkSaved=shifterU16;
3273     shifterU16>>=3;
3274     wScaleSaved=shifterU16;
3275     shifterU16>>=9;
3276     zkSaved=shifterU16;
3277     shifterU16>>=2;
3278     unused82_14=shifterU16;
3279 
3280     if(preservePos)
3281         stream->pop();
3282     return true;
3283 }
3284 
write(OLEStreamWriter * stream,bool preservePos) const3285 bool DOP::write(OLEStreamWriter *stream, bool preservePos) const {
3286 
3287     U8 shifterU8;
3288     U16 shifterU16;
3289 
3290     if(preservePos)
3291         stream->push();
3292 
3293     shifterU16=fFacingPages;
3294     shifterU16|=fWidowControl << 1;
3295     shifterU16|=fPMHMainDoc << 2;
3296     shifterU16|=grfSuppression << 3;
3297     shifterU16|=fpc << 5;
3298     shifterU16|=unused0_7 << 7;
3299     shifterU16|=grpfIhdt << 8;
3300     stream->write(shifterU16);
3301     shifterU16=rncFtn;
3302     shifterU16|=nFtn << 2;
3303     stream->write(shifterU16);
3304     shifterU8=fOutlineDirtySave;
3305     shifterU8|=unused4_1 << 1;
3306     stream->write(shifterU8);
3307     shifterU8=fOnlyMacPics;
3308     shifterU8|=fOnlyWinPics << 1;
3309     shifterU8|=fLabelDoc << 2;
3310     shifterU8|=fHyphCapitals << 3;
3311     shifterU8|=fAutoHyphen << 4;
3312     shifterU8|=fFormNoFields << 5;
3313     shifterU8|=fLinkStyles << 6;
3314     shifterU8|=fRevMarking << 7;
3315     stream->write(shifterU8);
3316     shifterU8=fBackup;
3317     shifterU8|=fExactCWords << 1;
3318     shifterU8|=fPagHidden << 2;
3319     shifterU8|=fPagResults << 3;
3320     shifterU8|=fLockAtn << 4;
3321     shifterU8|=fMirrorMargins << 5;
3322     shifterU8|=fReadOnlyRecommended << 6;
3323     shifterU8|=fDfltTrueType << 7;
3324     stream->write(shifterU8);
3325     shifterU8=fPagSuppressTopSpacing;
3326     shifterU8|=fProtEnabled << 1;
3327     shifterU8|=fDispFormFldSel << 2;
3328     shifterU8|=fRMView << 3;
3329     shifterU8|=fRMPrint << 4;
3330     shifterU8|=fWriteReservation << 5;
3331     shifterU8|=fLockRev << 6;
3332     shifterU8|=fEmbedFonts << 7;
3333     stream->write(shifterU8);
3334     shifterU16=copts_fNoTabForInd;
3335     shifterU16|=copts_fNoSpaceRaiseLower << 1;
3336     shifterU16|=copts_fSuppressSpbfAfterPageBreak << 2;
3337     shifterU16|=copts_fWrapTrailSpaces << 3;
3338     shifterU16|=copts_fMapPrintTextColor << 4;
3339     shifterU16|=copts_fNoColumnBalance << 5;
3340     shifterU16|=copts_fConvMailMergeEsc << 6;
3341     shifterU16|=copts_fSupressTopSpacing << 7;
3342     shifterU16|=copts_fOrigWordTableRules << 8;
3343     shifterU16|=copts_fTransparentMetafiles << 9;
3344     shifterU16|=copts_fShowBreaksInFrames << 10;
3345     shifterU16|=copts_fSwapBordersFacingPgs << 11;
3346     shifterU16|=unused8_12 << 12;
3347     stream->write(shifterU16);
3348     stream->write(dxaTab);
3349     stream->write(wSpare);
3350     stream->write(dxaHotZ);
3351     stream->write(cConsecHypLim);
3352     stream->write(wSpare2);
3353     dttmCreated.write(stream, false);
3354     dttmRevised.write(stream, false);
3355     dttmLastPrint.write(stream, false);
3356     stream->write(nRevision);
3357     stream->write(tmEdited);
3358     stream->write(cWords);
3359     stream->write(cCh);
3360     stream->write(cPg);
3361     stream->write(cParas);
3362     shifterU16=rncEdn;
3363     shifterU16|=nEdn << 2;
3364     stream->write(shifterU16);
3365     shifterU16=epc;
3366     shifterU16|=nfcFtnRef << 2;
3367     shifterU16|=nfcEdnRef << 6;
3368     shifterU16|=fPrintFormData << 10;
3369     shifterU16|=fSaveFormData << 11;
3370     shifterU16|=fShadeFormData << 12;
3371     shifterU16|=unused54_13 << 13;
3372     shifterU16|=fWCFtnEdn << 15;
3373     stream->write(shifterU16);
3374     stream->write(cLines);
3375     stream->write(cWordsFtnEnd);
3376     stream->write(cChFtnEdn);
3377     stream->write(cPgFtnEdn);
3378     stream->write(cParasFtnEdn);
3379     stream->write(cLinesFtnEdn);
3380     stream->write(lKeyProtDoc);
3381     shifterU16=wvkSaved;
3382     shifterU16|=wScaleSaved << 3;
3383     shifterU16|=zkSaved << 12;
3384     shifterU16|=unused82_14 << 14;
3385     stream->write(shifterU16);
3386 
3387     if(preservePos)
3388         stream->pop();
3389     return true;
3390 }
3391 
clear()3392 void DOP::clear() {
3393     fFacingPages=0;
3394     fWidowControl=0;
3395     fPMHMainDoc=0;
3396     grfSuppression=0;
3397     fpc=0;
3398     unused0_7=0;
3399     grpfIhdt=0;
3400     rncFtn=0;
3401     nFtn=0;
3402     fOutlineDirtySave=0;
3403     unused4_1=0;
3404     fOnlyMacPics=0;
3405     fOnlyWinPics=0;
3406     fLabelDoc=0;
3407     fHyphCapitals=0;
3408     fAutoHyphen=0;
3409     fFormNoFields=0;
3410     fLinkStyles=0;
3411     fRevMarking=0;
3412     fBackup=0;
3413     fExactCWords=0;
3414     fPagHidden=0;
3415     fPagResults=0;
3416     fLockAtn=0;
3417     fMirrorMargins=0;
3418     fReadOnlyRecommended=0;
3419     fDfltTrueType=0;
3420     fPagSuppressTopSpacing=0;
3421     fProtEnabled=0;
3422     fDispFormFldSel=0;
3423     fRMView=0;
3424     fRMPrint=0;
3425     fWriteReservation=0;
3426     fLockRev=0;
3427     fEmbedFonts=0;
3428     copts_fNoTabForInd=0;
3429     copts_fNoSpaceRaiseLower=0;
3430     copts_fSuppressSpbfAfterPageBreak=0;
3431     copts_fWrapTrailSpaces=0;
3432     copts_fMapPrintTextColor=0;
3433     copts_fNoColumnBalance=0;
3434     copts_fConvMailMergeEsc=0;
3435     copts_fSupressTopSpacing=0;
3436     copts_fOrigWordTableRules=0;
3437     copts_fTransparentMetafiles=0;
3438     copts_fShowBreaksInFrames=0;
3439     copts_fSwapBordersFacingPgs=0;
3440     unused8_12=0;
3441     dxaTab=0;
3442     wSpare=0;
3443     dxaHotZ=0;
3444     cConsecHypLim=0;
3445     wSpare2=0;
3446     dttmCreated.clear();
3447     dttmRevised.clear();
3448     dttmLastPrint.clear();
3449     nRevision=0;
3450     tmEdited=0;
3451     cWords=0;
3452     cCh=0;
3453     cPg=0;
3454     cParas=0;
3455     rncEdn=0;
3456     nEdn=0;
3457     epc=0;
3458     nfcFtnRef=0;
3459     nfcEdnRef=0;
3460     fPrintFormData=0;
3461     fSaveFormData=0;
3462     fShadeFormData=0;
3463     unused54_13=0;
3464     fWCFtnEdn=0;
3465     cLines=0;
3466     cWordsFtnEnd=0;
3467     cChFtnEdn=0;
3468     cPgFtnEdn=0;
3469     cParasFtnEdn=0;
3470     cLinesFtnEdn=0;
3471     lKeyProtDoc=0;
3472     wvkSaved=0;
3473     wScaleSaved=0;
3474     zkSaved=0;
3475     unused82_14=0;
3476 }
3477 
operator ==(const DOP & lhs,const DOP & rhs)3478 bool operator==(const DOP &lhs, const DOP &rhs) {
3479 
3480     return lhs.fFacingPages==rhs.fFacingPages &&
3481            lhs.fWidowControl==rhs.fWidowControl &&
3482            lhs.fPMHMainDoc==rhs.fPMHMainDoc &&
3483            lhs.grfSuppression==rhs.grfSuppression &&
3484            lhs.fpc==rhs.fpc &&
3485            lhs.unused0_7==rhs.unused0_7 &&
3486            lhs.grpfIhdt==rhs.grpfIhdt &&
3487            lhs.rncFtn==rhs.rncFtn &&
3488            lhs.nFtn==rhs.nFtn &&
3489            lhs.fOutlineDirtySave==rhs.fOutlineDirtySave &&
3490            lhs.unused4_1==rhs.unused4_1 &&
3491            lhs.fOnlyMacPics==rhs.fOnlyMacPics &&
3492            lhs.fOnlyWinPics==rhs.fOnlyWinPics &&
3493            lhs.fLabelDoc==rhs.fLabelDoc &&
3494            lhs.fHyphCapitals==rhs.fHyphCapitals &&
3495            lhs.fAutoHyphen==rhs.fAutoHyphen &&
3496            lhs.fFormNoFields==rhs.fFormNoFields &&
3497            lhs.fLinkStyles==rhs.fLinkStyles &&
3498            lhs.fRevMarking==rhs.fRevMarking &&
3499            lhs.fBackup==rhs.fBackup &&
3500            lhs.fExactCWords==rhs.fExactCWords &&
3501            lhs.fPagHidden==rhs.fPagHidden &&
3502            lhs.fPagResults==rhs.fPagResults &&
3503            lhs.fLockAtn==rhs.fLockAtn &&
3504            lhs.fMirrorMargins==rhs.fMirrorMargins &&
3505            lhs.fReadOnlyRecommended==rhs.fReadOnlyRecommended &&
3506            lhs.fDfltTrueType==rhs.fDfltTrueType &&
3507            lhs.fPagSuppressTopSpacing==rhs.fPagSuppressTopSpacing &&
3508            lhs.fProtEnabled==rhs.fProtEnabled &&
3509            lhs.fDispFormFldSel==rhs.fDispFormFldSel &&
3510            lhs.fRMView==rhs.fRMView &&
3511            lhs.fRMPrint==rhs.fRMPrint &&
3512            lhs.fWriteReservation==rhs.fWriteReservation &&
3513            lhs.fLockRev==rhs.fLockRev &&
3514            lhs.fEmbedFonts==rhs.fEmbedFonts &&
3515            lhs.copts_fNoTabForInd==rhs.copts_fNoTabForInd &&
3516            lhs.copts_fNoSpaceRaiseLower==rhs.copts_fNoSpaceRaiseLower &&
3517            lhs.copts_fSuppressSpbfAfterPageBreak==rhs.copts_fSuppressSpbfAfterPageBreak &&
3518            lhs.copts_fWrapTrailSpaces==rhs.copts_fWrapTrailSpaces &&
3519            lhs.copts_fMapPrintTextColor==rhs.copts_fMapPrintTextColor &&
3520            lhs.copts_fNoColumnBalance==rhs.copts_fNoColumnBalance &&
3521            lhs.copts_fConvMailMergeEsc==rhs.copts_fConvMailMergeEsc &&
3522            lhs.copts_fSupressTopSpacing==rhs.copts_fSupressTopSpacing &&
3523            lhs.copts_fOrigWordTableRules==rhs.copts_fOrigWordTableRules &&
3524            lhs.copts_fTransparentMetafiles==rhs.copts_fTransparentMetafiles &&
3525            lhs.copts_fShowBreaksInFrames==rhs.copts_fShowBreaksInFrames &&
3526            lhs.copts_fSwapBordersFacingPgs==rhs.copts_fSwapBordersFacingPgs &&
3527            lhs.unused8_12==rhs.unused8_12 &&
3528            lhs.dxaTab==rhs.dxaTab &&
3529            lhs.wSpare==rhs.wSpare &&
3530            lhs.dxaHotZ==rhs.dxaHotZ &&
3531            lhs.cConsecHypLim==rhs.cConsecHypLim &&
3532            lhs.wSpare2==rhs.wSpare2 &&
3533            lhs.dttmCreated==rhs.dttmCreated &&
3534            lhs.dttmRevised==rhs.dttmRevised &&
3535            lhs.dttmLastPrint==rhs.dttmLastPrint &&
3536            lhs.nRevision==rhs.nRevision &&
3537            lhs.tmEdited==rhs.tmEdited &&
3538            lhs.cWords==rhs.cWords &&
3539            lhs.cCh==rhs.cCh &&
3540            lhs.cPg==rhs.cPg &&
3541            lhs.cParas==rhs.cParas &&
3542            lhs.rncEdn==rhs.rncEdn &&
3543            lhs.nEdn==rhs.nEdn &&
3544            lhs.epc==rhs.epc &&
3545            lhs.nfcFtnRef==rhs.nfcFtnRef &&
3546            lhs.nfcEdnRef==rhs.nfcEdnRef &&
3547            lhs.fPrintFormData==rhs.fPrintFormData &&
3548            lhs.fSaveFormData==rhs.fSaveFormData &&
3549            lhs.fShadeFormData==rhs.fShadeFormData &&
3550            lhs.unused54_13==rhs.unused54_13 &&
3551            lhs.fWCFtnEdn==rhs.fWCFtnEdn &&
3552            lhs.cLines==rhs.cLines &&
3553            lhs.cWordsFtnEnd==rhs.cWordsFtnEnd &&
3554            lhs.cChFtnEdn==rhs.cChFtnEdn &&
3555            lhs.cPgFtnEdn==rhs.cPgFtnEdn &&
3556            lhs.cParasFtnEdn==rhs.cParasFtnEdn &&
3557            lhs.cLinesFtnEdn==rhs.cLinesFtnEdn &&
3558            lhs.lKeyProtDoc==rhs.lKeyProtDoc &&
3559            lhs.wvkSaved==rhs.wvkSaved &&
3560            lhs.wScaleSaved==rhs.wScaleSaved &&
3561            lhs.zkSaved==rhs.zkSaved &&
3562            lhs.unused82_14==rhs.unused82_14;
3563 }
3564 
operator !=(const DOP & lhs,const DOP & rhs)3565 bool operator!=(const DOP &lhs, const DOP &rhs) {
3566     return !(lhs==rhs);
3567 }
3568 
3569 
3570 // DPARC implementation
3571 
DPARC()3572 DPARC::DPARC() {
3573     clear();
3574 }
3575 
DPARC(OLEStreamReader * stream,bool preservePos)3576 DPARC::DPARC(OLEStreamReader *stream, bool preservePos) {
3577     clear();
3578     read(stream, preservePos);
3579 }
3580 
read(OLEStreamReader * stream,bool preservePos)3581 bool DPARC::read(OLEStreamReader *stream, bool preservePos) {
3582 
3583     U16 shifterU16;
3584 
3585     if(preservePos)
3586         stream->push();
3587 
3588     dphead.read(stream, false);
3589     lnpc=stream->readU32();
3590     lnpw=stream->readU16();
3591     lnps=stream->readU16();
3592     dlpcFg=stream->readU32();
3593     dlpcBg=stream->readU32();
3594     flpp=stream->readU16();
3595     shdwpi=stream->readU16();
3596     xaOffset=stream->readU16();
3597     yaOffset=stream->readU16();
3598     shifterU16=stream->readU16();
3599     fLeft=shifterU16;
3600     shifterU16>>=8;
3601     fUp=shifterU16;
3602 
3603     if(preservePos)
3604         stream->pop();
3605     return true;
3606 }
3607 
write(OLEStreamWriter * stream,bool preservePos) const3608 bool DPARC::write(OLEStreamWriter *stream, bool preservePos) const {
3609 
3610     U16 shifterU16;
3611 
3612     if(preservePos)
3613         stream->push();
3614 
3615     dphead.write(stream, false);
3616     stream->write(lnpc);
3617     stream->write(lnpw);
3618     stream->write(lnps);
3619     stream->write(dlpcFg);
3620     stream->write(dlpcBg);
3621     stream->write(flpp);
3622     stream->write(shdwpi);
3623     stream->write(xaOffset);
3624     stream->write(yaOffset);
3625     shifterU16=fLeft;
3626     shifterU16|=fUp << 8;
3627     stream->write(shifterU16);
3628 
3629     if(preservePos)
3630         stream->pop();
3631     return true;
3632 }
3633 
clear()3634 void DPARC::clear() {
3635     dphead.clear();
3636     lnpc=0;
3637     lnpw=0;
3638     lnps=0;
3639     dlpcFg=0;
3640     dlpcBg=0;
3641     flpp=0;
3642     shdwpi=0;
3643     xaOffset=0;
3644     yaOffset=0;
3645     fLeft=0;
3646     fUp=0;
3647 }
3648 
operator ==(const DPARC & lhs,const DPARC & rhs)3649 bool operator==(const DPARC &lhs, const DPARC &rhs) {
3650 
3651     return lhs.dphead==rhs.dphead &&
3652            lhs.lnpc==rhs.lnpc &&
3653            lhs.lnpw==rhs.lnpw &&
3654            lhs.lnps==rhs.lnps &&
3655            lhs.dlpcFg==rhs.dlpcFg &&
3656            lhs.dlpcBg==rhs.dlpcBg &&
3657            lhs.flpp==rhs.flpp &&
3658            lhs.shdwpi==rhs.shdwpi &&
3659            lhs.xaOffset==rhs.xaOffset &&
3660            lhs.yaOffset==rhs.yaOffset &&
3661            lhs.fLeft==rhs.fLeft &&
3662            lhs.fUp==rhs.fUp;
3663 }
3664 
operator !=(const DPARC & lhs,const DPARC & rhs)3665 bool operator!=(const DPARC &lhs, const DPARC &rhs) {
3666     return !(lhs==rhs);
3667 }
3668 
3669 
3670 // DPCALLOUT implementation
3671 
DPCALLOUT()3672 DPCALLOUT::DPCALLOUT() {
3673     clear();
3674 }
3675 
DPCALLOUT(OLEStreamReader * stream,bool preservePos)3676 DPCALLOUT::DPCALLOUT(OLEStreamReader *stream, bool preservePos) {
3677     clear();
3678     read(stream, preservePos);
3679 }
3680 
read(OLEStreamReader * stream,bool preservePos)3681 bool DPCALLOUT::read(OLEStreamReader *stream, bool preservePos) {
3682 
3683     if(preservePos)
3684         stream->push();
3685 
3686     dphead.read(stream, false);
3687     unused12=stream->readU16();
3688     dzaOffset=stream->readU16();
3689     dzaDescent=stream->readU16();
3690     dzaLength=stream->readU16();
3691     dptxbx.read(stream, false);
3692     dpPolyLine.read(stream, false);
3693 
3694     if(preservePos)
3695         stream->pop();
3696     return true;
3697 }
3698 
write(OLEStreamWriter * stream,bool preservePos) const3699 bool DPCALLOUT::write(OLEStreamWriter *stream, bool preservePos) const {
3700 
3701     if(preservePos)
3702         stream->push();
3703 
3704     dphead.write(stream, false);
3705     stream->write(unused12);
3706     stream->write(dzaOffset);
3707     stream->write(dzaDescent);
3708     stream->write(dzaLength);
3709     dptxbx.write(stream, false);
3710     dpPolyLine.write(stream, false);
3711 
3712     if(preservePos)
3713         stream->pop();
3714     return true;
3715 }
3716 
clear()3717 void DPCALLOUT::clear() {
3718     dphead.clear();
3719     unused12=0;
3720     dzaOffset=0;
3721     dzaDescent=0;
3722     dzaLength=0;
3723     dptxbx.clear();
3724     dpPolyLine.clear();
3725 }
3726 
operator ==(const DPCALLOUT & lhs,const DPCALLOUT & rhs)3727 bool operator==(const DPCALLOUT &lhs, const DPCALLOUT &rhs) {
3728 
3729     return lhs.dphead==rhs.dphead &&
3730            lhs.unused12==rhs.unused12 &&
3731            lhs.dzaOffset==rhs.dzaOffset &&
3732            lhs.dzaDescent==rhs.dzaDescent &&
3733            lhs.dzaLength==rhs.dzaLength &&
3734            lhs.dptxbx==rhs.dptxbx &&
3735            lhs.dpPolyLine==rhs.dpPolyLine;
3736 }
3737 
operator !=(const DPCALLOUT & lhs,const DPCALLOUT & rhs)3738 bool operator!=(const DPCALLOUT &lhs, const DPCALLOUT &rhs) {
3739     return !(lhs==rhs);
3740 }
3741 
3742 
3743 // DPELLIPSE implementation
3744 
DPELLIPSE()3745 DPELLIPSE::DPELLIPSE() {
3746     clear();
3747 }
3748 
DPELLIPSE(OLEStreamReader * stream,bool preservePos)3749 DPELLIPSE::DPELLIPSE(OLEStreamReader *stream, bool preservePos) {
3750     clear();
3751     read(stream, preservePos);
3752 }
3753 
read(OLEStreamReader * stream,bool preservePos)3754 bool DPELLIPSE::read(OLEStreamReader *stream, bool preservePos) {
3755 
3756     if(preservePos)
3757         stream->push();
3758 
3759     dphead.read(stream, false);
3760     lnpc=stream->readU32();
3761     lnpw=stream->readU16();
3762     lnps=stream->readU16();
3763     dlpcFg=stream->readU32();
3764     dlpcBg=stream->readU32();
3765     flpp=stream->readU16();
3766     shdwpi=stream->readU16();
3767     xaOffset=stream->readU16();
3768     yaOffset=stream->readU16();
3769 
3770     if(preservePos)
3771         stream->pop();
3772     return true;
3773 }
3774 
write(OLEStreamWriter * stream,bool preservePos) const3775 bool DPELLIPSE::write(OLEStreamWriter *stream, bool preservePos) const {
3776 
3777     if(preservePos)
3778         stream->push();
3779 
3780     dphead.write(stream, false);
3781     stream->write(lnpc);
3782     stream->write(lnpw);
3783     stream->write(lnps);
3784     stream->write(dlpcFg);
3785     stream->write(dlpcBg);
3786     stream->write(flpp);
3787     stream->write(shdwpi);
3788     stream->write(xaOffset);
3789     stream->write(yaOffset);
3790 
3791     if(preservePos)
3792         stream->pop();
3793     return true;
3794 }
3795 
clear()3796 void DPELLIPSE::clear() {
3797     dphead.clear();
3798     lnpc=0;
3799     lnpw=0;
3800     lnps=0;
3801     dlpcFg=0;
3802     dlpcBg=0;
3803     flpp=0;
3804     shdwpi=0;
3805     xaOffset=0;
3806     yaOffset=0;
3807 }
3808 
operator ==(const DPELLIPSE & lhs,const DPELLIPSE & rhs)3809 bool operator==(const DPELLIPSE &lhs, const DPELLIPSE &rhs) {
3810 
3811     return lhs.dphead==rhs.dphead &&
3812            lhs.lnpc==rhs.lnpc &&
3813            lhs.lnpw==rhs.lnpw &&
3814            lhs.lnps==rhs.lnps &&
3815            lhs.dlpcFg==rhs.dlpcFg &&
3816            lhs.dlpcBg==rhs.dlpcBg &&
3817            lhs.flpp==rhs.flpp &&
3818            lhs.shdwpi==rhs.shdwpi &&
3819            lhs.xaOffset==rhs.xaOffset &&
3820            lhs.yaOffset==rhs.yaOffset;
3821 }
3822 
operator !=(const DPELLIPSE & lhs,const DPELLIPSE & rhs)3823 bool operator!=(const DPELLIPSE &lhs, const DPELLIPSE &rhs) {
3824     return !(lhs==rhs);
3825 }
3826 
3827 
3828 // DPLINE implementation
3829 
DPLINE()3830 DPLINE::DPLINE() {
3831     clear();
3832 }
3833 
DPLINE(OLEStreamReader * stream,bool preservePos)3834 DPLINE::DPLINE(OLEStreamReader *stream, bool preservePos) {
3835     clear();
3836     read(stream, preservePos);
3837 }
3838 
read(OLEStreamReader * stream,bool preservePos)3839 bool DPLINE::read(OLEStreamReader *stream, bool preservePos) {
3840 
3841     U16 shifterU16;
3842 
3843     if(preservePos)
3844         stream->push();
3845 
3846     dphead.read(stream, false);
3847     xaStart=stream->readU16();
3848     yaStart=stream->readU16();
3849     xaEnd=stream->readU16();
3850     yaEnd=stream->readU16();
3851     lnpc=stream->readU32();
3852     lnpw=stream->readU16();
3853     lnps=stream->readU16();
3854     shifterU16=stream->readU16();
3855     eppsStart=shifterU16;
3856     shifterU16>>=2;
3857     eppwStart=shifterU16;
3858     shifterU16>>=2;
3859     epplStart=shifterU16;
3860     shifterU16>>=2;
3861     unused24_6=shifterU16;
3862     shifterU16=stream->readU16();
3863     eppsEnd=shifterU16;
3864     shifterU16>>=2;
3865     eppwEnd=shifterU16;
3866     shifterU16>>=2;
3867     epplEnd=shifterU16;
3868     shifterU16>>=2;
3869     unused26_6=shifterU16;
3870     shdwpi=stream->readU16();
3871     xaOffset=stream->readU16();
3872     yaOffset=stream->readU16();
3873 
3874     if(preservePos)
3875         stream->pop();
3876     return true;
3877 }
3878 
write(OLEStreamWriter * stream,bool preservePos) const3879 bool DPLINE::write(OLEStreamWriter *stream, bool preservePos) const {
3880 
3881     U16 shifterU16;
3882 
3883     if(preservePos)
3884         stream->push();
3885 
3886     dphead.write(stream, false);
3887     stream->write(xaStart);
3888     stream->write(yaStart);
3889     stream->write(xaEnd);
3890     stream->write(yaEnd);
3891     stream->write(lnpc);
3892     stream->write(lnpw);
3893     stream->write(lnps);
3894     shifterU16=eppsStart;
3895     shifterU16|=eppwStart << 2;
3896     shifterU16|=epplStart << 4;
3897     shifterU16|=unused24_6 << 6;
3898     stream->write(shifterU16);
3899     shifterU16=eppsEnd;
3900     shifterU16|=eppwEnd << 2;
3901     shifterU16|=epplEnd << 4;
3902     shifterU16|=unused26_6 << 6;
3903     stream->write(shifterU16);
3904     stream->write(shdwpi);
3905     stream->write(xaOffset);
3906     stream->write(yaOffset);
3907 
3908     if(preservePos)
3909         stream->pop();
3910     return true;
3911 }
3912 
clear()3913 void DPLINE::clear() {
3914     dphead.clear();
3915     xaStart=0;
3916     yaStart=0;
3917     xaEnd=0;
3918     yaEnd=0;
3919     lnpc=0;
3920     lnpw=0;
3921     lnps=0;
3922     eppsStart=0;
3923     eppwStart=0;
3924     epplStart=0;
3925     unused24_6=0;
3926     eppsEnd=0;
3927     eppwEnd=0;
3928     epplEnd=0;
3929     unused26_6=0;
3930     shdwpi=0;
3931     xaOffset=0;
3932     yaOffset=0;
3933 }
3934 
operator ==(const DPLINE & lhs,const DPLINE & rhs)3935 bool operator==(const DPLINE &lhs, const DPLINE &rhs) {
3936 
3937     return lhs.dphead==rhs.dphead &&
3938            lhs.xaStart==rhs.xaStart &&
3939            lhs.yaStart==rhs.yaStart &&
3940            lhs.xaEnd==rhs.xaEnd &&
3941            lhs.yaEnd==rhs.yaEnd &&
3942            lhs.lnpc==rhs.lnpc &&
3943            lhs.lnpw==rhs.lnpw &&
3944            lhs.lnps==rhs.lnps &&
3945            lhs.eppsStart==rhs.eppsStart &&
3946            lhs.eppwStart==rhs.eppwStart &&
3947            lhs.epplStart==rhs.epplStart &&
3948            lhs.unused24_6==rhs.unused24_6 &&
3949            lhs.eppsEnd==rhs.eppsEnd &&
3950            lhs.eppwEnd==rhs.eppwEnd &&
3951            lhs.epplEnd==rhs.epplEnd &&
3952            lhs.unused26_6==rhs.unused26_6 &&
3953            lhs.shdwpi==rhs.shdwpi &&
3954            lhs.xaOffset==rhs.xaOffset &&
3955            lhs.yaOffset==rhs.yaOffset;
3956 }
3957 
operator !=(const DPLINE & lhs,const DPLINE & rhs)3958 bool operator!=(const DPLINE &lhs, const DPLINE &rhs) {
3959     return !(lhs==rhs);
3960 }
3961 
3962 
3963 // DPRECT implementation
3964 
DPRECT()3965 DPRECT::DPRECT() {
3966     clear();
3967 }
3968 
DPRECT(OLEStreamReader * stream,bool preservePos)3969 DPRECT::DPRECT(OLEStreamReader *stream, bool preservePos) {
3970     clear();
3971     read(stream, preservePos);
3972 }
3973 
read(OLEStreamReader * stream,bool preservePos)3974 bool DPRECT::read(OLEStreamReader *stream, bool preservePos) {
3975 
3976     U16 shifterU16;
3977 
3978     if(preservePos)
3979         stream->push();
3980 
3981     dphead.read(stream, false);
3982     lnpc=stream->readU32();
3983     lnpw=stream->readU16();
3984     lnps=stream->readU16();
3985     dlpcFg=stream->readU32();
3986     dlpcBg=stream->readU32();
3987     flpp=stream->readU16();
3988     shdwpi=stream->readU16();
3989     xaOffset=stream->readU16();
3990     yaOffset=stream->readU16();
3991     shifterU16=stream->readU16();
3992     fRoundCorners=shifterU16;
3993     shifterU16>>=1;
3994     zaShape=shifterU16;
3995 
3996     if(preservePos)
3997         stream->pop();
3998     return true;
3999 }
4000 
write(OLEStreamWriter * stream,bool preservePos) const4001 bool DPRECT::write(OLEStreamWriter *stream, bool preservePos) const {
4002 
4003     U16 shifterU16;
4004 
4005     if(preservePos)
4006         stream->push();
4007 
4008     dphead.write(stream, false);
4009     stream->write(lnpc);
4010     stream->write(lnpw);
4011     stream->write(lnps);
4012     stream->write(dlpcFg);
4013     stream->write(dlpcBg);
4014     stream->write(flpp);
4015     stream->write(shdwpi);
4016     stream->write(xaOffset);
4017     stream->write(yaOffset);
4018     shifterU16=fRoundCorners;
4019     shifterU16|=zaShape << 1;
4020     stream->write(shifterU16);
4021 
4022     if(preservePos)
4023         stream->pop();
4024     return true;
4025 }
4026 
clear()4027 void DPRECT::clear() {
4028     dphead.clear();
4029     lnpc=0;
4030     lnpw=0;
4031     lnps=0;
4032     dlpcFg=0;
4033     dlpcBg=0;
4034     flpp=0;
4035     shdwpi=0;
4036     xaOffset=0;
4037     yaOffset=0;
4038     fRoundCorners=0;
4039     zaShape=0;
4040 }
4041 
operator ==(const DPRECT & lhs,const DPRECT & rhs)4042 bool operator==(const DPRECT &lhs, const DPRECT &rhs) {
4043 
4044     return lhs.dphead==rhs.dphead &&
4045            lhs.lnpc==rhs.lnpc &&
4046            lhs.lnpw==rhs.lnpw &&
4047            lhs.lnps==rhs.lnps &&
4048            lhs.dlpcFg==rhs.dlpcFg &&
4049            lhs.dlpcBg==rhs.dlpcBg &&
4050            lhs.flpp==rhs.flpp &&
4051            lhs.shdwpi==rhs.shdwpi &&
4052            lhs.xaOffset==rhs.xaOffset &&
4053            lhs.yaOffset==rhs.yaOffset &&
4054            lhs.fRoundCorners==rhs.fRoundCorners &&
4055            lhs.zaShape==rhs.zaShape;
4056 }
4057 
operator !=(const DPRECT & lhs,const DPRECT & rhs)4058 bool operator!=(const DPRECT &lhs, const DPRECT &rhs) {
4059     return !(lhs==rhs);
4060 }
4061 
4062 
4063 // DPSAMPLE implementation
4064 
DPSAMPLE()4065 DPSAMPLE::DPSAMPLE() {
4066     clear();
4067 }
4068 
DPSAMPLE(OLEStreamReader * stream,bool preservePos)4069 DPSAMPLE::DPSAMPLE(OLEStreamReader *stream, bool preservePos) {
4070     clear();
4071     read(stream, preservePos);
4072 }
4073 
read(OLEStreamReader * stream,bool preservePos)4074 bool DPSAMPLE::read(OLEStreamReader *stream, bool preservePos) {
4075 
4076     U16 shifterU16;
4077 
4078     if(preservePos)
4079         stream->push();
4080 
4081     dphead.read(stream, false);
4082     lnpc=stream->readU32();
4083     lnpw=stream->readU16();
4084     lnps=stream->readU16();
4085     dlpcFg=stream->readU32();
4086     dlpcBg=stream->readU32();
4087     flpp=stream->readU16();
4088     shifterU16=stream->readU16();
4089     eppsStart=shifterU16;
4090     shifterU16>>=2;
4091     eppwStart=shifterU16;
4092     shifterU16>>=2;
4093     epplStart=shifterU16;
4094     shifterU16>>=2;
4095     unused30_6=shifterU16;
4096     shifterU16=stream->readU16();
4097     eppsEnd=shifterU16;
4098     shifterU16>>=2;
4099     eppwEnd=shifterU16;
4100     shifterU16>>=2;
4101     epplEnd=shifterU16;
4102     shifterU16>>=2;
4103     unused32_6=shifterU16;
4104     shdwpi=stream->readU16();
4105     xaOffset=stream->readU16();
4106     yaOffset=stream->readU16();
4107     unused40=stream->readU16();
4108     dzaOffset=stream->readU16();
4109     dzaDescent=stream->readU16();
4110     dzaLength=stream->readU16();
4111     shifterU16=stream->readU16();
4112     fRoundCorners=shifterU16;
4113     shifterU16>>=1;
4114     zaShape=shifterU16;
4115     dzaInternalMargin=stream->readU16();
4116 
4117     if(preservePos)
4118         stream->pop();
4119     return true;
4120 }
4121 
write(OLEStreamWriter * stream,bool preservePos) const4122 bool DPSAMPLE::write(OLEStreamWriter *stream, bool preservePos) const {
4123 
4124     U16 shifterU16;
4125 
4126     if(preservePos)
4127         stream->push();
4128 
4129     dphead.write(stream, false);
4130     stream->write(lnpc);
4131     stream->write(lnpw);
4132     stream->write(lnps);
4133     stream->write(dlpcFg);
4134     stream->write(dlpcBg);
4135     stream->write(flpp);
4136     shifterU16=eppsStart;
4137     shifterU16|=eppwStart << 2;
4138     shifterU16|=epplStart << 4;
4139     shifterU16|=unused30_6 << 6;
4140     stream->write(shifterU16);
4141     shifterU16=eppsEnd;
4142     shifterU16|=eppwEnd << 2;
4143     shifterU16|=epplEnd << 4;
4144     shifterU16|=unused32_6 << 6;
4145     stream->write(shifterU16);
4146     stream->write(shdwpi);
4147     stream->write(xaOffset);
4148     stream->write(yaOffset);
4149     stream->write(unused40);
4150     stream->write(dzaOffset);
4151     stream->write(dzaDescent);
4152     stream->write(dzaLength);
4153     shifterU16=fRoundCorners;
4154     shifterU16|=zaShape << 1;
4155     stream->write(shifterU16);
4156     stream->write(dzaInternalMargin);
4157 
4158     if(preservePos)
4159         stream->pop();
4160     return true;
4161 }
4162 
clear()4163 void DPSAMPLE::clear() {
4164     dphead.clear();
4165     lnpc=0;
4166     lnpw=0;
4167     lnps=0;
4168     dlpcFg=0;
4169     dlpcBg=0;
4170     flpp=0;
4171     eppsStart=0;
4172     eppwStart=0;
4173     epplStart=0;
4174     unused30_6=0;
4175     eppsEnd=0;
4176     eppwEnd=0;
4177     epplEnd=0;
4178     unused32_6=0;
4179     shdwpi=0;
4180     xaOffset=0;
4181     yaOffset=0;
4182     unused40=0;
4183     dzaOffset=0;
4184     dzaDescent=0;
4185     dzaLength=0;
4186     fRoundCorners=0;
4187     zaShape=0;
4188     dzaInternalMargin=0;
4189 }
4190 
operator ==(const DPSAMPLE & lhs,const DPSAMPLE & rhs)4191 bool operator==(const DPSAMPLE &lhs, const DPSAMPLE &rhs) {
4192 
4193     return lhs.dphead==rhs.dphead &&
4194            lhs.lnpc==rhs.lnpc &&
4195            lhs.lnpw==rhs.lnpw &&
4196            lhs.lnps==rhs.lnps &&
4197            lhs.dlpcFg==rhs.dlpcFg &&
4198            lhs.dlpcBg==rhs.dlpcBg &&
4199            lhs.flpp==rhs.flpp &&
4200            lhs.eppsStart==rhs.eppsStart &&
4201            lhs.eppwStart==rhs.eppwStart &&
4202            lhs.epplStart==rhs.epplStart &&
4203            lhs.unused30_6==rhs.unused30_6 &&
4204            lhs.eppsEnd==rhs.eppsEnd &&
4205            lhs.eppwEnd==rhs.eppwEnd &&
4206            lhs.epplEnd==rhs.epplEnd &&
4207            lhs.unused32_6==rhs.unused32_6 &&
4208            lhs.shdwpi==rhs.shdwpi &&
4209            lhs.xaOffset==rhs.xaOffset &&
4210            lhs.yaOffset==rhs.yaOffset &&
4211            lhs.unused40==rhs.unused40 &&
4212            lhs.dzaOffset==rhs.dzaOffset &&
4213            lhs.dzaDescent==rhs.dzaDescent &&
4214            lhs.dzaLength==rhs.dzaLength &&
4215            lhs.fRoundCorners==rhs.fRoundCorners &&
4216            lhs.zaShape==rhs.zaShape &&
4217            lhs.dzaInternalMargin==rhs.dzaInternalMargin;
4218 }
4219 
operator !=(const DPSAMPLE & lhs,const DPSAMPLE & rhs)4220 bool operator!=(const DPSAMPLE &lhs, const DPSAMPLE &rhs) {
4221     return !(lhs==rhs);
4222 }
4223 
4224 
4225 // FDOA implementation
4226 
FDOA()4227 FDOA::FDOA() {
4228     clear();
4229 }
4230 
FDOA(OLEStreamReader * stream,bool preservePos)4231 FDOA::FDOA(OLEStreamReader *stream, bool preservePos) {
4232     clear();
4233     read(stream, preservePos);
4234 }
4235 
read(OLEStreamReader * stream,bool preservePos)4236 bool FDOA::read(OLEStreamReader *stream, bool preservePos) {
4237 
4238     if(preservePos)
4239         stream->push();
4240 
4241     fc=stream->readU32();
4242     ctxbx=stream->readU16();
4243 
4244     if(preservePos)
4245         stream->pop();
4246     return true;
4247 }
4248 
write(OLEStreamWriter * stream,bool preservePos) const4249 bool FDOA::write(OLEStreamWriter *stream, bool preservePos) const {
4250 
4251     if(preservePos)
4252         stream->push();
4253 
4254     stream->write(fc);
4255     stream->write(ctxbx);
4256 
4257     if(preservePos)
4258         stream->pop();
4259     return true;
4260 }
4261 
clear()4262 void FDOA::clear() {
4263     fc=0;
4264     ctxbx=0;
4265 }
4266 
operator ==(const FDOA & lhs,const FDOA & rhs)4267 bool operator==(const FDOA &lhs, const FDOA &rhs) {
4268 
4269     return lhs.fc==rhs.fc &&
4270            lhs.ctxbx==rhs.ctxbx;
4271 }
4272 
operator !=(const FDOA & lhs,const FDOA & rhs)4273 bool operator!=(const FDOA &lhs, const FDOA &rhs) {
4274     return !(lhs==rhs);
4275 }
4276 
4277 
4278 // FIB implementation
4279 
FIB()4280 FIB::FIB() {
4281     clear();
4282 }
4283 
FIB(OLEStreamReader * stream,bool preservePos)4284 FIB::FIB(OLEStreamReader *stream, bool preservePos) {
4285     clear();
4286     read(stream, preservePos);
4287 }
4288 
read(OLEStreamReader * stream,bool preservePos)4289 bool FIB::read(OLEStreamReader *stream, bool preservePos) {
4290 
4291     U16 shifterU16;
4292 
4293     if(preservePos)
4294         stream->push();
4295 
4296     wIdent=stream->readU16();
4297     nFib=stream->readU16();
4298     nProduct=stream->readU16();
4299     lid=stream->readU16();
4300     pnNext=stream->readU16();
4301     shifterU16=stream->readU16();
4302     fDot=shifterU16;
4303     shifterU16>>=1;
4304     fGlsy=shifterU16;
4305     shifterU16>>=1;
4306     fComplex=shifterU16;
4307     shifterU16>>=1;
4308     fHasPic=shifterU16;
4309     shifterU16>>=1;
4310     cQuickSaves=shifterU16;
4311     shifterU16>>=4;
4312     fEncrypted=shifterU16;
4313     shifterU16>>=1;
4314     unused10_9=shifterU16;
4315     shifterU16>>=1;
4316     fReadOnlyRecommended=shifterU16;
4317     shifterU16>>=1;
4318     fWriteReservation=shifterU16;
4319     shifterU16>>=1;
4320     fExtChar=shifterU16;
4321     shifterU16>>=1;
4322     unused10_13=shifterU16;
4323     nFibBack=stream->readU16();
4324     lKey=stream->readU32();
4325     envr=stream->readU8();
4326     unused19=stream->readU8();
4327     chse=stream->readU16();
4328     chseTables=stream->readU16();
4329     fcMin=stream->readU32();
4330     fcMac=stream->readU32();
4331     cbMac=stream->readU32();
4332     fcSpare0=stream->readU32();
4333     fcSpare1=stream->readU32();
4334     fcSpare2=stream->readU32();
4335     fcSpare3=stream->readU32();
4336     ccpText=stream->readU32();
4337     ccpFtn=stream->readU32();
4338     ccpHdd=stream->readU32();
4339     ccpMcr=stream->readU32();
4340     ccpAtn=stream->readU32();
4341     ccpEdn=stream->readU32();
4342     ccpTxbx=stream->readU32();
4343     ccpHdrTxbx=stream->readU32();
4344     ccpSpare2=stream->readU32();
4345     fcStshfOrig=stream->readU32();
4346     lcbStshfOrig=stream->readU32();
4347     fcStshf=stream->readU32();
4348     lcbStshf=stream->readU32();
4349     fcPlcffndRef=stream->readU32();
4350     lcbPlcffndRef=stream->readU32();
4351     fcPlcffndTxt=stream->readU32();
4352     lcbPlcffndTxt=stream->readU32();
4353     fcPlcfandRef=stream->readU32();
4354     lcbPlcfandRef=stream->readU32();
4355     fcPlcfandTxt=stream->readU32();
4356     lcbPlcfandTxt=stream->readU32();
4357     fcPlcfsed=stream->readU32();
4358     lcbPlcfsed=stream->readU32();
4359     fcPlcfpad=stream->readU32();
4360     lcbPlcfpad=stream->readU32();
4361     fcPlcfphe=stream->readU32();
4362     lcbPlcfphe=stream->readU32();
4363     fcSttbfglsy=stream->readU32();
4364     lcbSttbfglsy=stream->readU32();
4365     fcPlcfglsy=stream->readU32();
4366     lcbPlcfglsy=stream->readU32();
4367     fcPlcfhdd=stream->readU32();
4368     lcbPlcfhdd=stream->readU32();
4369     fcPlcfbteChpx=stream->readU32();
4370     lcbPlcfbteChpx=stream->readU32();
4371     fcPlcfbtePapx=stream->readU32();
4372     lcbPlcfbtePapx=stream->readU32();
4373     fcPlcfsea=stream->readU32();
4374     lcbPlcfsea=stream->readU32();
4375     fcSttbfffn=stream->readU32();
4376     lcbSttbfffn=stream->readU32();
4377     fcPlcffldMom=stream->readU32();
4378     lcbPlcffldMom=stream->readU32();
4379     fcPlcffldHdr=stream->readU32();
4380     lcbPlcffldHdr=stream->readU32();
4381     fcPlcffldFtn=stream->readU32();
4382     lcbPlcffldFtn=stream->readU32();
4383     fcPlcffldAtn=stream->readU32();
4384     lcbPlcffldAtn=stream->readU32();
4385     fcPlcffldMcr=stream->readU32();
4386     lcbPlcffldMcr=stream->readU32();
4387     fcSttbfbkmk=stream->readU32();
4388     lcbSttbfbkmk=stream->readU32();
4389     fcPlcfbkf=stream->readU32();
4390     lcbPlcfbkf=stream->readU32();
4391     fcPlcfbkl=stream->readU32();
4392     lcbPlcfbkl=stream->readU32();
4393     fcCmds=stream->readU32();
4394     lcbCmds=stream->readU32();
4395     fcPlcmcr=stream->readU32();
4396     lcbPlcmcr=stream->readU32();
4397     fcSttbfmcr=stream->readU32();
4398     lcbSttbfmcr=stream->readU32();
4399     fcPrDrvr=stream->readU32();
4400     lcbPrDrvr=stream->readU32();
4401     fcPrEnvPort=stream->readU32();
4402     lcbPrEnvPort=stream->readU32();
4403     fcPrEnvLand=stream->readU32();
4404     lcbPrEnvLand=stream->readU32();
4405     fcWss=stream->readU32();
4406     lcbWss=stream->readU32();
4407     fcDop=stream->readU32();
4408     lcbDop=stream->readU32();
4409     fcSttbfAssoc=stream->readU32();
4410     lcbSttbfAssoc=stream->readU32();
4411     fcClx=stream->readU32();
4412     lcbClx=stream->readU32();
4413     fcPlcfpgdFtn=stream->readU32();
4414     lcbPlcfpgdFtn=stream->readU32();
4415     fcAutosaveSource=stream->readU32();
4416     lcbAutosaveSource=stream->readU32();
4417     fcGrpStAtnOwners=stream->readU32();
4418     lcbGrpStAtnOwners=stream->readU32();
4419     fcSttbfAtnbkmk=stream->readU32();
4420     lcbSttbfAtnbkmk=stream->readU32();
4421     wSpare4Fib=stream->readU16();
4422     pnChpFirst=stream->readU16();
4423     pnPapFirst=stream->readU16();
4424     cpnBteChp=stream->readU16();
4425     cpnBtePap=stream->readU16();
4426     fcPlcfdoaMom=stream->readU32();
4427     lcbPlcfdoaMom=stream->readU32();
4428     fcPlcfdoaHdr=stream->readU32();
4429     lcbPlcfdoaHdr=stream->readU32();
4430     fcUnused1=stream->readU32();
4431     lcbUnused1=stream->readU32();
4432     fcUnused2=stream->readU32();
4433     lcbUnused2=stream->readU32();
4434     fcPlcfAtnbkf=stream->readU32();
4435     lcbPlcfAtnbkf=stream->readU32();
4436     fcPlcfAtnbkl=stream->readU32();
4437     lcbPlcfAtnbkl=stream->readU32();
4438     fcPms=stream->readU32();
4439     lcbPms=stream->readU32();
4440     fcFormFldSttbf=stream->readU32();
4441     lcbFormFldSttbf=stream->readU32();
4442     fcPlcfendRef=stream->readU32();
4443     lcbPlcfendRef=stream->readU32();
4444     fcPlcfendTxt=stream->readU32();
4445     lcbPlcfendTxt=stream->readU32();
4446     fcPlcffldEdn=stream->readU32();
4447     lcbPlcffldEdn=stream->readU32();
4448     fcPlcfpgdEdn=stream->readU32();
4449     lcbPlcfpgdEdn=stream->readU32();
4450     fcUnused3=stream->readU32();
4451     lcbUnused3=stream->readU32();
4452     fcSttbfRMark=stream->readU32();
4453     lcbSttbfRMark=stream->readU32();
4454     fcSttbfCaption=stream->readU32();
4455     lcbSttbfCaption=stream->readU32();
4456     fcSttbfAutoCaption=stream->readU32();
4457     lcbSttbfAutoCaption=stream->readU32();
4458     fcPlcfwkb=stream->readU32();
4459     lcbPlcfwkb=stream->readU32();
4460     fcUnused4=stream->readU32();
4461     lcbUnused4=stream->readU32();
4462     fcPlcftxbxTxt=stream->readU32();
4463     lcbPlcftxbxTxt=stream->readU32();
4464     fcPlcffldTxbx=stream->readU32();
4465     lcbPlcffldTxbx=stream->readU32();
4466     fcPlcfHdrtxbxTxt=stream->readU32();
4467     lcbPlcfHdrtxbxTxt=stream->readU32();
4468     fcPlcffldHdrTxbx=stream->readU32();
4469     lcbPlcffldHdrTxbx=stream->readU32();
4470     fcStwUser=stream->readU32();
4471     lcbStwUser=stream->readU32();
4472     fcSttbttmbd=stream->readU32();
4473     lcbSttbttmbd=stream->readU32();
4474     fcUnused=stream->readU32();
4475     lcbUnused=stream->readU32();
4476     fcPgdMother=stream->readU32();
4477     lcbPgdMother=stream->readU32();
4478     fcBkdMother=stream->readU32();
4479     lcbBkdMother=stream->readU32();
4480     fcPgdFtn=stream->readU32();
4481     lcbPgdFtn=stream->readU32();
4482     fcBkdFtn=stream->readU32();
4483     lcbBkdFtn=stream->readU32();
4484     fcPgdEdn=stream->readU32();
4485     lcbPgdEdn=stream->readU32();
4486     fcBkdEdn=stream->readU32();
4487     lcbBkdEdn=stream->readU32();
4488     fcSttbfIntlFld=stream->readU32();
4489     lcbSttbfIntlFld=stream->readU32();
4490     fcRouteSlip=stream->readU32();
4491     lcbRouteSlip=stream->readU32();
4492     fcSttbSavedBy=stream->readU32();
4493     lcbSttbSavedBy=stream->readU32();
4494     fcSttbFnm=stream->readU32();
4495     lcbSttbFnm=stream->readU32();
4496 
4497     if(preservePos)
4498         stream->pop();
4499     return true;
4500 }
4501 
write(OLEStreamWriter * stream,bool preservePos) const4502 bool FIB::write(OLEStreamWriter *stream, bool preservePos) const {
4503 
4504     U16 shifterU16;
4505 
4506     if(preservePos)
4507         stream->push();
4508 
4509     stream->write(wIdent);
4510     stream->write(nFib);
4511     stream->write(nProduct);
4512     stream->write(lid);
4513     stream->write(pnNext);
4514     shifterU16=fDot;
4515     shifterU16|=fGlsy << 1;
4516     shifterU16|=fComplex << 2;
4517     shifterU16|=fHasPic << 3;
4518     shifterU16|=cQuickSaves << 4;
4519     shifterU16|=fEncrypted << 8;
4520     shifterU16|=unused10_9 << 9;
4521     shifterU16|=fReadOnlyRecommended << 10;
4522     shifterU16|=fWriteReservation << 11;
4523     shifterU16|=fExtChar << 12;
4524     shifterU16|=unused10_13 << 13;
4525     stream->write(shifterU16);
4526     stream->write(nFibBack);
4527     stream->write(lKey);
4528     stream->write(envr);
4529     stream->write(unused19);
4530     stream->write(chse);
4531     stream->write(chseTables);
4532     stream->write(fcMin);
4533     stream->write(fcMac);
4534     stream->write(cbMac);
4535     stream->write(fcSpare0);
4536     stream->write(fcSpare1);
4537     stream->write(fcSpare2);
4538     stream->write(fcSpare3);
4539     stream->write(ccpText);
4540     stream->write(ccpFtn);
4541     stream->write(ccpHdd);
4542     stream->write(ccpMcr);
4543     stream->write(ccpAtn);
4544     stream->write(ccpEdn);
4545     stream->write(ccpTxbx);
4546     stream->write(ccpHdrTxbx);
4547     stream->write(ccpSpare2);
4548     stream->write(fcStshfOrig);
4549     stream->write(lcbStshfOrig);
4550     stream->write(fcStshf);
4551     stream->write(lcbStshf);
4552     stream->write(fcPlcffndRef);
4553     stream->write(lcbPlcffndRef);
4554     stream->write(fcPlcffndTxt);
4555     stream->write(lcbPlcffndTxt);
4556     stream->write(fcPlcfandRef);
4557     stream->write(lcbPlcfandRef);
4558     stream->write(fcPlcfandTxt);
4559     stream->write(lcbPlcfandTxt);
4560     stream->write(fcPlcfsed);
4561     stream->write(lcbPlcfsed);
4562     stream->write(fcPlcfpad);
4563     stream->write(lcbPlcfpad);
4564     stream->write(fcPlcfphe);
4565     stream->write(lcbPlcfphe);
4566     stream->write(fcSttbfglsy);
4567     stream->write(lcbSttbfglsy);
4568     stream->write(fcPlcfglsy);
4569     stream->write(lcbPlcfglsy);
4570     stream->write(fcPlcfhdd);
4571     stream->write(lcbPlcfhdd);
4572     stream->write(fcPlcfbteChpx);
4573     stream->write(lcbPlcfbteChpx);
4574     stream->write(fcPlcfbtePapx);
4575     stream->write(lcbPlcfbtePapx);
4576     stream->write(fcPlcfsea);
4577     stream->write(lcbPlcfsea);
4578     stream->write(fcSttbfffn);
4579     stream->write(lcbSttbfffn);
4580     stream->write(fcPlcffldMom);
4581     stream->write(lcbPlcffldMom);
4582     stream->write(fcPlcffldHdr);
4583     stream->write(lcbPlcffldHdr);
4584     stream->write(fcPlcffldFtn);
4585     stream->write(lcbPlcffldFtn);
4586     stream->write(fcPlcffldAtn);
4587     stream->write(lcbPlcffldAtn);
4588     stream->write(fcPlcffldMcr);
4589     stream->write(lcbPlcffldMcr);
4590     stream->write(fcSttbfbkmk);
4591     stream->write(lcbSttbfbkmk);
4592     stream->write(fcPlcfbkf);
4593     stream->write(lcbPlcfbkf);
4594     stream->write(fcPlcfbkl);
4595     stream->write(lcbPlcfbkl);
4596     stream->write(fcCmds);
4597     stream->write(lcbCmds);
4598     stream->write(fcPlcmcr);
4599     stream->write(lcbPlcmcr);
4600     stream->write(fcSttbfmcr);
4601     stream->write(lcbSttbfmcr);
4602     stream->write(fcPrDrvr);
4603     stream->write(lcbPrDrvr);
4604     stream->write(fcPrEnvPort);
4605     stream->write(lcbPrEnvPort);
4606     stream->write(fcPrEnvLand);
4607     stream->write(lcbPrEnvLand);
4608     stream->write(fcWss);
4609     stream->write(lcbWss);
4610     stream->write(fcDop);
4611     stream->write(lcbDop);
4612     stream->write(fcSttbfAssoc);
4613     stream->write(lcbSttbfAssoc);
4614     stream->write(fcClx);
4615     stream->write(lcbClx);
4616     stream->write(fcPlcfpgdFtn);
4617     stream->write(lcbPlcfpgdFtn);
4618     stream->write(fcAutosaveSource);
4619     stream->write(lcbAutosaveSource);
4620     stream->write(fcGrpStAtnOwners);
4621     stream->write(lcbGrpStAtnOwners);
4622     stream->write(fcSttbfAtnbkmk);
4623     stream->write(lcbSttbfAtnbkmk);
4624     stream->write(wSpare4Fib);
4625     stream->write(pnChpFirst);
4626     stream->write(pnPapFirst);
4627     stream->write(cpnBteChp);
4628     stream->write(cpnBtePap);
4629     stream->write(fcPlcfdoaMom);
4630     stream->write(lcbPlcfdoaMom);
4631     stream->write(fcPlcfdoaHdr);
4632     stream->write(lcbPlcfdoaHdr);
4633     stream->write(fcUnused1);
4634     stream->write(lcbUnused1);
4635     stream->write(fcUnused2);
4636     stream->write(lcbUnused2);
4637     stream->write(fcPlcfAtnbkf);
4638     stream->write(lcbPlcfAtnbkf);
4639     stream->write(fcPlcfAtnbkl);
4640     stream->write(lcbPlcfAtnbkl);
4641     stream->write(fcPms);
4642     stream->write(lcbPms);
4643     stream->write(fcFormFldSttbf);
4644     stream->write(lcbFormFldSttbf);
4645     stream->write(fcPlcfendRef);
4646     stream->write(lcbPlcfendRef);
4647     stream->write(fcPlcfendTxt);
4648     stream->write(lcbPlcfendTxt);
4649     stream->write(fcPlcffldEdn);
4650     stream->write(lcbPlcffldEdn);
4651     stream->write(fcPlcfpgdEdn);
4652     stream->write(lcbPlcfpgdEdn);
4653     stream->write(fcUnused3);
4654     stream->write(lcbUnused3);
4655     stream->write(fcSttbfRMark);
4656     stream->write(lcbSttbfRMark);
4657     stream->write(fcSttbfCaption);
4658     stream->write(lcbSttbfCaption);
4659     stream->write(fcSttbfAutoCaption);
4660     stream->write(lcbSttbfAutoCaption);
4661     stream->write(fcPlcfwkb);
4662     stream->write(lcbPlcfwkb);
4663     stream->write(fcUnused4);
4664     stream->write(lcbUnused4);
4665     stream->write(fcPlcftxbxTxt);
4666     stream->write(lcbPlcftxbxTxt);
4667     stream->write(fcPlcffldTxbx);
4668     stream->write(lcbPlcffldTxbx);
4669     stream->write(fcPlcfHdrtxbxTxt);
4670     stream->write(lcbPlcfHdrtxbxTxt);
4671     stream->write(fcPlcffldHdrTxbx);
4672     stream->write(lcbPlcffldHdrTxbx);
4673     stream->write(fcStwUser);
4674     stream->write(lcbStwUser);
4675     stream->write(fcSttbttmbd);
4676     stream->write(lcbSttbttmbd);
4677     stream->write(fcUnused);
4678     stream->write(lcbUnused);
4679     stream->write(fcPgdMother);
4680     stream->write(lcbPgdMother);
4681     stream->write(fcBkdMother);
4682     stream->write(lcbBkdMother);
4683     stream->write(fcPgdFtn);
4684     stream->write(lcbPgdFtn);
4685     stream->write(fcBkdFtn);
4686     stream->write(lcbBkdFtn);
4687     stream->write(fcPgdEdn);
4688     stream->write(lcbPgdEdn);
4689     stream->write(fcBkdEdn);
4690     stream->write(lcbBkdEdn);
4691     stream->write(fcSttbfIntlFld);
4692     stream->write(lcbSttbfIntlFld);
4693     stream->write(fcRouteSlip);
4694     stream->write(lcbRouteSlip);
4695     stream->write(fcSttbSavedBy);
4696     stream->write(lcbSttbSavedBy);
4697     stream->write(fcSttbFnm);
4698     stream->write(lcbSttbFnm);
4699 
4700     if(preservePos)
4701         stream->pop();
4702     return true;
4703 }
4704 
clear()4705 void FIB::clear() {
4706     wIdent=0;
4707     nFib=0;
4708     nProduct=0;
4709     lid=0;
4710     pnNext=0;
4711     fDot=0;
4712     fGlsy=0;
4713     fComplex=0;
4714     fHasPic=0;
4715     cQuickSaves=0;
4716     fEncrypted=0;
4717     unused10_9=0;
4718     fReadOnlyRecommended=0;
4719     fWriteReservation=0;
4720     fExtChar=0;
4721     unused10_13=0;
4722     nFibBack=0;
4723     lKey=0;
4724     envr=0;
4725     unused19=0;
4726     chse=0;
4727     chseTables=0;
4728     fcMin=0;
4729     fcMac=0;
4730     cbMac=0;
4731     fcSpare0=0;
4732     fcSpare1=0;
4733     fcSpare2=0;
4734     fcSpare3=0;
4735     ccpText=0;
4736     ccpFtn=0;
4737     ccpHdd=0;
4738     ccpMcr=0;
4739     ccpAtn=0;
4740     ccpEdn=0;
4741     ccpTxbx=0;
4742     ccpHdrTxbx=0;
4743     ccpSpare2=0;
4744     fcStshfOrig=0;
4745     lcbStshfOrig=0;
4746     fcStshf=0;
4747     lcbStshf=0;
4748     fcPlcffndRef=0;
4749     lcbPlcffndRef=0;
4750     fcPlcffndTxt=0;
4751     lcbPlcffndTxt=0;
4752     fcPlcfandRef=0;
4753     lcbPlcfandRef=0;
4754     fcPlcfandTxt=0;
4755     lcbPlcfandTxt=0;
4756     fcPlcfsed=0;
4757     lcbPlcfsed=0;
4758     fcPlcfpad=0;
4759     lcbPlcfpad=0;
4760     fcPlcfphe=0;
4761     lcbPlcfphe=0;
4762     fcSttbfglsy=0;
4763     lcbSttbfglsy=0;
4764     fcPlcfglsy=0;
4765     lcbPlcfglsy=0;
4766     fcPlcfhdd=0;
4767     lcbPlcfhdd=0;
4768     fcPlcfbteChpx=0;
4769     lcbPlcfbteChpx=0;
4770     fcPlcfbtePapx=0;
4771     lcbPlcfbtePapx=0;
4772     fcPlcfsea=0;
4773     lcbPlcfsea=0;
4774     fcSttbfffn=0;
4775     lcbSttbfffn=0;
4776     fcPlcffldMom=0;
4777     lcbPlcffldMom=0;
4778     fcPlcffldHdr=0;
4779     lcbPlcffldHdr=0;
4780     fcPlcffldFtn=0;
4781     lcbPlcffldFtn=0;
4782     fcPlcffldAtn=0;
4783     lcbPlcffldAtn=0;
4784     fcPlcffldMcr=0;
4785     lcbPlcffldMcr=0;
4786     fcSttbfbkmk=0;
4787     lcbSttbfbkmk=0;
4788     fcPlcfbkf=0;
4789     lcbPlcfbkf=0;
4790     fcPlcfbkl=0;
4791     lcbPlcfbkl=0;
4792     fcCmds=0;
4793     lcbCmds=0;
4794     fcPlcmcr=0;
4795     lcbPlcmcr=0;
4796     fcSttbfmcr=0;
4797     lcbSttbfmcr=0;
4798     fcPrDrvr=0;
4799     lcbPrDrvr=0;
4800     fcPrEnvPort=0;
4801     lcbPrEnvPort=0;
4802     fcPrEnvLand=0;
4803     lcbPrEnvLand=0;
4804     fcWss=0;
4805     lcbWss=0;
4806     fcDop=0;
4807     lcbDop=0;
4808     fcSttbfAssoc=0;
4809     lcbSttbfAssoc=0;
4810     fcClx=0;
4811     lcbClx=0;
4812     fcPlcfpgdFtn=0;
4813     lcbPlcfpgdFtn=0;
4814     fcAutosaveSource=0;
4815     lcbAutosaveSource=0;
4816     fcGrpStAtnOwners=0;
4817     lcbGrpStAtnOwners=0;
4818     fcSttbfAtnbkmk=0;
4819     lcbSttbfAtnbkmk=0;
4820     wSpare4Fib=0;
4821     pnChpFirst=0;
4822     pnPapFirst=0;
4823     cpnBteChp=0;
4824     cpnBtePap=0;
4825     fcPlcfdoaMom=0;
4826     lcbPlcfdoaMom=0;
4827     fcPlcfdoaHdr=0;
4828     lcbPlcfdoaHdr=0;
4829     fcUnused1=0;
4830     lcbUnused1=0;
4831     fcUnused2=0;
4832     lcbUnused2=0;
4833     fcPlcfAtnbkf=0;
4834     lcbPlcfAtnbkf=0;
4835     fcPlcfAtnbkl=0;
4836     lcbPlcfAtnbkl=0;
4837     fcPms=0;
4838     lcbPms=0;
4839     fcFormFldSttbf=0;
4840     lcbFormFldSttbf=0;
4841     fcPlcfendRef=0;
4842     lcbPlcfendRef=0;
4843     fcPlcfendTxt=0;
4844     lcbPlcfendTxt=0;
4845     fcPlcffldEdn=0;
4846     lcbPlcffldEdn=0;
4847     fcPlcfpgdEdn=0;
4848     lcbPlcfpgdEdn=0;
4849     fcUnused3=0;
4850     lcbUnused3=0;
4851     fcSttbfRMark=0;
4852     lcbSttbfRMark=0;
4853     fcSttbfCaption=0;
4854     lcbSttbfCaption=0;
4855     fcSttbfAutoCaption=0;
4856     lcbSttbfAutoCaption=0;
4857     fcPlcfwkb=0;
4858     lcbPlcfwkb=0;
4859     fcUnused4=0;
4860     lcbUnused4=0;
4861     fcPlcftxbxTxt=0;
4862     lcbPlcftxbxTxt=0;
4863     fcPlcffldTxbx=0;
4864     lcbPlcffldTxbx=0;
4865     fcPlcfHdrtxbxTxt=0;
4866     lcbPlcfHdrtxbxTxt=0;
4867     fcPlcffldHdrTxbx=0;
4868     lcbPlcffldHdrTxbx=0;
4869     fcStwUser=0;
4870     lcbStwUser=0;
4871     fcSttbttmbd=0;
4872     lcbSttbttmbd=0;
4873     fcUnused=0;
4874     lcbUnused=0;
4875     fcPgdMother=0;
4876     lcbPgdMother=0;
4877     fcBkdMother=0;
4878     lcbBkdMother=0;
4879     fcPgdFtn=0;
4880     lcbPgdFtn=0;
4881     fcBkdFtn=0;
4882     lcbBkdFtn=0;
4883     fcPgdEdn=0;
4884     lcbPgdEdn=0;
4885     fcBkdEdn=0;
4886     lcbBkdEdn=0;
4887     fcSttbfIntlFld=0;
4888     lcbSttbfIntlFld=0;
4889     fcRouteSlip=0;
4890     lcbRouteSlip=0;
4891     fcSttbSavedBy=0;
4892     lcbSttbSavedBy=0;
4893     fcSttbFnm=0;
4894     lcbSttbFnm=0;
4895 }
4896 
operator ==(const FIB & lhs,const FIB & rhs)4897 bool operator==(const FIB &lhs, const FIB &rhs) {
4898 
4899     return lhs.wIdent==rhs.wIdent &&
4900            lhs.nFib==rhs.nFib &&
4901            lhs.nProduct==rhs.nProduct &&
4902            lhs.lid==rhs.lid &&
4903            lhs.pnNext==rhs.pnNext &&
4904            lhs.fDot==rhs.fDot &&
4905            lhs.fGlsy==rhs.fGlsy &&
4906            lhs.fComplex==rhs.fComplex &&
4907            lhs.fHasPic==rhs.fHasPic &&
4908            lhs.cQuickSaves==rhs.cQuickSaves &&
4909            lhs.fEncrypted==rhs.fEncrypted &&
4910            lhs.unused10_9==rhs.unused10_9 &&
4911            lhs.fReadOnlyRecommended==rhs.fReadOnlyRecommended &&
4912            lhs.fWriteReservation==rhs.fWriteReservation &&
4913            lhs.fExtChar==rhs.fExtChar &&
4914            lhs.unused10_13==rhs.unused10_13 &&
4915            lhs.nFibBack==rhs.nFibBack &&
4916            lhs.lKey==rhs.lKey &&
4917            lhs.envr==rhs.envr &&
4918            lhs.unused19==rhs.unused19 &&
4919            lhs.chse==rhs.chse &&
4920            lhs.chseTables==rhs.chseTables &&
4921            lhs.fcMin==rhs.fcMin &&
4922            lhs.fcMac==rhs.fcMac &&
4923            lhs.cbMac==rhs.cbMac &&
4924            lhs.fcSpare0==rhs.fcSpare0 &&
4925            lhs.fcSpare1==rhs.fcSpare1 &&
4926            lhs.fcSpare2==rhs.fcSpare2 &&
4927            lhs.fcSpare3==rhs.fcSpare3 &&
4928            lhs.ccpText==rhs.ccpText &&
4929            lhs.ccpFtn==rhs.ccpFtn &&
4930            lhs.ccpHdd==rhs.ccpHdd &&
4931            lhs.ccpMcr==rhs.ccpMcr &&
4932            lhs.ccpAtn==rhs.ccpAtn &&
4933            lhs.ccpEdn==rhs.ccpEdn &&
4934            lhs.ccpTxbx==rhs.ccpTxbx &&
4935            lhs.ccpHdrTxbx==rhs.ccpHdrTxbx &&
4936            lhs.ccpSpare2==rhs.ccpSpare2 &&
4937            lhs.fcStshfOrig==rhs.fcStshfOrig &&
4938            lhs.lcbStshfOrig==rhs.lcbStshfOrig &&
4939            lhs.fcStshf==rhs.fcStshf &&
4940            lhs.lcbStshf==rhs.lcbStshf &&
4941            lhs.fcPlcffndRef==rhs.fcPlcffndRef &&
4942            lhs.lcbPlcffndRef==rhs.lcbPlcffndRef &&
4943            lhs.fcPlcffndTxt==rhs.fcPlcffndTxt &&
4944            lhs.lcbPlcffndTxt==rhs.lcbPlcffndTxt &&
4945            lhs.fcPlcfandRef==rhs.fcPlcfandRef &&
4946            lhs.lcbPlcfandRef==rhs.lcbPlcfandRef &&
4947            lhs.fcPlcfandTxt==rhs.fcPlcfandTxt &&
4948            lhs.lcbPlcfandTxt==rhs.lcbPlcfandTxt &&
4949            lhs.fcPlcfsed==rhs.fcPlcfsed &&
4950            lhs.lcbPlcfsed==rhs.lcbPlcfsed &&
4951            lhs.fcPlcfpad==rhs.fcPlcfpad &&
4952            lhs.lcbPlcfpad==rhs.lcbPlcfpad &&
4953            lhs.fcPlcfphe==rhs.fcPlcfphe &&
4954            lhs.lcbPlcfphe==rhs.lcbPlcfphe &&
4955            lhs.fcSttbfglsy==rhs.fcSttbfglsy &&
4956            lhs.lcbSttbfglsy==rhs.lcbSttbfglsy &&
4957            lhs.fcPlcfglsy==rhs.fcPlcfglsy &&
4958            lhs.lcbPlcfglsy==rhs.lcbPlcfglsy &&
4959            lhs.fcPlcfhdd==rhs.fcPlcfhdd &&
4960            lhs.lcbPlcfhdd==rhs.lcbPlcfhdd &&
4961            lhs.fcPlcfbteChpx==rhs.fcPlcfbteChpx &&
4962            lhs.lcbPlcfbteChpx==rhs.lcbPlcfbteChpx &&
4963            lhs.fcPlcfbtePapx==rhs.fcPlcfbtePapx &&
4964            lhs.lcbPlcfbtePapx==rhs.lcbPlcfbtePapx &&
4965            lhs.fcPlcfsea==rhs.fcPlcfsea &&
4966            lhs.lcbPlcfsea==rhs.lcbPlcfsea &&
4967            lhs.fcSttbfffn==rhs.fcSttbfffn &&
4968            lhs.lcbSttbfffn==rhs.lcbSttbfffn &&
4969            lhs.fcPlcffldMom==rhs.fcPlcffldMom &&
4970            lhs.lcbPlcffldMom==rhs.lcbPlcffldMom &&
4971            lhs.fcPlcffldHdr==rhs.fcPlcffldHdr &&
4972            lhs.lcbPlcffldHdr==rhs.lcbPlcffldHdr &&
4973            lhs.fcPlcffldFtn==rhs.fcPlcffldFtn &&
4974            lhs.lcbPlcffldFtn==rhs.lcbPlcffldFtn &&
4975            lhs.fcPlcffldAtn==rhs.fcPlcffldAtn &&
4976            lhs.lcbPlcffldAtn==rhs.lcbPlcffldAtn &&
4977            lhs.fcPlcffldMcr==rhs.fcPlcffldMcr &&
4978            lhs.lcbPlcffldMcr==rhs.lcbPlcffldMcr &&
4979            lhs.fcSttbfbkmk==rhs.fcSttbfbkmk &&
4980            lhs.lcbSttbfbkmk==rhs.lcbSttbfbkmk &&
4981            lhs.fcPlcfbkf==rhs.fcPlcfbkf &&
4982            lhs.lcbPlcfbkf==rhs.lcbPlcfbkf &&
4983            lhs.fcPlcfbkl==rhs.fcPlcfbkl &&
4984            lhs.lcbPlcfbkl==rhs.lcbPlcfbkl &&
4985            lhs.fcCmds==rhs.fcCmds &&
4986            lhs.lcbCmds==rhs.lcbCmds &&
4987            lhs.fcPlcmcr==rhs.fcPlcmcr &&
4988            lhs.lcbPlcmcr==rhs.lcbPlcmcr &&
4989            lhs.fcSttbfmcr==rhs.fcSttbfmcr &&
4990            lhs.lcbSttbfmcr==rhs.lcbSttbfmcr &&
4991            lhs.fcPrDrvr==rhs.fcPrDrvr &&
4992            lhs.lcbPrDrvr==rhs.lcbPrDrvr &&
4993            lhs.fcPrEnvPort==rhs.fcPrEnvPort &&
4994            lhs.lcbPrEnvPort==rhs.lcbPrEnvPort &&
4995            lhs.fcPrEnvLand==rhs.fcPrEnvLand &&
4996            lhs.lcbPrEnvLand==rhs.lcbPrEnvLand &&
4997            lhs.fcWss==rhs.fcWss &&
4998            lhs.lcbWss==rhs.lcbWss &&
4999            lhs.fcDop==rhs.fcDop &&
5000            lhs.lcbDop==rhs.lcbDop &&
5001            lhs.fcSttbfAssoc==rhs.fcSttbfAssoc &&
5002            lhs.lcbSttbfAssoc==rhs.lcbSttbfAssoc &&
5003            lhs.fcClx==rhs.fcClx &&
5004            lhs.lcbClx==rhs.lcbClx &&
5005            lhs.fcPlcfpgdFtn==rhs.fcPlcfpgdFtn &&
5006            lhs.lcbPlcfpgdFtn==rhs.lcbPlcfpgdFtn &&
5007            lhs.fcAutosaveSource==rhs.fcAutosaveSource &&
5008            lhs.lcbAutosaveSource==rhs.lcbAutosaveSource &&
5009            lhs.fcGrpStAtnOwners==rhs.fcGrpStAtnOwners &&
5010            lhs.lcbGrpStAtnOwners==rhs.lcbGrpStAtnOwners &&
5011            lhs.fcSttbfAtnbkmk==rhs.fcSttbfAtnbkmk &&
5012            lhs.lcbSttbfAtnbkmk==rhs.lcbSttbfAtnbkmk &&
5013            lhs.wSpare4Fib==rhs.wSpare4Fib &&
5014            lhs.pnChpFirst==rhs.pnChpFirst &&
5015            lhs.pnPapFirst==rhs.pnPapFirst &&
5016            lhs.cpnBteChp==rhs.cpnBteChp &&
5017            lhs.cpnBtePap==rhs.cpnBtePap &&
5018            lhs.fcPlcfdoaMom==rhs.fcPlcfdoaMom &&
5019            lhs.lcbPlcfdoaMom==rhs.lcbPlcfdoaMom &&
5020            lhs.fcPlcfdoaHdr==rhs.fcPlcfdoaHdr &&
5021            lhs.lcbPlcfdoaHdr==rhs.lcbPlcfdoaHdr &&
5022            lhs.fcUnused1==rhs.fcUnused1 &&
5023            lhs.lcbUnused1==rhs.lcbUnused1 &&
5024            lhs.fcUnused2==rhs.fcUnused2 &&
5025            lhs.lcbUnused2==rhs.lcbUnused2 &&
5026            lhs.fcPlcfAtnbkf==rhs.fcPlcfAtnbkf &&
5027            lhs.lcbPlcfAtnbkf==rhs.lcbPlcfAtnbkf &&
5028            lhs.fcPlcfAtnbkl==rhs.fcPlcfAtnbkl &&
5029            lhs.lcbPlcfAtnbkl==rhs.lcbPlcfAtnbkl &&
5030            lhs.fcPms==rhs.fcPms &&
5031            lhs.lcbPms==rhs.lcbPms &&
5032            lhs.fcFormFldSttbf==rhs.fcFormFldSttbf &&
5033            lhs.lcbFormFldSttbf==rhs.lcbFormFldSttbf &&
5034            lhs.fcPlcfendRef==rhs.fcPlcfendRef &&
5035            lhs.lcbPlcfendRef==rhs.lcbPlcfendRef &&
5036            lhs.fcPlcfendTxt==rhs.fcPlcfendTxt &&
5037            lhs.lcbPlcfendTxt==rhs.lcbPlcfendTxt &&
5038            lhs.fcPlcffldEdn==rhs.fcPlcffldEdn &&
5039            lhs.lcbPlcffldEdn==rhs.lcbPlcffldEdn &&
5040            lhs.fcPlcfpgdEdn==rhs.fcPlcfpgdEdn &&
5041            lhs.lcbPlcfpgdEdn==rhs.lcbPlcfpgdEdn &&
5042            lhs.fcUnused3==rhs.fcUnused3 &&
5043            lhs.lcbUnused3==rhs.lcbUnused3 &&
5044            lhs.fcSttbfRMark==rhs.fcSttbfRMark &&
5045            lhs.lcbSttbfRMark==rhs.lcbSttbfRMark &&
5046            lhs.fcSttbfCaption==rhs.fcSttbfCaption &&
5047            lhs.lcbSttbfCaption==rhs.lcbSttbfCaption &&
5048            lhs.fcSttbfAutoCaption==rhs.fcSttbfAutoCaption &&
5049            lhs.lcbSttbfAutoCaption==rhs.lcbSttbfAutoCaption &&
5050            lhs.fcPlcfwkb==rhs.fcPlcfwkb &&
5051            lhs.lcbPlcfwkb==rhs.lcbPlcfwkb &&
5052            lhs.fcUnused4==rhs.fcUnused4 &&
5053            lhs.lcbUnused4==rhs.lcbUnused4 &&
5054            lhs.fcPlcftxbxTxt==rhs.fcPlcftxbxTxt &&
5055            lhs.lcbPlcftxbxTxt==rhs.lcbPlcftxbxTxt &&
5056            lhs.fcPlcffldTxbx==rhs.fcPlcffldTxbx &&
5057            lhs.lcbPlcffldTxbx==rhs.lcbPlcffldTxbx &&
5058            lhs.fcPlcfHdrtxbxTxt==rhs.fcPlcfHdrtxbxTxt &&
5059            lhs.lcbPlcfHdrtxbxTxt==rhs.lcbPlcfHdrtxbxTxt &&
5060            lhs.fcPlcffldHdrTxbx==rhs.fcPlcffldHdrTxbx &&
5061            lhs.lcbPlcffldHdrTxbx==rhs.lcbPlcffldHdrTxbx &&
5062            lhs.fcStwUser==rhs.fcStwUser &&
5063            lhs.lcbStwUser==rhs.lcbStwUser &&
5064            lhs.fcSttbttmbd==rhs.fcSttbttmbd &&
5065            lhs.lcbSttbttmbd==rhs.lcbSttbttmbd &&
5066            lhs.fcUnused==rhs.fcUnused &&
5067            lhs.lcbUnused==rhs.lcbUnused &&
5068            lhs.fcPgdMother==rhs.fcPgdMother &&
5069            lhs.lcbPgdMother==rhs.lcbPgdMother &&
5070            lhs.fcBkdMother==rhs.fcBkdMother &&
5071            lhs.lcbBkdMother==rhs.lcbBkdMother &&
5072            lhs.fcPgdFtn==rhs.fcPgdFtn &&
5073            lhs.lcbPgdFtn==rhs.lcbPgdFtn &&
5074            lhs.fcBkdFtn==rhs.fcBkdFtn &&
5075            lhs.lcbBkdFtn==rhs.lcbBkdFtn &&
5076            lhs.fcPgdEdn==rhs.fcPgdEdn &&
5077            lhs.lcbPgdEdn==rhs.lcbPgdEdn &&
5078            lhs.fcBkdEdn==rhs.fcBkdEdn &&
5079            lhs.lcbBkdEdn==rhs.lcbBkdEdn &&
5080            lhs.fcSttbfIntlFld==rhs.fcSttbfIntlFld &&
5081            lhs.lcbSttbfIntlFld==rhs.lcbSttbfIntlFld &&
5082            lhs.fcRouteSlip==rhs.fcRouteSlip &&
5083            lhs.lcbRouteSlip==rhs.lcbRouteSlip &&
5084            lhs.fcSttbSavedBy==rhs.fcSttbSavedBy &&
5085            lhs.lcbSttbSavedBy==rhs.lcbSttbSavedBy &&
5086            lhs.fcSttbFnm==rhs.fcSttbFnm &&
5087            lhs.lcbSttbFnm==rhs.lcbSttbFnm;
5088 }
5089 
operator !=(const FIB & lhs,const FIB & rhs)5090 bool operator!=(const FIB &lhs, const FIB &rhs) {
5091     return !(lhs==rhs);
5092 }
5093 
5094 
5095 // LSPD implementation
5096 
LSPD()5097 LSPD::LSPD() {
5098     clear();
5099 }
5100 
LSPD(OLEStreamReader * stream,bool preservePos)5101 LSPD::LSPD(OLEStreamReader *stream, bool preservePos) {
5102     clear();
5103     read(stream, preservePos);
5104 }
5105 
read(OLEStreamReader * stream,bool preservePos)5106 bool LSPD::read(OLEStreamReader *stream, bool preservePos) {
5107 
5108     if(preservePos)
5109         stream->push();
5110 
5111     dyaLine=stream->readU16();
5112     fMultLinespace=stream->readU16();
5113 
5114     if(preservePos)
5115         stream->pop();
5116     return true;
5117 }
5118 
write(OLEStreamWriter * stream,bool preservePos) const5119 bool LSPD::write(OLEStreamWriter *stream, bool preservePos) const {
5120 
5121     if(preservePos)
5122         stream->push();
5123 
5124     stream->write(dyaLine);
5125     stream->write(fMultLinespace);
5126 
5127     if(preservePos)
5128         stream->pop();
5129     return true;
5130 }
5131 
clear()5132 void LSPD::clear() {
5133     dyaLine=0;
5134     fMultLinespace=0;
5135 }
5136 
dump() const5137 void LSPD::dump() const
5138 {
5139     wvlog << "Dumping LSPD:" << std::endl;
5140     wvlog << toString().c_str() << std::endl;
5141     wvlog << "\nDumping LSPD done." << std::endl;
5142 }
5143 
toString() const5144 std::string LSPD::toString() const
5145 {
5146     std::string s( "LSPD:" );
5147     s += "\ndyaLine=";
5148     s += uint2string( dyaLine );
5149     s += "\nfMultLinespace=";
5150     s += uint2string( fMultLinespace );
5151     s += "\nLSPD Done.";
5152     return s;
5153 }
5154 
operator ==(const LSPD & lhs,const LSPD & rhs)5155 bool operator==(const LSPD &lhs, const LSPD &rhs) {
5156 
5157     return lhs.dyaLine==rhs.dyaLine &&
5158            lhs.fMultLinespace==rhs.fMultLinespace;
5159 }
5160 
operator !=(const LSPD & lhs,const LSPD & rhs)5161 bool operator!=(const LSPD &lhs, const LSPD &rhs) {
5162     return !(lhs==rhs);
5163 }
5164 
5165 
5166 // METAFILEPICT implementation
5167 
METAFILEPICT()5168 METAFILEPICT::METAFILEPICT() {
5169     clear();
5170 }
5171 
METAFILEPICT(OLEStreamReader * stream,bool preservePos)5172 METAFILEPICT::METAFILEPICT(OLEStreamReader *stream, bool preservePos) {
5173     clear();
5174     read(stream, preservePos);
5175 }
5176 
read(OLEStreamReader * stream,bool preservePos)5177 bool METAFILEPICT::read(OLEStreamReader *stream, bool preservePos) {
5178 
5179     if(preservePos)
5180         stream->push();
5181 
5182     mm=stream->readU16();
5183     xExt=stream->readU16();
5184     yExt=stream->readU16();
5185     hMF=stream->readU16();
5186 
5187     if(preservePos)
5188         stream->pop();
5189     return true;
5190 }
5191 
write(OLEStreamWriter * stream,bool preservePos) const5192 bool METAFILEPICT::write(OLEStreamWriter *stream, bool preservePos) const {
5193 
5194     if(preservePos)
5195         stream->push();
5196 
5197     stream->write(mm);
5198     stream->write(xExt);
5199     stream->write(yExt);
5200     stream->write(hMF);
5201 
5202     if(preservePos)
5203         stream->pop();
5204     return true;
5205 }
5206 
clear()5207 void METAFILEPICT::clear() {
5208     mm=0;
5209     xExt=0;
5210     yExt=0;
5211     hMF=0;
5212 }
5213 
dump() const5214 void METAFILEPICT::dump() const
5215 {
5216     wvlog << "Dumping METAFILEPICT:" << std::endl;
5217     wvlog << toString().c_str() << std::endl;
5218     wvlog << "\nDumping METAFILEPICT done." << std::endl;
5219 }
5220 
toString() const5221 std::string METAFILEPICT::toString() const
5222 {
5223     std::string s( "METAFILEPICT:" );
5224     s += "\nmm=";
5225     s += uint2string( mm );
5226     s += "\nxExt=";
5227     s += uint2string( xExt );
5228     s += "\nyExt=";
5229     s += uint2string( yExt );
5230     s += "\nhMF=";
5231     s += uint2string( hMF );
5232     s += "\nMETAFILEPICT Done.";
5233     return s;
5234 }
5235 
operator ==(const METAFILEPICT & lhs,const METAFILEPICT & rhs)5236 bool operator==(const METAFILEPICT &lhs, const METAFILEPICT &rhs) {
5237 
5238     return lhs.mm==rhs.mm &&
5239            lhs.xExt==rhs.xExt &&
5240            lhs.yExt==rhs.yExt &&
5241            lhs.hMF==rhs.hMF;
5242 }
5243 
operator !=(const METAFILEPICT & lhs,const METAFILEPICT & rhs)5244 bool operator!=(const METAFILEPICT &lhs, const METAFILEPICT &rhs) {
5245     return !(lhs==rhs);
5246 }
5247 
5248 
5249 // OBJHEADER implementation
5250 
OBJHEADER()5251 OBJHEADER::OBJHEADER() {
5252     clear();
5253 }
5254 
OBJHEADER(OLEStreamReader * stream,bool preservePos)5255 OBJHEADER::OBJHEADER(OLEStreamReader *stream, bool preservePos) {
5256     clear();
5257     read(stream, preservePos);
5258 }
5259 
read(OLEStreamReader * stream,bool preservePos)5260 bool OBJHEADER::read(OLEStreamReader *stream, bool preservePos) {
5261 
5262     if(preservePos)
5263         stream->push();
5264 
5265     lcb=stream->readU32();
5266     cbHeader=stream->readU16();
5267     icf=stream->readU16();
5268 
5269     if(preservePos)
5270         stream->pop();
5271     return true;
5272 }
5273 
write(OLEStreamWriter * stream,bool preservePos) const5274 bool OBJHEADER::write(OLEStreamWriter *stream, bool preservePos) const {
5275 
5276     if(preservePos)
5277         stream->push();
5278 
5279     stream->write(lcb);
5280     stream->write(cbHeader);
5281     stream->write(icf);
5282 
5283     if(preservePos)
5284         stream->pop();
5285     return true;
5286 }
5287 
clear()5288 void OBJHEADER::clear() {
5289     lcb=0;
5290     cbHeader=0;
5291     icf=0;
5292 }
5293 
operator ==(const OBJHEADER & lhs,const OBJHEADER & rhs)5294 bool operator==(const OBJHEADER &lhs, const OBJHEADER &rhs) {
5295 
5296     return lhs.lcb==rhs.lcb &&
5297            lhs.cbHeader==rhs.cbHeader &&
5298            lhs.icf==rhs.icf;
5299 }
5300 
operator !=(const OBJHEADER & lhs,const OBJHEADER & rhs)5301 bool operator!=(const OBJHEADER &lhs, const OBJHEADER &rhs) {
5302     return !(lhs==rhs);
5303 }
5304 
5305 
5306 // OLST implementation
5307 
5308 const unsigned int OLST::sizeOf = 212;
5309 
OLST()5310 OLST::OLST() {
5311     clear();
5312 }
5313 
OLST(OLEStreamReader * stream,bool preservePos)5314 OLST::OLST(OLEStreamReader *stream, bool preservePos) {
5315     clear();
5316     read(stream, preservePos);
5317 }
5318 
OLST(const U8 * ptr)5319 OLST::OLST(const U8 *ptr) {
5320     clear();
5321     readPtr(ptr);
5322 }
5323 
read(OLEStreamReader * stream,bool preservePos)5324 bool OLST::read(OLEStreamReader *stream, bool preservePos) {
5325 
5326     if(preservePos)
5327         stream->push();
5328 
5329     for(int _i=0; _i<(9); ++_i)
5330         rganlv[_i].read(stream, false);
5331     fRestartHdr=stream->readU8();
5332     fSpareOlst2=stream->readU8();
5333     fSpareOlst3=stream->readU8();
5334     fSpareOlst4=stream->readU8();
5335     for(int _i=0; _i<(64); ++_i)
5336         rgch[_i]=stream->readU8();
5337 
5338     if(preservePos)
5339         stream->pop();
5340     return true;
5341 }
5342 
readPtr(const U8 * ptr)5343 void OLST::readPtr(const U8 *ptr) {
5344 
5345     for(int _i=0; _i<(9); ++_i) {
5346         rganlv[_i].readPtr(ptr);
5347         ptr+=ANLV::sizeOf;
5348     }
5349     fRestartHdr=readU8(ptr);
5350     ptr+=sizeof(U8);
5351     fSpareOlst2=readU8(ptr);
5352     ptr+=sizeof(U8);
5353     fSpareOlst3=readU8(ptr);
5354     ptr+=sizeof(U8);
5355     fSpareOlst4=readU8(ptr);
5356     ptr+=sizeof(U8);
5357     for(int _i=0; _i<(64); ++_i) {
5358         rgch[_i]=readU8(ptr);
5359         ptr+=sizeof(U8);
5360     }
5361 }
5362 
write(OLEStreamWriter * stream,bool preservePos) const5363 bool OLST::write(OLEStreamWriter *stream, bool preservePos) const {
5364 
5365     if(preservePos)
5366         stream->push();
5367 
5368     for(int _i=0; _i<(9); ++_i)
5369         rganlv[_i].write(stream, false);
5370     stream->write(fRestartHdr);
5371     stream->write(fSpareOlst2);
5372     stream->write(fSpareOlst3);
5373     stream->write(fSpareOlst4);
5374     for(int _i=0; _i<(64); ++_i)
5375         stream->write(rgch[_i]);
5376 
5377     if(preservePos)
5378         stream->pop();
5379     return true;
5380 }
5381 
clear()5382 void OLST::clear() {
5383     for(int _i=0; _i<(9); ++_i)
5384         rganlv[_i].clear();
5385     fRestartHdr=0;
5386     fSpareOlst2=0;
5387     fSpareOlst3=0;
5388     fSpareOlst4=0;
5389     for(int _i=0; _i<(64); ++_i)
5390         rgch[_i]=0;
5391 }
5392 
dump() const5393 void OLST::dump() const
5394 {
5395     wvlog << "Dumping OLST:" << std::endl;
5396     wvlog << toString().c_str() << std::endl;
5397     wvlog << "\nDumping OLST done." << std::endl;
5398 }
5399 
toString() const5400 std::string OLST::toString() const
5401 {
5402     std::string s( "OLST:" );
5403     for(int _i=0; _i<(9); ++_i) {
5404         s += "\nrganlv[" + int2string( _i ) + "]=";
5405     s += "\n{" + rganlv[_i].toString() + "}\n";
5406     }
5407     s += "\nfRestartHdr=";
5408     s += uint2string( fRestartHdr );
5409     s += "\nfSpareOlst2=";
5410     s += uint2string( fSpareOlst2 );
5411     s += "\nfSpareOlst3=";
5412     s += uint2string( fSpareOlst3 );
5413     s += "\nfSpareOlst4=";
5414     s += uint2string( fSpareOlst4 );
5415     for(int _i=0; _i<(64); ++_i) {
5416         s += "\nrgch[" + int2string( _i ) + "]=";
5417     s += uint2string( rgch[_i] );
5418     }
5419     s += "\nOLST Done.";
5420     return s;
5421 }
5422 
operator ==(const OLST & lhs,const OLST & rhs)5423 bool operator==(const OLST &lhs, const OLST &rhs) {
5424 
5425     for(int _i=0; _i<(9); ++_i) {
5426         if(lhs.rganlv[_i]!=rhs.rganlv[_i])
5427             return false;
5428     }
5429 
5430     for(int _i=0; _i<(64); ++_i) {
5431         if(lhs.rgch[_i]!=rhs.rgch[_i])
5432             return false;
5433     }
5434 
5435     return lhs.fRestartHdr==rhs.fRestartHdr &&
5436            lhs.fSpareOlst2==rhs.fSpareOlst2 &&
5437            lhs.fSpareOlst3==rhs.fSpareOlst3 &&
5438            lhs.fSpareOlst4==rhs.fSpareOlst4;
5439 }
5440 
operator !=(const OLST & lhs,const OLST & rhs)5441 bool operator!=(const OLST &lhs, const OLST &rhs) {
5442     return !(lhs==rhs);
5443 }
5444 
5445 
5446 // PAP implementation
5447 
PAP()5448 PAP::PAP() : Shared() {
5449     clearInternal();
5450 }
5451 
PAP(OLEStreamReader * stream,bool preservePos)5452 PAP::PAP(OLEStreamReader *stream, bool preservePos) : Shared() {
5453     clearInternal();
5454     read(stream, preservePos);
5455 }
5456 
PAP(const PAP & rhs)5457 PAP::PAP(const PAP &rhs) : Shared() {
5458     istd=rhs.istd;
5459     jc=rhs.jc;
5460     fKeep=rhs.fKeep;
5461     fKeepFollow=rhs.fKeepFollow;
5462     fPageBreakBefore=rhs.fPageBreakBefore;
5463     fBrLnAbove=rhs.fBrLnAbove;
5464     fBrLnBelow=rhs.fBrLnBelow;
5465     fUnused=rhs.fUnused;
5466     pcVert=rhs.pcVert;
5467     pcHorz=rhs.pcHorz;
5468     brcp=rhs.brcp;
5469     brcl=rhs.brcl;
5470     unused9=rhs.unused9;
5471     nLvlAnm=rhs.nLvlAnm;
5472     fNoLnn=rhs.fNoLnn;
5473     fSideBySide=rhs.fSideBySide;
5474     dxaRight=rhs.dxaRight;
5475     dxaLeft=rhs.dxaLeft;
5476     dxaLeft1=rhs.dxaLeft1;
5477     lspd=rhs.lspd;
5478     dyaBefore=rhs.dyaBefore;
5479     dyaAfter=rhs.dyaAfter;
5480     phe=rhs.phe;
5481     fAutoHyph=rhs.fAutoHyph;
5482     fWidowControl=rhs.fWidowControl;
5483     fInTable=rhs.fInTable;
5484     fTtp=rhs.fTtp;
5485     ptap=rhs.ptap;
5486     dxaAbs=rhs.dxaAbs;
5487     dyaAbs=rhs.dyaAbs;
5488     dxaWidth=rhs.dxaWidth;
5489     brcTop=rhs.brcTop;
5490     brcLeft=rhs.brcLeft;
5491     brcBottom=rhs.brcBottom;
5492     brcRight=rhs.brcRight;
5493     brcBetween=rhs.brcBetween;
5494     brcBar=rhs.brcBar;
5495     dxaFromText=rhs.dxaFromText;
5496     dyaFromText=rhs.dyaFromText;
5497     wr=rhs.wr;
5498     fLocked=rhs.fLocked;
5499     dyaHeight=rhs.dyaHeight;
5500     fMinHeight=rhs.fMinHeight;
5501     shd=rhs.shd;
5502     dcs=rhs.dcs;
5503     anld=rhs.anld;
5504     itbdMac=rhs.itbdMac;
5505     rgdxaTab=new U16[itbdMac];
5506     memcpy(rgdxaTab, rhs.rgdxaTab, sizeof(U16)*(itbdMac));
5507     rgtbd=new U8[itbdMac];
5508     memcpy(rgtbd, rhs.rgtbd, sizeof(U8)*(itbdMac));
5509 }
5510 
~PAP()5511 PAP::~PAP() {
5512     delete [] rgdxaTab;
5513     delete [] rgtbd;
5514 }
5515 
operator =(const PAP & rhs)5516 PAP &PAP::operator=(const PAP &rhs) {
5517 
5518     // Check for assignment to self
5519     if(this==&rhs)
5520         return *this;
5521 
5522     istd=rhs.istd;
5523     jc=rhs.jc;
5524     fKeep=rhs.fKeep;
5525     fKeepFollow=rhs.fKeepFollow;
5526     fPageBreakBefore=rhs.fPageBreakBefore;
5527     fBrLnAbove=rhs.fBrLnAbove;
5528     fBrLnBelow=rhs.fBrLnBelow;
5529     fUnused=rhs.fUnused;
5530     pcVert=rhs.pcVert;
5531     pcHorz=rhs.pcHorz;
5532     brcp=rhs.brcp;
5533     brcl=rhs.brcl;
5534     unused9=rhs.unused9;
5535     nLvlAnm=rhs.nLvlAnm;
5536     fNoLnn=rhs.fNoLnn;
5537     fSideBySide=rhs.fSideBySide;
5538     dxaRight=rhs.dxaRight;
5539     dxaLeft=rhs.dxaLeft;
5540     dxaLeft1=rhs.dxaLeft1;
5541     lspd=rhs.lspd;
5542     dyaBefore=rhs.dyaBefore;
5543     dyaAfter=rhs.dyaAfter;
5544     phe=rhs.phe;
5545     fAutoHyph=rhs.fAutoHyph;
5546     fWidowControl=rhs.fWidowControl;
5547     fInTable=rhs.fInTable;
5548     fTtp=rhs.fTtp;
5549     ptap=rhs.ptap;
5550     dxaAbs=rhs.dxaAbs;
5551     dyaAbs=rhs.dyaAbs;
5552     dxaWidth=rhs.dxaWidth;
5553     brcTop=rhs.brcTop;
5554     brcLeft=rhs.brcLeft;
5555     brcBottom=rhs.brcBottom;
5556     brcRight=rhs.brcRight;
5557     brcBetween=rhs.brcBetween;
5558     brcBar=rhs.brcBar;
5559     dxaFromText=rhs.dxaFromText;
5560     dyaFromText=rhs.dyaFromText;
5561     wr=rhs.wr;
5562     fLocked=rhs.fLocked;
5563     dyaHeight=rhs.dyaHeight;
5564     fMinHeight=rhs.fMinHeight;
5565     shd=rhs.shd;
5566     dcs=rhs.dcs;
5567     anld=rhs.anld;
5568     itbdMac=rhs.itbdMac;
5569     delete [] rgdxaTab;
5570     rgdxaTab=new U16[itbdMac];
5571     memcpy(rgdxaTab, rhs.rgdxaTab, sizeof(U16)*(itbdMac));
5572     delete [] rgtbd;
5573     rgtbd=new U8[itbdMac];
5574     memcpy(rgtbd, rhs.rgtbd, sizeof(U8)*(itbdMac));
5575 
5576     return *this;
5577 }
5578 
read(OLEStreamReader * stream,bool preservePos)5579 bool PAP::read(OLEStreamReader *stream, bool preservePos) {
5580 
5581     U8 shifterU8;
5582     U16 shifterU16;
5583 
5584     if(preservePos)
5585         stream->push();
5586 
5587     istd=stream->readU16();
5588     jc=stream->readU8();
5589     fKeep=stream->readU8();
5590     fKeepFollow=stream->readU8();
5591     fPageBreakBefore=stream->readU8();
5592     shifterU8=stream->readU8();
5593     fBrLnAbove=shifterU8;
5594     shifterU8>>=1;
5595     fBrLnBelow=shifterU8;
5596     shifterU8>>=1;
5597     fUnused=shifterU8;
5598     shifterU8>>=2;
5599     pcVert=shifterU8;
5600     shifterU8>>=2;
5601     pcHorz=shifterU8;
5602     brcp=stream->readU8();
5603     brcl=stream->readU8();
5604     unused9=stream->readU8();
5605     nLvlAnm=stream->readU8();
5606     fNoLnn=stream->readU8();
5607     fSideBySide=stream->readU8();
5608     dxaRight=stream->readS16();
5609     dxaLeft=stream->readS16();
5610     dxaLeft1=stream->readS16();
5611     lspd.read(stream, false);
5612     dyaBefore=stream->readU16();
5613     dyaAfter=stream->readU16();
5614     phe.read(stream, false);
5615     fAutoHyph=stream->readU8();
5616     fWidowControl=stream->readU8();
5617     fInTable=stream->readU8();
5618     fTtp=stream->readU8();
5619     ptap=stream->readU16();
5620     dxaAbs=stream->readS16();
5621     dyaAbs=stream->readS16();
5622     dxaWidth=stream->readU16();
5623     brcTop.read(stream, false);
5624     brcLeft.read(stream, false);
5625     brcBottom.read(stream, false);
5626     brcRight.read(stream, false);
5627     brcBetween.read(stream, false);
5628     brcBar.read(stream, false);
5629     dxaFromText=stream->readU16();
5630     dyaFromText=stream->readU16();
5631     wr=stream->readU8();
5632     fLocked=stream->readU8();
5633     shifterU16=stream->readU16();
5634     dyaHeight=shifterU16;
5635     shifterU16>>=15;
5636     fMinHeight=shifterU16;
5637     shd.read(stream, false);
5638     dcs.read(stream, false);
5639     anld.read(stream, false);
5640     itbdMac=stream->readU16();
5641     rgdxaTab=new U16[itbdMac];
5642     for(int _i=0; _i<(itbdMac); ++_i)
5643         rgdxaTab[_i]=stream->readU16();
5644     rgtbd=new U8[itbdMac];
5645     for(int _i=0; _i<(itbdMac); ++_i)
5646         rgtbd[_i]=stream->readU8();
5647 
5648     if(preservePos)
5649         stream->pop();
5650     return true;
5651 }
5652 
write(OLEStreamWriter * stream,bool preservePos) const5653 bool PAP::write(OLEStreamWriter *stream, bool preservePos) const {
5654 
5655     U8 shifterU8;
5656     U16 shifterU16;
5657 
5658     if(preservePos)
5659         stream->push();
5660 
5661     stream->write(istd);
5662     stream->write(jc);
5663     stream->write(fKeep);
5664     stream->write(fKeepFollow);
5665     stream->write(fPageBreakBefore);
5666     shifterU8=fBrLnAbove;
5667     shifterU8|=fBrLnBelow << 1;
5668     shifterU8|=fUnused << 2;
5669     shifterU8|=pcVert << 4;
5670     shifterU8|=pcHorz << 6;
5671     stream->write(shifterU8);
5672     stream->write(brcp);
5673     stream->write(brcl);
5674     stream->write(unused9);
5675     stream->write(nLvlAnm);
5676     stream->write(fNoLnn);
5677     stream->write(fSideBySide);
5678     stream->write(dxaRight);
5679     stream->write(dxaLeft);
5680     stream->write(dxaLeft1);
5681     lspd.write(stream, false);
5682     stream->write(dyaBefore);
5683     stream->write(dyaAfter);
5684     phe.write(stream, false);
5685     stream->write(fAutoHyph);
5686     stream->write(fWidowControl);
5687     stream->write(fInTable);
5688     stream->write(fTtp);
5689     stream->write(ptap);
5690     stream->write(dxaAbs);
5691     stream->write(dyaAbs);
5692     stream->write(dxaWidth);
5693     brcTop.write(stream, false);
5694     brcLeft.write(stream, false);
5695     brcBottom.write(stream, false);
5696     brcRight.write(stream, false);
5697     brcBetween.write(stream, false);
5698     brcBar.write(stream, false);
5699     stream->write(dxaFromText);
5700     stream->write(dyaFromText);
5701     stream->write(wr);
5702     stream->write(fLocked);
5703     shifterU16=dyaHeight;
5704     shifterU16|=fMinHeight << 15;
5705     stream->write(shifterU16);
5706     shd.write(stream, false);
5707     dcs.write(stream, false);
5708     anld.write(stream, false);
5709     stream->write(itbdMac);
5710     for(int _i=0; _i<(itbdMac); ++_i)
5711         stream->write(rgdxaTab[_i]);
5712     for(int _i=0; _i<(itbdMac); ++_i)
5713         stream->write(rgtbd[_i]);
5714 
5715     if(preservePos)
5716         stream->pop();
5717     return true;
5718 }
5719 
clear()5720 void PAP::clear() {
5721     delete [] rgdxaTab;
5722     delete [] rgtbd;
5723     clearInternal();
5724 }
5725 
dump() const5726 void PAP::dump() const
5727 {
5728     wvlog << "Dumping PAP:" << std::endl;
5729     wvlog << toString().c_str() << std::endl;
5730     wvlog << "\nDumping PAP done." << std::endl;
5731 }
5732 
toString() const5733 std::string PAP::toString() const
5734 {
5735     std::string s( "PAP:" );
5736     s += "\nistd=";
5737     s += uint2string( istd );
5738     s += "\njc=";
5739     s += uint2string( jc );
5740     s += "\nfKeep=";
5741     s += uint2string( fKeep );
5742     s += "\nfKeepFollow=";
5743     s += uint2string( fKeepFollow );
5744     s += "\nfPageBreakBefore=";
5745     s += uint2string( fPageBreakBefore );
5746     s += "\nfBrLnAbove=";
5747     s += uint2string( fBrLnAbove );
5748     s += "\nfBrLnBelow=";
5749     s += uint2string( fBrLnBelow );
5750     s += "\nfUnused=";
5751     s += uint2string( fUnused );
5752     s += "\npcVert=";
5753     s += uint2string( pcVert );
5754     s += "\npcHorz=";
5755     s += uint2string( pcHorz );
5756     s += "\nbrcp=";
5757     s += uint2string( brcp );
5758     s += "\nbrcl=";
5759     s += uint2string( brcl );
5760     s += "\nunused9=";
5761     s += uint2string( unused9 );
5762     s += "\nnLvlAnm=";
5763     s += uint2string( nLvlAnm );
5764     s += "\nfNoLnn=";
5765     s += uint2string( fNoLnn );
5766     s += "\nfSideBySide=";
5767     s += uint2string( fSideBySide );
5768     s += "\ndxaRight=";
5769     s += int2string( dxaRight );
5770     s += "\ndxaLeft=";
5771     s += int2string( dxaLeft );
5772     s += "\ndxaLeft1=";
5773     s += int2string( dxaLeft1 );
5774     s += "\nlspd=";
5775     s += "\n{" + lspd.toString() + "}\n";
5776     s += "\ndyaBefore=";
5777     s += uint2string( dyaBefore );
5778     s += "\ndyaAfter=";
5779     s += uint2string( dyaAfter );
5780     s += "\nphe=";
5781     s += "\n{" + phe.toString() + "}\n";
5782     s += "\nfAutoHyph=";
5783     s += uint2string( fAutoHyph );
5784     s += "\nfWidowControl=";
5785     s += uint2string( fWidowControl );
5786     s += "\nfInTable=";
5787     s += uint2string( fInTable );
5788     s += "\nfTtp=";
5789     s += uint2string( fTtp );
5790     s += "\nptap=";
5791     s += uint2string( ptap );
5792     s += "\ndxaAbs=";
5793     s += int2string( dxaAbs );
5794     s += "\ndyaAbs=";
5795     s += int2string( dyaAbs );
5796     s += "\ndxaWidth=";
5797     s += uint2string( dxaWidth );
5798     s += "\nbrcTop=";
5799     s += "\n{" + brcTop.toString() + "}\n";
5800     s += "\nbrcLeft=";
5801     s += "\n{" + brcLeft.toString() + "}\n";
5802     s += "\nbrcBottom=";
5803     s += "\n{" + brcBottom.toString() + "}\n";
5804     s += "\nbrcRight=";
5805     s += "\n{" + brcRight.toString() + "}\n";
5806     s += "\nbrcBetween=";
5807     s += "\n{" + brcBetween.toString() + "}\n";
5808     s += "\nbrcBar=";
5809     s += "\n{" + brcBar.toString() + "}\n";
5810     s += "\ndxaFromText=";
5811     s += uint2string( dxaFromText );
5812     s += "\ndyaFromText=";
5813     s += uint2string( dyaFromText );
5814     s += "\nwr=";
5815     s += uint2string( wr );
5816     s += "\nfLocked=";
5817     s += uint2string( fLocked );
5818     s += "\ndyaHeight=";
5819     s += uint2string( dyaHeight );
5820     s += "\nfMinHeight=";
5821     s += uint2string( fMinHeight );
5822     s += "\nshd=";
5823     s += "\n{" + shd.toString() + "}\n";
5824     s += "\ndcs=";
5825     s += "\n{" + dcs.toString() + "}\n";
5826     s += "\nanld=";
5827     s += "\n{" + anld.toString() + "}\n";
5828     s += "\nitbdMac=";
5829     s += uint2string( itbdMac );
5830     for(int _i=0; _i<(itbdMac); ++_i) {
5831         s += "\nrgdxaTab[" + int2string( _i ) + "]=";
5832     s += uint2string( rgdxaTab[_i] );
5833     }
5834     for(int _i=0; _i<(itbdMac); ++_i) {
5835         s += "\nrgtbd[" + int2string( _i ) + "]=";
5836     s += uint2string( rgtbd[_i] );
5837     }
5838     s += "\nPAP Done.";
5839     return s;
5840 }
5841 
clearInternal()5842 void PAP::clearInternal() {
5843     istd=0;
5844     jc=0;
5845     fKeep=0;
5846     fKeepFollow=0;
5847     fPageBreakBefore=0;
5848     fBrLnAbove=0;
5849     fBrLnBelow=0;
5850     fUnused=0;
5851     pcVert=0;
5852     pcHorz=0;
5853     brcp=0;
5854     brcl=0;
5855     unused9=0;
5856     nLvlAnm=0;
5857     fNoLnn=0;
5858     fSideBySide=0;
5859     dxaRight=0;
5860     dxaLeft=0;
5861     dxaLeft1=0;
5862     lspd.clear();
5863     dyaBefore=0;
5864     dyaAfter=0;
5865     phe.clear();
5866     fAutoHyph=0;
5867     fWidowControl=0;
5868     fInTable=0;
5869     fTtp=0;
5870     ptap=0;
5871     dxaAbs=0;
5872     dyaAbs=0;
5873     dxaWidth=0;
5874     brcTop.clear();
5875     brcLeft.clear();
5876     brcBottom.clear();
5877     brcRight.clear();
5878     brcBetween.clear();
5879     brcBar.clear();
5880     dxaFromText=0;
5881     dyaFromText=0;
5882     wr=0;
5883     fLocked=0;
5884     dyaHeight=0;
5885     fMinHeight=0;
5886     shd.clear();
5887     dcs.clear();
5888     anld.clear();
5889     itbdMac=0;
5890     rgdxaTab=0;
5891     rgtbd=0;
5892 }
5893 
operator ==(const PAP & lhs,const PAP & rhs)5894 bool operator==(const PAP &lhs, const PAP &rhs) {
5895 
5896     if((lhs.itbdMac)!=(rhs.itbdMac))
5897         return false;
5898     for(int _i=0; _i<(lhs.itbdMac); ++_i) {
5899         if(lhs.rgdxaTab[_i]!=rhs.rgdxaTab[_i])
5900             return false;
5901     }
5902 
5903     if((lhs.itbdMac)!=(rhs.itbdMac))
5904         return false;
5905     for(int _i=0; _i<(lhs.itbdMac); ++_i) {
5906         if(lhs.rgtbd[_i]!=rhs.rgtbd[_i])
5907             return false;
5908     }
5909 
5910     return lhs.istd==rhs.istd &&
5911            lhs.jc==rhs.jc &&
5912            lhs.fKeep==rhs.fKeep &&
5913            lhs.fKeepFollow==rhs.fKeepFollow &&
5914            lhs.fPageBreakBefore==rhs.fPageBreakBefore &&
5915            lhs.fBrLnAbove==rhs.fBrLnAbove &&
5916            lhs.fBrLnBelow==rhs.fBrLnBelow &&
5917            lhs.fUnused==rhs.fUnused &&
5918            lhs.pcVert==rhs.pcVert &&
5919            lhs.pcHorz==rhs.pcHorz &&
5920            lhs.brcp==rhs.brcp &&
5921            lhs.brcl==rhs.brcl &&
5922            lhs.unused9==rhs.unused9 &&
5923            lhs.nLvlAnm==rhs.nLvlAnm &&
5924            lhs.fNoLnn==rhs.fNoLnn &&
5925            lhs.fSideBySide==rhs.fSideBySide &&
5926            lhs.dxaRight==rhs.dxaRight &&
5927            lhs.dxaLeft==rhs.dxaLeft &&
5928            lhs.dxaLeft1==rhs.dxaLeft1 &&
5929            lhs.lspd==rhs.lspd &&
5930            lhs.dyaBefore==rhs.dyaBefore &&
5931            lhs.dyaAfter==rhs.dyaAfter &&
5932            lhs.phe==rhs.phe &&
5933            lhs.fAutoHyph==rhs.fAutoHyph &&
5934            lhs.fWidowControl==rhs.fWidowControl &&
5935            lhs.fInTable==rhs.fInTable &&
5936            lhs.fTtp==rhs.fTtp &&
5937            lhs.ptap==rhs.ptap &&
5938            lhs.dxaAbs==rhs.dxaAbs &&
5939            lhs.dyaAbs==rhs.dyaAbs &&
5940            lhs.dxaWidth==rhs.dxaWidth &&
5941            lhs.brcTop==rhs.brcTop &&
5942            lhs.brcLeft==rhs.brcLeft &&
5943            lhs.brcBottom==rhs.brcBottom &&
5944            lhs.brcRight==rhs.brcRight &&
5945            lhs.brcBetween==rhs.brcBetween &&
5946            lhs.brcBar==rhs.brcBar &&
5947            lhs.dxaFromText==rhs.dxaFromText &&
5948            lhs.dyaFromText==rhs.dyaFromText &&
5949            lhs.wr==rhs.wr &&
5950            lhs.fLocked==rhs.fLocked &&
5951            lhs.dyaHeight==rhs.dyaHeight &&
5952            lhs.fMinHeight==rhs.fMinHeight &&
5953            lhs.shd==rhs.shd &&
5954            lhs.dcs==rhs.dcs &&
5955            lhs.anld==rhs.anld &&
5956            lhs.itbdMac==rhs.itbdMac;
5957 }
5958 
operator !=(const PAP & lhs,const PAP & rhs)5959 bool operator!=(const PAP &lhs, const PAP &rhs) {
5960     return !(lhs==rhs);
5961 }
5962 
5963 
5964 // PCD implementation
5965 
5966 const unsigned int PCD::sizeOf = 8;
5967 
PCD()5968 PCD::PCD() {
5969     clear();
5970 }
5971 
PCD(OLEStreamReader * stream,bool preservePos)5972 PCD::PCD(OLEStreamReader *stream, bool preservePos) {
5973     clear();
5974     read(stream, preservePos);
5975 }
5976 
PCD(const U8 * ptr)5977 PCD::PCD(const U8 *ptr) {
5978     clear();
5979     readPtr(ptr);
5980 }
5981 
read(OLEStreamReader * stream,bool preservePos)5982 bool PCD::read(OLEStreamReader *stream, bool preservePos) {
5983 
5984     U16 shifterU16;
5985 
5986     if(preservePos)
5987         stream->push();
5988 
5989     shifterU16=stream->readU16();
5990     fNoParaLast=shifterU16;
5991     shifterU16>>=1;
5992     fPaphNil=shifterU16;
5993     shifterU16>>=1;
5994     fCopied=shifterU16;
5995     shifterU16>>=1;
5996     unused0_3=shifterU16;
5997     shifterU16>>=5;
5998     fn=shifterU16;
5999     fc=stream->readU32();
6000     prm.read(stream, false);
6001 
6002     if(preservePos)
6003         stream->pop();
6004     return true;
6005 }
6006 
readPtr(const U8 * ptr)6007 void PCD::readPtr(const U8 *ptr) {
6008 
6009     U16 shifterU16;
6010 
6011     shifterU16=readU16(ptr);
6012     ptr+=sizeof(U16);
6013     fNoParaLast=shifterU16;
6014     shifterU16>>=1;
6015     fPaphNil=shifterU16;
6016     shifterU16>>=1;
6017     fCopied=shifterU16;
6018     shifterU16>>=1;
6019     unused0_3=shifterU16;
6020     shifterU16>>=5;
6021     fn=shifterU16;
6022     fc=readU32(ptr);
6023     ptr+=sizeof(U32);
6024     prm.readPtr(ptr);
6025     ptr+=PRM::sizeOf;
6026 }
6027 
write(OLEStreamWriter * stream,bool preservePos) const6028 bool PCD::write(OLEStreamWriter *stream, bool preservePos) const {
6029 
6030     U16 shifterU16;
6031 
6032     if(preservePos)
6033         stream->push();
6034 
6035     shifterU16=fNoParaLast;
6036     shifterU16|=fPaphNil << 1;
6037     shifterU16|=fCopied << 2;
6038     shifterU16|=unused0_3 << 3;
6039     shifterU16|=fn << 8;
6040     stream->write(shifterU16);
6041     stream->write(fc);
6042     prm.write(stream, false);
6043 
6044     if(preservePos)
6045         stream->pop();
6046     return true;
6047 }
6048 
clear()6049 void PCD::clear() {
6050     fNoParaLast=0;
6051     fPaphNil=0;
6052     fCopied=0;
6053     unused0_3=0;
6054     fn=0;
6055     fc=0;
6056     prm.clear();
6057 }
6058 
operator ==(const PCD & lhs,const PCD & rhs)6059 bool operator==(const PCD &lhs, const PCD &rhs) {
6060 
6061     return lhs.fNoParaLast==rhs.fNoParaLast &&
6062            lhs.fPaphNil==rhs.fPaphNil &&
6063            lhs.fCopied==rhs.fCopied &&
6064            lhs.unused0_3==rhs.unused0_3 &&
6065            lhs.fn==rhs.fn &&
6066            lhs.fc==rhs.fc &&
6067            lhs.prm==rhs.prm;
6068 }
6069 
operator !=(const PCD & lhs,const PCD & rhs)6070 bool operator!=(const PCD &lhs, const PCD &rhs) {
6071     return !(lhs==rhs);
6072 }
6073 
6074 
6075 // PGD implementation
6076 
PGD()6077 PGD::PGD() {
6078     clear();
6079 }
6080 
PGD(OLEStreamReader * stream,bool preservePos)6081 PGD::PGD(OLEStreamReader *stream, bool preservePos) {
6082     clear();
6083     read(stream, preservePos);
6084 }
6085 
read(OLEStreamReader * stream,bool preservePos)6086 bool PGD::read(OLEStreamReader *stream, bool preservePos) {
6087 
6088     U16 shifterU16;
6089 
6090     if(preservePos)
6091         stream->push();
6092 
6093     shifterU16=stream->readU16();
6094     unused0_0=shifterU16;
6095     shifterU16>>=5;
6096     fGhost=shifterU16;
6097     shifterU16>>=2;
6098     unused0_7=shifterU16;
6099     shifterU16=stream->readU16();
6100     fContinue=shifterU16;
6101     shifterU16>>=1;
6102     fUnk=shifterU16;
6103     shifterU16>>=1;
6104     fRight=shifterU16;
6105     shifterU16>>=1;
6106     fPgnRestart=shifterU16;
6107     shifterU16>>=1;
6108     fEmptyPage=shifterU16;
6109     shifterU16>>=1;
6110     fAllFtn=shifterU16;
6111     shifterU16>>=1;
6112     fColOnly=shifterU16;
6113     shifterU16>>=1;
6114     fTableBreaks=shifterU16;
6115     shifterU16>>=1;
6116     fMarked=shifterU16;
6117     shifterU16>>=1;
6118     fColumnBreaks=shifterU16;
6119     shifterU16>>=1;
6120     fTableHeader=shifterU16;
6121     shifterU16>>=1;
6122     fNewPage=shifterU16;
6123     shifterU16>>=1;
6124     bkc=shifterU16;
6125     lnn=stream->readU16();
6126     pgn=stream->readU16();
6127 
6128     if(preservePos)
6129         stream->pop();
6130     return true;
6131 }
6132 
write(OLEStreamWriter * stream,bool preservePos) const6133 bool PGD::write(OLEStreamWriter *stream, bool preservePos) const {
6134 
6135     U16 shifterU16;
6136 
6137     if(preservePos)
6138         stream->push();
6139 
6140     shifterU16=unused0_0;
6141     shifterU16|=fGhost << 5;
6142     shifterU16|=unused0_7 << 7;
6143     stream->write(shifterU16);
6144     shifterU16=fContinue;
6145     shifterU16|=fUnk << 1;
6146     shifterU16|=fRight << 2;
6147     shifterU16|=fPgnRestart << 3;
6148     shifterU16|=fEmptyPage << 4;
6149     shifterU16|=fAllFtn << 5;
6150     shifterU16|=fColOnly << 6;
6151     shifterU16|=fTableBreaks << 7;
6152     shifterU16|=fMarked << 8;
6153     shifterU16|=fColumnBreaks << 9;
6154     shifterU16|=fTableHeader << 10;
6155     shifterU16|=fNewPage << 11;
6156     shifterU16|=bkc << 12;
6157     stream->write(shifterU16);
6158     stream->write(lnn);
6159     stream->write(pgn);
6160 
6161     if(preservePos)
6162         stream->pop();
6163     return true;
6164 }
6165 
clear()6166 void PGD::clear() {
6167     unused0_0=0;
6168     fGhost=0;
6169     unused0_7=0;
6170     fContinue=0;
6171     fUnk=0;
6172     fRight=0;
6173     fPgnRestart=0;
6174     fEmptyPage=0;
6175     fAllFtn=0;
6176     fColOnly=0;
6177     fTableBreaks=0;
6178     fMarked=0;
6179     fColumnBreaks=0;
6180     fTableHeader=0;
6181     fNewPage=0;
6182     bkc=0;
6183     lnn=0;
6184     pgn=0;
6185 }
6186 
operator ==(const PGD & lhs,const PGD & rhs)6187 bool operator==(const PGD &lhs, const PGD &rhs) {
6188 
6189     return lhs.unused0_0==rhs.unused0_0 &&
6190            lhs.fGhost==rhs.fGhost &&
6191            lhs.unused0_7==rhs.unused0_7 &&
6192            lhs.fContinue==rhs.fContinue &&
6193            lhs.fUnk==rhs.fUnk &&
6194            lhs.fRight==rhs.fRight &&
6195            lhs.fPgnRestart==rhs.fPgnRestart &&
6196            lhs.fEmptyPage==rhs.fEmptyPage &&
6197            lhs.fAllFtn==rhs.fAllFtn &&
6198            lhs.fColOnly==rhs.fColOnly &&
6199            lhs.fTableBreaks==rhs.fTableBreaks &&
6200            lhs.fMarked==rhs.fMarked &&
6201            lhs.fColumnBreaks==rhs.fColumnBreaks &&
6202            lhs.fTableHeader==rhs.fTableHeader &&
6203            lhs.fNewPage==rhs.fNewPage &&
6204            lhs.bkc==rhs.bkc &&
6205            lhs.lnn==rhs.lnn &&
6206            lhs.pgn==rhs.pgn;
6207 }
6208 
operator !=(const PGD & lhs,const PGD & rhs)6209 bool operator!=(const PGD &lhs, const PGD &rhs) {
6210     return !(lhs==rhs);
6211 }
6212 
6213 
6214 // PICF implementation
6215 
PICF()6216 PICF::PICF() : Shared() {
6217     clear();
6218 }
6219 
PICF(OLEStreamReader * stream,bool preservePos)6220 PICF::PICF(OLEStreamReader *stream, bool preservePos) : Shared() {
6221     clear();
6222     read(stream, preservePos);
6223 }
6224 
read(OLEStreamReader * stream,bool preservePos)6225 bool PICF::read(OLEStreamReader *stream, bool preservePos) {
6226 
6227     U16 shifterU16;
6228 
6229     if(preservePos)
6230         stream->push();
6231 
6232     lcb=stream->readU32();
6233     cbHeader=stream->readU16();
6234     mfp.read(stream, false);
6235     for(int _i=0; _i<(14); ++_i)
6236         bm_rcWinMF[_i]=stream->readU8();
6237     dxaGoal=stream->readU16();
6238     dyaGoal=stream->readU16();
6239     mx=stream->readU16();
6240     my=stream->readU16();
6241     dxaCropLeft=stream->readU16();
6242     dyaCropTop=stream->readU16();
6243     dxaCropRight=stream->readU16();
6244     dyaCropBottom=stream->readU16();
6245     shifterU16=stream->readU16();
6246     brcl=shifterU16;
6247     shifterU16>>=4;
6248     fFrameEmpty=shifterU16;
6249     shifterU16>>=1;
6250     fBitmap=shifterU16;
6251     shifterU16>>=1;
6252     fDrawHatch=shifterU16;
6253     shifterU16>>=1;
6254     fError=shifterU16;
6255     shifterU16>>=1;
6256     bpp=shifterU16;
6257     brcTop.read(stream, false);
6258     brcLeft.read(stream, false);
6259     brcBottom.read(stream, false);
6260     brcRight.read(stream, false);
6261     dxaOrigin=stream->readU16();
6262     dyaOrigin=stream->readU16();
6263 
6264     if(preservePos)
6265         stream->pop();
6266     return true;
6267 }
6268 
write(OLEStreamWriter * stream,bool preservePos) const6269 bool PICF::write(OLEStreamWriter *stream, bool preservePos) const {
6270 
6271     U16 shifterU16;
6272 
6273     if(preservePos)
6274         stream->push();
6275 
6276     stream->write(lcb);
6277     stream->write(cbHeader);
6278     mfp.write(stream, false);
6279     for(int _i=0; _i<(14); ++_i)
6280         stream->write(bm_rcWinMF[_i]);
6281     stream->write(dxaGoal);
6282     stream->write(dyaGoal);
6283     stream->write(mx);
6284     stream->write(my);
6285     stream->write(dxaCropLeft);
6286     stream->write(dyaCropTop);
6287     stream->write(dxaCropRight);
6288     stream->write(dyaCropBottom);
6289     shifterU16=brcl;
6290     shifterU16|=fFrameEmpty << 4;
6291     shifterU16|=fBitmap << 5;
6292     shifterU16|=fDrawHatch << 6;
6293     shifterU16|=fError << 7;
6294     shifterU16|=bpp << 8;
6295     stream->write(shifterU16);
6296     brcTop.write(stream, false);
6297     brcLeft.write(stream, false);
6298     brcBottom.write(stream, false);
6299     brcRight.write(stream, false);
6300     stream->write(dxaOrigin);
6301     stream->write(dyaOrigin);
6302 
6303     if(preservePos)
6304         stream->pop();
6305     return true;
6306 }
6307 
clear()6308 void PICF::clear() {
6309     lcb=0;
6310     cbHeader=0;
6311     mfp.clear();
6312     for(int _i=0; _i<(14); ++_i)
6313         bm_rcWinMF[_i]=0;
6314     dxaGoal=0;
6315     dyaGoal=0;
6316     mx=0;
6317     my=0;
6318     dxaCropLeft=0;
6319     dyaCropTop=0;
6320     dxaCropRight=0;
6321     dyaCropBottom=0;
6322     brcl=0;
6323     fFrameEmpty=0;
6324     fBitmap=0;
6325     fDrawHatch=0;
6326     fError=0;
6327     bpp=0;
6328     brcTop.clear();
6329     brcLeft.clear();
6330     brcBottom.clear();
6331     brcRight.clear();
6332     dxaOrigin=0;
6333     dyaOrigin=0;
6334 }
6335 
dump() const6336 void PICF::dump() const
6337 {
6338     wvlog << "Dumping PICF:" << std::endl;
6339     wvlog << toString().c_str() << std::endl;
6340     wvlog << "\nDumping PICF done." << std::endl;
6341 }
6342 
toString() const6343 std::string PICF::toString() const
6344 {
6345     std::string s( "PICF:" );
6346     s += "\nlcb=";
6347     s += uint2string( lcb );
6348     s += "\ncbHeader=";
6349     s += uint2string( cbHeader );
6350     s += "\nmfp=";
6351     s += "\n{" + mfp.toString() + "}\n";
6352     for(int _i=0; _i<(14); ++_i) {
6353         s += "\nbm_rcWinMF[" + int2string( _i ) + "]=";
6354     s += uint2string( bm_rcWinMF[_i] );
6355     }
6356     s += "\ndxaGoal=";
6357     s += uint2string( dxaGoal );
6358     s += "\ndyaGoal=";
6359     s += uint2string( dyaGoal );
6360     s += "\nmx=";
6361     s += uint2string( mx );
6362     s += "\nmy=";
6363     s += uint2string( my );
6364     s += "\ndxaCropLeft=";
6365     s += uint2string( dxaCropLeft );
6366     s += "\ndyaCropTop=";
6367     s += uint2string( dyaCropTop );
6368     s += "\ndxaCropRight=";
6369     s += uint2string( dxaCropRight );
6370     s += "\ndyaCropBottom=";
6371     s += uint2string( dyaCropBottom );
6372     s += "\nbrcl=";
6373     s += uint2string( brcl );
6374     s += "\nfFrameEmpty=";
6375     s += uint2string( fFrameEmpty );
6376     s += "\nfBitmap=";
6377     s += uint2string( fBitmap );
6378     s += "\nfDrawHatch=";
6379     s += uint2string( fDrawHatch );
6380     s += "\nfError=";
6381     s += uint2string( fError );
6382     s += "\nbpp=";
6383     s += uint2string( bpp );
6384     s += "\nbrcTop=";
6385     s += "\n{" + brcTop.toString() + "}\n";
6386     s += "\nbrcLeft=";
6387     s += "\n{" + brcLeft.toString() + "}\n";
6388     s += "\nbrcBottom=";
6389     s += "\n{" + brcBottom.toString() + "}\n";
6390     s += "\nbrcRight=";
6391     s += "\n{" + brcRight.toString() + "}\n";
6392     s += "\ndxaOrigin=";
6393     s += uint2string( dxaOrigin );
6394     s += "\ndyaOrigin=";
6395     s += uint2string( dyaOrigin );
6396     s += "\nPICF Done.";
6397     return s;
6398 }
6399 
operator ==(const PICF & lhs,const PICF & rhs)6400 bool operator==(const PICF &lhs, const PICF &rhs) {
6401 
6402     for(int _i=0; _i<(14); ++_i) {
6403         if(lhs.bm_rcWinMF[_i]!=rhs.bm_rcWinMF[_i])
6404             return false;
6405     }
6406 
6407     return lhs.lcb==rhs.lcb &&
6408            lhs.cbHeader==rhs.cbHeader &&
6409            lhs.mfp==rhs.mfp &&
6410            lhs.dxaGoal==rhs.dxaGoal &&
6411            lhs.dyaGoal==rhs.dyaGoal &&
6412            lhs.mx==rhs.mx &&
6413            lhs.my==rhs.my &&
6414            lhs.dxaCropLeft==rhs.dxaCropLeft &&
6415            lhs.dyaCropTop==rhs.dyaCropTop &&
6416            lhs.dxaCropRight==rhs.dxaCropRight &&
6417            lhs.dyaCropBottom==rhs.dyaCropBottom &&
6418            lhs.brcl==rhs.brcl &&
6419            lhs.fFrameEmpty==rhs.fFrameEmpty &&
6420            lhs.fBitmap==rhs.fBitmap &&
6421            lhs.fDrawHatch==rhs.fDrawHatch &&
6422            lhs.fError==rhs.fError &&
6423            lhs.bpp==rhs.bpp &&
6424            lhs.brcTop==rhs.brcTop &&
6425            lhs.brcLeft==rhs.brcLeft &&
6426            lhs.brcBottom==rhs.brcBottom &&
6427            lhs.brcRight==rhs.brcRight &&
6428            lhs.dxaOrigin==rhs.dxaOrigin &&
6429            lhs.dyaOrigin==rhs.dyaOrigin;
6430 }
6431 
operator !=(const PICF & lhs,const PICF & rhs)6432 bool operator!=(const PICF &lhs, const PICF &rhs) {
6433     return !(lhs==rhs);
6434 }
6435 
6436 
6437 // SED implementation
6438 
6439 const unsigned int SED::sizeOf = 12;
6440 
SED()6441 SED::SED() {
6442     clear();
6443 }
6444 
SED(OLEStreamReader * stream,bool preservePos)6445 SED::SED(OLEStreamReader *stream, bool preservePos) {
6446     clear();
6447     read(stream, preservePos);
6448 }
6449 
read(OLEStreamReader * stream,bool preservePos)6450 bool SED::read(OLEStreamReader *stream, bool preservePos) {
6451 
6452     U16 shifterU16;
6453 
6454     if(preservePos)
6455         stream->push();
6456 
6457     shifterU16=stream->readU16();
6458     fSwap=shifterU16;
6459     shifterU16>>=1;
6460     fUnk=shifterU16;
6461     shifterU16>>=1;
6462     fn=shifterU16;
6463     fcSepx=stream->readU32();
6464     fnMpr=stream->readU16();
6465     fcMpr=stream->readU32();
6466 
6467     if(preservePos)
6468         stream->pop();
6469     return true;
6470 }
6471 
write(OLEStreamWriter * stream,bool preservePos) const6472 bool SED::write(OLEStreamWriter *stream, bool preservePos) const {
6473 
6474     U16 shifterU16;
6475 
6476     if(preservePos)
6477         stream->push();
6478 
6479     shifterU16=fSwap;
6480     shifterU16|=fUnk << 1;
6481     shifterU16|=fn << 2;
6482     stream->write(shifterU16);
6483     stream->write(fcSepx);
6484     stream->write(fnMpr);
6485     stream->write(fcMpr);
6486 
6487     if(preservePos)
6488         stream->pop();
6489     return true;
6490 }
6491 
clear()6492 void SED::clear() {
6493     fSwap=0;
6494     fUnk=0;
6495     fn=0;
6496     fcSepx=0;
6497     fnMpr=0;
6498     fcMpr=0;
6499 }
6500 
operator ==(const SED & lhs,const SED & rhs)6501 bool operator==(const SED &lhs, const SED &rhs) {
6502 
6503     return lhs.fSwap==rhs.fSwap &&
6504            lhs.fUnk==rhs.fUnk &&
6505            lhs.fn==rhs.fn &&
6506            lhs.fcSepx==rhs.fcSepx &&
6507            lhs.fnMpr==rhs.fnMpr &&
6508            lhs.fcMpr==rhs.fcMpr;
6509 }
6510 
operator !=(const SED & lhs,const SED & rhs)6511 bool operator!=(const SED &lhs, const SED &rhs) {
6512     return !(lhs==rhs);
6513 }
6514 
6515 
6516 // SEP implementation
6517 
SEP()6518 SEP::SEP() : Shared() {
6519     clear();
6520 }
6521 
SEP(OLEStreamReader * stream,bool preservePos)6522 SEP::SEP(OLEStreamReader *stream, bool preservePos) : Shared() {
6523     clear();
6524     read(stream, preservePos);
6525 }
6526 
read(OLEStreamReader * stream,bool preservePos)6527 bool SEP::read(OLEStreamReader *stream, bool preservePos) {
6528 
6529     if(preservePos)
6530         stream->push();
6531 
6532     bkc=stream->readU8();
6533     fTitlePage=stream->readU8();
6534     ccolM1=stream->readU16();
6535     dxaColumns=stream->readU16();
6536     fAutoPgn=stream->readU8();
6537     nfcPgn=stream->readU8();
6538     pgnStart=stream->readU16();
6539     fUnlocked=stream->readU8();
6540     cnsPgn=stream->readU8();
6541     fPgnRestart=stream->readU8();
6542     fEndNote=stream->readU8();
6543     lnc=stream->readU8();
6544     grpfIhdt=stream->readU8();
6545     nLnnMod=stream->readU16();
6546     dxaLnn=stream->readU16();
6547     dyaHdrTop=stream->readU16();
6548     dyaHdrBottom=stream->readU16();
6549     dxaPgn=stream->readU16();
6550     dyaPgn=stream->readU16();
6551     fLBetween=stream->readU8();
6552     vjc=stream->readU8();
6553     lnnMin=stream->readU16();
6554     dmOrientPage=stream->readU8();
6555     iHeadingPgn=stream->readU8();
6556     xaPage=stream->readU16();
6557     yaPage=stream->readU16();
6558     dxaLeft=stream->readU16();
6559     dxaRight=stream->readU16();
6560     dyaTop=stream->readU16();
6561     dyaBottom=stream->readU16();
6562     dzaGutter=stream->readU16();
6563     dmBinFirst=stream->readU16();
6564     dmBinOther=stream->readU16();
6565     dmPaperReq=stream->readU16();
6566     fEvenlySpaced=stream->readU8();
6567     unused55=stream->readU8();
6568     dxaColumnWidth=stream->readU16();
6569     for(int _i=0; _i<(89); ++_i)
6570         rgdxaColumnWidthSpacing[_i]=stream->readU16();
6571     olstAnm.read(stream, false);
6572 
6573     if(preservePos)
6574         stream->pop();
6575     return true;
6576 }
6577 
write(OLEStreamWriter * stream,bool preservePos) const6578 bool SEP::write(OLEStreamWriter *stream, bool preservePos) const {
6579 
6580     if(preservePos)
6581         stream->push();
6582 
6583     stream->write(bkc);
6584     stream->write(fTitlePage);
6585     stream->write(ccolM1);
6586     stream->write(dxaColumns);
6587     stream->write(fAutoPgn);
6588     stream->write(nfcPgn);
6589     stream->write(pgnStart);
6590     stream->write(fUnlocked);
6591     stream->write(cnsPgn);
6592     stream->write(fPgnRestart);
6593     stream->write(fEndNote);
6594     stream->write(lnc);
6595     stream->write(grpfIhdt);
6596     stream->write(nLnnMod);
6597     stream->write(dxaLnn);
6598     stream->write(dyaHdrTop);
6599     stream->write(dyaHdrBottom);
6600     stream->write(dxaPgn);
6601     stream->write(dyaPgn);
6602     stream->write(fLBetween);
6603     stream->write(vjc);
6604     stream->write(lnnMin);
6605     stream->write(dmOrientPage);
6606     stream->write(iHeadingPgn);
6607     stream->write(xaPage);
6608     stream->write(yaPage);
6609     stream->write(dxaLeft);
6610     stream->write(dxaRight);
6611     stream->write(dyaTop);
6612     stream->write(dyaBottom);
6613     stream->write(dzaGutter);
6614     stream->write(dmBinFirst);
6615     stream->write(dmBinOther);
6616     stream->write(dmPaperReq);
6617     stream->write(fEvenlySpaced);
6618     stream->write(unused55);
6619     stream->write(dxaColumnWidth);
6620     for(int _i=0; _i<(89); ++_i)
6621         stream->write(rgdxaColumnWidthSpacing[_i]);
6622     olstAnm.write(stream, false);
6623 
6624     if(preservePos)
6625         stream->pop();
6626     return true;
6627 }
6628 
clear()6629 void SEP::clear() {
6630     bkc=2;
6631     fTitlePage=0;
6632     ccolM1=0;
6633     dxaColumns=0;
6634     fAutoPgn=0;
6635     nfcPgn=0;
6636     pgnStart=0;
6637     fUnlocked=0;
6638     cnsPgn=0;
6639     fPgnRestart=0;
6640     fEndNote=true;
6641     lnc=0;
6642     grpfIhdt=0;
6643     nLnnMod=0;
6644     dxaLnn=0;
6645     dyaHdrTop=720;
6646     dyaHdrBottom=720;
6647     dxaPgn=720;
6648     dyaPgn=720;
6649     fLBetween=0;
6650     vjc=0;
6651     lnnMin=0;
6652     dmOrientPage=1;
6653     iHeadingPgn=0;
6654     xaPage=12240;
6655     yaPage=15840;
6656     dxaLeft=0;
6657     dxaRight=0;
6658     dyaTop=0;
6659     dyaBottom=0;
6660     dzaGutter=0;
6661     dmBinFirst=0;
6662     dmBinOther=0;
6663     dmPaperReq=0;
6664     fEvenlySpaced=true;
6665     unused55=0;
6666     dxaColumnWidth=0;
6667     for(int _i=0; _i<(89); ++_i)
6668         rgdxaColumnWidthSpacing[_i]=0;
6669     olstAnm.clear();
6670 }
6671 
dump() const6672 void SEP::dump() const
6673 {
6674     wvlog << "Dumping SEP:" << std::endl;
6675     wvlog << toString().c_str() << std::endl;
6676     wvlog << "\nDumping SEP done." << std::endl;
6677 }
6678 
toString() const6679 std::string SEP::toString() const
6680 {
6681     std::string s( "SEP:" );
6682     s += "\nbkc=";
6683     s += uint2string( bkc );
6684     s += "\nfTitlePage=";
6685     s += uint2string( fTitlePage );
6686     s += "\nccolM1=";
6687     s += uint2string( ccolM1 );
6688     s += "\ndxaColumns=";
6689     s += uint2string( dxaColumns );
6690     s += "\nfAutoPgn=";
6691     s += uint2string( fAutoPgn );
6692     s += "\nnfcPgn=";
6693     s += uint2string( nfcPgn );
6694     s += "\npgnStart=";
6695     s += uint2string( pgnStart );
6696     s += "\nfUnlocked=";
6697     s += uint2string( fUnlocked );
6698     s += "\ncnsPgn=";
6699     s += uint2string( cnsPgn );
6700     s += "\nfPgnRestart=";
6701     s += uint2string( fPgnRestart );
6702     s += "\nfEndNote=";
6703     s += uint2string( fEndNote );
6704     s += "\nlnc=";
6705     s += uint2string( lnc );
6706     s += "\ngrpfIhdt=";
6707     s += uint2string( grpfIhdt );
6708     s += "\nnLnnMod=";
6709     s += uint2string( nLnnMod );
6710     s += "\ndxaLnn=";
6711     s += uint2string( dxaLnn );
6712     s += "\ndyaHdrTop=";
6713     s += uint2string( dyaHdrTop );
6714     s += "\ndyaHdrBottom=";
6715     s += uint2string( dyaHdrBottom );
6716     s += "\ndxaPgn=";
6717     s += uint2string( dxaPgn );
6718     s += "\ndyaPgn=";
6719     s += uint2string( dyaPgn );
6720     s += "\nfLBetween=";
6721     s += uint2string( fLBetween );
6722     s += "\nvjc=";
6723     s += uint2string( vjc );
6724     s += "\nlnnMin=";
6725     s += uint2string( lnnMin );
6726     s += "\ndmOrientPage=";
6727     s += uint2string( dmOrientPage );
6728     s += "\niHeadingPgn=";
6729     s += uint2string( iHeadingPgn );
6730     s += "\nxaPage=";
6731     s += uint2string( xaPage );
6732     s += "\nyaPage=";
6733     s += uint2string( yaPage );
6734     s += "\ndxaLeft=";
6735     s += uint2string( dxaLeft );
6736     s += "\ndxaRight=";
6737     s += uint2string( dxaRight );
6738     s += "\ndyaTop=";
6739     s += uint2string( dyaTop );
6740     s += "\ndyaBottom=";
6741     s += uint2string( dyaBottom );
6742     s += "\ndzaGutter=";
6743     s += uint2string( dzaGutter );
6744     s += "\ndmBinFirst=";
6745     s += uint2string( dmBinFirst );
6746     s += "\ndmBinOther=";
6747     s += uint2string( dmBinOther );
6748     s += "\ndmPaperReq=";
6749     s += uint2string( dmPaperReq );
6750     s += "\nfEvenlySpaced=";
6751     s += uint2string( fEvenlySpaced );
6752     s += "\nunused55=";
6753     s += uint2string( unused55 );
6754     s += "\ndxaColumnWidth=";
6755     s += uint2string( dxaColumnWidth );
6756     for(int _i=0; _i<(89); ++_i) {
6757         s += "\nrgdxaColumnWidthSpacing[" + int2string( _i ) + "]=";
6758     s += uint2string( rgdxaColumnWidthSpacing[_i] );
6759     }
6760     s += "\nolstAnm=";
6761     s += "\n{" + olstAnm.toString() + "}\n";
6762     s += "\nSEP Done.";
6763     return s;
6764 }
6765 
operator ==(const SEP & lhs,const SEP & rhs)6766 bool operator==(const SEP &lhs, const SEP &rhs) {
6767 
6768     for(int _i=0; _i<(89); ++_i) {
6769         if(lhs.rgdxaColumnWidthSpacing[_i]!=rhs.rgdxaColumnWidthSpacing[_i])
6770             return false;
6771     }
6772 
6773     return lhs.bkc==rhs.bkc &&
6774            lhs.fTitlePage==rhs.fTitlePage &&
6775            lhs.ccolM1==rhs.ccolM1 &&
6776            lhs.dxaColumns==rhs.dxaColumns &&
6777            lhs.fAutoPgn==rhs.fAutoPgn &&
6778            lhs.nfcPgn==rhs.nfcPgn &&
6779            lhs.pgnStart==rhs.pgnStart &&
6780            lhs.fUnlocked==rhs.fUnlocked &&
6781            lhs.cnsPgn==rhs.cnsPgn &&
6782            lhs.fPgnRestart==rhs.fPgnRestart &&
6783            lhs.fEndNote==rhs.fEndNote &&
6784            lhs.lnc==rhs.lnc &&
6785            lhs.grpfIhdt==rhs.grpfIhdt &&
6786            lhs.nLnnMod==rhs.nLnnMod &&
6787            lhs.dxaLnn==rhs.dxaLnn &&
6788            lhs.dyaHdrTop==rhs.dyaHdrTop &&
6789            lhs.dyaHdrBottom==rhs.dyaHdrBottom &&
6790            lhs.dxaPgn==rhs.dxaPgn &&
6791            lhs.dyaPgn==rhs.dyaPgn &&
6792            lhs.fLBetween==rhs.fLBetween &&
6793            lhs.vjc==rhs.vjc &&
6794            lhs.lnnMin==rhs.lnnMin &&
6795            lhs.dmOrientPage==rhs.dmOrientPage &&
6796            lhs.iHeadingPgn==rhs.iHeadingPgn &&
6797            lhs.xaPage==rhs.xaPage &&
6798            lhs.yaPage==rhs.yaPage &&
6799            lhs.dxaLeft==rhs.dxaLeft &&
6800            lhs.dxaRight==rhs.dxaRight &&
6801            lhs.dyaTop==rhs.dyaTop &&
6802            lhs.dyaBottom==rhs.dyaBottom &&
6803            lhs.dzaGutter==rhs.dzaGutter &&
6804            lhs.dmBinFirst==rhs.dmBinFirst &&
6805            lhs.dmBinOther==rhs.dmBinOther &&
6806            lhs.dmPaperReq==rhs.dmPaperReq &&
6807            lhs.fEvenlySpaced==rhs.fEvenlySpaced &&
6808            lhs.unused55==rhs.unused55 &&
6809            lhs.dxaColumnWidth==rhs.dxaColumnWidth &&
6810            lhs.olstAnm==rhs.olstAnm;
6811 }
6812 
operator !=(const SEP & lhs,const SEP & rhs)6813 bool operator!=(const SEP &lhs, const SEP &rhs) {
6814     return !(lhs==rhs);
6815 }
6816 
6817 
6818 // SEPX implementation
6819 
SEPX()6820 SEPX::SEPX() {
6821     clearInternal();
6822 }
6823 
SEPX(OLEStreamReader * stream,bool preservePos)6824 SEPX::SEPX(OLEStreamReader *stream, bool preservePos) {
6825     clearInternal();
6826     read(stream, preservePos);
6827 }
6828 
SEPX(const SEPX & rhs)6829 SEPX::SEPX(const SEPX &rhs) {
6830     cb=rhs.cb;
6831     grpprl=rhs.grpprl;
6832 }
6833 
~SEPX()6834 SEPX::~SEPX() {
6835     delete [] grpprl;
6836 }
6837 
operator =(const SEPX & rhs)6838 SEPX &SEPX::operator=(const SEPX &rhs) {
6839 
6840     // Check for assignment to self
6841     if(this==&rhs)
6842         return *this;
6843 
6844     cb=rhs.cb;
6845     grpprl=rhs.grpprl;
6846 
6847     return *this;
6848 }
6849 
read(OLEStreamReader * stream,bool preservePos)6850 bool SEPX::read(OLEStreamReader *stream, bool preservePos) {
6851 
6852     if(preservePos)
6853         stream->push();
6854 
6855     cb=stream->readU8();
6856     // Attention: I don't know how to read grpprl - U8[]
6857 #ifdef __GNUC__
6858 #warning "Couldn't generate reading code for SEPX::grpprl"
6859 #endif
6860 
6861     if(preservePos)
6862         stream->pop();
6863     return true;
6864 }
6865 
write(OLEStreamWriter * stream,bool preservePos) const6866 bool SEPX::write(OLEStreamWriter *stream, bool preservePos) const {
6867 
6868     if(preservePos)
6869         stream->push();
6870 
6871     stream->write(cb);
6872     // Attention: I don't know how to write grpprl - U8[]
6873 #ifdef __GNUC__
6874 #warning "Couldn't generate writing code for SEPX::grpprl"
6875 #endif
6876 
6877     if(preservePos)
6878         stream->pop();
6879     return true;
6880 }
6881 
clear()6882 void SEPX::clear() {
6883     delete [] grpprl;
6884     clearInternal();
6885 }
6886 
clearInternal()6887 void SEPX::clearInternal() {
6888     cb=0;
6889     grpprl=0;
6890 }
6891 
operator ==(const SEPX & lhs,const SEPX & rhs)6892 bool operator==(const SEPX &lhs, const SEPX &rhs) {
6893     // Attention: I don't know how to compare grpprl - U8[]
6894 #ifdef __GNUC__
6895 #warning "Can't compare SEPX::grpprl items"
6896 #endif
6897 
6898     return lhs.cb==rhs.cb;
6899 }
6900 
operator !=(const SEPX & lhs,const SEPX & rhs)6901 bool operator!=(const SEPX &lhs, const SEPX &rhs) {
6902     return !(lhs==rhs);
6903 }
6904 
6905 
6906 // STSHI implementation
6907 
6908 const unsigned int STSHI::sizeOf = 14;
6909 
STSHI()6910 STSHI::STSHI() {
6911     clear();
6912 }
6913 
STSHI(OLEStreamReader * stream,bool preservePos)6914 STSHI::STSHI(OLEStreamReader *stream, bool preservePos) {
6915     clear();
6916     read(stream, preservePos);
6917 }
6918 
read(OLEStreamReader * stream,bool preservePos)6919 bool STSHI::read(OLEStreamReader *stream, bool preservePos) {
6920 
6921     U16 shifterU16;
6922 
6923     if(preservePos)
6924         stream->push();
6925 
6926     cstd=stream->readU16();
6927     cbSTDBaseInFile=stream->readU16();
6928     shifterU16=stream->readU16();
6929     fStdStylenamesWritten=shifterU16;
6930     shifterU16>>=1;
6931     unused4_2=shifterU16;
6932     stiMaxWhenSaved=stream->readU16();
6933     istdMaxFixedWhenSaved=stream->readU16();
6934     nVerBuiltInNamesWhenSaved=stream->readU16();
6935     ftcStandardChpStsh=stream->readU16();
6936 
6937     if(preservePos)
6938         stream->pop();
6939     return true;
6940 }
6941 
write(OLEStreamWriter * stream,bool preservePos) const6942 bool STSHI::write(OLEStreamWriter *stream, bool preservePos) const {
6943 
6944     U16 shifterU16;
6945 
6946     if(preservePos)
6947         stream->push();
6948 
6949     stream->write(cstd);
6950     stream->write(cbSTDBaseInFile);
6951     shifterU16=fStdStylenamesWritten;
6952     shifterU16|=unused4_2 << 1;
6953     stream->write(shifterU16);
6954     stream->write(stiMaxWhenSaved);
6955     stream->write(istdMaxFixedWhenSaved);
6956     stream->write(nVerBuiltInNamesWhenSaved);
6957     stream->write(ftcStandardChpStsh);
6958 
6959     if(preservePos)
6960         stream->pop();
6961     return true;
6962 }
6963 
clear()6964 void STSHI::clear() {
6965     cstd=0;
6966     cbSTDBaseInFile=0;
6967     fStdStylenamesWritten=0;
6968     unused4_2=0;
6969     stiMaxWhenSaved=0;
6970     istdMaxFixedWhenSaved=0;
6971     nVerBuiltInNamesWhenSaved=0;
6972     ftcStandardChpStsh=0;
6973 }
6974 
operator ==(const STSHI & lhs,const STSHI & rhs)6975 bool operator==(const STSHI &lhs, const STSHI &rhs) {
6976 
6977     return lhs.cstd==rhs.cstd &&
6978            lhs.cbSTDBaseInFile==rhs.cbSTDBaseInFile &&
6979            lhs.fStdStylenamesWritten==rhs.fStdStylenamesWritten &&
6980            lhs.unused4_2==rhs.unused4_2 &&
6981            lhs.stiMaxWhenSaved==rhs.stiMaxWhenSaved &&
6982            lhs.istdMaxFixedWhenSaved==rhs.istdMaxFixedWhenSaved &&
6983            lhs.nVerBuiltInNamesWhenSaved==rhs.nVerBuiltInNamesWhenSaved &&
6984            lhs.ftcStandardChpStsh==rhs.ftcStandardChpStsh;
6985 }
6986 
operator !=(const STSHI & lhs,const STSHI & rhs)6987 bool operator!=(const STSHI &lhs, const STSHI &rhs) {
6988     return !(lhs==rhs);
6989 }
6990 
6991 
6992 
6993 } // namespace Word95
6994 
6995 } // namespace wvWare
6996