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
>( "rec-id", getRecNames() );
689 sal_Int16 nFlags
= bWithFlags
? dumpHex
< sal_uInt16
>( "flags", "FR-FLAGS" ) : 0x0001;
692 if( getFlag
< sal_uInt16
>( nFlags
, 0x0001 ) )
693 dumpRange( "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 BIFF_TOK_ATTR_SKIP
:
1341 dumpDec
< sal_uInt16
, sal_uInt8
>( !bBiff2
, "skip" );
1343 case BIFF_TOK_ATTR_SUM
:
1344 dumpUnused( bBiff2
? 1 : 2 );
1345 mxStack
->pushFuncOp( CREATE_OUSTRING( "SUM" ), OUString( OOX_DUMP_BASECLASS
), 1 );
1347 case BIFF_TOK_ATTR_ASSIGN
:
1348 dumpUnused( bBiff2
? 1 : 2 );
1350 case BIFF_TOK_ATTR_SPACE
:
1351 case BIFF_TOK_ATTR_SPACE
| BIFF_TOK_ATTR_VOLATILE
:
1358 dumpDec
< sal_uInt16
>( "leading-spaces" );
1363 dumpDec
< sal_uInt8
>( "char-type", mxSpTypes
);
1364 dumpDec
< sal_uInt8
>( "char-count" );
1366 case BIFF_UNKNOWN
: break;
1375 bool FormulaObject::dumpNlrToken()
1377 const OUString aRefClass
= cfg().getName( mxClasses
, BIFF_TOKCLASS_REF
);
1378 const OUString aValClass
= cfg().getName( mxClasses
, BIFF_TOKCLASS_VAL
);
1381 sal_uInt8 nType
= dumpHex
< sal_uInt8
>( "type", mxNlrTypes
);
1384 case BIFF_TOK_NLR_ERR
: dumpNlrErrToken(); break;
1385 case BIFF_TOK_NLR_ROWR
: dumpNlrColRowToken( aRefClass
, false ); break;
1386 case BIFF_TOK_NLR_COLR
: dumpNlrColRowToken( aRefClass
, false ); break;
1387 case BIFF_TOK_NLR_ROWV
: dumpNlrColRowToken( aValClass
, false ); break;
1388 case BIFF_TOK_NLR_COLV
: dumpNlrColRowToken( aValClass
, false ); break;
1389 case BIFF_TOK_NLR_RANGE
: dumpNlrRangeToken( aRefClass
, false ); break;
1390 case BIFF_TOK_NLR_SRANGE
: dumpNlrRangeToken( aRefClass
, true ); break;
1391 case BIFF_TOK_NLR_SROWR
: dumpNlrColRowToken( aRefClass
, true ); break;
1392 case BIFF_TOK_NLR_SCOLR
: dumpNlrColRowToken( aRefClass
, true ); break;
1393 case BIFF_TOK_NLR_SROWV
: dumpNlrColRowToken( aValClass
, true ); break;
1394 case BIFF_TOK_NLR_SCOLV
: dumpNlrColRowToken( aValClass
, true ); break;
1395 case BIFF_TOK_NLR_RANGEERR
: dumpNlrRangeErrToken(); break;
1396 default: bValid
= false;
1401 void FormulaObject::dumpNlrErrToken()
1403 dumpDec
< sal_uInt32
>( "delname-idx" );
1404 mxStack
->pushOperand( lclCreateNlr( getErrorName( BIFF_ERR_NAME
) ) );
1407 void FormulaObject::dumpNlrColRowToken( const OUString
& rTokClass
, bool bAddData
)
1412 mxStack
->pushOperand( createPlaceHolder(), rTokClass
);
1413 maAddData
.push_back( ADDDATA_NLR
);
1417 TokenAddress aPos
= dumpTokenAddress( false );
1418 writeInfoItem( "addr", lclCreateNlr( aPos
) );
1419 mxStack
->pushOperand( out().getLastItemValue(), rTokClass
);
1423 void FormulaObject::dumpNlrRangeToken( const OUString
& rTokClass
, bool bAddData
)
1428 mxStack
->pushOperand( createPlaceHolder(), rTokClass
);
1429 maAddData
.push_back( ADDDATA_NLR
);
1433 TokenAddress aPos
= dumpTokenAddress( false );
1434 writeInfoItem( "addr", lclCreateNlr( aPos
) );
1435 mxStack
->pushOperand( out().getLastItemValue(), rTokClass
);
1438 dumpRange( "target-range" );
1441 void FormulaObject::dumpNlrRangeErrToken()
1443 dumpDec
< sal_uInt32
>( "delname-idx" );
1445 mxStack
->pushOperand( lclCreateNlr( getErrorName( BIFF_ERR_NAME
) ) );
1448 void FormulaObject::dumpAddTokenData()
1450 Output
& rOut
= out();
1451 rOut
.resetItemIndex();
1452 for( AddDataTypeVec::const_iterator aIt
= maAddData
.begin(), aEnd
= maAddData
.end(); aIt
!= aEnd
; ++aIt
)
1454 AddDataType eType
= *aIt
;
1457 ItemGuard
aItem( rOut
, "#add-data" );
1460 case ADDDATA_NLR
: rOut
.writeAscii( "tNlr" ); break;
1461 case ADDDATA_ARRAY
: rOut
.writeAscii( "tArray" ); break;
1462 case ADDDATA_MEMAREA
: rOut
.writeAscii( "tMemArea" ); break;
1466 size_t nIdx
= aIt
- maAddData
.begin();
1467 IndentGuard
aIndGuard( rOut
);
1470 case ADDDATA_NLR
: dumpAddDataNlr( nIdx
); break;
1471 case ADDDATA_ARRAY
: dumpAddDataArray( nIdx
); break;
1472 case ADDDATA_MEMAREA
: dumpAddDataMemArea( nIdx
); break;
1477 void FormulaObject::dumpAddDataNlr( size_t nIdx
)
1479 sal_uInt32 nFlags
= dumpHex
< sal_uInt32
>( "flags", "NLRADDFLAGS" );
1480 sal_uInt32 nCount
= nFlags
& BIFF_TOK_NLR_ADDMASK
;
1481 OUStringBuffer aBuffer
;
1482 for( sal_uInt32 nPos
= 0; nPos
< nCount
; ++nPos
)
1485 readAddress( aPos
);
1486 OUStringBuffer aAddr
;
1487 StringHelper::appendAddress( aAddr
, aPos
);
1488 StringHelper::appendToken( aBuffer
, aAddr
.makeStringAndClear(), OOX_DUMP_LISTSEP
);
1490 OUString aAddrList
= aBuffer
.makeStringAndClear();
1491 writeInfoItem( "stacked-positions", aAddrList
);
1492 mxStack
->replaceOnTop( createPlaceHolder( nIdx
), lclCreateNlr( aAddrList
) );
1495 void FormulaObject::dumpAddDataArray( size_t nIdx
)
1497 sal_uInt32 nCols
, nRows
;
1498 dumpConstArrayHeader( nCols
, nRows
);
1501 TableGuard
aTabGuard( out(), 17 );
1502 for( sal_uInt32 nRow
= 0; nRow
< nRows
; ++nRow
)
1504 OUStringBuffer aArrayLine
;
1505 for( sal_uInt32 nCol
= 0; nCol
< nCols
; ++nCol
)
1506 StringHelper::appendToken( aArrayLine
, dumpConstValue( OOX_DUMP_FMLASTRQUOTE
), OOX_DUMP_LISTSEP
);
1507 StringHelper::appendToken( aOp
, aArrayLine
.makeStringAndClear(), OOX_DUMP_ARRAYSEP
);
1509 StringHelper::enclose( aOp
, '{', '}' );
1510 mxStack
->replaceOnTop( createPlaceHolder( nIdx
), aOp
.makeStringAndClear() );
1513 void FormulaObject::dumpAddDataMemArea( size_t /*nIdx*/ )
1515 dumpRangeList( EMPTY_STRING
, getBiff() == BIFF8
);
1518 // ============================================================================
1519 // ============================================================================
1521 RecordStreamObject::~RecordStreamObject()
1525 void RecordStreamObject::construct( const ObjectBase
& rParent
, const BinaryInputStreamRef
& rxStrm
, BiffType eBiff
, const OUString
& rSysFileName
)
1527 BiffObjectBase::construct( rParent
, rxStrm
, eBiff
, rSysFileName
);
1528 if( BiffObjectBase::implIsValid() )
1529 mxFmlaObj
.reset( new FormulaObject( *this ) );
1532 bool RecordStreamObject::implIsValid() const
1534 return isValid( mxFmlaObj
) && BiffObjectBase::implIsValid();
1537 // ============================================================================
1539 WorkbookStreamObject::WorkbookStreamObject( const ObjectBase
& rParent
, const BinaryInputStreamRef
& rxStrm
, const OUString
& rSysFileName
)
1543 BiffType eBiff
= BiffDetector::detectStreamBiffVersion( *rxStrm
);
1544 RecordStreamObject::construct( rParent
, rxStrm
, eBiff
, rSysFileName
);
1545 if( RecordStreamObject::implIsValid() )
1547 Config
& rCfg
= cfg();
1548 mxColors
= rCfg
.getNameList( "COLORS" );
1549 mxBorderStyles
= rCfg
.getNameList( "BORDERSTYLES" );
1550 mxFillPatterns
= rCfg
.getNameList( "FILLPATTERNS" );
1553 mnPTRowColItemsIdx
= 0;
1555 initializePerSheet();
1560 WorkbookStreamObject::~WorkbookStreamObject()
1562 if( WorkbookStreamObject::implIsValid() )
1564 Config
& rCfg
= cfg();
1565 rCfg
.eraseNameList( "FONTNAMES" );
1566 rCfg
.eraseNameList( "FORMATS" );
1570 void WorkbookStreamObject::implDumpRecordBody()
1572 BiffInputStream
& rStrm
= getBiffStream();
1573 sal_uInt16 nRecId
= rStrm
.getRecId();
1574 sal_Int64 nRecSize
= rStrm
.getLength();
1575 BiffType eBiff
= getBiff();
1579 case BIFF2_ID_ARRAY
:
1580 case BIFF3_ID_ARRAY
:
1581 dumpRange( "array-range", false );
1582 dumpHex
< sal_uInt16
, sal_uInt8
>( eBiff
!= BIFF2
, "flags", "ARRAY-FLAGS" );
1583 if( eBiff
>= BIFF5
) dumpUnused( 4 );
1584 getFormulaDumper().dumpCellFormula();
1587 case BIFF2_ID_BLANK
:
1588 case BIFF3_ID_BLANK
:
1589 dumpCellHeader( nRecId
== BIFF2_ID_BLANK
);
1596 dumpHex
< sal_uInt16
>( "bof-type", "BOF-BIFFTYPE" );
1597 dumpHex
< sal_uInt16
>( "sheet-type", "BOF-SHEETTYPE" );
1598 if( nRecSize
>= 6 ) dumpDec
< sal_uInt16
>( "build-id" );
1599 if( nRecSize
>= 8 ) dumpDec
< sal_uInt16
>( "build-year" );
1600 if( nRecSize
>= 12 ) dumpHex
< sal_uInt32
>( "history-flags", "BOF-HISTORY-FLAGS" );
1601 if( nRecSize
>= 16 ) dumpHex
< sal_uInt32
>( "lowest-version", "BOF-LOWESTVERSION-FLAGS" );
1602 if( (eBiff
== BIFF4
) && (getLastRecId() != BIFF_ID_OBJ
) )
1603 initializePerSheet();
1606 case BIFF2_ID_BOOLERR
:
1607 case BIFF3_ID_BOOLERR
:
1608 dumpCellHeader( nRecId
== BIFF2_ID_BOOLERR
);
1612 case BIFF_ID_CFHEADER
:
1613 dumpDec
< sal_uInt16
>( "rule-count" );
1614 dumpBool
< sal_uInt16
>( "need-update" );
1615 dumpRange( "bounding-range" );
1619 case BIFF_ID_CFRULE
:
1621 dumpDec
< sal_uInt8
>( "type", "CFRULE-TYPE" );
1622 dumpDec
< sal_uInt8
>( "operator", "CFRULE-OPERATOR" );
1623 sal_uInt16 nFmla1Size
= dumpDec
< sal_uInt16
>( "formula1-size" );
1624 sal_uInt16 nFmla2Size
= dumpDec
< sal_uInt16
>( "formula2-size" );
1625 sal_uInt32 nFlags
= dumpHex
< sal_uInt32
>( "flags", "CFRULE-FLAGS" );
1627 if( getFlag
< sal_uInt32
>( nFlags
, 0x04000000 ) )
1629 writeEmptyItem( "font-block" );
1630 IndentGuard
aIndGuard( out() );
1631 sal_Int64 nRecPos
= rStrm
.tell();
1632 dumpUniString( "name", BIFF_STR_8BITLENGTH
);
1633 dumpUnused( static_cast< sal_Int32
>( nRecPos
+ 64 - rStrm
.tell() ) );
1634 dumpDec
< sal_Int32
>( "height", "CONV-TWIP-TO-PT" );
1635 dumpHex
< sal_uInt32
>( "flags", "CFRULE-FONTFLAGS" );
1636 dumpDec
< sal_uInt16
>( "weight", "FONT-WEIGHT" );
1637 dumpDec
< sal_uInt16
>( "escapement", "FONT-ESCAPEMENT" );
1638 dumpDec
< sal_uInt8
>( "underline", "FONT-UNDERLINE" );
1639 dumpUnused( 3 ); // family/charset?
1640 dumpDec
< sal_Int32
>( "color", mxColors
);
1642 dumpHex
< sal_uInt32
>( "used-flags", "CFRULE-FONTUSEDFLAGS" );
1643 dumpDec
< sal_uInt32
>( "escapement-used", "CFRULE-FONTUSED" );
1644 dumpDec
< sal_uInt32
>( "underline-used", "CFRULE-FONTUSED" );
1647 if( getFlag
< sal_uInt32
>( nFlags
, 0x08000000 ) )
1649 writeEmptyItem( "alignment-block" );
1650 IndentGuard
aIndGuard( out() );
1651 dumpHex
< sal_uInt8
>( "alignent", "CFRULE-ALIGNMENT" );
1652 dumpHex
< sal_uInt8
>( "rotation", "TEXTROTATION" );
1653 dumpHex
< sal_uInt16
>( "indent", "CFRULE-INDENT" );
1654 dumpDec
< sal_uInt16
>( "relative-indent" );
1657 if( getFlag
< sal_uInt32
>( nFlags
, 0x10000000 ) )
1659 writeEmptyItem( "border-block" );
1660 IndentGuard
aIndGuard( out() );
1661 dumpHex
< sal_uInt16
>( "border-style", "XF-BORDERSTYLE" );
1662 dumpHex
< sal_uInt16
>( "border-color1", "XF-BORDERCOLOR1" );
1663 dumpHex
< sal_uInt32
>( "border-color2", "CFRULE-BORDERCOLOR2" );
1665 if( getFlag
< sal_uInt32
>( nFlags
, 0x20000000 ) )
1667 writeEmptyItem( "pattern-block" );
1668 IndentGuard
aIndGuard( out() );
1669 dumpHex
< sal_uInt32
>( "pattern", "CFRULE-FILLBLOCK" );
1671 if( getFlag
< sal_uInt32
>( nFlags
, 0x40000000 ) )
1673 writeEmptyItem( "protection-block" );
1674 IndentGuard
aIndGuard( out() );
1675 dumpHex
< sal_uInt16
>( "flags", "CFRULE-PROTECTION-FLAGS" );
1677 if( nFmla1Size
> 0 )
1678 getFormulaDumper().dumpNameFormula( "formula1", nFmla1Size
);
1679 if( nFmla2Size
> 0 )
1680 getFormulaDumper().dumpNameFormula( "formula2", nFmla2Size
);
1684 case BIFF_ID_CH3DDATAFORMAT
:
1685 dumpDec
< sal_uInt8
>( "base", "CH3DDATAFORMAT-BASE" );
1686 dumpDec
< sal_uInt8
>( "top", "CH3DDATAFORMAT-TOP" );
1689 case BIFF_ID_CHAREAFORMAT
:
1690 dumpColorABGR( "fg-color" );
1691 dumpColorABGR( "bg-color" );
1693 dumpHex
< sal_uInt16
>( "flags", "CHAREAFORMAT-FLAGS" );
1694 if( eBiff
== BIFF8
) dumpColorIdx( "fg-color-idx" );
1695 if( eBiff
== BIFF8
) dumpColorIdx( "bg-color-idx" );
1698 case BIFF_ID_CHAXESSET
:
1699 dumpDec
< sal_uInt16
>( "axesset-id", "CHAXESSET-ID" );
1700 dumpRect
< sal_Int32
>( "position", (eBiff
<= BIFF4
) ? "CONV-TWIP-TO-CM" : "" );
1703 case BIFF_ID_CHAXIS
:
1704 dumpDec
< sal_uInt16
>( "axis-type", "CHAXIS-TYPE" );
1705 if( eBiff
<= BIFF4
)
1706 dumpRect
< sal_Int32
>( "position", "CONV-TWIP-TO-CM" );
1712 dumpDec
< sal_Int16
>( "overlap", "CONV-PERCENT-NEG" );
1713 dumpDec
< sal_Int16
>( "gap", "CONV-PERCENT" );
1714 dumpHex
< sal_uInt16
>( "flags", "CHBAR-FLAGS" );
1717 case BIFF_ID_CHCHART
:
1718 dumpRect
< sal_Int32
>( "chart-frame", "CONV-PT1616-TO-CM", FORMATTYPE_FIX
);
1721 case BIFF_ID_CHCHART3D
:
1722 dumpDec
< sal_uInt16
>( "rotation-angle", "CONV-DEG" );
1723 dumpDec
< sal_Int16
>( "elevation-angle", "CONV-DEG" );
1724 dumpDec
< sal_uInt16
>( "eye-distance" );
1725 dumpDec
< sal_uInt16
>( "relative-height", "CONV-PERCENT" );
1726 dumpDec
< sal_uInt16
>( "relative-depth", "CONV-PERCENT" );
1727 dumpDec
< sal_uInt16
>( "depth-gap", "CONV-PERCENT" );
1728 dumpHex
< sal_uInt16
>( "flags", "CHCHART3D-FLAGS" );
1731 case BIFF_ID_CHTYPEGROUP
:
1733 dumpHex
< sal_uInt16
>( "flags", "CHTYPEGROUP-FLAGS" );
1734 if( eBiff
>= BIFF5
) dumpDec
< sal_uInt16
>( "group-idx" );
1737 case BIFF_ID_CHDATAFORMAT
:
1738 dumpDec
< sal_Int16
>( "point-idx", "CHDATAFORMAT-POINTIDX" );
1739 dumpDec
< sal_Int16
>( "series-idx" );
1740 if( eBiff
>= BIFF5
) dumpDec
< sal_Int16
>( "format-idx", "CHDATAFORMAT-FORMATIDX" );
1741 if( eBiff
>= BIFF5
) dumpHex
< sal_uInt16
>( "flags", "CHDATAFORMAT-FLAGS" );
1744 case BIFF_ID_CHESCHERFORMAT
:
1748 case BIFF_ID_CHFRAME
:
1749 dumpDec
< sal_uInt16
>( "format", "CHFRAME-FORMAT" );
1750 dumpHex
< sal_uInt16
>( "flags", "CHFRAME-FLAGS" );
1753 case BIFF_ID_CHFRAMEPOS
:
1754 dumpDec
< sal_uInt16
>( "object-type", "CHFRAMEPOS-OBJTYPE" );
1755 dumpDec
< sal_uInt16
>( "size-mode", "CHFRAMEPOS-SIZEMODE" );
1756 dumpRect
< sal_Int32
>( "position", (eBiff
<= BIFF4
) ? "CONV-TWIP-TO-CM" : "" );
1759 case BIFF_ID_CHFRBLOCKBEGIN
:
1760 dumpFrHeader( true, false );
1761 dumpDec
< sal_uInt16
>( "type", "CHFRBLOCK-TYPE" );
1762 dumpDec
< sal_uInt16
>( "context" );
1763 dumpDec
< sal_uInt16
>( "value-1" );
1764 dumpDec
< sal_uInt16
>( "value-2" );
1767 case BIFF_ID_CHFRBLOCKEND
:
1768 dumpFrHeader( true, false );
1769 dumpDec
< sal_uInt16
>( "type", "CHFRBLOCK-TYPE" );
1770 if( rStrm
.getRemaining() >= 6 )
1774 case BIFF_ID_CHFRINFO
:
1776 dumpFrHeader( true, false );
1777 dumpDec
< sal_uInt8
>( "creator", "CHFRINFO-APPVERSION" );
1778 dumpDec
< sal_uInt8
>( "writer", "CHFRINFO-APPVERSION" );
1779 sal_uInt16 nCount
= dumpDec
< sal_uInt16
>( "rec-range-count" );
1780 out().resetItemIndex();
1781 for( sal_uInt16 nIndex
= 0; !rStrm
.isEof() && (nIndex
< nCount
); ++nIndex
)
1782 dumpHexPair
< sal_uInt16
>( "#rec-range", '-' );
1786 case BIFF_ID_CHFRLABELPROPS
:
1787 dumpFrHeader( true, true );
1788 dumpHex
< sal_uInt16
>( "flags", "CHFRLABELPROPS-FLAGS" );
1789 dumpUniString( "separator", BIFF_STR_SMARTFLAGS
);
1792 case BIFF_ID_CHFRUNITPROPS
:
1793 dumpFrHeader( true, false );
1794 dumpDec
< sal_Int16
>( "preset", "CHFRUNITPROPS-PRESET" );
1795 dumpDec
< double >( "unit" );
1796 dumpHex
< sal_uInt16
>( "flags", "CHFRUNITPROPS-FLAGS" );
1799 case BIFF_ID_CHFRWRAPPER
:
1800 dumpFrHeader( true, false );
1803 case BIFF_ID_CHLABELRANGE
:
1804 dumpDec
< sal_uInt16
>( "axis-crossing" );
1805 dumpDec
< sal_uInt16
>( "label-frequency" );
1806 dumpDec
< sal_uInt16
>( "tick-frequency" );
1807 dumpHex
< sal_uInt16
>( "flags", "CHLABELRANGE-FLAGS" );
1810 case BIFF_ID_CHLABELRANGE2
:
1811 dumpDec
< sal_uInt16
>( "minimum-categ" );
1812 dumpDec
< sal_uInt16
>( "maximum-categ" );
1813 dumpDec
< sal_uInt16
>( "major-unit-value" );
1814 dumpDec
< sal_uInt16
>( "major-unit" );
1815 dumpDec
< sal_uInt16
>( "minor-unit-value" );
1816 dumpDec
< sal_uInt16
>( "minor-unit" );
1817 dumpDec
< sal_uInt16
>( "base-unit" );
1818 dumpDec
< sal_uInt16
>( "axis-crossing-date" );
1819 dumpHex
< sal_uInt16
>( "flags", "CHLABELRANGE2-FLAGS" );
1822 case BIFF_ID_CHLEGEND
:
1823 dumpRect
< sal_Int32
>( "position", (eBiff
<= BIFF4
) ? "CONV-TWIP-TO-CM" : "" );
1824 dumpDec
< sal_uInt8
>( "docked-pos", "CHLEGEND-DOCKPOS" );
1825 dumpDec
< sal_uInt8
>( "spacing", "CHLEGEND-SPACING" );
1826 dumpHex
< sal_uInt16
>( "flags", "CHLEGEND-FLAGS" );
1829 case BIFF_ID_CHLINEFORMAT
:
1831 dumpDec
< sal_uInt16
>( "line-type", "CHLINEFORMAT-LINETYPE" );
1832 dumpDec
< sal_Int16
>( "line-weight", "CHLINEFORMAT-LINEWEIGHT" );
1833 dumpHex
< sal_uInt16
>( "flags", "CHLINEFORMAT-FLAGS" );
1834 if( eBiff
== BIFF8
) dumpColorIdx();
1837 case BIFF_ID_CHMARKERFORMAT
:
1838 dumpColorABGR( "border-color" );
1839 dumpColorABGR( "fill-color" );
1840 dumpDec
< sal_uInt16
>( "marker-type", "CHMARKERFORMAT-TYPE" );
1841 dumpHex
< sal_uInt16
>( "flags", "CHMARKERFORMAT-FLAGS" );
1842 if( eBiff
== BIFF8
) dumpColorIdx( "border-color-idx" );
1843 if( eBiff
== BIFF8
) dumpColorIdx( "fill-color-idx" );
1844 if( eBiff
== BIFF8
) dumpDec
< sal_Int32
>( "marker-size", "CONV-TWIP-TO-PT" );
1847 case BIFF_ID_CHOBJECTLINK
:
1848 dumpDec
< sal_uInt16
>( "link-target", "CHOBJECTLINK-TARGET" );
1849 dumpDec
< sal_Int16
>( "series-idx" );
1850 dumpDec
< sal_Int16
>( "point-idx", "CHOBJECTLINK-POINT" );
1853 case BIFF_ID_CHPICFORMAT
:
1854 dumpDec
< sal_uInt16
>( "bitmap-mode", "CHPICFORMAT-BITMAP-MODE" );
1855 dumpDec
< sal_uInt16
>( "image-format", "CHPICFORMAT-IMAGE-FORMAT" );
1856 dumpHex
< sal_uInt16
>( "flags", "CHPICFORMAT-FLAGS" );
1857 dumpDec
< double >( "scaling-factor" );
1861 dumpDec
< sal_uInt16
>( "angle", "CONV-DEG" );
1862 if( eBiff
>= BIFF5
) dumpDec
< sal_uInt16
>( "hole-size" );
1863 if( eBiff
>= BIFF8
) dumpHex
< sal_uInt16
>( "flags", "CHPIE-FLAGS" );
1866 case BIFF_ID_CHPLOTGROWTH
:
1867 dumpFix
< sal_Int32
>( "horizontal-growth" );
1868 dumpFix
< sal_Int32
>( "vertical-growth" );
1871 case BIFF_ID_CHPROPERTIES
:
1872 dumpHex
< sal_uInt16
>( "flags", "CHPROPERTIES-FLAGS" );
1873 dumpDec
< sal_uInt8
>( "empty-cells", "CHPROPERTIES-EMPTYCELLS" );
1876 case BIFF_ID_CHSCATTER
:
1877 if( eBiff
== BIFF8
) dumpDec
< sal_uInt16
>( "bubble-size", "CONV-PERCENT" );
1878 if( eBiff
== BIFF8
) dumpDec
< sal_uInt16
>( "size-type", "CHSCATTER-SIZETYPE" );
1879 if( eBiff
== BIFF8
) dumpHex
< sal_uInt16
>( "flags", "CHSCATTER-FLAGS" );
1882 case BIFF_ID_CHSERERRORBAR
:
1883 dumpDec
< sal_uInt8
>( "type", "CHSERERRORBAR-TYPE" );
1884 dumpDec
< sal_uInt8
>( "source", "CHSERERRORBAR-SOURCE" );
1885 dumpBool
< sal_uInt8
>( "draw-t-shape" );
1886 dumpBool
< sal_uInt8
>( "draw-line" );
1887 dumpDec
< double >( "value" );
1888 dumpDec
< sal_uInt16
>( "custom-count" );
1891 case BIFF_ID_CHSERIES
:
1892 dumpDec
< sal_uInt16
>( "categories-type", "CHSERIES-TYPE" );
1893 dumpDec
< sal_uInt16
>( "values-type", "CHSERIES-TYPE" );
1894 dumpDec
< sal_uInt16
>( "categories-count" );
1895 dumpDec
< sal_uInt16
>( "values-count" );
1896 if( eBiff
== BIFF8
) dumpDec
< sal_uInt16
>( "bubbles-type", "CHSERIES-TYPE" );
1897 if( eBiff
== BIFF8
) dumpDec
< sal_uInt16
>( "bubbles-count" );
1900 case BIFF_ID_CHSERTRENDLINE
:
1901 switch( dumpDec
< sal_uInt8
>( "type", "CHSERTRENDLINE-TYPE" ) )
1903 case 0: dumpDec
< sal_uInt8
>( "order" ); break;
1904 case 4: dumpDec
< sal_uInt8
>( "average-period" ); break;
1905 default: dumpUnused( 1 );
1907 dumpDec
< double >( "intercept" );
1908 dumpBool
< sal_uInt8
>( "show-equation" );
1909 dumpBool
< sal_uInt8
>( "show-r-sqrare" );
1910 dumpDec
< double >( "forecast-forward" );
1911 dumpDec
< double >( "forecast-backward" );
1914 case BIFF_ID_CHSOURCELINK
:
1915 dumpDec
< sal_uInt8
>( "link-target", "CHSOURCELINK-TARGET" );
1916 dumpDec
< sal_uInt8
>( "link-type", "CHSOURCELINK-TYPE" );
1917 dumpHex
< sal_uInt16
>( "flags", "CHSOURCELINK-FLAGS" );
1919 getFormulaDumper().dumpNameFormula();
1922 case BIFF_ID_CHSTRING
:
1923 dumpDec
< sal_uInt16
>( "text-type", "CHSTRING-TYPE" );
1924 dumpString( "text", BIFF_STR_8BITLENGTH
, BIFF_STR_8BITLENGTH
);
1927 case BIFF_ID_CHTEXT
:
1928 dumpDec
< sal_uInt8
>( "horizontal-align", "CHTEXT-HORALIGN" );
1929 dumpDec
< sal_uInt8
>( "vertical-align", "CHTEXT-VERALIGN" );
1930 dumpDec
< sal_uInt16
>( "fill-mode", "CHTEXT-FILLMODE" );
1932 dumpRect
< sal_Int32
>( "position", (eBiff
<= BIFF4
) ? "CONV-TWIP-TO-CM" : "" );
1933 dumpHex
< sal_uInt16
>( "flags", "CHTEXT-FLAGS" );
1934 if( eBiff
== BIFF8
) dumpColorIdx();
1935 if( eBiff
== BIFF8
) dumpDec
< sal_uInt16
>( "placement", "CHTEXT-PLACEMENT" );
1936 if( eBiff
== BIFF8
) dumpDec
< sal_uInt16
>( "rotation", "TEXTROTATION" );
1939 case BIFF_ID_CHTICK
:
1940 dumpDec
< sal_uInt8
>( "major-ticks", "CHTICK-TYPE" );
1941 dumpDec
< sal_uInt8
>( "minor-ticks", "CHTICK-TYPE" );
1942 dumpDec
< sal_uInt8
>( "label-position", "CHTICK-LABELPOS" );
1943 dumpDec
< sal_uInt8
>( "fill-mode", "CHTEXT-FILLMODE" );
1944 dumpColorABGR( "label-color" );
1946 dumpHex
< sal_uInt16
>( "flags", "CHTICK-FLAGS" );
1947 if( eBiff
== BIFF8
) dumpColorIdx( "label-color-idx" );
1948 if( eBiff
== BIFF8
) dumpDec
< sal_uInt16
>( "label-rotation", "TEXTROTATION" );
1951 case BIFF_ID_CHVALUERANGE
:
1952 dumpDec
< double >( "minimum" );
1953 dumpDec
< double >( "maximum" );
1954 dumpDec
< double >( "major-inc" );
1955 dumpDec
< double >( "minor-inc" );
1956 dumpDec
< double >( "axis-crossing" );
1957 dumpHex
< sal_uInt16
>( "flags", "CHVALUERANGE-FLAGS" );
1960 case BIFF_ID_CODENAME
:
1961 dumpUniString( "codename" );
1964 case BIFF_ID_CODEPAGE
:
1965 getBiffData().setTextEncoding( dumpCodePage() );
1966 mbHasCodePage
= true;
1969 case BIFF_ID_COLINFO
:
1971 dumpDec
< sal_uInt16
>( "col-width", "CONV-COLWIDTH" );
1972 dumpXfIdx( "xf-idx" );
1973 dumpHex
< sal_uInt16
>( "flags", "COLINFO-FLAGS" );
1977 case BIFF_ID_COLUMNDEFAULT
:
1978 out().resetItemIndex();
1979 for( sal_Int32 nCol
= 0, nCount
= dumpColRange(); nCol
< nCount
; ++nCol
)
1980 dumpXfIdx( "#xf-idx", true );
1984 case BIFF_ID_COLWIDTH
:
1985 dumpColRange( EMPTY_STRING
, false );
1986 dumpDec
< sal_uInt16
>( "col-width", "CONV-COLWIDTH" );
1990 if( (eBiff
== BIFF8
) && (getLastRecId() == BIFF_ID_OBJ
) )
1994 case BIFF_ID_COORDLIST
:
1996 out().resetItemIndex();
1997 TableGuard
aTabGuard( out(), 12, 10 );
1998 while( rStrm
.getRemaining() >= 4 )
2000 MultiItemsGuard
aMultiGuard( out() );
2001 writeEmptyItem( "#point" );
2002 dumpDec
< sal_uInt16
>( "x" );
2003 dumpDec
< sal_uInt16
>( "y" );
2010 sal_Int32 nCol2
= dumpColIndex( "last-col-idx", false );
2011 sal_Int32 nCol1
= dumpColIndex( "first-col-idx", false );
2012 sal_Int32 nRow
= dumpRowIndex( "row-idx" );
2013 TableGuard
aTabGuard( out(), 14, 17 );
2014 for( Address
aPos( nCol1
, nRow
); !rStrm
.isEof() && (aPos
.mnCol
<= nCol2
); ++aPos
.mnCol
)
2016 MultiItemsGuard
aMultiGuard( out() );
2017 writeAddressItem( "pos", aPos
);
2023 case BIFF_ID_DCONBINAME
:
2024 dumpDec
< sal_uInt8
>( "builtin-id", "DEFINEDNAME-BUILTINID" );
2026 dumpString( "source-link", BIFF_STR_8BITLENGTH
, BIFF_STR_SMARTFLAGS
);
2029 case BIFF_ID_DCONNAME
:
2030 dumpString( "source-name", BIFF_STR_8BITLENGTH
);
2031 dumpString( "source-link", BIFF_STR_8BITLENGTH
, BIFF_STR_SMARTFLAGS
);
2034 case BIFF_ID_DCONREF
:
2035 dumpRange( "source-range", false );
2036 dumpString( "source-link", BIFF_STR_8BITLENGTH
, BIFF_STR_SMARTFLAGS
);
2039 case BIFF2_ID_DATATABLE
:
2040 dumpRange( "table-range", false );
2041 dumpBoolean( "recalc-always" );
2042 dumpBoolean( "row-table" );
2043 dumpAddress( "ref1" );
2046 case BIFF3_ID_DATATABLE
:
2047 dumpRange( "table-range", false );
2048 dumpHex
< sal_uInt16
>( "flags", "DATATABLE-FLAGS" );
2049 dumpAddress( "ref1" );
2050 dumpAddress( "ref2" );
2053 case BIFF2_ID_DATATABLE2
:
2054 dumpRange( "table-range", false );
2055 dumpBoolean( "recalc-always" );
2057 dumpAddress( "ref1" );
2058 dumpAddress( "ref2" );
2061 case BIFF_ID_DATAVALIDATION
:
2063 dumpHex
< sal_uInt32
>( "flags", "DATAVALIDATION-FLAGS" );
2064 dumpUniString( "input-title" );
2065 dumpUniString( "error-title" );
2066 dumpUniString( "input-message" );
2067 dumpUniString( "error-message" );
2068 sal_uInt16 nFmla1Size
= getFormulaDumper().dumpFormulaSize( "formula1-size" );
2070 if( nFmla1Size
> 0 )
2071 getFormulaDumper().dumpNameFormula( "formula1", nFmla1Size
);
2072 sal_uInt16 nFmla2Size
= getFormulaDumper().dumpFormulaSize( "formula2-size" );
2074 if( nFmla2Size
> 0 )
2075 getFormulaDumper().dumpNameFormula( "formula2", nFmla2Size
);
2080 case BIFF_ID_DATAVALIDATIONS
:
2081 dumpHex
< sal_uInt16
>( "flags", "DATAVALIDATIONS-FLAGS" );
2082 dumpDec
< sal_Int32
>( "input-box-pos-x" );
2083 dumpDec
< sal_Int32
>( "input-box-pos-y" );
2084 dumpDec
< sal_Int32
>( "dropdown-object-id" );
2085 dumpDec
< sal_Int32
>( "dval-entry-count" );
2088 case BIFF2_ID_DEFINEDNAME
:
2089 case BIFF3_ID_DEFINEDNAME
:
2091 rtl_TextEncoding eTextEnc
= getBiffData().getTextEncoding();
2092 dumpHex
< sal_uInt16
, sal_uInt8
>( eBiff
!= BIFF2
, "flags", "DEFINEDNAME-FLAGS" );
2093 if( eBiff
== BIFF2
) dumpDec
< sal_uInt8
>( "macro-type", "DEFINEDNAME-MACROTYPE-BIFF2" );
2094 dumpChar( "accelerator", eTextEnc
);
2095 sal_uInt8 nNameLen
= dumpDec
< sal_uInt8
>( "name-len" );
2096 sal_uInt16 nFmlaSize
= getFormulaDumper().dumpFormulaSize();
2097 if( eBiff
>= BIFF5
)
2099 bool bBiff8
= eBiff
== BIFF8
;
2100 if( bBiff8
) dumpUnused( 2 ); else dumpDec
< sal_uInt16
>( "externsheet-idx", "DEFINEDNAME-SHEETIDX" );
2101 dumpDec
< sal_uInt16
>( "sheet-idx", "DEFINEDNAME-SHEETIDX" );
2102 sal_uInt8 nMenuLen
= dumpDec
< sal_uInt8
>( "menu-text-len" );
2103 sal_uInt8 nDescrLen
= dumpDec
< sal_uInt8
>( "description-text-len" );
2104 sal_uInt8 nHelpLen
= dumpDec
< sal_uInt8
>( "help-text-len" );
2105 sal_uInt8 nStatusLen
= dumpDec
< sal_uInt8
>( "statusbar-text-len" );
2106 writeStringItem( "name", bBiff8
? rStrm
.readUniStringBody( nNameLen
, true ) : rStrm
.readCharArrayUC( nNameLen
, eTextEnc
, true ) );
2107 getFormulaDumper().dumpNameFormula( EMPTY_STRING
, nFmlaSize
);
2108 if( nMenuLen
> 0 ) writeStringItem( "menu-text", bBiff8
? rStrm
.readUniStringBody( nMenuLen
, true ) : rStrm
.readCharArrayUC( nMenuLen
, eTextEnc
, true ) );
2109 if( nDescrLen
> 0 ) writeStringItem( "description-text", bBiff8
? rStrm
.readUniStringBody( nDescrLen
, true ) : rStrm
.readCharArrayUC( nDescrLen
, eTextEnc
, true ) );
2110 if( nHelpLen
> 0 ) writeStringItem( "help-text", bBiff8
? rStrm
.readUniStringBody( nHelpLen
, true ) : rStrm
.readCharArrayUC( nHelpLen
, eTextEnc
, true ) );
2111 if( nStatusLen
> 0 ) writeStringItem( "statusbar-text", bBiff8
? rStrm
.readUniStringBody( nStatusLen
, true ) : rStrm
.readCharArrayUC( nStatusLen
, eTextEnc
, true ) );
2115 writeStringItem( "name", rStrm
.readCharArrayUC( nNameLen
, eTextEnc
, true ) );
2116 getFormulaDumper().dumpNameFormula( EMPTY_STRING
, nFmlaSize
);
2117 if( eBiff
== BIFF2
) getFormulaDumper().dumpFormulaSize();
2122 case BIFF3_ID_DEFROWHEIGHT
:
2123 dumpHex
< sal_uInt16
>( "flags", "DEFROWHEIGHT-FLAGS" );
2124 dumpDec
< sal_uInt16
>( "row-height", "CONV-TWIP-TO-PT" );
2127 case BIFF2_ID_DIMENSION
:
2128 case BIFF3_ID_DIMENSION
:
2129 dumpRange( "used-area", true, (nRecId
== BIFF3_ID_DIMENSION
) && (eBiff
== BIFF8
) );
2130 if( nRecId
== BIFF3_ID_DIMENSION
) dumpUnused( 2 );
2133 case BIFF_ID_EXTERNALBOOK
:
2135 sal_uInt16 nCount
= dumpDec
< sal_uInt16
>( "sheet-count" );
2136 if( rStrm
.getRemaining() == 2 )
2137 dumpHex
< sal_uInt16
>( "special-key", "EXTERNALBOOK-KEY" );
2140 dumpString( "workbook-url" );
2141 out().resetItemIndex();
2142 for( sal_uInt16 nSheet
= 0; !rStrm
.isEof() && (nSheet
< nCount
); ++nSheet
)
2143 dumpString( "#sheet-name" );
2148 case BIFF2_ID_EXTERNALNAME
:
2149 case BIFF3_ID_EXTERNALNAME
:
2151 sal_uInt16 nFlags
= (eBiff
>= BIFF3
) ? dumpHex
< sal_uInt16
>( "flags", "EXTERNALNAME-FLAGS" ) : 0;
2152 if( eBiff
>= BIFF5
)
2154 if( getFlag
< sal_uInt16
>( nFlags
, 0x0010 ) )
2156 dumpHex
< sal_uInt32
>( "storage-id" );
2160 dumpDec
< sal_uInt16
>( "externsheet-idx" );
2164 OUString aName
= dumpString( "name", BIFF_STR_8BITLENGTH
, BIFF_STR_8BITLENGTH
);
2165 if( (aName
.getLength() > 0) && (aName
[ 0 ] == 1) && (rStrm
.getRemaining() >= 2) )
2166 getFormulaDumper().dumpNameFormula();
2170 case BIFF_ID_EXTERNSHEET
:
2171 if( eBiff
== BIFF8
)
2173 sal_uInt16 nCount
= dumpDec
< sal_uInt16
>( "ref-count" );
2174 TableGuard
aTabGuard( out(), 10, 17, 24 );
2175 out().resetItemIndex();
2176 for( sal_uInt16 nRefId
= 0; !rStrm
.isEof() && (nRefId
< nCount
); ++nRefId
)
2178 MultiItemsGuard
aMultiGuard( out() );
2179 writeEmptyItem( "#ref" );
2180 dumpDec
< sal_uInt16
>( "extbook-idx" );
2181 dumpDec
< sal_Int16
>( "first-sheet", "EXTERNSHEET-IDX" );
2182 dumpDec
< sal_Int16
>( "last-sheet", "EXTERNSHEET-IDX" );
2187 OStringBuffer
aUrl( rStrm
.readByteString( false, true ) );
2188 if( (aUrl
.getLength() > 0) && (aUrl
[ 0 ] == '\x03') )
2189 aUrl
.append( static_cast< sal_Char
>( rStrm
.readuInt8() ) );
2190 writeStringItem( "encoded-url", OStringToOUString( aUrl
.makeStringAndClear(), getBiffData().getTextEncoding() ) );
2194 case BIFF_ID_FILEPASS
:
2196 rStrm
.enableDecoder( false );
2197 if( eBiff
== BIFF8
)
2199 switch( dumpDec
< sal_uInt16
>( "type", "FILEPASS-TYPE" ) )
2202 dumpHex
< sal_uInt16
>( "key" );
2203 dumpHex
< sal_uInt16
>( "verifier" );
2207 sal_uInt16 nMajor
= dumpDec
< sal_uInt16
>( "major-version", "FILEPASS-MAJOR" );
2208 dumpDec
< sal_uInt16
>( "minor-version" );
2212 dumpArray( "salt", 16 );
2213 dumpArray( "verifier", 16 );
2214 dumpArray( "verifier-hash", 16 );
2223 dumpHex
< sal_uInt16
>( "key" );
2224 dumpHex
< sal_uInt16
>( "verifier" );
2226 rStrm
.seekToStart();
2227 BiffDecoderRef xDecoder
= BiffCodecHelper::implReadFilePass( rStrm
, eBiff
);
2228 if( xDecoder
.get() )
2229 cfg().requestPassword( *xDecoder
);
2230 setBinaryOnlyMode( !xDecoder
|| !xDecoder
->isValid() );
2234 case BIFF_ID_FILESHARING
:
2235 dumpBool
< sal_uInt16
>( "recommend-read-only" );
2236 dumpHex
< sal_uInt16
>( "password-hash" );
2237 dumpString( "password-creator", BIFF_STR_8BITLENGTH
, BIFF_STR_SMARTFLAGS
);
2245 case BIFF2_ID_FORMAT
:
2246 case BIFF4_ID_FORMAT
:
2250 case BIFF2_ID_FORMULA
:
2251 case BIFF3_ID_FORMULA
:
2252 case BIFF4_ID_FORMULA
:
2253 dumpCellHeader( eBiff
== BIFF2
);
2254 dumpFormulaResult();
2255 dumpHex
< sal_uInt16
, sal_uInt8
>( eBiff
!= BIFF2
, "flags", "FORMULA-FLAGS" );
2256 if( eBiff
>= BIFF5
) dumpUnused( 4 );
2257 getFormulaDumper().dumpCellFormula();
2260 case BIFF_ID_FOOTER
:
2261 if( rStrm
.getRemaining() > 0 )
2262 dumpString( "footer", BIFF_STR_8BITLENGTH
);
2265 case BIFF_ID_HEADER
:
2266 if( rStrm
.getRemaining() > 0 )
2267 dumpString( "header", BIFF_STR_8BITLENGTH
);
2270 case BIFF_ID_HYPERLINK
:
2272 if( cfg().getStringOption( dumpGuid( "guid" ), OUString() ).equalsAscii( "StdHlink" ) )
2273 StdHlinkObject( *this ).dump();
2276 case BIFF3_ID_IMGDATA
:
2277 case BIFF8_ID_IMGDATA
:
2279 sal_uInt16 nFormat
= dumpDec
< sal_uInt16
>( "image-format", "IMGDATA-FORMAT" );
2280 dumpDec
< sal_uInt16
>( "environment", "IMGDATA-ENV" );
2281 dumpDec
< sal_uInt32
>( "data-size" );
2284 writeEmptyItem( "bitmap-header" );
2285 IndentGuard
aIndGuard( out() );
2286 if( dumpDec
< sal_uInt32
>( "header-size" ) == 12 )
2288 dumpDec
< sal_Int16
>( "width" );
2289 dumpDec
< sal_Int16
>( "height" );
2290 dumpDec
< sal_Int16
>( "planes" );
2291 dumpDec
< sal_Int16
>( "bit-count" );
2297 case BIFF2_ID_INTEGER
:
2298 dumpCellHeader( true );
2299 dumpDec
< sal_uInt16
>( "value" );
2302 case BIFF2_ID_LABEL
:
2303 case BIFF3_ID_LABEL
:
2305 bool bBiff2
= nRecId
== BIFF2_ID_LABEL
;
2306 sal_uInt16 nXfIdx
= dumpCellHeader( bBiff2
);
2307 rtl_TextEncoding eOldTextEnc
= getBiffData().getTextEncoding();
2308 getBiffData().setTextEncoding( getBiffData().getXfEncoding( nXfIdx
) );
2309 dumpString( "value", bBiff2
? BIFF_STR_8BITLENGTH
: BIFF_STR_DEFAULT
);
2310 getBiffData().setTextEncoding( eOldTextEnc
);
2314 case BIFF_ID_LABELRANGES
:
2315 dumpRangeList( "row-ranges" );
2316 dumpRangeList( "col-ranges" );
2319 case BIFF_ID_LABELSST
:
2321 dumpDec
< sal_Int32
>( "sst-idx" );
2324 case BIFF_ID_MSODRAWING
:
2325 case BIFF_ID_MSODRAWINGGROUP
:
2326 case BIFF_ID_MSODRAWINGSEL
:
2331 case BIFF_ID_MULTBLANK
:
2333 Address aPos
= dumpAddress();
2335 TableGuard
aTabGuard( out(), 12 );
2336 for( ; rStrm
.getRemaining() >= 4; ++aPos
.mnCol
)
2338 MultiItemsGuard
aMultiGuard( out() );
2339 writeAddressItem( "pos", aPos
);
2343 dumpColIndex( "last-col-idx" );
2347 case BIFF_ID_MULTRK
:
2349 Address aPos
= dumpAddress();
2351 TableGuard
aTabGuard( out(), 12, 12 );
2352 for( ; rStrm
.getRemaining() >= 8; ++aPos
.mnCol
)
2354 MultiItemsGuard
aMultiGuard( out() );
2355 writeAddressItem( "pos", aPos
);
2360 dumpColIndex( "last-col-idx" );
2365 dumpAddress( "anchor-cell" );
2366 if( eBiff
== BIFF8
)
2368 dumpHex
< sal_uInt16
>( "flags", "NOTE-FLAGS" );
2369 dumpDec
< sal_uInt16
>( "obj-id" );
2373 sal_uInt16 nTextLen
= ::std::min( dumpDec
< sal_uInt16
>( "text-len" ), static_cast< sal_uInt16
>( rStrm
.getRemaining() ) );
2374 writeStringItem( "note-text", rStrm
.readCharArrayUC( nTextLen
, getBiffData().getTextEncoding(), true ) );
2378 case BIFF2_ID_NUMBER
:
2379 case BIFF3_ID_NUMBER
:
2380 dumpCellHeader( nRecId
== BIFF2_ID_NUMBER
);
2381 dumpDec
< double >( "value" );
2388 case BIFF_ID_PAGESETUP
:
2389 dumpDec
< sal_uInt16
>( "paper-size", "PAGESETUP-PAPERSIZE" );
2390 dumpDec
< sal_uInt16
>( "scaling", "CONV-PERCENT" );
2391 dumpDec
< sal_uInt16
>( "first-page" );
2392 dumpDec
< sal_uInt16
>( "scale-to-width", "PAGESETUP-SCALETOPAGES" );
2393 dumpDec
< sal_uInt16
>( "scale-to-height", "PAGESETUP-SCALETOPAGES" );
2394 dumpHex
< sal_uInt16
>( "flags", "PAGESETUP-FLAGS" );
2395 if( eBiff
>= BIFF5
)
2397 dumpDec
< sal_uInt16
>( "horizontal-res", "PAGESETUP-DPI" );
2398 dumpDec
< sal_uInt16
>( "vertical-res", "PAGESETUP-DPI" );
2399 dumpDec
< double >( "header-margin", "CONV-INCH-TO-CM" );
2400 dumpDec
< double >( "footer-margin", "CONV-INCH-TO-CM" );
2401 dumpDec
< sal_uInt16
>( "copies" );
2406 dumpDec
< sal_uInt16
>( "x-pos", "CONV-TWIP-TO-CM" );
2407 dumpDec
< sal_uInt16
>( "y-pos", "CONV-TWIP-TO-CM" );
2408 dumpAddress( "first-visible-cell" );
2409 dumpDec
< sal_uInt8
>( "active-pane", "PANE-ID" );
2412 case BIFF_ID_PCITEM_STRING
:
2413 dumpString( "value" );
2416 case BIFF_ID_PHONETICPR
:
2417 dumpDec
< sal_uInt16
>( "font-id", "FONTNAMES" );
2418 dumpHex
< sal_uInt16
>( "flags", "PHONETICPR-FLAGS" );
2419 dumpRangeList( "show-phonetic" );
2422 case BIFF_ID_PROJEXTSHEET
:
2423 dumpDec
< sal_uInt8
>( "sheet-type", "PROJEXTSHEET-TYPE" );
2425 dumpByteString( "sheet-link", BIFF_STR_8BITLENGTH
);
2428 case BIFF_ID_PTDATAFIELD
:
2429 dumpDec
< sal_Int16
>( "field" );
2430 dumpDec
< sal_uInt16
>( "subtotal", "PTDATAFIELD-SUBTOTAL" );
2431 dumpDec
< sal_uInt16
>( "show-data-as", "PTDATAFIELD-SHOWDATAAS" );
2432 dumpDec
< sal_Int16
>( "base-field" );
2433 dumpDec
< sal_Int16
>( "base-item", "PTDATAFIELD-BASEITEM" );
2435 dumpPivotString( "name" );
2438 case BIFF_ID_PTDEFINITION
:
2440 dumpRange( "output-range" );
2441 dumpRowIndex( "first-header-row-idx" );
2442 dumpAddress( "first-data-pos" );
2443 dumpDec
< sal_uInt16
>( "cache-idx" );
2445 dumpDec
< sal_uInt16
>( "default-data-axis", "PTFIELD-AXISTYPE" );
2446 dumpDec
< sal_Int16
>( "default-data-pos", "PTDEFINITION-DATAFIELD-POS" );
2447 dumpDec
< sal_uInt16
>( "field-count" );
2448 mnPTRowFields
= dumpDec
< sal_uInt16
>( "row-field-count" );
2449 mnPTColFields
= dumpDec
< sal_uInt16
>( "column-field-count" );
2450 dumpDec
< sal_uInt16
>( "page-field-count" );
2451 dumpDec
< sal_uInt16
>( "data-field-count" );
2452 dumpDec
< sal_uInt16
>( "data-row-count" );
2453 dumpDec
< sal_uInt16
>( "data-column-count" );
2454 dumpHex
< sal_uInt16
>( "flags", "PTDEFINITION-FLAGS" );
2455 dumpDec
< sal_uInt16
>( "auto-format-idx" );
2456 sal_uInt16 nTabNameLen
= dumpDec
< sal_uInt16
>( "table-name-len" );
2457 sal_uInt16 nDataNameLen
= dumpDec
< sal_uInt16
>( "data-name-len" );
2458 dumpPivotString( "table-name", nTabNameLen
);
2459 dumpPivotString( "data-name", nDataNameLen
);
2460 mnPTRowColItemsIdx
= 0;
2464 case BIFF_ID_PTDEFINITION2
:
2466 dumpDec
< sal_uInt16
>( "format-rec-count" );
2467 sal_uInt16 nErrCaptLen
= dumpDec
< sal_uInt16
>( "error-caption-len" );
2468 sal_uInt16 nMissCaptLen
= dumpDec
< sal_uInt16
>( "missing-caption-len" );
2469 sal_uInt16 nTagLen
= dumpDec
< sal_uInt16
>( "tag-len" );
2470 dumpDec
< sal_uInt16
>( "select-rec-count" );
2471 dumpDec
< sal_uInt16
>( "page-rows" );
2472 dumpDec
< sal_uInt16
>( "page-cols" );
2473 dumpHex
< sal_uInt32
>( "flags", "PTDEFINITION2-FLAGS" );
2474 sal_uInt16 nPageStyleLen
= dumpDec
< sal_uInt16
>( "page-field-style-len" );
2475 sal_uInt16 nTabStyleLen
= dumpDec
< sal_uInt16
>( "pivot-table-style-len" );
2476 sal_uInt16 nVacStyleLen
= dumpDec
< sal_uInt16
>( "vacated-style-len" );
2477 dumpPivotString( "error-caption", nErrCaptLen
);
2478 dumpPivotString( "missing-caption", nMissCaptLen
);
2479 dumpPivotString( "tag", nTagLen
);
2480 dumpPivotString( "page-field-style", nPageStyleLen
);
2481 dumpPivotString( "pivot-table-style", nTabStyleLen
);
2482 dumpPivotString( "vacated-style", nVacStyleLen
);
2486 case BIFF_ID_PTFIELD
:
2487 dumpDec
< sal_uInt16
>( "axis-type", "PTFIELD-AXISTYPE" );
2488 dumpDec
< sal_uInt16
>( "subtotal-count" );
2489 dumpHex
< sal_uInt16
>( "subtotals", "PTFIELD-SUBTOTALS" );
2490 dumpDec
< sal_uInt16
>( "item-count" );
2491 dumpPivotString( "field-name" );
2494 case BIFF_ID_PTFIELD2
:
2495 dumpHex
< sal_uInt32
>( "flags", "PTFIELD2-FLAGS" );
2496 dumpDec
< sal_Int16
>( "autosort-basefield-idx" );
2497 dumpDec
< sal_Int16
>( "autoshow-basefield-idx" );
2499 if( rStrm
.getRemaining() >= 2 )
2501 sal_uInt16 nFuncNameLen
= dumpDec
< sal_uInt16
>( "subtotal-func-name-len" );
2503 dumpPivotString( "subtotal-func-name", nFuncNameLen
);
2507 case BIFF_ID_PTFITEM
:
2508 dumpDec
< sal_uInt16
>( "item-type", "PTFITEM-ITEMTYPE" );
2509 dumpHex
< sal_uInt16
>( "flags", "PTFITEM-FLAGS" );
2510 dumpDec
< sal_Int16
>( "cache-idx", "PTFITEM-CACHEIDX" );
2511 dumpPivotString( "item-name" );
2514 case BIFF_ID_PTPAGEFIELDS
:
2516 out().resetItemIndex();
2517 TableGuard
aTabGuard( out(), 17, 17, 17 );
2518 while( rStrm
.getRemaining() >= 6 )
2520 writeEmptyItem( "#page-field" );
2521 MultiItemsGuard
aMultiGuard( out() );
2522 IndentGuard
aIndGuard( out() );
2523 dumpDec
< sal_Int16
>( "base-field" );
2524 dumpDec
< sal_Int16
>( "item", "PTPAGEFIELDS-ITEM" );
2525 dumpDec
< sal_uInt16
>( "dropdown-obj-id" );
2530 case BIFF_ID_PTROWCOLFIELDS
:
2531 out().resetItemIndex();
2532 for( sal_Int64 nIdx
= 0, nCount
= rStrm
.getRemaining() / 2; nIdx
< nCount
; ++nIdx
)
2533 dumpDec
< sal_Int16
>( "#field-idx" );
2536 case BIFF_ID_PTROWCOLITEMS
:
2537 if( mnPTRowColItemsIdx
< 2 )
2539 sal_uInt16 nCount
= (mnPTRowColItemsIdx
== 0) ? mnPTRowFields
: mnPTColFields
;
2540 sal_Int64 nLineSize
= 8 + 2 * nCount
;
2541 out().resetItemIndex();
2542 while( rStrm
.getRemaining() >= nLineSize
)
2544 writeEmptyItem( "#line-data" );
2545 IndentGuard
aIndGuard( out() );
2546 MultiItemsGuard
aMultiGuard( out() );
2547 dumpDec
< sal_uInt16
>( "ident-count" );
2548 dumpDec
< sal_uInt16
>( "item-type", "PTROWCOLITEMS-ITEMTYPE" );
2549 dumpDec
< sal_uInt16
>( "used-count" );
2550 dumpHex
< sal_uInt16
>( "flags", "PTROWCOLITEMS-FLAGS" );
2551 OUStringBuffer aItemList
;
2552 for( sal_uInt16 nIdx
= 0; nIdx
< nCount
; ++nIdx
)
2553 StringHelper::appendToken( aItemList
, in().readInt16() );
2554 writeInfoItem( "item-idxs", aItemList
.makeStringAndClear() );
2556 ++mnPTRowColItemsIdx
;
2568 dumpColIndex( "first-used-col-idx" );
2569 dumpColIndex( "first-free-col-idx" );
2570 dumpHex
< sal_uInt16
>( "height", "ROW-HEIGHT" );
2572 bool bHasDefXf
= dumpBool
< sal_uInt8
>( "custom-format" );
2573 dumpDec
< sal_uInt16
>( "cell-offset" );
2574 if( bHasDefXf
) dumpXfIdx( "custom-format", true );
2575 if( bHasDefXf
) dumpXfIdx( "custom-xf-idx", false );
2581 dumpColIndex( "first-used-col-idx" );
2582 dumpColIndex( "first-free-col-idx" );
2583 dumpHex
< sal_uInt16
>( "height", "ROW-HEIGHT" );
2584 dumpUnused( (eBiff
<= BIFF4
) ? 2 : 4 );
2585 if( eBiff
<= BIFF4
) dumpDec
< sal_uInt16
>( "cell-offset" );
2586 dumpHex
< sal_uInt32
>( "flags", "ROW-FLAGS" );
2589 case BIFF_ID_RSTRING
:
2591 sal_uInt16 nXfIdx
= dumpCellHeader();
2592 rtl_TextEncoding eOldTextEnc
= getBiffData().getTextEncoding();
2593 getBiffData().setTextEncoding( getBiffData().getXfEncoding( nXfIdx
) );
2594 dumpString( "value" );
2595 getBiffData().setTextEncoding( eOldTextEnc
);
2596 FontPortionModelList aPortions
;
2597 aPortions
.importPortions( rStrm
, eBiff
== BIFF8
);
2598 writeFontPortions( aPortions
);
2602 case BIFF_ID_SCENARIO
:
2604 sal_uInt16 nCellCount
= dumpDec
< sal_uInt16
>( "cell-count" );
2605 // two bytes instead of flag field
2606 dumpBoolean( "locked" );
2607 dumpBoolean( "hidden" );
2608 sal_uInt16 nNameLen
= dumpDec
< sal_uInt8
>( "name-len" );
2609 sal_uInt16 nCommentLen
= dumpDec
< sal_uInt8
>( "comment-len" );
2610 sal_uInt16 nUserLen
= dumpDec
< sal_uInt8
>( "user-len" );
2611 writeStringItem( "name", rStrm
.readUniStringBody( nNameLen
, true ) );
2612 if( nUserLen
> 0 ) dumpUniString( "user" ); // repeated string length
2613 if( nCommentLen
> 0 ) dumpUniString( "comment" ); // repeated string length
2614 out().resetItemIndex();
2615 for( sal_uInt16 nCell
= 0; !rStrm
.isEof() && (nCell
< nCellCount
); ++nCell
)
2616 dumpAddress( "#pos" );
2617 out().resetItemIndex();
2618 for( sal_uInt16 nCell
= 0; !rStrm
.isEof() && (nCell
< nCellCount
); ++nCell
)
2619 dumpString( "#value" );
2620 dumpUnused( 2 * nCellCount
);
2624 case BIFF_ID_SCENARIOS
:
2625 dumpDec
< sal_uInt16
>( "count" );
2626 dumpDec
< sal_uInt16
>( "selected" );
2627 dumpDec
< sal_uInt16
>( "shown" );
2628 dumpRangeList( "result-cells" );
2633 sal_uInt16 nNum
= dumpDec
< sal_uInt16
>( "numerator" );
2634 sal_uInt16 nDen
= dumpDec
< sal_uInt16
>( "denominator" );
2635 if( nDen
> 0 ) writeDecItem( "current-zoom", static_cast< sal_uInt16
>( nNum
* 100 / nDen
), "CONV-PERCENT" );
2639 case BIFF_ID_SCREENTIP
:
2640 dumpFrHeader( false, true );
2641 dumpNullUnicodeArray( "tooltip" );
2644 case BIFF_ID_SELECTION
:
2645 dumpDec
< sal_uInt8
>( "pane", "PANE-ID" );
2646 dumpAddress( "active-cell" );
2647 dumpDec
< sal_uInt16
>( "list-idx" );
2648 dumpRangeList( "selection", false );
2651 case BIFF_ID_SHAREDFMLA
:
2652 dumpRange( "formula-range", false );
2654 dumpDec
< sal_uInt8
>( "cell-count" );
2655 getFormulaDumper().dumpCellFormula();
2659 if( eBiff
>= BIFF5
)
2661 rStrm
.enableDecoder( false );
2662 dumpHex
< sal_uInt32
>( "sheet-stream-pos", "CONV-DEC" );
2663 rStrm
.enableDecoder( true );
2664 dumpDec
< sal_uInt8
>( "sheet-state", "SHEET-STATE" );
2665 dumpDec
< sal_uInt8
>( "sheet-type", "SHEET-TYPE" );
2667 dumpString( "sheet-name", BIFF_STR_8BITLENGTH
, BIFF_STR_8BITLENGTH
);
2670 case BIFF_ID_SHEETHEADER
:
2671 dumpHex
< sal_uInt32
>( "substream-size", "CONV-DEC" );
2672 dumpByteString( "sheet-name", BIFF_STR_8BITLENGTH
);
2675 case BIFF_ID_SHEETPROTECTION
:
2676 dumpFrHeader( true, true );
2678 dumpHex
< sal_uInt16
>( "allowed-flags", "SHEETPROTECTION-FLAGS" );
2683 dumpDec
< sal_uInt32
>( "string-cell-count" );
2684 dumpDec
< sal_uInt32
>( "sst-size" );
2685 out().resetItemIndex();
2686 while( !rStrm
.isEof() && (rStrm
.getRemaining() >= 3) )
2687 dumpUniString( "#entry" );
2690 case BIFF2_ID_STRING
:
2691 case BIFF3_ID_STRING
:
2692 dumpString( "result", ((nRecId
== BIFF2_ID_STRING
) && (eBiff
<= BIFF4
)) ? BIFF_STR_8BITLENGTH
: BIFF_STR_DEFAULT
);
2697 sal_uInt16 nFlags
= dumpHex
< sal_uInt16
>( "flags", "STYLE-FLAGS" );
2698 if( getFlag( nFlags
, BIFF_STYLE_BUILTIN
) )
2700 dumpDec
< sal_uInt8
>( "builtin-idx", "STYLE-BUILTIN" );
2701 dumpDec
< sal_uInt8
>( "outline-level" );
2704 dumpString( "style-name", BIFF_STR_8BITLENGTH
);
2709 if( eBiff
== BIFF8
)
2711 dumpHex
< sal_uInt16
>( "flags", "SXEXT-FLAGS" );
2712 dumpDec
< sal_uInt16
>( "param-string-count" );
2713 dumpDec
< sal_uInt16
>( "sql-statement-string-count" );
2714 dumpDec
< sal_uInt16
>( "webquery-postmethod-string-count" );
2715 dumpDec
< sal_uInt16
>( "server-pagefields-string-count" );
2716 dumpDec
< sal_uInt16
>( "odbc-connection-string-count" );
2721 dumpHex
< sal_uInt16
>( "flags", "TXO-FLAGS" );
2722 dumpDec
< sal_uInt16
>( "orientation", "TEXTORIENTATION" );
2723 dumpHex
< sal_uInt16
>( "button-flags", "OBJ-BUTTON-FLAGS" );
2724 dumpUnicode( "accelerator" );
2725 dumpUnicode( "fareast-accelerator" );
2726 dumpDec
< sal_uInt16
>( "text-len" );
2727 dumpDec
< sal_uInt16
>( "format-run-size" );
2731 case BIFF_ID_WINDOW1
:
2732 dumpDec
< sal_uInt16
>( "window-x", "CONV-TWIP-TO-CM" );
2733 dumpDec
< sal_uInt16
>( "window-y", "CONV-TWIP-TO-CM" );
2734 dumpDec
< sal_uInt16
>( "window-width", "CONV-TWIP-TO-CM" );
2735 dumpDec
< sal_uInt16
>( "window-height", "CONV-TWIP-TO-CM" );
2736 if( eBiff
<= BIFF4
)
2738 dumpBool
< sal_uInt8
>( "hidden" );
2742 dumpHex
< sal_uInt16
>( "flags", "WINDOW1-FLAGS" );
2743 dumpDec
< sal_uInt16
>( "active-tab" );
2744 dumpDec
< sal_uInt16
>( "first-visible-tab" );
2745 dumpDec
< sal_uInt16
>( "selected-tabs" );
2746 dumpDec
< sal_uInt16
>( "tabbar-ratio", "WINDOW1-TABBARRATIO" );
2750 case BIFF2_ID_WINDOW2
:
2751 dumpBool
< sal_uInt8
>( "show-formulas" );
2752 dumpBool
< sal_uInt8
>( "show-gridlines" );
2753 dumpBool
< sal_uInt8
>( "show-headings" );
2754 dumpBool
< sal_uInt8
>( "frozen-panes" );
2755 dumpBool
< sal_uInt8
>( "show-zeros" );
2756 dumpAddress( "first-visible-cell" );
2757 dumpBool
< sal_uInt8
>( "auto-grid-color" );
2758 dumpColorABGR( "grid-color" );
2761 case BIFF3_ID_WINDOW2
:
2762 dumpHex
< sal_uInt16
>( "flags", "WINDOW2-FLAGS" );
2763 dumpAddress( "first-visible-cell" );
2764 if( eBiff
== BIFF8
)
2766 dumpColorIdx( "grid-color-idx" );
2768 if( rStrm
.getRemaining() >= 8 )
2770 dumpDec
< sal_uInt16
>( "pagebreak-zoom", "CONV-PERCENT" );
2771 dumpDec
< sal_uInt16
>( "normal-zoom", "CONV-PERCENT" );
2776 dumpColorABGR( "grid-color" );
2780 dumpDec
< sal_uInt16
>( "crn-count" );
2781 if( eBiff
== BIFF8
) dumpDec
< sal_Int16
>( "sheet-idx" );
2793 void WorkbookStreamObject::initializePerSheet()
2795 getBiffData().initializePerSheet();
2796 mxFontNames
= cfg().createNameList
< ConstList
>( "FONTNAMES" );
2797 mxFontNames
->setName( 0, createFontName( CREATE_OUSTRING( "Arial" ), 200, false, false ) );
2798 mxFormats
= cfg().createNameList
< ConstList
>( "FORMATS" );
2799 mxFormats
->includeList( cfg().getNameList( "BUILTIN-FORMATS" ) );
2801 mbHasCodePage
= false;
2804 OUString
WorkbookStreamObject::createFontName( const OUString
& rName
, sal_uInt16 nHeight
, bool bBold
, bool bItalic
) const
2806 OUStringBuffer
aName( rName
);
2807 StringHelper::enclose( aName
, OOX_DUMP_STRQUOTE
);
2808 StringHelper::appendToken( aName
, cfg().getName( "CONV-TWIP-TO-PT", nHeight
), ',' );
2810 StringHelper::appendToken( aName
, CREATE_OUSTRING( "bold" ), ',' );
2812 StringHelper::appendToken( aName
, CREATE_OUSTRING( "italic" ), ',' );
2813 return aName
.makeStringAndClear();
2816 sal_uInt16
WorkbookStreamObject::dumpPatternIdx( const String
& rName
, bool b16Bit
)
2818 return dumpDec
< sal_uInt16
, sal_uInt8
>( b16Bit
, rName( "fill-pattern" ), mxFillPatterns
);
2821 sal_uInt16
WorkbookStreamObject::dumpColorIdx( const String
& rName
, bool b16Bit
)
2823 return dumpDec
< sal_uInt16
, sal_uInt8
>( b16Bit
, rName( "color-idx" ), mxColors
);
2826 sal_uInt16
WorkbookStreamObject::dumpFontIdx( const String
& rName
, bool b16Bit
)
2828 return dumpDec
< sal_uInt16
, sal_uInt8
>( b16Bit
, rName( "font-idx" ), "FONTNAMES" );
2831 sal_uInt16
WorkbookStreamObject::dumpFormatIdx( const String
& rName
)
2833 return dumpDec
< sal_uInt16
, sal_uInt8
>( getBiff() >= BIFF5
, rName( "fmt-idx" ), "FORMATS" );
2836 sal_uInt16
WorkbookStreamObject::dumpXfIdx( const String
& rName
, bool bBiff2Style
)
2838 String aName
= rName( "xf-idx" );
2839 sal_uInt16 nXfIdx
= 0;
2842 dumpHex
< sal_uInt8
>( aName
, "CELL-XFINDEX" );
2843 dumpHex
< sal_uInt8
>( "fmt-font-idx", "CELL-XFFORMAT" );
2844 dumpHex
< sal_uInt8
>( "style", "CELL-XFSTYLE" );
2847 nXfIdx
= dumpDec
< sal_uInt16
>( aName
);
2851 OUString
WorkbookStreamObject::dumpPivotString( const String
& rName
, sal_uInt16 nStrLen
)
2854 if( nStrLen
!= BIFF_PT_NOSTRING
)
2856 aString
= (getBiff() == BIFF8
) ?
2857 getBiffStream().readUniString( nStrLen
) :
2858 getBiffStream().readCharArrayUC( nStrLen
, getBiffData().getTextEncoding() );
2859 writeStringItem( rName
, aString
);
2864 OUString
WorkbookStreamObject::dumpPivotString( const String
& rName
)
2866 sal_uInt16 nStrLen
= dumpDec
< sal_uInt16
>( "string-len", "PIVOT-NAMELEN" );
2867 return dumpPivotString( rName
, nStrLen
);
2870 sal_uInt16
WorkbookStreamObject::dumpCellHeader( bool bBiff2Style
)
2873 return dumpXfIdx( EMPTY_STRING
, bBiff2Style
);
2876 void WorkbookStreamObject::dumpBoolErr()
2878 MultiItemsGuard
aMultiGuard( out() );
2879 sal_uInt8 nValue
= dumpHex
< sal_uInt8
>( "value" );
2880 bool bErrCode
= dumpBool
< sal_uInt8
>( "is-errorcode" );
2882 writeErrorCodeItem( "errorcode", nValue
);
2884 writeBooleanItem( "boolean", nValue
);
2887 void WorkbookStreamObject::dumpFontRec()
2889 sal_uInt16 nFontId
= getBiffData().getFontCount();
2890 out().resetItemIndex( nFontId
);
2891 writeEmptyItem( "#font" );
2892 sal_uInt16 nHeight
= dumpDec
< sal_uInt16
>( "height", "CONV-TWIP-TO-PT" );
2893 sal_uInt16 nFlags
= dumpHex
< sal_uInt16
>( "flags", "FONT-FLAGS" );
2894 bool bBold
= getFlag( nFlags
, BIFF_FONTFLAG_BOLD
);
2895 bool bItalic
= getFlag( nFlags
, BIFF_FONTFLAG_ITALIC
);
2896 rtl_TextEncoding eFontEnc
= RTL_TEXTENCODING_DONTKNOW
;
2897 if( getBiff() >= BIFF3
)
2899 if( getBiff() >= BIFF5
)
2901 bBold
= dumpDec
< sal_uInt16
>( "weight", "FONT-WEIGHT" ) > 450;
2902 dumpDec
< sal_uInt16
>( "escapement", "FONT-ESCAPEMENT" );
2903 dumpDec
< sal_uInt8
>( "underline", "FONT-UNDERLINE" );
2904 dumpDec
< sal_uInt8
>( "family", "FONT-FAMILY" );
2905 sal_uInt8 nCharSet
= dumpDec
< sal_uInt8
>( "charset", "CHARSET" );
2906 eFontEnc
= rtl_getTextEncodingFromWindowsCharset( nCharSet
);
2909 OUString aName
= dumpString( "name", BIFF_STR_8BITLENGTH
, BIFF_STR_8BITLENGTH
);
2911 // append font data to vector
2912 mxFontNames
->setName( nFontId
, createFontName( aName
, nHeight
, bBold
, bItalic
) );
2914 // store font encoding
2915 getBiffData().appendFontEncoding( eFontEnc
);
2917 // set font encoding as default text encoding in case of missing CODEPAGE record
2918 if( !mbHasCodePage
&& (nFontId
== 0) )
2919 getBiffData().setTextEncoding( eFontEnc
);
2922 void WorkbookStreamObject::dumpFormatRec()
2924 sal_uInt16 nFormatIdx
= 0;
2929 nFormatIdx
= mnFormatIdx
++;
2930 out().resetItemIndex( nFormatIdx
);
2931 writeEmptyItem( "#fmt" );
2934 nFormatIdx
= mnFormatIdx
++;
2935 out().resetItemIndex( nFormatIdx
);
2936 writeEmptyItem( "#fmt" );
2941 getBiffStream() >> nFormatIdx
;
2942 out().resetItemIndex( nFormatIdx
);
2943 writeEmptyItem( "#fmt" );
2944 writeDecItem( "fmt-idx", nFormatIdx
);
2946 case BIFF_UNKNOWN
: break;
2948 OUString aFormat
= dumpString( "format", BIFF_STR_8BITLENGTH
);
2949 mxFormats
->setName( nFormatIdx
, aFormat
);
2952 void WorkbookStreamObject::dumpXfRec()
2954 sal_uInt16 nXfId
= getBiffData().getXfCount();
2955 out().resetItemIndex( nXfId
);
2956 writeEmptyItem( "#xf" );
2957 sal_uInt16 nFontId
= dumpFontIdx( EMPTY_STRING
, getBiff() >= BIFF5
);
2962 dumpHex
< sal_uInt8
>( "type-flags", "XF-TYPEFLAGS" );
2963 dumpHex
< sal_uInt8
>( "style-flags", "XF-STYLEFLAGS" );
2967 dumpHex
< sal_uInt8
>( "type-flags", "XF-TYPEFLAGS" );
2968 dumpHex
< sal_uInt8
>( "used-attributes", "XF-USEDATTRIBS-FLAGS" );
2969 dumpHex
< sal_uInt16
>( "alignment", "XF-ALIGNMENT" );
2970 dumpHex
< sal_uInt16
>( "fill-style", "XF-FILL" );
2971 dumpHex
< sal_uInt32
>( "border-style", "XF-BORDER" );
2975 dumpHex
< sal_uInt16
>( "type-flags", "XF-TYPEFLAGS" );
2976 dumpHex
< sal_uInt8
>( "alignment", "XF-ALIGNMENT" );
2977 dumpHex
< sal_uInt8
>( "used-attributes", "XF-USEDATTRIBS-FLAGS" );
2978 dumpHex
< sal_uInt16
>( "fill-style", "XF-FILL" );
2979 dumpHex
< sal_uInt32
>( "border-style", "XF-BORDER" );
2983 dumpHex
< sal_uInt16
>( "type-flags", "XF-TYPEFLAGS" );
2984 dumpHex
< sal_uInt8
>( "alignment", "XF-ALIGNMENT" );
2985 dumpHex
< sal_uInt8
>( "orientation", "XF-ORIENTATTRIBS" );
2986 dumpHex
< sal_uInt32
>( "fill-style", "XF-FILL" );
2987 dumpHex
< sal_uInt32
>( "border-style", "XF-BORDER" );
2991 dumpHex
< sal_uInt16
>( "type-flags", "XF-TYPEFLAGS" );
2992 dumpHex
< sal_uInt8
>( "alignment", "XF-ALIGNMENT" );
2993 dumpDec
< sal_uInt8
>( "rotation", "TEXTROTATION" );
2994 dumpHex
< sal_uInt8
>( "text-flags", "XF-TEXTFLAGS" );
2995 dumpHex
< sal_uInt8
>( "used-attributes", "XF-USEDATTRIBS-FLAGS" );
2996 dumpHex
< sal_uInt16
>( "border-style", "XF-BORDERSTYLE" );
2997 dumpHex
< sal_uInt16
>( "border-color1", "XF-BORDERCOLOR1" );
2998 dumpHex
< sal_uInt32
>( "border-color2", "XF-BORDERCOLOR2" );
2999 dumpHex
< sal_uInt16
>( "fill-color", "XF-FILLCOLOR" );
3001 case BIFF_UNKNOWN
: break;
3003 getBiffData().appendXfFontId( nFontId
);
3006 void WorkbookStreamObject::dumpObjRec()
3020 // #i61786# OBJ records without DFF stream are in BIFF5 format
3021 if( mbHasDff
) dumpObjRecBiff8(); else dumpObjRecBiff5();
3027 void WorkbookStreamObject::dumpObjRecBiff3()
3029 dumpDec
< sal_uInt32
>( "obj-count" );
3030 sal_uInt16 nObjType
= dumpDec
< sal_uInt16
>( "obj-type", "OBJ-TYPE" );
3031 dumpDec
< sal_uInt16
>( "obj-id" );
3032 dumpHex
< sal_uInt16
>( "flags", "OBJ-FLAGS" );
3033 dumpDffClientRect();
3034 sal_uInt16 nMacroSize
= dumpDec
< sal_uInt16
>( "macro-size" );
3036 sal_uInt16 nTextLen
= 0, nFormatSize
= 0, nLinkSize
= 0;
3039 case BIFF_OBJTYPE_GROUP
:
3041 dumpDec
< sal_uInt16
>( "next-ungrouped-id" );
3043 dumpObjRecString( "macro", nMacroSize
, true );
3045 case BIFF_OBJTYPE_LINE
:
3046 dumpObjRecLineData();
3047 dumpHex
< sal_uInt16
>( "line-end", "OBJ-LINEENDS" );
3048 dumpDec
< sal_uInt8
>( "line-direction", "OBJ-LINEDIR" );
3050 dumpObjRecString( "macro", nMacroSize
, true );
3052 case BIFF_OBJTYPE_RECTANGLE
:
3053 case BIFF_OBJTYPE_OVAL
:
3054 dumpObjRecRectData();
3055 dumpObjRecString( "macro", nMacroSize
, true );
3057 case BIFF_OBJTYPE_ARC
:
3058 dumpObjRecFillData();
3059 dumpObjRecLineData();
3060 dumpDec
< sal_uInt8
>( "quadrant", "OBJ-ARC-QUADRANT" );
3062 dumpObjRecString( "macro", nMacroSize
, true );
3064 case BIFF_OBJTYPE_CHART
:
3065 dumpObjRecRectData();
3067 dumpObjRecString( "macro", nMacroSize
, true );
3069 case BIFF_OBJTYPE_TEXT
:
3070 case BIFF_OBJTYPE_BUTTON
:
3071 dumpObjRecRectData();
3072 dumpObjRecTextDataBiff3( nTextLen
, nFormatSize
);
3073 dumpObjRecString( "macro", nMacroSize
, true );
3074 dumpObjRecString( "text", nTextLen
, false );
3075 dumpObjRecTextFmt( nFormatSize
);
3077 case BIFF_OBJTYPE_PICTURE
:
3078 dumpObjRecRectData();
3079 dumpDec
< sal_Int16
>( "image-format", "IMGDATA-FORMAT" );
3081 nLinkSize
= dumpDec
< sal_uInt16
>( "pic-link-size" );
3083 dumpHex
< sal_uInt16
>( "flags", "OBJ-PICTURE-FLAGS" );
3084 dumpObjRecString( "macro", nMacroSize
, true );
3085 dumpObjRecPictFmla( nLinkSize
);
3090 void WorkbookStreamObject::dumpObjRecBiff4()
3092 dumpDec
< sal_uInt32
>( "obj-count" );
3093 sal_uInt16 nObjType
= dumpDec
< sal_uInt16
>( "obj-type", "OBJ-TYPE" );
3094 dumpDec
< sal_uInt16
>( "obj-id" );
3095 dumpHex
< sal_uInt16
>( "flags", "OBJ-FLAGS" );
3096 dumpDffClientRect();
3097 sal_uInt16 nMacroSize
= dumpDec
< sal_uInt16
>( "macro-size" );
3099 sal_uInt16 nTextLen
= 0, nFormatSize
= 0, nLinkSize
= 0;
3102 case BIFF_OBJTYPE_GROUP
:
3104 dumpDec
< sal_uInt16
>( "next-ungrouped-id" );
3106 dumpObjRecFmla( "macro", nMacroSize
);
3108 case BIFF_OBJTYPE_LINE
:
3109 dumpObjRecLineData();
3110 dumpHex
< sal_uInt16
>( "line-end", "OBJ-LINEENDS" );
3111 dumpDec
< sal_uInt8
>( "line-direction", "OBJ-LINEDIR" );
3113 dumpObjRecFmla( "macro", nMacroSize
);
3115 case BIFF_OBJTYPE_RECTANGLE
:
3116 case BIFF_OBJTYPE_OVAL
:
3117 dumpObjRecRectData();
3118 dumpObjRecFmla( "macro", nMacroSize
);
3120 case BIFF_OBJTYPE_ARC
:
3121 dumpObjRecFillData();
3122 dumpObjRecLineData();
3123 dumpDec
< sal_uInt8
>( "quadrant", "OBJ-ARC-QUADRANT" );
3125 dumpObjRecFmla( "macro", nMacroSize
);
3127 case BIFF_OBJTYPE_CHART
:
3128 dumpObjRecRectData();
3130 dumpObjRecFmla( "macro", nMacroSize
);
3132 case BIFF_OBJTYPE_TEXT
:
3133 case BIFF_OBJTYPE_BUTTON
:
3134 dumpObjRecRectData();
3135 dumpObjRecTextDataBiff3( nTextLen
, nFormatSize
);
3136 dumpObjRecFmla( "macro", nMacroSize
);
3137 dumpObjRecString( "text", nTextLen
, false );
3138 dumpObjRecTextFmt( nFormatSize
);
3140 case BIFF_OBJTYPE_PICTURE
:
3141 dumpObjRecRectData();
3142 dumpDec
< sal_Int16
>( "image-format", "IMGDATA-FORMAT" );
3144 nLinkSize
= dumpDec
< sal_uInt16
>( "pic-link-size" );
3146 dumpHex
< sal_uInt16
>( "flags", "OBJ-PICTURE-FLAGS" );
3147 dumpObjRecFmla( "macro", nMacroSize
);
3148 dumpObjRecPictFmla( nLinkSize
);
3150 case BIFF_OBJTYPE_POLYGON
:
3151 dumpObjRecRectData();
3152 dumpHex
< sal_uInt16
>( "flags", "OBJ-POLYGON-FLAGS" );
3154 dumpDec
< sal_uInt16
>( "point-count" );
3156 dumpObjRecFmla( "macro", nMacroSize
);
3161 void WorkbookStreamObject::dumpObjRecBiff5()
3163 BiffInputStream
& rStrm
= getBiffStream();
3164 dumpDec
< sal_uInt32
>( "obj-count" );
3165 sal_uInt16 nObjType
= dumpDec
< sal_uInt16
>( "obj-type", "OBJ-TYPE" );
3166 dumpDec
< sal_uInt16
>( "obj-id" );
3167 dumpHex
< sal_uInt16
>( "flags", "OBJ-FLAGS" );
3168 dumpDffClientRect();
3169 sal_uInt16 nMacroSize
= dumpDec
< sal_uInt16
>( "macro-size" );
3171 sal_uInt16 nNameLen
= dumpDec
< sal_uInt16
>( "name-len" );
3173 sal_uInt16 nTextLen
= 0, nFormatSize
= 0, nLinkSize
= 0;
3176 case BIFF_OBJTYPE_GROUP
:
3178 dumpDec
< sal_uInt16
>( "next-ungrouped-id" );
3180 dumpObjRecString( "obj-name", nNameLen
, true );
3181 dumpObjRecFmla( "macro", nMacroSize
);
3183 case BIFF_OBJTYPE_LINE
:
3184 dumpObjRecLineData();
3185 dumpHex
< sal_uInt16
>( "line-end", "OBJ-LINEENDS" );
3186 dumpDec
< sal_uInt8
>( "line-direction", "OBJ-LINEDIR" );
3188 dumpObjRecString( "obj-name", nNameLen
, true );
3189 dumpObjRecFmla( "macro", nMacroSize
);
3191 case BIFF_OBJTYPE_RECTANGLE
:
3192 case BIFF_OBJTYPE_OVAL
:
3193 dumpObjRecRectData();
3194 dumpObjRecString( "obj-name", nNameLen
, true );
3195 dumpObjRecFmla( "macro", nMacroSize
);
3197 case BIFF_OBJTYPE_ARC
:
3198 dumpObjRecFillData();
3199 dumpObjRecLineData();
3200 dumpDec
< sal_uInt8
>( "quadrant", "OBJ-ARC-QUADRANT" );
3202 dumpObjRecString( "obj-name", nNameLen
, true );
3203 dumpObjRecFmla( "macro", nMacroSize
);
3205 case BIFF_OBJTYPE_CHART
:
3206 dumpObjRecRectData();
3207 dumpHex
< sal_uInt16
>( "chart-flags", "OBJ-CHART-FLAGS" );
3209 dumpObjRecString( "obj-name", nNameLen
, true );
3210 dumpObjRecFmla( "macro", nMacroSize
);
3212 case BIFF_OBJTYPE_TEXT
:
3213 case BIFF_OBJTYPE_BUTTON
:
3214 case BIFF_OBJTYPE_LABEL
:
3215 case BIFF_OBJTYPE_DIALOG
:
3216 dumpObjRecRectData();
3217 dumpObjRecTextDataBiff5( nTextLen
, nFormatSize
, nLinkSize
);
3218 dumpObjRecString( "obj-name", nNameLen
, true );
3219 dumpObjRecFmla( "macro", nMacroSize
);
3220 dumpObjRecString( "text", nTextLen
, false );
3221 dumpObjRecFmla( "text-link", nLinkSize
);
3222 dumpObjRecTextFmt( nFormatSize
);
3224 case BIFF_OBJTYPE_PICTURE
:
3225 dumpObjRecRectData();
3226 dumpDec
< sal_Int16
>( "image-format", "IMGDATA-FORMAT" );
3228 nLinkSize
= dumpDec
< sal_uInt16
>( "pic-link-size" );
3230 dumpHex
< sal_uInt16
>( "flags", "OBJ-PICTURE-FLAGS" );
3232 dumpObjRecString( "obj-name", nNameLen
, true );
3233 dumpObjRecFmla( "macro", nMacroSize
);
3234 dumpObjRecPictFmla( nLinkSize
);
3235 if( rStrm
.getRemaining() >= 4 )
3236 dumpHex
< sal_uInt32
>( "ole-storage-id" );
3238 case BIFF_OBJTYPE_POLYGON
:
3239 dumpObjRecRectData();
3240 dumpHex
< sal_uInt16
>( "flags", "OBJ-POLYGON-FLAGS" );
3242 dumpDec
< sal_uInt16
>( "point-count" );
3244 dumpObjRecString( "obj-name", nNameLen
, true );
3245 dumpObjRecFmla( "macro", nMacroSize
);
3247 case BIFF_OBJTYPE_CHECKBOX
:
3248 dumpObjRecRectData();
3250 dumpHex
< sal_uInt16
>( "flags", "OBJ-TEXT-FLAGS" );
3252 dumpObjRecString( "obj-name", nNameLen
, true );
3253 dumpObjRecFmla( "macro", dumpDec
< sal_uInt16
>( "macro-size" ) );
3254 dumpObjRecFmla( "cell-link", dumpDec
< sal_uInt16
>( "cell-link-size" ) );
3255 dumpObjRecString( "text", dumpDec
< sal_uInt16
>( "text-len" ), false );
3256 dumpObjRecCblsData();
3258 case BIFF_OBJTYPE_OPTIONBUTTON
:
3259 dumpObjRecRectData();
3261 dumpHex
< sal_uInt16
>( "flags", "OBJ-TEXT-FLAGS" );
3263 dumpObjRecString( "obj-name", nNameLen
, true );
3264 dumpObjRecFmla( "macro", dumpDec
< sal_uInt16
>( "macro-size" ) );
3265 dumpObjRecFmla( "cell-link", dumpDec
< sal_uInt16
>( "cell-link-size" ) );
3266 dumpObjRecString( "text", dumpDec
< sal_uInt16
>( "text-len" ), false );
3267 dumpObjRecCblsData();
3268 dumpObjRecRboData();
3270 case BIFF_OBJTYPE_EDIT
:
3271 dumpObjRecRectData();
3273 dumpHex
< sal_uInt16
>( "flags", "OBJ-TEXT-FLAGS" );
3275 dumpObjRecString( "obj-name", nNameLen
, true );
3276 dumpObjRecFmla( "macro", dumpDec
< sal_uInt16
>( "macro-size" ) );
3277 dumpObjRecString( "text", dumpDec
< sal_uInt16
>( "text-len" ), false );
3278 dumpObjRecEdoData();
3280 case BIFF_OBJTYPE_SPIN
:
3281 case BIFF_OBJTYPE_SCROLLBAR
:
3282 dumpObjRecRectData();
3283 dumpObjRecSbsData();
3284 dumpObjRecString( "obj-name", nNameLen
, true );
3285 dumpObjRecFmla( "macro", dumpDec
< sal_uInt16
>( "macro-size" ) );
3286 dumpObjRecFmla( "cell-link", dumpDec
< sal_uInt16
>( "cell-link-size" ) );
3288 case BIFF_OBJTYPE_LISTBOX
:
3289 dumpObjRecRectData();
3290 dumpObjRecSbsData();
3292 dumpFontIdx( "font-idx" );
3294 dumpObjRecString( "obj-name", nNameLen
, true );
3295 dumpObjRecFmla( "macro", dumpDec
< sal_uInt16
>( "macro-size" ) );
3296 dumpObjRecFmla( "cell-link", dumpDec
< sal_uInt16
>( "cell-link-size" ) );
3297 dumpObjRecLbsData();
3299 case BIFF_OBJTYPE_GROUPBOX
:
3300 dumpObjRecRectData();
3302 dumpHex
< sal_uInt16
>( "flags", "OBJ-TEXT-FLAGS" );
3304 dumpObjRecString( "obj-name", nNameLen
, true );
3305 dumpObjRecFmla( "macro", dumpDec
< sal_uInt16
>( "macro-size" ) );
3306 dumpObjRecString( "text", dumpDec
< sal_uInt16
>( "text-len" ), false );
3307 dumpObjRecGboData();
3309 case BIFF_OBJTYPE_DROPDOWN
:
3310 dumpObjRecRectData();
3311 dumpObjRecSbsData();
3313 dumpFontIdx( "font-idx" );
3315 dumpDec
< sal_uInt16
>( "bounding-left" );
3316 dumpDec
< sal_uInt16
>( "bounding-top" );
3317 dumpDec
< sal_uInt16
>( "bounding-right" );
3318 dumpDec
< sal_uInt16
>( "bounding-bottom" );
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();
3324 dumpDec
< sal_uInt16
>( "type", "OBJ-DROPDOWN-TYPE" );
3325 dumpDec
< sal_uInt16
>( "line-count" );
3326 dumpDec
< sal_uInt16
>( "min-list-width" );
3327 dumpObjRecString( "text", dumpDec
< sal_uInt16
>( "text-len" ), false );
3332 void WorkbookStreamObject::dumpObjRecBiff8()
3334 Output
& rOut
= out();
3335 BiffInputStream
& rStrm
= getBiffStream();
3336 NameListRef xRecNames
= cfg().getNameList( "OBJ-RECNAMES" );
3337 sal_uInt16 nObjType
= 0xFFFF;
3338 bool bControl
= false;
3339 bool bCtlsStrm
= false;
3341 while( bLoop
&& (rStrm
.getRemaining() >= 4) )
3344 sal_uInt16 nSubRecId
, nSubRecSize
;
3346 MultiItemsGuard
aMultiGuard( rOut
);
3347 writeEmptyItem( "OBJREC" );
3348 writeHexItem( "pos", static_cast< sal_uInt32
>( rStrm
.tell() ) );
3349 rStrm
>> nSubRecId
>> nSubRecSize
;
3350 writeHexItem( "size", nSubRecSize
);
3351 writeHexItem( "id", nSubRecId
, xRecNames
);
3354 sal_Int64 nSubRecStart
= rStrm
.tell();
3355 // sometimes the last subrecord has an invalid length
3356 sal_Int64 nRealRecSize
= ::std::min
< sal_Int64
>( nSubRecSize
, rStrm
.getRemaining() );
3357 sal_Int64 nSubRecEnd
= nSubRecStart
+ nRealRecSize
;
3359 IndentGuard
aIndGuard( rOut
);
3362 case BIFF_ID_OBJMACRO
:
3363 dumpObjRecFmlaRaw();
3366 dumpDec
< sal_Int16
>( "clipboard-format", "IMGDATA-FORMAT" );
3368 case BIFF_ID_OBJFLAGS
:
3370 sal_uInt16 nFlags
= dumpHex
< sal_uInt16
>( "flags", "OBJFLAGS-FLAGS" );
3371 bControl
= getFlag( nFlags
, BIFF_OBJFLAGS_CONTROL
);
3372 bCtlsStrm
= getFlag( nFlags
, BIFF_OBJFLAGS_CTLSSTREAM
);
3375 case BIFF_ID_OBJPICTFMLA
:
3377 dumpObjRecPictFmla( dumpDec
< sal_uInt16
>( "pic-link-size" ) );
3378 if( rStrm
.tell() + 4 <= nSubRecEnd
)
3380 if( bControl
&& bCtlsStrm
)
3383 dumpHex
< sal_uInt32
>( "ole-storage-id" );
3385 if( bControl
&& (rStrm
.tell() + 8 <= nSubRecEnd
) )
3387 sal_uInt32 nKeySize
= dumpDec
< sal_uInt32
>( "licence-key-size" );
3390 IndentGuard
aIndGuard2( rOut
);
3391 sal_Int64 nKeyEnd
= rStrm
.tell() + nKeySize
;
3392 dumpArray( "licence-key", static_cast< sal_Int32
>( nKeySize
) );
3393 rStrm
.seek( nKeyEnd
);
3395 dumpObjRecFmla( "cell-link", dumpDec
< sal_uInt16
>( "cell-link-size" ) );
3396 dumpObjRecFmla( "source-range", dumpDec
< sal_uInt16
>( "source-range-size" ) );
3400 case BIFF_ID_OBJCBLS
:
3401 dumpDec
< sal_uInt16
>( "state", "OBJ-CHECKBOX-STATE" );
3403 dumpUnicode( "accelerator" );
3404 dumpUnicode( "fareast-accelerator" );
3405 dumpHex
< sal_uInt16
>( "checkbox-flags", "OBJ-CHECKBOX-FLAGS" );
3407 case BIFF_ID_OBJRBO
:
3409 dumpBool
< sal_uInt16
>( "first-in-group" );
3411 case BIFF_ID_OBJSBS
:
3412 dumpObjRecSbsData();
3414 case BIFF_ID_OBJGBODATA
:
3415 dumpObjRecGboData();
3417 case BIFF_ID_OBJEDODATA
:
3418 dumpObjRecEdoData();
3420 case BIFF_ID_OBJRBODATA
:
3421 dumpObjRecRboData();
3423 case BIFF_ID_OBJCBLSDATA
:
3424 dumpObjRecCblsData();
3426 case BIFF_ID_OBJLBSDATA
:
3427 dumpObjRecLbsData();
3428 if( nObjType
== BIFF_OBJTYPE_DROPDOWN
)
3430 dumpHex
< sal_uInt16
>( "dropdown-flags", "OBJ-DROPDOWN-FLAGS" );
3431 dumpDec
< sal_uInt16
>( "line-count" );
3432 dumpDec
< sal_uInt16
>( "min-list-width" );
3433 dumpObjRecString( "text", dumpDec
< sal_uInt16
>( "text-len" ), false );
3436 case BIFF_ID_OBJCBLSFMLA
:
3437 case BIFF_ID_OBJSBSFMLA
:
3438 dumpObjRecFmlaRaw();
3440 case BIFF_ID_OBJCMO
:
3441 nObjType
= dumpDec
< sal_uInt16
>( "type", "OBJ-TYPE" );
3442 dumpDec
< sal_uInt16
>( "id" );
3443 dumpHex
< sal_uInt16
>( "flags", "OBJCMO-FLAGS" );
3447 // remaining undumped data
3448 if( !rStrm
.isEof() && (rStrm
.tell() == nSubRecStart
) )
3449 dumpRawBinary( nRealRecSize
, false );
3451 dumpRemainingTo( nSubRecEnd
);
3455 void WorkbookStreamObject::dumpObjRecLineData()
3457 dumpColorIdx( "line-color-idx", false );
3458 dumpDec
< sal_uInt8
>( "line-type", "OBJ-LINETYPE" );
3459 dumpDec
< sal_uInt8
>( "line-weight", "OBJ-LINEWEIGHT" );
3460 dumpHex
< sal_uInt8
>( "line-flags", "OBJ-AUTO-FLAGS" );
3463 void WorkbookStreamObject::dumpObjRecFillData()
3465 dumpColorIdx( "back-color-idx", false );
3466 dumpColorIdx( "patt-color-idx", false );
3467 dumpPatternIdx( EMPTY_STRING
, false );
3468 dumpHex
< sal_uInt8
>( "area-flags", "OBJ-AUTO-FLAGS" );
3471 void WorkbookStreamObject::dumpObjRecRectData()
3473 dumpObjRecFillData();
3474 dumpObjRecLineData();
3475 dumpHex
< sal_uInt16
>( "frame-style", "OBJ-FRAMESTYLE-FLAGS" );
3478 void WorkbookStreamObject::dumpObjRecTextDataBiff3( sal_uInt16
& ornTextLen
, sal_uInt16
& ornFormatSize
)
3480 ornTextLen
= dumpDec
< sal_uInt16
>( "text-len" );
3482 ornFormatSize
= dumpDec
< sal_uInt16
>( "format-run-size" );
3483 dumpFontIdx( "default-font-idx" );
3485 dumpHex
< sal_uInt16
>( "flags", "OBJ-TEXT-FLAGS" );
3486 dumpDec
< sal_uInt16
>( "orientation", "TEXTORIENTATION" );
3490 void WorkbookStreamObject::dumpObjRecTextDataBiff5( sal_uInt16
& ornTextLen
, sal_uInt16
& ornFormatSize
, sal_uInt16
& ornLinkSize
)
3492 ornTextLen
= dumpDec
< sal_uInt16
>( "text-len" );
3494 ornFormatSize
= dumpDec
< sal_uInt16
>( "format-run-size" );
3495 dumpFontIdx( "default-font-idx" );
3497 dumpHex
< sal_uInt16
>( "flags", "OBJ-TEXT-FLAGS" );
3498 dumpDec
< sal_uInt16
>( "orientation", "TEXTORIENTATION" );
3500 ornLinkSize
= dumpDec
< sal_uInt16
>( "link-size" );
3502 dumpHex
< sal_uInt16
>( "button-flags", "OBJ-BUTTON-FLAGS" );
3503 dumpUnicode( "accelerator" );
3504 dumpUnicode( "fareast-accelerator" );
3507 void WorkbookStreamObject::dumpObjRecSbsData()
3510 dumpDec
< sal_uInt16
>( "value" );
3511 dumpDec
< sal_uInt16
>( "min" );
3512 dumpDec
< sal_uInt16
>( "max" );
3513 dumpDec
< sal_uInt16
>( "step" );
3514 dumpDec
< sal_uInt16
>( "page-step" );
3515 dumpBool
< sal_uInt16
>( "horizontal" );
3516 dumpDec
< sal_uInt16
>( "thumb-width" );
3517 dumpHex
< sal_uInt16
>( "scrollbar-flags", "OBJ-SCROLLBAR-FLAGS" );
3520 void WorkbookStreamObject::dumpObjRecGboData()
3522 dumpUnicode( "accelerator" );
3523 dumpUnicode( "fareast-accelerator" );
3524 dumpHex
< sal_uInt16
>( "groupbox-flags", "OBJ-GROUPBOX-FLAGS" );
3527 void WorkbookStreamObject::dumpObjRecEdoData()
3529 dumpDec
< sal_uInt16
>( "type", "OBJ-EDIT-TYPE" );
3530 dumpBool
< sal_uInt16
>( "multiline" );
3531 dumpBool
< sal_uInt16
>( "scrollbar" );
3532 dumpDec
< sal_uInt16
>( "listbox-obj-id" );
3535 void WorkbookStreamObject::dumpObjRecRboData()
3537 dumpDec
< sal_uInt16
>( "next-in-group" );
3538 dumpBool
< sal_uInt16
>( "first-in-group" );
3541 void WorkbookStreamObject::dumpObjRecCblsData()
3543 dumpDec
< sal_uInt16
>( "state", "OBJ-CHECKBOX-STATE" );
3544 dumpUnicode( "accelerator" );
3545 dumpUnicode( "fareast-accelerator" );
3546 dumpHex
< sal_uInt16
>( "checkbox-flags", "OBJ-CHECKBOX-FLAGS" );
3549 void WorkbookStreamObject::dumpObjRecLbsData()
3551 dumpObjRecFmla( "source-range", dumpDec
< sal_uInt16
>( "source-range-size" ) );
3552 dumpDec
< sal_uInt16
>( "entry-count" );
3553 dumpDec
< sal_uInt16
>( "selected-entry" );
3554 dumpHex
< sal_uInt16
>( "listbox-flags", "OBJ-LISTBOX-FLAGS" );
3555 dumpDec
< sal_uInt16
>( "edit-obj-id" );
3558 void WorkbookStreamObject::dumpObjRecPadding()
3560 if( getBiffStream().tell() & 1 )
3562 IndentGuard
aIndGuard( out() );
3563 dumpHex
< sal_uInt8
>( "padding" );
3567 void WorkbookStreamObject::dumpObjRecString( const String
& rName
, sal_uInt16 nTextLen
, bool bRepeatLen
)
3572 dumpByteString( rName
, BIFF_STR_8BITLENGTH
);
3574 writeStringItem( rName
, getBiffStream().readCharArrayUC( nTextLen
, getBiffData().getTextEncoding() ) );
3575 dumpObjRecPadding();
3579 void WorkbookStreamObject::dumpObjRecTextFmt( sal_uInt16 nFormatSize
)
3581 FontPortionModelList aPortions
;
3582 aPortions
.importPortions( getBiffStream(), nFormatSize
/ 8, BIFF_FONTPORTION_OBJ
);
3583 writeFontPortions( aPortions
);
3586 void WorkbookStreamObject::dumpObjRecFmlaRaw()
3588 sal_uInt16 nFmlaSize
= dumpDec
< sal_uInt16
>( "fmla-size" );
3590 getFormulaDumper().dumpNameFormula( "fmla", nFmlaSize
);
3591 dumpObjRecPadding();
3594 void WorkbookStreamObject::dumpObjRecFmla( const String
& rName
, sal_uInt16 nFmlaSize
)
3596 BiffInputStream
& rStrm
= getBiffStream();
3599 writeEmptyItem( rName
);
3600 IndentGuard
aIndGuard( out() );
3601 sal_Int64 nStrmEnd
= rStrm
.tell() + nFmlaSize
;
3602 dumpObjRecFmlaRaw();
3603 if( rStrm
.isEof() || (rStrm
.tell() != nStrmEnd
) )
3604 writeEmptyItem( OOX_DUMP_ERRASCII( "fmla-size" ) );
3605 dumpRemainingTo( nStrmEnd
);
3609 void WorkbookStreamObject::dumpObjRecPictFmla( sal_uInt16 nFmlaSize
)
3611 BiffInputStream
& rStrm
= getBiffStream();
3614 writeEmptyItem( "pic-link" );
3615 IndentGuard
aIndGuard( out() );
3616 sal_Int64 nStrmEnd
= rStrm
.tell() + nFmlaSize
;
3617 if( (getBiff() == BIFF3
) && (nStrmEnd
& 1) ) ++nStrmEnd
; // BIFF3 size without padding
3618 dumpObjRecFmlaRaw();
3619 if( rStrm
.tell() + 2 <= nStrmEnd
)
3621 dumpString( "class-name", BIFF_STR_DEFAULT
, BIFF_STR_SMARTFLAGS
);
3622 dumpObjRecPadding();
3624 if( rStrm
.isEof() || (rStrm
.tell() != nStrmEnd
) )
3625 writeEmptyItem( OOX_DUMP_ERRASCII( "pic-link-size" ) );
3626 dumpRemainingTo( nStrmEnd
);
3630 // ============================================================================
3632 PivotCacheStreamObject::PivotCacheStreamObject( const ObjectBase
& rParent
, const BinaryInputStreamRef
& rxStrm
, BiffType eBiff
, const ::rtl::OUString
& rSysFileName
)
3634 RecordStreamObject::construct( rParent
, rxStrm
, eBiff
, rSysFileName
);
3637 void PivotCacheStreamObject::implDumpRecordBody()
3639 BiffInputStream
& rStrm
= getBiffStream();
3640 sal_uInt16 nRecId
= rStrm
.getRecId();
3644 case BIFF_ID_PCDEFINITION
:
3645 dumpDec
< sal_Int32
>( "source-records" );
3646 dumpHex
< sal_uInt16
>( "cache-id" );
3647 dumpHex
< sal_uInt16
>( "flags", "PCDEFINITION-FLAGS" );
3649 dumpDec
< sal_uInt16
>( "sourcedata-field-count" );
3650 dumpDec
< sal_uInt16
>( "cache-field-count" );
3651 dumpDec
< sal_uInt16
>( "report-record-count" );
3652 dumpDec
< sal_uInt16
>( "database-type", "PCDSOURCE-TYPE" );
3653 dumpString( "user-name" );
3656 case BIFF_ID_PCDEFINITION2
:
3657 dumpDec
< double >( "refreshed-date" );
3658 dumpDec
< sal_Int32
>( "formula-count" );
3661 case BIFF_ID_PCDFDISCRETEPR
:
3662 out().resetItemIndex();
3663 while( !rStrm
.isEof() && (rStrm
.getRemaining() >= 2) )
3664 dumpDec
< sal_uInt16
>( "#item-index" );
3667 case BIFF_ID_PCDFIELD
:
3668 dumpHex
< sal_uInt16
>( "flags", "PCDFIELD-FLAGS" );
3669 dumpDec
< sal_uInt16
>( "group-parent-field" );
3670 dumpDec
< sal_uInt16
>( "group-base-field" );
3671 dumpDec
< sal_uInt16
>( "unique-items" );
3672 dumpDec
< sal_uInt16
>( "group-items" );
3673 dumpDec
< sal_uInt16
>( "base-items" );
3674 dumpDec
< sal_uInt16
>( "shared-items" );
3675 if( rStrm
.getRemaining() >= 3 )
3676 dumpString( "item-name" );
3679 case BIFF_ID_PCITEM_DATE
:
3682 aDateTime
.Year
= in().readuInt16();
3683 aDateTime
.Month
= in().readuInt16();
3684 aDateTime
.Day
= in().readuInt8();
3685 aDateTime
.Hours
= in().readuInt8();
3686 aDateTime
.Minutes
= in().readuInt8();
3687 aDateTime
.Seconds
= in().readuInt8();
3688 writeDateTimeItem( "value", aDateTime
);
3692 case BIFF_ID_PCITEM_STRING
:
3693 dumpString( "value" );
3698 // ============================================================================
3699 // ============================================================================
3701 RootStorageObject::RootStorageObject( const DumperBase
& rParent
)
3703 OleStorageObject::construct( rParent
);
3704 addPreferredStream( "Book" );
3705 addPreferredStream( "Workbook" );
3708 void RootStorageObject::implDumpStream( const BinaryInputStreamRef
& rxStrm
, const OUString
& rStrgPath
, const OUString
& rStrmName
, const OUString
& rSysFileName
)
3710 if( (rStrgPath
.getLength() == 0) && (rStrmName
.equalsAscii( "Book" ) || rStrmName
.equalsAscii( "Workbook" )) )
3711 WorkbookStreamObject( *this, rxStrm
, rSysFileName
).dump();
3712 else if( rStrgPath
.equalsAscii( "_SX_DB" ) )
3713 PivotCacheStreamObject( *this, rxStrm
, BIFF5
, rSysFileName
).dump();
3714 else if( rStrgPath
.equalsAscii( "_SX_DB_CUR" ) )
3715 PivotCacheStreamObject( *this, rxStrm
, BIFF8
, rSysFileName
).dump();
3717 OleStorageObject::implDumpStream( rxStrm
, rStrgPath
, rStrmName
, rSysFileName
);
3720 void RootStorageObject::implDumpStorage( const StorageRef
& rxStrg
, const OUString
& rStrgPath
, const OUString
& rSysPath
)
3722 if( rStrgPath
.equalsAscii( "_VBA_PROJECT_CUR" ) )
3723 VbaProjectStorageObject( *this, rxStrg
, rSysPath
).dump();
3725 OleStorageObject::implDumpStorage( rxStrg
, rStrgPath
, rSysPath
);
3728 // ============================================================================
3729 // ============================================================================
3731 #define DUMP_BIFF_CONFIG_ENVVAR "OOO_BIFFDUMPER"
3733 Dumper::Dumper( const FilterBase
& rFilter
)
3735 ConfigRef
xCfg( new Config( DUMP_BIFF_CONFIG_ENVVAR
, rFilter
) );
3736 DumperBase::construct( xCfg
);
3739 Dumper::Dumper( const Reference
< XMultiServiceFactory
>& rxFactory
, const Reference
< XInputStream
>& rxInStrm
, const OUString
& rSysFileName
)
3741 if( rxFactory
.is() && rxInStrm
.is() )
3743 StorageRef
xStrg( new OleStorage( rxFactory
, rxInStrm
, true ) );
3744 MediaDescriptor aMediaDesc
;
3745 ConfigRef
xCfg( new Config( DUMP_BIFF_CONFIG_ENVVAR
, rxFactory
, xStrg
, rSysFileName
, aMediaDesc
) );
3746 DumperBase::construct( xCfg
);
3750 void Dumper::implDump()
3752 RootStorageObject
aRootStrg( *this );
3753 if( aRootStrg
.isValid() )
3757 else if( StorageBase
* pRootStrg
= cfg().getRootStorage().get() )
3759 // try to dump plain BIFF stream
3760 BinaryInputStreamRef
xStrm( new BinaryXInputStream( pRootStrg
->openInputStream( OUString() ), false ) );
3761 WorkbookStreamObject( *this, xStrm
, cfg().getSysFileName() ).dump();
3765 // ============================================================================