xref: /trunk/main/oox/source/dump/oledumper.cxx (revision ca5ec200)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #include "oox/dump/oledumper.hxx"
25 
26 #include <com/sun/star/io/XInputStream.hpp>
27 #include <com/sun/star/io/XOutputStream.hpp>
28 #include <osl/file.hxx>
29 #include <osl/thread.h>
30 #include <rtl/tencinfo.h>
31 #include "oox/core/filterbase.hxx"
32 #include "oox/helper/binaryoutputstream.hxx"
33 #include "oox/ole/olestorage.hxx"
34 #include "oox/ole/vbainputstream.hxx"
35 
36 #if OOX_INCLUDE_DUMPER
37 
38 namespace oox {
39 namespace dump {
40 
41 // ============================================================================
42 
43 using namespace ::com::sun::star::io;
44 using namespace ::com::sun::star::uno;
45 
46 using ::rtl::OString;
47 using ::rtl::OStringToOUString;
48 using ::rtl::OUString;
49 using ::rtl::OUStringBuffer;
50 
51 // ============================================================================
52 // ============================================================================
53 
dumpAnsiString32(const String & rName)54 OUString OleInputObjectBase::dumpAnsiString32( const String& rName )
55 {
56     return dumpCharArray( rName, mxStrm->readInt32(), RTL_TEXTENCODING_MS_1252 );
57 }
58 
dumpUniString32(const String & rName)59 OUString OleInputObjectBase::dumpUniString32( const String& rName )
60 {
61     return dumpUnicodeArray( rName, mxStrm->readInt32() );
62 }
63 
dumpStdClipboardFormat(const String & rName)64 sal_Int32 OleInputObjectBase::dumpStdClipboardFormat( const String& rName )
65 {
66     return dumpDec< sal_Int32 >( rName( "clipboard-format" ), "OLE-STD-CLIPBOARD-FORMAT" );
67 }
68 
dumpAnsiString32OrStdClip(const String & rName)69 OUString OleInputObjectBase::dumpAnsiString32OrStdClip( const String& rName )
70 {
71     sal_Int32 nLen = mxStrm->readInt32();
72     return (nLen < 0) ? OUString::valueOf( dumpStdClipboardFormat( rName ) ) : dumpCharArray( rName, nLen, RTL_TEXTENCODING_MS_1252 );
73 }
74 
dumpUniString32OrStdClip(const String & rName)75 OUString OleInputObjectBase::dumpUniString32OrStdClip( const String& rName )
76 {
77     sal_Int32 nLen = mxStrm->readInt32();
78     return (nLen < 0) ? OUString::valueOf( dumpStdClipboardFormat( rName ) ) : dumpUnicodeArray( rName, nLen );
79 }
80 
writeOleColorItem(const String & rName,sal_uInt32 nColor)81 void OleInputObjectBase::writeOleColorItem( const String& rName, sal_uInt32 nColor )
82 {
83     MultiItemsGuard aMultiGuard( mxOut );
84     writeHexItem( rName, nColor, "OLE-COLOR" );
85 }
86 
dumpOleColor(const String & rName)87 sal_uInt32 OleInputObjectBase::dumpOleColor( const String& rName )
88 {
89     sal_uInt32 nOleColor = mxStrm->readuInt32();
90     writeOleColorItem( rName, nOleColor );
91     return nOleColor;
92 }
93 
94 // ============================================================================
95 // ============================================================================
96 
StdFontObject(const InputObjectBase & rParent)97 StdFontObject::StdFontObject( const InputObjectBase& rParent )
98 {
99     construct( rParent );
100 }
101 
implDump()102 void StdFontObject::implDump()
103 {
104     dumpDec< sal_uInt8 >( "version" );
105     dumpDec< sal_uInt16 >( "charset", "CHARSET" );
106     dumpHex< sal_uInt8 >( "flags", "STDFONT-FLAGS" );
107     dumpDec< sal_uInt16 >( "weight", "FONT-WEIGHT" );
108     dumpDec< sal_uInt32 >( "height", "STDFONT-HEIGHT" );
109     dumpCharArray( "name", mxStrm->readuInt8(), RTL_TEXTENCODING_ASCII_US );
110 }
111 
112 // ============================================================================
113 
StdPicObject(const InputObjectBase & rParent)114 StdPicObject::StdPicObject( const InputObjectBase& rParent )
115 {
116     construct( rParent );
117 }
118 
implDump()119 void StdPicObject::implDump()
120 {
121     dumpHex< sal_uInt32 >( "identifier", "STDPIC-ID" );
122     sal_uInt32 nSize = dumpHex< sal_uInt32 >( "image-size", "CONV-DEC" );
123     dumpBinary( "image-data", nSize );
124 }
125 
126 // ============================================================================
127 
128 namespace {
129 
130 const sal_uInt32 STDHLINK_HASTARGET         = 0x00000001;   /// Has hyperlink moniker.
131 const sal_uInt32 STDHLINK_ABSOLUTE          = 0x00000002;   /// Absolute path.
132 const sal_uInt32 STDHLINK_HASLOCATION       = 0x00000008;   /// Has target location.
133 const sal_uInt32 STDHLINK_HASDISPLAY        = 0x00000010;   /// Has display string.
134 const sal_uInt32 STDHLINK_HASGUID           = 0x00000020;   /// Has identification GUID.
135 const sal_uInt32 STDHLINK_HASTIME           = 0x00000040;   /// Has creation time.
136 const sal_uInt32 STDHLINK_HASFRAME          = 0x00000080;   /// Has frame.
137 const sal_uInt32 STDHLINK_ASSTRING          = 0x00000100;   /// Hyperlink as simple string.
138 
139 } // namespace
140 
StdHlinkObject(const InputObjectBase & rParent)141 StdHlinkObject::StdHlinkObject( const InputObjectBase& rParent )
142 {
143     construct( rParent );
144 }
145 
implDump()146 void StdHlinkObject::implDump()
147 {
148     dumpDec< sal_uInt32 >( "stream-version" );
149     sal_uInt32 nFlags = dumpHex< sal_uInt32 >( "flags", "STDHLINK-FLAGS" );
150     if( getFlag( nFlags, STDHLINK_HASDISPLAY ) )
151         dumpHyperlinkString( "display", true );
152     if( getFlag( nFlags, STDHLINK_HASFRAME ) )
153         dumpHyperlinkString( "frame", true );
154     if( getFlag( nFlags, STDHLINK_HASTARGET ) )
155     {
156         if( getFlag( nFlags, STDHLINK_ASSTRING ) )
157             dumpHyperlinkString( "filename", true );
158         else if( !dumpGuidAndMoniker() )
159             return;
160     }
161     if( getFlag( nFlags, STDHLINK_HASLOCATION ) )
162         dumpHyperlinkString( "location", true );
163     if( getFlag( nFlags, STDHLINK_HASGUID ) )
164         dumpGuid( "id-guid" );
165     if( getFlag( nFlags, STDHLINK_HASTIME ) )
166         dumpFileTime( "creation-time" );
167 }
168 
dumpHyperlinkString(const String & rName,bool bUnicode)169 OUString StdHlinkObject::dumpHyperlinkString( const String& rName, bool bUnicode )
170 {
171     return bUnicode ? dumpUniString32( rName ) : dumpAnsiString32( rName );
172 }
173 
dumpGuidAndMoniker()174 bool StdHlinkObject::dumpGuidAndMoniker()
175 {
176     bool bValidMoniker = true;
177     OUString aGuid = cfg().getStringOption( dumpGuid( "moniker" ), OUString() );
178     IndentGuard aIndGuard( mxOut );
179     if( aGuid.equalsAscii( "URLMoniker" ) )
180         dumpUrlMoniker();
181     else if( aGuid.equalsAscii( "FileMoniker" ) )
182         dumpFileMoniker();
183     else if( aGuid.equalsAscii( "ItemMoniker" ) )
184         dumpItemMoniker();
185     else if( aGuid.equalsAscii( "AntiMoniker" ) )
186         dumpAntiMoniker();
187     else if( aGuid.equalsAscii( "CompositeMoniker" ) )
188         dumpCompositeMoniker();
189     else
190         bValidMoniker = false;
191     return bValidMoniker;
192 }
193 
dumpUrlMoniker()194 void StdHlinkObject::dumpUrlMoniker()
195 {
196     sal_Int32 nBytes = dumpDec< sal_Int32 >( "url-bytes" );
197     sal_Int64 nEndPos = mxStrm->tell() + ::std::max< sal_Int32 >( nBytes, 0 );
198     dumpNullUnicodeArray( "url" );
199     if( mxStrm->tell() + 24 == nEndPos )
200     {
201         dumpGuid( "implementation-id" );
202         dumpDec< sal_uInt32 >( "version" );
203         dumpHex< sal_uInt32 >( "flags", "STDHLINK-URL-FLAGS" );
204     }
205     dumpRemainingTo( nEndPos );
206 }
207 
dumpFileMoniker()208 void StdHlinkObject::dumpFileMoniker()
209 {
210     dumpDec< sal_Int16 >( "up-levels" );
211     dumpHyperlinkString( "ansi-filename", false );
212     dumpDec< sal_Int16 >( "server-path-len" );
213     dumpHex< sal_uInt16 >( "version" );
214     dumpUnused( 20 );
215     sal_Int32 nBytes = dumpDec< sal_Int32 >( "total-bytes" );
216     sal_Int64 nEndPos = mxStrm->tell() + ::std::max< sal_Int32 >( nBytes, 0 );
217     if( nBytes > 0 )
218     {
219         sal_Int32 nFileBytes = dumpDec< sal_Int32 >( "uni-filename-bytes" );
220         dumpDec< sal_uInt16 >( "key-value" );
221         dumpUnicodeArray( "unicode-filename", nFileBytes / 2 );
222     }
223     dumpRemainingTo( nEndPos );
224 }
225 
dumpItemMoniker()226 void StdHlinkObject::dumpItemMoniker()
227 {
228     sal_Int32 nBytes = dumpDec< sal_Int32 >( "delimiter-bytes" );
229     sal_Int64 nEndPos = mxStrm->tell() + ::std::max< sal_Int32 >( nBytes, 0 );
230     dumpNullCharArray( "ansi-delimiter", RTL_TEXTENCODING_MS_1252 );
231     if( mxStrm->tell() < nEndPos )
232         dumpUnicodeArray( "unicode-delimiter", (nEndPos - mxStrm->tell()) / 2 );
233     mxStrm->seek( nEndPos );
234 
235     nBytes = dumpDec< sal_Int32 >( "item-bytes" );
236     nEndPos = mxStrm->tell() + ::std::max< sal_Int32 >( nBytes, 0 );
237     dumpNullCharArray( "ansi-item", RTL_TEXTENCODING_MS_1252 );
238     if( mxStrm->tell() < nEndPos )
239         dumpUnicodeArray( "unicode-item", (nEndPos - mxStrm->tell()) / 2 );
240     mxStrm->seek( nEndPos );
241 }
242 
dumpAntiMoniker()243 void StdHlinkObject::dumpAntiMoniker()
244 {
245     dumpDec< sal_Int32 >( "count" );
246 }
247 
dumpCompositeMoniker()248 void StdHlinkObject::dumpCompositeMoniker()
249 {
250     sal_Int32 nCount = dumpDec< sal_Int32 >( "moniker-count" );
251     for( sal_Int32 nIndex = 0; !mxStrm->isEof() && (nIndex < nCount); ++nIndex )
252         dumpGuidAndMoniker();
253 }
254 
255 // ============================================================================
256 // ============================================================================
257 
OleStreamObject(const ObjectBase & rParent,const BinaryInputStreamRef & rxStrm,const OUString & rSysFileName)258 OleStreamObject::OleStreamObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName )
259 {
260     construct( rParent, rxStrm, rSysFileName );
261 }
262 
263 // ============================================================================
264 
OleCompObjObject(const ObjectBase & rParent,const BinaryInputStreamRef & rxStrm,const OUString & rSysFileName)265 OleCompObjObject::OleCompObjObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName ) :
266     OleStreamObject( rParent, rxStrm, rSysFileName )
267 {
268 }
269 
implDump()270 void OleCompObjObject::implDump()
271 {
272     dumpUnused( 4 );
273     dumpDec< sal_uInt32 >( "version" );
274     dumpUnused( 20 );
275     dumpAnsiString32( "ansi-display-name" );
276     dumpAnsiString32OrStdClip( "ansi-clipboard-format" );
277     if( mxStrm->getRemaining() >= 4 )
278     {
279         sal_Int32 nLen = mxStrm->readInt32();
280         if( (0 <= nLen) && (nLen <= 40) )
281         {
282             dumpCharArray( "ansi-unused", nLen, RTL_TEXTENCODING_MS_1252 );
283             if( (mxStrm->getRemaining() >= 4) && (dumpHex< sal_Int32 >( "unicode-marker" ) == 0x71B239F4) )
284             {
285                 dumpUniString32( "unicode-display-name" );
286                 dumpUniString32OrStdClip( "unicode-clipboard-format" );
287                 dumpUniString32( "unicode-unused" );
288             }
289         }
290         else
291             writeDecItem( "length", nLen );
292     }
293     dumpRemainingStream();
294 }
295 
296 // ============================================================================
297 // ============================================================================
298 
299 namespace {
300 
301 const sal_Int32 OLEPROP_ID_DICTIONARY   = 0;
302 const sal_Int32 OLEPROP_ID_CODEPAGE     = 1;
303 
304 const sal_uInt16 OLEPROP_TYPE_INT16     = 2;
305 const sal_uInt16 OLEPROP_TYPE_INT32     = 3;
306 const sal_uInt16 OLEPROP_TYPE_FLOAT     = 4;
307 const sal_uInt16 OLEPROP_TYPE_DOUBLE    = 5;
308 const sal_uInt16 OLEPROP_TYPE_DATE      = 7;
309 const sal_uInt16 OLEPROP_TYPE_STRING    = 8;
310 const sal_uInt16 OLEPROP_TYPE_STATUS    = 10;
311 const sal_uInt16 OLEPROP_TYPE_BOOL      = 11;
312 const sal_uInt16 OLEPROP_TYPE_VARIANT   = 12;
313 const sal_uInt16 OLEPROP_TYPE_INT8      = 16;
314 const sal_uInt16 OLEPROP_TYPE_UINT8     = 17;
315 const sal_uInt16 OLEPROP_TYPE_UINT16    = 18;
316 const sal_uInt16 OLEPROP_TYPE_UINT32    = 19;
317 const sal_uInt16 OLEPROP_TYPE_INT64     = 20;
318 const sal_uInt16 OLEPROP_TYPE_UINT64    = 21;
319 const sal_uInt16 OLEPROP_TYPE_STRING8   = 30;
320 const sal_uInt16 OLEPROP_TYPE_STRING16  = 31;
321 const sal_uInt16 OLEPROP_TYPE_FILETIME  = 64;
322 const sal_uInt16 OLEPROP_TYPE_BLOB      = 65;
323 const sal_uInt16 OLEPROP_TYPE_STREAM    = 66;
324 const sal_uInt16 OLEPROP_TYPE_STORAGE   = 67;
325 const sal_uInt16 OLEPROP_TYPE_CLIPFMT   = 71;
326 
327 const sal_uInt16 OLEPROP_TYPE_SIMPLE    = 0x0000;
328 const sal_uInt16 OLEPROP_TYPE_VECTOR    = 0x1000;
329 const sal_uInt16 OLEPROP_TYPE_ARRAY     = 0x2000;
330 
331 const sal_uInt16 CODEPAGE_UNICODE       = 1200;
332 
333 const sal_uInt32 AX_STRING_COMPRESSED   = 0x80000000;
334 
335 } // namespace
336 
337 // ============================================================================
338 
OlePropertyStreamObject(const ObjectBase & rParent,const BinaryInputStreamRef & rxStrm,const OUString & rSysFileName)339 OlePropertyStreamObject::OlePropertyStreamObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName )
340 {
341     construct( rParent, rxStrm, rSysFileName );
342 }
343 
implDump()344 void OlePropertyStreamObject::implDump()
345 {
346     OUStringVector aGuidVec;
347     ::std::vector< sal_uInt32 > aStartPosVec;
348 
349     // dump header
350     writeEmptyItem( "HEADER" );
351     {
352         IndentGuard aIndGuard( mxOut );
353         dumpHex< sal_uInt16 >( "byte-order", "OLEPROP-BYTE-ORDER" );
354         dumpDec< sal_uInt16 >( "version" );
355         dumpDec< sal_uInt16 >( "os-minor" );
356         dumpDec< sal_uInt16 >( "os-type", "OLEPROP-OSTYPE" );
357         dumpGuid( "guid" );
358         sal_Int32 nSectCount = dumpDec< sal_Int32 >( "section-count" );
359 
360         // dump table of section positions
361         {
362             TableGuard aTabGuard( mxOut, 15, 60 );
363             mxOut->resetItemIndex();
364             for( sal_Int32 nSectIdx = 0; !mxStrm->isEof() && (nSectIdx < nSectCount); ++nSectIdx )
365             {
366                 MultiItemsGuard aMultiGuard( mxOut );
367                 writeEmptyItem( "#section" );
368                 aGuidVec.push_back( dumpGuid( "guid" ) );
369                 aStartPosVec.push_back( dumpHex< sal_uInt32 >( "start-pos", "CONV-DEC" ) );
370             }
371         }
372     }
373     mxOut->emptyLine();
374 
375     // dump sections
376     for( size_t nSectIdx = 0; !mxStrm->isEof() && (nSectIdx < aStartPosVec.size()); ++nSectIdx )
377         dumpSection( aGuidVec[ nSectIdx ], aStartPosVec[ nSectIdx ] );
378 }
379 
dumpSection(const OUString & rGuid,sal_uInt32 nStartPos)380 void OlePropertyStreamObject::dumpSection( const OUString& rGuid, sal_uInt32 nStartPos )
381 {
382     // property ID names
383     mxPropIds = cfg().createNameList< ConstList >( "OLEPROP-IDS" );
384     OUString aGuidName = cfg().getStringOption( rGuid, OUString() );
385     if( aGuidName.equalsAscii( "GlobalDocProp" ) )
386         mxPropIds->includeList( cfg().getNameList( "OLEPROP-GLOBALIDS" ) );
387     else if( aGuidName.equalsAscii( "BuiltinDocProp" ) )
388         mxPropIds->includeList( cfg().getNameList( "OLEPROP-BUILTINIDS" ) );
389     else
390         mxPropIds->includeList( cfg().getNameList( "OLEPROP-BASEIDS" ) );
391 
392     // property ID/position map
393     typedef ::std::map< sal_Int32, sal_uInt32 > PropertyPosMap;
394     PropertyPosMap aPropMap;
395 
396     // dump section header line
397     writeSectionHeader( rGuid, nStartPos );
398 
399     // seek to section
400     IndentGuard aIndGuard( mxOut );
401     if( startElement( nStartPos ) )
402     {
403         // dump section header
404         dumpDec< sal_Int32 >( "size" );
405         sal_Int32 nPropCount = dumpDec< sal_Int32 >( "property-count" );
406 
407         // dump table of property positions
408         {
409             TableGuard aTabGuard( mxOut, 15, 25 );
410             mxOut->resetItemIndex();
411             for( sal_Int32 nPropIdx = 0; !mxStrm->isEof() && (nPropIdx < nPropCount); ++nPropIdx )
412             {
413                 MultiItemsGuard aMultiGuard( mxOut );
414                 writeEmptyItem( "#property" );
415                 sal_Int32 nPropId = dumpDec< sal_Int32 >( "id", mxPropIds );
416                 sal_uInt32 nPropPos = nStartPos + dumpHex< sal_uInt32 >( "start-pos", "CONV-DEC" );
417                 aPropMap[ nPropId ] = nPropPos;
418             }
419         }
420     }
421     mxOut->emptyLine();
422 
423     // code page property
424     meTextEnc = RTL_TEXTENCODING_MS_1252;
425     mbIsUnicode = false;
426     PropertyPosMap::iterator aCodePageIt = aPropMap.find( OLEPROP_ID_CODEPAGE );
427     if( aCodePageIt != aPropMap.end() )
428     {
429         dumpCodePageProperty( aCodePageIt->second );
430         aPropMap.erase( aCodePageIt );
431     }
432 
433     // dictionary property
434     PropertyPosMap::iterator aDictIt = aPropMap.find( OLEPROP_ID_DICTIONARY );
435     if( aDictIt != aPropMap.end() )
436     {
437         dumpDictionaryProperty( aDictIt->second );
438         aPropMap.erase( aDictIt );
439     }
440 
441     // other properties
442     for( PropertyPosMap::const_iterator aIt = aPropMap.begin(), aEnd = aPropMap.end(); aIt != aEnd; ++aIt )
443         dumpProperty( aIt->first, aIt->second );
444 
445     // remove the user defined list of property ID names
446     cfg().eraseNameList( "OLEPROP-IDS" );
447 }
448 
dumpProperty(sal_Int32 nPropId,sal_uInt32 nStartPos)449 void OlePropertyStreamObject::dumpProperty( sal_Int32 nPropId, sal_uInt32 nStartPos )
450 {
451     writePropertyHeader( nPropId, nStartPos );
452     IndentGuard aIndGuard( mxOut );
453     if( startElement( nStartPos ) )
454         dumpPropertyContents( nPropId );
455     mxOut->emptyLine();
456 }
457 
dumpCodePageProperty(sal_uInt32 nStartPos)458 void OlePropertyStreamObject::dumpCodePageProperty( sal_uInt32 nStartPos )
459 {
460     writePropertyHeader( OLEPROP_ID_CODEPAGE, nStartPos );
461     IndentGuard aIndGuard( mxOut );
462     if( startElement( nStartPos ) )
463     {
464         sal_uInt16 nType = dumpPropertyType();
465         if( nType == OLEPROP_TYPE_INT16 )
466         {
467             sal_uInt16 nCodePage = dumpDec< sal_uInt16 >( "codepage", "CODEPAGES" );
468             rtl_TextEncoding eNewTextEnc = rtl_getTextEncodingFromWindowsCodePage( nCodePage );
469             if( eNewTextEnc != RTL_TEXTENCODING_DONTKNOW )
470                 meTextEnc = eNewTextEnc;
471             mbIsUnicode = nCodePage == CODEPAGE_UNICODE;
472         }
473         else
474             dumpPropertyContents( OLEPROP_ID_CODEPAGE );
475     }
476     mxOut->emptyLine();
477 }
478 
dumpDictionaryProperty(sal_uInt32 nStartPos)479 void OlePropertyStreamObject::dumpDictionaryProperty( sal_uInt32 nStartPos )
480 {
481     writePropertyHeader( OLEPROP_ID_DICTIONARY, nStartPos );
482     IndentGuard aIndGuard( mxOut );
483     if( startElement( nStartPos ) )
484     {
485         sal_Int32 nCount = dumpDec< sal_Int32 >( "count" );
486         for( sal_Int32 nIdx = 0; !mxStrm->isEof() && (nIdx < nCount); ++nIdx )
487         {
488             MultiItemsGuard aMultiGuard( mxOut );
489             TableGuard aTabGuard( mxOut, 10, 20 );
490             sal_Int32 nId = dumpDec< sal_Int32 >( "id" );
491             OUString aName = dumpString8( "name" );
492             if( mxPropIds.get() )
493                 mxPropIds->setName( nId, aName );
494         }
495     }
496     mxOut->emptyLine();
497 }
498 
dumpPropertyContents(sal_Int32 nPropId)499 sal_uInt16 OlePropertyStreamObject::dumpPropertyContents( sal_Int32 nPropId )
500 {
501     sal_uInt16 nType = dumpPropertyType();
502     sal_uInt16 nBaseType = static_cast< sal_uInt16 >( nType & 0x0FFF );
503     sal_uInt16 nArrayType = static_cast< sal_uInt16 >( nType & 0xF000 );
504     switch( nArrayType )
505     {
506         case OLEPROP_TYPE_SIMPLE:   dumpPropertyValue( nPropId, nBaseType );    break;
507         case OLEPROP_TYPE_VECTOR:   dumpPropertyVector( nPropId, nBaseType );   break;
508         case OLEPROP_TYPE_ARRAY:    dumpPropertyArray( nPropId, nBaseType );    break;
509     }
510     return nType;
511 }
512 
dumpPropertyValue(sal_Int32 nPropId,sal_uInt16 nBaseType)513 void OlePropertyStreamObject::dumpPropertyValue( sal_Int32 nPropId, sal_uInt16 nBaseType )
514 {
515     switch( nBaseType )
516     {
517         case OLEPROP_TYPE_INT16:        dumpDec< sal_Int16 >( "value" );        break;
518         case OLEPROP_TYPE_INT32:        dumpDec< sal_Int32 >( "value" );        break;
519         case OLEPROP_TYPE_FLOAT:        dumpDec< float >( "value" );            break;
520         case OLEPROP_TYPE_DOUBLE:       dumpDec< double >( "value" );           break;
521         case OLEPROP_TYPE_DATE:         dumpDec< double >( "date" );            break;
522         case OLEPROP_TYPE_STRING:       dumpString8( "value" );                 break;
523         case OLEPROP_TYPE_STATUS:       dumpHex< sal_Int32 >( "status" );       break;
524         case OLEPROP_TYPE_BOOL:         dumpBool< sal_Int16 >( "value" );       break;
525         case OLEPROP_TYPE_VARIANT:      dumpPropertyContents( nPropId );        break;
526         case OLEPROP_TYPE_INT8:         dumpDec< sal_Int8 >( "value" );         break;
527         case OLEPROP_TYPE_UINT8:        dumpDec< sal_uInt8 >( "value" );        break;
528         case OLEPROP_TYPE_UINT16:       dumpDec< sal_uInt16 >( "value" );       break;
529         case OLEPROP_TYPE_UINT32:       dumpDec< sal_uInt32 >( "value" );       break;
530         case OLEPROP_TYPE_INT64:        dumpDec< sal_Int64 >( "value" );        break;
531         case OLEPROP_TYPE_UINT64:       dumpDec< sal_uInt64 >( "value" );       break;
532         case OLEPROP_TYPE_STRING8:      dumpString8( "value" );                 break;
533         case OLEPROP_TYPE_STRING16:     dumpString16( "value" );                break;
534         case OLEPROP_TYPE_FILETIME:     dumpFileTime( "file-time" );            break;
535         case OLEPROP_TYPE_BLOB:         dumpBlob( nPropId, "data" );            break;
536         case OLEPROP_TYPE_STREAM:       dumpString8( "stream-name" );           break;
537         case OLEPROP_TYPE_STORAGE:      dumpString8( "storage-name" );          break;
538         case OLEPROP_TYPE_CLIPFMT:      dumpBlob( nPropId, "clip-data" );       break;
539     }
540 }
541 
dumpPropertyVector(sal_Int32 nPropId,sal_uInt16 nBaseType)542 void OlePropertyStreamObject::dumpPropertyVector( sal_Int32 nPropId, sal_uInt16 nBaseType )
543 {
544     sal_Int32 nElemCount = dumpDec< sal_Int32 >( "element-count" );
545     for( sal_Int32 nElemIdx = 0; !mxStrm->isEof() && (nElemIdx < nElemCount); ++nElemIdx )
546     {
547         mxOut->resetItemIndex( nElemIdx );
548         writeEmptyItem( "#element" );
549         IndentGuard aIndGuard( mxOut );
550         dumpPropertyValue( nPropId, nBaseType );
551     }
552 }
553 
dumpPropertyArray(sal_Int32,sal_uInt16)554 void OlePropertyStreamObject::dumpPropertyArray( sal_Int32 /*nPropId*/, sal_uInt16 /*nBaseType*/ )
555 {
556     // TODO
557 }
558 
dumpPropertyType()559 sal_uInt16 OlePropertyStreamObject::dumpPropertyType()
560 {
561     return static_cast< sal_uInt16 >( dumpHex< sal_Int32 >( "type", "OLEPROP-TYPE" ) & 0xFFFF );
562 }
563 
dumpBlob(sal_Int32 nPropId,const String & rName)564 void OlePropertyStreamObject::dumpBlob( sal_Int32 nPropId, const String& rName )
565 {
566     sal_Int32 nSize = dumpDec< sal_Int32 >( "data-size" );
567     if( nSize > 0 )
568     {
569         OUString aPropName = mxPropIds->getName( cfg(), nPropId );
570         if( aPropName == CREATE_OUSTRING( "'_PID_HLINKS'" ) )
571             dumpHlinks( nSize );
572         else
573             dumpBinary( rName, nSize );
574     }
575 }
576 
dumpString8(const String & rName)577 OUString OlePropertyStreamObject::dumpString8( const String& rName )
578 {
579     sal_Int32 nLen = dumpDec< sal_Int32 >( "string-len" );
580     return mbIsUnicode ? dumpCharArray16( rName, nLen ) : dumpCharArray8( rName, nLen );
581 }
582 
dumpCharArray8(const String & rName,sal_Int32 nLen)583 OUString OlePropertyStreamObject::dumpCharArray8( const String& rName, sal_Int32 nLen )
584 {
585     sal_Int32 nNewLen = getLimitedValue< sal_Int32, sal_Int32 >( nLen, 0, 1024 );
586     OUString aData = mxStrm->readCharArrayUC( nNewLen, meTextEnc );
587     writeStringItem( rName, aData );
588     return aData;
589 }
590 
dumpString16(const String & rName)591 OUString OlePropertyStreamObject::dumpString16( const String& rName )
592 {
593     sal_Int32 nLen = dumpDec< sal_Int32 >( "string-len" );
594     return dumpCharArray16( rName, nLen );
595 }
596 
dumpCharArray16(const String & rName,sal_Int32 nLen)597 OUString OlePropertyStreamObject::dumpCharArray16( const String& rName, sal_Int32 nLen )
598 {
599     sal_Int32 nNewLen = getLimitedValue< sal_Int32, sal_Int32 >( nLen, 0, 1024 );
600     OUString aData = mxStrm->readUnicodeArray( nNewLen );
601     writeStringItem( rName, aData );
602     if( nNewLen & 1 ) dumpUnused( 2 ); // always padding to 32bit
603     return aData;
604 }
605 
dumpTypedProperty(const String & rName,sal_uInt16 nExpectedType)606 bool OlePropertyStreamObject::dumpTypedProperty( const String& rName, sal_uInt16 nExpectedType )
607 {
608     writeEmptyItem( rName );
609     IndentGuard aIndGuard( mxOut );
610     return (dumpPropertyContents( -1 ) == nExpectedType) && !mxStrm->isEof();
611 }
612 
dumpHlinks(sal_Int32 nSize)613 void OlePropertyStreamObject::dumpHlinks( sal_Int32 nSize )
614 {
615     sal_Int64 nEndPos = mxStrm->tell() + nSize;
616     sal_Int32 nCount = dumpDec< sal_Int32 >( "property-count" );
617     bool bValid = true;
618     for( sal_Int32 nHlinkIndex = 0, nHlinkCount = nCount / 6; bValid && !mxStrm->isEof() && (nHlinkIndex < nHlinkCount); ++nHlinkIndex )
619     {
620         writeEmptyItem( "HYPERLINK" );
621         IndentGuard aIndGuard( mxOut );
622         bValid =
623             dumpTypedProperty( "hash", OLEPROP_TYPE_INT32 ) &&
624             dumpTypedProperty( "app", OLEPROP_TYPE_INT32 ) &&
625             dumpTypedProperty( "shape-id", OLEPROP_TYPE_INT32 ) &&
626             dumpTypedProperty( "info", OLEPROP_TYPE_INT32 ) &&
627             dumpTypedProperty( "target", OLEPROP_TYPE_STRING16 ) &&
628             dumpTypedProperty( "location", OLEPROP_TYPE_STRING16 );
629     }
630     dumpRemainingTo( nEndPos );
631 }
632 
startElement(sal_uInt32 nStartPos)633 bool OlePropertyStreamObject::startElement( sal_uInt32 nStartPos )
634 {
635     mxStrm->seek( nStartPos );
636     if( mxStrm->isEof() )
637         writeInfoItem( "stream-state", OOX_DUMP_ERR_STREAM );
638     return !mxStrm->isEof();
639 }
640 
writeSectionHeader(const OUString & rGuid,sal_uInt32 nStartPos)641 void OlePropertyStreamObject::writeSectionHeader( const OUString& rGuid, sal_uInt32 nStartPos )
642 {
643     MultiItemsGuard aMultiGuard( mxOut );
644     writeEmptyItem( "SECTION" );
645     writeHexItem( "pos", nStartPos, "CONV-DEC" );
646     writeGuidItem( "guid", rGuid );
647 }
648 
writePropertyHeader(sal_Int32 nPropId,sal_uInt32 nStartPos)649 void OlePropertyStreamObject::writePropertyHeader( sal_Int32 nPropId, sal_uInt32 nStartPos )
650 {
651     MultiItemsGuard aMultiGuard( mxOut );
652     writeEmptyItem( "PROPERTY" );
653     writeHexItem( "pos", nStartPos, "CONV-DEC" );
654     writeDecItem( "id", nPropId, mxPropIds );
655 }
656 
657 // ============================================================================
658 
OleStorageObject(const ObjectBase & rParent,const StorageRef & rxStrg,const OUString & rSysPath)659 OleStorageObject::OleStorageObject( const ObjectBase& rParent, const StorageRef& rxStrg, const OUString& rSysPath )
660 {
661     construct( rParent, rxStrg, rSysPath );
662 }
663 
construct(const ObjectBase & rParent,const StorageRef & rxStrg,const OUString & rSysPath)664 void OleStorageObject::construct( const ObjectBase& rParent, const StorageRef& rxStrg, const OUString& rSysPath )
665 {
666     StorageObjectBase::construct( rParent, rxStrg, rSysPath );
667 }
668 
construct(const ObjectBase & rParent)669 void OleStorageObject::construct( const ObjectBase& rParent )
670 {
671     StorageObjectBase::construct( rParent );
672 }
673 
implDumpStream(const Reference<XInputStream> & rxStrm,const OUString &,const OUString & rStrmName,const OUString & rSysFileName)674 void OleStorageObject::implDumpStream( const Reference< XInputStream >& rxStrm, const OUString& /*rStrgPath*/, const OUString& rStrmName, const OUString& rSysFileName )
675 {
676     if( rStrmName.equalsAscii( "\001CompObj" ) )
677         OleCompObjObject( *this, rxStrm, rSysFileName ).dump();
678     else if( rStrmName.equalsAscii( "\005SummaryInformation" ) || rStrmName.equalsAscii( "\005DocumentSummaryInformation" ) )
679         OlePropertyStreamObject( *this, rxStrm, rSysFileName ).dump();
680     else
681         BinaryStreamObject( *this, rxStrm, rSysFileName ).dump();
682 }
683 
684 // ============================================================================
685 // ============================================================================
686 
ComCtlObjectBase(const InputObjectBase & rParent,sal_uInt32 nDataId5,sal_uInt32 nDataId6,sal_uInt16 nVersion,bool bCommonPart,bool bComplexPart)687 ComCtlObjectBase::ComCtlObjectBase( const InputObjectBase& rParent,
688         sal_uInt32 nDataId5, sal_uInt32 nDataId6, sal_uInt16 nVersion, bool bCommonPart, bool bComplexPart ) :
689     mnDataId5( nDataId5 ),
690     mnDataId6( nDataId6 ),
691     mnVersion( nVersion ),
692     mbCommonPart( bCommonPart ),
693     mbComplexPart( bComplexPart )
694 {
695     construct( rParent );
696 }
697 
implDump()698 void ComCtlObjectBase::implDump()
699 {
700     sal_uInt32 nCommonSize = 0;
701     dumpComCtlSize() && dumpComCtlData( nCommonSize ) && (!mbCommonPart || dumpComCtlCommon( nCommonSize )) && (!mbComplexPart || dumpComCtlComplex());
702 }
703 
implDumpCommonExtra(sal_Int64)704 void ComCtlObjectBase::implDumpCommonExtra( sal_Int64 /*nEndPos*/ )
705 {
706 }
707 
implDumpCommonTrailing()708 void ComCtlObjectBase::implDumpCommonTrailing()
709 {
710 }
711 
dumpComCtlHeader(sal_uInt32 nExpId,sal_uInt16 nExpMajor,sal_uInt16 nExpMinor)712 bool ComCtlObjectBase::dumpComCtlHeader( sal_uInt32 nExpId, sal_uInt16 nExpMajor, sal_uInt16 nExpMinor )
713 {
714     // no idea if all this is correct...
715     sal_uInt32 nId = dumpHex< sal_uInt32 >( "header-id", "COMCTL-HEADER-IDS" );
716     ItemGuard aItem( mxOut, "version" );
717     sal_uInt16 nMinor, nMajor;
718     *mxStrm >> nMinor >> nMajor;
719     mxOut->writeDec( nMajor );
720     mxOut->writeChar( '.' );
721     mxOut->writeDec( nMinor );
722     return !mxStrm->isEof() && (nId == nExpId) && ((nExpMajor == SAL_MAX_UINT16) || (nExpMajor == nMajor)) && ((nExpMinor == SAL_MAX_UINT16) || (nExpMinor == nMinor));
723 }
724 
dumpComCtlSize()725 bool ComCtlObjectBase::dumpComCtlSize()
726 {
727     if( dumpComCtlHeader( 0x12344321, 0, 8 ) )
728     {
729         IndentGuard aIndGuard( mxOut );
730         dumpDec< sal_Int32 >( "width", "CONV-HMM-TO-CM" );
731         dumpDec< sal_Int32 >( "height", "CONV-HMM-TO-CM" );
732         return !mxStrm->isEof();
733     }
734     return false;
735 }
736 
dumpComCtlData(sal_uInt32 & ornCommonPartSize)737 bool ComCtlObjectBase::dumpComCtlData( sal_uInt32& ornCommonPartSize )
738 {
739     if( dumpComCtlHeader( (mnVersion == 5) ? mnDataId5 : mnDataId6, mnVersion ) )
740     {
741         IndentGuard aIndGuard( mxOut );
742         if( mbCommonPart )
743             ornCommonPartSize = dumpDec< sal_uInt32 >( "common-part-size" );
744         implDumpProperties();
745         return !mxStrm->isEof();
746     }
747     return false;
748 }
749 
dumpComCtlCommon(sal_uInt32 nPartSize)750 bool ComCtlObjectBase::dumpComCtlCommon( sal_uInt32 nPartSize )
751 {
752     sal_Int64 nEndPos = mxStrm->tell() + nPartSize;
753     if( (nPartSize >= 16) && dumpComCtlHeader( 0xABCDEF01, 5, 0 ) )
754     {
755         IndentGuard aIndGuard( mxOut );
756         dumpUnknown( 4 );
757         dumpHex< sal_uInt32 >( "common-flags", "COMCTL-COMMON-FLAGS" );
758         implDumpCommonExtra( nEndPos );
759         dumpRemainingTo( nEndPos );
760         implDumpCommonTrailing();
761         return !mxStrm->isEof();
762     }
763     return false;
764 }
765 
dumpComCtlComplex()766 bool ComCtlObjectBase::dumpComCtlComplex()
767 {
768     if( dumpComCtlHeader( 0xBDECDE1F, 5, 1 ) )
769     {
770         IndentGuard aIndGuard( mxOut );
771         sal_uInt32 nFlags = dumpHex< sal_uInt32 >( "comctl-complex-flags", "COMCTL-COMPLEX-FLAGS" );
772         if( !mxStrm->isEof() && (nFlags & 0x01) )
773         {
774             writeEmptyItem( "font" );
775             IndentGuard aIndGuard2( mxOut );
776             OUString aClassName = cfg().getStringOption( dumpGuid(), OUString() );
777             if( aClassName.equalsAscii( "StdFont" ) )
778                 StdFontObject( *this ).dump();
779         }
780         if( !mxStrm->isEof() && (nFlags & 0x02) )
781         {
782             writeEmptyItem( "mouse-icon" );
783             IndentGuard aIndGuard2( mxOut );
784             OUString aClassName = cfg().getStringOption( dumpGuid(), OUString() );
785             if( aClassName.equalsAscii( "StdPic" ) )
786                 StdPicObject( *this ).dump();
787         }
788         return !mxStrm->isEof();
789     }
790     return false;
791 }
792 
793 // ============================================================================
794 
ComCtlScrollBarObject(const InputObjectBase & rParent,sal_uInt16 nVersion)795 ComCtlScrollBarObject::ComCtlScrollBarObject( const InputObjectBase& rParent, sal_uInt16 nVersion ) :
796     ComCtlObjectBase( rParent, SAL_MAX_UINT32, 0x99470A83, nVersion, true, true )
797 {
798 }
799 
implDumpProperties()800 void ComCtlScrollBarObject::implDumpProperties()
801 {
802     dumpHex< sal_uInt32 >( "flags", "COMCTL-SCROLLBAR-FLAGS" );
803     dumpDec< sal_Int32 >( "large-change" );
804     dumpDec< sal_Int32 >( "small-change" );
805     dumpDec< sal_Int32 >( "min" );
806     dumpDec< sal_Int32 >( "max" );
807     dumpDec< sal_Int32 >( "value" );
808 }
809 
810 // ============================================================================
811 
ComCtlProgressBarObject(const InputObjectBase & rParent,sal_uInt16 nVersion)812 ComCtlProgressBarObject::ComCtlProgressBarObject( const InputObjectBase& rParent, sal_uInt16 nVersion ) :
813     ComCtlObjectBase( rParent, 0xE6E17E84, 0x97AB8A01, nVersion, true, true )
814 {
815 }
816 
implDumpProperties()817 void ComCtlProgressBarObject::implDumpProperties()
818 {
819     dumpDec< float >( "min" );
820     dumpDec< float >( "max" );
821     if( mnVersion == 6 )
822     {
823         dumpBool< sal_uInt16 >( "vertical" );
824         dumpBool< sal_uInt16 >( "smooth-scroll" );
825     }
826 }
827 
828 // ============================================================================
829 
ComCtlSliderObject(const InputObjectBase & rParent,sal_uInt16 nVersion)830 ComCtlSliderObject::ComCtlSliderObject( const InputObjectBase& rParent, sal_uInt16 nVersion ) :
831     ComCtlObjectBase( rParent, 0xE6E17E86, 0x0A2BAE11, nVersion, true, true )
832 {
833 }
834 
implDumpProperties()835 void ComCtlSliderObject::implDumpProperties()
836 {
837     dumpBool< sal_Int32 >( "vertical" );
838     dumpDec< sal_Int32 >( "large-change" );
839     dumpDec< sal_Int32 >( "small-change" );
840     dumpDec< sal_Int32 >( "min" );
841     dumpDec< sal_Int32 >( "max" );
842     dumpDec< sal_Int16 >( "select-range", "COMCTL-SLIDER-SELECTRANGE" );
843     dumpUnused( 2 );
844     dumpDec< sal_Int32 >( "select-start" );
845     dumpDec< sal_Int32 >( "select-length" );
846     dumpDec< sal_Int32 >( "tick-style", "COMCTL-SLIDER-TICKSTYLE" );
847     dumpDec< sal_Int32 >( "tick-frequency" );
848     dumpDec< sal_Int32 >( "value" );
849     if( mnVersion == 6 )
850         dumpBool< sal_Int32 >( "tooltip-below" );
851 }
852 
853 // ============================================================================
854 
ComCtlUpDownObject(const InputObjectBase & rParent,sal_uInt16 nVersion)855 ComCtlUpDownObject::ComCtlUpDownObject( const InputObjectBase& rParent, sal_uInt16 nVersion ) :
856     ComCtlObjectBase( rParent, 0xFF3626A0, 0xFF3626A0, nVersion, false, false )
857 {
858 }
859 
implDumpProperties()860 void ComCtlUpDownObject::implDumpProperties()
861 {
862     dumpUnknown( 16 ); // buddy-property, somehow
863     dumpDec< sal_Int32 >( "buddy-control" );
864     dumpUnknown( 8 );
865     dumpDec< sal_Int32 >( "value" );
866     dumpUnknown( 4 );
867     dumpDec< sal_Int32 >( "increment" );
868     dumpDec< sal_Int32 >( "max" );
869     dumpDec< sal_Int32 >( "min" );
870     dumpHex< sal_uInt32 >( "flags-1", "COMCTL-UPDOWN-FLAGS1" );
871     dumpHex< sal_uInt32 >( "flags-2", "COMCTL-UPDOWN-FLAGS2" );
872     dumpUnknown( 4 );
873 }
874 
875 // ============================================================================
876 
ComCtlImageListObject(const InputObjectBase & rParent,sal_uInt16 nVersion)877 ComCtlImageListObject::ComCtlImageListObject( const InputObjectBase& rParent, sal_uInt16 nVersion ) :
878     ComCtlObjectBase( rParent, 0xE6E17E80, 0xE6E17E80, nVersion, true, false )
879 {
880 }
881 
implDumpProperties()882 void ComCtlImageListObject::implDumpProperties()
883 {
884     dumpDec< sal_uInt16 >( "image-width" );
885     dumpDec< sal_uInt16 >( "image-height" );
886     dumpOleColor( "mask-color" );
887     dumpBool< sal_Int16 >( "use-mask-color" );
888     dumpUnknown( 2 );
889 }
890 
implDumpCommonExtra(sal_Int64)891 void ComCtlImageListObject::implDumpCommonExtra( sal_Int64 /*nEndPos*/ )
892 {
893     dumpUnknown( 4 );
894     dumpOleColor( "back-color" );
895     dumpUnknown( 4 );
896     sal_Int32 nImageCount = dumpDec< sal_Int32 >( "image-count" );
897     mxOut->resetItemIndex();
898     for( sal_Int32 nImageIndex = 0; (nImageIndex < nImageCount) && !mxStrm->isEof(); ++nImageIndex )
899     {
900         writeEmptyItem( "#image" );
901         IndentGuard aIndGuard( mxOut );
902         sal_uInt8 nFlags = dumpHex< sal_uInt8 >( "text-flags", "COMCTL-IMAGELIST-TEXTFLAGS" );
903         if( nFlags & 0x01 ) dumpUniString32( "caption" );
904         if( nFlags & 0x02 ) dumpUniString32( "key" );
905     }
906 }
907 
implDumpCommonTrailing()908 void ComCtlImageListObject::implDumpCommonTrailing()
909 {
910     sal_Int32 nImageCount = dumpDec< sal_Int32 >( "image-count" );
911     mxOut->resetItemIndex();
912     for( sal_Int32 nImageIndex = 0; (nImageIndex < nImageCount) && !mxStrm->isEof(); ++nImageIndex )
913     {
914         writeEmptyItem( "#image" );
915         IndentGuard aIndGuard( mxOut );
916         dumpDec< sal_Int32 >( "index" );
917         StdPicObject( *this ).dump();
918     }
919 }
920 
921 // ============================================================================
922 
ComCtlTabStripObject(const InputObjectBase & rParent,sal_uInt16 nVersion)923 ComCtlTabStripObject::ComCtlTabStripObject( const InputObjectBase& rParent, sal_uInt16 nVersion ) :
924     ComCtlObjectBase( rParent, 0xE6E17E8A, 0xD12A7AC1, nVersion, true, true )
925 {
926 }
927 
implDumpProperties()928 void ComCtlTabStripObject::implDumpProperties()
929 {
930     dumpHex< sal_uInt32 >( "flags-1", "COMCTL-TABSTRIP-FLAGS1" );
931     dumpDec< sal_uInt16 >( "tab-fixed-width", "CONV-HMM-TO-CM" );
932     dumpDec< sal_uInt16 >( "tab-fixed-height", "CONV-HMM-TO-CM" );
933     if( mnVersion == 6 )
934     {
935         dumpHex< sal_uInt32 >( "flags-2", "COMCTL-TABSTRIP-FLAGS2" );
936         dumpDec< sal_uInt16 >( "tab-min-width", "CONV-HMM-TO-CM" );
937         dumpUnknown( 2 );
938         dumpHex< sal_uInt32 >( "flags-3", "COMCTL-TABSTRIP-FLAGS3" );
939     }
940 }
941 
implDumpCommonExtra(sal_Int64)942 void ComCtlTabStripObject::implDumpCommonExtra( sal_Int64 /*nEndPos*/ )
943 {
944     dumpUnknown( 12 );
945     dumpUniString32( "image-list" );
946     sal_Int32 nTabCount = dumpDec< sal_Int32 >( "tab-count" );
947     mxOut->resetItemIndex();
948     for( sal_Int32 nTabIndex = 0; (nTabIndex < nTabCount) && !mxStrm->isEof(); ++nTabIndex )
949     {
950         writeEmptyItem( "#tab" );
951         IndentGuard aIndGuard( mxOut );
952         dumpUnknown( 4 );
953         sal_uInt32 nTabFlags = dumpHex< sal_uInt32 >( "tab-flags", "COMCTL-TABSTRIP-TABFLAGS" );
954         if( nTabFlags & 0x01 ) dumpUniString32( "caption" );
955         if( nTabFlags & 0x02 ) dumpUniString32( "key" );
956         if( nTabFlags & 0x04 ) dumpUniString32( "tag" );
957         if( nTabFlags & 0x08 ) dumpUniString32( "tooltip" );
958         dumpDec< sal_uInt16 >( "image-id" );
959     }
960 }
961 
962 // ============================================================================
963 
ComCtlTreeViewObject(const InputObjectBase & rParent,sal_uInt16 nVersion)964 ComCtlTreeViewObject::ComCtlTreeViewObject( const InputObjectBase& rParent, sal_uInt16 nVersion ) :
965     ComCtlObjectBase( rParent, 0xE6E17E8E, 0x6AC13CB1, nVersion, true, true ),
966     mnStringFlags( 0 )
967 {
968 }
969 
implDumpProperties()970 void ComCtlTreeViewObject::implDumpProperties()
971 {
972     dumpHex< sal_uInt32 >( "flags", "COMCTL-TREEVIEW-FLAGS" );
973     dumpDec< sal_Int32 >( "indentation", "CONV-HMM-TO-CM" );
974     if( mnVersion == 6 )
975         dumpHex< sal_uInt32 >( "flags-2", "COMCTL-TREEVIEW-FLAGS2" );
976     mnStringFlags = dumpHex< sal_uInt32 >( "string-flags", "COMCTL-TREEVIEW-STRINGFLAGS" );
977 }
978 
implDumpCommonExtra(sal_Int64)979 void ComCtlTreeViewObject::implDumpCommonExtra( sal_Int64 /*nEndPos*/ )
980 {
981     dumpOleColor( "text-color" );
982     dumpOleColor( "back-color" );
983     dumpUnknown( 4 );
984     if( mnStringFlags & 0x02 )
985         dumpUniString32( "image-list" );
986     dumpUniString32( "path-separator" );
987 }
988 
989 // ============================================================================
990 
ComCtlStatusBarObject(const InputObjectBase & rParent,sal_uInt16 nVersion)991 ComCtlStatusBarObject::ComCtlStatusBarObject( const InputObjectBase& rParent, sal_uInt16 nVersion ) :
992     ComCtlObjectBase( rParent, 0xE6E17E88, SAL_MAX_UINT32, nVersion, true, true )
993 {
994 }
995 
implDumpProperties()996 void ComCtlStatusBarObject::implDumpProperties()
997 {
998     dumpBool< sal_Int32 >( "style-simple-text" );
999     dumpBool< sal_Int16 >( "show-tips" );
1000     dumpUnknown( 2 );
1001 }
1002 
implDumpCommonExtra(sal_Int64)1003 void ComCtlStatusBarObject::implDumpCommonExtra( sal_Int64 /*nEndPos*/ )
1004 {
1005     dumpUnknown( 12 );
1006     dumpUniString32( "simple-text" );
1007     sal_Int32 nPanelCount = dumpDec< sal_Int32 >( "panel-count" );
1008     mxOut->resetItemIndex();
1009     for( sal_Int32 nPanelIndex = 0; (nPanelIndex < nPanelCount) && !mxStrm->isEof(); ++nPanelIndex )
1010     {
1011         writeEmptyItem( "#panel" );
1012         IndentGuard aIndGuard( mxOut );
1013         dumpHex< sal_uInt32 >( "panel-flags", "COMCTL-STATUSBAR-PANELFLAGS" );
1014         dumpDec< sal_Int32 >( "current-width", "CONV-HMM-TO-CM" );
1015         dumpDec< sal_Int32 >( "minimal-width", "CONV-HMM-TO-CM" );
1016         sal_uInt32 nTextFlags = dumpHex< sal_uInt32 >( "text-flags", "COMCTL-STATUSBAR-TEXTFLAGS" );
1017         if( nTextFlags & 0x01 ) dumpUniString32( "text" );
1018         if( nTextFlags & 0x02 ) dumpUniString32( "vis-text" );
1019         if( nTextFlags & 0x04 ) dumpUniString32( "key" );
1020         if( nTextFlags & 0x08 ) dumpUniString32( "tag" );
1021         if( nTextFlags & 0x10 ) dumpUniString32( "tooltip" );
1022     }
1023 }
1024 
implDumpCommonTrailing()1025 void ComCtlStatusBarObject::implDumpCommonTrailing()
1026 {
1027     sal_Int32 nImageCount = dumpDec< sal_Int32 >( "image-count" );
1028     mxOut->resetItemIndex();
1029     for( sal_Int32 nImageIndex = 0; (nImageIndex < nImageCount) && !mxStrm->isEof(); ++nImageIndex )
1030     {
1031         writeEmptyItem( "#image" );
1032         IndentGuard aIndGuard( mxOut );
1033         dumpDec< sal_Int32 >( "panel-index" );
1034         StdPicObject( *this ).dump();
1035     }
1036 }
1037 
1038 // ============================================================================
1039 // ============================================================================
1040 
construct(const ObjectBase & rParent,const BinaryInputStreamRef & rxStrm,const OUString & rSysFileName,const String & rPropNameList,bool b64BitPropFlags)1041 void AxPropertyObjectBase::construct( const ObjectBase& rParent,
1042         const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName, const String& rPropNameList, bool b64BitPropFlags )
1043 {
1044     OleInputObjectBase::construct( rParent, rxStrm, rSysFileName );
1045     constructAxPropObj( rPropNameList, b64BitPropFlags );
1046 }
1047 
construct(const OutputObjectBase & rParent,const BinaryInputStreamRef & rxStrm,const String & rPropNameList,bool b64BitPropFlags)1048 void AxPropertyObjectBase::construct( const OutputObjectBase& rParent,
1049         const BinaryInputStreamRef& rxStrm, const String& rPropNameList, bool b64BitPropFlags )
1050 {
1051     OleInputObjectBase::construct( rParent, rxStrm );
1052     constructAxPropObj( rPropNameList, b64BitPropFlags );
1053 }
1054 
construct(const InputObjectBase & rParent,const String & rPropNameList,bool b64BitPropFlags)1055 void AxPropertyObjectBase::construct( const InputObjectBase& rParent,
1056         const String& rPropNameList, bool b64BitPropFlags )
1057 {
1058     OleInputObjectBase::construct( rParent );
1059     constructAxPropObj( rPropNameList, b64BitPropFlags );
1060 }
1061 
implIsValid() const1062 bool AxPropertyObjectBase::implIsValid() const
1063 {
1064     return OleInputObjectBase::implIsValid() && mxStrm->isSeekable();
1065 }
1066 
implDump()1067 void AxPropertyObjectBase::implDump()
1068 {
1069     mbValid = true;
1070     // header
1071     setAlignAnchor();
1072     dumpVersion();
1073     sal_uInt16 nSize = dumpDec< sal_uInt16 >( "size" );
1074     mnPropertiesEnd = mxStrm->tell() + nSize;
1075     // property flags
1076     maLargeProps.clear();
1077     maStreamProps.clear();
1078     mnPropFlags = dumpHex< sal_Int64, sal_uInt32 >( mb64BitPropFlags, "properties", mxPropNames );
1079     mnCurrProp = 0;
1080     // properties
1081     dumpShortProperties();
1082     dumpLargeProperties();
1083     setAlignAnchor();
1084     if( ensureValid() )
1085         implDumpExtended();
1086 }
1087 
implDumpShortProperties()1088 void AxPropertyObjectBase::implDumpShortProperties()
1089 {
1090 }
1091 
implDumpExtended()1092 void AxPropertyObjectBase::implDumpExtended()
1093 {
1094 }
1095 
ensureValid(bool bCondition)1096 bool AxPropertyObjectBase::ensureValid( bool bCondition )
1097 {
1098     if( mbValid && (!bCondition || mxStrm->isEof()) )
1099     {
1100         if( !bCondition )
1101             writeInfoItem( "state", OOX_DUMP_ERRASCII( "format-error" ) );
1102         mbValid = false;
1103     }
1104     return mbValid;
1105 }
1106 
setAlignAnchor()1107 void AxPropertyObjectBase::setAlignAnchor()
1108 {
1109     mnPropertiesStart = mxStrm->tell();
1110 }
1111 
startNextProperty()1112 bool AxPropertyObjectBase::startNextProperty()
1113 {
1114     if( mnCurrProp == 0 ) mnCurrProp = 1; else mnCurrProp <<= 1;
1115     bool bHasProp = getFlag( mnPropFlags, mnCurrProp );
1116     setFlag( mnPropFlags, mnCurrProp, false );
1117     return ensureValid() && bHasProp;
1118 }
1119 
getPropertyName() const1120 OUString AxPropertyObjectBase::getPropertyName() const
1121 {
1122     return cfg().getName( mxPropNames, mnCurrProp );
1123 }
1124 
dumpFlagsProperty(sal_uInt32 nDefault,const sal_Char * pcNameList)1125 sal_uInt32 AxPropertyObjectBase::dumpFlagsProperty( sal_uInt32 nDefault, const sal_Char* pcNameList )
1126 {
1127     if( startNextProperty() )
1128     {
1129         alignInput< sal_uInt32 >();
1130         return dumpHex< sal_uInt32 >( getPropertyName(), pcNameList );
1131     }
1132     return nDefault;
1133 }
1134 
dumpColorProperty(sal_uInt32 nDefault)1135 sal_uInt32 AxPropertyObjectBase::dumpColorProperty( sal_uInt32 nDefault )
1136 {
1137     if( startNextProperty() )
1138     {
1139         alignInput< sal_uInt32 >();
1140         return dumpOleColor( getPropertyName() );
1141     }
1142     return nDefault;
1143 }
1144 
dumpUnicodeProperty()1145 sal_Unicode AxPropertyObjectBase::dumpUnicodeProperty()
1146 {
1147     if( startNextProperty() )
1148     {
1149         alignInput< sal_uInt16 >();
1150         return dumpUnicode( getPropertyName() );
1151     }
1152     return '\0';
1153 }
1154 
dumpUnknownProperty()1155 void AxPropertyObjectBase::dumpUnknownProperty()
1156 {
1157     if( startNextProperty() )
1158         ensureValid( false );
1159 }
1160 
dumpPosProperty()1161 void AxPropertyObjectBase::dumpPosProperty()
1162 {
1163     if( startNextProperty() )
1164         maLargeProps.push_back( LargeProperty( LargeProperty::PROPTYPE_POS, getPropertyName(), 8 ) );
1165 }
1166 
dumpSizeProperty()1167 void AxPropertyObjectBase::dumpSizeProperty()
1168 {
1169     if( startNextProperty() )
1170         maLargeProps.push_back( LargeProperty( LargeProperty::PROPTYPE_SIZE, getPropertyName(), 8 ) );
1171 }
1172 
dumpGuidProperty(OUString * pValue)1173 void AxPropertyObjectBase::dumpGuidProperty( OUString* pValue )
1174 {
1175     if( startNextProperty() )
1176         maLargeProps.push_back( LargeProperty( LargeProperty::PROPTYPE_GUID, getPropertyName(), 16, pValue ) );
1177 }
1178 
dumpStringProperty(OUString * pValue)1179 void AxPropertyObjectBase::dumpStringProperty( OUString* pValue )
1180 {
1181     if( startNextProperty() )
1182     {
1183         alignInput< sal_uInt32 >();
1184         sal_uInt32 nLen = dumpHex< sal_uInt32 >( getPropertyName(), "AX-STRINGLEN" );
1185         maLargeProps.push_back( LargeProperty( LargeProperty::PROPTYPE_STRING, getPropertyName(), nLen, pValue ) );
1186     }
1187 }
1188 
dumpStringArrayProperty()1189 void AxPropertyObjectBase::dumpStringArrayProperty()
1190 {
1191     if( startNextProperty() )
1192     {
1193         alignInput< sal_uInt32 >();
1194         sal_uInt32 nLen = dumpHex< sal_uInt32 >( getPropertyName(), "CONV-DEC" );
1195         maLargeProps.push_back( LargeProperty( LargeProperty::PROPTYPE_STRINGARRAY, getPropertyName(), nLen ) );
1196     }
1197 }
1198 
dumpStreamProperty()1199 void AxPropertyObjectBase::dumpStreamProperty()
1200 {
1201     if( startNextProperty() )
1202     {
1203         alignInput< sal_uInt16 >();
1204         sal_uInt16 nData = dumpHex< sal_uInt16 >( getPropertyName() );
1205         maStreamProps.push_back( StreamProperty( getPropertyName(), nData ) );
1206     }
1207 }
1208 
dumpEmbeddedFont()1209 void AxPropertyObjectBase::dumpEmbeddedFont()
1210 {
1211     if( ensureValid() )
1212     {
1213         writeEmptyItem( "embedded-fontdata" );
1214         IndentGuard aIndGuard( mxOut );
1215         AxCFontNewObject( *this ).dump();
1216     }
1217 }
1218 
dumpToPosition(sal_Int64 nPos)1219 void AxPropertyObjectBase::dumpToPosition( sal_Int64 nPos )
1220 {
1221     dumpRemainingTo( nPos );
1222     mbValid = true;
1223     ensureValid();
1224 }
1225 
constructAxPropObj(const String & rPropNameList,bool b64BitPropFlags)1226 void AxPropertyObjectBase::constructAxPropObj( const String& rPropNameList, bool b64BitPropFlags )
1227 {
1228     if( OleInputObjectBase::implIsValid() )
1229     {
1230         mxPropNames = cfg().getNameList( rPropNameList );
1231         mb64BitPropFlags = b64BitPropFlags;
1232         mbValid = true;
1233     }
1234 }
1235 
dumpVersion()1236 void AxPropertyObjectBase::dumpVersion()
1237 {
1238     ItemGuard aItem( mxOut, "version" );
1239     sal_uInt8 nMinor, nMajor;
1240     *mxStrm >> nMinor >> nMajor;
1241     mxOut->writeDec( nMajor );
1242     mxOut->writeChar( '.' );
1243     mxOut->writeDec( nMinor );
1244 }
1245 
dumpString(const String & rName,sal_uInt32 nSize,bool bArray)1246 OUString AxPropertyObjectBase::dumpString( const String& rName, sal_uInt32 nSize, bool bArray )
1247 {
1248     bool bCompressed = getFlag( nSize, AX_STRING_COMPRESSED );
1249     sal_uInt32 nBufSize = extractValue< sal_uInt32 >( nSize, 0, 31 );
1250     OUString aString = bCompressed ?
1251         dumpCharArray( rName, nBufSize, RTL_TEXTENCODING_ISO_8859_1 ) :
1252         dumpUnicodeArray( rName, bArray ? nBufSize : (nBufSize / 2) );
1253     alignInput< sal_Int32 >();
1254     return aString;
1255 }
1256 
dumpShortProperties()1257 void AxPropertyObjectBase::dumpShortProperties()
1258 {
1259     if( ensureValid() )
1260     {
1261         writeEmptyItem( "short-properties" );
1262         IndentGuard aIndGuard( mxOut );
1263         implDumpShortProperties();
1264         alignInput< sal_uInt32 >();
1265     }
1266 }
1267 
dumpLargeProperties()1268 void AxPropertyObjectBase::dumpLargeProperties()
1269 {
1270     if( ensureValid( mnPropFlags == 0 ) && !maLargeProps.empty() )
1271     {
1272         writeEmptyItem( "large-properties" );
1273         IndentGuard aIndGuard( mxOut );
1274         for( LargePropertyVector::iterator aIt = maLargeProps.begin(), aEnd = maLargeProps.end(); ensureValid() && (aIt != aEnd); ++aIt )
1275         {
1276             switch( aIt->mePropType )
1277             {
1278                 case LargeProperty::PROPTYPE_POS:
1279                 {
1280                     MultiItemsGuard aMultiGuard( mxOut );
1281                     writeEmptyItem( aIt->maItemName );
1282                     dumpDec< sal_Int32 >( "top", "CONV-HMM-TO-CM" );
1283                     dumpDec< sal_Int32 >( "left", "CONV-HMM-TO-CM" );
1284                 }
1285                 break;
1286                 case LargeProperty::PROPTYPE_SIZE:
1287                 {
1288                     MultiItemsGuard aMultiGuard( mxOut );
1289                     writeEmptyItem( aIt->maItemName );
1290                     dumpDec< sal_Int32 >( "width", "CONV-HMM-TO-CM" );
1291                     dumpDec< sal_Int32 >( "height", "CONV-HMM-TO-CM" );
1292                 }
1293                 break;
1294                 case LargeProperty::PROPTYPE_GUID:
1295                 {
1296                     OUString aGuid = dumpGuid( aIt->maItemName );
1297                     if( aIt->mpItemValue )
1298                         *aIt->mpItemValue = cfg().getStringOption( aGuid, OUString() );
1299                 }
1300                 break;
1301                 case LargeProperty::PROPTYPE_STRING:
1302                 {
1303                     OUString aString = dumpString( aIt->maItemName, aIt->mnDataSize, false );
1304                     if( aIt->mpItemValue )
1305                         *aIt->mpItemValue = aString;
1306                 }
1307                 break;
1308                 case LargeProperty::PROPTYPE_STRINGARRAY:
1309                 {
1310                     writeEmptyItem( aIt->maItemName );
1311                     IndentGuard aIndGuard2( mxOut );
1312                     mxOut->resetItemIndex();
1313                     sal_Int64 nEndPos = mxStrm->tell() + aIt->mnDataSize;
1314                     while( mxStrm->tell() < nEndPos )
1315                     {
1316                         MultiItemsGuard aMultiGuard( mxOut );
1317                         sal_uInt32 nDataSize = dumpHex< sal_uInt32 >( "#flags", "AX-ARRAYSTRINGLEN" );
1318                         dumpString( "string", nDataSize, true );
1319                     }
1320                     dumpToPosition( nEndPos );
1321                 }
1322                 break;
1323             }
1324         }
1325     }
1326     dumpToPosition( mnPropertiesEnd );
1327 
1328     if( ensureValid() && !maStreamProps.empty() )
1329     {
1330         writeEmptyItem( "stream-properties" );
1331         IndentGuard aIndGuard( mxOut );
1332         for( StreamPropertyVector::iterator aIt = maStreamProps.begin(), aEnd = maStreamProps.end(); ensureValid() && (aIt != aEnd); ++aIt )
1333         {
1334             writeEmptyItem( aIt->maItemName );
1335             if( ensureValid( aIt->mnData == 0xFFFF ) )
1336             {
1337                 IndentGuard aIndGuard2( mxOut );
1338                 OUString aClassName = cfg().getStringOption( dumpGuid(), OUString() );
1339                 if( aClassName.equalsAscii( "StdFont" ) )
1340                     StdFontObject( *this ).dump();
1341                 else if( aClassName.equalsAscii( "StdPic" ) )
1342                     StdPicObject( *this ).dump();
1343                 else if( aClassName.equalsAscii( "CFontNew" ) )
1344                     AxCFontNewObject( *this ).dump();
1345                 else
1346                     ensureValid( false );
1347             }
1348         }
1349     }
1350 }
1351 
1352 // ============================================================================
1353 
AxCFontNewObject(const InputObjectBase & rParent)1354 AxCFontNewObject::AxCFontNewObject( const InputObjectBase& rParent )
1355 {
1356     AxPropertyObjectBase::construct( rParent, "AX-CFONTNEW-PROPERTIES" );
1357 }
1358 
implDumpShortProperties()1359 void AxCFontNewObject::implDumpShortProperties()
1360 {
1361     dumpStringProperty();
1362     dumpFlagsProperty( 0, "AX-CFONTNEW-FLAGS" );
1363     dumpDecProperty< sal_Int32 >( 160 );
1364     dumpDecProperty< sal_Int32 >( 0 );
1365     dumpDecProperty< sal_uInt8 >( WINDOWS_CHARSET_DEFAULT, "CHARSET" );
1366     dumpDecProperty< sal_uInt8 >( 0, "FONT-PITCHFAMILY" );
1367     dumpDecProperty< sal_uInt8 >( 1, "AX-CFONTNEW-ALIGNMENT" );
1368     dumpDecProperty< sal_uInt16 >( 400, "FONT-WEIGHT" );
1369 }
1370 
1371 // ============================================================================
1372 
AxColumnInfoObject(const InputObjectBase & rParent)1373 AxColumnInfoObject::AxColumnInfoObject( const InputObjectBase& rParent )
1374 {
1375     AxPropertyObjectBase::construct( rParent, "AX-COLUMNINFO-PROPERTIES" );
1376 }
1377 
implDumpShortProperties()1378 void AxColumnInfoObject::implDumpShortProperties()
1379 {
1380     dumpDecProperty< sal_Int32 >( -1, "CONV-HMM-TO-CM" );
1381 }
1382 
1383 // ============================================================================
1384 
AxCommandButtonObject(const InputObjectBase & rParent)1385 AxCommandButtonObject::AxCommandButtonObject( const InputObjectBase& rParent )
1386 {
1387     AxPropertyObjectBase::construct( rParent, "AX-COMMANDBUTTON-PROPERTIES" );
1388 }
1389 
implDumpShortProperties()1390 void AxCommandButtonObject::implDumpShortProperties()
1391 {
1392     dumpColorProperty( 0x80000012 );
1393     dumpColorProperty( 0x80000008 );
1394     dumpFlagsProperty( 0x0000001B );
1395     dumpStringProperty();
1396     dumpImagePosProperty();
1397     dumpSizeProperty();
1398     dumpMousePtrProperty();
1399     dumpStreamProperty();
1400     dumpUnicodeProperty();
1401     dumpBoolProperty();
1402     dumpStreamProperty();
1403 }
1404 
implDumpExtended()1405 void AxCommandButtonObject::implDumpExtended()
1406 {
1407     dumpEmbeddedFont();
1408 }
1409 
1410 // ============================================================================
1411 
AxMorphControlObject(const InputObjectBase & rParent)1412 AxMorphControlObject::AxMorphControlObject( const InputObjectBase& rParent )
1413 {
1414     AxPropertyObjectBase::construct( rParent, "AX-MORPH-PROPERTIES", true );
1415 }
1416 
implDumpShortProperties()1417 void AxMorphControlObject::implDumpShortProperties()
1418 {
1419     dumpFlagsProperty( 0x2C80081B );
1420     dumpColorProperty( 0x80000005 );
1421     dumpColorProperty( 0x80000008 );
1422     dumpDecProperty< sal_uInt32 >( 0 );
1423     dumpBorderStyleProperty< sal_uInt8 >( 0 );
1424     dumpDecProperty< sal_uInt8 >( 0, "AX-MORPH-SCROLLBARS" );
1425     mnCtrlType = dumpDecProperty< sal_uInt8 >( 1, "AX-MORPH-CONTROLTYPE" );
1426     dumpMousePtrProperty();
1427     dumpSizeProperty();
1428     dumpUnicodeProperty();
1429     dumpDecProperty< sal_uInt32 >( 0, "CONV-HMM-TO-CM" );
1430     dumpDecProperty< sal_uInt16 >( 1, "AX-MORPH-BOUNDCOLUMN" );
1431     dumpDecProperty< sal_Int16 >( -1, "AX-MORPH-TEXTCOLUMN" );
1432     dumpDecProperty< sal_Int16 >( 1, "AX-MORPH-COLUMNCOUNT" );
1433     dumpDecProperty< sal_uInt16 >( 8 );
1434     mnColInfoCount = dumpDecProperty< sal_uInt16 >( 1 );
1435     dumpDecProperty< sal_uInt8 >( 2, "AX-MORPH-MATCHENTRYTYPE" );
1436     dumpDecProperty< sal_uInt8 >( 0, "AX-MORPH-LISTSTYLE" );
1437     dumpDecProperty< sal_uInt8 >( 0, "AX-MORPH-SHOWDROPDOWNMODE" );
1438     dumpUnknownProperty();
1439     dumpDecProperty< sal_uInt8 >( 1, "AX-MORPH-DROPDOWNSTYLE" );
1440     dumpDecProperty< sal_uInt8 >( 0, "AX-MORPH-SELECTIONTYPE" );
1441     dumpStringProperty();
1442     dumpStringProperty();
1443     dumpImagePosProperty();
1444     dumpColorProperty( 0x80000006 );
1445     dumpSpecialEffectProperty< sal_uInt32 >( 2 );
1446     dumpStreamProperty();
1447     dumpStreamProperty();
1448     dumpUnicodeProperty();
1449     dumpUnknownProperty();
1450     dumpBoolProperty();
1451     dumpStringProperty();
1452 }
1453 
implDumpExtended()1454 void AxMorphControlObject::implDumpExtended()
1455 {
1456     dumpEmbeddedFont();
1457     dumpColumnInfos();
1458 }
1459 
dumpColumnInfos()1460 void AxMorphControlObject::dumpColumnInfos()
1461 {
1462     if( ensureValid() && (mnColInfoCount > 0) && ((mnCtrlType == 2) || (mnCtrlType == 3)) )
1463     {
1464         mxOut->resetItemIndex();
1465         for( sal_uInt16 nIdx = 0; ensureValid() && (nIdx < mnColInfoCount); ++nIdx )
1466         {
1467             writeEmptyItem( "#column-info" );
1468             IndentGuard aIndGuard( mxOut );
1469             AxColumnInfoObject( *this ).dump();
1470         }
1471     }
1472 }
1473 
1474 // ============================================================================
1475 
AxLabelObject(const InputObjectBase & rParent)1476 AxLabelObject::AxLabelObject( const InputObjectBase& rParent )
1477 {
1478     AxPropertyObjectBase::construct( rParent, "AX-LABEL-PROPERTIES" );
1479 }
1480 
implDumpShortProperties()1481 void AxLabelObject::implDumpShortProperties()
1482 {
1483     dumpColorProperty( 0x80000012 );
1484     dumpColorProperty( 0x8000000F );
1485     dumpFlagsProperty( 0x0080001B );
1486     dumpStringProperty();
1487     dumpImagePosProperty();
1488     dumpSizeProperty();
1489     dumpMousePtrProperty();
1490     dumpColorProperty( 0x80000006 );
1491     dumpBorderStyleProperty< sal_uInt16 >( 0 );
1492     dumpSpecialEffectProperty< sal_uInt16 >( 0 );
1493     dumpStreamProperty();
1494     dumpUnicodeProperty();
1495     dumpStreamProperty();
1496 }
1497 
implDumpExtended()1498 void AxLabelObject::implDumpExtended()
1499 {
1500     dumpEmbeddedFont();
1501 }
1502 
1503 // ============================================================================
1504 
AxImageObject(const InputObjectBase & rParent)1505 AxImageObject::AxImageObject( const InputObjectBase& rParent )
1506 {
1507     AxPropertyObjectBase::construct( rParent, "AX-IMAGE-PROPERTIES" );
1508 }
1509 
implDumpShortProperties()1510 void AxImageObject::implDumpShortProperties()
1511 {
1512     dumpUnknownProperty();
1513     dumpUnknownProperty();
1514     dumpBoolProperty();
1515     dumpColorProperty( 0x80000006 );
1516     dumpColorProperty( 0x8000000F );
1517     dumpBorderStyleProperty< sal_uInt8 >( 1 );
1518     dumpMousePtrProperty();
1519     dumpImageSizeModeProperty();
1520     dumpSpecialEffectProperty< sal_uInt8 >( 0 );
1521     dumpSizeProperty();
1522     dumpStreamProperty();
1523     dumpImageAlignProperty();
1524     dumpBoolProperty();
1525     dumpFlagsProperty( 0x0000001B );
1526     dumpStreamProperty();
1527 }
1528 
1529 // ============================================================================
1530 
AxScrollBarObject(const InputObjectBase & rParent)1531 AxScrollBarObject::AxScrollBarObject( const InputObjectBase& rParent )
1532 {
1533     AxPropertyObjectBase::construct( rParent, "AX-SCROLLBAR-PROPERTIES" );
1534 }
1535 
implDumpShortProperties()1536 void AxScrollBarObject::implDumpShortProperties()
1537 {
1538     dumpColorProperty( 0x80000012 );
1539     dumpColorProperty( 0x8000000F );
1540     dumpFlagsProperty( 0x0000001B );
1541     dumpSizeProperty();
1542     dumpMousePtrProperty();
1543     dumpDecProperty< sal_Int32 >( 0 );
1544     dumpDecProperty< sal_Int32 >( 32767 );
1545     dumpDecProperty< sal_Int32 >( 0 );
1546     dumpHexProperty< sal_uInt32 >( 0 );
1547     dumpEnabledProperty();
1548     dumpEnabledProperty();
1549     dumpDecProperty< sal_Int32 >( 1 );
1550     dumpDecProperty< sal_Int32 >( 1 );
1551     dumpOrientationProperty();
1552     dumpDecProperty< sal_Int16 >( -1, "AX-SCROLLBAR-PROPTHUMB" );
1553     dumpDelayProperty();
1554     dumpStreamProperty();
1555 }
1556 
1557 // ============================================================================
1558 
AxSpinButtonObject(const InputObjectBase & rParent)1559 AxSpinButtonObject::AxSpinButtonObject( const InputObjectBase& rParent )
1560 {
1561     AxPropertyObjectBase::construct( rParent, "AX-SPINBUTTON-PROPERTIES" );
1562 }
1563 
implDumpShortProperties()1564 void AxSpinButtonObject::implDumpShortProperties()
1565 {
1566     dumpColorProperty( 0x80000012 );
1567     dumpColorProperty( 0x8000000F );
1568     dumpFlagsProperty( 0x0000001B );
1569     dumpSizeProperty();
1570     dumpHexProperty< sal_uInt32 >( 0 );
1571     dumpDecProperty< sal_Int32 >( 0 );
1572     dumpDecProperty< sal_Int32 >( 100 );
1573     dumpDecProperty< sal_Int32 >( 0 );
1574     dumpEnabledProperty();
1575     dumpEnabledProperty();
1576     dumpDecProperty< sal_Int32 >( 1 );
1577     dumpOrientationProperty();
1578     dumpDelayProperty();
1579     dumpStreamProperty();
1580     dumpMousePtrProperty();
1581 }
1582 
1583 // ============================================================================
1584 
AxTabStripObject(const InputObjectBase & rParent)1585 AxTabStripObject::AxTabStripObject( const InputObjectBase& rParent )
1586 {
1587     AxPropertyObjectBase::construct( rParent, "AX-TABSTRIP-PROPERTIES" );
1588 }
1589 
implDumpShortProperties()1590 void AxTabStripObject::implDumpShortProperties()
1591 {
1592     dumpDecProperty< sal_Int32 >( -1 );
1593     dumpColorProperty( 0x8000000F );
1594     dumpColorProperty( 0x80000012 );
1595     dumpUnknownProperty();
1596     dumpSizeProperty();
1597     dumpStringArrayProperty();
1598     dumpMousePtrProperty();
1599     dumpUnknownProperty();
1600     dumpDecProperty< sal_uInt32 >( 0, "AX-TABSTRIP-ORIENTATION" );
1601     dumpDecProperty< sal_uInt32 >( 0, "AX-TABSTRIP-TABSTYLE" );
1602     dumpBoolProperty();
1603     dumpHmmProperty();
1604     dumpHmmProperty();
1605     dumpBoolProperty();
1606     dumpUnknownProperty();
1607     dumpStringArrayProperty();
1608     dumpUnknownProperty();
1609     dumpStringArrayProperty();
1610     dumpFlagsProperty( 0x0000001B );
1611     dumpBoolProperty();
1612     dumpDecProperty< sal_uInt32 >( 0 );
1613     dumpStringArrayProperty();
1614     mnTabFlagCount = dumpDecProperty< sal_Int32 >( 0 );
1615     dumpStringArrayProperty();
1616     dumpStreamProperty();
1617 }
1618 
implDumpExtended()1619 void AxTabStripObject::implDumpExtended()
1620 {
1621     dumpEmbeddedFont();
1622     if( mnTabFlagCount > 0 )
1623     {
1624         writeEmptyItem( "tab-flags" );
1625         IndentGuard aIndGuard( mxOut );
1626         mxOut->resetItemIndex();
1627         for( sal_Int32 nIdx = 0; ensureValid() && (nIdx < mnTabFlagCount); ++nIdx )
1628             dumpHex< sal_uInt32 >( "#flags", "AX-TABSTRIP-FLAGS" );
1629     }
1630 }
1631 
1632 // ============================================================================
1633 // ============================================================================
1634 
FormControlStreamObject(const ObjectBase & rParent,const BinaryInputStreamRef & rxStrm,const OUString & rSysFileName,const OUString * pProgId)1635 FormControlStreamObject::FormControlStreamObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName, const OUString* pProgId )
1636 {
1637     construct( rParent, rxStrm, rSysFileName );
1638     constructFormCtrlStrmObj( pProgId );
1639 }
1640 
FormControlStreamObject(const OutputObjectBase & rParent,const BinaryInputStreamRef & rxStrm,const OUString * pProgId)1641 FormControlStreamObject::FormControlStreamObject( const OutputObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString* pProgId )
1642 {
1643     construct( rParent, rxStrm );
1644     constructFormCtrlStrmObj( pProgId );
1645 }
1646 
implDump()1647 void FormControlStreamObject::implDump()
1648 {
1649     if( mbReadGuid )
1650         maProgId = cfg().getStringOption( dumpGuid(), OUString() );
1651 
1652     if( (maProgId.getLength() > 0) && !mxStrm->isEof() )
1653     {
1654         if( maProgId.equalsAscii( "Forms.CommandButton.1" ) )
1655             AxCommandButtonObject( *this ).dump();
1656         else if( maProgId.equalsAscii( "Forms.TextBox.1" ) ||
1657                  maProgId.equalsAscii( "Forms.ListBox.1" ) ||
1658                  maProgId.equalsAscii( "Forms.ComboBox.1" ) ||
1659                  maProgId.equalsAscii( "Forms.CheckBox.1" ) ||
1660                  maProgId.equalsAscii( "Forms.OptionButton.1" ) ||
1661                  maProgId.equalsAscii( "Forms.ToggleButton.1" ) ||
1662                  maProgId.equalsAscii( "RefEdit.Ctrl" ) )
1663             AxMorphControlObject( *this ).dump();
1664         else if( maProgId.equalsAscii( "Forms.Label.1" ) )
1665             AxLabelObject( *this ).dump();
1666         else if( maProgId.equalsAscii( "Forms.Image.1" ) )
1667             AxImageObject( *this ).dump();
1668         else if( maProgId.equalsAscii( "Forms.ScrollBar.1" ) )
1669             AxScrollBarObject( *this ).dump();
1670         else if( maProgId.equalsAscii( "Forms.SpinButton.1" ) )
1671             AxSpinButtonObject( *this ).dump();
1672         else if( maProgId.equalsAscii( "Forms.TabStrip.1" ) )
1673             AxTabStripObject( *this ).dump();
1674         else if( maProgId.equalsAscii( "MSComCtl2.FlatScrollBar.2" ) )
1675             ComCtlScrollBarObject( *this, 6 ).dump();
1676         else if( maProgId.equalsAscii( "COMCTL.ProgCtrl.1" ) )
1677             ComCtlProgressBarObject( *this, 5 ).dump();
1678         else if( maProgId.equalsAscii( "MSComctlLib.ProgCtrl.2" ) )
1679             ComCtlProgressBarObject( *this, 6 ).dump();
1680         else if( maProgId.equalsAscii( "COMCTL.Slider.1" ) )
1681             ComCtlSliderObject( *this, 5 ).dump();
1682         else if( maProgId.equalsAscii( "MSComctlLib.Slider.2" ) )
1683             ComCtlSliderObject( *this, 6 ).dump();
1684         else if( maProgId.equalsAscii( "ComCtl2.UpDown.1" ) )
1685             ComCtlUpDownObject( *this, 5 ).dump();
1686         else if( maProgId.equalsAscii( "MSComCtl2.UpDown.2" ) )
1687             ComCtlUpDownObject( *this, 6 ).dump();
1688         else if( maProgId.equalsAscii( "COMCTL.ImageListCtrl.1" ) )
1689             ComCtlImageListObject( *this, 5 ).dump();
1690         else if( maProgId.equalsAscii( "MSComctlLib.ImageListCtrl.2" ) )
1691             ComCtlImageListObject( *this, 6 ).dump();
1692         else if( maProgId.equalsAscii( "COMCTL.TabStrip.1" ) )
1693             ComCtlTabStripObject( *this, 5 ).dump();
1694         else if( maProgId.equalsAscii( "MSComctlLib.TabStrip.2" ) )
1695             ComCtlTabStripObject( *this, 6 ).dump();
1696         else if( maProgId.equalsAscii( "COMCTL.TreeCtrl.1" ) )
1697             ComCtlTreeViewObject( *this, 5 ).dump();
1698         else if( maProgId.equalsAscii( "MSComctlLib.TreeCtrl.2" ) )
1699             ComCtlTreeViewObject( *this, 6 ).dump();
1700         else if( maProgId.equalsAscii( "COMCTL.SBarCtrl.1" ) )
1701             ComCtlStatusBarObject( *this, 5 ).dump();
1702         else if( maProgId.equalsAscii( "StdPic" ) )
1703             StdPicObject( *this ).dump();
1704     }
1705     dumpRemainingStream();
1706 }
1707 
constructFormCtrlStrmObj(const OUString * pProgId)1708 void FormControlStreamObject::constructFormCtrlStrmObj( const OUString* pProgId )
1709 {
1710     mbReadGuid = pProgId == 0;
1711     if( pProgId )
1712         maProgId = *pProgId;
1713 }
1714 
1715 // ============================================================================
1716 // ============================================================================
1717 
VbaFormClassInfoObject(const InputObjectBase & rParent,VbaFormSharedData & rFormData)1718 VbaFormClassInfoObject::VbaFormClassInfoObject( const InputObjectBase& rParent, VbaFormSharedData& rFormData ) :
1719     mrFormData( rFormData )
1720 {
1721     AxPropertyObjectBase::construct( rParent, "VBA-CLASSINFO-PROPERTIES" );
1722 }
1723 
implDumpShortProperties()1724 void VbaFormClassInfoObject::implDumpShortProperties()
1725 {
1726     mrFormData.maClassInfoProgIds.push_back( OUString() );
1727     dumpGuidProperty( &mrFormData.maClassInfoProgIds.back() );
1728     dumpGuidProperty();
1729     dumpUnknownProperty();
1730     dumpGuidProperty();
1731     dumpFlagsProperty( 0, "VBA-CLASSINFO-FLAGS" );
1732     dumpDecProperty< sal_uInt32 >( 0 );
1733     dumpDecProperty< sal_Int32 >( -1 );
1734     dumpDecProperty< sal_uInt16 >( 0 );
1735     dumpDecProperty< sal_uInt16 >( 0 );
1736     dumpDecProperty< sal_uInt16 >( 0, "OLEPROP-TYPE" );
1737     dumpDecProperty< sal_uInt16 >( 0 );
1738     dumpDecProperty< sal_uInt16 >( 0 );
1739     dumpDecProperty< sal_uInt16 >( 0, "OLEPROP-TYPE" );
1740     dumpDecProperty< sal_Int32 >( -1 );
1741     dumpDecProperty< sal_uInt16 >( 0 );
1742 }
1743 
1744 // ============================================================================
1745 
1746 namespace {
1747 
1748 const sal_uInt32 VBA_FORMSITE_OBJSTREAM         = 0x0010;
1749 
1750 const sal_uInt16 VBA_FORMSITE_CLASSTABLEINDEX   = 0x8000;
1751 const sal_uInt16 VBA_FORMSITE_CLASSTABLEMASK    = 0x7FFF;
1752 
1753 } // namespace
1754 
1755 // ----------------------------------------------------------------------------
1756 
VbaFormSiteObject(const InputObjectBase & rParent,VbaFormSharedData & rFormData)1757 VbaFormSiteObject::VbaFormSiteObject( const InputObjectBase& rParent, VbaFormSharedData& rFormData ) :
1758     mrFormData( rFormData )
1759 {
1760     AxPropertyObjectBase::construct( rParent, "VBA-FORMSITE-PROPERTIES" );
1761 }
1762 
implDumpShortProperties()1763 void VbaFormSiteObject::implDumpShortProperties()
1764 {
1765     VbaFormSiteInfo aSiteInfo;
1766     dumpStringProperty();
1767     dumpStringProperty();
1768     sal_Int32 nId = dumpDecProperty< sal_Int32 >( 0 );
1769     dumpDecProperty< sal_Int32 >( 0 );
1770     sal_uInt32 nFlags = dumpFlagsProperty( 0x00000033, "VBA-FORMSITE-FLAGS" );
1771     sal_uInt32 nLength = dumpDecProperty< sal_uInt32 >( 0 );
1772     dumpDecProperty< sal_Int16 >( -1 );
1773     sal_uInt16 nClassId = dumpHexProperty< sal_uInt16 >( 0x7FFF, "VBA-FORMSITE-CLASSIDCACHE" );
1774     dumpPosProperty();
1775     dumpDecProperty< sal_uInt16 >( 0 );
1776     dumpUnknownProperty();
1777     dumpStringProperty();
1778     dumpStringProperty();
1779     dumpStringProperty();
1780     dumpStringProperty();
1781 
1782     sal_uInt16 nIndex = nClassId & VBA_FORMSITE_CLASSTABLEMASK;
1783     if( getFlag( nClassId, VBA_FORMSITE_CLASSTABLEINDEX ) )
1784     {
1785         if( nIndex < mrFormData.maClassInfoProgIds.size() )
1786             aSiteInfo.maProgId = mrFormData.maClassInfoProgIds[ nIndex ];
1787     }
1788     else
1789     {
1790         if( cfg().hasName( "VBA-FORMSITE-CLASSNAMES", nIndex ) )
1791             aSiteInfo.maProgId = cfg().getName( "VBA-FORMSITE-CLASSNAMES", nIndex );
1792     }
1793     aSiteInfo.mnId = nId;
1794     aSiteInfo.mnLength = nLength;
1795     aSiteInfo.mbInStream = getFlag( nFlags, VBA_FORMSITE_OBJSTREAM );
1796 
1797     mrFormData.maSiteInfos.push_back( aSiteInfo );
1798 }
1799 
1800 // ============================================================================
1801 
VbaFormDesignExtObject(const InputObjectBase & rParent)1802 VbaFormDesignExtObject::VbaFormDesignExtObject( const InputObjectBase& rParent )
1803 {
1804     AxPropertyObjectBase::construct( rParent, "VBA-FORMDESIGNEXT-PROPERTIES" );
1805 }
1806 
implDumpShortProperties()1807 void VbaFormDesignExtObject::implDumpShortProperties()
1808 {
1809     dumpFlagsProperty( 0x00015F55, "VBA-FORMDESIGNEXT-FLAGS" );
1810     dumpHmmProperty();
1811     dumpHmmProperty();
1812     dumpDecProperty< sal_Int8 >( 0, "VBA-FORMDESIGNEXT-CLICKCTRLMODE" );
1813     dumpDecProperty< sal_Int8 >( 0, "VBA-FORMDESIGNEXT-DBLCLICKCTRLMODE" );
1814 }
1815 
1816 // ============================================================================
1817 
1818 namespace {
1819 
1820 const sal_uInt32 AX_FORM_HASDESIGNEXTENDER      = 0x00004000;
1821 const sal_uInt32 AX_FORM_SKIPCLASSTABLE         = 0x00008000;
1822 
1823 const sal_uInt8 AX_FORM_SITECOUNTTYPE_COUNT     = 0x80;
1824 const sal_uInt8 AX_FORM_SITECOUNTTYPE_MASK      = 0x7F;
1825 
1826 } // namespace
1827 
1828 // ----------------------------------------------------------------------------
1829 
VbaFStreamObject(const ObjectBase & rParent,const BinaryInputStreamRef & rxStrm,const OUString & rSysFileName,VbaFormSharedData & rFormData)1830 VbaFStreamObject::VbaFStreamObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName, VbaFormSharedData& rFormData ) :
1831     mrFormData( rFormData )
1832 {
1833     AxPropertyObjectBase::construct( rParent, rxStrm, rSysFileName, "VBA-FORM-PROPERTIES" );
1834 }
1835 
implDumpShortProperties()1836 void VbaFStreamObject::implDumpShortProperties()
1837 {
1838     dumpUnknownProperty();
1839     dumpColorProperty( 0x8000000F );
1840     dumpColorProperty( 0x80000012 );
1841     dumpDecProperty< sal_uInt32 >( 0 );
1842     dumpUnknownProperty();
1843     dumpUnknownProperty();
1844     mnFlags = dumpFlagsProperty( 0x00000004, "VBA-FORM-FLAGS" );
1845     dumpBorderStyleProperty< sal_uInt8 >( 0 );
1846     dumpMousePtrProperty();
1847     dumpHexProperty< sal_uInt8 >( 0x0C, "VBA-FORM-SCROLLBARS" );
1848     dumpSizeProperty();
1849     dumpSizeProperty();
1850     dumpPosProperty();
1851     dumpDecProperty< sal_uInt32 >( 0 );
1852     dumpUnknownProperty();
1853     dumpStreamProperty();
1854     dumpDecProperty< sal_uInt8 >( 0, "VBA-FORM-CYCLE" );
1855     dumpSpecialEffectProperty< sal_uInt8 >( 0 );
1856     dumpColorProperty( 0x80000012 );
1857     dumpStringProperty();
1858     dumpStreamProperty();
1859     dumpStreamProperty();
1860     dumpDecProperty< sal_Int32 >( 100, "CONV-PERCENT" );
1861     dumpImageAlignProperty();
1862     dumpBoolProperty();
1863     dumpImageSizeModeProperty();
1864     dumpDecProperty< sal_uInt32 >( 0 );
1865     dumpDecProperty< sal_uInt32 >( 0 );
1866 }
1867 
implDumpExtended()1868 void VbaFStreamObject::implDumpExtended()
1869 {
1870     dumpClassInfos();
1871     dumpSiteData();
1872     dumpDesignExtender();
1873     dumpRemainingStream();
1874 }
1875 
dumpClassInfos()1876 void VbaFStreamObject::dumpClassInfos()
1877 {
1878     if( ensureValid() && !getFlag( mnFlags, AX_FORM_SKIPCLASSTABLE ) )
1879     {
1880         mxOut->emptyLine();
1881         sal_uInt16 nCount = dumpDec< sal_uInt16 >( "class-info-count" );
1882         mxOut->resetItemIndex();
1883         for( sal_uInt16 nIdx = 0; ensureValid() && (nIdx < nCount); ++nIdx )
1884         {
1885             writeEmptyItem( "#class-info" );
1886             IndentGuard aIndGuard( mxOut );
1887             VbaFormClassInfoObject( *this, mrFormData ).dump();
1888         }
1889     }
1890 }
1891 
dumpFormSites(sal_uInt32 nCount)1892 void VbaFStreamObject::dumpFormSites( sal_uInt32 nCount )
1893 {
1894     mxOut->resetItemIndex();
1895     for( sal_uInt32 nIdx = 0; ensureValid() && (nIdx < nCount); ++nIdx )
1896     {
1897         mxOut->emptyLine();
1898         writeEmptyItem( "#form-site" );
1899         IndentGuard aIndGuard( mxOut );
1900         VbaFormSiteObject( *this, mrFormData ).dump();
1901     }
1902 }
1903 
dumpSiteData()1904 void VbaFStreamObject::dumpSiteData()
1905 {
1906     if( ensureValid() )
1907     {
1908         mxOut->emptyLine();
1909         setAlignAnchor();
1910         sal_uInt32 nSiteCount = dumpDec< sal_uInt32 >( "site-count" );
1911         sal_uInt32 nSiteLength = dumpDec< sal_uInt32 >( "site-data-size" );
1912         sal_Int64 nEndPos = mxStrm->tell() + nSiteLength;
1913         if( ensureValid( nEndPos <= mxStrm->size() ) )
1914         {
1915             mxOut->resetItemIndex();
1916             sal_uInt32 nSiteIdx = 0;
1917             while( ensureValid() && (nSiteIdx < nSiteCount) )
1918             {
1919                 mxOut->emptyLine();
1920                 writeEmptyItem( "#site-info" );
1921                 IndentGuard aIndGuard( mxOut );
1922                 dumpDec< sal_uInt8 >( "depth" );
1923                 sal_uInt8 nTypeCount = dumpHex< sal_uInt8 >( "type-count", "VBA-FORM-SITE-TYPECOUNT" );
1924                 if( getFlag( nTypeCount, AX_FORM_SITECOUNTTYPE_COUNT ) )
1925                 {
1926                     dumpDec< sal_uInt8 >( "repeated-type" );
1927                     nSiteIdx += (nTypeCount & AX_FORM_SITECOUNTTYPE_MASK);
1928                 }
1929                 else
1930                 {
1931                     ++nSiteIdx;
1932                 }
1933             }
1934             alignInput< sal_uInt32 >();
1935             dumpFormSites( nSiteCount );
1936             dumpToPosition( nEndPos );
1937         }
1938     }
1939 }
1940 
dumpDesignExtender()1941 void VbaFStreamObject::dumpDesignExtender()
1942 {
1943     if( ensureValid() && getFlag( mnFlags, AX_FORM_HASDESIGNEXTENDER ) )
1944     {
1945         mxOut->emptyLine();
1946         writeEmptyItem( "design-extender" );
1947         IndentGuard aIndGuard( mxOut );
1948         VbaFormDesignExtObject( *this ).dump();
1949     }
1950 }
1951 
1952 // ============================================================================
1953 
VbaOStreamObject(const ObjectBase & rParent,const BinaryInputStreamRef & rxStrm,const OUString & rSysFileName,VbaFormSharedData & rFormData)1954 VbaOStreamObject::VbaOStreamObject( const ObjectBase& rParent,
1955         const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName, VbaFormSharedData& rFormData ) :
1956     mrFormData( rFormData )
1957 {
1958     OleInputObjectBase::construct( rParent, rxStrm, rSysFileName );
1959 }
1960 
implDump()1961 void VbaOStreamObject::implDump()
1962 {
1963     for( VbaFormSiteInfoVector::iterator aIt = mrFormData.maSiteInfos.begin(), aEnd = mrFormData.maSiteInfos.end(); !mxStrm->isEof() && (aIt != aEnd); ++aIt )
1964     {
1965         if( (aIt->mbInStream) && (aIt->mnLength > 0) )
1966         {
1967             mxOut->emptyLine();
1968             writeDecItem( "control-id", aIt->mnId );
1969             writeInfoItem( "prog-id", aIt->maProgId );
1970             IndentGuard aIndGuard( mxOut );
1971             BinaryInputStreamRef xRelStrm( new RelativeInputStream( *mxStrm, aIt->mnLength ) );
1972             FormControlStreamObject( *this, xRelStrm, &aIt->maProgId ).dump();
1973         }
1974     }
1975     dumpRemainingStream();
1976 }
1977 
1978 // ============================================================================
1979 
VbaPageObject(const InputObjectBase & rParent)1980 VbaPageObject::VbaPageObject( const InputObjectBase& rParent )
1981 {
1982     AxPropertyObjectBase::construct( rParent, "VBA-PAGE-PROPERTIES" );
1983 }
1984 
implDumpShortProperties()1985 void VbaPageObject::implDumpShortProperties()
1986 {
1987     dumpUnknownProperty();
1988     dumpDecProperty< sal_uInt32 >( 0, "VBA-PAGE-TRANSITIONEFFECT" );
1989     dumpDecProperty< sal_uInt32 >( 0, "AX-CONV-MS" );
1990 }
1991 
1992 // ============================================================================
1993 
VbaMultiPageObject(const InputObjectBase & rParent)1994 VbaMultiPageObject::VbaMultiPageObject( const InputObjectBase& rParent )
1995 {
1996     AxPropertyObjectBase::construct( rParent, "VBA-MULTIPAGE-PROPERTIES" );
1997 }
1998 
implDumpShortProperties()1999 void VbaMultiPageObject::implDumpShortProperties()
2000 {
2001     dumpUnknownProperty();
2002     mnPageCount = dumpDecProperty< sal_Int32 >( 0 );
2003     dumpDecProperty< sal_Int32 >( 0 );
2004     dumpBoolProperty();
2005 }
2006 
implDumpExtended()2007 void VbaMultiPageObject::implDumpExtended()
2008 {
2009     if( ensureValid() && (mnPageCount > 0) )
2010     {
2011         writeEmptyItem( "page-ids" );
2012         IndentGuard aIndGuard( mxOut );
2013         mxOut->resetItemIndex();
2014         for( sal_Int32 nIdx = 0; ensureValid() && (nIdx < mnPageCount); ++nIdx )
2015             dumpDec< sal_Int32 >( "#id" );
2016     }
2017 }
2018 
2019 // ============================================================================
2020 
VbaXStreamObject(const ObjectBase & rParent,const BinaryInputStreamRef & rxStrm,const OUString & rSysFileName,VbaFormSharedData & rFormData)2021 VbaXStreamObject::VbaXStreamObject( const ObjectBase& rParent,
2022         const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName, VbaFormSharedData& rFormData ) :
2023     mrFormData( rFormData )
2024 {
2025     InputObjectBase::construct( rParent, rxStrm,  rSysFileName );
2026 }
2027 
implDump()2028 void VbaXStreamObject::implDump()
2029 {
2030     for( size_t nIdx = 0, nCount = mrFormData.maSiteInfos.size(); !mxStrm->isEof() && (nIdx < nCount); ++nIdx )
2031     {
2032         mxOut->emptyLine();
2033         writeEmptyItem( "page" );
2034         IndentGuard aIndGuard( mxOut );
2035         VbaPageObject( *this ).dump();
2036     }
2037     if( !mxStrm->isEof() )
2038     {
2039         mxOut->emptyLine();
2040         writeEmptyItem( "multi-page" );
2041         IndentGuard aIndGuard( mxOut );
2042         VbaMultiPageObject( *this ).dump();
2043     }
2044     dumpRemainingStream();
2045 }
2046 
2047 // ============================================================================
2048 
VbaContainerStorageObject(const ObjectBase & rParent,const StorageRef & rxStrg,const OUString & rSysPath)2049 VbaContainerStorageObject::VbaContainerStorageObject( const ObjectBase& rParent, const StorageRef& rxStrg, const OUString& rSysPath ) :
2050     OleStorageObject( rParent, rxStrg, rSysPath )
2051 {
2052     addPreferredStream( "f" );
2053 }
2054 
implDumpStream(const Reference<XInputStream> & rxStrm,const OUString & rStrgPath,const OUString & rStrmName,const OUString & rSysFileName)2055 void VbaContainerStorageObject::implDumpStream( const Reference< XInputStream >& rxStrm, const OUString& rStrgPath, const OUString& rStrmName, const OUString& rSysFileName )
2056 {
2057     if( rStrmName.equalsAscii( "f" ) )
2058         VbaFStreamObject( *this, rxStrm, rSysFileName, maFormData ).dump();
2059     else if( rStrmName.equalsAscii( "o" ) )
2060         VbaOStreamObject( *this, rxStrm, rSysFileName, maFormData ).dump();
2061     else if( rStrmName.equalsAscii( "x" ) )
2062         VbaXStreamObject( *this, rxStrm, rSysFileName, maFormData ).dump();
2063     else
2064         OleStorageObject::implDumpStream( rxStrm, rStrgPath, rStrmName, rSysFileName );
2065 }
2066 
implDumpStorage(const StorageRef & rxStrg,const OUString & rStrgPath,const OUString & rSysPath)2067 void VbaContainerStorageObject::implDumpStorage( const StorageRef& rxStrg, const OUString& rStrgPath, const OUString& rSysPath )
2068 {
2069     if( isFormStorage( rStrgPath ) )
2070         VbaContainerStorageObject( *this, rxStrg, rSysPath ).dump();
2071     else
2072         OleStorageObject( *this, rxStrg, rSysPath ).dump();
2073 }
2074 
isFormStorage(const OUString & rStrgPath) const2075 bool VbaContainerStorageObject::isFormStorage( const OUString& rStrgPath ) const
2076 {
2077     if( (rStrgPath.getLength() >= 3) && (rStrgPath[ 0 ] == 'i') )
2078     {
2079         OUString aId = rStrgPath.copy( 1 );
2080         if( (aId.getLength() == 2) && (aId[ 0 ] == '0') )
2081             aId = aId.copy( 1 );
2082         sal_Int32 nId = aId.toInt32();
2083         if( (nId > 0) && (OUString::valueOf( nId ) == aId) )
2084             for( VbaFormSiteInfoVector::const_iterator aIt = maFormData.maSiteInfos.begin(), aEnd = maFormData.maSiteInfos.end(); aIt != aEnd; ++aIt )
2085                 if( aIt->mnId == nId )
2086                     return true;
2087     }
2088     return false;
2089 }
2090 
2091 // ============================================================================
2092 // ============================================================================
2093 
VbaSharedData()2094 VbaSharedData::VbaSharedData() :
2095     meTextEnc( RTL_TEXTENCODING_MS_1252 )
2096 {
2097 }
2098 
isModuleStream(const::rtl::OUString & rStrmName) const2099 bool VbaSharedData::isModuleStream( const ::rtl::OUString& rStrmName ) const
2100 {
2101     return maStrmOffsets.count( rStrmName ) > 0;
2102 }
2103 
getStreamOffset(const OUString & rStrmName) const2104 sal_Int32 VbaSharedData::getStreamOffset( const OUString& rStrmName ) const
2105 {
2106     StreamOffsetMap::const_iterator aIt = maStrmOffsets.find( rStrmName );
2107     return (aIt == maStrmOffsets.end()) ? 0 : aIt->second;
2108 }
2109 
2110 // ============================================================================
2111 
VbaDirStreamObject(const ObjectBase & rParent,const BinaryInputStreamRef & rxStrm,const OUString & rSysFileName,VbaSharedData & rVbaData)2112 VbaDirStreamObject::VbaDirStreamObject( const ObjectBase& rParent,
2113         const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName, VbaSharedData& rVbaData ) :
2114     mrVbaData( rVbaData )
2115 {
2116     mxInStrm = rxStrm;
2117     if( mxInStrm.get() )
2118     {
2119         BinaryInputStreamRef xVbaStrm( new ::oox::ole::VbaInputStream( *mxInStrm ) );
2120         SequenceRecordObjectBase::construct( rParent, xVbaStrm, rSysFileName, "VBA-DIR-RECORD-NAMES", "VBA-DIR-SIMPLE-RECORDS" );
2121     }
2122 }
2123 
implIsValid() const2124 bool VbaDirStreamObject::implIsValid() const
2125 {
2126     return mxInStrm.get() && SequenceRecordObjectBase::implIsValid();
2127 }
2128 
implReadRecordHeader(BinaryInputStream & rBaseStrm,sal_Int64 & ornRecId,sal_Int64 & ornRecSize)2129 bool VbaDirStreamObject::implReadRecordHeader( BinaryInputStream& rBaseStrm, sal_Int64& ornRecId, sal_Int64& ornRecSize )
2130 {
2131     ornRecId = rBaseStrm.readuInt16();
2132     ornRecSize = rBaseStrm.readInt32();
2133 
2134     // for no obvious reason, PROJECTVERSION record contains size field of 4, but is 6 bytes long
2135     if( ornRecId == 9 )
2136         ornRecSize = 6;
2137 
2138     return !rBaseStrm.isEof();
2139 }
2140 
implDumpRecordBody()2141 void VbaDirStreamObject::implDumpRecordBody()
2142 {
2143     switch( getRecId() )
2144     {
2145         case 0x0003:
2146             mrVbaData.meTextEnc = rtl_getTextEncodingFromWindowsCodePage( dumpDec< sal_uInt16 >( "codepage", "CODEPAGES" ) );
2147         break;
2148         case 0x0004:
2149             dumpByteString( "name" );
2150         break;
2151         case 0x0005:
2152             dumpByteString( "description" );
2153         break;
2154         case 0x0006:
2155             dumpByteString( "helpfile-path" );
2156         break;
2157         case 0x0009:
2158             dumpDec< sal_uInt32 >( "major" );
2159             dumpDec< sal_uInt16 >( "minor" );
2160         break;
2161         case 0x000C:
2162             dumpByteString( "constants" );
2163         break;
2164         case 0x000D:
2165             dumpByteStringWithLength( "lib-id" );
2166             dumpUnused( 6 );
2167         break;
2168         case 0x000E:
2169             dumpByteStringWithLength( "lib-id-absolute" );
2170             dumpByteStringWithLength( "lib-id-relative" );
2171             dumpDec< sal_uInt32 >( "major" );
2172             dumpDec< sal_uInt16 >( "minor" );
2173         break;
2174         case 0x0016:
2175             dumpByteString( "name" );
2176         break;
2177         case 0x0019:
2178             dumpByteString( "name" );
2179             maCurrStream = OUString();
2180             mnCurrOffset = 0;
2181         break;
2182         case 0x001A:
2183             maCurrStream = dumpByteString( "stream-name" );
2184         break;
2185         case 0x001C:
2186             dumpByteString( "description" );
2187         break;
2188         case 0x002B:
2189             if( maCurrStream.getLength() > 0 )
2190                 mrVbaData.maStrmOffsets[ maCurrStream ] = mnCurrOffset;
2191             maCurrStream = OUString();
2192             mnCurrOffset = 0;
2193         break;
2194         case 0x002F:
2195             dumpByteStringWithLength( "lib-id-twiddled" );
2196             dumpUnused( 6 );
2197         break;
2198         case 0x0030:
2199             dumpByteStringWithLength( "lib-id-extended" );
2200             dumpUnused( 6 );
2201             dumpGuid( "original-typelib" );
2202             dumpDec< sal_uInt32 >( "cookie" );
2203         break;
2204         case 0x0031:
2205             mnCurrOffset = dumpHex< sal_Int32 >( "stream-offset", "CONV-DEC" );
2206         break;
2207         case 0x0032:
2208             dumpUniString( "stream-name" );
2209         break;
2210         case 0x0033:
2211             dumpByteString( "lib-id-original" );
2212         break;
2213         case 0x003C:
2214             dumpUniString( "constants" );
2215         break;
2216         case 0x003D:
2217             dumpByteString( "helpfile-path" );
2218         break;
2219         case 0x003E:
2220             dumpUniString( "name" );
2221         break;
2222         case 0x0040:
2223             dumpUniString( "description" );
2224         break;
2225         case 0x0047:
2226             dumpUniString( "name" );
2227         break;
2228         case 0x0048:
2229             dumpUniString( "description" );
2230         break;
2231     }
2232 }
2233 
dumpByteString(const String & rName)2234 OUString VbaDirStreamObject::dumpByteString( const String& rName )
2235 {
2236     return dumpCharArray( rName, static_cast< sal_Int32 >( getRecSize() ), mrVbaData.meTextEnc );
2237 }
2238 
dumpUniString(const String & rName)2239 OUString VbaDirStreamObject::dumpUniString( const String& rName )
2240 {
2241     return dumpUnicodeArray( rName, static_cast< sal_Int32 >( getRecSize() / 2 ) );
2242 }
2243 
dumpByteStringWithLength(const String & rName)2244 OUString VbaDirStreamObject::dumpByteStringWithLength( const String& rName )
2245 {
2246     return dumpCharArray( rName, mxStrm->readInt32(), mrVbaData.meTextEnc );
2247 }
2248 
2249 // ============================================================================
2250 
VbaModuleStreamObject(const ObjectBase & rParent,const BinaryInputStreamRef & rxStrm,const OUString & rSysFileName,VbaSharedData & rVbaData,sal_Int32 nStrmOffset)2251 VbaModuleStreamObject::VbaModuleStreamObject(
2252         const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm,
2253         const OUString& rSysFileName, VbaSharedData& rVbaData, sal_Int32 nStrmOffset ) :
2254     mrVbaData( rVbaData ),
2255     mnStrmOffset( nStrmOffset )
2256 {
2257     InputObjectBase::construct( rParent, rxStrm, rSysFileName );
2258 }
2259 
implDump()2260 void VbaModuleStreamObject::implDump()
2261 {
2262     dumpBinary( "perf-cache", mnStrmOffset );
2263     mxOut->emptyLine();
2264     writeEmptyItem( "source-code" );
2265     IndentGuard aIndGuard( mxOut );
2266     BinaryInputStreamRef xVbaStrm( new ::oox::ole::VbaInputStream( *mxStrm ) );
2267     TextLineStreamObject( *this, xVbaStrm, mrVbaData.meTextEnc ).dump();
2268 }
2269 
2270 // ============================================================================
2271 
VbaStorageObject(const ObjectBase & rParent,const StorageRef & rxStrg,const OUString & rSysPath,VbaSharedData & rVbaData)2272 VbaStorageObject::VbaStorageObject( const ObjectBase& rParent, const StorageRef& rxStrg, const OUString& rSysPath, VbaSharedData& rVbaData ) :
2273     OleStorageObject( rParent, rxStrg, rSysPath ),
2274     mrVbaData( rVbaData )
2275 {
2276     addPreferredStream( "dir" );
2277 }
2278 
implDumpStream(const Reference<XInputStream> & rxStrm,const OUString & rStrgPath,const OUString & rStrmName,const OUString & rSysFileName)2279 void VbaStorageObject::implDumpStream( const Reference< XInputStream >& rxStrm, const OUString& rStrgPath, const OUString& rStrmName, const OUString& rSysFileName )
2280 {
2281     if( (rStrgPath.getLength() == 0) && rStrmName.equalsAscii( "dir" ) )
2282         VbaDirStreamObject( *this, rxStrm, rSysFileName, mrVbaData ).dump();
2283     else if( mrVbaData.isModuleStream( rStrmName ) )
2284         VbaModuleStreamObject( *this, rxStrm, rSysFileName, mrVbaData, mrVbaData.getStreamOffset( rStrmName ) ).dump();
2285     else
2286         OleStorageObject::implDumpStream( rxStrm, rStrgPath, rStrmName, rSysFileName );
2287 }
2288 
2289 // ============================================================================
2290 
VbaFormStorageObject(const ObjectBase & rParent,const StorageRef & rxStrg,const OUString & rSysPath,VbaSharedData & rVbaData)2291 VbaFormStorageObject::VbaFormStorageObject( const ObjectBase& rParent, const StorageRef& rxStrg, const OUString& rSysPath, VbaSharedData& rVbaData ) :
2292     VbaContainerStorageObject( rParent, rxStrg, rSysPath ),
2293     mrVbaData( rVbaData )
2294 {
2295 }
2296 
implDumpStream(const Reference<XInputStream> & rxStrm,const OUString & rStrgPath,const OUString & rStrmName,const OUString & rSysFileName)2297 void VbaFormStorageObject::implDumpStream( const Reference< XInputStream >& rxStrm, const OUString& rStrgPath, const OUString& rStrmName, const OUString& rSysFileName )
2298 {
2299     if( rStrmName.equalsAscii( "\003VBFrame" ) )
2300         TextLineStreamObject( *this, rxStrm, mrVbaData.meTextEnc, rSysFileName ).dump();
2301     else
2302         VbaContainerStorageObject::implDumpStream( rxStrm, rStrgPath, rStrmName, rSysFileName );
2303 }
2304 
2305 // ============================================================================
2306 
VbaProjectStorageObject(const ObjectBase & rParent,const StorageRef & rxStrg,const OUString & rSysPath)2307 VbaProjectStorageObject::VbaProjectStorageObject( const ObjectBase& rParent, const StorageRef& rxStrg, const OUString& rSysPath ) :
2308     OleStorageObject( rParent, rxStrg, rSysPath )
2309 {
2310     addPreferredStorage( "VBA" );
2311 }
2312 
implDumpStream(const Reference<XInputStream> & rxStrm,const OUString & rStrgPath,const OUString & rStrmName,const OUString & rSysFileName)2313 void VbaProjectStorageObject::implDumpStream( const Reference< XInputStream >& rxStrm, const OUString& rStrgPath, const OUString& rStrmName, const OUString& rSysFileName )
2314 {
2315     if( (rStrgPath.getLength() == 0) && rStrmName.equalsAscii( "PROJECT" ) )
2316         TextLineStreamObject( *this, rxStrm, maVbaData.meTextEnc, rSysFileName ).dump();
2317     else
2318         OleStorageObject::implDumpStream( rxStrm, rStrgPath, rStrmName, rSysFileName );
2319 }
2320 
implDumpStorage(const StorageRef & rxStrg,const OUString & rStrgPath,const OUString & rSysPath)2321 void VbaProjectStorageObject::implDumpStorage( const StorageRef& rxStrg, const OUString& rStrgPath, const OUString& rSysPath )
2322 {
2323     if( rStrgPath.equalsAscii( "VBA" ) )
2324         VbaStorageObject( *this, rxStrg, rSysPath, maVbaData ).dump();
2325     else
2326         VbaFormStorageObject( *this, rxStrg, rSysPath, maVbaData ).dump();
2327 }
2328 
2329 // ============================================================================
2330 // ============================================================================
2331 
ActiveXStorageObject(const ObjectBase & rParent,const StorageRef & rxStrg,const OUString & rSysPath)2332 ActiveXStorageObject::ActiveXStorageObject( const ObjectBase& rParent, const StorageRef& rxStrg, const OUString& rSysPath ) :
2333     VbaContainerStorageObject( rParent, rxStrg, rSysPath )
2334 {
2335 }
2336 
implDumpBaseStream(const BinaryInputStreamRef & rxStrm,const OUString & rSysFileName)2337 void ActiveXStorageObject::implDumpBaseStream( const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName )
2338 {
2339     FormControlStreamObject( *this, rxStrm, rSysFileName ).dump();
2340 }
2341 
2342 // ============================================================================
2343 // ============================================================================
2344 
2345 } // namespace dump
2346 } // namespace oox
2347 
2348 #endif
2349