kpresenter/powerpoint/libppt/powerpoint.cpp
1/* libppt - library to read PowerPoint presentation
2 Copyright (C) 2005 Yolla Indria <yolla.indria@gmail.com>
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 as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA
18*/
19
20#include "powerpoint.h"
21#include "presentation.h"
22#include "slide.h"
23#include "pole.h"
24#include "objects.h"
25
26#include <iostream>
27#include <iomanip>
28
29#include <vector>
30#include <map>
31
32#include <kdebug.h>
33#include <stdio.h>
34
35// Use anonymous namespace to cover following functions
36namespace{
37
38static inline unsigned long readU16( const void* p )
39{
40 const unsigned char* ptr = (const unsigned char*) p;
41 return ptr[0]+(ptr[1]<<8);
42}
43
44static inline signed long readS16( const void* p )
45{
46 const unsigned char* ptr = (const unsigned char*) p;
47 return ptr[0]+(ptr[1]<<8);
48}
49
50static inline unsigned long readU32( const void* p )
51{
52 const unsigned char* ptr = (const unsigned char*) p;
53 return ptr[0]+(ptr[1]<<8)+(ptr[2]<<16)+(ptr[3]<<24);
54}
55
56static inline signed long readS32( const void* p )
57{
58 const unsigned char* ptr = (const unsigned char*) p;
59 return ptr[0]+(ptr[1]<<8)+(ptr[2]<<16)+(ptr[3]<<24);
60}
61
62}
63
64namespace Libppt
65{
66std::ostream& operator<<( std::ostream& s, UString ustring )
67{
68 char* str = ustring.ascii();
69 s << str;
70 return s;
71}
72
73}
74
75
76using namespace Libppt;
77
78
79// ========== base record ==========
80
81const unsigned int Record::id = 0; // invalid of-course
82
83Record::Record()
84{
85 stream_position = 0;
86 record_instance = 0;
87 record_parent = 0;
88}
89
90Record::~Record()
91{
92}
93
94Record* Record::create( unsigned type )
95{
96 Record* record = 0;
97
98 if( type == BookmarkCollectionContainer::id )
99 record = new BookmarkCollectionContainer();
100
101 else if( type == DocumentContainer::id )
102 record = new DocumentContainer();
103
104 else if( type == EnvironmentContainer::id )
105 record = new EnvironmentContainer();
106
107 else if( type == ExObjListContainer::id )
108 record = new ExObjListContainer();
109
110 else if( type == ExOleObjStgContainer::id )
111 record = new ExOleObjStgContainer();
112
113 else if( type == ExHyperlinkContainer::id )
114 record = new ExHyperlinkContainer();
115
116 else if( type == ExEmbedContainer::id )
117 record = new ExEmbedContainer();
118
119 else if( type == ExLinkContainer::id )
120 record = new ExLinkContainer();
121
122 else if( type == FontCollectionContainer::id )
123 record = new FontCollectionContainer();
124
125 else if( type == HandoutContainer::id )
126 record = new HandoutContainer();
127
128 else if( type == HeadersFootersContainer::id )
129 record = new HeadersFootersContainer();
130
131 else if( type == ListContainer::id )
132 record = new ListContainer();
133
134 else if( type == SlideContainer::id )
135 record = new SlideContainer();
136
137 else if( type == SlideBaseContainer::id )
138 record = new SlideBaseContainer();
139
140 else if( type == MainMasterContainer::id )
141 record = new MainMasterContainer();
142
143 else if( type == NotesContainer::id )
144 record = new NotesContainer();
145
146 else if( type == RunArrayContainer::id )
147 record = new RunArrayContainer();
148
149 else if( type == SlideListWithTextContainer::id )
150 record = new SlideListWithTextContainer();
151
152 else if( type == SlideViewInfoContainer::id )
153 record = new SlideViewInfoContainer();
154
155 else if( type == SorterViewInfoContainer::id )
156 record = new SorterViewInfoContainer();
157
158 else if( type == SrKinsokuContainer::id )
159 record = new SrKinsokuContainer();
160
161 else if( type == SummaryContainer::id )
162 record = new SummaryContainer();
163
164 else if( type == OutlineViewInfoContainer::id )
165 record = new OutlineViewInfoContainer();
166
167 else if( type == ProgStringTagContainer ::id )
168 record = new ProgStringTagContainer ();
169
170 else if( type == PPDrawingGroupContainer ::id )
171 record = new PPDrawingGroupContainer ();
172
173 else if( type == PPDrawingContainer ::id )
174 record = new PPDrawingContainer ();
175
176 else if( type == ProgBinaryTagContainer ::id )
177 record = new ProgBinaryTagContainer ();
178
179 else if( type == ProgTagsContainer ::id )
180 record = new ProgTagsContainer ();
181
182 else if( type == VBAInfoContainer::id )
183 record = new VBAInfoContainer();
184
185 else if( type == ViewInfoContainer::id )
186 record = new ViewInfoContainer();
187
188
189 else if( type == msofbtDgContainer::id )
190 record = new msofbtDgContainer();
191
192 else if( type == msofbtSpgrContainer::id )
193 record = new msofbtSpgrContainer();
194
195 else if( type == msofbtSpContainer::id )
196 record = new msofbtSpContainer();
197
198 else if( type == msofbtDggContainer::id )
199 record = new msofbtDggContainer();
200
201 else if( type == msofbtBstoreContainer::id )
202 record = new msofbtBstoreContainer();
203
204 else if( type == msofbtSolverContainer::id )
205 record = new msofbtSolverContainer();
206
207
208 else if( type == BookmarkEntityAtom::id )
209 record = new BookmarkEntityAtom();
210
211 else if( type == CStringAtom::id )
212 record = new CStringAtom();
213
214 else if( type == ColorSchemeAtom::id )
215 record = new ColorSchemeAtom();
216
217 else if( type == CurrentUserAtom::id )
218 record = new CurrentUserAtom();
219
220 else if( type == DocumentAtom::id )
221 record = new DocumentAtom();
222
223 else if( type == EndDocumentAtom::id )
224 record = new EndDocumentAtom();
225
226 else if( type == ExEmbedAtom::id )
227 record = new ExEmbedAtom();
228
229 else if( type == ExHyperlinkAtom::id )
230 record = new ExHyperlinkAtom();
231
232 else if( type == ExLinkAtom::id )
233 record = new ExLinkAtom();
234
235 else if( type == ExObjListAtom::id )
236 record = new ExObjListAtom();
237
238 else if( type == ExOleObjAtom::id )
239 record = new ExOleObjAtom();
240
241 else if( type == FontEntityAtom::id )
242 record = new FontEntityAtom();
243
244 else if( type == GuideAtom::id )
245 record = new GuideAtom();
246
247 else if( type == HeadersFootersAtom ::id )
248 record = new HeadersFootersAtom ();
249
250 else if( type == NotesAtom::id )
251 record = new NotesAtom();
252
253 else if( type == PersistIncrementalBlockAtom::id )
254 record = new PersistIncrementalBlockAtom();
255
256 else if( type == Record1043::id )
257 record = new Record1043 ();
258
259 else if( type == Record1044::id )
260 record = new Record1044 ();
261
262 else if( type == SrKinsokuAtom::id )
263 record = new SrKinsokuAtom();
264
265 else if( type == SlideAtom::id )
266 record = new SlideAtom();
267
268 else if( type == SlidePersistAtom::id )
269 record = new SlidePersistAtom();
270
271 else if( type == StyleTextPropAtom::id )
272 record = new StyleTextPropAtom();
273
274 else if( type == SlideViewInfoAtom::id )
275 record = new SlideViewInfoAtom();
276
277 else if( type == SSDocInfoAtom ::id )
278 record = new SSDocInfoAtom();
279
280 else if( type == SSlideLayoutAtom ::id )
281 record = new SSlideLayoutAtom();
282
283 else if( type == SSSlideInfoAtom ::id )
284 record = new SSSlideInfoAtom();
285
286 else if( type == TextHeaderAtom ::id )
287 record = new TextHeaderAtom();
288
289 else if( type == TextBookmarkAtom ::id )
290 record = new TextBookmarkAtom();
291
292 else if( type == TextBytesAtom::id )
293 record = new TextBytesAtom ();
294
295 else if( type == TextCharsAtom::id )
296 record = new TextCharsAtom ();
297
298 else if( type == TextSpecInfoAtom ::id )
299 record = new TextSpecInfoAtom();
300
301 else if( type == TxCFStyleAtom ::id )
302 record = new TxCFStyleAtom();
303
304 else if( type == TxMasterStyleAtom ::id )
305 record = new TxMasterStyleAtom();
306
307 else if( type == TxPFStyleAtom ::id )
308 record = new TxPFStyleAtom();
309
310 else if( type == TxSIStyleAtom ::id )
311 record = new TxSIStyleAtom();
312
313 else if( type == UserEditAtom::id )
314 record = new UserEditAtom();
315
316 else if( type == ViewInfoAtom::id )
317 record = new ViewInfoAtom();
318
319 else if( type == msofbtDgAtom::id )
320 record = new msofbtDgAtom() ;
321
322 else if( type == msofbtSpgrAtom::id )
323 record = new msofbtSpgrAtom() ;
324
325 else if( type == msofbtSpAtom::id )
326 record = new msofbtSpAtom() ;
327
328 else if( type == msofbtOPTAtom::id )
329 record = new msofbtOPTAtom() ;
330
331 else if( type == msofbtChildAnchorAtom::id )
332 record = new msofbtChildAnchorAtom() ;
333
334 else if( type == msofbtClientAnchorAtom::id )
335 record = new msofbtClientAnchorAtom() ;
336
337 else if( type == msofbtClientDataAtom::id )
338 record = new msofbtClientDataAtom() ;
339
340 else if( type == msofbtClientTextboxAtom::id )
341 record = new msofbtClientTextboxAtom() ;
342
343 else if( type == msofbtDggAtom::id )
344 record = new msofbtDggAtom() ;
345
346 else if( type == msofbtColorMRUAtom::id )
347 record = new msofbtColorMRUAtom() ;
348
349 else if( type == msofbtSplitMenuColorsAtom::id )
350 record = new msofbtSplitMenuColorsAtom() ;
351
352 else if( type == msofbtBSEAtom::id )
353 record = new msofbtBSEAtom() ;
354
355 else if( type == msofbtCLSIDAtom::id )
356 record = new msofbtCLSIDAtom() ;
357
358 else if( type == msofbtRegroupItemsAtom::id )
359 record = new msofbtRegroupItemsAtom() ;
360
361 else if( type == msofbtColorSchemeAtom::id )
362 record = new msofbtColorSchemeAtom() ;
363
364 else if( type == msofbtClientTextboxAtom::id )
365 record = new msofbtClientTextboxAtom() ;
366
367 else if( type == msofbtAnchorAtom::id )
368 record = new msofbtAnchorAtom() ;
369
370 else if( type == msofbtOleObjectAtom::id )
371 record = new msofbtOleObjectAtom() ;
372
373 else if( type == msofbtDeletedPsplAtom::id )
374 record = new msofbtDeletedPsplAtom() ;
375
376 else if( type == msofbtConnectorRuleAtom::id )
377 record = new msofbtConnectorRuleAtom() ;
378
379 else if( type == msofbtAlignRuleAtom::id )
380 record = new msofbtAlignRuleAtom() ;
381
382 else if( type == msofbtArcRuleAtom::id )
383 record = new msofbtArcRuleAtom() ;
384
385 else if( type == msofbtClientRuleAtom::id )
386 record = new msofbtClientRuleAtom() ;
387
388 else if( type == msofbtCalloutRuleAtom::id )
389 record = new msofbtCalloutRuleAtom() ;
390
391 else if( type == msofbtSelectionAtom::id )
392 record = new msofbtSelectionAtom() ;
393
394return record;
395}
396
397void Record::setParent( Record* parent )
398{
399 record_parent = parent;
400}
401
402const Record* Record::parent() const
403{
404 return record_parent;
405}
406
407void Record::setPosition( unsigned pos )
408{
409 stream_position = pos;
410}
411
412unsigned Record::position() const
413{
414 return stream_position;
415}
416
417void Record::setInstance( unsigned instance )
418{
419 record_instance = instance;
420}
421
422unsigned Record::instance() const
423{
424 return record_instance;
425}
426
427void Record::setData( unsigned, const unsigned char* )
428{
429}
430
431void Record::setData( unsigned, const unsigned char*, unsigned )
432{
433}
434
435void Record::dump( std::ostream& ) const
436{
437 // nothing to dump
438}
439
440// ========== Container ==========
441
442Container::Container()
443{
444}
445
446// ========== BookmarkCollectionContainer ==========
447
448const unsigned int BookmarkCollectionContainer::id = 2019;
449
450BookmarkCollectionContainer::BookmarkCollectionContainer()
451{
452}
453
454// ========== msofbtDggContainer ==========
455
456const unsigned int msofbtDggContainer::id = 61440; /* F000 */
457
458msofbtDggContainer::msofbtDggContainer()
459{
460}
461
462// ========== msofbtBstoreContainer ==========
463
464const unsigned int msofbtBstoreContainer::id = 61441; /* F001 */
465
466msofbtBstoreContainer::msofbtBstoreContainer()
467{
468}
469
470// ========== msofbtDgContainer ==========
471
472const unsigned int msofbtDgContainer::id = 61442; /* F002 */
473
474msofbtDgContainer::msofbtDgContainer()
475{
476}
477
478// ========== msofbtSpgrContainer ==========
479
480const unsigned int msofbtSpgrContainer::id = 61443; /* F003*/
481
482msofbtSpgrContainer::msofbtSpgrContainer()
483{
484}
485
486// ========== msofbtSpContainer ==========
487
488const unsigned int msofbtSpContainer::id = 61444; /* F004 */
489
490msofbtSpContainer::msofbtSpContainer()
491{
492}
493
494// ========== msofbtSolverContainer ==========
495
496const unsigned int msofbtSolverContainer::id = 61445; /* F005 */
497
498msofbtSolverContainer::msofbtSolverContainer()
499{
500}
501
502
503// ========== DocumentContainer ==========
504
505const unsigned int DocumentContainer::id = 1000;
506
507DocumentContainer::DocumentContainer()
508{
509}
510
511// ========== NotesContainer ==========
512
513const unsigned int NotesContainer::id = 1008;
514
515NotesContainer::NotesContainer()
516{
517}
518
519// ========== ExOleObjStgContainer ==========
520
521const unsigned int ExOleObjStgContainer::id = 4113;
522
523ExOleObjStgContainer::ExOleObjStgContainer()
524{
525}
526
527// ========== FontCollectionContainer ==========
528
529const unsigned int FontCollectionContainer::id = 2005;
530
531FontCollectionContainer::FontCollectionContainer()
532{
533}
534
535
536// ========== ExObjListContainer ==========
537
538const unsigned int ExObjListContainer::id = 1033;
539
540ExObjListContainer::ExObjListContainer()
541{
542}
543
544// ========== SlideContainer ==========
545
546const unsigned int SlideContainer::id = 1006;
547
548SlideContainer::SlideContainer()
549{
550}
551
552// ========== SlideBaseContainer ==========
553
554const unsigned int SlideBaseContainer::id = 1004;
555
556SlideBaseContainer::SlideBaseContainer()
557{
558}
559
560// ========== SlideListWithTextContainer ==========
561
562const unsigned int SlideListWithTextContainer::id = 4080;
563
564SlideListWithTextContainer::SlideListWithTextContainer()
565{
566}
567
568// ========== SlideViewInfoContainer ==========
569
570const unsigned int SlideViewInfoContainer::id = 1018;
571
572SlideViewInfoContainer::SlideViewInfoContainer()
573{
574}
575
576// ========== OutlineViewInfoContainer ==========
577
578const unsigned int OutlineViewInfoContainer::id = 1031;
579
580OutlineViewInfoContainer::OutlineViewInfoContainer()
581{
582}
583
584// ========== SorterViewInfoContainer ==========
585
586const unsigned int SorterViewInfoContainer::id = 1032;
587
588SorterViewInfoContainer::SorterViewInfoContainer()
589{
590}
591
592// ========== HandoutContainer ==========
593
594const unsigned int HandoutContainer::id = 4041;
595
596HandoutContainer::HandoutContainer()
597{
598}
599
600// ========== ListContainer ==========
601
602const unsigned int ListContainer::id = 2000;
603
604ListContainer::ListContainer()
605{
606}
607
608// ========== ExEmbedContainer ==========
609
610const unsigned int ExEmbedContainer::id = 4044;
611
612ExEmbedContainer::ExEmbedContainer()
613{
614}
615
616// ========== ExLinkContainer ==========
617
618const unsigned int ExLinkContainer::id = 4046;
619
620ExLinkContainer::ExLinkContainer()
621{
622}
623
624// ========== ExHyperlinkContainer ==========
625
626const unsigned int ExHyperlinkContainer::id = 4055;
627
628ExHyperlinkContainer::ExHyperlinkContainer()
629{
630}
631
632// ========== MainMasterContainer ==========
633
634const unsigned int MainMasterContainer::id = 1016;
635
636MainMasterContainer::MainMasterContainer()
637{
638}
639
640// ========== EnvironmentContainer ==========
641
642const unsigned int EnvironmentContainer::id = 1010;
643
644EnvironmentContainer::EnvironmentContainer()
645{
646}
647
648// ========== HeadersFootersContainer ==========
649
650const unsigned int HeadersFootersContainer::id = 4057;
651
652HeadersFootersContainer::HeadersFootersContainer()
653{
654}
655
656// ========== RunArrayContainer ==========
657
658const unsigned int RunArrayContainer::id = 2028;
659
660RunArrayContainer::RunArrayContainer()
661{
662}
663
664// ========== SrKinsokuContainer ==========
665
666const unsigned int SrKinsokuContainer::id = 4040;
667
668SrKinsokuContainer::SrKinsokuContainer()
669{
670}
671
672// ========== ProgTagsContainer ==========
673
674const unsigned int ProgTagsContainer::id = 5000;
675
676ProgTagsContainer::ProgTagsContainer()
677{
678}
679
680// ========== ProgBinaryTagContainer ==========
681
682const unsigned int ProgBinaryTagContainer::id = 5002;
683
684ProgBinaryTagContainer::ProgBinaryTagContainer()
685{
686}
687
688// ========== ProgStringTagContainer ==========
689
690const unsigned int ProgStringTagContainer::id = 5001;
691
692ProgStringTagContainer::ProgStringTagContainer()
693{
694}
695
696// ========== PPDrawingGroupContainer ==========
697
698const unsigned int PPDrawingGroupContainer::id = 1035;
699
700PPDrawingGroupContainer::PPDrawingGroupContainer()
701{
702}
703
704// ========== PPDrawingContainer ==========
705
706const unsigned int PPDrawingContainer::id = 1036;
707
708PPDrawingContainer::PPDrawingContainer()
709{
710}
711
712// ========== SummaryContainer ==========
713
714const unsigned int SummaryContainer::id = 1026;
715
716SummaryContainer::SummaryContainer()
717{
718}
719
720// ========== VBAInfoContainer ==========
721
722const unsigned int VBAInfoContainer::id = 1023;
723
724VBAInfoContainer::VBAInfoContainer()
725{
726}
727
728// ========== ViewInfoContainer ==========
729
730const unsigned int ViewInfoContainer::id = 1020;
731
732ViewInfoContainer::ViewInfoContainer()
733{
734}
735
736// ========== CStringAtom ==========
737
738const unsigned int CStringAtom::id = 4026;
739
740class CStringAtom::Private
741{
742public:
743 UString ustring;
744};
745
746
747CStringAtom::CStringAtom()
748{
749 d = new Private;
750}
751
752CStringAtom::~CStringAtom()
753{
754 delete d;
755}
756
757UString CStringAtom::ustring() const
758{
759 return d->ustring;
760}
761
762void CStringAtom::setUString( const UString& ustr )
763{
764 d->ustring = ustr;
765}
766
767void CStringAtom::setData( unsigned size, const unsigned char* data )
768{
769 UString str;
770 for( unsigned k=0; k<(size/2); k++ )
771 {
772 unsigned uchar = readU16( data + k*2 );
773 if (uchar == 0x0d)
774 {
775 uchar = 0x0b;
776// std::cout << "found 0x0d in CStringAtom " << std::endl;
777 }
778 str.append( UString(uchar) );
779 }
780 setUString( str );
781}
782
783void CStringAtom::dump( std::ostream& out ) const
784{
785 out << "CStringAtom" << std::endl;
786 out << "String : [" << ustring() << "]" << std::endl;
787}
788
789// ========== DocumentAtom ==========
790
791const unsigned int DocumentAtom::id = 1001;
792
793class DocumentAtom::Private
794{
795public:
796 int slideWidth;
797 int slideHeight;
798 int notesWidth;
799 int notesHeight;
800 int zoomNumer;
801 int zoomDenom;
802 int notesMasterPersist;
803 int handoutMasterPersist;
804 int firstSlideNum;
805 int slideSizeType;
806 int saveWithFonts;
807 int omitTitlePlace;
808 int rightToLeft;
809 int showComments;
810};
811
812DocumentAtom::DocumentAtom()
813{
814 d = new Private;
815 d->slideWidth = 5760; // 10 inches
816 d->slideHeight = 4320; // 7.5 inches
817 d->notesWidth = 4320;
818 d->notesHeight = 5760;
819 d->zoomNumer = 1;
820 d->zoomDenom = 2;
821 d->notesMasterPersist = 0;
822 d->handoutMasterPersist = 0;
823 d->firstSlideNum = 0;
824 d->slideSizeType = 0;
825 d->saveWithFonts = 0;
826 d->omitTitlePlace = 0;
827 d->rightToLeft = 0 ;
828 d->showComments = 0;
829}
830
831DocumentAtom::~DocumentAtom()
832{
833 delete d;
834}
835
836int DocumentAtom::slideWidth() const
837{
838 return d->slideWidth;
839}
840
841void DocumentAtom::setSlideWidth( int w )
842{
843 d->slideWidth = w;
844}
845
846int DocumentAtom::slideHeight() const
847{
848 return d->slideHeight;
849}
850
851void DocumentAtom::setSlideHeight( int h )
852{
853 d->slideHeight = h;
854}
855
856int DocumentAtom::notesWidth() const
857{
858 return d->notesWidth;
859}
860
861void DocumentAtom::setNotesWidth( int nw )
862{
863 d->notesWidth = nw;
864}
865
866int DocumentAtom::notesHeight() const
867{
868 return d->notesHeight;
869}
870
871void DocumentAtom::setNotesHeight( int nh )
872{
873 d->notesHeight = nh;
874}
875
876int DocumentAtom::zoomNumer () const
877{
878 return d->zoomNumer;
879}
880
881void DocumentAtom::setZoomNumer( int numer )
882{
883 d->zoomNumer = numer;
884}
885
886int DocumentAtom::zoomDenom() const
887{
888 return d->zoomDenom;
889}
890
891void DocumentAtom::setZoomDenom( int denom )
892{
893 d->zoomDenom = denom;
894}
895
896int DocumentAtom::notesMasterPersist() const
897{
898 return d->notesMasterPersist;
899}
900
901void DocumentAtom::setNotesMasterPersist( int notesMasterPersist )
902{
903 d->notesMasterPersist = notesMasterPersist;
904}
905
906int DocumentAtom::handoutMasterPersist() const
907{
908 return d->handoutMasterPersist;
909}
910
911void DocumentAtom::setHandoutMasterPersist(int handoutMasterPersist)
912{
913 d->handoutMasterPersist = handoutMasterPersist;
914}
915
916int DocumentAtom::firstSlideNum() const
917{
918 return d->firstSlideNum;
919}
920
921void DocumentAtom::setFirstSlideNum( int firstSlideNum )
922{
923 d->firstSlideNum = firstSlideNum;
924}
925
926int DocumentAtom::slideSizeType() const
927{
928 return d->slideSizeType;
929}
930
931void DocumentAtom::setSlideSizeType( int slideSizeType )
932{
933 d->slideSizeType = slideSizeType;
934}
935
936int DocumentAtom::saveWithFonts() const
937{
938 return d->saveWithFonts;
939}
940
941void DocumentAtom::setSaveWithFonts( int saveWithFonts )
942{
943 d->saveWithFonts = saveWithFonts;
944}
945
946int DocumentAtom::omitTitlePlace() const
947{
948 return d->omitTitlePlace;
949}
950
951void DocumentAtom::setOmitTitlePlace( int omitTitlePlace )
952{
953 d->omitTitlePlace = omitTitlePlace;
954}
955
956int DocumentAtom::rightToLeft() const
957{
958 return d->rightToLeft;
959}
960
961void DocumentAtom::setRightToLeft( int rightToLeft )
962{
963 d->rightToLeft = rightToLeft;
964}
965
966int DocumentAtom::showComments() const
967{
968 return d->showComments;
969}
970
971void DocumentAtom::setShowComments( int showComments)
972{
973 d->showComments = showComments;
974}
975
976void DocumentAtom::setData( unsigned , const unsigned char* data )
977{
978 setSlideWidth( readU32( data+0 ) );
979 setSlideHeight( readU32( data+4 ) );
980 setNotesWidth( readU32( data+8 ) );
981 setNotesHeight( readU32( data+12 ) );
982 setZoomNumer( readS32( data+16 ) );
983 setZoomDenom( readS32( data+20) );
984 setNotesMasterPersist( readU32( data+24 ) );
985 setHandoutMasterPersist ( readU32( data+28 ) );
986 setFirstSlideNum( readU16( data+32 ) );
987 setSlideSizeType( readS16( data+34 ) );
988 setSaveWithFonts(data[36]);
989 setOmitTitlePlace(data[37]);
990 setRightToLeft(data[38]);
991 setShowComments(data[39]);
992}
993
994void DocumentAtom::dump( std::ostream& out ) const
995{
996 out << "DocumentAtom" << std::endl;
997 out << "slide width " << slideWidth() << std::endl;
998 out << "slide height " << slideHeight() << std::endl;
999 out << "notes width " << notesWidth() << std::endl;
1000 out << "notes height " << notesHeight() << std::endl;
1001 out << "zoom numer " << zoomNumer() << std::endl;
1002 out << "zoom denum " << zoomDenom() << std::endl;
1003 out << "notesMasterPersist " << notesMasterPersist() << std::endl;
1004 out << "handoutMasterPersist " << handoutMasterPersist() << std::endl;
1005 out << "firstSlideNum " << firstSlideNum() << std::endl;
1006 out << "slideSizeType " << slideSizeType() << std::endl;
1007 out << "saveWithFonts " << saveWithFonts() << std::endl;
1008 out << "omitTitlePlace " << omitTitlePlace() << std::endl;
1009 out << "rightToLeft " << rightToLeft() << std::endl;
1010 out << "showComments " << showComments() << std::endl;
1011}
1012
1013// ========== EndDocumentAtom ==========
1014
1015const unsigned int EndDocumentAtom::id = 1002;
1016
1017EndDocumentAtom::EndDocumentAtom()
1018{
1019}
1020
1021void EndDocumentAtom::dump( std::ostream& out ) const
1022{
1023 out << "EndDocumentAtom" << std::endl;
1024}
1025
1026
1027// ========== FontEntityAtom ==========
1028
1029const unsigned int FontEntityAtom::id = 4023;
1030
1031class FontEntityAtom::Private
1032{
1033public:
1034 UString ustring;
1035 int charset;
1036 int clipPrecision;
1037 int quality;
1038 int pitchAndFamily;
1039
1040};
1041
1042FontEntityAtom::FontEntityAtom()
1043{
1044 d = new Private;
1045 d->charset = 0;
1046 d->clipPrecision = 0;
1047 d->quality = 0;
1048 d->pitchAndFamily = 0;
1049}
1050
1051FontEntityAtom::~FontEntityAtom()
1052{
1053 delete d;
1054}
1055
1056UString FontEntityAtom::ustring() const
1057{
1058 return d->ustring;
1059}
1060
1061void FontEntityAtom::setUString( const UString& ustring )
1062{
1063 d->ustring = ustring;
1064}
1065
1066int FontEntityAtom::charset() const
1067{
1068 return d->charset;
1069}
1070
1071void FontEntityAtom::setCharset( int charset )
1072{
1073 d->charset = charset;
1074}
1075
1076int FontEntityAtom::clipPrecision() const
1077{
1078 return d->clipPrecision;
1079}
1080
1081void FontEntityAtom::setClipPrecision( int clipPrecision)
1082{
1083 d->clipPrecision = clipPrecision ;
1084}
1085
1086int FontEntityAtom::quality() const
1087{
1088 return d->quality;
1089}
1090
1091void FontEntityAtom::setQuality( int quality )
1092{
1093 d->quality = quality;
1094}
1095
1096int FontEntityAtom::pitchAndFamily() const
1097{
1098 return d->pitchAndFamily;
1099}
1100
1101void FontEntityAtom::setPitchAndFamily( int pitchAndFamily )
1102{
1103 d->pitchAndFamily = pitchAndFamily;
1104}
1105
1106void FontEntityAtom::setData( unsigned , const unsigned char* data )
1107{
1108
1109 UString str;
1110 for( unsigned k=0; k<32; k++ )
1111 {
1112 unsigned uchar = readU16( data + k*2 );
1113 str.append( UString(uchar) );
1114 }
1115 setUString( str );
1116 setCharset( data[64] );
1117 setClipPrecision( data[65] );
1118 setQuality( data[66] );
1119 setPitchAndFamily( data[67] );
1120}
1121
1122void FontEntityAtom::dump( std::ostream& out ) const
1123{
1124 out << "FontEntityAtom" << std::endl;
1125 out << "String : [" << ustring() << "]" << std::endl;
1126 out << "Charset " << charset() << std::endl;
1127 out << "ClipPrecision " << clipPrecision() << std::endl;
1128 out << "Quality " << quality() << std::endl;
1129 out << "PitchAndFamily " << pitchAndFamily() << std::endl;
1130}
1131
1132// ========== TextCharsAtom ==========
1133
1134const unsigned int TextCharsAtom::id = 4000;
1135
1136
1137class TextCharsAtom::Private
1138{
1139public:
1140 std::vector<unsigned> index;
1141 std::vector<UString> ustring;
1142};
1143
1144TextCharsAtom::TextCharsAtom()
1145{
1146 d = new Private;
1147}
1148
1149TextCharsAtom::~TextCharsAtom()
1150{
1151 delete d;
1152}
1153
1154unsigned TextCharsAtom::listSize() const
1155{
1156 return d->ustring.size();
1157}
1158
1159UString TextCharsAtom::strValue( unsigned index ) const
1160{
1161 return d->ustring[index];
1162}
1163
1164void TextCharsAtom::setText( UString ustring )
1165{
1166 d->ustring.push_back( ustring );
1167}
1168
1169void TextCharsAtom::setData( unsigned size, const unsigned char* data )
1170{
1171 UString tempStr;
1172 int index = 0;
1173
1174 for( unsigned k=0; k<((0.5*size) + 1); k++ )
1175 {
1176 unsigned uchar = readU16( data + k*2 );
1177 if ( (uchar == 0x0b) | (uchar == 0x0d) | (k == 0.5*size) )
1178 {
1179 setText(tempStr);
1180 index++;
1181 tempStr = "";
1182 }
1183 else
1184 tempStr.append( UString(uchar) );
1185
1186 if ( ( uchar & 0xff00 ) == 0xf000 )
1187 { // handle later
1188 std::cout << "got a symbol at " << k << "th character" << std::endl;
1189 }
1190
1191 }
1192}
1193
1194void TextCharsAtom::dump( std::ostream& out ) const
1195{
1196 out << "TextCharsAtom" << std::endl;
1197 out << "listSize " << listSize() << std::endl;
1198
1199 for (uint i=0; i<listSize() ; i++)
1200 {
1201 out << "String " << i << " [" << strValue(i) << "]" << std::endl;
1202 }
1203
1204}
1205
1206
1207// ========== GuideAtom ==========
1208
1209const unsigned int GuideAtom::id = 1019;
1210
1211class GuideAtom::Private
1212{
1213public:
1214 int type;
1215 int pos;
1216};
1217
1218GuideAtom::GuideAtom ()
1219{
1220 d = new Private;
1221 d->type = 0;
1222 d->pos = 0;
1223}
1224
1225GuideAtom::~GuideAtom ()
1226{
1227 delete d;
1228}
1229
1230int GuideAtom::type() const
1231{
1232 return d->type;
1233}
1234
1235void GuideAtom::setType(int type)
1236{
1237 d->type= type;
1238}
1239
1240int GuideAtom::pos() const
1241{
1242 return d->pos;
1243}
1244
1245void GuideAtom::setPos(int pos)
1246{
1247 d->pos= pos;
1248}
1249
1250void GuideAtom::setData( unsigned , const unsigned char* data )
1251{
1252 setType( readS32( data + 0 ) );
1253 setPos( readS32( data + 4 ) );
1254}
1255
1256void GuideAtom::dump( std::ostream& out ) const
1257{
1258 out << "GuideAtom" << std::endl;
1259 out << "type " << type() << std::endl;
1260 out << "pos " << pos() << std::endl;
1261}
1262
1263
1264// ========== SSlideLayoutAtom ==========
1265
1266const unsigned int SSlideLayoutAtom::id = 1015;
1267
1268class SSlideLayoutAtom ::Private
1269{
1270public:
1271 int geom;
1272 int placeholderId;
1273};
1274
1275SSlideLayoutAtom::SSlideLayoutAtom ()
1276{
1277 d = new Private;
1278 d->geom = 0;
1279 d->placeholderId = 0;
1280}
1281
1282SSlideLayoutAtom::~SSlideLayoutAtom ()
1283{
1284 delete d;
1285}
1286
1287int SSlideLayoutAtom::geom() const
1288{
1289 return d->geom;
1290}
1291
1292void SSlideLayoutAtom::setGeom(int geom)
1293{
1294 d->geom= geom;
1295}
1296
1297int SSlideLayoutAtom::placeholderId() const
1298{
1299 return d->placeholderId;
1300}
1301
1302void SSlideLayoutAtom::setPlaceholderId(int placeholderId)
1303{
1304 d->placeholderId= placeholderId;
1305}
1306
1307void SSlideLayoutAtom ::setData( unsigned , const unsigned char* data )
1308{
1309 setGeom( readS32( data + 0 ) );
1310 setPlaceholderId( data [4] );
1311}
1312
1313void SSlideLayoutAtom ::dump( std::ostream& out ) const
1314{
1315 out << "SSlideLayoutAtom" << std::endl;
1316 out << "geom " << geom() << std::endl;
1317 out << "placeholderId " << placeholderId() << std::endl;
1318}
1319
1320// ========== ExLinkAtom ==========
1321
1322const unsigned int ExLinkAtom::id = 4049;
1323
1324class ExLinkAtom ::Private
1325{
1326public:
1327 int exObjId;
1328 int flags;
1329 int unavailable;
1330};
1331
1332ExLinkAtom::ExLinkAtom ()
1333{
1334 d = new Private;
1335 d->exObjId = 0;
1336 d->flags = 0;
1337 d->unavailable = 0;
1338}
1339
1340ExLinkAtom::~ExLinkAtom ()
1341{
1342 delete d;
1343}
1344
1345int ExLinkAtom::exObjId() const
1346{
1347 return d->exObjId;
1348}
1349
1350void ExLinkAtom::setExObjId(int exObjId)
1351{
1352 d->exObjId= exObjId;
1353}
1354
1355int ExLinkAtom::flags() const
1356{
1357 return d->flags;
1358}
1359
1360void ExLinkAtom::setFlags(int flags)
1361{
1362 d->flags= flags;
1363}
1364
1365int ExLinkAtom::unavailable() const
1366{
1367 return d->unavailable;
1368}
1369
1370void ExLinkAtom::setUnavailable(int unavailable)
1371{
1372 d->unavailable= unavailable;
1373}
1374
1375void ExLinkAtom ::setData( unsigned , const unsigned char* data )
1376{
1377 setExObjId( readU32( data + 0 ) );
1378 setFlags( readU16( data + 4 ) );
1379 setUnavailable( data [6] );
1380
1381}
1382
1383void ExLinkAtom ::dump( std::ostream& out ) const
1384{
1385 out << "ExLinkAtom" << std::endl;
1386 out << "exObjId " << exObjId() << std::endl;
1387 out << "flags " << flags() << std::endl;
1388 out << "unavailable " << unavailable() << std::endl;
1389}
1390
1391// ========== NotesAtom ==========
1392
1393const unsigned int NotesAtom::id = 1009;
1394
1395class NotesAtom ::Private
1396{
1397public:
1398 int slideId;
1399 int flags;
1400};
1401
1402NotesAtom::NotesAtom ()
1403{
1404 d = new Private;
1405 d->slideId = 0;
1406 d->flags = 0;
1407}
1408
1409NotesAtom::~NotesAtom ()
1410{
1411 delete d;
1412}
1413
1414int NotesAtom::slideId() const
1415{
1416 return d->slideId;
1417}
1418
1419void NotesAtom::setSlideId(int slideId)
1420{
1421 d->slideId= slideId;
1422}
1423
1424int NotesAtom::flags() const
1425{
1426 return d->flags;
1427}
1428
1429void NotesAtom::setFlags(int flags)
1430{
1431 d->flags= flags;
1432}
1433
1434void NotesAtom ::setData( unsigned , const unsigned char* data )
1435{
1436 setSlideId( readS32( data + 0 ) );
1437 setFlags( readU16( data + 4 ) );
1438}
1439
1440void NotesAtom ::dump( std::ostream& out ) const
1441{
1442 out << "NotesAtom" << std::endl;
1443 out << "slideId " << slideId() << std::endl;
1444 out << "flags " << flags() << std::endl;
1445}
1446
1447
1448// ========== ExObjListAtom ==========
1449
1450const unsigned int ExObjListAtom::id = 1034;
1451
1452class ExObjListAtom ::Private
1453{
1454public:
1455 int objectIdSeed;
1456};
1457
1458ExObjListAtom::ExObjListAtom ()
1459{
1460 d = new Private;
1461 d->objectIdSeed = 0;
1462}
1463
1464ExObjListAtom::~ExObjListAtom ()
1465{
1466 delete d;
1467}
1468
1469int ExObjListAtom::objectIdSeed() const
1470{
1471 return d->objectIdSeed;
1472}
1473
1474void ExObjListAtom::setObjectIdSeed(int objectIdSeed)
1475{
1476 d->objectIdSeed= objectIdSeed;
1477}
1478
1479void ExObjListAtom ::setData( unsigned , const unsigned char* data )
1480{ // check later for valid value
1481 setObjectIdSeed( readU32( data + 0 ) );
1482}
1483
1484void ExObjListAtom ::dump( std::ostream& out ) const
1485{
1486 out << "ExObjListAtom" << std::endl;
1487 out << "objectIdSeed " << objectIdSeed() << std::endl;
1488}
1489
1490
1491// ========== ExEmbedAtom ==========
1492
1493const unsigned int ExEmbedAtom::id = 4045;
1494
1495class ExEmbedAtom ::Private
1496{
1497public:
1498 int followColorScheme;
1499 int cantLockServerB;
1500 int noSizeToServerB;
1501 int isTable;
1502};
1503
1504ExEmbedAtom::ExEmbedAtom ()
1505{
1506 d = new Private;
1507 d->followColorScheme = 0;
1508 d->cantLockServerB = 0;
1509 d->noSizeToServerB = 0;
1510 d->isTable = 0;
1511}
1512
1513ExEmbedAtom::~ExEmbedAtom ()
1514{
1515 delete d;
1516}
1517
1518int ExEmbedAtom::followColorScheme() const
1519{
1520 return d->followColorScheme;
1521}
1522
1523void ExEmbedAtom::setFollowColorScheme(int followColorScheme)
1524{
1525 d->followColorScheme= followColorScheme;
1526}
1527
1528int ExEmbedAtom::cantLockServerB() const
1529{
1530 return d->cantLockServerB;
1531}
1532
1533void ExEmbedAtom::setCantLockServerB(int cantLockServerB)
1534{
1535 d->cantLockServerB= cantLockServerB;
1536}
1537
1538int ExEmbedAtom::noSizeToServerB() const
1539{
1540 return d->noSizeToServerB;
1541}
1542
1543void ExEmbedAtom::setNoSizeToServerB(int noSizeToServerB)
1544{
1545 d->noSizeToServerB= noSizeToServerB;
1546}
1547
1548int ExEmbedAtom::isTable() const
1549{
1550 return d->isTable;
1551}
1552
1553void ExEmbedAtom::setIsTable(int isTable)
1554{
1555 d->isTable= isTable;
1556}
1557
1558void ExEmbedAtom ::setData( unsigned , const unsigned char* data )
1559{
1560 setFollowColorScheme( readS32( data + 0 ) );
1561 setCantLockServerB( data [4] );
1562 setNoSizeToServerB( data[5] );
1563 setIsTable( data[6] );
1564}
1565
1566void ExEmbedAtom ::dump( std::ostream& out ) const
1567{
1568 out << "ExEmbedAtom" << std::endl;
1569 out << "followColorScheme " << followColorScheme() << std::endl;
1570 out << "cantLockServerB " << cantLockServerB() << std::endl;
1571 out << "noSizeToServerB " << noSizeToServerB() << std::endl;
1572 out << "isTable " << isTable() << std::endl;
1573}
1574
1575// ========== ExOleObjAtom ==========
1576
1577const unsigned int ExOleObjAtom::id = 4035;
1578
1579class ExOleObjAtom ::Private
1580{
1581public:
1582 int drawAspect;
1583 int type;
1584 int objID;
1585 int subType;
1586 int objStgDataRef;
1587 int isBlank;
1588};
1589
1590ExOleObjAtom::ExOleObjAtom ()
1591{
1592 d = new Private;
1593 d->drawAspect = 0;
1594 d->type = 0;
1595 d->objID = 0;
1596 d->subType = 0;
1597 d->objStgDataRef = 0;
1598 d->isBlank = 0;
1599}
1600
1601ExOleObjAtom::~ExOleObjAtom ()
1602{
1603 delete d;
1604}
1605
1606int ExOleObjAtom::drawAspect() const
1607{
1608 return d->drawAspect;
1609}
1610
1611void ExOleObjAtom::setDrawAspect(int drawAspect)
1612{
1613 d->drawAspect= drawAspect;
1614}
1615
1616int ExOleObjAtom::type() const
1617{
1618 return d->type;
1619}
1620
1621void ExOleObjAtom::setType(int type)
1622{
1623 d->type= type;
1624}
1625
1626int ExOleObjAtom::objID() const
1627{
1628 return d->objID;
1629}
1630
1631void ExOleObjAtom::setObjID(int objID)
1632{
1633 d->objID= objID;
1634}
1635
1636int ExOleObjAtom::subType() const
1637{
1638 return d->subType;
1639}
1640
1641void ExOleObjAtom::setSubType(int subType)
1642{
1643 d->subType= subType;
1644}
1645
1646int ExOleObjAtom::objStgDataRef() const
1647{
1648 return d->objStgDataRef;
1649}
1650
1651void ExOleObjAtom::setObjStgDataRef(int objStgDataRef)
1652{
1653 d->objStgDataRef= objStgDataRef;
1654}
1655
1656int ExOleObjAtom::isBlank() const
1657{
1658 return d->isBlank;
1659}
1660
1661void ExOleObjAtom::setIsBlank(int isBlank)
1662{
1663 d->isBlank= isBlank;
1664}
1665
1666void ExOleObjAtom ::setData( unsigned , const unsigned char* data )
1667{
1668 setDrawAspect( readU32( data + 0 ) );
1669 setType( readS32( data + 4 ) );
1670 setObjID( readS32( data + 8 ) );
1671 setSubType( readS32( data + 12 ) );
1672 setObjStgDataRef( readS32( data + 16 ) );
1673 setIsBlank( data[20] );
1674}
1675
1676void ExOleObjAtom ::dump( std::ostream& out ) const
1677{
1678 out << "ExOleObjAtom" << std::endl;
1679 out << "drawAspect " << drawAspect() << std::endl;
1680 out << "type " << type() << std::endl;
1681 out << "objID " << objID() << std::endl;
1682 out << "subType " << subType() << std::endl;
1683 out << "objID " << objID() << std::endl;
1684 out << "objStgDataRef " << objStgDataRef() << std::endl;
1685 out << "isBlank " << isBlank() << std::endl;
1686}
1687
1688// ========== ExHyperlinkAtom ==========
1689
1690const unsigned int ExHyperlinkAtom::id = 4051;
1691
1692class ExHyperlinkAtom ::Private
1693{
1694public:
1695 int objID;
1696};
1697
1698ExHyperlinkAtom ::ExHyperlinkAtom ()
1699{
1700 d = new Private;
1701 d->objID = 0;
1702}
1703
1704ExHyperlinkAtom ::~ExHyperlinkAtom ()
1705{
1706 delete d;
1707}
1708
1709int ExHyperlinkAtom ::objID() const
1710{
1711 return d->objID;
1712}
1713
1714void ExHyperlinkAtom ::setObjID(int objID)
1715{
1716 d->objID = objID;
1717}
1718
1719void ExHyperlinkAtom::setData( unsigned , const unsigned char* data )
1720{
1721 setObjID( readU32( data + 0 ) );
1722}
1723
1724void ExHyperlinkAtom ::dump( std::ostream& out ) const
1725{
1726 out << "ExHyperlinkAtom" << std::endl;
1727 out << "objID " << objID() << std::endl;
1728}
1729
1730
1731// ========== PersistIncrementalBlockAtom ==========
1732
1733const unsigned int PersistIncrementalBlockAtom::id = 6002;
1734
1735class PersistIncrementalBlockAtom::Private
1736{
1737public:
1738 std::vector<unsigned long> references;
1739 std::vector<unsigned long> offsets;
1740};
1741
1742PersistIncrementalBlockAtom::PersistIncrementalBlockAtom()
1743{
1744 d = new Private;
1745}
1746
1747PersistIncrementalBlockAtom::~PersistIncrementalBlockAtom()
1748{
1749 delete d;
1750}
1751
1752unsigned PersistIncrementalBlockAtom::entryCount() const
1753{
1754 return d->references.size();
1755}
1756
1757unsigned long PersistIncrementalBlockAtom::reference( unsigned index ) const
1758{
1759 unsigned long r = 0;
1760 if( index < d->references.size() )
1761 r = d->references[index];
1762 return r;
1763}
1764
1765unsigned long PersistIncrementalBlockAtom::offset( unsigned index ) const
1766{
1767 unsigned long ofs = 0;
1768 if( index < d->offsets.size() )
1769 ofs = d->offsets[index];
1770 return ofs;
1771}
1772
1773void PersistIncrementalBlockAtom ::setData( unsigned size, const unsigned char* data )
1774{
1775 d->references.clear();
1776 d->offsets.clear();
1777
1778 unsigned ofs = 0;
1779 while( ofs < size )
1780 {
1781 long k = readU32( data+ ofs );
1782 unsigned count = k>>20;
1783 unsigned start = k&0xfffff;
1784 ofs += 4;
1785 for( unsigned c=0; c < count; c++, ofs+=4 )
1786 {
1787 if( ofs >= size ) break;
1788 long of = readU32( data + ofs );
1789 d->references.push_back( start+c );
1790 d->offsets.push_back( of );
1791 }
1792 }
1793}
1794
1795void PersistIncrementalBlockAtom ::dump( std::ostream& out ) const
1796{
1797 out << "PersistIncrementalBlockAtom" << std::endl;
1798 for( unsigned i = 0; i < entryCount(); i++ )
1799 out << " Ref #" << reference(i) << " at offset " << offset(i) << std::endl;
1800}
1801
1802
1803// ========== HeadersFootersAtom ==========
1804
1805const unsigned int HeadersFootersAtom::id = 4058;
1806
1807class HeadersFootersAtom ::Private
1808{
1809public:
1810 int formatId;
1811 int flags;
1812};
1813
1814HeadersFootersAtom::HeadersFootersAtom ()
1815{
1816 d = new Private;
1817 d->formatId = 0;
1818 d->flags = 0;
1819}
1820
1821HeadersFootersAtom::~HeadersFootersAtom ()
1822{
1823 delete d;
1824}
1825
1826int HeadersFootersAtom::formatId() const
1827{
1828 return d->formatId;
1829}
1830
1831void HeadersFootersAtom::setFormatId(int formatId)
1832{
1833 d->formatId= formatId;
1834}
1835
1836int HeadersFootersAtom::flags() const
1837{
1838 return d->flags;
1839}
1840
1841void HeadersFootersAtom::setFlags(int flags)
1842{
1843 d->flags= flags;
1844}
1845
1846void HeadersFootersAtom::setData( unsigned , const unsigned char* data )
1847{
1848 setFormatId( readS16( data + 0 ) );
1849 setFlags( readU16( data + 2 ) );
1850}
1851
1852void HeadersFootersAtom::dump( std::ostream& out ) const
1853{
1854 out << "HeadersFootersAtom" << std::endl;
1855 out << "formatId " << formatId() << std::endl;
1856 out << "flags " << flags() << std::endl;
1857}
1858
1859
1860// ========== ColorSchemeAtom ==========
1861
1862const unsigned int ColorSchemeAtom::id = 2032;
1863
1864class ColorSchemeAtom ::Private
1865{
1866public:
1867 int background;
1868 int textAndLines;
1869 int shadows;
1870 int titleText;
1871 int fills;
1872 int accent;
1873 int accentAndHyperlink;
1874 int accentAndFollowedHyperlink;
1875
1876};
1877
1878ColorSchemeAtom::ColorSchemeAtom ()
1879{
1880 d = new Private;
1881 d->background = 0 ;
1882 d->textAndLines = 0;
1883 d->shadows = 0 ;
1884 d->titleText = 0 ;
1885 d->fills = 0;
1886 d->accent = 0;
1887 d->accentAndHyperlink = 0;
1888 d->accentAndFollowedHyperlink = 0;
1889}
1890
1891
1892ColorSchemeAtom::~ColorSchemeAtom ()
1893{
1894 delete d;
1895}
1896
1897int ColorSchemeAtom::background() const
1898{
1899 return d->background;
1900}
1901
1902void ColorSchemeAtom::setBackground( int background )
1903{
1904 d->background = background;
1905}
1906
1907int ColorSchemeAtom::textAndLines() const
1908{
1909 return d->textAndLines;
1910}
1911
1912void ColorSchemeAtom::setTextAndLines( int textAndLines )
1913{
1914 d->textAndLines = textAndLines;
1915}
1916
1917int ColorSchemeAtom::shadows() const
1918{
1919 return d->shadows;
1920}
1921
1922void ColorSchemeAtom::setShadows( int shadows )
1923{
1924 d->shadows = shadows;
1925}
1926
1927int ColorSchemeAtom::titleText() const
1928{
1929 return d->titleText;
1930}
1931
1932void ColorSchemeAtom::setTitleText( int titleText )
1933{
1934 d->titleText = titleText;
1935}
1936
1937int ColorSchemeAtom::fills() const
1938{
1939 return d->fills;
1940}
1941
1942void ColorSchemeAtom::setFills( int fills )
1943{
1944 d->fills = fills;
1945}
1946
1947int ColorSchemeAtom::accent() const
1948{
1949 return d->accent;
1950}
1951
1952void ColorSchemeAtom::setAccent( int accent )
1953{
1954 d->accent = accent;
1955}
1956
1957int ColorSchemeAtom::accentAndHyperlink() const
1958{
1959 return d->accentAndHyperlink;
1960}
1961
1962void ColorSchemeAtom::setAccentAndHyperlink ( int accentAndHyperlink )
1963{
1964 d->accentAndHyperlink = accentAndHyperlink;
1965}
1966
1967int ColorSchemeAtom::accentAndFollowedHyperlink() const
1968{
1969 return d->accentAndFollowedHyperlink;
1970}
1971
1972void ColorSchemeAtom::setAccentAndFollowedHyperlink( int accentAndFollowedHyperlink )
1973{
1974 d->accentAndFollowedHyperlink = accentAndFollowedHyperlink;
1975}
1976
1977void ColorSchemeAtom ::setData( unsigned , const unsigned char* data )
1978{
1979 setBackground( readS32( data + 0 ) );
1980 setTextAndLines( readU32( data + 4 ) );
1981 setShadows( readU32( data + 8 ) );
1982 setTitleText( readU32( data + 12 ) );
1983 setFills( readU32( data + 16 ) );
1984 setAccent( readU32( data + 20 ) );
1985 setAccentAndHyperlink( readU32( data + 24 ) );
1986 setAccentAndFollowedHyperlink( readU32( data + 28 ) );
1987
1988}
1989
1990void ColorSchemeAtom ::dump( std::ostream& out ) const
1991{
1992 out << "ColorSchemeAtom" << std::endl;
1993 out << "background " << background() << std::endl;
1994 out << " R " << ( (background() >> 0 ) & 0xff ) ;
1995 out << " G " << ( (background() >> 8 ) & 0xff ) ;
1996 out << " B " << ( (background() >> 16 ) & 0xff ) ;
1997 out << " I " << ( (background() >> 24 ) & 0xff ) << std::endl;
1998 out << "text and Lines " << textAndLines() << std::endl;
1999 out << " R " << ( ( textAndLines() >> 0 ) & 0xff ) ;
2000 out << " G " << ( ( textAndLines() >> 8 ) & 0xff ) ;
2001 out << " B " << ( ( textAndLines() >> 16 ) & 0xff ) ;
2002 out << " I " << ( ( textAndLines() >> 24 ) & 0xff ) << std::endl;
2003 out << "shadows " << shadows() << std::endl;
2004 out << " R " << ( ( shadows() >> 0 ) & 0xff ) ;
2005 out << " G " << ( ( shadows() >> 8 ) & 0xff ) ;
2006 out << " B " << ( ( shadows() >> 16 ) & 0xff ) ;
2007 out << " I " << ( ( shadows() >> 24 ) & 0xff ) << std::endl;
2008 out << "titleText " << titleText() << std::endl;
2009 out << " R " << ( ( titleText() >> 0 ) & 0xff ) ;
2010 out << " G " << ( ( titleText() >> 8 ) & 0xff ) ;
2011 out << " B " << ( ( titleText() >> 16 ) & 0xff ) ;
2012 out << " I " << ( ( titleText() >> 24 ) & 0xff ) << std::endl;
2013 out << "fills " << fills() << std::endl;
2014 out << " R " << ( ( fills() >> 0 ) & 0xff ) ;
2015 out << " G " << ( ( fills() >> 8 ) & 0xff ) ;
2016 out << " B " << ( ( fills() >> 16 ) & 0xff ) ;
2017 out << " I " << ( ( fills() >> 24 ) & 0xff ) << std::endl;
2018 out << "accent " << accent() << std::endl;
2019 out << " R " << ( ( accent() >> 0 ) & 0xff ) ;
2020 out << " G " << ( ( accent() >> 8 ) & 0xff ) ;
2021 out << " B " << ( ( accent() >> 16 ) & 0xff ) ;
2022 out << " I " << ( ( accent() >> 24 ) & 0xff ) << std::endl;
2023 out << "accentAndHyperlink " << accentAndHyperlink() << std::endl;
2024 out << " R " << ( ( accentAndHyperlink() >> 0 ) & 0xff ) ;
2025 out << " G " << ( ( accentAndHyperlink() >> 8 ) & 0xff ) ;
2026 out << " B " << ( ( accentAndHyperlink() >> 16 ) & 0xff ) ;
2027 out << " I " << ( ( accentAndHyperlink() >> 24 ) & 0xff ) << std::endl;
2028 out << "accentAndFollowedHyperlink " << accentAndFollowedHyperlink() << std::endl;
2029 out << " R " << ( ( accentAndFollowedHyperlink() >> 0 ) & 0xff ) ;
2030 out << " G " << ( ( accentAndFollowedHyperlink() >> 8 ) & 0xff ) ;
2031 out << " B " << ( ( accentAndFollowedHyperlink() >> 16 ) & 0xff ) ;
2032 out << " I " << ( ( accentAndFollowedHyperlink() >> 24 ) & 0xff ) << std::endl;
2033}
2034
2035
2036// ========== CurrentUserAtom ==========
2037
2038const unsigned int CurrentUserAtom::id = 4086;
2039
2040class CurrentUserAtom ::Private
2041{
2042public:
2043 int size;
2044 int magic;
2045 int offsetToCurrentEdit;
2046 int lenUserName;
2047 int docFileVersion;
2048 int majorVersion;
2049 int minorVersion;
2050};
2051
2052CurrentUserAtom::CurrentUserAtom ()
2053{
2054 d = new Private;
2055 d->size = 0 ;
2056 d->magic = 0 ;
2057 d->offsetToCurrentEdit = 0;
2058 d->lenUserName = 0 ;
2059 d->docFileVersion = 0 ;
2060 d->majorVersion = 0;
2061 d->minorVersion = 0;
2062}
2063
2064CurrentUserAtom::~CurrentUserAtom ()
2065{
2066 delete d;
2067}
2068
2069int CurrentUserAtom::size() const
2070{
2071 return d->size;
2072}
2073
2074void CurrentUserAtom::setSize( int size )
2075{
2076 d->size = size;
2077}
2078
2079int CurrentUserAtom::magic() const
2080{
2081 return d->magic;
2082}
2083
2084void CurrentUserAtom::setMagic( int magic )
2085{
2086 d->magic = magic;
2087}
2088
2089int CurrentUserAtom::offsetToCurrentEdit() const
2090{
2091 return d->offsetToCurrentEdit;
2092}
2093
2094void CurrentUserAtom::setOffsetToCurrentEdit( int offsetToCurrentEdit )
2095{
2096 d->offsetToCurrentEdit = offsetToCurrentEdit;
2097}
2098
2099int CurrentUserAtom::lenUserName() const
2100{
2101 return d->lenUserName;
2102}
2103
2104void CurrentUserAtom::setLenUserName( int lenUserName )
2105{
2106 d->lenUserName = lenUserName;
2107}
2108
2109int CurrentUserAtom::docFileVersion() const
2110{
2111 return d->docFileVersion;
2112}
2113
2114void CurrentUserAtom::setDocFileVersion( int docFileVersion )
2115{
2116 d->docFileVersion = docFileVersion;
2117}
2118
2119int CurrentUserAtom::majorVersion() const
2120{
2121 return d->majorVersion;
2122}
2123
2124void CurrentUserAtom::setMajorVersion( int majorVersion )
2125{
2126 d->majorVersion = majorVersion;
2127}
2128
2129int CurrentUserAtom::minorVersion() const
2130{
2131 return d->minorVersion;
2132}
2133
2134void CurrentUserAtom::setMinorVersion( int minorVersion )
2135{
2136 d->minorVersion = minorVersion;
2137}
2138
2139void CurrentUserAtom ::setData( unsigned , const unsigned char* data )
2140{
2141 setSize( readU32( data + 0 ) );
2142 setMagic( readU32( data + 4 ) );
2143 setOffsetToCurrentEdit( readU32( data + 8 ) );
2144 setLenUserName( readU16( data + 12 ) );
2145 setDocFileVersion( readU32( data + 14 ) );
2146 setMajorVersion( data[18] );
2147 setMinorVersion( data[19] );
2148}
2149
2150void CurrentUserAtom ::dump( std::ostream& out ) const
2151{
2152 out << " CurrentUserAtom" << std::endl;
2153 out << " size " << size() << std::endl;
2154 out << " magic " << magic() << std::endl;
2155 out << " offsetToCurrentEdit " << offsetToCurrentEdit() << std::endl;
2156 out << " lenUserName " << lenUserName() << std::endl;
2157 out << " docFileVersion " << docFileVersion() << std::endl;
2158 out << " majorVersion " << majorVersion() << std::endl;
2159 out << " minorVersion " << minorVersion() << std::endl;
2160}
2161
2162
2163// ========== UserEditAtom ==========
2164
2165const unsigned int UserEditAtom::id = 4085;
2166
2167class UserEditAtom::Private
2168{
2169public:
2170 int lastSlideId;
2171 int majorVersion;
2172 int minorVersion;
2173 unsigned long offsetLastEdit;
2174 unsigned long offsetPersistDir;
2175 unsigned long documentRef;
2176};
2177
2178UserEditAtom::UserEditAtom()
2179{
2180 d = new Private;
2181 d->lastSlideId = 0;
2182 d->majorVersion = 0;
2183 d->minorVersion = 0;
2184}
2185
2186UserEditAtom::~UserEditAtom()
2187{
2188 delete d;
2189}
2190
2191int UserEditAtom::lastSlideId() const
2192{
2193 return d->lastSlideId;
2194}
2195
2196void UserEditAtom::setLastSlideId( int id )
2197{
2198 d->lastSlideId = id;
2199}
2200
2201int UserEditAtom::majorVersion() const
2202{
2203 return d->majorVersion;
2204}
2205
2206void UserEditAtom::setMajorVersion( int majorVersion )
2207{
2208 d->majorVersion = majorVersion;
2209}
2210
2211int UserEditAtom::minorVersion() const
2212{
2213 return d->minorVersion;
2214}
2215
2216void UserEditAtom::setMinorVersion( int minorVersion )
2217{
2218 d->minorVersion = minorVersion;
2219}
2220
2221unsigned long UserEditAtom::offsetLastEdit() const
2222{
2223 return d->offsetLastEdit;
2224}
2225
2226void UserEditAtom::setOffsetLastEdit( unsigned long ofs )
2227{
2228 d->offsetLastEdit = ofs;
2229}
2230
2231unsigned long UserEditAtom::offsetPersistDir() const
2232{
2233 return d->offsetPersistDir;
2234}
2235
2236void UserEditAtom::setOffsetPersistDir( unsigned long ofs ) const
2237{
2238 d->offsetPersistDir = ofs;
2239}
2240
2241unsigned long UserEditAtom::documentRef() const
2242{
2243 return d->documentRef;
2244}
2245
2246void UserEditAtom::setDocumentRef( unsigned long ref ) const
2247{
2248 d->documentRef = ref;
2249}
2250
2251void UserEditAtom::setData( unsigned , const unsigned char* data )
2252{
2253 setLastSlideId( readU32( data + 0 ) );
2254 setMinorVersion( readU16( data + 4 ) );
2255 setMajorVersion( readU16( data + 6 ) );
2256 setOffsetLastEdit( readU32( data + 8 ) );
2257 setOffsetPersistDir( readU32( data + 12 ) );
2258 setDocumentRef( readU32( data + 16 ) );
2259}
2260
2261void UserEditAtom::dump( std::ostream& out ) const
2262{
2263 out << " UserEditAtom" << std::endl;
2264 out << " LastSlideID " << lastSlideId() << std::endl;
2265 out << " MajorVersion " << majorVersion() << std::endl;
2266 out << " MinorVersion " << minorVersion() << std::endl;
2267 out << " Offset Last Edit " << offsetLastEdit() << std::endl;
2268 out << " Offset Persist Dir " << offsetPersistDir() << std::endl;
2269 out << " Document Ref " << documentRef() << std::endl;
2270}
2271
2272// ========== TextBookmarkAtom ==========
2273
2274const unsigned int TextBookmarkAtom::id = 4007;
2275
2276class TextBookmarkAtom::Private
2277{
2278public:
2279 int begin;
2280 int end;
2281 int bookmarkID;
2282};
2283
2284TextBookmarkAtom::TextBookmarkAtom()
2285{
2286 d = new Private;
2287 d->begin = 0;
2288 d->end = 0;
2289 d->bookmarkID = 0;
2290}
2291
2292TextBookmarkAtom::~TextBookmarkAtom()
2293{
2294 delete d;
2295}
2296
2297int TextBookmarkAtom::begin() const
2298{
2299 return d->begin;
2300}
2301
2302void TextBookmarkAtom::setBegin( int begin )
2303{
2304 d->begin = begin;
2305}
2306
2307int TextBookmarkAtom::end() const
2308{
2309 return d->end;
2310}
2311
2312void TextBookmarkAtom::setEnd( int end )
2313{
2314 d->end = end;
2315}
2316
2317int TextBookmarkAtom::bookmarkID() const
2318{
2319 return d->bookmarkID;
2320}
2321
2322void TextBookmarkAtom::setBookmarkID( int bookmarkID )
2323{
2324 d->bookmarkID = bookmarkID;
2325}
2326
2327void TextBookmarkAtom::setData( unsigned , const unsigned char* data )
2328{
2329 setBegin( readU32( data + 0 ) );
2330 setEnd( readU32( data + 4 ) );
2331 setBookmarkID( readU32( data + 8 ) );
2332}
2333
2334void TextBookmarkAtom::dump( std::ostream& out ) const
2335{
2336 out << "TextBookmarkAtom" << std::endl;
2337 out << "begin " << begin() << std::endl;
2338 out << "end " << end() << std::endl;
2339 out << "bookmarkID " << bookmarkID() << std::endl;
2340}
2341
2342// ========== BookmarkEntityAtom ==========
2343
2344const unsigned int BookmarkEntityAtom::id = 4048;
2345
2346class BookmarkEntityAtom::Private
2347{
2348public:
2349 int bookmarkID;
2350 int bookmarkName;
2351};
2352
2353BookmarkEntityAtom::BookmarkEntityAtom()
2354{
2355 d = new Private;
2356 d->bookmarkID = 0;
2357 d->bookmarkName = 0;
2358}
2359
2360BookmarkEntityAtom::~BookmarkEntityAtom()
2361{
2362 delete d;
2363}
2364
2365int BookmarkEntityAtom::bookmarkID() const
2366{
2367 return d->bookmarkID;
2368}
2369
2370void BookmarkEntityAtom::setBookmarkID( int bookmarkID )
2371{
2372 d->bookmarkID = bookmarkID;
2373}
2374
2375int BookmarkEntityAtom::bookmarkName() const
2376{
2377 return d->bookmarkName;
2378}
2379
2380void BookmarkEntityAtom::setBookmarkName( int bookmarkName )
2381{
2382 d->bookmarkName = bookmarkName;
2383}
2384
2385void BookmarkEntityAtom::setData( unsigned , const unsigned char* data )
2386{
2387 setBookmarkID( readU32( data + 0 ) );
2388 setBookmarkName( readU16( data + 4 ) );
2389}
2390
2391void BookmarkEntityAtom::dump( std::ostream& out ) const
2392{
2393 out << "BookmarkEntityAtom" << std::endl;
2394 out << "bookmarkID " << bookmarkID() << std::endl;
2395 out << "bookmarkName " << bookmarkName() << std::endl;
2396}
2397
2398// ========== SSDocInfoAtom ==========
2399
2400const unsigned int SSDocInfoAtom::id = 1025;
2401
2402class SSDocInfoAtom::Private
2403{
2404public:
2405 int penColorRed;
2406 int penColorGreen;
2407 int penColorBlue;
2408 int penColorIndex;
2409 int restartTime;
2410 int startSlide;
2411 int endSlide;
2412 int namedShow;
2413 int flags;
2414};
2415
2416SSDocInfoAtom::SSDocInfoAtom()
2417{
2418 d = new Private;
2419 d->penColorRed = 0;
2420 d->penColorGreen = 0;
2421 d->penColorBlue = 0;
2422 d->penColorIndex = 0;
2423 d->restartTime = 0;
2424 d->startSlide = 0;
2425 d->endSlide = 0;
2426 d->namedShow = 0;
2427 d->flags = 0;
2428}
2429
2430SSDocInfoAtom::~SSDocInfoAtom()
2431{
2432 delete d;
2433}
2434
2435int SSDocInfoAtom::penColorRed() const
2436{
2437 return d->penColorRed;
2438}
2439
2440void SSDocInfoAtom::setPenColorRed( int penColorRed )
2441{
2442 d->penColorRed = penColorRed;
2443}
2444
2445int SSDocInfoAtom::penColorGreen() const
2446{
2447 return d->penColorGreen;
2448}
2449
2450void SSDocInfoAtom::setPenColorGreen( int penColorGreen )
2451{
2452 d->penColorGreen = penColorGreen;
2453}
2454
2455int SSDocInfoAtom::penColorBlue() const
2456{
2457 return d->penColorBlue;
2458}
2459
2460void SSDocInfoAtom::setPenColorBlue( int penColorBlue )
2461{
2462 d->penColorBlue = penColorBlue;
2463}
2464
2465int SSDocInfoAtom::penColorIndex() const
2466{
2467 return d->penColorIndex;
2468}
2469
2470void SSDocInfoAtom::setPenColorIndex( int penColorIndex )
2471{
2472 d->penColorIndex = penColorIndex;
2473}
2474
2475int SSDocInfoAtom::restartTime() const
2476{
2477 return d->restartTime;
2478}
2479
2480void SSDocInfoAtom::setRestartTime( int restartTime )
2481{
2482 d->restartTime = restartTime;
2483}
2484
2485int SSDocInfoAtom::startSlide() const
2486{
2487 return d->startSlide;
2488}
2489
2490void SSDocInfoAtom::setStartSlide( int startSlide )
2491{
2492 d->startSlide = startSlide;
2493}
2494
2495int SSDocInfoAtom::endSlide() const
2496{
2497 return d->endSlide;
2498}
2499
2500void SSDocInfoAtom::setEndSlide( int endSlide )
2501{
2502 d->endSlide = endSlide;
2503}
2504
2505int SSDocInfoAtom::namedShow() const
2506{
2507 return d->namedShow;
2508}
2509
2510void SSDocInfoAtom::setNamedShow( int namedShow )
2511{
2512 d->namedShow = namedShow;
2513}
2514
2515int SSDocInfoAtom::flags() const
2516{
2517 return d->flags;
2518}
2519
2520void SSDocInfoAtom::setFlags( int flags )
2521{
2522 d->flags = flags;
2523}
2524
2525void SSDocInfoAtom::setData( unsigned , const unsigned char* data )
2526{
2527 setPenColorRed( data[0] );
2528 setPenColorGreen( data[1] );
2529 setPenColorBlue( data[2]);
2530 setPenColorIndex( data[3] );
2531 setRestartTime( readS32( data + 4 ) );
2532 setStartSlide( readS16( data + 8 ) );
2533 setEndSlide( readS16( data + 10 ) );
2534 setNamedShow( readU16( data + 12 ) ); // 2 bytes repeat 32x
2535 setFlags( readU16( data + 76 ) ); // offset correct ?
2536}
2537
2538void SSDocInfoAtom::dump( std::ostream& out ) const
2539{
2540 out << "UserEditAtom" << std::endl;
2541 out << "penColorRed " << penColorRed() << std::endl;
2542 out << "penColorGreen " << penColorGreen() << std::endl;
2543 out << "penColorBlue " << penColorBlue() << std::endl;
2544 out << "penColorIndex " << penColorIndex() << std::endl;
2545 out << "restartTime " << restartTime() << std::endl;
2546 out << "startSlide " << startSlide() << std::endl;
2547 out << "endSlide " << endSlide() << std::endl;
2548 out << "namedShow " << namedShow() << std::endl;
2549 out << "Flags " << flags() << std::endl;
2550}
2551
2552// ========== SrKinsokuAtom ==========
2553
2554const unsigned int SrKinsokuAtom::id = 4050;
2555
2556SrKinsokuAtom::SrKinsokuAtom()
2557{
2558}
2559
2560SrKinsokuAtom::~SrKinsokuAtom()
2561{
2562}
2563
2564void SrKinsokuAtom::dump( std::ostream& out ) const
2565{
2566 out << "SrKinsokuAtom - not yet implemented" << std::endl;
2567}
2568
2569// ========== TxMasterStyleAtom ==========
2570
2571const unsigned int TxMasterStyleAtom::id = 4003;
2572
2573TxMasterStyleAtom::TxMasterStyleAtom()
2574{
2575}
2576
2577TxMasterStyleAtom::~TxMasterStyleAtom()
2578{
2579}
2580
2581void TxMasterStyleAtom::dump( std::ostream& out ) const
2582{
2583 out << "TxMasterStyleAtom - not yet implemented" << std::endl;
2584}
2585
2586// ========== SlideViewInfoAtom ==========
2587
2588const unsigned int SlideViewInfoAtom::id = 1022;
2589
2590class SlideViewInfoAtom ::Private
2591{
2592public:
2593 int showGuides;
2594 int snapToGrid;
2595 int snapToShape;
2596};
2597
2598SlideViewInfoAtom::SlideViewInfoAtom ()
2599{
2600 d = new Private;
2601 d->showGuides = 0;
2602 d->snapToGrid = 0;
2603 d->snapToShape = 0;
2604}
2605
2606SlideViewInfoAtom::~SlideViewInfoAtom ()
2607{
2608 delete d;
2609}
2610
2611int SlideViewInfoAtom::showGuides() const
2612{
2613 return d->showGuides;
2614}
2615
2616void SlideViewInfoAtom::setShowGuides(int showGuides)
2617{
2618 d->showGuides= showGuides;
2619}
2620
2621int SlideViewInfoAtom::snapToGrid() const
2622{
2623 return d->snapToGrid;
2624}
2625
2626void SlideViewInfoAtom::setSnapToGrid(int snapToGrid)
2627{
2628 d->snapToGrid= snapToGrid;
2629}
2630
2631int SlideViewInfoAtom::snapToShape() const
2632{
2633 return d->snapToShape;
2634}
2635
2636void SlideViewInfoAtom::setSnapToShape(int snapToShape)
2637{
2638 d->snapToGrid= snapToShape;
2639}
2640
2641void SlideViewInfoAtom ::setData( unsigned , const unsigned char* data )
2642{
2643 setShowGuides(data[0]);
2644 setSnapToGrid(data[1]);
2645 setSnapToShape(data[2]);
2646}
2647
2648void SlideViewInfoAtom ::dump( std::ostream& out ) const
2649{
2650 out << "SlideViewInfoAtom" << std::endl;
2651 out << "showGuides " << showGuides() << std::endl;
2652 out << "snapToGrid " << snapToGrid() << std::endl;
2653 out << "snapToShape " << snapToShape() << std::endl;
2654}
2655
2656// ========== ViewInfoAtom ==========
2657
2658const unsigned int ViewInfoAtom::id = 1021;
2659
2660class ViewInfoAtom ::Private
2661{
2662public:
2663 int curScaleXNum;
2664 int curScaleXDen;
2665 int curScaleYNum;
2666 int curScaleYDen;
2667 int prevScaleXNum;
2668 int prevScaleXDen;
2669 int prevScaleYNum;
2670 int prevScaleYDen;
2671 int viewSizeX;
2672 int viewSizeY;
2673 int originX;
2674 int originY;
2675 int varScale;
2676 int draftMode;
2677 int padding;
2678};
2679
2680ViewInfoAtom::ViewInfoAtom ()
2681{
2682 d = new Private;
2683 d->curScaleXNum = 0;
2684 d->curScaleXDen = 0;
2685 d->curScaleYNum = 0;
2686 d->curScaleYDen = 0;
2687 d->prevScaleXNum = 0;
2688 d->prevScaleXDen = 0;
2689 d->prevScaleYNum = 0;
2690 d->prevScaleYDen = 0;
2691 d->viewSizeX = 0;
2692 d->viewSizeY = 0;
2693 d->originX = 0;
2694 d->originY = 0;
2695 d->varScale = 0;
2696 d->draftMode = 0;
2697 d->padding = 0;
2698}
2699
2700ViewInfoAtom::~ViewInfoAtom ()
2701{
2702 delete d;
2703}
2704
2705int ViewInfoAtom::varScale() const
2706{
2707 return d->varScale;
2708}
2709
2710void ViewInfoAtom::setVarScale(int varScale)
2711{
2712 d->varScale= varScale;
2713}
2714
2715int ViewInfoAtom::draftMode() const
2716{
2717 return d->draftMode;
2718}
2719
2720void ViewInfoAtom::setDraftMode(int draftMode)
2721{
2722 d->draftMode= draftMode;
2723}
2724
2725int ViewInfoAtom::padding() const
2726{
2727 return d->padding;
2728}
2729
2730void ViewInfoAtom::setPadding(int padding)
2731{
2732 d->padding= padding;
2733}
2734
2735int ViewInfoAtom::viewSizeX() const
2736{
2737 return d->viewSizeX;
2738}
2739
2740void ViewInfoAtom::setViewSizeX(int viewSizeX)
2741{
2742 d->viewSizeX= viewSizeX;
2743}
2744
2745int ViewInfoAtom::viewSizeY() const
2746{
2747 return d->viewSizeY;
2748}
2749
2750void ViewInfoAtom::setViewSizeY(int viewSizeY)
2751{
2752 d->viewSizeY= viewSizeY;
2753}
2754
2755int ViewInfoAtom::originX() const
2756{
2757 return d->originX;
2758}
2759
2760void ViewInfoAtom::setOriginX(int originX)
2761{
2762 d->originX= originX;
2763}
2764
2765int ViewInfoAtom::originY() const
2766{
2767 return d->originY;
2768}
2769
2770void ViewInfoAtom::setOriginY (int originY)
2771{
2772 d->originY= originY;
2773}
2774
2775int ViewInfoAtom::prevScaleXNum() const
2776{
2777 return d->prevScaleXNum;
2778}
2779
2780void ViewInfoAtom::setPrevScaleXNum(int prevScaleXNum)
2781{
2782 d->prevScaleXNum= prevScaleXNum;
2783}
2784
2785int ViewInfoAtom::prevScaleXDen() const
2786{
2787 return d->prevScaleXDen;
2788}
2789
2790void ViewInfoAtom::setPrevScaleXDen(int prevScaleXDen)
2791{
2792 d->prevScaleXDen= prevScaleXDen;
2793}
2794
2795int ViewInfoAtom::prevScaleYNum() const
2796{
2797 return d->prevScaleYNum;
2798}
2799
2800void ViewInfoAtom::setPrevScaleYNum(int prevScaleYNum)
2801{
2802 d->prevScaleYNum= prevScaleYNum;
2803}
2804
2805int ViewInfoAtom::prevScaleYDen() const
2806{
2807 return d->prevScaleYDen;
2808}
2809
2810void ViewInfoAtom::setPrevScaleYDen(int prevScaleYDen)
2811{
2812 d->prevScaleYDen= prevScaleYDen;
2813}
2814
2815int ViewInfoAtom::curScaleXNum() const
2816{
2817 return d->curScaleXNum;
2818}
2819
2820void ViewInfoAtom::setCurScaleXNum(int curScaleXNum)
2821{
2822 d->curScaleXNum= curScaleXNum;
2823}
2824
2825int ViewInfoAtom::curScaleXDen() const
2826{
2827 return d->curScaleXDen;
2828}
2829
2830void ViewInfoAtom::setCurScaleXDen(int curScaleXDen)
2831{
2832 d->curScaleXDen= curScaleXDen;
2833}
2834
2835int ViewInfoAtom::curScaleYNum() const
2836{
2837 return d->curScaleYNum;
2838}
2839
2840void ViewInfoAtom::setCurScaleYNum(int curScaleYNum)
2841{
2842 d->curScaleYNum= curScaleYNum;
2843}
2844
2845int ViewInfoAtom::curScaleYDen() const
2846{
2847 return d->curScaleYDen;
2848}
2849
2850void ViewInfoAtom::setCurScaleYDen(int curScaleYDen)
2851{
2852 d->curScaleYDen= curScaleYDen;
2853}
2854
2855void ViewInfoAtom ::setData( unsigned , const unsigned char* data )
2856{
2857 setCurScaleXNum(readS32( data + 0));
2858 setCurScaleXDen(readS32( data + 4 ));
2859 setCurScaleYNum(readS32( data + 8));
2860 setCurScaleYDen(readS32( data + 12 ));
2861 setPrevScaleXNum(readS32( data + 16 ));
2862 setPrevScaleXDen(readS32( data + 20 ));
2863 setPrevScaleYNum(readS32( data + 24 ));
2864 setPrevScaleYDen(readS32( data + 28 ));
2865 setViewSizeX(readS32( data + 32 ));
2866 setViewSizeY(readS32( data + 36 ));
2867 setOriginX(readS32( data + 40 ));
2868 setOriginY(readS32( data + 44));
2869 setVarScale(data[48]);
2870 setDraftMode(data[49]);
2871 setPadding(readU16( data + 50 ));
2872}
2873
2874void ViewInfoAtom ::dump( std::ostream& out ) const
2875{
2876 out << "ViewInfoAtom" << std::endl;
2877 out << "curScaleXNum " << curScaleXNum() << std::endl;
2878 out << "curScaleXDen " << curScaleXDen() << std::endl;
2879 out << "curScaleYNum " << curScaleYNum() << std::endl;
2880 out << "curScaleYDen " << curScaleYDen() << std::endl;
2881 out << "prevScaleXNum " << prevScaleXNum() << std::endl;
2882 out << "prevScaleXDen " << prevScaleXNum() << std::endl;
2883 out << "prevScaleYNum " << prevScaleYNum() << std::endl;
2884 out << "prevScaleYDen " << prevScaleYNum() << std::endl;
2885 out << "viewSizeX " << viewSizeX() << std::endl;
2886 out << "viewSizeY " << viewSizeY() << std::endl;
2887 out << "originX " << originX() << std::endl;
2888 out << "originY " << originY() << std::endl;
2889 out << "varScale " << varScale() << std::endl;
2890 out << "draftMode " << draftMode() << std::endl;
2891 out << "padding " << padding() << std::endl;
2892}
2893
2894// ========== StyleTextPropAtom ==========
2895
2896const unsigned int StyleTextPropAtom ::id = 4001;
2897
2898class StyleTextPropAtom::Private
2899{
2900public:
2901 unsigned stringLength;
2902 struct PropAtomData
2903 {
2904 PropAtomData()
2905 : charCount(0)
2906 , depth(0)
2907 , bulletOn(0)
2908 , bulletHardFont(0)
2909 , bulletHardColor(0)
2910 , bulletChar(0)
2911 , bulletFont(0)
2912 , bulletHeight(0)
2913 , bulletColor(0)
2914 , align(0)
2915 , lineFeed(0)
2916 , upperDist(0)
2917 , lowerDist(0)
2918 , asianLB1(0)
2919 , asianLB2(0)
2920 , asianLB3(0)
2921 , biDi(0)
2922 {}
2923
2924 int charCount;
2925 int depth;
2926 unsigned bulletOn;
2927 unsigned bulletHardFont;
2928 unsigned bulletHardColor;
2929 unsigned bulletChar;
2930 unsigned bulletFont;
2931 unsigned bulletHeight;
2932 unsigned bulletColor;
2933 unsigned align;
2934 unsigned lineFeed;
2935 int upperDist;
2936 int lowerDist;
2937 int asianLB1;
2938 int asianLB2;
2939 int asianLB3;
2940 unsigned biDi;
2941 };
2942 std::vector<PropAtomData> atomData;
2943
2944 int charMask;
2945 int charCount2;
2946 int charFlags;
2947};
2948
2949StyleTextPropAtom::StyleTextPropAtom()
2950{
2951 d = new Private;
2952 d->charMask = 0;
2953 d->charCount2 = 0;
2954 d->charFlags = 0;
2955}
2956
2957StyleTextPropAtom::~StyleTextPropAtom()
2958{
2959 delete d;
2960}
2961
2962unsigned StyleTextPropAtom::listSize() const
2963{
2964 return d->atomData.size();
2965}
2966
2967int StyleTextPropAtom::charCount( unsigned index ) const
2968{
2969 return d->atomData[index].charCount;
2970}
2971
2972int StyleTextPropAtom::depth( unsigned index ) const
2973{
2974 return d->atomData[index].depth;
2975}
2976
2977int StyleTextPropAtom::bulletOn( unsigned index ) const
2978{
2979 return d->atomData[index].bulletOn;
2980}
2981
2982int StyleTextPropAtom::bulletHardFont( unsigned index ) const
2983{
2984 return d->atomData[index].bulletHardFont;
2985}
2986
2987int StyleTextPropAtom::bulletHardColor( unsigned index ) const
2988{
2989 return d->atomData[index].bulletHardColor;
2990}
2991
2992int StyleTextPropAtom::bulletChar( unsigned index ) const
2993{
2994 return d->atomData[index].bulletChar;
2995}
2996
2997int StyleTextPropAtom::bulletFont( unsigned index ) const
2998{
2999 return d->atomData[index].bulletFont;
3000}
3001
3002int StyleTextPropAtom::bulletHeight( unsigned index ) const
3003{
3004 return d->atomData[index].bulletHeight;
3005}
3006
3007int StyleTextPropAtom::bulletColor( unsigned index ) const
3008{
3009 return d->atomData[index].bulletColor;
3010}
3011
3012int StyleTextPropAtom::lineFeed( unsigned index ) const
3013{
3014 return d->atomData[index].lineFeed;
3015}
3016
3017int StyleTextPropAtom::upperDist( unsigned index ) const
3018{
3019 return d->atomData[index].upperDist;
3020}
3021
3022int StyleTextPropAtom::lowerDist( unsigned index ) const
3023{
3024 return d->atomData[index].lowerDist;
3025}
3026
3027int StyleTextPropAtom::align( unsigned index ) const
3028{
3029 return d->atomData[index].align;
3030}
3031
3032int StyleTextPropAtom::asianLB1( unsigned index ) const
3033{
3034 return d->atomData[index].asianLB1;
3035}
3036
3037int StyleTextPropAtom::asianLB2( unsigned index ) const
3038{
3039 return d->atomData[index].asianLB2;
3040}
3041
3042int StyleTextPropAtom::asianLB3( unsigned index ) const
3043{
3044 return d->atomData[index].asianLB3;
3045}
3046
3047int StyleTextPropAtom::biDi( unsigned index ) const
3048{
3049 return d->atomData[index].biDi;
3050}
3051
3052int StyleTextPropAtom::charMask() const
3053{
3054 return d->charMask;
3055}
3056
3057void StyleTextPropAtom::setCharMask( int charMask )
3058{
3059 d->charMask = charMask;
3060}
3061
3062int StyleTextPropAtom::charFlags() const
3063{
3064 return d->charFlags;
3065}
3066
3067void StyleTextPropAtom::setCharFlags( int charFlags )
3068{
3069 d->charFlags = charFlags;
3070}
3071
3072void StyleTextPropAtom::setData( unsigned /*size*/, const unsigned char* data, unsigned lastSize )
3073{
3074 unsigned charRead = 0;
3075 unsigned charCount = 0;
3076 unsigned stringLength = unsigned( (0.5*lastSize) + 1 );
3077
3078 bool isTextPropAtom = true;
3079 unsigned k=0;
3080
3081 while ( charRead < stringLength )
3082 {
3083 if ( isTextPropAtom == true )
3084 {
3085 Private::PropAtomData atomData;
3086 charCount = readU32(data+k) - 1;
3087 k += 4;
3088 atomData.charCount = charCount;
3089 atomData.depth = readU16(data+k);
3090 k += 2;
3091 unsigned mask = readU32(data+6);
3092 k += 4;
3093
3094 if ( mask & 0xF )
3095 {
3096 int bulletFlag = readU16(data+k);
3097 k += 2;
3098 atomData.bulletOn = ( bulletFlag & 1 ) ? 1 : 0;
3099 atomData.bulletHardFont = ( bulletFlag & 2 ) ? 1 : 0;
3100 atomData.bulletHardColor = ( bulletFlag & 4 ) ? 1 : 0;
3101 }
3102
3103 if ( mask & 0x0080 )
3104 {
3105 atomData.bulletChar = readU16(data+k);
3106 k += 2;
3107 }
3108
3109 if ( mask & 0x0010 )
3110 {
3111 atomData.bulletFont = readU16(data+k);
3112 k += 2;
3113 }
3114
3115 if ( mask & 0x0040 )
3116 {
3117 atomData.bulletHeight = readU16(data+k);
3118 k += 2;
3119 }
3120
3121 if ( mask & 0x0020 )
3122 {
3123 atomData.bulletColor = readU32(data+k);
3124 k += 4;
3125 }
3126
3127 if ( mask & 0x0F00 )
3128 {
3129 if ( mask & 0x800 )
3130 {
3131 unsigned dummy = readU16(data+k);
3132 atomData.align = ( dummy & 3 );
3133 k += 2;
3134 }
3135 if ( mask & 0x400 )
3136 {
3137 /*unsigned dummy =*/ readU16(data+k);
3138 k += 2;
3139 }
3140 if ( mask & 0x200 )
3141 {
3142 /*unsigned dummy =*/ readU16(data+k);
3143 k += 2;
3144 }
3145 if ( mask & 0x100 )
3146 {
3147 /*unsigned dummy =*/ readU16(data+k);
3148 k += 2;
3149 }
3150 }
3151
3152 if ( mask & 0x1000 )
3153 {
3154 atomData.lineFeed = readU16(data+k);
3155 k += 2;
3156 }
3157
3158 if ( mask & 0x2000 )
3159 {
3160 atomData.upperDist = readU16(data+k);
3161 k += 2;
3162 }
3163
3164 if ( mask & 0x4000 )
3165 {
3166 atomData.lowerDist = readU16(data+k);
3167 k += 2;
3168 }
3169
3170 if ( mask & 0x8000 )
3171 {
3172 /*unsigned dummy =*/ readU16(data+k);
3173 k += 2;
3174 }
3175
3176 if ( mask & 0x10000 )
3177 {
3178 /*unsigned dummy =*/ readU16(data+k);
3179 k += 2;
3180 }
3181
3182 if ( mask & 0xe0000 )
3183 {
3184 unsigned dummy = readU16(data+k);
3185 if ( mask & 0x20000 )
3186 atomData.asianLB1 = dummy & 1;
3187 if ( mask & 0x40000 )
3188 atomData.asianLB2 = (dummy >> 1) & 1;
3189 if ( mask & 0x80000 )
3190 atomData.asianLB3 = (dummy >> 2) & 1;
3191
3192 k += 2;
3193 }
3194
3195 if ( mask & 0x200000 )
3196 {
3197 atomData.biDi = readU16(data+k);
3198 k += 2;
3199 }
3200 d->atomData.push_back( atomData );
3201 }
3202 else
3203 {
3204 std::cout << "isTextPropAtom == false " << std::endl;
3205 charCount = stringLength;
3206 Private::PropAtomData atomData;
3207 atomData.charCount = charCount;
3208 d->atomData.push_back( atomData );
3209 }
3210
3211 if ( ( charCount > stringLength ) || ( stringLength - ( charRead + charCount ) < 0 ) )
3212 {
3213 isTextPropAtom = false;
3214 charCount = stringLength - charRead;
3215 Private::PropAtomData atomData;
3216 atomData.charCount = charCount;
3217 d->atomData.push_back( atomData );
3218 }
3219
3220 charRead += charCount + 1;
3221
3222 // std::cout << "k = " << k << std::endl;
3223 }
3224
3225
3226 /* charRead = 0;
3227 while ( charRead < stringLength )
3228 {
3229 std::cout << "in second while-loop " << std::endl;
3230 if ( (isTextPropAtom == false) && (k < size) )
3231 {
3232 unsigned charCount = readU16(data+k) ;
3233 setCharCount (charCount);
3234 k += 2;
3235 unsigned dummy = readU16(data+k);
3236 k += 2;else setAlign( dummy & 3 );
3237 int charToRead = size - (charRead + charCount);
3238 // std::cout << "charToRead = " << charToRead << std::endl;
3239 if (charToRead < 0)
3240 {
3241 charCount = size - charRead;
3242 if ( charToRead < -1 )
3243 {
3244 isTextPropAtom = false;
3245 }
3246 }
3247 unsigned charMask = readU16(data+k) ;
3248 k += 2;
3249 setCharMask ( charMask );
3250 if ( charMask )
3251 {
3252 setCharFlags( readU16(data+k) );
3253 k += 2;
3254 }
3255 // std::cout << "k = " << k << std::endl;
3256
3257 static unsigned charAttrTable[16] =
3258 { 16, 21, 22, 23, 17, 18, 19, 20, 24, 25, 26, 27, 28, 29, 30, 31 };
3259
3260 for ( int i = 0; i < 16; i++ )
3261 {
3262 int j = charAttrTable[ i ];
3263 if ( charMask & ( 1 << j ) )
3264 {
3265 switch ( j )
3266 {
3267 case 23: //PPT_CharAttr_Symbol
3268 { else setAlign( dummy & 3 );
3269 unsigned setSymbolFont= (readU16(data+k));
3270 std::cout << "setSymbolFont = " << setSymbolFont << std::endl;
3271 //setSymbolFont(readU16(data+k));
3272 } break;
3273 case 16: //PPT_CharAttr_Font
3274 {
3275 unsigned setFont= (readU16(data+k));
3276 std::cout << "setFont = " << setFont << std::endl;
3277 //setFont(readU16(data+k));
3278 } break;
3279 case 21: //PPT_CharAttr_AsianOrComplexFont
3280 {
3281 unsigned setAsianOrComplexFont= (readU16(data+k));
3282 std::cout << "setAsianOrComplexFont = " << setAsianOrComplexFont << std::endl;
3283 //setAsianOrComplexFont(readU16(data+k));
3284 } break;
3285 case 22: // PPT_CharAttr_Unknown2
3286 { unsigned setUnknown= (readU16(data+k));
3287 std::cout << "setUnknown = " << setUnknown << std::endl;
3288 //setUnknown(readU16(data+k));
3289 } break;
3290 case 17: //PPT_CharAttr_Fontvoid Record::setData( unsigned, const unsigned char* )
3291 { unsigned setFonttPropAtomHeight= (readU16(data+k));
3292 std::cout << "setFontHeight = " << setFontHeight << std::endl;
3293 //setFontHeight(readU16(data+k));
3294 } break;
3295 case 18: //PPT_CharAttr_FontColor
3296 { unsigned setFontColor= (readU32(data+k));
3297 std::cout << "setFontColor = " << setFontColor << std::endl;
3298 //setFontColor(readU32(data+k));
3299 k +=2;
3300 } break;
3301 case 19://PPT_CharAttr_Escapement
3302 { unsigned setEscapement= (readU16(data+k));
3303 std::cout << "setEscapement = " << setEscapement << std::endl;
3304 //setEscapement(readU32(data+k));
3305 } break;
3306 default:
3307 { unsigned dummy = readU16(data+k);
3308 std::cout << "default " << dummy << std::endl;
3309 }
3310 }
3311 k +=2;
3312 }
3313 }
3314powerpoint.cpp:3370: warning: convert
3315 std::cout << "k = " << k << std::endl;
3316 }
3317 else
3318 {
3319 charRead = stringLength;
3320 }
3321 } */
3322
3323}
3324
3325
3326void StyleTextPropAtom::dump( std::ostream& out ) const
3327{
3328 out << "StyleTextPropAtom" << std::endl;
3329 out << "listSize " << listSize() << std::endl << std::endl;
3330 for ( unsigned i = 0; i < listSize(); i++)
3331 {
3332 out << "charCount " << charCount(i) << std::endl;
3333 out << "depth " << depth(i) << std::endl;
3334 out << "isBulletOn " << bulletOn(i) << std::endl;
3335 out << "isbulletHardFont " << bulletHardFont(i) << std::endl;
3336 out << "isbulletHardColor " << bulletHardColor(i) << std::endl;
3337 out << "bulletChar " << bulletChar(i) << std::endl;
3338 out << "bulletFont " << bulletFont(i) << std::endl;
3339 out << "bulletHeight " << bulletHeight(i) << std::endl;
3340 out << "bulletColor " << std::endl;
3341 out << " R " << ((bulletColor(i) >>0) & 0xff) << std::endl;
3342 out << " G " << ((bulletColor(i) >>8) & 0xff) << std::endl;
3343 out << " B " << ((bulletColor(i) >>16) & 0xff) << std::endl;
3344 out << " I " << ((bulletColor(i) >>24) & 0xff) << std::endl;
3345 out << "align " << align(i) << std::endl;
3346 out << "lineFeed " << lineFeed(i) << std::endl;
3347 out << "upperDist " << upperDist(i) << std::endl;
3348 out << "lowerDist " << lowerDist(i) << std::endl;
3349 out << "biDi " << biDi(i) << std::endl;
3350
3351 out << std::endl;
3352 }
3353// out << "charMask " << charMask() << std::endl;
3354// out << "charFlags " << charFlags() << std::endl;
3355
3356}
3357
3358
3359
3360// ========== TxCFStyleAtom ==========
3361
3362const unsigned int TxCFStyleAtom ::id = 4004;
3363
3364
3365class TxCFStyleAtom ::Private
3366{
3367public:
3368 int flags1;
3369 int flags2;
3370 int flags3;
3371 int n1;
3372 int fontHeight;
3373 int fontColor;
3374};
3375
3376TxCFStyleAtom ::TxCFStyleAtom ()
3377{
3378 d = new Private;
3379 d->flags1 = 0;
3380 d->flags2 = 0;
3381 d->flags3 = 0;
3382 d->n1 = 0;
3383 d->fontHeight = 0;
3384 d->fontColor = 0;
3385}
3386
3387TxCFStyleAtom ::~TxCFStyleAtom ()
3388{
3389 delete d;
3390}
3391
3392int TxCFStyleAtom::flags1() const
3393{
3394 return d->flags1;
3395}
3396
3397void TxCFStyleAtom::setFlags1( int flags1 )
3398{
3399 d->flags1 = flags1;
3400}
3401
3402int TxCFStyleAtom::flags2() const
3403{
3404 return d->flags2;
3405}
3406
3407void TxCFStyleAtom::setFlags2( int flags2 )
3408{
3409 d->flags2 = flags2;
3410}
3411
3412int TxCFStyleAtom::flags3() const
3413{
3414 return d->flags3;
3415}
3416
3417void TxCFStyleAtom::setFlags3( int flags3 )
3418{
3419 d->flags3 = flags3;
3420}
3421
3422int TxCFStyleAtom::n1() const
3423{
3424 return d->n1;
3425}
3426
3427void TxCFStyleAtom::setN1( int n1 )
3428{
3429 d->n1 = n1;
3430}
3431
3432int TxCFStyleAtom::fontHeight() const
3433{
3434 return d->fontHeight;
3435}
3436
3437void TxCFStyleAtom::setFontHeight( int fontHeight )
3438{
3439 d->fontHeight = fontHeight;
3440}
3441
3442int TxCFStyleAtom::fontColor() const
3443{
3444 return d->fontColor;
3445}
3446
3447void TxCFStyleAtom::setFontColor( int fontColor )
3448{
3449 d->fontColor = fontColor;
3450}
3451
3452void TxCFStyleAtom::setData( unsigned , const unsigned char* data )
3453{
3454 setFlags1(readU16( data + 0));
3455 setFlags2(readU16( data + 2));
3456 setFlags3(readU16( data + 4));
3457 setN1(readU32( data + 6));
3458 setFontHeight(readU16( data + 10));
3459 setFontColor(readU32( data + 12));
3460}
3461
3462void TxCFStyleAtom ::dump( std::ostream& out ) const
3463{
3464 out << "TxCFStyleAtom " << std::endl;
3465 out << "flags1 " << flags1() << std::endl;
3466 out << "flags2 " << flags2() << std::endl;
3467 out << "flags3 " << flags3() << std::endl;
3468 out << "n1 " << n1() << std::endl;
3469 out << "font height " << fontHeight() << std::endl;
3470 out << "font color " << fontColor() << std::endl;
3471}
3472
3473// ========== TxPFStyleAtom ==========
3474
3475const unsigned int TxPFStyleAtom::id = 4005;
3476
3477TxPFStyleAtom::TxPFStyleAtom()
3478{
3479}
3480
3481TxPFStyleAtom::~TxPFStyleAtom()
3482{
3483}
3484
3485void TxPFStyleAtom::dump( std::ostream& out ) const
3486{
3487 out << "TxPFStyleAtom - need special parse code" << std::endl;
3488}
3489
3490// ========== TxSIStyleAtom ==========
3491
3492const unsigned int TxSIStyleAtom ::id = 4009;
3493
3494TxSIStyleAtom ::TxSIStyleAtom ()
3495{
3496}
3497
3498TxSIStyleAtom ::~TxSIStyleAtom ()
3499{
3500}
3501
3502void TxSIStyleAtom ::dump( std::ostream& out ) const
3503{
3504 out << "TxSIStyleAtom - need special parse code" << std::endl;
3505}
3506
3507// ========== Record1043 ==========
3508
3509const unsigned int Record1043::id = 1043;
3510
3511Record1043::Record1043()
3512{
3513}
3514
3515void Record1043::dump( std::ostream& out ) const
3516{
3517 out << "Record1043 - not known" << std::endl;
3518}
3519
3520// ========== Record1044 ==========
3521
3522const unsigned int Record1044::id = 1044;
3523
3524Record1044::Record1044()
3525{
3526}
3527
3528void Record1044::dump( std::ostream& out ) const
3529{
3530 out << "Record1044 - not known" << std::endl;
3531}
3532
3533// ========== SlideAtom ==========
3534
3535const unsigned int SlideAtom::id = 1007;
3536
3537class SlideAtom::Private
3538{
3539public:
3540 int layoutGeom;
3541 int layoutPlaceholderId1;
3542 int layoutPlaceholderId2;
3543 int layoutPlaceholderId3;
3544 int layoutPlaceholderId4;
3545 int layoutPlaceholderId5;
3546 int layoutPlaceholderId6;
3547 int layoutPlaceholderId7;
3548 int layoutPlaceholderId8;
3549 int masterId;
3550 int notesId;
3551 int flags;
3552};
3553
3554SlideAtom::SlideAtom()
3555{
3556 d = new Private;
3557 d->layoutGeom = 0;
3558 d->layoutPlaceholderId1 = 0;
3559 d->layoutPlaceholderId2 = 0;
3560 d->layoutPlaceholderId3 = 0;
3561 d->layoutPlaceholderId4 = 0;
3562 d->layoutPlaceholderId5 = 0;
3563 d->layoutPlaceholderId6 = 0;
3564 d->layoutPlaceholderId7 = 0;
3565 d->layoutPlaceholderId8 = 0;
3566 d->masterId = 0;
3567 d->notesId = 0;
3568 d->flags = 0;
3569}
3570
3571SlideAtom::~SlideAtom()
3572{
3573 delete d;
3574}
3575
3576int SlideAtom::layoutGeom() const
3577{
3578 return d->layoutGeom;
3579}
3580
3581void SlideAtom::setLayoutGeom(int layoutGeom )
3582{
3583 d->layoutGeom = layoutGeom;
3584}
3585
3586
3587int SlideAtom::layoutPlaceholderId() const
3588{
3589 return d->layoutPlaceholderId1;
3590 return d->layoutPlaceholderId2;
3591 return d->layoutPlaceholderId3;
3592 return d->layoutPlaceholderId4;
3593 return d->layoutPlaceholderId5;
3594 return d->layoutPlaceholderId6;
3595 return d->layoutPlaceholderId7;
3596 return d->layoutPlaceholderId8;
3597}
3598
3599void SlideAtom::setLayoutPlaceholderId(int layoutPlaceholderId1, int layoutPlaceholderId2,int layoutPlaceholderId3,int layoutPlaceholderId4,int layoutPlaceholderId5,int layoutPlaceholderId6,int layoutPlaceholderId7,int layoutPlaceholderId8)
3600{
3601 d->layoutPlaceholderId1 = layoutPlaceholderId1;
3602 d->layoutPlaceholderId2 = layoutPlaceholderId2;
3603 d->layoutPlaceholderId3 = layoutPlaceholderId3;
3604 d->layoutPlaceholderId4 = layoutPlaceholderId4;
3605 d->layoutPlaceholderId5 = layoutPlaceholderId5;
3606 d->layoutPlaceholderId6 = layoutPlaceholderId6;
3607 d->layoutPlaceholderId7 = layoutPlaceholderId7;
3608 d->layoutPlaceholderId8 = layoutPlaceholderId8;
3609}
3610
3611int SlideAtom::masterId() const
3612{
3613 return d->masterId;
3614}
3615
3616void SlideAtom::setMasterId(int masterId )
3617{
3618 d->masterId = masterId;
3619}
3620
3621int SlideAtom::notesId() const
3622{
3623 return d->notesId;
3624}
3625
3626void SlideAtom::setNotesId(int notesId)
3627{
3628 d->notesId = notesId;
3629}
3630
3631int SlideAtom::flags() const
3632{
3633 return d->flags;
3634}
3635
3636void SlideAtom::setFlags( int flags)
3637{
3638 d->flags = flags;
3639}
3640
3641void SlideAtom::setData( unsigned , const unsigned char* data )
3642{
3643 setLayoutGeom(readS32( data + 0 ) );
3644 setLayoutPlaceholderId (data[4], data[5], data[6], data[7], data[8], data[9], data[10],data[11]);
3645 setMasterId( readS32( data + 12 ) );
3646 setNotesId( readS32( data + 16 ) );
3647 setFlags( readU16( data + 20 ) );
3648}
3649
3650void SlideAtom::dump( std::ostream& out ) const
3651{
3652 out << "SlideAtom" << std::endl;
3653 out << "layoutGeom " << layoutGeom() << std::endl;
3654 // out << "layoutPlaceholderId " << layoutPlaceholderId() <<std::endl;
3655 out << "layoutPlaceholderId1 " << d->layoutPlaceholderId1 <<std::endl;
3656 out << "layoutPlaceholderId2 " << d->layoutPlaceholderId2 <<std::endl;
3657 out << "layoutPlaceholderId3 " << d->layoutPlaceholderId3 <<std::endl;
3658 out << "layoutPlaceholderId4 " << d->layoutPlaceholderId4 <<std::endl;
3659 out << "layoutPlaceholderId5 " << d->layoutPlaceholderId5 <<std::endl;
3660 out << "layoutPlaceholderId6 " << d->layoutPlaceholderId6 <<std::endl;
3661 out << "layoutPlaceholderId7 " << d->layoutPlaceholderId7 <<std::endl;
3662 out << "layoutPlaceholderId8 " << d->layoutPlaceholderId8 <<std::endl;
3663 out << "masterId " << masterId() << std::endl;
3664 out << "notesId " << notesId() << std::endl;
3665 out << "flags " << flags() << std::endl;
3666}
3667
3668// ========== SSSlideInfoAtom ==========
3669
3670const unsigned int SSSlideInfoAtom::id = 1017;
3671
3672class SSSlideInfoAtom ::Private
3673{
3674public:
3675 int transType;
3676 int speed;
3677 int direction;
3678 int slideTime;
3679 int buildFlags;
3680 int soundRef;
3681};
3682
3683SSSlideInfoAtom ::SSSlideInfoAtom ()
3684{
3685 d = new Private;
3686 d->transType = 0;
3687 d->speed = 0;
3688 d->direction = 0;
3689 d->slideTime = 0;
3690 d->buildFlags = 0;
3691 d->soundRef = 0;
3692}
3693
3694SSSlideInfoAtom ::~SSSlideInfoAtom ()
3695{
3696 delete d;
3697}
3698
3699int SSSlideInfoAtom ::transType() const
3700{
3701 return d->transType;
3702}
3703
3704void SSSlideInfoAtom ::settransType(int transType)
3705{
3706 d->transType = transType;
3707}
3708
3709int SSSlideInfoAtom ::speed() const
3710{
3711 return d->transType;
3712}
3713
3714void SSSlideInfoAtom ::setspeed(int speed)
3715{
3716 d->speed = speed;
3717}
3718
3719int SSSlideInfoAtom ::direction() const
3720{
3721 return d->transType;
3722}
3723
3724void SSSlideInfoAtom ::setdirection(int direction)
3725{
3726 d->direction = direction;
3727}
3728
3729int SSSlideInfoAtom ::slideTime() const
3730{
3731 return d->slideTime;
3732}
3733
3734void SSSlideInfoAtom ::setslideTime(int slideTime)
3735{
3736 d->slideTime = slideTime;
3737}
3738
3739int SSSlideInfoAtom ::buildFlags() const
3740{
3741 return d->buildFlags;
3742}
3743
3744void SSSlideInfoAtom ::setbuildFlags(int buildFlags)
3745{
3746 d->buildFlags = buildFlags;
3747}
3748
3749int SSSlideInfoAtom ::soundRef() const
3750{
3751 return d->soundRef;
3752}
3753
3754void SSSlideInfoAtom ::setsoundRef(int soundRef)
3755{
3756 d->soundRef = soundRef;
3757}
3758
3759void SSSlideInfoAtom ::setData( unsigned , const unsigned char* data )
3760{
3761 settransType( readU32( data + 0 ) );
3762 setspeed(readS32( data + 4 ));
3763 setdirection(readS32( data + 8 ));
3764 setslideTime(readS32( data + 12 ));
3765 setbuildFlags(readS32( data + 16 ));
3766 setsoundRef(readS32( data + 20 ));
3767}
3768
3769void SSSlideInfoAtom ::dump( std::ostream& out ) const
3770{
3771 out << "SSSlideInfoAtom" << std::endl;
3772 out << "transType " << transType() << std::endl;
3773 out << "speed " << speed() << std::endl;
3774 out << "direction " << direction() << std::endl;
3775 out << "slideTime " << slideTime() << std::endl;
3776 out << "buildFlags " << buildFlags() << std::endl;
3777 out << "soundRef " << soundRef() << std::endl;
3778}
3779
3780// ========== TextHeaderAtom ==========
3781
3782const unsigned int TextHeaderAtom::id = 3999;
3783
3784class TextHeaderAtom ::Private
3785{
3786public:
3787 int textType;
3788};
3789
3790TextHeaderAtom ::TextHeaderAtom ()
3791{
3792 d = new Private;
3793 d->textType = 0;
3794}
3795
3796TextHeaderAtom ::~TextHeaderAtom ()
3797{
3798 delete d;
3799}
3800
3801int TextHeaderAtom ::textType() const
3802{
3803 return d->textType;
3804}
3805
3806void TextHeaderAtom ::setTextType( int type )
3807{
3808 d->textType = type;
3809}
3810
3811void TextHeaderAtom ::setData( unsigned size, const unsigned char* data )
3812{
3813 if( size < 4 ) return;
3814 setTextType( readU32( data + 0 ) );
3815}
3816
3817void TextHeaderAtom ::dump( std::ostream& out ) const
3818{
3819 out << "TextHeaderAtom" << std::endl;
3820 out << " textType " << textType() << std::endl;
3821}
3822
3823// ========== TextBytesAtom ==========
3824
3825const unsigned int TextBytesAtom::id = 4008;
3826
3827class TextBytesAtom::Private
3828{
3829public:
3830 std::vector<unsigned> index;
3831 std::vector<UString> ustring;
3832 unsigned stringLength;
3833};
3834
3835TextBytesAtom::TextBytesAtom()
3836{
3837 d = new Private;
3838}
3839
3840TextBytesAtom::~TextBytesAtom()
3841{
3842 delete d;
3843}
3844
3845unsigned TextBytesAtom::listSize() const
3846{
3847 return d->ustring.size();
3848}
3849
3850unsigned TextBytesAtom::stringLength() const
3851{
3852 return d->stringLength;
3853}
3854
3855void TextBytesAtom::setStringLength( unsigned stringLength )
3856{
3857 d->stringLength = stringLength;
3858}
3859
3860UString TextBytesAtom::strValue( unsigned index ) const
3861{
3862 return d->ustring[index];
3863}
3864
3865void TextBytesAtom::setText( UString ustring )
3866{
3867 d->ustring.push_back( ustring );
3868}
3869
3870void TextBytesAtom::setData( unsigned size, const unsigned char* data )
3871{
3872 UString tempStr;
3873 int index = 0;
3874 unsigned length = 0;
3875 for( unsigned k=0; k<(size + 1); k++ )
3876 {
3877 unsigned uchar = data[k];
3878 if ( (uchar == 0x0b) | (uchar == 0x0d) | (k == size) )
3879 {
3880 setText(tempStr);
3881 index++;
3882 tempStr = "";
3883 }
3884 else
3885 tempStr.append( UString(uchar) );
3886
3887 if ( ( uchar & 0xff00 ) == 0xf000 )
3888 { // handle later
3889 std::cout << "got a symbol at " << k << "th character" << std::endl;
3890 }
3891 length++;
3892 }
3893
3894 setStringLength(length);
3895}
3896
3897void TextBytesAtom::dump( std::ostream& out ) const
3898{
3899 out << "TextBytesAtom" << std::endl;
3900 out << "stringLength " << stringLength() << std::endl;
3901 out << "listSize " << listSize() << std::endl;
3902 for (uint i=0; i<listSize() ; i++)
3903 {
3904 out << "String " << i << " [" << strValue(i) << "]" << std::endl;
3905 }
3906
3907}
3908
3909
3910// ========== TextSpecInfoAtom ==========
3911
3912const unsigned int TextSpecInfoAtom::id = 4010;
3913
3914class TextSpecInfoAtom::Private
3915{
3916public:
3917 int charCount;
3918 int flags;
3919};
3920
3921TextSpecInfoAtom::TextSpecInfoAtom ()
3922{
3923 d = new Private;
3924 d->charCount = 0;
3925 d->flags = 0;
3926}
3927
3928TextSpecInfoAtom::~TextSpecInfoAtom ()
3929{
3930 delete d;
3931}
3932
3933int TextSpecInfoAtom::charCount() const
3934{
3935 return d->charCount;
3936}
3937
3938void TextSpecInfoAtom::setCharCount(int charCount)
3939{
3940 d->charCount = charCount;
3941}
3942
3943int TextSpecInfoAtom::flags() const
3944{
3945 return d->flags;
3946}
3947
3948void TextSpecInfoAtom::setFlags(int flags)
3949{
3950 d->flags = flags;
3951}
3952
3953void TextSpecInfoAtom::setData( unsigned , const unsigned char* data )
3954{
3955 setCharCount( readU32( data + 0 ) );
3956 setFlags( readU32( data + 4 ) );
3957
3958}
3959
3960void TextSpecInfoAtom::dump( std::ostream& out ) const
3961{
3962 out << "TextSpecInfoAtom" << std::endl;
3963 out << "charCount " << charCount() << std::endl;
3964 out << "flags " << flags() << std::endl;
3965}
3966
3967// ========== SlidePersistAtom ==========
3968
3969const unsigned int SlidePersistAtom::id = 1011;
3970
3971class SlidePersistAtom::Private
3972{
3973public:
3974 int psrReference;
3975 int flags;
3976 int numberTexts;
3977 int slideId;
3978 int reserved;
3979};
3980
3981SlidePersistAtom::SlidePersistAtom ()
3982{
3983 d = new Private;
3984 d->psrReference = 0;
3985 d->flags = 0;
3986 d->numberTexts=0;
3987 d->slideId=0;
3988 d->reserved=0;
3989 }
3990
3991SlidePersistAtom::~SlidePersistAtom ()
3992{
3993 delete d;
3994}
3995
3996int SlidePersistAtom::psrReference() const
3997{
3998 return d->psrReference;
3999}
4000
4001void SlidePersistAtom::setPsrReference( int psrReference )
4002{
4003 d->psrReference = psrReference;
4004}
4005
4006int SlidePersistAtom::flags() const
4007{
4008 return d->flags;
4009}
4010
4011void SlidePersistAtom::setFlags( int flags )
4012{
4013 d->flags = flags;
4014}
4015
4016int SlidePersistAtom::numberTexts() const
4017{
4018 return d->numberTexts;
4019}
4020
4021void SlidePersistAtom::setNumberTexts( int numberTexts )
4022{
4023 d->numberTexts = numberTexts;
4024}
4025
4026int SlidePersistAtom::slideId() const
4027{
4028 return d->slideId;
4029}
4030
4031void SlidePersistAtom::setSlideId( int slideId )
4032{
4033 d->slideId = slideId;
4034}
4035
4036int SlidePersistAtom::reserved() const
4037{
4038 return d->reserved;
4039}
4040
4041void SlidePersistAtom::setReserved( int reserved )
4042{
4043 d->reserved = reserved;
4044}
4045
4046void SlidePersistAtom::setData( unsigned size, const unsigned char* data )
4047{
4048 if( size < 20 ) return;
4049
4050 setPsrReference( readU32( data + 0 ) );
4051 setFlags( readU32( data + 4 ) );
4052 setNumberTexts( readS32( data + 8 ) );
4053 setSlideId( readS32( data + 12 ) );
4054 setReserved(readU32( data + 16) );
4055}
4056
4057void SlidePersistAtom ::dump( std::ostream& out ) const
4058{
4059 out << "SlidePersistAtom" << std::endl;
4060 out << "psrReference " << psrReference() << std::endl;
4061 out << "flags " << flags() << std::endl;
4062 out << "numberTexts " << numberTexts() << std::endl;
4063 out << "slideId " << slideId() << std::endl;
4064 out << "reserved " << reserved() << " always 0."<<std::endl;
4065}
4066
4067// ========== msofbtDgAtom ==========
4068
4069const unsigned int msofbtDgAtom::id = 61448; /* F008 */
4070
4071msofbtDgAtom ::msofbtDgAtom ()
4072{
4073}
4074
4075msofbtDgAtom ::~msofbtDgAtom ()
4076{
4077}
4078
4079void msofbtDgAtom ::dump( std::ostream& out ) const
4080{
4081 out << "msofbtDgAtom " << std::endl;
4082}
4083
4084// ========== msofbtSpgrAtom ==========
4085
4086const unsigned int msofbtSpgrAtom::id = 61449; /* F009 */
4087
4088msofbtSpgrAtom ::msofbtSpgrAtom ()
4089{
4090}
4091
4092msofbtSpgrAtom ::~msofbtSpgrAtom ()
4093{
4094}
4095
4096void msofbtSpgrAtom ::dump( std::ostream& out ) const
4097{
4098 out << "msofbtSpgrAtom " << std::endl;
4099}
4100
4101// ========== msofbtSpAtom ==========
4102
4103const unsigned int msofbtSpAtom::id = 61450; /* F00A */
4104
4105class msofbtSpAtom::Private
4106{
4107public:
4108 unsigned long shapeId;
4109 unsigned long persistentFlag;
4110 bool background;
4111 bool hFlip;
4112 bool vFlip;
4113};
4114
4115msofbtSpAtom ::msofbtSpAtom ()
4116{
4117 d = new Private;
4118 d->shapeId = 0;
4119 d->persistentFlag = 0;
4120 d->background = false;
4121 d->hFlip = false;
4122 d->vFlip = false;
4123}
4124
4125msofbtSpAtom ::~msofbtSpAtom ()
4126{
4127 delete d;
4128}
4129
4130unsigned long msofbtSpAtom::shapeId() const
4131{
4132 return d->shapeId;
4133}
4134
4135void msofbtSpAtom::setShapeId( unsigned long id )
4136{
4137 d->shapeId = id;
4138}
4139
4140const char* msofbtSpAtom::shapeTypeAsString() const
4141{
4142 switch( instance() )
4143 {
4144 case 0: return "msosptMin";
4145 case 1: return "msosptRectangle";
4146 case 2: return "msosptRoundRectangle";
4147 case 3: return "msosptEllipse";
4148 case 4: return "msosptDiamond";
4149 case 5: return "msosptIsoscelesTriangle";
4150 case 6: return "msosptRightTriangle";
4151 case 7: return "msosptParallelogram";
4152 case 8: return "msosptTrapezoid";
4153 case 9: return "msosptHexagon";
4154 case 10: return "msosptOctagon";
4155 case 11: return "msosptPlus";
4156 case 12: return "msosptStar";
4157 case 13: return "msosptArrow";
4158 case 14: return "msosptThickArrow";
4159 case 15: return "msosptHomePlate";
4160 case 16: return "msosptCube";
4161 case 17: return "msosptBalloon";
4162 case 18: return "msosptSeal";
4163 case 19: return "msosptArc";
4164 case 20: return "msosptLine";
4165 case 21: return "msosptPlaque";
4166 case 22: return "msosptCan =";
4167 case 23: return "msosptDonut";
4168 case 24: return "msosptTextSimple";
4169 case 25: return "msosptTextOctagon";
4170 case 26: return "msosptTextHexagon";
4171 case 27: return "msosptTextCurve";
4172 case 28: return "msosptTextOnRing";
4173 case 29: return "msosptTextRing";
4174 case 30: return "msosptTextOnCurve";
4175 case 31: return "msosptTextOnRing";
4176 case 32: return "msosptStraightConnector1";
4177 case 75: return "msosptPictureFrame";
4178 case 74: return "msosptHeart";
4179 case 96: return "msosptSmileyFace";
4180 case 202: return "msosptTextBox";
4181 default: break;
4182 };
4183 return "Unknown";
4184}
4185
4186unsigned long msofbtSpAtom::persistentFlag() const
4187{
4188 return d->persistentFlag;
4189}
4190
4191void msofbtSpAtom::setPersistentFlag( unsigned long persistentFlag )
4192{
4193 d->persistentFlag = persistentFlag;
4194}
4195
4196bool msofbtSpAtom::isBackground() const
4197{
4198 return d->background;
4199}
4200
4201void msofbtSpAtom::setBackground( bool bg )
4202{
4203 d->background = bg;
4204}
4205
4206bool msofbtSpAtom::isVerFlip() const
4207{
4208 return d->vFlip;
4209}
4210
4211void msofbtSpAtom::setVerFlip( bool vFlip )
4212{
4213 d->vFlip = vFlip;
4214}
4215
4216bool msofbtSpAtom::isHorFlip() const
4217{
4218 return d->hFlip;
4219}
4220
4221void msofbtSpAtom::setHorFlip( bool hFlip )
4222{
4223 d->hFlip = hFlip;
4224}
4225
4226void msofbtSpAtom::setData( unsigned size, const unsigned char* data )
4227{
4228 if( size < 8 ) return;
4229
4230 setShapeId( readU32( data + 0 ) );
4231 setPersistentFlag( readU32( data + 4 ) );
4232
4233 unsigned flag = readU16( data + 4 );
4234 setBackground( flag & 0x800 );
4235 setVerFlip( flag & 0x80 );
4236 setHorFlip( flag & 0x40 );
4237}
4238
4239void msofbtSpAtom ::dump( std::ostream& out ) const
4240{
4241 out << "msofbtSpAtom " << std::endl;
4242}
4243
4244// ========== msofbtOPTAtom ==========
4245
4246const unsigned int msofbtOPTAtom::id = 61451; /* F00B */
4247
4248class msofbtOPTAtom::Private
4249{
4250public:
4251 std::vector<unsigned> ids;
4252 std::vector<unsigned long> values;
4253};
4254
4255msofbtOPTAtom ::msofbtOPTAtom ()
4256{
4257 d = new Private;
4258}
4259
4260msofbtOPTAtom ::~msofbtOPTAtom ()
4261{
4262 delete d;
4263}
4264
4265unsigned msofbtOPTAtom ::propertyCount() const
4266{
4267 return d->ids.size();
4268}
4269
4270unsigned msofbtOPTAtom ::propertyId( unsigned index ) const
4271{
4272 return d->ids[index];
4273}
4274
4275unsigned long msofbtOPTAtom ::propertyValue( unsigned index ) const
4276{
4277 return d->values[index];
4278}
4279
4280void msofbtOPTAtom::setProperty( unsigned id, unsigned long val )
4281{
4282 d->ids.push_back( id );
4283 d->values.push_back( val );
4284}
4285
4286void msofbtOPTAtom::setData( unsigned size, const unsigned char* data )
4287{
4288 unsigned i = 0;
4289 unsigned comp_len = 0;
4290
4291 d->ids.clear();
4292 d->values.clear();
4293
4294 while( i < size )
4295 {
4296 unsigned x = readU16( data+i );
4297 unsigned int id = x & 0x3fff;
4298 bool comp = x & 0x8000;
4299 unsigned long val = readU32( data + i + 2 );
4300 if( comp )
4301 comp_len += val;
4302 i += 6;
4303 setProperty( id, val );
4304 }
4305}
4306
4307void msofbtOPTAtom ::dump( std::ostream& out ) const
4308{
4309 out << "msofbtOPTAtom " << std::endl;
4310}
4311
4312
4313// ========== msofbtChildAnchorAtom ==========
4314
4315const unsigned int msofbtChildAnchorAtom::id = 61455; /* F00F */
4316
4317msofbtChildAnchorAtom ::msofbtChildAnchorAtom ()
4318{
4319}
4320
4321msofbtChildAnchorAtom ::~msofbtChildAnchorAtom ()
4322{
4323}
4324
4325void msofbtChildAnchorAtom ::dump( std::ostream& out ) const
4326{
4327 out << "msofbtChildAnchorAtom " << std::endl;
4328}
4329
4330// ========== msofbtClientAnchorAtom ==========
4331
4332const unsigned int msofbtClientAnchorAtom::id = 61456; /* F010 */
4333
4334class msofbtClientAnchorAtom::Private
4335{
4336public:
4337 int left;
4338 int top;
4339 int right;
4340 int bottom;
4341};
4342
4343msofbtClientAnchorAtom::msofbtClientAnchorAtom ()
4344{
4345 d = new Private;
4346 d->left = 0;
4347 d->top = 0;
4348 d->right=0;
4349 d->bottom=0;
4350 }
4351
4352msofbtClientAnchorAtom ::~msofbtClientAnchorAtom ()
4353{
4354 delete d;
4355}
4356
4357int msofbtClientAnchorAtom ::left() const
4358{
4359 return d->left;
4360}
4361
4362void msofbtClientAnchorAtom ::setLeft( int left )
4363{
4364 d->left = left;
4365}
4366
4367int msofbtClientAnchorAtom ::top() const
4368{
4369 return d->top;
4370}
4371
4372void msofbtClientAnchorAtom ::setTop( int top )
4373{
4374 d->top = top;
4375}
4376
4377int msofbtClientAnchorAtom ::right() const
4378{
4379 return d->right;
4380}
4381
4382void msofbtClientAnchorAtom ::setRight( int right )
4383{
4384 d->right = right;
4385}
4386
4387int msofbtClientAnchorAtom ::bottom() const
4388{
4389 return d->bottom;
4390}
4391
4392void msofbtClientAnchorAtom ::setBottom( int bottom )
4393{
4394 d->bottom = bottom;
4395}
4396
4397void msofbtClientAnchorAtom ::setData( unsigned , const unsigned char* data )
4398{
4399 setTop( readU16( data + 0 ) );
4400 setLeft( readU16( data + 2 ) );
4401 setRight( readU16( data + 4 ) );
4402 setBottom( readU16( data + 6 ) );
4403}
4404
4405void msofbtClientAnchorAtom ::dump( std::ostream& out ) const
4406{
4407 out << "msofbtClientAnchorAtom " << std::endl;
4408 out << "left " << left() << std::endl;
4409 out << "top " << top() << std::endl;
4410 out << "right " << right() << std::endl;
4411 out << "bottom " << bottom() << std::endl;
4412
4413}
4414
4415// ========== msofbtClientDataAtom ==========
4416
4417const unsigned int msofbtClientDataAtom::id = 61457; /* F011 */
4418
4419class msofbtClientDataAtom::Private
4420{
4421public:
4422 unsigned placementId;
4423 unsigned placeholderId;
4424};
4425
4426msofbtClientDataAtom::msofbtClientDataAtom ()
4427{
4428 d = new Private;
4429 d->placementId = 0;
4430 d->placeholderId = 0;
4431}
4432
4433msofbtClientDataAtom::~msofbtClientDataAtom ()
4434{
4435 delete d;
4436}
4437
4438unsigned msofbtClientDataAtom::placementId() const
4439{
4440 return d->placementId;
4441}
4442
4443void msofbtClientDataAtom::setPlacementId( unsigned id )
4444{
4445 d->placementId = id;
4446}
4447
4448unsigned msofbtClientDataAtom::placeholderId() const
4449{
4450 return d->placeholderId;
4451}
4452
4453void msofbtClientDataAtom::setPlaceholderId( unsigned id )
4454{
4455 d->placeholderId = id;
4456}
4457
4458const char* msofbtClientDataAtom::placeholderIdAsString() const
4459{
4460 switch( d->placeholderId )
4461 {
4462 case 0: return "None";
4463 case 1: return "Master title";
4464 case 2: return "Master body";
4465 case 3: return "Master centered title";
4466 case 4: return "Master notes slide image";
4467 case 5: return "Master notes body image";
4468 case 6: return "Master date";
4469 case 7: return "Master slide number";
4470 case 8: return "Master footer";
4471 case 9: return "Master header";
4472 case 10: return "Master subtitle";
4473 case 11: return "Generic text object";
4474 case 12: return "Title";
4475 case 13: return "Body";
4476 case 14: return "Notes body";
4477 case 15: return "Centered title";
4478 case 16: return "Subtitle";
4479 case 17: return "Vertical text title";
4480 case 18: return "Vertical text body";
4481 case 19: return "Notes slide image";
4482 case 20: return "Object";
4483 case 21: return "Graph";
4484 case 22: return "Table";
4485 case 23: return "Clip Art";
4486 case 24: return "Organization Chart";
4487 case 25: return "Media Clip";
4488 default: break;
4489 };
4490
4491 return "Unknown";
4492}
4493
4494
4495// 00 00 c3 0b ===> OEPlaceholderAtom
4496// 08 00 00 00
4497// 00 00 00 00 ===> Placement ID
4498// 0f ====> Placeholder ID
4499// 00 =====> Size of placeholder
4500// 9e 00
4501
4502void msofbtClientDataAtom::setData( unsigned size, const unsigned char* data )
4503{
4504 if( size < 12 ) return;
4505 setPlacementId( readU16( data+8 ) );
4506 setPlaceholderId( data[12]-1 );
4507}
4508
4509void msofbtClientDataAtom ::dump( std::ostream& out ) const
4510{
4511 out << "msofbtClientDataAtom " << std::endl;
4512}
4513
4514// ========== msofbtDggAtom ==========
4515
4516const unsigned int msofbtDggAtom::id = 61446; /* F011 */
4517
4518msofbtDggAtom ::msofbtDggAtom ()
4519{
4520}
4521
4522msofbtDggAtom ::~msofbtDggAtom ()
4523{
4524}
4525
4526void msofbtDggAtom ::dump( std::ostream& out ) const
4527{
4528 out << "msofbtDggAtom " << std::endl;
4529}
4530
4531// ========== msofbtClientTextboxAtom ==========
4532
4533const unsigned int msofbtClientTextboxAtom::id = 61453; /* F00D */
4534
4535class msofbtClientTextboxAtom::Private
4536{
4537public:
4538 UString ustring;
4539};
4540
4541msofbtClientTextboxAtom::msofbtClientTextboxAtom()
4542{
4543 d = new Private;
4544}
4545
4546msofbtClientTextboxAtom::~msofbtClientTextboxAtom()
4547{
4548 delete d;
4549}
4550
4551UString msofbtClientTextboxAtom::ustring() const
4552{
4553 return d->ustring;
4554}
4555
4556void msofbtClientTextboxAtom::setUString( const UString& ustr )
4557{
4558 d->ustring = ustr;
4559}
4560
4561void msofbtClientTextboxAtom::setData( unsigned size, const unsigned char* data )
4562{
4563 UString str;
4564 for( unsigned k=0; k<size/2; k++ )
4565 {
4566 unsigned uchar = readU16( data + k*2 );
4567 str.append( UString(uchar) );
4568 }
4569 setUString( str );
4570}
4571
4572void msofbtClientTextboxAtom::dump( std::ostream& out ) const
4573{
4574 out << "msofbtClientTextboxAtom" << std::endl;
4575 out << "String : [" << ustring() << "]" << std::endl;
4576}
4577
4578/*
4579msofbtClientTextboxAtom ::msofbtClientTextboxAtom ()
4580{
4581}
4582
4583msofbtClientTextboxAtom ::~msofbtClientTextboxAtom ()
4584{
4585}
4586
4587void msofbtClientTextboxAtom ::dump( std::ostream& out ) const
4588{
4589 out << "msofbtClientTextboxAtom " << std::endl;
4590}
4591*/
4592
4593// ========== msofbtDeletedPsplAtom ==========
4594
4595const unsigned int msofbtDeletedPsplAtom::id = 61725; /* F11D */
4596
4597msofbtDeletedPsplAtom ::msofbtDeletedPsplAtom ()
4598{
4599}
4600
4601msofbtDeletedPsplAtom ::~msofbtDeletedPsplAtom ()
4602{
4603}
4604
4605void msofbtDeletedPsplAtom ::dump( std::ostream& out ) const
4606{
4607 out << "msofbtDeletedPsplAtom " << std::endl;
4608}
4609
4610// ========== msofbtAnchorAtom ==========
4611
4612const unsigned int msofbtAnchorAtom::id = 61454; /* F00E */
4613
4614msofbtAnchorAtom ::msofbtAnchorAtom ()
4615{
4616}
4617
4618msofbtAnchorAtom ::~msofbtAnchorAtom ()
4619{
4620}
4621
4622void msofbtAnchorAtom ::dump( std::ostream& out ) const
4623{
4624 out << "msofbtAnchorAtom " << std::endl;
4625}
4626
4627// ========== msofbtColorMRUAtom ==========
4628
4629const unsigned int msofbtColorMRUAtom::id = 61722; /* F11A */
4630
4631msofbtColorMRUAtom ::msofbtColorMRUAtom ()
4632{
4633}
4634
4635msofbtColorMRUAtom ::~msofbtColorMRUAtom ()
4636{
4637}
4638
4639void msofbtColorMRUAtom ::dump( std::ostream& out ) const
4640{
4641 out << "msofbtColorMRUAtom " << std::endl;
4642}
4643
4644// ========== msofbtOleObjectAtom ==========
4645
4646const unsigned int msofbtOleObjectAtom::id = 61727; /* F11F */
4647
4648msofbtOleObjectAtom ::msofbtOleObjectAtom ()
4649{
4650}
4651
4652msofbtOleObjectAtom ::~msofbtOleObjectAtom ()
4653{
4654}
4655
4656void msofbtOleObjectAtom ::dump( std::ostream& out ) const
4657{
4658 out << "msofbtOleObjectAtom " << std::endl;
4659}
4660
4661// ========== msofbtSplitMenuColorsAtom ==========
4662
4663const unsigned int msofbtSplitMenuColorsAtom::id = 61726; /* F11E */
4664
4665class msofbtSplitMenuColorsAtom::Private
4666{
4667public:
4668 unsigned fillColor;
4669 unsigned lineColor;
4670 unsigned shadowColor;
4671 unsigned threeDColor;
4672};
4673
4674msofbtSplitMenuColorsAtom ::msofbtSplitMenuColorsAtom ()
4675{
4676 d = new Private;
4677 d->fillColor = 0;
4678 d->lineColor = 0;
4679 d->shadowColor = 0;
4680 d->threeDColor = 0;
4681}
4682
4683msofbtSplitMenuColorsAtom ::~msofbtSplitMenuColorsAtom ()
4684{
4685 delete d;
4686}
4687
4688unsigned msofbtSplitMenuColorsAtom::fillColor() const
4689{
4690 return d->fillColor;
4691}
4692
4693void msofbtSplitMenuColorsAtom::setFillColor( unsigned fillColor )
4694{
4695 d->fillColor = fillColor;
4696}
4697
4698unsigned msofbtSplitMenuColorsAtom::lineColor() const
4699{
4700 return d->lineColor;
4701}
4702
4703void msofbtSplitMenuColorsAtom::setLineColor( unsigned lineColor )
4704{
4705 d->lineColor = lineColor;
4706}
4707
4708unsigned msofbtSplitMenuColorsAtom::shadowColor() const
4709{
4710 return d->shadowColor;
4711}
4712
4713void msofbtSplitMenuColorsAtom::setShadowColor( unsigned shadowColor )
4714{
4715 d->shadowColor = shadowColor;
4716}
4717
4718unsigned msofbtSplitMenuColorsAtom::threeDColor() const
4719{
4720 return d->threeDColor;
4721}
4722
4723void msofbtSplitMenuColorsAtom::setThreeDColor( unsigned threeDColor )
4724{
4725 d->threeDColor = threeDColor;
4726}
4727
4728void msofbtSplitMenuColorsAtom::setData( unsigned , const unsigned char* data )
4729{
4730 setFillColor( readU32( data+0 ) );
4731 setLineColor( readU32( data+4 ) );
4732 setShadowColor( readU32( data+8 ) );
4733 setThreeDColor( readU32( data+12 ) );
4734}
4735
4736void msofbtSplitMenuColorsAtom ::dump( std::ostream& out ) const
4737{
4738 out << "msofbtSplitMenuColorsAtom " << std::endl;
4739 out << "fillColor" << fillColor() << std::endl;
4740 out << "lineColor" << lineColor() << std::endl;
4741 out << "shadowColor" << shadowColor() << std::endl;
4742 out << "threeDColor" << threeDColor() << std::endl;
4743}
4744
4745// ========== msofbtBSEAtom ==========
4746
4747const unsigned int msofbtBSEAtom::id = 61447; /* F007 */
4748
4749msofbtBSEAtom ::msofbtBSEAtom ()
4750{
4751}
4752
4753msofbtBSEAtom ::~msofbtBSEAtom ()
4754{
4755}
4756
4757void msofbtBSEAtom ::dump( std::ostream& out ) const
4758{
4759 out << "msofbtBSEAtom " << std::endl;
4760}
4761
4762// ========== msofbtCLSIDAtom ==========
4763
4764const unsigned int msofbtCLSIDAtom::id = 61462; /* F016 */
4765
4766msofbtCLSIDAtom ::msofbtCLSIDAtom ()
4767{
4768}
4769
4770msofbtCLSIDAtom ::~msofbtCLSIDAtom ()
4771{
4772}
4773
4774void msofbtCLSIDAtom ::dump( std::ostream& out ) const
4775{
4776 out << "msofbtCLSIDAtom " << std::endl;
4777}
4778
4779// ========== msofbtRegroupItemsAtom ==========
4780
4781const unsigned int msofbtRegroupItemsAtom::id = 61720; /* F118 */
4782
4783msofbtRegroupItemsAtom ::msofbtRegroupItemsAtom ()
4784{
4785}
4786
4787msofbtRegroupItemsAtom ::~msofbtRegroupItemsAtom ()
4788{
4789}
4790
4791void msofbtRegroupItemsAtom ::dump( std::ostream& out ) const
4792{
4793 out << "msofbtRegroupItemsAtom " << std::endl;
4794}
4795
4796// ========== msofbtColorSchemeAtom ==========
4797
4798const unsigned int msofbtColorSchemeAtom::id = 61728; /* F120 */
4799
4800msofbtColorSchemeAtom ::msofbtColorSchemeAtom ()
4801{
4802}
4803
4804msofbtColorSchemeAtom ::~msofbtColorSchemeAtom ()
4805{
4806}
4807
4808void msofbtColorSchemeAtom ::dump( std::ostream& out ) const
4809{
4810 out << "msofbtColorSchemeAtom " << std::endl;
4811}
4812
4813// ========== msofbtConnectorRuleAtom ==========
4814
4815const unsigned int msofbtConnectorRuleAtom::id = 61458; /* F012 */
4816
4817msofbtConnectorRuleAtom ::msofbtConnectorRuleAtom ()
4818{
4819}
4820
4821msofbtConnectorRuleAtom ::~msofbtConnectorRuleAtom ()
4822{
4823}
4824
4825void msofbtConnectorRuleAtom ::dump( std::ostream& out ) const
4826{
4827 out << "msofbtConnectorRuleAtom " << std::endl;
4828}
4829
4830// ========== msofbtAlignRuleAtom ==========
4831
4832const unsigned int msofbtAlignRuleAtom::id = 61459; /* F013 */
4833
4834class msofbtAlignRuleAtom ::Private
4835{
4836public:
4837 int ruid;
4838 int align;
4839 int cProxies;
4840};
4841
4842
4843msofbtAlignRuleAtom ::msofbtAlignRuleAtom ()
4844{ d = new Private;
4845 d->ruid = 0;
4846 d->align = 0;
4847 d->cProxies = 0;
4848}
4849
4850msofbtAlignRuleAtom ::~msofbtAlignRuleAtom ()
4851{
4852 delete d;
4853}
4854
4855int msofbtAlignRuleAtom::ruid() const
4856{
4857 return d->ruid;
4858}
4859
4860void msofbtAlignRuleAtom::setRuid( int ruid )
4861{
4862 d->ruid = ruid;
4863}
4864
4865int msofbtAlignRuleAtom::align() const
4866{
4867 return d->align;
4868}
4869
4870void msofbtAlignRuleAtom::setAlign( int ruid )
4871{
4872 d->ruid = ruid;
4873}
4874
4875int msofbtAlignRuleAtom::cProxies() const
4876{
4877 return d->cProxies;
4878}
4879
4880void msofbtAlignRuleAtom::setCProxies( int cProxies )
4881{
4882 d->cProxies = cProxies;
4883}
4884
4885void msofbtAlignRuleAtom::setData( unsigned , const unsigned char* data )
4886{
4887 setRuid( readU32( data+0 ) );
4888 setAlign( readU32( data+4 ) );
4889 setCProxies( readU32( data+8 ) );
4890}
4891
4892void msofbtAlignRuleAtom ::dump( std::ostream& out ) const
4893{
4894 out << "msofbtAlignRuleAtom " << std::endl;
4895 out << "ruid" << ruid() << std::endl;
4896 out << "align " << align() << std::endl;
4897 out << "cProxies " << cProxies() << std::endl;
4898}
4899
4900
4901// ========== msofbtArcRuleAtom ==========
4902
4903const unsigned int msofbtArcRuleAtom::id = 61460; /* F014 */
4904
4905msofbtArcRuleAtom ::msofbtArcRuleAtom ()
4906{
4907}
4908
4909msofbtArcRuleAtom ::~msofbtArcRuleAtom ()
4910{
4911}
4912
4913void msofbtArcRuleAtom ::dump( std::ostream& out ) const
4914{
4915 out << "msofbtArcRuleAtom " << std::endl;
4916}
4917
4918// ========== msofbtClientRuleAtom ==========
4919
4920const unsigned int msofbtClientRuleAtom::id = 61461; /* F015 */
4921
4922msofbtClientRuleAtom ::msofbtClientRuleAtom ()
4923{
4924}
4925
4926msofbtClientRuleAtom ::~msofbtClientRuleAtom ()
4927{
4928}
4929
4930void msofbtClientRuleAtom ::dump( std::ostream& out ) const
4931{
4932 out << "msofbtClientRuleAtom " << std::endl;
4933}
4934
4935// ========== msofbtCalloutRuleAtom ==========
4936
4937const unsigned int msofbtCalloutRuleAtom::id = 61463; /* F017 */
4938
4939msofbtCalloutRuleAtom ::msofbtCalloutRuleAtom ()
4940{
4941}
4942
4943msofbtCalloutRuleAtom ::~msofbtCalloutRuleAtom ()
4944{
4945}
4946
4947void msofbtCalloutRuleAtom ::dump( std::ostream& out ) const
4948{
4949 out << "msofbtCalloutRuleAtom " << std::endl;
4950}
4951
4952// ========== msofbtSelectionAtom ==========
4953
4954const unsigned int msofbtSelectionAtom::id = 61465; /* F019 */
4955
4956msofbtSelectionAtom ::msofbtSelectionAtom ()
4957{
4958}
4959
4960msofbtSelectionAtom ::~msofbtSelectionAtom ()
4961{
4962}
4963
4964void msofbtSelectionAtom ::dump( std::ostream& out ) const
4965{
4966 out << "msofbtSelectionAtom " << std::endl;
4967}
4968
4969// ========== PPTReader ==========
4970
4971class PPTReader::Private
4972{
4973public:
4974 Libppt::Presentation* presentation; // put result here
4975
4976 POLE::Stream* userStream; // "/Current User"
4977 POLE::Stream* docStream; // "/PowerPoint Document"
4978
4979 std::vector<long> persistenceList;
4980 std::map<int,Libppt::Slide*> slideMap;
4981 Libppt::Slide* currentSlide;
4982 unsigned currentTextType;
4983 unsigned currentTextId;
4984
4985 GroupObject* currentGroup;
4986 Object* currentObject;
4987 bool isShapeGroup;
4988};
4989
4990
4991PPTReader::PPTReader()
4992{
4993 d = new Private;
4994 d->presentation = 0;
4995
4996 d->userStream = 0;
4997 d->docStream = 0;
4998
4999 d->persistenceList.clear();
5000 d->slideMap.clear();
5001 d->currentSlide = 0;
5002 d->currentTextType = 0;
5003 d->currentTextId = 0;
5004 d->isShapeGroup = false;
5005}
5006
5007PPTReader::~PPTReader()
5008{
5009 delete d;
5010}
5011
5012bool PPTReader::load( Presentation* pr, const char* filename )
5013{
5014 bool result = false;
5015
5016 // initialization
5017 d->presentation = pr;
5018 d->docStream = 0;
5019 d->userStream = 0;
5020 d->persistenceList.clear();
5021 d->slideMap.clear();
5022 d->currentSlide = 0;
5023 d->currentTextType = 0;
5024 d->currentTextId = 0;
5025 d->currentGroup = 0;
5026 d->currentObject = 0;
5027 d->isShapeGroup = false;
5028
5029 POLE::Storage storage( filename );
5030 if( !storage.open() )
5031 {
5032 std::cerr << "Cannot open " << filename << std::endl;
5033 }
5034 else
5035 {
5036 // file is MS Office document
5037 // check whether it's PowerPoint presentation of not
5038 std::cout << "Loading file " << filename << std::endl;
5039 d->docStream = new POLE::Stream( &storage, "/PowerPoint Document" );
5040 d->userStream = new POLE::Stream( &storage, "/Current User" );
5041
5042 if( d->docStream->fail() || d->userStream->fail() )
5043 {
5044 // not PowerPoint, we need to quit
5045 storage.close();
5046 std::cerr << filename << " is not PowerPoint presentation" << std::endl;
5047 delete d->docStream;
5048 d->docStream = 0;
5049 return false;
5050 }
5051 else
5052 {
5053 // so here is PowerPoint stuff
5054 loadUserEdit();
5055
5056 d->presentation->clear();
5057 loadMaster();
5058 loadSlides();
5059 loadDocument();
5060
5061 result = true;
5062 std::cout << std::endl << filename << " loaded. Done." << std::endl;
5063 }
5064
5065 // clean-up
5066 storage.close();
5067 delete d->docStream;
5068 delete d->userStream;
5069 d->presentation = 0;
5070 d->docStream = 0;
5071 d->userStream = 0;
5072 d->persistenceList.clear();
5073 d->slideMap.clear();
5074 d->currentSlide = 0;
5075 d->currentTextType = 0;
5076 d->currentTextId = 0;
5077 d->currentGroup = 0;
5078 d->currentObject = 0;
5079 d->isShapeGroup = false;
5080 }
5081
5082 return result;
5083}
5084
5085void PPTReader::loadUserEdit()
5086{
5087 unsigned char buffer[128];
5088 unsigned long currentUserEditAtom = 0;
5089 std::vector<unsigned long> userEditList;
5090 std::vector<unsigned long> lastEditList;
5091 std::vector<unsigned long> persistDirList;
5092 std::vector<unsigned long> usefulPersistDirList;
5093 std::map<int,unsigned long> persistenceMap;
5094
5095#ifdef LIBPPT_DEBUG
5096 std::cout << std::endl;
5097 std::cout << "Parsing Current User information" << std::endl;
5098 std::cout << "================================================" << std::endl;
5099#endif
5100
5101 // read one record from "/Current User" stream
5102 d->userStream->seek( 0 );
5103 unsigned bytes_read = d->userStream->read( buffer, 8 );
5104 if( bytes_read != 8 ) return;
5105 unsigned long type = readU16( buffer + 2 );
5106 unsigned long size = readU32( buffer + 4 );
5107
5108 // sanity checks
5109 if( ( size < 20 ) || ( size > sizeof(buffer) ) )
5110 {
5111 std::cerr << "ERROR: CurrentUserAtom is not recognized" << std::endl;
5112 return;
5113 }
5114
5115 // the first in "/Current User" must be CurrentUserAtom
5116 if( type != CurrentUserAtom::id )
5117 {
5118 std::cerr << "ERROR: First in /Current User is not CurrentUserAtom" << std::endl;
5119 return;
5120 }
5121 else
5122 {
5123 d->userStream->read( buffer, size );
5124 CurrentUserAtom* atom = new CurrentUserAtom;
5125 atom->setData( size, buffer );
5126 currentUserEditAtom = atom->offsetToCurrentEdit();
5127#ifdef LIBPPT_DEBUG
5128#if 0
5129 d->userStream->read( buffer, atom->lenUserName()*2 );
5130 std::cout << "Found username: ";
5131 for( unsigned b=0; b<atom->lenUserName()*2; b+=2 )
5132 std::cout << (char)buffer[b];
5133 std::cout << std::endl;
5134#endif
5135 atom->dump( std::cout );
5136#endif
5137 delete atom;
5138 }
5139
5140
5141#ifdef LIBPPT_DEBUG
5142 std::cout << std::endl;
5143 std::cout << "Scanning for all UserEdit atoms" << std::endl;
5144 std::cout << "================================================" << std::endl;
5145#endif
5146
5147 d->docStream->seek( 0 );
5148 unsigned long stream_size = d->docStream->size();
5149 while( d->docStream->tell() < stream_size )
5150 {
5151 // get record type and data size
5152 unsigned long pos = d->docStream->tell();
5153 unsigned bytes_read = d->docStream->read( buffer, 8 );
5154 if( bytes_read != 8 ) break;
5155
5156 unsigned long type = readU16( buffer + 2 );
5157 unsigned long size = readU32( buffer + 4 );
5158 unsigned long nextpos = d->docStream->tell() + size;
5159
5160 // we only care for UserEditAtom
5161 if( type == UserEditAtom::id )
5162 if( size < sizeof(buffer) )
5163 {
5164 d->docStream->read( buffer, size );
5165 UserEditAtom* atom = new UserEditAtom;
5166 atom->setData( size, buffer );
5167 userEditList.push_back( pos );
5168 lastEditList.push_back( atom->offsetLastEdit() );
5169 persistDirList.push_back( atom->offsetPersistDir() );
5170#ifdef LIBPPT_DEBUG
5171 std::cout << "Found at pos " << pos << " size is " << size << std::endl;
5172#endif
5173 atom->dump( std::cout );
5174 delete atom;
5175 }
5176
5177 d->docStream->seek( nextpos );
5178 }
5179
5180#ifdef LIBPPT_DEBUG
5181 std::cout << "Found: " << userEditList.size() << " UserEdit atom(s) " << std::endl;
5182#endif
5183
5184#ifdef LIBPPT_DEBUG
5185 std::cout << std::endl;
5186 std::cout << "Constructing UserEdit list" << std::endl;
5187 std::cout << "================================================" << std::endl;
5188#endif
5189
5190 bool stop = true;
5191 do
5192 {
5193 stop = true;
5194
5195#ifdef LIBPPT_DEBUG
5196 std::cout << "Searching for UserEdit at offset " << currentUserEditAtom << std::endl;
5197#endif
5198 // search current user edit
5199 for( unsigned k=0; k < userEditList.size(); k++ )
5200 if( (userEditList[k] = currentUserEditAtom) )
5201 {
5202 stop = false;
5203 usefulPersistDirList.push_back( persistDirList[k] );
5204 currentUserEditAtom = lastEditList[k];
5205#ifdef LIBPPT_DEBUG
5206 std::cout << " found... ";
5207 std::cout << " persistence at offset " << persistDirList[k];
5208 if( lastEditList[k] != 0 )
5209 std::cout << " previous is " << lastEditList[k];
5210 std::cout << std::endl;
5211#endif
5212 break;
5213 }
5214 }
5215 while( !stop && (currentUserEditAtom!=0) );
5216
5217 // sanity check
5218 if( usefulPersistDirList.size() == 0 )
5219 {
5220 std::cerr << "ERROR: No useful UserEdit information !" << std::endl;
5221 return;
5222 }
5223
5224#ifdef LIBPPT_DEBUG
5225 std::cout << std::endl;
5226 std::cout << "Searching for persistence information" << std::endl;
5227 std::cout << "================================================" << std::endl;
5228#endif
5229
5230 unsigned max = 0;
5231
5232 for( unsigned j = 0; j < usefulPersistDirList.size(); j++ )
5233 {
5234 unsigned long offset = usefulPersistDirList[j];
5235
5236 d->docStream->seek( 0 );
5237 while( d->docStream->tell() < stream_size )
5238 {
5239 unsigned long pos = d->docStream->tell();
5240 unsigned bytes_read = d->docStream->read( buffer, 8 );
5241 if( bytes_read != 8 ) break;
5242
5243 unsigned long type = readU16( buffer + 2 );
5244 unsigned long size = readU32( buffer + 4 );
5245 unsigned long nextpos = d->docStream->tell() + size;
5246
5247 // we only care for PersistIncrementalBlockAtom
5248 if( pos == offset ) //TODO VERIFY IT
5249 if( type == PersistIncrementalBlockAtom::id )
5250 {
5251 unsigned char* buf = new unsigned char[ size ];
5252 d->docStream->read( buf, size );
5253 PersistIncrementalBlockAtom* atom = new PersistIncrementalBlockAtom;
5254 atom->setData( size, buf );
5255 delete [] buf;
5256
5257
5258#ifdef LIBPPT_DEBUG
5259 std::cout << "Found at pos " << pos << " size is " << size << std::endl;
5260 atom->dump( std::cout );
5261#endif
5262
5263 for( unsigned m = 0; m < atom->entryCount(); m++ )
5264 {
5265 unsigned long ref = atom->reference(m);
5266 unsigned long ofs = atom->offset(m);
5267 // if it is already there, ignore !!
5268 if( !persistenceMap.count( ref ) )
5269 persistenceMap[ref] = ofs;
5270 max = (ref > max) ? ref : max;
5271 }
5272 delete atom;
5273 }
5274
5275 d->docStream->seek( nextpos );
5276 }
5277 }
5278
5279 // convert to a good list
5280 for( unsigned n = 0; n <= max; n++ )
5281 {
5282 unsigned long ofs = -1;
5283 if( persistenceMap.count( n ) )
5284 ofs = persistenceMap[n];
5285 d->persistenceList.push_back( ofs );
5286 }
5287
5288#ifdef LIBPPT_DEBUG
5289 std::cout << std::endl;
5290 std::cout << "Final persistence list" << std::endl;
5291 for( unsigned nn = 1; nn < d->persistenceList.size(); nn++ )
5292 std::cout << " #" << nn << ": " << d->persistenceList[nn] << std::endl;
5293 std::cout << std::endl;
5294#endif
5295
5296}
5297
5298void PPTReader::loadMaster()
5299{
5300#ifdef LIBPPT_DEBUG
5301 std::cout << std::endl;
5302 std::cout << "Loading master" << std::endl;
5303 std::cout << "================================================" << std::endl;
5304#endif
5305
5306 d->docStream->seek( 0 );
5307 unsigned long stream_size = d->docStream->size();
5308 while( d->docStream->tell() < stream_size )
5309 {
5310 unsigned char buffer[8];
5311 unsigned long pos = d->docStream->tell();
5312 unsigned bytes_read = d->docStream->read( buffer, 8 );
5313 if( bytes_read != 8 ) break;
5314
5315 unsigned long type = readU16( buffer + 2 );
5316 unsigned long size = readU32( buffer + 4 );
5317 unsigned long nextpos = d->docStream->tell() + size;
5318
5319 // we only care for MainMasterContainer....
5320 if( type == MainMasterContainer::id )
5321 if( indexPersistence( pos ) )
5322 {
5323#ifdef LIBPPT_DEBUG
5324 std::cout << "Found at pos " << pos << " size is " << size << std::endl;
5325 std::cout << std::endl;
5326#endif
5327 Slide* master = new Slide( d->presentation );
5328 d->presentation->setMasterSlide( master );
5329 d->currentSlide = master;
5330 MainMasterContainer* container = new MainMasterContainer;
5331 handleContainer( container, type, size );
5332 delete container;
5333 }
5334
5335 d->docStream->seek( nextpos );
5336 }
5337 d->currentSlide = 0;
5338}
5339
5340void PPTReader::loadSlides()
5341{
5342#ifdef LIBPPT_DEBUG
5343 std::cout << std::endl;
5344 std::cout << "Loading all slide containers" << std::endl;
5345 std::cout << "================================================" << std::endl;
5346#endif
5347
5348 int totalSlides = 0;
5349
5350 d->docStream->seek( 0 );
5351 unsigned long stream_size = d->docStream->size();
5352 while( d->docStream->tell() < stream_size )
5353 {
5354 unsigned char buffer[8];
5355 unsigned long pos = d->docStream->tell();
5356 unsigned bytes_read = d->docStream->read( buffer, 8 );
5357 if( bytes_read != 8 ) break;
5358
5359 unsigned long type = readU16( buffer + 2 );
5360 unsigned long size = readU32( buffer + 4 );
5361 unsigned long nextpos = d->docStream->tell() + size;
5362
5363 unsigned k = 0;
5364
5365 // we only care for SlideContainer....
5366 if( type == SlideContainer::id )
5367 if( (k = indexPersistence( pos )) )
5368 {
5369 // create a new slide, make it current
5370 Slide* s = new Slide( d->presentation );
5371 d->slideMap[ k ] = s;
5372 d->presentation->appendSlide( s );
5373 d->currentSlide = s;
5374 d->currentTextId = 0;
5375 d->currentTextType = TextObject::Body;
5376
5377#ifdef LIBPPT_DEBUG
5378 std::cout << "SLIDE #" << totalSlides+1 << std::endl;
5379 std::cout << "Found at pos " << pos << " size is " << size << std::endl;
5380 std::cout << "Reference #" << k << std::endl;
5381 std::cout << std::endl;
5382#endif
5383
5384 // process all atoms inside
5385 SlideContainer* container = new SlideContainer;
5386 handleContainer( container, type, size );
5387 delete container;
5388
5389 totalSlides++;
5390 }
5391
5392 d->docStream->seek( nextpos );
5393 }
5394
5395
5396#ifdef LIBPPT_DEBUG
5397 std::cout << std::endl;
5398 std::cout << "Total: " << totalSlides << " slides" << std::endl;
5399#endif
5400}
5401
5402void PPTReader::loadDocument()
5403{
5404#ifdef LIBPPT_DEBUG
5405 std::cout << std::endl;
5406 std::cout << "Loading document content" << std::endl;
5407 std::cout << "================================================" << std::endl;
5408#endif
5409
5410 d->currentSlide = 0;
5411 d->currentGroup = 0;
5412 d->currentObject = 0;
5413 d->isShapeGroup = false;
5414
5415 d->docStream->seek( 0 );
5416 unsigned long stream_size = d->docStream->size();
5417 while( d->docStream->tell() < stream_size )
5418 {
5419 unsigned char buffer[8];
5420 unsigned long pos = d->docStream->tell();
5421 unsigned bytes_read = d->docStream->read( buffer, 8 );
5422 if( bytes_read != 8 ) break;
5423
5424 unsigned long type = readU16( buffer + 2 );
5425 unsigned long size = readU32( buffer + 4 );
5426 unsigned long nextpos = d->docStream->tell() + size;
5427
5428 // we only care for DocumentContainer....
5429 if( type == DocumentContainer::id )
5430 if( indexPersistence( pos ) )
5431 {
5432#ifdef LIBPPT_DEBUG
5433 std::cout << "Found at pos " << pos << " size is " << size << std::endl;
5434 std::cout << std::endl;
5435#endif
5436 DocumentContainer* container = new DocumentContainer;
5437 container->setPosition( pos );
5438 handleContainer( container, type, size );
5439 delete container;
5440 }
5441
5442 d->docStream->seek( nextpos );
5443 }
5444
5445}
5446
5447int PPTReader::indexPersistence( unsigned long ofs )
5448{
5449 for( unsigned k=1; k < d->persistenceList.size(); k++ )
5450 if( (d->persistenceList[k] == ofs) )
5451 return k;
5452
5453 return 0;
5454}
5455
5456void PPTReader::loadRecord( Record* parent )
5457{
5458 // FIXME
5459 unsigned char buffer[65536];
5460
5461 // get record type and data size
5462 unsigned long pos = d->docStream->tell();
5463 unsigned bytes_read = d->docStream->read( buffer, 8 );
5464 if( bytes_read != 8 ) return;
5465
5466 unsigned instance = readU16( buffer ) >> 4;
5467 unsigned long type = readU16( buffer + 2 );
5468 unsigned long size = readU32( buffer + 4 );
5469 unsigned long nextpos = d->docStream->tell() + size;
5470 unsigned lastSize;
5471 // create the record using the factory
5472 Record* record = Record::create( type );
5473 if( record )
5474 {
5475 record->setParent( parent );
5476 record->setPosition( pos );
5477 record->setInstance( instance );
5478
5479 if( !record->isContainer() )
5480 {
5481 d->docStream->read( buffer, size );
5482 // special treatment for StyleTextPropAtom
5483 if ( type == StyleTextPropAtom::id )
5484 record->setData(size, buffer, lastSize);
5485 else
5486 record->setData( size, buffer );
5487 handleRecord( record, type );
5488 }
5489 else
5490 handleContainer( static_cast<Container*>( record ), type, size );
5491
5492 delete record;
5493 }
5494 lastSize = size;
5495 d->docStream->seek( nextpos );
5496}
5497
5498void PPTReader::handleRecord( Record* record, int type )
5499{
5500 if( !record ) return;
5501
5502 switch( type )
5503 {
5504 case DocumentAtom::id:
5505 handleDocumentAtom( static_cast<DocumentAtom*>(record) ); break;
5506 case SlidePersistAtom::id:
5507 handleSlidePersistAtom( static_cast<SlidePersistAtom*>(record) ); break;
5508 case TextHeaderAtom::id:
5509 handleTextHeaderAtom( static_cast<TextHeaderAtom*>(record) ); break;
5510 case TextCharsAtom::id:
5511 handleTextCharsAtom( static_cast<TextCharsAtom*>(record) ); break;
5512 case TextBytesAtom::id:
5513 handleTextBytesAtom( static_cast<TextBytesAtom*>(record) ); break;
5514 case StyleTextPropAtom::id:
5515 handleStyleTextPropAtom( static_cast<StyleTextPropAtom*>(record) ); break;
5516 case ColorSchemeAtom::id:
5517 handleColorSchemeAtom( static_cast<ColorSchemeAtom*>(record) ); break;
5518
5519 case msofbtSpgrAtom::id:
5520 handleEscherGroupAtom( static_cast<msofbtSpgrAtom*>(record) ); break;
5521 case msofbtSpAtom::id:
5522 handleEscherSpAtom( static_cast<msofbtSpAtom*>(record) ); break;
5523 case msofbtOPTAtom::id:
5524 handleEscherPropertiesAtom( static_cast<msofbtOPTAtom*>(record) ); break;
5525 case msofbtClientDataAtom::id:
5526 handleEscherClientDataAtom( static_cast<msofbtClientDataAtom*>(record) ); break;
5527 case msofbtClientAnchorAtom::id:
5528 handleEscherClientAnchorAtom( static_cast<msofbtClientAnchorAtom*>(record) ); break;
5529 case msofbtClientTextboxAtom::id:
5530 handleEscherTextBoxAtom( static_cast<msofbtClientTextboxAtom*>(record) ); break;
5531
5532 default: break;
5533 }
5534}
5535
5536void PPTReader::handleContainer( Container* container, int type, unsigned size )
5537{
5538 if( !container || !container->isContainer() ) return;
5539
5540 unsigned long nextpos = d->docStream->tell() + size - 6;
5541
5542 switch( type )
5543 {
5544 case msofbtDgContainer::id:
5545 handleDrawingContainer( static_cast<msofbtDgContainer*>(container), size ); break;
5546 case msofbtSpgrContainer::id:
5547 handleEscherGroupContainer( static_cast<msofbtSpgrContainer*>(container), size ); break;
5548 case msofbtSpContainer::id:
5549 handleSPContainer( static_cast<msofbtSpContainer*>(container), size ); break;
5550 default:
5551 while( d->docStream->tell() < nextpos )
5552 loadRecord( container );
5553 }
5554}
5555
5556void PPTReader::handleDocumentAtom( DocumentAtom* atom )
5557{
5558 if( !atom ) return;
5559 if( !d->presentation ) return;
5560
5561 double pageWidth = atom->slideWidth() * 0.125; // pt, in cm * 0.0440972
5562 double pageHeight = atom->slideHeight() * 0.125; // pt
5563
5564 d->presentation->masterSlide()->setPageWidth( pageWidth );
5565 d->presentation->masterSlide()->setPageHeight ( pageHeight );
5566
5567#ifdef LIBPPT_DEBUG
5568 std::cout << std::endl<< "page width = " << pageWidth << std::endl;
5569 std::cout << std::endl<< "page height = " << pageHeight << std::endl;
5570#endif
5571}
5572
5573void PPTReader::handleSlidePersistAtom( SlidePersistAtom* atom )
5574{
5575 if( !atom ) return;
5576 if( !d->presentation ) return;
5577
5578 //int id = atom->slideId();
5579 unsigned ref = atom->psrReference();
5580
5581 d->currentSlide = d->slideMap[ ref ];
5582 d->currentTextId = 0;
5583 d->currentTextType = TextObject::Body;
5584
5585#ifdef LIBPPT_DEBUG
5586 std::cout << std::endl<< "Slide id = " << id << std::endl;
5587#endif
5588}
5589
5590void PPTReader::handleTextHeaderAtom( TextHeaderAtom* atom )
5591{
5592 if( !atom ) return;
5593 if( !d->presentation ) return;
5594 if( !d->currentSlide ) return;
5595
5596 d->currentTextId++;
5597 d->currentTextType = atom->textType();
5598}
5599
5600void PPTReader::handleTextCharsAtom( TextCharsAtom* atom )
5601{
5602 if( !atom ) return;
5603 if( !d->presentation ) return;
5604 if( !d->currentSlide ) return;
5605 if( !d->currentTextId ) return;
5606
5607 int placeId = d->currentTextId-1;
5608 TextObject* text = d->currentSlide->textObject( placeId );
5609 if( !text )
5610 {
5611 std::cerr << "No place for text object! " << placeId << std::endl;
5612 return;
5613 }
5614
5615 text->setType( d->currentTextType );
5616
5617 for (uint i=0; i<atom->listSize(); i++)
5618 {
5619 text->setText(atom->strValue(i));
5620 // tqDebug("=====================text list ================");
5621 }
5622
5623 if( (d->currentTextType == TextObject::Title) | (d->currentTextType == TextObject::CenterTitle) )
5624 for (unsigned i=0; i<atom->listSize(); i++)
5625 d->currentSlide->setTitle( atom->strValue(i) );
5626
5627
5628
5629#ifdef LIBPPT_DEBUG
5630 std::cout << " Text Object " << atom->ustring().ascii();
5631 std::cout << " placed at " << placeId << std::endl;
5632#endif
5633
5634}
5635
5636void PPTReader::handleTextBytesAtom( TextBytesAtom* atom )
5637{
5638 if( !atom ) return;
5639 if( !d->presentation ) return;
5640 if( !d->currentSlide ) return;
5641 if( !d->currentTextId ) return;
5642
5643 int placeId = d->currentTextId-1;
5644 TextObject* text = d->currentSlide->textObject( placeId );
5645 if( !text )
5646 {
5647 std::cerr << "No place for text object! " << placeId << std::endl;
5648 return;
5649 }
5650
5651 text->setType( d->currentTextType );
5652
5653 for (uint i=0; i<atom->listSize(); i++)
5654 {
5655 text->setText(atom->strValue(i));
5656 // tqDebug("=====================text list ================");
5657 }
5658
5659 if( (d->currentTextType == TextObject::Title) | (d->currentTextType == TextObject::CenterTitle) )
5660 for (unsigned i=0; i<atom->listSize(); i++)
5661 d->currentSlide->setTitle( atom->strValue(i) );
5662
5663
5664
5665#ifdef LIBPPT_DEBUG
5666 std::cout << " Text Object " << atom->ustring().ascii();
5667 std::cout << " placed at " << placeId << std::endl;
5668#endif
5669}
5670
5671void PPTReader::handleStyleTextPropAtom ( StyleTextPropAtom* atom )
5672{
5673 if( !atom ) return;
5674 if( !d->presentation ) return;
5675 if( !d->currentSlide ) return;
5676 if( !d->currentTextId ) return;
5677
5678 int placeId = d->currentTextId-1;
5679 TextObject* text = d->currentSlide->textObject( placeId );
5680
5681 for (uint i=0; i<atom->listSize(); i++)
5682 {
5683 if (atom->bulletOn(i) == 1)
5684 text->setBulletFlag(true);
5685 else /* if (atom->bulletOn(i) == 0) */
5686 text->setBulletFlag(false);
5687 }
5688
5689}
5690
5691void PPTReader::handleColorSchemeAtom( ColorSchemeAtom* atom )
5692{
5693 if( !atom ) return;
5694 if( !d->presentation ) return;
5695
5696}
5697
5698std::string spaces( int x )
5699{
5700 std::string str;
5701 for( int i=0; i<x; i++ )
5702 str += ' ';
5703 return str;
5704}
5705
5706void dumpGroup( GroupObject* obj, unsigned indent );
5707
5708void dumpObject( Object* obj, unsigned indent )
5709{
5710 std::cout << spaces(indent) << "Top: " << obj->top() << std::endl;
5711 std::cout << spaces(indent) << "Left: " << obj->left() << std::endl;
5712
5713 if( obj->isGroup() )
5714 {
5715 std::cout << spaces(indent) << "This is a group" << std::endl;
5716 GroupObject* gr = static_cast<GroupObject*>(obj);
5717 dumpGroup( gr, indent+2 );
5718 }
5719}
5720
5721void dumpGroup( GroupObject* obj, unsigned indent )
5722{
5723 for( unsigned i=0; i <obj->objectCount(); i++ )
5724 {
5725 std::cout << spaces(indent) << "Object #" << i+1 << std::endl;
5726 Object* o = obj->object(i);
5727 dumpObject( o, indent+2 );
5728 }
5729}
5730
5731void dumpSlide( Slide* slide )
5732{
5733 std::cout << "Slide: " << slide->title().ascii() << std::endl;
5734 GroupObject* root = slide->rootObject();
5735 dumpGroup( root, 0 );
5736 std::cout << std::endl;
5737}
5738
5739
5740void PPTReader::handleDrawingContainer( msofbtDgContainer* container, unsigned size )
5741{
5742 if( !container ) return;
5743 if( !d->presentation ) return;
5744 if( !d->currentSlide ) return;
5745
5746 d->currentGroup = new GroupObject();
5747 d->currentObject = 0;
5748 d->isShapeGroup = false;
5749
5750 unsigned long nextpos = d->docStream->tell() + size - 6;
5751 while( d->docStream->tell() < nextpos )
5752 loadRecord( container );
5753
5754 for( unsigned i=0; i<d->currentGroup->objectCount(); i++ )
5755 {
5756 Object* obj = d->currentGroup->object(i);
5757 if( ( i == 0 ) && ( obj->isGroup() ) )
5758 {
5759 d->currentGroup->takeObject( obj );
5760 d->currentSlide->setRootObject( (GroupObject*)obj );
5761 break;
5762 }
5763 }
5764
5765 delete d->currentGroup;
5766 d->currentGroup = 0;
5767 d->currentObject = 0;
5768 d->isShapeGroup = false;
5769}
5770
5771void PPTReader::handleEscherGroupContainer( msofbtSpgrContainer* container, unsigned size )
5772{
5773 if( !container ) return;
5774 if( !d->presentation ) return;
5775 if( !d->currentSlide ) return;
5776 if( !d->currentGroup ) return;
5777
5778 GroupObject* lastGroup = d->currentGroup;
5779
5780 d->currentGroup = new GroupObject();
5781 d->currentObject = 0;
5782 d->isShapeGroup = false;
5783
5784 unsigned long nextpos = d->docStream->tell() + size - 6;
5785 while( d->docStream->tell() < nextpos )
5786 loadRecord( container );
5787
5788 lastGroup->addObject( d->currentGroup ); // FIXME only if patriarch
5789 d->currentGroup = lastGroup;
5790 d->currentObject = 0;
5791 d->isShapeGroup = false;
5792}
5793
5794void PPTReader::handleSPContainer( msofbtSpContainer* container, unsigned size )
5795{
5796 if( !container ) return;
5797 if( !d->presentation ) return;
5798 if( !d->currentSlide ) return;
5799 if( !d->currentGroup ) return;
5800
5801 d->isShapeGroup = false;
5802
5803 unsigned long nextpos = d->docStream->tell() + size - 6;
5804 while( d->docStream->tell() < nextpos )
5805 loadRecord( container );
5806
5807 if( d->currentObject )
5808 if( !d->isShapeGroup )
5809 d->currentGroup->addObject( d->currentObject );
5810
5811 d->currentObject = 0;
5812 d->isShapeGroup = false;
5813}
5814
5815void PPTReader::handleEscherGroupAtom( msofbtSpgrAtom* atom )
5816{
5817 if( !atom ) return;
5818 if( !d->presentation ) return;
5819 if( !d->currentSlide ) return;
5820 if( !d->currentGroup ) return;
5821
5822 // set rect bound of current group
5823
5824 // this is shape for the group, no need to
5825 d->isShapeGroup = true;
5826}
5827
5828void PPTReader::handleEscherSpAtom( msofbtSpAtom* atom )
5829{
5830 if( !atom ) return;
5831 if( !d->presentation ) return;
5832 if( !d->currentSlide ) return;
5833 if( !d->currentGroup ) return;
5834
5835 DrawObject* drawObject = new DrawObject;
5836
5837 drawObject->setBackground( atom->isBackground() );
5838
5839 unsigned sh = DrawObject::None;
5840 switch( atom->instance() )
5841 {
5842 case msofbtSpAtom::msosptRectangle: sh = DrawObject::Rectangle; break;
5843 case msofbtSpAtom::msosptRoundRectangle: sh = DrawObject::RoundRectangle; break;
5844 case msofbtSpAtom::msosptEllipse: sh = DrawObject::Ellipse; break;
5845 case msofbtSpAtom::msosptDiamond: sh = DrawObject::Diamond; break;
5846 case msofbtSpAtom::msosptIsoscelesTriangle: sh = DrawObject::IsoscelesTriangle; break;
5847 case msofbtSpAtom::msosptRightTriangle: sh = DrawObject::RightTriangle; break;
5848 case msofbtSpAtom::msosptParallelogram: sh = DrawObject::Parallelogram; break;
5849 case msofbtSpAtom::msosptTrapezoid: sh = DrawObject::Trapezoid; break;
5850 case msofbtSpAtom::msosptHexagon: sh = DrawObject::Hexagon; break;
5851 case msofbtSpAtom::msosptOctagon: sh = DrawObject::Octagon; break;
5852
5853 case msofbtSpAtom::msosptArrow: sh = DrawObject::LeftArrow; break;
5854 case msofbtSpAtom::msosptDownArrow: sh = DrawObject::DownArrow; break;
5855 case msofbtSpAtom::msosptUpArrow: sh = DrawObject::UpArrow; break;
5856 case msofbtSpAtom::msosptLeftArrow: sh = DrawObject::LeftArrow; break;
5857
5858 case msofbtSpAtom::msosptLine: sh = DrawObject::Line; break;
5859 case msofbtSpAtom::msosptSmileyFace: sh = DrawObject::Smiley; break;
5860 case msofbtSpAtom::msosptHeart: sh = DrawObject::Heart; break;
5861 case msofbtSpAtom::msosptMin: sh = DrawObject::FreeLine; break;
5862
5863 default: break;
5864 }
5865
5866 drawObject->setShape( sh );
5867/*
5868 if (atom->isVerFlip() == true)
5869 d->currentObject->setProperty( "draw:mirror-vertical", "true");
5870
5871 if (atom->isHorFlip() == true)
5872 d->currentObject->setProperty( "draw:mirror-horizontal", "true");
5873*/
5874 d->currentObject = drawObject;
5875
5876 if (atom->isVerFlip() == true)
5877 d->currentObject->setProperty( "draw:mirror-vertical", "true");
5878
5879 if (atom->isHorFlip() == true)
5880 d->currentObject->setProperty( "draw:mirror-horizontal", "true");
5881
5882
5883}
5884
5885void PPTReader::handleEscherClientDataAtom( msofbtClientDataAtom* atom )
5886{
5887 if( !atom ) return;
5888 if( !d->presentation ) return;
5889 if( !d->currentSlide ) return;
5890 if( !d->currentGroup ) return;
5891 if( !d->currentObject ) return;
5892
5893 TextObject* textObject = 0;
5894 if( !d->currentObject->isText() )
5895 {
5896 textObject = new TextObject();
5897 textObject->convertFrom( d->currentObject );
5898 delete d->currentObject;
5899 d->currentObject = textObject;
5900 }
5901 else
5902 textObject = static_cast<TextObject*>( d->currentObject );
5903
5904 switch( atom->placeholderId() )
5905 {
5906 case msofbtClientDataAtom::MasterTitle:
5907 case msofbtClientDataAtom::Title:
5908 textObject->setType( TextObject::Title ); break;
5909
5910 case msofbtClientDataAtom::MasterBody:
5911 case msofbtClientDataAtom::MasterSubtitle:
5912 case msofbtClientDataAtom::Body:
5913 case msofbtClientDataAtom::Subtitle:
5914 textObject->setType( TextObject::Body ); break;
5915
5916 case msofbtClientDataAtom::MasterCenteredTitle:
5917 case msofbtClientDataAtom::CenteredTitle:
5918 textObject->setType( TextObject::CenterTitle ); break;
5919
5920 default:
5921 textObject->setType( TextObject::Other ); break;
5922 break;
5923 }
5924
5925 textObject->setId( atom->placementId() );
5926}
5927
5928void PPTReader::handleEscherClientAnchorAtom( msofbtClientAnchorAtom* atom )
5929{
5930 if( !atom ) return;
5931 if( !d->presentation ) return;
5932 if( !d->currentSlide ) return;
5933 if( !d->currentGroup ) return;
5934 if( !d->currentObject ) return;
5935
5936 d->currentObject->setLeft( atom->left()*25.4/576 );
5937 d->currentObject->setTop( atom->top()*25.4/576 );
5938 d->currentObject->setWidth( (atom->right()-atom->left())*25.4/576 );
5939 d->currentObject->setHeight( (atom->bottom()-atom->top())*25.4/576 );
5940}
5941
5942void PPTReader::handleEscherTextBoxAtom( msofbtClientTextboxAtom* atom )
5943{
5944 if( !atom ) return;
5945 if( !d->presentation ) return;
5946 if( !d->currentGroup ) return;
5947 if( !d->currentObject ) return;
5948
5949 TextObject* textObject = 0;
5950 if( !d->currentObject->isText() )
5951 {
5952 textObject = new TextObject();
5953 textObject->convertFrom( d->currentObject );
5954 delete d->currentObject;
5955 d->currentObject = textObject;
5956 }
5957 else
5958 textObject = static_cast<TextObject*>( d->currentObject );
5959
5960 textObject->setType( TextObject::Other );
5961 textObject->setText( atom->ustring() );
5962 textObject->setBulletFlag( false );
5963}
5964
5965Color convertFromLong( unsigned long i )
5966{
5967 unsigned r = (i & 0xff);
5968 unsigned g = (i>>8) & 0xff;
5969 unsigned b = (i>>16) & 0xff;
5970 //unsigned index = (i>>24) & 0xff;
5971 return Color( r, g, b );
5972}
5973
5974void PPTReader::handleEscherPropertiesAtom( msofbtOPTAtom* atom )
5975{
5976 if( !atom ) return;
5977 if( !d->presentation ) return;
5978 if( !d->currentSlide ) return;
5979 if( !d->currentGroup ) return;
5980 if( !d->currentObject ) return;
5981
5982 for( unsigned c=0; c<atom->propertyCount(); c++ )
5983 {
5984 unsigned pid = atom->propertyId(c);
5985 signed long pvalue = atom->propertyValue(c);
5986
5987 switch( pid )
5988 {
5989 case msofbtOPTAtom::FillColor:
5990 d->currentObject->setProperty( "draw:fill-color", convertFromLong(pvalue) );
5991 break;
5992 case msofbtOPTAtom::LineColor:
5993 d->currentObject->setProperty( "svg:stroke-color", convertFromLong(pvalue) );
5994 break;
5995 case msofbtOPTAtom::LineWidth:
5996 d->currentObject->setProperty( "svg:stroke-width", pvalue*(25.4/(12700*72) ));
5997 break;
5998 case msofbtOPTAtom::Rotation:
5999 { double deg = pvalue/65536.00 ;
6000 if (deg > 180.00) deg = 360.00 - deg; // in range (-180,180) deg
6001 d->currentObject->setProperty( "libppt:rotation", (deg*0.0174533) ) ;// rad
6002 } break;
6003 case msofbtOPTAtom::FillType:
6004 switch( pvalue )
6005 {
6006 case msofbtOPTAtom::FillSolid:
6007 d->currentObject->setProperty( "draw:fill", "solid"); break;
6008 case msofbtOPTAtom::FillPattern:
6009 d->currentObject->setProperty( "draw:fill", "solid"); break;
6010 default:
6011 d->currentObject->setProperty( "draw:fill", "solid"); break;
6012 }
6013 break;
6014 case msofbtOPTAtom::LineDashing:
6015 switch( pvalue )
6016 {
6017 case msofbtOPTAtom::LineSolid :
6018 {d->currentObject->setProperty( "draw:stroke", "solid");
6019 //tqDebug("=====================solid================");
6020 } break;
6021 case msofbtOPTAtom::LineDashSys :
6022 {
6023 d->currentObject->setProperty( "draw:stroke", "dash");
6024 d->currentObject->setProperty( "draw:stroke-dash", "Dash_20_2");
6025 //tqDebug("===================== solid================");
6026 } break;
6027 case msofbtOPTAtom::LineDotSys :
6028 {
6029 d->currentObject->setProperty( "draw:stroke", "dash");
6030 d->currentObject->setProperty( "draw:stroke-dash", "Dash_20_3");
6031 //tqDebug("===================== dash 2================");
6032 } break;
6033 case msofbtOPTAtom::LineDashDotSys :
6034 {
6035 d->currentObject->setProperty( "draw:stroke", "dash");
6036 d->currentObject->setProperty( "draw:stroke-dash", "Dash_20_2");
6037 //tqDebug("===================== dash 3================");
6038 } break;
6039 case msofbtOPTAtom::LineDashDotDotSys :
6040 { d->currentObject->setProperty( "draw:stroke", "dash");
6041 d->currentObject->setProperty( "draw:stroke-dash", "Dash_20_2");
6042 //tqDebug("===================== dash 4================");
6043 } break;
6044 case msofbtOPTAtom::LineDotGEL :
6045 { d->currentObject->setProperty( "draw:stroke", "dash");
6046 d->currentObject->setProperty( "draw:stroke-dash", "Dash_20_2");
6047 //tqDebug("===================== dash 5================");
6048 } break;
6049 case msofbtOPTAtom::LineDashGEL :
6050 { d->currentObject->setProperty( "draw:stroke", "dash");
6051 d->currentObject->setProperty( "draw:stroke-dash", "Dash_20_4");
6052 //tqDebug("===================== dash 6================");
6053 } break;
6054 case msofbtOPTAtom::LineLongDashGEL :
6055 { d->currentObject->setProperty( "draw:stroke", "dash");
6056 d->currentObject->setProperty( "draw:stroke-dash", "Dash_20_6");
6057 //tqDebug("=====================dash 7================");
6058 } break;
6059 case msofbtOPTAtom::LineDashDotGEL :
6060 { d->currentObject->setProperty( "draw:stroke", "dash");
6061 d->currentObject->setProperty( "draw:stroke-dash", "Dash_20_5");
6062 //tqDebug("=====================dash 8================");
6063 } break;
6064 case msofbtOPTAtom::LineLongDashDotGEL :
6065 { d->currentObject->setProperty( "draw:stroke", "dash");
6066 d->currentObject->setProperty( "draw:stroke-dash", "Dash_20_7");
6067 //tqDebug("=====================dash 9================");
6068 } break;
6069 case msofbtOPTAtom::LineLongDashDotDotGEL :
6070 { d->currentObject->setProperty( "draw:stroke", "dash");
6071 d->currentObject->setProperty( "draw:stroke-dash", "Dash_20_8");
6072 //tqDebug("=====================dash 10================");
6073 } break;
6074 default:
6075 d->currentObject->setProperty( "draw:stroke", "solid"); break;
6076 } break;
6077
6078 case msofbtOPTAtom::FlagNoLineDrawDash:
6079 { if (pvalue == 589824 )
6080 d->currentObject->setProperty( "libppt:invisibleLine", true );
6081 } break;
6082
6083 case msofbtOPTAtom::LineStartArrowhead:
6084 {
6085 switch( pvalue )
6086 {
6087 case msofbtOPTAtom::LineNoEnd : break;
6088 case msofbtOPTAtom::LineArrowEnd :
6089 d->currentObject->setProperty( "draw:marker-start", "msArrowEnd_20_5" ); break;
6090 case msofbtOPTAtom::LineArrowStealthEnd :
6091 d->currentObject->setProperty( "draw:marker-start", "msArrowStealthEnd_20_5" ); break;
6092 case msofbtOPTAtom::LineArrowDiamondEnd :
6093 d->currentObject->setProperty( "draw:marker-start", "msArrowDiamondEnd_20_5" ); break;
6094 case msofbtOPTAtom::LineArrowOvalEnd :
6095 d->currentObject->setProperty( "draw:marker-start", "msArrowOvalEnd_20_5" ); break;
6096 case msofbtOPTAtom::LineArrowOpenEnd :
6097 d->currentObject->setProperty( "draw:marker-start", "msArrowOpenEnd_20_5" ); break;
6098 default : break;
6099 }
6100 } break;
6101
6102 case msofbtOPTAtom::LineStartArrowWidth:
6103 {
6104 switch ( pvalue )
6105 {
6106 case msofbtOPTAtom::LineNarrowArrow :
6107 d->currentObject->setProperty( "draw:marker-start-width", 0.2 ); break;
6108 case msofbtOPTAtom::LineMediumWidthArrow :
6109 d->currentObject->setProperty( "draw:marker-start-width", 0.3 ); break;
6110 case msofbtOPTAtom::LineWideArrow :
6111 d->currentObject->setProperty( "draw:marker-start-width", 0.4 ); break;
6112 default : break;
6113 }
6114 } break;
6115
6116 case msofbtOPTAtom::LineEndArrowhead:
6117 {
6118 switch( pvalue )
6119 {
6120 case msofbtOPTAtom::LineNoEnd : break;
6121 case msofbtOPTAtom::LineArrowEnd :
6122 d->currentObject->setProperty( "draw:marker-end", "msArrowEnd_20_5" ); break;
6123 case msofbtOPTAtom::LineArrowStealthEnd :
6124 d->currentObject->setProperty( "draw:marker-end", "msArrowStealthEnd_20_5" ); break;
6125 case msofbtOPTAtom::LineArrowDiamondEnd :
6126 d->currentObject->setProperty( "draw:marker-end", "msArrowDiamondEnd_20_5" ); break;
6127 case msofbtOPTAtom::LineArrowOvalEnd :
6128 d->currentObject->setProperty( "draw:marker-end", "msArrowOvalEnd_20_5" ); break;
6129 case msofbtOPTAtom::LineArrowOpenEnd :
6130 d->currentObject->setProperty( "draw:marker-end", "msArrowOpenEnd_20_5" ); break;
6131 default : break;
6132 }
6133 } break;
6134
6135
6136/*
6137 case msofbtOPTAtom::LineStartArrowLength:
6138 {
6139 switch ( pvalue )
6140 {
6141 case msofbtOPTAtom::LineShortArrow :
6142 d->currentObject->setProperty( "draw:marker-end-length", "0.2cm" ); break;
6143 case msofbtOPTAtom::LineMediumLenArrow :
6144 d->currentObject->setProperty( "draw:marker-end-length", "0.4cm" ); break;
6145 case msofbtOPTAtom::LineLongArrow :
6146 d->currentObject->setProperty( "draw:marker-end-length", "0.6cm" ); break;
6147 default : break;
6148 }
6149 } break;
6150*/
6151 case msofbtOPTAtom::LineEndArrowWidth:
6152 {
6153 switch ( pvalue )
6154 {
6155 case msofbtOPTAtom::LineNarrowArrow :
6156 d->currentObject->setProperty( "draw:marker-end-width", 0.2 ); break;
6157 case msofbtOPTAtom::LineMediumWidthArrow :
6158 d->currentObject->setProperty( "draw:marker-end-width", 0.3 ); break;
6159 case msofbtOPTAtom::LineWideArrow :
6160 d->currentObject->setProperty( "draw:marker-end-width", 0.4 ); break;
6161 default : break;
6162 }
6163 } break;
6164/*
6165 case msofbtOPTAtom::LineEndArrowLength:
6166 {
6167 switch ( pvalue )
6168 {
6169 case msofbtOPTAtom::LineShortArrow :
6170 d->currentObject->setProperty( "draw:marker-end-length", "0.2cm" ); break;
6171 case msofbtOPTAtom::LineMediumLenArrow :
6172 d->currentObject->setProperty( "draw:marker-end-length", "0.4cm" ); break;
6173 case msofbtOPTAtom::LineLongArrow :
6174 d->currentObject->setProperty( "draw:marker-end-length", "0.6cm" ); break;
6175 default : break;
6176 }
6177 } break;
6178*/
6179 #if 0
6180 case msofbtOPTAtom::ShadowColor:
6181 {
6182 d->currentObject->setProperty( "draw:shadow-color", convertFromLong(pvalue) );
6183 } break;
6184 case msofbtOPTAtom::ShadowOpacity:
6185 {
6186 d->currentObject->setProperty( "draw:shadow-opacity", 100.0-(pvalue/(65536.0)) );
6187 } break;
6188 case msofbtOPTAtom::ShadowOffsetX:
6189 {
6190 d->currentObject->setProperty("draw:shadow-offset-x",(pvalue*2.54/(12700*72)));
6191 } break;
6192 case msofbtOPTAtom::ShadowOffsetY:
6193 {
6194 d->currentObject->setProperty("draw:shadow-offset-y",(pvalue*2.54/(12700*72)));
6195 } break;
6196#endif
6197 } // switch pid
6198
6199 } // for
6200
6201} // handleEscherPropertiesAtom
char * ascii() const
Convert the Unicode string to plain ASCII chars chopping of any higher bytes.
UString & append(const UString &)
Append another string.