Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / oox / source / dump / oledumper.cxx
blob76b4ce61088d6582e16e5ed65ec2f76c9cd70c42
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #include <oox/dump/oledumper.hxx>
22 #include <com/sun/star/io/XInputStream.hpp>
23 #include <com/sun/star/io/XOutputStream.hpp>
24 #include <osl/file.hxx>
25 #include <osl/thread.h>
26 #include <rtl/tencinfo.h>
27 #include <oox/core/filterbase.hxx>
28 #include <oox/helper/binaryoutputstream.hxx>
29 #include <oox/ole/olestorage.hxx>
30 #include <oox/ole/vbainputstream.hxx>
32 #ifdef DBG_UTIL
34 namespace oox {
35 namespace dump {
37 using namespace ::com::sun::star::io;
38 using namespace ::com::sun::star::uno;
40 OUString OleInputObjectBase::dumpAnsiString32( const String& rName )
42 return dumpCharArray( rName, mxStrm->readInt32(), RTL_TEXTENCODING_MS_1252 );
45 OUString OleInputObjectBase::dumpUniString32( const String& rName )
47 return dumpUnicodeArray( rName, mxStrm->readInt32() );
50 sal_Int32 OleInputObjectBase::dumpStdClipboardFormat( const String& rName )
52 return dumpDec< sal_Int32 >( rName( "clipboard-format" ), "OLE-STD-CLIPBOARD-FORMAT" );
55 OUString OleInputObjectBase::dumpAnsiString32OrStdClip( const String& rName )
57 sal_Int32 nLen = mxStrm->readInt32();
58 return (nLen < 0) ? OUString::number( dumpStdClipboardFormat( rName ) ) : dumpCharArray( rName, nLen, RTL_TEXTENCODING_MS_1252 );
61 OUString OleInputObjectBase::dumpUniString32OrStdClip( const String& rName )
63 sal_Int32 nLen = mxStrm->readInt32();
64 return (nLen < 0) ? OUString::number( dumpStdClipboardFormat( rName ) ) : dumpUnicodeArray( rName, nLen );
67 void OleInputObjectBase::writeOleColorItem( const String& rName, sal_uInt32 nColor )
69 MultiItemsGuard aMultiGuard( mxOut );
70 writeHexItem( rName, nColor, "OLE-COLOR" );
73 sal_uInt32 OleInputObjectBase::dumpOleColor( const String& rName )
75 sal_uInt32 nOleColor = mxStrm->readuInt32();
76 writeOleColorItem( rName, nOleColor );
77 return nOleColor;
80 StdFontObject::StdFontObject( const InputObjectBase& rParent )
82 construct( rParent );
85 void StdFontObject::implDump()
87 dumpDec< sal_uInt8 >( "version" );
88 dumpDec< sal_uInt16 >( "charset", "CHARSET" );
89 dumpHex< sal_uInt8 >( "flags", "STDFONT-FLAGS" );
90 dumpDec< sal_uInt16 >( "weight", "FONT-WEIGHT" );
91 dumpDec< sal_uInt32 >( "height", "STDFONT-HEIGHT" );
92 dumpCharArray( "name", mxStrm->readuInt8(), RTL_TEXTENCODING_ASCII_US );
95 StdPicObject::StdPicObject( const InputObjectBase& rParent )
97 construct( rParent );
100 void StdPicObject::implDump()
102 dumpHex< sal_uInt32 >( "identifier", "STDPIC-ID" );
103 sal_uInt32 nSize = dumpHex< sal_uInt32 >( "image-size", "CONV-DEC" );
104 dumpBinary( "image-data", nSize );
107 OleStreamObject::OleStreamObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName )
109 construct( rParent, rxStrm, rSysFileName );
112 OleCompObjObject::OleCompObjObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName ) :
113 OleStreamObject( rParent, rxStrm, rSysFileName )
117 void OleCompObjObject::implDump()
119 dumpUnused( 4 );
120 dumpDec< sal_uInt32 >( "version" );
121 dumpUnused( 20 );
122 dumpAnsiString32( "ansi-display-name" );
123 dumpAnsiString32OrStdClip( "ansi-clipboard-format" );
124 if( mxStrm->getRemaining() >= 4 )
126 sal_Int32 nLen = mxStrm->readInt32();
127 if( (0 <= nLen) && (nLen <= 40) )
129 dumpCharArray( "ansi-unused", nLen, RTL_TEXTENCODING_MS_1252 );
130 if( (mxStrm->getRemaining() >= 4) && (dumpHex< sal_Int32 >( "unicode-marker" ) == 0x71B239F4) )
132 dumpUniString32( "unicode-display-name" );
133 dumpUniString32OrStdClip( "unicode-clipboard-format" );
134 dumpUniString32( "unicode-unused" );
137 else
138 writeDecItem( "length", nLen );
140 dumpRemainingStream();
143 namespace {
145 const sal_Int32 OLEPROP_ID_DICTIONARY = 0;
146 const sal_Int32 OLEPROP_ID_CODEPAGE = 1;
148 const sal_uInt16 OLEPROP_TYPE_INT16 = 2;
149 const sal_uInt16 OLEPROP_TYPE_INT32 = 3;
150 const sal_uInt16 OLEPROP_TYPE_FLOAT = 4;
151 const sal_uInt16 OLEPROP_TYPE_DOUBLE = 5;
152 const sal_uInt16 OLEPROP_TYPE_DATE = 7;
153 const sal_uInt16 OLEPROP_TYPE_STRING = 8;
154 const sal_uInt16 OLEPROP_TYPE_STATUS = 10;
155 const sal_uInt16 OLEPROP_TYPE_BOOL = 11;
156 const sal_uInt16 OLEPROP_TYPE_VARIANT = 12;
157 const sal_uInt16 OLEPROP_TYPE_INT8 = 16;
158 const sal_uInt16 OLEPROP_TYPE_UINT8 = 17;
159 const sal_uInt16 OLEPROP_TYPE_UINT16 = 18;
160 const sal_uInt16 OLEPROP_TYPE_UINT32 = 19;
161 const sal_uInt16 OLEPROP_TYPE_INT64 = 20;
162 const sal_uInt16 OLEPROP_TYPE_UINT64 = 21;
163 const sal_uInt16 OLEPROP_TYPE_STRING8 = 30;
164 const sal_uInt16 OLEPROP_TYPE_STRING16 = 31;
165 const sal_uInt16 OLEPROP_TYPE_FILETIME = 64;
166 const sal_uInt16 OLEPROP_TYPE_BLOB = 65;
167 const sal_uInt16 OLEPROP_TYPE_STREAM = 66;
168 const sal_uInt16 OLEPROP_TYPE_STORAGE = 67;
169 const sal_uInt16 OLEPROP_TYPE_CLIPFMT = 71;
171 const sal_uInt16 OLEPROP_TYPE_SIMPLE = 0x0000;
172 const sal_uInt16 OLEPROP_TYPE_VECTOR = 0x1000;
173 const sal_uInt16 OLEPROP_TYPE_ARRAY = 0x2000;
175 const sal_uInt16 CODEPAGE_UNICODE = 1200;
177 const sal_uInt32 AX_STRING_COMPRESSED = 0x80000000;
179 } // namespace
181 OlePropertyStreamObject::OlePropertyStreamObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName )
183 construct( rParent, rxStrm, rSysFileName );
186 void OlePropertyStreamObject::implDump()
188 OUStringVector aGuidVec;
189 ::std::vector< sal_uInt32 > aStartPosVec;
191 // dump header
192 writeEmptyItem( "HEADER" );
194 IndentGuard aIndGuard( mxOut );
195 dumpHex< sal_uInt16 >( "byte-order", "OLEPROP-BYTE-ORDER" );
196 dumpDec< sal_uInt16 >( "version" );
197 dumpDec< sal_uInt16 >( "os-minor" );
198 dumpDec< sal_uInt16 >( "os-type", "OLEPROP-OSTYPE" );
199 dumpGuid( "guid" );
200 sal_Int32 nSectCount = dumpDec< sal_Int32 >( "section-count" );
202 // dump table of section positions
204 TableGuard aTabGuard( mxOut, 15, 60 );
205 mxOut->resetItemIndex();
206 for( sal_Int32 nSectIdx = 0; !mxStrm->isEof() && (nSectIdx < nSectCount); ++nSectIdx )
208 MultiItemsGuard aMultiGuard( mxOut );
209 writeEmptyItem( "#section" );
210 aGuidVec.push_back( dumpGuid( "guid" ) );
211 aStartPosVec.push_back( dumpHex< sal_uInt32 >( "start-pos", "CONV-DEC" ) );
215 mxOut->emptyLine();
217 // dump sections
218 for( size_t nSectIdx = 0; !mxStrm->isEof() && (nSectIdx < aStartPosVec.size()); ++nSectIdx )
219 dumpSection( aGuidVec[ nSectIdx ], aStartPosVec[ nSectIdx ] );
222 void OlePropertyStreamObject::dumpSection( const OUString& rGuid, sal_uInt32 nStartPos )
224 // property ID names
225 mxPropIds = cfg().createNameList< ConstList >( "OLEPROP-IDS" );
226 OUString aGuidName = cfg().getStringOption( rGuid, OUString() );
227 if ( aGuidName == "GlobalDocProp" )
228 mxPropIds->includeList( cfg().getNameList( "OLEPROP-GLOBALIDS" ) );
229 else if ( aGuidName == "BuiltinDocProp" )
230 mxPropIds->includeList( cfg().getNameList( "OLEPROP-BUILTINIDS" ) );
231 else
232 mxPropIds->includeList( cfg().getNameList( "OLEPROP-BASEIDS" ) );
234 // property ID/position map
235 typedef ::std::map< sal_Int32, sal_uInt32 > PropertyPosMap;
236 PropertyPosMap aPropMap;
238 // dump section header line
239 writeSectionHeader( rGuid, nStartPos );
241 // seek to section
242 IndentGuard aIndGuard( mxOut );
243 if( startElement( nStartPos ) )
245 // dump section header
246 dumpDec< sal_Int32 >( "size" );
247 sal_Int32 nPropCount = dumpDec< sal_Int32 >( "property-count" );
249 // dump table of property positions
251 TableGuard aTabGuard( mxOut, 15, 25 );
252 mxOut->resetItemIndex();
253 for( sal_Int32 nPropIdx = 0; !mxStrm->isEof() && (nPropIdx < nPropCount); ++nPropIdx )
255 MultiItemsGuard aMultiGuard( mxOut );
256 writeEmptyItem( "#property" );
257 sal_Int32 nPropId = dumpDec< sal_Int32 >( "id", mxPropIds );
258 sal_uInt32 nPropPos = nStartPos + dumpHex< sal_uInt32 >( "start-pos", "CONV-DEC" );
259 aPropMap[ nPropId ] = nPropPos;
263 mxOut->emptyLine();
265 // code page property
266 meTextEnc = RTL_TEXTENCODING_MS_1252;
267 mbIsUnicode = false;
268 PropertyPosMap::iterator aCodePageIt = aPropMap.find( OLEPROP_ID_CODEPAGE );
269 if( aCodePageIt != aPropMap.end() )
271 dumpCodePageProperty( aCodePageIt->second );
272 aPropMap.erase( aCodePageIt );
275 // dictionary property
276 PropertyPosMap::iterator aDictIt = aPropMap.find( OLEPROP_ID_DICTIONARY );
277 if( aDictIt != aPropMap.end() )
279 dumpDictionaryProperty( aDictIt->second );
280 aPropMap.erase( aDictIt );
283 // other properties
284 for (auto const& elem : aPropMap)
285 dumpProperty( elem.first, elem.second );
287 // remove the user defined list of property ID names
288 cfg().eraseNameList( "OLEPROP-IDS" );
291 void OlePropertyStreamObject::dumpProperty( sal_Int32 nPropId, sal_uInt32 nStartPos )
293 writePropertyHeader( nPropId, nStartPos );
294 IndentGuard aIndGuard( mxOut );
295 if( startElement( nStartPos ) )
296 dumpPropertyContents( nPropId );
297 mxOut->emptyLine();
300 void OlePropertyStreamObject::dumpCodePageProperty( sal_uInt32 nStartPos )
302 writePropertyHeader( OLEPROP_ID_CODEPAGE, nStartPos );
303 IndentGuard aIndGuard( mxOut );
304 if( startElement( nStartPos ) )
306 sal_uInt16 nType = dumpPropertyType();
307 if( nType == OLEPROP_TYPE_INT16 )
309 sal_uInt16 nCodePage = dumpDec< sal_uInt16 >( "codepage", "CODEPAGES" );
310 rtl_TextEncoding eNewTextEnc = rtl_getTextEncodingFromWindowsCodePage( nCodePage );
311 if( eNewTextEnc != RTL_TEXTENCODING_DONTKNOW )
312 meTextEnc = eNewTextEnc;
313 mbIsUnicode = nCodePage == CODEPAGE_UNICODE;
315 else
316 dumpPropertyContents( OLEPROP_ID_CODEPAGE );
318 mxOut->emptyLine();
321 void OlePropertyStreamObject::dumpDictionaryProperty( sal_uInt32 nStartPos )
323 writePropertyHeader( OLEPROP_ID_DICTIONARY, nStartPos );
324 IndentGuard aIndGuard( mxOut );
325 if( startElement( nStartPos ) )
327 sal_Int32 nCount = dumpDec< sal_Int32 >( "count" );
328 for( sal_Int32 nIdx = 0; !mxStrm->isEof() && (nIdx < nCount); ++nIdx )
330 MultiItemsGuard aMultiGuard( mxOut );
331 TableGuard aTabGuard( mxOut, 10, 20 );
332 sal_Int32 nId = dumpDec< sal_Int32 >( "id" );
333 OUString aName = dumpString8( "name" );
334 if( mxPropIds.get() )
335 mxPropIds->setName( nId, aName );
338 mxOut->emptyLine();
341 sal_uInt16 OlePropertyStreamObject::dumpPropertyContents( sal_Int32 nPropId )
343 sal_uInt16 nType = dumpPropertyType();
344 sal_uInt16 nBaseType = static_cast< sal_uInt16 >( nType & 0x0FFF );
345 sal_uInt16 nArrayType = static_cast< sal_uInt16 >( nType & 0xF000 );
346 switch( nArrayType )
348 case OLEPROP_TYPE_SIMPLE: dumpPropertyValue( nPropId, nBaseType ); break;
349 case OLEPROP_TYPE_VECTOR: dumpPropertyVector( nPropId, nBaseType ); break;
350 case OLEPROP_TYPE_ARRAY: /*TODO*/; break;
352 return nType;
355 void OlePropertyStreamObject::dumpPropertyValue( sal_Int32 nPropId, sal_uInt16 nBaseType )
357 switch( nBaseType )
359 case OLEPROP_TYPE_INT16: dumpDec< sal_Int16 >( "value" ); break;
360 case OLEPROP_TYPE_INT32: dumpDec< sal_Int32 >( "value" ); break;
361 case OLEPROP_TYPE_FLOAT: dumpDec< float >( "value" ); break;
362 case OLEPROP_TYPE_DOUBLE: dumpDec< double >( "value" ); break;
363 case OLEPROP_TYPE_DATE: dumpDec< double >( "date" ); break;
364 case OLEPROP_TYPE_STRING: dumpString8( "value" ); break;
365 case OLEPROP_TYPE_STATUS: dumpHex< sal_Int32 >( "status" ); break;
366 case OLEPROP_TYPE_BOOL: dumpBool< sal_Int16 >( "value" ); break;
367 case OLEPROP_TYPE_VARIANT: dumpPropertyContents( nPropId ); break;
368 case OLEPROP_TYPE_INT8: dumpDec< sal_Int8 >( "value" ); break;
369 case OLEPROP_TYPE_UINT8: dumpDec< sal_uInt8 >( "value" ); break;
370 case OLEPROP_TYPE_UINT16: dumpDec< sal_uInt16 >( "value" ); break;
371 case OLEPROP_TYPE_UINT32: dumpDec< sal_uInt32 >( "value" ); break;
372 case OLEPROP_TYPE_INT64: dumpDec< sal_Int64 >( "value" ); break;
373 case OLEPROP_TYPE_UINT64: dumpDec< sal_uInt64 >( "value" ); break;
374 case OLEPROP_TYPE_STRING8: dumpString8( "value" ); break;
375 case OLEPROP_TYPE_STRING16: dumpString16( "value" ); break;
376 case OLEPROP_TYPE_FILETIME: dumpFileTime( "file-time" ); break;
377 case OLEPROP_TYPE_BLOB: dumpBlob( nPropId, "data" ); break;
378 case OLEPROP_TYPE_STREAM: dumpString8( "stream-name" ); break;
379 case OLEPROP_TYPE_STORAGE: dumpString8( "storage-name" ); break;
380 case OLEPROP_TYPE_CLIPFMT: dumpBlob( nPropId, "clip-data" ); break;
384 void OlePropertyStreamObject::dumpPropertyVector( sal_Int32 nPropId, sal_uInt16 nBaseType )
386 sal_Int32 nElemCount = dumpDec< sal_Int32 >( "element-count" );
387 for( sal_Int32 nElemIdx = 0; !mxStrm->isEof() && (nElemIdx < nElemCount); ++nElemIdx )
389 mxOut->resetItemIndex( nElemIdx );
390 writeEmptyItem( "#element" );
391 IndentGuard aIndGuard( mxOut );
392 dumpPropertyValue( nPropId, nBaseType );
396 sal_uInt16 OlePropertyStreamObject::dumpPropertyType()
398 return static_cast< sal_uInt16 >( dumpHex< sal_Int32 >( "type", "OLEPROP-TYPE" ) & 0xFFFF );
401 void OlePropertyStreamObject::dumpBlob( sal_Int32 nPropId, const String& rName )
403 sal_Int32 nSize = dumpDec< sal_Int32 >( "data-size" );
404 if( nSize > 0 )
406 OUString aPropName = mxPropIds->getName( cfg(), nPropId );
407 if( aPropName == "'_PID_HLINKS'" )
408 dumpHlinks( nSize );
409 else
410 dumpBinary( rName, nSize );
414 OUString OlePropertyStreamObject::dumpString8( const String& rName )
416 sal_Int32 nLen = dumpDec< sal_Int32 >( "string-len" );
417 return mbIsUnicode ? dumpCharArray16( rName, nLen ) : dumpCharArray8( rName, nLen );
420 OUString OlePropertyStreamObject::dumpCharArray8( const String& rName, sal_Int32 nLen )
422 sal_Int32 nNewLen = getLimitedValue< sal_Int32, sal_Int32 >( nLen, 0, 1024 );
423 OUString aData = mxStrm->readCharArrayUC( nNewLen, meTextEnc );
424 writeStringItem( rName, aData );
425 return aData;
428 OUString OlePropertyStreamObject::dumpString16( const String& rName )
430 sal_Int32 nLen = dumpDec< sal_Int32 >( "string-len" );
431 return dumpCharArray16( rName, nLen );
434 OUString OlePropertyStreamObject::dumpCharArray16( const String& rName, sal_Int32 nLen )
436 sal_Int32 nNewLen = getLimitedValue< sal_Int32, sal_Int32 >( nLen, 0, 1024 );
437 OUString aData = mxStrm->readUnicodeArray( nNewLen );
438 writeStringItem( rName, aData );
439 if( nNewLen & 1 ) dumpUnused( 2 ); // always padding to 32bit
440 return aData;
443 bool OlePropertyStreamObject::dumpTypedProperty( const String& rName, sal_uInt16 nExpectedType )
445 writeEmptyItem( rName );
446 IndentGuard aIndGuard( mxOut );
447 return (dumpPropertyContents( -1 ) == nExpectedType) && !mxStrm->isEof();
450 void OlePropertyStreamObject::dumpHlinks( sal_Int32 nSize )
452 sal_Int64 nEndPos = mxStrm->tell() + nSize;
453 sal_Int32 nCount = dumpDec< sal_Int32 >( "property-count" );
454 bool bValid = true;
455 for( sal_Int32 nHlinkIndex = 0, nHlinkCount = nCount / 6; bValid && !mxStrm->isEof() && (nHlinkIndex < nHlinkCount); ++nHlinkIndex )
457 writeEmptyItem( "HYPERLINK" );
458 IndentGuard aIndGuard( mxOut );
459 bValid =
460 dumpTypedProperty( "hash", OLEPROP_TYPE_INT32 ) &&
461 dumpTypedProperty( "app", OLEPROP_TYPE_INT32 ) &&
462 dumpTypedProperty( "shape-id", OLEPROP_TYPE_INT32 ) &&
463 dumpTypedProperty( "info", OLEPROP_TYPE_INT32 ) &&
464 dumpTypedProperty( "target", OLEPROP_TYPE_STRING16 ) &&
465 dumpTypedProperty( "location", OLEPROP_TYPE_STRING16 );
467 dumpRemainingTo( nEndPos );
470 bool OlePropertyStreamObject::startElement( sal_uInt32 nStartPos )
472 mxStrm->seek( nStartPos );
473 if( mxStrm->isEof() )
474 writeInfoItem( "stream-state", OOX_DUMP_ERR_STREAM );
475 return !mxStrm->isEof();
478 void OlePropertyStreamObject::writeSectionHeader( const OUString& rGuid, sal_uInt32 nStartPos )
480 MultiItemsGuard aMultiGuard( mxOut );
481 writeEmptyItem( "SECTION" );
482 writeHexItem( "pos", nStartPos, "CONV-DEC" );
483 writeGuidItem( "guid", rGuid );
486 void OlePropertyStreamObject::writePropertyHeader( sal_Int32 nPropId, sal_uInt32 nStartPos )
488 MultiItemsGuard aMultiGuard( mxOut );
489 writeEmptyItem( "PROPERTY" );
490 writeHexItem( "pos", nStartPos, "CONV-DEC" );
491 writeDecItem( "id", nPropId, mxPropIds );
494 OleStorageObject::OleStorageObject( const ObjectBase& rParent, const StorageRef& rxStrg, const OUString& rSysPath )
496 construct( rParent, rxStrg, rSysPath );
499 void OleStorageObject::implDumpStream( const Reference< XInputStream >& rxStrm, const OUString& /*rStrgPath*/, const OUString& rStrmName, const OUString& rSysFileName )
501 if ( rStrmName == "\001CompObj" )
502 OleCompObjObject( *this, rxStrm, rSysFileName ).dump();
503 else if( rStrmName == "\005SummaryInformation" || rStrmName == "\005DocumentSummaryInformation" )
504 OlePropertyStreamObject( *this, rxStrm, rSysFileName ).dump();
505 else
506 BinaryStreamObject( *this, rxStrm, rSysFileName ).dump();
509 ComCtlObjectBase::ComCtlObjectBase( const InputObjectBase& rParent,
510 sal_uInt32 nDataId5, sal_uInt32 nDataId6, sal_uInt16 nVersion, bool bCommonPart, bool bComplexPart ) :
511 mnDataId5( nDataId5 ),
512 mnDataId6( nDataId6 ),
513 mnVersion( nVersion ),
514 mbCommonPart( bCommonPart ),
515 mbComplexPart( bComplexPart )
517 construct( rParent );
520 void ComCtlObjectBase::implDump()
522 sal_uInt32 nCommonSize = 0;
523 dumpComCtlSize() && dumpComCtlData( nCommonSize ) && (!mbCommonPart || dumpComCtlCommon( nCommonSize )) && (!mbComplexPart || dumpComCtlComplex());
526 void ComCtlObjectBase::implDumpCommonExtra( sal_Int64 /*nEndPos*/ )
530 void ComCtlObjectBase::implDumpCommonTrailing()
534 bool ComCtlObjectBase::dumpComCtlHeader( sal_uInt32 nExpId, sal_uInt16 nExpMajor, sal_uInt16 nExpMinor )
536 // no idea if all this is correct...
537 sal_uInt32 nId = dumpHex< sal_uInt32 >( "header-id", "COMCTL-HEADER-IDS" );
538 ItemGuard aItem( mxOut, "version" );
539 sal_uInt16 nMinor = mxStrm->readuInt16();
540 sal_uInt16 nMajor = mxStrm->readuInt16();
541 mxOut->writeDec( nMajor );
542 mxOut->writeChar( '.' );
543 mxOut->writeDec( nMinor );
544 return !mxStrm->isEof() && (nId == nExpId) && ((nExpMajor == SAL_MAX_UINT16) || (nExpMajor == nMajor)) && ((nExpMinor == SAL_MAX_UINT16) || (nExpMinor == nMinor));
547 bool ComCtlObjectBase::dumpComCtlSize()
549 if( dumpComCtlHeader( 0x12344321, 0, 8 ) )
551 IndentGuard aIndGuard( mxOut );
552 dumpDec< sal_Int32 >( "width", "CONV-HMM-TO-CM" );
553 dumpDec< sal_Int32 >( "height", "CONV-HMM-TO-CM" );
554 return !mxStrm->isEof();
556 return false;
559 bool ComCtlObjectBase::dumpComCtlData( sal_uInt32& ornCommonPartSize )
561 if( dumpComCtlHeader( (mnVersion == 5) ? mnDataId5 : mnDataId6, mnVersion ) )
563 IndentGuard aIndGuard( mxOut );
564 if( mbCommonPart )
565 ornCommonPartSize = dumpDec< sal_uInt32 >( "common-part-size" );
566 implDumpProperties();
567 return !mxStrm->isEof();
569 return false;
572 bool ComCtlObjectBase::dumpComCtlCommon( sal_uInt32 nPartSize )
574 sal_Int64 nEndPos = mxStrm->tell() + nPartSize;
575 if( (nPartSize >= 16) && dumpComCtlHeader( 0xABCDEF01, 5, 0 ) )
577 IndentGuard aIndGuard( mxOut );
578 dumpUnknown( 4 );
579 dumpHex< sal_uInt32 >( "common-flags", "COMCTL-COMMON-FLAGS" );
580 implDumpCommonExtra( nEndPos );
581 dumpRemainingTo( nEndPos );
582 implDumpCommonTrailing();
583 return !mxStrm->isEof();
585 return false;
588 bool ComCtlObjectBase::dumpComCtlComplex()
590 if( dumpComCtlHeader( 0xBDECDE1F, 5, 1 ) )
592 IndentGuard aIndGuard( mxOut );
593 sal_uInt32 nFlags = dumpHex< sal_uInt32 >( "comctl-complex-flags", "COMCTL-COMPLEX-FLAGS" );
594 if( !mxStrm->isEof() && (nFlags & 0x01) )
596 writeEmptyItem( "font" );
597 IndentGuard aIndGuard2( mxOut );
598 OUString aClassName = cfg().getStringOption( dumpGuid(), OUString() );
599 if ( aClassName == "StdFont" )
600 StdFontObject( *this ).dump();
602 if( !mxStrm->isEof() && (nFlags & 0x02) )
604 writeEmptyItem( "mouse-icon" );
605 IndentGuard aIndGuard2( mxOut );
606 OUString aClassName = cfg().getStringOption( dumpGuid(), OUString() );
607 if ( aClassName == "StdPic" )
608 StdPicObject( *this ).dump();
610 return !mxStrm->isEof();
612 return false;
615 ComCtlScrollBarObject::ComCtlScrollBarObject( const InputObjectBase& rParent, sal_uInt16 nVersion ) :
616 ComCtlObjectBase( rParent, SAL_MAX_UINT32, 0x99470A83, nVersion, true, true )
620 void ComCtlScrollBarObject::implDumpProperties()
622 dumpHex< sal_uInt32 >( "flags", "COMCTL-SCROLLBAR-FLAGS" );
623 dumpDec< sal_Int32 >( "large-change" );
624 dumpDec< sal_Int32 >( "small-change" );
625 dumpDec< sal_Int32 >( "min" );
626 dumpDec< sal_Int32 >( "max" );
627 dumpDec< sal_Int32 >( "value" );
630 ComCtlProgressBarObject::ComCtlProgressBarObject( const InputObjectBase& rParent, sal_uInt16 nVersion ) :
631 ComCtlObjectBase( rParent, 0xE6E17E84, 0x97AB8A01, nVersion, true, true )
635 void ComCtlProgressBarObject::implDumpProperties()
637 dumpDec< float >( "min" );
638 dumpDec< float >( "max" );
639 if( mnVersion == 6 )
641 dumpBool< sal_uInt16 >( "vertical" );
642 dumpBool< sal_uInt16 >( "smooth-scroll" );
646 ComCtlSliderObject::ComCtlSliderObject( const InputObjectBase& rParent, sal_uInt16 nVersion ) :
647 ComCtlObjectBase( rParent, 0xE6E17E86, 0x0A2BAE11, nVersion, true, true )
651 void ComCtlSliderObject::implDumpProperties()
653 dumpBool< sal_Int32 >( "vertical" );
654 dumpDec< sal_Int32 >( "large-change" );
655 dumpDec< sal_Int32 >( "small-change" );
656 dumpDec< sal_Int32 >( "min" );
657 dumpDec< sal_Int32 >( "max" );
658 dumpDec< sal_Int16 >( "select-range", "COMCTL-SLIDER-SELECTRANGE" );
659 dumpUnused( 2 );
660 dumpDec< sal_Int32 >( "select-start" );
661 dumpDec< sal_Int32 >( "select-length" );
662 dumpDec< sal_Int32 >( "tick-style", "COMCTL-SLIDER-TICKSTYLE" );
663 dumpDec< sal_Int32 >( "tick-frequency" );
664 dumpDec< sal_Int32 >( "value" );
665 if( mnVersion == 6 )
666 dumpBool< sal_Int32 >( "tooltip-below" );
669 ComCtlUpDownObject::ComCtlUpDownObject( const InputObjectBase& rParent, sal_uInt16 nVersion ) :
670 ComCtlObjectBase( rParent, 0xFF3626A0, 0xFF3626A0, nVersion, false, false )
674 void ComCtlUpDownObject::implDumpProperties()
676 dumpUnknown( 16 ); // buddy-property, somehow
677 dumpDec< sal_Int32 >( "buddy-control" );
678 dumpUnknown( 8 );
679 dumpDec< sal_Int32 >( "value" );
680 dumpUnknown( 4 );
681 dumpDec< sal_Int32 >( "increment" );
682 dumpDec< sal_Int32 >( "max" );
683 dumpDec< sal_Int32 >( "min" );
684 dumpHex< sal_uInt32 >( "flags-1", "COMCTL-UPDOWN-FLAGS1" );
685 dumpHex< sal_uInt32 >( "flags-2", "COMCTL-UPDOWN-FLAGS2" );
686 dumpUnknown( 4 );
689 ComCtlImageListObject::ComCtlImageListObject( const InputObjectBase& rParent, sal_uInt16 nVersion ) :
690 ComCtlObjectBase( rParent, 0xE6E17E80, 0xE6E17E80, nVersion, true, false )
694 void ComCtlImageListObject::implDumpProperties()
696 dumpDec< sal_uInt16 >( "image-width" );
697 dumpDec< sal_uInt16 >( "image-height" );
698 dumpOleColor( "mask-color" );
699 dumpBool< sal_Int16 >( "use-mask-color" );
700 dumpUnknown( 2 );
703 void ComCtlImageListObject::implDumpCommonExtra( sal_Int64 /*nEndPos*/ )
705 dumpUnknown( 4 );
706 dumpOleColor( "back-color" );
707 dumpUnknown( 4 );
708 sal_Int32 nImageCount = dumpDec< sal_Int32 >( "image-count" );
709 mxOut->resetItemIndex();
710 for( sal_Int32 nImageIndex = 0; (nImageIndex < nImageCount) && !mxStrm->isEof(); ++nImageIndex )
712 writeEmptyItem( "#image" );
713 IndentGuard aIndGuard( mxOut );
714 sal_uInt8 nFlags = dumpHex< sal_uInt8 >( "text-flags", "COMCTL-IMAGELIST-TEXTFLAGS" );
715 if( nFlags & 0x01 ) dumpUniString32( "caption" );
716 if( nFlags & 0x02 ) dumpUniString32( "key" );
720 void ComCtlImageListObject::implDumpCommonTrailing()
722 sal_Int32 nImageCount = dumpDec< sal_Int32 >( "image-count" );
723 mxOut->resetItemIndex();
724 for( sal_Int32 nImageIndex = 0; (nImageIndex < nImageCount) && !mxStrm->isEof(); ++nImageIndex )
726 writeEmptyItem( "#image" );
727 IndentGuard aIndGuard( mxOut );
728 dumpDec< sal_Int32 >( "index" );
729 StdPicObject( *this ).dump();
733 ComCtlTabStripObject::ComCtlTabStripObject( const InputObjectBase& rParent, sal_uInt16 nVersion ) :
734 ComCtlObjectBase( rParent, 0xE6E17E8A, 0xD12A7AC1, nVersion, true, true )
738 void ComCtlTabStripObject::implDumpProperties()
740 dumpHex< sal_uInt32 >( "flags-1", "COMCTL-TABSTRIP-FLAGS1" );
741 dumpDec< sal_uInt16 >( "tab-fixed-width", "CONV-HMM-TO-CM" );
742 dumpDec< sal_uInt16 >( "tab-fixed-height", "CONV-HMM-TO-CM" );
743 if( mnVersion == 6 )
745 dumpHex< sal_uInt32 >( "flags-2", "COMCTL-TABSTRIP-FLAGS2" );
746 dumpDec< sal_uInt16 >( "tab-min-width", "CONV-HMM-TO-CM" );
747 dumpUnknown( 2 );
748 dumpHex< sal_uInt32 >( "flags-3", "COMCTL-TABSTRIP-FLAGS3" );
752 void ComCtlTabStripObject::implDumpCommonExtra( sal_Int64 /*nEndPos*/ )
754 dumpUnknown( 12 );
755 dumpUniString32( "image-list" );
756 sal_Int32 nTabCount = dumpDec< sal_Int32 >( "tab-count" );
757 mxOut->resetItemIndex();
758 for( sal_Int32 nTabIndex = 0; (nTabIndex < nTabCount) && !mxStrm->isEof(); ++nTabIndex )
760 writeEmptyItem( "#tab" );
761 IndentGuard aIndGuard( mxOut );
762 dumpUnknown( 4 );
763 sal_uInt32 nTabFlags = dumpHex< sal_uInt32 >( "tab-flags", "COMCTL-TABSTRIP-TABFLAGS" );
764 if( nTabFlags & 0x01 ) dumpUniString32( "caption" );
765 if( nTabFlags & 0x02 ) dumpUniString32( "key" );
766 if( nTabFlags & 0x04 ) dumpUniString32( "tag" );
767 if( nTabFlags & 0x08 ) dumpUniString32( "tooltip" );
768 dumpDec< sal_uInt16 >( "image-id" );
772 ComCtlTreeViewObject::ComCtlTreeViewObject( const InputObjectBase& rParent, sal_uInt16 nVersion ) :
773 ComCtlObjectBase( rParent, 0xE6E17E8E, 0x6AC13CB1, nVersion, true, true ),
774 mnStringFlags( 0 )
778 void ComCtlTreeViewObject::implDumpProperties()
780 dumpHex< sal_uInt32 >( "flags", "COMCTL-TREEVIEW-FLAGS" );
781 dumpDec< sal_Int32 >( "indentation", "CONV-HMM-TO-CM" );
782 if( mnVersion == 6 )
783 dumpHex< sal_uInt32 >( "flags-2", "COMCTL-TREEVIEW-FLAGS2" );
784 mnStringFlags = dumpHex< sal_uInt32 >( "string-flags", "COMCTL-TREEVIEW-STRINGFLAGS" );
787 void ComCtlTreeViewObject::implDumpCommonExtra( sal_Int64 /*nEndPos*/ )
789 dumpOleColor( "text-color" );
790 dumpOleColor( "back-color" );
791 dumpUnknown( 4 );
792 if( mnStringFlags & 0x02 )
793 dumpUniString32( "image-list" );
794 dumpUniString32( "path-separator" );
797 ComCtlStatusBarObject::ComCtlStatusBarObject( const InputObjectBase& rParent, sal_uInt16 nVersion ) :
798 ComCtlObjectBase( rParent, 0xE6E17E88, SAL_MAX_UINT32, nVersion, true, true )
802 void ComCtlStatusBarObject::implDumpProperties()
804 dumpBool< sal_Int32 >( "style-simple-text" );
805 dumpBool< sal_Int16 >( "show-tips" );
806 dumpUnknown( 2 );
809 void ComCtlStatusBarObject::implDumpCommonExtra( sal_Int64 /*nEndPos*/ )
811 dumpUnknown( 12 );
812 dumpUniString32( "simple-text" );
813 sal_Int32 nPanelCount = dumpDec< sal_Int32 >( "panel-count" );
814 mxOut->resetItemIndex();
815 for( sal_Int32 nPanelIndex = 0; (nPanelIndex < nPanelCount) && !mxStrm->isEof(); ++nPanelIndex )
817 writeEmptyItem( "#panel" );
818 IndentGuard aIndGuard( mxOut );
819 dumpHex< sal_uInt32 >( "panel-flags", "COMCTL-STATUSBAR-PANELFLAGS" );
820 dumpDec< sal_Int32 >( "current-width", "CONV-HMM-TO-CM" );
821 dumpDec< sal_Int32 >( "minimal-width", "CONV-HMM-TO-CM" );
822 sal_uInt32 nTextFlags = dumpHex< sal_uInt32 >( "text-flags", "COMCTL-STATUSBAR-TEXTFLAGS" );
823 if( nTextFlags & 0x01 ) dumpUniString32( "text" );
824 if( nTextFlags & 0x02 ) dumpUniString32( "vis-text" );
825 if( nTextFlags & 0x04 ) dumpUniString32( "key" );
826 if( nTextFlags & 0x08 ) dumpUniString32( "tag" );
827 if( nTextFlags & 0x10 ) dumpUniString32( "tooltip" );
831 void ComCtlStatusBarObject::implDumpCommonTrailing()
833 sal_Int32 nImageCount = dumpDec< sal_Int32 >( "image-count" );
834 mxOut->resetItemIndex();
835 for( sal_Int32 nImageIndex = 0; (nImageIndex < nImageCount) && !mxStrm->isEof(); ++nImageIndex )
837 writeEmptyItem( "#image" );
838 IndentGuard aIndGuard( mxOut );
839 dumpDec< sal_Int32 >( "panel-index" );
840 StdPicObject( *this ).dump();
844 void AxPropertyObjectBase::construct( const ObjectBase& rParent,
845 const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName, const String& rPropNameList, bool b64BitPropFlags )
847 OleInputObjectBase::construct( rParent, rxStrm, rSysFileName );
848 constructAxPropObj( rPropNameList, b64BitPropFlags );
851 void AxPropertyObjectBase::construct( const InputObjectBase& rParent,
852 const String& rPropNameList, bool b64BitPropFlags )
854 OleInputObjectBase::construct( rParent );
855 constructAxPropObj( rPropNameList, b64BitPropFlags );
858 bool AxPropertyObjectBase::implIsValid() const
860 return OleInputObjectBase::implIsValid() && mxStrm->isSeekable();
863 void AxPropertyObjectBase::implDump()
865 mbValid = true;
866 // header
867 setAlignAnchor();
868 dumpVersion();
869 sal_uInt16 nSize = dumpDec< sal_uInt16 >( "size" );
870 mnPropertiesEnd = mxStrm->tell() + nSize;
871 // property flags
872 maLargeProps.clear();
873 maStreamProps.clear();
874 mnPropFlags = dumpHex< sal_Int64, sal_uInt32 >( mb64BitPropFlags, "properties", mxPropNames );
875 mnCurrProp = 0;
876 // properties
877 dumpShortProperties();
878 dumpLargeProperties();
879 setAlignAnchor();
880 if( ensureValid() )
881 implDumpExtended();
884 void AxPropertyObjectBase::implDumpShortProperties()
888 void AxPropertyObjectBase::implDumpExtended()
892 bool AxPropertyObjectBase::ensureValid( bool bCondition )
894 if( mbValid && (!bCondition || mxStrm->isEof()) )
896 if( !bCondition )
897 writeInfoItem( "state", OOX_DUMP_ERRASCII( "format-error" ) );
898 mbValid = false;
900 return mbValid;
903 void AxPropertyObjectBase::setAlignAnchor()
905 mnPropertiesStart = mxStrm->tell();
908 bool AxPropertyObjectBase::startNextProperty()
910 if( mnCurrProp == 0 ) mnCurrProp = 1; else mnCurrProp <<= 1;
911 bool bHasProp = getFlag( mnPropFlags, mnCurrProp );
912 setFlag( mnPropFlags, mnCurrProp, false );
913 return ensureValid() && bHasProp;
916 OUString AxPropertyObjectBase::getPropertyName() const
918 return cfg().getName( mxPropNames, mnCurrProp );
921 sal_uInt32 AxPropertyObjectBase::dumpFlagsProperty( sal_uInt32 nDefault, const sal_Char* pcNameList )
923 if( startNextProperty() )
925 alignInput< sal_uInt32 >();
926 return dumpHex< sal_uInt32 >( getPropertyName(), pcNameList );
928 return nDefault;
931 sal_uInt32 AxPropertyObjectBase::dumpColorProperty( sal_uInt32 nDefault )
933 if( startNextProperty() )
935 alignInput< sal_uInt32 >();
936 return dumpOleColor( getPropertyName() );
938 return nDefault;
941 sal_Unicode AxPropertyObjectBase::dumpUnicodeProperty()
943 if( startNextProperty() )
945 alignInput< sal_uInt16 >();
946 return dumpUnicode( getPropertyName() );
948 return '\0';
951 void AxPropertyObjectBase::dumpUnknownProperty()
953 if( startNextProperty() )
954 ensureValid( false );
957 void AxPropertyObjectBase::dumpPosProperty()
959 if( startNextProperty() )
960 maLargeProps.emplace_back( LargeProperty::PROPTYPE_POS, getPropertyName(), 8 );
963 void AxPropertyObjectBase::dumpSizeProperty()
965 if( startNextProperty() )
966 maLargeProps.emplace_back( LargeProperty::PROPTYPE_SIZE, getPropertyName(), 8 );
969 void AxPropertyObjectBase::dumpGuidProperty( OUString* pValue )
971 if( startNextProperty() )
972 maLargeProps.emplace_back( LargeProperty::PROPTYPE_GUID, getPropertyName(), 16, pValue );
975 void AxPropertyObjectBase::dumpStringProperty( OUString* pValue )
977 if( startNextProperty() )
979 alignInput< sal_uInt32 >();
980 sal_uInt32 nLen = dumpHex< sal_uInt32 >( getPropertyName(), "AX-STRINGLEN" );
981 maLargeProps.emplace_back( LargeProperty::PROPTYPE_STRING, getPropertyName(), nLen, pValue );
985 void AxPropertyObjectBase::dumpStringArrayProperty()
987 if( startNextProperty() )
989 alignInput< sal_uInt32 >();
990 sal_uInt32 nLen = dumpHex< sal_uInt32 >( getPropertyName(), "CONV-DEC" );
991 maLargeProps.emplace_back( LargeProperty::PROPTYPE_STRINGARRAY, getPropertyName(), nLen );
995 void AxPropertyObjectBase::dumpStreamProperty()
997 if( startNextProperty() )
999 alignInput< sal_uInt16 >();
1000 sal_uInt16 nData = dumpHex< sal_uInt16 >( getPropertyName() );
1001 maStreamProps.emplace_back( getPropertyName(), nData );
1005 void AxPropertyObjectBase::dumpEmbeddedFont()
1007 if( ensureValid() )
1009 writeEmptyItem( "embedded-fontdata" );
1010 IndentGuard aIndGuard( mxOut );
1011 AxCFontNewObject( *this ).dump();
1015 void AxPropertyObjectBase::dumpToPosition( sal_Int64 nPos )
1017 dumpRemainingTo( nPos );
1018 mbValid = true;
1019 ensureValid();
1022 void AxPropertyObjectBase::constructAxPropObj( const String& rPropNameList, bool b64BitPropFlags )
1024 if( OleInputObjectBase::implIsValid() )
1026 mxPropNames = cfg().getNameList( rPropNameList );
1027 mb64BitPropFlags = b64BitPropFlags;
1028 mbValid = true;
1032 void AxPropertyObjectBase::dumpVersion()
1034 ItemGuard aItem( mxOut, "version" );
1035 sal_uInt8 nMinor = mxStrm->readuChar();
1036 sal_uInt8 nMajor = mxStrm->readuChar();
1037 mxOut->writeDec( nMajor );
1038 mxOut->writeChar( '.' );
1039 mxOut->writeDec( nMinor );
1042 OUString AxPropertyObjectBase::dumpString( const String& rName, sal_uInt32 nSize, bool bArray )
1044 bool bCompressed = getFlag( nSize, AX_STRING_COMPRESSED );
1045 sal_uInt32 nBufSize = extractValue< sal_uInt32 >( nSize, 0, 31 );
1046 OUString aString = bCompressed ?
1047 dumpCharArray( rName, nBufSize, RTL_TEXTENCODING_ISO_8859_1 ) :
1048 dumpUnicodeArray( rName, bArray ? nBufSize : (nBufSize / 2) );
1049 alignInput< sal_Int32 >();
1050 return aString;
1053 void AxPropertyObjectBase::dumpShortProperties()
1055 if( ensureValid() )
1057 writeEmptyItem( "short-properties" );
1058 IndentGuard aIndGuard( mxOut );
1059 implDumpShortProperties();
1060 alignInput< sal_uInt32 >();
1064 void AxPropertyObjectBase::dumpLargeProperties()
1066 if( ensureValid( mnPropFlags == 0 ) && !maLargeProps.empty() )
1068 writeEmptyItem( "large-properties" );
1069 IndentGuard aIndGuard( mxOut );
1070 for (auto const& largeProp : maLargeProps)
1072 if (!ensureValid())
1073 break;
1074 switch( largeProp.mePropType )
1076 case LargeProperty::PROPTYPE_POS:
1078 MultiItemsGuard aMultiGuard( mxOut );
1079 writeEmptyItem( largeProp.maItemName );
1080 dumpDec< sal_Int32 >( "top", "CONV-HMM-TO-CM" );
1081 dumpDec< sal_Int32 >( "left", "CONV-HMM-TO-CM" );
1083 break;
1084 case LargeProperty::PROPTYPE_SIZE:
1086 MultiItemsGuard aMultiGuard( mxOut );
1087 writeEmptyItem( largeProp.maItemName );
1088 dumpDec< sal_Int32 >( "width", "CONV-HMM-TO-CM" );
1089 dumpDec< sal_Int32 >( "height", "CONV-HMM-TO-CM" );
1091 break;
1092 case LargeProperty::PROPTYPE_GUID:
1094 OUString aGuid = dumpGuid( largeProp.maItemName );
1095 if( largeProp.mpItemValue )
1096 *largeProp.mpItemValue = cfg().getStringOption( aGuid, OUString() );
1098 break;
1099 case LargeProperty::PROPTYPE_STRING:
1101 OUString aString = dumpString( largeProp.maItemName, largeProp.mnDataSize, false );
1102 if( largeProp.mpItemValue )
1103 *largeProp.mpItemValue = aString;
1105 break;
1106 case LargeProperty::PROPTYPE_STRINGARRAY:
1108 writeEmptyItem( largeProp.maItemName );
1109 IndentGuard aIndGuard2( mxOut );
1110 mxOut->resetItemIndex();
1111 sal_Int64 nEndPos = mxStrm->tell() + largeProp.mnDataSize;
1112 while( mxStrm->tell() < nEndPos )
1114 MultiItemsGuard aMultiGuard( mxOut );
1115 sal_uInt32 nDataSize = dumpHex< sal_uInt32 >( "#flags", "AX-ARRAYSTRINGLEN" );
1116 dumpString( "string", nDataSize, true );
1118 dumpToPosition( nEndPos );
1120 break;
1124 dumpToPosition( mnPropertiesEnd );
1126 if( ensureValid() && !maStreamProps.empty() )
1128 writeEmptyItem( "stream-properties" );
1129 IndentGuard aIndGuard( mxOut );
1130 for (auto const& streamProp : maStreamProps)
1132 if (!ensureValid())
1133 break;
1134 writeEmptyItem( streamProp.maItemName );
1135 if( ensureValid( streamProp.mnData == 0xFFFF ) )
1137 IndentGuard aIndGuard2( mxOut );
1138 OUString aClassName = cfg().getStringOption( dumpGuid(), OUString() );
1139 if ( aClassName == "StdFont" )
1140 StdFontObject( *this ).dump();
1141 else if ( aClassName == "StdPic" )
1142 StdPicObject( *this ).dump();
1143 else if ( aClassName == "CFontNew" )
1144 AxCFontNewObject( *this ).dump();
1145 else
1146 ensureValid( false );
1152 AxCFontNewObject::AxCFontNewObject( const InputObjectBase& rParent )
1154 AxPropertyObjectBase::construct( rParent, "AX-CFONTNEW-PROPERTIES" );
1157 void AxCFontNewObject::implDumpShortProperties()
1159 dumpStringProperty();
1160 dumpFlagsProperty( 0, "AX-CFONTNEW-FLAGS" );
1161 dumpDecProperty< sal_Int32 >( 160 );
1162 dumpDecProperty< sal_Int32 >( 0 );
1163 dumpDecProperty< sal_uInt8 >( WINDOWS_CHARSET_DEFAULT, "CHARSET" );
1164 dumpDecProperty< sal_uInt8 >( 0, "FONT-PITCHFAMILY" );
1165 dumpDecProperty< sal_uInt8 >( 1, "AX-CFONTNEW-ALIGNMENT" );
1166 dumpDecProperty< sal_uInt16 >( 400, "FONT-WEIGHT" );
1169 AxColumnInfoObject::AxColumnInfoObject( const InputObjectBase& rParent )
1171 AxPropertyObjectBase::construct( rParent, "AX-COLUMNINFO-PROPERTIES" );
1174 void AxColumnInfoObject::implDumpShortProperties()
1176 dumpDecProperty< sal_Int32 >( -1, "CONV-HMM-TO-CM" );
1179 AxCommandButtonObject::AxCommandButtonObject( const InputObjectBase& rParent )
1181 AxPropertyObjectBase::construct( rParent, "AX-COMMANDBUTTON-PROPERTIES" );
1184 void AxCommandButtonObject::implDumpShortProperties()
1186 dumpColorProperty( 0x80000012 );
1187 dumpColorProperty( 0x80000008 );
1188 dumpFlagsProperty( 0x0000001B );
1189 dumpStringProperty();
1190 dumpImagePosProperty();
1191 dumpSizeProperty();
1192 dumpMousePtrProperty();
1193 dumpStreamProperty();
1194 dumpUnicodeProperty();
1195 dumpBoolProperty();
1196 dumpStreamProperty();
1199 void AxCommandButtonObject::implDumpExtended()
1201 dumpEmbeddedFont();
1204 AxMorphControlObject::AxMorphControlObject( const InputObjectBase& rParent )
1206 AxPropertyObjectBase::construct( rParent, "AX-MORPH-PROPERTIES", true );
1209 void AxMorphControlObject::implDumpShortProperties()
1211 dumpFlagsProperty( 0x2C80081B );
1212 dumpColorProperty( 0x80000005 );
1213 dumpColorProperty( 0x80000008 );
1214 dumpDecProperty< sal_uInt32 >( 0 );
1215 dumpBorderStyleProperty< sal_uInt8 >( 0 );
1216 dumpDecProperty< sal_uInt8 >( 0, "AX-MORPH-SCROLLBARS" );
1217 mnCtrlType = dumpDecProperty< sal_uInt8 >( 1, "AX-MORPH-CONTROLTYPE" );
1218 dumpMousePtrProperty();
1219 dumpSizeProperty();
1220 dumpUnicodeProperty();
1221 dumpDecProperty< sal_uInt32 >( 0, "CONV-HMM-TO-CM" );
1222 dumpDecProperty< sal_uInt16 >( 1, "AX-MORPH-BOUNDCOLUMN" );
1223 dumpDecProperty< sal_Int16 >( -1, "AX-MORPH-TEXTCOLUMN" );
1224 dumpDecProperty< sal_Int16 >( 1, "AX-MORPH-COLUMNCOUNT" );
1225 dumpDecProperty< sal_uInt16 >( 8 );
1226 mnColInfoCount = dumpDecProperty< sal_uInt16 >( 1 );
1227 dumpDecProperty< sal_uInt8 >( 2, "AX-MORPH-MATCHENTRYTYPE" );
1228 dumpDecProperty< sal_uInt8 >( 0, "AX-MORPH-LISTSTYLE" );
1229 dumpDecProperty< sal_uInt8 >( 0, "AX-MORPH-SHOWDROPDOWNMODE" );
1230 dumpUnknownProperty();
1231 dumpDecProperty< sal_uInt8 >( 1, "AX-MORPH-DROPDOWNSTYLE" );
1232 dumpDecProperty< sal_uInt8 >( 0, "AX-MORPH-SELECTIONTYPE" );
1233 dumpStringProperty();
1234 dumpStringProperty();
1235 dumpImagePosProperty();
1236 dumpColorProperty( 0x80000006 );
1237 dumpSpecialEffectProperty< sal_uInt32 >( 2 );
1238 dumpStreamProperty();
1239 dumpStreamProperty();
1240 dumpUnicodeProperty();
1241 dumpUnknownProperty();
1242 dumpBoolProperty();
1243 dumpStringProperty();
1246 void AxMorphControlObject::implDumpExtended()
1248 dumpEmbeddedFont();
1249 dumpColumnInfos();
1252 void AxMorphControlObject::dumpColumnInfos()
1254 if( ensureValid() && (mnColInfoCount > 0) && ((mnCtrlType == 2) || (mnCtrlType == 3)) )
1256 mxOut->resetItemIndex();
1257 for( sal_uInt16 nIdx = 0; ensureValid() && (nIdx < mnColInfoCount); ++nIdx )
1259 writeEmptyItem( "#column-info" );
1260 IndentGuard aIndGuard( mxOut );
1261 AxColumnInfoObject( *this ).dump();
1266 AxLabelObject::AxLabelObject( const InputObjectBase& rParent )
1268 AxPropertyObjectBase::construct( rParent, "AX-LABEL-PROPERTIES" );
1271 void AxLabelObject::implDumpShortProperties()
1273 dumpColorProperty( 0x80000012 );
1274 dumpColorProperty( 0x8000000F );
1275 dumpFlagsProperty( 0x0080001B );
1276 dumpStringProperty();
1277 dumpImagePosProperty();
1278 dumpSizeProperty();
1279 dumpMousePtrProperty();
1280 dumpColorProperty( 0x80000006 );
1281 dumpBorderStyleProperty< sal_uInt16 >( 0 );
1282 dumpSpecialEffectProperty< sal_uInt16 >( 0 );
1283 dumpStreamProperty();
1284 dumpUnicodeProperty();
1285 dumpStreamProperty();
1288 void AxLabelObject::implDumpExtended()
1290 dumpEmbeddedFont();
1293 AxImageObject::AxImageObject( const InputObjectBase& rParent )
1295 AxPropertyObjectBase::construct( rParent, "AX-IMAGE-PROPERTIES" );
1298 void AxImageObject::implDumpShortProperties()
1300 dumpUnknownProperty();
1301 dumpUnknownProperty();
1302 dumpBoolProperty();
1303 dumpColorProperty( 0x80000006 );
1304 dumpColorProperty( 0x8000000F );
1305 dumpBorderStyleProperty< sal_uInt8 >( 1 );
1306 dumpMousePtrProperty();
1307 dumpImageSizeModeProperty();
1308 dumpSpecialEffectProperty< sal_uInt8 >( 0 );
1309 dumpSizeProperty();
1310 dumpStreamProperty();
1311 dumpImageAlignProperty();
1312 dumpBoolProperty();
1313 dumpFlagsProperty( 0x0000001B );
1314 dumpStreamProperty();
1317 AxScrollBarObject::AxScrollBarObject( const InputObjectBase& rParent )
1319 AxPropertyObjectBase::construct( rParent, "AX-SCROLLBAR-PROPERTIES" );
1322 void AxScrollBarObject::implDumpShortProperties()
1324 dumpColorProperty( 0x80000012 );
1325 dumpColorProperty( 0x8000000F );
1326 dumpFlagsProperty( 0x0000001B );
1327 dumpSizeProperty();
1328 dumpMousePtrProperty();
1329 dumpDecProperty< sal_Int32 >( 0 );
1330 dumpDecProperty< sal_Int32 >( 32767 );
1331 dumpDecProperty< sal_Int32 >( 0 );
1332 dumpHexProperty< sal_uInt32 >( 0 );
1333 dumpEnabledProperty();
1334 dumpEnabledProperty();
1335 dumpDecProperty< sal_Int32 >( 1 );
1336 dumpDecProperty< sal_Int32 >( 1 );
1337 dumpOrientationProperty();
1338 dumpDecProperty< sal_Int16 >( -1, "AX-SCROLLBAR-PROPTHUMB" );
1339 dumpDelayProperty();
1340 dumpStreamProperty();
1343 AxSpinButtonObject::AxSpinButtonObject( const InputObjectBase& rParent )
1345 AxPropertyObjectBase::construct( rParent, "AX-SPINBUTTON-PROPERTIES" );
1348 void AxSpinButtonObject::implDumpShortProperties()
1350 dumpColorProperty( 0x80000012 );
1351 dumpColorProperty( 0x8000000F );
1352 dumpFlagsProperty( 0x0000001B );
1353 dumpSizeProperty();
1354 dumpHexProperty< sal_uInt32 >( 0 );
1355 dumpDecProperty< sal_Int32 >( 0 );
1356 dumpDecProperty< sal_Int32 >( 100 );
1357 dumpDecProperty< sal_Int32 >( 0 );
1358 dumpEnabledProperty();
1359 dumpEnabledProperty();
1360 dumpDecProperty< sal_Int32 >( 1 );
1361 dumpOrientationProperty();
1362 dumpDelayProperty();
1363 dumpStreamProperty();
1364 dumpMousePtrProperty();
1367 AxTabStripObject::AxTabStripObject( const InputObjectBase& rParent )
1369 AxPropertyObjectBase::construct( rParent, "AX-TABSTRIP-PROPERTIES" );
1372 void AxTabStripObject::implDumpShortProperties()
1374 dumpDecProperty< sal_Int32 >( -1 );
1375 dumpColorProperty( 0x8000000F );
1376 dumpColorProperty( 0x80000012 );
1377 dumpUnknownProperty();
1378 dumpSizeProperty();
1379 dumpStringArrayProperty();
1380 dumpMousePtrProperty();
1381 dumpUnknownProperty();
1382 dumpDecProperty< sal_uInt32 >( 0, "AX-TABSTRIP-ORIENTATION" );
1383 dumpDecProperty< sal_uInt32 >( 0, "AX-TABSTRIP-TABSTYLE" );
1384 dumpBoolProperty();
1385 dumpHmmProperty();
1386 dumpHmmProperty();
1387 dumpBoolProperty();
1388 dumpUnknownProperty();
1389 dumpStringArrayProperty();
1390 dumpUnknownProperty();
1391 dumpStringArrayProperty();
1392 dumpFlagsProperty( 0x0000001B );
1393 dumpBoolProperty();
1394 dumpDecProperty< sal_uInt32 >( 0 );
1395 dumpStringArrayProperty();
1396 mnTabFlagCount = dumpDecProperty< sal_Int32 >( 0 );
1397 dumpStringArrayProperty();
1398 dumpStreamProperty();
1401 void AxTabStripObject::implDumpExtended()
1403 dumpEmbeddedFont();
1404 if( mnTabFlagCount > 0 )
1406 writeEmptyItem( "tab-flags" );
1407 IndentGuard aIndGuard( mxOut );
1408 mxOut->resetItemIndex();
1409 for( sal_Int32 nIdx = 0; ensureValid() && (nIdx < mnTabFlagCount); ++nIdx )
1410 dumpHex< sal_uInt32 >( "#flags", "AX-TABSTRIP-FLAGS" );
1414 FormControlStreamObject::FormControlStreamObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName, const OUString* pProgId )
1416 construct( rParent, rxStrm, rSysFileName );
1417 constructFormCtrlStrmObj( pProgId );
1420 FormControlStreamObject::FormControlStreamObject( const OutputObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString* pProgId )
1422 construct( rParent, rxStrm );
1423 constructFormCtrlStrmObj( pProgId );
1426 void FormControlStreamObject::implDump()
1428 if( mbReadGuid )
1429 maProgId = cfg().getStringOption( dumpGuid(), OUString() );
1431 if( !maProgId.isEmpty() && !mxStrm->isEof() )
1433 if ( maProgId == "Forms.CommandButton.1" )
1434 AxCommandButtonObject( *this ).dump();
1435 else if( maProgId == "Forms.TextBox.1" ||
1436 maProgId == "Forms.ListBox.1" ||
1437 maProgId == "Forms.ComboBox.1" ||
1438 maProgId == "Forms.CheckBox.1" ||
1439 maProgId == "Forms.OptionButton.1" ||
1440 maProgId == "Forms.ToggleButton.1" ||
1441 maProgId == "RefEdit.Ctrl" )
1442 AxMorphControlObject( *this ).dump();
1443 else if ( maProgId == "Forms.Label.1" )
1444 AxLabelObject( *this ).dump();
1445 else if ( maProgId == "Forms.Image.1" )
1446 AxImageObject( *this ).dump();
1447 else if ( maProgId == "Forms.ScrollBar.1" )
1448 AxScrollBarObject( *this ).dump();
1449 else if ( maProgId == "Forms.SpinButton.1" )
1450 AxSpinButtonObject( *this ).dump();
1451 else if ( maProgId == "Forms.TabStrip.1" )
1452 AxTabStripObject( *this ).dump();
1453 else if ( maProgId == "MSComCtl2.FlatScrollBar.2" )
1454 ComCtlScrollBarObject( *this, 6 ).dump();
1455 else if ( maProgId == "COMCTL.ProgCtrl.1" )
1456 ComCtlProgressBarObject( *this, 5 ).dump();
1457 else if ( maProgId == "MSComctlLib.ProgCtrl.2" )
1458 ComCtlProgressBarObject( *this, 6 ).dump();
1459 else if ( maProgId == "COMCTL.Slider.1" )
1460 ComCtlSliderObject( *this, 5 ).dump();
1461 else if ( maProgId == "MSComctlLib.Slider.2" )
1462 ComCtlSliderObject( *this, 6 ).dump();
1463 else if ( maProgId == "ComCtl2.UpDown.1" )
1464 ComCtlUpDownObject( *this, 5 ).dump();
1465 else if ( maProgId == "MSComCtl2.UpDown.2" )
1466 ComCtlUpDownObject( *this, 6 ).dump();
1467 else if ( maProgId == "COMCTL.ImageListCtrl.1" )
1468 ComCtlImageListObject( *this, 5 ).dump();
1469 else if ( maProgId == "MSComctlLib.ImageListCtrl.2" )
1470 ComCtlImageListObject( *this, 6 ).dump();
1471 else if ( maProgId == "COMCTL.TabStrip.1" )
1472 ComCtlTabStripObject( *this, 5 ).dump();
1473 else if ( maProgId == "MSComctlLib.TabStrip.2" )
1474 ComCtlTabStripObject( *this, 6 ).dump();
1475 else if ( maProgId == "COMCTL.TreeCtrl.1" )
1476 ComCtlTreeViewObject( *this, 5 ).dump();
1477 else if ( maProgId == "MSComctlLib.TreeCtrl.2" )
1478 ComCtlTreeViewObject( *this, 6 ).dump();
1479 else if ( maProgId == "COMCTL.SBarCtrl.1" )
1480 ComCtlStatusBarObject( *this, 5 ).dump();
1481 else if ( maProgId == "StdPic" )
1482 StdPicObject( *this ).dump();
1484 dumpRemainingStream();
1487 void FormControlStreamObject::constructFormCtrlStrmObj( const OUString* pProgId )
1489 mbReadGuid = pProgId == nullptr;
1490 if( pProgId )
1491 maProgId = *pProgId;
1494 VbaFormClassInfoObject::VbaFormClassInfoObject( const InputObjectBase& rParent, VbaFormSharedData& rFormData ) :
1495 mrFormData( rFormData )
1497 AxPropertyObjectBase::construct( rParent, "VBA-CLASSINFO-PROPERTIES" );
1500 void VbaFormClassInfoObject::implDumpShortProperties()
1502 mrFormData.maClassInfoProgIds.emplace_back( );
1503 dumpGuidProperty( &mrFormData.maClassInfoProgIds.back() );
1504 dumpGuidProperty();
1505 dumpUnknownProperty();
1506 dumpGuidProperty();
1507 dumpFlagsProperty( 0, "VBA-CLASSINFO-FLAGS" );
1508 dumpDecProperty< sal_uInt32 >( 0 );
1509 dumpDecProperty< sal_Int32 >( -1 );
1510 dumpDecProperty< sal_uInt16 >( 0 );
1511 dumpDecProperty< sal_uInt16 >( 0 );
1512 dumpDecProperty< sal_uInt16 >( 0, "OLEPROP-TYPE" );
1513 dumpDecProperty< sal_uInt16 >( 0 );
1514 dumpDecProperty< sal_uInt16 >( 0 );
1515 dumpDecProperty< sal_uInt16 >( 0, "OLEPROP-TYPE" );
1516 dumpDecProperty< sal_Int32 >( -1 );
1517 dumpDecProperty< sal_uInt16 >( 0 );
1520 namespace {
1522 const sal_uInt32 VBA_FORMSITE_OBJSTREAM = 0x0010;
1524 const sal_uInt16 VBA_FORMSITE_CLASSTABLEINDEX = 0x8000;
1525 const sal_uInt16 VBA_FORMSITE_CLASSTABLEMASK = 0x7FFF;
1527 } // namespace
1529 VbaFormSiteObject::VbaFormSiteObject( const InputObjectBase& rParent, VbaFormSharedData& rFormData ) :
1530 mrFormData( rFormData )
1532 AxPropertyObjectBase::construct( rParent, "VBA-FORMSITE-PROPERTIES" );
1535 void VbaFormSiteObject::implDumpShortProperties()
1537 VbaFormSiteInfo aSiteInfo;
1538 dumpStringProperty();
1539 dumpStringProperty();
1540 sal_Int32 nId = dumpDecProperty< sal_Int32 >( 0 );
1541 dumpDecProperty< sal_Int32 >( 0 );
1542 sal_uInt32 nFlags = dumpFlagsProperty( 0x00000033, "VBA-FORMSITE-FLAGS" );
1543 sal_uInt32 nLength = dumpDecProperty< sal_uInt32 >( 0 );
1544 dumpDecProperty< sal_Int16 >( -1 );
1545 sal_uInt16 nClassId = dumpHexProperty< sal_uInt16 >( 0x7FFF, "VBA-FORMSITE-CLASSIDCACHE" );
1546 dumpPosProperty();
1547 dumpDecProperty< sal_uInt16 >( 0 );
1548 dumpUnknownProperty();
1549 dumpStringProperty();
1550 dumpStringProperty();
1551 dumpStringProperty();
1552 dumpStringProperty();
1554 sal_uInt16 nIndex = nClassId & VBA_FORMSITE_CLASSTABLEMASK;
1555 if( getFlag( nClassId, VBA_FORMSITE_CLASSTABLEINDEX ) )
1557 if( nIndex < mrFormData.maClassInfoProgIds.size() )
1558 aSiteInfo.maProgId = mrFormData.maClassInfoProgIds[ nIndex ];
1560 else
1562 if( cfg().hasName( "VBA-FORMSITE-CLASSNAMES", nIndex ) )
1563 aSiteInfo.maProgId = cfg().getName( "VBA-FORMSITE-CLASSNAMES", nIndex );
1565 aSiteInfo.mnId = nId;
1566 aSiteInfo.mnLength = nLength;
1567 aSiteInfo.mbInStream = getFlag( nFlags, VBA_FORMSITE_OBJSTREAM );
1569 mrFormData.maSiteInfos.push_back( aSiteInfo );
1572 VbaFormDesignExtObject::VbaFormDesignExtObject( const InputObjectBase& rParent )
1574 AxPropertyObjectBase::construct( rParent, "VBA-FORMDESIGNEXT-PROPERTIES" );
1577 void VbaFormDesignExtObject::implDumpShortProperties()
1579 dumpFlagsProperty( 0x00015F55, "VBA-FORMDESIGNEXT-FLAGS" );
1580 dumpHmmProperty();
1581 dumpHmmProperty();
1582 dumpDecProperty< sal_Int8 >( 0, "VBA-FORMDESIGNEXT-CLICKCTRLMODE" );
1583 dumpDecProperty< sal_Int8 >( 0, "VBA-FORMDESIGNEXT-DBLCLICKCTRLMODE" );
1586 namespace {
1588 const sal_uInt32 AX_FORM_HASDESIGNEXTENDER = 0x00004000;
1589 const sal_uInt32 AX_FORM_SKIPCLASSTABLE = 0x00008000;
1591 const sal_uInt8 AX_FORM_SITECOUNTTYPE_COUNT = 0x80;
1592 const sal_uInt8 AX_FORM_SITECOUNTTYPE_MASK = 0x7F;
1594 } // namespace
1596 VbaFStreamObject::VbaFStreamObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName, VbaFormSharedData& rFormData ) :
1597 mrFormData( rFormData )
1599 AxPropertyObjectBase::construct( rParent, rxStrm, rSysFileName, "VBA-FORM-PROPERTIES" );
1602 void VbaFStreamObject::implDumpShortProperties()
1604 dumpUnknownProperty();
1605 dumpColorProperty( 0x8000000F );
1606 dumpColorProperty( 0x80000012 );
1607 dumpDecProperty< sal_uInt32 >( 0 );
1608 dumpUnknownProperty();
1609 dumpUnknownProperty();
1610 mnFlags = dumpFlagsProperty( 0x00000004, "VBA-FORM-FLAGS" );
1611 dumpBorderStyleProperty< sal_uInt8 >( 0 );
1612 dumpMousePtrProperty();
1613 dumpHexProperty< sal_uInt8 >( 0x0C, "VBA-FORM-SCROLLBARS" );
1614 dumpSizeProperty();
1615 dumpSizeProperty();
1616 dumpPosProperty();
1617 dumpDecProperty< sal_uInt32 >( 0 );
1618 dumpUnknownProperty();
1619 dumpStreamProperty();
1620 dumpDecProperty< sal_uInt8 >( 0, "VBA-FORM-CYCLE" );
1621 dumpSpecialEffectProperty< sal_uInt8 >( 0 );
1622 dumpColorProperty( 0x80000012 );
1623 dumpStringProperty();
1624 dumpStreamProperty();
1625 dumpStreamProperty();
1626 dumpDecProperty< sal_Int32 >( 100, "CONV-PERCENT" );
1627 dumpImageAlignProperty();
1628 dumpBoolProperty();
1629 dumpImageSizeModeProperty();
1630 dumpDecProperty< sal_uInt32 >( 0 );
1631 dumpDecProperty< sal_uInt32 >( 0 );
1634 void VbaFStreamObject::implDumpExtended()
1636 dumpClassInfos();
1637 dumpSiteData();
1638 dumpDesignExtender();
1639 dumpRemainingStream();
1642 void VbaFStreamObject::dumpClassInfos()
1644 if( ensureValid() && !getFlag( mnFlags, AX_FORM_SKIPCLASSTABLE ) )
1646 mxOut->emptyLine();
1647 sal_uInt16 nCount = dumpDec< sal_uInt16 >( "class-info-count" );
1648 mxOut->resetItemIndex();
1649 for( sal_uInt16 nIdx = 0; ensureValid() && (nIdx < nCount); ++nIdx )
1651 writeEmptyItem( "#class-info" );
1652 IndentGuard aIndGuard( mxOut );
1653 VbaFormClassInfoObject( *this, mrFormData ).dump();
1658 void VbaFStreamObject::dumpFormSites( sal_uInt32 nCount )
1660 mxOut->resetItemIndex();
1661 for( sal_uInt32 nIdx = 0; ensureValid() && (nIdx < nCount); ++nIdx )
1663 mxOut->emptyLine();
1664 writeEmptyItem( "#form-site" );
1665 IndentGuard aIndGuard( mxOut );
1666 VbaFormSiteObject( *this, mrFormData ).dump();
1670 void VbaFStreamObject::dumpSiteData()
1672 if( ensureValid() )
1674 mxOut->emptyLine();
1675 setAlignAnchor();
1676 sal_uInt32 nSiteCount = dumpDec< sal_uInt32 >( "site-count" );
1677 sal_uInt32 nSiteLength = dumpDec< sal_uInt32 >( "site-data-size" );
1678 sal_Int64 nEndPos = mxStrm->tell() + nSiteLength;
1679 if( ensureValid( nEndPos <= mxStrm->size() ) )
1681 mxOut->resetItemIndex();
1682 sal_uInt32 nSiteIdx = 0;
1683 while( ensureValid() && (nSiteIdx < nSiteCount) )
1685 mxOut->emptyLine();
1686 writeEmptyItem( "#site-info" );
1687 IndentGuard aIndGuard( mxOut );
1688 dumpDec< sal_uInt8 >( "depth" );
1689 sal_uInt8 nTypeCount = dumpHex< sal_uInt8 >( "type-count", "VBA-FORM-SITE-TYPECOUNT" );
1690 if( getFlag( nTypeCount, AX_FORM_SITECOUNTTYPE_COUNT ) )
1692 dumpDec< sal_uInt8 >( "repeated-type" );
1693 nSiteIdx += (nTypeCount & AX_FORM_SITECOUNTTYPE_MASK);
1695 else
1697 ++nSiteIdx;
1700 alignInput< sal_uInt32 >();
1701 dumpFormSites( nSiteCount );
1702 dumpToPosition( nEndPos );
1707 void VbaFStreamObject::dumpDesignExtender()
1709 if( ensureValid() && getFlag( mnFlags, AX_FORM_HASDESIGNEXTENDER ) )
1711 mxOut->emptyLine();
1712 writeEmptyItem( "design-extender" );
1713 IndentGuard aIndGuard( mxOut );
1714 VbaFormDesignExtObject( *this ).dump();
1718 VbaOStreamObject::VbaOStreamObject( const ObjectBase& rParent,
1719 const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName, VbaFormSharedData& rFormData ) :
1720 mrFormData( rFormData )
1722 OleInputObjectBase::construct( rParent, rxStrm, rSysFileName );
1725 void VbaOStreamObject::implDump()
1727 for (auto const& siteInfo : mrFormData.maSiteInfos)
1729 if (mxStrm->isEof())
1730 break;
1731 if( (siteInfo.mbInStream) && (siteInfo.mnLength > 0) )
1733 mxOut->emptyLine();
1734 writeDecItem( "control-id", siteInfo.mnId );
1735 writeInfoItem( "prog-id", siteInfo.maProgId );
1736 IndentGuard aIndGuard( mxOut );
1737 BinaryInputStreamRef xRelStrm( new RelativeInputStream( *mxStrm, siteInfo.mnLength ) );
1738 FormControlStreamObject( *this, xRelStrm, &siteInfo.maProgId ).dump();
1741 dumpRemainingStream();
1744 VbaPageObject::VbaPageObject( const InputObjectBase& rParent )
1746 AxPropertyObjectBase::construct( rParent, "VBA-PAGE-PROPERTIES" );
1749 void VbaPageObject::implDumpShortProperties()
1751 dumpUnknownProperty();
1752 dumpDecProperty< sal_uInt32 >( 0, "VBA-PAGE-TRANSITIONEFFECT" );
1753 dumpDecProperty< sal_uInt32 >( 0, "AX-CONV-MS" );
1756 VbaMultiPageObject::VbaMultiPageObject( const InputObjectBase& rParent )
1758 AxPropertyObjectBase::construct( rParent, "VBA-MULTIPAGE-PROPERTIES" );
1761 void VbaMultiPageObject::implDumpShortProperties()
1763 dumpUnknownProperty();
1764 mnPageCount = dumpDecProperty< sal_Int32 >( 0 );
1765 dumpDecProperty< sal_Int32 >( 0 );
1766 dumpBoolProperty();
1769 void VbaMultiPageObject::implDumpExtended()
1771 if( ensureValid() && (mnPageCount > 0) )
1773 writeEmptyItem( "page-ids" );
1774 IndentGuard aIndGuard( mxOut );
1775 mxOut->resetItemIndex();
1776 for( sal_Int32 nIdx = 0; ensureValid() && (nIdx < mnPageCount); ++nIdx )
1777 dumpDec< sal_Int32 >( "#id" );
1781 VbaXStreamObject::VbaXStreamObject( const ObjectBase& rParent,
1782 const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName, VbaFormSharedData& rFormData ) :
1783 mrFormData( rFormData )
1785 InputObjectBase::construct( rParent, rxStrm, rSysFileName );
1788 void VbaXStreamObject::implDump()
1790 for( size_t nIdx = 0, nCount = mrFormData.maSiteInfos.size(); !mxStrm->isEof() && (nIdx < nCount); ++nIdx )
1792 mxOut->emptyLine();
1793 writeEmptyItem( "page" );
1794 IndentGuard aIndGuard( mxOut );
1795 VbaPageObject( *this ).dump();
1797 if( !mxStrm->isEof() )
1799 mxOut->emptyLine();
1800 writeEmptyItem( "multi-page" );
1801 IndentGuard aIndGuard( mxOut );
1802 VbaMultiPageObject( *this ).dump();
1804 dumpRemainingStream();
1807 VbaContainerStorageObject::VbaContainerStorageObject( const ObjectBase& rParent, const StorageRef& rxStrg, const OUString& rSysPath ) :
1808 OleStorageObject( rParent, rxStrg, rSysPath )
1810 addPreferredStream( "f" );
1813 void VbaContainerStorageObject::implDumpStream( const Reference< XInputStream >& rxStrm, const OUString& rStrgPath, const OUString& rStrmName, const OUString& rSysFileName )
1815 if ( rStrmName == "f" )
1816 VbaFStreamObject( *this, rxStrm, rSysFileName, maFormData ).dump();
1817 else if ( rStrmName == "o" )
1818 VbaOStreamObject( *this, rxStrm, rSysFileName, maFormData ).dump();
1819 else if ( rStrmName == "x" )
1820 VbaXStreamObject( *this, rxStrm, rSysFileName, maFormData ).dump();
1821 else
1822 OleStorageObject::implDumpStream( rxStrm, rStrgPath, rStrmName, rSysFileName );
1825 void VbaContainerStorageObject::implDumpStorage( const StorageRef& rxStrg, const OUString& rStrgPath, const OUString& rSysPath )
1827 if( isFormStorage( rStrgPath ) )
1828 VbaContainerStorageObject( *this, rxStrg, rSysPath ).dump();
1829 else
1830 OleStorageObject( *this, rxStrg, rSysPath ).dump();
1833 bool VbaContainerStorageObject::isFormStorage( const OUString& rStrgPath ) const
1835 if( (rStrgPath.getLength() >= 3) && (rStrgPath[ 0 ] == 'i') )
1837 OUString aId = rStrgPath.copy( 1 );
1838 if( (aId.getLength() == 2) && (aId[ 0 ] == '0') )
1839 aId = aId.copy( 1 );
1840 sal_Int32 nId = aId.toInt32();
1841 if( (nId > 0) && (OUString::number( nId ) == aId) )
1842 for (auto const& siteInfo : maFormData.maSiteInfos)
1843 if( siteInfo.mnId == nId )
1844 return true;
1846 return false;
1849 VbaSharedData::VbaSharedData() :
1850 meTextEnc( RTL_TEXTENCODING_MS_1252 )
1854 bool VbaSharedData::isModuleStream( const OUString& rStrmName ) const
1856 return maStrmOffsets.count( rStrmName ) > 0;
1859 sal_Int32 VbaSharedData::getStreamOffset( const OUString& rStrmName ) const
1861 StreamOffsetMap::const_iterator aIt = maStrmOffsets.find( rStrmName );
1862 return (aIt == maStrmOffsets.end()) ? 0 : aIt->second;
1865 VbaDirStreamObject::VbaDirStreamObject( const ObjectBase& rParent,
1866 const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName, VbaSharedData& rVbaData ) :
1867 mrVbaData( rVbaData )
1869 mxInStrm = rxStrm;
1870 if( mxInStrm.get() )
1872 BinaryInputStreamRef xVbaStrm( new ::oox::ole::VbaInputStream( *mxInStrm ) );
1873 SequenceRecordObjectBase::construct( rParent, xVbaStrm, rSysFileName, "VBA-DIR-RECORD-NAMES", "VBA-DIR-SIMPLE-RECORDS" );
1877 bool VbaDirStreamObject::implIsValid() const
1879 return mxInStrm.get() && SequenceRecordObjectBase::implIsValid();
1882 bool VbaDirStreamObject::implReadRecordHeader( BinaryInputStream& rBaseStrm, sal_Int64& ornRecId, sal_Int64& ornRecSize )
1884 ornRecId = rBaseStrm.readuInt16();
1885 ornRecSize = rBaseStrm.readInt32();
1887 // for no obvious reason, PROJECTVERSION record contains size field of 4, but is 6 bytes long
1888 if( ornRecId == 9 )
1889 ornRecSize = 6;
1891 return !rBaseStrm.isEof();
1894 void VbaDirStreamObject::implDumpRecordBody()
1896 switch( getRecId() )
1898 case 0x0003:
1899 mrVbaData.meTextEnc = rtl_getTextEncodingFromWindowsCodePage( dumpDec< sal_uInt16 >( "codepage", "CODEPAGES" ) );
1900 break;
1901 case 0x0004:
1902 dumpByteString( "name" );
1903 break;
1904 case 0x0005:
1905 dumpByteString( "description" );
1906 break;
1907 case 0x0006:
1908 dumpByteString( "helpfile-path" );
1909 break;
1910 case 0x0009:
1911 dumpDec< sal_uInt32 >( "major" );
1912 dumpDec< sal_uInt16 >( "minor" );
1913 break;
1914 case 0x000C:
1915 dumpByteString( "constants" );
1916 break;
1917 case 0x000D:
1918 dumpByteStringWithLength( "lib-id" );
1919 dumpUnused( 6 );
1920 break;
1921 case 0x000E:
1922 dumpByteStringWithLength( "lib-id-absolute" );
1923 dumpByteStringWithLength( "lib-id-relative" );
1924 dumpDec< sal_uInt32 >( "major" );
1925 dumpDec< sal_uInt16 >( "minor" );
1926 break;
1927 case 0x0016:
1928 dumpByteString( "name" );
1929 break;
1930 case 0x0019:
1931 dumpByteString( "name" );
1932 maCurrStream.clear();
1933 mnCurrOffset = 0;
1934 break;
1935 case 0x001A:
1936 maCurrStream = dumpByteString( "stream-name" );
1937 break;
1938 case 0x001C:
1939 dumpByteString( "description" );
1940 break;
1941 case 0x002B:
1942 if( !maCurrStream.isEmpty() )
1943 mrVbaData.maStrmOffsets[ maCurrStream ] = mnCurrOffset;
1944 maCurrStream.clear();
1945 mnCurrOffset = 0;
1946 break;
1947 case 0x002F:
1948 dumpByteStringWithLength( "lib-id-twiddled" );
1949 dumpUnused( 6 );
1950 break;
1951 case 0x0030:
1952 dumpByteStringWithLength( "lib-id-extended" );
1953 dumpUnused( 6 );
1954 dumpGuid( "original-typelib" );
1955 dumpDec< sal_uInt32 >( "cookie" );
1956 break;
1957 case 0x0031:
1958 mnCurrOffset = dumpHex< sal_Int32 >( "stream-offset", "CONV-DEC" );
1959 break;
1960 case 0x0032:
1961 dumpUniString( "stream-name" );
1962 break;
1963 case 0x0033:
1964 dumpByteString( "lib-id-original" );
1965 break;
1966 case 0x003C:
1967 dumpUniString( "constants" );
1968 break;
1969 case 0x003D:
1970 dumpByteString( "helpfile-path" );
1971 break;
1972 case 0x003E:
1973 dumpUniString( "name" );
1974 break;
1975 case 0x0040:
1976 dumpUniString( "description" );
1977 break;
1978 case 0x0047:
1979 dumpUniString( "name" );
1980 break;
1981 case 0x0048:
1982 dumpUniString( "description" );
1983 break;
1987 OUString VbaDirStreamObject::dumpByteString( const String& rName )
1989 return dumpCharArray( rName, static_cast< sal_Int32 >( getRecSize() ), mrVbaData.meTextEnc );
1992 OUString VbaDirStreamObject::dumpUniString( const String& rName )
1994 return dumpUnicodeArray( rName, static_cast< sal_Int32 >( getRecSize() / 2 ) );
1997 OUString VbaDirStreamObject::dumpByteStringWithLength( const String& rName )
1999 return dumpCharArray( rName, mxStrm->readInt32(), mrVbaData.meTextEnc );
2002 VbaModuleStreamObject::VbaModuleStreamObject(
2003 const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm,
2004 const OUString& rSysFileName, VbaSharedData& rVbaData, sal_Int32 nStrmOffset ) :
2005 mrVbaData( rVbaData ),
2006 mnStrmOffset( nStrmOffset )
2008 InputObjectBase::construct( rParent, rxStrm, rSysFileName );
2011 void VbaModuleStreamObject::implDump()
2013 dumpBinary( "perf-cache", mnStrmOffset );
2014 mxOut->emptyLine();
2015 writeEmptyItem( "source-code" );
2016 IndentGuard aIndGuard( mxOut );
2017 BinaryInputStreamRef xVbaStrm( new ::oox::ole::VbaInputStream( *mxStrm ) );
2018 TextLineStreamObject( *this, xVbaStrm, mrVbaData.meTextEnc ).dump();
2021 VbaStorageObject::VbaStorageObject( const ObjectBase& rParent, const StorageRef& rxStrg, const OUString& rSysPath, VbaSharedData& rVbaData ) :
2022 OleStorageObject( rParent, rxStrg, rSysPath ),
2023 mrVbaData( rVbaData )
2025 addPreferredStream( "dir" );
2028 void VbaStorageObject::implDumpStream( const Reference< XInputStream >& rxStrm, const OUString& rStrgPath, const OUString& rStrmName, const OUString& rSysFileName )
2030 if( rStrgPath.isEmpty() && rStrmName == "dir" )
2031 VbaDirStreamObject( *this, rxStrm, rSysFileName, mrVbaData ).dump();
2032 else if( mrVbaData.isModuleStream( rStrmName ) )
2033 VbaModuleStreamObject( *this, rxStrm, rSysFileName, mrVbaData, mrVbaData.getStreamOffset( rStrmName ) ).dump();
2034 else
2035 OleStorageObject::implDumpStream( rxStrm, rStrgPath, rStrmName, rSysFileName );
2038 VbaFormStorageObject::VbaFormStorageObject( const ObjectBase& rParent, const StorageRef& rxStrg, const OUString& rSysPath, VbaSharedData& rVbaData ) :
2039 VbaContainerStorageObject( rParent, rxStrg, rSysPath ),
2040 mrVbaData( rVbaData )
2044 void VbaFormStorageObject::implDumpStream( const Reference< XInputStream >& rxStrm, const OUString& rStrgPath, const OUString& rStrmName, const OUString& rSysFileName )
2046 if ( rStrmName == "\003VBFrame" )
2047 TextLineStreamObject( *this, rxStrm, mrVbaData.meTextEnc, rSysFileName ).dump();
2048 else
2049 VbaContainerStorageObject::implDumpStream( rxStrm, rStrgPath, rStrmName, rSysFileName );
2052 VbaProjectStorageObject::VbaProjectStorageObject( const ObjectBase& rParent, const StorageRef& rxStrg, const OUString& rSysPath ) :
2053 OleStorageObject( rParent, rxStrg, rSysPath )
2055 addPreferredStorage( "VBA" );
2058 void VbaProjectStorageObject::implDumpStream( const Reference< XInputStream >& rxStrm, const OUString& rStrgPath, const OUString& rStrmName, const OUString& rSysFileName )
2060 if( rStrgPath.isEmpty() && rStrmName == "PROJECT" )
2061 TextLineStreamObject( *this, rxStrm, maVbaData.meTextEnc, rSysFileName ).dump();
2062 else
2063 OleStorageObject::implDumpStream( rxStrm, rStrgPath, rStrmName, rSysFileName );
2066 void VbaProjectStorageObject::implDumpStorage( const StorageRef& rxStrg, const OUString& rStrgPath, const OUString& rSysPath )
2068 if ( rStrgPath == "VBA" )
2069 VbaStorageObject( *this, rxStrg, rSysPath, maVbaData ).dump();
2070 else
2071 VbaFormStorageObject( *this, rxStrg, rSysPath, maVbaData ).dump();
2074 ActiveXStorageObject::ActiveXStorageObject( const ObjectBase& rParent, const StorageRef& rxStrg, const OUString& rSysPath ) :
2075 VbaContainerStorageObject( rParent, rxStrg, rSysPath )
2079 void ActiveXStorageObject::implDumpBaseStream( const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName )
2081 FormControlStreamObject( *this, rxStrm, rSysFileName ).dump();
2084 } // namespace dump
2085 } // namespace oox
2087 #endif
2089 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */