fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / oox / source / dump / oledumper.cxx
blob100b9b1af0ed5a39770d683e87220a018250eac9
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 #if OOX_INCLUDE_DUMPER
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( PropertyPosMap::const_iterator aIt = aPropMap.begin(), aEnd = aPropMap.end(); aIt != aEnd; ++aIt )
285 dumpProperty( aIt->first, aIt->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::construct( const ObjectBase& rParent, const StorageRef& rxStrg, const OUString& rSysPath )
501 StorageObjectBase::construct( rParent, rxStrg, rSysPath );
504 void OleStorageObject::implDumpStream( const Reference< XInputStream >& rxStrm, const OUString& /*rStrgPath*/, const OUString& rStrmName, const OUString& rSysFileName )
506 if ( rStrmName == "\001CompObj" )
507 OleCompObjObject( *this, rxStrm, rSysFileName ).dump();
508 else if( rStrmName == "\005SummaryInformation" || rStrmName == "\005DocumentSummaryInformation" )
509 OlePropertyStreamObject( *this, rxStrm, rSysFileName ).dump();
510 else
511 BinaryStreamObject( *this, rxStrm, rSysFileName ).dump();
514 ComCtlObjectBase::ComCtlObjectBase( const InputObjectBase& rParent,
515 sal_uInt32 nDataId5, sal_uInt32 nDataId6, sal_uInt16 nVersion, bool bCommonPart, bool bComplexPart ) :
516 mnDataId5( nDataId5 ),
517 mnDataId6( nDataId6 ),
518 mnVersion( nVersion ),
519 mbCommonPart( bCommonPart ),
520 mbComplexPart( bComplexPart )
522 construct( rParent );
525 void ComCtlObjectBase::implDump()
527 sal_uInt32 nCommonSize = 0;
528 dumpComCtlSize() && dumpComCtlData( nCommonSize ) && (!mbCommonPart || dumpComCtlCommon( nCommonSize )) && (!mbComplexPart || dumpComCtlComplex());
531 void ComCtlObjectBase::implDumpCommonExtra( sal_Int64 /*nEndPos*/ )
535 void ComCtlObjectBase::implDumpCommonTrailing()
539 bool ComCtlObjectBase::dumpComCtlHeader( sal_uInt32 nExpId, sal_uInt16 nExpMajor, sal_uInt16 nExpMinor )
541 // no idea if all this is correct...
542 sal_uInt32 nId = dumpHex< sal_uInt32 >( "header-id", "COMCTL-HEADER-IDS" );
543 ItemGuard aItem( mxOut, "version" );
544 sal_uInt16 nMinor = mxStrm->readuInt16();
545 sal_uInt16 nMajor = mxStrm->readuInt16();
546 mxOut->writeDec( nMajor );
547 mxOut->writeChar( '.' );
548 mxOut->writeDec( nMinor );
549 return !mxStrm->isEof() && (nId == nExpId) && ((nExpMajor == SAL_MAX_UINT16) || (nExpMajor == nMajor)) && ((nExpMinor == SAL_MAX_UINT16) || (nExpMinor == nMinor));
552 bool ComCtlObjectBase::dumpComCtlSize()
554 if( dumpComCtlHeader( 0x12344321, 0, 8 ) )
556 IndentGuard aIndGuard( mxOut );
557 dumpDec< sal_Int32 >( "width", "CONV-HMM-TO-CM" );
558 dumpDec< sal_Int32 >( "height", "CONV-HMM-TO-CM" );
559 return !mxStrm->isEof();
561 return false;
564 bool ComCtlObjectBase::dumpComCtlData( sal_uInt32& ornCommonPartSize )
566 if( dumpComCtlHeader( (mnVersion == 5) ? mnDataId5 : mnDataId6, mnVersion ) )
568 IndentGuard aIndGuard( mxOut );
569 if( mbCommonPart )
570 ornCommonPartSize = dumpDec< sal_uInt32 >( "common-part-size" );
571 implDumpProperties();
572 return !mxStrm->isEof();
574 return false;
577 bool ComCtlObjectBase::dumpComCtlCommon( sal_uInt32 nPartSize )
579 sal_Int64 nEndPos = mxStrm->tell() + nPartSize;
580 if( (nPartSize >= 16) && dumpComCtlHeader( 0xABCDEF01, 5, 0 ) )
582 IndentGuard aIndGuard( mxOut );
583 dumpUnknown( 4 );
584 dumpHex< sal_uInt32 >( "common-flags", "COMCTL-COMMON-FLAGS" );
585 implDumpCommonExtra( nEndPos );
586 dumpRemainingTo( nEndPos );
587 implDumpCommonTrailing();
588 return !mxStrm->isEof();
590 return false;
593 bool ComCtlObjectBase::dumpComCtlComplex()
595 if( dumpComCtlHeader( 0xBDECDE1F, 5, 1 ) )
597 IndentGuard aIndGuard( mxOut );
598 sal_uInt32 nFlags = dumpHex< sal_uInt32 >( "comctl-complex-flags", "COMCTL-COMPLEX-FLAGS" );
599 if( !mxStrm->isEof() && (nFlags & 0x01) )
601 writeEmptyItem( "font" );
602 IndentGuard aIndGuard2( mxOut );
603 OUString aClassName = cfg().getStringOption( dumpGuid(), OUString() );
604 if ( aClassName == "StdFont" )
605 StdFontObject( *this ).dump();
607 if( !mxStrm->isEof() && (nFlags & 0x02) )
609 writeEmptyItem( "mouse-icon" );
610 IndentGuard aIndGuard2( mxOut );
611 OUString aClassName = cfg().getStringOption( dumpGuid(), OUString() );
612 if ( aClassName == "StdPic" )
613 StdPicObject( *this ).dump();
615 return !mxStrm->isEof();
617 return false;
620 ComCtlScrollBarObject::ComCtlScrollBarObject( const InputObjectBase& rParent, sal_uInt16 nVersion ) :
621 ComCtlObjectBase( rParent, SAL_MAX_UINT32, 0x99470A83, nVersion, true, true )
625 void ComCtlScrollBarObject::implDumpProperties()
627 dumpHex< sal_uInt32 >( "flags", "COMCTL-SCROLLBAR-FLAGS" );
628 dumpDec< sal_Int32 >( "large-change" );
629 dumpDec< sal_Int32 >( "small-change" );
630 dumpDec< sal_Int32 >( "min" );
631 dumpDec< sal_Int32 >( "max" );
632 dumpDec< sal_Int32 >( "value" );
635 ComCtlProgressBarObject::ComCtlProgressBarObject( const InputObjectBase& rParent, sal_uInt16 nVersion ) :
636 ComCtlObjectBase( rParent, 0xE6E17E84, 0x97AB8A01, nVersion, true, true )
640 void ComCtlProgressBarObject::implDumpProperties()
642 dumpDec< float >( "min" );
643 dumpDec< float >( "max" );
644 if( mnVersion == 6 )
646 dumpBool< sal_uInt16 >( "vertical" );
647 dumpBool< sal_uInt16 >( "smooth-scroll" );
651 ComCtlSliderObject::ComCtlSliderObject( const InputObjectBase& rParent, sal_uInt16 nVersion ) :
652 ComCtlObjectBase( rParent, 0xE6E17E86, 0x0A2BAE11, nVersion, true, true )
656 void ComCtlSliderObject::implDumpProperties()
658 dumpBool< sal_Int32 >( "vertical" );
659 dumpDec< sal_Int32 >( "large-change" );
660 dumpDec< sal_Int32 >( "small-change" );
661 dumpDec< sal_Int32 >( "min" );
662 dumpDec< sal_Int32 >( "max" );
663 dumpDec< sal_Int16 >( "select-range", "COMCTL-SLIDER-SELECTRANGE" );
664 dumpUnused( 2 );
665 dumpDec< sal_Int32 >( "select-start" );
666 dumpDec< sal_Int32 >( "select-length" );
667 dumpDec< sal_Int32 >( "tick-style", "COMCTL-SLIDER-TICKSTYLE" );
668 dumpDec< sal_Int32 >( "tick-frequency" );
669 dumpDec< sal_Int32 >( "value" );
670 if( mnVersion == 6 )
671 dumpBool< sal_Int32 >( "tooltip-below" );
674 ComCtlUpDownObject::ComCtlUpDownObject( const InputObjectBase& rParent, sal_uInt16 nVersion ) :
675 ComCtlObjectBase( rParent, 0xFF3626A0, 0xFF3626A0, nVersion, false, false )
679 void ComCtlUpDownObject::implDumpProperties()
681 dumpUnknown( 16 ); // buddy-property, somehow
682 dumpDec< sal_Int32 >( "buddy-control" );
683 dumpUnknown( 8 );
684 dumpDec< sal_Int32 >( "value" );
685 dumpUnknown( 4 );
686 dumpDec< sal_Int32 >( "increment" );
687 dumpDec< sal_Int32 >( "max" );
688 dumpDec< sal_Int32 >( "min" );
689 dumpHex< sal_uInt32 >( "flags-1", "COMCTL-UPDOWN-FLAGS1" );
690 dumpHex< sal_uInt32 >( "flags-2", "COMCTL-UPDOWN-FLAGS2" );
691 dumpUnknown( 4 );
694 ComCtlImageListObject::ComCtlImageListObject( const InputObjectBase& rParent, sal_uInt16 nVersion ) :
695 ComCtlObjectBase( rParent, 0xE6E17E80, 0xE6E17E80, nVersion, true, false )
699 void ComCtlImageListObject::implDumpProperties()
701 dumpDec< sal_uInt16 >( "image-width" );
702 dumpDec< sal_uInt16 >( "image-height" );
703 dumpOleColor( "mask-color" );
704 dumpBool< sal_Int16 >( "use-mask-color" );
705 dumpUnknown( 2 );
708 void ComCtlImageListObject::implDumpCommonExtra( sal_Int64 /*nEndPos*/ )
710 dumpUnknown( 4 );
711 dumpOleColor( "back-color" );
712 dumpUnknown( 4 );
713 sal_Int32 nImageCount = dumpDec< sal_Int32 >( "image-count" );
714 mxOut->resetItemIndex();
715 for( sal_Int32 nImageIndex = 0; (nImageIndex < nImageCount) && !mxStrm->isEof(); ++nImageIndex )
717 writeEmptyItem( "#image" );
718 IndentGuard aIndGuard( mxOut );
719 sal_uInt8 nFlags = dumpHex< sal_uInt8 >( "text-flags", "COMCTL-IMAGELIST-TEXTFLAGS" );
720 if( nFlags & 0x01 ) dumpUniString32( "caption" );
721 if( nFlags & 0x02 ) dumpUniString32( "key" );
725 void ComCtlImageListObject::implDumpCommonTrailing()
727 sal_Int32 nImageCount = dumpDec< sal_Int32 >( "image-count" );
728 mxOut->resetItemIndex();
729 for( sal_Int32 nImageIndex = 0; (nImageIndex < nImageCount) && !mxStrm->isEof(); ++nImageIndex )
731 writeEmptyItem( "#image" );
732 IndentGuard aIndGuard( mxOut );
733 dumpDec< sal_Int32 >( "index" );
734 StdPicObject( *this ).dump();
738 ComCtlTabStripObject::ComCtlTabStripObject( const InputObjectBase& rParent, sal_uInt16 nVersion ) :
739 ComCtlObjectBase( rParent, 0xE6E17E8A, 0xD12A7AC1, nVersion, true, true )
743 void ComCtlTabStripObject::implDumpProperties()
745 dumpHex< sal_uInt32 >( "flags-1", "COMCTL-TABSTRIP-FLAGS1" );
746 dumpDec< sal_uInt16 >( "tab-fixed-width", "CONV-HMM-TO-CM" );
747 dumpDec< sal_uInt16 >( "tab-fixed-height", "CONV-HMM-TO-CM" );
748 if( mnVersion == 6 )
750 dumpHex< sal_uInt32 >( "flags-2", "COMCTL-TABSTRIP-FLAGS2" );
751 dumpDec< sal_uInt16 >( "tab-min-width", "CONV-HMM-TO-CM" );
752 dumpUnknown( 2 );
753 dumpHex< sal_uInt32 >( "flags-3", "COMCTL-TABSTRIP-FLAGS3" );
757 void ComCtlTabStripObject::implDumpCommonExtra( sal_Int64 /*nEndPos*/ )
759 dumpUnknown( 12 );
760 dumpUniString32( "image-list" );
761 sal_Int32 nTabCount = dumpDec< sal_Int32 >( "tab-count" );
762 mxOut->resetItemIndex();
763 for( sal_Int32 nTabIndex = 0; (nTabIndex < nTabCount) && !mxStrm->isEof(); ++nTabIndex )
765 writeEmptyItem( "#tab" );
766 IndentGuard aIndGuard( mxOut );
767 dumpUnknown( 4 );
768 sal_uInt32 nTabFlags = dumpHex< sal_uInt32 >( "tab-flags", "COMCTL-TABSTRIP-TABFLAGS" );
769 if( nTabFlags & 0x01 ) dumpUniString32( "caption" );
770 if( nTabFlags & 0x02 ) dumpUniString32( "key" );
771 if( nTabFlags & 0x04 ) dumpUniString32( "tag" );
772 if( nTabFlags & 0x08 ) dumpUniString32( "tooltip" );
773 dumpDec< sal_uInt16 >( "image-id" );
777 ComCtlTreeViewObject::ComCtlTreeViewObject( const InputObjectBase& rParent, sal_uInt16 nVersion ) :
778 ComCtlObjectBase( rParent, 0xE6E17E8E, 0x6AC13CB1, nVersion, true, true ),
779 mnStringFlags( 0 )
783 void ComCtlTreeViewObject::implDumpProperties()
785 dumpHex< sal_uInt32 >( "flags", "COMCTL-TREEVIEW-FLAGS" );
786 dumpDec< sal_Int32 >( "indentation", "CONV-HMM-TO-CM" );
787 if( mnVersion == 6 )
788 dumpHex< sal_uInt32 >( "flags-2", "COMCTL-TREEVIEW-FLAGS2" );
789 mnStringFlags = dumpHex< sal_uInt32 >( "string-flags", "COMCTL-TREEVIEW-STRINGFLAGS" );
792 void ComCtlTreeViewObject::implDumpCommonExtra( sal_Int64 /*nEndPos*/ )
794 dumpOleColor( "text-color" );
795 dumpOleColor( "back-color" );
796 dumpUnknown( 4 );
797 if( mnStringFlags & 0x02 )
798 dumpUniString32( "image-list" );
799 dumpUniString32( "path-separator" );
802 ComCtlStatusBarObject::ComCtlStatusBarObject( const InputObjectBase& rParent, sal_uInt16 nVersion ) :
803 ComCtlObjectBase( rParent, 0xE6E17E88, SAL_MAX_UINT32, nVersion, true, true )
807 void ComCtlStatusBarObject::implDumpProperties()
809 dumpBool< sal_Int32 >( "style-simple-text" );
810 dumpBool< sal_Int16 >( "show-tips" );
811 dumpUnknown( 2 );
814 void ComCtlStatusBarObject::implDumpCommonExtra( sal_Int64 /*nEndPos*/ )
816 dumpUnknown( 12 );
817 dumpUniString32( "simple-text" );
818 sal_Int32 nPanelCount = dumpDec< sal_Int32 >( "panel-count" );
819 mxOut->resetItemIndex();
820 for( sal_Int32 nPanelIndex = 0; (nPanelIndex < nPanelCount) && !mxStrm->isEof(); ++nPanelIndex )
822 writeEmptyItem( "#panel" );
823 IndentGuard aIndGuard( mxOut );
824 dumpHex< sal_uInt32 >( "panel-flags", "COMCTL-STATUSBAR-PANELFLAGS" );
825 dumpDec< sal_Int32 >( "current-width", "CONV-HMM-TO-CM" );
826 dumpDec< sal_Int32 >( "minimal-width", "CONV-HMM-TO-CM" );
827 sal_uInt32 nTextFlags = dumpHex< sal_uInt32 >( "text-flags", "COMCTL-STATUSBAR-TEXTFLAGS" );
828 if( nTextFlags & 0x01 ) dumpUniString32( "text" );
829 if( nTextFlags & 0x02 ) dumpUniString32( "vis-text" );
830 if( nTextFlags & 0x04 ) dumpUniString32( "key" );
831 if( nTextFlags & 0x08 ) dumpUniString32( "tag" );
832 if( nTextFlags & 0x10 ) dumpUniString32( "tooltip" );
836 void ComCtlStatusBarObject::implDumpCommonTrailing()
838 sal_Int32 nImageCount = dumpDec< sal_Int32 >( "image-count" );
839 mxOut->resetItemIndex();
840 for( sal_Int32 nImageIndex = 0; (nImageIndex < nImageCount) && !mxStrm->isEof(); ++nImageIndex )
842 writeEmptyItem( "#image" );
843 IndentGuard aIndGuard( mxOut );
844 dumpDec< sal_Int32 >( "panel-index" );
845 StdPicObject( *this ).dump();
849 void AxPropertyObjectBase::construct( const ObjectBase& rParent,
850 const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName, const String& rPropNameList, bool b64BitPropFlags )
852 OleInputObjectBase::construct( rParent, rxStrm, rSysFileName );
853 constructAxPropObj( rPropNameList, b64BitPropFlags );
856 void AxPropertyObjectBase::construct( const InputObjectBase& rParent,
857 const String& rPropNameList, bool b64BitPropFlags )
859 OleInputObjectBase::construct( rParent );
860 constructAxPropObj( rPropNameList, b64BitPropFlags );
863 bool AxPropertyObjectBase::implIsValid() const
865 return OleInputObjectBase::implIsValid() && mxStrm->isSeekable();
868 void AxPropertyObjectBase::implDump()
870 mbValid = true;
871 // header
872 setAlignAnchor();
873 dumpVersion();
874 sal_uInt16 nSize = dumpDec< sal_uInt16 >( "size" );
875 mnPropertiesEnd = mxStrm->tell() + nSize;
876 // property flags
877 maLargeProps.clear();
878 maStreamProps.clear();
879 mnPropFlags = dumpHex< sal_Int64, sal_uInt32 >( mb64BitPropFlags, "properties", mxPropNames );
880 mnCurrProp = 0;
881 // properties
882 dumpShortProperties();
883 dumpLargeProperties();
884 setAlignAnchor();
885 if( ensureValid() )
886 implDumpExtended();
889 void AxPropertyObjectBase::implDumpShortProperties()
893 void AxPropertyObjectBase::implDumpExtended()
897 bool AxPropertyObjectBase::ensureValid( bool bCondition )
899 if( mbValid && (!bCondition || mxStrm->isEof()) )
901 if( !bCondition )
902 writeInfoItem( "state", OOX_DUMP_ERRASCII( "format-error" ) );
903 mbValid = false;
905 return mbValid;
908 void AxPropertyObjectBase::setAlignAnchor()
910 mnPropertiesStart = mxStrm->tell();
913 bool AxPropertyObjectBase::startNextProperty()
915 if( mnCurrProp == 0 ) mnCurrProp = 1; else mnCurrProp <<= 1;
916 bool bHasProp = getFlag( mnPropFlags, mnCurrProp );
917 setFlag( mnPropFlags, mnCurrProp, false );
918 return ensureValid() && bHasProp;
921 OUString AxPropertyObjectBase::getPropertyName() const
923 return cfg().getName( mxPropNames, mnCurrProp );
926 sal_uInt32 AxPropertyObjectBase::dumpFlagsProperty( sal_uInt32 nDefault, const sal_Char* pcNameList )
928 if( startNextProperty() )
930 alignInput< sal_uInt32 >();
931 return dumpHex< sal_uInt32 >( getPropertyName(), pcNameList );
933 return nDefault;
936 sal_uInt32 AxPropertyObjectBase::dumpColorProperty( sal_uInt32 nDefault )
938 if( startNextProperty() )
940 alignInput< sal_uInt32 >();
941 return dumpOleColor( getPropertyName() );
943 return nDefault;
946 sal_Unicode AxPropertyObjectBase::dumpUnicodeProperty()
948 if( startNextProperty() )
950 alignInput< sal_uInt16 >();
951 return dumpUnicode( getPropertyName() );
953 return '\0';
956 void AxPropertyObjectBase::dumpUnknownProperty()
958 if( startNextProperty() )
959 ensureValid( false );
962 void AxPropertyObjectBase::dumpPosProperty()
964 if( startNextProperty() )
965 maLargeProps.push_back( LargeProperty( LargeProperty::PROPTYPE_POS, getPropertyName(), 8 ) );
968 void AxPropertyObjectBase::dumpSizeProperty()
970 if( startNextProperty() )
971 maLargeProps.push_back( LargeProperty( LargeProperty::PROPTYPE_SIZE, getPropertyName(), 8 ) );
974 void AxPropertyObjectBase::dumpGuidProperty( OUString* pValue )
976 if( startNextProperty() )
977 maLargeProps.push_back( LargeProperty( LargeProperty::PROPTYPE_GUID, getPropertyName(), 16, pValue ) );
980 void AxPropertyObjectBase::dumpStringProperty( OUString* pValue )
982 if( startNextProperty() )
984 alignInput< sal_uInt32 >();
985 sal_uInt32 nLen = dumpHex< sal_uInt32 >( getPropertyName(), "AX-STRINGLEN" );
986 maLargeProps.push_back( LargeProperty( LargeProperty::PROPTYPE_STRING, getPropertyName(), nLen, pValue ) );
990 void AxPropertyObjectBase::dumpStringArrayProperty()
992 if( startNextProperty() )
994 alignInput< sal_uInt32 >();
995 sal_uInt32 nLen = dumpHex< sal_uInt32 >( getPropertyName(), "CONV-DEC" );
996 maLargeProps.push_back( LargeProperty( LargeProperty::PROPTYPE_STRINGARRAY, getPropertyName(), nLen ) );
1000 void AxPropertyObjectBase::dumpStreamProperty()
1002 if( startNextProperty() )
1004 alignInput< sal_uInt16 >();
1005 sal_uInt16 nData = dumpHex< sal_uInt16 >( getPropertyName() );
1006 maStreamProps.push_back( StreamProperty( getPropertyName(), nData ) );
1010 void AxPropertyObjectBase::dumpEmbeddedFont()
1012 if( ensureValid() )
1014 writeEmptyItem( "embedded-fontdata" );
1015 IndentGuard aIndGuard( mxOut );
1016 AxCFontNewObject( *this ).dump();
1020 void AxPropertyObjectBase::dumpToPosition( sal_Int64 nPos )
1022 dumpRemainingTo( nPos );
1023 mbValid = true;
1024 ensureValid();
1027 void AxPropertyObjectBase::constructAxPropObj( const String& rPropNameList, bool b64BitPropFlags )
1029 if( OleInputObjectBase::implIsValid() )
1031 mxPropNames = cfg().getNameList( rPropNameList );
1032 mb64BitPropFlags = b64BitPropFlags;
1033 mbValid = true;
1037 void AxPropertyObjectBase::dumpVersion()
1039 ItemGuard aItem( mxOut, "version" );
1040 sal_uInt8 nMinor = mxStrm->readuChar();
1041 sal_uInt8 nMajor = mxStrm->readuChar();
1042 mxOut->writeDec( nMajor );
1043 mxOut->writeChar( '.' );
1044 mxOut->writeDec( nMinor );
1047 OUString AxPropertyObjectBase::dumpString( const String& rName, sal_uInt32 nSize, bool bArray )
1049 bool bCompressed = getFlag( nSize, AX_STRING_COMPRESSED );
1050 sal_uInt32 nBufSize = extractValue< sal_uInt32 >( nSize, 0, 31 );
1051 OUString aString = bCompressed ?
1052 dumpCharArray( rName, nBufSize, RTL_TEXTENCODING_ISO_8859_1 ) :
1053 dumpUnicodeArray( rName, bArray ? nBufSize : (nBufSize / 2) );
1054 alignInput< sal_Int32 >();
1055 return aString;
1058 void AxPropertyObjectBase::dumpShortProperties()
1060 if( ensureValid() )
1062 writeEmptyItem( "short-properties" );
1063 IndentGuard aIndGuard( mxOut );
1064 implDumpShortProperties();
1065 alignInput< sal_uInt32 >();
1069 void AxPropertyObjectBase::dumpLargeProperties()
1071 if( ensureValid( mnPropFlags == 0 ) && !maLargeProps.empty() )
1073 writeEmptyItem( "large-properties" );
1074 IndentGuard aIndGuard( mxOut );
1075 for( LargePropertyVector::iterator aIt = maLargeProps.begin(), aEnd = maLargeProps.end(); ensureValid() && (aIt != aEnd); ++aIt )
1077 switch( aIt->mePropType )
1079 case LargeProperty::PROPTYPE_POS:
1081 MultiItemsGuard aMultiGuard( mxOut );
1082 writeEmptyItem( aIt->maItemName );
1083 dumpDec< sal_Int32 >( "top", "CONV-HMM-TO-CM" );
1084 dumpDec< sal_Int32 >( "left", "CONV-HMM-TO-CM" );
1086 break;
1087 case LargeProperty::PROPTYPE_SIZE:
1089 MultiItemsGuard aMultiGuard( mxOut );
1090 writeEmptyItem( aIt->maItemName );
1091 dumpDec< sal_Int32 >( "width", "CONV-HMM-TO-CM" );
1092 dumpDec< sal_Int32 >( "height", "CONV-HMM-TO-CM" );
1094 break;
1095 case LargeProperty::PROPTYPE_GUID:
1097 OUString aGuid = dumpGuid( aIt->maItemName );
1098 if( aIt->mpItemValue )
1099 *aIt->mpItemValue = cfg().getStringOption( aGuid, OUString() );
1101 break;
1102 case LargeProperty::PROPTYPE_STRING:
1104 OUString aString = dumpString( aIt->maItemName, aIt->mnDataSize, false );
1105 if( aIt->mpItemValue )
1106 *aIt->mpItemValue = aString;
1108 break;
1109 case LargeProperty::PROPTYPE_STRINGARRAY:
1111 writeEmptyItem( aIt->maItemName );
1112 IndentGuard aIndGuard2( mxOut );
1113 mxOut->resetItemIndex();
1114 sal_Int64 nEndPos = mxStrm->tell() + aIt->mnDataSize;
1115 while( mxStrm->tell() < nEndPos )
1117 MultiItemsGuard aMultiGuard( mxOut );
1118 sal_uInt32 nDataSize = dumpHex< sal_uInt32 >( "#flags", "AX-ARRAYSTRINGLEN" );
1119 dumpString( "string", nDataSize, true );
1121 dumpToPosition( nEndPos );
1123 break;
1127 dumpToPosition( mnPropertiesEnd );
1129 if( ensureValid() && !maStreamProps.empty() )
1131 writeEmptyItem( "stream-properties" );
1132 IndentGuard aIndGuard( mxOut );
1133 for( StreamPropertyVector::iterator aIt = maStreamProps.begin(), aEnd = maStreamProps.end(); ensureValid() && (aIt != aEnd); ++aIt )
1135 writeEmptyItem( aIt->maItemName );
1136 if( ensureValid( aIt->mnData == 0xFFFF ) )
1138 IndentGuard aIndGuard2( mxOut );
1139 OUString aClassName = cfg().getStringOption( dumpGuid(), OUString() );
1140 if ( aClassName == "StdFont" )
1141 StdFontObject( *this ).dump();
1142 else if ( aClassName == "StdPic" )
1143 StdPicObject( *this ).dump();
1144 else if ( aClassName == "CFontNew" )
1145 AxCFontNewObject( *this ).dump();
1146 else
1147 ensureValid( false );
1153 AxCFontNewObject::AxCFontNewObject( const InputObjectBase& rParent )
1155 AxPropertyObjectBase::construct( rParent, "AX-CFONTNEW-PROPERTIES" );
1158 void AxCFontNewObject::implDumpShortProperties()
1160 dumpStringProperty();
1161 dumpFlagsProperty( 0, "AX-CFONTNEW-FLAGS" );
1162 dumpDecProperty< sal_Int32 >( 160 );
1163 dumpDecProperty< sal_Int32 >( 0 );
1164 dumpDecProperty< sal_uInt8 >( WINDOWS_CHARSET_DEFAULT, "CHARSET" );
1165 dumpDecProperty< sal_uInt8 >( 0, "FONT-PITCHFAMILY" );
1166 dumpDecProperty< sal_uInt8 >( 1, "AX-CFONTNEW-ALIGNMENT" );
1167 dumpDecProperty< sal_uInt16 >( 400, "FONT-WEIGHT" );
1170 AxColumnInfoObject::AxColumnInfoObject( const InputObjectBase& rParent )
1172 AxPropertyObjectBase::construct( rParent, "AX-COLUMNINFO-PROPERTIES" );
1175 void AxColumnInfoObject::implDumpShortProperties()
1177 dumpDecProperty< sal_Int32 >( -1, "CONV-HMM-TO-CM" );
1180 AxCommandButtonObject::AxCommandButtonObject( const InputObjectBase& rParent )
1182 AxPropertyObjectBase::construct( rParent, "AX-COMMANDBUTTON-PROPERTIES" );
1185 void AxCommandButtonObject::implDumpShortProperties()
1187 dumpColorProperty( 0x80000012 );
1188 dumpColorProperty( 0x80000008 );
1189 dumpFlagsProperty( 0x0000001B );
1190 dumpStringProperty();
1191 dumpImagePosProperty();
1192 dumpSizeProperty();
1193 dumpMousePtrProperty();
1194 dumpStreamProperty();
1195 dumpUnicodeProperty();
1196 dumpBoolProperty();
1197 dumpStreamProperty();
1200 void AxCommandButtonObject::implDumpExtended()
1202 dumpEmbeddedFont();
1205 AxMorphControlObject::AxMorphControlObject( const InputObjectBase& rParent )
1207 AxPropertyObjectBase::construct( rParent, "AX-MORPH-PROPERTIES", true );
1210 void AxMorphControlObject::implDumpShortProperties()
1212 dumpFlagsProperty( 0x2C80081B );
1213 dumpColorProperty( 0x80000005 );
1214 dumpColorProperty( 0x80000008 );
1215 dumpDecProperty< sal_uInt32 >( 0 );
1216 dumpBorderStyleProperty< sal_uInt8 >( 0 );
1217 dumpDecProperty< sal_uInt8 >( 0, "AX-MORPH-SCROLLBARS" );
1218 mnCtrlType = dumpDecProperty< sal_uInt8 >( 1, "AX-MORPH-CONTROLTYPE" );
1219 dumpMousePtrProperty();
1220 dumpSizeProperty();
1221 dumpUnicodeProperty();
1222 dumpDecProperty< sal_uInt32 >( 0, "CONV-HMM-TO-CM" );
1223 dumpDecProperty< sal_uInt16 >( 1, "AX-MORPH-BOUNDCOLUMN" );
1224 dumpDecProperty< sal_Int16 >( -1, "AX-MORPH-TEXTCOLUMN" );
1225 dumpDecProperty< sal_Int16 >( 1, "AX-MORPH-COLUMNCOUNT" );
1226 dumpDecProperty< sal_uInt16 >( 8 );
1227 mnColInfoCount = dumpDecProperty< sal_uInt16 >( 1 );
1228 dumpDecProperty< sal_uInt8 >( 2, "AX-MORPH-MATCHENTRYTYPE" );
1229 dumpDecProperty< sal_uInt8 >( 0, "AX-MORPH-LISTSTYLE" );
1230 dumpDecProperty< sal_uInt8 >( 0, "AX-MORPH-SHOWDROPDOWNMODE" );
1231 dumpUnknownProperty();
1232 dumpDecProperty< sal_uInt8 >( 1, "AX-MORPH-DROPDOWNSTYLE" );
1233 dumpDecProperty< sal_uInt8 >( 0, "AX-MORPH-SELECTIONTYPE" );
1234 dumpStringProperty();
1235 dumpStringProperty();
1236 dumpImagePosProperty();
1237 dumpColorProperty( 0x80000006 );
1238 dumpSpecialEffectProperty< sal_uInt32 >( 2 );
1239 dumpStreamProperty();
1240 dumpStreamProperty();
1241 dumpUnicodeProperty();
1242 dumpUnknownProperty();
1243 dumpBoolProperty();
1244 dumpStringProperty();
1247 void AxMorphControlObject::implDumpExtended()
1249 dumpEmbeddedFont();
1250 dumpColumnInfos();
1253 void AxMorphControlObject::dumpColumnInfos()
1255 if( ensureValid() && (mnColInfoCount > 0) && ((mnCtrlType == 2) || (mnCtrlType == 3)) )
1257 mxOut->resetItemIndex();
1258 for( sal_uInt16 nIdx = 0; ensureValid() && (nIdx < mnColInfoCount); ++nIdx )
1260 writeEmptyItem( "#column-info" );
1261 IndentGuard aIndGuard( mxOut );
1262 AxColumnInfoObject( *this ).dump();
1267 AxLabelObject::AxLabelObject( const InputObjectBase& rParent )
1269 AxPropertyObjectBase::construct( rParent, "AX-LABEL-PROPERTIES" );
1272 void AxLabelObject::implDumpShortProperties()
1274 dumpColorProperty( 0x80000012 );
1275 dumpColorProperty( 0x8000000F );
1276 dumpFlagsProperty( 0x0080001B );
1277 dumpStringProperty();
1278 dumpImagePosProperty();
1279 dumpSizeProperty();
1280 dumpMousePtrProperty();
1281 dumpColorProperty( 0x80000006 );
1282 dumpBorderStyleProperty< sal_uInt16 >( 0 );
1283 dumpSpecialEffectProperty< sal_uInt16 >( 0 );
1284 dumpStreamProperty();
1285 dumpUnicodeProperty();
1286 dumpStreamProperty();
1289 void AxLabelObject::implDumpExtended()
1291 dumpEmbeddedFont();
1294 AxImageObject::AxImageObject( const InputObjectBase& rParent )
1296 AxPropertyObjectBase::construct( rParent, "AX-IMAGE-PROPERTIES" );
1299 void AxImageObject::implDumpShortProperties()
1301 dumpUnknownProperty();
1302 dumpUnknownProperty();
1303 dumpBoolProperty();
1304 dumpColorProperty( 0x80000006 );
1305 dumpColorProperty( 0x8000000F );
1306 dumpBorderStyleProperty< sal_uInt8 >( 1 );
1307 dumpMousePtrProperty();
1308 dumpImageSizeModeProperty();
1309 dumpSpecialEffectProperty< sal_uInt8 >( 0 );
1310 dumpSizeProperty();
1311 dumpStreamProperty();
1312 dumpImageAlignProperty();
1313 dumpBoolProperty();
1314 dumpFlagsProperty( 0x0000001B );
1315 dumpStreamProperty();
1318 AxScrollBarObject::AxScrollBarObject( const InputObjectBase& rParent )
1320 AxPropertyObjectBase::construct( rParent, "AX-SCROLLBAR-PROPERTIES" );
1323 void AxScrollBarObject::implDumpShortProperties()
1325 dumpColorProperty( 0x80000012 );
1326 dumpColorProperty( 0x8000000F );
1327 dumpFlagsProperty( 0x0000001B );
1328 dumpSizeProperty();
1329 dumpMousePtrProperty();
1330 dumpDecProperty< sal_Int32 >( 0 );
1331 dumpDecProperty< sal_Int32 >( 32767 );
1332 dumpDecProperty< sal_Int32 >( 0 );
1333 dumpHexProperty< sal_uInt32 >( 0 );
1334 dumpEnabledProperty();
1335 dumpEnabledProperty();
1336 dumpDecProperty< sal_Int32 >( 1 );
1337 dumpDecProperty< sal_Int32 >( 1 );
1338 dumpOrientationProperty();
1339 dumpDecProperty< sal_Int16 >( -1, "AX-SCROLLBAR-PROPTHUMB" );
1340 dumpDelayProperty();
1341 dumpStreamProperty();
1344 AxSpinButtonObject::AxSpinButtonObject( const InputObjectBase& rParent )
1346 AxPropertyObjectBase::construct( rParent, "AX-SPINBUTTON-PROPERTIES" );
1349 void AxSpinButtonObject::implDumpShortProperties()
1351 dumpColorProperty( 0x80000012 );
1352 dumpColorProperty( 0x8000000F );
1353 dumpFlagsProperty( 0x0000001B );
1354 dumpSizeProperty();
1355 dumpHexProperty< sal_uInt32 >( 0 );
1356 dumpDecProperty< sal_Int32 >( 0 );
1357 dumpDecProperty< sal_Int32 >( 100 );
1358 dumpDecProperty< sal_Int32 >( 0 );
1359 dumpEnabledProperty();
1360 dumpEnabledProperty();
1361 dumpDecProperty< sal_Int32 >( 1 );
1362 dumpOrientationProperty();
1363 dumpDelayProperty();
1364 dumpStreamProperty();
1365 dumpMousePtrProperty();
1368 AxTabStripObject::AxTabStripObject( const InputObjectBase& rParent )
1370 AxPropertyObjectBase::construct( rParent, "AX-TABSTRIP-PROPERTIES" );
1373 void AxTabStripObject::implDumpShortProperties()
1375 dumpDecProperty< sal_Int32 >( -1 );
1376 dumpColorProperty( 0x8000000F );
1377 dumpColorProperty( 0x80000012 );
1378 dumpUnknownProperty();
1379 dumpSizeProperty();
1380 dumpStringArrayProperty();
1381 dumpMousePtrProperty();
1382 dumpUnknownProperty();
1383 dumpDecProperty< sal_uInt32 >( 0, "AX-TABSTRIP-ORIENTATION" );
1384 dumpDecProperty< sal_uInt32 >( 0, "AX-TABSTRIP-TABSTYLE" );
1385 dumpBoolProperty();
1386 dumpHmmProperty();
1387 dumpHmmProperty();
1388 dumpBoolProperty();
1389 dumpUnknownProperty();
1390 dumpStringArrayProperty();
1391 dumpUnknownProperty();
1392 dumpStringArrayProperty();
1393 dumpFlagsProperty( 0x0000001B );
1394 dumpBoolProperty();
1395 dumpDecProperty< sal_uInt32 >( 0 );
1396 dumpStringArrayProperty();
1397 mnTabFlagCount = dumpDecProperty< sal_Int32 >( 0 );
1398 dumpStringArrayProperty();
1399 dumpStreamProperty();
1402 void AxTabStripObject::implDumpExtended()
1404 dumpEmbeddedFont();
1405 if( mnTabFlagCount > 0 )
1407 writeEmptyItem( "tab-flags" );
1408 IndentGuard aIndGuard( mxOut );
1409 mxOut->resetItemIndex();
1410 for( sal_Int32 nIdx = 0; ensureValid() && (nIdx < mnTabFlagCount); ++nIdx )
1411 dumpHex< sal_uInt32 >( "#flags", "AX-TABSTRIP-FLAGS" );
1415 FormControlStreamObject::FormControlStreamObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName, const OUString* pProgId )
1417 construct( rParent, rxStrm, rSysFileName );
1418 constructFormCtrlStrmObj( pProgId );
1421 FormControlStreamObject::FormControlStreamObject( const OutputObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString* pProgId )
1423 construct( rParent, rxStrm );
1424 constructFormCtrlStrmObj( pProgId );
1427 void FormControlStreamObject::implDump()
1429 if( mbReadGuid )
1430 maProgId = cfg().getStringOption( dumpGuid(), OUString() );
1432 if( !maProgId.isEmpty() && !mxStrm->isEof() )
1434 if ( maProgId == "Forms.CommandButton.1" )
1435 AxCommandButtonObject( *this ).dump();
1436 else if( maProgId == "Forms.TextBox.1" ||
1437 maProgId == "Forms.ListBox.1" ||
1438 maProgId == "Forms.ComboBox.1" ||
1439 maProgId == "Forms.CheckBox.1" ||
1440 maProgId == "Forms.OptionButton.1" ||
1441 maProgId == "Forms.ToggleButton.1" ||
1442 maProgId == "RefEdit.Ctrl" )
1443 AxMorphControlObject( *this ).dump();
1444 else if ( maProgId == "Forms.Label.1" )
1445 AxLabelObject( *this ).dump();
1446 else if ( maProgId == "Forms.Image.1" )
1447 AxImageObject( *this ).dump();
1448 else if ( maProgId == "Forms.ScrollBar.1" )
1449 AxScrollBarObject( *this ).dump();
1450 else if ( maProgId == "Forms.SpinButton.1" )
1451 AxSpinButtonObject( *this ).dump();
1452 else if ( maProgId == "Forms.TabStrip.1" )
1453 AxTabStripObject( *this ).dump();
1454 else if ( maProgId == "MSComCtl2.FlatScrollBar.2" )
1455 ComCtlScrollBarObject( *this, 6 ).dump();
1456 else if ( maProgId == "COMCTL.ProgCtrl.1" )
1457 ComCtlProgressBarObject( *this, 5 ).dump();
1458 else if ( maProgId == "MSComctlLib.ProgCtrl.2" )
1459 ComCtlProgressBarObject( *this, 6 ).dump();
1460 else if ( maProgId == "COMCTL.Slider.1" )
1461 ComCtlSliderObject( *this, 5 ).dump();
1462 else if ( maProgId == "MSComctlLib.Slider.2" )
1463 ComCtlSliderObject( *this, 6 ).dump();
1464 else if ( maProgId == "ComCtl2.UpDown.1" )
1465 ComCtlUpDownObject( *this, 5 ).dump();
1466 else if ( maProgId == "MSComCtl2.UpDown.2" )
1467 ComCtlUpDownObject( *this, 6 ).dump();
1468 else if ( maProgId == "COMCTL.ImageListCtrl.1" )
1469 ComCtlImageListObject( *this, 5 ).dump();
1470 else if ( maProgId == "MSComctlLib.ImageListCtrl.2" )
1471 ComCtlImageListObject( *this, 6 ).dump();
1472 else if ( maProgId == "COMCTL.TabStrip.1" )
1473 ComCtlTabStripObject( *this, 5 ).dump();
1474 else if ( maProgId == "MSComctlLib.TabStrip.2" )
1475 ComCtlTabStripObject( *this, 6 ).dump();
1476 else if ( maProgId == "COMCTL.TreeCtrl.1" )
1477 ComCtlTreeViewObject( *this, 5 ).dump();
1478 else if ( maProgId == "MSComctlLib.TreeCtrl.2" )
1479 ComCtlTreeViewObject( *this, 6 ).dump();
1480 else if ( maProgId == "COMCTL.SBarCtrl.1" )
1481 ComCtlStatusBarObject( *this, 5 ).dump();
1482 else if ( maProgId == "StdPic" )
1483 StdPicObject( *this ).dump();
1485 dumpRemainingStream();
1488 void FormControlStreamObject::constructFormCtrlStrmObj( const OUString* pProgId )
1490 mbReadGuid = pProgId == 0;
1491 if( pProgId )
1492 maProgId = *pProgId;
1495 VbaFormClassInfoObject::VbaFormClassInfoObject( const InputObjectBase& rParent, VbaFormSharedData& rFormData ) :
1496 mrFormData( rFormData )
1498 AxPropertyObjectBase::construct( rParent, "VBA-CLASSINFO-PROPERTIES" );
1501 void VbaFormClassInfoObject::implDumpShortProperties()
1503 mrFormData.maClassInfoProgIds.push_back( OUString() );
1504 dumpGuidProperty( &mrFormData.maClassInfoProgIds.back() );
1505 dumpGuidProperty();
1506 dumpUnknownProperty();
1507 dumpGuidProperty();
1508 dumpFlagsProperty( 0, "VBA-CLASSINFO-FLAGS" );
1509 dumpDecProperty< sal_uInt32 >( 0 );
1510 dumpDecProperty< sal_Int32 >( -1 );
1511 dumpDecProperty< sal_uInt16 >( 0 );
1512 dumpDecProperty< sal_uInt16 >( 0 );
1513 dumpDecProperty< sal_uInt16 >( 0, "OLEPROP-TYPE" );
1514 dumpDecProperty< sal_uInt16 >( 0 );
1515 dumpDecProperty< sal_uInt16 >( 0 );
1516 dumpDecProperty< sal_uInt16 >( 0, "OLEPROP-TYPE" );
1517 dumpDecProperty< sal_Int32 >( -1 );
1518 dumpDecProperty< sal_uInt16 >( 0 );
1521 namespace {
1523 const sal_uInt32 VBA_FORMSITE_OBJSTREAM = 0x0010;
1525 const sal_uInt16 VBA_FORMSITE_CLASSTABLEINDEX = 0x8000;
1526 const sal_uInt16 VBA_FORMSITE_CLASSTABLEMASK = 0x7FFF;
1528 } // namespace
1530 VbaFormSiteObject::VbaFormSiteObject( const InputObjectBase& rParent, VbaFormSharedData& rFormData ) :
1531 mrFormData( rFormData )
1533 AxPropertyObjectBase::construct( rParent, "VBA-FORMSITE-PROPERTIES" );
1536 void VbaFormSiteObject::implDumpShortProperties()
1538 VbaFormSiteInfo aSiteInfo;
1539 dumpStringProperty();
1540 dumpStringProperty();
1541 sal_Int32 nId = dumpDecProperty< sal_Int32 >( 0 );
1542 dumpDecProperty< sal_Int32 >( 0 );
1543 sal_uInt32 nFlags = dumpFlagsProperty( 0x00000033, "VBA-FORMSITE-FLAGS" );
1544 sal_uInt32 nLength = dumpDecProperty< sal_uInt32 >( 0 );
1545 dumpDecProperty< sal_Int16 >( -1 );
1546 sal_uInt16 nClassId = dumpHexProperty< sal_uInt16 >( 0x7FFF, "VBA-FORMSITE-CLASSIDCACHE" );
1547 dumpPosProperty();
1548 dumpDecProperty< sal_uInt16 >( 0 );
1549 dumpUnknownProperty();
1550 dumpStringProperty();
1551 dumpStringProperty();
1552 dumpStringProperty();
1553 dumpStringProperty();
1555 sal_uInt16 nIndex = nClassId & VBA_FORMSITE_CLASSTABLEMASK;
1556 if( getFlag( nClassId, VBA_FORMSITE_CLASSTABLEINDEX ) )
1558 if( nIndex < mrFormData.maClassInfoProgIds.size() )
1559 aSiteInfo.maProgId = mrFormData.maClassInfoProgIds[ nIndex ];
1561 else
1563 if( cfg().hasName( "VBA-FORMSITE-CLASSNAMES", nIndex ) )
1564 aSiteInfo.maProgId = cfg().getName( "VBA-FORMSITE-CLASSNAMES", nIndex );
1566 aSiteInfo.mnId = nId;
1567 aSiteInfo.mnLength = nLength;
1568 aSiteInfo.mbInStream = getFlag( nFlags, VBA_FORMSITE_OBJSTREAM );
1570 mrFormData.maSiteInfos.push_back( aSiteInfo );
1573 VbaFormDesignExtObject::VbaFormDesignExtObject( const InputObjectBase& rParent )
1575 AxPropertyObjectBase::construct( rParent, "VBA-FORMDESIGNEXT-PROPERTIES" );
1578 void VbaFormDesignExtObject::implDumpShortProperties()
1580 dumpFlagsProperty( 0x00015F55, "VBA-FORMDESIGNEXT-FLAGS" );
1581 dumpHmmProperty();
1582 dumpHmmProperty();
1583 dumpDecProperty< sal_Int8 >( 0, "VBA-FORMDESIGNEXT-CLICKCTRLMODE" );
1584 dumpDecProperty< sal_Int8 >( 0, "VBA-FORMDESIGNEXT-DBLCLICKCTRLMODE" );
1587 namespace {
1589 const sal_uInt32 AX_FORM_HASDESIGNEXTENDER = 0x00004000;
1590 const sal_uInt32 AX_FORM_SKIPCLASSTABLE = 0x00008000;
1592 const sal_uInt8 AX_FORM_SITECOUNTTYPE_COUNT = 0x80;
1593 const sal_uInt8 AX_FORM_SITECOUNTTYPE_MASK = 0x7F;
1595 } // namespace
1597 VbaFStreamObject::VbaFStreamObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName, VbaFormSharedData& rFormData ) :
1598 mrFormData( rFormData )
1600 AxPropertyObjectBase::construct( rParent, rxStrm, rSysFileName, "VBA-FORM-PROPERTIES" );
1603 void VbaFStreamObject::implDumpShortProperties()
1605 dumpUnknownProperty();
1606 dumpColorProperty( 0x8000000F );
1607 dumpColorProperty( 0x80000012 );
1608 dumpDecProperty< sal_uInt32 >( 0 );
1609 dumpUnknownProperty();
1610 dumpUnknownProperty();
1611 mnFlags = dumpFlagsProperty( 0x00000004, "VBA-FORM-FLAGS" );
1612 dumpBorderStyleProperty< sal_uInt8 >( 0 );
1613 dumpMousePtrProperty();
1614 dumpHexProperty< sal_uInt8 >( 0x0C, "VBA-FORM-SCROLLBARS" );
1615 dumpSizeProperty();
1616 dumpSizeProperty();
1617 dumpPosProperty();
1618 dumpDecProperty< sal_uInt32 >( 0 );
1619 dumpUnknownProperty();
1620 dumpStreamProperty();
1621 dumpDecProperty< sal_uInt8 >( 0, "VBA-FORM-CYCLE" );
1622 dumpSpecialEffectProperty< sal_uInt8 >( 0 );
1623 dumpColorProperty( 0x80000012 );
1624 dumpStringProperty();
1625 dumpStreamProperty();
1626 dumpStreamProperty();
1627 dumpDecProperty< sal_Int32 >( 100, "CONV-PERCENT" );
1628 dumpImageAlignProperty();
1629 dumpBoolProperty();
1630 dumpImageSizeModeProperty();
1631 dumpDecProperty< sal_uInt32 >( 0 );
1632 dumpDecProperty< sal_uInt32 >( 0 );
1635 void VbaFStreamObject::implDumpExtended()
1637 dumpClassInfos();
1638 dumpSiteData();
1639 dumpDesignExtender();
1640 dumpRemainingStream();
1643 void VbaFStreamObject::dumpClassInfos()
1645 if( ensureValid() && !getFlag( mnFlags, AX_FORM_SKIPCLASSTABLE ) )
1647 mxOut->emptyLine();
1648 sal_uInt16 nCount = dumpDec< sal_uInt16 >( "class-info-count" );
1649 mxOut->resetItemIndex();
1650 for( sal_uInt16 nIdx = 0; ensureValid() && (nIdx < nCount); ++nIdx )
1652 writeEmptyItem( "#class-info" );
1653 IndentGuard aIndGuard( mxOut );
1654 VbaFormClassInfoObject( *this, mrFormData ).dump();
1659 void VbaFStreamObject::dumpFormSites( sal_uInt32 nCount )
1661 mxOut->resetItemIndex();
1662 for( sal_uInt32 nIdx = 0; ensureValid() && (nIdx < nCount); ++nIdx )
1664 mxOut->emptyLine();
1665 writeEmptyItem( "#form-site" );
1666 IndentGuard aIndGuard( mxOut );
1667 VbaFormSiteObject( *this, mrFormData ).dump();
1671 void VbaFStreamObject::dumpSiteData()
1673 if( ensureValid() )
1675 mxOut->emptyLine();
1676 setAlignAnchor();
1677 sal_uInt32 nSiteCount = dumpDec< sal_uInt32 >( "site-count" );
1678 sal_uInt32 nSiteLength = dumpDec< sal_uInt32 >( "site-data-size" );
1679 sal_Int64 nEndPos = mxStrm->tell() + nSiteLength;
1680 if( ensureValid( nEndPos <= mxStrm->size() ) )
1682 mxOut->resetItemIndex();
1683 sal_uInt32 nSiteIdx = 0;
1684 while( ensureValid() && (nSiteIdx < nSiteCount) )
1686 mxOut->emptyLine();
1687 writeEmptyItem( "#site-info" );
1688 IndentGuard aIndGuard( mxOut );
1689 dumpDec< sal_uInt8 >( "depth" );
1690 sal_uInt8 nTypeCount = dumpHex< sal_uInt8 >( "type-count", "VBA-FORM-SITE-TYPECOUNT" );
1691 if( getFlag( nTypeCount, AX_FORM_SITECOUNTTYPE_COUNT ) )
1693 dumpDec< sal_uInt8 >( "repeated-type" );
1694 nSiteIdx += (nTypeCount & AX_FORM_SITECOUNTTYPE_MASK);
1696 else
1698 ++nSiteIdx;
1701 alignInput< sal_uInt32 >();
1702 dumpFormSites( nSiteCount );
1703 dumpToPosition( nEndPos );
1708 void VbaFStreamObject::dumpDesignExtender()
1710 if( ensureValid() && getFlag( mnFlags, AX_FORM_HASDESIGNEXTENDER ) )
1712 mxOut->emptyLine();
1713 writeEmptyItem( "design-extender" );
1714 IndentGuard aIndGuard( mxOut );
1715 VbaFormDesignExtObject( *this ).dump();
1719 VbaOStreamObject::VbaOStreamObject( const ObjectBase& rParent,
1720 const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName, VbaFormSharedData& rFormData ) :
1721 mrFormData( rFormData )
1723 OleInputObjectBase::construct( rParent, rxStrm, rSysFileName );
1726 void VbaOStreamObject::implDump()
1728 for( VbaFormSiteInfoVector::iterator aIt = mrFormData.maSiteInfos.begin(), aEnd = mrFormData.maSiteInfos.end(); !mxStrm->isEof() && (aIt != aEnd); ++aIt )
1730 if( (aIt->mbInStream) && (aIt->mnLength > 0) )
1732 mxOut->emptyLine();
1733 writeDecItem( "control-id", aIt->mnId );
1734 writeInfoItem( "prog-id", aIt->maProgId );
1735 IndentGuard aIndGuard( mxOut );
1736 BinaryInputStreamRef xRelStrm( new RelativeInputStream( *mxStrm, aIt->mnLength ) );
1737 FormControlStreamObject( *this, xRelStrm, &aIt->maProgId ).dump();
1740 dumpRemainingStream();
1743 VbaPageObject::VbaPageObject( const InputObjectBase& rParent )
1745 AxPropertyObjectBase::construct( rParent, "VBA-PAGE-PROPERTIES" );
1748 void VbaPageObject::implDumpShortProperties()
1750 dumpUnknownProperty();
1751 dumpDecProperty< sal_uInt32 >( 0, "VBA-PAGE-TRANSITIONEFFECT" );
1752 dumpDecProperty< sal_uInt32 >( 0, "AX-CONV-MS" );
1755 VbaMultiPageObject::VbaMultiPageObject( const InputObjectBase& rParent )
1757 AxPropertyObjectBase::construct( rParent, "VBA-MULTIPAGE-PROPERTIES" );
1760 void VbaMultiPageObject::implDumpShortProperties()
1762 dumpUnknownProperty();
1763 mnPageCount = dumpDecProperty< sal_Int32 >( 0 );
1764 dumpDecProperty< sal_Int32 >( 0 );
1765 dumpBoolProperty();
1768 void VbaMultiPageObject::implDumpExtended()
1770 if( ensureValid() && (mnPageCount > 0) )
1772 writeEmptyItem( "page-ids" );
1773 IndentGuard aIndGuard( mxOut );
1774 mxOut->resetItemIndex();
1775 for( sal_Int32 nIdx = 0; ensureValid() && (nIdx < mnPageCount); ++nIdx )
1776 dumpDec< sal_Int32 >( "#id" );
1780 VbaXStreamObject::VbaXStreamObject( const ObjectBase& rParent,
1781 const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName, VbaFormSharedData& rFormData ) :
1782 mrFormData( rFormData )
1784 InputObjectBase::construct( rParent, rxStrm, rSysFileName );
1787 void VbaXStreamObject::implDump()
1789 for( size_t nIdx = 0, nCount = mrFormData.maSiteInfos.size(); !mxStrm->isEof() && (nIdx < nCount); ++nIdx )
1791 mxOut->emptyLine();
1792 writeEmptyItem( "page" );
1793 IndentGuard aIndGuard( mxOut );
1794 VbaPageObject( *this ).dump();
1796 if( !mxStrm->isEof() )
1798 mxOut->emptyLine();
1799 writeEmptyItem( "multi-page" );
1800 IndentGuard aIndGuard( mxOut );
1801 VbaMultiPageObject( *this ).dump();
1803 dumpRemainingStream();
1806 VbaContainerStorageObject::VbaContainerStorageObject( const ObjectBase& rParent, const StorageRef& rxStrg, const OUString& rSysPath ) :
1807 OleStorageObject( rParent, rxStrg, rSysPath )
1809 addPreferredStream( "f" );
1812 void VbaContainerStorageObject::implDumpStream( const Reference< XInputStream >& rxStrm, const OUString& rStrgPath, const OUString& rStrmName, const OUString& rSysFileName )
1814 if ( rStrmName == "f" )
1815 VbaFStreamObject( *this, rxStrm, rSysFileName, maFormData ).dump();
1816 else if ( rStrmName == "o" )
1817 VbaOStreamObject( *this, rxStrm, rSysFileName, maFormData ).dump();
1818 else if ( rStrmName == "x" )
1819 VbaXStreamObject( *this, rxStrm, rSysFileName, maFormData ).dump();
1820 else
1821 OleStorageObject::implDumpStream( rxStrm, rStrgPath, rStrmName, rSysFileName );
1824 void VbaContainerStorageObject::implDumpStorage( const StorageRef& rxStrg, const OUString& rStrgPath, const OUString& rSysPath )
1826 if( isFormStorage( rStrgPath ) )
1827 VbaContainerStorageObject( *this, rxStrg, rSysPath ).dump();
1828 else
1829 OleStorageObject( *this, rxStrg, rSysPath ).dump();
1832 bool VbaContainerStorageObject::isFormStorage( const OUString& rStrgPath ) const
1834 if( (rStrgPath.getLength() >= 3) && (rStrgPath[ 0 ] == 'i') )
1836 OUString aId = rStrgPath.copy( 1 );
1837 if( (aId.getLength() == 2) && (aId[ 0 ] == '0') )
1838 aId = aId.copy( 1 );
1839 sal_Int32 nId = aId.toInt32();
1840 if( (nId > 0) && (OUString::number( nId ) == aId) )
1841 for( VbaFormSiteInfoVector::const_iterator aIt = maFormData.maSiteInfos.begin(), aEnd = maFormData.maSiteInfos.end(); aIt != aEnd; ++aIt )
1842 if( aIt->mnId == nId )
1843 return true;
1845 return false;
1848 VbaSharedData::VbaSharedData() :
1849 meTextEnc( RTL_TEXTENCODING_MS_1252 )
1853 bool VbaSharedData::isModuleStream( const OUString& rStrmName ) const
1855 return maStrmOffsets.count( rStrmName ) > 0;
1858 sal_Int32 VbaSharedData::getStreamOffset( const OUString& rStrmName ) const
1860 StreamOffsetMap::const_iterator aIt = maStrmOffsets.find( rStrmName );
1861 return (aIt == maStrmOffsets.end()) ? 0 : aIt->second;
1864 VbaDirStreamObject::VbaDirStreamObject( const ObjectBase& rParent,
1865 const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName, VbaSharedData& rVbaData ) :
1866 mrVbaData( rVbaData )
1868 mxInStrm = rxStrm;
1869 if( mxInStrm.get() )
1871 BinaryInputStreamRef xVbaStrm( new ::oox::ole::VbaInputStream( *mxInStrm ) );
1872 SequenceRecordObjectBase::construct( rParent, xVbaStrm, rSysFileName, "VBA-DIR-RECORD-NAMES", "VBA-DIR-SIMPLE-RECORDS" );
1876 bool VbaDirStreamObject::implIsValid() const
1878 return mxInStrm.get() && SequenceRecordObjectBase::implIsValid();
1881 bool VbaDirStreamObject::implReadRecordHeader( BinaryInputStream& rBaseStrm, sal_Int64& ornRecId, sal_Int64& ornRecSize )
1883 ornRecId = rBaseStrm.readuInt16();
1884 ornRecSize = rBaseStrm.readInt32();
1886 // for no obvious reason, PROJECTVERSION record contains size field of 4, but is 6 bytes long
1887 if( ornRecId == 9 )
1888 ornRecSize = 6;
1890 return !rBaseStrm.isEof();
1893 void VbaDirStreamObject::implDumpRecordBody()
1895 switch( getRecId() )
1897 case 0x0003:
1898 mrVbaData.meTextEnc = rtl_getTextEncodingFromWindowsCodePage( dumpDec< sal_uInt16 >( "codepage", "CODEPAGES" ) );
1899 break;
1900 case 0x0004:
1901 dumpByteString( "name" );
1902 break;
1903 case 0x0005:
1904 dumpByteString( "description" );
1905 break;
1906 case 0x0006:
1907 dumpByteString( "helpfile-path" );
1908 break;
1909 case 0x0009:
1910 dumpDec< sal_uInt32 >( "major" );
1911 dumpDec< sal_uInt16 >( "minor" );
1912 break;
1913 case 0x000C:
1914 dumpByteString( "constants" );
1915 break;
1916 case 0x000D:
1917 dumpByteStringWithLength( "lib-id" );
1918 dumpUnused( 6 );
1919 break;
1920 case 0x000E:
1921 dumpByteStringWithLength( "lib-id-absolute" );
1922 dumpByteStringWithLength( "lib-id-relative" );
1923 dumpDec< sal_uInt32 >( "major" );
1924 dumpDec< sal_uInt16 >( "minor" );
1925 break;
1926 case 0x0016:
1927 dumpByteString( "name" );
1928 break;
1929 case 0x0019:
1930 dumpByteString( "name" );
1931 maCurrStream.clear();
1932 mnCurrOffset = 0;
1933 break;
1934 case 0x001A:
1935 maCurrStream = dumpByteString( "stream-name" );
1936 break;
1937 case 0x001C:
1938 dumpByteString( "description" );
1939 break;
1940 case 0x002B:
1941 if( !maCurrStream.isEmpty() )
1942 mrVbaData.maStrmOffsets[ maCurrStream ] = mnCurrOffset;
1943 maCurrStream.clear();
1944 mnCurrOffset = 0;
1945 break;
1946 case 0x002F:
1947 dumpByteStringWithLength( "lib-id-twiddled" );
1948 dumpUnused( 6 );
1949 break;
1950 case 0x0030:
1951 dumpByteStringWithLength( "lib-id-extended" );
1952 dumpUnused( 6 );
1953 dumpGuid( "original-typelib" );
1954 dumpDec< sal_uInt32 >( "cookie" );
1955 break;
1956 case 0x0031:
1957 mnCurrOffset = dumpHex< sal_Int32 >( "stream-offset", "CONV-DEC" );
1958 break;
1959 case 0x0032:
1960 dumpUniString( "stream-name" );
1961 break;
1962 case 0x0033:
1963 dumpByteString( "lib-id-original" );
1964 break;
1965 case 0x003C:
1966 dumpUniString( "constants" );
1967 break;
1968 case 0x003D:
1969 dumpByteString( "helpfile-path" );
1970 break;
1971 case 0x003E:
1972 dumpUniString( "name" );
1973 break;
1974 case 0x0040:
1975 dumpUniString( "description" );
1976 break;
1977 case 0x0047:
1978 dumpUniString( "name" );
1979 break;
1980 case 0x0048:
1981 dumpUniString( "description" );
1982 break;
1986 OUString VbaDirStreamObject::dumpByteString( const String& rName )
1988 return dumpCharArray( rName, static_cast< sal_Int32 >( getRecSize() ), mrVbaData.meTextEnc );
1991 OUString VbaDirStreamObject::dumpUniString( const String& rName )
1993 return dumpUnicodeArray( rName, static_cast< sal_Int32 >( getRecSize() / 2 ) );
1996 OUString VbaDirStreamObject::dumpByteStringWithLength( const String& rName )
1998 return dumpCharArray( rName, mxStrm->readInt32(), mrVbaData.meTextEnc );
2001 VbaModuleStreamObject::VbaModuleStreamObject(
2002 const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm,
2003 const OUString& rSysFileName, VbaSharedData& rVbaData, sal_Int32 nStrmOffset ) :
2004 mrVbaData( rVbaData ),
2005 mnStrmOffset( nStrmOffset )
2007 InputObjectBase::construct( rParent, rxStrm, rSysFileName );
2010 void VbaModuleStreamObject::implDump()
2012 dumpBinary( "perf-cache", mnStrmOffset );
2013 mxOut->emptyLine();
2014 writeEmptyItem( "source-code" );
2015 IndentGuard aIndGuard( mxOut );
2016 BinaryInputStreamRef xVbaStrm( new ::oox::ole::VbaInputStream( *mxStrm ) );
2017 TextLineStreamObject( *this, xVbaStrm, mrVbaData.meTextEnc ).dump();
2020 VbaStorageObject::VbaStorageObject( const ObjectBase& rParent, const StorageRef& rxStrg, const OUString& rSysPath, VbaSharedData& rVbaData ) :
2021 OleStorageObject( rParent, rxStrg, rSysPath ),
2022 mrVbaData( rVbaData )
2024 addPreferredStream( "dir" );
2027 void VbaStorageObject::implDumpStream( const Reference< XInputStream >& rxStrm, const OUString& rStrgPath, const OUString& rStrmName, const OUString& rSysFileName )
2029 if( rStrgPath.isEmpty() && rStrmName == "dir" )
2030 VbaDirStreamObject( *this, rxStrm, rSysFileName, mrVbaData ).dump();
2031 else if( mrVbaData.isModuleStream( rStrmName ) )
2032 VbaModuleStreamObject( *this, rxStrm, rSysFileName, mrVbaData, mrVbaData.getStreamOffset( rStrmName ) ).dump();
2033 else
2034 OleStorageObject::implDumpStream( rxStrm, rStrgPath, rStrmName, rSysFileName );
2037 VbaFormStorageObject::VbaFormStorageObject( const ObjectBase& rParent, const StorageRef& rxStrg, const OUString& rSysPath, VbaSharedData& rVbaData ) :
2038 VbaContainerStorageObject( rParent, rxStrg, rSysPath ),
2039 mrVbaData( rVbaData )
2043 void VbaFormStorageObject::implDumpStream( const Reference< XInputStream >& rxStrm, const OUString& rStrgPath, const OUString& rStrmName, const OUString& rSysFileName )
2045 if ( rStrmName == "\003VBFrame" )
2046 TextLineStreamObject( *this, rxStrm, mrVbaData.meTextEnc, rSysFileName ).dump();
2047 else
2048 VbaContainerStorageObject::implDumpStream( rxStrm, rStrgPath, rStrmName, rSysFileName );
2051 VbaProjectStorageObject::VbaProjectStorageObject( const ObjectBase& rParent, const StorageRef& rxStrg, const OUString& rSysPath ) :
2052 OleStorageObject( rParent, rxStrg, rSysPath )
2054 addPreferredStorage( "VBA" );
2057 void VbaProjectStorageObject::implDumpStream( const Reference< XInputStream >& rxStrm, const OUString& rStrgPath, const OUString& rStrmName, const OUString& rSysFileName )
2059 if( rStrgPath.isEmpty() && rStrmName == "PROJECT" )
2060 TextLineStreamObject( *this, rxStrm, maVbaData.meTextEnc, rSysFileName ).dump();
2061 else
2062 OleStorageObject::implDumpStream( rxStrm, rStrgPath, rStrmName, rSysFileName );
2065 void VbaProjectStorageObject::implDumpStorage( const StorageRef& rxStrg, const OUString& rStrgPath, const OUString& rSysPath )
2067 if ( rStrgPath == "VBA" )
2068 VbaStorageObject( *this, rxStrg, rSysPath, maVbaData ).dump();
2069 else
2070 VbaFormStorageObject( *this, rxStrg, rSysPath, maVbaData ).dump();
2073 ActiveXStorageObject::ActiveXStorageObject( const ObjectBase& rParent, const StorageRef& rxStrg, const OUString& rSysPath ) :
2074 VbaContainerStorageObject( rParent, rxStrg, rSysPath )
2078 void ActiveXStorageObject::implDumpBaseStream( const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName )
2080 FormControlStreamObject( *this, rxStrm, rSysFileName ).dump();
2083 } // namespace dump
2084 } // namespace oox
2086 #endif
2088 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */