bump product version to 4.1.6.2
[LibreOffice.git] / oox / source / dump / oledumper.cxx
blobbd38cd4dc64ba04a066b9c3fc9b7c86a92c4b3ad
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 // ============================================================================
39 using namespace ::com::sun::star::io;
40 using namespace ::com::sun::star::uno;
42 // ============================================================================
44 OUString OleInputObjectBase::dumpAnsiString32( const String& rName )
46 return dumpCharArray( rName, mxStrm->readInt32(), RTL_TEXTENCODING_MS_1252 );
49 OUString OleInputObjectBase::dumpUniString32( const String& rName )
51 return dumpUnicodeArray( rName, mxStrm->readInt32() );
54 sal_Int32 OleInputObjectBase::dumpStdClipboardFormat( const String& rName )
56 return dumpDec< sal_Int32 >( rName( "clipboard-format" ), "OLE-STD-CLIPBOARD-FORMAT" );
59 OUString OleInputObjectBase::dumpAnsiString32OrStdClip( const String& rName )
61 sal_Int32 nLen = mxStrm->readInt32();
62 return (nLen < 0) ? OUString::valueOf( dumpStdClipboardFormat( rName ) ) : dumpCharArray( rName, nLen, RTL_TEXTENCODING_MS_1252 );
65 OUString OleInputObjectBase::dumpUniString32OrStdClip( const String& rName )
67 sal_Int32 nLen = mxStrm->readInt32();
68 return (nLen < 0) ? OUString::valueOf( dumpStdClipboardFormat( rName ) ) : dumpUnicodeArray( rName, nLen );
71 void OleInputObjectBase::writeOleColorItem( const String& rName, sal_uInt32 nColor )
73 MultiItemsGuard aMultiGuard( mxOut );
74 writeHexItem( rName, nColor, "OLE-COLOR" );
77 sal_uInt32 OleInputObjectBase::dumpOleColor( const String& rName )
79 sal_uInt32 nOleColor = mxStrm->readuInt32();
80 writeOleColorItem( rName, nOleColor );
81 return nOleColor;
84 // ============================================================================
85 // ============================================================================
87 StdFontObject::StdFontObject( const InputObjectBase& rParent )
89 construct( rParent );
92 void StdFontObject::implDump()
94 dumpDec< sal_uInt8 >( "version" );
95 dumpDec< sal_uInt16 >( "charset", "CHARSET" );
96 dumpHex< sal_uInt8 >( "flags", "STDFONT-FLAGS" );
97 dumpDec< sal_uInt16 >( "weight", "FONT-WEIGHT" );
98 dumpDec< sal_uInt32 >( "height", "STDFONT-HEIGHT" );
99 dumpCharArray( "name", mxStrm->readuInt8(), RTL_TEXTENCODING_ASCII_US );
102 // ============================================================================
104 StdPicObject::StdPicObject( const InputObjectBase& rParent )
106 construct( rParent );
109 void StdPicObject::implDump()
111 dumpHex< sal_uInt32 >( "identifier", "STDPIC-ID" );
112 sal_uInt32 nSize = dumpHex< sal_uInt32 >( "image-size", "CONV-DEC" );
113 dumpBinary( "image-data", nSize );
116 // ============================================================================
118 namespace {
120 const sal_uInt32 STDHLINK_HASTARGET = 0x00000001; /// Has hyperlink moniker.
121 const sal_uInt32 STDHLINK_ABSOLUTE = 0x00000002; /// Absolute path.
122 const sal_uInt32 STDHLINK_HASLOCATION = 0x00000008; /// Has target location.
123 const sal_uInt32 STDHLINK_HASDISPLAY = 0x00000010; /// Has display string.
124 const sal_uInt32 STDHLINK_HASGUID = 0x00000020; /// Has identification GUID.
125 const sal_uInt32 STDHLINK_HASTIME = 0x00000040; /// Has creation time.
126 const sal_uInt32 STDHLINK_HASFRAME = 0x00000080; /// Has frame.
127 const sal_uInt32 STDHLINK_ASSTRING = 0x00000100; /// Hyperlink as simple string.
129 } // namespace
131 // ============================================================================
132 // ============================================================================
134 OleStreamObject::OleStreamObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName )
136 construct( rParent, rxStrm, rSysFileName );
139 // ============================================================================
141 OleCompObjObject::OleCompObjObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName ) :
142 OleStreamObject( rParent, rxStrm, rSysFileName )
146 void OleCompObjObject::implDump()
148 dumpUnused( 4 );
149 dumpDec< sal_uInt32 >( "version" );
150 dumpUnused( 20 );
151 dumpAnsiString32( "ansi-display-name" );
152 dumpAnsiString32OrStdClip( "ansi-clipboard-format" );
153 if( mxStrm->getRemaining() >= 4 )
155 sal_Int32 nLen = mxStrm->readInt32();
156 if( (0 <= nLen) && (nLen <= 40) )
158 dumpCharArray( "ansi-unused", nLen, RTL_TEXTENCODING_MS_1252 );
159 if( (mxStrm->getRemaining() >= 4) && (dumpHex< sal_Int32 >( "unicode-marker" ) == 0x71B239F4) )
161 dumpUniString32( "unicode-display-name" );
162 dumpUniString32OrStdClip( "unicode-clipboard-format" );
163 dumpUniString32( "unicode-unused" );
166 else
167 writeDecItem( "length", nLen );
169 dumpRemainingStream();
172 // ============================================================================
173 // ============================================================================
175 namespace {
177 const sal_Int32 OLEPROP_ID_DICTIONARY = 0;
178 const sal_Int32 OLEPROP_ID_CODEPAGE = 1;
180 const sal_uInt16 OLEPROP_TYPE_INT16 = 2;
181 const sal_uInt16 OLEPROP_TYPE_INT32 = 3;
182 const sal_uInt16 OLEPROP_TYPE_FLOAT = 4;
183 const sal_uInt16 OLEPROP_TYPE_DOUBLE = 5;
184 const sal_uInt16 OLEPROP_TYPE_DATE = 7;
185 const sal_uInt16 OLEPROP_TYPE_STRING = 8;
186 const sal_uInt16 OLEPROP_TYPE_STATUS = 10;
187 const sal_uInt16 OLEPROP_TYPE_BOOL = 11;
188 const sal_uInt16 OLEPROP_TYPE_VARIANT = 12;
189 const sal_uInt16 OLEPROP_TYPE_INT8 = 16;
190 const sal_uInt16 OLEPROP_TYPE_UINT8 = 17;
191 const sal_uInt16 OLEPROP_TYPE_UINT16 = 18;
192 const sal_uInt16 OLEPROP_TYPE_UINT32 = 19;
193 const sal_uInt16 OLEPROP_TYPE_INT64 = 20;
194 const sal_uInt16 OLEPROP_TYPE_UINT64 = 21;
195 const sal_uInt16 OLEPROP_TYPE_STRING8 = 30;
196 const sal_uInt16 OLEPROP_TYPE_STRING16 = 31;
197 const sal_uInt16 OLEPROP_TYPE_FILETIME = 64;
198 const sal_uInt16 OLEPROP_TYPE_BLOB = 65;
199 const sal_uInt16 OLEPROP_TYPE_STREAM = 66;
200 const sal_uInt16 OLEPROP_TYPE_STORAGE = 67;
201 const sal_uInt16 OLEPROP_TYPE_CLIPFMT = 71;
203 const sal_uInt16 OLEPROP_TYPE_SIMPLE = 0x0000;
204 const sal_uInt16 OLEPROP_TYPE_VECTOR = 0x1000;
205 const sal_uInt16 OLEPROP_TYPE_ARRAY = 0x2000;
207 const sal_uInt16 CODEPAGE_UNICODE = 1200;
209 const sal_uInt32 AX_STRING_COMPRESSED = 0x80000000;
211 } // namespace
213 // ============================================================================
215 OlePropertyStreamObject::OlePropertyStreamObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName )
217 construct( rParent, rxStrm, rSysFileName );
220 void OlePropertyStreamObject::implDump()
222 OUStringVector aGuidVec;
223 ::std::vector< sal_uInt32 > aStartPosVec;
225 // dump header
226 writeEmptyItem( "HEADER" );
228 IndentGuard aIndGuard( mxOut );
229 dumpHex< sal_uInt16 >( "byte-order", "OLEPROP-BYTE-ORDER" );
230 dumpDec< sal_uInt16 >( "version" );
231 dumpDec< sal_uInt16 >( "os-minor" );
232 dumpDec< sal_uInt16 >( "os-type", "OLEPROP-OSTYPE" );
233 dumpGuid( "guid" );
234 sal_Int32 nSectCount = dumpDec< sal_Int32 >( "section-count" );
236 // dump table of section positions
238 TableGuard aTabGuard( mxOut, 15, 60 );
239 mxOut->resetItemIndex();
240 for( sal_Int32 nSectIdx = 0; !mxStrm->isEof() && (nSectIdx < nSectCount); ++nSectIdx )
242 MultiItemsGuard aMultiGuard( mxOut );
243 writeEmptyItem( "#section" );
244 aGuidVec.push_back( dumpGuid( "guid" ) );
245 aStartPosVec.push_back( dumpHex< sal_uInt32 >( "start-pos", "CONV-DEC" ) );
249 mxOut->emptyLine();
251 // dump sections
252 for( size_t nSectIdx = 0; !mxStrm->isEof() && (nSectIdx < aStartPosVec.size()); ++nSectIdx )
253 dumpSection( aGuidVec[ nSectIdx ], aStartPosVec[ nSectIdx ] );
256 void OlePropertyStreamObject::dumpSection( const OUString& rGuid, sal_uInt32 nStartPos )
258 // property ID names
259 mxPropIds = cfg().createNameList< ConstList >( "OLEPROP-IDS" );
260 OUString aGuidName = cfg().getStringOption( rGuid, OUString() );
261 if ( aGuidName == "GlobalDocProp" )
262 mxPropIds->includeList( cfg().getNameList( "OLEPROP-GLOBALIDS" ) );
263 else if ( aGuidName == "BuiltinDocProp" )
264 mxPropIds->includeList( cfg().getNameList( "OLEPROP-BUILTINIDS" ) );
265 else
266 mxPropIds->includeList( cfg().getNameList( "OLEPROP-BASEIDS" ) );
268 // property ID/position map
269 typedef ::std::map< sal_Int32, sal_uInt32 > PropertyPosMap;
270 PropertyPosMap aPropMap;
272 // dump section header line
273 writeSectionHeader( rGuid, nStartPos );
275 // seek to section
276 IndentGuard aIndGuard( mxOut );
277 if( startElement( nStartPos ) )
279 // dump section header
280 dumpDec< sal_Int32 >( "size" );
281 sal_Int32 nPropCount = dumpDec< sal_Int32 >( "property-count" );
283 // dump table of property positions
285 TableGuard aTabGuard( mxOut, 15, 25 );
286 mxOut->resetItemIndex();
287 for( sal_Int32 nPropIdx = 0; !mxStrm->isEof() && (nPropIdx < nPropCount); ++nPropIdx )
289 MultiItemsGuard aMultiGuard( mxOut );
290 writeEmptyItem( "#property" );
291 sal_Int32 nPropId = dumpDec< sal_Int32 >( "id", mxPropIds );
292 sal_uInt32 nPropPos = nStartPos + dumpHex< sal_uInt32 >( "start-pos", "CONV-DEC" );
293 aPropMap[ nPropId ] = nPropPos;
297 mxOut->emptyLine();
299 // code page property
300 meTextEnc = RTL_TEXTENCODING_MS_1252;
301 mbIsUnicode = false;
302 PropertyPosMap::iterator aCodePageIt = aPropMap.find( OLEPROP_ID_CODEPAGE );
303 if( aCodePageIt != aPropMap.end() )
305 dumpCodePageProperty( aCodePageIt->second );
306 aPropMap.erase( aCodePageIt );
309 // dictionary property
310 PropertyPosMap::iterator aDictIt = aPropMap.find( OLEPROP_ID_DICTIONARY );
311 if( aDictIt != aPropMap.end() )
313 dumpDictionaryProperty( aDictIt->second );
314 aPropMap.erase( aDictIt );
317 // other properties
318 for( PropertyPosMap::const_iterator aIt = aPropMap.begin(), aEnd = aPropMap.end(); aIt != aEnd; ++aIt )
319 dumpProperty( aIt->first, aIt->second );
321 // remove the user defined list of property ID names
322 cfg().eraseNameList( "OLEPROP-IDS" );
325 void OlePropertyStreamObject::dumpProperty( sal_Int32 nPropId, sal_uInt32 nStartPos )
327 writePropertyHeader( nPropId, nStartPos );
328 IndentGuard aIndGuard( mxOut );
329 if( startElement( nStartPos ) )
330 dumpPropertyContents( nPropId );
331 mxOut->emptyLine();
334 void OlePropertyStreamObject::dumpCodePageProperty( sal_uInt32 nStartPos )
336 writePropertyHeader( OLEPROP_ID_CODEPAGE, nStartPos );
337 IndentGuard aIndGuard( mxOut );
338 if( startElement( nStartPos ) )
340 sal_uInt16 nType = dumpPropertyType();
341 if( nType == OLEPROP_TYPE_INT16 )
343 sal_uInt16 nCodePage = dumpDec< sal_uInt16 >( "codepage", "CODEPAGES" );
344 rtl_TextEncoding eNewTextEnc = rtl_getTextEncodingFromWindowsCodePage( nCodePage );
345 if( eNewTextEnc != RTL_TEXTENCODING_DONTKNOW )
346 meTextEnc = eNewTextEnc;
347 mbIsUnicode = nCodePage == CODEPAGE_UNICODE;
349 else
350 dumpPropertyContents( OLEPROP_ID_CODEPAGE );
352 mxOut->emptyLine();
355 void OlePropertyStreamObject::dumpDictionaryProperty( sal_uInt32 nStartPos )
357 writePropertyHeader( OLEPROP_ID_DICTIONARY, nStartPos );
358 IndentGuard aIndGuard( mxOut );
359 if( startElement( nStartPos ) )
361 sal_Int32 nCount = dumpDec< sal_Int32 >( "count" );
362 for( sal_Int32 nIdx = 0; !mxStrm->isEof() && (nIdx < nCount); ++nIdx )
364 MultiItemsGuard aMultiGuard( mxOut );
365 TableGuard aTabGuard( mxOut, 10, 20 );
366 sal_Int32 nId = dumpDec< sal_Int32 >( "id" );
367 OUString aName = dumpString8( "name" );
368 if( mxPropIds.get() )
369 mxPropIds->setName( nId, aName );
372 mxOut->emptyLine();
375 sal_uInt16 OlePropertyStreamObject::dumpPropertyContents( sal_Int32 nPropId )
377 sal_uInt16 nType = dumpPropertyType();
378 sal_uInt16 nBaseType = static_cast< sal_uInt16 >( nType & 0x0FFF );
379 sal_uInt16 nArrayType = static_cast< sal_uInt16 >( nType & 0xF000 );
380 switch( nArrayType )
382 case OLEPROP_TYPE_SIMPLE: dumpPropertyValue( nPropId, nBaseType ); break;
383 case OLEPROP_TYPE_VECTOR: dumpPropertyVector( nPropId, nBaseType ); break;
384 case OLEPROP_TYPE_ARRAY: dumpPropertyArray( nPropId, nBaseType ); break;
386 return nType;
389 void OlePropertyStreamObject::dumpPropertyValue( sal_Int32 nPropId, sal_uInt16 nBaseType )
391 switch( nBaseType )
393 case OLEPROP_TYPE_INT16: dumpDec< sal_Int16 >( "value" ); break;
394 case OLEPROP_TYPE_INT32: dumpDec< sal_Int32 >( "value" ); break;
395 case OLEPROP_TYPE_FLOAT: dumpDec< float >( "value" ); break;
396 case OLEPROP_TYPE_DOUBLE: dumpDec< double >( "value" ); break;
397 case OLEPROP_TYPE_DATE: dumpDec< double >( "date" ); break;
398 case OLEPROP_TYPE_STRING: dumpString8( "value" ); break;
399 case OLEPROP_TYPE_STATUS: dumpHex< sal_Int32 >( "status" ); break;
400 case OLEPROP_TYPE_BOOL: dumpBool< sal_Int16 >( "value" ); break;
401 case OLEPROP_TYPE_VARIANT: dumpPropertyContents( nPropId ); break;
402 case OLEPROP_TYPE_INT8: dumpDec< sal_Int8 >( "value" ); break;
403 case OLEPROP_TYPE_UINT8: dumpDec< sal_uInt8 >( "value" ); break;
404 case OLEPROP_TYPE_UINT16: dumpDec< sal_uInt16 >( "value" ); break;
405 case OLEPROP_TYPE_UINT32: dumpDec< sal_uInt32 >( "value" ); break;
406 case OLEPROP_TYPE_INT64: dumpDec< sal_Int64 >( "value" ); break;
407 case OLEPROP_TYPE_UINT64: dumpDec< sal_uInt64 >( "value" ); break;
408 case OLEPROP_TYPE_STRING8: dumpString8( "value" ); break;
409 case OLEPROP_TYPE_STRING16: dumpString16( "value" ); break;
410 case OLEPROP_TYPE_FILETIME: dumpFileTime( "file-time" ); break;
411 case OLEPROP_TYPE_BLOB: dumpBlob( nPropId, "data" ); break;
412 case OLEPROP_TYPE_STREAM: dumpString8( "stream-name" ); break;
413 case OLEPROP_TYPE_STORAGE: dumpString8( "storage-name" ); break;
414 case OLEPROP_TYPE_CLIPFMT: dumpBlob( nPropId, "clip-data" ); break;
418 void OlePropertyStreamObject::dumpPropertyVector( sal_Int32 nPropId, sal_uInt16 nBaseType )
420 sal_Int32 nElemCount = dumpDec< sal_Int32 >( "element-count" );
421 for( sal_Int32 nElemIdx = 0; !mxStrm->isEof() && (nElemIdx < nElemCount); ++nElemIdx )
423 mxOut->resetItemIndex( nElemIdx );
424 writeEmptyItem( "#element" );
425 IndentGuard aIndGuard( mxOut );
426 dumpPropertyValue( nPropId, nBaseType );
430 void OlePropertyStreamObject::dumpPropertyArray( sal_Int32 /*nPropId*/, sal_uInt16 /*nBaseType*/ )
432 // TODO
435 sal_uInt16 OlePropertyStreamObject::dumpPropertyType()
437 return static_cast< sal_uInt16 >( dumpHex< sal_Int32 >( "type", "OLEPROP-TYPE" ) & 0xFFFF );
440 void OlePropertyStreamObject::dumpBlob( sal_Int32 nPropId, const String& rName )
442 sal_Int32 nSize = dumpDec< sal_Int32 >( "data-size" );
443 if( nSize > 0 )
445 OUString aPropName = mxPropIds->getName( cfg(), nPropId );
446 if( aPropName == "'_PID_HLINKS'" )
447 dumpHlinks( nSize );
448 else
449 dumpBinary( rName, nSize );
453 OUString OlePropertyStreamObject::dumpString8( const String& rName )
455 sal_Int32 nLen = dumpDec< sal_Int32 >( "string-len" );
456 return mbIsUnicode ? dumpCharArray16( rName, nLen ) : dumpCharArray8( rName, nLen );
459 OUString OlePropertyStreamObject::dumpCharArray8( const String& rName, sal_Int32 nLen )
461 sal_Int32 nNewLen = getLimitedValue< sal_Int32, sal_Int32 >( nLen, 0, 1024 );
462 OUString aData = mxStrm->readCharArrayUC( nNewLen, meTextEnc );
463 writeStringItem( rName, aData );
464 return aData;
467 OUString OlePropertyStreamObject::dumpString16( const String& rName )
469 sal_Int32 nLen = dumpDec< sal_Int32 >( "string-len" );
470 return dumpCharArray16( rName, nLen );
473 OUString OlePropertyStreamObject::dumpCharArray16( const String& rName, sal_Int32 nLen )
475 sal_Int32 nNewLen = getLimitedValue< sal_Int32, sal_Int32 >( nLen, 0, 1024 );
476 OUString aData = mxStrm->readUnicodeArray( nNewLen );
477 writeStringItem( rName, aData );
478 if( nNewLen & 1 ) dumpUnused( 2 ); // always padding to 32bit
479 return aData;
482 bool OlePropertyStreamObject::dumpTypedProperty( const String& rName, sal_uInt16 nExpectedType )
484 writeEmptyItem( rName );
485 IndentGuard aIndGuard( mxOut );
486 return (dumpPropertyContents( -1 ) == nExpectedType) && !mxStrm->isEof();
489 void OlePropertyStreamObject::dumpHlinks( sal_Int32 nSize )
491 sal_Int64 nEndPos = mxStrm->tell() + nSize;
492 sal_Int32 nCount = dumpDec< sal_Int32 >( "property-count" );
493 bool bValid = true;
494 for( sal_Int32 nHlinkIndex = 0, nHlinkCount = nCount / 6; bValid && !mxStrm->isEof() && (nHlinkIndex < nHlinkCount); ++nHlinkIndex )
496 writeEmptyItem( "HYPERLINK" );
497 IndentGuard aIndGuard( mxOut );
498 bValid =
499 dumpTypedProperty( "hash", OLEPROP_TYPE_INT32 ) &&
500 dumpTypedProperty( "app", OLEPROP_TYPE_INT32 ) &&
501 dumpTypedProperty( "shape-id", OLEPROP_TYPE_INT32 ) &&
502 dumpTypedProperty( "info", OLEPROP_TYPE_INT32 ) &&
503 dumpTypedProperty( "target", OLEPROP_TYPE_STRING16 ) &&
504 dumpTypedProperty( "location", OLEPROP_TYPE_STRING16 );
506 dumpRemainingTo( nEndPos );
509 bool OlePropertyStreamObject::startElement( sal_uInt32 nStartPos )
511 mxStrm->seek( nStartPos );
512 if( mxStrm->isEof() )
513 writeInfoItem( "stream-state", OOX_DUMP_ERR_STREAM );
514 return !mxStrm->isEof();
517 void OlePropertyStreamObject::writeSectionHeader( const OUString& rGuid, sal_uInt32 nStartPos )
519 MultiItemsGuard aMultiGuard( mxOut );
520 writeEmptyItem( "SECTION" );
521 writeHexItem( "pos", nStartPos, "CONV-DEC" );
522 writeGuidItem( "guid", rGuid );
525 void OlePropertyStreamObject::writePropertyHeader( sal_Int32 nPropId, sal_uInt32 nStartPos )
527 MultiItemsGuard aMultiGuard( mxOut );
528 writeEmptyItem( "PROPERTY" );
529 writeHexItem( "pos", nStartPos, "CONV-DEC" );
530 writeDecItem( "id", nPropId, mxPropIds );
533 // ============================================================================
535 OleStorageObject::OleStorageObject( const ObjectBase& rParent, const StorageRef& rxStrg, const OUString& rSysPath )
537 construct( rParent, rxStrg, rSysPath );
540 void OleStorageObject::construct( const ObjectBase& rParent, const StorageRef& rxStrg, const OUString& rSysPath )
542 StorageObjectBase::construct( rParent, rxStrg, rSysPath );
545 void OleStorageObject::implDumpStream( const Reference< XInputStream >& rxStrm, const OUString& /*rStrgPath*/, const OUString& rStrmName, const OUString& rSysFileName )
547 if ( rStrmName == "\001CompObj" )
548 OleCompObjObject( *this, rxStrm, rSysFileName ).dump();
549 else if( rStrmName == "\005SummaryInformation" || rStrmName == "\005DocumentSummaryInformation" )
550 OlePropertyStreamObject( *this, rxStrm, rSysFileName ).dump();
551 else
552 BinaryStreamObject( *this, rxStrm, rSysFileName ).dump();
555 // ============================================================================
556 // ============================================================================
558 ComCtlObjectBase::ComCtlObjectBase( const InputObjectBase& rParent,
559 sal_uInt32 nDataId5, sal_uInt32 nDataId6, sal_uInt16 nVersion, bool bCommonPart, bool bComplexPart ) :
560 mnDataId5( nDataId5 ),
561 mnDataId6( nDataId6 ),
562 mnVersion( nVersion ),
563 mbCommonPart( bCommonPart ),
564 mbComplexPart( bComplexPart )
566 construct( rParent );
569 void ComCtlObjectBase::implDump()
571 sal_uInt32 nCommonSize = 0;
572 dumpComCtlSize() && dumpComCtlData( nCommonSize ) && (!mbCommonPart || dumpComCtlCommon( nCommonSize )) && (!mbComplexPart || dumpComCtlComplex());
575 void ComCtlObjectBase::implDumpCommonExtra( sal_Int64 /*nEndPos*/ )
579 void ComCtlObjectBase::implDumpCommonTrailing()
583 bool ComCtlObjectBase::dumpComCtlHeader( sal_uInt32 nExpId, sal_uInt16 nExpMajor, sal_uInt16 nExpMinor )
585 // no idea if all this is correct...
586 sal_uInt32 nId = dumpHex< sal_uInt32 >( "header-id", "COMCTL-HEADER-IDS" );
587 ItemGuard aItem( mxOut, "version" );
588 sal_uInt16 nMinor, nMajor;
589 *mxStrm >> nMinor >> nMajor;
590 mxOut->writeDec( nMajor );
591 mxOut->writeChar( '.' );
592 mxOut->writeDec( nMinor );
593 return !mxStrm->isEof() && (nId == nExpId) && ((nExpMajor == SAL_MAX_UINT16) || (nExpMajor == nMajor)) && ((nExpMinor == SAL_MAX_UINT16) || (nExpMinor == nMinor));
596 bool ComCtlObjectBase::dumpComCtlSize()
598 if( dumpComCtlHeader( 0x12344321, 0, 8 ) )
600 IndentGuard aIndGuard( mxOut );
601 dumpDec< sal_Int32 >( "width", "CONV-HMM-TO-CM" );
602 dumpDec< sal_Int32 >( "height", "CONV-HMM-TO-CM" );
603 return !mxStrm->isEof();
605 return false;
608 bool ComCtlObjectBase::dumpComCtlData( sal_uInt32& ornCommonPartSize )
610 if( dumpComCtlHeader( (mnVersion == 5) ? mnDataId5 : mnDataId6, mnVersion ) )
612 IndentGuard aIndGuard( mxOut );
613 if( mbCommonPart )
614 ornCommonPartSize = dumpDec< sal_uInt32 >( "common-part-size" );
615 implDumpProperties();
616 return !mxStrm->isEof();
618 return false;
621 bool ComCtlObjectBase::dumpComCtlCommon( sal_uInt32 nPartSize )
623 sal_Int64 nEndPos = mxStrm->tell() + nPartSize;
624 if( (nPartSize >= 16) && dumpComCtlHeader( 0xABCDEF01, 5, 0 ) )
626 IndentGuard aIndGuard( mxOut );
627 dumpUnknown( 4 );
628 dumpHex< sal_uInt32 >( "common-flags", "COMCTL-COMMON-FLAGS" );
629 implDumpCommonExtra( nEndPos );
630 dumpRemainingTo( nEndPos );
631 implDumpCommonTrailing();
632 return !mxStrm->isEof();
634 return false;
637 bool ComCtlObjectBase::dumpComCtlComplex()
639 if( dumpComCtlHeader( 0xBDECDE1F, 5, 1 ) )
641 IndentGuard aIndGuard( mxOut );
642 sal_uInt32 nFlags = dumpHex< sal_uInt32 >( "comctl-complex-flags", "COMCTL-COMPLEX-FLAGS" );
643 if( !mxStrm->isEof() && (nFlags & 0x01) )
645 writeEmptyItem( "font" );
646 IndentGuard aIndGuard2( mxOut );
647 OUString aClassName = cfg().getStringOption( dumpGuid(), OUString() );
648 if ( aClassName == "StdFont" )
649 StdFontObject( *this ).dump();
651 if( !mxStrm->isEof() && (nFlags & 0x02) )
653 writeEmptyItem( "mouse-icon" );
654 IndentGuard aIndGuard2( mxOut );
655 OUString aClassName = cfg().getStringOption( dumpGuid(), OUString() );
656 if ( aClassName == "StdPic" )
657 StdPicObject( *this ).dump();
659 return !mxStrm->isEof();
661 return false;
664 // ============================================================================
666 ComCtlScrollBarObject::ComCtlScrollBarObject( const InputObjectBase& rParent, sal_uInt16 nVersion ) :
667 ComCtlObjectBase( rParent, SAL_MAX_UINT32, 0x99470A83, nVersion, true, true )
671 void ComCtlScrollBarObject::implDumpProperties()
673 dumpHex< sal_uInt32 >( "flags", "COMCTL-SCROLLBAR-FLAGS" );
674 dumpDec< sal_Int32 >( "large-change" );
675 dumpDec< sal_Int32 >( "small-change" );
676 dumpDec< sal_Int32 >( "min" );
677 dumpDec< sal_Int32 >( "max" );
678 dumpDec< sal_Int32 >( "value" );
681 // ============================================================================
683 ComCtlProgressBarObject::ComCtlProgressBarObject( const InputObjectBase& rParent, sal_uInt16 nVersion ) :
684 ComCtlObjectBase( rParent, 0xE6E17E84, 0x97AB8A01, nVersion, true, true )
688 void ComCtlProgressBarObject::implDumpProperties()
690 dumpDec< float >( "min" );
691 dumpDec< float >( "max" );
692 if( mnVersion == 6 )
694 dumpBool< sal_uInt16 >( "vertical" );
695 dumpBool< sal_uInt16 >( "smooth-scroll" );
699 // ============================================================================
701 ComCtlSliderObject::ComCtlSliderObject( const InputObjectBase& rParent, sal_uInt16 nVersion ) :
702 ComCtlObjectBase( rParent, 0xE6E17E86, 0x0A2BAE11, nVersion, true, true )
706 void ComCtlSliderObject::implDumpProperties()
708 dumpBool< sal_Int32 >( "vertical" );
709 dumpDec< sal_Int32 >( "large-change" );
710 dumpDec< sal_Int32 >( "small-change" );
711 dumpDec< sal_Int32 >( "min" );
712 dumpDec< sal_Int32 >( "max" );
713 dumpDec< sal_Int16 >( "select-range", "COMCTL-SLIDER-SELECTRANGE" );
714 dumpUnused( 2 );
715 dumpDec< sal_Int32 >( "select-start" );
716 dumpDec< sal_Int32 >( "select-length" );
717 dumpDec< sal_Int32 >( "tick-style", "COMCTL-SLIDER-TICKSTYLE" );
718 dumpDec< sal_Int32 >( "tick-frequency" );
719 dumpDec< sal_Int32 >( "value" );
720 if( mnVersion == 6 )
721 dumpBool< sal_Int32 >( "tooltip-below" );
724 // ============================================================================
726 ComCtlUpDownObject::ComCtlUpDownObject( const InputObjectBase& rParent, sal_uInt16 nVersion ) :
727 ComCtlObjectBase( rParent, 0xFF3626A0, 0xFF3626A0, nVersion, false, false )
731 void ComCtlUpDownObject::implDumpProperties()
733 dumpUnknown( 16 ); // buddy-property, somehow
734 dumpDec< sal_Int32 >( "buddy-control" );
735 dumpUnknown( 8 );
736 dumpDec< sal_Int32 >( "value" );
737 dumpUnknown( 4 );
738 dumpDec< sal_Int32 >( "increment" );
739 dumpDec< sal_Int32 >( "max" );
740 dumpDec< sal_Int32 >( "min" );
741 dumpHex< sal_uInt32 >( "flags-1", "COMCTL-UPDOWN-FLAGS1" );
742 dumpHex< sal_uInt32 >( "flags-2", "COMCTL-UPDOWN-FLAGS2" );
743 dumpUnknown( 4 );
746 // ============================================================================
748 ComCtlImageListObject::ComCtlImageListObject( const InputObjectBase& rParent, sal_uInt16 nVersion ) :
749 ComCtlObjectBase( rParent, 0xE6E17E80, 0xE6E17E80, nVersion, true, false )
753 void ComCtlImageListObject::implDumpProperties()
755 dumpDec< sal_uInt16 >( "image-width" );
756 dumpDec< sal_uInt16 >( "image-height" );
757 dumpOleColor( "mask-color" );
758 dumpBool< sal_Int16 >( "use-mask-color" );
759 dumpUnknown( 2 );
762 void ComCtlImageListObject::implDumpCommonExtra( sal_Int64 /*nEndPos*/ )
764 dumpUnknown( 4 );
765 dumpOleColor( "back-color" );
766 dumpUnknown( 4 );
767 sal_Int32 nImageCount = dumpDec< sal_Int32 >( "image-count" );
768 mxOut->resetItemIndex();
769 for( sal_Int32 nImageIndex = 0; (nImageIndex < nImageCount) && !mxStrm->isEof(); ++nImageIndex )
771 writeEmptyItem( "#image" );
772 IndentGuard aIndGuard( mxOut );
773 sal_uInt8 nFlags = dumpHex< sal_uInt8 >( "text-flags", "COMCTL-IMAGELIST-TEXTFLAGS" );
774 if( nFlags & 0x01 ) dumpUniString32( "caption" );
775 if( nFlags & 0x02 ) dumpUniString32( "key" );
779 void ComCtlImageListObject::implDumpCommonTrailing()
781 sal_Int32 nImageCount = dumpDec< sal_Int32 >( "image-count" );
782 mxOut->resetItemIndex();
783 for( sal_Int32 nImageIndex = 0; (nImageIndex < nImageCount) && !mxStrm->isEof(); ++nImageIndex )
785 writeEmptyItem( "#image" );
786 IndentGuard aIndGuard( mxOut );
787 dumpDec< sal_Int32 >( "index" );
788 StdPicObject( *this ).dump();
792 // ============================================================================
794 ComCtlTabStripObject::ComCtlTabStripObject( const InputObjectBase& rParent, sal_uInt16 nVersion ) :
795 ComCtlObjectBase( rParent, 0xE6E17E8A, 0xD12A7AC1, nVersion, true, true )
799 void ComCtlTabStripObject::implDumpProperties()
801 dumpHex< sal_uInt32 >( "flags-1", "COMCTL-TABSTRIP-FLAGS1" );
802 dumpDec< sal_uInt16 >( "tab-fixed-width", "CONV-HMM-TO-CM" );
803 dumpDec< sal_uInt16 >( "tab-fixed-height", "CONV-HMM-TO-CM" );
804 if( mnVersion == 6 )
806 dumpHex< sal_uInt32 >( "flags-2", "COMCTL-TABSTRIP-FLAGS2" );
807 dumpDec< sal_uInt16 >( "tab-min-width", "CONV-HMM-TO-CM" );
808 dumpUnknown( 2 );
809 dumpHex< sal_uInt32 >( "flags-3", "COMCTL-TABSTRIP-FLAGS3" );
813 void ComCtlTabStripObject::implDumpCommonExtra( sal_Int64 /*nEndPos*/ )
815 dumpUnknown( 12 );
816 dumpUniString32( "image-list" );
817 sal_Int32 nTabCount = dumpDec< sal_Int32 >( "tab-count" );
818 mxOut->resetItemIndex();
819 for( sal_Int32 nTabIndex = 0; (nTabIndex < nTabCount) && !mxStrm->isEof(); ++nTabIndex )
821 writeEmptyItem( "#tab" );
822 IndentGuard aIndGuard( mxOut );
823 dumpUnknown( 4 );
824 sal_uInt32 nTabFlags = dumpHex< sal_uInt32 >( "tab-flags", "COMCTL-TABSTRIP-TABFLAGS" );
825 if( nTabFlags & 0x01 ) dumpUniString32( "caption" );
826 if( nTabFlags & 0x02 ) dumpUniString32( "key" );
827 if( nTabFlags & 0x04 ) dumpUniString32( "tag" );
828 if( nTabFlags & 0x08 ) dumpUniString32( "tooltip" );
829 dumpDec< sal_uInt16 >( "image-id" );
833 // ============================================================================
835 ComCtlTreeViewObject::ComCtlTreeViewObject( const InputObjectBase& rParent, sal_uInt16 nVersion ) :
836 ComCtlObjectBase( rParent, 0xE6E17E8E, 0x6AC13CB1, nVersion, true, true ),
837 mnStringFlags( 0 )
841 void ComCtlTreeViewObject::implDumpProperties()
843 dumpHex< sal_uInt32 >( "flags", "COMCTL-TREEVIEW-FLAGS" );
844 dumpDec< sal_Int32 >( "indentation", "CONV-HMM-TO-CM" );
845 if( mnVersion == 6 )
846 dumpHex< sal_uInt32 >( "flags-2", "COMCTL-TREEVIEW-FLAGS2" );
847 mnStringFlags = dumpHex< sal_uInt32 >( "string-flags", "COMCTL-TREEVIEW-STRINGFLAGS" );
850 void ComCtlTreeViewObject::implDumpCommonExtra( sal_Int64 /*nEndPos*/ )
852 dumpOleColor( "text-color" );
853 dumpOleColor( "back-color" );
854 dumpUnknown( 4 );
855 if( mnStringFlags & 0x02 )
856 dumpUniString32( "image-list" );
857 dumpUniString32( "path-separator" );
860 // ============================================================================
862 ComCtlStatusBarObject::ComCtlStatusBarObject( const InputObjectBase& rParent, sal_uInt16 nVersion ) :
863 ComCtlObjectBase( rParent, 0xE6E17E88, SAL_MAX_UINT32, nVersion, true, true )
867 void ComCtlStatusBarObject::implDumpProperties()
869 dumpBool< sal_Int32 >( "style-simple-text" );
870 dumpBool< sal_Int16 >( "show-tips" );
871 dumpUnknown( 2 );
874 void ComCtlStatusBarObject::implDumpCommonExtra( sal_Int64 /*nEndPos*/ )
876 dumpUnknown( 12 );
877 dumpUniString32( "simple-text" );
878 sal_Int32 nPanelCount = dumpDec< sal_Int32 >( "panel-count" );
879 mxOut->resetItemIndex();
880 for( sal_Int32 nPanelIndex = 0; (nPanelIndex < nPanelCount) && !mxStrm->isEof(); ++nPanelIndex )
882 writeEmptyItem( "#panel" );
883 IndentGuard aIndGuard( mxOut );
884 dumpHex< sal_uInt32 >( "panel-flags", "COMCTL-STATUSBAR-PANELFLAGS" );
885 dumpDec< sal_Int32 >( "current-width", "CONV-HMM-TO-CM" );
886 dumpDec< sal_Int32 >( "minimal-width", "CONV-HMM-TO-CM" );
887 sal_uInt32 nTextFlags = dumpHex< sal_uInt32 >( "text-flags", "COMCTL-STATUSBAR-TEXTFLAGS" );
888 if( nTextFlags & 0x01 ) dumpUniString32( "text" );
889 if( nTextFlags & 0x02 ) dumpUniString32( "vis-text" );
890 if( nTextFlags & 0x04 ) dumpUniString32( "key" );
891 if( nTextFlags & 0x08 ) dumpUniString32( "tag" );
892 if( nTextFlags & 0x10 ) dumpUniString32( "tooltip" );
896 void ComCtlStatusBarObject::implDumpCommonTrailing()
898 sal_Int32 nImageCount = dumpDec< sal_Int32 >( "image-count" );
899 mxOut->resetItemIndex();
900 for( sal_Int32 nImageIndex = 0; (nImageIndex < nImageCount) && !mxStrm->isEof(); ++nImageIndex )
902 writeEmptyItem( "#image" );
903 IndentGuard aIndGuard( mxOut );
904 dumpDec< sal_Int32 >( "panel-index" );
905 StdPicObject( *this ).dump();
909 // ============================================================================
910 // ============================================================================
912 void AxPropertyObjectBase::construct( const ObjectBase& rParent,
913 const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName, const String& rPropNameList, bool b64BitPropFlags )
915 OleInputObjectBase::construct( rParent, rxStrm, rSysFileName );
916 constructAxPropObj( rPropNameList, b64BitPropFlags );
919 void AxPropertyObjectBase::construct( const InputObjectBase& rParent,
920 const String& rPropNameList, bool b64BitPropFlags )
922 OleInputObjectBase::construct( rParent );
923 constructAxPropObj( rPropNameList, b64BitPropFlags );
926 bool AxPropertyObjectBase::implIsValid() const
928 return OleInputObjectBase::implIsValid() && mxStrm->isSeekable();
931 void AxPropertyObjectBase::implDump()
933 mbValid = true;
934 // header
935 setAlignAnchor();
936 dumpVersion();
937 sal_uInt16 nSize = dumpDec< sal_uInt16 >( "size" );
938 mnPropertiesEnd = mxStrm->tell() + nSize;
939 // property flags
940 maLargeProps.clear();
941 maStreamProps.clear();
942 mnPropFlags = dumpHex< sal_Int64, sal_uInt32 >( mb64BitPropFlags, "properties", mxPropNames );
943 mnCurrProp = 0;
944 // properties
945 dumpShortProperties();
946 dumpLargeProperties();
947 setAlignAnchor();
948 if( ensureValid() )
949 implDumpExtended();
952 void AxPropertyObjectBase::implDumpShortProperties()
956 void AxPropertyObjectBase::implDumpExtended()
960 bool AxPropertyObjectBase::ensureValid( bool bCondition )
962 if( mbValid && (!bCondition || mxStrm->isEof()) )
964 if( !bCondition )
965 writeInfoItem( "state", OOX_DUMP_ERRASCII( "format-error" ) );
966 mbValid = false;
968 return mbValid;
971 void AxPropertyObjectBase::setAlignAnchor()
973 mnPropertiesStart = mxStrm->tell();
976 bool AxPropertyObjectBase::startNextProperty()
978 if( mnCurrProp == 0 ) mnCurrProp = 1; else mnCurrProp <<= 1;
979 bool bHasProp = getFlag( mnPropFlags, mnCurrProp );
980 setFlag( mnPropFlags, mnCurrProp, false );
981 return ensureValid() && bHasProp;
984 OUString AxPropertyObjectBase::getPropertyName() const
986 return cfg().getName( mxPropNames, mnCurrProp );
989 sal_uInt32 AxPropertyObjectBase::dumpFlagsProperty( sal_uInt32 nDefault, const sal_Char* pcNameList )
991 if( startNextProperty() )
993 alignInput< sal_uInt32 >();
994 return dumpHex< sal_uInt32 >( getPropertyName(), pcNameList );
996 return nDefault;
999 sal_uInt32 AxPropertyObjectBase::dumpColorProperty( sal_uInt32 nDefault )
1001 if( startNextProperty() )
1003 alignInput< sal_uInt32 >();
1004 return dumpOleColor( getPropertyName() );
1006 return nDefault;
1009 sal_Unicode AxPropertyObjectBase::dumpUnicodeProperty()
1011 if( startNextProperty() )
1013 alignInput< sal_uInt16 >();
1014 return dumpUnicode( getPropertyName() );
1016 return '\0';
1019 void AxPropertyObjectBase::dumpUnknownProperty()
1021 if( startNextProperty() )
1022 ensureValid( false );
1025 void AxPropertyObjectBase::dumpPosProperty()
1027 if( startNextProperty() )
1028 maLargeProps.push_back( LargeProperty( LargeProperty::PROPTYPE_POS, getPropertyName(), 8 ) );
1031 void AxPropertyObjectBase::dumpSizeProperty()
1033 if( startNextProperty() )
1034 maLargeProps.push_back( LargeProperty( LargeProperty::PROPTYPE_SIZE, getPropertyName(), 8 ) );
1037 void AxPropertyObjectBase::dumpGuidProperty( OUString* pValue )
1039 if( startNextProperty() )
1040 maLargeProps.push_back( LargeProperty( LargeProperty::PROPTYPE_GUID, getPropertyName(), 16, pValue ) );
1043 void AxPropertyObjectBase::dumpStringProperty( OUString* pValue )
1045 if( startNextProperty() )
1047 alignInput< sal_uInt32 >();
1048 sal_uInt32 nLen = dumpHex< sal_uInt32 >( getPropertyName(), "AX-STRINGLEN" );
1049 maLargeProps.push_back( LargeProperty( LargeProperty::PROPTYPE_STRING, getPropertyName(), nLen, pValue ) );
1053 void AxPropertyObjectBase::dumpStringArrayProperty()
1055 if( startNextProperty() )
1057 alignInput< sal_uInt32 >();
1058 sal_uInt32 nLen = dumpHex< sal_uInt32 >( getPropertyName(), "CONV-DEC" );
1059 maLargeProps.push_back( LargeProperty( LargeProperty::PROPTYPE_STRINGARRAY, getPropertyName(), nLen ) );
1063 void AxPropertyObjectBase::dumpStreamProperty()
1065 if( startNextProperty() )
1067 alignInput< sal_uInt16 >();
1068 sal_uInt16 nData = dumpHex< sal_uInt16 >( getPropertyName() );
1069 maStreamProps.push_back( StreamProperty( getPropertyName(), nData ) );
1073 void AxPropertyObjectBase::dumpEmbeddedFont()
1075 if( ensureValid() )
1077 writeEmptyItem( "embedded-fontdata" );
1078 IndentGuard aIndGuard( mxOut );
1079 AxCFontNewObject( *this ).dump();
1083 void AxPropertyObjectBase::dumpToPosition( sal_Int64 nPos )
1085 dumpRemainingTo( nPos );
1086 mbValid = true;
1087 ensureValid();
1090 void AxPropertyObjectBase::constructAxPropObj( const String& rPropNameList, bool b64BitPropFlags )
1092 if( OleInputObjectBase::implIsValid() )
1094 mxPropNames = cfg().getNameList( rPropNameList );
1095 mb64BitPropFlags = b64BitPropFlags;
1096 mbValid = true;
1100 void AxPropertyObjectBase::dumpVersion()
1102 ItemGuard aItem( mxOut, "version" );
1103 sal_uInt8 nMinor, nMajor;
1104 *mxStrm >> nMinor >> nMajor;
1105 mxOut->writeDec( nMajor );
1106 mxOut->writeChar( '.' );
1107 mxOut->writeDec( nMinor );
1110 OUString AxPropertyObjectBase::dumpString( const String& rName, sal_uInt32 nSize, bool bArray )
1112 bool bCompressed = getFlag( nSize, AX_STRING_COMPRESSED );
1113 sal_uInt32 nBufSize = extractValue< sal_uInt32 >( nSize, 0, 31 );
1114 OUString aString = bCompressed ?
1115 dumpCharArray( rName, nBufSize, RTL_TEXTENCODING_ISO_8859_1 ) :
1116 dumpUnicodeArray( rName, bArray ? nBufSize : (nBufSize / 2) );
1117 alignInput< sal_Int32 >();
1118 return aString;
1121 void AxPropertyObjectBase::dumpShortProperties()
1123 if( ensureValid() )
1125 writeEmptyItem( "short-properties" );
1126 IndentGuard aIndGuard( mxOut );
1127 implDumpShortProperties();
1128 alignInput< sal_uInt32 >();
1132 void AxPropertyObjectBase::dumpLargeProperties()
1134 if( ensureValid( mnPropFlags == 0 ) && !maLargeProps.empty() )
1136 writeEmptyItem( "large-properties" );
1137 IndentGuard aIndGuard( mxOut );
1138 for( LargePropertyVector::iterator aIt = maLargeProps.begin(), aEnd = maLargeProps.end(); ensureValid() && (aIt != aEnd); ++aIt )
1140 switch( aIt->mePropType )
1142 case LargeProperty::PROPTYPE_POS:
1144 MultiItemsGuard aMultiGuard( mxOut );
1145 writeEmptyItem( aIt->maItemName );
1146 dumpDec< sal_Int32 >( "top", "CONV-HMM-TO-CM" );
1147 dumpDec< sal_Int32 >( "left", "CONV-HMM-TO-CM" );
1149 break;
1150 case LargeProperty::PROPTYPE_SIZE:
1152 MultiItemsGuard aMultiGuard( mxOut );
1153 writeEmptyItem( aIt->maItemName );
1154 dumpDec< sal_Int32 >( "width", "CONV-HMM-TO-CM" );
1155 dumpDec< sal_Int32 >( "height", "CONV-HMM-TO-CM" );
1157 break;
1158 case LargeProperty::PROPTYPE_GUID:
1160 OUString aGuid = dumpGuid( aIt->maItemName );
1161 if( aIt->mpItemValue )
1162 *aIt->mpItemValue = cfg().getStringOption( aGuid, OUString() );
1164 break;
1165 case LargeProperty::PROPTYPE_STRING:
1167 OUString aString = dumpString( aIt->maItemName, aIt->mnDataSize, false );
1168 if( aIt->mpItemValue )
1169 *aIt->mpItemValue = aString;
1171 break;
1172 case LargeProperty::PROPTYPE_STRINGARRAY:
1174 writeEmptyItem( aIt->maItemName );
1175 IndentGuard aIndGuard2( mxOut );
1176 mxOut->resetItemIndex();
1177 sal_Int64 nEndPos = mxStrm->tell() + aIt->mnDataSize;
1178 while( mxStrm->tell() < nEndPos )
1180 MultiItemsGuard aMultiGuard( mxOut );
1181 sal_uInt32 nDataSize = dumpHex< sal_uInt32 >( "#flags", "AX-ARRAYSTRINGLEN" );
1182 dumpString( "string", nDataSize, true );
1184 dumpToPosition( nEndPos );
1186 break;
1190 dumpToPosition( mnPropertiesEnd );
1192 if( ensureValid() && !maStreamProps.empty() )
1194 writeEmptyItem( "stream-properties" );
1195 IndentGuard aIndGuard( mxOut );
1196 for( StreamPropertyVector::iterator aIt = maStreamProps.begin(), aEnd = maStreamProps.end(); ensureValid() && (aIt != aEnd); ++aIt )
1198 writeEmptyItem( aIt->maItemName );
1199 if( ensureValid( aIt->mnData == 0xFFFF ) )
1201 IndentGuard aIndGuard2( mxOut );
1202 OUString aClassName = cfg().getStringOption( dumpGuid(), OUString() );
1203 if ( aClassName == "StdFont" )
1204 StdFontObject( *this ).dump();
1205 else if ( aClassName == "StdPic" )
1206 StdPicObject( *this ).dump();
1207 else if ( aClassName == "CFontNew" )
1208 AxCFontNewObject( *this ).dump();
1209 else
1210 ensureValid( false );
1216 // ============================================================================
1218 AxCFontNewObject::AxCFontNewObject( const InputObjectBase& rParent )
1220 AxPropertyObjectBase::construct( rParent, "AX-CFONTNEW-PROPERTIES" );
1223 void AxCFontNewObject::implDumpShortProperties()
1225 dumpStringProperty();
1226 dumpFlagsProperty( 0, "AX-CFONTNEW-FLAGS" );
1227 dumpDecProperty< sal_Int32 >( 160 );
1228 dumpDecProperty< sal_Int32 >( 0 );
1229 dumpDecProperty< sal_uInt8 >( WINDOWS_CHARSET_DEFAULT, "CHARSET" );
1230 dumpDecProperty< sal_uInt8 >( 0, "FONT-PITCHFAMILY" );
1231 dumpDecProperty< sal_uInt8 >( 1, "AX-CFONTNEW-ALIGNMENT" );
1232 dumpDecProperty< sal_uInt16 >( 400, "FONT-WEIGHT" );
1235 // ============================================================================
1237 AxColumnInfoObject::AxColumnInfoObject( const InputObjectBase& rParent )
1239 AxPropertyObjectBase::construct( rParent, "AX-COLUMNINFO-PROPERTIES" );
1242 void AxColumnInfoObject::implDumpShortProperties()
1244 dumpDecProperty< sal_Int32 >( -1, "CONV-HMM-TO-CM" );
1247 // ============================================================================
1249 AxCommandButtonObject::AxCommandButtonObject( const InputObjectBase& rParent )
1251 AxPropertyObjectBase::construct( rParent, "AX-COMMANDBUTTON-PROPERTIES" );
1254 void AxCommandButtonObject::implDumpShortProperties()
1256 dumpColorProperty( 0x80000012 );
1257 dumpColorProperty( 0x80000008 );
1258 dumpFlagsProperty( 0x0000001B );
1259 dumpStringProperty();
1260 dumpImagePosProperty();
1261 dumpSizeProperty();
1262 dumpMousePtrProperty();
1263 dumpStreamProperty();
1264 dumpUnicodeProperty();
1265 dumpBoolProperty();
1266 dumpStreamProperty();
1269 void AxCommandButtonObject::implDumpExtended()
1271 dumpEmbeddedFont();
1274 // ============================================================================
1276 AxMorphControlObject::AxMorphControlObject( const InputObjectBase& rParent )
1278 AxPropertyObjectBase::construct( rParent, "AX-MORPH-PROPERTIES", true );
1281 void AxMorphControlObject::implDumpShortProperties()
1283 dumpFlagsProperty( 0x2C80081B );
1284 dumpColorProperty( 0x80000005 );
1285 dumpColorProperty( 0x80000008 );
1286 dumpDecProperty< sal_uInt32 >( 0 );
1287 dumpBorderStyleProperty< sal_uInt8 >( 0 );
1288 dumpDecProperty< sal_uInt8 >( 0, "AX-MORPH-SCROLLBARS" );
1289 mnCtrlType = dumpDecProperty< sal_uInt8 >( 1, "AX-MORPH-CONTROLTYPE" );
1290 dumpMousePtrProperty();
1291 dumpSizeProperty();
1292 dumpUnicodeProperty();
1293 dumpDecProperty< sal_uInt32 >( 0, "CONV-HMM-TO-CM" );
1294 dumpDecProperty< sal_uInt16 >( 1, "AX-MORPH-BOUNDCOLUMN" );
1295 dumpDecProperty< sal_Int16 >( -1, "AX-MORPH-TEXTCOLUMN" );
1296 dumpDecProperty< sal_Int16 >( 1, "AX-MORPH-COLUMNCOUNT" );
1297 dumpDecProperty< sal_uInt16 >( 8 );
1298 mnColInfoCount = dumpDecProperty< sal_uInt16 >( 1 );
1299 dumpDecProperty< sal_uInt8 >( 2, "AX-MORPH-MATCHENTRYTYPE" );
1300 dumpDecProperty< sal_uInt8 >( 0, "AX-MORPH-LISTSTYLE" );
1301 dumpDecProperty< sal_uInt8 >( 0, "AX-MORPH-SHOWDROPDOWNMODE" );
1302 dumpUnknownProperty();
1303 dumpDecProperty< sal_uInt8 >( 1, "AX-MORPH-DROPDOWNSTYLE" );
1304 dumpDecProperty< sal_uInt8 >( 0, "AX-MORPH-SELECTIONTYPE" );
1305 dumpStringProperty();
1306 dumpStringProperty();
1307 dumpImagePosProperty();
1308 dumpColorProperty( 0x80000006 );
1309 dumpSpecialEffectProperty< sal_uInt32 >( 2 );
1310 dumpStreamProperty();
1311 dumpStreamProperty();
1312 dumpUnicodeProperty();
1313 dumpUnknownProperty();
1314 dumpBoolProperty();
1315 dumpStringProperty();
1318 void AxMorphControlObject::implDumpExtended()
1320 dumpEmbeddedFont();
1321 dumpColumnInfos();
1324 void AxMorphControlObject::dumpColumnInfos()
1326 if( ensureValid() && (mnColInfoCount > 0) && ((mnCtrlType == 2) || (mnCtrlType == 3)) )
1328 mxOut->resetItemIndex();
1329 for( sal_uInt16 nIdx = 0; ensureValid() && (nIdx < mnColInfoCount); ++nIdx )
1331 writeEmptyItem( "#column-info" );
1332 IndentGuard aIndGuard( mxOut );
1333 AxColumnInfoObject( *this ).dump();
1338 // ============================================================================
1340 AxLabelObject::AxLabelObject( const InputObjectBase& rParent )
1342 AxPropertyObjectBase::construct( rParent, "AX-LABEL-PROPERTIES" );
1345 void AxLabelObject::implDumpShortProperties()
1347 dumpColorProperty( 0x80000012 );
1348 dumpColorProperty( 0x8000000F );
1349 dumpFlagsProperty( 0x0080001B );
1350 dumpStringProperty();
1351 dumpImagePosProperty();
1352 dumpSizeProperty();
1353 dumpMousePtrProperty();
1354 dumpColorProperty( 0x80000006 );
1355 dumpBorderStyleProperty< sal_uInt16 >( 0 );
1356 dumpSpecialEffectProperty< sal_uInt16 >( 0 );
1357 dumpStreamProperty();
1358 dumpUnicodeProperty();
1359 dumpStreamProperty();
1362 void AxLabelObject::implDumpExtended()
1364 dumpEmbeddedFont();
1367 // ============================================================================
1369 AxImageObject::AxImageObject( const InputObjectBase& rParent )
1371 AxPropertyObjectBase::construct( rParent, "AX-IMAGE-PROPERTIES" );
1374 void AxImageObject::implDumpShortProperties()
1376 dumpUnknownProperty();
1377 dumpUnknownProperty();
1378 dumpBoolProperty();
1379 dumpColorProperty( 0x80000006 );
1380 dumpColorProperty( 0x8000000F );
1381 dumpBorderStyleProperty< sal_uInt8 >( 1 );
1382 dumpMousePtrProperty();
1383 dumpImageSizeModeProperty();
1384 dumpSpecialEffectProperty< sal_uInt8 >( 0 );
1385 dumpSizeProperty();
1386 dumpStreamProperty();
1387 dumpImageAlignProperty();
1388 dumpBoolProperty();
1389 dumpFlagsProperty( 0x0000001B );
1390 dumpStreamProperty();
1393 // ============================================================================
1395 AxScrollBarObject::AxScrollBarObject( const InputObjectBase& rParent )
1397 AxPropertyObjectBase::construct( rParent, "AX-SCROLLBAR-PROPERTIES" );
1400 void AxScrollBarObject::implDumpShortProperties()
1402 dumpColorProperty( 0x80000012 );
1403 dumpColorProperty( 0x8000000F );
1404 dumpFlagsProperty( 0x0000001B );
1405 dumpSizeProperty();
1406 dumpMousePtrProperty();
1407 dumpDecProperty< sal_Int32 >( 0 );
1408 dumpDecProperty< sal_Int32 >( 32767 );
1409 dumpDecProperty< sal_Int32 >( 0 );
1410 dumpHexProperty< sal_uInt32 >( 0 );
1411 dumpEnabledProperty();
1412 dumpEnabledProperty();
1413 dumpDecProperty< sal_Int32 >( 1 );
1414 dumpDecProperty< sal_Int32 >( 1 );
1415 dumpOrientationProperty();
1416 dumpDecProperty< sal_Int16 >( -1, "AX-SCROLLBAR-PROPTHUMB" );
1417 dumpDelayProperty();
1418 dumpStreamProperty();
1421 // ============================================================================
1423 AxSpinButtonObject::AxSpinButtonObject( const InputObjectBase& rParent )
1425 AxPropertyObjectBase::construct( rParent, "AX-SPINBUTTON-PROPERTIES" );
1428 void AxSpinButtonObject::implDumpShortProperties()
1430 dumpColorProperty( 0x80000012 );
1431 dumpColorProperty( 0x8000000F );
1432 dumpFlagsProperty( 0x0000001B );
1433 dumpSizeProperty();
1434 dumpHexProperty< sal_uInt32 >( 0 );
1435 dumpDecProperty< sal_Int32 >( 0 );
1436 dumpDecProperty< sal_Int32 >( 100 );
1437 dumpDecProperty< sal_Int32 >( 0 );
1438 dumpEnabledProperty();
1439 dumpEnabledProperty();
1440 dumpDecProperty< sal_Int32 >( 1 );
1441 dumpOrientationProperty();
1442 dumpDelayProperty();
1443 dumpStreamProperty();
1444 dumpMousePtrProperty();
1447 // ============================================================================
1449 AxTabStripObject::AxTabStripObject( const InputObjectBase& rParent )
1451 AxPropertyObjectBase::construct( rParent, "AX-TABSTRIP-PROPERTIES" );
1454 void AxTabStripObject::implDumpShortProperties()
1456 dumpDecProperty< sal_Int32 >( -1 );
1457 dumpColorProperty( 0x8000000F );
1458 dumpColorProperty( 0x80000012 );
1459 dumpUnknownProperty();
1460 dumpSizeProperty();
1461 dumpStringArrayProperty();
1462 dumpMousePtrProperty();
1463 dumpUnknownProperty();
1464 dumpDecProperty< sal_uInt32 >( 0, "AX-TABSTRIP-ORIENTATION" );
1465 dumpDecProperty< sal_uInt32 >( 0, "AX-TABSTRIP-TABSTYLE" );
1466 dumpBoolProperty();
1467 dumpHmmProperty();
1468 dumpHmmProperty();
1469 dumpBoolProperty();
1470 dumpUnknownProperty();
1471 dumpStringArrayProperty();
1472 dumpUnknownProperty();
1473 dumpStringArrayProperty();
1474 dumpFlagsProperty( 0x0000001B );
1475 dumpBoolProperty();
1476 dumpDecProperty< sal_uInt32 >( 0 );
1477 dumpStringArrayProperty();
1478 mnTabFlagCount = dumpDecProperty< sal_Int32 >( 0 );
1479 dumpStringArrayProperty();
1480 dumpStreamProperty();
1483 void AxTabStripObject::implDumpExtended()
1485 dumpEmbeddedFont();
1486 if( mnTabFlagCount > 0 )
1488 writeEmptyItem( "tab-flags" );
1489 IndentGuard aIndGuard( mxOut );
1490 mxOut->resetItemIndex();
1491 for( sal_Int32 nIdx = 0; ensureValid() && (nIdx < mnTabFlagCount); ++nIdx )
1492 dumpHex< sal_uInt32 >( "#flags", "AX-TABSTRIP-FLAGS" );
1496 // ============================================================================
1497 // ============================================================================
1499 FormControlStreamObject::FormControlStreamObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName, const OUString* pProgId )
1501 construct( rParent, rxStrm, rSysFileName );
1502 constructFormCtrlStrmObj( pProgId );
1505 FormControlStreamObject::FormControlStreamObject( const OutputObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString* pProgId )
1507 construct( rParent, rxStrm );
1508 constructFormCtrlStrmObj( pProgId );
1511 void FormControlStreamObject::implDump()
1513 if( mbReadGuid )
1514 maProgId = cfg().getStringOption( dumpGuid(), OUString() );
1516 if( !maProgId.isEmpty() && !mxStrm->isEof() )
1518 if ( maProgId == "Forms.CommandButton.1" )
1519 AxCommandButtonObject( *this ).dump();
1520 else if( maProgId == "Forms.TextBox.1" ||
1521 maProgId == "Forms.ListBox.1" ||
1522 maProgId == "Forms.ComboBox.1" ||
1523 maProgId == "Forms.CheckBox.1" ||
1524 maProgId == "Forms.OptionButton.1" ||
1525 maProgId == "Forms.ToggleButton.1" ||
1526 maProgId == "RefEdit.Ctrl" )
1527 AxMorphControlObject( *this ).dump();
1528 else if ( maProgId == "Forms.Label.1" )
1529 AxLabelObject( *this ).dump();
1530 else if ( maProgId == "Forms.Image.1" )
1531 AxImageObject( *this ).dump();
1532 else if ( maProgId == "Forms.ScrollBar.1" )
1533 AxScrollBarObject( *this ).dump();
1534 else if ( maProgId == "Forms.SpinButton.1" )
1535 AxSpinButtonObject( *this ).dump();
1536 else if ( maProgId == "Forms.TabStrip.1" )
1537 AxTabStripObject( *this ).dump();
1538 else if ( maProgId == "MSComCtl2.FlatScrollBar.2" )
1539 ComCtlScrollBarObject( *this, 6 ).dump();
1540 else if ( maProgId == "COMCTL.ProgCtrl.1" )
1541 ComCtlProgressBarObject( *this, 5 ).dump();
1542 else if ( maProgId == "MSComctlLib.ProgCtrl.2" )
1543 ComCtlProgressBarObject( *this, 6 ).dump();
1544 else if ( maProgId == "COMCTL.Slider.1" )
1545 ComCtlSliderObject( *this, 5 ).dump();
1546 else if ( maProgId == "MSComctlLib.Slider.2" )
1547 ComCtlSliderObject( *this, 6 ).dump();
1548 else if ( maProgId == "ComCtl2.UpDown.1" )
1549 ComCtlUpDownObject( *this, 5 ).dump();
1550 else if ( maProgId == "MSComCtl2.UpDown.2" )
1551 ComCtlUpDownObject( *this, 6 ).dump();
1552 else if ( maProgId == "COMCTL.ImageListCtrl.1" )
1553 ComCtlImageListObject( *this, 5 ).dump();
1554 else if ( maProgId == "MSComctlLib.ImageListCtrl.2" )
1555 ComCtlImageListObject( *this, 6 ).dump();
1556 else if ( maProgId == "COMCTL.TabStrip.1" )
1557 ComCtlTabStripObject( *this, 5 ).dump();
1558 else if ( maProgId == "MSComctlLib.TabStrip.2" )
1559 ComCtlTabStripObject( *this, 6 ).dump();
1560 else if ( maProgId == "COMCTL.TreeCtrl.1" )
1561 ComCtlTreeViewObject( *this, 5 ).dump();
1562 else if ( maProgId == "MSComctlLib.TreeCtrl.2" )
1563 ComCtlTreeViewObject( *this, 6 ).dump();
1564 else if ( maProgId == "COMCTL.SBarCtrl.1" )
1565 ComCtlStatusBarObject( *this, 5 ).dump();
1566 else if ( maProgId == "StdPic" )
1567 StdPicObject( *this ).dump();
1569 dumpRemainingStream();
1572 void FormControlStreamObject::constructFormCtrlStrmObj( const OUString* pProgId )
1574 mbReadGuid = pProgId == 0;
1575 if( pProgId )
1576 maProgId = *pProgId;
1579 // ============================================================================
1580 // ============================================================================
1582 VbaFormClassInfoObject::VbaFormClassInfoObject( const InputObjectBase& rParent, VbaFormSharedData& rFormData ) :
1583 mrFormData( rFormData )
1585 AxPropertyObjectBase::construct( rParent, "VBA-CLASSINFO-PROPERTIES" );
1588 void VbaFormClassInfoObject::implDumpShortProperties()
1590 mrFormData.maClassInfoProgIds.push_back( OUString() );
1591 dumpGuidProperty( &mrFormData.maClassInfoProgIds.back() );
1592 dumpGuidProperty();
1593 dumpUnknownProperty();
1594 dumpGuidProperty();
1595 dumpFlagsProperty( 0, "VBA-CLASSINFO-FLAGS" );
1596 dumpDecProperty< sal_uInt32 >( 0 );
1597 dumpDecProperty< sal_Int32 >( -1 );
1598 dumpDecProperty< sal_uInt16 >( 0 );
1599 dumpDecProperty< sal_uInt16 >( 0 );
1600 dumpDecProperty< sal_uInt16 >( 0, "OLEPROP-TYPE" );
1601 dumpDecProperty< sal_uInt16 >( 0 );
1602 dumpDecProperty< sal_uInt16 >( 0 );
1603 dumpDecProperty< sal_uInt16 >( 0, "OLEPROP-TYPE" );
1604 dumpDecProperty< sal_Int32 >( -1 );
1605 dumpDecProperty< sal_uInt16 >( 0 );
1608 // ============================================================================
1610 namespace {
1612 const sal_uInt32 VBA_FORMSITE_OBJSTREAM = 0x0010;
1614 const sal_uInt16 VBA_FORMSITE_CLASSTABLEINDEX = 0x8000;
1615 const sal_uInt16 VBA_FORMSITE_CLASSTABLEMASK = 0x7FFF;
1617 } // namespace
1619 // ----------------------------------------------------------------------------
1621 VbaFormSiteObject::VbaFormSiteObject( const InputObjectBase& rParent, VbaFormSharedData& rFormData ) :
1622 mrFormData( rFormData )
1624 AxPropertyObjectBase::construct( rParent, "VBA-FORMSITE-PROPERTIES" );
1627 void VbaFormSiteObject::implDumpShortProperties()
1629 VbaFormSiteInfo aSiteInfo;
1630 dumpStringProperty();
1631 dumpStringProperty();
1632 sal_Int32 nId = dumpDecProperty< sal_Int32 >( 0 );
1633 dumpDecProperty< sal_Int32 >( 0 );
1634 sal_uInt32 nFlags = dumpFlagsProperty( 0x00000033, "VBA-FORMSITE-FLAGS" );
1635 sal_uInt32 nLength = dumpDecProperty< sal_uInt32 >( 0 );
1636 dumpDecProperty< sal_Int16 >( -1 );
1637 sal_uInt16 nClassId = dumpHexProperty< sal_uInt16 >( 0x7FFF, "VBA-FORMSITE-CLASSIDCACHE" );
1638 dumpPosProperty();
1639 dumpDecProperty< sal_uInt16 >( 0 );
1640 dumpUnknownProperty();
1641 dumpStringProperty();
1642 dumpStringProperty();
1643 dumpStringProperty();
1644 dumpStringProperty();
1646 sal_uInt16 nIndex = nClassId & VBA_FORMSITE_CLASSTABLEMASK;
1647 if( getFlag( nClassId, VBA_FORMSITE_CLASSTABLEINDEX ) )
1649 if( nIndex < mrFormData.maClassInfoProgIds.size() )
1650 aSiteInfo.maProgId = mrFormData.maClassInfoProgIds[ nIndex ];
1652 else
1654 if( cfg().hasName( "VBA-FORMSITE-CLASSNAMES", nIndex ) )
1655 aSiteInfo.maProgId = cfg().getName( "VBA-FORMSITE-CLASSNAMES", nIndex );
1657 aSiteInfo.mnId = nId;
1658 aSiteInfo.mnLength = nLength;
1659 aSiteInfo.mbInStream = getFlag( nFlags, VBA_FORMSITE_OBJSTREAM );
1661 mrFormData.maSiteInfos.push_back( aSiteInfo );
1664 // ============================================================================
1666 VbaFormDesignExtObject::VbaFormDesignExtObject( const InputObjectBase& rParent )
1668 AxPropertyObjectBase::construct( rParent, "VBA-FORMDESIGNEXT-PROPERTIES" );
1671 void VbaFormDesignExtObject::implDumpShortProperties()
1673 dumpFlagsProperty( 0x00015F55, "VBA-FORMDESIGNEXT-FLAGS" );
1674 dumpHmmProperty();
1675 dumpHmmProperty();
1676 dumpDecProperty< sal_Int8 >( 0, "VBA-FORMDESIGNEXT-CLICKCTRLMODE" );
1677 dumpDecProperty< sal_Int8 >( 0, "VBA-FORMDESIGNEXT-DBLCLICKCTRLMODE" );
1680 // ============================================================================
1682 namespace {
1684 const sal_uInt32 AX_FORM_HASDESIGNEXTENDER = 0x00004000;
1685 const sal_uInt32 AX_FORM_SKIPCLASSTABLE = 0x00008000;
1687 const sal_uInt8 AX_FORM_SITECOUNTTYPE_COUNT = 0x80;
1688 const sal_uInt8 AX_FORM_SITECOUNTTYPE_MASK = 0x7F;
1690 } // namespace
1692 // ----------------------------------------------------------------------------
1694 VbaFStreamObject::VbaFStreamObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName, VbaFormSharedData& rFormData ) :
1695 mrFormData( rFormData )
1697 AxPropertyObjectBase::construct( rParent, rxStrm, rSysFileName, "VBA-FORM-PROPERTIES" );
1700 void VbaFStreamObject::implDumpShortProperties()
1702 dumpUnknownProperty();
1703 dumpColorProperty( 0x8000000F );
1704 dumpColorProperty( 0x80000012 );
1705 dumpDecProperty< sal_uInt32 >( 0 );
1706 dumpUnknownProperty();
1707 dumpUnknownProperty();
1708 mnFlags = dumpFlagsProperty( 0x00000004, "VBA-FORM-FLAGS" );
1709 dumpBorderStyleProperty< sal_uInt8 >( 0 );
1710 dumpMousePtrProperty();
1711 dumpHexProperty< sal_uInt8 >( 0x0C, "VBA-FORM-SCROLLBARS" );
1712 dumpSizeProperty();
1713 dumpSizeProperty();
1714 dumpPosProperty();
1715 dumpDecProperty< sal_uInt32 >( 0 );
1716 dumpUnknownProperty();
1717 dumpStreamProperty();
1718 dumpDecProperty< sal_uInt8 >( 0, "VBA-FORM-CYCLE" );
1719 dumpSpecialEffectProperty< sal_uInt8 >( 0 );
1720 dumpColorProperty( 0x80000012 );
1721 dumpStringProperty();
1722 dumpStreamProperty();
1723 dumpStreamProperty();
1724 dumpDecProperty< sal_Int32 >( 100, "CONV-PERCENT" );
1725 dumpImageAlignProperty();
1726 dumpBoolProperty();
1727 dumpImageSizeModeProperty();
1728 dumpDecProperty< sal_uInt32 >( 0 );
1729 dumpDecProperty< sal_uInt32 >( 0 );
1732 void VbaFStreamObject::implDumpExtended()
1734 dumpClassInfos();
1735 dumpSiteData();
1736 dumpDesignExtender();
1737 dumpRemainingStream();
1740 void VbaFStreamObject::dumpClassInfos()
1742 if( ensureValid() && !getFlag( mnFlags, AX_FORM_SKIPCLASSTABLE ) )
1744 mxOut->emptyLine();
1745 sal_uInt16 nCount = dumpDec< sal_uInt16 >( "class-info-count" );
1746 mxOut->resetItemIndex();
1747 for( sal_uInt16 nIdx = 0; ensureValid() && (nIdx < nCount); ++nIdx )
1749 writeEmptyItem( "#class-info" );
1750 IndentGuard aIndGuard( mxOut );
1751 VbaFormClassInfoObject( *this, mrFormData ).dump();
1756 void VbaFStreamObject::dumpFormSites( sal_uInt32 nCount )
1758 mxOut->resetItemIndex();
1759 for( sal_uInt32 nIdx = 0; ensureValid() && (nIdx < nCount); ++nIdx )
1761 mxOut->emptyLine();
1762 writeEmptyItem( "#form-site" );
1763 IndentGuard aIndGuard( mxOut );
1764 VbaFormSiteObject( *this, mrFormData ).dump();
1768 void VbaFStreamObject::dumpSiteData()
1770 if( ensureValid() )
1772 mxOut->emptyLine();
1773 setAlignAnchor();
1774 sal_uInt32 nSiteCount = dumpDec< sal_uInt32 >( "site-count" );
1775 sal_uInt32 nSiteLength = dumpDec< sal_uInt32 >( "site-data-size" );
1776 sal_Int64 nEndPos = mxStrm->tell() + nSiteLength;
1777 if( ensureValid( nEndPos <= mxStrm->size() ) )
1779 mxOut->resetItemIndex();
1780 sal_uInt32 nSiteIdx = 0;
1781 while( ensureValid() && (nSiteIdx < nSiteCount) )
1783 mxOut->emptyLine();
1784 writeEmptyItem( "#site-info" );
1785 IndentGuard aIndGuard( mxOut );
1786 dumpDec< sal_uInt8 >( "depth" );
1787 sal_uInt8 nTypeCount = dumpHex< sal_uInt8 >( "type-count", "VBA-FORM-SITE-TYPECOUNT" );
1788 if( getFlag( nTypeCount, AX_FORM_SITECOUNTTYPE_COUNT ) )
1790 dumpDec< sal_uInt8 >( "repeated-type" );
1791 nSiteIdx += (nTypeCount & AX_FORM_SITECOUNTTYPE_MASK);
1793 else
1795 ++nSiteIdx;
1798 alignInput< sal_uInt32 >();
1799 dumpFormSites( nSiteCount );
1800 dumpToPosition( nEndPos );
1805 void VbaFStreamObject::dumpDesignExtender()
1807 if( ensureValid() && getFlag( mnFlags, AX_FORM_HASDESIGNEXTENDER ) )
1809 mxOut->emptyLine();
1810 writeEmptyItem( "design-extender" );
1811 IndentGuard aIndGuard( mxOut );
1812 VbaFormDesignExtObject( *this ).dump();
1816 // ============================================================================
1818 VbaOStreamObject::VbaOStreamObject( const ObjectBase& rParent,
1819 const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName, VbaFormSharedData& rFormData ) :
1820 mrFormData( rFormData )
1822 OleInputObjectBase::construct( rParent, rxStrm, rSysFileName );
1825 void VbaOStreamObject::implDump()
1827 for( VbaFormSiteInfoVector::iterator aIt = mrFormData.maSiteInfos.begin(), aEnd = mrFormData.maSiteInfos.end(); !mxStrm->isEof() && (aIt != aEnd); ++aIt )
1829 if( (aIt->mbInStream) && (aIt->mnLength > 0) )
1831 mxOut->emptyLine();
1832 writeDecItem( "control-id", aIt->mnId );
1833 writeInfoItem( "prog-id", aIt->maProgId );
1834 IndentGuard aIndGuard( mxOut );
1835 BinaryInputStreamRef xRelStrm( new RelativeInputStream( *mxStrm, aIt->mnLength ) );
1836 FormControlStreamObject( *this, xRelStrm, &aIt->maProgId ).dump();
1839 dumpRemainingStream();
1842 // ============================================================================
1844 VbaPageObject::VbaPageObject( const InputObjectBase& rParent )
1846 AxPropertyObjectBase::construct( rParent, "VBA-PAGE-PROPERTIES" );
1849 void VbaPageObject::implDumpShortProperties()
1851 dumpUnknownProperty();
1852 dumpDecProperty< sal_uInt32 >( 0, "VBA-PAGE-TRANSITIONEFFECT" );
1853 dumpDecProperty< sal_uInt32 >( 0, "AX-CONV-MS" );
1856 // ============================================================================
1858 VbaMultiPageObject::VbaMultiPageObject( const InputObjectBase& rParent )
1860 AxPropertyObjectBase::construct( rParent, "VBA-MULTIPAGE-PROPERTIES" );
1863 void VbaMultiPageObject::implDumpShortProperties()
1865 dumpUnknownProperty();
1866 mnPageCount = dumpDecProperty< sal_Int32 >( 0 );
1867 dumpDecProperty< sal_Int32 >( 0 );
1868 dumpBoolProperty();
1871 void VbaMultiPageObject::implDumpExtended()
1873 if( ensureValid() && (mnPageCount > 0) )
1875 writeEmptyItem( "page-ids" );
1876 IndentGuard aIndGuard( mxOut );
1877 mxOut->resetItemIndex();
1878 for( sal_Int32 nIdx = 0; ensureValid() && (nIdx < mnPageCount); ++nIdx )
1879 dumpDec< sal_Int32 >( "#id" );
1883 // ============================================================================
1885 VbaXStreamObject::VbaXStreamObject( const ObjectBase& rParent,
1886 const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName, VbaFormSharedData& rFormData ) :
1887 mrFormData( rFormData )
1889 InputObjectBase::construct( rParent, rxStrm, rSysFileName );
1892 void VbaXStreamObject::implDump()
1894 for( size_t nIdx = 0, nCount = mrFormData.maSiteInfos.size(); !mxStrm->isEof() && (nIdx < nCount); ++nIdx )
1896 mxOut->emptyLine();
1897 writeEmptyItem( "page" );
1898 IndentGuard aIndGuard( mxOut );
1899 VbaPageObject( *this ).dump();
1901 if( !mxStrm->isEof() )
1903 mxOut->emptyLine();
1904 writeEmptyItem( "multi-page" );
1905 IndentGuard aIndGuard( mxOut );
1906 VbaMultiPageObject( *this ).dump();
1908 dumpRemainingStream();
1911 // ============================================================================
1913 VbaContainerStorageObject::VbaContainerStorageObject( const ObjectBase& rParent, const StorageRef& rxStrg, const OUString& rSysPath ) :
1914 OleStorageObject( rParent, rxStrg, rSysPath )
1916 addPreferredStream( "f" );
1919 void VbaContainerStorageObject::implDumpStream( const Reference< XInputStream >& rxStrm, const OUString& rStrgPath, const OUString& rStrmName, const OUString& rSysFileName )
1921 if ( rStrmName == "f" )
1922 VbaFStreamObject( *this, rxStrm, rSysFileName, maFormData ).dump();
1923 else if ( rStrmName == "o" )
1924 VbaOStreamObject( *this, rxStrm, rSysFileName, maFormData ).dump();
1925 else if ( rStrmName == "x" )
1926 VbaXStreamObject( *this, rxStrm, rSysFileName, maFormData ).dump();
1927 else
1928 OleStorageObject::implDumpStream( rxStrm, rStrgPath, rStrmName, rSysFileName );
1931 void VbaContainerStorageObject::implDumpStorage( const StorageRef& rxStrg, const OUString& rStrgPath, const OUString& rSysPath )
1933 if( isFormStorage( rStrgPath ) )
1934 VbaContainerStorageObject( *this, rxStrg, rSysPath ).dump();
1935 else
1936 OleStorageObject( *this, rxStrg, rSysPath ).dump();
1939 bool VbaContainerStorageObject::isFormStorage( const OUString& rStrgPath ) const
1941 if( (rStrgPath.getLength() >= 3) && (rStrgPath[ 0 ] == 'i') )
1943 OUString aId = rStrgPath.copy( 1 );
1944 if( (aId.getLength() == 2) && (aId[ 0 ] == '0') )
1945 aId = aId.copy( 1 );
1946 sal_Int32 nId = aId.toInt32();
1947 if( (nId > 0) && (OUString::valueOf( nId ) == aId) )
1948 for( VbaFormSiteInfoVector::const_iterator aIt = maFormData.maSiteInfos.begin(), aEnd = maFormData.maSiteInfos.end(); aIt != aEnd; ++aIt )
1949 if( aIt->mnId == nId )
1950 return true;
1952 return false;
1955 // ============================================================================
1956 // ============================================================================
1958 VbaSharedData::VbaSharedData() :
1959 meTextEnc( RTL_TEXTENCODING_MS_1252 )
1963 bool VbaSharedData::isModuleStream( const OUString& rStrmName ) const
1965 return maStrmOffsets.count( rStrmName ) > 0;
1968 sal_Int32 VbaSharedData::getStreamOffset( const OUString& rStrmName ) const
1970 StreamOffsetMap::const_iterator aIt = maStrmOffsets.find( rStrmName );
1971 return (aIt == maStrmOffsets.end()) ? 0 : aIt->second;
1974 // ============================================================================
1976 VbaDirStreamObject::VbaDirStreamObject( const ObjectBase& rParent,
1977 const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName, VbaSharedData& rVbaData ) :
1978 mrVbaData( rVbaData )
1980 mxInStrm = rxStrm;
1981 if( mxInStrm.get() )
1983 BinaryInputStreamRef xVbaStrm( new ::oox::ole::VbaInputStream( *mxInStrm ) );
1984 SequenceRecordObjectBase::construct( rParent, xVbaStrm, rSysFileName, "VBA-DIR-RECORD-NAMES", "VBA-DIR-SIMPLE-RECORDS" );
1988 bool VbaDirStreamObject::implIsValid() const
1990 return mxInStrm.get() && SequenceRecordObjectBase::implIsValid();
1993 bool VbaDirStreamObject::implReadRecordHeader( BinaryInputStream& rBaseStrm, sal_Int64& ornRecId, sal_Int64& ornRecSize )
1995 ornRecId = rBaseStrm.readuInt16();
1996 ornRecSize = rBaseStrm.readInt32();
1998 // for no obvious reason, PROJECTVERSION record contains size field of 4, but is 6 bytes long
1999 if( ornRecId == 9 )
2000 ornRecSize = 6;
2002 return !rBaseStrm.isEof();
2005 void VbaDirStreamObject::implDumpRecordBody()
2007 switch( getRecId() )
2009 case 0x0003:
2010 mrVbaData.meTextEnc = rtl_getTextEncodingFromWindowsCodePage( dumpDec< sal_uInt16 >( "codepage", "CODEPAGES" ) );
2011 break;
2012 case 0x0004:
2013 dumpByteString( "name" );
2014 break;
2015 case 0x0005:
2016 dumpByteString( "description" );
2017 break;
2018 case 0x0006:
2019 dumpByteString( "helpfile-path" );
2020 break;
2021 case 0x0009:
2022 dumpDec< sal_uInt32 >( "major" );
2023 dumpDec< sal_uInt16 >( "minor" );
2024 break;
2025 case 0x000C:
2026 dumpByteString( "constants" );
2027 break;
2028 case 0x000D:
2029 dumpByteStringWithLength( "lib-id" );
2030 dumpUnused( 6 );
2031 break;
2032 case 0x000E:
2033 dumpByteStringWithLength( "lib-id-absolute" );
2034 dumpByteStringWithLength( "lib-id-relative" );
2035 dumpDec< sal_uInt32 >( "major" );
2036 dumpDec< sal_uInt16 >( "minor" );
2037 break;
2038 case 0x0016:
2039 dumpByteString( "name" );
2040 break;
2041 case 0x0019:
2042 dumpByteString( "name" );
2043 maCurrStream = OUString();
2044 mnCurrOffset = 0;
2045 break;
2046 case 0x001A:
2047 maCurrStream = dumpByteString( "stream-name" );
2048 break;
2049 case 0x001C:
2050 dumpByteString( "description" );
2051 break;
2052 case 0x002B:
2053 if( !maCurrStream.isEmpty() )
2054 mrVbaData.maStrmOffsets[ maCurrStream ] = mnCurrOffset;
2055 maCurrStream = OUString();
2056 mnCurrOffset = 0;
2057 break;
2058 case 0x002F:
2059 dumpByteStringWithLength( "lib-id-twiddled" );
2060 dumpUnused( 6 );
2061 break;
2062 case 0x0030:
2063 dumpByteStringWithLength( "lib-id-extended" );
2064 dumpUnused( 6 );
2065 dumpGuid( "original-typelib" );
2066 dumpDec< sal_uInt32 >( "cookie" );
2067 break;
2068 case 0x0031:
2069 mnCurrOffset = dumpHex< sal_Int32 >( "stream-offset", "CONV-DEC" );
2070 break;
2071 case 0x0032:
2072 dumpUniString( "stream-name" );
2073 break;
2074 case 0x0033:
2075 dumpByteString( "lib-id-original" );
2076 break;
2077 case 0x003C:
2078 dumpUniString( "constants" );
2079 break;
2080 case 0x003D:
2081 dumpByteString( "helpfile-path" );
2082 break;
2083 case 0x003E:
2084 dumpUniString( "name" );
2085 break;
2086 case 0x0040:
2087 dumpUniString( "description" );
2088 break;
2089 case 0x0047:
2090 dumpUniString( "name" );
2091 break;
2092 case 0x0048:
2093 dumpUniString( "description" );
2094 break;
2098 OUString VbaDirStreamObject::dumpByteString( const String& rName )
2100 return dumpCharArray( rName, static_cast< sal_Int32 >( getRecSize() ), mrVbaData.meTextEnc );
2103 OUString VbaDirStreamObject::dumpUniString( const String& rName )
2105 return dumpUnicodeArray( rName, static_cast< sal_Int32 >( getRecSize() / 2 ) );
2108 OUString VbaDirStreamObject::dumpByteStringWithLength( const String& rName )
2110 return dumpCharArray( rName, mxStrm->readInt32(), mrVbaData.meTextEnc );
2113 // ============================================================================
2115 VbaModuleStreamObject::VbaModuleStreamObject(
2116 const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm,
2117 const OUString& rSysFileName, VbaSharedData& rVbaData, sal_Int32 nStrmOffset ) :
2118 mrVbaData( rVbaData ),
2119 mnStrmOffset( nStrmOffset )
2121 InputObjectBase::construct( rParent, rxStrm, rSysFileName );
2124 void VbaModuleStreamObject::implDump()
2126 dumpBinary( "perf-cache", mnStrmOffset );
2127 mxOut->emptyLine();
2128 writeEmptyItem( "source-code" );
2129 IndentGuard aIndGuard( mxOut );
2130 BinaryInputStreamRef xVbaStrm( new ::oox::ole::VbaInputStream( *mxStrm ) );
2131 TextLineStreamObject( *this, xVbaStrm, mrVbaData.meTextEnc ).dump();
2134 // ============================================================================
2136 VbaStorageObject::VbaStorageObject( const ObjectBase& rParent, const StorageRef& rxStrg, const OUString& rSysPath, VbaSharedData& rVbaData ) :
2137 OleStorageObject( rParent, rxStrg, rSysPath ),
2138 mrVbaData( rVbaData )
2140 addPreferredStream( "dir" );
2143 void VbaStorageObject::implDumpStream( const Reference< XInputStream >& rxStrm, const OUString& rStrgPath, const OUString& rStrmName, const OUString& rSysFileName )
2145 if( rStrgPath.isEmpty() && rStrmName == "dir" )
2146 VbaDirStreamObject( *this, rxStrm, rSysFileName, mrVbaData ).dump();
2147 else if( mrVbaData.isModuleStream( rStrmName ) )
2148 VbaModuleStreamObject( *this, rxStrm, rSysFileName, mrVbaData, mrVbaData.getStreamOffset( rStrmName ) ).dump();
2149 else
2150 OleStorageObject::implDumpStream( rxStrm, rStrgPath, rStrmName, rSysFileName );
2153 // ============================================================================
2155 VbaFormStorageObject::VbaFormStorageObject( const ObjectBase& rParent, const StorageRef& rxStrg, const OUString& rSysPath, VbaSharedData& rVbaData ) :
2156 VbaContainerStorageObject( rParent, rxStrg, rSysPath ),
2157 mrVbaData( rVbaData )
2161 void VbaFormStorageObject::implDumpStream( const Reference< XInputStream >& rxStrm, const OUString& rStrgPath, const OUString& rStrmName, const OUString& rSysFileName )
2163 if ( rStrmName == "\003VBFrame" )
2164 TextLineStreamObject( *this, rxStrm, mrVbaData.meTextEnc, rSysFileName ).dump();
2165 else
2166 VbaContainerStorageObject::implDumpStream( rxStrm, rStrgPath, rStrmName, rSysFileName );
2169 // ============================================================================
2171 VbaProjectStorageObject::VbaProjectStorageObject( const ObjectBase& rParent, const StorageRef& rxStrg, const OUString& rSysPath ) :
2172 OleStorageObject( rParent, rxStrg, rSysPath )
2174 addPreferredStorage( "VBA" );
2177 void VbaProjectStorageObject::implDumpStream( const Reference< XInputStream >& rxStrm, const OUString& rStrgPath, const OUString& rStrmName, const OUString& rSysFileName )
2179 if( rStrgPath.isEmpty() && rStrmName == "PROJECT" )
2180 TextLineStreamObject( *this, rxStrm, maVbaData.meTextEnc, rSysFileName ).dump();
2181 else
2182 OleStorageObject::implDumpStream( rxStrm, rStrgPath, rStrmName, rSysFileName );
2185 void VbaProjectStorageObject::implDumpStorage( const StorageRef& rxStrg, const OUString& rStrgPath, const OUString& rSysPath )
2187 if ( rStrgPath == "VBA" )
2188 VbaStorageObject( *this, rxStrg, rSysPath, maVbaData ).dump();
2189 else
2190 VbaFormStorageObject( *this, rxStrg, rSysPath, maVbaData ).dump();
2193 // ============================================================================
2194 // ============================================================================
2196 ActiveXStorageObject::ActiveXStorageObject( const ObjectBase& rParent, const StorageRef& rxStrg, const OUString& rSysPath ) :
2197 VbaContainerStorageObject( rParent, rxStrg, rSysPath )
2201 void ActiveXStorageObject::implDumpBaseStream( const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName )
2203 FormControlStreamObject( *this, rxStrm, rSysFileName ).dump();
2206 // ============================================================================
2207 // ============================================================================
2209 } // namespace dump
2210 } // namespace oox
2212 #endif
2214 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */