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>
37 namespace com::sun::star
{
38 namespace io
{ class XInputStream
; }
44 class OleInputObjectBase
: public InputObjectBase
47 OleInputObjectBase() {}
49 OUString
dumpAnsiString32( const String
& rName
);
50 OUString
dumpUniString32( const String
& rName
);
52 sal_Int32
dumpStdClipboardFormat( const String
& rName
);
53 OUString
dumpAnsiString32OrStdClip( const String
& rName
);
54 OUString
dumpUniString32OrStdClip( const String
& rName
);
56 void writeOleColorItem( const String
& rName
, sal_uInt32 nColor
);
57 sal_uInt32
dumpOleColor( const String
& rName
);
61 class StdFontObject
: public OleInputObjectBase
64 explicit StdFontObject( const InputObjectBase
& rParent
);
67 virtual void implDump() override
;
71 class StdPicObject
: public OleInputObjectBase
74 explicit StdPicObject( const InputObjectBase
& rParent
);
77 virtual void implDump() override
;
81 class OleStreamObject
: public OleInputObjectBase
84 explicit OleStreamObject( const ObjectBase
& rParent
, const BinaryInputStreamRef
& rxStrm
, const OUString
& rSysFileName
);
88 class OleCompObjObject
: public OleStreamObject
91 explicit OleCompObjObject( const ObjectBase
& rParent
, const BinaryInputStreamRef
& rxStrm
, const OUString
& rSysFileName
);
94 virtual void implDump() override
;
98 class OlePropertyStreamObject
: public InputObjectBase
101 explicit OlePropertyStreamObject( const ObjectBase
& rParent
, const BinaryInputStreamRef
& rxStrm
, const OUString
& rSysFileName
);
104 virtual void implDump() override
;
107 void dumpSection( const OUString
& rGuid
, sal_uInt32 nStartPos
);
109 void dumpProperty( sal_Int32 nPropId
, sal_uInt32 nStartPos
);
110 void dumpCodePageProperty( sal_uInt32 nStartPos
);
111 void dumpDictionaryProperty( sal_uInt32 nStartPos
);
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
);
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
);
126 bool startElement( sal_uInt32 nStartPos
);
127 void writeSectionHeader( const OUString
& rGuid
, sal_uInt32 nStartPos
);
128 void writePropertyHeader( sal_Int32 nPropId
, sal_uInt32 nStartPos
);
131 NameListRef mxPropIds
;
132 rtl_TextEncoding meTextEnc
;
137 class OleStorageObject
: public StorageObjectBase
140 explicit OleStorageObject( const ObjectBase
& rParent
, const StorageRef
& rxStrg
, const OUString
& rSysPath
);
143 OleStorageObject() {}
145 using StorageObjectBase::construct
;
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
;
155 class ComCtlObjectBase
: public OleInputObjectBase
158 explicit ComCtlObjectBase(
159 const InputObjectBase
& rParent
,
160 sal_uInt32 nDataId5
, sal_uInt32 nDataId6
, sal_uInt16 nVersion
,
161 bool bCommonPart
, bool bComplexPart
);
163 virtual void implDump() override
;
164 virtual void implDumpProperties() = 0;
165 virtual void implDumpCommonExtra( sal_Int64 nEndPos
);
166 virtual void implDumpCommonTrailing();
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();
176 sal_uInt32 mnDataId5
;
177 sal_uInt32 mnDataId6
;
178 sal_uInt16 mnVersion
;
184 class ComCtlScrollBarObject
: public ComCtlObjectBase
187 explicit ComCtlScrollBarObject( const InputObjectBase
& rParent
, sal_uInt16 nVersion
);
190 virtual void implDumpProperties() override
;
194 class ComCtlProgressBarObject
: public ComCtlObjectBase
197 explicit ComCtlProgressBarObject( const InputObjectBase
& rParent
, sal_uInt16 nVersion
);
200 virtual void implDumpProperties() override
;
204 class ComCtlSliderObject
: public ComCtlObjectBase
207 explicit ComCtlSliderObject( const InputObjectBase
& rParent
, sal_uInt16 nVersion
);
210 virtual void implDumpProperties() override
;
214 class ComCtlUpDownObject
: public ComCtlObjectBase
217 explicit ComCtlUpDownObject( const InputObjectBase
& rParent
, sal_uInt16 nVersion
);
220 virtual void implDumpProperties() override
;
224 class ComCtlImageListObject
: public ComCtlObjectBase
227 explicit ComCtlImageListObject( const InputObjectBase
& rParent
, sal_uInt16 nVersion
);
230 virtual void implDumpProperties() override
;
231 virtual void implDumpCommonExtra( sal_Int64 nEndPos
) override
;
232 virtual void implDumpCommonTrailing() override
;
236 class ComCtlTabStripObject
: public ComCtlObjectBase
239 explicit ComCtlTabStripObject( const InputObjectBase
& rParent
, sal_uInt16 nVersion
);
242 virtual void implDumpProperties() override
;
243 virtual void implDumpCommonExtra( sal_Int64 nEndPos
) override
;
247 class ComCtlTreeViewObject
: public ComCtlObjectBase
250 explicit ComCtlTreeViewObject( const InputObjectBase
& rParent
, sal_uInt16 nVersion
);
253 virtual void implDumpProperties() override
;
254 virtual void implDumpCommonExtra( sal_Int64 nEndPos
) override
;
257 sal_uInt32 mnStringFlags
;
261 class ComCtlStatusBarObject
: public ComCtlObjectBase
264 explicit ComCtlStatusBarObject( const InputObjectBase
& rParent
, sal_uInt16 nVersion
);
267 virtual void implDumpProperties() override
;
268 virtual void implDumpCommonExtra( sal_Int64 nEndPos
) override
;
269 virtual void implDumpCommonTrailing() override
;
273 class AxPropertyObjectBase
: public OleInputObjectBase
276 AxPropertyObjectBase() {}
278 using OleInputObjectBase::construct
;
280 const ObjectBase
& rParent
,
281 const BinaryInputStreamRef
& rxStrm
,
282 const OUString
& rSysFileName
,
283 const String
& rPropNameList
,
284 bool b64BitPropFlags
= false );
286 const InputObjectBase
& rParent
,
287 const String
& rPropNameList
,
288 bool b64BitPropFlags
= false );
290 virtual bool implIsValid() const override
;
291 virtual void implDump() override
;
293 virtual void implDumpShortProperties();
294 virtual void implDumpExtended();
296 bool ensureValid( bool bCondition
= true );
298 template< typename Type
>
301 void setAlignAnchor();
302 bool startNextProperty();
303 OUString
getPropertyName() const;
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
);
310 bool dumpBoolProperty() { return startNextProperty(); }
311 sal_Int32
dumpHmmProperty() { return dumpDecProperty
< sal_Int32
>( 0, "CONV-HMM-TO-CM" ); }
312 sal_uInt8
dumpMousePtrProperty() { return dumpDecProperty
< sal_uInt8
>( 0, "OLE-MOUSEPTR" ); }
313 template< typename Type
>
314 Type
dumpBorderStyleProperty( Type nDefault
) { return dumpDecProperty
< Type
>( nDefault
, "AX-BORDERSTYLE" ); }
315 template< typename Type
>
316 Type
dumpSpecialEffectProperty( Type nDefault
) { return dumpDecProperty
< Type
>( nDefault
, "AX-SPECIALEFFECT" ); }
317 sal_uInt32
dumpEnabledProperty() { return dumpDecProperty
< sal_uInt32
>( 1, "AX-ENABLED" ); }
318 sal_Int32
dumpOrientationProperty() { return dumpDecProperty
< sal_Int32
>( -1, "AX-ORIENTATION" ); }
319 sal_Int32
dumpDelayProperty() { return dumpDecProperty
< sal_Int32
>( 50, "AX-CONV-MS" ); }
320 sal_uInt32
dumpImagePosProperty() { return dumpHexProperty
< sal_uInt32
>( 0x00070001, "AX-IMAGEPOS" ); }
321 sal_uInt8
dumpImageSizeModeProperty() { return dumpDecProperty
< sal_uInt8
>( 0, "AX-IMAGESIZEMODE" ); }
322 sal_uInt8
dumpImageAlignProperty() { return dumpDecProperty
< sal_uInt8
>( 2, "AX-IMAGEALIGN" ); }
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();
329 void dumpPosProperty();
330 void dumpSizeProperty();
331 void dumpGuidProperty( OUString
* pValue
= nullptr );
332 void dumpStringProperty( OUString
* pValue
= nullptr );
333 void dumpStringArrayProperty();
334 void dumpStreamProperty();
336 void dumpEmbeddedFont();
337 void dumpToPosition( sal_Int64 nPos
);
340 void constructAxPropObj( const String
& rPropNameList
, bool b64BitPropFlags
);
343 OUString
dumpString( const String
& rName
, sal_uInt32 nSize
, bool bArray
);
344 void dumpShortProperties();
345 void dumpLargeProperties();
350 enum LargePropertyType
{ PROPTYPE_POS
, PROPTYPE_SIZE
, PROPTYPE_GUID
, PROPTYPE_STRING
, PROPTYPE_STRINGARRAY
};
352 LargePropertyType mePropType
;
354 sal_uInt32 mnDataSize
;
355 OUString
* mpItemValue
;
356 explicit LargeProperty( LargePropertyType ePropType
, const String
& rItemName
, sal_uInt32 nDataSize
, OUString
* pItemValue
= nullptr ) :
357 mePropType( ePropType
), maItemName( rItemName
), mnDataSize( nDataSize
), mpItemValue( pItemValue
) {}
359 typedef ::std::vector
< LargeProperty
> LargePropertyVector
;
361 struct StreamProperty
365 explicit StreamProperty( const String
& rItemName
, sal_uInt16 nData
) :
366 maItemName( rItemName
), mnData( nData
) {}
369 LargePropertyVector maLargeProps
;
370 std::vector
< StreamProperty
>
372 NameListRef mxPropNames
;
373 sal_Int64 mnPropertiesStart
;
374 sal_Int64 mnPropertiesEnd
;
375 sal_Int64 mnPropFlags
;
376 sal_Int64 mnCurrProp
;
377 bool mb64BitPropFlags
;
382 template< typename Type
>
383 void AxPropertyObjectBase::alignInput()
385 mxStrm
->skip( (sizeof( Type
) - ((mxStrm
->tell() - mnPropertiesStart
) % sizeof( Type
))) % sizeof( Type
) );
388 template< typename Type
>
389 Type
AxPropertyObjectBase::dumpDecProperty( Type nDefault
, const NameListWrapper
& rListWrp
)
391 if( startNextProperty() )
393 alignInput
< Type
>();
394 return dumpDec
< Type
>( getPropertyName(), rListWrp
);
399 template< typename Type
>
400 Type
AxPropertyObjectBase::dumpHexProperty( Type nDefault
, const NameListWrapper
& rListWrp
)
402 if( startNextProperty() )
404 alignInput
< Type
>();
405 return dumpHex
< Type
>( getPropertyName(), rListWrp
);
411 class AxCFontNewObject
: public AxPropertyObjectBase
414 explicit AxCFontNewObject( const InputObjectBase
& rParent
);
417 virtual void implDumpShortProperties() override
;
421 class AxColumnInfoObject
: public AxPropertyObjectBase
424 explicit AxColumnInfoObject( const InputObjectBase
& rParent
);
427 virtual void implDumpShortProperties() override
;
431 class AxCommandButtonObject
: public AxPropertyObjectBase
434 explicit AxCommandButtonObject( const InputObjectBase
& rParent
);
437 virtual void implDumpShortProperties() override
;
438 virtual void implDumpExtended() override
;
442 class AxMorphControlObject
: public AxPropertyObjectBase
445 explicit AxMorphControlObject( const InputObjectBase
& rParent
);
448 virtual void implDumpShortProperties() override
;
449 virtual void implDumpExtended() override
;
452 void dumpColumnInfos();
455 sal_uInt16 mnColInfoCount
;
456 sal_uInt8 mnCtrlType
;
460 class AxLabelObject
: public AxPropertyObjectBase
463 explicit AxLabelObject( const InputObjectBase
& rParent
);
466 virtual void implDumpShortProperties() override
;
467 virtual void implDumpExtended() override
;
471 class AxImageObject
: public AxPropertyObjectBase
474 explicit AxImageObject( const InputObjectBase
& rParent
);
477 virtual void implDumpShortProperties() override
;
481 class AxScrollBarObject
: public AxPropertyObjectBase
484 explicit AxScrollBarObject( const InputObjectBase
& rParent
);
487 virtual void implDumpShortProperties() override
;
491 class AxSpinButtonObject
: public AxPropertyObjectBase
494 explicit AxSpinButtonObject( const InputObjectBase
& rParent
);
497 virtual void implDumpShortProperties() override
;
501 class AxTabStripObject
: public AxPropertyObjectBase
504 explicit AxTabStripObject( const InputObjectBase
& rParent
);
507 virtual void implDumpShortProperties() override
;
508 virtual void implDumpExtended() override
;
511 sal_Int32 mnTabFlagCount
;
515 class FormControlStreamObject
: public OleInputObjectBase
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 );
529 virtual void implDump() override
;
532 void constructFormCtrlStrmObj( const OUString
* pProgId
);
540 struct VbaFormSiteInfo
547 VbaFormSiteInfo() : mnId( 0 ), mnLength( 0 ), mbInStream( false ) {}
551 struct VbaFormSharedData
553 OUStringVector maClassInfoProgIds
;
554 std::vector
< VbaFormSiteInfo
> maSiteInfos
;
558 class VbaFormClassInfoObject
: public AxPropertyObjectBase
561 explicit VbaFormClassInfoObject( const InputObjectBase
& rParent
, VbaFormSharedData
& rFormData
);
564 virtual void implDumpShortProperties() override
;
567 VbaFormSharedData
& mrFormData
;
571 class VbaFormSiteObject
: public AxPropertyObjectBase
574 explicit VbaFormSiteObject( const InputObjectBase
& rParent
, VbaFormSharedData
& rFormData
);
577 virtual void implDumpShortProperties() override
;
580 VbaFormSharedData
& mrFormData
;
584 class VbaFormDesignExtObject
: public AxPropertyObjectBase
587 explicit VbaFormDesignExtObject( const InputObjectBase
& rParent
);
590 virtual void implDumpShortProperties() override
;
594 class VbaFStreamObject
: public AxPropertyObjectBase
597 explicit VbaFStreamObject(
598 const ObjectBase
& rParent
,
599 const BinaryInputStreamRef
& rxStrm
,
600 const OUString
& rSysFileName
,
601 VbaFormSharedData
& rFormData
);
604 virtual void implDumpShortProperties() override
;
605 virtual void implDumpExtended() override
;
608 void dumpClassInfos();
609 void dumpFormSites( sal_uInt32 nCount
);
611 void dumpDesignExtender();
614 VbaFormSharedData
& mrFormData
;
619 class VbaOStreamObject
: public OleInputObjectBase
622 explicit VbaOStreamObject(
623 const ObjectBase
& rParent
,
624 const BinaryInputStreamRef
& rxStrm
,
625 const OUString
& rSysFileName
,
626 VbaFormSharedData
& rFormData
);
629 virtual void implDump() override
;
632 VbaFormSharedData
& mrFormData
;
636 class VbaPageObject
: public AxPropertyObjectBase
639 explicit VbaPageObject( const InputObjectBase
& rParent
);
642 virtual void implDumpShortProperties() override
;
646 class VbaMultiPageObject
: public AxPropertyObjectBase
649 explicit VbaMultiPageObject( const InputObjectBase
& rParent
);
652 virtual void implDumpShortProperties() override
;
653 virtual void implDumpExtended() override
;
656 sal_Int32 mnPageCount
;
660 class VbaXStreamObject
: public InputObjectBase
663 explicit VbaXStreamObject(
664 const ObjectBase
& rParent
,
665 const BinaryInputStreamRef
& rxStrm
,
666 const OUString
& rSysFileName
,
667 VbaFormSharedData
& rFormData
);
670 virtual void implDump() override
;
673 VbaFormSharedData
& mrFormData
;
677 class VbaContainerStorageObject
: public OleStorageObject
680 explicit VbaContainerStorageObject(
681 const ObjectBase
& rParent
,
682 const StorageRef
& rxStrg
,
683 const OUString
& rSysPath
);
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
;
692 virtual void implDumpStorage(
693 const StorageRef
& rxStrg
,
694 const OUString
& rStrgPath
,
695 const OUString
& rSysPath
) override
;
698 bool isFormStorage( const OUString
& rStrgPath
) const;
701 VbaFormSharedData maFormData
;
707 typedef ::std::map
< OUString
, sal_Int32
> StreamOffsetMap
;
709 StreamOffsetMap maStrmOffsets
;
710 rtl_TextEncoding meTextEnc
;
714 bool isModuleStream( const OUString
& rStrmName
) const;
715 sal_Int32
getStreamOffset( const OUString
& rStrmName
) const;
719 class VbaDirStreamObject
: public SequenceRecordObjectBase
722 explicit VbaDirStreamObject(
723 const ObjectBase
& rParent
,
724 const BinaryInputStreamRef
& rxStrm
,
725 const OUString
& rSysFileName
,
726 VbaSharedData
& rVbaData
);
729 virtual bool implIsValid() const override
;
730 virtual bool implReadRecordHeader( BinaryInputStream
& rBaseStrm
, sal_Int64
& ornRecId
, sal_Int64
& ornRecSize
) override
;
731 virtual void implDumpRecordBody() override
;
734 OUString
dumpByteString( const String
& rName
);
735 OUString
dumpUniString( const String
& rName
);
736 OUString
dumpByteStringWithLength( const String
& rName
);
739 VbaSharedData
& mrVbaData
;
740 BinaryInputStreamRef mxInStrm
;
741 OUString maCurrStream
;
742 sal_Int32 mnCurrOffset
;
746 class VbaModuleStreamObject
: public InputObjectBase
749 explicit VbaModuleStreamObject(
750 const ObjectBase
& rParent
,
751 const BinaryInputStreamRef
& rxStrm
,
752 const OUString
& rSysFileName
,
753 VbaSharedData
& rVbaData
,
754 sal_Int32 nStrmOffset
);
757 virtual void implDump() override
;
760 VbaSharedData
& mrVbaData
;
761 sal_Int32 mnStrmOffset
;
765 class VbaStorageObject
: public OleStorageObject
768 explicit VbaStorageObject(
769 const ObjectBase
& rParent
,
770 const StorageRef
& rxStrg
,
771 const OUString
& rSysPath
,
772 VbaSharedData
& rVbaData
);
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
;
782 VbaSharedData
& mrVbaData
;
786 class VbaFormStorageObject
: public VbaContainerStorageObject
789 explicit VbaFormStorageObject(
790 const ObjectBase
& rParent
,
791 const StorageRef
& rxStrg
,
792 const OUString
& rSysPath
,
793 VbaSharedData
& rVbaData
);
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
;
803 VbaSharedData
& mrVbaData
;
807 class VbaProjectStorageObject
: public OleStorageObject
810 explicit VbaProjectStorageObject( const ObjectBase
& rParent
, const StorageRef
& rxStrg
, const OUString
& rSysPath
);
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
;
819 virtual void implDumpStorage(
820 const StorageRef
& rxStrg
,
821 const OUString
& rStrgPath
,
822 const OUString
& rSysPath
) override
;
825 VbaSharedData maVbaData
;
829 class ActiveXStorageObject
: public VbaContainerStorageObject
832 explicit ActiveXStorageObject(
833 const ObjectBase
& rParent
,
834 const StorageRef
& rxStrg
,
835 const OUString
& rSysPath
);
838 virtual void implDumpBaseStream(
839 const BinaryInputStreamRef
& rxStrm
,
840 const OUString
& rSysFileName
) override
;
844 } // namespace oox::dump
849 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */