1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: biffdumper.cxx,v $
10 * $Revision: 1.5.20.26 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include "oox/dump/biffdumper.hxx"
33 #include <osl/thread.h>
34 #include <rtl/tencinfo.h>
35 #include "oox/dump/oledumper.hxx"
36 #include "oox/helper/olestorage.hxx"
37 #include "oox/core/filterbase.hxx"
38 #include "oox/xls/biffdetector.hxx"
39 #include "oox/xls/biffinputstream.hxx"
40 #include "oox/xls/formulabase.hxx"
42 #if OOX_INCLUDE_DUMPER
44 using ::rtl::OUString
;
45 using ::rtl::OUStringBuffer
;
47 using ::rtl::OStringBuffer
;
48 using ::rtl::OStringToOUString
;
49 using ::com::sun::star::uno::Reference
;
50 using ::com::sun::star::util::DateTime
;
51 using ::com::sun::star::lang::XMultiServiceFactory
;
52 using ::com::sun::star::io::XInputStream
;
53 using ::comphelper::MediaDescriptor
;
54 using ::oox::core::FilterBase
;
56 using namespace ::oox::xls
;
64 // constants ------------------------------------------------------------------
66 const sal_uInt16 BIFF_FONTFLAG_BOLD
= 0x0001;
67 const sal_uInt16 BIFF_FONTFLAG_ITALIC
= 0x0002;
69 const sal_uInt16 BIFF_OBJTYPE_GROUP
= 0;
70 const sal_uInt16 BIFF_OBJTYPE_LINE
= 1;
71 const sal_uInt16 BIFF_OBJTYPE_RECTANGLE
= 2;
72 const sal_uInt16 BIFF_OBJTYPE_OVAL
= 3;
73 const sal_uInt16 BIFF_OBJTYPE_ARC
= 4;
74 const sal_uInt16 BIFF_OBJTYPE_CHART
= 5;
75 const sal_uInt16 BIFF_OBJTYPE_TEXT
= 6;
76 const sal_uInt16 BIFF_OBJTYPE_BUTTON
= 7;
77 const sal_uInt16 BIFF_OBJTYPE_PICTURE
= 8;
78 const sal_uInt16 BIFF_OBJTYPE_POLYGON
= 9;
79 const sal_uInt16 BIFF_OBJTYPE_CHECKBOX
= 11;
80 const sal_uInt16 BIFF_OBJTYPE_OPTIONBUTTON
= 12;
81 const sal_uInt16 BIFF_OBJTYPE_EDIT
= 13;
82 const sal_uInt16 BIFF_OBJTYPE_LABEL
= 14;
83 const sal_uInt16 BIFF_OBJTYPE_DIALOG
= 15;
84 const sal_uInt16 BIFF_OBJTYPE_SPIN
= 16;
85 const sal_uInt16 BIFF_OBJTYPE_SCROLLBAR
= 17;
86 const sal_uInt16 BIFF_OBJTYPE_LISTBOX
= 18;
87 const sal_uInt16 BIFF_OBJTYPE_GROUPBOX
= 19;
88 const sal_uInt16 BIFF_OBJTYPE_DROPDOWN
= 20;
89 const sal_uInt16 BIFF_OBJTYPE_NOTE
= 25;
90 const sal_uInt16 BIFF_OBJTYPE_DRAWING
= 30;
92 const sal_uInt16 BIFF_OBJFLAGS_CONTROL
= 0x0010; /// Form control.
93 const sal_uInt16 BIFF_OBJFLAGS_CTLSSTREAM
= 0x0020; /// Data in Ctls stream.
95 const sal_uInt16 BIFF_STYLE_BUILTIN
= 0x8000;
97 const sal_uInt16 BIFF_PT_NOSTRING
= 0xFFFF;
101 // ============================================================================
102 // ============================================================================
106 void lclDumpDffClientPos( Output
& rOut
, BinaryInputStream
& rStrm
, const String
& rName
, sal_uInt16 nSubScale
)
108 MultiItemsGuard
aMultiGuard( rOut
);
109 TableGuard
aTabGuard( rOut
, 17 );
111 sal_uInt16 nPos
= rStrm
.readuInt16();
112 ItemGuard
aItem( rOut
, rName
);
113 rOut
.writeDec( nPos
);
116 sal_uInt16 nSubUnits
= rStrm
.readuInt16();
117 ItemGuard
aItem( rOut
, "sub-units" );
118 rOut
.writeDec( nSubUnits
);
119 rOut
.writeChar( '/' );
120 rOut
.writeDec( nSubScale
);
124 void lclDumpDffClientRect( Output
& rOut
, BinaryInputStream
& rStrm
)
126 lclDumpDffClientPos( rOut
, rStrm
, "start-col", 1024 );
127 lclDumpDffClientPos( rOut
, rStrm
, "start-row", 256 );
128 lclDumpDffClientPos( rOut
, rStrm
, "end-col", 1024 );
129 lclDumpDffClientPos( rOut
, rStrm
, "end-row", 256 );
134 // ----------------------------------------------------------------------------
136 BiffDffStreamObject::BiffDffStreamObject( const OutputObjectBase
& rParent
, const BinaryInputStreamRef
& rxStrm
)
138 DffStreamObject::construct( rParent
, rxStrm
);
141 void BiffDffStreamObject::implDumpClientAnchor()
143 dumpHex
< sal_uInt16
>( "flags", "DFF-CLIENTANCHOR-FLAGS" );
144 lclDumpDffClientRect( out(), in() );
147 // ============================================================================
149 BiffCtlsStreamObject::BiffCtlsStreamObject( const OutputObjectBase
& rParent
, const BinaryInputStreamRef
& rxStrm
)
151 InputObjectBase::construct( rParent
, rxStrm
);
152 mnStartPos
= mnLength
= 0;
155 void BiffCtlsStreamObject::dumpControl( sal_uInt32 nStartPos
, sal_uInt32 nLength
)
157 mnStartPos
= nStartPos
;
160 mnStartPos
= mnLength
= 0;
163 void BiffCtlsStreamObject::implDump()
168 writeEmptyItem( "CTLS-START" );
170 IndentGuard
aIndGuard( out() );
171 in().seek( mnStartPos
);
172 OcxGuidControlObject( *this, mnLength
).dump();
174 writeEmptyItem( "CTLS-END" );
179 // ============================================================================
180 // ============================================================================
182 BiffConfig::BiffConfig( const Config
& rParent
, BiffType eBiff
) :
185 Config::construct( rParent
);
188 bool BiffConfig::implIsValid() const
190 return (meBiff
!= BIFF_UNKNOWN
) && Config::implIsValid();
193 NameListRef
BiffConfig::implGetNameList( const OUString
& rKey
) const
195 NameListRef xList
= Config::implGetNameList( rKey
);
198 OUString aBaseKey
= rKey
+ CREATE_OUSTRING( "-BIFF" );
201 // fall-through intended!
202 case BIFF8
: if( !xList
) xList
= Config::implGetNameList( aBaseKey
+ OUString( sal_Unicode( '8' ) ) );
203 case BIFF5
: if( !xList
) xList
= Config::implGetNameList( aBaseKey
+ OUString( sal_Unicode( '5' ) ) );
204 case BIFF4
: if( !xList
) xList
= Config::implGetNameList( aBaseKey
+ OUString( sal_Unicode( '4' ) ) );
205 case BIFF3
: if( !xList
) xList
= Config::implGetNameList( aBaseKey
+ OUString( sal_Unicode( '3' ) ) );
206 case BIFF2
: if( !xList
) xList
= Config::implGetNameList( aBaseKey
+ OUString( sal_Unicode( '2' ) ) );
207 case BIFF_UNKNOWN
: break;
213 // ============================================================================
215 BiffSharedData::BiffSharedData( BiffType eBiff
) :
217 meTextEnc( osl_getThreadTextEncoding() )
221 void BiffSharedData::initializePerSheet()
225 meTextEnc
= osl_getThreadTextEncoding();
228 void BiffSharedData::setTextEncoding( rtl_TextEncoding eTextEnc
)
230 if( eTextEnc
!= RTL_TEXTENCODING_DONTKNOW
)
231 meTextEnc
= eTextEnc
;
234 sal_uInt16
BiffSharedData::getFontCount() const
236 return static_cast< sal_uInt16
>( maFontEncs
.size() );
239 rtl_TextEncoding
BiffSharedData::getFontEncoding( sal_uInt16 nFontId
) const
241 return (nFontId
< getFontCount()) ? maFontEncs
[ nFontId
] : meTextEnc
;
244 void BiffSharedData::appendFontEncoding( rtl_TextEncoding eFontEnc
)
246 maFontEncs
.push_back( (eFontEnc
== RTL_TEXTENCODING_DONTKNOW
) ? meTextEnc
: eFontEnc
);
247 if( maFontEncs
.size() == 4 )
248 maFontEncs
.push_back( meTextEnc
);
251 sal_uInt16
BiffSharedData::getXfCount() const
253 return static_cast< sal_uInt16
>( maXfFontIds
.size() );
256 rtl_TextEncoding
BiffSharedData::getXfEncoding( sal_uInt16 nXfId
) const
258 sal_uInt16 nFontId
= (nXfId
< getXfCount()) ? maXfFontIds
[ nXfId
] : 0;
259 return getFontEncoding( nFontId
);
262 void BiffSharedData::appendXfFontId( sal_uInt16 nFontId
)
264 maXfFontIds
.push_back( nFontId
);
267 bool BiffSharedData::implIsValid() const
269 return meBiff
!= BIFF_UNKNOWN
;
272 // ============================================================================
274 BiffObjectBase::~BiffObjectBase()
278 void BiffObjectBase::construct( const ObjectBase
& rParent
, const BinaryInputStreamRef
& rxStrm
, BiffType eBiff
, const OUString
& rSysFileName
)
280 if( rParent
.isValid() && rxStrm
.get() && (eBiff
!= BIFF_UNKNOWN
) )
282 mxBiffData
.reset( new BiffSharedData( eBiff
) );
283 mxBiffStrm
.reset( new BiffInputStream( *rxStrm
) );
284 RecordObjectBase::construct( rParent
, rxStrm
, rSysFileName
, mxBiffStrm
, "RECORD-NAMES", "SIMPLE-RECORDS" );
285 if( RecordObjectBase::implIsValid() )
287 reconstructConfig( ConfigRef( new BiffConfig( cfg(), eBiff
) ) );
288 mxDffObj
.reset( new BiffDffStreamObject( *this, mxBiffStrm
) );
289 if( StorageBase
* pRootStrg
= cfg().getRootStorage().get() )
291 BinaryInputStreamRef
xCtlsStrm( new BinaryXInputStream( pRootStrg
->openInputStream( CREATE_OUSTRING( "Ctls" ) ), true ) );
292 mxCtlsObj
.reset( new BiffCtlsStreamObject( *this, xCtlsStrm
) );
294 const Config
& rCfg
= cfg();
295 mxErrCodes
= rCfg
.getNameList( "ERRORCODES" );
296 mxConstType
= rCfg
.getNameList( "CONSTVALUE-TYPE" );
297 mxResultType
= rCfg
.getNameList( "FORMULA-RESULTTYPE" );
298 mnLastRecId
= BIFF_ID_UNKNOWN
;
299 mbMergeContRec
= rCfg
.getBoolOption( "merge-continue-record", true );
304 void BiffObjectBase::construct( const BiffObjectBase
& rParent
)
309 bool BiffObjectBase::implIsValid() const
311 return isValid( mxBiffData
) && mxBiffStrm
.get() && isValid( mxDffObj
) && InputObjectBase::implIsValid();
314 bool BiffObjectBase::implStartRecord( BinaryInputStream
&, sal_Int64
& ornRecPos
, sal_Int64
& ornRecId
, sal_Int64
& ornRecSize
)
317 mnLastRecId
= mxBiffStrm
->getRecId();
318 switch( mnLastRecId
)
320 case BIFF_ID_CHBEGIN
:
326 bool bValid
= mxBiffStrm
->startNextRecord();
327 ornRecPos
= mxBiffStrm
->tellBase() - 4;
328 ornRecId
= mxBiffStrm
->getRecId();
330 // special CONTINUE handling
331 mxBiffStrm
->resetRecord( mbMergeContRec
);
332 if( mbMergeContRec
) switch( mxBiffStrm
->getRecId() )
338 mxBiffStrm
->resetRecord( false );
340 case BIFF_ID_MSODRAWINGGROUP
:
341 case BIFF_ID_CHESCHERFORMAT
:
342 mxBiffStrm
->resetRecord( true, mxBiffStrm
->getRecId() );
346 // record specific settings
347 switch( mxBiffStrm
->getRecId() )
353 case BIFF_ID_INTERFACEHDR
:
354 mxBiffStrm
->enableDecoder( false );
361 ornRecSize
= mxBiffStrm
->getLength();
365 OUString
BiffObjectBase::getErrorName( sal_uInt8 nErrCode
) const
367 return cfg().getName( mxErrCodes
, nErrCode
);
370 // ----------------------------------------------------------------------------
372 sal_Int32
BiffObjectBase::readCol( bool bCol16Bit
)
374 return bCol16Bit
? mxBiffStrm
->readuInt16() : mxBiffStrm
->readuInt8();
377 sal_Int32
BiffObjectBase::readRow( bool bRow32Bit
)
379 return bRow32Bit
? mxBiffStrm
->readInt32() : mxBiffStrm
->readuInt16();
382 void BiffObjectBase::readAddress( Address
& orAddress
, bool bCol16Bit
, bool bRow32Bit
)
384 orAddress
.mnRow
= readRow( bRow32Bit
);
385 orAddress
.mnCol
= readCol( bCol16Bit
);
388 void BiffObjectBase::readRange( Range
& orRange
, bool bCol16Bit
, bool bRow32Bit
)
390 orRange
.maFirst
.mnRow
= readRow( bRow32Bit
);
391 orRange
.maLast
.mnRow
= readRow( bRow32Bit
);
392 orRange
.maFirst
.mnCol
= readCol( bCol16Bit
);
393 orRange
.maLast
.mnCol
= readCol( bCol16Bit
);
396 void BiffObjectBase::readRangeList( RangeList
& orRanges
, bool bCol16Bit
, bool bRow32Bit
)
399 *mxBiffStrm
>> nCount
;
400 orRanges
.resize( nCount
);
401 for( RangeList::iterator aIt
= orRanges
.begin(), aEnd
= orRanges
.end(); !mxBiffStrm
->isEof() && (aIt
!= aEnd
); ++aIt
)
402 readRange( *aIt
, bCol16Bit
, bRow32Bit
);
405 // ----------------------------------------------------------------------------
407 void BiffObjectBase::writeBooleanItem( const String
& rName
, sal_uInt8 nBool
)
409 writeDecItem( rName
, nBool
, "BOOLEAN" );
412 void BiffObjectBase::writeErrorCodeItem( const String
& rName
, sal_uInt8 nErrCode
)
414 writeHexItem( rName
, nErrCode
, mxErrCodes
);
417 void BiffObjectBase::writeFontPortions( const FontPortionModelList
& rPortions
)
419 if( !rPortions
.empty() )
421 writeDecItem( "font-count", static_cast< sal_uInt32
>( rPortions
.size() ) );
422 TableGuard
aTabGuard( out(), 14 );
423 for( FontPortionModelList::const_iterator aIt
= rPortions
.begin(), aEnd
= rPortions
.end(); aIt
!= aEnd
; ++aIt
)
425 MultiItemsGuard
aMultiGuard( out() );
426 writeDecItem( "char-pos", aIt
->mnPos
);
427 writeDecItem( "font-idx", aIt
->mnFontId
, "FONTNAMES" );
432 // ----------------------------------------------------------------------------
434 OUString
BiffObjectBase::dumpByteString( const String
& rName
, BiffStringFlags nFlags
, rtl_TextEncoding eDefaultTextEnc
)
436 OSL_ENSURE( !getFlag( nFlags
, static_cast< BiffStringFlags
>( ~(BIFF_STR_8BITLENGTH
| BIFF_STR_EXTRAFONTS
) ) ), "BiffObjectBase::dumpByteString - unknown flag" );
437 bool b8BitLength
= getFlag( nFlags
, BIFF_STR_8BITLENGTH
);
439 OString aString
= mxBiffStrm
->readByteString( !b8BitLength
, true );
440 FontPortionModelList aPortions
;
441 if( getFlag( nFlags
, BIFF_STR_EXTRAFONTS
) )
442 aPortions
.importPortions( *mxBiffStrm
, false );
444 // create string portions
445 OUStringBuffer aBuffer
;
446 sal_Int32 nStrLen
= aString
.getLength();
449 // add leading and trailing string position to ease the following loop
450 if( aPortions
.empty() || (aPortions
.front().mnPos
> 0) )
451 aPortions
.insert( aPortions
.begin(), FontPortionModel( 0, -1 ) );
452 if( aPortions
.back().mnPos
< nStrLen
)
453 aPortions
.push_back( FontPortionModel( nStrLen
, -1 ) );
455 // use global text encoding, if nothing special is specified
456 if( eDefaultTextEnc
== RTL_TEXTENCODING_DONTKNOW
)
457 eDefaultTextEnc
= getBiffData().getTextEncoding();
459 // create all string portions according to the font id vector
460 for( FontPortionModelList::const_iterator aIt
= aPortions
.begin(); aIt
->mnPos
< nStrLen
; ++aIt
)
462 sal_Int32 nPortionLen
= (aIt
+ 1)->mnPos
- aIt
->mnPos
;
463 if( nPortionLen
> 0 )
465 // convert byte string to unicode string, using current font encoding
466 rtl_TextEncoding eTextEnc
= mxBiffData
->getFontEncoding( static_cast< sal_uInt16
>( aIt
->mnFontId
) );
467 if( eTextEnc
== RTL_TEXTENCODING_DONTKNOW
)
468 eTextEnc
= eDefaultTextEnc
;
469 aBuffer
.append( OStringToOUString( aString
.copy( aIt
->mnPos
, nPortionLen
), eTextEnc
) );
474 OUString aUniStr
= aBuffer
.makeStringAndClear();
475 writeStringItem( rName( "text" ), aUniStr
);
479 OUString
BiffObjectBase::dumpUniString( const String
& rName
, BiffStringFlags nFlags
)
481 OSL_ENSURE( !getFlag( nFlags
, static_cast< BiffStringFlags
>( ~(BIFF_STR_8BITLENGTH
| BIFF_STR_SMARTFLAGS
) ) ), "BiffObjectBase::dumpUniString - unknown flag" );
482 bool b8BitLength
= getFlag( nFlags
, BIFF_STR_8BITLENGTH
);
484 // --- string header ---
485 sal_uInt16 nChars
= b8BitLength
? mxBiffStrm
->readuInt8() : mxBiffStrm
->readuInt16();
486 sal_uInt8 nFlagField
= 0;
487 if( (nChars
> 0) || !getFlag( nFlags
, BIFF_STR_SMARTFLAGS
) )
488 *mxBiffStrm
>> nFlagField
;
489 bool b16Bit
= getFlag( nFlagField
, BIFF_STRF_16BIT
);
490 bool bFonts
= getFlag( nFlagField
, BIFF_STRF_RICH
);
491 bool bPhonetic
= getFlag( nFlagField
, BIFF_STRF_PHONETIC
);
492 sal_uInt16 nFontCount
= bFonts
? mxBiffStrm
->readuInt16() : 0;
493 sal_uInt32 nPhoneticSize
= bPhonetic
? mxBiffStrm
->readuInt32() : 0;
495 // --- character array ---
496 OUString aString
= mxBiffStrm
->readUniStringChars( nChars
, b16Bit
, true );
497 writeStringItem( rName( "text" ), aString
);
499 // --- formatting ---
500 // #122185# bRich flag may be set, but format runs may be missing
503 IndentGuard
aIndGuard( out() );
504 FontPortionModelList aPortions
;
505 aPortions
.importPortions( *mxBiffStrm
, nFontCount
, BIFF_FONTPORTION_16BIT
);
506 writeFontPortions( aPortions
);
509 // --- phonetic information ---
510 // #122185# bPhonetic flag may be set, but phonetic data may be missing
511 if( nPhoneticSize
> 0 )
513 IndentGuard
aIndGuard( out() );
514 dumpBinary( "phonetic-data", nPhoneticSize
, false );
520 OUString
BiffObjectBase::dumpString( const String
& rName
, BiffStringFlags nByteFlags
, BiffStringFlags nUniFlags
, rtl_TextEncoding eDefaultTextEnc
)
522 return (getBiff() == BIFF8
) ? dumpUniString( rName
, nUniFlags
) : dumpByteString( rName
, nByteFlags
, eDefaultTextEnc
);
525 sal_uInt8
BiffObjectBase::dumpBoolean( const String
& rName
)
528 *mxBiffStrm
>> nBool
;
529 writeBooleanItem( rName( "boolean" ), nBool
);
533 sal_uInt8
BiffObjectBase::dumpErrorCode( const String
& rName
)
536 *mxBiffStrm
>> nErrCode
;
537 writeErrorCodeItem( rName( "error-code" ), nErrCode
);
541 rtl_TextEncoding
BiffObjectBase::dumpCodePage( const String
& rName
)
543 sal_uInt16 nCodePage
= dumpDec
< sal_uInt16
>( rName( "codepage" ), "CODEPAGES" );
544 return BiffHelper::calcTextEncodingFromCodePage( nCodePage
);
547 void BiffObjectBase::dumpFormulaResult( const String
& rName
)
549 MultiItemsGuard
aMultiGuard( out() );
550 sal_uInt8 pnResult
[ 8 ];
551 mxBiffStrm
->readMemory( pnResult
, 8 );
552 writeArrayItem( rName( "result" ), pnResult
, 8 );
553 if( (pnResult
[ 6 ] == 0xFF) && (pnResult
[ 7 ] == 0xFF) )
555 sal_uInt8 nType
= pnResult
[ 0 ];
556 sal_uInt8 nData
= pnResult
[ 2 ];
557 writeHexItem( "type", nType
, mxResultType
);
560 case 1: writeBooleanItem( "value", nData
); break;
561 case 2: writeErrorCodeItem( "value", nData
); break;
566 double* pfValue
= reinterpret_cast< double* >( pnResult
);
567 ByteOrderConverter::convertLittleEndian( *pfValue
);
568 writeDecItem( "value", *pfValue
);
572 sal_Int32
BiffObjectBase::dumpColIndex( const String
& rName
, bool bCol16Bit
)
574 sal_Int32 nCol
= readCol( bCol16Bit
);
575 writeColIndexItem( rName( "col-idx" ), nCol
);
579 sal_Int32
BiffObjectBase::dumpRowIndex( const String
& rName
, bool bRow32Bit
)
581 sal_Int32 nRow
= readRow( bRow32Bit
);
582 writeRowIndexItem( rName( "row-idx" ), nRow
);
586 sal_Int32
BiffObjectBase::dumpColRange( const String
& rName
, bool bCol16Bit
)
588 sal_Int32 nCol1
= readCol( bCol16Bit
);
589 sal_Int32 nCol2
= readCol( bCol16Bit
);
590 writeColRangeItem( rName( "col-range" ), nCol1
, nCol2
);
591 return nCol2
- nCol1
+ 1;
594 sal_Int32
BiffObjectBase::dumpRowRange( const String
& rName
, bool bRow32Bit
)
596 sal_Int32 nRow1
= readRow( bRow32Bit
);
597 sal_Int32 nRow2
= readRow( bRow32Bit
);
598 writeRowRangeItem( rName( "row-range" ), nRow1
, nRow2
);
599 return nRow2
- nRow1
+ 1;
602 Address
BiffObjectBase::dumpAddress( const String
& rName
, bool bCol16Bit
, bool bRow32Bit
)
605 readAddress( aPos
, bCol16Bit
, bRow32Bit
);
606 writeAddressItem( rName( "addr" ), aPos
);
610 Range
BiffObjectBase::dumpRange( const String
& rName
, bool bCol16Bit
, bool bRow32Bit
)
613 readRange( aRange
, bCol16Bit
, bRow32Bit
);
614 writeRangeItem( rName( "range" ), aRange
);
618 void BiffObjectBase::dumpRangeList( const String
& rName
, bool bCol16Bit
, bool bRow32Bit
)
621 readRangeList( aRanges
, bCol16Bit
, bRow32Bit
);
622 writeRangeListItem( rName( "range-list" ), aRanges
);
625 void BiffObjectBase::dumpConstArrayHeader( sal_uInt32
& rnCols
, sal_uInt32
& rnRows
)
627 Output
& rOut
= out();
628 MultiItemsGuard
aMultiGuard( rOut
);
629 rnCols
= dumpDec
< sal_uInt8
>( "width" );
630 rnRows
= dumpDec
< sal_uInt16
>( "height" );
636 case BIFF5
: if( rnCols
== 0 ) rnCols
= 256; break;
637 case BIFF8
: ++rnCols
; ++rnRows
; break;
638 case BIFF_UNKNOWN
: break;
640 ItemGuard
aItem( rOut
, "size" );
641 rOut
.writeDec( rnCols
);
642 rOut
.writeChar( 'x' );
643 rOut
.writeDec( rnRows
);
645 rOut
.writeDec( rnCols
* rnRows
);
648 OUString
BiffObjectBase::dumpConstValue( sal_Unicode cStrQuote
)
650 Output
& rOut
= out();
651 MultiItemsGuard
aMultiGuard( rOut
);
652 OUStringBuffer aValue
;
653 switch( dumpDec
< sal_uInt8
>( "type", mxConstType
) )
655 case BIFF_DATATYPE_EMPTY
:
657 aValue
.append( OOX_DUMP_EMPTYVALUE
);
659 case BIFF_DATATYPE_DOUBLE
:
660 dumpDec
< double >( "value" );
661 aValue
.append( rOut
.getLastItemValue() );
663 case BIFF_DATATYPE_STRING
:
664 aValue
.append( dumpString( "value", BIFF_STR_8BITLENGTH
) );
665 StringHelper::enclose( aValue
, cStrQuote
);
667 case BIFF_DATATYPE_BOOL
:
668 dumpBoolean( "value" );
669 aValue
.append( rOut
.getLastItemValue() );
672 case BIFF_DATATYPE_ERROR
:
673 dumpErrorCode( "value" );
674 aValue
.append( rOut
.getLastItemValue() );
678 return aValue
.makeStringAndClear();
681 sal_uInt16
BiffObjectBase::dumpRepeatedRecId()
683 return dumpHex
< sal_uInt16
>( "repeated-rec-id", getRecNames() );
686 void BiffObjectBase::dumpFrHeader( bool bWithFlags
, bool bWithRange
)
688 dumpHex
< sal_uInt16
>( "fr-rec-id", getRecNames() );
689 sal_Int16 nFlags
= bWithFlags
? dumpHex
< sal_uInt16
>( "fr-flags", "FR-FLAGS" ) : 0x0001;
692 if( getFlag
< sal_uInt16
>( nFlags
, 0x0001 ) )
693 dumpRange( "fr-range" );
699 void BiffObjectBase::dumpDffClientRect()
701 lclDumpDffClientRect( out(), in() );
704 void BiffObjectBase::dumpEmbeddedDff()
707 writeEmptyItem( "EMBEDDED-DFF-START" );
712 writeEmptyItem( "EMBEDDED-DFF-END" );
716 void BiffObjectBase::dumpOcxControl()
718 sal_uInt32 nStartPos
= dumpHex
< sal_uInt32
>( "ctls-stream-pos", "CONV-DEC" );
719 sal_uInt32 nLength
= dumpHex
< sal_uInt32
>( "ctls-stream-length", "CONV-DEC" );
720 if( isValid( mxCtlsObj
) )
721 mxCtlsObj
->dumpControl( nStartPos
, nLength
);
724 // ============================================================================
725 // ============================================================================
727 FormulaObject::FormulaObject( const BiffObjectBase
& rParent
) :
730 BiffObjectBase::construct( rParent
);
734 FormulaObject::~FormulaObject()
738 sal_uInt16
FormulaObject::readFormulaSize()
740 return (getBiff() == BIFF2
) ? getBiffStream().readuInt8() : getBiffStream().readuInt16();
743 sal_uInt16
FormulaObject::dumpFormulaSize( const String
& rName
)
745 sal_uInt16 nSize
= readFormulaSize();
746 writeDecItem( rName( "formula-size" ), nSize
);
750 void FormulaObject::dumpCellFormula( const String
& rName
, sal_uInt16 nSize
)
752 dumpFormula( rName
, nSize
, false );
755 void FormulaObject::dumpCellFormula( const String
& rName
)
757 dumpFormula( rName
, false );
760 void FormulaObject::dumpNameFormula( const String
& rName
, sal_uInt16 nSize
)
762 dumpFormula( rName
, nSize
, true );
765 void FormulaObject::dumpNameFormula( const String
& rName
)
767 dumpFormula( rName
, true );
770 void FormulaObject::implDump()
773 MultiItemsGuard
aMultiGuard( out() );
774 writeEmptyItem( maName
);
775 writeDecItem( "formula-size", mnSize
);
777 if( mnSize
== 0 ) return;
779 BinaryInputStream
& rStrm
= in();
780 sal_Int64 nStartPos
= rStrm
.tell();
781 sal_Int64 nEndPos
= ::std::min
< sal_Int64
>( nStartPos
+ mnSize
, rStrm
.getLength() );
783 bool bValid
= mxTokens
.get();
784 mxStack
.reset( new FormulaStack
);
786 IndentGuard
aIndGuard( out() );
788 TableGuard
aTabGuard( out(), 8, 18 );
789 while( bValid
&& !rStrm
.isEof() && (rStrm
.tell() < nEndPos
) )
791 MultiItemsGuard
aMultiGuard( out() );
792 writeHexItem( EMPTY_STRING
, static_cast< sal_uInt16
>( rStrm
.tell() - nStartPos
) );
793 sal_uInt8 nTokenId
= dumpHex
< sal_uInt8
>( EMPTY_STRING
, mxTokens
);
794 bValid
= mxTokens
->hasName( nTokenId
);
797 sal_uInt8 nTokClass
= nTokenId
& BIFF_TOKCLASS_MASK
;
798 sal_uInt8 nBaseId
= nTokenId
& BIFF_TOKID_MASK
;
799 if( nTokClass
== BIFF_TOKCLASS_NONE
)
803 case BIFF_TOKID_EXP
: dumpExpToken( "EXP" ); break;
804 case BIFF_TOKID_TBL
: dumpExpToken( "TBL" ); break;
805 case BIFF_TOKID_ADD
: dumpBinaryOpToken( "+" ); break;
806 case BIFF_TOKID_SUB
: dumpBinaryOpToken( "-" ); break;
807 case BIFF_TOKID_MUL
: dumpBinaryOpToken( "*" ); break;
808 case BIFF_TOKID_DIV
: dumpBinaryOpToken( "/" ); break;
809 case BIFF_TOKID_POWER
: dumpBinaryOpToken( "^" ); break;
810 case BIFF_TOKID_CONCAT
: dumpBinaryOpToken( "&" ); break;
811 case BIFF_TOKID_LT
: dumpBinaryOpToken( "<" ); break;
812 case BIFF_TOKID_LE
: dumpBinaryOpToken( "<=" ); break;
813 case BIFF_TOKID_EQ
: dumpBinaryOpToken( "=" ); break;
814 case BIFF_TOKID_GE
: dumpBinaryOpToken( ">=" ); break;
815 case BIFF_TOKID_GT
: dumpBinaryOpToken( "<" ); break;
816 case BIFF_TOKID_NE
: dumpBinaryOpToken( "<>" ); break;
817 case BIFF_TOKID_ISECT
: dumpBinaryOpToken( " " ); break;
818 case BIFF_TOKID_LIST
: dumpBinaryOpToken( "," ); break;
819 case BIFF_TOKID_RANGE
: dumpBinaryOpToken( ":" ); break;
820 case BIFF_TOKID_UPLUS
: dumpUnaryOpToken( "+", "" ); break;
821 case BIFF_TOKID_UMINUS
: dumpUnaryOpToken( "-", "" ); break;
822 case BIFF_TOKID_PERCENT
: dumpUnaryOpToken( "", "%" ); break;
823 case BIFF_TOKID_PAREN
: dumpUnaryOpToken( "(", ")" ); break;
824 case BIFF_TOKID_MISSARG
: dumpMissArgToken(); break;
825 case BIFF_TOKID_STR
: dumpStringToken(); break;
826 case BIFF_TOKID_NLR
: bValid
= dumpNlrToken(); break;
827 case BIFF_TOKID_ATTR
: bValid
= dumpAttrToken(); break;
828 case BIFF_TOKID_SHEET
: dumpSheetToken(); break;
829 case BIFF_TOKID_ENDSHEET
: dumpEndSheetToken(); break;
830 case BIFF_TOKID_ERR
: dumpErrorToken(); break;
831 case BIFF_TOKID_BOOL
: dumpBoolToken(); break;
832 case BIFF_TOKID_INT
: dumpIntToken(); break;
833 case BIFF_TOKID_NUM
: dumpDoubleToken(); break;
834 default: bValid
= false;
839 OUString aTokClass
= cfg().getName( mxClasses
, nTokClass
);
842 case BIFF_TOKID_ARRAY
: dumpArrayToken( aTokClass
); break;
843 case BIFF_TOKID_FUNC
: dumpFuncToken( aTokClass
); break;
844 case BIFF_TOKID_FUNCVAR
: dumpFuncVarToken( aTokClass
); break;
845 case BIFF_TOKID_NAME
: dumpNameToken( aTokClass
); break;
846 case BIFF_TOKID_REF
: dumpRefToken( aTokClass
, false ); break;
847 case BIFF_TOKID_AREA
: dumpAreaToken( aTokClass
, false ); break;
848 case BIFF_TOKID_MEMAREA
: dumpMemAreaToken( aTokClass
, true ); break;
849 case BIFF_TOKID_MEMERR
: dumpMemAreaToken( aTokClass
, false ); break;
850 case BIFF_TOKID_MEMNOMEM
: dumpMemAreaToken( aTokClass
, false ); break;
851 case BIFF_TOKID_MEMFUNC
: dumpMemFuncToken( aTokClass
); break;
852 case BIFF_TOKID_REFERR
: dumpRefErrToken( aTokClass
, false ); break;
853 case BIFF_TOKID_AREAERR
: dumpRefErrToken( aTokClass
, true ); break;
854 case BIFF_TOKID_REFN
: dumpRefToken( aTokClass
, true ); break;
855 case BIFF_TOKID_AREAN
: dumpAreaToken( aTokClass
, true ); break;
856 case BIFF_TOKID_MEMAREAN
: dumpMemFuncToken( aTokClass
); break;
857 case BIFF_TOKID_MEMNOMEMN
: dumpMemFuncToken( aTokClass
); break;
858 case BIFF_TOKID_FUNCCE
: dumpCmdToken( aTokClass
); break;
859 case BIFF_TOKID_NAMEX
: dumpNameXToken( aTokClass
); break;
860 case BIFF_TOKID_REF3D
: dumpRef3dToken( aTokClass
, mbNameMode
); break;
861 case BIFF_TOKID_AREA3D
: dumpArea3dToken( aTokClass
, mbNameMode
); break;
862 case BIFF_TOKID_REFERR3D
: dumpRefErr3dToken( aTokClass
, false ); break;
863 case BIFF_TOKID_AREAERR3D
: dumpRefErr3dToken( aTokClass
, true ); break;
864 default: bValid
= false;
870 bValid
= nEndPos
== rStrm
.tell();
874 writeInfoItem( "formula", mxStack
->getFormulaString() );
875 writeInfoItem( "classes", mxStack
->getClassesString() );
878 dumpBinary( OOX_DUMP_ERRASCII( "formula-error" ), nEndPos
- rStrm
.tell(), false );
883 void FormulaObject::dumpFormula( const String
& rName
, sal_uInt16 nSize
, bool bNameMode
)
885 maName
= rName( "formula" );
887 mbNameMode
= bNameMode
;
892 void FormulaObject::dumpFormula( const String
& rName
, bool bNameMode
)
894 dumpFormula( rName
, readFormulaSize(), bNameMode
);
897 // private --------------------------------------------------------------------
899 void FormulaObject::constructFmlaObj()
901 if( BiffObjectBase::implIsValid() )
903 mxFuncProv
.reset( new FunctionProvider( FILTER_BIFF
, getBiff(), true ) );
905 Config
& rCfg
= cfg();
906 mxClasses
= rCfg
.getNameList( "TOKENCLASSES" );
907 mxRelFlags
= rCfg
.getNameList( "REFRELFLAGS" );
908 mxNlrTypes
= rCfg
.getNameList( "NLRTYPES" );
909 mxAttrTypes
= rCfg
.getNameList( "ATTRTYPES" );
910 mxSpTypes
= rCfg
.getNameList( "ATTRSPACETYPES" );
912 // create classified token names
913 mxTokens
= rCfg
.createNameList
< ConstList
>( "TOKENS" );
914 mxTokens
->includeList( rCfg
.getNameList( "BASETOKENS" ) );
916 NameListRef xClassTokens
= rCfg
.getNameList( "CLASSTOKENS" );
917 if( mxClasses
.get() && xClassTokens
.get() )
918 for( NameListBase::const_iterator aCIt
= mxClasses
->begin(), aCEnd
= mxClasses
->end(); aCIt
!= aCEnd
; ++aCIt
)
919 for( NameListBase::const_iterator aTIt
= xClassTokens
->begin(), aTEnd
= xClassTokens
->end(); aTIt
!= aTEnd
; ++aTIt
)
920 mxTokens
->setName( aCIt
->first
| aTIt
->first
, aTIt
->second
+ aCIt
->second
);
923 mnRowCount
= (getBiff() == BIFF8
) ? 65536 : 16384;
927 // ----------------------------------------------------------------------------
931 OUString
lclCreateName( const OUString
& rRef
, sal_uInt16 nNameIdx
)
933 OUStringBuffer
aName( rRef
);
934 StringHelper::appendIndexedText( aName
, CREATE_OUSTRING( "NAME" ), nNameIdx
);
935 return aName
.makeStringAndClear();
938 OUString
lclCreateNlr( const OUString
& rData
, bool bRel
= true )
941 if( !bRel
) aNlr
.append( OOX_DUMP_ADDRABS
);
942 StringHelper::appendIndexedText( aNlr
, CREATE_OUSTRING( "NLR" ), rData
);
943 return aNlr
.makeStringAndClear();
946 OUString
lclCreateNlr( const TokenAddress
& rPos
)
948 OUStringBuffer aAddr
;
949 StringHelper::appendAddrCol( aAddr
, rPos
.mnCol
, true );
950 StringHelper::appendAddrRow( aAddr
, rPos
.mnRow
, true );
951 return lclCreateNlr( aAddr
.makeStringAndClear(), rPos
.mbRelRow
);
956 // ----------------------------------------------------------------------------
958 TokenAddress
FormulaObject::createTokenAddress( sal_uInt16 nCol
, sal_uInt16 nRow
, bool bRelC
, bool bRelR
, bool bNameMode
) const
962 if( bRelC
&& bNameMode
&& (nCol
>= mnColCount
/ 2) ) aPos
.mnCol
-= mnColCount
;
963 aPos
.mbRelCol
= bRelC
;
965 if( bRelR
&& bNameMode
&& (nRow
>= mnRowCount
/ 2) ) aPos
.mnRow
-= mnRowCount
;
966 aPos
.mbRelRow
= bRelR
;
970 OUString
FormulaObject::createRef( const OUString
& rData
) const
972 return maRefPrefix
+ rData
;
975 OUString
FormulaObject::createName( sal_uInt16 nNameIdx
) const
977 return lclCreateName( maRefPrefix
, nNameIdx
);
980 OUString
FormulaObject::createPlaceHolder( size_t nIdx
) const
983 StringHelper::appendDec( aStr
, static_cast< sal_uInt32
>( nIdx
) );
984 StringHelper::enclose( aStr
, OOX_DUMP_PLACEHOLDER
);
985 return aStr
.makeStringAndClear();
988 OUString
FormulaObject::createPlaceHolder() const
990 return createPlaceHolder( maAddData
.size() );
993 sal_uInt16
FormulaObject::readFuncId()
995 return (getBiff() >= BIFF4
) ? in().readuInt16() : in().readuInt8();
998 OUString
FormulaObject::writeFuncIdItem( sal_uInt16 nFuncId
, const FunctionInfo
** oppFuncInfo
)
1000 ItemGuard
aItemGuard( out(), "func-id" );
1001 writeHexItem( EMPTY_STRING
, nFuncId
, "FUNCID" );
1002 OUStringBuffer aBuffer
;
1003 const FunctionInfo
* pFuncInfo
= mxFuncProv
->getFuncInfoFromBiffFuncId( nFuncId
);
1005 aBuffer
.append( pFuncInfo
->maOoxFuncName
);
1008 bool bCmd
= getFlag( nFuncId
, BIFF_TOK_FUNCVAR_CMD
);
1009 aBuffer
.appendAscii( bCmd
? "CMD" : "FUNC" );
1010 StringHelper::appendIndex( aBuffer
, nFuncId
& BIFF_TOK_FUNCVAR_FUNCIDMASK
);
1012 OUString aFuncName
= aBuffer
.makeStringAndClear();
1014 out().writeChar( OOX_DUMP_STRQUOTE
);
1015 out().writeString( aFuncName
);
1016 out().writeChar( OOX_DUMP_STRQUOTE
);
1017 if( oppFuncInfo
) *oppFuncInfo
= pFuncInfo
;
1021 sal_uInt16
FormulaObject::dumpTokenCol( const String
& rName
, bool& rbRelC
, bool& rbRelR
)
1023 sal_uInt16 nCol
= 0;
1024 if( getBiff() == BIFF8
)
1026 nCol
= dumpHex
< sal_uInt16
>( rName
, mxRelFlags
);
1027 rbRelC
= getFlag( nCol
, BIFF_TOK_REF_COLREL
);
1028 rbRelR
= getFlag( nCol
, BIFF_TOK_REF_ROWREL
);
1029 nCol
&= BIFF_TOK_REF_COLMASK
;
1032 nCol
= dumpDec
< sal_uInt8
>( rName
);
1036 sal_uInt16
FormulaObject::dumpTokenRow( const String
& rName
, bool& rbRelC
, bool& rbRelR
)
1038 sal_uInt16 nRow
= 0;
1039 if( getBiff() == BIFF8
)
1040 nRow
= dumpDec
< sal_uInt16
>( rName
);
1043 nRow
= dumpHex
< sal_uInt16
>( rName
, mxRelFlags
);
1044 rbRelC
= getFlag( nRow
, BIFF_TOK_REF_COLREL
);
1045 rbRelR
= getFlag( nRow
, BIFF_TOK_REF_ROWREL
);
1046 nRow
&= BIFF_TOK_REF_ROWMASK
;
1051 TokenAddress
FormulaObject::dumpTokenAddress( bool bNameMode
)
1055 sal_uInt16 nRow
= dumpTokenRow( "row", bRelC
, bRelR
);
1056 sal_uInt16 nCol
= dumpTokenCol( "col", bRelC
, bRelR
);
1057 return createTokenAddress( nCol
, nRow
, bRelC
, bRelR
, bNameMode
);
1060 TokenRange
FormulaObject::dumpTokenRange( bool bNameMode
)
1062 bool bRelC1
= false;
1063 bool bRelR1
= false;
1064 bool bRelC2
= false;
1065 bool bRelR2
= false;
1066 sal_uInt16 nRow1
= dumpTokenRow( "row1", bRelC1
, bRelR1
);
1067 sal_uInt16 nRow2
= dumpTokenRow( "row2", bRelC2
, bRelR2
);
1068 sal_uInt16 nCol1
= dumpTokenCol( "col1", bRelC1
, bRelR1
);
1069 sal_uInt16 nCol2
= dumpTokenCol( "col2", bRelC2
, bRelR2
);
1071 aRange
.maFirst
= createTokenAddress( nCol1
, nRow1
, bRelC1
, bRelR1
, bNameMode
);
1072 aRange
.maLast
= createTokenAddress( nCol2
, nRow2
, bRelC2
, bRelR2
, bNameMode
);
1076 sal_Int16
FormulaObject::readTokenRefIdx()
1078 sal_Int16 nRefIdx
= dumpDec
< sal_Int16
>( "ref-idx" );
1081 case BIFF2
: dumpUnused( 1 ); break;
1082 case BIFF3
: dumpUnused( 2 ); break;
1083 case BIFF4
: dumpUnused( 2 ); break;
1084 case BIFF5
: dumpUnused( 8 ); break;
1086 case BIFF_UNKNOWN
: break;
1091 OUString
FormulaObject::dumpTokenRefIdx()
1093 OUStringBuffer
aRef( CREATE_OUSTRING( "REF" ) );
1094 StringHelper::appendIndex( aRef
, readTokenRefIdx() );
1095 aRef
.append( OOX_DUMP_TABSEP
);
1096 return aRef
.makeStringAndClear();
1099 OUString
FormulaObject::dumpTokenRefTabIdxs()
1101 sal_Int16 nRefIdx
= readTokenRefIdx();
1102 OUStringBuffer
aRef( CREATE_OUSTRING( "REF" ) );
1103 StringHelper::appendIndex( aRef
, nRefIdx
);
1104 if( getBiff() == BIFF5
)
1106 dumpDec
< sal_Int16
>( "tab1" );
1107 sal_Int16 nTab2
= dumpDec
< sal_Int16
>( "tab2" );
1108 if( (nRefIdx
> 0) && (nTab2
> 0) && (nRefIdx
!= nTab2
) )
1110 aRef
.append( OOX_DUMP_RANGESEP
);
1111 aRef
.appendAscii( "REF" );
1112 StringHelper::appendIndex( aRef
, nTab2
);
1115 aRef
.append( OOX_DUMP_TABSEP
);
1116 return aRef
.makeStringAndClear();
1119 void FormulaObject::dumpIntToken()
1121 dumpDec
< sal_uInt16
>( "value" );
1122 mxStack
->pushOperand( out().getLastItemValue() );
1125 void FormulaObject::dumpDoubleToken()
1127 dumpDec
< double >( "value" );
1128 mxStack
->pushOperand( out().getLastItemValue() );
1131 void FormulaObject::dumpStringToken()
1133 OUStringBuffer aValue
;
1134 aValue
.append( dumpString( "value", BIFF_STR_8BITLENGTH
, BIFF_STR_8BITLENGTH
) );
1135 StringHelper::enclose( aValue
, OOX_DUMP_FMLASTRQUOTE
);
1136 mxStack
->pushOperand( aValue
.makeStringAndClear() );
1139 void FormulaObject::dumpBoolToken()
1141 dumpBoolean( "value" );
1142 mxStack
->pushOperand( out().getLastItemValue() );
1145 void FormulaObject::dumpErrorToken()
1147 dumpErrorCode( "value" );
1148 mxStack
->pushOperand( out().getLastItemValue() );
1151 void FormulaObject::dumpMissArgToken()
1153 mxStack
->pushOperand( OUString( OOX_DUMP_EMPTYVALUE
) );
1156 void FormulaObject::dumpArrayToken( const OUString
& rTokClass
)
1158 dumpUnused( (getBiff() == BIFF2
) ? 6 : 7 );
1159 mxStack
->pushOperand( createPlaceHolder(), rTokClass
);
1160 maAddData
.push_back( ADDDATA_ARRAY
);
1163 void FormulaObject::dumpNameToken( const OUString
& rTokClass
)
1165 sal_uInt16 nNameIdx
= dumpDec
< sal_uInt16
>( "name-idx" );
1168 case BIFF2
: dumpUnused( 5 ); break;
1170 case BIFF4
: dumpUnused( 8 ); break;
1171 case BIFF5
: dumpUnused( 12 ); break;
1172 case BIFF8
: dumpUnused( 2 ); break;
1173 case BIFF_UNKNOWN
: break;
1175 mxStack
->pushOperand( createName( nNameIdx
), rTokClass
);
1178 void FormulaObject::dumpNameXToken( const OUString
& rTokClass
)
1180 OUString aRef
= dumpTokenRefIdx();
1181 sal_uInt16 nNameIdx
= dumpDec
< sal_uInt16
>( "name-idx" );
1182 dumpUnused( (getBiff() == BIFF8
) ? 2 : 12 );
1183 mxStack
->pushOperand( lclCreateName( aRef
, nNameIdx
), rTokClass
);
1186 void FormulaObject::dumpRefToken( const OUString
& rTokClass
, bool bNameMode
)
1188 TokenAddress aPos
= dumpTokenAddress( bNameMode
);
1189 writeTokenAddressItem( "addr", aPos
, bNameMode
);
1190 mxStack
->pushOperand( createRef( out().getLastItemValue() ), rTokClass
);
1193 void FormulaObject::dumpAreaToken( const OUString
& rTokClass
, bool bNameMode
)
1195 TokenRange aRange
= dumpTokenRange( bNameMode
);
1196 writeTokenRangeItem( "range", aRange
, bNameMode
);
1197 mxStack
->pushOperand( createRef( out().getLastItemValue() ), rTokClass
);
1200 void FormulaObject::dumpRefErrToken( const OUString
& rTokClass
, bool bArea
)
1202 dumpUnused( ((getBiff() == BIFF8
) ? 4 : 3) * (bArea
? 2 : 1) );
1203 mxStack
->pushOperand( createRef( getErrorName( BIFF_ERR_REF
) ), rTokClass
);
1206 void FormulaObject::dumpRef3dToken( const OUString
& rTokClass
, bool bNameMode
)
1208 OUString aRef
= dumpTokenRefTabIdxs();
1209 TokenAddress aPos
= dumpTokenAddress( bNameMode
);
1210 writeTokenAddress3dItem( "addr", aRef
, aPos
, bNameMode
);
1211 mxStack
->pushOperand( out().getLastItemValue(), rTokClass
);
1214 void FormulaObject::dumpArea3dToken( const OUString
& rTokClass
, bool bNameMode
)
1216 OUString aRef
= dumpTokenRefTabIdxs();
1217 TokenRange aRange
= dumpTokenRange( bNameMode
);
1218 writeTokenRange3dItem( "range", aRef
, aRange
, bNameMode
);
1219 mxStack
->pushOperand( out().getLastItemValue(), rTokClass
);
1222 void FormulaObject::dumpRefErr3dToken( const OUString
& rTokClass
, bool bArea
)
1224 OUString aRef
= dumpTokenRefTabIdxs();
1225 dumpUnused( ((getBiff() == BIFF8
) ? 4 : 3) * (bArea
? 2 : 1) );
1226 mxStack
->pushOperand( aRef
+ getErrorName( BIFF_ERR_REF
), rTokClass
);
1229 void FormulaObject::dumpMemFuncToken( const OUString
& /*rTokClass*/ )
1231 dumpDec
< sal_uInt16
, sal_uInt8
>( getBiff() != BIFF2
, "size" );
1234 void FormulaObject::dumpMemAreaToken( const OUString
& rTokClass
, bool bAddData
)
1236 dumpUnused( (getBiff() == BIFF2
) ? 3 : 4 );
1237 dumpMemFuncToken( rTokClass
);
1239 maAddData
.push_back( ADDDATA_MEMAREA
);
1242 void FormulaObject::dumpExpToken( const String
& rName
)
1245 aPos
.mnRow
= dumpDec
< sal_uInt16
>( "row" );
1246 aPos
.mnCol
= dumpDec
< sal_uInt16
, sal_uInt8
>( getBiff() != BIFF2
, "col" );
1247 writeAddressItem( "base-addr", aPos
);
1248 OUStringBuffer
aOp( rName
);
1249 StringHelper::appendIndex( aOp
, out().getLastItemValue() );
1250 mxStack
->pushOperand( aOp
.makeStringAndClear() );
1253 void FormulaObject::dumpUnaryOpToken( const String
& rLOp
, const String
& rROp
)
1255 mxStack
->pushUnaryOp( rLOp
, rROp
);
1258 void FormulaObject::dumpBinaryOpToken( const String
& rOp
)
1260 mxStack
->pushBinaryOp( rOp
);
1263 void FormulaObject::dumpFuncToken( const OUString
& rTokClass
)
1265 sal_uInt16 nFuncId
= readFuncId();
1266 const FunctionInfo
* pFuncInfo
= 0;
1267 OUString aFuncName
= writeFuncIdItem( nFuncId
, &pFuncInfo
);
1268 if( pFuncInfo
&& (pFuncInfo
->mnMinParamCount
== pFuncInfo
->mnMaxParamCount
) )
1269 mxStack
->pushFuncOp( aFuncName
, rTokClass
, pFuncInfo
->mnMinParamCount
);
1271 mxStack
->setError();
1274 void FormulaObject::dumpFuncVarToken( const OUString
& rTokClass
)
1276 sal_uInt8 nParamCount
;
1277 in() >> nParamCount
;
1278 sal_uInt16 nFuncId
= readFuncId();
1279 bool bCmd
= getFlag( nFuncId
, BIFF_TOK_FUNCVAR_CMD
);
1281 writeHexItem( "param-count", nParamCount
, "PARAMCOUNT-CMD" );
1283 writeDecItem( "param-count", nParamCount
);
1284 OUString aFuncName
= writeFuncIdItem( nFuncId
);
1285 if( bCmd
&& getFlag( nParamCount
, BIFF_TOK_FUNCVAR_CMDPROMPT
) )
1287 aFuncName
+= OUString( OOX_DUMP_CMDPROMPT
);
1288 nParamCount
&= BIFF_TOK_FUNCVAR_COUNTMASK
;
1290 mxStack
->pushFuncOp( aFuncName
, rTokClass
, nParamCount
);
1293 void FormulaObject::dumpCmdToken( const OUString
& rTokClass
)
1295 sal_uInt8 nParamCount
= dumpDec
< sal_uInt8
>( "param-count", "PARAMCOUNT-CMD" );
1296 sal_uInt16 nCmdId
= readFuncId() | BIFF_TOK_FUNCVAR_CMD
;
1297 OUString aFuncName
= writeFuncIdItem( nCmdId
);
1298 if( getFlag( nParamCount
, BIFF_TOK_FUNCVAR_CMDPROMPT
) )
1300 aFuncName
+= OUString( OOX_DUMP_CMDPROMPT
);
1301 nParamCount
&= BIFF_TOK_FUNCVAR_COUNTMASK
;
1303 mxStack
->pushFuncOp( aFuncName
, rTokClass
, nParamCount
);
1306 void FormulaObject::dumpSheetToken()
1308 dumpUnused( (getBiff() == BIFF2
) ? 4 : 6 );
1309 maRefPrefix
= dumpTokenRefIdx();
1312 void FormulaObject::dumpEndSheetToken()
1314 dumpUnused( (getBiff() == BIFF2
) ? 3 : 4 );
1315 maRefPrefix
= OUString();
1318 bool FormulaObject::dumpAttrToken()
1321 bool bBiff2
= getBiff() == BIFF2
;
1322 sal_uInt8 nType
= dumpHex
< sal_uInt8
>( "type", mxAttrTypes
);
1325 case BIFF_TOK_ATTR_VOLATILE
:
1326 dumpUnused( bBiff2
? 1 : 2 );
1328 case BIFF_TOK_ATTR_IF
:
1329 dumpDec
< sal_uInt16
, sal_uInt8
>( !bBiff2
, "skip" );
1331 case BIFF_TOK_ATTR_CHOOSE
:
1333 sal_uInt16 nCount
= dumpDec
< sal_uInt16
, sal_uInt8
>( !bBiff2
, "choices" );
1334 out().resetItemIndex();
1335 for( sal_uInt16 nIdx
= 0; nIdx
< nCount
; ++nIdx
)
1336 dumpDec
< sal_uInt16
, sal_uInt8
>( !bBiff2
, "#skip" );
1337 dumpDec
< sal_uInt16
, sal_uInt8
>( !bBiff2
, "skip-err" );
1340 case 0: // in array formulas and defined names, the skip-bit may be 0
1341 case BIFF_TOK_ATTR_SKIP
:
1342 dumpDec
< sal_uInt16
, sal_uInt8
>( !bBiff2
, "skip" );
1344 case BIFF_TOK_ATTR_SUM
:
1345 dumpUnused( bBiff2
? 1 : 2 );
1346 mxStack
->pushFuncOp( CREATE_OUSTRING( "SUM" ), OUString( OOX_DUMP_BASECLASS
), 1 );
1348 case BIFF_TOK_ATTR_ASSIGN
:
1349 dumpUnused( bBiff2
? 1 : 2 );
1351 case BIFF_TOK_ATTR_SPACE
:
1352 case BIFF_TOK_ATTR_SPACE
| BIFF_TOK_ATTR_VOLATILE
:
1359 dumpDec
< sal_uInt16
>( "leading-spaces" );
1364 dumpDec
< sal_uInt8
>( "char-type", mxSpTypes
);
1365 dumpDec
< sal_uInt8
>( "char-count" );
1367 case BIFF_UNKNOWN
: break;
1376 bool FormulaObject::dumpNlrToken()
1378 const OUString aRefClass
= cfg().getName( mxClasses
, BIFF_TOKCLASS_REF
);
1379 const OUString aValClass
= cfg().getName( mxClasses
, BIFF_TOKCLASS_VAL
);
1382 sal_uInt8 nType
= dumpHex
< sal_uInt8
>( "type", mxNlrTypes
);
1385 case BIFF_TOK_NLR_ERR
: dumpNlrErrToken(); break;
1386 case BIFF_TOK_NLR_ROWR
: dumpNlrColRowToken( aRefClass
, false ); break;
1387 case BIFF_TOK_NLR_COLR
: dumpNlrColRowToken( aRefClass
, false ); break;
1388 case BIFF_TOK_NLR_ROWV
: dumpNlrColRowToken( aValClass
, false ); break;
1389 case BIFF_TOK_NLR_COLV
: dumpNlrColRowToken( aValClass
, false ); break;
1390 case BIFF_TOK_NLR_RANGE
: dumpNlrRangeToken( aRefClass
, false ); break;
1391 case BIFF_TOK_NLR_SRANGE
: dumpNlrRangeToken( aRefClass
, true ); break;
1392 case BIFF_TOK_NLR_SROWR
: dumpNlrColRowToken( aRefClass
, true ); break;
1393 case BIFF_TOK_NLR_SCOLR
: dumpNlrColRowToken( aRefClass
, true ); break;
1394 case BIFF_TOK_NLR_SROWV
: dumpNlrColRowToken( aValClass
, true ); break;
1395 case BIFF_TOK_NLR_SCOLV
: dumpNlrColRowToken( aValClass
, true ); break;
1396 case BIFF_TOK_NLR_RANGEERR
: dumpNlrRangeErrToken(); break;
1397 default: bValid
= false;
1402 void FormulaObject::dumpNlrErrToken()
1404 dumpDec
< sal_uInt32
>( "delname-idx" );
1405 mxStack
->pushOperand( lclCreateNlr( getErrorName( BIFF_ERR_NAME
) ) );
1408 void FormulaObject::dumpNlrColRowToken( const OUString
& rTokClass
, bool bAddData
)
1413 mxStack
->pushOperand( createPlaceHolder(), rTokClass
);
1414 maAddData
.push_back( ADDDATA_NLR
);
1418 TokenAddress aPos
= dumpTokenAddress( false );
1419 writeInfoItem( "addr", lclCreateNlr( aPos
) );
1420 mxStack
->pushOperand( out().getLastItemValue(), rTokClass
);
1424 void FormulaObject::dumpNlrRangeToken( const OUString
& rTokClass
, bool bAddData
)
1429 mxStack
->pushOperand( createPlaceHolder(), rTokClass
);
1430 maAddData
.push_back( ADDDATA_NLR
);
1434 TokenAddress aPos
= dumpTokenAddress( false );
1435 writeInfoItem( "addr", lclCreateNlr( aPos
) );
1436 mxStack
->pushOperand( out().getLastItemValue(), rTokClass
);
1439 dumpRange( "target-range" );
1442 void FormulaObject::dumpNlrRangeErrToken()
1444 dumpDec
< sal_uInt32
>( "delname-idx" );
1446 mxStack
->pushOperand( lclCreateNlr( getErrorName( BIFF_ERR_NAME
) ) );
1449 void FormulaObject::dumpAddTokenData()
1451 Output
& rOut
= out();
1452 rOut
.resetItemIndex();
1453 for( AddDataTypeVec::const_iterator aIt
= maAddData
.begin(), aEnd
= maAddData
.end(); aIt
!= aEnd
; ++aIt
)
1455 AddDataType eType
= *aIt
;
1458 ItemGuard
aItem( rOut
, "#add-data" );
1461 case ADDDATA_NLR
: rOut
.writeAscii( "tNlr" ); break;
1462 case ADDDATA_ARRAY
: rOut
.writeAscii( "tArray" ); break;
1463 case ADDDATA_MEMAREA
: rOut
.writeAscii( "tMemArea" ); break;
1467 size_t nIdx
= aIt
- maAddData
.begin();
1468 IndentGuard
aIndGuard( rOut
);
1471 case ADDDATA_NLR
: dumpAddDataNlr( nIdx
); break;
1472 case ADDDATA_ARRAY
: dumpAddDataArray( nIdx
); break;
1473 case ADDDATA_MEMAREA
: dumpAddDataMemArea( nIdx
); break;
1478 void FormulaObject::dumpAddDataNlr( size_t nIdx
)
1480 sal_uInt32 nFlags
= dumpHex
< sal_uInt32
>( "flags", "NLRADDFLAGS" );
1481 sal_uInt32 nCount
= nFlags
& BIFF_TOK_NLR_ADDMASK
;
1482 OUStringBuffer aBuffer
;
1483 for( sal_uInt32 nPos
= 0; nPos
< nCount
; ++nPos
)
1486 readAddress( aPos
);
1487 OUStringBuffer aAddr
;
1488 StringHelper::appendAddress( aAddr
, aPos
);
1489 StringHelper::appendToken( aBuffer
, aAddr
.makeStringAndClear(), OOX_DUMP_LISTSEP
);
1491 OUString aAddrList
= aBuffer
.makeStringAndClear();
1492 writeInfoItem( "stacked-positions", aAddrList
);
1493 mxStack
->replaceOnTop( createPlaceHolder( nIdx
), lclCreateNlr( aAddrList
) );
1496 void FormulaObject::dumpAddDataArray( size_t nIdx
)
1498 sal_uInt32 nCols
, nRows
;
1499 dumpConstArrayHeader( nCols
, nRows
);
1502 TableGuard
aTabGuard( out(), 17 );
1503 for( sal_uInt32 nRow
= 0; nRow
< nRows
; ++nRow
)
1505 OUStringBuffer aArrayLine
;
1506 for( sal_uInt32 nCol
= 0; nCol
< nCols
; ++nCol
)
1507 StringHelper::appendToken( aArrayLine
, dumpConstValue( OOX_DUMP_FMLASTRQUOTE
), OOX_DUMP_LISTSEP
);
1508 StringHelper::appendToken( aOp
, aArrayLine
.makeStringAndClear(), OOX_DUMP_ARRAYSEP
);
1510 StringHelper::enclose( aOp
, '{', '}' );
1511 mxStack
->replaceOnTop( createPlaceHolder( nIdx
), aOp
.makeStringAndClear() );
1514 void FormulaObject::dumpAddDataMemArea( size_t /*nIdx*/ )
1516 dumpRangeList( EMPTY_STRING
, getBiff() == BIFF8
);
1519 // ============================================================================
1520 // ============================================================================
1522 RecordStreamObject::~RecordStreamObject()
1526 void RecordStreamObject::construct( const ObjectBase
& rParent
, const BinaryInputStreamRef
& rxStrm
, BiffType eBiff
, const OUString
& rSysFileName
)
1528 BiffObjectBase::construct( rParent
, rxStrm
, eBiff
, rSysFileName
);
1529 if( BiffObjectBase::implIsValid() )
1530 mxFmlaObj
.reset( new FormulaObject( *this ) );
1533 bool RecordStreamObject::implIsValid() const
1535 return isValid( mxFmlaObj
) && BiffObjectBase::implIsValid();
1538 // ============================================================================
1540 WorkbookStreamObject::WorkbookStreamObject( const ObjectBase
& rParent
, const BinaryInputStreamRef
& rxStrm
, const OUString
& rSysFileName
)
1544 BiffType eBiff
= BiffDetector::detectStreamBiffVersion( *rxStrm
);
1545 RecordStreamObject::construct( rParent
, rxStrm
, eBiff
, rSysFileName
);
1546 if( RecordStreamObject::implIsValid() )
1548 Config
& rCfg
= cfg();
1549 mxColors
= rCfg
.getNameList( "COLORS" );
1550 mxBorderStyles
= rCfg
.getNameList( "BORDERSTYLES" );
1551 mxFillPatterns
= rCfg
.getNameList( "FILLPATTERNS" );
1554 mnPTRowColItemsIdx
= 0;
1556 initializePerSheet();
1561 WorkbookStreamObject::~WorkbookStreamObject()
1563 if( WorkbookStreamObject::implIsValid() )
1565 Config
& rCfg
= cfg();
1566 rCfg
.eraseNameList( "FONTNAMES" );
1567 rCfg
.eraseNameList( "FORMATS" );
1571 void WorkbookStreamObject::implDumpRecordBody()
1573 BiffInputStream
& rStrm
= getBiffStream();
1574 sal_uInt16 nRecId
= rStrm
.getRecId();
1575 sal_Int64 nRecSize
= rStrm
.getLength();
1576 BiffType eBiff
= getBiff();
1580 case BIFF2_ID_ARRAY
:
1581 case BIFF3_ID_ARRAY
:
1582 dumpRange( "array-range", false );
1583 dumpHex
< sal_uInt16
, sal_uInt8
>( eBiff
!= BIFF2
, "flags", "ARRAY-FLAGS" );
1584 if( eBiff
>= BIFF5
) dumpUnused( 4 );
1585 getFormulaDumper().dumpCellFormula();
1588 case BIFF2_ID_BLANK
:
1589 case BIFF3_ID_BLANK
:
1590 dumpCellHeader( nRecId
== BIFF2_ID_BLANK
);
1597 dumpHex
< sal_uInt16
>( "bof-type", "BOF-BIFFTYPE" );
1598 dumpHex
< sal_uInt16
>( "sheet-type", "BOF-SHEETTYPE" );
1599 if( nRecSize
>= 6 ) dumpDec
< sal_uInt16
>( "build-id" );
1600 if( nRecSize
>= 8 ) dumpDec
< sal_uInt16
>( "build-year" );
1601 if( nRecSize
>= 12 ) dumpHex
< sal_uInt32
>( "history-flags", "BOF-HISTORY-FLAGS" );
1602 if( nRecSize
>= 16 ) dumpHex
< sal_uInt32
>( "lowest-version", "BOF-LOWESTVERSION-FLAGS" );
1603 if( (eBiff
== BIFF4
) && (getLastRecId() != BIFF_ID_OBJ
) )
1604 initializePerSheet();
1607 case BIFF2_ID_BOOLERR
:
1608 case BIFF3_ID_BOOLERR
:
1609 dumpCellHeader( nRecId
== BIFF2_ID_BOOLERR
);
1613 case BIFF_ID_CFHEADER
:
1614 dumpDec
< sal_uInt16
>( "rule-count" );
1615 dumpBool
< sal_uInt16
>( "need-update" );
1616 dumpRange( "bounding-range" );
1620 case BIFF_ID_CFRULE
:
1622 dumpDec
< sal_uInt8
>( "type", "CFRULE-TYPE" );
1623 dumpDec
< sal_uInt8
>( "operator", "CFRULE-OPERATOR" );
1624 sal_uInt16 nFmla1Size
= dumpDec
< sal_uInt16
>( "formula1-size" );
1625 sal_uInt16 nFmla2Size
= dumpDec
< sal_uInt16
>( "formula2-size" );
1626 sal_uInt32 nFlags
= dumpHex
< sal_uInt32
>( "flags", "CFRULE-FLAGS" );
1628 if( getFlag
< sal_uInt32
>( nFlags
, 0x04000000 ) )
1630 writeEmptyItem( "font-block" );
1631 IndentGuard
aIndGuard( out() );
1632 sal_Int64 nRecPos
= rStrm
.tell();
1633 dumpUniString( "name", BIFF_STR_8BITLENGTH
);
1634 dumpUnused( static_cast< sal_Int32
>( nRecPos
+ 64 - rStrm
.tell() ) );
1635 dumpDec
< sal_Int32
>( "height", "CONV-TWIP-TO-PT" );
1636 dumpHex
< sal_uInt32
>( "flags", "CFRULE-FONTFLAGS" );
1637 dumpDec
< sal_uInt16
>( "weight", "FONT-WEIGHT" );
1638 dumpDec
< sal_uInt16
>( "escapement", "FONT-ESCAPEMENT" );
1639 dumpDec
< sal_uInt8
>( "underline", "FONT-UNDERLINE" );
1640 dumpUnused( 3 ); // family/charset?
1641 dumpDec
< sal_Int32
>( "color", mxColors
);
1643 dumpHex
< sal_uInt32
>( "used-flags", "CFRULE-FONTUSEDFLAGS" );
1644 dumpDec
< sal_uInt32
>( "escapement-used", "CFRULE-FONTUSED" );
1645 dumpDec
< sal_uInt32
>( "underline-used", "CFRULE-FONTUSED" );
1648 if( getFlag
< sal_uInt32
>( nFlags
, 0x08000000 ) )
1650 writeEmptyItem( "alignment-block" );
1651 IndentGuard
aIndGuard( out() );
1652 dumpHex
< sal_uInt8
>( "alignent", "CFRULE-ALIGNMENT" );
1653 dumpHex
< sal_uInt8
>( "rotation", "TEXTROTATION" );
1654 dumpHex
< sal_uInt16
>( "indent", "CFRULE-INDENT" );
1655 dumpDec
< sal_uInt16
>( "relative-indent" );
1658 if( getFlag
< sal_uInt32
>( nFlags
, 0x10000000 ) )
1660 writeEmptyItem( "border-block" );
1661 IndentGuard
aIndGuard( out() );
1662 dumpHex
< sal_uInt16
>( "border-style", "XF-BORDERSTYLE" );
1663 dumpHex
< sal_uInt16
>( "border-color1", "XF-BORDERCOLOR1" );
1664 dumpHex
< sal_uInt32
>( "border-color2", "CFRULE-BORDERCOLOR2" );
1666 if( getFlag
< sal_uInt32
>( nFlags
, 0x20000000 ) )
1668 writeEmptyItem( "pattern-block" );
1669 IndentGuard
aIndGuard( out() );
1670 dumpHex
< sal_uInt32
>( "pattern", "CFRULE-FILLBLOCK" );
1672 if( getFlag
< sal_uInt32
>( nFlags
, 0x40000000 ) )
1674 writeEmptyItem( "protection-block" );
1675 IndentGuard
aIndGuard( out() );
1676 dumpHex
< sal_uInt16
>( "flags", "CFRULE-PROTECTION-FLAGS" );
1678 if( nFmla1Size
> 0 )
1679 getFormulaDumper().dumpNameFormula( "formula1", nFmla1Size
);
1680 if( nFmla2Size
> 0 )
1681 getFormulaDumper().dumpNameFormula( "formula2", nFmla2Size
);
1685 case BIFF_ID_CH3DDATAFORMAT
:
1686 dumpDec
< sal_uInt8
>( "base", "CH3DDATAFORMAT-BASE" );
1687 dumpDec
< sal_uInt8
>( "top", "CH3DDATAFORMAT-TOP" );
1690 case BIFF_ID_CHAREAFORMAT
:
1691 dumpColorABGR( "fg-color" );
1692 dumpColorABGR( "bg-color" );
1694 dumpHex
< sal_uInt16
>( "flags", "CHAREAFORMAT-FLAGS" );
1695 if( eBiff
== BIFF8
) dumpColorIdx( "fg-color-idx" );
1696 if( eBiff
== BIFF8
) dumpColorIdx( "bg-color-idx" );
1699 case BIFF_ID_CHAXESSET
:
1700 dumpDec
< sal_uInt16
>( "axesset-id", "CHAXESSET-ID" );
1701 dumpRect
< sal_Int32
>( "position", (eBiff
<= BIFF4
) ? "CONV-TWIP-TO-CM" : "" );
1704 case BIFF_ID_CHAXIS
:
1705 dumpDec
< sal_uInt16
>( "axis-type", "CHAXIS-TYPE" );
1706 if( eBiff
<= BIFF4
)
1707 dumpRect
< sal_Int32
>( "position", "CONV-TWIP-TO-CM" );
1713 dumpDec
< sal_Int16
>( "overlap", "CONV-PERCENT-NEG" );
1714 dumpDec
< sal_Int16
>( "gap", "CONV-PERCENT" );
1715 dumpHex
< sal_uInt16
>( "flags", "CHBAR-FLAGS" );
1718 case BIFF_ID_CHCHART
:
1719 dumpRect
< sal_Int32
>( "chart-frame", "CONV-PT1616-TO-CM", FORMATTYPE_FIX
);
1722 case BIFF_ID_CHCHART3D
:
1723 dumpDec
< sal_uInt16
>( "rotation-angle", "CONV-DEG" );
1724 dumpDec
< sal_Int16
>( "elevation-angle", "CONV-DEG" );
1725 dumpDec
< sal_uInt16
>( "eye-distance" );
1726 dumpDec
< sal_uInt16
>( "relative-height", "CONV-PERCENT" );
1727 dumpDec
< sal_uInt16
>( "relative-depth", "CONV-PERCENT" );
1728 dumpDec
< sal_uInt16
>( "depth-gap", "CONV-PERCENT" );
1729 dumpHex
< sal_uInt16
>( "flags", "CHCHART3D-FLAGS" );
1732 case BIFF_ID_CHTYPEGROUP
:
1734 dumpHex
< sal_uInt16
>( "flags", "CHTYPEGROUP-FLAGS" );
1735 if( eBiff
>= BIFF5
) dumpDec
< sal_uInt16
>( "group-idx" );
1738 case BIFF_ID_CHDATAFORMAT
:
1739 dumpDec
< sal_Int16
>( "point-idx", "CHDATAFORMAT-POINTIDX" );
1740 dumpDec
< sal_Int16
>( "series-idx" );
1741 if( eBiff
>= BIFF5
) dumpDec
< sal_Int16
>( "format-idx", "CHDATAFORMAT-FORMATIDX" );
1742 if( eBiff
>= BIFF5
) dumpHex
< sal_uInt16
>( "flags", "CHDATAFORMAT-FLAGS" );
1745 case BIFF_ID_CHESCHERFORMAT
:
1749 case BIFF_ID_CHFRAME
:
1750 dumpDec
< sal_uInt16
>( "format", "CHFRAME-FORMAT" );
1751 dumpHex
< sal_uInt16
>( "flags", "CHFRAME-FLAGS" );
1754 case BIFF_ID_CHFRAMEPOS
:
1755 dumpDec
< sal_uInt16
>( "object-type", "CHFRAMEPOS-OBJTYPE" );
1756 dumpDec
< sal_uInt16
>( "size-mode", "CHFRAMEPOS-SIZEMODE" );
1757 dumpRect
< sal_Int32
>( "position", (eBiff
<= BIFF4
) ? "CONV-TWIP-TO-CM" : "" );
1760 case BIFF_ID_CHFRBLOCKBEGIN
:
1761 dumpFrHeader( true, false );
1762 dumpDec
< sal_uInt16
>( "type", "CHFRBLOCK-TYPE" );
1763 dumpDec
< sal_uInt16
>( "context" );
1764 dumpDec
< sal_uInt16
>( "value-1" );
1765 dumpDec
< sal_uInt16
>( "value-2" );
1768 case BIFF_ID_CHFRBLOCKEND
:
1769 dumpFrHeader( true, false );
1770 dumpDec
< sal_uInt16
>( "type", "CHFRBLOCK-TYPE" );
1771 if( rStrm
.getRemaining() >= 6 )
1775 case BIFF_ID_CHFRINFO
:
1777 dumpFrHeader( true, false );
1778 dumpDec
< sal_uInt8
>( "creator", "CHFRINFO-APPVERSION" );
1779 dumpDec
< sal_uInt8
>( "writer", "CHFRINFO-APPVERSION" );
1780 sal_uInt16 nCount
= dumpDec
< sal_uInt16
>( "rec-range-count" );
1781 out().resetItemIndex();
1782 for( sal_uInt16 nIndex
= 0; !rStrm
.isEof() && (nIndex
< nCount
); ++nIndex
)
1783 dumpHexPair
< sal_uInt16
>( "#rec-range", '-' );
1787 case BIFF_ID_CHFRLABELPROPS
:
1788 dumpFrHeader( true, true );
1789 dumpHex
< sal_uInt16
>( "flags", "CHFRLABELPROPS-FLAGS" );
1790 dumpUniString( "separator", BIFF_STR_SMARTFLAGS
);
1793 case BIFF_ID_CHFRUNITPROPS
:
1794 dumpFrHeader( true, false );
1795 dumpDec
< sal_Int16
>( "preset", "CHFRUNITPROPS-PRESET" );
1796 dumpDec
< double >( "unit" );
1797 dumpHex
< sal_uInt16
>( "flags", "CHFRUNITPROPS-FLAGS" );
1800 case BIFF_ID_CHFRWRAPPER
:
1801 dumpFrHeader( true, false );
1804 case BIFF_ID_CHLABELRANGE
:
1805 dumpDec
< sal_uInt16
>( "axis-crossing" );
1806 dumpDec
< sal_uInt16
>( "label-frequency" );
1807 dumpDec
< sal_uInt16
>( "tick-frequency" );
1808 dumpHex
< sal_uInt16
>( "flags", "CHLABELRANGE-FLAGS" );
1811 case BIFF_ID_CHLABELRANGE2
:
1812 dumpDec
< sal_uInt16
>( "minimum-categ" );
1813 dumpDec
< sal_uInt16
>( "maximum-categ" );
1814 dumpDec
< sal_uInt16
>( "major-unit-value" );
1815 dumpDec
< sal_uInt16
>( "major-unit" );
1816 dumpDec
< sal_uInt16
>( "minor-unit-value" );
1817 dumpDec
< sal_uInt16
>( "minor-unit" );
1818 dumpDec
< sal_uInt16
>( "base-unit" );
1819 dumpDec
< sal_uInt16
>( "axis-crossing-date" );
1820 dumpHex
< sal_uInt16
>( "flags", "CHLABELRANGE2-FLAGS" );
1823 case BIFF_ID_CHLEGEND
:
1824 dumpRect
< sal_Int32
>( "position", (eBiff
<= BIFF4
) ? "CONV-TWIP-TO-CM" : "" );
1825 dumpDec
< sal_uInt8
>( "docked-pos", "CHLEGEND-DOCKPOS" );
1826 dumpDec
< sal_uInt8
>( "spacing", "CHLEGEND-SPACING" );
1827 dumpHex
< sal_uInt16
>( "flags", "CHLEGEND-FLAGS" );
1830 case BIFF_ID_CHLINEFORMAT
:
1832 dumpDec
< sal_uInt16
>( "line-type", "CHLINEFORMAT-LINETYPE" );
1833 dumpDec
< sal_Int16
>( "line-weight", "CHLINEFORMAT-LINEWEIGHT" );
1834 dumpHex
< sal_uInt16
>( "flags", "CHLINEFORMAT-FLAGS" );
1835 if( eBiff
== BIFF8
) dumpColorIdx();
1838 case BIFF_ID_CHMARKERFORMAT
:
1839 dumpColorABGR( "border-color" );
1840 dumpColorABGR( "fill-color" );
1841 dumpDec
< sal_uInt16
>( "marker-type", "CHMARKERFORMAT-TYPE" );
1842 dumpHex
< sal_uInt16
>( "flags", "CHMARKERFORMAT-FLAGS" );
1843 if( eBiff
== BIFF8
) dumpColorIdx( "border-color-idx" );
1844 if( eBiff
== BIFF8
) dumpColorIdx( "fill-color-idx" );
1845 if( eBiff
== BIFF8
) dumpDec
< sal_Int32
>( "marker-size", "CONV-TWIP-TO-PT" );
1848 case BIFF_ID_CHOBJECTLINK
:
1849 dumpDec
< sal_uInt16
>( "link-target", "CHOBJECTLINK-TARGET" );
1850 dumpDec
< sal_Int16
>( "series-idx" );
1851 dumpDec
< sal_Int16
>( "point-idx", "CHOBJECTLINK-POINT" );
1854 case BIFF_ID_CHPICFORMAT
:
1855 dumpDec
< sal_uInt16
>( "bitmap-mode", "CHPICFORMAT-BITMAP-MODE" );
1856 dumpDec
< sal_uInt16
>( "image-format", "CHPICFORMAT-IMAGE-FORMAT" );
1857 dumpHex
< sal_uInt16
>( "flags", "CHPICFORMAT-FLAGS" );
1858 dumpDec
< double >( "scaling-factor" );
1862 dumpDec
< sal_uInt16
>( "angle", "CONV-DEG" );
1863 if( eBiff
>= BIFF5
) dumpDec
< sal_uInt16
>( "hole-size" );
1864 if( eBiff
>= BIFF8
) dumpHex
< sal_uInt16
>( "flags", "CHPIE-FLAGS" );
1867 case BIFF_ID_CHPIVOTFLAGS
:
1868 dumpRepeatedRecId();
1870 dumpHex
< sal_uInt16
>( "flags", "CHPIVOTFLAGS-FLAGS" );
1873 case BIFF8_ID_CHPIVOTREF
:
1874 dumpRepeatedRecId();
1876 dumpUniString( "ref", BIFF_STR_8BITLENGTH
);
1879 case BIFF_ID_CHPLOTGROWTH
:
1880 dumpFix
< sal_Int32
>( "horizontal-growth" );
1881 dumpFix
< sal_Int32
>( "vertical-growth" );
1884 case BIFF_ID_CHPROPERTIES
:
1885 dumpHex
< sal_uInt16
>( "flags", "CHPROPERTIES-FLAGS" );
1886 dumpDec
< sal_uInt8
>( "empty-cells", "CHPROPERTIES-EMPTYCELLS" );
1889 case BIFF_ID_CHSCATTER
:
1890 if( eBiff
== BIFF8
) dumpDec
< sal_uInt16
>( "bubble-size", "CONV-PERCENT" );
1891 if( eBiff
== BIFF8
) dumpDec
< sal_uInt16
>( "size-type", "CHSCATTER-SIZETYPE" );
1892 if( eBiff
== BIFF8
) dumpHex
< sal_uInt16
>( "flags", "CHSCATTER-FLAGS" );
1895 case BIFF_ID_CHSERERRORBAR
:
1896 dumpDec
< sal_uInt8
>( "type", "CHSERERRORBAR-TYPE" );
1897 dumpDec
< sal_uInt8
>( "source", "CHSERERRORBAR-SOURCE" );
1898 dumpBool
< sal_uInt8
>( "draw-t-shape" );
1899 dumpBool
< sal_uInt8
>( "draw-line" );
1900 dumpDec
< double >( "value" );
1901 dumpDec
< sal_uInt16
>( "custom-count" );
1904 case BIFF_ID_CHSERIES
:
1905 dumpDec
< sal_uInt16
>( "categories-type", "CHSERIES-TYPE" );
1906 dumpDec
< sal_uInt16
>( "values-type", "CHSERIES-TYPE" );
1907 dumpDec
< sal_uInt16
>( "categories-count" );
1908 dumpDec
< sal_uInt16
>( "values-count" );
1909 if( eBiff
== BIFF8
) dumpDec
< sal_uInt16
>( "bubbles-type", "CHSERIES-TYPE" );
1910 if( eBiff
== BIFF8
) dumpDec
< sal_uInt16
>( "bubbles-count" );
1913 case BIFF_ID_CHSERTRENDLINE
:
1914 switch( dumpDec
< sal_uInt8
>( "type", "CHSERTRENDLINE-TYPE" ) )
1916 case 0: dumpDec
< sal_uInt8
>( "order" ); break;
1917 case 4: dumpDec
< sal_uInt8
>( "average-period" ); break;
1918 default: dumpUnused( 1 );
1920 dumpDec
< double >( "intercept" );
1921 dumpBool
< sal_uInt8
>( "show-equation" );
1922 dumpBool
< sal_uInt8
>( "show-r-sqrare" );
1923 dumpDec
< double >( "forecast-forward" );
1924 dumpDec
< double >( "forecast-backward" );
1927 case BIFF_ID_CHSOURCELINK
:
1928 dumpDec
< sal_uInt8
>( "link-target", "CHSOURCELINK-TARGET" );
1929 dumpDec
< sal_uInt8
>( "link-type", "CHSOURCELINK-TYPE" );
1930 dumpHex
< sal_uInt16
>( "flags", "CHSOURCELINK-FLAGS" );
1932 getFormulaDumper().dumpNameFormula();
1935 case BIFF_ID_CHSTRING
:
1936 dumpDec
< sal_uInt16
>( "text-type", "CHSTRING-TYPE" );
1937 dumpString( "text", BIFF_STR_8BITLENGTH
, BIFF_STR_8BITLENGTH
);
1940 case BIFF_ID_CHTEXT
:
1941 dumpDec
< sal_uInt8
>( "horizontal-align", "CHTEXT-HORALIGN" );
1942 dumpDec
< sal_uInt8
>( "vertical-align", "CHTEXT-VERALIGN" );
1943 dumpDec
< sal_uInt16
>( "fill-mode", "CHTEXT-FILLMODE" );
1945 dumpRect
< sal_Int32
>( "position", (eBiff
<= BIFF4
) ? "CONV-TWIP-TO-CM" : "" );
1946 dumpHex
< sal_uInt16
>( "flags", "CHTEXT-FLAGS" );
1947 if( eBiff
== BIFF8
) dumpColorIdx();
1948 if( eBiff
== BIFF8
) dumpDec
< sal_uInt16
>( "placement", "CHTEXT-PLACEMENT" );
1949 if( eBiff
== BIFF8
) dumpDec
< sal_uInt16
>( "rotation", "TEXTROTATION" );
1952 case BIFF_ID_CHTICK
:
1953 dumpDec
< sal_uInt8
>( "major-ticks", "CHTICK-TYPE" );
1954 dumpDec
< sal_uInt8
>( "minor-ticks", "CHTICK-TYPE" );
1955 dumpDec
< sal_uInt8
>( "label-position", "CHTICK-LABELPOS" );
1956 dumpDec
< sal_uInt8
>( "fill-mode", "CHTEXT-FILLMODE" );
1957 dumpColorABGR( "label-color" );
1959 dumpHex
< sal_uInt16
>( "flags", "CHTICK-FLAGS" );
1960 if( eBiff
== BIFF8
) dumpColorIdx( "label-color-idx" );
1961 if( eBiff
== BIFF8
) dumpDec
< sal_uInt16
>( "label-rotation", "TEXTROTATION" );
1964 case BIFF_ID_CHVALUERANGE
:
1965 dumpDec
< double >( "minimum" );
1966 dumpDec
< double >( "maximum" );
1967 dumpDec
< double >( "major-inc" );
1968 dumpDec
< double >( "minor-inc" );
1969 dumpDec
< double >( "axis-crossing" );
1970 dumpHex
< sal_uInt16
>( "flags", "CHVALUERANGE-FLAGS" );
1973 case BIFF_ID_CODENAME
:
1974 dumpUniString( "codename" );
1977 case BIFF_ID_CODEPAGE
:
1978 getBiffData().setTextEncoding( dumpCodePage() );
1979 mbHasCodePage
= true;
1982 case BIFF_ID_COLINFO
:
1984 dumpDec
< sal_uInt16
>( "col-width", "CONV-COLWIDTH" );
1985 dumpXfIdx( "xf-idx" );
1986 dumpHex
< sal_uInt16
>( "flags", "COLINFO-FLAGS" );
1990 case BIFF_ID_COLUMNDEFAULT
:
1991 out().resetItemIndex();
1992 for( sal_Int32 nCol
= 0, nCount
= dumpColRange(); nCol
< nCount
; ++nCol
)
1993 dumpXfIdx( "#xf-idx", true );
1997 case BIFF_ID_COLWIDTH
:
1998 dumpColRange( EMPTY_STRING
, false );
1999 dumpDec
< sal_uInt16
>( "col-width", "CONV-COLWIDTH" );
2003 if( (eBiff
== BIFF8
) && (getLastRecId() == BIFF_ID_OBJ
) )
2007 case BIFF_ID_COORDLIST
:
2009 out().resetItemIndex();
2010 TableGuard
aTabGuard( out(), 12, 10 );
2011 while( rStrm
.getRemaining() >= 4 )
2013 MultiItemsGuard
aMultiGuard( out() );
2014 writeEmptyItem( "#point" );
2015 dumpDec
< sal_uInt16
>( "x" );
2016 dumpDec
< sal_uInt16
>( "y" );
2023 sal_Int32 nCol2
= dumpColIndex( "last-col-idx", false );
2024 sal_Int32 nCol1
= dumpColIndex( "first-col-idx", false );
2025 sal_Int32 nRow
= dumpRowIndex( "row-idx" );
2026 TableGuard
aTabGuard( out(), 14, 17 );
2027 for( Address
aPos( nCol1
, nRow
); !rStrm
.isEof() && (aPos
.mnCol
<= nCol2
); ++aPos
.mnCol
)
2029 MultiItemsGuard
aMultiGuard( out() );
2030 writeAddressItem( "pos", aPos
);
2036 case BIFF_ID_DCONBINAME
:
2037 dumpDec
< sal_uInt8
>( "builtin-id", "DEFINEDNAME-BUILTINID" );
2039 dumpString( "source-link", BIFF_STR_8BITLENGTH
, BIFF_STR_SMARTFLAGS
);
2042 case BIFF_ID_DCONNAME
:
2043 dumpString( "source-name", BIFF_STR_8BITLENGTH
);
2044 dumpString( "source-link", BIFF_STR_8BITLENGTH
, BIFF_STR_SMARTFLAGS
);
2047 case BIFF_ID_DCONREF
:
2048 dumpRange( "source-range", false );
2049 dumpString( "source-link", BIFF_STR_8BITLENGTH
, BIFF_STR_SMARTFLAGS
);
2052 case BIFF2_ID_DATATABLE
:
2053 dumpRange( "table-range", false );
2054 dumpBoolean( "recalc-always" );
2055 dumpBoolean( "row-table" );
2056 dumpAddress( "ref1" );
2059 case BIFF3_ID_DATATABLE
:
2060 dumpRange( "table-range", false );
2061 dumpHex
< sal_uInt16
>( "flags", "DATATABLE-FLAGS" );
2062 dumpAddress( "ref1" );
2063 dumpAddress( "ref2" );
2066 case BIFF2_ID_DATATABLE2
:
2067 dumpRange( "table-range", false );
2068 dumpBoolean( "recalc-always" );
2070 dumpAddress( "ref1" );
2071 dumpAddress( "ref2" );
2074 case BIFF_ID_DATAVALIDATION
:
2076 dumpHex
< sal_uInt32
>( "flags", "DATAVALIDATION-FLAGS" );
2077 dumpUniString( "input-title" );
2078 dumpUniString( "error-title" );
2079 dumpUniString( "input-message" );
2080 dumpUniString( "error-message" );
2081 sal_uInt16 nFmla1Size
= getFormulaDumper().dumpFormulaSize( "formula1-size" );
2083 if( nFmla1Size
> 0 )
2084 getFormulaDumper().dumpNameFormula( "formula1", nFmla1Size
);
2085 sal_uInt16 nFmla2Size
= getFormulaDumper().dumpFormulaSize( "formula2-size" );
2087 if( nFmla2Size
> 0 )
2088 getFormulaDumper().dumpNameFormula( "formula2", nFmla2Size
);
2093 case BIFF_ID_DATAVALIDATIONS
:
2094 dumpHex
< sal_uInt16
>( "flags", "DATAVALIDATIONS-FLAGS" );
2095 dumpDec
< sal_Int32
>( "input-box-pos-x" );
2096 dumpDec
< sal_Int32
>( "input-box-pos-y" );
2097 dumpDec
< sal_Int32
>( "dropdown-object-id" );
2098 dumpDec
< sal_Int32
>( "dval-entry-count" );
2101 case BIFF2_ID_DEFINEDNAME
:
2102 case BIFF3_ID_DEFINEDNAME
:
2104 rtl_TextEncoding eTextEnc
= getBiffData().getTextEncoding();
2105 dumpHex
< sal_uInt16
, sal_uInt8
>( eBiff
!= BIFF2
, "flags", "DEFINEDNAME-FLAGS" );
2106 if( eBiff
== BIFF2
) dumpDec
< sal_uInt8
>( "macro-type", "DEFINEDNAME-MACROTYPE-BIFF2" );
2107 dumpChar( "accelerator", eTextEnc
);
2108 sal_uInt8 nNameLen
= dumpDec
< sal_uInt8
>( "name-len" );
2109 sal_uInt16 nFmlaSize
= getFormulaDumper().dumpFormulaSize();
2110 if( eBiff
>= BIFF5
)
2112 bool bBiff8
= eBiff
== BIFF8
;
2113 if( bBiff8
) dumpUnused( 2 ); else dumpDec
< sal_uInt16
>( "externsheet-idx", "DEFINEDNAME-SHEETIDX" );
2114 dumpDec
< sal_uInt16
>( "sheet-idx", "DEFINEDNAME-SHEETIDX" );
2115 sal_uInt8 nMenuLen
= dumpDec
< sal_uInt8
>( "menu-text-len" );
2116 sal_uInt8 nDescrLen
= dumpDec
< sal_uInt8
>( "description-text-len" );
2117 sal_uInt8 nHelpLen
= dumpDec
< sal_uInt8
>( "help-text-len" );
2118 sal_uInt8 nStatusLen
= dumpDec
< sal_uInt8
>( "statusbar-text-len" );
2119 writeStringItem( "name", bBiff8
? rStrm
.readUniStringBody( nNameLen
, true ) : rStrm
.readCharArrayUC( nNameLen
, eTextEnc
, true ) );
2120 getFormulaDumper().dumpNameFormula( EMPTY_STRING
, nFmlaSize
);
2121 if( nMenuLen
> 0 ) writeStringItem( "menu-text", bBiff8
? rStrm
.readUniStringBody( nMenuLen
, true ) : rStrm
.readCharArrayUC( nMenuLen
, eTextEnc
, true ) );
2122 if( nDescrLen
> 0 ) writeStringItem( "description-text", bBiff8
? rStrm
.readUniStringBody( nDescrLen
, true ) : rStrm
.readCharArrayUC( nDescrLen
, eTextEnc
, true ) );
2123 if( nHelpLen
> 0 ) writeStringItem( "help-text", bBiff8
? rStrm
.readUniStringBody( nHelpLen
, true ) : rStrm
.readCharArrayUC( nHelpLen
, eTextEnc
, true ) );
2124 if( nStatusLen
> 0 ) writeStringItem( "statusbar-text", bBiff8
? rStrm
.readUniStringBody( nStatusLen
, true ) : rStrm
.readCharArrayUC( nStatusLen
, eTextEnc
, true ) );
2128 writeStringItem( "name", rStrm
.readCharArrayUC( nNameLen
, eTextEnc
, true ) );
2129 getFormulaDumper().dumpNameFormula( EMPTY_STRING
, nFmlaSize
);
2130 if( eBiff
== BIFF2
) getFormulaDumper().dumpFormulaSize();
2135 case BIFF3_ID_DEFROWHEIGHT
:
2136 dumpHex
< sal_uInt16
>( "flags", "DEFROWHEIGHT-FLAGS" );
2137 dumpDec
< sal_uInt16
>( "row-height", "CONV-TWIP-TO-PT" );
2140 case BIFF2_ID_DIMENSION
:
2141 case BIFF3_ID_DIMENSION
:
2142 dumpRange( "used-area", true, (nRecId
== BIFF3_ID_DIMENSION
) && (eBiff
== BIFF8
) );
2143 if( nRecId
== BIFF3_ID_DIMENSION
) dumpUnused( 2 );
2146 case BIFF_ID_EXTERNALBOOK
:
2148 sal_uInt16 nCount
= dumpDec
< sal_uInt16
>( "sheet-count" );
2149 if( rStrm
.getRemaining() == 2 )
2150 dumpHex
< sal_uInt16
>( "special-key", "EXTERNALBOOK-KEY" );
2153 dumpString( "workbook-url" );
2154 out().resetItemIndex();
2155 for( sal_uInt16 nSheet
= 0; !rStrm
.isEof() && (nSheet
< nCount
); ++nSheet
)
2156 dumpString( "#sheet-name" );
2161 case BIFF2_ID_EXTERNALNAME
:
2162 case BIFF3_ID_EXTERNALNAME
:
2164 sal_uInt16 nFlags
= (eBiff
>= BIFF3
) ? dumpHex
< sal_uInt16
>( "flags", "EXTERNALNAME-FLAGS" ) : 0;
2165 if( eBiff
>= BIFF5
)
2167 if( getFlag
< sal_uInt16
>( nFlags
, 0x0010 ) )
2169 dumpHex
< sal_uInt32
>( "storage-id" );
2173 dumpDec
< sal_uInt16
>( "externsheet-idx" );
2177 OUString aName
= dumpString( "name", BIFF_STR_8BITLENGTH
, BIFF_STR_8BITLENGTH
);
2178 if( (aName
.getLength() > 0) && (aName
[ 0 ] == 1) && (rStrm
.getRemaining() >= 2) )
2179 getFormulaDumper().dumpNameFormula();
2183 case BIFF_ID_EXTERNSHEET
:
2184 if( eBiff
== BIFF8
)
2186 sal_uInt16 nCount
= dumpDec
< sal_uInt16
>( "ref-count" );
2187 TableGuard
aTabGuard( out(), 10, 17, 24 );
2188 out().resetItemIndex();
2189 for( sal_uInt16 nRefId
= 0; !rStrm
.isEof() && (nRefId
< nCount
); ++nRefId
)
2191 MultiItemsGuard
aMultiGuard( out() );
2192 writeEmptyItem( "#ref" );
2193 dumpDec
< sal_uInt16
>( "extbook-idx" );
2194 dumpDec
< sal_Int16
>( "first-sheet", "EXTERNSHEET-IDX" );
2195 dumpDec
< sal_Int16
>( "last-sheet", "EXTERNSHEET-IDX" );
2200 OStringBuffer
aUrl( rStrm
.readByteString( false, true ) );
2201 if( (aUrl
.getLength() > 0) && (aUrl
[ 0 ] == '\x03') )
2202 aUrl
.append( static_cast< sal_Char
>( rStrm
.readuInt8() ) );
2203 writeStringItem( "encoded-url", OStringToOUString( aUrl
.makeStringAndClear(), getBiffData().getTextEncoding() ) );
2207 case BIFF_ID_FILEPASS
:
2209 rStrm
.enableDecoder( false );
2210 if( eBiff
== BIFF8
)
2212 switch( dumpDec
< sal_uInt16
>( "type", "FILEPASS-TYPE" ) )
2215 dumpHex
< sal_uInt16
>( "key" );
2216 dumpHex
< sal_uInt16
>( "verifier" );
2220 sal_uInt16 nMajor
= dumpDec
< sal_uInt16
>( "major-version", "FILEPASS-MAJOR" );
2221 dumpDec
< sal_uInt16
>( "minor-version" );
2225 dumpArray( "salt", 16 );
2226 dumpArray( "verifier", 16 );
2227 dumpArray( "verifier-hash", 16 );
2236 dumpHex
< sal_uInt16
>( "key" );
2237 dumpHex
< sal_uInt16
>( "verifier" );
2239 rStrm
.seekToStart();
2240 BiffDecoderRef xDecoder
= BiffCodecHelper::implReadFilePass( rStrm
, eBiff
);
2241 if( xDecoder
.get() )
2242 cfg().requestPassword( *xDecoder
);
2243 setBinaryOnlyMode( !xDecoder
|| !xDecoder
->isValid() );
2247 case BIFF_ID_FILESHARING
:
2248 dumpBool
< sal_uInt16
>( "recommend-read-only" );
2249 dumpHex
< sal_uInt16
>( "password-hash" );
2250 dumpString( "password-creator", BIFF_STR_8BITLENGTH
, BIFF_STR_SMARTFLAGS
);
2258 case BIFF2_ID_FORMAT
:
2259 case BIFF4_ID_FORMAT
:
2263 case BIFF2_ID_FORMULA
:
2264 case BIFF3_ID_FORMULA
:
2265 case BIFF4_ID_FORMULA
:
2266 dumpCellHeader( eBiff
== BIFF2
);
2267 dumpFormulaResult();
2268 dumpHex
< sal_uInt16
, sal_uInt8
>( eBiff
!= BIFF2
, "flags", "FORMULA-FLAGS" );
2269 if( eBiff
>= BIFF5
) dumpUnused( 4 );
2270 getFormulaDumper().dumpCellFormula();
2273 case BIFF_ID_FOOTER
:
2274 if( rStrm
.getRemaining() > 0 )
2275 dumpString( "footer", BIFF_STR_8BITLENGTH
);
2278 case BIFF_ID_HEADER
:
2279 if( rStrm
.getRemaining() > 0 )
2280 dumpString( "header", BIFF_STR_8BITLENGTH
);
2283 case BIFF_ID_HYPERLINK
:
2285 if( cfg().getStringOption( dumpGuid( "guid" ), OUString() ).equalsAscii( "StdHlink" ) )
2286 StdHlinkObject( *this ).dump();
2289 case BIFF3_ID_IMGDATA
:
2290 case BIFF8_ID_IMGDATA
:
2292 sal_uInt16 nFormat
= dumpDec
< sal_uInt16
>( "image-format", "IMGDATA-FORMAT" );
2293 dumpDec
< sal_uInt16
>( "environment", "IMGDATA-ENV" );
2294 dumpDec
< sal_uInt32
>( "data-size" );
2297 writeEmptyItem( "bitmap-header" );
2298 IndentGuard
aIndGuard( out() );
2299 if( dumpDec
< sal_uInt32
>( "header-size" ) == 12 )
2301 dumpDec
< sal_Int16
>( "width" );
2302 dumpDec
< sal_Int16
>( "height" );
2303 dumpDec
< sal_Int16
>( "planes" );
2304 dumpDec
< sal_Int16
>( "bit-count" );
2310 case BIFF2_ID_INTEGER
:
2311 dumpCellHeader( true );
2312 dumpDec
< sal_uInt16
>( "value" );
2315 case BIFF2_ID_LABEL
:
2316 case BIFF3_ID_LABEL
:
2318 bool bBiff2
= nRecId
== BIFF2_ID_LABEL
;
2319 sal_uInt16 nXfIdx
= dumpCellHeader( bBiff2
);
2320 rtl_TextEncoding eOldTextEnc
= getBiffData().getTextEncoding();
2321 getBiffData().setTextEncoding( getBiffData().getXfEncoding( nXfIdx
) );
2322 dumpString( "value", bBiff2
? BIFF_STR_8BITLENGTH
: BIFF_STR_DEFAULT
);
2323 getBiffData().setTextEncoding( eOldTextEnc
);
2327 case BIFF_ID_LABELRANGES
:
2328 dumpRangeList( "row-ranges" );
2329 dumpRangeList( "col-ranges" );
2332 case BIFF_ID_LABELSST
:
2334 dumpDec
< sal_Int32
>( "sst-idx" );
2337 case BIFF_ID_MSODRAWING
:
2338 case BIFF_ID_MSODRAWINGGROUP
:
2339 case BIFF_ID_MSODRAWINGSEL
:
2344 case BIFF_ID_MULTBLANK
:
2346 Address aPos
= dumpAddress();
2348 TableGuard
aTabGuard( out(), 12 );
2349 for( ; rStrm
.getRemaining() >= 4; ++aPos
.mnCol
)
2351 MultiItemsGuard
aMultiGuard( out() );
2352 writeAddressItem( "pos", aPos
);
2356 dumpColIndex( "last-col-idx" );
2360 case BIFF_ID_MULTRK
:
2362 Address aPos
= dumpAddress();
2364 TableGuard
aTabGuard( out(), 12, 12 );
2365 for( ; rStrm
.getRemaining() >= 8; ++aPos
.mnCol
)
2367 MultiItemsGuard
aMultiGuard( out() );
2368 writeAddressItem( "pos", aPos
);
2373 dumpColIndex( "last-col-idx" );
2378 dumpAddress( "anchor-cell" );
2379 if( eBiff
== BIFF8
)
2381 dumpHex
< sal_uInt16
>( "flags", "NOTE-FLAGS" );
2382 dumpDec
< sal_uInt16
>( "obj-id" );
2386 sal_uInt16 nTextLen
= ::std::min( dumpDec
< sal_uInt16
>( "text-len" ), static_cast< sal_uInt16
>( rStrm
.getRemaining() ) );
2387 writeStringItem( "note-text", rStrm
.readCharArrayUC( nTextLen
, getBiffData().getTextEncoding(), true ) );
2391 case BIFF2_ID_NUMBER
:
2392 case BIFF3_ID_NUMBER
:
2393 dumpCellHeader( nRecId
== BIFF2_ID_NUMBER
);
2394 dumpDec
< double >( "value" );
2401 case BIFF_ID_PAGESETUP
:
2402 dumpDec
< sal_uInt16
>( "paper-size", "PAGESETUP-PAPERSIZE" );
2403 dumpDec
< sal_uInt16
>( "scaling", "CONV-PERCENT" );
2404 dumpDec
< sal_uInt16
>( "first-page" );
2405 dumpDec
< sal_uInt16
>( "scale-to-width", "PAGESETUP-SCALETOPAGES" );
2406 dumpDec
< sal_uInt16
>( "scale-to-height", "PAGESETUP-SCALETOPAGES" );
2407 dumpHex
< sal_uInt16
>( "flags", "PAGESETUP-FLAGS" );
2408 if( eBiff
>= BIFF5
)
2410 dumpDec
< sal_uInt16
>( "horizontal-res", "PAGESETUP-DPI" );
2411 dumpDec
< sal_uInt16
>( "vertical-res", "PAGESETUP-DPI" );
2412 dumpDec
< double >( "header-margin", "CONV-INCH-TO-CM" );
2413 dumpDec
< double >( "footer-margin", "CONV-INCH-TO-CM" );
2414 dumpDec
< sal_uInt16
>( "copies" );
2419 dumpDec
< sal_uInt16
>( "x-pos", "CONV-TWIP-TO-CM" );
2420 dumpDec
< sal_uInt16
>( "y-pos", "CONV-TWIP-TO-CM" );
2421 dumpAddress( "first-visible-cell" );
2422 dumpDec
< sal_uInt8
>( "active-pane", "PANE-ID" );
2425 case BIFF_ID_PCITEM_STRING
:
2426 dumpString( "value" );
2429 case BIFF_ID_PHONETICPR
:
2430 dumpDec
< sal_uInt16
>( "font-id", "FONTNAMES" );
2431 dumpHex
< sal_uInt16
>( "flags", "PHONETICPR-FLAGS" );
2432 dumpRangeList( "show-phonetic" );
2435 case BIFF_ID_PROJEXTSHEET
:
2436 dumpDec
< sal_uInt8
>( "sheet-type", "PROJEXTSHEET-TYPE" );
2438 dumpByteString( "sheet-link", BIFF_STR_8BITLENGTH
);
2441 case BIFF_ID_PTDATAFIELD
:
2442 dumpDec
< sal_Int16
>( "field" );
2443 dumpDec
< sal_uInt16
>( "subtotal", "PTDATAFIELD-SUBTOTAL" );
2444 dumpDec
< sal_uInt16
>( "show-data-as", "PTDATAFIELD-SHOWDATAAS" );
2445 dumpDec
< sal_Int16
>( "base-field" );
2446 dumpDec
< sal_Int16
>( "base-item", "PTDATAFIELD-BASEITEM" );
2448 dumpPivotString( "name" );
2451 case BIFF_ID_PTDEFINITION
:
2453 dumpRange( "output-range" );
2454 dumpRowIndex( "first-header-row-idx" );
2455 dumpAddress( "first-data-pos" );
2456 dumpDec
< sal_uInt16
>( "cache-idx" );
2458 dumpDec
< sal_uInt16
>( "default-data-axis", "PTFIELD-AXISTYPE" );
2459 dumpDec
< sal_Int16
>( "default-data-pos", "PTDEFINITION-DATAFIELD-POS" );
2460 dumpDec
< sal_uInt16
>( "field-count" );
2461 mnPTRowFields
= dumpDec
< sal_uInt16
>( "row-field-count" );
2462 mnPTColFields
= dumpDec
< sal_uInt16
>( "column-field-count" );
2463 dumpDec
< sal_uInt16
>( "page-field-count" );
2464 dumpDec
< sal_uInt16
>( "data-field-count" );
2465 dumpDec
< sal_uInt16
>( "data-row-count" );
2466 dumpDec
< sal_uInt16
>( "data-column-count" );
2467 dumpHex
< sal_uInt16
>( "flags", "PTDEFINITION-FLAGS" );
2468 dumpDec
< sal_uInt16
>( "auto-format-idx" );
2469 sal_uInt16 nTabNameLen
= dumpDec
< sal_uInt16
>( "table-name-len" );
2470 sal_uInt16 nDataNameLen
= dumpDec
< sal_uInt16
>( "data-name-len" );
2471 dumpPivotString( "table-name", nTabNameLen
);
2472 dumpPivotString( "data-name", nDataNameLen
);
2473 mnPTRowColItemsIdx
= 0;
2477 case BIFF_ID_PTDEFINITION2
:
2479 dumpDec
< sal_uInt16
>( "format-rec-count" );
2480 sal_uInt16 nErrCaptLen
= dumpDec
< sal_uInt16
>( "error-caption-len" );
2481 sal_uInt16 nMissCaptLen
= dumpDec
< sal_uInt16
>( "missing-caption-len" );
2482 sal_uInt16 nTagLen
= dumpDec
< sal_uInt16
>( "tag-len" );
2483 dumpDec
< sal_uInt16
>( "select-rec-count" );
2484 dumpDec
< sal_uInt16
>( "page-rows" );
2485 dumpDec
< sal_uInt16
>( "page-cols" );
2486 dumpHex
< sal_uInt32
>( "flags", "PTDEFINITION2-FLAGS" );
2487 sal_uInt16 nPageStyleLen
= dumpDec
< sal_uInt16
>( "page-field-style-len" );
2488 sal_uInt16 nTabStyleLen
= dumpDec
< sal_uInt16
>( "pivot-table-style-len" );
2489 sal_uInt16 nVacStyleLen
= dumpDec
< sal_uInt16
>( "vacated-style-len" );
2490 dumpPivotString( "error-caption", nErrCaptLen
);
2491 dumpPivotString( "missing-caption", nMissCaptLen
);
2492 dumpPivotString( "tag", nTagLen
);
2493 dumpPivotString( "page-field-style", nPageStyleLen
);
2494 dumpPivotString( "pivot-table-style", nTabStyleLen
);
2495 dumpPivotString( "vacated-style", nVacStyleLen
);
2499 case BIFF_ID_PTFIELD
:
2500 dumpDec
< sal_uInt16
>( "axis-type", "PTFIELD-AXISTYPE" );
2501 dumpDec
< sal_uInt16
>( "subtotal-count" );
2502 dumpHex
< sal_uInt16
>( "subtotals", "PTFIELD-SUBTOTALS" );
2503 dumpDec
< sal_uInt16
>( "item-count" );
2504 dumpPivotString( "field-name" );
2507 case BIFF_ID_PTFIELD2
:
2508 dumpHex
< sal_uInt32
>( "flags", "PTFIELD2-FLAGS" );
2509 dumpDec
< sal_Int16
>( "autosort-basefield-idx" );
2510 dumpDec
< sal_Int16
>( "autoshow-basefield-idx" );
2512 if( rStrm
.getRemaining() >= 2 )
2514 sal_uInt16 nFuncNameLen
= dumpDec
< sal_uInt16
>( "subtotal-func-name-len" );
2516 dumpPivotString( "subtotal-func-name", nFuncNameLen
);
2520 case BIFF_ID_PTFITEM
:
2521 dumpDec
< sal_uInt16
>( "item-type", "PTFITEM-ITEMTYPE" );
2522 dumpHex
< sal_uInt16
>( "flags", "PTFITEM-FLAGS" );
2523 dumpDec
< sal_Int16
>( "cache-idx", "PTFITEM-CACHEIDX" );
2524 dumpPivotString( "item-name" );
2527 case BIFF_ID_PTPAGEFIELDS
:
2529 out().resetItemIndex();
2530 TableGuard
aTabGuard( out(), 17, 17, 17 );
2531 while( rStrm
.getRemaining() >= 6 )
2533 writeEmptyItem( "#page-field" );
2534 MultiItemsGuard
aMultiGuard( out() );
2535 IndentGuard
aIndGuard( out() );
2536 dumpDec
< sal_Int16
>( "base-field" );
2537 dumpDec
< sal_Int16
>( "item", "PTPAGEFIELDS-ITEM" );
2538 dumpDec
< sal_uInt16
>( "dropdown-obj-id" );
2543 case BIFF_ID_PTROWCOLFIELDS
:
2544 out().resetItemIndex();
2545 for( sal_Int64 nIdx
= 0, nCount
= rStrm
.getRemaining() / 2; nIdx
< nCount
; ++nIdx
)
2546 dumpDec
< sal_Int16
>( "#field-idx" );
2549 case BIFF_ID_PTROWCOLITEMS
:
2550 if( mnPTRowColItemsIdx
< 2 )
2552 sal_uInt16 nCount
= (mnPTRowColItemsIdx
== 0) ? mnPTRowFields
: mnPTColFields
;
2553 sal_Int64 nLineSize
= 8 + 2 * nCount
;
2554 out().resetItemIndex();
2555 while( rStrm
.getRemaining() >= nLineSize
)
2557 writeEmptyItem( "#line-data" );
2558 IndentGuard
aIndGuard( out() );
2559 MultiItemsGuard
aMultiGuard( out() );
2560 dumpDec
< sal_uInt16
>( "ident-count" );
2561 dumpDec
< sal_uInt16
>( "item-type", "PTROWCOLITEMS-ITEMTYPE" );
2562 dumpDec
< sal_uInt16
>( "used-count" );
2563 dumpHex
< sal_uInt16
>( "flags", "PTROWCOLITEMS-FLAGS" );
2564 OUStringBuffer aItemList
;
2565 for( sal_uInt16 nIdx
= 0; nIdx
< nCount
; ++nIdx
)
2566 StringHelper::appendToken( aItemList
, in().readInt16() );
2567 writeInfoItem( "item-idxs", aItemList
.makeStringAndClear() );
2569 ++mnPTRowColItemsIdx
;
2581 dumpColIndex( "first-used-col-idx" );
2582 dumpColIndex( "first-free-col-idx" );
2583 dumpHex
< sal_uInt16
>( "height", "ROW-HEIGHT" );
2585 bool bHasDefXf
= dumpBool
< sal_uInt8
>( "custom-format" );
2586 dumpDec
< sal_uInt16
>( "cell-offset" );
2587 if( bHasDefXf
) dumpXfIdx( "custom-format", true );
2588 if( bHasDefXf
) dumpXfIdx( "custom-xf-idx", false );
2594 dumpColIndex( "first-used-col-idx" );
2595 dumpColIndex( "first-free-col-idx" );
2596 dumpHex
< sal_uInt16
>( "height", "ROW-HEIGHT" );
2597 dumpUnused( (eBiff
<= BIFF4
) ? 2 : 4 );
2598 if( eBiff
<= BIFF4
) dumpDec
< sal_uInt16
>( "cell-offset" );
2599 dumpHex
< sal_uInt32
>( "flags", "ROW-FLAGS" );
2602 case BIFF_ID_RSTRING
:
2604 sal_uInt16 nXfIdx
= dumpCellHeader();
2605 rtl_TextEncoding eOldTextEnc
= getBiffData().getTextEncoding();
2606 getBiffData().setTextEncoding( getBiffData().getXfEncoding( nXfIdx
) );
2607 dumpString( "value" );
2608 getBiffData().setTextEncoding( eOldTextEnc
);
2609 FontPortionModelList aPortions
;
2610 aPortions
.importPortions( rStrm
, eBiff
== BIFF8
);
2611 writeFontPortions( aPortions
);
2615 case BIFF_ID_SCENARIO
:
2617 sal_uInt16 nCellCount
= dumpDec
< sal_uInt16
>( "cell-count" );
2618 // two bytes instead of flag field
2619 dumpBoolean( "locked" );
2620 dumpBoolean( "hidden" );
2621 sal_uInt16 nNameLen
= dumpDec
< sal_uInt8
>( "name-len" );
2622 sal_uInt16 nCommentLen
= dumpDec
< sal_uInt8
>( "comment-len" );
2623 sal_uInt16 nUserLen
= dumpDec
< sal_uInt8
>( "user-len" );
2624 writeStringItem( "name", rStrm
.readUniStringBody( nNameLen
, true ) );
2625 if( nUserLen
> 0 ) dumpUniString( "user" ); // repeated string length
2626 if( nCommentLen
> 0 ) dumpUniString( "comment" ); // repeated string length
2627 out().resetItemIndex();
2628 for( sal_uInt16 nCell
= 0; !rStrm
.isEof() && (nCell
< nCellCount
); ++nCell
)
2629 dumpAddress( "#pos" );
2630 out().resetItemIndex();
2631 for( sal_uInt16 nCell
= 0; !rStrm
.isEof() && (nCell
< nCellCount
); ++nCell
)
2632 dumpString( "#value" );
2633 dumpUnused( 2 * nCellCount
);
2637 case BIFF_ID_SCENARIOS
:
2638 dumpDec
< sal_uInt16
>( "count" );
2639 dumpDec
< sal_uInt16
>( "selected" );
2640 dumpDec
< sal_uInt16
>( "shown" );
2641 dumpRangeList( "result-cells" );
2646 sal_uInt16 nNum
= dumpDec
< sal_uInt16
>( "numerator" );
2647 sal_uInt16 nDen
= dumpDec
< sal_uInt16
>( "denominator" );
2648 if( nDen
> 0 ) writeDecItem( "current-zoom", static_cast< sal_uInt16
>( nNum
* 100 / nDen
), "CONV-PERCENT" );
2652 case BIFF_ID_SCREENTIP
:
2653 dumpFrHeader( false, true );
2654 dumpNullUnicodeArray( "tooltip" );
2657 case BIFF_ID_SELECTION
:
2658 dumpDec
< sal_uInt8
>( "pane", "PANE-ID" );
2659 dumpAddress( "active-cell" );
2660 dumpDec
< sal_uInt16
>( "list-idx" );
2661 dumpRangeList( "selection", false );
2664 case BIFF_ID_SHAREDFMLA
:
2665 dumpRange( "formula-range", false );
2667 dumpDec
< sal_uInt8
>( "cell-count" );
2668 getFormulaDumper().dumpCellFormula();
2672 if( eBiff
>= BIFF5
)
2674 rStrm
.enableDecoder( false );
2675 dumpHex
< sal_uInt32
>( "sheet-stream-pos", "CONV-DEC" );
2676 rStrm
.enableDecoder( true );
2677 dumpDec
< sal_uInt8
>( "sheet-state", "SHEET-STATE" );
2678 dumpDec
< sal_uInt8
>( "sheet-type", "SHEET-TYPE" );
2680 dumpString( "sheet-name", BIFF_STR_8BITLENGTH
, BIFF_STR_8BITLENGTH
);
2683 case BIFF_ID_SHEETHEADER
:
2684 dumpHex
< sal_uInt32
>( "substream-size", "CONV-DEC" );
2685 dumpByteString( "sheet-name", BIFF_STR_8BITLENGTH
);
2688 case BIFF_ID_SHEETPROTECTION
:
2689 dumpFrHeader( true, true );
2691 dumpHex
< sal_uInt16
>( "allowed-flags", "SHEETPROTECTION-FLAGS" );
2696 dumpDec
< sal_uInt32
>( "string-cell-count" );
2697 dumpDec
< sal_uInt32
>( "sst-size" );
2698 out().resetItemIndex();
2699 while( !rStrm
.isEof() && (rStrm
.getRemaining() >= 3) )
2700 dumpUniString( "#entry" );
2703 case BIFF2_ID_STRING
:
2704 case BIFF3_ID_STRING
:
2705 dumpString( "result", ((nRecId
== BIFF2_ID_STRING
) && (eBiff
<= BIFF4
)) ? BIFF_STR_8BITLENGTH
: BIFF_STR_DEFAULT
);
2710 sal_uInt16 nFlags
= dumpHex
< sal_uInt16
>( "flags", "STYLE-FLAGS" );
2711 if( getFlag( nFlags
, BIFF_STYLE_BUILTIN
) )
2713 dumpDec
< sal_Int8
>( "builtin-idx", "STYLE-BUILTIN" );
2714 dumpDec
< sal_Int8
>( "outline-level" );
2717 dumpString( "style-name", BIFF_STR_8BITLENGTH
);
2721 case BIFF_ID_STYLEEXT
:
2722 dumpFrHeader( true, true );
2723 dumpHex
< sal_uInt8
>( "flags", "STYLEEXT-FLAGS" );
2724 dumpDec
< sal_uInt8
>( "category", "STYLEEXT-CATEGORY" );
2725 dumpDec
< sal_Int8
>( "builtin-idx", "STYLEEXT-BUILTIN" );
2726 dumpDec
< sal_Int8
>( "outline-level" );
2727 dumpUnicodeArray( "style-name", rStrm
.readuInt16() );
2731 if( eBiff
== BIFF8
)
2733 dumpHex
< sal_uInt16
>( "flags", "SXEXT-FLAGS" );
2734 dumpDec
< sal_uInt16
>( "param-string-count" );
2735 dumpDec
< sal_uInt16
>( "sql-statement-string-count" );
2736 dumpDec
< sal_uInt16
>( "webquery-postmethod-string-count" );
2737 dumpDec
< sal_uInt16
>( "server-pagefields-string-count" );
2738 dumpDec
< sal_uInt16
>( "odbc-connection-string-count" );
2743 dumpHex
< sal_uInt16
>( "flags", "TXO-FLAGS" );
2744 dumpDec
< sal_uInt16
>( "orientation", "TEXTORIENTATION" );
2745 dumpHex
< sal_uInt16
>( "button-flags", "OBJ-BUTTON-FLAGS" );
2746 dumpUnicode( "accelerator" );
2747 dumpUnicode( "fareast-accelerator" );
2748 dumpDec
< sal_uInt16
>( "text-len" );
2749 dumpDec
< sal_uInt16
>( "format-run-size" );
2753 case BIFF_ID_WINDOW1
:
2754 dumpDec
< sal_uInt16
>( "window-x", "CONV-TWIP-TO-CM" );
2755 dumpDec
< sal_uInt16
>( "window-y", "CONV-TWIP-TO-CM" );
2756 dumpDec
< sal_uInt16
>( "window-width", "CONV-TWIP-TO-CM" );
2757 dumpDec
< sal_uInt16
>( "window-height", "CONV-TWIP-TO-CM" );
2758 if( eBiff
<= BIFF4
)
2760 dumpBool
< sal_uInt8
>( "hidden" );
2764 dumpHex
< sal_uInt16
>( "flags", "WINDOW1-FLAGS" );
2765 dumpDec
< sal_uInt16
>( "active-tab" );
2766 dumpDec
< sal_uInt16
>( "first-visible-tab" );
2767 dumpDec
< sal_uInt16
>( "selected-tabs" );
2768 dumpDec
< sal_uInt16
>( "tabbar-ratio", "WINDOW1-TABBARRATIO" );
2772 case BIFF2_ID_WINDOW2
:
2773 dumpBool
< sal_uInt8
>( "show-formulas" );
2774 dumpBool
< sal_uInt8
>( "show-gridlines" );
2775 dumpBool
< sal_uInt8
>( "show-headings" );
2776 dumpBool
< sal_uInt8
>( "frozen-panes" );
2777 dumpBool
< sal_uInt8
>( "show-zeros" );
2778 dumpAddress( "first-visible-cell" );
2779 dumpBool
< sal_uInt8
>( "auto-grid-color" );
2780 dumpColorABGR( "grid-color" );
2783 case BIFF3_ID_WINDOW2
:
2784 dumpHex
< sal_uInt16
>( "flags", "WINDOW2-FLAGS" );
2785 dumpAddress( "first-visible-cell" );
2786 if( eBiff
== BIFF8
)
2788 dumpColorIdx( "grid-color-idx" );
2790 if( rStrm
.getRemaining() >= 8 )
2792 dumpDec
< sal_uInt16
>( "pagebreak-zoom", "CONV-PERCENT" );
2793 dumpDec
< sal_uInt16
>( "normal-zoom", "CONV-PERCENT" );
2798 dumpColorABGR( "grid-color" );
2801 case BIFF_ID_WRITEACCESS
:
2802 dumpString( "user-name", BIFF_STR_8BITLENGTH
);
2806 dumpDec
< sal_uInt16
>( "crn-count" );
2807 if( eBiff
== BIFF8
) dumpDec
< sal_Int16
>( "sheet-idx" );
2819 void WorkbookStreamObject::initializePerSheet()
2821 getBiffData().initializePerSheet();
2822 mxFontNames
= cfg().createNameList
< ConstList
>( "FONTNAMES" );
2823 mxFontNames
->setName( 0, createFontName( CREATE_OUSTRING( "Arial" ), 200, false, false ) );
2824 mxFormats
= cfg().createNameList
< ConstList
>( "FORMATS" );
2825 mxFormats
->includeList( cfg().getNameList( "BUILTIN-FORMATS" ) );
2827 mbHasCodePage
= false;
2830 OUString
WorkbookStreamObject::createFontName( const OUString
& rName
, sal_uInt16 nHeight
, bool bBold
, bool bItalic
) const
2832 OUStringBuffer
aName( rName
);
2833 StringHelper::enclose( aName
, OOX_DUMP_STRQUOTE
);
2834 StringHelper::appendToken( aName
, cfg().getName( "CONV-TWIP-TO-PT", nHeight
), ',' );
2836 StringHelper::appendToken( aName
, CREATE_OUSTRING( "bold" ), ',' );
2838 StringHelper::appendToken( aName
, CREATE_OUSTRING( "italic" ), ',' );
2839 return aName
.makeStringAndClear();
2842 sal_uInt16
WorkbookStreamObject::dumpPatternIdx( const String
& rName
, bool b16Bit
)
2844 return dumpDec
< sal_uInt16
, sal_uInt8
>( b16Bit
, rName( "fill-pattern" ), mxFillPatterns
);
2847 sal_uInt16
WorkbookStreamObject::dumpColorIdx( const String
& rName
, bool b16Bit
)
2849 return dumpDec
< sal_uInt16
, sal_uInt8
>( b16Bit
, rName( "color-idx" ), mxColors
);
2852 sal_uInt16
WorkbookStreamObject::dumpFontIdx( const String
& rName
, bool b16Bit
)
2854 return dumpDec
< sal_uInt16
, sal_uInt8
>( b16Bit
, rName( "font-idx" ), "FONTNAMES" );
2857 sal_uInt16
WorkbookStreamObject::dumpFormatIdx( const String
& rName
)
2859 return dumpDec
< sal_uInt16
, sal_uInt8
>( getBiff() >= BIFF5
, rName( "fmt-idx" ), "FORMATS" );
2862 sal_uInt16
WorkbookStreamObject::dumpXfIdx( const String
& rName
, bool bBiff2Style
)
2864 String aName
= rName( "xf-idx" );
2865 sal_uInt16 nXfIdx
= 0;
2868 dumpHex
< sal_uInt8
>( aName
, "CELL-XFINDEX" );
2869 dumpHex
< sal_uInt8
>( "fmt-font-idx", "CELL-XFFORMAT" );
2870 dumpHex
< sal_uInt8
>( "style", "CELL-XFSTYLE" );
2873 nXfIdx
= dumpDec
< sal_uInt16
>( aName
);
2877 OUString
WorkbookStreamObject::dumpPivotString( const String
& rName
, sal_uInt16 nStrLen
)
2880 if( nStrLen
!= BIFF_PT_NOSTRING
)
2882 aString
= (getBiff() == BIFF8
) ?
2883 getBiffStream().readUniStringBody( nStrLen
) :
2884 getBiffStream().readCharArrayUC( nStrLen
, getBiffData().getTextEncoding() );
2885 writeStringItem( rName
, aString
);
2890 OUString
WorkbookStreamObject::dumpPivotString( const String
& rName
)
2892 sal_uInt16 nStrLen
= dumpDec
< sal_uInt16
>( "string-len", "PIVOT-NAMELEN" );
2893 return dumpPivotString( rName
, nStrLen
);
2896 sal_uInt16
WorkbookStreamObject::dumpCellHeader( bool bBiff2Style
)
2899 return dumpXfIdx( EMPTY_STRING
, bBiff2Style
);
2902 void WorkbookStreamObject::dumpBoolErr()
2904 MultiItemsGuard
aMultiGuard( out() );
2905 sal_uInt8 nValue
= dumpHex
< sal_uInt8
>( "value" );
2906 bool bErrCode
= dumpBool
< sal_uInt8
>( "is-errorcode" );
2908 writeErrorCodeItem( "errorcode", nValue
);
2910 writeBooleanItem( "boolean", nValue
);
2913 void WorkbookStreamObject::dumpFontRec()
2915 sal_uInt16 nFontId
= getBiffData().getFontCount();
2916 out().resetItemIndex( nFontId
);
2917 writeEmptyItem( "#font" );
2918 sal_uInt16 nHeight
= dumpDec
< sal_uInt16
>( "height", "CONV-TWIP-TO-PT" );
2919 sal_uInt16 nFlags
= dumpHex
< sal_uInt16
>( "flags", "FONT-FLAGS" );
2920 bool bBold
= getFlag( nFlags
, BIFF_FONTFLAG_BOLD
);
2921 bool bItalic
= getFlag( nFlags
, BIFF_FONTFLAG_ITALIC
);
2922 rtl_TextEncoding eFontEnc
= RTL_TEXTENCODING_DONTKNOW
;
2923 if( getBiff() >= BIFF3
)
2925 if( getBiff() >= BIFF5
)
2927 bBold
= dumpDec
< sal_uInt16
>( "weight", "FONT-WEIGHT" ) > 450;
2928 dumpDec
< sal_uInt16
>( "escapement", "FONT-ESCAPEMENT" );
2929 dumpDec
< sal_uInt8
>( "underline", "FONT-UNDERLINE" );
2930 dumpDec
< sal_uInt8
>( "family", "FONT-FAMILY" );
2931 sal_uInt8 nCharSet
= dumpDec
< sal_uInt8
>( "charset", "CHARSET" );
2932 eFontEnc
= rtl_getTextEncodingFromWindowsCharset( nCharSet
);
2935 OUString aName
= dumpString( "name", BIFF_STR_8BITLENGTH
, BIFF_STR_8BITLENGTH
);
2937 // append font data to vector
2938 mxFontNames
->setName( nFontId
, createFontName( aName
, nHeight
, bBold
, bItalic
) );
2940 // store font encoding
2941 getBiffData().appendFontEncoding( eFontEnc
);
2943 // set font encoding as default text encoding in case of missing CODEPAGE record
2944 if( !mbHasCodePage
&& (nFontId
== 0) )
2945 getBiffData().setTextEncoding( eFontEnc
);
2948 void WorkbookStreamObject::dumpFormatRec()
2950 sal_uInt16 nFormatIdx
= 0;
2955 nFormatIdx
= mnFormatIdx
++;
2956 out().resetItemIndex( nFormatIdx
);
2957 writeEmptyItem( "#fmt" );
2960 nFormatIdx
= mnFormatIdx
++;
2961 out().resetItemIndex( nFormatIdx
);
2962 writeEmptyItem( "#fmt" );
2967 getBiffStream() >> nFormatIdx
;
2968 out().resetItemIndex( nFormatIdx
);
2969 writeEmptyItem( "#fmt" );
2970 writeDecItem( "fmt-idx", nFormatIdx
);
2972 case BIFF_UNKNOWN
: break;
2974 OUString aFormat
= dumpString( "format", BIFF_STR_8BITLENGTH
);
2975 mxFormats
->setName( nFormatIdx
, aFormat
);
2978 void WorkbookStreamObject::dumpXfRec()
2980 sal_uInt16 nXfId
= getBiffData().getXfCount();
2981 out().resetItemIndex( nXfId
);
2982 writeEmptyItem( "#xf" );
2983 sal_uInt16 nFontId
= dumpFontIdx( EMPTY_STRING
, getBiff() >= BIFF5
);
2988 dumpHex
< sal_uInt8
>( "type-flags", "XF-TYPEFLAGS" );
2989 dumpHex
< sal_uInt8
>( "style-flags", "XF-STYLEFLAGS" );
2993 dumpHex
< sal_uInt8
>( "type-flags", "XF-TYPEFLAGS" );
2994 dumpHex
< sal_uInt8
>( "used-attributes", "XF-USEDATTRIBS-FLAGS" );
2995 dumpHex
< sal_uInt16
>( "alignment", "XF-ALIGNMENT" );
2996 dumpHex
< sal_uInt16
>( "fill-style", "XF-FILL" );
2997 dumpHex
< sal_uInt32
>( "border-style", "XF-BORDER" );
3001 dumpHex
< sal_uInt16
>( "type-flags", "XF-TYPEFLAGS" );
3002 dumpHex
< sal_uInt8
>( "alignment", "XF-ALIGNMENT" );
3003 dumpHex
< sal_uInt8
>( "used-attributes", "XF-USEDATTRIBS-FLAGS" );
3004 dumpHex
< sal_uInt16
>( "fill-style", "XF-FILL" );
3005 dumpHex
< sal_uInt32
>( "border-style", "XF-BORDER" );
3009 dumpHex
< sal_uInt16
>( "type-flags", "XF-TYPEFLAGS" );
3010 dumpHex
< sal_uInt8
>( "alignment", "XF-ALIGNMENT" );
3011 dumpHex
< sal_uInt8
>( "orientation", "XF-ORIENTATTRIBS" );
3012 dumpHex
< sal_uInt32
>( "fill-style", "XF-FILL" );
3013 dumpHex
< sal_uInt32
>( "border-style", "XF-BORDER" );
3017 dumpHex
< sal_uInt16
>( "type-flags", "XF-TYPEFLAGS" );
3018 dumpHex
< sal_uInt8
>( "alignment", "XF-ALIGNMENT" );
3019 dumpDec
< sal_uInt8
>( "rotation", "TEXTROTATION" );
3020 dumpHex
< sal_uInt8
>( "text-flags", "XF-TEXTFLAGS" );
3021 dumpHex
< sal_uInt8
>( "used-attributes", "XF-USEDATTRIBS-FLAGS" );
3022 dumpHex
< sal_uInt16
>( "border-style", "XF-BORDERSTYLE" );
3023 dumpHex
< sal_uInt16
>( "border-color1", "XF-BORDERCOLOR1" );
3024 dumpHex
< sal_uInt32
>( "border-color2", "XF-BORDERCOLOR2" );
3025 dumpHex
< sal_uInt16
>( "fill-color", "XF-FILLCOLOR" );
3027 case BIFF_UNKNOWN
: break;
3029 getBiffData().appendXfFontId( nFontId
);
3032 void WorkbookStreamObject::dumpObjRec()
3046 // #i61786# OBJ records without DFF stream are in BIFF5 format
3047 if( mbHasDff
) dumpObjRecBiff8(); else dumpObjRecBiff5();
3053 void WorkbookStreamObject::dumpObjRecBiff3()
3055 dumpDec
< sal_uInt32
>( "obj-count" );
3056 sal_uInt16 nObjType
= dumpDec
< sal_uInt16
>( "obj-type", "OBJ-TYPE" );
3057 dumpDec
< sal_uInt16
>( "obj-id" );
3058 dumpHex
< sal_uInt16
>( "flags", "OBJ-FLAGS" );
3059 dumpDffClientRect();
3060 sal_uInt16 nMacroSize
= dumpDec
< sal_uInt16
>( "macro-size" );
3062 sal_uInt16 nTextLen
= 0, nFormatSize
= 0, nLinkSize
= 0;
3065 case BIFF_OBJTYPE_GROUP
:
3067 dumpDec
< sal_uInt16
>( "next-ungrouped-id" );
3069 dumpObjRecString( "macro", nMacroSize
, true );
3071 case BIFF_OBJTYPE_LINE
:
3072 dumpObjRecLineData();
3073 dumpHex
< sal_uInt16
>( "line-end", "OBJ-LINEENDS" );
3074 dumpDec
< sal_uInt8
>( "line-direction", "OBJ-LINEDIR" );
3076 dumpObjRecString( "macro", nMacroSize
, true );
3078 case BIFF_OBJTYPE_RECTANGLE
:
3079 case BIFF_OBJTYPE_OVAL
:
3080 dumpObjRecRectData();
3081 dumpObjRecString( "macro", nMacroSize
, true );
3083 case BIFF_OBJTYPE_ARC
:
3084 dumpObjRecFillData();
3085 dumpObjRecLineData();
3086 dumpDec
< sal_uInt8
>( "quadrant", "OBJ-ARC-QUADRANT" );
3088 dumpObjRecString( "macro", nMacroSize
, true );
3090 case BIFF_OBJTYPE_CHART
:
3091 dumpObjRecRectData();
3093 dumpObjRecString( "macro", nMacroSize
, true );
3095 case BIFF_OBJTYPE_TEXT
:
3096 case BIFF_OBJTYPE_BUTTON
:
3097 dumpObjRecRectData();
3098 dumpObjRecTextDataBiff3( nTextLen
, nFormatSize
);
3099 dumpObjRecString( "macro", nMacroSize
, true );
3100 dumpObjRecString( "text", nTextLen
, false );
3101 dumpObjRecTextFmt( nFormatSize
);
3103 case BIFF_OBJTYPE_PICTURE
:
3104 dumpObjRecRectData();
3105 dumpDec
< sal_Int16
>( "image-format", "IMGDATA-FORMAT" );
3107 nLinkSize
= dumpDec
< sal_uInt16
>( "pic-link-size" );
3109 dumpHex
< sal_uInt16
>( "flags", "OBJ-PICTURE-FLAGS" );
3110 dumpObjRecString( "macro", nMacroSize
, true );
3111 dumpObjRecPictFmla( nLinkSize
);
3116 void WorkbookStreamObject::dumpObjRecBiff4()
3118 dumpDec
< sal_uInt32
>( "obj-count" );
3119 sal_uInt16 nObjType
= dumpDec
< sal_uInt16
>( "obj-type", "OBJ-TYPE" );
3120 dumpDec
< sal_uInt16
>( "obj-id" );
3121 dumpHex
< sal_uInt16
>( "flags", "OBJ-FLAGS" );
3122 dumpDffClientRect();
3123 sal_uInt16 nMacroSize
= dumpDec
< sal_uInt16
>( "macro-size" );
3125 sal_uInt16 nTextLen
= 0, nFormatSize
= 0, nLinkSize
= 0;
3128 case BIFF_OBJTYPE_GROUP
:
3130 dumpDec
< sal_uInt16
>( "next-ungrouped-id" );
3132 dumpObjRecFmla( "macro", nMacroSize
);
3134 case BIFF_OBJTYPE_LINE
:
3135 dumpObjRecLineData();
3136 dumpHex
< sal_uInt16
>( "line-end", "OBJ-LINEENDS" );
3137 dumpDec
< sal_uInt8
>( "line-direction", "OBJ-LINEDIR" );
3139 dumpObjRecFmla( "macro", nMacroSize
);
3141 case BIFF_OBJTYPE_RECTANGLE
:
3142 case BIFF_OBJTYPE_OVAL
:
3143 dumpObjRecRectData();
3144 dumpObjRecFmla( "macro", nMacroSize
);
3146 case BIFF_OBJTYPE_ARC
:
3147 dumpObjRecFillData();
3148 dumpObjRecLineData();
3149 dumpDec
< sal_uInt8
>( "quadrant", "OBJ-ARC-QUADRANT" );
3151 dumpObjRecFmla( "macro", nMacroSize
);
3153 case BIFF_OBJTYPE_CHART
:
3154 dumpObjRecRectData();
3156 dumpObjRecFmla( "macro", nMacroSize
);
3158 case BIFF_OBJTYPE_TEXT
:
3159 case BIFF_OBJTYPE_BUTTON
:
3160 dumpObjRecRectData();
3161 dumpObjRecTextDataBiff3( nTextLen
, nFormatSize
);
3162 dumpObjRecFmla( "macro", nMacroSize
);
3163 dumpObjRecString( "text", nTextLen
, false );
3164 dumpObjRecTextFmt( nFormatSize
);
3166 case BIFF_OBJTYPE_PICTURE
:
3167 dumpObjRecRectData();
3168 dumpDec
< sal_Int16
>( "image-format", "IMGDATA-FORMAT" );
3170 nLinkSize
= dumpDec
< sal_uInt16
>( "pic-link-size" );
3172 dumpHex
< sal_uInt16
>( "flags", "OBJ-PICTURE-FLAGS" );
3173 dumpObjRecFmla( "macro", nMacroSize
);
3174 dumpObjRecPictFmla( nLinkSize
);
3176 case BIFF_OBJTYPE_POLYGON
:
3177 dumpObjRecRectData();
3178 dumpHex
< sal_uInt16
>( "flags", "OBJ-POLYGON-FLAGS" );
3180 dumpDec
< sal_uInt16
>( "point-count" );
3182 dumpObjRecFmla( "macro", nMacroSize
);
3187 void WorkbookStreamObject::dumpObjRecBiff5()
3189 BiffInputStream
& rStrm
= getBiffStream();
3190 dumpDec
< sal_uInt32
>( "obj-count" );
3191 sal_uInt16 nObjType
= dumpDec
< sal_uInt16
>( "obj-type", "OBJ-TYPE" );
3192 dumpDec
< sal_uInt16
>( "obj-id" );
3193 dumpHex
< sal_uInt16
>( "flags", "OBJ-FLAGS" );
3194 dumpDffClientRect();
3195 sal_uInt16 nMacroSize
= dumpDec
< sal_uInt16
>( "macro-size" );
3197 sal_uInt16 nNameLen
= dumpDec
< sal_uInt16
>( "name-len" );
3199 sal_uInt16 nTextLen
= 0, nFormatSize
= 0, nLinkSize
= 0;
3202 case BIFF_OBJTYPE_GROUP
:
3204 dumpDec
< sal_uInt16
>( "next-ungrouped-id" );
3206 dumpObjRecString( "obj-name", nNameLen
, true );
3207 dumpObjRecFmla( "macro", nMacroSize
);
3209 case BIFF_OBJTYPE_LINE
:
3210 dumpObjRecLineData();
3211 dumpHex
< sal_uInt16
>( "line-end", "OBJ-LINEENDS" );
3212 dumpDec
< sal_uInt8
>( "line-direction", "OBJ-LINEDIR" );
3214 dumpObjRecString( "obj-name", nNameLen
, true );
3215 dumpObjRecFmla( "macro", nMacroSize
);
3217 case BIFF_OBJTYPE_RECTANGLE
:
3218 case BIFF_OBJTYPE_OVAL
:
3219 dumpObjRecRectData();
3220 dumpObjRecString( "obj-name", nNameLen
, true );
3221 dumpObjRecFmla( "macro", nMacroSize
);
3223 case BIFF_OBJTYPE_ARC
:
3224 dumpObjRecFillData();
3225 dumpObjRecLineData();
3226 dumpDec
< sal_uInt8
>( "quadrant", "OBJ-ARC-QUADRANT" );
3228 dumpObjRecString( "obj-name", nNameLen
, true );
3229 dumpObjRecFmla( "macro", nMacroSize
);
3231 case BIFF_OBJTYPE_CHART
:
3232 dumpObjRecRectData();
3233 dumpHex
< sal_uInt16
>( "chart-flags", "OBJ-CHART-FLAGS" );
3235 dumpObjRecString( "obj-name", nNameLen
, true );
3236 dumpObjRecFmla( "macro", nMacroSize
);
3238 case BIFF_OBJTYPE_TEXT
:
3239 case BIFF_OBJTYPE_BUTTON
:
3240 case BIFF_OBJTYPE_LABEL
:
3241 case BIFF_OBJTYPE_DIALOG
:
3242 dumpObjRecRectData();
3243 dumpObjRecTextDataBiff5( nTextLen
, nFormatSize
, nLinkSize
);
3244 dumpObjRecString( "obj-name", nNameLen
, true );
3245 dumpObjRecFmla( "macro", nMacroSize
);
3246 dumpObjRecString( "text", nTextLen
, false );
3247 dumpObjRecFmla( "text-link", nLinkSize
);
3248 dumpObjRecTextFmt( nFormatSize
);
3250 case BIFF_OBJTYPE_PICTURE
:
3251 dumpObjRecRectData();
3252 dumpDec
< sal_Int16
>( "image-format", "IMGDATA-FORMAT" );
3254 nLinkSize
= dumpDec
< sal_uInt16
>( "pic-link-size" );
3256 dumpHex
< sal_uInt16
>( "flags", "OBJ-PICTURE-FLAGS" );
3258 dumpObjRecString( "obj-name", nNameLen
, true );
3259 dumpObjRecFmla( "macro", nMacroSize
);
3260 dumpObjRecPictFmla( nLinkSize
);
3261 if( rStrm
.getRemaining() >= 4 )
3262 dumpHex
< sal_uInt32
>( "ole-storage-id" );
3264 case BIFF_OBJTYPE_POLYGON
:
3265 dumpObjRecRectData();
3266 dumpHex
< sal_uInt16
>( "flags", "OBJ-POLYGON-FLAGS" );
3268 dumpDec
< sal_uInt16
>( "point-count" );
3270 dumpObjRecString( "obj-name", nNameLen
, true );
3271 dumpObjRecFmla( "macro", nMacroSize
);
3273 case BIFF_OBJTYPE_CHECKBOX
:
3274 dumpObjRecRectData();
3276 dumpHex
< sal_uInt16
>( "flags", "OBJ-TEXT-FLAGS" );
3278 dumpObjRecString( "obj-name", nNameLen
, true );
3279 dumpObjRecFmla( "macro", dumpDec
< sal_uInt16
>( "macro-size" ) );
3280 dumpObjRecFmla( "cell-link", dumpDec
< sal_uInt16
>( "cell-link-size" ) );
3281 dumpObjRecString( "text", dumpDec
< sal_uInt16
>( "text-len" ), false );
3282 dumpObjRecCblsData();
3284 case BIFF_OBJTYPE_OPTIONBUTTON
:
3285 dumpObjRecRectData();
3287 dumpHex
< sal_uInt16
>( "flags", "OBJ-TEXT-FLAGS" );
3289 dumpObjRecString( "obj-name", nNameLen
, true );
3290 dumpObjRecFmla( "macro", dumpDec
< sal_uInt16
>( "macro-size" ) );
3291 dumpObjRecFmla( "cell-link", dumpDec
< sal_uInt16
>( "cell-link-size" ) );
3292 dumpObjRecString( "text", dumpDec
< sal_uInt16
>( "text-len" ), false );
3293 dumpObjRecCblsData();
3294 dumpObjRecRboData();
3296 case BIFF_OBJTYPE_EDIT
:
3297 dumpObjRecRectData();
3299 dumpHex
< sal_uInt16
>( "flags", "OBJ-TEXT-FLAGS" );
3301 dumpObjRecString( "obj-name", nNameLen
, true );
3302 dumpObjRecFmla( "macro", dumpDec
< sal_uInt16
>( "macro-size" ) );
3303 dumpObjRecString( "text", dumpDec
< sal_uInt16
>( "text-len" ), false );
3304 dumpObjRecEdoData();
3306 case BIFF_OBJTYPE_SPIN
:
3307 case BIFF_OBJTYPE_SCROLLBAR
:
3308 dumpObjRecRectData();
3309 dumpObjRecSbsData();
3310 dumpObjRecString( "obj-name", nNameLen
, true );
3311 dumpObjRecFmla( "macro", dumpDec
< sal_uInt16
>( "macro-size" ) );
3312 dumpObjRecFmla( "cell-link", dumpDec
< sal_uInt16
>( "cell-link-size" ) );
3314 case BIFF_OBJTYPE_LISTBOX
:
3315 dumpObjRecRectData();
3316 dumpObjRecSbsData();
3318 dumpFontIdx( "font-idx" );
3320 dumpObjRecString( "obj-name", nNameLen
, true );
3321 dumpObjRecFmla( "macro", dumpDec
< sal_uInt16
>( "macro-size" ) );
3322 dumpObjRecFmla( "cell-link", dumpDec
< sal_uInt16
>( "cell-link-size" ) );
3323 dumpObjRecLbsData();
3325 case BIFF_OBJTYPE_GROUPBOX
:
3326 dumpObjRecRectData();
3328 dumpHex
< sal_uInt16
>( "flags", "OBJ-TEXT-FLAGS" );
3330 dumpObjRecString( "obj-name", nNameLen
, true );
3331 dumpObjRecFmla( "macro", dumpDec
< sal_uInt16
>( "macro-size" ) );
3332 dumpObjRecString( "text", dumpDec
< sal_uInt16
>( "text-len" ), false );
3333 dumpObjRecGboData();
3335 case BIFF_OBJTYPE_DROPDOWN
:
3336 dumpObjRecRectData();
3337 dumpObjRecSbsData();
3339 dumpFontIdx( "font-idx" );
3341 dumpDec
< sal_uInt16
>( "bounding-left" );
3342 dumpDec
< sal_uInt16
>( "bounding-top" );
3343 dumpDec
< sal_uInt16
>( "bounding-right" );
3344 dumpDec
< sal_uInt16
>( "bounding-bottom" );
3346 dumpObjRecString( "obj-name", nNameLen
, true );
3347 dumpObjRecFmla( "macro", dumpDec
< sal_uInt16
>( "macro-size" ) );
3348 dumpObjRecFmla( "cell-link", dumpDec
< sal_uInt16
>( "cell-link-size" ) );
3349 dumpObjRecLbsData();
3350 dumpDec
< sal_uInt16
>( "type", "OBJ-DROPDOWN-TYPE" );
3351 dumpDec
< sal_uInt16
>( "line-count" );
3352 dumpDec
< sal_uInt16
>( "min-list-width" );
3353 dumpObjRecString( "text", dumpDec
< sal_uInt16
>( "text-len" ), false );
3358 void WorkbookStreamObject::dumpObjRecBiff8()
3360 Output
& rOut
= out();
3361 BiffInputStream
& rStrm
= getBiffStream();
3362 NameListRef xRecNames
= cfg().getNameList( "OBJ-RECNAMES" );
3363 sal_uInt16 nObjType
= 0xFFFF;
3364 bool bControl
= false;
3365 bool bCtlsStrm
= false;
3367 while( bLoop
&& (rStrm
.getRemaining() >= 4) )
3370 sal_uInt16 nSubRecId
, nSubRecSize
;
3372 MultiItemsGuard
aMultiGuard( rOut
);
3373 writeEmptyItem( "OBJREC" );
3374 writeHexItem( "pos", static_cast< sal_uInt32
>( rStrm
.tell() ) );
3375 rStrm
>> nSubRecId
>> nSubRecSize
;
3376 writeHexItem( "size", nSubRecSize
);
3377 writeHexItem( "id", nSubRecId
, xRecNames
);
3380 sal_Int64 nSubRecStart
= rStrm
.tell();
3381 // sometimes the last subrecord has an invalid length
3382 sal_Int64 nRealRecSize
= ::std::min
< sal_Int64
>( nSubRecSize
, rStrm
.getRemaining() );
3383 sal_Int64 nSubRecEnd
= nSubRecStart
+ nRealRecSize
;
3385 IndentGuard
aIndGuard( rOut
);
3388 case BIFF_ID_OBJMACRO
:
3389 dumpObjRecFmlaRaw();
3392 dumpDec
< sal_Int16
>( "clipboard-format", "IMGDATA-FORMAT" );
3394 case BIFF_ID_OBJFLAGS
:
3396 sal_uInt16 nFlags
= dumpHex
< sal_uInt16
>( "flags", "OBJFLAGS-FLAGS" );
3397 bControl
= getFlag( nFlags
, BIFF_OBJFLAGS_CONTROL
);
3398 bCtlsStrm
= getFlag( nFlags
, BIFF_OBJFLAGS_CTLSSTREAM
);
3401 case BIFF_ID_OBJPICTFMLA
:
3403 dumpObjRecPictFmla( dumpDec
< sal_uInt16
>( "pic-link-size" ) );
3404 if( rStrm
.tell() + 4 <= nSubRecEnd
)
3406 if( bControl
&& bCtlsStrm
)
3409 dumpHex
< sal_uInt32
>( "ole-storage-id" );
3411 if( bControl
&& (rStrm
.tell() + 8 <= nSubRecEnd
) )
3413 sal_uInt32 nKeySize
= dumpDec
< sal_uInt32
>( "licence-key-size" );
3416 IndentGuard
aIndGuard2( rOut
);
3417 sal_Int64 nKeyEnd
= rStrm
.tell() + nKeySize
;
3418 dumpArray( "licence-key", static_cast< sal_Int32
>( nKeySize
) );
3419 rStrm
.seek( nKeyEnd
);
3421 dumpObjRecFmla( "cell-link", dumpDec
< sal_uInt16
>( "cell-link-size" ) );
3422 dumpObjRecFmla( "source-range", dumpDec
< sal_uInt16
>( "source-range-size" ) );
3426 case BIFF_ID_OBJCBLS
:
3427 dumpDec
< sal_uInt16
>( "state", "OBJ-CHECKBOX-STATE" );
3429 dumpUnicode( "accelerator" );
3430 dumpUnicode( "fareast-accelerator" );
3431 dumpHex
< sal_uInt16
>( "checkbox-flags", "OBJ-CHECKBOX-FLAGS" );
3433 case BIFF_ID_OBJRBO
:
3435 dumpBool
< sal_uInt16
>( "first-in-group" );
3437 case BIFF_ID_OBJSBS
:
3438 dumpObjRecSbsData();
3440 case BIFF_ID_OBJGBODATA
:
3441 dumpObjRecGboData();
3443 case BIFF_ID_OBJEDODATA
:
3444 dumpObjRecEdoData();
3446 case BIFF_ID_OBJRBODATA
:
3447 dumpObjRecRboData();
3449 case BIFF_ID_OBJCBLSDATA
:
3450 dumpObjRecCblsData();
3452 case BIFF_ID_OBJLBSDATA
:
3453 dumpObjRecLbsData();
3454 if( nObjType
== BIFF_OBJTYPE_DROPDOWN
)
3456 dumpHex
< sal_uInt16
>( "dropdown-flags", "OBJ-DROPDOWN-FLAGS" );
3457 dumpDec
< sal_uInt16
>( "line-count" );
3458 dumpDec
< sal_uInt16
>( "min-list-width" );
3459 dumpObjRecString( "text", dumpDec
< sal_uInt16
>( "text-len" ), false );
3462 case BIFF_ID_OBJCBLSFMLA
:
3463 case BIFF_ID_OBJSBSFMLA
:
3464 dumpObjRecFmlaRaw();
3466 case BIFF_ID_OBJCMO
:
3467 nObjType
= dumpDec
< sal_uInt16
>( "type", "OBJ-TYPE" );
3468 dumpDec
< sal_uInt16
>( "id" );
3469 dumpHex
< sal_uInt16
>( "flags", "OBJCMO-FLAGS" );
3473 // remaining undumped data
3474 if( !rStrm
.isEof() && (rStrm
.tell() == nSubRecStart
) )
3475 dumpRawBinary( nRealRecSize
, false );
3477 dumpRemainingTo( nSubRecEnd
);
3481 void WorkbookStreamObject::dumpObjRecLineData()
3483 dumpColorIdx( "line-color-idx", false );
3484 dumpDec
< sal_uInt8
>( "line-type", "OBJ-LINETYPE" );
3485 dumpDec
< sal_uInt8
>( "line-weight", "OBJ-LINEWEIGHT" );
3486 dumpHex
< sal_uInt8
>( "line-flags", "OBJ-AUTO-FLAGS" );
3489 void WorkbookStreamObject::dumpObjRecFillData()
3491 dumpColorIdx( "back-color-idx", false );
3492 dumpColorIdx( "patt-color-idx", false );
3493 dumpPatternIdx( EMPTY_STRING
, false );
3494 dumpHex
< sal_uInt8
>( "area-flags", "OBJ-AUTO-FLAGS" );
3497 void WorkbookStreamObject::dumpObjRecRectData()
3499 dumpObjRecFillData();
3500 dumpObjRecLineData();
3501 dumpHex
< sal_uInt16
>( "frame-style", "OBJ-FRAMESTYLE-FLAGS" );
3504 void WorkbookStreamObject::dumpObjRecTextDataBiff3( sal_uInt16
& ornTextLen
, sal_uInt16
& ornFormatSize
)
3506 ornTextLen
= dumpDec
< sal_uInt16
>( "text-len" );
3508 ornFormatSize
= dumpDec
< sal_uInt16
>( "format-run-size" );
3509 dumpFontIdx( "default-font-idx" );
3511 dumpHex
< sal_uInt16
>( "flags", "OBJ-TEXT-FLAGS" );
3512 dumpDec
< sal_uInt16
>( "orientation", "TEXTORIENTATION" );
3516 void WorkbookStreamObject::dumpObjRecTextDataBiff5( sal_uInt16
& ornTextLen
, sal_uInt16
& ornFormatSize
, sal_uInt16
& ornLinkSize
)
3518 ornTextLen
= dumpDec
< sal_uInt16
>( "text-len" );
3520 ornFormatSize
= dumpDec
< sal_uInt16
>( "format-run-size" );
3521 dumpFontIdx( "default-font-idx" );
3523 dumpHex
< sal_uInt16
>( "flags", "OBJ-TEXT-FLAGS" );
3524 dumpDec
< sal_uInt16
>( "orientation", "TEXTORIENTATION" );
3526 ornLinkSize
= dumpDec
< sal_uInt16
>( "link-size" );
3528 dumpHex
< sal_uInt16
>( "button-flags", "OBJ-BUTTON-FLAGS" );
3529 dumpUnicode( "accelerator" );
3530 dumpUnicode( "fareast-accelerator" );
3533 void WorkbookStreamObject::dumpObjRecSbsData()
3536 dumpDec
< sal_uInt16
>( "value" );
3537 dumpDec
< sal_uInt16
>( "min" );
3538 dumpDec
< sal_uInt16
>( "max" );
3539 dumpDec
< sal_uInt16
>( "step" );
3540 dumpDec
< sal_uInt16
>( "page-step" );
3541 dumpBool
< sal_uInt16
>( "horizontal" );
3542 dumpDec
< sal_uInt16
>( "thumb-width" );
3543 dumpHex
< sal_uInt16
>( "scrollbar-flags", "OBJ-SCROLLBAR-FLAGS" );
3546 void WorkbookStreamObject::dumpObjRecGboData()
3548 dumpUnicode( "accelerator" );
3549 dumpUnicode( "fareast-accelerator" );
3550 dumpHex
< sal_uInt16
>( "groupbox-flags", "OBJ-GROUPBOX-FLAGS" );
3553 void WorkbookStreamObject::dumpObjRecEdoData()
3555 dumpDec
< sal_uInt16
>( "type", "OBJ-EDIT-TYPE" );
3556 dumpBool
< sal_uInt16
>( "multiline" );
3557 dumpBool
< sal_uInt16
>( "scrollbar" );
3558 dumpDec
< sal_uInt16
>( "listbox-obj-id" );
3561 void WorkbookStreamObject::dumpObjRecRboData()
3563 dumpDec
< sal_uInt16
>( "next-in-group" );
3564 dumpBool
< sal_uInt16
>( "first-in-group" );
3567 void WorkbookStreamObject::dumpObjRecCblsData()
3569 dumpDec
< sal_uInt16
>( "state", "OBJ-CHECKBOX-STATE" );
3570 dumpUnicode( "accelerator" );
3571 dumpUnicode( "fareast-accelerator" );
3572 dumpHex
< sal_uInt16
>( "checkbox-flags", "OBJ-CHECKBOX-FLAGS" );
3575 void WorkbookStreamObject::dumpObjRecLbsData()
3577 dumpObjRecFmla( "source-range", dumpDec
< sal_uInt16
>( "source-range-size" ) );
3578 dumpDec
< sal_uInt16
>( "entry-count" );
3579 dumpDec
< sal_uInt16
>( "selected-entry" );
3580 dumpHex
< sal_uInt16
>( "listbox-flags", "OBJ-LISTBOX-FLAGS" );
3581 dumpDec
< sal_uInt16
>( "edit-obj-id" );
3584 void WorkbookStreamObject::dumpObjRecPadding()
3586 if( getBiffStream().tell() & 1 )
3588 IndentGuard
aIndGuard( out() );
3589 dumpHex
< sal_uInt8
>( "padding" );
3593 void WorkbookStreamObject::dumpObjRecString( const String
& rName
, sal_uInt16 nTextLen
, bool bRepeatLen
)
3598 dumpByteString( rName
, BIFF_STR_8BITLENGTH
);
3600 writeStringItem( rName
, getBiffStream().readCharArrayUC( nTextLen
, getBiffData().getTextEncoding() ) );
3601 dumpObjRecPadding();
3605 void WorkbookStreamObject::dumpObjRecTextFmt( sal_uInt16 nFormatSize
)
3607 FontPortionModelList aPortions
;
3608 aPortions
.importPortions( getBiffStream(), nFormatSize
/ 8, BIFF_FONTPORTION_OBJ
);
3609 writeFontPortions( aPortions
);
3612 void WorkbookStreamObject::dumpObjRecFmlaRaw()
3614 sal_uInt16 nFmlaSize
= dumpDec
< sal_uInt16
>( "fmla-size" );
3616 getFormulaDumper().dumpNameFormula( "fmla", nFmlaSize
);
3617 dumpObjRecPadding();
3620 void WorkbookStreamObject::dumpObjRecFmla( const String
& rName
, sal_uInt16 nFmlaSize
)
3622 BiffInputStream
& rStrm
= getBiffStream();
3625 writeEmptyItem( rName
);
3626 IndentGuard
aIndGuard( out() );
3627 sal_Int64 nStrmEnd
= rStrm
.tell() + nFmlaSize
;
3628 dumpObjRecFmlaRaw();
3629 if( rStrm
.isEof() || (rStrm
.tell() != nStrmEnd
) )
3630 writeEmptyItem( OOX_DUMP_ERRASCII( "fmla-size" ) );
3631 dumpRemainingTo( nStrmEnd
);
3635 void WorkbookStreamObject::dumpObjRecPictFmla( sal_uInt16 nFmlaSize
)
3637 BiffInputStream
& rStrm
= getBiffStream();
3640 writeEmptyItem( "pic-link" );
3641 IndentGuard
aIndGuard( out() );
3642 sal_Int64 nStrmEnd
= rStrm
.tell() + nFmlaSize
;
3643 if( (getBiff() == BIFF3
) && (nStrmEnd
& 1) ) ++nStrmEnd
; // BIFF3 size without padding
3644 dumpObjRecFmlaRaw();
3645 if( rStrm
.tell() + 2 <= nStrmEnd
)
3647 dumpString( "class-name", BIFF_STR_DEFAULT
, BIFF_STR_SMARTFLAGS
);
3648 dumpObjRecPadding();
3650 if( rStrm
.isEof() || (rStrm
.tell() != nStrmEnd
) )
3651 writeEmptyItem( OOX_DUMP_ERRASCII( "pic-link-size" ) );
3652 dumpRemainingTo( nStrmEnd
);
3656 // ============================================================================
3658 PivotCacheStreamObject::PivotCacheStreamObject( const ObjectBase
& rParent
, const BinaryInputStreamRef
& rxStrm
, BiffType eBiff
, const ::rtl::OUString
& rSysFileName
)
3660 RecordStreamObject::construct( rParent
, rxStrm
, eBiff
, rSysFileName
);
3663 void PivotCacheStreamObject::implDumpRecordBody()
3665 BiffInputStream
& rStrm
= getBiffStream();
3666 sal_uInt16 nRecId
= rStrm
.getRecId();
3670 case BIFF_ID_PCDEFINITION
:
3671 dumpDec
< sal_Int32
>( "source-records" );
3672 dumpHex
< sal_uInt16
>( "cache-id" );
3673 dumpHex
< sal_uInt16
>( "flags", "PCDEFINITION-FLAGS" );
3675 dumpDec
< sal_uInt16
>( "sourcedata-field-count" );
3676 dumpDec
< sal_uInt16
>( "cache-field-count" );
3677 dumpDec
< sal_uInt16
>( "report-record-count" );
3678 dumpDec
< sal_uInt16
>( "database-type", "PCDSOURCE-TYPE" );
3679 dumpString( "user-name" );
3682 case BIFF_ID_PCDEFINITION2
:
3683 dumpDec
< double >( "refreshed-date" );
3684 dumpDec
< sal_Int32
>( "formula-count" );
3687 case BIFF_ID_PCDFDISCRETEPR
:
3688 out().resetItemIndex();
3689 while( !rStrm
.isEof() && (rStrm
.getRemaining() >= 2) )
3690 dumpDec
< sal_uInt16
>( "#item-index" );
3693 case BIFF_ID_PCDFIELD
:
3694 dumpHex
< sal_uInt16
>( "flags", "PCDFIELD-FLAGS" );
3695 dumpDec
< sal_uInt16
>( "group-parent-field" );
3696 dumpDec
< sal_uInt16
>( "group-base-field" );
3697 dumpDec
< sal_uInt16
>( "unique-items" );
3698 dumpDec
< sal_uInt16
>( "group-items" );
3699 dumpDec
< sal_uInt16
>( "base-items" );
3700 dumpDec
< sal_uInt16
>( "shared-items" );
3701 if( rStrm
.getRemaining() >= 3 )
3702 dumpString( "item-name" );
3705 case BIFF_ID_PCITEM_DATE
:
3708 aDateTime
.Year
= in().readuInt16();
3709 aDateTime
.Month
= in().readuInt16();
3710 aDateTime
.Day
= in().readuInt8();
3711 aDateTime
.Hours
= in().readuInt8();
3712 aDateTime
.Minutes
= in().readuInt8();
3713 aDateTime
.Seconds
= in().readuInt8();
3714 writeDateTimeItem( "value", aDateTime
);
3718 case BIFF_ID_PCITEM_STRING
:
3719 dumpString( "value" );
3724 // ============================================================================
3725 // ============================================================================
3727 RootStorageObject::RootStorageObject( const DumperBase
& rParent
)
3729 OleStorageObject::construct( rParent
);
3730 addPreferredStream( "Book" );
3731 addPreferredStream( "Workbook" );
3734 void RootStorageObject::implDumpStream( const BinaryInputStreamRef
& rxStrm
, const OUString
& rStrgPath
, const OUString
& rStrmName
, const OUString
& rSysFileName
)
3736 if( (rStrgPath
.getLength() == 0) && (rStrmName
.equalsAscii( "Book" ) || rStrmName
.equalsAscii( "Workbook" )) )
3737 WorkbookStreamObject( *this, rxStrm
, rSysFileName
).dump();
3738 else if( rStrgPath
.equalsAscii( "_SX_DB" ) )
3739 PivotCacheStreamObject( *this, rxStrm
, BIFF5
, rSysFileName
).dump();
3740 else if( rStrgPath
.equalsAscii( "_SX_DB_CUR" ) )
3741 PivotCacheStreamObject( *this, rxStrm
, BIFF8
, rSysFileName
).dump();
3743 OleStorageObject::implDumpStream( rxStrm
, rStrgPath
, rStrmName
, rSysFileName
);
3746 void RootStorageObject::implDumpStorage( const StorageRef
& rxStrg
, const OUString
& rStrgPath
, const OUString
& rSysPath
)
3748 if( rStrgPath
.equalsAscii( "_VBA_PROJECT_CUR" ) )
3749 VbaProjectStorageObject( *this, rxStrg
, rSysPath
).dump();
3751 OleStorageObject::implDumpStorage( rxStrg
, rStrgPath
, rSysPath
);
3754 // ============================================================================
3755 // ============================================================================
3757 #define DUMP_BIFF_CONFIG_ENVVAR "OOO_BIFFDUMPER"
3759 Dumper::Dumper( const FilterBase
& rFilter
)
3761 ConfigRef
xCfg( new Config( DUMP_BIFF_CONFIG_ENVVAR
, rFilter
) );
3762 DumperBase::construct( xCfg
);
3765 Dumper::Dumper( const Reference
< XMultiServiceFactory
>& rxFactory
, const Reference
< XInputStream
>& rxInStrm
, const OUString
& rSysFileName
)
3767 if( rxFactory
.is() && rxInStrm
.is() )
3769 StorageRef
xStrg( new OleStorage( rxFactory
, rxInStrm
, true ) );
3770 MediaDescriptor aMediaDesc
;
3771 ConfigRef
xCfg( new Config( DUMP_BIFF_CONFIG_ENVVAR
, rxFactory
, xStrg
, rSysFileName
, aMediaDesc
) );
3772 DumperBase::construct( xCfg
);
3776 void Dumper::implDump()
3778 RootStorageObject
aRootStrg( *this );
3779 if( aRootStrg
.isValid() )
3783 else if( StorageBase
* pRootStrg
= cfg().getRootStorage().get() )
3785 // try to dump plain BIFF stream
3786 BinaryInputStreamRef
xStrm( new BinaryXInputStream( pRootStrg
->openInputStream( OUString() ), false ) );
3787 WorkbookStreamObject( *this, xStrm
, cfg().getSysFileName() ).dump();
3791 // ============================================================================