1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  *   Licensed to the Apache Software Foundation (ASF) under one or more
12  *   contributor license agreements. See the NOTICE file distributed
13  *   with this work for additional information regarding copyright
14  *   ownership. The ASF licenses this file to you under the Apache
15  *   License, Version 2.0 (the "License"); you may not use this file
16  *   except in compliance with the License. You may obtain a copy of
17  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #ifndef INCLUDED_OOX_DUMP_OLEDUMPER_HXX
21 #define INCLUDED_OOX_DUMP_OLEDUMPER_HXX
22 
23 #include <map>
24 #include <memory>
25 #include <vector>
26 
27 #include <com/sun/star/uno/Reference.hxx>
28 #include <oox/dump/dumperbase.hxx>
29 #include <oox/helper/binaryinputstream.hxx>
30 #include <oox/helper/storagebase.hxx>
31 #include <rtl/textenc.h>
32 #include <rtl/ustring.hxx>
33 #include <sal/types.h>
34 
35 #ifdef DBG_UTIL
36 
37 namespace com::sun::star {
38     namespace io { class XInputStream; }
39 }
40 
41 namespace oox::dump {
42 
43 
44 class OleInputObjectBase : public InputObjectBase
45 {
46 protected:
OleInputObjectBase()47     OleInputObjectBase() {}
48 
49     OUString     dumpAnsiString32( const String& rName );
50     OUString     dumpUniString32( const String& rName );
51 
52     sal_Int32    dumpStdClipboardFormat( const String& rName );
53     OUString     dumpAnsiString32OrStdClip( const String& rName );
54     OUString     dumpUniString32OrStdClip( const String& rName );
55 
56     void                writeOleColorItem( const String& rName, sal_uInt32 nColor );
57     sal_uInt32          dumpOleColor( const String& rName );
58 };
59 
60 
61 class StdFontObject : public OleInputObjectBase
62 {
63 public:
64     explicit            StdFontObject( const InputObjectBase& rParent );
65 
66 protected:
67     virtual void        implDump() override;
68 };
69 
70 
71 class StdPicObject : public OleInputObjectBase
72 {
73 public:
74     explicit            StdPicObject( const InputObjectBase& rParent );
75 
76 protected:
77     virtual void        implDump() override;
78 };
79 
80 
81 class OleStreamObject : public OleInputObjectBase
82 {
83 public:
84     explicit            OleStreamObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName );
85 };
86 
87 
88 class OleCompObjObject : public OleStreamObject
89 {
90 public:
91     explicit            OleCompObjObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName );
92 
93 protected:
94     virtual void        implDump() override;
95 };
96 
97 
98 class OlePropertyStreamObject : public InputObjectBase
99 {
100 public:
101     explicit            OlePropertyStreamObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName );
102 
103 protected:
104     virtual void        implDump() override;
105 
106 private:
107     void                dumpSection( const OUString& rGuid, sal_uInt32 nStartPos );
108 
109     void                dumpProperty( sal_Int32 nPropId, sal_uInt32 nStartPos );
110     void                dumpCodePageProperty( sal_uInt32 nStartPos );
111     void                dumpDictionaryProperty( sal_uInt32 nStartPos );
112 
113     sal_uInt16          dumpPropertyContents( sal_Int32 nPropId );
114     void                dumpPropertyValue( sal_Int32 nPropId, sal_uInt16 nBaseType );
115     void                dumpPropertyVector( sal_Int32 nPropId, sal_uInt16 nBaseType );
116 
117     sal_uInt16          dumpPropertyType();
118     void                dumpBlob( sal_Int32 nPropId, const String& rName );
119     OUString            dumpString8( const String& rName );
120     OUString            dumpCharArray8( const String& rName, sal_Int32 nLen );
121     OUString            dumpString16( const String& rName );
122     OUString            dumpCharArray16( const String& rName, sal_Int32 nLen );
123     bool                dumpTypedProperty( const String& rName, sal_uInt16 nExpectedType );
124     void                dumpHlinks( sal_Int32 nSize );
125 
126     bool                startElement( sal_uInt32 nStartPos );
127     void                writeSectionHeader( const OUString& rGuid, sal_uInt32 nStartPos );
128     void                writePropertyHeader( sal_Int32 nPropId, sal_uInt32 nStartPos );
129 
130 private:
131     NameListRef         mxPropIds;
132     rtl_TextEncoding    meTextEnc;
133     bool                mbIsUnicode;
134 };
135 
136 
137 class OleStorageObject : public StorageObjectBase
138 {
139 public:
140     explicit            OleStorageObject( const ObjectBase& rParent, const StorageRef& rxStrg, const OUString& rSysPath );
141 
142 protected:
OleStorageObject()143     OleStorageObject() {}
144 
145     using               StorageObjectBase::construct;
146 
147     virtual void        implDumpStream(
148                             const css::uno::Reference< css::io::XInputStream >& rxStrm,
149                             const OUString& rStrgPath,
150                             const OUString& rStrmName,
151                             const OUString& rSysFileName ) override;
152 };
153 
154 
155 class ComCtlObjectBase : public OleInputObjectBase
156 {
157 protected:
158     explicit            ComCtlObjectBase(
159                             const InputObjectBase& rParent,
160                             sal_uInt32 nDataId5, sal_uInt32 nDataId6, sal_uInt16 nVersion,
161                             bool bCommonPart, bool bComplexPart );
162 
163     virtual void        implDump() override;
164     virtual void        implDumpProperties() = 0;
165     virtual void        implDumpCommonExtra( sal_Int64 nEndPos );
166     virtual void        implDumpCommonTrailing();
167 
168 private:
169     bool                dumpComCtlHeader( sal_uInt32 nExpId, sal_uInt16 nExpMajor = SAL_MAX_UINT16, sal_uInt16 nExpMinor = SAL_MAX_UINT16 );
170     bool                dumpComCtlSize();
171     bool                dumpComCtlData( sal_uInt32& ornCommonPartSize );
172     bool                dumpComCtlCommon( sal_uInt32 nPartSize );
173     bool                dumpComCtlComplex();
174 
175 protected:
176     sal_uInt32          mnDataId5;
177     sal_uInt32          mnDataId6;
178     sal_uInt16          mnVersion;
179     bool                mbCommonPart;
180     bool                mbComplexPart;
181 };
182 
183 
184 class ComCtlScrollBarObject : public ComCtlObjectBase
185 {
186 public:
187     explicit            ComCtlScrollBarObject( const InputObjectBase& rParent, sal_uInt16 nVersion );
188 
189 protected:
190     virtual void        implDumpProperties() override;
191 };
192 
193 
194 class ComCtlProgressBarObject : public ComCtlObjectBase
195 {
196 public:
197     explicit            ComCtlProgressBarObject( const InputObjectBase& rParent, sal_uInt16 nVersion );
198 
199 protected:
200     virtual void        implDumpProperties() override;
201 };
202 
203 
204 class ComCtlSliderObject : public ComCtlObjectBase
205 {
206 public:
207     explicit            ComCtlSliderObject( const InputObjectBase& rParent, sal_uInt16 nVersion );
208 
209 protected:
210     virtual void        implDumpProperties() override;
211 };
212 
213 
214 class ComCtlUpDownObject : public ComCtlObjectBase
215 {
216 public:
217     explicit            ComCtlUpDownObject( const InputObjectBase& rParent, sal_uInt16 nVersion );
218 
219 protected:
220     virtual void        implDumpProperties() override;
221 };
222 
223 
224 class ComCtlImageListObject : public ComCtlObjectBase
225 {
226 public:
227     explicit            ComCtlImageListObject( const InputObjectBase& rParent, sal_uInt16 nVersion );
228 
229 protected:
230     virtual void        implDumpProperties() override;
231     virtual void        implDumpCommonExtra( sal_Int64 nEndPos ) override;
232     virtual void        implDumpCommonTrailing() override;
233 };
234 
235 
236 class ComCtlTabStripObject : public ComCtlObjectBase
237 {
238 public:
239     explicit            ComCtlTabStripObject( const InputObjectBase& rParent, sal_uInt16 nVersion );
240 
241 protected:
242     virtual void        implDumpProperties() override;
243     virtual void        implDumpCommonExtra( sal_Int64 nEndPos ) override;
244 };
245 
246 
247 class ComCtlTreeViewObject : public ComCtlObjectBase
248 {
249 public:
250     explicit            ComCtlTreeViewObject( const InputObjectBase& rParent, sal_uInt16 nVersion );
251 
252 protected:
253     virtual void        implDumpProperties() override;
254     virtual void        implDumpCommonExtra( sal_Int64 nEndPos ) override;
255 
256 private:
257     sal_uInt32          mnStringFlags;
258 };
259 
260 
261 class ComCtlStatusBarObject : public ComCtlObjectBase
262 {
263 public:
264     explicit            ComCtlStatusBarObject( const InputObjectBase& rParent, sal_uInt16 nVersion );
265 
266 protected:
267     virtual void        implDumpProperties() override;
268     virtual void        implDumpCommonExtra( sal_Int64 nEndPos ) override;
269     virtual void        implDumpCommonTrailing() override;
270 };
271 
272 
273 class AxPropertyObjectBase : public OleInputObjectBase
274 {
275 protected:
AxPropertyObjectBase()276     AxPropertyObjectBase() {}
277 
278     using               OleInputObjectBase::construct;
279     void                construct(
280                             const ObjectBase& rParent,
281                             const BinaryInputStreamRef& rxStrm,
282                             const OUString& rSysFileName,
283                             const String& rPropNameList,
284                             bool b64BitPropFlags = false );
285     void                construct(
286                             const InputObjectBase& rParent,
287                             const String& rPropNameList,
288                             bool b64BitPropFlags = false );
289 
290     virtual bool        implIsValid() const override;
291     virtual void        implDump() override;
292 
293     virtual void        implDumpShortProperties();
294     virtual void        implDumpExtended();
295 
296     bool                ensureValid( bool bCondition = true );
297 
298     template< typename Type >
299     void                alignInput();
300 
301     void                setAlignAnchor();
302     bool                startNextProperty();
303     OUString     getPropertyName() const;
304 
305     template< typename Type >
306     Type                dumpDecProperty( Type nDefault, const NameListWrapper& rListWrp = NO_LIST );
307     template< typename Type >
308     Type                dumpHexProperty( Type nDefault, const NameListWrapper& rListWrp = NO_LIST );
309 
dumpBoolProperty()310     bool         dumpBoolProperty() { return startNextProperty(); }
dumpHmmProperty()311     sal_Int32    dumpHmmProperty() { return dumpDecProperty< sal_Int32 >( 0, "CONV-HMM-TO-CM" ); }
dumpMousePtrProperty()312     sal_uInt8    dumpMousePtrProperty() { return dumpDecProperty< sal_uInt8 >( 0, "OLE-MOUSEPTR" ); }
313     template< typename Type >
dumpBorderStyleProperty(Type nDefault)314     Type         dumpBorderStyleProperty( Type nDefault ) { return dumpDecProperty< Type >( nDefault, "AX-BORDERSTYLE" ); }
315     template< typename Type >
dumpSpecialEffectProperty(Type nDefault)316     Type         dumpSpecialEffectProperty( Type nDefault ) { return dumpDecProperty< Type >( nDefault, "AX-SPECIALEFFECT" ); }
dumpEnabledProperty()317     sal_uInt32   dumpEnabledProperty() { return dumpDecProperty< sal_uInt32 >( 1, "AX-ENABLED" ); }
dumpOrientationProperty()318     sal_Int32    dumpOrientationProperty() { return dumpDecProperty< sal_Int32 >( -1, "AX-ORIENTATION" ); }
dumpDelayProperty()319     sal_Int32    dumpDelayProperty() { return dumpDecProperty< sal_Int32 >( 50, "AX-CONV-MS" ); }
dumpImagePosProperty()320     sal_uInt32   dumpImagePosProperty() { return dumpHexProperty< sal_uInt32 >( 0x00070001, "AX-IMAGEPOS" ); }
dumpImageSizeModeProperty()321     sal_uInt8    dumpImageSizeModeProperty() { return dumpDecProperty< sal_uInt8 >( 0, "AX-IMAGESIZEMODE" ); }
dumpImageAlignProperty()322     sal_uInt8    dumpImageAlignProperty() { return dumpDecProperty< sal_uInt8 >( 2, "AX-IMAGEALIGN" ); }
323 
324     sal_uInt32          dumpFlagsProperty( sal_uInt32 nDefault, const char* pcNameList = "AX-FLAGS" );
325     sal_uInt32          dumpColorProperty( sal_uInt32 nDefault );
326     sal_Unicode         dumpUnicodeProperty();
327     void                dumpUnknownProperty();
328 
329     void                dumpPosProperty();
330     void                dumpSizeProperty();
331     void                dumpGuidProperty( OUString* pValue = nullptr );
332     void                dumpStringProperty( OUString* pValue = nullptr );
333     void                dumpStringArrayProperty();
334     void                dumpStreamProperty();
335 
336     void                dumpEmbeddedFont();
337     void                dumpToPosition( sal_Int64 nPos );
338 
339 private:
340     void                constructAxPropObj( const String& rPropNameList, bool b64BitPropFlags );
341 
342     void                dumpVersion();
343     OUString            dumpString( const String& rName, sal_uInt32 nSize, bool bArray );
344     void                dumpShortProperties();
345     void                dumpLargeProperties();
346 
347 private:
348     struct LargeProperty
349     {
350         enum LargePropertyType { PROPTYPE_POS, PROPTYPE_SIZE, PROPTYPE_GUID, PROPTYPE_STRING, PROPTYPE_STRINGARRAY };
351 
352         LargePropertyType   mePropType;
353         OUString     maItemName;
354         sal_uInt32          mnDataSize;
355         OUString*    mpItemValue;
LargePropertyoox::dump::AxPropertyObjectBase::LargeProperty356         explicit     LargeProperty( LargePropertyType ePropType, const String& rItemName, sal_uInt32 nDataSize, OUString* pItemValue = nullptr ) :
357                                 mePropType( ePropType ), maItemName( rItemName ), mnDataSize( nDataSize ), mpItemValue( pItemValue ) {}
358     };
359     typedef ::std::vector< LargeProperty > LargePropertyVector;
360 
361     struct StreamProperty
362     {
363         OUString     maItemName;
364         sal_uInt16          mnData;
StreamPropertyoox::dump::AxPropertyObjectBase::StreamProperty365         explicit     StreamProperty( const String& rItemName, sal_uInt16 nData ) :
366                                 maItemName( rItemName ), mnData( nData ) {}
367     };
368 
369     LargePropertyVector maLargeProps;
370     std::vector< StreamProperty >
371                         maStreamProps;
372     NameListRef         mxPropNames;
373     sal_Int64           mnPropertiesStart;
374     sal_Int64           mnPropertiesEnd;
375     sal_Int64           mnPropFlags;
376     sal_Int64           mnCurrProp;
377     bool                mb64BitPropFlags;
378     bool                mbValid;
379 };
380 
381 
382 template< typename Type >
alignInput()383 void AxPropertyObjectBase::alignInput()
384 {
385     mxStrm->skip( (sizeof( Type ) - ((mxStrm->tell() - mnPropertiesStart) % sizeof( Type ))) % sizeof( Type ) );
386 }
387 
388 template< typename Type >
dumpDecProperty(Type nDefault,const NameListWrapper & rListWrp)389 Type AxPropertyObjectBase::dumpDecProperty( Type nDefault, const NameListWrapper& rListWrp )
390 {
391     if( startNextProperty() )
392     {
393         alignInput< Type >();
394         return dumpDec< Type >( getPropertyName(), rListWrp );
395     }
396     return nDefault;
397 }
398 
399 template< typename Type >
dumpHexProperty(Type nDefault,const NameListWrapper & rListWrp)400 Type AxPropertyObjectBase::dumpHexProperty( Type nDefault, const NameListWrapper& rListWrp )
401 {
402     if( startNextProperty() )
403     {
404         alignInput< Type >();
405         return dumpHex< Type >( getPropertyName(), rListWrp );
406     }
407     return nDefault;
408 }
409 
410 
411 class AxCFontNewObject : public AxPropertyObjectBase
412 {
413 public:
414     explicit            AxCFontNewObject( const InputObjectBase& rParent );
415 
416 protected:
417     virtual void        implDumpShortProperties() override;
418 };
419 
420 
421 class AxColumnInfoObject : public AxPropertyObjectBase
422 {
423 public:
424     explicit            AxColumnInfoObject( const InputObjectBase& rParent );
425 
426 protected:
427     virtual void        implDumpShortProperties() override;
428 };
429 
430 
431 class AxCommandButtonObject : public AxPropertyObjectBase
432 {
433 public:
434     explicit            AxCommandButtonObject( const InputObjectBase& rParent );
435 
436 protected:
437     virtual void        implDumpShortProperties() override;
438     virtual void        implDumpExtended() override;
439 };
440 
441 
442 class AxMorphControlObject : public AxPropertyObjectBase
443 {
444 public:
445     explicit            AxMorphControlObject( const InputObjectBase& rParent );
446 
447 protected:
448     virtual void        implDumpShortProperties() override;
449     virtual void        implDumpExtended() override;
450 
451 private:
452     void                dumpColumnInfos();
453 
454 private:
455     sal_uInt16          mnColInfoCount;
456     sal_uInt8           mnCtrlType;
457 };
458 
459 
460 class AxLabelObject : public AxPropertyObjectBase
461 {
462 public:
463     explicit            AxLabelObject( const InputObjectBase& rParent );
464 
465 protected:
466     virtual void        implDumpShortProperties() override;
467     virtual void        implDumpExtended() override;
468 };
469 
470 
471 class AxImageObject : public AxPropertyObjectBase
472 {
473 public:
474     explicit            AxImageObject( const InputObjectBase& rParent );
475 
476 protected:
477     virtual void        implDumpShortProperties() override;
478 };
479 
480 
481 class AxScrollBarObject : public AxPropertyObjectBase
482 {
483 public:
484     explicit            AxScrollBarObject( const InputObjectBase& rParent );
485 
486 protected:
487     virtual void        implDumpShortProperties() override;
488 };
489 
490 
491 class AxSpinButtonObject : public AxPropertyObjectBase
492 {
493 public:
494     explicit            AxSpinButtonObject( const InputObjectBase& rParent );
495 
496 protected:
497     virtual void        implDumpShortProperties() override;
498 };
499 
500 
501 class AxTabStripObject : public AxPropertyObjectBase
502 {
503 public:
504     explicit            AxTabStripObject( const InputObjectBase& rParent );
505 
506 protected:
507     virtual void        implDumpShortProperties() override;
508     virtual void        implDumpExtended() override;
509 
510 private:
511     sal_Int32           mnTabFlagCount;
512 };
513 
514 
515 class FormControlStreamObject : public OleInputObjectBase
516 {
517 public:
518     explicit            FormControlStreamObject(
519                             const ObjectBase& rParent,
520                             const BinaryInputStreamRef& rxStrm,
521                             const OUString& rSysFileName,
522                             const OUString* pProgId = nullptr );
523     explicit            FormControlStreamObject(
524                             const OutputObjectBase& rParent,
525                             const BinaryInputStreamRef& rxStrm,
526                             const OUString* pProgId = nullptr );
527 
528 protected:
529     virtual void        implDump() override;
530 
531 private:
532     void                constructFormCtrlStrmObj( const OUString* pProgId );
533 
534 private:
535     OUString     maProgId;
536     bool                mbReadGuid;
537 };
538 
539 
540 struct VbaFormSiteInfo
541 {
542     OUString     maProgId;
543     sal_Int32           mnId;
544     sal_uInt32          mnLength;
545     bool                mbInStream;
546 
VbaFormSiteInfooox::dump::VbaFormSiteInfo547     VbaFormSiteInfo() : mnId( 0 ), mnLength( 0 ), mbInStream( false ) {}
548 };
549 
550 
551 struct VbaFormSharedData
552 {
553     OUStringVector                 maClassInfoProgIds;
554     std::vector< VbaFormSiteInfo > maSiteInfos;
555 };
556 
557 
558 class VbaFormClassInfoObject : public AxPropertyObjectBase
559 {
560 public:
561     explicit            VbaFormClassInfoObject( const InputObjectBase& rParent, VbaFormSharedData& rFormData );
562 
563 protected:
564     virtual void        implDumpShortProperties() override;
565 
566 private:
567     VbaFormSharedData&  mrFormData;
568 };
569 
570 
571 class VbaFormSiteObject : public AxPropertyObjectBase
572 {
573 public:
574     explicit            VbaFormSiteObject( const InputObjectBase& rParent, VbaFormSharedData& rFormData );
575 
576 protected:
577     virtual void        implDumpShortProperties() override;
578 
579 private:
580     VbaFormSharedData&  mrFormData;
581 };
582 
583 
584 class VbaFormDesignExtObject : public AxPropertyObjectBase
585 {
586 public:
587     explicit            VbaFormDesignExtObject( const InputObjectBase& rParent );
588 
589 protected:
590     virtual void        implDumpShortProperties() override;
591 };
592 
593 
594 class VbaFStreamObject : public AxPropertyObjectBase
595 {
596 public:
597     explicit            VbaFStreamObject(
598                             const ObjectBase& rParent,
599                             const BinaryInputStreamRef& rxStrm,
600                             const OUString& rSysFileName,
601                             VbaFormSharedData& rFormData );
602 
603 protected:
604     virtual void        implDumpShortProperties() override;
605     virtual void        implDumpExtended() override;
606 
607 private:
608     void                dumpClassInfos();
609     void                dumpFormSites( sal_uInt32 nCount );
610     void                dumpSiteData();
611     void                dumpDesignExtender();
612 
613 private:
614     VbaFormSharedData&  mrFormData;
615     sal_uInt32          mnFlags;
616 };
617 
618 
619 class VbaOStreamObject : public OleInputObjectBase
620 {
621 public:
622     explicit            VbaOStreamObject(
623                             const ObjectBase& rParent,
624                             const BinaryInputStreamRef& rxStrm,
625                             const OUString& rSysFileName,
626                             VbaFormSharedData& rFormData );
627 
628 protected:
629     virtual void        implDump() override;
630 
631 private:
632     VbaFormSharedData&  mrFormData;
633 };
634 
635 
636 class VbaPageObject : public AxPropertyObjectBase
637 {
638 public:
639     explicit            VbaPageObject( const InputObjectBase& rParent );
640 
641 protected:
642     virtual void        implDumpShortProperties() override;
643 };
644 
645 
646 class VbaMultiPageObject : public AxPropertyObjectBase
647 {
648 public:
649     explicit            VbaMultiPageObject( const InputObjectBase& rParent );
650 
651 protected:
652     virtual void        implDumpShortProperties() override;
653     virtual void        implDumpExtended() override;
654 
655 private:
656     sal_Int32           mnPageCount;
657 };
658 
659 
660 class VbaXStreamObject : public InputObjectBase
661 {
662 public:
663     explicit            VbaXStreamObject(
664                             const ObjectBase& rParent,
665                             const BinaryInputStreamRef& rxStrm,
666                             const OUString& rSysFileName,
667                             VbaFormSharedData& rFormData );
668 
669 protected:
670     virtual void        implDump() override;
671 
672 private:
673     VbaFormSharedData&  mrFormData;
674 };
675 
676 
677 class VbaContainerStorageObject : public OleStorageObject
678 {
679 public:
680     explicit            VbaContainerStorageObject(
681                             const ObjectBase& rParent,
682                             const StorageRef& rxStrg,
683                             const OUString& rSysPath );
684 
685 protected:
686     virtual void        implDumpStream(
687                             const css::uno::Reference< css::io::XInputStream >& rxStrm,
688                             const OUString& rStrgPath,
689                             const OUString& rStrmName,
690                             const OUString& rSysFileName ) override;
691 
692     virtual void        implDumpStorage(
693                             const StorageRef& rxStrg,
694                             const OUString& rStrgPath,
695                             const OUString& rSysPath ) override;
696 
697 private:
698     bool                isFormStorage( const OUString& rStrgPath ) const;
699 
700 private:
701     VbaFormSharedData   maFormData;
702 };
703 
704 
705 struct VbaSharedData
706 {
707     typedef ::std::map< OUString, sal_Int32 > StreamOffsetMap;
708 
709     StreamOffsetMap     maStrmOffsets;
710     rtl_TextEncoding    meTextEnc;
711 
712                         VbaSharedData();
713 
714     bool                isModuleStream( const OUString& rStrmName ) const;
715     sal_Int32           getStreamOffset( const OUString& rStrmName ) const;
716 };
717 
718 
719 class VbaDirStreamObject : public SequenceRecordObjectBase
720 {
721 public:
722     explicit            VbaDirStreamObject(
723                             const ObjectBase& rParent,
724                             const BinaryInputStreamRef& rxStrm,
725                             const OUString& rSysFileName,
726                             VbaSharedData& rVbaData );
727 
728 protected:
729     virtual bool        implIsValid() const override;
730     virtual bool        implReadRecordHeader( BinaryInputStream& rBaseStrm, sal_Int64& ornRecId, sal_Int64& ornRecSize ) override;
731     virtual void        implDumpRecordBody() override;
732 
733 private:
734     OUString     dumpByteString( const String& rName );
735     OUString     dumpUniString( const String& rName );
736     OUString     dumpByteStringWithLength( const String& rName );
737 
738 private:
739     VbaSharedData&      mrVbaData;
740     BinaryInputStreamRef mxInStrm;
741     OUString     maCurrStream;
742     sal_Int32           mnCurrOffset;
743 };
744 
745 
746 class VbaModuleStreamObject : public InputObjectBase
747 {
748 public:
749     explicit            VbaModuleStreamObject(
750                             const ObjectBase& rParent,
751                             const BinaryInputStreamRef& rxStrm,
752                             const OUString& rSysFileName,
753                             VbaSharedData& rVbaData,
754                             sal_Int32 nStrmOffset );
755 
756 protected:
757     virtual void        implDump() override;
758 
759 private:
760     VbaSharedData&      mrVbaData;
761     sal_Int32           mnStrmOffset;
762 };
763 
764 
765 class VbaStorageObject : public OleStorageObject
766 {
767 public:
768     explicit            VbaStorageObject(
769                             const ObjectBase& rParent,
770                             const StorageRef& rxStrg,
771                             const OUString& rSysPath,
772                             VbaSharedData& rVbaData );
773 
774 protected:
775     virtual void        implDumpStream(
776                             const css::uno::Reference< css::io::XInputStream >& rxStrm,
777                             const OUString& rStrgPath,
778                             const OUString& rStrmName,
779                             const OUString& rSysFileName ) override;
780 
781 private:
782     VbaSharedData&      mrVbaData;
783 };
784 
785 
786 class VbaFormStorageObject : public VbaContainerStorageObject
787 {
788 public:
789     explicit            VbaFormStorageObject(
790                             const ObjectBase& rParent,
791                             const StorageRef& rxStrg,
792                             const OUString& rSysPath,
793                             VbaSharedData& rVbaData );
794 
795 protected:
796     virtual void        implDumpStream(
797                             const css::uno::Reference< css::io::XInputStream >& rxStrm,
798                             const OUString& rStrgPath,
799                             const OUString& rStrmName,
800                             const OUString& rSysFileName ) override;
801 
802 private:
803     VbaSharedData&      mrVbaData;
804 };
805 
806 
807 class VbaProjectStorageObject : public OleStorageObject
808 {
809 public:
810     explicit            VbaProjectStorageObject( const ObjectBase& rParent, const StorageRef& rxStrg, const OUString& rSysPath );
811 
812 protected:
813     virtual void        implDumpStream(
814                             const css::uno::Reference< css::io::XInputStream >& rxStrm,
815                             const OUString& rStrgPath,
816                             const OUString& rStrmName,
817                             const OUString& rSysFileName ) override;
818 
819     virtual void        implDumpStorage(
820                             const StorageRef& rxStrg,
821                             const OUString& rStrgPath,
822                             const OUString& rSysPath ) override;
823 
824 private:
825     VbaSharedData       maVbaData;
826 };
827 
828 
829 class ActiveXStorageObject : public VbaContainerStorageObject
830 {
831 public:
832     explicit            ActiveXStorageObject(
833                             const ObjectBase& rParent,
834                             const StorageRef& rxStrg,
835                             const OUString& rSysPath );
836 
837 protected:
838     virtual void        implDumpBaseStream(
839                             const BinaryInputStreamRef& rxStrm,
840                             const OUString& rSysFileName ) override;
841 };
842 
843 
844 } // namespace oox::dump
845 
846 #endif
847 #endif
848 
849 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
850