1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_OOX_DUMP_OLEDUMPER_HXX
21 #define INCLUDED_OOX_DUMP_OLEDUMPER_HXX
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>
35 #if OOX_INCLUDE_DUMPER
37 namespace com
{ namespace sun
{ namespace star
{
38 namespace io
{ class XInputStream
; }
45 class OleInputObjectBase
: public InputObjectBase
48 OleInputObjectBase() {}
50 OUString
dumpAnsiString32( const String
& rName
);
51 OUString
dumpUniString32( const String
& rName
);
53 sal_Int32
dumpStdClipboardFormat( const String
& rName
);
54 OUString
dumpAnsiString32OrStdClip( const String
& rName
);
55 OUString
dumpUniString32OrStdClip( const String
& rName
);
57 void writeOleColorItem( const String
& rName
, sal_uInt32 nColor
);
58 sal_uInt32
dumpOleColor( const String
& rName
);
62 class StdFontObject
: public OleInputObjectBase
65 explicit StdFontObject( const InputObjectBase
& rParent
);
68 virtual void implDump() override
;
72 class StdPicObject
: public OleInputObjectBase
75 explicit StdPicObject( const InputObjectBase
& rParent
);
78 virtual void implDump() override
;
82 class OleStreamObject
: public OleInputObjectBase
85 explicit OleStreamObject( const ObjectBase
& rParent
, const BinaryInputStreamRef
& rxStrm
, const OUString
& rSysFileName
);
89 class OleCompObjObject
: public OleStreamObject
92 explicit OleCompObjObject( const ObjectBase
& rParent
, const BinaryInputStreamRef
& rxStrm
, const OUString
& rSysFileName
);
95 virtual void implDump() override
;
99 class OlePropertyStreamObject
: public InputObjectBase
102 explicit OlePropertyStreamObject( const ObjectBase
& rParent
, const BinaryInputStreamRef
& rxStrm
, const OUString
& rSysFileName
);
105 virtual void implDump() override
;
108 void dumpSection( const OUString
& rGuid
, sal_uInt32 nStartPos
);
110 void dumpProperty( sal_Int32 nPropId
, sal_uInt32 nStartPos
);
111 void dumpCodePageProperty( sal_uInt32 nStartPos
);
112 void dumpDictionaryProperty( sal_uInt32 nStartPos
);
114 sal_uInt16
dumpPropertyContents( sal_Int32 nPropId
);
115 void dumpPropertyValue( sal_Int32 nPropId
, sal_uInt16 nBaseType
);
116 void dumpPropertyVector( sal_Int32 nPropId
, sal_uInt16 nBaseType
);
118 sal_uInt16
dumpPropertyType();
119 void dumpBlob( sal_Int32 nPropId
, const String
& rName
);
120 OUString
dumpString8( const String
& rName
);
121 OUString
dumpCharArray8( const String
& rName
, sal_Int32 nLen
);
122 OUString
dumpString16( const String
& rName
);
123 OUString
dumpCharArray16( const String
& rName
, sal_Int32 nLen
);
124 bool dumpTypedProperty( const String
& rName
, sal_uInt16 nExpectedType
);
125 void dumpHlinks( sal_Int32 nSize
);
127 bool startElement( sal_uInt32 nStartPos
);
128 void writeSectionHeader( const OUString
& rGuid
, sal_uInt32 nStartPos
);
129 void writePropertyHeader( sal_Int32 nPropId
, sal_uInt32 nStartPos
);
132 NameListRef mxPropIds
;
133 rtl_TextEncoding meTextEnc
;
138 class OleStorageObject
: public StorageObjectBase
141 explicit OleStorageObject( const ObjectBase
& rParent
, const StorageRef
& rxStrg
, const OUString
& rSysPath
);
144 OleStorageObject() {}
146 using StorageObjectBase::construct
;
148 virtual void implDumpStream(
149 const css::uno::Reference
< css::io::XInputStream
>& rxStrm
,
150 const OUString
& rStrgPath
,
151 const OUString
& rStrmName
,
152 const OUString
& rSysFileName
) override
;
156 class ComCtlObjectBase
: public OleInputObjectBase
159 explicit ComCtlObjectBase(
160 const InputObjectBase
& rParent
,
161 sal_uInt32 nDataId5
, sal_uInt32 nDataId6
, sal_uInt16 nVersion
,
162 bool bCommonPart
, bool bComplexPart
);
164 virtual void implDump() override
;
165 virtual void implDumpProperties() = 0;
166 virtual void implDumpCommonExtra( sal_Int64 nEndPos
);
167 virtual void implDumpCommonTrailing();
170 bool dumpComCtlHeader( sal_uInt32 nExpId
, sal_uInt16 nExpMajor
= SAL_MAX_UINT16
, sal_uInt16 nExpMinor
= SAL_MAX_UINT16
);
171 bool dumpComCtlSize();
172 bool dumpComCtlData( sal_uInt32
& ornCommonPartSize
);
173 bool dumpComCtlCommon( sal_uInt32 nPartSize
);
174 bool dumpComCtlComplex();
177 sal_uInt32 mnDataId5
;
178 sal_uInt32 mnDataId6
;
179 sal_uInt16 mnVersion
;
185 class ComCtlScrollBarObject
: public ComCtlObjectBase
188 explicit ComCtlScrollBarObject( const InputObjectBase
& rParent
, sal_uInt16 nVersion
);
191 virtual void implDumpProperties() override
;
195 class ComCtlProgressBarObject
: public ComCtlObjectBase
198 explicit ComCtlProgressBarObject( const InputObjectBase
& rParent
, sal_uInt16 nVersion
);
201 virtual void implDumpProperties() override
;
205 class ComCtlSliderObject
: public ComCtlObjectBase
208 explicit ComCtlSliderObject( const InputObjectBase
& rParent
, sal_uInt16 nVersion
);
211 virtual void implDumpProperties() override
;
215 class ComCtlUpDownObject
: public ComCtlObjectBase
218 explicit ComCtlUpDownObject( const InputObjectBase
& rParent
, sal_uInt16 nVersion
);
221 virtual void implDumpProperties() override
;
225 class ComCtlImageListObject
: public ComCtlObjectBase
228 explicit ComCtlImageListObject( const InputObjectBase
& rParent
, sal_uInt16 nVersion
);
231 virtual void implDumpProperties() override
;
232 virtual void implDumpCommonExtra( sal_Int64 nEndPos
) override
;
233 virtual void implDumpCommonTrailing() override
;
237 class ComCtlTabStripObject
: public ComCtlObjectBase
240 explicit ComCtlTabStripObject( const InputObjectBase
& rParent
, sal_uInt16 nVersion
);
243 virtual void implDumpProperties() override
;
244 virtual void implDumpCommonExtra( sal_Int64 nEndPos
) override
;
248 class ComCtlTreeViewObject
: public ComCtlObjectBase
251 explicit ComCtlTreeViewObject( const InputObjectBase
& rParent
, sal_uInt16 nVersion
);
254 virtual void implDumpProperties() override
;
255 virtual void implDumpCommonExtra( sal_Int64 nEndPos
) override
;
258 sal_uInt32 mnStringFlags
;
262 class ComCtlStatusBarObject
: public ComCtlObjectBase
265 explicit ComCtlStatusBarObject( const InputObjectBase
& rParent
, sal_uInt16 nVersion
);
268 virtual void implDumpProperties() override
;
269 virtual void implDumpCommonExtra( sal_Int64 nEndPos
) override
;
270 virtual void implDumpCommonTrailing() override
;
274 class AxPropertyObjectBase
: public OleInputObjectBase
277 AxPropertyObjectBase() {}
279 using OleInputObjectBase::construct
;
281 const ObjectBase
& rParent
,
282 const BinaryInputStreamRef
& rxStrm
,
283 const OUString
& rSysFileName
,
284 const String
& rPropNameList
,
285 bool b64BitPropFlags
= false );
287 const InputObjectBase
& rParent
,
288 const String
& rPropNameList
,
289 bool b64BitPropFlags
= false );
291 virtual bool implIsValid() const override
;
292 virtual void implDump() override
;
294 virtual void implDumpShortProperties();
295 virtual void implDumpExtended();
297 bool ensureValid( bool bCondition
= true );
299 template< typename Type
>
302 void setAlignAnchor();
303 bool startNextProperty();
304 OUString
getPropertyName() const;
306 template< typename Type
>
307 Type
dumpDecProperty( Type nDefault
, const NameListWrapper
& rListWrp
= NO_LIST
);
308 template< typename Type
>
309 Type
dumpHexProperty( Type nDefault
, const NameListWrapper
& rListWrp
= NO_LIST
);
311 bool dumpBoolProperty() { return startNextProperty(); }
312 sal_Int32
dumpHmmProperty() { return dumpDecProperty
< sal_Int32
>( 0, "CONV-HMM-TO-CM" ); }
313 sal_uInt8
dumpMousePtrProperty() { return dumpDecProperty
< sal_uInt8
>( 0, "OLE-MOUSEPTR" ); }
314 template< typename Type
>
315 Type
dumpBorderStyleProperty( Type nDefault
) { return dumpDecProperty
< Type
>( nDefault
, "AX-BORDERSTYLE" ); }
316 template< typename Type
>
317 Type
dumpSpecialEffectProperty( Type nDefault
) { return dumpDecProperty
< Type
>( nDefault
, "AX-SPECIALEFFECT" ); }
318 sal_uInt32
dumpEnabledProperty() { return dumpDecProperty
< sal_uInt32
>( 1, "AX-ENABLED" ); }
319 sal_Int32
dumpOrientationProperty() { return dumpDecProperty
< sal_Int32
>( -1, "AX-ORIENTATION" ); }
320 sal_Int32
dumpDelayProperty() { return dumpDecProperty
< sal_Int32
>( 50, "AX-CONV-MS" ); }
321 sal_uInt32
dumpImagePosProperty() { return dumpHexProperty
< sal_uInt32
>( 0x00070001, "AX-IMAGEPOS" ); }
322 sal_uInt8
dumpImageSizeModeProperty() { return dumpDecProperty
< sal_uInt8
>( 0, "AX-IMAGESIZEMODE" ); }
323 sal_uInt8
dumpImageAlignProperty() { return dumpDecProperty
< sal_uInt8
>( 2, "AX-IMAGEALIGN" ); }
325 sal_uInt32
dumpFlagsProperty( sal_uInt32 nDefault
, const sal_Char
* pcNameList
= "AX-FLAGS" );
326 sal_uInt32
dumpColorProperty( sal_uInt32 nDefault
);
327 sal_Unicode
dumpUnicodeProperty();
328 void dumpUnknownProperty();
330 void dumpPosProperty();
331 void dumpSizeProperty();
332 void dumpGuidProperty( OUString
* pValue
= nullptr );
333 void dumpStringProperty( OUString
* pValue
= nullptr );
334 void dumpStringArrayProperty();
335 void dumpStreamProperty();
337 void dumpEmbeddedFont();
338 void dumpToPosition( sal_Int64 nPos
);
341 void constructAxPropObj( const String
& rPropNameList
, bool b64BitPropFlags
);
344 OUString
dumpString( const String
& rName
, sal_uInt32 nSize
, bool bArray
);
345 void dumpShortProperties();
346 void dumpLargeProperties();
351 enum LargePropertyType
{ PROPTYPE_POS
, PROPTYPE_SIZE
, PROPTYPE_GUID
, PROPTYPE_STRING
, PROPTYPE_STRINGARRAY
};
353 LargePropertyType mePropType
;
355 sal_uInt32 mnDataSize
;
356 OUString
* mpItemValue
;
357 explicit LargeProperty( LargePropertyType ePropType
, const String
& rItemName
, sal_uInt32 nDataSize
, OUString
* pItemValue
= nullptr ) :
358 mePropType( ePropType
), maItemName( rItemName
), mnDataSize( nDataSize
), mpItemValue( pItemValue
) {}
360 typedef ::std::vector
< LargeProperty
> LargePropertyVector
;
362 struct StreamProperty
366 explicit StreamProperty( const String
& rItemName
, sal_uInt16 nData
) :
367 maItemName( rItemName
), mnData( nData
) {}
369 typedef ::std::vector
< StreamProperty
> StreamPropertyVector
;
371 LargePropertyVector maLargeProps
;
372 StreamPropertyVector maStreamProps
;
373 NameListRef mxPropNames
;
374 sal_Int64 mnPropertiesStart
;
375 sal_Int64 mnPropertiesEnd
;
376 sal_Int64 mnPropFlags
;
377 sal_Int64 mnCurrProp
;
378 bool mb64BitPropFlags
;
383 template< typename Type
>
384 void AxPropertyObjectBase::alignInput()
386 mxStrm
->skip( (sizeof( Type
) - ((mxStrm
->tell() - mnPropertiesStart
) % sizeof( Type
))) % sizeof( Type
) );
389 template< typename Type
>
390 Type
AxPropertyObjectBase::dumpDecProperty( Type nDefault
, const NameListWrapper
& rListWrp
)
392 if( startNextProperty() )
394 alignInput
< Type
>();
395 return dumpDec
< Type
>( getPropertyName(), rListWrp
);
400 template< typename Type
>
401 Type
AxPropertyObjectBase::dumpHexProperty( Type nDefault
, const NameListWrapper
& rListWrp
)
403 if( startNextProperty() )
405 alignInput
< Type
>();
406 return dumpHex
< Type
>( getPropertyName(), rListWrp
);
412 class AxCFontNewObject
: public AxPropertyObjectBase
415 explicit AxCFontNewObject( const InputObjectBase
& rParent
);
418 virtual void implDumpShortProperties() override
;
422 class AxColumnInfoObject
: public AxPropertyObjectBase
425 explicit AxColumnInfoObject( const InputObjectBase
& rParent
);
428 virtual void implDumpShortProperties() override
;
432 class AxCommandButtonObject
: public AxPropertyObjectBase
435 explicit AxCommandButtonObject( const InputObjectBase
& rParent
);
438 virtual void implDumpShortProperties() override
;
439 virtual void implDumpExtended() override
;
443 class AxMorphControlObject
: public AxPropertyObjectBase
446 explicit AxMorphControlObject( const InputObjectBase
& rParent
);
449 virtual void implDumpShortProperties() override
;
450 virtual void implDumpExtended() override
;
453 void dumpColumnInfos();
456 sal_uInt16 mnColInfoCount
;
457 sal_uInt8 mnCtrlType
;
461 class AxLabelObject
: public AxPropertyObjectBase
464 explicit AxLabelObject( const InputObjectBase
& rParent
);
467 virtual void implDumpShortProperties() override
;
468 virtual void implDumpExtended() override
;
472 class AxImageObject
: public AxPropertyObjectBase
475 explicit AxImageObject( const InputObjectBase
& rParent
);
478 virtual void implDumpShortProperties() override
;
482 class AxScrollBarObject
: public AxPropertyObjectBase
485 explicit AxScrollBarObject( const InputObjectBase
& rParent
);
488 virtual void implDumpShortProperties() override
;
492 class AxSpinButtonObject
: public AxPropertyObjectBase
495 explicit AxSpinButtonObject( const InputObjectBase
& rParent
);
498 virtual void implDumpShortProperties() override
;
502 class AxTabStripObject
: public AxPropertyObjectBase
505 explicit AxTabStripObject( const InputObjectBase
& rParent
);
508 virtual void implDumpShortProperties() override
;
509 virtual void implDumpExtended() override
;
512 sal_Int32 mnTabFlagCount
;
516 class FormControlStreamObject
: public OleInputObjectBase
519 explicit FormControlStreamObject(
520 const ObjectBase
& rParent
,
521 const BinaryInputStreamRef
& rxStrm
,
522 const OUString
& rSysFileName
,
523 const OUString
* pProgId
= nullptr );
524 explicit FormControlStreamObject(
525 const OutputObjectBase
& rParent
,
526 const BinaryInputStreamRef
& rxStrm
,
527 const OUString
* pProgId
= nullptr );
530 virtual void implDump() override
;
533 void constructFormCtrlStrmObj( const OUString
* pProgId
);
541 struct VbaFormSiteInfo
548 VbaFormSiteInfo() : mnId( 0 ), mnLength( 0 ), mbInStream( false ) {}
551 typedef ::std::vector
< VbaFormSiteInfo
> VbaFormSiteInfoVector
;
554 struct VbaFormSharedData
556 OUStringVector maClassInfoProgIds
;
557 VbaFormSiteInfoVector maSiteInfos
;
561 class VbaFormClassInfoObject
: public AxPropertyObjectBase
564 explicit VbaFormClassInfoObject( const InputObjectBase
& rParent
, VbaFormSharedData
& rFormData
);
567 virtual void implDumpShortProperties() override
;
570 VbaFormSharedData
& mrFormData
;
574 class VbaFormSiteObject
: public AxPropertyObjectBase
577 explicit VbaFormSiteObject( const InputObjectBase
& rParent
, VbaFormSharedData
& rFormData
);
580 virtual void implDumpShortProperties() override
;
583 VbaFormSharedData
& mrFormData
;
587 class VbaFormDesignExtObject
: public AxPropertyObjectBase
590 explicit VbaFormDesignExtObject( const InputObjectBase
& rParent
);
593 virtual void implDumpShortProperties() override
;
597 class VbaFStreamObject
: public AxPropertyObjectBase
600 explicit VbaFStreamObject(
601 const ObjectBase
& rParent
,
602 const BinaryInputStreamRef
& rxStrm
,
603 const OUString
& rSysFileName
,
604 VbaFormSharedData
& rFormData
);
607 virtual void implDumpShortProperties() override
;
608 virtual void implDumpExtended() override
;
611 void dumpClassInfos();
612 void dumpFormSites( sal_uInt32 nCount
);
614 void dumpDesignExtender();
617 VbaFormSharedData
& mrFormData
;
622 class VbaOStreamObject
: public OleInputObjectBase
625 explicit VbaOStreamObject(
626 const ObjectBase
& rParent
,
627 const BinaryInputStreamRef
& rxStrm
,
628 const OUString
& rSysFileName
,
629 VbaFormSharedData
& rFormData
);
632 virtual void implDump() override
;
635 VbaFormSharedData
& mrFormData
;
639 class VbaPageObject
: public AxPropertyObjectBase
642 explicit VbaPageObject( const InputObjectBase
& rParent
);
645 virtual void implDumpShortProperties() override
;
649 class VbaMultiPageObject
: public AxPropertyObjectBase
652 explicit VbaMultiPageObject( const InputObjectBase
& rParent
);
655 virtual void implDumpShortProperties() override
;
656 virtual void implDumpExtended() override
;
659 sal_Int32 mnPageCount
;
663 class VbaXStreamObject
: public InputObjectBase
666 explicit VbaXStreamObject(
667 const ObjectBase
& rParent
,
668 const BinaryInputStreamRef
& rxStrm
,
669 const OUString
& rSysFileName
,
670 VbaFormSharedData
& rFormData
);
673 virtual void implDump() override
;
676 VbaFormSharedData
& mrFormData
;
680 class VbaContainerStorageObject
: public OleStorageObject
683 explicit VbaContainerStorageObject(
684 const ObjectBase
& rParent
,
685 const StorageRef
& rxStrg
,
686 const OUString
& rSysPath
);
689 virtual void implDumpStream(
690 const css::uno::Reference
< css::io::XInputStream
>& rxStrm
,
691 const OUString
& rStrgPath
,
692 const OUString
& rStrmName
,
693 const OUString
& rSysFileName
) override
;
695 virtual void implDumpStorage(
696 const StorageRef
& rxStrg
,
697 const OUString
& rStrgPath
,
698 const OUString
& rSysPath
) override
;
701 bool isFormStorage( const OUString
& rStrgPath
) const;
704 VbaFormSharedData maFormData
;
710 typedef ::std::map
< OUString
, sal_Int32
> StreamOffsetMap
;
712 StreamOffsetMap maStrmOffsets
;
713 rtl_TextEncoding meTextEnc
;
717 bool isModuleStream( const OUString
& rStrmName
) const;
718 sal_Int32
getStreamOffset( const OUString
& rStrmName
) const;
722 class VbaDirStreamObject
: public SequenceRecordObjectBase
725 explicit VbaDirStreamObject(
726 const ObjectBase
& rParent
,
727 const BinaryInputStreamRef
& rxStrm
,
728 const OUString
& rSysFileName
,
729 VbaSharedData
& rVbaData
);
732 virtual bool implIsValid() const override
;
733 virtual bool implReadRecordHeader( BinaryInputStream
& rBaseStrm
, sal_Int64
& ornRecId
, sal_Int64
& ornRecSize
) override
;
734 virtual void implDumpRecordBody() override
;
737 OUString
dumpByteString( const String
& rName
);
738 OUString
dumpUniString( const String
& rName
);
739 OUString
dumpByteStringWithLength( const String
& rName
);
742 VbaSharedData
& mrVbaData
;
743 BinaryInputStreamRef mxInStrm
;
744 OUString maCurrStream
;
745 sal_Int32 mnCurrOffset
;
749 class VbaModuleStreamObject
: public InputObjectBase
752 explicit VbaModuleStreamObject(
753 const ObjectBase
& rParent
,
754 const BinaryInputStreamRef
& rxStrm
,
755 const OUString
& rSysFileName
,
756 VbaSharedData
& rVbaData
,
757 sal_Int32 nStrmOffset
);
760 virtual void implDump() override
;
763 VbaSharedData
& mrVbaData
;
764 sal_Int32 mnStrmOffset
;
768 class VbaStorageObject
: public OleStorageObject
771 explicit VbaStorageObject(
772 const ObjectBase
& rParent
,
773 const StorageRef
& rxStrg
,
774 const OUString
& rSysPath
,
775 VbaSharedData
& rVbaData
);
778 virtual void implDumpStream(
779 const css::uno::Reference
< css::io::XInputStream
>& rxStrm
,
780 const OUString
& rStrgPath
,
781 const OUString
& rStrmName
,
782 const OUString
& rSysFileName
) override
;
785 VbaSharedData
& mrVbaData
;
789 class VbaFormStorageObject
: public VbaContainerStorageObject
792 explicit VbaFormStorageObject(
793 const ObjectBase
& rParent
,
794 const StorageRef
& rxStrg
,
795 const OUString
& rSysPath
,
796 VbaSharedData
& rVbaData
);
799 virtual void implDumpStream(
800 const css::uno::Reference
< css::io::XInputStream
>& rxStrm
,
801 const OUString
& rStrgPath
,
802 const OUString
& rStrmName
,
803 const OUString
& rSysFileName
) override
;
806 VbaSharedData
& mrVbaData
;
810 class VbaProjectStorageObject
: public OleStorageObject
813 explicit VbaProjectStorageObject( const ObjectBase
& rParent
, const StorageRef
& rxStrg
, const OUString
& rSysPath
);
816 virtual void implDumpStream(
817 const css::uno::Reference
< css::io::XInputStream
>& rxStrm
,
818 const OUString
& rStrgPath
,
819 const OUString
& rStrmName
,
820 const OUString
& rSysFileName
) override
;
822 virtual void implDumpStorage(
823 const StorageRef
& rxStrg
,
824 const OUString
& rStrgPath
,
825 const OUString
& rSysPath
) override
;
828 VbaSharedData maVbaData
;
832 class ActiveXStorageObject
: public VbaContainerStorageObject
835 explicit ActiveXStorageObject(
836 const ObjectBase
& rParent
,
837 const StorageRef
& rxStrg
,
838 const OUString
& rSysPath
);
841 virtual void implDumpBaseStream(
842 const BinaryInputStreamRef
& rxStrm
,
843 const OUString
& rSysFileName
) override
;
853 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */