diff options
author | Vladimir Glazounov <vg@openoffice.org> | 2008-09-30 13:51:36 +0000 |
---|---|---|
committer | Vladimir Glazounov <vg@openoffice.org> | 2008-09-30 13:51:36 +0000 |
commit | 07cabd8e634679ff59db4d72eacdfb514feb3cd1 (patch) | |
tree | 41b064504b537ff35a017aad8373870ae2cc1738 | |
parent | a53f44d8fba07d9f7a79ac594a85b1059f1ae4a6 (diff) |
CWS-TOOLING: integrate CWS dr63
125 files changed, 13847 insertions, 9301 deletions
diff --git a/oox/inc/oox/core/filterbase.hxx b/oox/inc/oox/core/filterbase.hxx index 8da8c7a9a3f8..19a816d0aaae 100644 --- a/oox/inc/oox/core/filterbase.hxx +++ b/oox/inc/oox/core/filterbase.hxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: filterbase.hxx,v $ - * $Revision: 1.4 $ + * $Revision: 1.4.20.1 $ * * This file is part of OpenOffice.org. * @@ -85,9 +85,13 @@ public: // ------------------------------------------------------------------------ - /** Returns the service factory passed in the constructor. */ + /** Returns the arguments passed through the XInitialisation interface. */ + const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& + getArguments() const; + + /** Returns the global service factory passed in the filter constructor. */ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& - getServiceFactory() const; + getGlobalFactory() const; /** Returns the document model. */ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& diff --git a/oox/inc/oox/core/namespaces.hxx b/oox/inc/oox/core/namespaces.hxx index 0155bb5304df..ccc7d376ffc6 100644 --- a/oox/inc/oox/core/namespaces.hxx +++ b/oox/inc/oox/core/namespaces.hxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: namespaces.hxx,v $ - * $Revision: 1.5 $ + * $Revision: 1.5.4.1 $ * * This file is part of OpenOffice.org. * @@ -43,23 +43,24 @@ const sal_Int32 NMSP_PACKAGE_RELATIONSHIPS = 2 << 16; const sal_Int32 NMSP_RELATIONSHIPS = 3 << 16; const sal_Int32 NMSP_CONTENT_TYPES = 4 << 16; // office global -const sal_Int32 NMSP_OFFICE = 11 << 16; const sal_Int32 NMSP_ACTIVATION = 12 << 16; // DrawingML const sal_Int32 NMSP_DRAWINGML = 21 << 16; const sal_Int32 NMSP_DIAGRAM = 22 << 16; const sal_Int32 NMSP_CHART = 23 << 16; -const sal_Int32 NMSP_VML = 24 << 16; -// WordML -const sal_Int32 NMSP_WORD = 31 << 16; // Word VML +// VML +const sal_Int32 NMSP_VML = 31 << 16; +const sal_Int32 NMSP_OFFICE = 32 << 16; +const sal_Int32 NMSP_VML_DOC = 33 << 16; // Word VML +const sal_Int32 NMSP_VML_XLS = 34 << 16; // Excel VML +const sal_Int32 NMSP_VML_PPT = 35 << 16; // PowerPoint VML +const sal_Int32 NMSP_AX = 36 << 16; // ActiveX (for OCX form controls) // SpreadsheetML const sal_Int32 NMSP_XLS = 41 << 16; const sal_Int32 NMSP_XDR = 42 << 16; // SpreadsheetDrawingML const sal_Int32 NMSP_XM = 43 << 16; // Macro sheet -const sal_Int32 NMSP_EXCEL = 44 << 16; // Excel VML // PresentationML const sal_Int32 NMSP_PPT = 51 << 16; -const sal_Int32 NMSP_POWERPOINT = 52 << 16; // PowerPoint VML // Document properties const sal_Int32 NMSP_COREPR = 61 << 16; const sal_Int32 NMSP_DC = 62 << 16; diff --git a/oox/inc/oox/core/recordparser.hxx b/oox/inc/oox/core/recordparser.hxx index d3e9317819c0..aabdd4ad3152 100644 --- a/oox/inc/oox/core/recordparser.hxx +++ b/oox/inc/oox/core/recordparser.hxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: recordparser.hxx,v $ - * $Revision: 1.4 $ + * $Revision: 1.4.20.1 $ * * This file is part of OpenOffice.org. * diff --git a/oox/inc/oox/drawingml/chart/converterbase.hxx b/oox/inc/oox/drawingml/chart/converterbase.hxx index 1aafc4f2dec8..f456d955df5d 100644 --- a/oox/inc/oox/drawingml/chart/converterbase.hxx +++ b/oox/inc/oox/drawingml/chart/converterbase.hxx @@ -8,7 +8,7 @@ * * $RCSfile: converterbase.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.4.6.1 $ * * This file is part of OpenOffice.org. * @@ -72,8 +72,8 @@ public: const ::rtl::OUString& rServiceName ); /** Creates an instance for the passed service name, using the process service factory. */ - static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > - createInstance( const ::rtl::OUString& rServiceName ); + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > + createInstance( const ::rtl::OUString& rServiceName ) const; protected: /** Returns the filter object of the imported/exported document. */ diff --git a/oox/inc/oox/drawingml/theme.hxx b/oox/inc/oox/drawingml/theme.hxx index 25ae745e5639..17f23e533a7b 100644 --- a/oox/inc/oox/drawingml/theme.hxx +++ b/oox/inc/oox/drawingml/theme.hxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: theme.hxx,v $ - * $Revision: 1.6 $ + * $Revision: 1.6.6.1 $ * * This file is part of OpenOffice.org. * @@ -66,28 +66,25 @@ public: inline FillStyleList& getFillStyleList() { return maFillStyleList; } inline const FillStyleList& getFillStyleList() const { return maFillStyleList; } + inline FillStyleList& getBgFillStyleList() { return maBgFillStyleList; } + inline const FillStyleList& getBgFillStyleList() const { return maBgFillStyleList; } /** Returns the fill properties of the passed one-based themed style index. */ - inline const FillProperties* getFillStyle( sal_Int32 nIndex ) const { return maFillStyleList.get( nIndex - 1 ).get(); } + const FillProperties* getFillStyle( sal_Int32 nIndex ) const; inline LineStyleList& getLineStyleList() { return maLineStyleList; } inline const LineStyleList& getLineStyleList() const { return maLineStyleList; } /** Returns the line properties of the passed one-based themed style index. */ - inline const LineProperties* getLineStyle( sal_Int32 nIndex ) const { return maLineStyleList.get( nIndex - 1 ).get(); } + const LineProperties* getLineStyle( sal_Int32 nIndex ) const; inline EffectStyleList& getEffectStyleList() { return maEffectStyleList; } inline const EffectStyleList& getEffectStyleList() const { return maEffectStyleList; } /** Returns the effect properties of the passed one-based themed style index. */ - inline const PropertyMap* getEffectStyle( sal_Int32 nIndex ) const { return maEffectStyleList.get( nIndex - 1 ).get(); } - - inline FillStyleList& getBgFillStyleList() { return maBgFillStyleList; } - inline const FillStyleList& getBgFillStyleList() const { return maBgFillStyleList; } - /** Returns the bg-fill properties of the passed one-based themed style index. */ - inline const FillProperties* getBgFillStyle( sal_Int32 nIndex ) const { return maBgFillStyleList.get( nIndex - 1 ).get(); } + const PropertyMap* getEffectStyle( sal_Int32 nIndex ) const; inline FontScheme& getFontScheme() { return maFontScheme; } inline const FontScheme& getFontScheme() const { return maFontScheme; } /** Returns theme font properties by scheme type (major/minor). */ - const TextCharacterProperties* getFontStyle( sal_Int32 nSchemeType ) const { return maFontScheme.get( nSchemeType ).get(); } + const TextCharacterProperties* getFontStyle( sal_Int32 nSchemeType ) const; /** Returns theme font by placeholder name, e.g. the major latin theme font for the font name '+mj-lt'. */ const TextFont* resolveFont( const ::rtl::OUString& rName ) const; @@ -104,9 +101,9 @@ private: ::rtl::OUString maStyleName; ClrScheme maClrScheme; FillStyleList maFillStyleList; + FillStyleList maBgFillStyleList; LineStyleList maLineStyleList; EffectStyleList maEffectStyleList; - FillStyleList maBgFillStyleList; FontScheme maFontScheme; Shape maSpDef; Shape maLnDef; diff --git a/oox/inc/oox/dump/biffdumper.hxx b/oox/inc/oox/dump/biffdumper.hxx index 722b3fe67dc1..2695202dd2ba 100644 --- a/oox/inc/oox/dump/biffdumper.hxx +++ b/oox/inc/oox/dump/biffdumper.hxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: biffdumper.hxx,v $ - * $Revision: 1.4 $ + * $Revision: 1.4.20.20 $ * * This file is part of OpenOffice.org. * @@ -33,6 +33,7 @@ #include "oox/dump/dumperbase.hxx" #include "oox/dump/dffdumper.hxx" +#include "oox/dump/oledumper.hxx" #include "oox/xls/richstring.hxx" #if OOX_INCLUDE_DUMPER @@ -48,6 +49,39 @@ namespace oox { namespace dump { namespace biff { +typedef ::boost::shared_ptr< ::oox::xls::BiffInputStream > BiffInputStreamRef; + +// ============================================================================ +// ============================================================================ + +class BiffDffStreamObject : public DffStreamObject +{ +public: + explicit BiffDffStreamObject( + const OutputObjectBase& rParent, + const BinaryInputStreamRef& rxStrm ); + +protected: + virtual void implDumpClientAnchor(); +}; + +// ============================================================================ + +class BiffCtlsStreamObject : public InputObjectBase +{ +public: + explicit BiffCtlsStreamObject( const OutputObjectBase& rParent, const BinaryInputStreamRef& rxStrm ); + + void dumpControl( sal_uInt32 nStartPos, sal_uInt32 nLength ); + +protected: + virtual void implDump(); + +private: + sal_uInt32 mnStartPos; + sal_uInt32 mnLength; +}; + // ============================================================================ // ============================================================================ @@ -64,15 +98,14 @@ private: ::oox::xls::BiffType meBiff; }; -typedef ::boost::shared_ptr< BiffConfig > BiffConfigRef; - // ============================================================================ class BiffSharedData : public Base { public: explicit BiffSharedData( ::oox::xls::BiffType eBiff ); - virtual ~BiffSharedData(); + + void initializePerSheet(); inline ::oox::xls::BiffType getBiff() const { return meBiff; } @@ -100,29 +133,26 @@ private: rtl_TextEncoding meTextEnc; }; -typedef ::boost::shared_ptr< BiffSharedData > BiffSharedDataRef; - // ============================================================================ -class BiffObjectBase : public InputStreamObject +class BiffObjectBase : public RecordObjectBase { public: inline BiffSharedData& getBiffData() const { return *mxBiffData; } - inline ::oox::xls::BiffInputStream& getBiffStream() const { return *mxStrm; } + inline ::oox::xls::BiffInputStream& getBiffStream() const { return *mxBiffStrm; } inline ::oox::xls::BiffType getBiff() const { return mxBiffData->getBiff(); } protected: - explicit BiffObjectBase(); + inline explicit BiffObjectBase() {} virtual ~BiffObjectBase(); - using InputStreamObject::construct; - void construct( const ObjectBase& rParent, const ::rtl::OUString& rOutFileName, BinaryInputStreamRef xStrm, ::oox::xls::BiffType eBiff ); + void construct( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, ::oox::xls::BiffType eBiff, const ::rtl::OUString& rSysFileName ); void construct( const BiffObjectBase& rParent ); virtual bool implIsValid() const; - virtual ConfigRef implReconstructConfig(); - virtual InputRef implReconstructInput(); + virtual bool implStartRecord( BinaryInputStream& rBaseStrm, sal_Int64& ornRecPos, sal_Int64& ornRecId, sal_Int64& ornRecSize ); + inline sal_uInt16 getLastRecId() const { return mnLastRecId; } ::rtl::OUString getErrorName( sal_uInt8 nErrCode ) const; // ------------------------------------------------------------------------ @@ -135,13 +165,13 @@ protected: // ------------------------------------------------------------------------ - void writeBooleanItem( const sal_Char* pcName, sal_uInt8 nBool ); - void writeErrorCodeItem( const sal_Char* pcName, sal_uInt8 nErrCode ); + void writeBooleanItem( const String& rName, sal_uInt8 nBool ); + void writeErrorCodeItem( const String& rName, sal_uInt8 nErrCode ); void writeFontPortions( const ::oox::xls::BinFontPortionList& rPortions ); template< typename Type > - void writeRectItem( const sal_Char* pcName, + void writeRectItem( const String& rName, Type nLeft, Type nTop, Type nWidth, Type nHeight, const NameListWrapper& rListWrp = NO_LIST, FormatType eFmtType = FORMATTYPE_DEC ); @@ -149,66 +179,75 @@ protected: // ------------------------------------------------------------------------ ::rtl::OUString dumpByteString( - const sal_Char* pcName, + const String& rName, ::oox::xls::BiffStringFlags nFlags = ::oox::xls::BIFF_STR_DEFAULT, rtl_TextEncoding eDefaultTextEnc = RTL_TEXTENCODING_DONTKNOW ); ::rtl::OUString dumpUniString( - const sal_Char* pcName, + const String& rName, ::oox::xls::BiffStringFlags nFlags = ::oox::xls::BIFF_STR_DEFAULT ); ::rtl::OUString dumpString( - const sal_Char* pcName, + const String& rName, ::oox::xls::BiffStringFlags nByteFlags = ::oox::xls::BIFF_STR_DEFAULT, ::oox::xls::BiffStringFlags nUniFlags = ::oox::xls::BIFF_STR_DEFAULT, rtl_TextEncoding eDefaultTextEnc = RTL_TEXTENCODING_DONTKNOW ); - ::rtl::OUString dumpOleString( const sal_Char* pcName, sal_Int32 nCharCount, bool bUnicode ); - ::rtl::OUString dumpOleString( const sal_Char* pcName, bool bUnicode ); - ::rtl::OUString dumpNullString( const sal_Char* pcName, bool bUnicode ); - - sal_uInt8 dumpBoolean( const sal_Char* pcName = 0 ); - sal_uInt8 dumpErrorCode( const sal_Char* pcName = 0 ); + sal_uInt8 dumpBoolean( const String& rName = EMPTY_STRING ); + sal_uInt8 dumpErrorCode( const String& rName = EMPTY_STRING ); - sal_Int32 dumpRgbColor( const sal_Char* pcName = 0 ); - rtl_TextEncoding dumpCodePage( const sal_Char* pcName = 0 ); - void dumpFormulaResult( const sal_Char* pcName = 0 ); + rtl_TextEncoding dumpCodePage( const String& rName = EMPTY_STRING ); + void dumpFormulaResult( const String& rName = EMPTY_STRING ); - sal_Int32 dumpColIndex( const sal_Char* pcName = 0, bool bCol16Bit = true ); - sal_Int32 dumpRowIndex( const sal_Char* pcName = 0, bool bRow32Bit = false ); - sal_Int32 dumpColRange( const sal_Char* pcName = 0, bool bCol16Bit = true ); - sal_Int32 dumpRowRange( const sal_Char* pcName = 0, bool bRow32Bit = false ); + sal_Int32 dumpColIndex( const String& rName = EMPTY_STRING, bool bCol16Bit = true ); + sal_Int32 dumpRowIndex( const String& rName = EMPTY_STRING, bool bRow32Bit = false ); + sal_Int32 dumpColRange( const String& rName = EMPTY_STRING, bool bCol16Bit = true ); + sal_Int32 dumpRowRange( const String& rName = EMPTY_STRING, bool bRow32Bit = false ); - Address dumpAddress( const sal_Char* pcName = 0, bool bCol16Bit = true, bool bRow32Bit = false ); - Range dumpRange( const sal_Char* pcName = 0, bool bCol16Bit = true, bool bRow32Bit = false ); - void dumpRangeList( const sal_Char* pcName = 0, bool bCol16Bit = true, bool bRow32Bit = false ); + Address dumpAddress( const String& rName = EMPTY_STRING, bool bCol16Bit = true, bool bRow32Bit = false ); + Range dumpRange( const String& rName = EMPTY_STRING, bool bCol16Bit = true, bool bRow32Bit = false ); + void dumpRangeList( const String& rName = EMPTY_STRING, bool bCol16Bit = true, bool bRow32Bit = false ); void dumpConstArrayHeader( sal_uInt32& rnCols, sal_uInt32& rnRows ); ::rtl::OUString dumpConstValue( sal_Unicode cStrQuote = OOX_DUMP_STRQUOTE ); template< typename Type > - void dumpRect( const sal_Char* pcName, + void dumpRect( const String& rName, const NameListWrapper& rListWrp = NO_LIST, FormatType eFmtType = FORMATTYPE_DEC ); + sal_uInt16 dumpRepeatedRecId(); + + void dumpDffClientRect(); + void dumpEmbeddedDff(); + void dumpOcxControl(); + private: - typedef ::boost::shared_ptr< ::oox::xls::BiffInputStream > BiffInputStreamRef; + using InputObjectBase::construct; + +private: + typedef ::boost::shared_ptr< BiffSharedData > BiffSharedDataRef; + typedef ::boost::shared_ptr< BiffDffStreamObject > BiffDffStreamObjRef; + typedef ::boost::shared_ptr< BiffCtlsStreamObject > BiffCtlsStrmObjRef; - BiffConfigRef mxBiffCfg; BiffSharedDataRef mxBiffData; - BiffInputStreamRef mxStrm; + BiffInputStreamRef mxBiffStrm; + BiffDffStreamObjRef mxDffObj; + BiffCtlsStrmObjRef mxCtlsObj; NameListRef mxErrCodes; NameListRef mxConstType; NameListRef mxResultType; + sal_uInt16 mnLastRecId; + bool mbMergeContRec; }; // ---------------------------------------------------------------------------- template< typename Type > -void BiffObjectBase::writeRectItem( const sal_Char* pcName, +void BiffObjectBase::writeRectItem( const String& rName, Type nLeft, Type nTop, Type nWidth, Type nHeight, const NameListWrapper& rListWrp, FormatType eFmtType ) { MultiItemsGuard aMultiGuard( out() ); - writeEmptyItem( pcName ); + writeEmptyItem( rName ); writeValueItem( "x-pos", nLeft, eFmtType, rListWrp ); writeValueItem( "y-pos", nTop, eFmtType, rListWrp ); writeValueItem( "x-size", nWidth, eFmtType, rListWrp ); @@ -216,12 +255,12 @@ void BiffObjectBase::writeRectItem( const sal_Char* pcName, } template< typename Type > -void BiffObjectBase::dumpRect( const sal_Char* pcName, +void BiffObjectBase::dumpRect( const String& rName, const NameListWrapper& rListWrp, FormatType eFmtType ) { Type nLeft, nTop, nWidth, nHeight; - *mxStrm >> nLeft >> nTop >> nWidth >> nHeight; - writeRectItem( pcName, nLeft, nTop, nWidth, nHeight, rListWrp, eFmtType ); + *mxBiffStrm >> nLeft >> nTop >> nWidth >> nHeight; + writeRectItem( rName, nLeft, nTop, nWidth, nHeight, rListWrp, eFmtType ); } // ============================================================================ @@ -234,12 +273,12 @@ public: virtual ~FormulaObject(); sal_uInt16 readFormulaSize(); - sal_uInt16 dumpFormulaSize( const sal_Char* pcName = 0 ); + sal_uInt16 dumpFormulaSize( const String& rName = EMPTY_STRING ); - void dumpCellFormula( const sal_Char* pcName, sal_uInt16 nSize ); - void dumpCellFormula( const sal_Char* pcName = 0 ); - void dumpNameFormula( const sal_Char* pcName, sal_uInt16 nSize ); - void dumpNameFormula( const sal_Char* pcName = 0 ); + void dumpCellFormula( const String& rName, sal_uInt16 nSize ); + void dumpCellFormula( const String& rName = EMPTY_STRING ); + void dumpNameFormula( const String& rName, sal_uInt16 nSize ); + void dumpNameFormula( const String& rName = EMPTY_STRING ); protected: virtual void implDump(); @@ -247,8 +286,8 @@ protected: private: void constructFmlaObj(); - void dumpFormula( const sal_Char* pcName, sal_uInt16 nSize, bool bNameMode ); - void dumpFormula( const sal_Char* pcName, bool bNameMode ); + void dumpFormula( const String& rName, sal_uInt16 nSize, bool bNameMode ); + void dumpFormula( const String& rName, bool bNameMode ); TokenAddress createTokenAddress( sal_uInt16 nCol, sal_uInt16 nRow, bool bRelC, bool bRelR, bool bNameMode ) const; ::rtl::OUString createRef( const ::rtl::OUString& rData ) const; @@ -259,8 +298,8 @@ private: sal_uInt16 readFuncId(); ::rtl::OUString writeFuncIdItem( sal_uInt16 nFuncId, const ::oox::xls::FunctionInfo** oppFuncInfo = 0 ); - sal_uInt16 dumpTokenCol( const sal_Char* pcName, bool& rbRelC, bool& rbRelR ); - sal_uInt16 dumpTokenRow( const sal_Char* pcName, bool& rbRelC, bool& rbRelR ); + sal_uInt16 dumpTokenCol( const String& rName, bool& rbRelC, bool& rbRelR ); + sal_uInt16 dumpTokenRow( const String& rName, bool& rbRelC, bool& rbRelR ); TokenAddress dumpTokenAddress( bool bNameMode ); TokenRange dumpTokenRange( bool bNameMode ); @@ -287,9 +326,9 @@ private: void dumpMemFuncToken( const ::rtl::OUString& rTokClass ); void dumpMemAreaToken( const ::rtl::OUString& rTokClass, bool bAddData ); - void dumpExpToken( const StringWrapper& rName ); - void dumpUnaryOpToken( const StringWrapper& rLOp, const StringWrapper& rROp ); - void dumpBinaryOpToken( const StringWrapper& rOp ); + void dumpExpToken( const String& rName ); + void dumpUnaryOpToken( const String& rLOp, const String& rROp ); + void dumpBinaryOpToken( const String& rOp ); void dumpFuncToken( const ::rtl::OUString& rTokClass ); void dumpFuncVarToken( const ::rtl::OUString& rTokClass ); void dumpCmdToken( const ::rtl::OUString& rTokClass ); @@ -329,63 +368,32 @@ private: FuncProvRef mxFuncProv; AddDataTypeVec maAddData; ::rtl::OUString maRefPrefix; - const sal_Char* mpcName; + ::rtl::OUString maName; sal_uInt16 mnSize; bool mbNameMode; }; -typedef ::boost::shared_ptr< FormulaObject > FormulaObjectRef; - // ============================================================================ // ============================================================================ -class RecordHeaderObject : public RecordHeaderBase< sal_uInt16, sal_uInt32 > -{ -public: - explicit RecordHeaderObject( const InputObjectBase& rParent, ::oox::xls::BiffInputStream& rStrm ); - - inline bool isMergeContRec() const { return mbMergeContRec; } - -protected: - virtual bool implReadHeader( sal_Int64& ornRecPos, sal_uInt16& ornRecId, sal_uInt32& ornRecSize ); - -private: - ::oox::xls::BiffInputStream& mrStrm; - bool mbMergeContRec; -}; - -typedef ::boost::shared_ptr< RecordHeaderObject > RecHeaderObjectRef; - -// ============================================================================ - class RecordStreamObject : public BiffObjectBase { protected: inline explicit RecordStreamObject() {} virtual ~RecordStreamObject(); - using BiffObjectBase::construct; - void construct( const ObjectBase& rParent, const ::rtl::OUString& rOutFileName, BinaryInputStreamRef xStrm, ::oox::xls::BiffType eBiff ); + void construct( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, ::oox::xls::BiffType eBiff, const ::rtl::OUString& rSysFileName ); virtual bool implIsValid() const; - virtual void implDump(); - virtual void implDumpRecord(); - inline RecordHeaderObject& getRecordHeader() const { return *mxHdrObj; } inline FormulaObject& getFormulaDumper() const { return *mxFmlaObj; } - inline DffDumpObject& getDffDumper() const { return *mxDffObj; } - - sal_uInt16 dumpRepeatedRecId(); private: - void dumpRecordBody(); - void dumpSimpleRecord( const ::rtl::OUString& rRecData ); + using BiffObjectBase::construct; private: - RecHeaderObjectRef mxHdrObj; + typedef ::boost::shared_ptr< FormulaObject > FormulaObjectRef; FormulaObjectRef mxFmlaObj; - DffDumpObjectRef mxDffObj; - NameListRef mxSimpleRecs; }; // ============================================================================ @@ -393,23 +401,24 @@ private: class WorkbookStreamObject : public RecordStreamObject { public: - explicit WorkbookStreamObject( const ObjectBase& rParent, const ::rtl::OUString& rOutFileName, BinaryInputStreamRef xStrm ); + explicit WorkbookStreamObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const ::rtl::OUString& rSysFileName ); virtual ~WorkbookStreamObject(); protected: + virtual void implDumpRecordBody(); + +private: using RecordStreamObject::construct; - void construct( const ObjectBase& rParent, const ::rtl::OUString& rOutFileName, BinaryInputStreamRef xStrm ); - virtual void implDumpRecord(); + void initializePerSheet(); -private: ::rtl::OUString createFontName( const ::rtl::OUString& rName, sal_uInt16 nHeight, bool bBold, bool bItalic ) const; - sal_uInt16 dumpPatternIdx( const sal_Char* pcName = 0, bool b16Bit = true ); - sal_uInt16 dumpColorIdx( const sal_Char* pcName = 0, bool b16Bit = true ); - sal_uInt16 dumpFontIdx( const sal_Char* pcName = 0, bool b16Bit = true ); - sal_uInt16 dumpFormatIdx( const sal_Char* pcName = 0 ); - sal_uInt16 dumpXfIdx( const sal_Char* pcName = 0, bool bBiff2Style = false ); + sal_uInt16 dumpPatternIdx( const String& rName = EMPTY_STRING, bool b16Bit = true ); + sal_uInt16 dumpColorIdx( const String& rName = EMPTY_STRING, bool b16Bit = true ); + sal_uInt16 dumpFontIdx( const String& rName = EMPTY_STRING, bool b16Bit = true ); + sal_uInt16 dumpFormatIdx( const String& rName = EMPTY_STRING ); + sal_uInt16 dumpXfIdx( const String& rName = EMPTY_STRING, bool bBiff2Style = false ); sal_uInt16 dumpCellHeader( bool bBiff2Style = false ); void dumpBoolErr(); @@ -419,9 +428,29 @@ private: void dumpXfRec(); void dumpObjRec(); + void dumpObjRecBiff3(); + void dumpObjRecBiff4(); void dumpObjRecBiff5(); void dumpObjRecBiff8(); - void dumpFormControl( sal_uInt32 nStrmPos, sal_uInt32 nStrmSize ); + + void dumpObjRecLineData(); + void dumpObjRecFillData(); + void dumpObjRecRectData(); + void dumpObjRecTextDataBiff3( sal_uInt16& ornTextLen, sal_uInt16& ornFormatSize ); + void dumpObjRecTextDataBiff5( sal_uInt16& ornTextLen, sal_uInt16& ornFormatSize, sal_uInt16& ornLinkSize ); + void dumpObjRecSbsData(); + void dumpObjRecGboData(); + void dumpObjRecEdoData(); + void dumpObjRecRboData(); + void dumpObjRecCblsData(); + void dumpObjRecLbsData(); + + void dumpObjRecPadding(); + void dumpObjRecString( const String& rName, sal_uInt16 nTextLen, bool bRepeatLen ); + void dumpObjRecTextFmt( sal_uInt16 nFormatSize ); + void dumpObjRecFmlaRaw(); + void dumpObjRecFmla( const String& rName, sal_uInt16 nFmlaSize ); + void dumpObjRecPictFmla( sal_uInt16 nFmlaSize ); private: NameListRef mxColors; @@ -434,6 +463,7 @@ private: sal_uInt16 mnPTColFields; sal_uInt16 mnPTSxliIdx; bool mbHasCodePage; + bool mbHasDff; }; // ============================================================================ @@ -441,26 +471,31 @@ private: class PivotCacheStreamObject : public RecordStreamObject { public: - explicit PivotCacheStreamObject( const ObjectBase& rParent, const ::rtl::OUString& rOutFileName, BinaryInputStreamRef xStrm ); + explicit PivotCacheStreamObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const ::rtl::OUString& rSysFileName ); protected: - virtual void implDumpRecord(); + virtual void implDumpRecordBody(); }; // ============================================================================ // ============================================================================ -class RootStorageObject : public RootStorageObjectBase +class RootStorageObject : public OleStorageObject { public: explicit RootStorageObject( const DumperBase& rParent ); protected: virtual void implDumpStream( - BinaryInputStreamRef xStrm, + const BinaryInputStreamRef& rxStrm, const ::rtl::OUString& rStrgPath, const ::rtl::OUString& rStrmName, - const ::rtl::OUString& rSystemFileName ); + const ::rtl::OUString& rSysFileName ); + + virtual void implDumpStorage( + const StorageRef& rxStrg, + const ::rtl::OUString& rStrgPath, + const ::rtl::OUString& rSysPath ); }; // ============================================================================ @@ -471,6 +506,11 @@ class Dumper : public DumperBase public: explicit Dumper( const ::oox::core::FilterBase& rFilter ); + explicit Dumper( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxFactory, + const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStrm, + const ::rtl::OUString& rSysFileName ); + protected: virtual void implDump(); }; diff --git a/oox/inc/oox/dump/dffdumper.hxx b/oox/inc/oox/dump/dffdumper.hxx index d092e6cece14..6ef6ae1ca1fc 100644 --- a/oox/inc/oox/dump/dffdumper.hxx +++ b/oox/inc/oox/dump/dffdumper.hxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: dffdumper.hxx,v $ - * $Revision: 1.3 $ + * $Revision: 1.3.22.9 $ * * This file is part of OpenOffice.org. * @@ -40,57 +40,37 @@ namespace dump { // ============================================================================ -class DffRecordHeaderObject : public RecordHeaderBase< sal_uInt16, sal_uInt32 > +class DffStreamObject : public SequenceRecordObjectBase { public: - explicit DffRecordHeaderObject( const InputObjectBase& rParent ); - - inline sal_Int64 getBodyStart() const { return mnBodyStart; } - inline sal_Int64 getBodyEnd() const { return mnBodyEnd; } inline sal_uInt16 getVer() const { return mnInstVer & 0x000F; } inline sal_uInt16 getInst() const { return (mnInstVer & 0xFFF0) >> 4; } + inline bool isContainer() const { return getVer() == 15; } protected: - virtual bool implIsValid() const; - virtual bool implReadHeader( sal_Int64& ornRecPos, sal_uInt16& ornRecId, sal_uInt32& ornRecSize ); - virtual void implWriteExtHeader(); - -private: - NameListRef mxRecInst; - sal_Int64 mnBodyStart; - sal_Int64 mnBodyEnd; - sal_uInt16 mnInstVer; -}; - -// ============================================================================ + inline explicit DffStreamObject() {} -class DffDumpObject : public InputObjectBase -{ -public: - explicit DffDumpObject( const InputObjectBase& rParent ); - virtual ~DffDumpObject(); + void construct( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const ::rtl::OUString& rSysFileName ); + void construct( const OutputObjectBase& rParent, const BinaryInputStreamRef& rxStrm ); - void dumpDffClientPos( const sal_Char* pcName, sal_Int32 nSubScale ); - void dumpDffClientRect(); - -protected: - virtual bool implIsValid() const; - virtual void implDump(); + virtual bool implReadRecordHeader( BinaryInputStream& rBaseStrm, sal_Int64& ornRecId, sal_Int64& ornRecSize ); + virtual void implWriteExtHeader(); + virtual void implDumpRecordBody(); + virtual void implDumpClientAnchor(); private: - void dumpRecordBody(); + using SequenceRecordObjectBase::construct; + + void constructDffObj(); - void dumpDffOptRec(); sal_uInt16 dumpDffOptPropHeader(); void dumpDffOptPropValue( sal_uInt16 nPropId, sal_uInt32 nValue ); private: - typedef ::boost::shared_ptr< DffRecordHeaderObject > DffRecHeaderObjRef; - DffRecHeaderObjRef mxHdrObj; + sal_uInt16 mnInstVer; + sal_Int32 mnRealSize; }; -typedef ::boost::shared_ptr< DffDumpObject > DffDumpObjectRef; - // ============================================================================ } // namespace dump diff --git a/oox/inc/oox/dump/dumperbase.hxx b/oox/inc/oox/dump/dumperbase.hxx index 5a9107a5277f..d82b64758578 100644 --- a/oox/inc/oox/dump/dumperbase.hxx +++ b/oox/inc/oox/dump/dumperbase.hxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: dumperbase.hxx,v $ - * $Revision: 1.4 $ + * $Revision: 1.4.20.12 $ * * This file is part of OpenOffice.org. * @@ -37,8 +37,10 @@ #include <set> #include <map> #include <boost/shared_ptr.hpp> +#include <rtl/strbuf.hxx> #include <rtl/ustrbuf.hxx> #include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/util/DateTime.hpp> #include "oox/helper/helper.hxx" #include "oox/helper/storagebase.hxx" #include "oox/helper/binaryinputstream.hxx" @@ -48,14 +50,16 @@ #if OOX_INCLUDE_DUMPER namespace com { namespace sun { namespace star { - namespace util { struct DateTime; } namespace io { class XInputStream; } namespace io { class XTextInputStream; } namespace io { class XOutputStream; } namespace io { class XTextOutputStream; } + namespace lang { class XMultiServiceFactory; } } } } -namespace oox { class BinaryInputStream; } +namespace oox { + class BinaryOutputStream; +} namespace oox { namespace core { class FilterBase; @@ -76,6 +80,8 @@ namespace dump { #define OOX_DUMP_ERR_NONAME OOX_DUMP_ERRSTRING( "no-name" ) #define OOX_DUMP_ERR_STREAM OOX_DUMP_ERRSTRING( "stream-error" ) +#define OOX_DUMP_DUMPEXT CREATE_OUSTRING( ".dump" ) + const sal_Unicode OOX_DUMP_STRQUOTE = '\''; const sal_Unicode OOX_DUMP_FMLASTRQUOTE = '"'; const sal_Unicode OOX_DUMP_ADDRABS = '$'; @@ -103,12 +109,6 @@ typedef ::std::vector< sal_Int64 > Int64Vector; class InputOutputHelper { public: - typedef ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > XInputStreamRef; - typedef ::com::sun::star::uno::Reference< ::com::sun::star::io::XTextInputStream > XTextInputStreamRef; - typedef ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > XOutputStreamRef; - typedef ::com::sun::star::uno::Reference< ::com::sun::star::io::XTextOutputStream > XTextOutputStreamRef; - -public: // file names ------------------------------------------------------------- static ::rtl::OUString convertFileNameToUrl( const ::rtl::OUString& rFileName ); @@ -117,15 +117,44 @@ public: // input streams ---------------------------------------------------------- - static XInputStreamRef openInputStream( const ::rtl::OUString& rFileName ); - static XTextInputStreamRef openTextInputStream( const XInputStreamRef& rxInStrm, const ::rtl::OUString& rEncoding ); - static XTextInputStreamRef openTextInputStream( const ::rtl::OUString& rFileName, const ::rtl::OUString& rEncoding ); + static ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > + getXInputStream( BinaryInputStream& rStrm ); + + static ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > + openInputStream( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxFactory, + const ::rtl::OUString& rFileName ); + + static ::com::sun::star::uno::Reference< ::com::sun::star::io::XTextInputStream > + openTextInputStream( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxFactory, + const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStrm, + const ::rtl::OUString& rEncoding ); + + static ::com::sun::star::uno::Reference< ::com::sun::star::io::XTextInputStream > + openTextInputStream( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxFactory, + const ::rtl::OUString& rFileName, + const ::rtl::OUString& rEncoding ); // output streams --------------------------------------------------------- - static XOutputStreamRef openOutputStream( const ::rtl::OUString& rFileName ); - static XTextOutputStreamRef openTextOutputStream( const XOutputStreamRef& rxOutStrm, const ::rtl::OUString& rEncoding ); - static XTextOutputStreamRef openTextOutputStream( const ::rtl::OUString& rFileName, const ::rtl::OUString& rEncoding ); + static ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > + openOutputStream( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxFactory, + const ::rtl::OUString& rFileName ); + + static ::com::sun::star::uno::Reference< ::com::sun::star::io::XTextOutputStream > + openTextOutputStream( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxFactory, + const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& rxOutStrm, + const ::rtl::OUString& rEncoding ); + + static ::com::sun::star::uno::Reference< ::com::sun::star::io::XTextOutputStream > + openTextOutputStream( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxFactory, + const ::rtl::OUString& rFileName, + const ::rtl::OUString& rEncoding ); }; // ============================================================================ @@ -155,6 +184,7 @@ enum FormatType FORMATTYPE_NONE, /// No numeric format (e.g. show name only). FORMATTYPE_DEC, /// Decimal. FORMATTYPE_HEX, /// Hexadecimal. + FORMATTYPE_SHORTHEX, /// Hexadecimal, as short as possible (no leading zeros). FORMATTYPE_BIN, /// Binary. FORMATTYPE_FIX, /// Fixed-point. FORMATTYPE_BOOL /// Boolean ('true' or 'false'). @@ -168,7 +198,7 @@ enum FormatType <NAME>=<VALUE>=<NAME-FROM-LIST> - NAME is the name of the data item. The name is contained in the members + NAME is the name of the data item. The name is contained in the member maItemName. If the name is empty, only the value is written (without a leading equality sign). @@ -199,7 +229,7 @@ struct ItemFormat The vector must contain at least 2 strings. The struct is filled from the strings in the vector in the following order: 1) Data type (one of: [u]int8, [u]int16, [u]int32, [u]int64, float, double). - 2) Format type (one of: dec, hex, bin, fix, bool, unused, unknown). + 2) Format type (one of: dec, hex, shorthex, bin, fix, bool, unused, unknown). 3) Item name (optional). 4) Name list name (optional). @@ -310,6 +340,7 @@ public: static void appendShortHex( ::rtl::OUStringBuffer& rStr, sal_Int32 nData, bool bPrefix = true ); static void appendShortHex( ::rtl::OUStringBuffer& rStr, sal_uInt64 nData, bool bPrefix = true ); static void appendShortHex( ::rtl::OUStringBuffer& rStr, sal_Int64 nData, bool bPrefix = true ); + static void appendShortHex( ::rtl::OUStringBuffer& rStr, double fData, bool bPrefix = true ); // append binary ---------------------------------------------------------- @@ -404,32 +435,32 @@ void StringHelper::appendValue( ::rtl::OUStringBuffer& rStr, Type nData, FormatT { switch( eFmtType ) { - case FORMATTYPE_DEC: appendDec( rStr, nData ); break; - case FORMATTYPE_HEX: appendHex( rStr, nData ); break; - case FORMATTYPE_BIN: appendBin( rStr, nData ); break; - case FORMATTYPE_FIX: appendFix( rStr, nData ); break; - case FORMATTYPE_BOOL: appendBool( rStr, nData ); break; + case FORMATTYPE_DEC: appendDec( rStr, nData ); break; + case FORMATTYPE_HEX: appendHex( rStr, nData ); break; + case FORMATTYPE_SHORTHEX: appendShortHex( rStr, nData ); break; + case FORMATTYPE_BIN: appendBin( rStr, nData ); break; + case FORMATTYPE_FIX: appendFix( rStr, nData ); break; + case FORMATTYPE_BOOL: appendBool( rStr, nData ); break; default:; } } // ============================================================================ -class StringWrapper +class String : public ::rtl::OUString { public: - inline StringWrapper() {} - inline /*implicit*/ StringWrapper( const ::rtl::OUString& rStr ) : maStr( rStr ) {} - inline /*implicit*/ StringWrapper( const sal_Char* pcStr ) : maStr( ::rtl::OUString::createFromAscii( pcStr ? pcStr : "" ) ) {} - inline /*implicit*/ StringWrapper( sal_Unicode cChar ) : maStr( cChar ) {} - - inline bool isEmpty() const { return maStr.getLength() == 0; } - inline const ::rtl::OUString& getString() const { return maStr; } + inline String() {} + inline /*implicit*/ String( const ::rtl::OUString& rStr ) : ::rtl::OUString( rStr ) {} + inline /*implicit*/ String( const sal_Char* pcStr ) : ::rtl::OUString( ::rtl::OUString::createFromAscii( pcStr ? pcStr : "" ) ) {} + inline /*implicit*/ String( sal_Unicode cChar ) : ::rtl::OUString( cChar ) {} -private: - ::rtl::OUString maStr; + inline bool has() const { return getLength() > 0; } + inline ::rtl::OUString operator()( const sal_Char* pcDefault ) const { if( has() ) return *this; return String( pcDefault ); } }; +static const String EMPTY_STRING; + // ============================================================================ // ============================================================================ @@ -442,11 +473,11 @@ public: inline const ::rtl::OUString& getFormulaString() const { return getString( maFmlaStack ); } inline const ::rtl::OUString& getClassesString() const { return getString( maClassStack ); } - void pushOperand( const StringWrapper& rOp, const ::rtl::OUString& rTokClass ); - void pushOperand( const StringWrapper& rOp ); - void pushUnaryOp( const StringWrapper& rLOp, const StringWrapper& rROp ); - void pushBinaryOp( const StringWrapper& rOp ); - void pushFuncOp( const StringWrapper& rFunc, const ::rtl::OUString& rTokClass, sal_uInt8 nParamCount ); + void pushOperand( const String& rOp, const ::rtl::OUString& rTokClass ); + void pushOperand( const String& rOp ); + void pushUnaryOp( const String& rLOp, const String& rROp ); + void pushBinaryOp( const String& rOp ); + void pushFuncOp( const String& rFunc, const ::rtl::OUString& rTokClass, sal_uInt8 nParamCount ); inline void setError() { mbError = true; } void replaceOnTop( const ::rtl::OUString& rOld, const ::rtl::OUString& rNew ); @@ -487,30 +518,36 @@ typedef ::boost::shared_ptr< Base > BaseRef; +----> NameListBase | | | +----> ConstList ------> MultiList + | | | +----> FlagsList ------> CombiList + | | | +----> UnitConverter | +----> SharedConfigData + | +----> Config | - +----> Input ------> BinaryInput +----> Output | +----> StorageIterator | +----> ObjectBase | - +----> RootStorageObjectBase + +----> StorageObjectBase | +----> OutputObjectBase | | | +----> InputObjectBase | | - | +----> InputStreamObject + | +----> BinaryStreamObject + | | + | +----> TextStreamObject + | | | + | | +----> XmlStreamObject | | - | +----> RecordHeaderImplBase + | +----> RecordObjectBase | | - | +----> RecordHeaderBase<> + | +----> SequenceRecordObjectBase | +----> DumperBase */ @@ -520,7 +557,7 @@ public: virtual ~Base(); inline bool isValid() const { return implIsValid(); } - inline static bool isValid( BaseRef xBase ) { return xBase.get() && xBase->isValid(); } + inline static bool isValid( const BaseRef& rxBase ) { return rxBase.get() && rxBase->isValid(); } protected: inline explicit Base() {} @@ -598,10 +635,10 @@ public: virtual ~NameListBase(); /** Sets a name for the specified key. */ - void setName( sal_Int64 nKey, const StringWrapper& rNameWrp ); + void setName( sal_Int64 nKey, const String& rName ); /** Include all names of the passed list. */ - void includeList( NameListRef xList ); + void includeList( const NameListRef& rxList ); /** Returns true, if the map contains an entry for the passed key. */ template< typename Type > @@ -670,7 +707,7 @@ public: explicit ConstList( const SharedConfigData& rCfgData ); /** Sets a default name for unknown keys. */ - inline void setDefaultName( const StringWrapper& rDefName ) { maDefName = rDefName.getString(); } + inline void setDefaultName( const String& rDefName ) { maDefName = rDefName; } /** Enables or disables automatic quotation of returned names. */ inline void setQuoteNames( bool bQuoteNames ) { mbQuoteNames = bQuoteNames; } @@ -781,7 +818,7 @@ class UnitConverter : public NameListBase public: explicit UnitConverter( const SharedConfigData& rCfgData ); - inline void setUnitName( const StringWrapper& rUnitName ) { maUnitName = rUnitName.getString(); } + inline void setUnitName( const String& rUnitName ) { maUnitName = rUnitName; } inline void setFactor( double fFactor ) { mfFactor = fFactor; } protected: @@ -805,15 +842,15 @@ class NameListWrapper { public: inline NameListWrapper() {} - inline /*implicit*/ NameListWrapper( const ::rtl::OUString& rListName ) : maNameWrp( rListName ) {} - inline /*implicit*/ NameListWrapper( const sal_Char* pcListName ) : maNameWrp( pcListName ) {} - inline /*implicit*/ NameListWrapper( NameListRef xList ) : mxList( xList ) {} + inline /*implicit*/ NameListWrapper( const ::rtl::OUString& rListName ) : maName( rListName ) {} + inline /*implicit*/ NameListWrapper( const sal_Char* pcListName ) : maName( pcListName ) {} + inline /*implicit*/ NameListWrapper( const NameListRef& rxList ) : mxList( rxList ) {} - inline bool isEmpty() const { return !mxList && maNameWrp.isEmpty(); } + inline bool isEmpty() const { return !mxList && !maName.has(); } NameListRef getNameList( const Config& rCfg ) const; private: - StringWrapper maNameWrp; + String maName; mutable NameListRef mxList; }; @@ -825,22 +862,28 @@ static const NameListWrapper NO_LIST; class SharedConfigData : public Base, public ConfigItemBase { public: - explicit SharedConfigData( const ::rtl::OUString& rFileName ); + explicit SharedConfigData( + const ::rtl::OUString& rFileName, + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxFactory, + const StorageRef& rxRootStrg, + const ::rtl::OUString& rSysFileName ); + virtual ~SharedConfigData(); + inline const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& getFactory() const { return mxFactory; } + inline const StorageRef& getRootStorage() const { return mxRootStrg; } + inline const ::rtl::OUString& getSysFileName() const { return maSysFileName; } + void setOption( const ::rtl::OUString& rKey, const ::rtl::OUString& rData ); const ::rtl::OUString* getOption( const ::rtl::OUString& rKey ) const; template< typename ListType > ::boost::shared_ptr< ListType > createNameList( const ::rtl::OUString& rListName ); - void setNameList( const ::rtl::OUString& rListName, NameListRef xList ); + void setNameList( const ::rtl::OUString& rListName, const NameListRef& rxList ); void eraseNameList( const ::rtl::OUString& rListName ); NameListRef getNameList( const ::rtl::OUString& rListName ) const; protected: - inline explicit SharedConfigData() : mbLoaded( false ) {} - void construct( const ::rtl::OUString& rFileName ); - virtual bool implIsValid() const; virtual void implProcessConfigItemStr( const ConfigInputStreamRef& rxStrm, @@ -859,6 +902,9 @@ private: typedef ::std::map< ::rtl::OUString, ::rtl::OUString > ConfigDataMap; typedef ::std::map< ::rtl::OUString, NameListRef > NameListMap; + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxFactory; + StorageRef mxRootStrg; + ::rtl::OUString maSysFileName; ConfigFileSet maConfigFiles; ConfigDataMap maConfigData; NameListMap maNameLists; @@ -894,38 +940,55 @@ class Config : public Base { public: explicit Config( const Config& rParent ); - explicit Config( const ::rtl::OUString& rFileName ); - explicit Config( const sal_Char* pcEnvVar ); + explicit Config( + const sal_Char* pcEnvVar, + const ::oox::core::FilterBase& rFilter ); + explicit Config( + const sal_Char* pcEnvVar, + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxFactory, + const StorageRef& rxRootStrg, + const ::rtl::OUString& rSysFileName ); + virtual ~Config(); - void setStringOption( const StringWrapper& rKey, const StringWrapper& rData ); + inline const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& getFactory() const { return mxCfgData->getFactory(); } + inline const StorageRef& getRootStorage() const { return mxCfgData->getRootStorage(); } + inline const ::rtl::OUString& getSysFileName() const { return mxCfgData->getSysFileName(); } + + void setStringOption( const String& rKey, const String& rData ); - const ::rtl::OUString& getStringOption( const StringWrapper& rKey, const ::rtl::OUString& rDefault ) const; - bool getBoolOption( const StringWrapper& rKey, bool bDefault ) const; + const ::rtl::OUString& getStringOption( const String& rKey, const ::rtl::OUString& rDefault ) const; + bool getBoolOption( const String& rKey, bool bDefault ) const; template< typename Type > - Type getIntOption( const StringWrapper& rKey, Type nDefault ) const; + Type getIntOption( const String& rKey, Type nDefault ) const; bool isDumperEnabled() const; bool isImportEnabled() const; template< typename ListType > - ::boost::shared_ptr< ListType > createNameList( const StringWrapper& rListName ); - void setNameList( const StringWrapper& rListName, NameListRef xList ); - void eraseNameList( const StringWrapper& rListName ); - NameListRef getNameList( const StringWrapper& rListName ) const; + ::boost::shared_ptr< ListType > createNameList( const String& rListName ); + void setNameList( const String& rListName, const NameListRef& rxList ); + void eraseNameList( const String& rListName ); + NameListRef getNameList( const String& rListName ) const; /** Returns the name for the passed key from the passed name list. */ template< typename Type > ::rtl::OUString getName( const NameListWrapper& rListWrp, Type nKey ) const; /** Returns true, if the passed name list contains an entry for the passed key. */ template< typename Type > - bool hasName( const NameListWrapper& rList, Type nKey ) const; + bool hasName( const NameListWrapper& rListWrp, Type nKey ) const; protected: inline explicit Config() {} void construct( const Config& rParent ); - void construct( const ::rtl::OUString& rFileName ); - void construct( const sal_Char* pcEnvVar ); + void construct( + const sal_Char* pcEnvVar, + const ::oox::core::FilterBase& rFilter ); + void construct( + const sal_Char* pcEnvVar, + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxFactory, + const StorageRef& rxRootStrg, + const ::rtl::OUString& rSysFileName ); virtual bool implIsValid() const; virtual const ::rtl::OUString* implGetOption( const ::rtl::OUString& rKey ) const; @@ -941,18 +1004,18 @@ typedef ::boost::shared_ptr< Config > ConfigRef; // ---------------------------------------------------------------------------- template< typename Type > -Type Config::getIntOption( const StringWrapper& rKey, Type nDefault ) const +Type Config::getIntOption( const String& rKey, Type nDefault ) const { sal_Int64 nRawData; - const ::rtl::OUString* pData = implGetOption( rKey.getString() ); + const ::rtl::OUString* pData = implGetOption( rKey ); return (pData && StringHelper::convertStringToInt( nRawData, *pData )) ? static_cast< Type >( nRawData ) : nDefault; } template< typename ListType > -::boost::shared_ptr< ListType > Config::createNameList( const StringWrapper& rListName ) +::boost::shared_ptr< ListType > Config::createNameList( const String& rListName ) { - return mxCfgData->createNameList< ListType >( rListName.getString() ); + return mxCfgData->createNameList< ListType >( rListName ); } template< typename Type > @@ -972,77 +1035,15 @@ bool Config::hasName( const NameListWrapper& rListWrp, Type nKey ) const // ============================================================================ // ============================================================================ -class Input : public Base -{ -public: - virtual sal_Int64 getSize() const = 0; - virtual sal_Int64 tell() const = 0; - virtual void seek( sal_Int64 nPos ) = 0; - virtual void skip( sal_Int32 nBytes ) = 0; - virtual sal_Int32 read( void* pBuffer, sal_Int32 nBytes ) = 0; - - virtual Input& operator>>( sal_Int8& rnData ) = 0; - virtual Input& operator>>( sal_uInt8& rnData ) = 0; - virtual Input& operator>>( sal_Int16& rnData ) = 0; - virtual Input& operator>>( sal_uInt16& rnData ) = 0; - virtual Input& operator>>( sal_Int32& rnData ) = 0; - virtual Input& operator>>( sal_uInt32& rnData ) = 0; - virtual Input& operator>>( float& rfData ) = 0; - virtual Input& operator>>( double& rfData ) = 0; - - inline bool isValidPos() const { return tell() < getSize(); } - template< typename Type > - inline Type readValue() { Type nValue; *this >> nValue; return nValue; } - -protected: - virtual bool implIsValid() const; -}; - -typedef ::boost::shared_ptr< Input > InputRef; - -Input& operator>>( Input& rIn, sal_Int64& rnData ); -Input& operator>>( Input& rIn, sal_uInt64& rnData ); - -// ============================================================================ - -class BinaryInput : public Input -{ -public: - explicit BinaryInput( BinaryInputStream& rStrm ); - - virtual sal_Int64 getSize() const; - virtual sal_Int64 tell() const; - virtual void seek( sal_Int64 nPos ); - virtual void skip( sal_Int32 nBytes ); - virtual sal_Int32 read( void* pBuffer, sal_Int32 nBytes ); - - virtual BinaryInput& operator>>( sal_Int8& rnData ); - virtual BinaryInput& operator>>( sal_uInt8& rnData ); - virtual BinaryInput& operator>>( sal_Int16& rnData ); - virtual BinaryInput& operator>>( sal_uInt16& rnData ); - virtual BinaryInput& operator>>( sal_Int32& rnData ); - virtual BinaryInput& operator>>( sal_uInt32& rnData ); - virtual BinaryInput& operator>>( float& rfData ); - virtual BinaryInput& operator>>( double& rfData ); - -protected: - virtual bool implIsValid() const; - -private: - BinaryInputStream& mrStrm; -}; - -// ============================================================================ -// ============================================================================ - class Output : public Base { public: - typedef ::com::sun::star::uno::Reference< ::com::sun::star::io::XTextOutputStream > XTextOutputStreamRef; + explicit Output( + const ::com::sun::star::uno::Reference< ::com::sun::star::io::XTextOutputStream >& rxStrm ); -public: - explicit Output( const XTextOutputStreamRef& rxStrm ); - explicit Output( const ::rtl::OUString& rFileName ); + explicit Output( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxFactory, + const ::rtl::OUString& rFileName ); // ------------------------------------------------------------------------ @@ -1064,7 +1065,7 @@ public: void endTable(); void resetItemIndex( sal_Int64 nIdx = 0 ); - void startItem( const sal_Char* pcName = 0 ); + void startItem( const String& rItemName ); void contItem(); void endItem(); inline const ::rtl::OUString& getLastItemValue() const { return maLastItem; } @@ -1079,7 +1080,7 @@ public: void writeString( const ::rtl::OUString& rStr ); void writeArray( const sal_uInt8* pnData, sal_Size nSize, sal_Unicode cSep = OOX_DUMP_LISTSEP ); void writeBool( bool bData ); - void writeColor( sal_Int32 nColor ); + void writeColorABGR( sal_Int32 nColor ); void writeDateTime( const ::com::sun::star::util::DateTime& rDateTime ); void writeColIndex( sal_Int32 nCol ); void writeRowIndex( sal_Int32 nRow ); @@ -1097,6 +1098,9 @@ public: inline void writeHex( Type nData, bool bPrefix = true ) { StringHelper::appendHex( maLine, nData, bPrefix ); } template< typename Type > + inline void writeShortHex( Type nData, bool bPrefix = true ) + { StringHelper::appendShortHex( maLine, nData, bPrefix ); } + template< typename Type > inline void writeBin( Type nData, bool bDots = true ) { StringHelper::appendBin( maLine, nData, bDots ); } template< typename Type > @@ -1111,17 +1115,17 @@ public: // ------------------------------------------------------------------------ protected: - void construct( const XTextOutputStreamRef& rxStrm ); + void construct( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XTextOutputStream >& rxStrm ); virtual bool implIsValid() const; private: - void writeItemName( const sal_Char* pcName ); + void writeItemName( const String& rItemName ); private: typedef ::std::vector< sal_Int32 > StringLenVec; - XTextOutputStreamRef mxStrm; + ::com::sun::star::uno::Reference< ::com::sun::star::io::XTextOutputStream > mxStrm; ::rtl::OUString maIndent; ::rtl::OUStringBuffer maLine; ::rtl::OUString maLastItem; @@ -1180,8 +1184,8 @@ private: class ItemGuard { public: - inline explicit ItemGuard( Output& rOut, const sal_Char* pcName = 0 ) : - mrOut( rOut ) { mrOut.startItem( pcName ); } + inline explicit ItemGuard( Output& rOut, const String& rName = EMPTY_STRING ) : + mrOut( rOut ) { mrOut.startItem( rName ); } inline ~ItemGuard() { mrOut.endItem(); } inline void cont() { mrOut.contItem(); } private: @@ -1206,6 +1210,31 @@ private: }; // ============================================================================ + +class StorageIterator : public Base +{ +public: + explicit StorageIterator( const StorageRef& rxStrg ); + virtual ~StorageIterator(); + + size_t getElementCount() const; + + StorageIterator& operator++(); + + ::rtl::OUString getName() const; + bool isStream() const; + bool isStorage() const; + +private: + virtual bool implIsValid() const; + +private: + StorageRef mxStrg; + OUStringVector maNames; + OUStringVector::const_iterator maIt; +}; + +// ============================================================================ // ============================================================================ class ObjectBase : public Base @@ -1213,27 +1242,27 @@ class ObjectBase : public Base public: virtual ~ObjectBase(); + inline const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& getFactory() const { return mxConfig->getFactory(); } + void dump(); // ------------------------------------------------------------------------ protected: - inline explicit ObjectBase() : mpFilter( 0 ) {} - void construct( const ::oox::core::FilterBase& rFilter, ConfigRef xConfig ); + inline explicit ObjectBase() {} + + void construct( const ConfigRef& rxConfig ); void construct( const ObjectBase& rParent ); virtual bool implIsValid() const; - virtual ConfigRef implReconstructConfig(); virtual void implDump(); // ------------------------------------------------------------------------ - void reconstructConfig(); + void reconstructConfig( const ConfigRef& rxConfig ); - inline const ::oox::core::FilterBase& getFilter() const { return *mpFilter; } inline Config& cfg() const { return *mxConfig; } private: - const ::oox::core::FilterBase* mpFilter; ConfigRef mxConfig; }; @@ -1242,62 +1271,74 @@ typedef ::boost::shared_ptr< ObjectBase > ObjectRef; // ============================================================================ // ============================================================================ -class RootStorageObjectBase : public ObjectBase +class StorageObjectBase : public ObjectBase { -public: - virtual ~RootStorageObjectBase(); - protected: - inline explicit RootStorageObjectBase() {} + inline explicit StorageObjectBase() {} - using ObjectBase::construct; +protected: + void construct( const ObjectBase& rParent, const StorageRef& rxStrg, const ::rtl::OUString& rSysPath ); void construct( const ObjectBase& rParent ); + virtual bool implIsValid() const; virtual void implDump(); virtual void implDumpStream( - BinaryInputStreamRef xStrm, + const BinaryInputStreamRef& rxStrm, const ::rtl::OUString& rStrgPath, const ::rtl::OUString& rStrmName, - const ::rtl::OUString& rSystemFileName ); + const ::rtl::OUString& rSysFileName ); + + virtual void implDumpStorage( + const StorageRef& rxStrg, + const ::rtl::OUString& rStrgPath, + const ::rtl::OUString& rSysPath ); + + void addPreferredStream( const String& rStrmName ); + void addPreferredStorage( const String& rStrgPath ); private: + using ObjectBase::construct; + + ::rtl::OUString getSysFileName( + const ::rtl::OUString& rStrmName, + const ::rtl::OUString& rSysOutPath ); + void extractStream( StorageBase& rStrg, + const ::rtl::OUString& rStrgPath, const ::rtl::OUString& rStrmName, - const ::rtl::OUString& rSystemFileName ); + const ::rtl::OUString& rSysFileName ); void extractStorage( - StorageRef xStrg, - const ::rtl::OUString& rSystemPath ); -}; - -typedef ::boost::shared_ptr< RootStorageObjectBase > RootStorageObjectRef; - -// ============================================================================ - -class StorageIterator : public Base -{ -public: - explicit StorageIterator( StorageRef xStrg ); - virtual ~StorageIterator(); - - size_t getElementCount() const; - - StorageIterator& operator++(); + const StorageRef& rxStrg, + const ::rtl::OUString& rStrgPath, + const ::rtl::OUString& rSysPath ); - ::rtl::OUString getName() const; - bool isStream() const; - bool isStorage() const; + void extractItem( + const StorageRef& rxStrg, + const ::rtl::OUString& rStrgPath, + const ::rtl::OUString& rItemName, + const ::rtl::OUString& rSysOutPath, + bool bIsStrg, bool bIsStrm ); private: - virtual bool implIsValid() const; + struct PreferredItem + { + ::rtl::OUString maName; + bool mbStorage; + + inline explicit PreferredItem( const ::rtl::OUString rName, bool bStorage ) : + maName( rName ), mbStorage( bStorage ) {} + }; + typedef ::std::vector< PreferredItem > PreferredItemVector; -private: StorageRef mxStrg; - OUStringVector maNames; - OUStringVector::const_iterator maIt; + ::rtl::OUString maSysPath; + PreferredItemVector maPreferred; }; +typedef ::boost::shared_ptr< StorageObjectBase > StorageObjectRef; + // ============================================================================ // ============================================================================ @@ -1310,65 +1351,66 @@ public: protected: inline explicit OutputObjectBase() {} - using ObjectBase::construct; - void construct( const ObjectBase& rParent, const ::rtl::OUString& rOutFileName ); - void construct( const ObjectBase& rParent, OutputRef xOut ); + void construct( const ObjectBase& rParent, const ::rtl::OUString& rSysFileName ); + void construct( const ObjectBase& rParent, const OutputRef& rxOut ); void construct( const OutputObjectBase& rParent ); virtual bool implIsValid() const; - virtual OutputRef implReconstructOutput(); // ------------------------------------------------------------------------ - void reconstructOutput(); - inline Output& out() const { return *mxOut; } // ------------------------------------------------------------------------ - void writeEmptyItem( const sal_Char* pcName ); - void writeInfoItem( const sal_Char* pcName, const StringWrapper& rData ); - void writeStringItem( const sal_Char* pcName, const ::rtl::OUString& rData ); - void writeArrayItem( const sal_Char* pcName, const sal_uInt8* pnData, sal_Size nSize, sal_Unicode cSep = OOX_DUMP_LISTSEP ); - void writeBoolItem( const sal_Char* pcName, bool bData ); - double writeRkItem( const sal_Char* pcName, sal_Int32 nRk ); - void writeColorItem( const sal_Char* pcName, sal_Int32 nColor ); - void writeDateTimeItem( const sal_Char* pcName, const ::com::sun::star::util::DateTime& rDateTime ); - void writeGuidItem( const sal_Char* pcName, const ::rtl::OUString& rGuid ); - void writeColIndexItem( const sal_Char* pcName, sal_Int32 nCol ); - void writeRowIndexItem( const sal_Char* pcName, sal_Int32 nRow ); - void writeColRangeItem( const sal_Char* pcName, sal_Int32 nCol1, sal_Int32 nCol2 ); - void writeRowRangeItem( const sal_Char* pcName, sal_Int32 nRow1, sal_Int32 nRow2 ); - void writeAddressItem( const sal_Char* pcName, const Address& rPos ); - void writeRangeItem( const sal_Char* pcName, const Range& rRange ); - void writeRangeListItem( const sal_Char* pcName, const RangeList& rRanges ); - void writeTokenAddressItem( const sal_Char* pcName, const TokenAddress& rPos, bool bNameMode ); - void writeTokenAddress3dItem( const sal_Char* pcName, const ::rtl::OUString& rRef, const TokenAddress& rPos, bool bNameMode ); - void writeTokenRangeItem( const sal_Char* pcName, const TokenRange& rRange, bool bNameMode ); - void writeTokenRange3dItem( const sal_Char* pcName, const ::rtl::OUString& rRef, const TokenRange& rRange, bool bNameMode ); + void writeEmptyItem( const String& rName ); + void writeInfoItem( const String& rName, const String& rData ); + void writeCharItem( const String& rName, sal_Unicode cData ); + void writeStringItem( const String& rName, const ::rtl::OUString& rData ); + void writeArrayItem( const String& rName, const sal_uInt8* pnData, sal_Size nSize, sal_Unicode cSep = OOX_DUMP_LISTSEP ); + void writeBoolItem( const String& rName, bool bData ); + double writeRkItem( const String& rName, sal_Int32 nRk ); + void writeColorABGRItem( const String& rName, sal_Int32 nColor ); + void writeDateTimeItem( const String& rName, const ::com::sun::star::util::DateTime& rDateTime ); + void writeGuidItem( const String& rName, const ::rtl::OUString& rGuid ); + void writeColIndexItem( const String& rName, sal_Int32 nCol ); + void writeRowIndexItem( const String& rName, sal_Int32 nRow ); + void writeColRangeItem( const String& rName, sal_Int32 nCol1, sal_Int32 nCol2 ); + void writeRowRangeItem( const String& rName, sal_Int32 nRow1, sal_Int32 nRow2 ); + void writeAddressItem( const String& rName, const Address& rPos ); + void writeRangeItem( const String& rName, const Range& rRange ); + void writeRangeListItem( const String& rName, const RangeList& rRanges ); + void writeTokenAddressItem( const String& rName, const TokenAddress& rPos, bool bNameMode ); + void writeTokenAddress3dItem( const String& rName, const ::rtl::OUString& rRef, const TokenAddress& rPos, bool bNameMode ); + void writeTokenRangeItem( const String& rName, const TokenRange& rRange, bool bNameMode ); + void writeTokenRange3dItem( const String& rName, const ::rtl::OUString& rRef, const TokenRange& rRange, bool bNameMode ); template< typename Type > void addNameToItem( Type nData, const NameListWrapper& rListWrp ); template< typename Type > - void writeNameItem( const sal_Char* pcName, Type nData, const NameListWrapper& rListWrp ); + void writeNameItem( const String& rName, Type nData, const NameListWrapper& rListWrp ); template< typename Type > - void writeDecItem( const sal_Char* pcName, Type nData, const NameListWrapper& rListWrp = NO_LIST ); + void writeDecItem( const String& rName, Type nData, const NameListWrapper& rListWrp = NO_LIST ); template< typename Type > - void writeHexItem( const sal_Char* pcName, Type nData, const NameListWrapper& rListWrp = NO_LIST ); + void writeHexItem( const String& rName, Type nData, const NameListWrapper& rListWrp = NO_LIST ); template< typename Type > - void writeBinItem( const sal_Char* pcName, Type nData, const NameListWrapper& rListWrp = NO_LIST ); + void writeShortHexItem( const String& rName, Type nData, const NameListWrapper& rListWrp = NO_LIST ); template< typename Type > - void writeFixItem( const sal_Char* pcName, Type nData, const NameListWrapper& rListWrp = NO_LIST ); + void writeBinItem( const String& rName, Type nData, const NameListWrapper& rListWrp = NO_LIST ); template< typename Type > - void writeDecBoolItem( const sal_Char* pcName, Type nData, const NameListWrapper& rListWrp = NO_LIST ); + void writeFixItem( const String& rName, Type nData, const NameListWrapper& rListWrp = NO_LIST ); template< typename Type > - void writeValueItem( const sal_Char* pcName, Type nData, FormatType eFmtType, const NameListWrapper& rListWrp = NO_LIST ); + void writeDecBoolItem( const String& rName, Type nData, const NameListWrapper& rListWrp = NO_LIST ); + template< typename Type > + void writeValueItem( const String& rName, Type nData, FormatType eFmtType, const NameListWrapper& rListWrp = NO_LIST ); template< typename Type > void writeValueItem( const ItemFormat& rItemFmt, Type nData ); private: + using ObjectBase::construct; + OutputRef mxOut; }; @@ -1387,48 +1429,56 @@ void OutputObjectBase::addNameToItem( Type nData, const NameListWrapper& rListWr } template< typename Type > -void OutputObjectBase::writeNameItem( const sal_Char* pcName, Type nData, const NameListWrapper& rListWrp ) +void OutputObjectBase::writeNameItem( const String& rName, Type nData, const NameListWrapper& rListWrp ) { - ItemGuard aItem( *mxOut, pcName ); + ItemGuard aItem( *mxOut, rName ); mxOut->writeName( cfg(), nData, rListWrp ); } template< typename Type > -void OutputObjectBase::writeDecItem( const sal_Char* pcName, Type nData, const NameListWrapper& rListWrp ) +void OutputObjectBase::writeDecItem( const String& rName, Type nData, const NameListWrapper& rListWrp ) { - ItemGuard aItem( *mxOut, pcName ); + ItemGuard aItem( *mxOut, rName ); mxOut->writeDec( nData ); addNameToItem( nData, rListWrp ); } template< typename Type > -void OutputObjectBase::writeHexItem( const sal_Char* pcName, Type nData, const NameListWrapper& rListWrp ) +void OutputObjectBase::writeHexItem( const String& rName, Type nData, const NameListWrapper& rListWrp ) { - ItemGuard aItem( *mxOut, pcName ); + ItemGuard aItem( *mxOut, rName ); mxOut->writeHex( nData ); addNameToItem( nData, rListWrp ); } template< typename Type > -void OutputObjectBase::writeBinItem( const sal_Char* pcName, Type nData, const NameListWrapper& rListWrp ) +void OutputObjectBase::writeShortHexItem( const String& rName, Type nData, const NameListWrapper& rListWrp ) +{ + ItemGuard aItem( *mxOut, rName ); + mxOut->writeShortHex( nData ); + addNameToItem( nData, rListWrp ); +} + +template< typename Type > +void OutputObjectBase::writeBinItem( const String& rName, Type nData, const NameListWrapper& rListWrp ) { - ItemGuard aItem( *mxOut, pcName ); + ItemGuard aItem( *mxOut, rName ); mxOut->writeBin( nData ); addNameToItem( nData, rListWrp ); } template< typename Type > -void OutputObjectBase::writeFixItem( const sal_Char* pcName, Type nData, const NameListWrapper& rListWrp ) +void OutputObjectBase::writeFixItem( const String& rName, Type nData, const NameListWrapper& rListWrp ) { - ItemGuard aItem( *mxOut, pcName ); + ItemGuard aItem( *mxOut, rName ); mxOut->writeFix( nData ); addNameToItem( nData, rListWrp ); } template< typename Type > -void OutputObjectBase::writeDecBoolItem( const sal_Char* pcName, Type nData, const NameListWrapper& rListWrp ) +void OutputObjectBase::writeDecBoolItem( const String& rName, Type nData, const NameListWrapper& rListWrp ) { - ItemGuard aItem( *mxOut, pcName ); + ItemGuard aItem( *mxOut, rName ); mxOut->writeDec( nData ); aItem.cont(); mxOut->writeBool( nData != 0 ); @@ -1436,13 +1486,13 @@ void OutputObjectBase::writeDecBoolItem( const sal_Char* pcName, Type nData, con } template< typename Type > -void OutputObjectBase::writeValueItem( const sal_Char* pcName, Type nData, FormatType eFmtType, const NameListWrapper& rListWrp ) +void OutputObjectBase::writeValueItem( const String& rName, Type nData, FormatType eFmtType, const NameListWrapper& rListWrp ) { if( eFmtType == FORMATTYPE_BOOL ) - writeDecBoolItem( pcName, nData, rListWrp ); + writeDecBoolItem( rName, nData, rListWrp ); else { - ItemGuard aItem( *mxOut, pcName ); + ItemGuard aItem( *mxOut, rName ); mxOut->writeValue( nData, eFmtType ); addNameToItem( nData, rListWrp ); } @@ -1467,71 +1517,83 @@ public: protected: inline explicit InputObjectBase() {} - using OutputObjectBase::construct; - void construct( const ObjectBase& rParent, const ::rtl::OUString& rOutFileName, InputRef xIn ); - void construct( const ObjectBase& rParent, OutputRef xOut, InputRef xIn ); - void construct( const OutputObjectBase& rParent, InputRef xIn ); + void construct( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const ::rtl::OUString& rSysFileName ); + void construct( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OutputRef& rxOut ); + void construct( const OutputObjectBase& rParent, const BinaryInputStreamRef& rxStrm ); void construct( const InputObjectBase& rParent ); virtual bool implIsValid() const; - virtual InputRef implReconstructInput(); // ------------------------------------------------------------------------ - void reconstructInput(); - - inline Input& in() const { return *mxIn; } + inline BinaryInputStream& in() const { return *mxStrm; } + ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > + getXInputStream() const; // ------------------------------------------------------------------------ - void skipBlock( sal_Int32 nBytes, bool bShowSize = true ); - void dumpRawBinary( sal_Int32 nBytes, bool bShowOffset = true, bool bStream = false ); + void skipBlock( sal_Int64 nBytes, bool bShowSize = true ); + void dumpRawBinary( sal_Int64 nBytes, bool bShowOffset = true, bool bStream = false ); + + void dumpBinary( const String& rName, sal_Int64 nBytes, bool bShowOffset = true ); + void dumpRemaining( sal_Int64 nBytes ); + void dumpRemainingTo( sal_Int64 nPos ); + void dumpRemainingStream(); - void dumpBinary( const sal_Char* pcName, sal_Int32 nBytes, bool bShowOffset = true ); - void dumpArray( const sal_Char* pcName, sal_Int32 nBytes, sal_Unicode cSep = OOX_DUMP_LISTSEP ); - void dumpRemaining( sal_Int32 nBytes ); + void dumpArray( const String& rName, sal_Int32 nBytes, sal_Unicode cSep = OOX_DUMP_LISTSEP ); inline void dumpUnused( sal_Int32 nBytes ) { dumpArray( OOX_DUMP_UNUSED, nBytes ); } inline void dumpUnknown( sal_Int32 nBytes ) { dumpArray( OOX_DUMP_UNKNOWN, nBytes ); } - ::rtl::OUString dumpCharArray( const sal_Char* pcName, sal_Int32 nSize, rtl_TextEncoding eTextEnc ); - ::rtl::OUString dumpUnicodeArray( const sal_Char* pcName, sal_Int32 nSize ); + sal_Unicode dumpChar( const String& rName, rtl_TextEncoding eTextEnc ); + sal_Unicode dumpUnicode( const String& rName ); + + ::rtl::OUString dumpCharArray( const String& rName, sal_Int32 nLen, rtl_TextEncoding eTextEnc ); + ::rtl::OUString dumpUnicodeArray( const String& rName, sal_Int32 nLen ); + + ::rtl::OUString dumpNullCharArray( const String& rName, rtl_TextEncoding eTextEnc ); + ::rtl::OUString dumpNullUnicodeArray( const String& rName ); + + double dumpRk( const String& rName = EMPTY_STRING ); + sal_Int32 dumpColorABGR( const String& rName = EMPTY_STRING ); + ::com::sun::star::util::DateTime dumpFileTime( const String& rName = EMPTY_STRING ); + ::rtl::OUString dumpGuid( const String& rName = EMPTY_STRING ); - double dumpRk( const sal_Char* pcName = 0 ); - ::rtl::OUString dumpGuid( const sal_Char* pcName = 0 ); void dumpItem( const ItemFormat& rItemFmt ); template< typename Type > - Type dumpName( const sal_Char* pcName, const NameListWrapper& rListWrp ); + Type dumpName( const String& rName, const NameListWrapper& rListWrp ); template< typename Type > - Type dumpDec( const sal_Char* pcName, const NameListWrapper& rListWrp = NO_LIST ); + Type dumpDec( const String& rName, const NameListWrapper& rListWrp = NO_LIST ); template< typename Type > - Type dumpHex( const sal_Char* pcName, const NameListWrapper& rListWrp = NO_LIST ); + Type dumpHex( const String& rName, const NameListWrapper& rListWrp = NO_LIST ); template< typename Type > - Type dumpBin( const sal_Char* pcName, const NameListWrapper& rListWrp = NO_LIST ); + Type dumpBin( const String& rName, const NameListWrapper& rListWrp = NO_LIST ); template< typename Type > - Type dumpFix( const sal_Char* pcName, const NameListWrapper& rListWrp = NO_LIST ); + Type dumpFix( const String& rName, const NameListWrapper& rListWrp = NO_LIST ); template< typename Type > - Type dumpBool( const sal_Char* pcName, const NameListWrapper& rListWrp = NO_LIST ); + Type dumpBool( const String& rName, const NameListWrapper& rListWrp = NO_LIST ); template< typename Type > Type dumpValue( const ItemFormat& rItemFmt ); template< typename Type1, typename Type2 > - Type1 dumpName( bool bType1, const sal_Char* pcName, const NameListWrapper& rListWrp = NO_LIST ); + Type1 dumpName( bool bType1, const String& rName, const NameListWrapper& rListWrp = NO_LIST ); template< typename Type1, typename Type2 > - Type1 dumpDec( bool bType1, const sal_Char* pcName, const NameListWrapper& rListWrp = NO_LIST ); + Type1 dumpDec( bool bType1, const String& rName, const NameListWrapper& rListWrp = NO_LIST ); template< typename Type1, typename Type2 > - Type1 dumpHex( bool bType1, const sal_Char* pcName, const NameListWrapper& rListWrp = NO_LIST ); + Type1 dumpHex( bool bType1, const String& rName, const NameListWrapper& rListWrp = NO_LIST ); template< typename Type1, typename Type2 > - Type1 dumpBin( bool bType1, const sal_Char* pcName, const NameListWrapper& rListWrp = NO_LIST ); + Type1 dumpBin( bool bType1, const String& rName, const NameListWrapper& rListWrp = NO_LIST ); template< typename Type1, typename Type2 > - Type1 dumpFix( bool bType1, const sal_Char* pcName, const NameListWrapper& rListWrp = NO_LIST ); + Type1 dumpFix( bool bType1, const String& rName, const NameListWrapper& rListWrp = NO_LIST ); template< typename Type1, typename Type2 > - Type1 dumpBool( bool bType1, const sal_Char* pcName, const NameListWrapper& rListWrp = NO_LIST ); + Type1 dumpBool( bool bType1, const String& rName, const NameListWrapper& rListWrp = NO_LIST ); template< typename Type1, typename Type2 > Type1 dumpValue( bool bType1, const ItemFormat& rItemFmt ); private: - InputRef mxIn; + using OutputObjectBase::construct; + + BinaryInputStreamRef mxStrm; }; typedef ::boost::shared_ptr< InputObjectBase > InputObjectRef; @@ -1539,56 +1601,56 @@ typedef ::boost::shared_ptr< InputObjectBase > InputObjectRef; // ---------------------------------------------------------------------------- template< typename Type > -Type InputObjectBase::dumpName( const sal_Char* pcName, const NameListWrapper& rListWrp ) +Type InputObjectBase::dumpName( const String& rName, const NameListWrapper& rListWrp ) { Type nData; - *mxIn >> nData; - writeNameItem( pcName, nData, rListWrp ); + *mxStrm >> nData; + writeNameItem( rName, nData, rListWrp ); return nData; } template< typename Type > -Type InputObjectBase::dumpDec( const sal_Char* pcName, const NameListWrapper& rListWrp ) +Type InputObjectBase::dumpDec( const String& rName, const NameListWrapper& rListWrp ) { Type nData; - *mxIn >> nData; - writeDecItem( pcName, nData, rListWrp ); + *mxStrm >> nData; + writeDecItem( rName, nData, rListWrp ); return nData; } template< typename Type > -Type InputObjectBase::dumpHex( const sal_Char* pcName, const NameListWrapper& rListWrp ) +Type InputObjectBase::dumpHex( const String& rName, const NameListWrapper& rListWrp ) { Type nData; - *mxIn >> nData; - writeHexItem( pcName, nData, rListWrp ); + *mxStrm >> nData; + writeHexItem( rName, nData, rListWrp ); return nData; } template< typename Type > -Type InputObjectBase::dumpBin( const sal_Char* pcName, const NameListWrapper& rListWrp ) +Type InputObjectBase::dumpBin( const String& rName, const NameListWrapper& rListWrp ) { Type nData; - *mxIn >> nData; - writeBinItem( pcName, nData, rListWrp ); + *mxStrm >> nData; + writeBinItem( rName, nData, rListWrp ); return nData; } template< typename Type > -Type InputObjectBase::dumpFix( const sal_Char* pcName, const NameListWrapper& rListWrp ) +Type InputObjectBase::dumpFix( const String& rName, const NameListWrapper& rListWrp ) { Type nData; - *mxIn >> nData; - writeFixItem( pcName, nData, rListWrp ); + *mxStrm >> nData; + writeFixItem( rName, nData, rListWrp ); return nData; } template< typename Type > -Type InputObjectBase::dumpBool( const sal_Char* pcName, const NameListWrapper& rListWrp ) +Type InputObjectBase::dumpBool( const String& rName, const NameListWrapper& rListWrp ) { Type nData; - *mxIn >> nData; - writeDecBoolItem( pcName, nData, rListWrp ); + *mxStrm >> nData; + writeDecBoolItem( rName, nData, rListWrp ); return nData; } @@ -1596,45 +1658,45 @@ template< typename Type > Type InputObjectBase::dumpValue( const ItemFormat& rItemFmt ) { Type nData; - *mxIn >> nData; + *mxStrm >> nData; writeValueItem( rItemFmt, nData ); return nData; } template< typename Type1, typename Type2 > -Type1 InputObjectBase::dumpName( bool bType1, const sal_Char* pcName, const NameListWrapper& rListWrp ) +Type1 InputObjectBase::dumpName( bool bType1, const String& rName, const NameListWrapper& rListWrp ) { - return bType1 ? dumpName< Type1 >( pcName, rListWrp ) : static_cast< Type1 >( dumpName< Type2 >( pcName, rListWrp ) ); + return bType1 ? dumpName< Type1 >( rName, rListWrp ) : static_cast< Type1 >( dumpName< Type2 >( rName, rListWrp ) ); } template< typename Type1, typename Type2 > -Type1 InputObjectBase::dumpDec( bool bType1, const sal_Char* pcName, const NameListWrapper& rListWrp ) +Type1 InputObjectBase::dumpDec( bool bType1, const String& rName, const NameListWrapper& rListWrp ) { - return bType1 ? dumpDec< Type1 >( pcName, rListWrp ) : static_cast< Type1 >( dumpDec< Type2 >( pcName, rListWrp ) ); + return bType1 ? dumpDec< Type1 >( rName, rListWrp ) : static_cast< Type1 >( dumpDec< Type2 >( rName, rListWrp ) ); } template< typename Type1, typename Type2 > -Type1 InputObjectBase::dumpHex( bool bType1, const sal_Char* pcName, const NameListWrapper& rListWrp ) +Type1 InputObjectBase::dumpHex( bool bType1, const String& rName, const NameListWrapper& rListWrp ) { - return bType1 ? dumpHex< Type1 >( pcName, rListWrp ) : static_cast< Type1 >( dumpHex< Type2 >( pcName, rListWrp ) ); + return bType1 ? dumpHex< Type1 >( rName, rListWrp ) : static_cast< Type1 >( dumpHex< Type2 >( rName, rListWrp ) ); } template< typename Type1, typename Type2 > -Type1 InputObjectBase::dumpBin( bool bType1, const sal_Char* pcName, const NameListWrapper& rListWrp ) +Type1 InputObjectBase::dumpBin( bool bType1, const String& rName, const NameListWrapper& rListWrp ) { - return bType1 ? dumpBin< Type1 >( pcName, rListWrp ) : static_cast< Type1 >( dumpBin< Type2 >( pcName, rListWrp ) ); + return bType1 ? dumpBin< Type1 >( rName, rListWrp ) : static_cast< Type1 >( dumpBin< Type2 >( rName, rListWrp ) ); } template< typename Type1, typename Type2 > -Type1 InputObjectBase::dumpFix( bool bType1, const sal_Char* pcName, const NameListWrapper& rListWrp ) +Type1 InputObjectBase::dumpFix( bool bType1, const String& rName, const NameListWrapper& rListWrp ) { - return bType1 ? dumpFix< Type1 >( pcName, rListWrp ) : static_cast< Type1 >( dumpFix< Type2 >( pcName, rListWrp ) ); + return bType1 ? dumpFix< Type1 >( rName, rListWrp ) : static_cast< Type1 >( dumpFix< Type2 >( rName, rListWrp ) ); } template< typename Type1, typename Type2 > -Type1 InputObjectBase::dumpBool( bool bType1, const sal_Char* pcName, const NameListWrapper& rListWrp ) +Type1 InputObjectBase::dumpBool( bool bType1, const String& rName, const NameListWrapper& rListWrp ) { - return bType1 ? dumpBool< Type1 >( pcName, rListWrp ) : static_cast< Type1 >( dumpBool< Type2 >( pcName, rListWrp ) ); + return bType1 ? dumpBool< Type1 >( rName, rListWrp ) : static_cast< Type1 >( dumpBool< Type2 >( rName, rListWrp ) ); } template< typename Type1, typename Type2 > @@ -1644,48 +1706,52 @@ Type1 InputObjectBase::dumpValue( bool bType1, const ItemFormat& rItemFmt ) } // ============================================================================ +// ============================================================================ -class InputStreamObject : public InputObjectBase +class BinaryStreamObject : public InputObjectBase { public: - explicit InputStreamObject( const ObjectBase& rParent, const ::rtl::OUString& rOutFileName, BinaryInputStreamRef xStrm ); - virtual ~InputStreamObject(); + explicit BinaryStreamObject( + const ObjectBase& rParent, + const BinaryInputStreamRef& rxStrm, + const ::rtl::OUString& rSysFileName ); - inline BinaryInputStream& getStream() { return *mxStrm; } - sal_Int64 getStreamSize() const; + explicit BinaryStreamObject( + const OutputObjectBase& rParent, + const BinaryInputStreamRef& rxStrm ); protected: - inline explicit InputStreamObject() {} - - using InputObjectBase::construct; - void construct( const ObjectBase& rParent, const ::rtl::OUString& rOutFileName, BinaryInputStreamRef xStrm ); - void dumpBinaryStream( bool bShowOffset = true ); - virtual bool implIsValid() const; virtual void implDump(); - -private: - BinaryInputStreamRef mxStrm; }; -typedef ::boost::shared_ptr< InputStreamObject > InputStreamObjectRef; - -// ============================================================================ // ============================================================================ -class TextStreamObject : public InputStreamObject +class TextStreamObject : public InputObjectBase { public: - explicit TextStreamObject( const ObjectBase& rParent, - const ::rtl::OUString& rOutFileName, - BinaryInputStreamRef xStrm, rtl_TextEncoding eTextEnc ); + explicit TextStreamObject( + const ObjectBase& rParent, + const BinaryInputStreamRef& rxStrm, + rtl_TextEncoding eTextEnc, + const ::rtl::OUString& rSysFileName ); + + explicit TextStreamObject( + const OutputObjectBase& rParent, + const BinaryInputStreamRef& rxStrm, + rtl_TextEncoding eTextEnc ); protected: virtual void implDump(); virtual void implDumpLine( const ::rtl::OUString& rLine, sal_uInt32 nLine ); private: + bool readCharLine( ::rtl::OUString& orLine, sal_Unicode& orcNextLineChar ); + bool readUcs2Line( ::rtl::OUString& orLine, sal_Unicode& orcNextLineChar ); + bool readLine( ::rtl::OUString& orLine, sal_Unicode& orcNextLineChar ); + +private: rtl_TextEncoding meTextEnc; }; @@ -1694,7 +1760,10 @@ private: class XmlStreamObject : public TextStreamObject { public: - explicit XmlStreamObject( const ObjectBase& rParent, const ::rtl::OUString& rOutFileName, BinaryInputStreamRef xStrm ); + explicit XmlStreamObject( + const ObjectBase& rParent, + const BinaryInputStreamRef& rxStrm, + const ::rtl::OUString& rSysFileName ); protected: virtual void implDump(); @@ -1707,123 +1776,105 @@ private: // ============================================================================ // ============================================================================ -struct RecordHeaderConfigInfo +class RecordObjectBase : public InputObjectBase { - const sal_Char* mpcTitle; - const sal_Char* mpcRecNames; - const sal_Char* mpcShowRecPos; - const sal_Char* mpcShowRecSize; - const sal_Char* mpcShowRecId; - const sal_Char* mpcShowRecName; - const sal_Char* mpcShowRecBody; -}; +protected: + inline explicit RecordObjectBase() {} -// ============================================================================ + inline sal_Int64 getRecPos() const { return mnRecPos; } + inline sal_Int64 getRecId() const { return mnRecId; } + inline sal_Int64 getRecSize() const { return mnRecSize; } + inline NameListRef getRecNames() const { return maRecNames.getNameList( cfg() ); } + + void construct( + const ObjectBase& rParent, + const BinaryInputStreamRef& rxBaseStrm, + const ::rtl::OUString& rSysFileName, + const BinaryInputStreamRef& rxRecStrm, + const String& rRecNames, + const String& rSimpleRecs = EMPTY_STRING ); + + void construct( + const OutputObjectBase& rParent, + const BinaryInputStreamRef& rxBaseStrm, + const BinaryInputStreamRef& rxRecStrm, + const String& rRecNames, + const String& rSimpleRecs = EMPTY_STRING ); -class RecordHeaderImplBase : public InputObjectBase -{ -public: - inline const sal_Char* getTitle() const { return mpcTitle; } - inline NameListRef getRecNames() const { return mxRecNames; } - inline bool isShowRecPos() const { return mbShowRecPos; } - inline bool isShowRecSize() const { return mbShowRecSize; } - inline bool isShowRecId() const { return mbShowRecId; } - inline bool isShowRecName() const { return mbShowRecName; } - inline bool isShowRecBody() const { return mbShowRecBody; } + virtual bool implIsValid() const; + virtual void implDump(); -protected: - inline explicit RecordHeaderImplBase() {} - virtual ~RecordHeaderImplBase(); + virtual bool implStartRecord( BinaryInputStream& rBaseStrm, sal_Int64& ornRecPos, sal_Int64& ornRecId, sal_Int64& ornRecSize ) = 0; + virtual void implWriteExtHeader(); + virtual void implDumpRecordBody(); +private: using InputObjectBase::construct; - void construct( const InputObjectBase& rParent, const RecordHeaderConfigInfo& rCfgInfo ); - virtual bool implIsValid() const; + void constructRecObjBase( + const BinaryInputStreamRef& rxBaseStrm, + const String& rRecNames, + const String& rSimpleRecs ); + + void writeHeader(); private: - const sal_Char* mpcTitle; - NameListRef mxRecNames; - bool mbShowRecPos; - bool mbShowRecSize; - bool mbShowRecId; - bool mbShowRecName; - bool mbShowRecBody; + BinaryInputStreamRef mxBaseStrm; + NameListWrapper maRecNames; + NameListWrapper maSimpleRecs; + sal_Int64 mnRecPos; + sal_Int64 mnRecId; + sal_Int64 mnRecSize; }; // ============================================================================ -template< typename RecIdType, typename RecSizeType > -class RecordHeaderBase : public RecordHeaderImplBase +class SequenceRecordObjectBase : public RecordObjectBase { -public: - inline bool isValidHeader() const { return mbValidHeader; } - inline sal_Int64 getRecPos() const { return mnRecPos; } - inline RecIdType getRecId() const { return mnRecId; } - inline RecSizeType getRecSize() const { return mnRecSize; } - inline bool hasRecName() const { return getRecNames()->hasName( mnRecId ); } - - bool startNextRecord(); - protected: - using RecordHeaderImplBase::construct; - void construct( const InputObjectBase& rParent, const RecordHeaderConfigInfo& rCfgInfo ); - - inline virtual void implDump(); - virtual bool implReadHeader( sal_Int64& ornRecPos, RecIdType& ornRecId, RecSizeType& ornRecSize ) = 0; - inline virtual void implWriteExtHeader() {} + inline explicit SequenceRecordObjectBase() : mxRecData( new StreamDataSequence ) {} + + inline StreamDataSequence& getRecordDataSequence() { return *mxRecData; } + + void construct( + const ObjectBase& rParent, + const BinaryInputStreamRef& rxBaseStrm, + const ::rtl::OUString& rSysFileName, + const BinaryInputStreamRef& rxRecStrm, + const String& rRecNames, + const String& rSimpleRecs = EMPTY_STRING ); + + void construct( + const OutputObjectBase& rParent, + const BinaryInputStreamRef& rxBaseStrm, + const BinaryInputStreamRef& rxRecStrm, + const String& rRecNames, + const String& rSimpleRecs = EMPTY_STRING ); + + void construct( + const ObjectBase& rParent, + const BinaryInputStreamRef& rxBaseStrm, + const ::rtl::OUString& rSysFileName, + const String& rRecNames, + const String& rSimpleRecs = EMPTY_STRING ); + + void construct( + const OutputObjectBase& rParent, + const BinaryInputStreamRef& rxBaseStrm, + const String& rRecNames, + const String& rSimpleRecs = EMPTY_STRING ); + + virtual bool implStartRecord( BinaryInputStream& rBaseStrm, sal_Int64& ornRecPos, sal_Int64& ornRecId, sal_Int64& ornRecSize ); + virtual bool implReadRecordHeader( BinaryInputStream& rBaseStrm, sal_Int64& ornRecId, sal_Int64& ornRecSize ) = 0; private: - void writeHeader(); + using RecordObjectBase::construct; private: - sal_Int64 mnRecPos; - RecIdType mnRecId; - RecSizeType mnRecSize; - bool mbValidHeader; + typedef ::boost::shared_ptr< StreamDataSequence > StreamDataSeqRef; + StreamDataSeqRef mxRecData; }; -// ---------------------------------------------------------------------------- - -template< typename RecIdType, typename RecSizeType > -bool RecordHeaderBase< RecIdType, RecSizeType >::startNextRecord() -{ - dump(); - return mbValidHeader; -} - -template< typename RecIdType, typename RecSizeType > -void RecordHeaderBase< RecIdType, RecSizeType >::construct( - const InputObjectBase& rParent, const RecordHeaderConfigInfo& rCfgInfo ) -{ - RecordHeaderImplBase::construct( rParent, rCfgInfo ); - mnRecPos = 0; - mnRecId = 0; - mnRecSize = 0; - mbValidHeader = false; -} - -template< typename RecIdType, typename RecSizeType > -inline void RecordHeaderBase< RecIdType, RecSizeType >::implDump() -{ - mbValidHeader = implReadHeader( mnRecPos, mnRecId, mnRecSize ); - if( mbValidHeader ) - { - writeHeader(); - implWriteExtHeader(); - } -} - -template< typename RecIdType, typename RecSizeType > -void RecordHeaderBase< RecIdType, RecSizeType >::writeHeader() -{ - MultiItemsGuard aMultiGuard( out() ); - writeEmptyItem( getTitle() ); - if( isShowRecPos() ) writeHexItem( "pos", static_cast< sal_uInt32 >( mnRecPos ), "CONV-DEC" ); - if( isShowRecSize() ) writeHexItem( "size", mnRecSize, "CONV-DEC" ); - if( isShowRecId() ) writeHexItem( "id", mnRecId ); - if( isShowRecName() ) writeNameItem( "name", mnRecId, getRecNames() ); -} - // ============================================================================ // ============================================================================ @@ -1837,14 +1888,13 @@ public: bool isImportEnabled() const; - StorageRef getRootStorage() const; - BinaryInputStreamRef getRootStream() const; - protected: inline explicit DumperBase() {} + void construct( const ConfigRef& rxConfig ); + +private: using ObjectBase::construct; - void construct( const ::oox::core::FilterBase& rFilter, ConfigRef xConfig ); }; // ============================================================================ diff --git a/oox/inc/oox/dump/oledumper.hxx b/oox/inc/oox/dump/oledumper.hxx new file mode 100644 index 000000000000..ca6007999c51 --- /dev/null +++ b/oox/inc/oox/dump/oledumper.hxx @@ -0,0 +1,766 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: oledumper.hxx,v $ + * $Revision: 1.1.2.11 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef OOX_DUMP_OLEDUMPER_HXX +#define OOX_DUMP_OLEDUMPER_HXX + +#include "oox/helper/storagebase.hxx" +#include "oox/dump/dumperbase.hxx" + +#if OOX_INCLUDE_DUMPER + +namespace com { namespace sun { namespace star { + namespace io { class XInputStream; } +} } } + +namespace oox { +namespace dump { + +// ============================================================================ +// ============================================================================ + +class StdFontObject : public InputObjectBase +{ +public: + explicit StdFontObject( const InputObjectBase& rParent ); + +protected: + virtual void implDump(); +}; + +// ============================================================================ + +class StdPicObject : public InputObjectBase +{ +public: + explicit StdPicObject( const InputObjectBase& rParent ); + +protected: + virtual void implDump(); +}; + +// ============================================================================ + +class StdHlinkObject : public InputObjectBase +{ +public: + explicit StdHlinkObject( const InputObjectBase& rParent ); + +protected: + virtual void implDump(); + +private: + ::rtl::OUString dumpHyperlinkString( const String& rName, bool bUnicode ); + + bool dumpGuidAndMoniker(); + void dumpUrlMoniker(); + void dumpFileMoniker(); + void dumpItemMoniker(); + void dumpAntiMoniker(); + void dumpCompositeMoniker(); +}; + +// ============================================================================ +// ============================================================================ + +class OlePropertyStreamObject : public BinaryStreamObject +{ +public: + explicit OlePropertyStreamObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const ::rtl::OUString& rSysFileName ); + +protected: + virtual void implDump(); + +private: + void dumpSection( const ::rtl::OUString& rGuid, sal_uInt32 nStartPos ); + + void dumpProperty( sal_Int32 nPropId, sal_uInt32 nStartPos ); + void dumpCodePageProperty( sal_uInt32 nStartPos ); + void dumpDictionaryProperty( sal_uInt32 nStartPos ); + + void dumpPropertyContents( sal_Int32 nPropId ); + void dumpPropertyValue( sal_Int32 nPropId, sal_Int32 nBaseType ); + + sal_Int32 dumpPropertyType(); + void dumpBlob( const String& rName ); + ::rtl::OUString dumpString8( const String& rName ); + ::rtl::OUString dumpCharArray8( const String& rName, sal_Int32 nLen ); + ::rtl::OUString dumpString16( const String& rName ); + ::rtl::OUString dumpCharArray16( const String& rName, sal_Int32 nLen ); + + bool startElement( sal_uInt32 nStartPos ); + void writeSectionHeader( const ::rtl::OUString& rGuid, sal_uInt32 nStartPos ); + void writePropertyHeader( sal_Int32 nPropId, sal_uInt32 nStartPos ); + +private: + NameListRef mxPropIds; + rtl_TextEncoding meTextEnc; + bool mbIsUnicode; +}; + +// ============================================================================ + +class OleStorageObject : public StorageObjectBase +{ +public: + explicit OleStorageObject( const ObjectBase& rParent, const StorageRef& rxStrg, const ::rtl::OUString& rSysPath ); + +protected: + inline explicit OleStorageObject() {} + + void construct( const ObjectBase& rParent, const StorageRef& rxStrg, const ::rtl::OUString& rSysPath ); + void construct( const ObjectBase& rParent ); + + virtual void implDumpStream( + const BinaryInputStreamRef& rxStrm, + const ::rtl::OUString& rStrgPath, + const ::rtl::OUString& rStrmName, + const ::rtl::OUString& rSysFileName ); + +private: + using StorageObjectBase::construct; +}; + +// ============================================================================ +// ============================================================================ + +struct OcxFormSiteInfo +{ + ::rtl::OUString maProgId; + sal_Int32 mnId; + sal_uInt32 mnLength; + bool mbInStream; + + inline explicit OcxFormSiteInfo() : mnId( 0 ), mnLength( 0 ), mbInStream( false ) {} +}; + +typedef ::std::vector< OcxFormSiteInfo > OcxFormSiteInfoVector; + +// ---------------------------------------------------------------------------- + +struct OcxFormSharedData +{ + OUStringVector maClassInfoProgIds; + OcxFormSiteInfoVector maSiteInfos; +}; + +// ============================================================================ +// ============================================================================ + +class OcxPropertyObjectBase : public InputObjectBase +{ +protected: + inline explicit OcxPropertyObjectBase() {} + + void construct( + const ObjectBase& rParent, + const BinaryInputStreamRef& rxStrm, + const ::rtl::OUString& rSysFileName, + const String& rPropNameList, + bool b64BitPropFlags = false ); + void construct( + const OutputObjectBase& rParent, + const BinaryInputStreamRef& rxStrm, + const String& rPropNameList, + bool b64BitPropFlags = false ); + void construct( + const InputObjectBase& rParent, + const String& rPropNameList, + bool b64BitPropFlags = false ); + + virtual bool implIsValid() const; + virtual void implDump(); + + virtual void implDumpShortProperties(); + virtual void implDumpExtended(); + + bool ensureValid( bool bCondition = true ); + + template< typename Type > + void alignInput(); + + void setAlignAnchor(); + bool startNextProperty(); + ::rtl::OUString getPropertyName() const; + + template< typename Type > + Type dumpDecProperty( Type nDefault, const NameListWrapper& rListWrp = NO_LIST ); + template< typename Type > + Type dumpHexProperty( Type nDefault, const NameListWrapper& rListWrp = NO_LIST ); + + inline bool dumpBoolProperty() { return startNextProperty(); } + inline sal_Int32 dumpHmmProperty() { return dumpDecProperty< sal_Int32 >( 0, "CONV-HMM-TO-CM" ); } + inline sal_uInt8 dumpMousePtrProperty() { return dumpDecProperty< sal_uInt8 >( 0, "OCX-MOUSEPTR" ); } + template< typename Type > + inline Type dumpBorderStyleProperty( Type nDefault ) { return dumpDecProperty< Type >( nDefault, "OCX-BORDERSTYLE" ); } + template< typename Type > + inline Type dumpSpecialEffectProperty( Type nDefault ) { return dumpDecProperty< Type >( nDefault, "OCX-SPECIALEFFECT" ); } + inline sal_uInt32 dumpEnabledProperty() { return dumpDecProperty< sal_uInt32 >( 1, "OCX-ENABLED" ); } + inline sal_Int32 dumpOrientationProperty() { return dumpDecProperty< sal_Int32 >( -1, "OCX-ORIENTATION" ); } + inline sal_Int32 dumpDelayProperty() { return dumpDecProperty< sal_Int32 >( 50, "OCX-CONV-MS" ); } + inline sal_uInt32 dumpImagePosProperty() { return dumpHexProperty< sal_uInt32 >( 0x00070001, "OCX-IMAGEPOS" ); } + inline sal_uInt8 dumpImageSizeModeProperty() { return dumpDecProperty< sal_uInt8 >( 0, "OCX-IMAGESIZEMODE" ); } + inline sal_uInt8 dumpImageAlignProperty() { return dumpDecProperty< sal_uInt8 >( 2, "OCX-IMAGEALIGN" ); } + + sal_uInt32 dumpFlagsProperty( sal_uInt32 nDefault, const sal_Char* pcNameList = "OCX-FLAGS" ); + sal_uInt32 dumpColorProperty( sal_uInt32 nDefault ); + sal_Unicode dumpUnicodeProperty(); + void dumpUnknownProperty(); + + void dumpPosProperty(); + void dumpSizeProperty(); + void dumpGuidProperty( ::rtl::OUString* pValue = 0 ); + void dumpStringProperty( ::rtl::OUString* pValue = 0 ); + void dumpStringArrayProperty(); + void dumpStreamProperty(); + + void dumpEmbeddedFont(); + void dumpToPosition( sal_Int64 nPos ); + +private: + using InputObjectBase::construct; + + void constructOcxPropObj( const String& rPropNameList, bool b64BitPropFlags ); + + void dumpVersion(); + ::rtl::OUString dumpString( const String& rName, sal_uInt32 nSize, bool bArray ); + void dumpShortProperties(); + void dumpLargeProperties(); + +private: + enum LargePropertyType { PROPTYPE_POS, PROPTYPE_SIZE, PROPTYPE_GUID, PROPTYPE_STRING, PROPTYPE_STRINGARRAY }; + + struct LargeProperty + { + LargePropertyType mePropType; + ::rtl::OUString maItemName; + sal_uInt32 mnDataSize; + ::rtl::OUString* mpItemValue; + inline explicit LargeProperty( LargePropertyType ePropType, const String& rItemName, sal_uInt32 nDataSize, ::rtl::OUString* pItemValue = 0 ) : + mePropType( ePropType ), maItemName( rItemName ), mnDataSize( nDataSize ), mpItemValue( pItemValue ) {} + }; + typedef ::std::vector< LargeProperty > LargePropertyVector; + + struct StreamProperty + { + ::rtl::OUString maItemName; + sal_uInt16 mnData; + inline explicit StreamProperty( const String& rItemName, sal_uInt16 nData ) : + maItemName( rItemName ), mnData( nData ) {} + }; + typedef ::std::vector< StreamProperty > StreamPropertyVector; + + LargePropertyVector maLargeProps; + StreamPropertyVector maStreamProps; + NameListRef mxPropNames; + sal_Int64 mnPropertiesStart; + sal_Int64 mnPropertiesEnd; + sal_Int64 mnPropFlags; + sal_Int64 mnCurrProp; + bool mb64BitPropFlags; + bool mbValid; +}; + +// ---------------------------------------------------------------------------- + +template< typename Type > +void OcxPropertyObjectBase::alignInput() +{ + in().skip( (sizeof( Type ) - ((in().tell() - mnPropertiesStart) % sizeof( Type ))) % sizeof( Type ) ); +} + +template< typename Type > +Type OcxPropertyObjectBase::dumpDecProperty( Type nDefault, const NameListWrapper& rListWrp ) +{ + if( startNextProperty() ) + { + alignInput< Type >(); + return dumpDec< Type >( getPropertyName(), rListWrp ); + } + return nDefault; +} + +template< typename Type > +Type OcxPropertyObjectBase::dumpHexProperty( Type nDefault, const NameListWrapper& rListWrp ) +{ + if( startNextProperty() ) + { + alignInput< Type >(); + return dumpHex< Type >( getPropertyName(), rListWrp ); + } + return nDefault; +} + +// ============================================================================ + +class OcxCFontNewObject : public OcxPropertyObjectBase +{ +public: + explicit OcxCFontNewObject( const InputObjectBase& rParent ); + +protected: + virtual void implDumpShortProperties(); +}; + +// ============================================================================ + +class OcxColumnInfoObject : public OcxPropertyObjectBase +{ +public: + explicit OcxColumnInfoObject( const InputObjectBase& rParent ); + +protected: + virtual void implDumpShortProperties(); +}; + +// ============================================================================ + +class OcxCommandButtonObject : public OcxPropertyObjectBase +{ +public: + explicit OcxCommandButtonObject( const InputObjectBase& rParent ); + +protected: + virtual void implDumpShortProperties(); + virtual void implDumpExtended(); +}; + +// ============================================================================ + +class OcxMorphControlObject : public OcxPropertyObjectBase +{ +public: + explicit OcxMorphControlObject( const InputObjectBase& rParent ); + +protected: + virtual void implDumpShortProperties(); + virtual void implDumpExtended(); + +private: + void dumpColumnInfos(); + +private: + sal_uInt16 mnColInfoCount; + sal_uInt8 mnCtrlType; +}; + +// ============================================================================ + +class OcxLabelObject : public OcxPropertyObjectBase +{ +public: + explicit OcxLabelObject( const InputObjectBase& rParent ); + +protected: + virtual void implDumpShortProperties(); + virtual void implDumpExtended(); +}; + +// ============================================================================ + +class OcxImageObject : public OcxPropertyObjectBase +{ +public: + explicit OcxImageObject( const InputObjectBase& rParent ); + +protected: + virtual void implDumpShortProperties(); +}; + +// ============================================================================ + +class OcxScrollBarObject : public OcxPropertyObjectBase +{ +public: + explicit OcxScrollBarObject( const InputObjectBase& rParent ); + +protected: + virtual void implDumpShortProperties(); +}; + +// ============================================================================ + +class OcxSpinButtonObject : public OcxPropertyObjectBase +{ +public: + explicit OcxSpinButtonObject( const InputObjectBase& rParent ); + +protected: + virtual void implDumpShortProperties(); +}; + +// ============================================================================ + +class OcxTabStripObject : public OcxPropertyObjectBase +{ +public: + explicit OcxTabStripObject( const InputObjectBase& rParent ); + +protected: + virtual void implDumpShortProperties(); + virtual void implDumpExtended(); + +private: + sal_Int32 mnTabFlagCount; +}; + +// ============================================================================ + +class OcxControlObject : public InputObjectBase +{ +public: + explicit OcxControlObject( + const InputObjectBase& rParent, + const ::rtl::OUString& rProgId, + sal_Int64 nLength ); + +protected: + virtual void implDump(); + +private: + ::rtl::OUString maProgId; + sal_Int64 mnLength; +}; + +// ============================================================================ + +class OcxGuidControlObject : public InputObjectBase +{ +public: + explicit OcxGuidControlObject( + const InputObjectBase& rParent, + sal_Int64 nLength ); + +protected: + virtual void implDump(); + +private: + sal_Int64 mnLength; +}; + +// ============================================================================ + +class OcxControlsStreamObject : public InputObjectBase +{ +public: + explicit OcxControlsStreamObject( + const ObjectBase& rParent, + const BinaryInputStreamRef& rxStrm, + const ::rtl::OUString& rSysFileName, + OcxFormSharedData& rFormData ); + +protected: + virtual void implDump(); + +private: + OcxFormSharedData& mrFormData; +}; + +// ============================================================================ +// ============================================================================ + +class OcxPageObject : public OcxPropertyObjectBase +{ +public: + explicit OcxPageObject( const InputObjectBase& rParent ); + +protected: + virtual void implDumpShortProperties(); +}; + +// ============================================================================ + +class OcxMultiPageObject : public OcxPropertyObjectBase +{ +public: + explicit OcxMultiPageObject( const InputObjectBase& rParent ); + +protected: + virtual void implDumpShortProperties(); + virtual void implDumpExtended(); + +private: + sal_Int32 mnPageCount; +}; + +// ============================================================================ + +class OcxMultiPageStreamObject : public InputObjectBase +{ +public: + explicit OcxMultiPageStreamObject( + const ObjectBase& rParent, + const BinaryInputStreamRef& rxStrm, + const ::rtl::OUString& rSysFileName, + OcxFormSharedData& rFormData ); + +protected: + virtual void implDump(); + +private: + OcxFormSharedData& mrFormData; +}; + +// ============================================================================ +// ============================================================================ + +class OcxFormClassInfoObject : public OcxPropertyObjectBase +{ +public: + explicit OcxFormClassInfoObject( const InputObjectBase& rParent, OcxFormSharedData& rFormData ); + +protected: + virtual void implDumpShortProperties(); + +private: + OcxFormSharedData& mrFormData; +}; + +// ============================================================================ + +class OcxFormSiteObject : public OcxPropertyObjectBase +{ +public: + explicit OcxFormSiteObject( const InputObjectBase& rParent, OcxFormSharedData& rFormData ); + +protected: + virtual void implDumpShortProperties(); + +private: + OcxFormSharedData& mrFormData; +}; + +// ============================================================================ + +class OcxFormDesignExtObject : public OcxPropertyObjectBase +{ +public: + explicit OcxFormDesignExtObject( const InputObjectBase& rParent ); + +protected: + virtual void implDumpShortProperties(); +}; + +// ============================================================================ + +class OcxFormObject : public OcxPropertyObjectBase +{ +public: + explicit OcxFormObject( + const ObjectBase& rParent, + const BinaryInputStreamRef& rxStrm, + const ::rtl::OUString& rSysFileName, + OcxFormSharedData& rFormData ); + +protected: + virtual void implDumpShortProperties(); + virtual void implDumpExtended(); + +private: + void dumpClassInfos(); + void dumpFormSites( sal_uInt32 nCount ); + void dumpSiteData(); + void dumpDesignExtender(); + +private: + OcxFormSharedData& mrFormData; + sal_uInt32 mnFlags; +}; + +// ============================================================================ + +class OcxFormStorageObject : public OleStorageObject +{ +public: + explicit OcxFormStorageObject( + const ObjectBase& rParent, + const StorageRef& rxStrg, + const ::rtl::OUString& rSysPath ); + +protected: + virtual void implDumpStream( + const BinaryInputStreamRef& rxStrm, + const ::rtl::OUString& rStrgPath, + const ::rtl::OUString& rStrmName, + const ::rtl::OUString& rSysFileName ); + + virtual void implDumpStorage( + const StorageRef& rxStrg, + const ::rtl::OUString& rStrgPath, + const ::rtl::OUString& rSysPath ); + +private: + bool isFormStorage( const ::rtl::OUString& rStrgPath ) const; + +private: + OcxFormSharedData maFormData; +}; + +// ============================================================================ +// ============================================================================ + +struct VbaSharedData +{ + typedef ::std::map< ::rtl::OUString, sal_Int32 > StreamOffsetMap; + + StreamOffsetMap maStrmOffsets; + rtl_TextEncoding meTextEnc; + + explicit VbaSharedData(); + + bool isModuleStream( const ::rtl::OUString& rStrmName ) const; + sal_Int32 getStreamOffset( const ::rtl::OUString& rStrmName ) const; +}; + +// ============================================================================ + +class VbaDirStreamObject : public SequenceRecordObjectBase +{ +public: + explicit VbaDirStreamObject( + const ObjectBase& rParent, + const BinaryInputStreamRef& rxStrm, + const ::rtl::OUString& rSysFileName, + VbaSharedData& rVbaData ); + +protected: + virtual bool implIsValid() const; + virtual bool implReadRecordHeader( BinaryInputStream& rBaseStrm, sal_Int64& ornRecId, sal_Int64& ornRecSize ); + virtual void implDumpRecordBody(); + +private: + ::rtl::OUString dumpByteString( const String& rName = EMPTY_STRING ); + ::rtl::OUString dumpUniString( const String& rName = EMPTY_STRING ); + + ::rtl::OUString dumpByteStringWithLength( const String& rName = EMPTY_STRING ); + +private: + VbaSharedData& mrVbaData; + BinaryInputStreamRef mxInStrm; + ::rtl::OUString maCurrStream; + sal_Int32 mnCurrOffset; +}; + +// ============================================================================ + +class VbaModuleStreamObject : public InputObjectBase +{ +public: + explicit VbaModuleStreamObject( + const ObjectBase& rParent, + const BinaryInputStreamRef& rxStrm, + const ::rtl::OUString& rSysFileName, + VbaSharedData& rVbaData, + sal_Int32 nStrmOffset ); + +protected: + virtual void implDump(); + +private: + VbaSharedData& mrVbaData; + sal_Int32 mnStrmOffset; +}; + +// ============================================================================ + +class VbaStorageObject : public OleStorageObject +{ +public: + explicit VbaStorageObject( + const ObjectBase& rParent, + const StorageRef& rxStrg, + const ::rtl::OUString& rSysPath, + VbaSharedData& rVbaData ); + +protected: + virtual void implDumpStream( + const BinaryInputStreamRef& rxStrm, + const ::rtl::OUString& rStrgPath, + const ::rtl::OUString& rStrmName, + const ::rtl::OUString& rSysFileName ); + +private: + VbaSharedData& mrVbaData; +}; + +// ============================================================================ + +class VbaFormStorageObject : public OcxFormStorageObject +{ +public: + explicit VbaFormStorageObject( + const ObjectBase& rParent, + const StorageRef& rxStrg, + const ::rtl::OUString& rSysPath, + VbaSharedData& rVbaData ); + +protected: + virtual void implDumpStream( + const BinaryInputStreamRef& rxStrm, + const ::rtl::OUString& rStrgPath, + const ::rtl::OUString& rStrmName, + const ::rtl::OUString& rSysFileName ); + +private: + VbaSharedData& mrVbaData; +}; + +// ============================================================================ + +class VbaProjectStorageObject : public OleStorageObject +{ +public: + explicit VbaProjectStorageObject( const ObjectBase& rParent, const StorageRef& rxStrg, const ::rtl::OUString& rSysPath ); + +protected: + virtual void implDumpStream( + const BinaryInputStreamRef& rxStrm, + const ::rtl::OUString& rStrgPath, + const ::rtl::OUString& rStrmName, + const ::rtl::OUString& rSysFileName ); + + virtual void implDumpStorage( + const StorageRef& rxStrg, + const ::rtl::OUString& rStrgPath, + const ::rtl::OUString& rSysPath ); + +private: + VbaSharedData maVbaData; +}; + +// ============================================================================ +// ============================================================================ + +} // namespace dump +} // namespace oox + +#endif +#endif + diff --git a/oox/inc/oox/dump/olestoragedumper.hxx b/oox/inc/oox/dump/olestoragedumper.hxx index cf2c5be81be3..e69de29bb2d1 100644 --- a/oox/inc/oox/dump/olestoragedumper.hxx +++ b/oox/inc/oox/dump/olestoragedumper.hxx @@ -1,91 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: olestoragedumper.hxx,v $ - * $Revision: 1.3 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef OOX_DUMP_OLESTORAGEDUMPER_HXX -#define OOX_DUMP_OLESTORAGEDUMPER_HXX - -#include "oox/helper/storagebase.hxx" -#include "oox/dump/dumperbase.hxx" - -#if OOX_INCLUDE_DUMPER - -namespace com { namespace sun { namespace star { - namespace io { class XInputStream; } -} } } - -namespace oox { -namespace dump { - -// ============================================================================ - -class OlePropertyStreamObject : public InputStreamObject -{ -public: - explicit OlePropertyStreamObject( const ObjectBase& rParent, const ::rtl::OUString& rOutFileName, BinaryInputStreamRef xStrm ); - -protected: - virtual void implDump(); - -private: - void dumpSection( const ::rtl::OUString& rGuid, sal_uInt32 nStartPos ); - - void dumpProperty( sal_Int32 nPropId, sal_uInt32 nStartPos ); - void dumpCodePageProperty( sal_uInt32 nStartPos ); - void dumpDictionaryProperty( sal_uInt32 nStartPos ); - - void dumpPropertyContents( sal_Int32 nPropId ); - void dumpPropertyValue( sal_Int32 nPropId, sal_Int32 nBaseType ); - - sal_Int32 dumpPropertyType(); - void dumpBlob( const sal_Char* pcName ); - ::rtl::OUString dumpString8( const sal_Char* pcName ); - ::rtl::OUString dumpCharArray8( const sal_Char* pcName, sal_Int32 nCharCount ); - ::rtl::OUString dumpString16( const sal_Char* pcName ); - ::rtl::OUString dumpCharArray16( const sal_Char* pcName, sal_Int32 nCharCount ); - ::com::sun::star::util::DateTime dumpFileTime( const sal_Char* pcName ); - - bool startElement( sal_uInt32 nStartPos ); - void writeSectionHeader( const ::rtl::OUString& rGuid, sal_uInt32 nStartPos ); - void writePropertyHeader( sal_Int32 nPropId, sal_uInt32 nStartPos ); - -private: - NameListRef mxPropIds; - rtl_TextEncoding meTextEnc; - bool mbIsUnicode; -}; - -// ============================================================================ - -} // namespace dump -} // namespace oox - -#endif -#endif - diff --git a/oox/inc/oox/dump/pptxdumper.hxx b/oox/inc/oox/dump/pptxdumper.hxx index 022b96822392..a136a6333dfc 100644 --- a/oox/inc/oox/dump/pptxdumper.hxx +++ b/oox/inc/oox/dump/pptxdumper.hxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: pptxdumper.hxx,v $ - * $Revision: 1.3 $ + * $Revision: 1.3.20.5 $ * * This file is part of OpenOffice.org. * @@ -41,17 +41,17 @@ namespace pptx { // ============================================================================ -class RootStorageObject : public RootStorageObjectBase +class RootStorageObject : public StorageObjectBase { public: explicit RootStorageObject( const DumperBase& rParent ); protected: virtual void implDumpStream( - BinaryInputStreamRef xStrm, + const BinaryInputStreamRef& rxStrm, const ::rtl::OUString& rStrgPath, const ::rtl::OUString& rStrmName, - const ::rtl::OUString& rSystemFileName ); + const ::rtl::OUString& rSysFileName ); }; // ============================================================================ @@ -61,6 +61,11 @@ class Dumper : public DumperBase public: explicit Dumper( const ::oox::core::FilterBase& rFilter ); + explicit Dumper( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxFactory, + const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStrm, + const ::rtl::OUString& rSysFileName ); + protected: virtual void implDump(); }; diff --git a/oox/inc/oox/dump/xlsbdumper.hxx b/oox/inc/oox/dump/xlsbdumper.hxx index e062dd0f1cb1..44cda06b2e4c 100644 --- a/oox/inc/oox/dump/xlsbdumper.hxx +++ b/oox/inc/oox/dump/xlsbdumper.hxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: xlsbdumper.hxx,v $ - * $Revision: 1.4 $ + * $Revision: 1.4.20.7 $ * * This file is part of OpenOffice.org. * @@ -47,58 +47,18 @@ namespace oox { namespace dump { namespace xlsb { -typedef ::boost::shared_ptr< RecordInputStream > RecordInputStreamRef; - -// ============================================================================ - -class RecordStreamInput : public Input -{ -public: - explicit RecordStreamInput(); - virtual ~RecordStreamInput(); - - void createStream( const RecordDataSequence& rData ); - inline RecordInputStream& getStream() { return *mxStrm; } - - virtual sal_Int64 getSize() const; - virtual sal_Int64 tell() const; - virtual void seek( sal_Int64 nPos ); - virtual void skip( sal_Int32 nBytes ); - virtual sal_Int32 read( void* pBuffer, sal_Int32 nBytes ); - - virtual RecordStreamInput& operator>>( sal_Int8& rnData ); - virtual RecordStreamInput& operator>>( sal_uInt8& rnData ); - virtual RecordStreamInput& operator>>( sal_Int16& rnData ); - virtual RecordStreamInput& operator>>( sal_uInt16& rnData ); - virtual RecordStreamInput& operator>>( sal_Int32& rnData ); - virtual RecordStreamInput& operator>>( sal_uInt32& rnData ); - virtual RecordStreamInput& operator>>( float& rfData ); - virtual RecordStreamInput& operator>>( double& rfData ); - -protected: - virtual bool implIsValid() const; - -private: - RecordInputStreamRef mxStrm; -}; - -typedef ::boost::shared_ptr< RecordStreamInput > RecordStreamInputRef; - // ============================================================================ -class RecordObjectBase : public InputObjectBase +class RecordObjectBase : public SequenceRecordObjectBase { protected: explicit RecordObjectBase(); virtual ~RecordObjectBase(); - void construct( const OutputObjectBase& rParent ); + void construct( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const ::rtl::OUString& rSysFileName ); void construct( const RecordObjectBase& rParent ); - virtual bool implIsValid() const; - - void createRecordStream( const RecordDataSequence& rData ); - inline RecordInputStream& getRecordStream() const { return mxStrmIn->getStream(); } + virtual bool implReadRecordHeader( BinaryInputStream& rBaseStrm, sal_Int64& ornRecId, sal_Int64& ornRecSize ); ::rtl::OUString getErrorName( sal_uInt8 nErrCode ) const; @@ -110,37 +70,38 @@ protected: // ------------------------------------------------------------------------ - void writeBooleanItem( const sal_Char* pcName, sal_uInt8 nBool ); - void writeErrorCodeItem( const sal_Char* pcName, sal_uInt8 nErrCode ); + void writeBooleanItem( const String& rName, sal_uInt8 nBool ); + void writeErrorCodeItem( const String& rName, sal_uInt8 nErrCode ); void writeFontPortions( const ::oox::xls::BinFontPortionList& rPortions ); void writePhoneticPortions( const ::oox::xls::BinPhoneticPortionList& rPhonetics ); // ------------------------------------------------------------------------ - sal_uInt8 dumpBoolean( const sal_Char* pcName = 0 ); - sal_uInt8 dumpErrorCode( const sal_Char* pcName = 0 ); - ::rtl::OUString dumpString( const sal_Char* pcName = 0, bool bRich = false, bool b32BitLen = true ); - void dumpColor( const sal_Char* pcName = 0 ); + sal_uInt8 dumpBoolean( const String& rName = EMPTY_STRING ); + sal_uInt8 dumpErrorCode( const String& rName = EMPTY_STRING ); + ::rtl::OUString dumpString( const String& rName = EMPTY_STRING, bool bRich = false, bool b32BitLen = true ); + void dumpColor( const String& rName = EMPTY_STRING ); - sal_Int32 dumpColIndex( const sal_Char* pcName = 0 ); - sal_Int32 dumpRowIndex( const sal_Char* pcName = 0 ); - sal_Int32 dumpColRange( const sal_Char* pcName = 0 ); - sal_Int32 dumpRowRange( const sal_Char* pcName = 0 ); + sal_Int32 dumpColIndex( const String& rName = EMPTY_STRING ); + sal_Int32 dumpRowIndex( const String& rName = EMPTY_STRING ); + sal_Int32 dumpColRange( const String& rName = EMPTY_STRING ); + sal_Int32 dumpRowRange( const String& rName = EMPTY_STRING ); - Address dumpAddress( const sal_Char* pcName = 0 ); - Range dumpRange( const sal_Char* pcName = 0 ); - void dumpRangeList( const sal_Char* pcName = 0 ); + Address dumpAddress( const String& rName = EMPTY_STRING ); + Range dumpRange( const String& rName = EMPTY_STRING ); + void dumpRangeList( const String& rName = EMPTY_STRING ); // ------------------------------------------------------------------------ +private: + using SequenceRecordObjectBase::construct; - using InputObjectBase::construct; + bool readCompressedInt( BinaryInputStream& rStrm, sal_Int32& ornValue ); private: - void constructRecObjBase(); + typedef ::boost::shared_ptr< RecordInputStream > RecordInputStreamRef; -private: - RecordStreamInputRef mxStrmIn; + RecordInputStreamRef mxStrm; NameListRef mxErrCodes; }; @@ -152,8 +113,8 @@ public: explicit FormulaObject( const RecordObjectBase& rParent ); virtual ~FormulaObject(); - void dumpCellFormula( const sal_Char* pcName = 0 ); - void dumpNameFormula( const sal_Char* pcName = 0 ); + void dumpCellFormula( const String& rName = EMPTY_STRING ); + void dumpNameFormula( const String& rName = EMPTY_STRING ); protected: virtual void implDump(); @@ -161,7 +122,7 @@ protected: private: void constructFmlaObj(); - void dumpFormula( const sal_Char* pcName, bool bNameMode ); + void dumpFormula( const String& rName, bool bNameMode ); TokenAddress createTokenAddress( sal_Int32 nCol, sal_Int32 nRow, bool bRelC, bool bRelR, bool bNameMode ) const; ::rtl::OUString createRef( const ::rtl::OUString& rData ) const; @@ -171,8 +132,8 @@ private: ::rtl::OUString writeFuncIdItem( sal_uInt16 nFuncId, const ::oox::xls::FunctionInfo** oppFuncInfo = 0 ); - sal_Int32 dumpTokenCol( const sal_Char* pcName, bool& rbRelC, bool& rbRelR ); - sal_Int32 dumpTokenRow( const sal_Char* pcName ); + sal_Int32 dumpTokenCol( const String& rName, bool& rbRelC, bool& rbRelR ); + sal_Int32 dumpTokenRow( const String& rName ); TokenAddress dumpTokenAddress( bool bNameMode ); TokenRange dumpTokenRange( bool bNameMode ); @@ -198,9 +159,9 @@ private: void dumpMemFuncToken( const ::rtl::OUString& rTokClass ); void dumpMemAreaToken( const ::rtl::OUString& rTokClass, bool bAddData ); - void dumpExpToken( const StringWrapper& rName ); - void dumpUnaryOpToken( const StringWrapper& rLOp, const StringWrapper& rROp ); - void dumpBinaryOpToken( const StringWrapper& rOp ); + void dumpExpToken( const String& rName ); + void dumpUnaryOpToken( const String& rLOp, const String& rROp ); + void dumpBinaryOpToken( const String& rOp ); void dumpFuncToken( const ::rtl::OUString& rTokClass ); void dumpFuncVarToken( const ::rtl::OUString& rTokClass ); bool dumpTableToken(); @@ -233,92 +194,44 @@ private: FuncProvRef mxFuncProv; AddDataTypeVec maAddData; ::rtl::OUString maRefPrefix; - const sal_Char* mpcName; + ::rtl::OUString maName; sal_Int32 mnSize; bool mbNameMode; }; -typedef ::boost::shared_ptr< FormulaObject > FormulaObjectRef; - // ============================================================================ -class RecordObject : public RecordObjectBase +class RecordStreamObject : public RecordObjectBase { public: - explicit RecordObject( OutputObjectBase& rParent ); - - void dumpRecord( const RecordDataSequence& rData, sal_Int32 nRecId ); - + explicit RecordStreamObject( ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const ::rtl::OUString& rSysFileName ); protected: virtual bool implIsValid() const; - virtual void implDump(); + virtual void implDumpRecordBody(); private: void dumpCellHeader( bool bWithColumn ); - void dumpSimpleRecord( const ::rtl::OUString& rRecData ); - void dumpRecordBody(); - -private: - FormulaObjectRef mxFmlaObj; - NameListRef mxSimpleRecs; - sal_Int32 mnRecId; -}; - -typedef ::boost::shared_ptr< RecordObject > RecordObjectRef; - -// ============================================================================ - -class RecordHeaderObject : public RecordHeaderBase< sal_Int32, sal_Int32 > -{ -public: - explicit RecordHeaderObject( const InputObjectBase& rParent ); - virtual ~RecordHeaderObject(); - - inline const RecordDataSequence& getRecordData() const { return maData; } - -protected: - virtual bool implReadHeader( sal_Int64& ornRecPos, sal_Int32& ornRecId, sal_Int32& ornRecSize ); private: - bool readByte( sal_Int64& ornRecPos, sal_uInt8& ornByte ); - bool readCompressedInt( sal_Int64& ornRecPos, sal_Int32& ornValue ); - -private: - RecordDataSequence maData; -}; + typedef ::boost::shared_ptr< FormulaObject > FormulaObjectRef; -typedef ::boost::shared_ptr< RecordHeaderObject > RecordHeaderObjectRef; - -// ============================================================================ - -class RecordStreamObject : public InputStreamObject -{ -public: - explicit RecordStreamObject( const ObjectBase& rParent, const ::rtl::OUString& rOutFileName, BinaryInputStreamRef xStrm ); - -protected: - virtual bool implIsValid() const; - virtual void implDump(); - -private: - RecordHeaderObjectRef mxHdrObj; - RecordObjectRef mxRecObj; + FormulaObjectRef mxFmlaObj; }; // ============================================================================ -class RootStorageObject : public RootStorageObjectBase +class RootStorageObject : public StorageObjectBase { public: explicit RootStorageObject( const DumperBase& rParent ); protected: virtual void implDumpStream( - BinaryInputStreamRef xStrm, + const BinaryInputStreamRef& rxStrm, const ::rtl::OUString& rStrgPath, const ::rtl::OUString& rStrmName, - const ::rtl::OUString& rSystemFileName ); + const ::rtl::OUString& rSysFileName ); }; // ============================================================================ @@ -328,6 +241,11 @@ class Dumper : public DumperBase public: explicit Dumper( const ::oox::core::FilterBase& rFilter ); + explicit Dumper( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxFactory, + const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStrm, + const ::rtl::OUString& rSysFileName ); + protected: virtual void implDump(); }; diff --git a/oox/inc/oox/helper/binaryinputstream.hxx b/oox/inc/oox/helper/binaryinputstream.hxx index 08a59a802e86..9fd303b39ac5 100644 --- a/oox/inc/oox/helper/binaryinputstream.hxx +++ b/oox/inc/oox/helper/binaryinputstream.hxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: binaryinputstream.hxx,v $ - * $Revision: 1.3 $ + * $Revision: 1.3.22.1 $ * * This file is part of OpenOffice.org. * @@ -32,21 +32,79 @@ #define OOX_HELPER_BINARYINPUTSTREAM_HXX #include <boost/shared_ptr.hpp> +#include <com/sun/star/io/XInputStream.hpp> #include "oox/helper/binarystreambase.hxx" -namespace com { namespace sun { namespace star { - namespace io { class XInputStream; } -} } } - namespace oox { // ============================================================================ -/** Wraps a binary input stream and provides convenient access functions. +/** Interface for binary input stream classes. + + The binary data in the stream is assumed to be in little-endian format. + */ +class BinaryInputStream : public virtual BinaryStreamBase +{ +public: + /** Derived classes implement reading nBytes bytes to the passed sequence. + @return Number of bytes really read. */ + virtual sal_Int32 readData( StreamDataSequence& orData, sal_Int32 nBytes ) = 0; + /** Derived classes implement reading nBytes bytes to the (existing) buffer opMem. + @return Number of bytes really read. */ + virtual sal_Int32 readMemory( void* opMem, sal_Int32 nBytes ) = 0; + /** Derived classes implement seeking the stream forward by the passed + number of bytes. This should work for non-seekable streams too. */ + virtual void skip( sal_Int32 nBytes ) = 0; + + /** Reads a value from the stream and converts it to platform byte order. + Supported types: SAL integers (8 to 64 bit), float, double. */ + template< typename Type > + void readValue( Type& ornValue ); + /** Reads a value from the stream and converts it to platform byte order. + Supported types: SAL integers (8 to 64 bit), float, double. */ + template< typename Type > + inline Type readValue() { Type nValue; readValue( nValue ); return nValue; } + /** Stream operator for integral and floating-point types. */ + template< typename Type > + inline BinaryInputStream& operator>>( Type& ornValue ) { readValue( ornValue ); return *this; } + + inline sal_Int8 readInt8() { return readValue< sal_Int8 >(); } + inline sal_uInt8 readuInt8() { return readValue< sal_uInt8 >(); } + inline sal_Int16 readInt16() { return readValue< sal_Int16 >(); } + inline sal_uInt16 readuInt16() { return readValue< sal_uInt16 >(); } + inline sal_Int32 readInt32() { return readValue< sal_Int32 >(); } + inline sal_uInt32 readuInt32() { return readValue< sal_uInt32 >(); } + inline sal_Int64 readInt64() { return readValue< sal_Int64 >(); } + inline sal_uInt64 readuInt64() { return readValue< sal_uInt64 >(); } + inline float readFloat() { return readValue< float >(); } + inline double readDouble() { return readValue< double >(); } + +private: + /** Used by the readValue() template functions to read built-in types. + @descr Derived classes may overwrite this default implementation which + simply calls readMemory() with something own. */ + virtual void readAtom( void* opMem, sal_uInt8 nSize ); +}; + +typedef ::boost::shared_ptr< BinaryInputStream > BinaryInputStreamRef; + +// ---------------------------------------------------------------------------- + +template< typename Type > +void BinaryInputStream::readValue( Type& ornValue ) +{ + // can be instanciated for all types supported in class ByteOrderConverter + readAtom( &ornValue, static_cast< sal_Int32 >( sizeof( Type ) ) ); + ByteOrderConverter::convertLittleEndian( ornValue ); +} + +// ============================================================================ + +/** Wraps a com.sun.star.io.XInputStream and provides convenient access functions. The binary data in the stream is assumed to be in little-endian format. */ -class BinaryInputStream : public BinaryStreamBase +class BinaryXInputStream : public BinaryXSeekableStream, public BinaryInputStream { public: /** Constructs the wrapper object for the passed input stream. @@ -56,63 +114,75 @@ public: @param bAutoClose True = automatically close the wrapped input stream on destruction of this wrapper. */ - explicit BinaryInputStream( + explicit BinaryXInputStream( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStrm, bool bAutoClose ); - virtual ~BinaryInputStream(); - - /** Returns true, if the wrapped stream is valid. */ - inline bool is() const { return mxInStrm.is(); } - /** Returns the XInputStream interface of the wrapped input stream. */ - inline ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > - getXInputStream() const { return mxInStrm; } - - /** Seeks the stream forward by the passed number of bytes. This works for - non-seekable streams too. */ - void skip( sal_Int32 nBytes ); + virtual ~BinaryXInputStream(); /** Reads nBytes bytes to the passed sequence. @return Number of bytes really read. */ - sal_Int32 read( ::com::sun::star::uno::Sequence< sal_Int8 >& orBuffer, sal_Int32 nBytes ); - /** Reads nBytes bytes to the (existing) buffer pBuffer. + virtual sal_Int32 readData( StreamDataSequence& orData, sal_Int32 nBytes ); + /** Reads nBytes bytes to the (existing) buffer opMem. @return Number of bytes really read. */ - sal_Int32 read( void* opBuffer, sal_Int32 nBytes ); + virtual sal_Int32 readMemory( void* opMem, sal_Int32 nBytes ); + /** Seeks the stream forward by the passed number of bytes. This works for + non-seekable streams too. */ + virtual void skip( sal_Int32 nBytes ); - /** Reads a value from the stream and converts it to platform byte order. */ + /** Stream operator for integral and floating-point types. */ template< typename Type > - void readValue( Type& ornValue ); - /** Reads a value from the stream and converts it to platform byte order. */ - template< typename Type > - inline Type readValue() { Type nValue; readValue( nValue ); return nValue; } + inline BinaryXInputStream& operator>>( Type& ornValue ) { readValue( ornValue ); return *this; } + /** Returns the XInputStream interface of the wrapped input stream. */ + inline ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > + getXInputStream() const { return mxInStrm; } /** Closes the wrapped XInputStream. */ void close(); private: + StreamDataSequence maBuffer; /// Data buffer used in readMemory() function. ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > mxInStrm; /// Reference to the input stream. bool mbAutoClose; /// True = automatically close stream on destruction. }; -typedef ::boost::shared_ptr< BinaryInputStream > BinaryInputStreamRef; +typedef ::boost::shared_ptr< BinaryXInputStream > BinaryXInputStreamRef; -// ---------------------------------------------------------------------------- +// ============================================================================ -template< typename Type > -void BinaryInputStream::readValue( Type& ornValue ) -{ - // can be instanciated for all types supported in class ByteOrderConverter - read( &ornValue, static_cast< sal_Int32 >( sizeof( Type ) ) ); - ByteOrderConverter::convertLittleEndian( ornValue ); -} +/** Wraps a StreamDataSequence and provides convenient access functions. -template< typename Type > -inline BinaryInputStream& operator>>( BinaryInputStream& rInStrm, Type& ornValue ) + The binary data in the stream is assumed to be in little-endian format. + */ +class SequenceInputStream : public SequenceSeekableStream, public BinaryInputStream { - rInStrm.readValue( ornValue ); - return rInStrm; -} +public: + /** Constructs the wrapper object for the passed data sequence. + + @attention + The passed data sequence MUST live at least as long as this stream + wrapper. The data sequence MUST NOT be changed from outside as long + as this stream wrapper is used to read from it. + */ + explicit SequenceInputStream( StreamDataSequence& rData ); + + /** Reads nBytes bytes to the passed sequence. + @return Number of bytes really read. */ + virtual sal_Int32 readData( StreamDataSequence& orData, sal_Int32 nBytes ); + /** Reads nBytes bytes to the (existing) buffer opMem. + @return Number of bytes really read. */ + virtual sal_Int32 readMemory( void* opMem, sal_Int32 nBytes ); + /** Seeks the stream forward by the passed number of bytes. This works for + non-seekable streams too. */ + virtual void skip( sal_Int32 nBytes ); + + /** Stream operator for integral and floating-point types. */ + template< typename Type > + inline SequenceInputStream& operator>>( Type& ornValue ) { readValue( ornValue ); return *this; } +}; + +typedef ::boost::shared_ptr< SequenceInputStream > SequenceInputStreamRef; // ============================================================================ diff --git a/oox/inc/oox/helper/binaryoutputstream.hxx b/oox/inc/oox/helper/binaryoutputstream.hxx index 64a0bda859e1..d2eb5970f687 100644 --- a/oox/inc/oox/helper/binaryoutputstream.hxx +++ b/oox/inc/oox/helper/binaryoutputstream.hxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: binaryoutputstream.hxx,v $ - * $Revision: 1.3 $ + * $Revision: 1.3.22.2 $ * * This file is part of OpenOffice.org. * @@ -32,23 +32,64 @@ #define OOX_HELPER_BINARYOUTPUTSTREAM_HXX #include <boost/shared_ptr.hpp> +#include <com/sun/star/io/XOutputStream.hpp> #include "oox/helper/binarystreambase.hxx" -namespace com { namespace sun { namespace star { - namespace io { class XOutputStream; } -} } } - namespace oox { class BinaryInputStream; // ============================================================================ -/** Wraps a binary output stream and provides convenient access functions. +/** Interface for binary output stream classes. + + The binary data in the stream is written in little-endian format. + */ +class BinaryOutputStream : public virtual BinaryStreamBase +{ +public: + /** Derived classes implement writing the passed data sequence. */ + virtual void writeData( const StreamDataSequence& rData ) = 0; + /** Derived classes implement writing from the (existing) buffer pMem. */ + virtual void writeMemory( const void* pMem, sal_Int32 nBytes ) = 0; + + /** Copies nBytes bytes from the current position of the passed input stream. */ + void copyStream( BinaryInputStream& rInStrm, sal_Int64 nBytes = SAL_MAX_INT64 ); + + /** Writes a value to the stream and converts it to platform byte order. + Supported types: SAL integers (8 to 64 bit), float, double. */ + template< typename Type > + void writeValue( Type nValue ); + /** Stream operator for integral and floating-point types. */ + template< typename Type > + inline BinaryOutputStream& operator<<( Type nValue ) { writeValue( nValue ); return *this; } + +private: + /** Used by the writeValue() template function to write built-in types. + @descr Derived classes may overwrite this default implementation which + simply calls writeMemory() with something own. */ + virtual void writeAtom( const void* pMem, sal_uInt8 nSize ); +}; + +typedef ::boost::shared_ptr< BinaryOutputStream > BinaryOutputStreamRef; + +// ---------------------------------------------------------------------------- + +template< typename Type > +void BinaryOutputStream::writeValue( Type nValue ) +{ + // can be instanciated for all types supported in class ByteOrderConverter + ByteOrderConverter::convertLittleEndian( nValue ); + writeMemory( &nValue, static_cast< sal_Int32 >( sizeof( Type ) ) ); +} + +// ============================================================================ + +/** Wraps a com.sun.star.io.XOutputStream and provides convenient access functions. The binary data in the stream is written in little-endian format. */ -class BinaryOutputStream : public BinaryStreamBase +class BinaryXOutputStream : public BinaryXSeekableStream, public BinaryOutputStream { public: /** Constructs the wrapper object for the passed output stream. @@ -58,57 +99,65 @@ public: @param bAutoClose True = automatically close the wrapped output stream on destruction of this wrapper. */ - explicit BinaryOutputStream( + explicit BinaryXOutputStream( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& rxOutStrm, bool bAutoClose ); - virtual ~BinaryOutputStream(); - - /** Returns true, if the wrapped stream is valid. */ - inline bool is() const { return mxOutStrm.is(); } - /** Returns the XOutputStream interface of the wrapped output stream. */ - inline ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > - getXOutputStream() const { return mxOutStrm; } + virtual ~BinaryXOutputStream(); - /** Writes the passed sequence. */ - void write( const ::com::sun::star::uno::Sequence< sal_Int8 >& rBuffer ); - /** Writes nBytes bytes from the (existing) buffer pBuffer. */ - void write( const void* pBuffer, sal_Int32 nBytes ); + /** Writes the passed data sequence. */ + virtual void writeData( const StreamDataSequence& rData ); + /** Write nBytes bytes from the (existing) buffer pMem. */ + virtual void writeMemory( const void* pMem, sal_Int32 nBytes ); - /** Writes a value to the stream and converts it to platform byte order. */ + /** Stream operator for integral and floating-point types. */ template< typename Type > - void writeValue( Type nValue ); - - /** Copies nBytes bytes from the current position of the passed input stream. */ - void copy( BinaryInputStream& rInStrm, sal_Int64 nBytes = SAL_MAX_INT32 ); + inline BinaryXOutputStream& operator<<( Type nValue ) { writeValue( nValue ); return *this; } + /** Returns the XOutputStream interface of the wrapped output stream. */ + inline ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > + getXOutputStream() const { return mxOutStrm; } /** Flushes and closes the wrapped XOutputStream. */ void close(); private: + StreamDataSequence maBuffer; /// Data buffer used in writeMemory() function. ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > mxOutStrm; /// Reference to the output stream. bool mbAutoClose; /// True = automatically close stream on destruction. }; -typedef ::boost::shared_ptr< BinaryOutputStream > BinaryOutputStreamRef; +typedef ::boost::shared_ptr< BinaryXOutputStream > BinaryXOutputStreamRef; -// ---------------------------------------------------------------------------- +// ============================================================================ -template< typename Type > -void BinaryOutputStream::writeValue( Type nValue ) -{ - // can be instanciated for all types supported in class ByteOrderConverter - ByteOrderConverter::convertLittleEndian( nValue ); - write( &nValue, static_cast< sal_Int32 >( sizeof( Type ) ) ); -} +/** Wraps a StreamDataSequence and provides convenient access functions. -template< typename Type > -inline BinaryOutputStream& operator<<( BinaryOutputStream& rOutStrm, Type nValue ) + The binary data in the stream is written in little-endian format. + */ +class SequenceOutputStream : public SequenceSeekableStream, public BinaryOutputStream { - rOutStrm.writeValue( nValue ); - return rOutStrm; -} +public: + /** Constructs the wrapper object for the passed data sequence. + + @attention + The passed data sequence MUST live at least as long as this stream + wrapper. The data sequence MUST NOT be changed from outside as long + as this stream wrapper is used to write to it. + */ + explicit SequenceOutputStream( StreamDataSequence& rData ); + + /** Writes the passed data sequence. */ + virtual void writeData( const StreamDataSequence& rData ); + /** Write nBytes bytes from the (existing) buffer pMem. */ + virtual void writeMemory( const void* pMem, sal_Int32 nBytes ); + + /** Stream operator for integral and floating-point types. */ + template< typename Type > + inline SequenceOutputStream& operator<<( Type nValue ) { writeValue( nValue ); return *this; } +}; + +typedef ::boost::shared_ptr< SequenceOutputStream > SequenceOutputStreamRef; // ============================================================================ diff --git a/oox/inc/oox/helper/binarystreambase.hxx b/oox/inc/oox/helper/binarystreambase.hxx index 6be36a997258..b12bf6006ff2 100644 --- a/oox/inc/oox/helper/binarystreambase.hxx +++ b/oox/inc/oox/helper/binarystreambase.hxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: binarystreambase.hxx,v $ - * $Revision: 1.3 $ + * $Revision: 1.3.22.3 $ * * This file is part of OpenOffice.org. * @@ -37,53 +37,102 @@ namespace oox { +typedef ::com::sun::star::uno::Sequence< sal_Int8 > StreamDataSequence; + // ============================================================================ -/** Base class for binary input and output streams. */ +/** Base interface for seekable binary stream classes. */ class BinaryStreamBase { public: - template< typename Interface > - explicit BinaryStreamBase( - const ::com::sun::star::uno::Reference< Interface >& rxStrm ); - virtual ~BinaryStreamBase(); - /** Returns true, if the wrapped stream is seekable. */ - inline bool isSeekable() const { return mxSeekable.is(); } - /** Returns the XSeekable interface of the wrapped stream. */ - inline ::com::sun::star::uno::Reference< ::com::sun::star::io::XSeekable > - getXSeekable() const { return mxSeekable; } - - /** Returns the size of the stream, if stream is seekable, otherwise -1. */ - sal_Int64 getLength() const; - /** Returns the current stream position, if stream is seekable, otherwise -1. */ - sal_Int64 tell() const; - - /** Seeks the stream to the passed position, if stream is seekable. */ - void seek( sal_Int64 nPos ); + /** Derived classes return whether the stream is seekable. default: false. */ + virtual bool isSeekable() const; + /** Derived classes returns the size of the stream, if seekable, otherwise/default: -1. */ + virtual sal_Int64 getLength() const; + /** Derived classes return the current stream position, if seekable, otherwise/default: -1. */ + virtual sal_Int64 tell() const; + /** Derived classes implment seeking the stream to the passed position, if seekable. */ + virtual void seek( sal_Int64 nPos ); + + /** Returns true, if the stream position is invalid (EOF). This flag turns + true *after* the first attempt to seek/read beyond the stream end. */ + inline bool isEof() const { return mbEof; } + + /** Returns the size of the remaining data, if stream is seekable, otherwise -1. */ + sal_Int64 getRemaining() const; /** Seeks the stream to the beginning, if stream is seekable. */ inline void seekToStart() { seek( 0 ); } /** Seeks the stream to the end, if stream is seekable. */ inline void seekToEnd() { seek( getLength() ); } protected: - ::com::sun::star::uno::Sequence< sal_Int8 > - maBuffer; /// Data buffer. + inline explicit BinaryStreamBase() : mbEof( false ) {} + +private: + BinaryStreamBase( const BinaryStreamBase& ); + BinaryStreamBase& operator=( const BinaryStreamBase& ); + +protected: + bool mbEof; +}; + +// ============================================================================ + +/** Base class for binary input and output streams wrapping an API stream, + seekable via the com.sun.star.io.XSeekable interface. + */ +class BinaryXSeekableStream : public virtual BinaryStreamBase +{ +public: + /** Returns true, if the wrapped stream is seekable. */ + virtual bool isSeekable() const; + /** Returns the size of the stream, if stream is seekable, otherwise -1. */ + virtual sal_Int64 getLength() const; + /** Returns the current stream position, if stream is seekable, otherwise -1. */ + virtual sal_Int64 tell() const; + /** Seeks the stream to the passed position, if stream is seekable. */ + virtual void seek( sal_Int64 nPos ); + +protected: + explicit BinaryXSeekableStream( + const ::com::sun::star::uno::Reference< ::com::sun::star::io::XSeekable >& rxSeekable ); private: ::com::sun::star::uno::Reference< ::com::sun::star::io::XSeekable > mxSeekable; /// Stream seeking interface. }; -// ---------------------------------------------------------------------------- +// ============================================================================ -template< typename Interface > -BinaryStreamBase::BinaryStreamBase( const ::com::sun::star::uno::Reference< Interface >& rxStrm ) : - maBuffer( 0x8000 ), - mxSeekable( rxStrm, ::com::sun::star::uno::UNO_QUERY ) +/** Base class for binary input and output streams wrapping a StreamDataSequence. */ +class SequenceSeekableStream : public virtual BinaryStreamBase { -} +public: + /** Returns true, if the wrapped stream is seekable. */ + virtual bool isSeekable() const; + /** Returns the size of the stream, if stream is seekable, otherwise -1. */ + virtual sal_Int64 getLength() const; + /** Returns the current stream position, if stream is seekable, otherwise -1. */ + virtual sal_Int64 tell() const; + /** Seeks the stream to the passed position, if stream is seekable. */ + virtual void seek( sal_Int64 nPos ); + +protected: + /** Constructs the wrapper object for the passed data sequence. + + @attention + The passed data sequence MUST live at least as long as this stream + wrapper. The data sequence MUST NOT be changed from outside as long + as this stream wrapper is used to modify it. + */ + inline explicit SequenceSeekableStream( StreamDataSequence& rData ) : mrData( rData ), mnPos( 0 ) {} + +protected: + StreamDataSequence& mrData; /// Wrapped data sequence. + sal_Int32 mnPos; /// Current position in the sequence. +}; // ============================================================================ diff --git a/oox/inc/oox/helper/containerhelper.hxx b/oox/inc/oox/helper/containerhelper.hxx index 2444e46b2871..f2b52321b85d 100644 --- a/oox/inc/oox/helper/containerhelper.hxx +++ b/oox/inc/oox/helper/containerhelper.hxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: containerhelper.hxx,v $ - * $Revision: 1.4 $ + * $Revision: 1.4.6.2 $ * * This file is part of OpenOffice.org. * @@ -151,7 +151,7 @@ public: } /** Returns a reference to the object accossiated to the passed key, or 0 on error. */ - inline mapped_type get( key_type nKey ) const + inline mapped_type get( key_type nKey ) const { if( const mapped_type* pxRef = getRef( nKey ) ) return *pxRef; return mapped_type(); @@ -214,7 +214,7 @@ public: typedef typename container_type::iterator iterator; typedef typename container_type::const_iterator const_iterator; - inline explicit Matrix() : mnWidth( 0 ) {}; + inline explicit Matrix() : mnWidth( 0 ) {} inline explicit Matrix( size_type nWidth, size_type nHeight ) { this->resize( nWidth, nHeight ); } inline explicit Matrix( size_type nWidth, size_type nHeight, const_reference rData ) { this->resize( nWidth, nHeight, rData ); } @@ -273,7 +273,7 @@ public: /** Creates a new index container object from scratch. */ static ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > - createIndexContainer(); + createIndexContainer( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxFactory ); /** Inserts an object into an indexed container. @@ -295,7 +295,7 @@ public: /** Creates a new name container object from scratch. */ static ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > - createNameContainer(); + createNameContainer( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxFactory ); /** Returns a name that is not used in the passed name container. diff --git a/oox/inc/oox/helper/recordinputstream.hxx b/oox/inc/oox/helper/recordinputstream.hxx index 46be92bb38b3..e730bc727b5b 100644 --- a/oox/inc/oox/helper/recordinputstream.hxx +++ b/oox/inc/oox/helper/recordinputstream.hxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: recordinputstream.hxx,v $ - * $Revision: 1.3 $ + * $Revision: 1.3.22.1 $ * * This file is part of OpenOffice.org. * @@ -31,90 +31,28 @@ #ifndef OOX_HELPER_RECORDINPUTSTREAM_HXX #define OOX_HELPER_RECORDINPUTSTREAM_HXX -#include <com/sun/star/uno/Sequence.hxx> -#include "oox/helper/helper.hxx" +#include "oox/helper/binaryinputstream.hxx" namespace oox { // ============================================================================ -typedef ::com::sun::star::uno::Sequence< sal_Int8 > RecordDataSequence; - -// ---------------------------------------------------------------------------- - -/** Buffers the contents of a record from a binary OOBIN stream. */ -class RecordInputStream +/** Reads the contents of a record from a binary OOBIN stream. */ +class RecordInputStream : public SequenceInputStream { public: - explicit RecordInputStream( const RecordDataSequence& rData ); - - /** Returns record reading state: false = record overread. */ - inline bool isValid() const { return mbValid; } - /** Returns the record size. */ - inline sal_Int32 getRecSize() const { return mnRecSize; } - /** Returns the current read position in the record body. */ - inline sal_Int32 getRecPos() const { return mnRecPos; } - /** Returns the number of remaining bytes in the record body. */ - inline sal_Int32 getRecLeft() const { return mnRecSize - mnRecPos; } - - /** Reads nBytes bytes, writes them to the existing buffer pData. */ - sal_Int32 read( void* opData, sal_Int32 nBytes ); - - /** Reads a value from the stream and converts it to platform byte order. */ - template< typename Type > - void readValue( Type& ornValue ); - /** Reads a value from the stream and converts it to platform byte order. */ - template< typename Type > - inline Type readValue() { Type nValue; readValue( nValue ); return nValue; } - - inline sal_Int8 readInt8() { return readValue< sal_Int8 >(); } - inline sal_uInt8 readuInt8() { return readValue< sal_uInt8 >(); } - inline sal_Int16 readInt16() { return readValue< sal_Int16 >(); } - inline sal_uInt16 readuInt16() { return readValue< sal_uInt16 >(); } - inline sal_Int32 readInt32() { return readValue< sal_Int32 >(); } - inline sal_uInt32 readuInt32() { return readValue< sal_uInt32 >(); } - inline sal_Int64 readInt64() { return readValue< sal_Int64 >(); } - inline sal_uInt64 readuInt64() { return readValue< sal_uInt64 >(); } - inline float readFloat() { return readValue< float >(); } - inline double readDouble() { return readValue< double >(); } + explicit RecordInputStream( StreamDataSequence& rData ); /** Reads a string with leading 16-bit or 32-bit length field. */ ::rtl::OUString readString( bool b32BitLen = true ); - /** Seeks to the passed record position. */ - void seek( sal_Int32 nRecPos ); - /** Ignores nBytes bytes. */ - void skip( sal_Int32 nBytes ); - -private: - RecordDataSequence maData; /// Reference to record data. - sal_Int32 mnRecSize; /// Current record size. - sal_Int32 mnRecPos; /// Current position in record body. - bool mbValid; /// False = record overread. + /** Stream operator for integral types. */ + template< typename Type > + inline RecordInputStream& operator>>( Type& ornValue ) { readValue( ornValue ); return *this; } + /** Stream operator for an ::rtl::OUString, reads 32-bit string length and Unicode array. */ + inline RecordInputStream& operator>>( ::rtl::OUString& orString ) { orString = readString(); return *this; } }; -// ---------------------------------------------------------------------------- - -template< typename Type > -inline void RecordInputStream::readValue( Type& ornValue ) -{ - read( &ornValue, static_cast< sal_Int32 >( sizeof( Type ) ) ); - ByteOrderConverter::convertLittleEndian( ornValue ); -} - -template< typename Type > -inline RecordInputStream& operator>>( RecordInputStream& rStrm, Type& ornValue ) -{ - rStrm.readValue( ornValue ); - return rStrm; -} - -inline RecordInputStream& operator>>( RecordInputStream& rStrm, ::rtl::OUString& orString ) -{ - orString = rStrm.readString(); - return rStrm; -} - // ============================================================================ } // namespace oox diff --git a/oox/inc/oox/ole/vbainputstream.hxx b/oox/inc/oox/ole/vbainputstream.hxx new file mode 100644 index 000000000000..8116a1e7d0da --- /dev/null +++ b/oox/inc/oox/ole/vbainputstream.hxx @@ -0,0 +1,75 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: vbainputstream.hxx,v $ + * $Revision: 1.1.2.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef OOX_HELPER_VBAINPUTSTREAM_HXX +#define OOX_HELPER_VBAINPUTSTREAM_HXX + +#include <vector> +#include "oox/helper/binaryinputstream.hxx" + +namespace oox { +namespace ole { + +// ============================================================================ + +/** A non-seekable input stream that implements run-length decompression. */ +class VbaInputStream : public BinaryInputStream +{ +public: + explicit VbaInputStream( BinaryInputStream& rInStrm ); + + /** Reads nBytes bytes to the passed sequence. + @return Number of bytes really read. */ + virtual sal_Int32 readData( StreamDataSequence& orData, sal_Int32 nBytes ); + /** Reads nBytes bytes to the (existing) buffer opMem. + @return Number of bytes really read. */ + virtual sal_Int32 readMemory( void* opMem, sal_Int32 nBytes ); + /** Seeks the stream forward by the passed number of bytes. */ + virtual void skip( sal_Int32 nBytes ); + +private: + /** If no data left in chunk buffer, reads the next chunk from stream. */ + bool updateChunk(); + +private: + typedef ::std::vector< sal_uInt8 > ChunkBuffer; + + BinaryInputStream& mrInStrm; + ChunkBuffer maChunk; + size_t mnChunkPos; +}; + +// ============================================================================ + +} // namespace ole +} // namespace oox + +#endif + diff --git a/oox/inc/oox/ppt/timenode.hxx b/oox/inc/oox/ppt/timenode.hxx index ae622fc5b6f7..de8f57854287 100644 --- a/oox/inc/oox/ppt/timenode.hxx +++ b/oox/inc/oox/ppt/timenode.hxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: timenode.hxx,v $ - * $Revision: 1.4 $ + * $Revision: 1.4.6.1 $ * * This file is part of OpenOffice.org. * @@ -70,9 +70,10 @@ namespace oox { namespace ppt { void setId( sal_Int32 nId ); const ::rtl::OUString & getId() const { return msId; } - void addNode( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > &rxModel, - const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& rxNode, - const SlidePersistPtr & slide); + void addNode( + const ::oox::core::XmlFilterBase& rFilter, + const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& rxNode, + const SlidePersistPtr & slide); // data setters void setTo( const ::com::sun::star::uno::Any & aTo ); void setFrom( const ::com::sun::star::uno::Any & aFrom ); @@ -80,8 +81,10 @@ namespace oox { namespace ppt { void setTransitionFilter( const SlideTransition & aTransition) { maTransitionFilter = aTransition; } - void setNode( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > &rxModel, - const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xNode, const SlidePersistPtr & pSlide ); + void setNode( + const ::oox::core::XmlFilterBase& rFilter, + const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xNode, + const SlidePersistPtr & pSlide ); AnimTargetElementPtr getTarget() { @@ -105,9 +108,10 @@ namespace oox { namespace ppt { static rtl::OUString getServiceName( sal_Int16 nNodeType ); ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode > - createAndInsert( const rtl::OUString& rServiceName, - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > &rxModel, - const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& rxNode ); + createAndInsert( + const ::oox::core::XmlFilterBase& rFilter, + const rtl::OUString& rServiceName, + const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& rxNode ); private: const sal_Int16 mnNodeType; diff --git a/oox/inc/oox/xls/bifffragmenthandler.hxx b/oox/inc/oox/xls/bifffragmenthandler.hxx index 47f4856a6da6..e69de29bb2d1 100644 --- a/oox/inc/oox/xls/bifffragmenthandler.hxx +++ b/oox/inc/oox/xls/bifffragmenthandler.hxx @@ -1,118 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: bifffragmenthandler.hxx,v $ - * $Revision: 1.4 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef OOX_XLS_BIFFFRAGMENTHANDLER_HXX -#define OOX_XLS_BIFFFRAGMENTHANDLER_HXX - -#include "oox/xls/worksheethelper.hxx" - -namespace oox { -namespace xls { - -// ============================================================================ - -/** An enumeration for all types of fragments in a BIFF workbook stream. */ -enum BiffFragmentType -{ - BIFF_FRAGMENT_GLOBALS, /// Workbook globals fragment. - BIFF_FRAGMENT_WORKSHEET, /// Worksheet fragment. - BIFF_FRAGMENT_CHARTSHEET, /// Chart sheet fragment. - BIFF_FRAGMENT_MACROSHEET, /// Macro sheet fragment. - BIFF_FRAGMENT_MODULESHEET, /// BIFF5 VB module fragment. - BIFF_FRAGMENT_EMPTYSHEET, /// Sheet fragment of unsupported type. - BIFF_FRAGMENT_WORKSPACE, /// BIFF4 workspace/workbook globals. - BIFF_FRAGMENT_UNKNOWN /// Unknown fragment/error. -}; - -// ============================================================================ - -class BiffFragmentHandler -{ -public: - inline explicit BiffFragmentHandler() {} - virtual ~BiffFragmentHandler(); - - /** Imports the fragment, returns true, if EOF record has been reached. */ - virtual bool importFragment( BiffInputStream& rStrm ); - -protected: - /** @return True = passed record identifier is a BOF record. */ - static bool isBofRecord( sal_uInt16 nRecId ); - - /** Starts a new fragment in a workbbok stream and returns the fragment type. - - The passed stream must point before a BOF record. The function will - try to start the next record and read the contents of the BOF record, - if extant. - - @return Fragment type according to the imported BOF record. - */ - static BiffFragmentType startFragment( BiffInputStream& rStrm, BiffType eBiff ); - - /** Skips the current fragment (processes embedded BOF/EOF blocks correctly). - - Skips all records until next EOF record. When this function returns, - stream points to the EOF record, and the next call of startNextRecord() - at the stream will start the record following the EOF record. - - @return True = stream points to the EOF record of the current fragment. - */ - static bool skipFragment( BiffInputStream& rStrm ); -}; - -// ============================================================================ - -class BiffWorkbookFragmentBase : public BiffFragmentHandler, public WorkbookHelper -{ -public: - explicit BiffWorkbookFragmentBase( const WorkbookHelper& rHelper ); -}; - -// ============================================================================ - -class BiffWorksheetFragmentBase : public BiffFragmentHandler, public WorksheetHelperRoot -{ -public: - explicit BiffWorksheetFragmentBase( - const WorkbookHelper& rHelper, - ISegmentProgressBarRef xProgressBar, - WorksheetType eSheetType, - sal_Int32 nSheet ); - - explicit BiffWorksheetFragmentBase( const WorksheetHelper& rHelper ); -}; - -// ============================================================================ - -} // namespace xls -} // namespace oox - -#endif - diff --git a/oox/inc/oox/xls/biffhelper.hxx b/oox/inc/oox/xls/biffhelper.hxx index 354c39518800..0069f5ee5bb8 100644 --- a/oox/inc/oox/xls/biffhelper.hxx +++ b/oox/inc/oox/xls/biffhelper.hxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: biffhelper.hxx,v $ - * $Revision: 1.4 $ + * $Revision: 1.4.20.6 $ * * This file is part of OpenOffice.org. * @@ -75,6 +75,8 @@ const sal_Int32 OOBIN_ID_COLORS = 0x01D9; const sal_Int32 OOBIN_ID_COLORSCALE = 0x01D5; const sal_Int32 OOBIN_ID_COLS = 0x0186; const sal_Int32 OOBIN_ID_CONDFORMATTING = 0x01CD; +const sal_Int32 OOBIN_ID_CONTROL = 0x0284; +const sal_Int32 OOBIN_ID_CONTROLS = 0x0283; const sal_Int32 OOBIN_ID_CUSTOMCHARTVIEW = 0x028F; const sal_Int32 OOBIN_ID_CUSTOMCHARTVIEWS = 0x028D; const sal_Int32 OOBIN_ID_CUSTOMSHEETVIEW = 0x01A7; @@ -126,6 +128,7 @@ const sal_Int32 OOBIN_ID_HEADERFOOTER = 0x01DF; const sal_Int32 OOBIN_ID_HYPERLINK = 0x01EE; const sal_Int32 OOBIN_ID_ICONSET = 0x01D1; const sal_Int32 OOBIN_ID_INDEXEDCOLORS = 0x0235; +const sal_Int32 OOBIN_ID_LEGACYDRAWING = 0x0227; const sal_Int32 OOBIN_ID_MERGECELL = 0x00B0; const sal_Int32 OOBIN_ID_MERGECELLS = 0x00B1; const sal_Int32 OOBIN_ID_MRUCOLORS = 0x0239; @@ -139,6 +142,8 @@ const sal_Int32 OOBIN_ID_MULTCELL_SI = 0x0012; const sal_Int32 OOBIN_ID_MULTCELL_STRING = 0x0011; const sal_Int32 OOBIN_ID_NUMFMT = 0x002C; const sal_Int32 OOBIN_ID_NUMFMTS = 0x0267; +const sal_Int32 OOBIN_ID_OLEOBJECT = 0x027F; +const sal_Int32 OOBIN_ID_OLEOBJECTS = 0x027E; const sal_Int32 OOBIN_ID_PAGEMARGINS = 0x01DC; const sal_Int32 OOBIN_ID_PAGESETUP = 0x01DE; const sal_Int32 OOBIN_ID_PANE = 0x0097; @@ -273,6 +278,7 @@ const sal_uInt16 BIFF_ID_COLINFO = 0x007D; const sal_uInt16 BIFF_ID_COLUMNDEFAULT = 0x0020; const sal_uInt16 BIFF_ID_COLWIDTH = 0x0024; const sal_uInt16 BIFF_ID_CONT = 0x003C; +const sal_uInt16 BIFF_ID_COORDLIST = 0x00A9; const sal_uInt16 BIFF_ID_CRN = 0x005A; const sal_uInt16 BIFF2_ID_DATATABLE = 0x0036; const sal_uInt16 BIFF3_ID_DATATABLE = 0x0236; @@ -315,6 +321,8 @@ const sal_uInt16 BIFF_ID_HEADER = 0x0014; const sal_uInt16 BIFF_ID_HIDEOBJ = 0x008D; const sal_uInt16 BIFF_ID_HORPAGEBREAKS = 0x001B; const sal_uInt16 BIFF_ID_HYPERLINK = 0x01B8; +const sal_uInt16 BIFF3_ID_IMGDATA = 0x007F; +const sal_uInt16 BIFF8_ID_IMGDATA = 0x00E9; const sal_uInt16 BIFF2_ID_INTEGER = 0x0002; const sal_uInt16 BIFF_ID_ITERATION = 0x0011; const sal_uInt16 BIFF_ID_IXFE = 0x0044; @@ -397,14 +405,20 @@ const sal_uInt16 BIFF_ID_UNKNOWN = SAL_MAX_UINT16; const sal_uInt16 BIFF_ID_OBJEND = 0x0000; /// End of OBJ. const sal_uInt16 BIFF_ID_OBJMACRO = 0x0004; /// Macro link. +const sal_uInt16 BIFF_ID_OBJBUTTON = 0x0005; /// Button data. const sal_uInt16 BIFF_ID_OBJGMO = 0x0006; /// Group marker. const sal_uInt16 BIFF_ID_OBJCF = 0x0007; /// Clipboard format. -const sal_uInt16 BIFF_ID_OBJPIOGRBIT = 0x0008; /// Option flags. +const sal_uInt16 BIFF_ID_OBJFLAGS = 0x0008; /// Option flags. const sal_uInt16 BIFF_ID_OBJPICTFMLA = 0x0009; /// OLE link formula. const sal_uInt16 BIFF_ID_OBJCBLS = 0x000A; /// Check box/radio button data. +const sal_uInt16 BIFF_ID_OBJRBO = 0x000B; /// Radio button group data. const sal_uInt16 BIFF_ID_OBJSBS = 0x000C; /// Scroll bar data. +const sal_uInt16 BIFF_ID_OBJNTS = 0x000C; /// Note data. const sal_uInt16 BIFF_ID_OBJSBSFMLA = 0x000E; /// Scroll bar/list box/combo box cell link. const sal_uInt16 BIFF_ID_OBJGBODATA = 0x000F; /// Group box data. +const sal_uInt16 BIFF_ID_OBJEDODATA = 0x0010; /// Edit box data. +const sal_uInt16 BIFF_ID_OBJRBODATA = 0x0011; /// Radio button group data. +const sal_uInt16 BIFF_ID_OBJCBLSDATA = 0x0012; /// Check box/radio button data. const sal_uInt16 BIFF_ID_OBJLBSDATA = 0x0013; /// List box/combo box data. const sal_uInt16 BIFF_ID_OBJCBLSFMLA = 0x0014; /// Check box/radio button cell link. const sal_uInt16 BIFF_ID_OBJCMO = 0x0015; /// Common object settings. diff --git a/oox/inc/oox/xls/biffinputstream.hxx b/oox/inc/oox/xls/biffinputstream.hxx index 10fa4129a551..899909021c64 100644 --- a/oox/inc/oox/xls/biffinputstream.hxx +++ b/oox/inc/oox/xls/biffinputstream.hxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: biffinputstream.hxx,v $ - * $Revision: 1.4 $ + * $Revision: 1.4.20.1 $ * * This file is part of OpenOffice.org. * @@ -32,22 +32,17 @@ #define OOX_XLS_BIFFINPUTSTREAM_HXX #include <vector> +#include "oox/helper/binaryinputstream.hxx" #include "oox/xls/biffhelper.hxx" #include "oox/xls/biffcodec.hxx" namespace rtl { class OUStringBuffer; } -namespace oox { class BinaryInputStream; } namespace oox { namespace xls { // ============================================================================ -const sal_uInt32 BIFF_REC_SEEK_TO_BEGIN = 0; -const sal_uInt32 BIFF_REC_SEEK_TO_END = SAL_MAX_UINT32; - -// ============================================================================ - namespace prv { /** Buffers the contents of a raw record and encapsulates stream decoding. */ @@ -56,9 +51,8 @@ class BiffInputRecordBuffer public: explicit BiffInputRecordBuffer( BinaryInputStream& rInStrm ); - /** Returns the core stream object. */ - inline const BinaryInputStream& - getCoreStream() const { return mrInStrm; } + /** Returns the wrapped binary base stream. */ + inline const BinaryInputStream& getBaseStream() const { return mrInStrm; } /** Sets a decoder object and decrypts buffered record data. */ void setDecoder( BiffDecoderRef xDecoder ); @@ -91,11 +85,8 @@ public: /** Reads nBytes bytes to the existing buffer opData. Must NOT overread the source buffer. */ void read( void* opData, sal_uInt16 nBytes ); - /** Reads a value. Must NOT overread the buffer. */ - template< typename Type > - inline void readValue( Type& ornValue ); /** Ignores nBytes bytes. Must NOT overread the buffer. */ - inline void skip( sal_uInt16 nBytes ); + void skip( sal_uInt16 nBytes ); private: /** Updates data buffer from stream, if needed. */ @@ -121,15 +112,6 @@ private: bool mbValidHeader; /// True = valid record header. }; -// ---------------------------------------------------------------------------- - -template< typename Type > -inline void BiffInputRecordBuffer::readValue( Type& ornValue ) -{ - read( &ornValue, static_cast< sal_uInt16 >( sizeof( Type ) ) ); - ByteOrderConverter::convertLittleEndian( ornValue ); -} - } // namespace prv // ============================================================================ @@ -170,13 +152,8 @@ inline void BiffInputRecordBuffer::readValue( Type& ornValue ) records or the stream position in SHEET records). Decryption will be reenabled automatically, if a new record is started with the function startNextRecord(). - - Be careful with used data types: - sal_uInt16: Record identifiers, raw size of single records. - sal_uInt32: Record position and size (including CONTINUE records). - sal_Int64: Core stream position and size. */ -class BiffInputStream +class BiffInputStream : public BinaryInputStream { public: /** Constructs the BIFF record stream using the passed binary stream. @@ -191,8 +168,6 @@ public: BinaryInputStream& rInStream, bool bContLookup = true ); - ~BiffInputStream(); - // record control --------------------------------------------------------- /** Sets stream pointer to the start of the next record content. @@ -259,64 +234,45 @@ public: // stream/record state and info ------------------------------------------- - /** Returns record reading state: false = record overread. */ - inline bool isValid() const { return mbValid; } /** Returns the current record identifier. */ inline sal_uInt16 getRecId() const { return mnRecId; } - /** Returns the position inside of the whole record content. */ - sal_uInt32 getRecPos() const; - /** Returns the data size of the whole record without record headers. */ - sal_uInt32 getRecSize(); - /** Returns remaining data size of the whole record without record headers. */ - sal_uInt32 getRecLeft(); - /** Returns a unique handle for the current record that can be used with - the function startRecordByHandle(). */ - inline sal_Int64 getRecHandle() const { return mnRecHandle; } /** Returns the record identifier of the following record. */ sal_uInt16 getNextRecId(); - /** Returns the absolute core stream position. */ - sal_Int64 getCoreStreamPos() const; - /** Returns the stream size. */ - sal_Int64 getCoreStreamSize() const; - - // stream read access ----------------------------------------------------- + /** Returns a unique handle for the current record that can be used with + the function startRecordByHandle(). */ + inline sal_Int64 getRecHandle() const { return mnRecHandle; } - /** Reads nBytes bytes and copies them to the passed buffer opData. + // BinaryStreamBase interface (seeking) ----------------------------------- - @return Number of bytes really read. - */ - sal_uInt32 read( void* opData, sal_uInt32 nBytes ); + /** Returns true, as the BIFF input stream is required to be seekable. */ + virtual bool isSeekable() const; + /** Returns the position inside of the whole record content. */ + virtual sal_Int64 tell() const; + /** Returns the data size of the whole record without record headers. */ + virtual sal_Int64 getLength() const; + /** Seeks in record content to the specified position. */ + virtual void seek( sal_Int64 nRecPos ); + + /** Returns the absolute position in the wrapped binary stream. */ + sal_Int64 tellBase() const; + /** Returns the total size of the wrapped binary stream. */ + sal_Int64 getBaseLength() const; + + // BinaryInputStream interface (stream read access) ----------------------- + + /** Reads nBytes bytes to the passed sequence. + @return Number of bytes really read. */ + virtual sal_Int32 readData( StreamDataSequence& orData, sal_Int32 nBytes ); + /** Reads nBytes bytes and copies them to the passed buffer opMem. + @return Number of bytes really read. */ + virtual sal_Int32 readMemory( void* opMem, sal_Int32 nBytes ); + /** Seeks forward inside the current record. */ + virtual void skip( sal_Int32 nBytes ); - /** Reads a value from the stream and converts it to platform byte order. */ - template< typename Type > - void readValue( Type& ornValue ); - /** Reads a value from the stream and converts it to platform byte order. */ + /** Stream operator for integral and floating-point types. */ template< typename Type > - inline Type readValue() { Type nValue; readValue( nValue ); return nValue; } - - inline sal_Int8 readInt8() { return readValue< sal_Int8 >(); } - inline sal_uInt8 readuInt8() { return readValue< sal_uInt8 >(); } - inline sal_Int16 readInt16() { return readValue< sal_Int16 >(); } - inline sal_uInt16 readuInt16() { return readValue< sal_uInt16 >(); } - inline sal_Int32 readInt32() { return readValue< sal_Int32 >(); } - inline sal_uInt32 readuInt32() { return readValue< sal_uInt32 >(); } - inline sal_Int64 readInt64() { return readValue< sal_Int64 >(); } - inline sal_uInt64 readuInt64() { return readValue< sal_uInt64 >(); } - inline float readFloat() { return readValue< float >(); } - inline double readDouble() { return readValue< double >(); } - - // seeking ---------------------------------------------------------------- - - /** Seeks absolute in record content to the specified position. - - The value 0 means start of record, independent from physical stream - position. - */ - BiffInputStream& seek( sal_uInt32 nRecPos ); - - /** Seeks forward inside the current record. */ - BiffInputStream& skip( sal_uInt32 nBytes ); + inline BiffInputStream& operator>>( Type& ornValue ) { readValue( ornValue ); return *this; } // strings ---------------------------------------------------------------- @@ -349,6 +305,8 @@ public: // Unicode strings -------------------------------------------------------- + /** Reads a null-terminated Unicode characters and returns the string. */ + ::rtl::OUString readNulUnicodeArray(); /** Reads nChars Unicode characters and returns the string. */ ::rtl::OUString readUnicodeArray( sal_uInt16 nChars ); @@ -372,6 +330,9 @@ public: // ------------------------------------------------------------------------ private: + /** Forwards calls of readValue() template functions to the record buffer. */ + virtual void readAtom( void* opMem, sal_uInt8 nSize ); + /** Initializes all members after base stream has been seeked to new record. */ void setupRecord(); /** Restarts the current record from the beginning. */ @@ -386,7 +347,7 @@ private: /** Goes to start of the next CONTINUE record. @descr Stream must be located at the end of a raw record, and handling of CONTINUE records must be enabled. - @return Copy of mbValid. */ + @return True if next CONTINUE record has been found and initialized. */ bool jumpToNextContinue(); /** Goes to start of the next CONTINUE record while reading strings. @descr Stream must be located at the end of a raw record. If reading @@ -394,21 +355,24 @@ private: CONTINUE record, even if handling of CONTINUE records is disabled (this is a special handling for TXO string data). Reads additional Unicode flag byte at start of the new raw record and sets or resets rb16Bit. - @return Copy of mbValid. */ + @return True if next CONTINUE record has been found and initialized. */ bool jumpToNextStringContinue( bool& rb16Bit ); + /** Calculates the complete length of the current record including CONTINUE + records, stores the length in mnComplRecSize. */ + void calcRecordLength(); /** Ensures that reading nBytes bytes is possible with next stream access. @descr Stream must be located at the end of a raw record, and handling of CONTINUE records must be enabled. - @return Copy of mbValid. */ + @return True if nBytes can be read from stream. */ bool ensureRawReadSize( sal_uInt16 nBytes ); /** Returns the maximum size of raw data possible to read in one block. */ - sal_uInt16 getMaxRawReadSize( sal_uInt32 nBytes ) const; + sal_uInt16 getMaxRawReadSize( sal_Int32 nBytes ) const; /** Reads an array of Unicode characters and appends them to the passed buffer. */ void appendUnicodeArray( ::rtl::OUStringBuffer& orBuffer, sal_uInt16 nChars, bool b16Bit ); /** Reads the BIFF8 Unicode string header fields. */ - void readUniStringHeader( bool& orb16Bit, sal_uInt32& ornAddSize ); + void readUniStringHeader( bool& orb16Bit, sal_Int32& ornAddSize ); private: prv::BiffInputRecordBuffer maRecBuffer; /// Raw record data buffer. @@ -417,31 +381,14 @@ private: sal_uInt16 mnRecId; /// Identifier of current record (not the CONTINUE ID). sal_uInt16 mnAltContId; /// Alternative identifier for content continuation records. - sal_uInt32 mnCurrRecSize; /// Helper for record size and position. - sal_uInt32 mnComplRecSize; /// Size of complete record data (with CONTINUEs). + sal_Int64 mnCurrRecSize; /// Helper for record size and position. + sal_Int64 mnComplRecSize; /// Size of complete record data (with CONTINUEs). bool mbHasComplRec; /// True = mnComplRecSize is valid. bool mbCont; /// True = automatic CONTINUE lookup enabled. bool mbNulChars; /// True = import NUL characters. - bool mbValid; /// True = last stream operation successful (no overread). }; -// ---------------------------------------------------------------------------- - -template< typename Type > -inline void BiffInputStream::readValue( Type& ornValue ) -{ - if( ensureRawReadSize( static_cast< sal_uInt16 >( sizeof( Type ) ) ) ) - maRecBuffer.readValue( ornValue ); -} - -template< typename Type > -inline BiffInputStream& operator>>( BiffInputStream& rStrm, Type& ornValue ) -{ - rStrm.readValue( ornValue ); - return rStrm; -} - // ============================================================================ class BiffInputStreamPos @@ -456,16 +403,16 @@ public: private: BiffInputStream& mrStrm; sal_Int64 mnRecHandle; - sal_uInt32 mnRecPos; + sal_Int64 mnRecPos; }; // ============================================================================ -class BiffInputStreamGuard : private BiffInputStreamPos +class BiffInputStreamPosGuard : private BiffInputStreamPos { public: - explicit BiffInputStreamGuard( BiffInputStream& rStrm ); - ~BiffInputStreamGuard(); + explicit BiffInputStreamPosGuard( BiffInputStream& rStrm ); + ~BiffInputStreamPosGuard(); }; // ============================================================================ diff --git a/oox/inc/oox/xls/biffoutputstream.hxx b/oox/inc/oox/xls/biffoutputstream.hxx index d8fbe5cb53be..a25a45efde3e 100644 --- a/oox/inc/oox/xls/biffoutputstream.hxx +++ b/oox/inc/oox/xls/biffoutputstream.hxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: biffoutputstream.hxx,v $ - * $Revision: 1.3 $ + * $Revision: 1.3.22.1 $ * * This file is part of OpenOffice.org. * @@ -32,6 +32,7 @@ #define OOX_XLS_BIFFOUTPUTSTREAM_HXX #include <vector> +#include "oox/helper/binaryoutputstream.hxx" #include "oox/xls/biffhelper.hxx" namespace oox { class BinaryOutputStream; } @@ -51,9 +52,8 @@ public: BinaryOutputStream& rOutStrm, sal_uInt16 nMaxRecSize ); - /** Returns the core stream object. */ - inline const BinaryOutputStream& - getCoreStream() const { return mrOutStrm; } + /** Returns the wrapped binary base stream. */ + inline const BinaryOutputStream& getBaseStream() const { return mrOutStrm; } /** Starts a new record. */ void startRecord( sal_uInt16 nRecId ); @@ -67,9 +67,6 @@ public: void write( const void* pData, sal_uInt16 nBytes ); /** Writes a sequence of nBytes bytes with the passed value. */ void fill( sal_uInt8 nValue, sal_uInt16 nBytes ); - /** Writes a value. Must NOT overread the buffer. */ - template< typename Type > - inline void writeValue( Type nValue ); private: typedef ::std::vector< sal_uInt8 > DataBuffer; @@ -81,15 +78,6 @@ private: bool mbInRec; /// True = currently writing inside of a record. }; -// ---------------------------------------------------------------------------- - -template< typename Type > -inline void BiffOutputRecordBuffer::writeValue( Type nValue ) -{ - ByteOrderConverter::convertLittleEndian( nValue ); - write( &nValue, static_cast< sal_uInt16 >( sizeof( Type ) ) ); -} - } // namespace prv // ============================================================================ @@ -113,15 +101,13 @@ inline void BiffOutputRecordBuffer::writeValue( Type nValue ) To write unicode character arrays, call writeUnicodeBuffer(). It creates CONTINUE records and repeats the unicode string flag byte automatically. */ -class BiffOutputStream +class BiffOutputStream : public BinaryOutputStream { public: explicit BiffOutputStream( BinaryOutputStream& rOutStream, sal_uInt16 nMaxRecSize ); - ~BiffOutputStream(); - // record control --------------------------------------------------------- /** Starts a new record. */ @@ -133,25 +119,39 @@ public: /** Sets size of data portion in bytes. 0 means no portions are used. */ void setPortionSize( sal_uInt16 nSize ); - // stream/record state and info ------------------------------------------- + // BinaryStreamBase interface (seeking) ----------------------------------- + + /** Returns the absolute position in the wrapped binary stream. */ + sal_Int64 tellBase() const; + /** Returns the total size of the wrapped binary stream. */ + sal_Int64 getBaseLength() const; + + // BinaryOutputStream interface (stream write access) --------------------- - // stream write access ---------------------------------------------------- + /** Writes the passed data sequence. */ + virtual void writeData( const StreamDataSequence& rData ); + /** Writes nBytes bytes from the passed buffer pMem. */ + virtual void writeMemory( const void* pMem, sal_Int32 nBytes ); - /** Writes nBytes bytes from the passed buffer pData. */ - void write( const void* pData, sal_uInt32 nBytes ); /** Writes a sequence of nBytes bytes with the passed value. */ - void fill( sal_uInt8 nValue, sal_uInt32 nBytes ); + void fill( sal_uInt8 nValue, sal_Int32 nBytes ); + /** Writes a block of memory, ensures that it is not split to a CONTINUE record. */ + void writeBlock( const void* pMem, sal_uInt16 nBytes ); - /** Writes a value to the stream and converts it to little-endian byte order. */ + /** Stream operator for integral and floating-point types. */ template< typename Type > - void writeValue( Type nValue ); + inline BiffOutputStream& operator<<( Type nValue ) { writeValue( nValue ); return *this; } + // ------------------------------------------------------------------------ private: + /** Forwards calls of writeValue() template functions to the record buffer. */ + virtual void writeAtom( const void* pMem, sal_uInt8 nSize ); + /** Checks the remaining size in the current record, creates CONTINUE record if needed. */ void ensureRawBlock( sal_uInt16 nSize ); /** Checks the remaining size in the current record and creates CONTINUE record if needed. @return Maximum size left for writing to current record. */ - sal_uInt16 prepareRawBlock( sal_uInt32 nTotalSize ); + sal_uInt16 prepareRawBlock( sal_Int32 nTotalSize ); private: prv::BiffOutputRecordBuffer maRecBuffer; /// Raw record data buffer. @@ -159,22 +159,6 @@ private: sal_uInt16 mnPortionPos; /// Position in current portion. }; -// ---------------------------------------------------------------------------- - -template< typename Type > -inline void BiffOutputStream::writeValue( Type nValue ) -{ - ensureRawBlock( static_cast< sal_uInt16 >( sizeof( Type ) ) ); - maRecBuffer.writeValue( nValue ); -} - -template< typename Type > -inline BiffOutputStream& operator<<( BiffOutputStream& rStrm, Type nValue ) -{ - rStrm.writeValue( nValue ); - return rStrm; -} - // ============================================================================ } // namespace xls diff --git a/oox/inc/oox/xls/chartsheetfragment.hxx b/oox/inc/oox/xls/chartsheetfragment.hxx index 451138ac0611..dfb08230f5d5 100644 --- a/oox/inc/oox/xls/chartsheetfragment.hxx +++ b/oox/inc/oox/xls/chartsheetfragment.hxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: chartsheetfragment.hxx,v $ - * $Revision: 1.3 $ + * $Revision: 1.3.20.2 $ * * This file is part of OpenOffice.org. * @@ -31,7 +31,6 @@ #ifndef OOX_XLS_CHARTSHEETFRAGMENT_HXX #define OOX_XLS_CHARTSHEETFRAGMENT_HXX -#include "oox/xls/bifffragmenthandler.hxx" #include "oox/xls/excelhandlers.hxx" namespace oox { @@ -77,12 +76,12 @@ class BiffChartsheetFragment : public BiffWorksheetFragmentBase { public: explicit BiffChartsheetFragment( - const WorkbookHelper& rHelper, + const BiffWorkbookFragmentBase& rParent, ISegmentProgressBarRef xProgressBar, sal_Int32 nSheet ); /** Imports the entire sheet fragment, returns true, if EOF record has been reached. */ - virtual bool importFragment( BiffInputStream& rStrm ); + virtual bool importFragment(); }; // ============================================================================ diff --git a/oox/inc/oox/xls/condformatbuffer.hxx b/oox/inc/oox/xls/condformatbuffer.hxx index 327c89065ec4..cf4d2e6c1d1e 100644 --- a/oox/inc/oox/xls/condformatbuffer.hxx +++ b/oox/inc/oox/xls/condformatbuffer.hxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: condformatbuffer.hxx,v $ - * $Revision: 1.3 $ + * $Revision: 1.3.22.1 $ * * This file is part of OpenOffice.org. * @@ -31,6 +31,7 @@ #ifndef OOX_XLS_CONDFORMATBUFFER_HXX #define OOX_XLS_CONDFORMATBUFFER_HXX +#include <com/sun/star/sheet/ConditionOperator.hpp> #include "oox/helper/containerhelper.hxx" #include "oox/xls/formulaparser.hxx" #include "oox/xls/worksheethelper.hxx" @@ -176,6 +177,10 @@ public: /** Creates all conditional formattings in the Calc document. */ void finalizeImport(); + /** Converts an OOXML condition operator token to the API constant. */ + static ::com::sun::star::sheet::ConditionOperator + convertToApiOperator( sal_Int32 nToken ); + private: CondFormatRef createCondFormat(); diff --git a/oox/inc/oox/xls/defnamesbuffer.hxx b/oox/inc/oox/xls/defnamesbuffer.hxx index c12ab16dbf00..fa9d377a63f3 100644 --- a/oox/inc/oox/xls/defnamesbuffer.hxx +++ b/oox/inc/oox/xls/defnamesbuffer.hxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: defnamesbuffer.hxx,v $ - * $Revision: 1.4 $ + * $Revision: 1.4.20.3 $ * * This file is part of OpenOffice.org. * @@ -93,6 +93,8 @@ public: /** Returns the original name as imported from or exported to the file. */ inline const ::rtl::OUString& getOoxName() const { return maOoxData.maName; } + /** Returns the name as used in the Calc document. */ + inline const ::rtl::OUString& getDocName() const { return maFinalName; } /** Returns the 0-based sheet index for local names, or -1 for global names. */ inline sal_Int32 getSheetIndex() const { return maOoxData.mnSheet; } @@ -142,7 +144,7 @@ public: /** Returns true, if this defined name is a special builtin name. */ inline bool isBuiltinName() const { return mcBuiltinId != OOX_DEFNAME_UNKNOWN; } /** Returns true, if this defined name is a macro function call. */ - inline bool isMacroFunc( bool bVBName ) const { return maOoxData.mbMacro && maOoxData.mbFunction && (maOoxData.mbVBName == bVBName); } + inline bool isMacroFunction() const { return maOoxData.mbMacro && maOoxData.mbFunction; } /** Returns the token index used in API token arrays (com.sun.star.sheet.FormulaToken). */ inline sal_Int32 getTokenIndex() const { return mnTokenIndex; } @@ -154,14 +156,14 @@ private: void implImportBiffFormula( FormulaContext& rContext ); private: - typedef ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XNamedRange > XNamedRangeRef; - typedef ::std::auto_ptr< RecordDataSequence > RecordDataSeqPtr; - typedef ::std::auto_ptr< BiffInputStreamPos > BiffStreamPosPtr; + typedef ::std::auto_ptr< StreamDataSequence > StreamDataSeqPtr; + typedef ::std::auto_ptr< BiffInputStreamPos > BiffStreamPosPtr; - XNamedRangeRef mxNamedRange; /// XNamedRange interface of the defined name. + ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XNamedRange > + mxNamedRange; /// XNamedRange interface of the defined name. sal_Int32 mnTokenIndex; /// Name index used in API token array. sal_Unicode mcBuiltinId; /// Identifier for built-in defined names. - RecordDataSeqPtr mxFormula; /// Formula data for OOBIN import. + StreamDataSeqPtr mxFormula; /// Formula data for OOBIN import. BiffStreamPosPtr mxBiffStrm; /// Cached BIFF stream for formula import. sal_uInt16 mnFmlaSize; /// Cached BIFF formula size for formula import. }; @@ -175,15 +177,6 @@ class DefinedNamesBuffer : public WorkbookHelper public: explicit DefinedNamesBuffer( const WorkbookHelper& rHelper ); - /** Creates and returns a defined name on-the-fly in the Calc document. - The name will not be buffered in this defined names buffer. - @param orName (in/out-parameter) Returns the resulting used name. */ - ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XNamedRange > - createDefinedName( ::rtl::OUString& orName, sal_Int32 nNameFlags = 0 ) const; - - /** Returns the index of the passed defined name used in formula token arrays. */ - sal_Int32 getTokenIndex( const ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XNamedRange >& rxNamedRange ) const; - /** Sets the current sheet index for files with local defined names, e.g. BIFF4 workspaces. All created names initially will contain this index. */ void setLocalSheetIndex( sal_Int32 nLocalSheet ); @@ -199,6 +192,8 @@ public: /** Returns a defined name by zero-based index (order of appearence). */ DefinedNameRef getByIndex( sal_Int32 nIndex ) const; + /** Returns a defined name by token index (index in XDefinedNames container). */ + DefinedNameRef getByTokenIndex( sal_Int32 nIndex ) const; /** Returns a defined name by its OOX name. @param nSheet The sheet index for local names or -1 for global names. If no local name is found, tries to find a matching global name. @@ -209,11 +204,12 @@ private: DefinedNameRef createDefinedName(); private: - typedef RefVector< DefinedName > DefNameVec; + typedef RefVector< DefinedName > DefNameVector; + typedef RefMap< sal_Int32, DefinedName > DefNameMap; - const ::rtl::OUString maTokenIndexProp; - DefNameVec maDefNames; - sal_Int32 mnLocalSheet; + DefNameVector maDefNames; /// List of all defined names in insertion order. + DefNameMap maDefNameMap; /// Maps all defined names by API token index. */ + sal_Int32 mnLocalSheet; /// Current sheet index for import of BIFF sheet-local names. }; // ============================================================================ diff --git a/oox/inc/oox/xls/excelhandlers.hxx b/oox/inc/oox/xls/excelhandlers.hxx index 5a9f7fecc90c..1c7a511e826d 100644 --- a/oox/inc/oox/xls/excelhandlers.hxx +++ b/oox/inc/oox/xls/excelhandlers.hxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: excelhandlers.hxx,v $ - * $Revision: 1.4 $ + * $Revision: 1.4.20.2 $ * * This file is part of OpenOffice.org. * @@ -43,15 +43,19 @@ namespace oox { namespace xls { -typedef ::oox::core::ContextWrapper ContextWrapper; +typedef ::oox::core::ContextHandler2 OoxContextHandler; +typedef ::oox::core::FragmentHandler2 OoxFragmentHandler; +typedef ::oox::core::ContextWrapper ContextWrapper; + +// ============================================================================ // ============================================================================ /** Context handler derived from the WorkbookHelper helper class. Used to import contexts in global workbook fragments. */ -class OoxWorkbookContextBase : public ::oox::core::ContextHandler2, public WorkbookHelper +class OoxWorkbookContextBase : public OoxContextHandler, public WorkbookHelper { public: template< typename ParentType > @@ -62,7 +66,7 @@ public: template< typename ParentType > OoxWorkbookContextBase::OoxWorkbookContextBase( ParentType& rParent ) : - ::oox::core::ContextHandler2( rParent ), + OoxContextHandler( rParent ), WorkbookHelper( rParent ) { } @@ -73,7 +77,7 @@ OoxWorkbookContextBase::OoxWorkbookContextBase( ParentType& rParent ) : Used to import contexts in sheet fragments. */ -class OoxWorksheetContextBase : public ::oox::core::ContextHandler2, public WorksheetHelperRoot +class OoxWorksheetContextBase : public OoxContextHandler, public WorksheetHelperRoot { public: template< typename ParentType > @@ -92,14 +96,14 @@ public: template< typename ParentType > OoxWorksheetContextBase::OoxWorksheetContextBase( ParentType& rParent, ISegmentProgressBarRef xProgressBar, WorksheetType eSheetType, sal_Int32 nSheet ) : - ::oox::core::ContextHandler2( rParent ), + OoxContextHandler( rParent ), WorksheetHelperRoot( rParent, xProgressBar, eSheetType, nSheet ) { } template< typename ParentType > OoxWorksheetContextBase::OoxWorksheetContextBase( ParentType& rParent ) : - ::oox::core::ContextHandler2( rParent ), + OoxContextHandler( rParent ), WorksheetHelperRoot( rParent ) { } @@ -110,7 +114,7 @@ OoxWorksheetContextBase::OoxWorksheetContextBase( ParentType& rParent ) : Used to import global workbook fragments. */ -class OoxWorkbookFragmentBase : public ::oox::core::FragmentHandler2, public WorkbookHelper +class OoxWorkbookFragmentBase : public OoxFragmentHandler, public WorkbookHelper { public: explicit OoxWorkbookFragmentBase( @@ -124,7 +128,7 @@ public: Used to import sheet fragments. */ -class OoxWorksheetFragmentBase : public ::oox::core::FragmentHandler2, public WorksheetHelperRoot +class OoxWorksheetFragmentBase : public OoxFragmentHandler, public WorksheetHelperRoot { public: explicit OoxWorksheetFragmentBase( @@ -140,6 +144,216 @@ public: }; // ============================================================================ +// ============================================================================ + +/** An enumeration for all types of fragments in a BIFF workbook stream. */ +enum BiffFragmentType +{ + BIFF_FRAGMENT_GLOBALS, /// Workbook globals fragment. + BIFF_FRAGMENT_WORKSHEET, /// Worksheet fragment. + BIFF_FRAGMENT_CHARTSHEET, /// Chart sheet fragment. + BIFF_FRAGMENT_MACROSHEET, /// Macro sheet fragment. + BIFF_FRAGMENT_MODULESHEET, /// BIFF5 VB module fragment. + BIFF_FRAGMENT_EMPTYSHEET, /// Sheet fragment of unsupported type. + BIFF_FRAGMENT_WORKSPACE, /// BIFF4 workspace/workbook globals. + BIFF_FRAGMENT_UNKNOWN /// Unknown fragment/error. +}; + +// ============================================================================ + +/** Base class for all BIFF context handlers and fragment handlers. + + This base class holds a reference to the BIFF input stream which can be + accessed in all derived classes. + */ +class BiffHandlerBase +{ +protected: + inline explicit BiffHandlerBase( BiffInputStream& rStrm ) : mrStrm( rStrm ) {} + virtual ~BiffHandlerBase(); + + /** Skips a block of records up to the specified end record. + + Skips all records until next end record. When this function returns, + stream points to the end record, and the next call of startNextRecord() + at the stream will start the record following the end record. + + The identifier of the record that is active while this function is + called is used as start record identifier. This identifier is used to + correctly skip embedded record blocks with the same start and end + record identifier. + + @return True = stream points to the end record. + */ + bool skipRecordBlock( sal_uInt16 nEndRecId ); + + /** @return True = current record identifier is a BOF record. */ + bool isBofRecord() const; + +protected: + BiffInputStream& mrStrm; +}; + +// ============================================================================ + +/** Base class for all BIFF context handlers. + + Derived handlers have to implement the importRecord() function that has to + import the record the BIFF input stream currently points to. + */ +class BiffContextHandler : public BiffHandlerBase +{ +public: + /** Derived classes have to implement importing the current record. */ + virtual void importRecord() = 0; + +protected: + explicit BiffContextHandler( const BiffHandlerBase& rParent ); +}; + +// ============================================================================ + +/** Context handler derived from the WorkbookHelper helper class. + + Used to import contexts in global workbook fragments. + */ +class BiffWorkbookContextBase : public BiffContextHandler, public WorkbookHelper +{ +protected: + template< typename ParentType > + explicit BiffWorkbookContextBase( const ParentType& rParent ); +}; + +// ---------------------------------------------------------------------------- + +template< typename ParentType > +BiffWorkbookContextBase::BiffWorkbookContextBase( const ParentType& rParent ) : + BiffContextHandler( rParent ), + WorkbookHelper( rParent ) +{ +} + +// ============================================================================ + +/** Context handler derived from the WorksheetHelper helper class. + + Used to import contexts in sheet fragments. + */ +class BiffWorksheetContextBase : public BiffContextHandler, public WorksheetHelperRoot +{ +protected: + template< typename ParentType > + explicit BiffWorksheetContextBase( + const ParentType& rParent, + ISegmentProgressBarRef xProgressBar, + WorksheetType eSheetType, + sal_Int32 nSheet ); + + template< typename ParentType > + explicit BiffWorksheetContextBase( const ParentType& rParent ); +}; + +// ---------------------------------------------------------------------------- + +template< typename ParentType > +BiffWorksheetContextBase::BiffWorksheetContextBase( const ParentType& rParent, + ISegmentProgressBarRef xProgressBar, WorksheetType eSheetType, sal_Int32 nSheet ) : + BiffContextHandler( rParent ), + WorksheetHelperRoot( rParent, xProgressBar, eSheetType, nSheet ) +{ +} + +template< typename ParentType > +BiffWorksheetContextBase::BiffWorksheetContextBase( const ParentType& rParent ) : + BiffContextHandler( rParent ), + WorksheetHelperRoot( rParent ) +{ +} + +// ============================================================================ + +class BiffFragmentHandler : public BiffHandlerBase +{ +public: + /** Imports the fragment, returns true, if EOF record has been reached. */ + virtual bool importFragment() = 0; + +protected: + explicit BiffFragmentHandler( BiffInputStream& rStrm ); + + /** Starts a new fragment in a workbbok stream and returns the fragment type. + + The passed stream must point before a BOF record. The function will + try to start the next record and read the contents of the BOF record, + if extant. + + @return Fragment type according to the imported BOF record. + */ + BiffFragmentType startFragment( BiffType eBiff ); + + /** Skips the current fragment up to its trailing EOF record. + + Skips all records until next EOF record. When this function returns, + stream points to the EOF record, and the next call of startNextRecord() + at the stream will start the record following the EOF record. + + Embedded fragments enclosed in BOF/EOF records (e.g. embedded chart + objects) are skipped correctly. + + @return True = stream points to the EOF record of the current fragment. + */ + bool skipFragment(); +}; + +// ============================================================================ + +/** Fragment handler derived from the WorkbookHelper helper class. + + Used to import global workbook fragments. + */ +class BiffWorkbookFragmentBase : public BiffFragmentHandler, public WorkbookHelper +{ +protected: + explicit BiffWorkbookFragmentBase( + const WorkbookHelper& rHelper, + BiffInputStream& rStrm ); +}; + +// ============================================================================ + +/** Fragment handler derived from the WorksheetHelper helper class. + + Used to import sheet fragments. + */ +class BiffWorksheetFragmentBase : public BiffFragmentHandler, public WorksheetHelperRoot +{ +protected: + explicit BiffWorksheetFragmentBase( + const BiffWorkbookFragmentBase& rParent, + ISegmentProgressBarRef xProgressBar, + WorksheetType eSheetType, + sal_Int32 nSheet ); + + explicit BiffWorksheetFragmentBase( + const WorksheetHelper& rHelper, + BiffInputStream& rStrm ); +}; + +// ============================================================================ + +class BiffSkipWorksheetFragment : public BiffWorksheetFragmentBase +{ +public: + explicit BiffSkipWorksheetFragment( + const BiffWorkbookFragmentBase& rParent, + ISegmentProgressBarRef xProgressBar, + sal_Int32 nSheet ); + + virtual bool importFragment(); +}; + +// ============================================================================ +// ============================================================================ } // namespace xls } // namespace oox diff --git a/oox/inc/oox/xls/externallinkfragment.hxx b/oox/inc/oox/xls/externallinkfragment.hxx index ec56bae1c1d9..c09068e60abd 100644 --- a/oox/inc/oox/xls/externallinkfragment.hxx +++ b/oox/inc/oox/xls/externallinkfragment.hxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: externallinkfragment.hxx,v $ - * $Revision: 1.4 $ + * $Revision: 1.4.20.2 $ * * This file is part of OpenOffice.org. * @@ -31,7 +31,6 @@ #ifndef OOX_XLS_EXTERNALLINKFRAGMENT_HXX #define OOX_XLS_EXTERNALLINKFRAGMENT_HXX -#include "oox/xls/bifffragmenthandler.hxx" #include "oox/xls/excelhandlers.hxx" #include "oox/xls/externallinkbuffer.hxx" @@ -39,7 +38,6 @@ namespace oox { namespace xls { class ExternalLink; -class OoxExternalSheetDataContext; // ============================================================================ @@ -66,8 +64,7 @@ protected: virtual const ::oox::core::RecordInfo* getRecordInfos() const; private: - ::rtl::Reference< OoxExternalSheetDataContext > - createSheetDataContext( sal_Int32 nSheetId ); + ContextWrapper createSheetDataContext( sal_Int32 nSheetId ); private: ExternalLink& mrExtLink; @@ -83,28 +80,28 @@ class BiffExternalSheetDataContext; class BiffExternalLinkFragment : public BiffWorkbookFragmentBase { public: - explicit BiffExternalLinkFragment( const WorkbookHelper& rHelper, bool bImportDefNames ); + explicit BiffExternalLinkFragment( const BiffWorkbookFragmentBase& rParent, bool bImportDefNames ); virtual ~BiffExternalLinkFragment(); /** Imports all records related to external links. */ - virtual bool importFragment( BiffInputStream& rStrm ); + virtual bool importFragment(); /** Tries to import a record related to external links and defined names. */ - void importRecord( BiffInputStream& rStrm ); + void importRecord(); /** Finalizes buffers related to external links and defined names. */ void finalizeImport(); private: - void importExternSheet( BiffInputStream& rStrm ); - void importExternalBook( BiffInputStream& rStrm ); - void importExternalName( BiffInputStream& rStrm ); - void importXct( BiffInputStream& rStrm ); - void importCrn( BiffInputStream& rStrm ); - void importDefinedName( BiffInputStream& rStrm ); + void importExternSheet(); + void importExternalBook(); + void importExternalName(); + void importXct(); + void importCrn(); + void importDefinedName(); private: - typedef ::boost::shared_ptr< BiffExternalSheetDataContext > SheetContextRef; + typedef ::boost::shared_ptr< BiffWorksheetContextBase > SheetContextRef; SheetContextRef mxContext; ExternalLinkRef mxExtLink; diff --git a/oox/inc/oox/xls/formulabase.hxx b/oox/inc/oox/xls/formulabase.hxx index fb6b7ded7af8..2e882a8d35cf 100644 --- a/oox/inc/oox/xls/formulabase.hxx +++ b/oox/inc/oox/xls/formulabase.hxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: formulabase.hxx,v $ - * $Revision: 1.6 $ + * $Revision: 1.5.20.5 $ * * This file is part of OpenOffice.org. * @@ -36,10 +36,12 @@ #include <com/sun/star/table/CellRangeAddress.hpp> #include <com/sun/star/sheet/FormulaToken.hpp> #include <com/sun/star/sheet/FormulaOpCodeMapEntry.hpp> +#include "oox/helper/containerhelper.hxx" #include "oox/xls/addressconverter.hxx" namespace com { namespace sun { namespace star { namespace sheet { class XFormulaTokens; } + namespace sheet { class XFormulaOpCodeMapper; } } } } namespace oox { template< typename Type > class Matrix; } @@ -216,12 +218,13 @@ const sal_uInt16 OOBIN_FUNC_FALSE = 35; /// OOBIN function i const sal_uInt16 OOBIN_FUNC_ROWS = 76; /// OOBIN function id of the ROWS function. const sal_uInt16 OOBIN_FUNC_COLUMNS = 77; /// OOBIN function id of the COLUMNS function. const sal_uInt16 OOBIN_FUNC_OFFSET = 78; /// OOBIN function id of the OFFSET function. -const sal_uInt16 OOBIN_FUNC_EXTERNCALL = 255; /// OOBIN function id of the EXTERN.CALL function. const sal_uInt16 OOBIN_FUNC_FLOOR = 285; /// OOBIN function id of the FLOOR function. const sal_uInt16 OOBIN_FUNC_CEILING = 288; /// OOBIN function id of the CEILING function. +const sal_uInt16 OOBIN_FUNC_HYPERLINK = 359; /// OOBIN function id of the HYPERLINK function. const sal_uInt16 OOBIN_FUNC_WEEKNUM = 465; /// OOBIN function id of the WEEKNUM function. const sal_uInt16 BIFF_FUNC_SUM = 4; /// BIFF function id of the SUM function. +const sal_uInt16 BIFF_FUNC_EXTERNCALL = 255; /// BIFF function id of the EXTERN.CALL function. // reference helpers ========================================================== @@ -257,14 +260,61 @@ struct BinComplexRef2d void readBiff8Data( BiffInputStream& rStrm, bool bRelativeAsOffset ); }; +// token vector, sequence ===================================================== + +typedef ::com::sun::star::sheet::FormulaToken ApiToken; +typedef ::com::sun::star::uno::Sequence< ApiToken > ApiTokenSequence; + +/** A vector of formula tokens with additional convenience functions. */ +class ApiTokenVector : public ::std::vector< ApiToken > +{ +public: + explicit ApiTokenVector(); + + /** Appends a new token with the passed op-code, returns its data field. */ + ::com::sun::star::uno::Any& + append( sal_Int32 nOpCode ); + + /** Appends a new token with the passed op-code and data. */ + template< typename Type > + inline void append( sal_Int32 nOpCode, const Type& rData ) { append( nOpCode ) <<= rData; } +}; + +// token sequence iterator ==================================================== + +/** Token sequence iterator that is able to skip space tokens. */ +class ApiTokenIterator +{ +public: + explicit ApiTokenIterator( const ApiTokenSequence& rTokens, sal_Int32 nSpacesOpCode, bool bSkipSpaces ); + /** Copy constructor that allows to change the skip spaces mode. */ + explicit ApiTokenIterator( const ApiTokenIterator& rIter, bool bSkipSpaces ); + + inline bool is() const { return mpToken != mpTokenEnd; } + inline const ApiToken* get() const { return mpToken; } + inline const ApiToken* operator->() const { return mpToken; } + inline const ApiToken& operator*() const { return *mpToken; } + + ApiTokenIterator& operator++(); + +private: + void skipSpaces(); + +private: + const ApiToken* mpToken; /// Pointer to current token of the token sequence. + const ApiToken* mpTokenEnd; /// Pointer behind last token of the token sequence. + const sal_Int32 mnSpacesOpCode; /// Op-code for whitespace tokens. + const bool mbSkipSpaces; /// true = Skip whitespace tokens. +}; + // list of API op-codes ======================================================= /** Contains all API op-codes needed to build formulas with tokens. */ struct ApiOpCodes { // special - sal_Int32 OPCODE_EXTERNAL; /// External function call (e.g. add-ins). sal_Int32 OPCODE_UNKNOWN; /// Internal: function name unknown to mapper. + sal_Int32 OPCODE_EXTERNAL; /// External function call (e.g. add-ins). // formula structure sal_Int32 OPCODE_PUSH; /// Op-code for common value operands. sal_Int32 OPCODE_MISSING; /// Placeholder for a missing function parameter. @@ -274,7 +324,7 @@ struct ApiOpCodes sal_Int32 OPCODE_NLR; /// Natural language reference. sal_Int32 OPCODE_DDE; /// DDE link function. sal_Int32 OPCODE_MACRO; /// Macro function call. - sal_Int32 OPCODE_BAD; /// Bad token (formula error). + sal_Int32 OPCODE_BAD; /// Bad token (unknown name, formula error). sal_Int32 OPCODE_NONAME; /// Function style #NAME? error. // separators sal_Int32 OPCODE_OPEN; /// Opening parenthesis. @@ -331,7 +381,7 @@ struct FunctionInfo { ::rtl::OUString maOdfFuncName; /// ODF function name. ::rtl::OUString maOoxFuncName; /// OOXML function name. - ::rtl::OUString maExternCallName; /// Expected name in EXTERN.CALL function. + ::rtl::OUString maBiffMacroName; /// Expected macro name in EXTERN.CALL function. ::rtl::OUString maExtProgName; /// Programmatic function name for external functions. sal_Int32 mnApiOpCode; /// API function opcode. sal_uInt16 mnOobFuncId; /// OOBIN function identifier. @@ -341,6 +391,9 @@ struct FunctionInfo sal_uInt8 mnRetClass; /// BIFF token class of the return value. const sal_uInt8* mpnParamClass; /// Expected BIFF token classes of parameters. bool mbVolatile; /// True = volatile function. + bool mbExternal; /// True = external function in Calc. + bool mbMacroFunc; /// True = macro sheet function or command. + bool mbVarParam; /// True = use a tFuncVar token, also if min/max are equal. }; // function info parameter class iterator ===================================== @@ -369,32 +422,21 @@ private: const sal_uInt8* mpnParamClassEnd; }; -// function provider ========================================================== - -typedef ::com::sun::star::sheet::FormulaToken ApiToken; -typedef ::com::sun::star::uno::Sequence< ApiToken > ApiTokenSequence; +// base function provider ===================================================== class FunctionProviderImpl; +namespace { struct FunctionData; } -/** Provides access to function info structs for all available functions. +/** Provides access to function info structs for all available sheet functions. */ -class FunctionProvider : public ApiOpCodes // not derived from WorkbookHelper to make it usable in BIFF dumper +class FunctionProvider // not derived from WorkbookHelper to make it usable in file dumpers { public: - explicit FunctionProvider( const WorkbookHelper& rHelper ); + explicit FunctionProvider( FilterType eFilter, BiffType eBiff, bool bImportFilter ); + virtual ~FunctionProvider(); - explicit FunctionProvider( - const ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument >& rxDocument, - bool bImportFilter ); - - explicit FunctionProvider( - const ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument >& rxDocument, - BiffType eBiff, bool bImportFilter ); - - ~FunctionProvider(); - - /** Returns the function info for an API token, or 0 on error. */ - const FunctionInfo* getFuncInfoFromApiToken( const ApiToken& rToken ) const; + /** Returns the function info for an ODF function name, or 0 on error. */ + const FunctionInfo* getFuncInfoFromOdfFuncName( const ::rtl::OUString& rFuncName ) const; /** Returns the function info for an OOX function name, or 0 on error. */ const FunctionInfo* getFuncInfoFromOoxFuncName( const ::rtl::OUString& rFuncName ) const; @@ -405,43 +447,83 @@ public: /** Returns the function info for a BIFF function index, or 0 on error. */ const FunctionInfo* getFuncInfoFromBiffFuncId( sal_uInt16 nFuncId ) const; - /** Returns the function info for a specific function expressed by the + /** Returns the function info for a macro function referred by the EXTERN.CALL function, or 0 on error. */ - const FunctionInfo* getFuncInfoFromExternCallName( const ::rtl::OUString& rExtCallName ) const; + const FunctionInfo* getFuncInfoFromMacroName( const ::rtl::OUString& rFuncName ) const; - /** Returns the op-code map that is used by the OOX formula parser. */ - ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaOpCodeMapEntry > - getOoxParserMap() const; +protected: + typedef RefVector< FunctionInfo > FuncVector; + typedef RefMap< ::rtl::OUString, FunctionInfo > FuncNameMap; + typedef RefMap< sal_uInt16, FunctionInfo > FuncIdMap; + + typedef ::boost::shared_ptr< FuncVector > FuncVectorRef; + typedef ::boost::shared_ptr< FuncNameMap > FuncNameMapRef; + typedef ::boost::shared_ptr< FuncIdMap > FuncIdMapRef; + + /** Returns the list of all function infos. */ + inline const FuncVector& getFuncs() const { return *mxFuncs; } private: - ::std::auto_ptr< FunctionProviderImpl > mxImpl; + /** Creates and inserts a function info struct from the passed function data. */ + void initFunc( const FunctionData& rFuncData, sal_uInt8 nMaxParam ); + + /** Initializes the members from the passed function data list. */ + void initFuncs( + const FunctionData* pBeg, const FunctionData* pEnd, + sal_uInt8 nMaxParam, bool bImportFilter ); + +private: + FuncVectorRef mxFuncs; /// All function infos in one list. + FuncNameMapRef mxOdfFuncs; /// Maps ODF function names to function data. + FuncNameMapRef mxOoxFuncs; /// Maps OOXML function names to function data. + FuncIdMapRef mxOobFuncs; /// Maps OOBIN function indexes to function data. + FuncIdMapRef mxBiffFuncs; /// Maps BIFF function indexes to function data. + FuncNameMapRef mxMacroFuncs; /// Maps macro function names to function data. }; -// token sequence iterator ==================================================== +// op-code and function provider ============================================== -/** Token sequence iterator that is able to skip space tokens. */ -class ApiTokenIterator +/** Provides access to API op-codes for all available formula tokens and to + function info structs for all available sheet functions. + */ +class OpCodeProvider : public ApiOpCodes, public FunctionProvider, public WorkbookHelper { public: - explicit ApiTokenIterator( const ApiTokenSequence& rTokens, sal_Int32 nSpacesOpCode, bool bSkipSpaces ); - /** Copy constructor that allows to change the skip spaces mode. */ - explicit ApiTokenIterator( const ApiTokenIterator& rIter, bool bSkipSpaces ); + explicit OpCodeProvider( const WorkbookHelper& rHelper ); + virtual ~OpCodeProvider(); - inline bool is() const { return mpToken != mpTokenEnd; } - inline const ApiToken* get() const { return mpToken; } - inline const ApiToken* operator->() const { return mpToken; } - inline const ApiToken& operator*() const { return *mpToken; } + /** Returns the function info for an API token, or 0 on error. */ + const FunctionInfo* getFuncInfoFromApiToken( const ApiToken& rToken ) const; - ApiTokenIterator& operator++(); + /** Returns the op-code map that is used by the OOX formula parser. */ + ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaOpCodeMapEntry > + getOoxParserMap() const; private: - void skipSpaces(); + typedef ::std::map< ::rtl::OUString, ApiToken > ApiTokenMap; + typedef ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaOpCodeMapEntry > OpCodeEntrySequence; + typedef ::std::vector< ::com::sun::star::sheet::FormulaOpCodeMapEntry > OpCodeEntryVector; + + static bool fillEntrySeq( OpCodeEntrySequence& orEntrySeq, const ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XFormulaOpCodeMapper >& rxMapper, sal_Int32 nMapGroup ); + static bool fillTokenMap( ApiTokenMap& orTokenMap, OpCodeEntrySequence& orEntrySeq, const ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XFormulaOpCodeMapper >& rxMapper, sal_Int32 nMapGroup ); + bool fillFuncTokenMaps( ApiTokenMap& orIntFuncTokenMap, ApiTokenMap& orExtFuncTokenMap, OpCodeEntrySequence& orEntrySeq, const ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XFormulaOpCodeMapper >& rxMapper ) const; + + static bool initOpCode( sal_Int32& ornOpCode, const OpCodeEntrySequence& rEntrySeq, sal_Int32 nSpecialId ); + bool initOpCode( sal_Int32& ornOpCode, const ApiTokenMap& rTokenMap, const ::rtl::OUString& rOdfName, const ::rtl::OUString& rOoxName ); + bool initOpCode( sal_Int32& ornOpCode, const ApiTokenMap& rTokenMap, const sal_Char* pcOdfName, const sal_Char* pcOoxName ); + bool initOpCode( sal_Int32& ornOpCode, const ApiTokenMap& rTokenMap, sal_Unicode cOdfName, sal_Unicode cOoxName ); + + bool initFuncOpCode( FunctionInfo& orFuncInfo, const ApiTokenMap& rFuncTokenMap ); + bool initFuncOpCodes( const ApiTokenMap& rIntFuncTokenMap, const ApiTokenMap& rExtFuncTokenMap ); private: - const ApiToken* mpToken; /// Pointer to current token of the token sequence. - const ApiToken* mpTokenEnd; /// Pointer behind last token of the token sequence. - const sal_Int32 mnSpacesOpCode; /// Op-code for whitespace tokens. - const bool mbSkipSpaces; /// true = Skip whitespace tokens. + typedef RefMap< sal_Int32, FunctionInfo > OpCodeFuncMap; + typedef ::boost::shared_ptr< OpCodeFuncMap > OpCodeFuncMapRef; + typedef ::boost::shared_ptr< OpCodeEntryVector > OpCodeEntryVectorRef; + + OpCodeFuncMapRef mxOpCodeFuncs; /// Maps API op-codes to function data. + FuncNameMapRef mxExtProgFuncs; /// Maps programmatical API function names to function data. + OpCodeEntryVectorRef mxParserMap; /// OOXML token mapping for formula parser service. }; // formula contexts =========================================================== @@ -509,7 +591,7 @@ private: // formula parser/formula compiler base class ================================= /** Base class for import formula parsers and export formula compilers. */ -class FormulaProcessorBase : public WorkbookHelper +class FormulaProcessorBase : public OpCodeProvider { public: explicit FormulaProcessorBase( const WorkbookHelper& rHelper ); @@ -682,8 +764,7 @@ public: sal_Unicode cStringSep, bool bTrimLeadingSpaces ) const; -protected: - FunctionProvider maFuncProv; /// Provides info structs for all functions. +private: const ::rtl::OUString maAbsNameProp; /// Property name for absolute name of cells and ranges. }; diff --git a/oox/inc/oox/xls/formulaparser.hxx b/oox/inc/oox/xls/formulaparser.hxx index 3256acd4dcc8..fa3b86ef8757 100644 --- a/oox/inc/oox/xls/formulaparser.hxx +++ b/oox/inc/oox/xls/formulaparser.hxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: formulaparser.hxx,v $ - * $Revision: 1.3 $ + * $Revision: 1.3.22.1 $ * * This file is part of OpenOffice.org. * @@ -80,6 +80,12 @@ public: FormulaContext& rContext, sal_Int32 nTokenIndex ) const; + /** Converts the passed number into a HYPERLINK formula with the passed URL. */ + void convertNumberToHyperlink( + FormulaContext& rContext, + const ::rtl::OUString& rUrl, + double fValue ) const; + private: ::std::auto_ptr< FormulaParserImpl > mxImpl; }; diff --git a/oox/inc/oox/xls/richstring.hxx b/oox/inc/oox/xls/richstring.hxx index 14b0da56a211..f1dc8cfa6baa 100644 --- a/oox/inc/oox/xls/richstring.hxx +++ b/oox/inc/oox/xls/richstring.hxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: richstring.hxx,v $ - * $Revision: 1.4 $ + * $Revision: 1.4.20.2 $ * * This file is part of OpenOffice.org. * @@ -86,6 +86,15 @@ typedef ::boost::shared_ptr< RichStringPortion > RichStringPortionRef; // ---------------------------------------------------------------------------- +enum BiffFontPortionMode +{ + BIFF_FONTPORTION_8BIT, /// Font portion with 8-bit values. + BIFF_FONTPORTION_16BIT, /// Font portion with 16-bit values. + BIFF_FONTPORTION_OBJ /// Font portion in OBJ or TXO record. +}; + +// ---------------------------------------------------------------------------- + /** Represents a position in a rich-string containing current font identifier. This object stores the position of a formatted character in a rich-string @@ -102,7 +111,7 @@ struct BinFontPortionData mnPos( nPos ), mnFontId( nFontId ) {} void read( RecordInputStream& rStrm ); - void read( BiffInputStream& rStrm, bool b16Bit ); + void read( BiffInputStream& rStrm, BiffFontPortionMode eMode ); }; // ---------------------------------------------------------------------------- @@ -118,7 +127,7 @@ public: /** Reads count and font identifiers from the passed stream. */ void importPortions( RecordInputStream& rStrm ); /** Reads nCount font identifiers from the passed stream. */ - void importPortions( BiffInputStream& rStrm, sal_uInt16 nCount, bool b16Bit ); + void importPortions( BiffInputStream& rStrm, sal_uInt16 nCount, BiffFontPortionMode eMode ); /** Reads count and font identifiers from the passed stream. */ void importPortions( BiffInputStream& rStrm, bool b16Bit ); }; @@ -213,7 +222,7 @@ public: /** Reads all phonetic portions from the passed stream. */ void importPortions( RecordInputStream& rStrm ); /** Reads phonetic portion data from the passed stream. */ - ::rtl::OUString importPortions( BiffInputStream& rStrm, sal_uInt32 nPhoneticSize ); + ::rtl::OUString importPortions( BiffInputStream& rStrm, sal_Int32 nPhoneticSize ); }; // ============================================================================ diff --git a/oox/inc/oox/xls/sheetdatacontext.hxx b/oox/inc/oox/xls/sheetdatacontext.hxx index 648ff3c8b856..7fc09631e953 100644 --- a/oox/inc/oox/xls/sheetdatacontext.hxx +++ b/oox/inc/oox/xls/sheetdatacontext.hxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: sheetdatacontext.hxx,v $ - * $Revision: 1.4 $ + * $Revision: 1.4.20.2 $ * * This file is part of OpenOffice.org. * @@ -33,7 +33,6 @@ #include "oox/xls/excelhandlers.hxx" #include "oox/xls/richstring.hxx" -#include "oox/xls/worksheethelper.hxx" namespace com { namespace sun { namespace star { namespace table { class XCell; } @@ -123,10 +122,7 @@ private: class OoxExternalSheetDataContext : public OoxWorksheetContextBase { public: - explicit OoxExternalSheetDataContext( - OoxWorkbookFragmentBase& rFragment, - WorksheetType eSheetType, - sal_Int32 nSheet ); + explicit OoxExternalSheetDataContext( OoxWorkbookFragmentBase& rFragment, sal_Int32 nSheet ); protected: // oox.core.ContextHandler2Helper interface ------------------------------- @@ -164,52 +160,52 @@ private: /** This class implements importing row settings and all cells of a sheet. */ -class BiffSheetDataContext : public WorksheetHelper +class BiffSheetDataContext : public BiffWorksheetContextBase { public: - explicit BiffSheetDataContext( const WorksheetHelper& rHelper ); + explicit BiffSheetDataContext( const BiffWorksheetFragmentBase& rParent ); /** Tries to import a sheet data record. */ - void importRecord( BiffInputStream& rStrm ); + virtual void importRecord(); private: /** Sets current cell according to the passed address. */ void setCurrCell( const BinAddress& rAddr ); /** Imports an XF identifier and sets the mnXfId member. */ - void importXfId( BiffInputStream& rStrm, bool bBiff2 ); + void importXfId( bool bBiff2 ); /** Imports a BIFF cell address and the following XF identifier. */ - void importCellHeader( BiffInputStream& rStrm, bool bBiff2 ); + void importCellHeader( bool bBiff2 ); /** Imports a BLANK record describing a blank but formatted cell. */ - void importBlank( BiffInputStream& rStrm ); + void importBlank(); /** Imports a BOOLERR record describing a boolean or error code cell. */ - void importBoolErr( BiffInputStream& rStrm ); + void importBoolErr(); /** Imports a FORMULA record describing a formula cell. */ - void importFormula( BiffInputStream& rStrm ); + void importFormula(); /** Imports an INTEGER record describing a BIFF2 integer cell. */ - void importInteger( BiffInputStream& rStrm ); + void importInteger(); /** Imports a LABEL record describing an unformatted string cell. */ - void importLabel( BiffInputStream& rStrm ); + void importLabel(); /** Imports a LABELSST record describing a string cell using the shared string list. */ - void importLabelSst( BiffInputStream& rStrm ); + void importLabelSst(); /** Imports a MULTBLANK record describing a range of blank but formatted cells. */ - void importMultBlank( BiffInputStream& rStrm ); + void importMultBlank(); /** Imports a MULTRK record describing a range of numeric cells. */ - void importMultRk( BiffInputStream& rStrm ); + void importMultRk(); /** Imports a NUMBER record describing a floating-point cell. */ - void importNumber( BiffInputStream& rStrm ); + void importNumber(); /** Imports an RK record describing a numeric cell. */ - void importRk( BiffInputStream& rStrm ); + void importRk(); /** Imports row settings from a ROW record. */ - void importRow( BiffInputStream& rStrm ); + void importRow(); /** Imports an ARRAY record describing an array formula of a cell range. */ - void importArray( BiffInputStream& rStrm ); + void importArray(); /** Imports a SHAREDFMLA record describing a shared formula in a cell range. */ - void importSharedFmla( BiffInputStream& rStrm ); + void importSharedFmla(); /** Imports table operation from a DATATABLE or DATATABLE2 record. */ - void importDataTable( BiffInputStream& rStrm ); + void importDataTable(); private: OoxCellData maCurrCell; /// Position and formatting of current imported cell. @@ -222,16 +218,13 @@ private: /** This class implements importing cached cell data of external links. */ -class BiffExternalSheetDataContext : public WorksheetHelperRoot +class BiffExternalSheetDataContext : public BiffWorksheetContextBase { public: - explicit BiffExternalSheetDataContext( - const WorkbookHelper& rHelper, - WorksheetType eSheetType, - sal_Int32 nSheet ); + explicit BiffExternalSheetDataContext( const BiffWorkbookFragmentBase& rParent, sal_Int32 nSheet ); /** Import the CRN record containing cached cell values. */ - void importCrn( BiffInputStream& rStrm ); + virtual void importRecord(); }; // ============================================================================ diff --git a/oox/inc/oox/xls/stylesfragment.hxx b/oox/inc/oox/xls/stylesfragment.hxx index 145ae6b7d8f7..e0eada56e3c8 100644 --- a/oox/inc/oox/xls/stylesfragment.hxx +++ b/oox/inc/oox/xls/stylesfragment.hxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: stylesfragment.hxx,v $ - * $Revision: 1.4 $ + * $Revision: 1.4.20.1 $ * * This file is part of OpenOffice.org. * diff --git a/oox/inc/oox/xls/stylespropertyhelper.hxx b/oox/inc/oox/xls/stylespropertyhelper.hxx index 336618cf712c..ed94d089448b 100644 --- a/oox/inc/oox/xls/stylespropertyhelper.hxx +++ b/oox/inc/oox/xls/stylespropertyhelper.hxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: stylespropertyhelper.hxx,v $ - * $Revision: 1.3 $ + * $Revision: 1.3.22.1 $ * * This file is part of OpenOffice.org. * @@ -83,20 +83,32 @@ struct ApiFontUsedFlags // ---------------------------------------------------------------------------- +/** Contains API font name, family, and charset for a script type. */ +struct ApiScriptFontName +{ + ::rtl::OUString maName; /// Font name. + sal_Int16 mnFamily; /// Font family. + sal_Int16 mnCharSet; /// Font character set. + + explicit ApiScriptFontName(); +}; + +// ---------------------------------------------------------------------------- + /** Contains all API font attributes. */ struct ApiFontData { typedef ::com::sun::star::awt::FontDescriptor ApiFontDescriptor; - ApiFontDescriptor maDesc; /// Font descriptor holding most font information (height in twips, weight in %). + ApiScriptFontName maLatinFont; /// Font name for latin scripts. + ApiScriptFontName maAsianFont; /// Font name for east-asian scripts. + ApiScriptFontName maCmplxFont; /// Font name for complex scripts. + ApiFontDescriptor maDesc; /// Font descriptor (height in twips, weight in %). sal_Int32 mnColor; /// Font color. sal_Int16 mnEscapement; /// Escapement style. sal_Int8 mnEscapeHeight; /// Escapement font height. bool mbOutline; /// True = outlined characters. bool mbShadow; /// True = shadowed chgaracters. - bool mbHasWstrn; /// True = font contains Western script characters. - bool mbHasAsian; /// True = font contains Asian script characters. - bool mbHasCmplx; /// True = font contains Complex script characters. explicit ApiFontData(); }; @@ -231,7 +243,7 @@ public: const ApiSolidFillData& rFillData ); private: - PropertySequence maWstrnFontNameProps; + PropertySequence maLatinFontNameProps; PropertySequence maAsianFontNameProps; PropertySequence maCmplxFontNameProps; PropertySequence maFontHeightProps; diff --git a/oox/inc/oox/xls/themebuffer.hxx b/oox/inc/oox/xls/themebuffer.hxx index adbddebc80f2..51b42bc465c6 100644 --- a/oox/inc/oox/xls/themebuffer.hxx +++ b/oox/inc/oox/xls/themebuffer.hxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: themebuffer.hxx,v $ - * $Revision: 1.5 $ + * $Revision: 1.5.20.1 $ * * This file is part of OpenOffice.org. * @@ -41,18 +41,12 @@ struct OoxFontData; // ============================================================================ -class ThemeBuffer : public WorkbookHelper +class ThemeBuffer : public ::oox::drawingml::Theme, public WorkbookHelper { public: explicit ThemeBuffer( const WorkbookHelper& rHelper ); virtual ~ThemeBuffer(); - /** Returns the pointer to the core drawingml theme. */ - inline const ::oox::drawingml::ThemePtr& getCoreThemePtr() const { return mxTheme; } - - /** Returns the core drawingml theme needed by the theme fragment importer. */ - ::oox::drawingml::Theme& getOrCreateCoreTheme(); - /** Returns the theme color with the specified token identifier. */ sal_Int32 getColorByToken( sal_Int32 nToken ) const; /** Returns the theme color with the specified index. */ @@ -63,8 +57,6 @@ public: private: typedef ::std::auto_ptr< OoxFontData > OoxFontDataPtr; - - ::oox::drawingml::ThemePtr mxTheme; OoxFontDataPtr mxDefFontData; }; diff --git a/oox/inc/oox/xls/validationpropertyhelper.hxx b/oox/inc/oox/xls/validationpropertyhelper.hxx index 338d90db276e..e69de29bb2d1 100644 --- a/oox/inc/oox/xls/validationpropertyhelper.hxx +++ b/oox/inc/oox/xls/validationpropertyhelper.hxx @@ -1,71 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: validationpropertyhelper.hxx,v $ - * $Revision: 1.3 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef OOX_XLS_VALIDATIONPROPERTYHELPER_HXX -#define OOX_XLS_VALIDATIONPROPERTYHELPER_HXX - -#include <com/sun/star/sheet/ConditionOperator.hpp> -#include "oox/helper/propertysequence.hxx" -#include "oox/xls/workbookhelper.hxx" - -namespace oox { -namespace xls { - -// ============================================================================ - -struct OoxValidationData; - -/** Helper for data validation related properties. */ -class ValidationPropertyHelper : public WorkbookHelper -{ -public: - explicit ValidationPropertyHelper( const WorkbookHelper& rHelper ); - - /** Writes data validation properties to the passed property set. */ - void writeValidationProperties( - PropertySet& rPropSet, - const OoxValidationData& rValData ); - - /** Converts an OOXML condition operator token to the API constant. */ - static ::com::sun::star::sheet::ConditionOperator - convertToApiOperator( sal_Int32 nToken ); - -private: - PropertySequence maValProps; - const ::rtl::OUString maValidationProp; /// Property name for data validation settings. -}; - -// ============================================================================ - -} // namespace xls -} // namespace oox - -#endif - diff --git a/oox/inc/oox/xls/workbookfragment.hxx b/oox/inc/oox/xls/workbookfragment.hxx index bc05bd6f5556..2ca6291c341f 100644 --- a/oox/inc/oox/xls/workbookfragment.hxx +++ b/oox/inc/oox/xls/workbookfragment.hxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: workbookfragment.hxx,v $ - * $Revision: 1.4 $ + * $Revision: 1.4.20.2 $ * * This file is part of OpenOffice.org. * @@ -31,7 +31,6 @@ #ifndef OOX_XLS_WORKBOOKFRAGMENT_HXX #define OOX_XLS_WORKBOOKFRAGMENT_HXX -#include "oox/xls/bifffragmenthandler.hxx" #include "oox/xls/defnamesbuffer.hxx" #include "oox/xls/excelhandlers.hxx" @@ -82,26 +81,23 @@ private: class BiffWorkbookFragment : public BiffWorkbookFragmentBase { public: - explicit BiffWorkbookFragment( const WorkbookHelper& rHelper ); + explicit BiffWorkbookFragment( const WorkbookHelper& rHelper, BiffInputStream& rStrm ); /** Imports the entire workbook stream, including all contained worksheets. */ - virtual bool importFragment( BiffInputStream& rStrm ); + virtual bool importFragment(); private: /** Imports a complete BIFF4 workspace fragment (with embedded sheets). */ - bool importWorkspaceFragment( BiffInputStream& rStrm ); + bool importWorkspaceFragment(); /** Imports the workbook globals fragment from current stream position. */ - bool importGlobalsFragment( - BiffInputStream& rStrm, - ISegmentProgressBar& rProgressBar ); + bool importGlobalsFragment( ISegmentProgressBar& rProgressBar ); /** Imports a sheet fragment with passed type from current stream position. */ bool importSheetFragment( - BiffInputStream& rStrm, ISegmentProgressBar& rProgressBar, BiffFragmentType eFragment, sal_Int32 nSheet ); /** Imports the FILEPASS record and sets a decoder at the passed stream. */ - bool importFilePass( BiffInputStream& rStrm ); + bool importFilePass(); }; // ============================================================================ diff --git a/oox/inc/oox/xls/workbookhelper.hxx b/oox/inc/oox/xls/workbookhelper.hxx index 5a957a9f62b1..3a7e70a78f85 100644 --- a/oox/inc/oox/xls/workbookhelper.hxx +++ b/oox/inc/oox/xls/workbookhelper.hxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: workbookhelper.hxx,v $ - * $Revision: 1.5 $ + * $Revision: 1.5.20.3 $ * * This file is part of OpenOffice.org. * @@ -43,6 +43,7 @@ namespace com { namespace sun { namespace star { namespace sheet { class XSpreadsheetDocument; } namespace sheet { class XSpreadsheet; } namespace sheet { class XNamedRanges; } + namespace sheet { class XNamedRange; } namespace sheet { class XDatabaseRanges; } namespace style { class XStyle; } } } } @@ -60,6 +61,10 @@ namespace oox { namespace core { class XmlFilterBase; } } +namespace oox { namespace drawingml { + class Theme; +} } + namespace oox { namespace xls { @@ -109,7 +114,6 @@ class AddressConverter; class ExcelChartConverter; class StylesPropertyHelper; class PageSettingsPropertyHelper; -class ValidationPropertyHelper; /** Helper class to provice access to global workbook data. @@ -173,12 +177,19 @@ public: ::com::sun::star::uno::Reference< ::com::sun::star::style::XStyle > getStyleObject( const ::rtl::OUString& rStyleName, bool bPageStyle ) const; + /** Creates and returns a defined name on-the-fly in the Calc document. + The name will not be buffered in this defined names buffer. + @param orName (in/out-parameter) Returns the resulting used name. */ + ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XNamedRange > + createNamedRangeObject( + ::rtl::OUString& orName, + sal_Int32 nNameFlags = 0 ) const; /** Creates a com.sun.star.style.Style object and returns its final name. */ ::com::sun::star::uno::Reference< ::com::sun::star::style::XStyle > createStyleObject( ::rtl::OUString& orStyleName, bool bPageStyle, - bool bRenameOldExisting = false ); + bool bRenameOldExisting = false ) const; // buffers ---------------------------------------------------------------- @@ -190,6 +201,8 @@ public: WorksheetBuffer& getWorksheets() const; /** Returns the office theme object read from the theme substorage. */ ThemeBuffer& getTheme() const; + /** Returns the office theme object reference read from the theme substorage. */ + ::boost::shared_ptr< ::oox::drawingml::Theme > getThemeRef() const; /** Returns all cell formatting objects read from the styles substream. */ StylesBuffer& getStyles() const; /** Returns the shared strings read from the shared strings substream. */ @@ -222,8 +235,6 @@ public: StylesPropertyHelper& getStylesPropertyHelper() const; /** Returns the converter for properties related to page and print settings. */ PageSettingsPropertyHelper& getPageSettingsPropertyHelper() const; - /** Returns the converter for properties related to data validation. */ - ValidationPropertyHelper& getValidationPropertyHelper() const; // OOX specific ----------------------------------------------------------- diff --git a/oox/inc/oox/xls/worksheetfragment.hxx b/oox/inc/oox/xls/worksheetfragment.hxx index 11a8f829329f..827614d3ec80 100644 --- a/oox/inc/oox/xls/worksheetfragment.hxx +++ b/oox/inc/oox/xls/worksheetfragment.hxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: worksheetfragment.hxx,v $ - * $Revision: 1.4 $ + * $Revision: 1.4.20.5 $ * * This file is part of OpenOffice.org. * @@ -31,7 +31,6 @@ #ifndef OOX_XLS_WORKSHEETFRAGMENT_HXX #define OOX_XLS_WORKSHEETFRAGMENT_HXX -#include "oox/xls/bifffragmenthandler.hxx" #include "oox/xls/excelhandlers.hxx" namespace oox { @@ -84,6 +83,12 @@ private: void importBrk( const AttributeList& rAttribs ); /** Imports the the relation identifier for the DrawingML part. */ void importDrawing( const AttributeList& rAttribs ); + /** Imports the the relation identifier for the legacy VML drawing part. */ + void importLegacyDrawing( const AttributeList& rAttribs ); + /** Imports additional data for an OLE object. */ + void importOleObject( const AttributeList& rAttribs ); + /** Imports additional data for an OCX form control. */ + void importControl( const AttributeList& rAttribs ); /** Imports the DIMENSION record containing the used area of the sheet. */ void importDimension( RecordInputStream& rStrm ); @@ -101,6 +106,12 @@ private: void importBrk( RecordInputStream& rStrm ); /** Imports the DRAWING record containing the relation identifier for the DrawingML part. */ void importDrawing( RecordInputStream& rStrm ); + /** Imports the LEGACYDRAWING record containing the relation identifier for the VML drawing part. */ + void importLegacyDrawing( RecordInputStream& rStrm ); + /** Imports additional data for an OLE object. */ + void importOleObject( RecordInputStream& rStrm ); + /** Imports additional data for an OCX form control. */ + void importControl( RecordInputStream& rStrm ); private: ::std::auto_ptr< OoxValidationData > mxValData; @@ -112,41 +123,43 @@ class BiffWorksheetFragment : public BiffWorksheetFragmentBase { public: explicit BiffWorksheetFragment( - const WorkbookHelper& rHelper, + const BiffWorkbookFragmentBase& rParent, ISegmentProgressBarRef xProgressBar, WorksheetType eSheetType, sal_Int32 nSheet ); /** Imports the entire worksheet fragment, returns true, if EOF record has been reached. */ - virtual bool importFragment( BiffInputStream& rStrm ); + virtual bool importFragment(); private: /** Imports the COLINFO record and sets column properties and formatting. */ - void importColInfo( BiffInputStream& rStrm ); + void importColInfo(); /** Imports the BIFF2 COLUMNDEFAULT record and sets column default formatting. */ - void importColumnDefault( BiffInputStream& rStrm ); + void importColumnDefault(); /** Imports the BIFF2 COLWIDTH record and sets column width. */ - void importColWidth( BiffInputStream& rStrm ); + void importColWidth(); /** Imports the DATAVALIDATION record containing cell ranges with data validation settings. */ - void importDataValidation( BiffInputStream& rStrm ); + void importDataValidation(); /** Imports the DATAVALIDATIONS record containing global data validation settings. */ - void importDataValidations( BiffInputStream& rStrm ); + void importDataValidations(); /** Imports the DEFCOLWIDTH record and sets default column width. */ - void importDefColWidth( BiffInputStream& rStrm ); + void importDefColWidth(); /** Imports the DEFROWHEIGHT record and sets default row height and properties. */ - void importDefRowHeight( BiffInputStream& rStrm ); + void importDefRowHeight(); /** Imports the DIMENSION record containing the used area of the sheet. */ - void importDimension( BiffInputStream& rStrm ); + void importDimension(); + /** Reads a string as used in the HYPERLINK record. */ + ::rtl::OUString readHyperlinkString( rtl_TextEncoding eTextEnc, bool bUnicode ); /** Imports the HYPERLINK record and sets a cell hyperlink. */ - void importHyperlink( BiffInputStream& rStrm ); + void importHyperlink(); /** Imports the LABELRANGES record and sets the imported label ranges. */ - void importLabelRanges( BiffInputStream& rStrm ); + void importLabelRanges(); /** Imports the MEREDCELLS record and merges all cells in the document. */ - void importMergedCells( BiffInputStream& rStrm ); + void importMergedCells(); /** Imports the HORPAGEBREAKS or VERPAGEBREAKS record and inserts page breaks. */ - void importPageBreaks( BiffInputStream& rStrm, bool bRowBreak ); + void importPageBreaks( bool bRowBreak ); /** Imports the STANDARDWIDTH record and sets standard column width. */ - void importStandardWidth( BiffInputStream& rStrm ); + void importStandardWidth(); }; // ============================================================================ diff --git a/oox/inc/oox/xls/worksheethelper.hxx b/oox/inc/oox/xls/worksheethelper.hxx index 99e7e030f27d..3f2fdf76bcec 100644 --- a/oox/inc/oox/xls/worksheethelper.hxx +++ b/oox/inc/oox/xls/worksheethelper.hxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: worksheethelper.hxx,v $ - * $Revision: 1.4 $ + * $Revision: 1.4.20.4 $ * * This file is part of OpenOffice.org. * @@ -68,7 +68,8 @@ enum WorksheetType SHEETTYPE_CHARTSHEET, /// Chart sheet. SHEETTYPE_MACROSHEET, /// Macro sheet. SHEETTYPE_DIALOGSHEET, /// Dialog sheet (BIFF5+). - SHEETTYPE_MODULESHEET /// VB module sheet (BIFF5 only). + SHEETTYPE_MODULESHEET, /// VB module sheet (BIFF5 only). + SHEETTYPE_EMPTYSHEET /// Other (unsupported) sheet type. }; // ============================================================================ @@ -172,6 +173,7 @@ struct OoxHyperlinkData ::rtl::OUString maTarget; ::rtl::OUString maLocation; ::rtl::OUString maDisplay; + ::rtl::OUString maFrame; ::rtl::OUString maTooltip; explicit OoxHyperlinkData(); @@ -207,6 +209,33 @@ struct OoxValidationData void setBinErrorStyle( sal_uInt8 nErrorStyle ); }; +// ---------------------------------------------------------------------------- + +/** Stores data about embedded objects. */ +struct OoxOleObjectData +{ + ::rtl::OUString maProgId; + ::rtl::OUString maStoragePath; + sal_Int32 mnAspect; + sal_Int32 mnUpdateMode; + sal_Int32 mnShapeId; + bool mbAutoLoad; + + explicit OoxOleObjectData(); +}; + +// ---------------------------------------------------------------------------- + +/** Stores data about embedded form controls. */ +struct OoxFormControlData +{ + ::rtl::OUString maStoragePath; + ::rtl::OUString maName; + sal_Int32 mnShapeId; + + explicit OoxFormControlData(); +}; + // ============================================================================ // ============================================================================ @@ -362,6 +391,12 @@ public: const ApiCellRangeList& rRowRanges ); /** Sets the path to the DrawingML fragment of this sheet. */ void setDrawingPath( const ::rtl::OUString& rDrawingPath ); + /** Sets the path to the legacy VML drawing fragment of this sheet. */ + void setVmlDrawingPath( const ::rtl::OUString& rVmlDrawingPath ); + /** Sets additional data for an OLE object. */ + void setOleObject( const OoxOleObjectData& rOleObjectData ); + /** Sets additional data for an OCX form control. */ + void setFormControl( const OoxFormControlData& rFormControlData ); /** Sets base width for all columns (without padding pixels). This value is only used, if width has not been set with setDefaultColumnWidth(). */ diff --git a/oox/prj/build.lst b/oox/prj/build.lst index 5b3035cfbc9a..599b99227472 100644 --- a/oox/prj/build.lst +++ b/oox/prj/build.lst @@ -4,6 +4,7 @@ oox oox\prj get - all oox_prj NULL oox oox\source\token nmake - all oox_token NULL oox oox\source\helper nmake - all oox_helper oox_token NULL oox oox\source\core nmake - all oox_core oox_token NULL +oox oox\source\ole nmake - all oox_ole oox_token NULL oox oox\source\docprop nmake - all oox_docprop oox_token NULL oox oox\source\drawingml nmake - all oox_drawingml oox_token NULL oox oox\source\drawingml\diagram nmake - all oox_diagram oox_token NULL @@ -14,4 +15,4 @@ oox oox\source\vml nmake - all oox_vml oox_token NULL oox oox\source\xls nmake - all oox_xls oox_token NULL oox oox\source\dump nmake - all oox_dump oox_token NULL oox oox\source\shape nmake - all oox_shape oox_token NULL -oox oox\util nmake - all oox_util oox_token oox_helper oox_core oox_vml oox_drawingml oox_diagram oox_chart oox_table oox_ppt oox_xls oox_dump oox_shape oox_docprop NULL +oox oox\util nmake - all oox_util oox_token oox_helper oox_core oox_ole oox_vml oox_drawingml oox_diagram oox_chart oox_table oox_ppt oox_xls oox_dump oox_shape oox_docprop NULL diff --git a/oox/source/core/binaryfilterbase.cxx b/oox/source/core/binaryfilterbase.cxx index a9b76bc2492c..3e7040cb9c21 100644 --- a/oox/source/core/binaryfilterbase.cxx +++ b/oox/source/core/binaryfilterbase.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: binaryfilterbase.cxx,v $ - * $Revision: 1.3 $ + * $Revision: 1.3.22.1 $ * * This file is part of OpenOffice.org. * @@ -56,9 +56,9 @@ StorageRef BinaryFilterBase::implCreateStorage( { StorageRef xStorage; if( rxInStream.is() ) - xStorage.reset( new OleStorage( getServiceFactory(), rxInStream, true ) ); + xStorage.reset( new OleStorage( getGlobalFactory(), rxInStream, true ) ); else if( rxOutStream.is() ) - xStorage.reset( new OleStorage( getServiceFactory(), rxOutStream, true ) ); + xStorage.reset( new OleStorage( getGlobalFactory(), rxOutStream, true ) ); return xStorage; } diff --git a/oox/source/core/filterbase.cxx b/oox/source/core/filterbase.cxx index 46ddb8776f8b..169a4884958a 100644 --- a/oox/source/core/filterbase.cxx +++ b/oox/source/core/filterbase.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: filterbase.cxx,v $ - * $Revision: 1.5 $ + * $Revision: 1.5.20.1 $ * * This file is part of OpenOffice.org. * @@ -64,6 +64,7 @@ struct FilterBaseImpl OUString maFileUrl; StorageRef mxStorage; + Sequence< Any > maArguments; Reference< XMultiServiceFactory > mxFactory; Reference< XModel > mxModel; Reference< XInputStream > mxInStream; @@ -80,6 +81,7 @@ struct FilterBaseImpl FilterBaseImpl::FilterBaseImpl( const Reference< XMultiServiceFactory >& rxFactory ) : mxFactory( rxFactory ) { + OSL_ENSURE( mxFactory.is(), "FilterBaseImpl::FilterBaseImpl - missing service factory" ); } void FilterBaseImpl::setMediaDescriptor( const Sequence< PropertyValue >& rDescriptor ) @@ -117,7 +119,12 @@ bool FilterBase::isExportFilter() const // ---------------------------------------------------------------------------- -const Reference< XMultiServiceFactory >& FilterBase::getServiceFactory() const +const Sequence< Any >& FilterBase::getArguments() const +{ + return mxImpl->maArguments; +} + +const Reference< XMultiServiceFactory >& FilterBase::getGlobalFactory() const { return mxImpl->mxFactory; } @@ -250,8 +257,9 @@ Sequence< OUString > SAL_CALL FilterBase::getSupportedServiceNames() throw( Runt // com.sun.star.lang.XInitialization interface -------------------------------- -void SAL_CALL FilterBase::initialize( const Sequence< Any >& /*rArgs*/ ) throw( Exception, RuntimeException ) +void SAL_CALL FilterBase::initialize( const Sequence< Any >& rArgs ) throw( Exception, RuntimeException ) { + mxImpl->maArguments = rArgs; } // com.sun.star.document.XImporter interface ---------------------------------- @@ -277,16 +285,19 @@ void SAL_CALL FilterBase::setSourceDocument( const Reference< XComponent >& rxDo sal_Bool SAL_CALL FilterBase::filter( const Sequence< PropertyValue >& rDescriptor ) throw( RuntimeException ) { sal_Bool bRet = sal_False; - mxImpl->setMediaDescriptor( rDescriptor ); - mxImpl->mxStorage = implCreateStorage( mxImpl->mxInStream, mxImpl->mxOutStream ); - if( mxImpl->mxModel.is() && mxImpl->mxStorage.get() ) + if( mxImpl->mxFactory.is() && mxImpl->mxModel.is() ) { - mxImpl->mxModel->lockControllers(); - if( mxImpl->mxInStream.is() ) - bRet = importDocument(); - else if( mxImpl->mxOutStream.is() ) - bRet = exportDocument(); - mxImpl->mxModel->unlockControllers(); + mxImpl->setMediaDescriptor( rDescriptor ); + mxImpl->mxStorage = implCreateStorage( mxImpl->mxInStream, mxImpl->mxOutStream ); + if( mxImpl->mxStorage.get() ) + { + mxImpl->mxModel->lockControllers(); + if( mxImpl->mxInStream.is() ) + bRet = importDocument(); + else if( mxImpl->mxOutStream.is() ) + bRet = exportDocument(); + mxImpl->mxModel->unlockControllers(); + } } return bRet; } diff --git a/oox/source/core/filterdetect.cxx b/oox/source/core/filterdetect.cxx index 32f68b184f45..b0496de26589 100644 --- a/oox/source/core/filterdetect.cxx +++ b/oox/source/core/filterdetect.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: filterdetect.cxx,v $ - * $Revision: 1.5 $ + * $Revision: 1.5.4.1 $ * * This file is part of OpenOffice.org. * @@ -37,7 +37,6 @@ #include <com/sun/star/xml/sax/XFastContextHandler.hpp> #include <com/sun/star/xml/sax/XFastParser.hpp> -#include <comphelper/processfactory.hxx> #include <comphelper/mediadescriptor.hxx> #include <cppuhelper/implbase1.hxx> #include <cppuhelper/implbase2.hxx> @@ -311,6 +310,7 @@ Reference< XInterface > SAL_CALL FilterDetect_createInstance( const Reference< X FilterDetect::FilterDetect( const Reference< XMultiServiceFactory >& xFactory ) : mxFactory( xFactory ) { + OSL_ENSURE( mxFactory.is(), "FilterDetect::FilterDetect - no service factory" ); } FilterDetect::~FilterDetect() @@ -323,9 +323,9 @@ OUString SAL_CALL FilterDetect::detect( Sequence< PropertyValue >& lDescriptor ) { OUString aFilter; - try + if( mxFactory.is() ) try { - Reference< XFastParser > xParser( ::comphelper::getProcessServiceFactory()->createInstance( + Reference< XFastParser > xParser( mxFactory->createInstance( CREATE_OUSTRING( "com.sun.star.xml.sax.FastParser" ) ), UNO_QUERY_THROW ); xParser->setFastDocumentHandler( new FilterDetectDocHandler( aFilter ) ); diff --git a/oox/source/core/recordparser.cxx b/oox/source/core/recordparser.cxx index 51c29b0d5502..2d24ed40cc91 100644 --- a/oox/source/core/recordparser.cxx +++ b/oox/source/core/recordparser.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: recordparser.cxx,v $ - * $Revision: 1.4 $ + * $Revision: 1.4.20.1 $ * * This file is part of OpenOffice.org. * @@ -182,7 +182,7 @@ namespace { /** Reads a byte from the passed stream, returns true on success. */ inline bool lclReadByte( sal_uInt8& ornByte, BinaryInputStream& rStrm ) { - return rStrm.read( &ornByte, 1 ) == 1; + return rStrm.readMemory( &ornByte, 1 ) == 1; } /** Reads a compressed signed 32-bit integer from the passed stream. */ @@ -211,14 +211,14 @@ bool lclReadRecordHeader( sal_Int32& ornRecId, sal_Int32& ornRecSize, BinaryInpu lclReadCompressedInt( ornRecSize, rStrm ) && (ornRecSize >= 0); } -bool lclReadNextRecord( sal_Int32& ornRecId, RecordDataSequence& orData, BinaryInputStream& rStrm ) +bool lclReadNextRecord( sal_Int32& ornRecId, StreamDataSequence& orData, BinaryInputStream& rStrm ) { sal_Int32 nRecSize = 0; bool bValid = lclReadRecordHeader( ornRecId, nRecSize, rStrm ); if( bValid ) { orData.realloc( nRecSize ); - bValid = (nRecSize == 0) || (rStrm.read( orData, nRecSize ) == nRecSize); + bValid = (nRecSize == 0) || (rStrm.readData( orData, nRecSize ) == nRecSize); } return bValid; } @@ -259,7 +259,7 @@ void RecordParser::parseStream( const RecordInputSource& rInputSource ) throw( S { maSource = rInputSource; - if( !maSource.mxInStream || !maSource.mxInStream->is() ) + if( !maSource.mxInStream || maSource.mxInStream->isEof() ) throw IOException(); if( !mxHandler.is() ) throw SAXException(); @@ -272,7 +272,7 @@ void RecordParser::parseStream( const RecordInputSource& rInputSource ) throw( S // parse the stream mxStack.reset( new prv::ContextStack( mxHandler ) ); sal_Int32 nRecId = 0; - RecordDataSequence aRecData; + StreamDataSequence aRecData; while( lclReadNextRecord( nRecId, aRecData, *maSource.mxInStream ) ) { // create record stream object from imported record data diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx index 9f559412fdd6..6e7f4e6c9f55 100644 --- a/oox/source/core/xmlfilterbase.cxx +++ b/oox/source/core/xmlfilterbase.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: xmlfilterbase.cxx,v $ - * $Revision: 1.5 $ + * $Revision: 1.5.6.2 $ * * This file is part of OpenOffice.org. * @@ -141,7 +141,7 @@ bool XmlFilterBase::importFragment( const ::rtl::Reference< FragmentHandler >& r // create the input source and parse the stream RecordInputSource aSource; - aSource.mxInStream.reset( new BinaryInputStream( xInStrm, true ) ); + aSource.mxInStream.reset( new BinaryXInputStream( xInStrm, true ) ); aSource.maSystemId = aFragmentPath; aParser.parseStream( aSource ); return true; @@ -161,7 +161,7 @@ bool XmlFilterBase::importFragment( const ::rtl::Reference< FragmentHandler >& r try { // create the fast parser - Reference< XFastParser > xParser( getServiceFactory()->createInstance( + Reference< XFastParser > xParser( getGlobalFactory()->createInstance( CREATE_OUSTRING( "com.sun.star.xml.sax.FastParser" ) ), UNO_QUERY_THROW ); xParser->setFastDocumentHandler( xDocHandler ); xParser->setTokenHandler( mxImpl->mxTokenHandler ); @@ -170,22 +170,23 @@ bool XmlFilterBase::importFragment( const ::rtl::Reference< FragmentHandler >& r xParser->registerNamespace( CREATE_OUSTRING( "http://www.w3.org/XML/1998/namespace" ), NMSP_XML ); xParser->registerNamespace( CREATE_OUSTRING( "http://schemas.openxmlformats.org/package/2006/relationships" ), NMSP_PACKAGE_RELATIONSHIPS ); xParser->registerNamespace( CREATE_OUSTRING( "http://schemas.openxmlformats.org/officeDocument/2006/relationships" ), NMSP_RELATIONSHIPS ); - xParser->registerNamespace( CREATE_OUSTRING( "urn:schemas-microsoft-com:office:office" ), NMSP_OFFICE ); xParser->registerNamespace( CREATE_OUSTRING( "http://schemas.openxmlformats.org/drawingml/2006/main" ), NMSP_DRAWINGML ); xParser->registerNamespace( CREATE_OUSTRING( "http://schemas.openxmlformats.org/drawingml/2006/diagram" ), NMSP_DIAGRAM ); xParser->registerNamespace( CREATE_OUSTRING( "http://schemas.openxmlformats.org/drawingml/2006/chart" ), NMSP_CHART ); - xParser->registerNamespace( CREATE_OUSTRING( "urn:schemas-microsoft-com:vml" ), NMSP_VML ); - xParser->registerNamespace( CREATE_OUSTRING( "urn:schemas-microsoft-com:office:word" ), NMSP_WORD ); + xParser->registerNamespace( CREATE_OUSTRING( "urn:schemas-microsoft-com:vml" ), NMSP_VML ); + xParser->registerNamespace( CREATE_OUSTRING( "urn:schemas-microsoft-com:office:office" ), NMSP_OFFICE ); + xParser->registerNamespace( CREATE_OUSTRING( "urn:schemas-microsoft-com:office:word" ), NMSP_VML_DOC ); + xParser->registerNamespace( CREATE_OUSTRING( "urn:schemas-microsoft-com:office:excel" ), NMSP_VML_XLS ); + xParser->registerNamespace( CREATE_OUSTRING( "urn:schemas-microsoft-com:office:powerpoint" ), NMSP_VML_PPT ); + xParser->registerNamespace( CREATE_OUSTRING( "http://schemas.microsoft.com/office/2006/activeX" ), NMSP_AX ); xParser->registerNamespace( CREATE_OUSTRING( "http://schemas.openxmlformats.org/spreadsheetml/2006/main"), NMSP_XLS ); xParser->registerNamespace( CREATE_OUSTRING( "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing" ), NMSP_XDR ); xParser->registerNamespace( CREATE_OUSTRING( "http://schemas.microsoft.com/office/excel/2006/main" ), NMSP_XM ); - xParser->registerNamespace( CREATE_OUSTRING( "urn:schemas-microsoft-com:office:excel" ), NMSP_EXCEL ); xParser->registerNamespace( CREATE_OUSTRING( "http://schemas.openxmlformats.org/presentationml/2006/main"), NMSP_PPT ); - xParser->registerNamespace( CREATE_OUSTRING( "urn:schemas-microsoft-com:office:powerpoint" ), NMSP_POWERPOINT ); // create the input source and parse the stream InputSource aSource; @@ -277,9 +278,9 @@ StorageRef XmlFilterBase::implCreateStorage( { StorageRef xStorage; if( rxInStream.is() ) - xStorage.reset( new ZipStorage( getServiceFactory(), rxInStream ) ); + xStorage.reset( new ZipStorage( getGlobalFactory(), rxInStream ) ); else if( rxOutStream.is() ) - xStorage.reset( new ZipStorage( getServiceFactory(), rxOutStream ) ); + xStorage.reset( new ZipStorage( getGlobalFactory(), rxOutStream ) ); return xStorage; } diff --git a/oox/source/drawingml/chart/converterbase.cxx b/oox/source/drawingml/chart/converterbase.cxx index f8ffd5500317..c9b91e308414 100644 --- a/oox/source/drawingml/chart/converterbase.cxx +++ b/oox/source/drawingml/chart/converterbase.cxx @@ -8,7 +8,7 @@ * * $RCSfile: converterbase.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.4.6.1 $ * * This file is part of OpenOffice.org. * @@ -30,12 +30,12 @@ ************************************************************************/ #include "oox/drawingml/chart/converterbase.hxx" -#include "oox/drawingml/theme.hxx" #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/drawing/FillStyle.hpp> #include <com/sun/star/drawing/LineStyle.hpp> -#include <comphelper/processfactory.hxx> +#include "oox/core/xmlfilterbase.hxx" +#include "oox/drawingml/theme.hxx" using ::rtl::OUString; using ::com::sun::star::uno::Reference; @@ -135,9 +135,9 @@ Reference< XInterface > ConverterRoot::createInstance( return xInt; } -Reference< XInterface > ConverterRoot::createInstance( const OUString& rServiceName ) +Reference< XInterface > ConverterRoot::createInstance( const OUString& rServiceName ) const { - return createInstance( ::comphelper::getProcessServiceFactory(), rServiceName ); + return createInstance( mxData->mrFilter.getGlobalFactory(), rServiceName ); } XmlFilterBase& ConverterRoot::getFilter() const diff --git a/oox/source/drawingml/chart/seriesconverter.cxx b/oox/source/drawingml/chart/seriesconverter.cxx index 9ed373e52b74..621108a2d019 100644 --- a/oox/source/drawingml/chart/seriesconverter.cxx +++ b/oox/source/drawingml/chart/seriesconverter.cxx @@ -8,7 +8,7 @@ * * $RCSfile: seriesconverter.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.4.6.2 $ * * This file is part of OpenOffice.org. * @@ -90,7 +90,7 @@ Reference< XLabeledDataSequence > lclCreateLabeledDataSequence( Reference< XLabeledDataSequence > xLabeledSeq; if( xValueSeq.is() || xTitleSeq.is() ) { - xLabeledSeq.set( ConverterRoot::createInstance( CREATE_OUSTRING( "com.sun.star.chart2.data.LabeledDataSequence" ) ), UNO_QUERY ); + xLabeledSeq.set( rParent.createInstance( CREATE_OUSTRING( "com.sun.star.chart2.data.LabeledDataSequence" ) ), UNO_QUERY ); if( xLabeledSeq.is() ) { xLabeledSeq->setValues( xValueSeq ); @@ -526,23 +526,27 @@ Reference< XDataSeries > SeriesConverter::createDataSeries( const TypeGroupConve ObjectType eObjType = rTypeGroup.getSeriesObjectType(); rFormatter.convertFrameFormatting( aSeriesProp, mrModel.mxShapeProp, eObjType, mrModel.mnIndex ); - // set the property default value used by the Chart2 templates (true for pie/doughnut charts) - aSeriesProp.setProperty( CREATE_OUSTRING( "VaryColorsByPoint" ), rTypeInfo.meTypeCategory == TYPECATEGORY_PIE ); + // set the (unused) property default value used by the Chart2 templates (true for pie/doughnut charts) + bool bIsPie = rTypeInfo.meTypeCategory == TYPECATEGORY_PIE; + aSeriesProp.setProperty( CREATE_OUSTRING( "VaryColorsByPoint" ), bIsPie ); + // own area formatting for every data point (TODO: varying line color not supported) - if( bVaryColorsByPoint && rTypeGroup.isSeriesFrameFormat() && ObjectFormatter::isAutomaticFill( mrModel.mxShapeProp ) ) + // #i91271# always set area formatting for every point in pie/doughnut charts to override their automatic point formatting + if( bIsPie || (bVaryColorsByPoint && rTypeGroup.isSeriesFrameFormat() && ObjectFormatter::isAutomaticFill( mrModel.mxShapeProp )) ) { /* Set the series point number as color cycle size at the object formatter to get correct start-shade/end-tint. TODO: in doughnut charts, the sizes of the series may vary, need to use the maximum point count of all series. */ sal_Int32 nOldMax = rFormatter.getMaxSeriesIndex(); - rFormatter.setMaxSeriesIndex( nDataPointCount - 1 ); + if( bVaryColorsByPoint ) + rFormatter.setMaxSeriesIndex( nDataPointCount - 1 ); for( sal_Int32 nIndex = 0; nIndex < nDataPointCount; ++nIndex ) { try { PropertySet aPointProp( xDataSeries->getDataPointByIndex( nIndex ) ); - rFormatter.convertAutomaticFill( aPointProp, eObjType, nIndex ); + rFormatter.convertAutomaticFill( aPointProp, eObjType, bVaryColorsByPoint ? nIndex : mrModel.mnIndex ); } catch( Exception& ) { diff --git a/oox/source/drawingml/customshapeproperties.cxx b/oox/source/drawingml/customshapeproperties.cxx index 340b61e59d3c..b6c440e63a3a 100644 --- a/oox/source/drawingml/customshapeproperties.cxx +++ b/oox/source/drawingml/customshapeproperties.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: customshapeproperties.cxx,v $ - * $Revision: 1.6 $ + * $Revision: 1.6.4.1 $ * * This file is part of OpenOffice.org. * @@ -28,7 +28,6 @@ * ************************************************************************/ -#include <comphelper/processfactory.hxx> #include "oox/drawingml/customshapeproperties.hxx" #include "oox/helper/helper.hxx" #include "oox/helper/propertyset.hxx" diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx index a051f4ec4a24..836b44621546 100644 --- a/oox/source/drawingml/fillproperties.cxx +++ b/oox/source/drawingml/fillproperties.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: fillproperties.cxx,v $ - * $Revision: 1.7 $ + * $Revision: 1.7.6.1 $ * * This file is part of OpenOffice.org. * @@ -115,8 +115,7 @@ const awt::DeviceInfo& lclGetDeviceInfo( const XmlFilterBase& rFilter ) { try { - Reference< lang::XMultiServiceFactory > xMSFT( rFilter.getServiceFactory(), UNO_QUERY_THROW ); - Reference< frame::XFramesSupplier > xDesktop( xMSFT->createInstance( + Reference< frame::XFramesSupplier > xDesktop( rFilter.getGlobalFactory()->createInstance( CREATE_OUSTRING( "com.sun.star.frame.Desktop" ) ), UNO_QUERY_THROW ); Reference< frame::XFrame > xFrame( xDesktop->getActiveFrame() ); Reference< awt::XWindow > xWindow( xFrame->getContainerWindow() ); diff --git a/oox/source/drawingml/fillpropertiesgroupcontext.cxx b/oox/source/drawingml/fillpropertiesgroupcontext.cxx index c326aac26e32..623762df7e4d 100644 --- a/oox/source/drawingml/fillpropertiesgroupcontext.cxx +++ b/oox/source/drawingml/fillpropertiesgroupcontext.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: fillpropertiesgroupcontext.cxx,v $ - * $Revision: 1.8 $ + * $Revision: 1.8.6.1 $ * * This file is part of OpenOffice.org. * @@ -299,8 +299,7 @@ void BlipFillPropertiesContext::endFastElement( sal_Int32 ) throw (SAXException, // load the fill bitmap into an XGraphic with the GraphicProvider static const OUString sGraphicProvider = CREATE_OUSTRING( "com.sun.star.graphic.GraphicProvider" ); - Reference< lang::XMultiServiceFactory > xMSFT( rFilter.getServiceFactory(), UNO_QUERY_THROW ); - Reference< graphic::XGraphicProvider > xGraphicProvider( xMSFT->createInstance( sGraphicProvider ), UNO_QUERY_THROW ); + Reference< graphic::XGraphicProvider > xGraphicProvider( rFilter.getGlobalFactory()->createInstance( sGraphicProvider ), UNO_QUERY_THROW ); static const OUString sInputStream = CREATE_OUSTRING( "InputStream" ); beans::PropertyValues aMediaProperties(1); diff --git a/oox/source/drawingml/graphicshapecontext.cxx b/oox/source/drawingml/graphicshapecontext.cxx index 18f3e12a30d8..ed41e31ea2e9 100644 --- a/oox/source/drawingml/graphicshapecontext.cxx +++ b/oox/source/drawingml/graphicshapecontext.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: graphicshapecontext.cxx,v $ - * $Revision: 1.8 $ + * $Revision: 1.8.6.1 $ * * This file is part of OpenOffice.org. * @@ -43,7 +43,6 @@ #include "oox/drawingml/chart/chartspacefragment.hxx" #include "oox/drawingml/chart/chartspacemodel.hxx" #include "tokens.hxx" -#include <comphelper/processfactory.hxx> #include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/io/XStream.hpp> #include <com/sun/star/beans/XPropertySet.hpp> @@ -207,9 +206,8 @@ PresentationOle2006Context::~PresentationOle2006Context() { try { - Reference< lang::XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory() ); Reference< io::XInputStream > xInputStream( rFilter.openInputStream( aGraphicURL ), UNO_QUERY_THROW ); - Reference< graphic::XGraphicProvider > xGraphicProvider( xMSF->createInstance( CREATE_OUSTRING( "com.sun.star.graphic.GraphicProvider" ) ), UNO_QUERY_THROW ); + Reference< graphic::XGraphicProvider > xGraphicProvider( rFilter.getGlobalFactory()->createInstance( CREATE_OUSTRING( "com.sun.star.graphic.GraphicProvider" ) ), UNO_QUERY_THROW ); Sequence< PropertyValue > aArgs( 1 ); const OUString sInputStream = CREATE_OUSTRING( "InputStream" ); aArgs[ 0 ].Name = sInputStream; diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index 568be03b6dae..6d2dcf0f677b 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: shape.cxx,v $ - * $Revision: 1.8 $ + * $Revision: 1.8.6.1 $ * * This file is part of OpenOffice.org. * @@ -360,10 +360,10 @@ Reference< XShape > Shape::createAndInsert( rxShapes->add( mxShape ); LineProperties aLineProperties; - aLineProperties.maLineFill.moFillType = XML_none; + aLineProperties.maLineFill.moFillType = XML_noFill; sal_Int32 nLinePhClr = -1; FillProperties aFillProperties; - aFillProperties.moFillType = XML_none; + aFillProperties.moFillType = XML_noFill; sal_Int32 nFillPhClr = -1; if( rxTheme.get() ) diff --git a/oox/source/drawingml/textbody.cxx b/oox/source/drawingml/textbody.cxx index 2e3d19a09542..61a478ff9644 100644 --- a/oox/source/drawingml/textbody.cxx +++ b/oox/source/drawingml/textbody.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: textbody.cxx,v $ - * $Revision: 1.7 $ + * $Revision: 1.7.6.1 $ * * This file is part of OpenOffice.org. * @@ -71,7 +71,6 @@ void TextBody::insertAt( while( aIter != rListStyle.end() ) { (*aIter)->getTextParagraphPropertyMap().dump_debug("TextParagraph paragraph props"); - (*aIter)->getTextCharacterProperties()->getTextCharacterPropertyMap().dump_debug("TextParagraph paragraph props"); aIter++; } } diff --git a/oox/source/drawingml/textparagraph.cxx b/oox/source/drawingml/textparagraph.cxx index 33f4c0302b80..383d02d987f3 100644 --- a/oox/source/drawingml/textparagraph.cxx +++ b/oox/source/drawingml/textparagraph.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: textparagraph.cxx,v $ - * $Revision: 1.7 $ + * $Revision: 1.7.6.1 $ * * This file is part of OpenOffice.org. * @@ -35,7 +35,6 @@ #include <com/sun/star/text/XText.hpp> #include <com/sun/star/text/XTextCursor.hpp> #include <com/sun/star/text/ControlCharacter.hpp> -#include <comphelper/processfactory.hxx> using ::rtl::OUString; using namespace ::com::sun::star::text; diff --git a/oox/source/drawingml/theme.cxx b/oox/source/drawingml/theme.cxx index 1a8b0049bd71..e1a7f634fa21 100644 --- a/oox/source/drawingml/theme.cxx +++ b/oox/source/drawingml/theme.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: theme.cxx,v $ - * $Revision: 1.5 $ + * $Revision: 1.5.6.1 $ * * This file is part of OpenOffice.org. * @@ -45,6 +45,39 @@ Theme::~Theme() { } +namespace { + +template< typename Type > +const Type* lclGetStyleElement( const RefVector< Type >& rVector, sal_Int32 nIndex ) +{ + return (rVector.empty() || (nIndex < 1)) ? 0 : + rVector.get( ::std::min( static_cast< sal_Int32 >( nIndex - 1 ), static_cast< sal_Int32 >( rVector.size() - 1 ) ) ).get(); +} + +} // namespace + +const FillProperties* Theme::getFillStyle( sal_Int32 nIndex ) const +{ + return (nIndex >= 1000) ? + lclGetStyleElement( maBgFillStyleList, nIndex - 1000 ) : + lclGetStyleElement( maFillStyleList, nIndex ); +} + +const LineProperties* Theme::getLineStyle( sal_Int32 nIndex ) const +{ + return lclGetStyleElement( maLineStyleList, nIndex ); +} + +const PropertyMap* Theme::getEffectStyle( sal_Int32 nIndex ) const +{ + return lclGetStyleElement( maEffectStyleList, nIndex ); +} + +const TextCharacterProperties* Theme::getFontStyle( sal_Int32 nSchemeType ) const +{ + return maFontScheme.get( nSchemeType ).get(); +} + const TextFont* Theme::resolveFont( const OUString& rName ) const { /* Resolves the following names: diff --git a/oox/source/dump/biffdumper.cxx b/oox/source/dump/biffdumper.cxx index 1b5491e9d82b..387775f209c1 100644 --- a/oox/source/dump/biffdumper.cxx +++ b/oox/source/dump/biffdumper.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: biffdumper.cxx,v $ - * $Revision: 1.5 $ + * $Revision: 1.5.20.26 $ * * This file is part of OpenOffice.org. * @@ -32,10 +32,8 @@ #include <osl/thread.h> #include <rtl/tencinfo.h> -#include <rtl/strbuf.hxx> -#include <com/sun/star/util/DateTime.hpp> -#include <com/sun/star/sheet/XSpreadsheetDocument.hpp> -#include "oox/dump/olestoragedumper.hxx" +#include "oox/dump/oledumper.hxx" +#include "oox/helper/olestorage.hxx" #include "oox/core/filterbase.hxx" #include "oox/xls/biffdetector.hxx" #include "oox/xls/biffinputstream.hxx" @@ -49,9 +47,9 @@ using ::rtl::OString; using ::rtl::OStringBuffer; using ::rtl::OStringToOUString; using ::com::sun::star::uno::Reference; -using ::com::sun::star::uno::UNO_QUERY; using ::com::sun::star::util::DateTime; -using ::com::sun::star::sheet::XSpreadsheetDocument; +using ::com::sun::star::lang::XMultiServiceFactory; +using ::com::sun::star::io::XInputStream; using ::oox::core::FilterBase; using namespace ::oox::xls; @@ -67,42 +65,31 @@ namespace { const sal_uInt16 BIFF_FONTFLAG_BOLD = 0x0001; const sal_uInt16 BIFF_FONTFLAG_ITALIC = 0x0002; -const sal_uInt32 BIFF_HYPERLINK_TARGET = 0x00000001; /// File name or URL. -const sal_uInt32 BIFF_HYPERLINK_ABS = 0x00000002; /// Absolute path. -const sal_uInt32 BIFF_HYPERLINK_DISPLAY = 0x00000014; /// Display string. -const sal_uInt32 BIFF_HYPERLINK_LOC = 0x00000008; /// Target location. -const sal_uInt32 BIFF_HYPERLINK_FRAME = 0x00000080; /// Target frame. -const sal_uInt32 BIFF_HYPERLINK_UNC = 0x00000100; /// UNC path. - -const sal_uInt16 BIFF_OBJPIO_MANUALSIZE = 0x0001; -const sal_uInt16 BIFF_OBJPIO_LINKED = 0x0002; -const sal_uInt16 BIFF_OBJPIO_SYMBOL = 0x0008; -const sal_uInt16 BIFF_OBJPIO_CONTROL = 0x0010; /// Form control. -const sal_uInt16 BIFF_OBJPIO_CTLSSTREAM = 0x0020; /// Data in Ctls stream. -const sal_uInt16 BIFF_OBJPIO_AUTOLOAD = 0x0200; - -const sal_uInt16 BIFF_OBJCMO_GROUP = 0x0000; -const sal_uInt16 BIFF_OBJCMO_LINE = 0x0001; -const sal_uInt16 BIFF_OBJCMO_RECTANGLE = 0x0002; -const sal_uInt16 BIFF_OBJCMO_ELLIPSE = 0x0003; -const sal_uInt16 BIFF_OBJCMO_ARC = 0x0004; -const sal_uInt16 BIFF_OBJCMO_CHART = 0x0005; -const sal_uInt16 BIFF_OBJCMO_TEXT = 0x0006; -const sal_uInt16 BIFF_OBJCMO_BUTTON = 0x0007; -const sal_uInt16 BIFF_OBJCMO_PICTURE = 0x0008; -const sal_uInt16 BIFF_OBJCMO_POLYGON = 0x0009; -const sal_uInt16 BIFF_OBJCMO_CHECKBOX = 0x000B; -const sal_uInt16 BIFF_OBJCMO_OPTIONBUTTON = 0x000C; -const sal_uInt16 BIFF_OBJCMO_EDIT = 0x000D; -const sal_uInt16 BIFF_OBJCMO_LABEL = 0x000E; -const sal_uInt16 BIFF_OBJCMO_DIALOG = 0x000F; -const sal_uInt16 BIFF_OBJCMO_SPIN = 0x0010; -const sal_uInt16 BIFF_OBJCMO_SCROLLBAR = 0x0011; -const sal_uInt16 BIFF_OBJCMO_LISTBOX = 0x0012; -const sal_uInt16 BIFF_OBJCMO_GROUPBOX = 0x0013; -const sal_uInt16 BIFF_OBJCMO_COMBOBOX = 0x0014; -const sal_uInt16 BIFF_OBJCMO_NOTE = 0x0019; -const sal_uInt16 BIFF_OBJCMO_DRAWING = 0x001E; +const sal_uInt16 BIFF_OBJTYPE_GROUP = 0; +const sal_uInt16 BIFF_OBJTYPE_LINE = 1; +const sal_uInt16 BIFF_OBJTYPE_RECTANGLE = 2; +const sal_uInt16 BIFF_OBJTYPE_OVAL = 3; +const sal_uInt16 BIFF_OBJTYPE_ARC = 4; +const sal_uInt16 BIFF_OBJTYPE_CHART = 5; +const sal_uInt16 BIFF_OBJTYPE_TEXT = 6; +const sal_uInt16 BIFF_OBJTYPE_BUTTON = 7; +const sal_uInt16 BIFF_OBJTYPE_PICTURE = 8; +const sal_uInt16 BIFF_OBJTYPE_POLYGON = 9; +const sal_uInt16 BIFF_OBJTYPE_CHECKBOX = 11; +const sal_uInt16 BIFF_OBJTYPE_OPTIONBUTTON = 12; +const sal_uInt16 BIFF_OBJTYPE_EDIT = 13; +const sal_uInt16 BIFF_OBJTYPE_LABEL = 14; +const sal_uInt16 BIFF_OBJTYPE_DIALOG = 15; +const sal_uInt16 BIFF_OBJTYPE_SPIN = 16; +const sal_uInt16 BIFF_OBJTYPE_SCROLLBAR = 17; +const sal_uInt16 BIFF_OBJTYPE_LISTBOX = 18; +const sal_uInt16 BIFF_OBJTYPE_GROUPBOX = 19; +const sal_uInt16 BIFF_OBJTYPE_DROPDOWN = 20; +const sal_uInt16 BIFF_OBJTYPE_NOTE = 25; +const sal_uInt16 BIFF_OBJTYPE_DRAWING = 30; + +const sal_uInt16 BIFF_OBJFLAGS_CONTROL = 0x0010; /// Form control. +const sal_uInt16 BIFF_OBJFLAGS_CTLSSTREAM = 0x0020; /// Data in Ctls stream. const sal_uInt16 BIFF_STYLE_BUILTIN = 0x8000; @@ -113,71 +100,81 @@ const sal_uInt16 BIFF_PT_NOSTRING = 0xFFFF; // ============================================================================ // ============================================================================ -class BiffStreamInput : public Input -{ -public: - inline explicit BiffStreamInput( BiffInputStream& rStrm ) : mrStrm( rStrm ) {} - virtual ~BiffStreamInput(); +namespace { - virtual sal_Int64 getSize() const; - virtual sal_Int64 tell() const; - virtual void seek( sal_Int64 nPos ); - virtual void skip( sal_Int32 nBytes ); - virtual sal_Int32 read( void* pBuffer, sal_Int32 nBytes ); +void lclDumpDffClientPos( Output& rOut, BinaryInputStream& rStrm, const String& rName, sal_uInt16 nSubScale ) +{ + MultiItemsGuard aMultiGuard( rOut ); + TableGuard aTabGuard( rOut, 17 ); + { + sal_uInt16 nPos = rStrm.readuInt16(); + ItemGuard aItem( rOut, rName ); + rOut.writeDec( nPos ); + } + { + sal_uInt16 nSubUnits = rStrm.readuInt16(); + ItemGuard aItem( rOut, "sub-units" ); + rOut.writeDec( nSubUnits ); + rOut.writeChar( '/' ); + rOut.writeDec( nSubScale ); + } +} - virtual BiffStreamInput& operator>>( sal_Int8& rnData ); - virtual BiffStreamInput& operator>>( sal_uInt8& rnData ); - virtual BiffStreamInput& operator>>( sal_Int16& rnData ); - virtual BiffStreamInput& operator>>( sal_uInt16& rnData ); - virtual BiffStreamInput& operator>>( sal_Int32& rnData ); - virtual BiffStreamInput& operator>>( sal_uInt32& rnData ); - virtual BiffStreamInput& operator>>( float& rfData ); - virtual BiffStreamInput& operator>>( double& rfData ); +void lclDumpDffClientRect( Output& rOut, BinaryInputStream& rStrm ) +{ + lclDumpDffClientPos( rOut, rStrm, "start-col", 1024 ); + lclDumpDffClientPos( rOut, rStrm, "start-row", 256 ); + lclDumpDffClientPos( rOut, rStrm, "end-col", 1024 ); + lclDumpDffClientPos( rOut, rStrm, "end-row", 256 ); +} -private: - BiffInputStream& mrStrm; -}; +} // namespace // ---------------------------------------------------------------------------- -BiffStreamInput::~BiffStreamInput() +BiffDffStreamObject::BiffDffStreamObject( const OutputObjectBase& rParent, const BinaryInputStreamRef& rxStrm ) { + DffStreamObject::construct( rParent, rxStrm ); } -sal_Int64 BiffStreamInput::getSize() const +void BiffDffStreamObject::implDumpClientAnchor() { - return mrStrm.getRecSize(); + dumpHex< sal_uInt16 >( "flags", "DFF-CLIENTANCHOR-FLAGS" ); + lclDumpDffClientRect( out(), in() ); } -sal_Int64 BiffStreamInput::tell() const -{ - return mrStrm.getRecPos(); -} +// ============================================================================ -void BiffStreamInput::seek( sal_Int64 nPos ) +BiffCtlsStreamObject::BiffCtlsStreamObject( const OutputObjectBase& rParent, const BinaryInputStreamRef& rxStrm ) { - mrStrm.seek( static_cast< sal_uInt32 >( nPos ) ); + InputObjectBase::construct( rParent, rxStrm ); + mnStartPos = mnLength = 0; } -void BiffStreamInput::skip( sal_Int32 nBytes ) +void BiffCtlsStreamObject::dumpControl( sal_uInt32 nStartPos, sal_uInt32 nLength ) { - mrStrm.skip( static_cast< sal_uInt32 >( nBytes ) ); + mnStartPos = nStartPos; + mnLength = nLength; + dump(); + mnStartPos = mnLength = 0; } -sal_Int32 BiffStreamInput::read( void* pBuffer, sal_Int32 nSize ) +void BiffCtlsStreamObject::implDump() { - return static_cast< sal_Int32 >( mrStrm.read( pBuffer, static_cast< sal_uInt32 >( nSize ) ) ); + if( mnLength > 0 ) + { + out().emptyLine(); + writeEmptyItem( "CTLS-START" ); + { + IndentGuard aIndGuard( out() ); + in().seek( mnStartPos ); + OcxGuidControlObject( *this, mnLength ).dump(); + } + writeEmptyItem( "CTLS-END" ); + out().emptyLine(); + } } -BiffStreamInput& BiffStreamInput::operator>>( sal_Int8& rnData ) { mrStrm >> rnData; return *this; } -BiffStreamInput& BiffStreamInput::operator>>( sal_uInt8& rnData ) { mrStrm >> rnData; return *this; } -BiffStreamInput& BiffStreamInput::operator>>( sal_Int16& rnData ) { mrStrm >> rnData; return *this; } -BiffStreamInput& BiffStreamInput::operator>>( sal_uInt16& rnData ) { mrStrm >> rnData; return *this; } -BiffStreamInput& BiffStreamInput::operator>>( sal_Int32& rnData ) { mrStrm >> rnData; return *this; } -BiffStreamInput& BiffStreamInput::operator>>( sal_uInt32& rnData ) { mrStrm >> rnData; return *this; } -BiffStreamInput& BiffStreamInput::operator>>( float& rfData ) { mrStrm >> rfData; return *this; } -BiffStreamInput& BiffStreamInput::operator>>( double& rfData ) { mrStrm >> rfData; return *this; } - // ============================================================================ // ============================================================================ @@ -220,8 +217,11 @@ BiffSharedData::BiffSharedData( BiffType eBiff ) : { } -BiffSharedData::~BiffSharedData() +void BiffSharedData::initializePerSheet() { + maFontEncs.clear(); + maXfFontIds.clear(); + meTextEnc = osl_getThreadTextEncoding(); } void BiffSharedData::setTextEncoding( rtl_TextEncoding eTextEnc ) @@ -270,32 +270,32 @@ bool BiffSharedData::implIsValid() const // ============================================================================ -BiffObjectBase::BiffObjectBase() -{ -} - BiffObjectBase::~BiffObjectBase() { } -void BiffObjectBase::construct( const ObjectBase& rParent, const OUString& rOutFileName, BinaryInputStreamRef xStrm, BiffType eBiff ) +void BiffObjectBase::construct( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, BiffType eBiff, const OUString& rSysFileName ) { - if( eBiff != BIFF_UNKNOWN ) + if( rParent.isValid() && rxStrm.get() && (eBiff != BIFF_UNKNOWN) ) { - InputStreamObject::construct( rParent, rOutFileName, xStrm ); - if( InputStreamObject::implIsValid() ) - { - mxBiffData.reset( new BiffSharedData( eBiff ) ); - mxStrm.reset( new BiffInputStream( getStream() ) ); - reconstructConfig(); - reconstructInput(); - } - if( BiffObjectBase::implIsValid() ) + mxBiffData.reset( new BiffSharedData( eBiff ) ); + mxBiffStrm.reset( new BiffInputStream( *rxStrm ) ); + RecordObjectBase::construct( rParent, rxStrm, rSysFileName, mxBiffStrm, "RECORD-NAMES", "SIMPLE-RECORDS" ); + if( RecordObjectBase::implIsValid() ) { + reconstructConfig( ConfigRef( new BiffConfig( cfg(), eBiff ) ) ); + mxDffObj.reset( new BiffDffStreamObject( *this, mxBiffStrm ) ); + if( StorageBase* pRootStrg = cfg().getRootStorage().get() ) + { + BinaryInputStreamRef xCtlsStrm( new BinaryXInputStream( pRootStrg->openInputStream( CREATE_OUSTRING( "Ctls" ) ), true ) ); + mxCtlsObj.reset( new BiffCtlsStreamObject( *this, xCtlsStrm ) ); + } const Config& rCfg = cfg(); mxErrCodes = rCfg.getNameList( "ERRORCODES" ); mxConstType = rCfg.getNameList( "CONSTVALUE-TYPE" ); mxResultType = rCfg.getNameList( "FORMULA-RESULTTYPE" ); + mnLastRecId = BIFF_ID_UNKNOWN; + mbMergeContRec = rCfg.getBoolOption( "merge-continue-record", true ); } } } @@ -307,21 +307,52 @@ void BiffObjectBase::construct( const BiffObjectBase& rParent ) bool BiffObjectBase::implIsValid() const { - return isValid( mxBiffCfg ) && isValid( mxBiffData ) && mxStrm.get() && InputStreamObject::implIsValid(); + return isValid( mxBiffData ) && mxBiffStrm.get() && isValid( mxDffObj ) && InputObjectBase::implIsValid(); } -ConfigRef BiffObjectBase::implReconstructConfig() +bool BiffObjectBase::implStartRecord( BinaryInputStream&, sal_Int64& ornRecPos, sal_Int64& ornRecId, sal_Int64& ornRecSize ) { - mxBiffCfg.reset( new BiffConfig( cfg(), getBiff() ) ); - return mxBiffCfg; -} + // previous record + mnLastRecId = mxBiffStrm->getRecId(); + switch( mnLastRecId ) + { + case BIFF_ID_CHBEGIN: + out().incIndent(); + break; + } -InputRef BiffObjectBase::implReconstructInput() -{ - InputRef xIn; - if( mxStrm.get() ) - xIn.reset( new BiffStreamInput( *mxStrm ) ); - return xIn; + // start next record + bool bValid = mxBiffStrm->startNextRecord(); + ornRecPos = mxBiffStrm->tellBase() - 4; + ornRecId = mxBiffStrm->getRecId(); + + // record specific settings + switch( mxBiffStrm->getRecId() ) + { + case BIFF_ID_CHEND: + out().decIndent(); + break; + } + + // special CONTINUE handling + mxBiffStrm->resetRecord( mbMergeContRec ); + if( mbMergeContRec ) switch( mxBiffStrm->getRecId() ) + { + case BIFF_ID_OBJ: + case BIFF_ID_TXO: + case BIFF_ID_EOF: + case BIFF_ID_CONT: + mxBiffStrm->resetRecord( false ); + break; + case BIFF_ID_MSODRAWINGGROUP: + case BIFF_ID_CHESCHERFORMAT: + mxBiffStrm->resetRecord( true, mxBiffStrm->getRecId() ); + break; + } + + ornRecSize = mxBiffStrm->getLength(); + mxBiffStrm->enableNulChars( true ); + return bValid; } OUString BiffObjectBase::getErrorName( sal_uInt8 nErrCode ) const @@ -333,12 +364,12 @@ OUString BiffObjectBase::getErrorName( sal_uInt8 nErrCode ) const sal_Int32 BiffObjectBase::readCol( bool bCol16Bit ) { - return bCol16Bit ? mxStrm->readuInt16() : mxStrm->readuInt8(); + return bCol16Bit ? mxBiffStrm->readuInt16() : mxBiffStrm->readuInt8(); } sal_Int32 BiffObjectBase::readRow( bool bRow32Bit ) { - return bRow32Bit ? mxStrm->readInt32() : mxStrm->readuInt16(); + return bRow32Bit ? mxBiffStrm->readInt32() : mxBiffStrm->readuInt16(); } void BiffObjectBase::readAddress( Address& orAddress, bool bCol16Bit, bool bRow32Bit ) @@ -358,22 +389,22 @@ void BiffObjectBase::readRange( Range& orRange, bool bCol16Bit, bool bRow32Bit ) void BiffObjectBase::readRangeList( RangeList& orRanges, bool bCol16Bit, bool bRow32Bit ) { sal_uInt16 nCount; - *mxStrm >> nCount; + *mxBiffStrm >> nCount; orRanges.resize( nCount ); - for( RangeList::iterator aIt = orRanges.begin(), aEnd = orRanges.end(); mxStrm->isValid() && (aIt != aEnd); ++aIt ) + for( RangeList::iterator aIt = orRanges.begin(), aEnd = orRanges.end(); !mxBiffStrm->isEof() && (aIt != aEnd); ++aIt ) readRange( *aIt, bCol16Bit, bRow32Bit ); } // ---------------------------------------------------------------------------- -void BiffObjectBase::writeBooleanItem( const sal_Char* pcName, sal_uInt8 nBool ) +void BiffObjectBase::writeBooleanItem( const String& rName, sal_uInt8 nBool ) { - writeDecItem( pcName, nBool, "BOOLEAN" ); + writeDecItem( rName, nBool, "BOOLEAN" ); } -void BiffObjectBase::writeErrorCodeItem( const sal_Char* pcName, sal_uInt8 nErrCode ) +void BiffObjectBase::writeErrorCodeItem( const String& rName, sal_uInt8 nErrCode ) { - writeHexItem( pcName, nErrCode, mxErrCodes ); + writeHexItem( rName, nErrCode, mxErrCodes ); } void BiffObjectBase::writeFontPortions( const BinFontPortionList& rPortions ) @@ -393,15 +424,15 @@ void BiffObjectBase::writeFontPortions( const BinFontPortionList& rPortions ) // ---------------------------------------------------------------------------- -OUString BiffObjectBase::dumpByteString( const sal_Char* pcName, BiffStringFlags nFlags, rtl_TextEncoding eDefaultTextEnc ) +OUString BiffObjectBase::dumpByteString( const String& rName, BiffStringFlags nFlags, rtl_TextEncoding eDefaultTextEnc ) { OSL_ENSURE( !getFlag( nFlags, static_cast< BiffStringFlags >( ~(BIFF_STR_8BITLENGTH | BIFF_STR_EXTRAFONTS) ) ), "BiffObjectBase::dumpByteString - unknown flag" ); bool b8BitLength = getFlag( nFlags, BIFF_STR_8BITLENGTH ); - OString aString = mxStrm->readByteString( !b8BitLength ); + OString aString = mxBiffStrm->readByteString( !b8BitLength ); BinFontPortionList aPortions; if( getFlag( nFlags, BIFF_STR_EXTRAFONTS ) ) - aPortions.importPortions( *mxStrm, false ); + aPortions.importPortions( *mxBiffStrm, false ); // create string portions OUStringBuffer aBuffer; @@ -434,29 +465,29 @@ OUString BiffObjectBase::dumpByteString( const sal_Char* pcName, BiffStringFlags } OUString aUniStr = aBuffer.makeStringAndClear(); - writeStringItem( pcName ? pcName : "text", aUniStr ); + writeStringItem( rName( "text" ), aUniStr ); return aUniStr; } -OUString BiffObjectBase::dumpUniString( const sal_Char* pcName, BiffStringFlags nFlags ) +OUString BiffObjectBase::dumpUniString( const String& rName, BiffStringFlags nFlags ) { OSL_ENSURE( !getFlag( nFlags, static_cast< BiffStringFlags >( ~(BIFF_STR_8BITLENGTH | BIFF_STR_SMARTFLAGS) ) ), "BiffObjectBase::dumpUniString - unknown flag" ); bool b8BitLength = getFlag( nFlags, BIFF_STR_8BITLENGTH ); // --- string header --- - sal_uInt16 nChars = b8BitLength ? mxStrm->readuInt8() : mxStrm->readuInt16(); + sal_uInt16 nChars = b8BitLength ? mxBiffStrm->readuInt8() : mxBiffStrm->readuInt16(); sal_uInt8 nFlagField = 0; if( (nChars > 0) || !getFlag( nFlags, BIFF_STR_SMARTFLAGS ) ) - *mxStrm >> nFlagField; + *mxBiffStrm >> nFlagField; bool b16Bit = getFlag( nFlagField, BIFF_STRF_16BIT ); bool bFonts = getFlag( nFlagField, BIFF_STRF_RICH ); bool bPhonetic = getFlag( nFlagField, BIFF_STRF_PHONETIC ); - sal_uInt16 nFontCount = bFonts ? mxStrm->readuInt16() : 0; - sal_uInt32 nPhoneticSize = bPhonetic ? mxStrm->readuInt32() : 0; + sal_uInt16 nFontCount = bFonts ? mxBiffStrm->readuInt16() : 0; + sal_uInt32 nPhoneticSize = bPhonetic ? mxBiffStrm->readuInt32() : 0; // --- character array --- - OUString aString = mxStrm->readUniStringChars( nChars, b16Bit ); - writeStringItem( pcName ? pcName : "text", aString ); + OUString aString = mxBiffStrm->readUniStringChars( nChars, b16Bit ); + writeStringItem( rName( "text" ), aString ); // --- formatting --- // #122185# bRich flag may be set, but format runs may be missing @@ -464,7 +495,7 @@ OUString BiffObjectBase::dumpUniString( const sal_Char* pcName, BiffStringFlags { IndentGuard aIndGuard( out() ); BinFontPortionList aPortions; - aPortions.importPortions( *mxStrm, nFontCount, true ); + aPortions.importPortions( *mxBiffStrm, nFontCount, BIFF_FONTPORTION_16BIT ); writeFontPortions( aPortions ); } @@ -479,101 +510,39 @@ OUString BiffObjectBase::dumpUniString( const sal_Char* pcName, BiffStringFlags return aString; } -OUString BiffObjectBase::dumpString( const sal_Char* pcName, BiffStringFlags nByteFlags, BiffStringFlags nUniFlags, rtl_TextEncoding eDefaultTextEnc ) +OUString BiffObjectBase::dumpString( const String& rName, BiffStringFlags nByteFlags, BiffStringFlags nUniFlags, rtl_TextEncoding eDefaultTextEnc ) { - return (getBiff() == BIFF8) ? dumpUniString( pcName, nUniFlags ) : dumpByteString( pcName, nByteFlags, eDefaultTextEnc ); + return (getBiff() == BIFF8) ? dumpUniString( rName, nUniFlags ) : dumpByteString( rName, nByteFlags, eDefaultTextEnc ); } -OUString BiffObjectBase::dumpOleString( const sal_Char* pcName, sal_Int32 nCharCount, bool bUnicode ) -{ - OUString aString; - if( nCharCount > 0 ) - { - sal_uInt16 nReadChars = getLimitedValue< sal_uInt16, sal_Int32 >( nCharCount, 0, SAL_MAX_UINT16 ); - aString = bUnicode ? - mxStrm->readUnicodeArray( nReadChars ) : - mxStrm->readCharArray( nReadChars, getBiffData().getTextEncoding() ); - // skip remaining chars - sal_uInt32 nSkip = static_cast< sal_uInt32 >( nCharCount - nReadChars ); - mxStrm->skip( bUnicode ? (nSkip * 2) : nSkip ); - } - writeStringItem( pcName ? pcName : "text", aString ); - return aString; -} - -OUString BiffObjectBase::dumpOleString( const sal_Char* pcName, bool bUnicode ) -{ - return dumpOleString( pcName, mxStrm->readInt32(), bUnicode ); -} - -OUString BiffObjectBase::dumpNullString( const sal_Char* pcName, bool bUnicode ) -{ - OUString aString; - if( bUnicode ) - { - OUStringBuffer aBuffer; - sal_uInt16 nChar; - for( bool bLoop = true; bLoop && mxStrm->isValid(); ) - { - *mxStrm >> nChar; - if( (bLoop = (nChar != 0)) == true ) - aBuffer.append( static_cast< sal_Unicode >( nChar ) ); - } - aString = aBuffer.makeStringAndClear(); - } - else - { - OStringBuffer aBuffer; - sal_uInt8 nChar; - for( bool bLoop = true; bLoop && mxStrm->isValid(); ) - { - *mxStrm >> nChar; - if( (bLoop = (nChar != 0)) == true ) - aBuffer.append( static_cast< sal_Char >( nChar ) ); - } - aString = OStringToOUString( aBuffer.makeStringAndClear(), getBiffData().getTextEncoding() ); - } - writeStringItem( pcName ? pcName : "text", aString ); - return aString; -} - -sal_uInt8 BiffObjectBase::dumpBoolean( const sal_Char* pcName ) +sal_uInt8 BiffObjectBase::dumpBoolean( const String& rName ) { sal_uInt8 nBool; - *mxStrm >> nBool; - writeBooleanItem( pcName ? pcName : "boolean", nBool ); + *mxBiffStrm >> nBool; + writeBooleanItem( rName( "boolean" ), nBool ); return nBool; } -sal_uInt8 BiffObjectBase::dumpErrorCode( const sal_Char* pcName ) +sal_uInt8 BiffObjectBase::dumpErrorCode( const String& rName ) { sal_uInt8 nErrCode; - *mxStrm >> nErrCode; - writeErrorCodeItem( pcName ? pcName : "errorcode", nErrCode ); + *mxBiffStrm >> nErrCode; + writeErrorCodeItem( rName( "error-code" ), nErrCode ); return nErrCode; } -sal_Int32 BiffObjectBase::dumpRgbColor( const sal_Char* pcName ) -{ - sal_uInt8 nR, nG, nB, nA; - *mxStrm >> nR >> nG >> nB >> nA; - sal_Int32 nValue = (nA << 24) | (nR << 16) | (nG << 8) | nB; - writeColorItem( pcName ? pcName : "color-rgb", nValue ); - return nValue; -} - -rtl_TextEncoding BiffObjectBase::dumpCodePage( const sal_Char* pcName ) +rtl_TextEncoding BiffObjectBase::dumpCodePage( const String& rName ) { - sal_uInt16 nCodePage = dumpDec< sal_uInt16 >( pcName ? pcName : "codepage", "CODEPAGES" ); + sal_uInt16 nCodePage = dumpDec< sal_uInt16 >( rName( "codepage" ), "CODEPAGES" ); return BiffHelper::calcTextEncodingFromCodePage( nCodePage ); } -void BiffObjectBase::dumpFormulaResult( const sal_Char* pcName ) +void BiffObjectBase::dumpFormulaResult( const String& rName ) { MultiItemsGuard aMultiGuard( out() ); sal_uInt8 pnResult[ 8 ]; - mxStrm->read( pnResult, 8 ); - writeArrayItem( pcName ? pcName : "result", pnResult, 8 ); + mxBiffStrm->readMemory( pnResult, 8 ); + writeArrayItem( rName( "result" ), pnResult, 8 ); if( (pnResult[ 6 ] == 0xFF) && (pnResult[ 7 ] == 0xFF) ) { sal_uInt8 nType = pnResult[ 0 ]; @@ -593,57 +562,57 @@ void BiffObjectBase::dumpFormulaResult( const sal_Char* pcName ) } } -sal_Int32 BiffObjectBase::dumpColIndex( const sal_Char* pcName, bool bCol16Bit ) +sal_Int32 BiffObjectBase::dumpColIndex( const String& rName, bool bCol16Bit ) { sal_Int32 nCol = readCol( bCol16Bit ); - writeColIndexItem( pcName ? pcName : "col-idx", nCol ); + writeColIndexItem( rName( "col-idx" ), nCol ); return nCol; } -sal_Int32 BiffObjectBase::dumpRowIndex( const sal_Char* pcName, bool bRow32Bit ) +sal_Int32 BiffObjectBase::dumpRowIndex( const String& rName, bool bRow32Bit ) { sal_Int32 nRow = readRow( bRow32Bit ); - writeRowIndexItem( pcName ? pcName : "row-idx", nRow ); + writeRowIndexItem( rName( "row-idx" ), nRow ); return nRow; } -sal_Int32 BiffObjectBase::dumpColRange( const sal_Char* pcName, bool bCol16Bit ) +sal_Int32 BiffObjectBase::dumpColRange( const String& rName, bool bCol16Bit ) { sal_Int32 nCol1 = readCol( bCol16Bit ); sal_Int32 nCol2 = readCol( bCol16Bit ); - writeColRangeItem( pcName ? pcName : "col-range", nCol1, nCol2 ); + writeColRangeItem( rName( "col-range" ), nCol1, nCol2 ); return nCol2 - nCol1 + 1; } -sal_Int32 BiffObjectBase::dumpRowRange( const sal_Char* pcName, bool bRow32Bit ) +sal_Int32 BiffObjectBase::dumpRowRange( const String& rName, bool bRow32Bit ) { sal_Int32 nRow1 = readRow( bRow32Bit ); sal_Int32 nRow2 = readRow( bRow32Bit ); - writeRowRangeItem( pcName ? pcName : "row-range", nRow1, nRow2 ); + writeRowRangeItem( rName( "row-range" ), nRow1, nRow2 ); return nRow2 - nRow1 + 1; } -Address BiffObjectBase::dumpAddress( const sal_Char* pcName, bool bCol16Bit, bool bRow32Bit ) +Address BiffObjectBase::dumpAddress( const String& rName, bool bCol16Bit, bool bRow32Bit ) { Address aPos; readAddress( aPos, bCol16Bit, bRow32Bit ); - writeAddressItem( pcName ? pcName : "addr", aPos ); + writeAddressItem( rName( "addr" ), aPos ); return aPos; } -Range BiffObjectBase::dumpRange( const sal_Char* pcName, bool bCol16Bit, bool bRow32Bit ) +Range BiffObjectBase::dumpRange( const String& rName, bool bCol16Bit, bool bRow32Bit ) { Range aRange; readRange( aRange, bCol16Bit, bRow32Bit ); - writeRangeItem( pcName ? pcName : "range", aRange ); + writeRangeItem( rName( "range" ), aRange ); return aRange; } -void BiffObjectBase::dumpRangeList( const sal_Char* pcName, bool bCol16Bit, bool bRow32Bit ) +void BiffObjectBase::dumpRangeList( const String& rName, bool bCol16Bit, bool bRow32Bit ) { RangeList aRanges; readRangeList( aRanges, bCol16Bit, bRow32Bit ); - writeRangeListItem( pcName ? pcName : "range-list", aRanges ); + writeRangeListItem( rName( "range-list" ), aRanges ); } void BiffObjectBase::dumpConstArrayHeader( sal_uInt32& rnCols, sal_uInt32& rnRows ) @@ -702,11 +671,40 @@ OUString BiffObjectBase::dumpConstValue( sal_Unicode cStrQuote ) return aValue.makeStringAndClear(); } +sal_uInt16 BiffObjectBase::dumpRepeatedRecId() +{ + return dumpHex< sal_uInt16 >( "repeated-rec-id", getRecNames() ); +} + +void BiffObjectBase::dumpDffClientRect() +{ + lclDumpDffClientRect( out(), in() ); +} + +void BiffObjectBase::dumpEmbeddedDff() +{ + out().decIndent(); + writeEmptyItem( "EMBEDDED-DFF-START" ); + out().incIndent(); + mxDffObj->dump(); + out().emptyLine(); + out().decIndent(); + writeEmptyItem( "EMBEDDED-DFF-END" ); + out().incIndent(); +} + +void BiffObjectBase::dumpOcxControl() +{ + sal_uInt32 nStartPos = dumpHex< sal_uInt32 >( "ctls-stream-pos", "CONV-DEC" ); + sal_uInt32 nLength = dumpHex< sal_uInt32 >( "ctls-stream-length", "CONV-DEC" ); + if( isValid( mxCtlsObj ) ) + mxCtlsObj->dumpControl( nStartPos, nLength ); +} + // ============================================================================ // ============================================================================ FormulaObject::FormulaObject( const BiffObjectBase& rParent ) : - mpcName( 0 ), mnSize( 0 ) { BiffObjectBase::construct( rParent ); @@ -722,46 +720,45 @@ sal_uInt16 FormulaObject::readFormulaSize() return (getBiff() == BIFF2) ? getBiffStream().readuInt8() : getBiffStream().readuInt16(); } -sal_uInt16 FormulaObject::dumpFormulaSize( const sal_Char* pcName ) +sal_uInt16 FormulaObject::dumpFormulaSize( const String& rName ) { - if( !pcName ) pcName = "formula-size"; sal_uInt16 nSize = readFormulaSize(); - writeDecItem( pcName, nSize ); + writeDecItem( rName( "formula-size" ), nSize ); return nSize; } -void FormulaObject::dumpCellFormula( const sal_Char* pcName, sal_uInt16 nSize ) +void FormulaObject::dumpCellFormula( const String& rName, sal_uInt16 nSize ) { - dumpFormula( pcName, nSize, false ); + dumpFormula( rName, nSize, false ); } -void FormulaObject::dumpCellFormula( const sal_Char* pcName ) +void FormulaObject::dumpCellFormula( const String& rName ) { - dumpFormula( pcName, false ); + dumpFormula( rName, false ); } -void FormulaObject::dumpNameFormula( const sal_Char* pcName, sal_uInt16 nSize ) +void FormulaObject::dumpNameFormula( const String& rName, sal_uInt16 nSize ) { - dumpFormula( pcName, nSize, true ); + dumpFormula( rName, nSize, true ); } -void FormulaObject::dumpNameFormula( const sal_Char* pcName ) +void FormulaObject::dumpNameFormula( const String& rName ) { - dumpFormula( pcName, true ); + dumpFormula( rName, true ); } void FormulaObject::implDump() { { MultiItemsGuard aMultiGuard( out() ); - writeEmptyItem( mpcName ); + writeEmptyItem( maName ); writeDecItem( "formula-size", mnSize ); } if( mnSize == 0 ) return; - Input& rIn = in(); - sal_Int64 nStartPos = rIn.tell(); - sal_Int64 nEndPos = ::std::min< sal_Int64 >( nStartPos + mnSize, rIn.getSize() ); + BinaryInputStream& rStrm = in(); + sal_Int64 nStartPos = rStrm.tell(); + sal_Int64 nEndPos = ::std::min< sal_Int64 >( nStartPos + mnSize, rStrm.getLength() ); bool bValid = mxTokens.get(); mxStack.reset( new FormulaStack ); @@ -769,11 +766,11 @@ void FormulaObject::implDump() IndentGuard aIndGuard( out() ); { TableGuard aTabGuard( out(), 8, 18 ); - while( bValid && (rIn.tell() < nEndPos) ) + while( bValid && !rStrm.isEof() && (rStrm.tell() < nEndPos) ) { MultiItemsGuard aMultiGuard( out() ); - writeHexItem( 0, static_cast< sal_uInt16 >( rIn.tell() - nStartPos ) ); - sal_uInt8 nTokenId = dumpHex< sal_uInt8 >( 0, mxTokens ); + writeHexItem( EMPTY_STRING, static_cast< sal_uInt16 >( rStrm.tell() - nStartPos ) ); + sal_uInt8 nTokenId = dumpHex< sal_uInt8 >( EMPTY_STRING, mxTokens ); bValid = mxTokens->hasName( nTokenId ); if( bValid ) { @@ -850,7 +847,7 @@ void FormulaObject::implDump() } } } - bValid = nEndPos == rIn.tell(); + bValid = nEndPos == rStrm.tell(); if( bValid ) { dumpAddTokenData(); @@ -858,23 +855,23 @@ void FormulaObject::implDump() writeInfoItem( "classes", mxStack->getClassesString() ); } else - dumpBinary( OOX_DUMP_ERRASCII( "formula-error" ), static_cast< sal_Int32 >( nEndPos - rIn.tell() ), false ); + dumpBinary( OOX_DUMP_ERRASCII( "formula-error" ), nEndPos - rStrm.tell(), false ); - mpcName = 0; mnSize = 0; } -void FormulaObject::dumpFormula( const sal_Char* pcName, sal_uInt16 nSize, bool bNameMode ) +void FormulaObject::dumpFormula( const String& rName, sal_uInt16 nSize, bool bNameMode ) { - mpcName = pcName ? pcName : "formula"; + maName = rName( "formula" ); mnSize = nSize; mbNameMode = bNameMode; dump(); + mnSize = 0; } -void FormulaObject::dumpFormula( const sal_Char* pcName, bool bNameMode ) +void FormulaObject::dumpFormula( const String& rName, bool bNameMode ) { - dumpFormula( pcName, readFormulaSize(), bNameMode ); + dumpFormula( rName, readFormulaSize(), bNameMode ); } // private -------------------------------------------------------------------- @@ -883,8 +880,7 @@ void FormulaObject::constructFmlaObj() { if( BiffObjectBase::implIsValid() ) { - Reference< XSpreadsheetDocument > xDocument( getFilter().getModel(), UNO_QUERY ); - mxFuncProv.reset( new FunctionProvider( xDocument, getBiff(), true ) ); + mxFuncProv.reset( new FunctionProvider( FILTER_BIFF, getBiff(), true ) ); Config& rCfg = cfg(); mxClasses = rCfg.getNameList( "TOKENCLASSES" ); @@ -976,13 +972,13 @@ OUString FormulaObject::createPlaceHolder() const sal_uInt16 FormulaObject::readFuncId() { - return (getBiff() >= BIFF4) ? in().readValue< sal_uInt16 >() : in().readValue< sal_uInt8 >(); + return (getBiff() >= BIFF4) ? in().readuInt16() : in().readuInt8(); } OUString FormulaObject::writeFuncIdItem( sal_uInt16 nFuncId, const FunctionInfo** oppFuncInfo ) { ItemGuard aItemGuard( out(), "func-id" ); - writeHexItem( 0, nFuncId, "FUNCID" ); + writeHexItem( EMPTY_STRING, nFuncId, "FUNCID" ); OUStringBuffer aBuffer; const FunctionInfo* pFuncInfo = mxFuncProv->getFuncInfoFromBiffFuncId( nFuncId ); if( pFuncInfo ) @@ -995,34 +991,36 @@ OUString FormulaObject::writeFuncIdItem( sal_uInt16 nFuncId, const FunctionInfo* } OUString aFuncName = aBuffer.makeStringAndClear(); aItemGuard.cont(); + out().writeChar( OOX_DUMP_STRQUOTE ); out().writeString( aFuncName ); + out().writeChar( OOX_DUMP_STRQUOTE ); if( oppFuncInfo ) *oppFuncInfo = pFuncInfo; return aFuncName; } -sal_uInt16 FormulaObject::dumpTokenCol( const sal_Char* pcName, bool& rbRelC, bool& rbRelR ) +sal_uInt16 FormulaObject::dumpTokenCol( const String& rName, bool& rbRelC, bool& rbRelR ) { sal_uInt16 nCol = 0; if( getBiff() == BIFF8 ) { - nCol = dumpHex< sal_uInt16 >( pcName, mxRelFlags ); + nCol = dumpHex< sal_uInt16 >( rName, mxRelFlags ); rbRelC = getFlag( nCol, BIFF_TOK_REF_COLREL ); rbRelR = getFlag( nCol, BIFF_TOK_REF_ROWREL ); nCol &= BIFF_TOK_REF_COLMASK; } else - nCol = dumpDec< sal_uInt8 >( pcName ); + nCol = dumpDec< sal_uInt8 >( rName ); return nCol; } -sal_uInt16 FormulaObject::dumpTokenRow( const sal_Char* pcName, bool& rbRelC, bool& rbRelR ) +sal_uInt16 FormulaObject::dumpTokenRow( const String& rName, bool& rbRelC, bool& rbRelR ) { sal_uInt16 nRow = 0; if( getBiff() == BIFF8 ) - nRow = dumpDec< sal_uInt16 >( pcName ); + nRow = dumpDec< sal_uInt16 >( rName ); else { - nRow = dumpHex< sal_uInt16 >( pcName, mxRelFlags ); + nRow = dumpHex< sal_uInt16 >( rName, mxRelFlags ); rbRelC = getFlag( nRow, BIFF_TOK_REF_COLREL ); rbRelR = getFlag( nRow, BIFF_TOK_REF_ROWREL ); nRow &= BIFF_TOK_REF_ROWMASK; @@ -1221,23 +1219,23 @@ void FormulaObject::dumpMemAreaToken( const OUString& rTokClass, bool bAddData ) maAddData.push_back( ADDDATA_MEMAREA ); } -void FormulaObject::dumpExpToken( const StringWrapper& rName ) +void FormulaObject::dumpExpToken( const String& rName ) { Address aPos; aPos.mnRow = dumpDec< sal_uInt16 >( "row" ); aPos.mnCol = dumpDec< sal_uInt16, sal_uInt8 >( getBiff() != BIFF2, "col" ); writeAddressItem( "base-addr", aPos ); - OUStringBuffer aOp( rName.getString() ); + OUStringBuffer aOp( rName ); StringHelper::appendIndex( aOp, out().getLastItemValue() ); mxStack->pushOperand( aOp.makeStringAndClear() ); } -void FormulaObject::dumpUnaryOpToken( const StringWrapper& rLOp, const StringWrapper& rROp ) +void FormulaObject::dumpUnaryOpToken( const String& rLOp, const String& rROp ) { mxStack->pushUnaryOp( rLOp, rROp ); } -void FormulaObject::dumpBinaryOpToken( const StringWrapper& rOp ) +void FormulaObject::dumpBinaryOpToken( const String& rOp ) { mxStack->pushBinaryOp( rOp ); } @@ -1494,153 +1492,51 @@ void FormulaObject::dumpAddDataArray( size_t nIdx ) void FormulaObject::dumpAddDataMemArea( size_t /*nIdx*/ ) { - dumpRangeList( 0, getBiff() == BIFF8 ); + dumpRangeList( EMPTY_STRING, getBiff() == BIFF8 ); } // ============================================================================ // ============================================================================ -RecordHeaderObject::RecordHeaderObject( const InputObjectBase& rParent, BiffInputStream& rStrm ) : - mrStrm( rStrm ) -{ - static const RecordHeaderConfigInfo saHeaderCfgInfo = - { - "REC", - "RECORD-NAMES", - "show-record-pos", - "show-record-size", - "show-record-id", - "show-record-name", - "show-record-body", - }; - RecordHeaderBase< sal_uInt16, sal_uInt32 >::construct( rParent, saHeaderCfgInfo ); - if( RecordHeaderBase< sal_uInt16, sal_uInt32 >::implIsValid() ) - mbMergeContRec = cfg().getBoolOption( "merge-continue-record", true ); -} - -bool RecordHeaderObject::implReadHeader( sal_Int64& ornRecPos, sal_uInt16& ornRecId, sal_uInt32& ornRecSize ) -{ - // previous record - switch( mrStrm.getRecId() ) - { - case BIFF_ID_CHBEGIN: - out().incIndent(); - break; - } - - // start next record - bool bValidRec = mrStrm.startNextRecord(); - ornRecPos = mrStrm.getCoreStreamPos() - 4; - ornRecId = mrStrm.getRecId(); - - // record specific settings - switch( ornRecId ) - { - case BIFF_ID_CHEND: - out().decIndent(); - break; - } - - // special CONTINUE handling - mrStrm.resetRecord( mbMergeContRec ); - if( mbMergeContRec ) switch( ornRecId ) - { - case BIFF_ID_OBJ: - case BIFF_ID_TXO: - case BIFF_ID_EOF: - case BIFF_ID_CONT: - mrStrm.resetRecord( false ); - break; - case BIFF_ID_MSODRAWINGGROUP: - case BIFF_ID_CHESCHERFORMAT: - mrStrm.resetRecord( true, ornRecId ); - break; - } - - ornRecSize = mrStrm.getRecSize(); - return bValidRec; -} - -// ============================================================================ - RecordStreamObject::~RecordStreamObject() { } -void RecordStreamObject::construct( const ObjectBase& rParent, const OUString& rOutFileName, BinaryInputStreamRef xStrm, BiffType eBiff ) +void RecordStreamObject::construct( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, BiffType eBiff, const OUString& rSysFileName ) { - BiffObjectBase::construct( rParent, rOutFileName, xStrm, eBiff ); + BiffObjectBase::construct( rParent, rxStrm, eBiff, rSysFileName ); if( BiffObjectBase::implIsValid() ) - { - mxHdrObj.reset( new RecordHeaderObject( *this, getBiffStream() ) ); mxFmlaObj.reset( new FormulaObject( *this ) ); - mxDffObj.reset( new DffDumpObject( *this ) ); - mxSimpleRecs = cfg().getNameList( "SIMPLE-RECORDS" ); - } } bool RecordStreamObject::implIsValid() const { - return isValid( mxHdrObj ) && isValid( mxFmlaObj ) && isValid( mxDffObj ) && BiffObjectBase::implIsValid(); + return isValid( mxFmlaObj ) && BiffObjectBase::implIsValid(); } -void RecordStreamObject::implDump() +// ============================================================================ + +WorkbookStreamObject::WorkbookStreamObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName ) { - while( mxHdrObj->startNextRecord() ) + if( rxStrm.get() ) { - if( mxHdrObj->isShowRecBody() ) + BiffType eBiff = BiffDetector::detectStreamBiffVersion( *rxStrm ); + RecordStreamObject::construct( rParent, rxStrm, eBiff, rSysFileName ); + if( RecordStreamObject::implIsValid() ) { - IndentGuard aIndGuard( out() ); - if( mxHdrObj->hasRecName() ) - dumpRecordBody(); - else - dumpRawBinary( mxHdrObj->getRecSize(), false ); - if( !getBiffStream().isValid() ) - writeInfoItem( "stream-state", OOX_DUMP_ERR_STREAM ); + Config& rCfg = cfg(); + mxColors = rCfg.getNameList( "COLORS" ); + mxBorderStyles = rCfg.getNameList( "BORDERSTYLES" ); + mxFillPatterns = rCfg.getNameList( "FILLPATTERNS" ); + mnPTRowFields = 0; + mnPTColFields = 0; + mnPTSxliIdx = 0; + mbHasDff = false; + initializePerSheet(); } - out().emptyLine(); } } -void RecordStreamObject::implDumpRecord() -{ -} - -sal_uInt16 RecordStreamObject::dumpRepeatedRecId() -{ - return dumpHex< sal_uInt16 >( "repeated-rec-id", mxHdrObj->getRecNames() ); -} - -void RecordStreamObject::dumpRecordBody() -{ - BiffInputStream& rStrm = getBiffStream(); - sal_uInt16 nRecId = rStrm.getRecId(); - rStrm.enableNulChars( true ); - if( cfg().hasName( mxSimpleRecs, nRecId ) ) - dumpSimpleRecord( cfg().getName( mxSimpleRecs, nRecId ) ); - else - implDumpRecord(); - // remaining undumped data - if( rStrm.getRecPos() == 0 ) - dumpRawBinary( rStrm.getRecSize(), false ); - else - dumpRemaining( rStrm.getRecLeft() ); -} - -void RecordStreamObject::dumpSimpleRecord( const OUString& rRecData ) -{ - ItemFormat aItemFmt; - aItemFmt.parse( rRecData ); - dumpItem( aItemFmt ); -} - -// ============================================================================ - -WorkbookStreamObject::WorkbookStreamObject( const ObjectBase& rParent, const OUString& rOutFileName, BinaryInputStreamRef xStrm ) -{ - construct( rParent, rOutFileName, xStrm ); -} - WorkbookStreamObject::~WorkbookStreamObject() { if( WorkbookStreamObject::implIsValid() ) @@ -1651,36 +1547,11 @@ WorkbookStreamObject::~WorkbookStreamObject() } } -void WorkbookStreamObject::construct( const ObjectBase& rParent, const OUString& rOutFileName, BinaryInputStreamRef xStrm ) -{ - if( xStrm.get() ) - { - BiffType eBiff = BiffDetector::detectStreamBiffVersion( *xStrm ); - RecordStreamObject::construct( rParent, rOutFileName, xStrm, eBiff ); - if( RecordStreamObject::implIsValid() ) - { - Config& rCfg = cfg(); - mxColors = rCfg.getNameList( "COLORS" ); - mxBorderStyles = rCfg.getNameList( "BORDERSTYLES" ); - mxFillPatterns = rCfg.getNameList( "FILLPATTERNS" ); - mxFontNames = rCfg.createNameList< ConstList >( "FONTNAMES" ); - mxFontNames->setName( 0, createFontName( CREATE_OUSTRING( "Arial" ), 200, false, false ) ); - mxFormats = rCfg.createNameList< ConstList >( "FORMATS" ); - mxFormats->includeList( rCfg.getNameList( "BUILTIN-FORMATS" ) ); - mnFormatIdx = 0; - mnPTRowFields = 0; - mnPTColFields = 0; - mnPTSxliIdx = 0; - mbHasCodePage = false; - } - } -} - -void WorkbookStreamObject::implDumpRecord() +void WorkbookStreamObject::implDumpRecordBody() { BiffInputStream& rStrm = getBiffStream(); sal_uInt16 nRecId = rStrm.getRecId(); - sal_Size nRecSize = rStrm.getRecSize(); + sal_Int64 nRecSize = rStrm.getLength(); BiffType eBiff = getBiff(); switch( nRecId ) @@ -1708,6 +1579,8 @@ void WorkbookStreamObject::implDumpRecord() if( nRecSize >= 8 ) dumpDec< sal_uInt16 >( "build-year" ); if( nRecSize >= 12 ) dumpHex< sal_uInt32 >( "history-flags", "BOF-HISTORY-FLAGS" ); if( nRecSize >= 16 ) dumpDec< sal_uInt32 >( "lowest-ver" ); + if( (eBiff == BIFF4) && (getLastRecId() != BIFF_ID_OBJ) ) + initializePerSheet(); break; case BIFF2_ID_BOOLERR: @@ -1735,9 +1608,9 @@ void WorkbookStreamObject::implDumpRecord() { writeEmptyItem( "font-block" ); IndentGuard aIndGuard( out() ); - sal_uInt32 nRecPos = rStrm.getRecPos(); + sal_Int64 nRecPos = rStrm.tell(); dumpUniString( "name", BIFF_STR_8BITLENGTH ); - dumpUnused( nRecPos + 64 - rStrm.getRecPos() ); + dumpUnused( static_cast< sal_Int32 >( nRecPos + 64 - rStrm.tell() ) ); dumpDec< sal_Int32 >( "height", "CONV-TWIP-TO-PT" ); dumpHex< sal_uInt32 >( "flags", "CFRULE-FONTFLAGS" ); dumpDec< sal_uInt16 >( "weight", "FONT-WEIGHT" ); @@ -1794,8 +1667,8 @@ void WorkbookStreamObject::implDumpRecord() break; case BIFF_ID_CHAREAFORMAT: - dumpRgbColor( "fg-color-rgb" ); - dumpRgbColor( "bg-color-rgb" ); + dumpColorABGR( "fg-color" ); + dumpColorABGR( "bg-color" ); dumpPatternIdx(); dumpHex< sal_uInt16 >( "flags", "CHAREAFORMAT-FLAGS" ); if( eBiff == BIFF8 ) dumpColorIdx( "fg-color-idx" ); @@ -1849,7 +1722,7 @@ void WorkbookStreamObject::implDumpRecord() break; case BIFF_ID_CHESCHERFORMAT: - getDffDumper().dump(); + dumpEmbeddedDff(); break; case BIFF_ID_CHFRAME: @@ -1890,7 +1763,7 @@ void WorkbookStreamObject::implDumpRecord() break; case BIFF_ID_CHLINEFORMAT: - dumpRgbColor(); + dumpColorABGR(); dumpDec< sal_uInt16 >( "line-type", "CHLINEFORMAT-LINETYPE" ); dumpDec< sal_Int16 >( "line-weight", "CHLINEFORMAT-LINEWEIGHT" ); dumpHex< sal_uInt16 >( "flags", "CHLINEFORMAT-FLAGS" ); @@ -1898,8 +1771,8 @@ void WorkbookStreamObject::implDumpRecord() break; case BIFF_ID_CHMARKERFORMAT: - dumpRgbColor( "border-color-rgb" ); - dumpRgbColor( "fill-color-rgb" ); + dumpColorABGR( "border-color" ); + dumpColorABGR( "fill-color" ); dumpDec< sal_uInt16 >( "marker-type", "CHMARKERFORMAT-TYPE" ); dumpHex< sal_uInt16 >( "flags", "CHMARKERFORMAT-FLAGS" ); if( eBiff == BIFF8 ) dumpColorIdx( "border-color-idx" ); @@ -1991,7 +1864,7 @@ void WorkbookStreamObject::implDumpRecord() dumpDec< sal_uInt8 >( "horizontal-align", "CHTEXT-HORALIGN" ); dumpDec< sal_uInt8 >( "vertical-align", "CHTEXT-VERALIGN" ); dumpDec< sal_uInt16 >( "fill-mode", "CHTEXT-FILLMODE" ); - dumpRgbColor(); + dumpColorABGR(); dumpRect< sal_Int32 >( "position", (eBiff <= BIFF4) ? "CONV-TWIP-TO-CM" : "" ); dumpHex< sal_uInt16 >( "flags", "CHTEXT-FLAGS" ); if( eBiff == BIFF8 ) dumpColorIdx(); @@ -2004,7 +1877,7 @@ void WorkbookStreamObject::implDumpRecord() dumpDec< sal_uInt8 >( "minor-ticks", "CHTICK-TYPE" ); dumpDec< sal_uInt8 >( "label-position", "CHTICK-LABELPOS" ); dumpDec< sal_uInt8 >( "fill-mode", "CHTEXT-FILLMODE" ); - dumpRgbColor( "label-color-rgb" ); + dumpColorABGR( "label-color" ); dumpUnused( 16 ); dumpHex< sal_uInt16 >( "flags", "CHTICK-FLAGS" ); if( eBiff == BIFF8 ) dumpColorIdx( "label-color-idx" ); @@ -2058,17 +1931,36 @@ void WorkbookStreamObject::implDumpRecord() break; case BIFF_ID_COLWIDTH: - dumpColRange( 0, false ); + dumpColRange( EMPTY_STRING, false ); dumpDec< sal_uInt16 >( "col-width", "CONV-COLWIDTH" ); break; + case BIFF_ID_CONT: + if( (eBiff == BIFF8) && (getLastRecId() == BIFF_ID_OBJ) ) + dumpEmbeddedDff(); + break; + + case BIFF_ID_COORDLIST: + { + out().resetItemIndex(); + TableGuard aTabGuard( out(), 12, 10 ); + while( rStrm.getRemaining() >= 4 ) + { + MultiItemsGuard aMultiGuard( out() ); + writeEmptyItem( "#point" ); + dumpDec< sal_uInt16 >( "x" ); + dumpDec< sal_uInt16 >( "y" ); + } + } + break; + case BIFF_ID_CRN: { sal_Int32 nCol2 = dumpColIndex( "last-col-idx", false ); sal_Int32 nCol1 = dumpColIndex( "first-col-idx", false ); sal_Int32 nRow = dumpRowIndex( "row-idx" ); TableGuard aTabGuard( out(), 14, 17 ); - for( Address aPos( nCol1, nRow ); rStrm.isValid() && (aPos.mnCol <= nCol2); ++aPos.mnCol ) + for( Address aPos( nCol1, nRow ); !rStrm.isEof() && (aPos.mnCol <= nCol2); ++aPos.mnCol ) { MultiItemsGuard aMultiGuard( out() ); writeAddressItem( "pos", aPos ); @@ -2139,12 +2031,12 @@ void WorkbookStreamObject::implDumpRecord() case BIFF2_ID_DEFINEDNAME: case BIFF3_ID_DEFINEDNAME: { + rtl_TextEncoding eTextEnc = getBiffData().getTextEncoding(); dumpHex< sal_uInt16, sal_uInt8 >( eBiff != BIFF2, "flags", "DEFINEDNAME-FLAGS" ); if( eBiff == BIFF2 ) dumpDec< sal_uInt8 >( "macro-type", "DEFINEDNAME-MACROTYPE-BIFF2" ); - dumpHex< sal_uInt8 >( "keyboard-shortcut" ); + dumpChar( "accelerator", eTextEnc ); sal_uInt8 nNameLen = dumpDec< sal_uInt8 >( "name-len" ); sal_uInt16 nFmlaSize = getFormulaDumper().dumpFormulaSize(); - rtl_TextEncoding eTextEnc = getBiffData().getTextEncoding(); if( eBiff >= BIFF5 ) { bool bBiff8 = eBiff == BIFF8; @@ -2155,7 +2047,7 @@ void WorkbookStreamObject::implDumpRecord() sal_uInt8 nHelpLen = dumpDec< sal_uInt8 >( "help-text-len" ); sal_uInt8 nStatusLen = dumpDec< sal_uInt8 >( "statusbar-text-len" ); writeStringItem( "name", bBiff8 ? rStrm.readUniString( nNameLen ) : rStrm.readCharArray( nNameLen, eTextEnc ) ); - getFormulaDumper().dumpNameFormula( 0, nFmlaSize ); + getFormulaDumper().dumpNameFormula( EMPTY_STRING, nFmlaSize ); if( nMenuLen > 0 ) writeStringItem( "menu-text", bBiff8 ? rStrm.readUniString( nMenuLen ) : rStrm.readCharArray( nMenuLen, eTextEnc ) ); if( nDescrLen > 0 ) writeStringItem( "description-text", bBiff8 ? rStrm.readUniString( nDescrLen ) : rStrm.readCharArray( nDescrLen, eTextEnc ) ); if( nHelpLen > 0 ) writeStringItem( "help-text", bBiff8 ? rStrm.readUniString( nHelpLen ) : rStrm.readCharArray( nHelpLen, eTextEnc ) ); @@ -2164,7 +2056,7 @@ void WorkbookStreamObject::implDumpRecord() else { writeStringItem( "name", rStrm.readCharArray( nNameLen, eTextEnc ) ); - getFormulaDumper().dumpNameFormula( 0, nFmlaSize ); + getFormulaDumper().dumpNameFormula( EMPTY_STRING, nFmlaSize ); if( eBiff == BIFF2 ) getFormulaDumper().dumpFormulaSize(); } } @@ -2184,13 +2076,13 @@ void WorkbookStreamObject::implDumpRecord() case BIFF_ID_EXTERNALBOOK: { sal_uInt16 nCount = dumpDec< sal_uInt16 >( "sheet-count" ); - if( rStrm.getRecLeft() == 2 ) + if( rStrm.getRemaining() == 2 ) dumpHex< sal_uInt16 >( "special-key", "EXTERNALBOOK-KEY" ); else { dumpString( "workbook-url" ); out().resetItemIndex(); - for( sal_uInt16 nSheet = 0; rStrm.isValid() && (nSheet < nCount); ++nSheet ) + for( sal_uInt16 nSheet = 0; !rStrm.isEof() && (nSheet < nCount); ++nSheet ) dumpString( "#sheet-name" ); } } @@ -2213,7 +2105,7 @@ void WorkbookStreamObject::implDumpRecord() } } OUString aName = dumpString( "name", BIFF_STR_8BITLENGTH, BIFF_STR_8BITLENGTH ); - if( (aName.getLength() > 0) && (aName[ 0 ] == 1) && (rStrm.getRecLeft() >= 2) ) + if( (aName.getLength() > 0) && (aName[ 0 ] == 1) && (rStrm.getRemaining() >= 2) ) getFormulaDumper().dumpNameFormula(); } break; @@ -2224,7 +2116,7 @@ void WorkbookStreamObject::implDumpRecord() sal_uInt16 nCount = dumpDec< sal_uInt16 >( "ref-count" ); TableGuard aTabGuard( out(), 10, 17, 24 ); out().resetItemIndex(); - for( sal_uInt16 nRefId = 0; rStrm.isValid() && (nRefId < nCount); ++nRefId ) + for( sal_uInt16 nRefId = 0; !rStrm.isEof() && (nRefId < nCount); ++nRefId ) { MultiItemsGuard aMultiGuard( out() ); writeEmptyItem( "#ref" ); @@ -2263,56 +2155,40 @@ void WorkbookStreamObject::implDumpRecord() break; case BIFF_ID_FOOTER: - if( rStrm.getRecLeft() > 0 ) + if( rStrm.getRemaining() > 0 ) dumpString( "footer", BIFF_STR_8BITLENGTH ); break; case BIFF_ID_HEADER: - if( rStrm.getRecLeft() > 0 ) + if( rStrm.getRemaining() > 0 ) dumpString( "header", BIFF_STR_8BITLENGTH ); break; case BIFF_ID_HYPERLINK: dumpRange(); if( cfg().getStringOption( dumpGuid( "guid" ), OUString() ).equalsAscii( "StdHlink" ) ) + StdHlinkObject( *this ).dump(); + break; + + case BIFF3_ID_IMGDATA: + case BIFF8_ID_IMGDATA: + { + sal_uInt16 nFormat = dumpDec< sal_uInt16 >( "image-format", "IMGDATA-FORMAT" ); + dumpDec< sal_uInt16 >( "environment", "IMGDATA-ENV" ); + dumpDec< sal_uInt32 >( "data-size" ); + if( nFormat == 9 ) { - dumpUnknown( 4 ); - sal_uInt32 nFlags = dumpHex< sal_uInt32 >( "flags", "HYPERLINK-FLAGS" ); - if( getFlag( nFlags, BIFF_HYPERLINK_DISPLAY ) ) - dumpOleString( "display", true ); - if( getFlag( nFlags, BIFF_HYPERLINK_FRAME ) ) - dumpOleString( "target-frame", true ); - if( getFlag( nFlags, BIFF_HYPERLINK_TARGET ) ) + writeEmptyItem( "bitmap-header" ); + IndentGuard aIndGuard( out() ); + if( dumpDec< sal_uInt32 >( "header-size" ) == 12 ) { - if( getFlag( nFlags, BIFF_HYPERLINK_UNC ) ) - { - dumpOleString( "unc-path", true ); - } - else - { - OUString aGuid = cfg().getStringOption( dumpGuid( "content-type" ), OUString() ); - if( aGuid.equalsAscii( "FileMoniker" ) ) - { - dumpDec< sal_Int16 >( "up-level" ); - dumpOleString( "dos-name", false ); - dumpUnknown( 24 ); - if( dumpDec< sal_Int32 >( "total-bytes" ) > 0 ) - { - sal_Int32 nBytes = dumpDec< sal_Int32 >( "filename-bytes" ); - dumpUnknown( 2 ); - dumpOleString( "filename", nBytes / 2, true ); - } - } - else if( aGuid.equalsAscii( "URLMoniker" ) ) - { - sal_Int32 nBytes = dumpDec< sal_Int32 >( "url-bytes" ); - dumpOleString( "url", nBytes / 2, true ); - } - } + dumpDec< sal_Int16 >( "width" ); + dumpDec< sal_Int16 >( "height" ); + dumpDec< sal_Int16 >( "planes" ); + dumpDec< sal_Int16 >( "bit-count" ); } - if( getFlag( nFlags, BIFF_HYPERLINK_LOC ) ) - dumpOleString( "location", true ); } + } break; case BIFF2_ID_INTEGER: @@ -2345,7 +2221,8 @@ void WorkbookStreamObject::implDumpRecord() case BIFF_ID_MSODRAWING: case BIFF_ID_MSODRAWINGGROUP: case BIFF_ID_MSODRAWINGSEL: - getDffDumper().dump(); + dumpEmbeddedDff(); + mbHasDff = true; break; case BIFF_ID_MULTBLANK: @@ -2353,7 +2230,7 @@ void WorkbookStreamObject::implDumpRecord() Address aPos = dumpAddress(); { TableGuard aTabGuard( out(), 12 ); - for( ; rStrm.getRecLeft() >= 4; ++aPos.mnCol ) + for( ; rStrm.getRemaining() >= 4; ++aPos.mnCol ) { MultiItemsGuard aMultiGuard( out() ); writeAddressItem( "pos", aPos ); @@ -2369,7 +2246,7 @@ void WorkbookStreamObject::implDumpRecord() Address aPos = dumpAddress(); { TableGuard aTabGuard( out(), 12, 12 ); - for( ; rStrm.getRecLeft() >= 8; ++aPos.mnCol ) + for( ; rStrm.getRemaining() >= 8; ++aPos.mnCol ) { MultiItemsGuard aMultiGuard( out() ); writeAddressItem( "pos", aPos ); @@ -2381,6 +2258,20 @@ void WorkbookStreamObject::implDumpRecord() } break; + case BIFF_ID_NOTE: + dumpAddress( "anchor-cell" ); + if( eBiff == BIFF8 ) + { + dumpHex< sal_uInt16 >( "flags", "NOTE-FLAGS" ); + dumpDec< sal_uInt16 >( "obj-id" ); + } + else + { + sal_uInt16 nTextLen = ::std::min( dumpDec< sal_uInt16 >( "text-len" ), static_cast< sal_uInt16 >( rStrm.getRemaining() ) ); + writeStringItem( "note-text", rStrm.readCharArray( nTextLen, getBiffData().getTextEncoding() ) ); + } + break; + case BIFF2_ID_NUMBER: case BIFF3_ID_NUMBER: dumpCellHeader( nRecId == BIFF2_ID_NUMBER ); @@ -2480,7 +2371,7 @@ void WorkbookStreamObject::implDumpRecord() case BIFF_ID_SCREENTIP: dumpRepeatedRecId(); dumpRange(); - dumpNullString( "tooltip", true ); + dumpNullUnicodeArray( "tooltip" ); break; case BIFF_ID_SELECTION: @@ -2520,7 +2411,7 @@ void WorkbookStreamObject::implDumpRecord() dumpDec< sal_uInt32 >( "string-cell-count" ); dumpDec< sal_uInt32 >( "sst-size" ); out().resetItemIndex(); - while( rStrm.isValid() && (rStrm.getRecLeft() >= 3) ) + while( !rStrm.isEof() && (rStrm.getRemaining() >= 3) ) dumpUniString( "#entry" ); break; @@ -2570,7 +2461,7 @@ void WorkbookStreamObject::implDumpRecord() case BIFF_ID_SXIVD: out().resetItemIndex(); - for( sal_Size nIdx = 0, nCount = rStrm.getRecLeft() / 2; nIdx < nCount; ++nIdx ) + for( sal_Int64 nIdx = 0, nCount = rStrm.getRemaining() / 2; nIdx < nCount; ++nIdx ) dumpDec< sal_uInt16 >( "#field-idx" ); break; @@ -2578,9 +2469,9 @@ void WorkbookStreamObject::implDumpRecord() if( mnPTSxliIdx < 2 ) { sal_uInt16 nCount = (mnPTSxliIdx == 0) ? mnPTRowFields : mnPTColFields; - sal_Size nLineSize = 8 + 2 * nCount; + sal_Int64 nLineSize = 8 + 2 * nCount; out().resetItemIndex(); - while( rStrm.getRecLeft() >= nLineSize ) + while( rStrm.getRemaining() >= nLineSize ) { writeEmptyItem( "#line-data" ); IndentGuard aIndGuard( out() ); @@ -2591,7 +2482,7 @@ void WorkbookStreamObject::implDumpRecord() dumpHex< sal_uInt16 >( "flags", "SXLI-FLAGS" ); OUStringBuffer aItemList; for( sal_uInt16 nIdx = 0; nIdx < nCount; ++nIdx ) - StringHelper::appendToken( aItemList, in().readValue< sal_uInt16 >() ); + StringHelper::appendToken( aItemList, in().readuInt16() ); writeInfoItem( "item-idxs", aItemList.makeStringAndClear() ); } ++mnPTSxliIdx; @@ -2658,6 +2549,17 @@ void WorkbookStreamObject::implDumpRecord() } break; + case BIFF_ID_TXO: + dumpHex< sal_uInt16 >( "flags", "TXO-FLAGS" ); + dumpDec< sal_uInt16 >( "orientation", "TEXTORIENTATION" ); + dumpHex< sal_uInt16 >( "button-flags", "OBJ-BUTTON-FLAGS" ); + dumpUnicode( "accelerator" ); + dumpUnicode( "fareast-accelerator" ); + dumpDec< sal_uInt16 >( "text-len" ); + dumpDec< sal_uInt16 >( "format-run-size" ); + dumpUnused( 4 ); + break; + case BIFF_ID_WINDOW1: dumpDec< sal_uInt16 >( "window-x", "CONV-TWIP-TO-CM" ); dumpDec< sal_uInt16 >( "window-y", "CONV-TWIP-TO-CM" ); @@ -2685,7 +2587,7 @@ void WorkbookStreamObject::implDumpRecord() dumpBool< sal_uInt8 >( "show-zeros" ); dumpAddress( "first-visible-cell" ); dumpBool< sal_uInt8 >( "auto-grid-color" ); - dumpRgbColor( "grid-color-rgb" ); + dumpColorABGR( "grid-color" ); break; case BIFF3_ID_WINDOW2: @@ -2695,7 +2597,7 @@ void WorkbookStreamObject::implDumpRecord() { dumpColorIdx( "grid-color-idx" ); dumpUnused( 2 ); - if( rStrm.getRecLeft() >= 8 ) + if( rStrm.getRemaining() >= 8 ) { dumpDec< sal_uInt16 >( "pagebreak-zoom", "CONV-PERCENT" ); dumpDec< sal_uInt16 >( "normal-zoom", "CONV-PERCENT" ); @@ -2703,7 +2605,7 @@ void WorkbookStreamObject::implDumpRecord() } } else - dumpRgbColor( "grid-color-rgb" ); + dumpColorABGR( "grid-color" ); break; case BIFF_ID_XCT: @@ -2720,6 +2622,17 @@ void WorkbookStreamObject::implDumpRecord() } } +void WorkbookStreamObject::initializePerSheet() +{ + getBiffData().initializePerSheet(); + mxFontNames = cfg().createNameList< ConstList >( "FONTNAMES" ); + mxFontNames->setName( 0, createFontName( CREATE_OUSTRING( "Arial" ), 200, false, false ) ); + mxFormats = cfg().createNameList< ConstList >( "FORMATS" ); + mxFormats->includeList( cfg().getNameList( "BUILTIN-FORMATS" ) ); + mnFormatIdx = 0; + mbHasCodePage = false; +} + OUString WorkbookStreamObject::createFontName( const OUString& rName, sal_uInt16 nHeight, bool bBold, bool bItalic ) const { OUStringBuffer aName( rName ); @@ -2732,45 +2645,45 @@ OUString WorkbookStreamObject::createFontName( const OUString& rName, sal_uInt16 return aName.makeStringAndClear(); } -sal_uInt16 WorkbookStreamObject::dumpPatternIdx( const sal_Char* pcName, bool b16Bit ) +sal_uInt16 WorkbookStreamObject::dumpPatternIdx( const String& rName, bool b16Bit ) { - return dumpDec< sal_uInt16, sal_uInt8 >( b16Bit, pcName ? pcName : "fill-pattern", mxFillPatterns ); + return dumpDec< sal_uInt16, sal_uInt8 >( b16Bit, rName( "fill-pattern" ), mxFillPatterns ); } -sal_uInt16 WorkbookStreamObject::dumpColorIdx( const sal_Char* pcName, bool b16Bit ) +sal_uInt16 WorkbookStreamObject::dumpColorIdx( const String& rName, bool b16Bit ) { - return dumpDec< sal_uInt16, sal_uInt8 >( b16Bit, pcName ? pcName : "color-idx", mxColors ); + return dumpDec< sal_uInt16, sal_uInt8 >( b16Bit, rName( "color-idx" ), mxColors ); } -sal_uInt16 WorkbookStreamObject::dumpFontIdx( const sal_Char* pcName, bool b16Bit ) +sal_uInt16 WorkbookStreamObject::dumpFontIdx( const String& rName, bool b16Bit ) { - return dumpDec< sal_uInt16, sal_uInt8 >( b16Bit, pcName ? pcName : "font-idx", "FONTNAMES" ); + return dumpDec< sal_uInt16, sal_uInt8 >( b16Bit, rName( "font-idx" ), "FONTNAMES" ); } -sal_uInt16 WorkbookStreamObject::dumpFormatIdx( const sal_Char* pcName ) +sal_uInt16 WorkbookStreamObject::dumpFormatIdx( const String& rName ) { - return dumpDec< sal_uInt16, sal_uInt8 >( getBiff() >= BIFF5, pcName ? pcName : "fmt-idx", "FORMATS" ); + return dumpDec< sal_uInt16, sal_uInt8 >( getBiff() >= BIFF5, rName( "fmt-idx" ), "FORMATS" ); } -sal_uInt16 WorkbookStreamObject::dumpXfIdx( const sal_Char* pcName, bool bBiff2Style ) +sal_uInt16 WorkbookStreamObject::dumpXfIdx( const String& rName, bool bBiff2Style ) { - if( !pcName ) pcName = "xf-idx"; + String aName = rName( "xf-idx" ); sal_uInt16 nXfIdx = 0; if( bBiff2Style ) { - dumpHex< sal_uInt8 >( pcName, "CELL-XFINDEX" ); + dumpHex< sal_uInt8 >( aName, "CELL-XFINDEX" ); dumpHex< sal_uInt8 >( "fmt-font-idx", "CELL-XFFORMAT" ); dumpHex< sal_uInt8 >( "style", "CELL-XFSTYLE" ); } else - nXfIdx = dumpDec< sal_uInt16 >( pcName ); + nXfIdx = dumpDec< sal_uInt16 >( aName ); return nXfIdx; } sal_uInt16 WorkbookStreamObject::dumpCellHeader( bool bBiff2Style ) { dumpAddress(); - return dumpXfIdx( 0, bBiff2Style ); + return dumpXfIdx( EMPTY_STRING, bBiff2Style ); } void WorkbookStreamObject::dumpBoolErr() @@ -2854,7 +2767,7 @@ void WorkbookStreamObject::dumpXfRec() sal_uInt16 nXfId = getBiffData().getXfCount(); out().resetItemIndex( nXfId ); writeEmptyItem( "#xf" ); - sal_uInt16 nFontId = dumpFontIdx( 0, getBiff() >= BIFF5 ); + sal_uInt16 nFontId = dumpFontIdx( EMPTY_STRING, getBiff() >= BIFF5 ); switch( getBiff() ) { case BIFF2: @@ -2907,55 +2820,326 @@ void WorkbookStreamObject::dumpObjRec() { switch( getBiff() ) { - case BIFF5: dumpObjRecBiff5(); break; - case BIFF8: dumpObjRecBiff8(); break; + case BIFF3: + dumpObjRecBiff3(); + break; + case BIFF4: + dumpObjRecBiff4(); + break; + case BIFF5: + dumpObjRecBiff5(); + break; + case BIFF8: + // #i61786# OBJ records without DFF stream are in BIFF5 format + if( mbHasDff ) dumpObjRecBiff8(); else dumpObjRecBiff5(); + break; default:; } } +void WorkbookStreamObject::dumpObjRecBiff3() +{ + BiffInputStream& rStrm = getBiffStream(); + dumpDec< sal_uInt32 >( "obj-count" ); + sal_uInt16 nObjType = dumpDec< sal_uInt16 >( "obj-type", "OBJ-TYPE" ); + dumpDec< sal_uInt16 >( "obj-id" ); + dumpHex< sal_uInt16 >( "flags", "OBJ-FLAGS" ); + dumpDffClientRect(); + sal_uInt16 nMacroSize = dumpDec< sal_uInt16 >( "macro-size" ); + dumpUnused( 2 ); + sal_uInt16 nTextLen = 0, nFormatSize = 0, nLinkSize = 0; + switch( nObjType ) + { + case BIFF_OBJTYPE_GROUP: + dumpUnused( 4 ); + dumpDec< sal_uInt16 >( "next-ungrouped-id" ); + dumpUnused( 16 ); + dumpObjRecString( "macro", nMacroSize, true ); + break; + case BIFF_OBJTYPE_LINE: + dumpObjRecLineData(); + dumpHex< sal_uInt16 >( "line-end", "OBJ-LINEENDS" ); + dumpDec< sal_uInt8 >( "line-direction", "OBJ-LINEDIR" ); + dumpUnused( 1 ); + dumpObjRecString( "macro", nMacroSize, true ); + break; + case BIFF_OBJTYPE_RECTANGLE: + case BIFF_OBJTYPE_OVAL: + dumpObjRecRectData(); + dumpObjRecString( "macro", nMacroSize, true ); + break; + case BIFF_OBJTYPE_ARC: + dumpObjRecFillData(); + dumpObjRecLineData(); + dumpDec< sal_uInt8 >( "quadrant", "OBJ-ARC-QUADRANT" ); + dumpUnused( 1 ); + dumpObjRecString( "macro", nMacroSize, true ); + break; + case BIFF_OBJTYPE_CHART: + dumpObjRecRectData(); + dumpUnused( 18 ); + dumpObjRecString( "macro", nMacroSize, true ); + break; + case BIFF_OBJTYPE_TEXT: + case BIFF_OBJTYPE_BUTTON: + dumpObjRecRectData(); + dumpObjRecTextDataBiff3( nTextLen, nFormatSize ); + dumpObjRecString( "macro", nMacroSize, true ); + dumpObjRecString( "text", nTextLen, false ); + dumpObjRecTextFmt( nFormatSize ); + break; + case BIFF_OBJTYPE_PICTURE: + dumpObjRecRectData(); + dumpDec< sal_Int16 >( "image-format", "IMGDATA-FORMAT" ); + dumpUnused( 4 ); + nLinkSize = dumpDec< sal_uInt16 >( "pic-link-size" ); + dumpUnused( 2 ); + dumpHex< sal_uInt16 >( "flags", "OBJ-PICTURE-FLAGS" ); + dumpObjRecString( "macro", nMacroSize, true ); + dumpObjRecPictFmla( nLinkSize ); + break; + } +} + +void WorkbookStreamObject::dumpObjRecBiff4() +{ + BiffInputStream& rStrm = getBiffStream(); + dumpDec< sal_uInt32 >( "obj-count" ); + sal_uInt16 nObjType = dumpDec< sal_uInt16 >( "obj-type", "OBJ-TYPE" ); + dumpDec< sal_uInt16 >( "obj-id" ); + dumpHex< sal_uInt16 >( "flags", "OBJ-FLAGS" ); + dumpDffClientRect(); + sal_uInt16 nMacroSize = dumpDec< sal_uInt16 >( "macro-size" ); + dumpUnused( 2 ); + sal_uInt16 nTextLen = 0, nFormatSize = 0, nLinkSize = 0; + switch( nObjType ) + { + case BIFF_OBJTYPE_GROUP: + dumpUnused( 4 ); + dumpDec< sal_uInt16 >( "next-ungrouped-id" ); + dumpUnused( 16 ); + dumpObjRecFmla( "macro", nMacroSize ); + break; + case BIFF_OBJTYPE_LINE: + dumpObjRecLineData(); + dumpHex< sal_uInt16 >( "line-end", "OBJ-LINEENDS" ); + dumpDec< sal_uInt8 >( "line-direction", "OBJ-LINEDIR" ); + dumpUnused( 1 ); + dumpObjRecFmla( "macro", nMacroSize ); + break; + case BIFF_OBJTYPE_RECTANGLE: + case BIFF_OBJTYPE_OVAL: + dumpObjRecRectData(); + dumpObjRecFmla( "macro", nMacroSize ); + break; + case BIFF_OBJTYPE_ARC: + dumpObjRecFillData(); + dumpObjRecLineData(); + dumpDec< sal_uInt8 >( "quadrant", "OBJ-ARC-QUADRANT" ); + dumpUnused( 1 ); + dumpObjRecFmla( "macro", nMacroSize ); + break; + case BIFF_OBJTYPE_CHART: + dumpObjRecRectData(); + dumpUnused( 18 ); + dumpObjRecFmla( "macro", nMacroSize ); + break; + case BIFF_OBJTYPE_TEXT: + case BIFF_OBJTYPE_BUTTON: + dumpObjRecRectData(); + dumpObjRecTextDataBiff3( nTextLen, nFormatSize ); + dumpObjRecFmla( "macro", nMacroSize ); + dumpObjRecString( "text", nTextLen, false ); + dumpObjRecTextFmt( nFormatSize ); + break; + case BIFF_OBJTYPE_PICTURE: + dumpObjRecRectData(); + dumpDec< sal_Int16 >( "image-format", "IMGDATA-FORMAT" ); + dumpUnused( 4 ); + nLinkSize = dumpDec< sal_uInt16 >( "pic-link-size" ); + dumpUnused( 2 ); + dumpHex< sal_uInt16 >( "flags", "OBJ-PICTURE-FLAGS" ); + dumpObjRecFmla( "macro", nMacroSize ); + dumpObjRecPictFmla( nLinkSize ); + break; + case BIFF_OBJTYPE_POLYGON: + dumpObjRecRectData(); + dumpHex< sal_uInt16 >( "flags", "OBJ-POLYGON-FLAGS" ); + dumpUnused( 10 ); + dumpDec< sal_uInt16 >( "point-count" ); + dumpUnused( 8 ); + dumpObjRecFmla( "macro", nMacroSize ); + break; + } +} + void WorkbookStreamObject::dumpObjRecBiff5() { + BiffInputStream& rStrm = getBiffStream(); dumpDec< sal_uInt32 >( "obj-count" ); sal_uInt16 nObjType = dumpDec< sal_uInt16 >( "obj-type", "OBJ-TYPE" ); dumpDec< sal_uInt16 >( "obj-id" ); dumpHex< sal_uInt16 >( "flags", "OBJ-FLAGS" ); - getDffDumper().dumpDffClientRect(); - dumpDec< sal_uInt16 >( "macro-len" ); - dumpUnused( 6 ); + dumpDffClientRect(); + sal_uInt16 nMacroSize = dumpDec< sal_uInt16 >( "macro-size" ); + dumpUnused( 2 ); + sal_uInt16 nNameLen = dumpDec< sal_uInt16 >( "name-len" ); + dumpUnused( 2 ); + sal_uInt16 nTextLen = 0, nFormatSize = 0, nLinkSize = 0; switch( nObjType ) { - case BIFF_OBJCMO_LINE: - dumpColorIdx( "line-color-idx", false ); - dumpDec< sal_uInt8 >( "line-type", "OBJ-LINETYPE" ); - dumpDec< sal_uInt8 >( "line-weight", "OBJ-LINEWEIGHT" ); - dumpHex< sal_uInt8 >( "line-flags", "OBJ-FLAGS-AUTO" ); + case BIFF_OBJTYPE_GROUP: + dumpUnused( 4 ); + dumpDec< sal_uInt16 >( "next-ungrouped-id" ); + dumpUnused( 16 ); + dumpObjRecString( "obj-name", nNameLen, true ); + dumpObjRecFmla( "macro", nMacroSize ); + break; + case BIFF_OBJTYPE_LINE: + dumpObjRecLineData(); dumpHex< sal_uInt16 >( "line-end", "OBJ-LINEENDS" ); dumpDec< sal_uInt8 >( "line-direction", "OBJ-LINEDIR" ); dumpUnused( 1 ); + dumpObjRecString( "obj-name", nNameLen, true ); + dumpObjRecFmla( "macro", nMacroSize ); + break; + case BIFF_OBJTYPE_RECTANGLE: + case BIFF_OBJTYPE_OVAL: + dumpObjRecRectData(); + dumpObjRecString( "obj-name", nNameLen, true ); + dumpObjRecFmla( "macro", nMacroSize ); + break; + case BIFF_OBJTYPE_ARC: + dumpObjRecFillData(); + dumpObjRecLineData(); + dumpDec< sal_uInt8 >( "quadrant", "OBJ-ARC-QUADRANT" ); + dumpUnused( 1 ); + dumpObjRecString( "obj-name", nNameLen, true ); + dumpObjRecFmla( "macro", nMacroSize ); break; - case BIFF_OBJCMO_RECTANGLE: - dumpColorIdx( "back-color-idx", false ); - dumpColorIdx( "patt-color-idx", false ); - dumpPatternIdx( 0, false ); - dumpHex< sal_uInt8 >( "area-flags", "OBJ-FLAGS-AUTO" ); - dumpColorIdx( "line-color-idx", false ); - dumpDec< sal_uInt8 >( "line-type", "OBJ-LINETYPE" ); - dumpDec< sal_uInt8 >( "line-weight", "OBJ-LINEWEIGHT" ); - dumpHex< sal_uInt8 >( "line-flags", "OBJ-FLAGS-AUTO" ); - dumpHex< sal_uInt16 >( "frame-style", "OBJ-FRAMESTYLE-FLAGS" ); - break; - case BIFF_OBJCMO_CHART: - dumpColorIdx( "back-color-idx", false ); - dumpColorIdx( "patt-color-idx", false ); - dumpPatternIdx( 0, false ); - dumpHex< sal_uInt8 >( "area-flags", "OBJ-FLAGS-AUTO" ); - dumpColorIdx( "line-color-idx", false ); - dumpDec< sal_uInt8 >( "line-type", "OBJ-LINETYPE" ); - dumpDec< sal_uInt8 >( "line-weight", "OBJ-LINEWEIGHT" ); - dumpHex< sal_uInt8 >( "line-flags", "OBJ-FLAGS-AUTO" ); - dumpHex< sal_uInt16 >( "frame-style", "OBJ-FRAMESTYLE-FLAGS" ); + case BIFF_OBJTYPE_CHART: + dumpObjRecRectData(); dumpHex< sal_uInt16 >( "chart-flags", "OBJ-CHART-FLAGS" ); dumpUnused( 16 ); + dumpObjRecString( "obj-name", nNameLen, true ); + dumpObjRecFmla( "macro", nMacroSize ); + break; + case BIFF_OBJTYPE_TEXT: + case BIFF_OBJTYPE_BUTTON: + case BIFF_OBJTYPE_LABEL: + case BIFF_OBJTYPE_DIALOG: + dumpObjRecRectData(); + dumpObjRecTextDataBiff5( nTextLen, nFormatSize, nLinkSize ); + dumpObjRecString( "obj-name", nNameLen, true ); + dumpObjRecFmla( "macro", nMacroSize ); + dumpObjRecString( "text", nTextLen, false ); + dumpObjRecFmla( "text-link", nLinkSize ); + dumpObjRecTextFmt( nFormatSize ); + break; + case BIFF_OBJTYPE_PICTURE: + dumpObjRecRectData(); + dumpDec< sal_Int16 >( "image-format", "IMGDATA-FORMAT" ); + dumpUnused( 4 ); + nLinkSize = dumpDec< sal_uInt16 >( "pic-link-size" ); + dumpUnused( 2 ); + dumpHex< sal_uInt16 >( "flags", "OBJ-PICTURE-FLAGS" ); + dumpUnused( 4 ); + dumpObjRecString( "obj-name", nNameLen, true ); + dumpObjRecFmla( "macro", nMacroSize ); + dumpObjRecPictFmla( nLinkSize ); + if( rStrm.getRemaining() >= 4 ) + dumpHex< sal_uInt32 >( "ole-storage-id" ); + break; + case BIFF_OBJTYPE_POLYGON: + dumpObjRecRectData(); + dumpHex< sal_uInt16 >( "flags", "OBJ-POLYGON-FLAGS" ); + dumpUnused( 10 ); + dumpDec< sal_uInt16 >( "point-count" ); + dumpUnused( 8 ); + dumpObjRecString( "obj-name", nNameLen, true ); + dumpObjRecFmla( "macro", nMacroSize ); + break; + case BIFF_OBJTYPE_CHECKBOX: + dumpObjRecRectData(); + dumpUnused( 10 ); + dumpHex< sal_uInt16 >( "flags", "OBJ-TEXT-FLAGS" ); + dumpUnused( 20 ); + dumpObjRecString( "obj-name", nNameLen, true ); + dumpObjRecFmla( "macro", dumpDec< sal_uInt16 >( "macro-size" ) ); + dumpObjRecFmla( "cell-link", dumpDec< sal_uInt16 >( "cell-link-size" ) ); + dumpObjRecString( "text", dumpDec< sal_uInt16 >( "text-len" ), false ); + dumpObjRecCblsData(); + break; + case BIFF_OBJTYPE_OPTIONBUTTON: + dumpObjRecRectData(); + dumpUnused( 10 ); + dumpHex< sal_uInt16 >( "flags", "OBJ-TEXT-FLAGS" ); + dumpUnused( 32 ); + dumpObjRecString( "obj-name", nNameLen, true ); + dumpObjRecFmla( "macro", dumpDec< sal_uInt16 >( "macro-size" ) ); + dumpObjRecFmla( "cell-link", dumpDec< sal_uInt16 >( "cell-link-size" ) ); + dumpObjRecString( "text", dumpDec< sal_uInt16 >( "text-len" ), false ); + dumpObjRecCblsData(); + dumpObjRecRboData(); + break; + case BIFF_OBJTYPE_EDIT: + dumpObjRecRectData(); + dumpUnused( 10 ); + dumpHex< sal_uInt16 >( "flags", "OBJ-TEXT-FLAGS" ); + dumpUnused( 14 ); + dumpObjRecString( "obj-name", nNameLen, true ); + dumpObjRecFmla( "macro", dumpDec< sal_uInt16 >( "macro-size" ) ); + dumpObjRecString( "text", dumpDec< sal_uInt16 >( "text-len" ), false ); + dumpObjRecEdoData(); + break; + case BIFF_OBJTYPE_SPIN: + case BIFF_OBJTYPE_SCROLLBAR: + dumpObjRecRectData(); + dumpObjRecSbsData(); + dumpObjRecString( "obj-name", nNameLen, true ); + dumpObjRecFmla( "macro", dumpDec< sal_uInt16 >( "macro-size" ) ); + dumpObjRecFmla( "cell-link", dumpDec< sal_uInt16 >( "cell-link-size" ) ); + break; + case BIFF_OBJTYPE_LISTBOX: + dumpObjRecRectData(); + dumpObjRecSbsData(); + dumpUnused( 18 ); + dumpFontIdx( "font-idx" ); + dumpUnused( 4 ); + dumpObjRecString( "obj-name", nNameLen, true ); + dumpObjRecFmla( "macro", dumpDec< sal_uInt16 >( "macro-size" ) ); + dumpObjRecFmla( "cell-link", dumpDec< sal_uInt16 >( "cell-link-size" ) ); + dumpObjRecLbsData(); + break; + case BIFF_OBJTYPE_GROUPBOX: + dumpObjRecRectData(); + dumpUnused( 10 ); + dumpHex< sal_uInt16 >( "flags", "OBJ-TEXT-FLAGS" ); + dumpUnused( 26 ); + dumpObjRecString( "obj-name", nNameLen, true ); + dumpObjRecFmla( "macro", dumpDec< sal_uInt16 >( "macro-size" ) ); + dumpObjRecString( "text", dumpDec< sal_uInt16 >( "text-len" ), false ); + dumpObjRecGboData(); + break; + case BIFF_OBJTYPE_DROPDOWN: + dumpObjRecRectData(); + dumpObjRecSbsData(); + dumpUnused( 18 ); + dumpFontIdx( "font-idx" ); + dumpUnused( 14 ); + dumpDec< sal_uInt16 >( "bounding-left" ); + dumpDec< sal_uInt16 >( "bounding-top" ); + dumpDec< sal_uInt16 >( "bounding-right" ); + dumpDec< sal_uInt16 >( "bounding-bottom" ); + dumpUnused( 4 ); + dumpObjRecString( "obj-name", nNameLen, true ); + dumpObjRecFmla( "macro", dumpDec< sal_uInt16 >( "macro-size" ) ); + dumpObjRecFmla( "cell-link", dumpDec< sal_uInt16 >( "cell-link-size" ) ); + dumpObjRecLbsData(); + dumpDec< sal_uInt16 >( "type", "OBJ-DROPDOWN-TYPE" ); + dumpDec< sal_uInt16 >( "line-count" ); + dumpDec< sal_uInt16 >( "min-list-width" ); + dumpObjRecString( "text", dumpDec< sal_uInt16 >( "text-len" ), false ); break; } } @@ -2965,137 +3149,307 @@ void WorkbookStreamObject::dumpObjRecBiff8() Output& rOut = out(); BiffInputStream& rStrm = getBiffStream(); NameListRef xRecNames = cfg().getNameList( "OBJ-RECNAMES" ); - bool bLinked = false; + sal_uInt16 nObjType = 0xFFFF; bool bControl = false; bool bCtlsStrm = false; bool bLoop = true; - while( bLoop && (rStrm.getRecLeft() >= 4) ) + while( bLoop && (rStrm.getRemaining() >= 4) ) { rOut.emptyLine(); sal_uInt16 nSubRecId, nSubRecSize; { MultiItemsGuard aMultiGuard( rOut ); writeEmptyItem( "OBJREC" ); - writeHexItem( "pos", rStrm.getRecPos() ); + writeHexItem( "pos", static_cast< sal_uInt32 >( rStrm.tell() ) ); rStrm >> nSubRecId >> nSubRecSize; writeHexItem( "size", nSubRecSize ); writeHexItem( "id", nSubRecId, xRecNames ); } - sal_uInt32 nSubRecStart = rStrm.getRecPos(); + sal_Int64 nSubRecStart = rStrm.tell(); // sometimes the last subrecord has an invalid length - sal_uInt32 nRealRecSize = ::std::min< sal_uInt32 >( nSubRecSize, rStrm.getRecLeft() ); - sal_uInt32 nSubRecEnd = nSubRecStart + nRealRecSize; + sal_Int64 nRealRecSize = ::std::min< sal_Int64 >( nSubRecSize, rStrm.getRemaining() ); + sal_Int64 nSubRecEnd = nSubRecStart + nRealRecSize; IndentGuard aIndGuard( rOut ); switch( nSubRecId ) { - case BIFF_ID_OBJPIOGRBIT: + case BIFF_ID_OBJMACRO: + dumpObjRecFmlaRaw(); + break; + case BIFF_ID_OBJCF: + dumpDec< sal_Int16 >( "clipboard-format", "IMGDATA-FORMAT" ); + break; + case BIFF_ID_OBJFLAGS: { - sal_uInt16 nFlags = dumpHex< sal_uInt16 >( "flags", "OBJPIOGRBIT-FLAGS" ); - bLinked = getFlag( nFlags, BIFF_OBJPIO_LINKED ); - bControl = getFlag( nFlags, BIFF_OBJPIO_CONTROL ); - bCtlsStrm = getFlag( nFlags, BIFF_OBJPIO_CTLSSTREAM ); + sal_uInt16 nFlags = dumpHex< sal_uInt16 >( "flags", "OBJFLAGS-FLAGS" ); + bControl = getFlag( nFlags, BIFF_OBJFLAGS_CONTROL ); + bCtlsStrm = getFlag( nFlags, BIFF_OBJFLAGS_CTLSSTREAM ); } break; case BIFF_ID_OBJPICTFMLA: { - sal_uInt16 nLinkDataSize = dumpDec< sal_uInt16 >( "link-data-size" ); - sal_uInt32 nLinkDataEnd = rStrm.getRecPos() + nLinkDataSize; - { - IndentGuard aIndGuard2( rOut ); - sal_uInt16 nFmlaSize = getFormulaDumper().dumpFormulaSize(); - dumpUnused( 4 ); - getFormulaDumper().dumpNameFormula( "link", nFmlaSize ); - if( dumpDec< sal_uInt8 >( "has-class-name", "OBJPICTFMLA-HASCLASSNAME" ) == 3 ) - { - dumpUniString( "class-name", BIFF_STR_SMARTFLAGS ); - if( ((rStrm.getRecPos() - nSubRecStart) & 1) != 0 ) - dumpHex< sal_uInt8 >( "padding" ); - } - } - if( rStrm.getRecPos() != nLinkDataEnd ) - writeEmptyItem( OOX_DUMP_ERRASCII( "link-data-size" ) ); - if( rStrm.getRecPos() < nLinkDataEnd ) - dumpRemaining( nLinkDataEnd - rStrm.getRecPos() ); - rStrm.seek( nLinkDataEnd ); - if( nLinkDataEnd + 4 <= nSubRecEnd ) + dumpObjRecPictFmla( dumpDec< sal_uInt16 >( "pic-link-size" ) ); + if( rStrm.tell() + 4 <= nSubRecEnd ) { if( bControl && bCtlsStrm ) - { - sal_uInt32 nPos = dumpHex< sal_uInt32 >( "ctls-stream-pos", "CONV-DEC" ); - sal_uInt32 nSize = dumpHex< sal_uInt32 >( "ctls-stream-size", "CONV-DEC" ); - IndentGuard aIndGuard2( rOut ); - rOut.emptyLine(); - dumpFormControl( nPos, nSize ); - rOut.emptyLine(); - } + dumpOcxControl(); else dumpHex< sal_uInt32 >( "ole-storage-id" ); } - if( bControl && (rStrm.getRecPos() + 8 <= nSubRecEnd) ) + if( bControl && (rStrm.tell() + 8 <= nSubRecEnd) ) { - sal_uInt32 nClassIdSize = dumpDec< sal_uInt32 >( "class-id-size" ); - if( nClassIdSize > 0 ) - { - IndentGuard aIndGuard2( rOut ); - sal_uInt32 nClassIdEnd = rStrm.getRecPos() + nClassIdSize; - dumpUnicodeArray( "class-id", static_cast< sal_Int32 >( nClassIdSize / 2 ) ); - rStrm.seek( nClassIdEnd ); - } - sal_uInt16 nCellLinkSize = dumpDec< sal_uInt16 >( "cell-link-size" ); - if( nCellLinkSize > 0 ) - { - IndentGuard aIndGuard2( rOut ); - sal_uInt32 nCellLinkEnd = rStrm.getRecPos() + nCellLinkSize; - sal_uInt16 nFmlaSize = getFormulaDumper().dumpFormulaSize( "cell-link-fmla-size" ); - dumpUnused( 4 ); - getFormulaDumper().dumpNameFormula( "cell-link", nFmlaSize ); - rStrm.seek( nCellLinkEnd ); - } - sal_uInt16 nSrcRangeSize = dumpDec< sal_uInt16 >( "source-range-size" ); - if( nSrcRangeSize > 0 ) + sal_uInt32 nKeySize = dumpDec< sal_uInt32 >( "licence-key-size" ); + if( nKeySize > 0 ) { IndentGuard aIndGuard2( rOut ); - sal_uInt32 nSrcRangeEnd = rStrm.getRecPos() + nSrcRangeSize; - sal_uInt16 nFmlaSize = getFormulaDumper().dumpFormulaSize( "source-range-fmla-size" ); - dumpUnused( 4 ); - getFormulaDumper().dumpNameFormula( "source-range", nFmlaSize ); - rStrm.seek( nSrcRangeEnd ); + sal_Int64 nKeyEnd = rStrm.tell() + nKeySize; + dumpArray( "licence-key", static_cast< sal_Int32 >( nKeySize ) ); + rStrm.seek( nKeyEnd ); } + dumpObjRecFmla( "cell-link", dumpDec< sal_uInt16 >( "cell-link-size" ) ); + dumpObjRecFmla( "source-range", dumpDec< sal_uInt16 >( "source-range-size" ) ); } } break; + case BIFF_ID_OBJCBLS: + dumpDec< sal_uInt16 >( "state", "OBJ-CHECKBOX-STATE" ); + dumpUnused( 4 ); + dumpUnicode( "accelerator" ); + dumpUnicode( "fareast-accelerator" ); + dumpHex< sal_uInt16 >( "checkbox-flags", "OBJ-CHECKBOX-FLAGS" ); + break; + case BIFF_ID_OBJRBO: + dumpUnused( 4 ); + dumpBool< sal_uInt16 >( "first-in-group" ); + break; + case BIFF_ID_OBJSBS: + dumpObjRecSbsData(); + break; + case BIFF_ID_OBJGBODATA: + dumpObjRecGboData(); + break; + case BIFF_ID_OBJEDODATA: + dumpObjRecEdoData(); + break; + case BIFF_ID_OBJRBODATA: + dumpObjRecRboData(); + break; + case BIFF_ID_OBJCBLSDATA: + dumpObjRecCblsData(); + break; + case BIFF_ID_OBJLBSDATA: + dumpObjRecLbsData(); + if( nObjType == BIFF_OBJTYPE_DROPDOWN ) + { + dumpHex< sal_uInt16 >( "dropdown-flags", "OBJ-DROPDOWN-FLAGS" ); + dumpDec< sal_uInt16 >( "line-count" ); + dumpDec< sal_uInt16 >( "min-list-width" ); + dumpObjRecString( "text", dumpDec< sal_uInt16 >( "text-len" ), false ); + } + break; + case BIFF_ID_OBJCBLSFMLA: + case BIFF_ID_OBJSBSFMLA: + dumpObjRecFmlaRaw(); + break; case BIFF_ID_OBJCMO: - dumpDec< sal_uInt16 >( "type", "OBJCMO-TYPE" ); + nObjType = dumpDec< sal_uInt16 >( "type", "OBJ-TYPE" ); dumpDec< sal_uInt16 >( "id" ); dumpHex< sal_uInt16 >( "flags", "OBJCMO-FLAGS" ); dumpUnused( 12 ); break; } // remaining undumped data - if( rStrm.getRecPos() == nSubRecStart ) + if( !rStrm.isEof() && (rStrm.tell() == nSubRecStart) ) dumpRawBinary( nRealRecSize, false ); else - dumpRemaining( nSubRecEnd - rStrm.getRecPos() ); - rStrm.seek( nSubRecStart + nRealRecSize ); + dumpRemainingTo( nSubRecEnd ); } } -void WorkbookStreamObject::dumpFormControl( sal_uInt32 nStrmPos, sal_uInt32 nStrmSize ) +void WorkbookStreamObject::dumpObjRecLineData() { - writeHexItem( "stream-pos", nStrmPos, "CONV-DEC" ); - writeHexItem( "stream-size", nStrmSize, "CONV-DEC" ); + dumpColorIdx( "line-color-idx", false ); + dumpDec< sal_uInt8 >( "line-type", "OBJ-LINETYPE" ); + dumpDec< sal_uInt8 >( "line-weight", "OBJ-LINEWEIGHT" ); + dumpHex< sal_uInt8 >( "line-flags", "OBJ-AUTO-FLAGS" ); +} + +void WorkbookStreamObject::dumpObjRecFillData() +{ + dumpColorIdx( "back-color-idx", false ); + dumpColorIdx( "patt-color-idx", false ); + dumpPatternIdx( EMPTY_STRING, false ); + dumpHex< sal_uInt8 >( "area-flags", "OBJ-AUTO-FLAGS" ); +} + +void WorkbookStreamObject::dumpObjRecRectData() +{ + dumpObjRecFillData(); + dumpObjRecLineData(); + dumpHex< sal_uInt16 >( "frame-style", "OBJ-FRAMESTYLE-FLAGS" ); +} + +void WorkbookStreamObject::dumpObjRecTextDataBiff3( sal_uInt16& ornTextLen, sal_uInt16& ornFormatSize ) +{ + ornTextLen = dumpDec< sal_uInt16 >( "text-len" ); + dumpUnused( 2 ); + ornFormatSize = dumpDec< sal_uInt16 >( "format-run-size" ); + dumpFontIdx( "default-font-idx" ); + dumpUnused( 2 ); + dumpHex< sal_uInt16 >( "flags", "OBJ-TEXT-FLAGS" ); + dumpDec< sal_uInt16 >( "orientation", "TEXTORIENTATION" ); + dumpUnused( 8 ); +} + +void WorkbookStreamObject::dumpObjRecTextDataBiff5( sal_uInt16& ornTextLen, sal_uInt16& ornFormatSize, sal_uInt16& ornLinkSize ) +{ + ornTextLen = dumpDec< sal_uInt16 >( "text-len" ); + dumpUnused( 2 ); + ornFormatSize = dumpDec< sal_uInt16 >( "format-run-size" ); + dumpFontIdx( "default-font-idx" ); + dumpUnused( 2 ); + dumpHex< sal_uInt16 >( "flags", "OBJ-TEXT-FLAGS" ); + dumpDec< sal_uInt16 >( "orientation", "TEXTORIENTATION" ); + dumpUnused( 2 ); + ornLinkSize = dumpDec< sal_uInt16 >( "link-size" ); + dumpUnused( 2 ); + dumpHex< sal_uInt16 >( "button-flags", "OBJ-BUTTON-FLAGS" ); + dumpUnicode( "accelerator" ); + dumpUnicode( "fareast-accelerator" ); +} + +void WorkbookStreamObject::dumpObjRecSbsData() +{ + dumpUnused( 4 ); + dumpDec< sal_uInt16 >( "value" ); + dumpDec< sal_uInt16 >( "min" ); + dumpDec< sal_uInt16 >( "max" ); + dumpDec< sal_uInt16 >( "step" ); + dumpDec< sal_uInt16 >( "page-step" ); + dumpBool< sal_uInt16 >( "horizontal" ); + dumpDec< sal_uInt16 >( "thumb-width" ); + dumpHex< sal_uInt16 >( "scrollbar-flags", "OBJ-SCROLLBAR-FLAGS" ); +} + +void WorkbookStreamObject::dumpObjRecGboData() +{ + dumpUnicode( "accelerator" ); + dumpUnicode( "fareast-accelerator" ); + dumpHex< sal_uInt16 >( "groupbox-flags", "OBJ-GROUPBOX-FLAGS" ); +} + +void WorkbookStreamObject::dumpObjRecEdoData() +{ + dumpDec< sal_uInt16 >( "type", "OBJ-EDIT-TYPE" ); + dumpBool< sal_uInt16 >( "multiline" ); + dumpBool< sal_uInt16 >( "scrollbar" ); + dumpDec< sal_uInt16 >( "listbox-obj-id" ); +} + +void WorkbookStreamObject::dumpObjRecRboData() +{ + dumpDec< sal_uInt16 >( "next-in-group" ); + dumpBool< sal_uInt16 >( "first-in-group" ); +} + +void WorkbookStreamObject::dumpObjRecCblsData() +{ + dumpDec< sal_uInt16 >( "state", "OBJ-CHECKBOX-STATE" ); + dumpUnicode( "accelerator" ); + dumpUnicode( "fareast-accelerator" ); + dumpHex< sal_uInt16 >( "checkbox-flags", "OBJ-CHECKBOX-FLAGS" ); +} + +void WorkbookStreamObject::dumpObjRecLbsData() +{ + dumpObjRecFmla( "source-range", dumpDec< sal_uInt16 >( "source-range-size" ) ); + dumpDec< sal_uInt16 >( "entry-count" ); + dumpDec< sal_uInt16 >( "selected-entry" ); + dumpHex< sal_uInt16 >( "listbox-flags", "OBJ-LISTBOX-FLAGS" ); + dumpDec< sal_uInt16 >( "edit-obj-id" ); +} + +void WorkbookStreamObject::dumpObjRecPadding() +{ + if( getBiffStream().tell() & 1 ) + { + IndentGuard aIndGuard( out() ); + dumpHex< sal_uInt8 >( "padding" ); + } +} + +void WorkbookStreamObject::dumpObjRecString( const String& rName, sal_uInt16 nTextLen, bool bRepeatLen ) +{ + if( nTextLen > 0 ) + { + if( bRepeatLen ) + dumpByteString( rName, BIFF_STR_8BITLENGTH ); + else + writeStringItem( rName, getBiffStream().readCharArray( nTextLen, getBiffData().getTextEncoding() ) ); + dumpObjRecPadding(); + } +} + +void WorkbookStreamObject::dumpObjRecTextFmt( sal_uInt16 nFormatSize ) +{ + BinFontPortionList aPortions; + aPortions.importPortions( getBiffStream(), nFormatSize / 8, BIFF_FONTPORTION_OBJ ); + writeFontPortions( aPortions ); +} + +void WorkbookStreamObject::dumpObjRecFmlaRaw() +{ + sal_uInt16 nFmlaSize = dumpDec< sal_uInt16 >( "fmla-size" ); + dumpUnused( 4 ); + getFormulaDumper().dumpNameFormula( "fmla", nFmlaSize ); + dumpObjRecPadding(); +} + +void WorkbookStreamObject::dumpObjRecFmla( const String& rName, sal_uInt16 nFmlaSize ) +{ + BiffInputStream& rStrm = getBiffStream(); + if( nFmlaSize > 0 ) + { + writeEmptyItem( rName ); + IndentGuard aIndGuard( out() ); + sal_Int64 nStrmEnd = rStrm.tell() + nFmlaSize; + dumpObjRecFmlaRaw(); + if( rStrm.isEof() || (rStrm.tell() != nStrmEnd) ) + writeEmptyItem( OOX_DUMP_ERRASCII( "fmla-size" ) ); + dumpRemainingTo( nStrmEnd ); + } +} + +void WorkbookStreamObject::dumpObjRecPictFmla( sal_uInt16 nFmlaSize ) +{ + BiffInputStream& rStrm = getBiffStream(); + if( nFmlaSize > 0 ) + { + writeEmptyItem( "pic-link" ); + IndentGuard aIndGuard( out() ); + sal_Int64 nStrmEnd = rStrm.tell() + nFmlaSize; + if( (getBiff() == BIFF3) && (nStrmEnd & 1) ) ++nStrmEnd; // BIFF3 size without padding + dumpObjRecFmlaRaw(); + if( rStrm.tell() + 2 <= nStrmEnd ) + { + dumpString( "class-name", BIFF_STR_DEFAULT, BIFF_STR_SMARTFLAGS ); + dumpObjRecPadding(); + } + if( rStrm.isEof() || (rStrm.tell() != nStrmEnd) ) + writeEmptyItem( OOX_DUMP_ERRASCII( "pic-link-size" ) ); + dumpRemainingTo( nStrmEnd ); + } } // ============================================================================ -PivotCacheStreamObject::PivotCacheStreamObject( const ObjectBase& rParent, const ::rtl::OUString& rOutFileName, BinaryInputStreamRef xStrm ) +PivotCacheStreamObject::PivotCacheStreamObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const ::rtl::OUString& rSysFileName ) { - RecordStreamObject::construct( rParent, rOutFileName, xStrm, BIFF8 ); + RecordStreamObject::construct( rParent, rxStrm, BIFF8, rSysFileName ); } -void PivotCacheStreamObject::implDumpRecord() +void PivotCacheStreamObject::implDumpRecordBody() { BiffInputStream& rStrm = getBiffStream(); sal_uInt16 nRecId = rStrm.getRecId(); @@ -3132,7 +3486,7 @@ void PivotCacheStreamObject::implDumpRecord() dumpDec< sal_uInt16 >( "group-items" ); dumpDec< sal_uInt16 >( "base-items" ); dumpDec< sal_uInt16 >( "original-items" ); - if( rStrm.getRecLeft() >= 3 ) + if( rStrm.getRemaining() >= 3 ) dumpUniString( "item-name" ); break; @@ -3147,39 +3501,63 @@ void PivotCacheStreamObject::implDumpRecord() RootStorageObject::RootStorageObject( const DumperBase& rParent ) { - RootStorageObjectBase::construct( rParent ); + OleStorageObject::construct( rParent ); + addPreferredStream( "Book" ); + addPreferredStream( "Workbook" ); } -void RootStorageObject::implDumpStream( BinaryInputStreamRef xStrm, const OUString& rStrgPath, const OUString& rStrmName, const OUString& rSystemFileName ) +void RootStorageObject::implDumpStream( const BinaryInputStreamRef& rxStrm, const OUString& rStrgPath, const OUString& rStrmName, const OUString& rSysFileName ) { - if( rStrgPath.getLength() == 0 ) - { - if( (rStrmName == CREATE_OUSTRING( "Book" )) || (rStrmName == CREATE_OUSTRING( "Workbook" )) ) - WorkbookStreamObject( *this, rSystemFileName, xStrm ).dump(); - else if( (rStrmName == CREATE_OUSTRING( "\005SummaryInformation" )) || (rStrmName == CREATE_OUSTRING( "\005DocumentSummaryInformation" )) ) - OlePropertyStreamObject( *this, rSystemFileName, xStrm ).dump(); - else - InputStreamObject( *this, rSystemFileName, xStrm ).dump(); - } - else if( rStrgPath == CREATE_OUSTRING( "_SX_DB_CUR" ) ) - { - PivotCacheStreamObject( *this, rSystemFileName, xStrm ).dump(); - } + if( (rStrgPath.getLength() == 0) && (rStrmName.equalsAscii( "Book" ) || rStrmName.equalsAscii( "Workbook" )) ) + WorkbookStreamObject( *this, rxStrm, rSysFileName ).dump(); + else if( rStrgPath.equalsAscii( "_SX_DB_CUR" ) ) + PivotCacheStreamObject( *this, rxStrm, rSysFileName ).dump(); + else + OleStorageObject::implDumpStream( rxStrm, rStrgPath, rStrmName, rSysFileName ); +} + +void RootStorageObject::implDumpStorage( const StorageRef& rxStrg, const OUString& rStrgPath, const OUString& rSysPath ) +{ + if( rStrgPath.equalsAscii( "_VBA_PROJECT_CUR" ) ) + VbaProjectStorageObject( *this, rxStrg, rSysPath ).dump(); + else + OleStorageObject::implDumpStorage( rxStrg, rStrgPath, rSysPath ); } // ============================================================================ // ============================================================================ +#define DUMP_BIFF_CONFIG_ENVVAR "OOO_BIFFDUMPER" + Dumper::Dumper( const FilterBase& rFilter ) { - ConfigRef xCfg( new Config( "OOO_BIFFDUMPER" ) ); - DumperBase::construct( rFilter, xCfg ); + ConfigRef xCfg( new Config( DUMP_BIFF_CONFIG_ENVVAR, rFilter ) ); + DumperBase::construct( xCfg ); +} + +Dumper::Dumper( const Reference< XMultiServiceFactory >& rxFactory, const Reference< XInputStream >& rxInStrm, const OUString& rSysFileName ) +{ + if( rxFactory.is() && rxInStrm.is() ) + { + StorageRef xStrg( new OleStorage( rxFactory, rxInStrm, true ) ); + ConfigRef xCfg( new Config( DUMP_BIFF_CONFIG_ENVVAR, rxFactory, xStrg, rSysFileName ) ); + DumperBase::construct( xCfg ); + } } void Dumper::implDump() { - WorkbookStreamObject( *this, getFilter().getFileUrl() + CREATE_OUSTRING( ".dump" ), getRootStream() ).dump(); - RootStorageObject( *this ).dump(); + RootStorageObject aRootStrg( *this ); + if( aRootStrg.isValid() ) + { + aRootStrg.dump(); + } + else if( StorageBase* pRootStrg = cfg().getRootStorage().get() ) + { + // try to dump plain BIFF stream + BinaryInputStreamRef xStrm( new BinaryXInputStream( pRootStrg->openInputStream( OUString() ), false ) ); + WorkbookStreamObject( *this, xStrm, cfg().getSysFileName() ).dump(); + } } // ============================================================================ diff --git a/oox/source/dump/biffdumper.ini b/oox/source/dump/biffdumper.ini new file mode 100644 index 000000000000..99b05ccbf3d0 --- /dev/null +++ b/oox/source/dump/biffdumper.ini @@ -0,0 +1,1818 @@ + +# dumper settings ============================================================ + +# Path to additional configuration data, relative to this file. +include-config-file=dumperbase.ini +include-config-file=dffdumper.ini +include-config-file=oledumper.ini + +# Enable entire dumper (default=off). This option does not affect the option +# 'enable-import'. +# 0=off, 1=on, missing: setting from dumperbase.ini +# enable-dumper=1 + +# Enable import after dumping (default=on). Disabling this option allows +# to dump a file without loading it. This option is independent from the +# 'enable-dumper' option. +# 0=off, 1=on, missing: setting from dumperbase.ini +# enable-import=1 + +# BIFF record settings ------------------------------------------------------- + +# Merge CONTINUE records with leading record (default=on). +# 0=off - show CONTINUE records separately (hex dump) +# 1=on - show contents of leading record together with following CONTINUE +merge-continue-record=1 + +# name lists ================================================================= + +# common --------------------------------------------------------------------- + +unitconverter=CONV-PERCENT-NEG,-1,% +unitconverter=CONV-COLWIDTH,/256,chars + +shortlist=BIFF,0,biff2,biff3,biff4,biff5,biff8 + +constlist=ERRORCODES + 0x00=#NULL! + 0x07=#DIV/0! + 0x0F=#VALUE! + 0x17=#REF! + 0x1D=#NAME? + 0x24=#NUM! + 0x2A=#N/A +end + +shortlist=EGA-COLORS,0,ega-black,ega-white,ega-red,ega-green,ega-blue,ega-yellow,ega-magenta,ega-cyan + +constlist=COLORS-BIFF2 + include=EGA-COLORS + default= + 24=sys-window-text + 25=sys-window-bg + 0x7FFF=sys-window-text +end + +constlist=COLORS-BIFF5 + include=EGA-COLORS + default= + 64=sys-window-text + 65=sys-window-bg + 67=sys-button-face + 77=sys-window-text-chart + 78=sys-window-bg-chart + 79=auto-border-chart + 80=sys-tooltip-bg + 81=sys-tooltip-text + 0x7FFF=sys-window-text +end + +shortlist=BORDERSTYLES-BIFF3,0,none,thin,medium,dash,dot,thick,double,hair + +multilist=BORDERSTYLES-BIFF8 + include=BORDERSTYLES-BIFF3 + 8=medium-dash,thin-dash-dot,medium-dash-dot,thin-dash-dot-dot,medium-dash-dot-dot,slant-dash-dot +end + +multilist=FILLPATTERNS-BIFF3 + 0=no-fill,solid-fill,50%-grey,75%-grey,25%-grey + 5=hor-stripe,ver-stripe,rev-diag-stripe,diag-stripe,diag-crosshatch + 10=thick-diag-crosshatch,thin-hor-stripe,thin-ver-stripe,thin-rev-diag-stripe,thin-diag-stripe + 15=thin-hor-crosshatch,thin-diag-crosshatch,12.5%-grey,6.25%-grey +end + +shortlist=TEXTORIENTATION,0,horizontal,stacked,90°-ccw,90°-cw + +constlist=TEXTROTATION-BIFF8 + default= + 255=stacked +end + +multilist=BUILTIN-FORMATS + quote-names=1 + 0=General,0,0.00,'#,##0','#,##0.00' + 5='"$"#,##0_);\("$"#,##0\)','"$"#,##0_);[Red]\("$"#,##0\)','"$"#,##0.00_);\("$"#,##0.00\)','"$"#,##0.00_);[Red]\("$"#,##0.00\)',0% + 10=0.00%,0.00E+00,# ?/?,# ??/??,M/D/YYYY + 15=D-MMM-YY,D-MMM,MMM-YY,h:mm AM/PM,h:mm:ss AM/PM + 20=h:mm,h:mm:ss,M/D/YYYY h:mm,General,General + 25=General,General,M/D/YYYY,M/D/YYYY,M/D/YYYY + 30=M/D/YYYY,M/D/YYYY,h:mm:ss,h:mm:ss,h:mm:ss + 35=h:mm:ss,M/D/YYYY,'#,##0_);(#,##0)','#,##0_);[Red](#,##0)','#,##0.00_);(#,##0.00)' + 40='#,##0.00_);[Red](#,##0.00)' + 41='_(* #,##0_);_(* \(#,##0\);_(* "-"_);_(@_)' + 42='_("$"* #,##0_);_("$"* \(#,##0\);_("$"* "-"_);_(@_)' + 43='_(* #,##0.00_);_(* \(#,##0.00\);_(* "-"??_);_(@_)' + 44='_("$"* #,##0.00_);_("$"* \(#,##0.00\);_("$"* "-"??_);_(@_)' + 45=mm:ss,[h]:mm:ss,mm:ss.0,##0.0E+0,@ + 50=M/D/YYYY,M/D/YYYY,M/D/YYYY,M/D/YYYY,M/D/YYYY + 55=M/D/YYYY,M/D/YYYY,M/D/YYYY,M/D/YYYY,0 + 60=0.00,'#,##0','#,##0.00','$#,##0_);($#,##0)','$#,##0_);[Red]($#,##0)' + 65='$#,##0.00_);($#,##0.00)','$#,##0.00_);[Red]($#,##0.00)',0%,0.00%,# ?/? + 70=# ??/??,M/D/YYYY,M/D/YYYY,D-MMM-YY,D-MMM + 75=MMM-YY,h:mm,h:mm:ss,M/D/YYYY h:mm,mm:ss + 80=[h]:mm:ss,mm:ss.0 +end + +constlist=CONSTVALUE-TYPE + 0=empty + 1=number + 2=string + 4=boolean + 16=error +end + +# DFF ------------------------------------------------------------------------ + +flagslist=DFF-CLIENTANCHOR-FLAGS + 0x0001=pos-locked + 0x0002=size-locked +end + +# formulas ------------------------------------------------------------------- + +multilist=BASETOKENS-BIFF2 + 0x00=,tExp,tTbl,tAdd,tSub,tMul,tDiv,tPower + 0x08=tConcat,tLT,tLE,tEQ,tGE,tGT,tNE,tIsect + 0x10=tList,tRange,tUplus,tUminus,tPercent,tParen,tMissArg,tStr + 0x18=,tAttr,tSheet,tEndSheet,tErr,tBool,tInt,tNum +end + +constlist=BASETOKENS-BIFF5 + include=BASETOKENS-BIFF2 + exclude=0x1A,0x1B +end + +constlist=BASETOKENS-BIFF8 + include=BASETOKENS-BIFF5 + 0x18=tNlr +end + +constlist=TOKENCLASSES + 0x20=R + 0x40=V + 0x60=A +end + +multilist=CLASSTOKENS-BIFF2 + 0x00=tArray,tFunc,tFuncVar,tName,tRef,tArea,tMemArea,tMemErr + 0x08=tMemNoMem,tMemFunc,tRefErr,tAreaErr,tRefN,tAreaN,tMemAreaN,tMemNoMemN + 0x18=tFuncCE +end + +constlist=CLASSTOKENS-BIFF4 + include=CLASSTOKENS-BIFF2 + exclude=0x18 +end + +multilist=CLASSTOKENS-BIFF5 + include=CLASSTOKENS-BIFF4 + 0x19=tNameX,tRef3d,tArea3d,tRefErr3d,tAreaErr3d +end + +combilist=FUNCID + 0x7FFF=uint16,dec,func-id + 0x8000=command +end + +combilist=PARAMCOUNT-CMD + 0x7F=uint8,dec,count + 0x80=prompt +end + +combilist=REFRELFLAGS + 0x3FFF=uint16,dec,value + 0x4000=col-rel + 0x8000=row-rel +end + +multilist=NLRTYPES + 0x00=,tNlrErr,tNlrRowR,tNlrColR,,,tNlrRowV,tNlrColV + 0x08=,,tNlrRange,tNlrSRange,tNlrSRowR,tNlrSColR,tNlrSRowV,tNlrSColV + 0x10=tNlrRangeErr,,,,,,, + 0x18=,,,,,tNlrSxName,, +end + +combilist=NLRADDFLAGS + 0x3FFFFFFF=uint32,dec,count + 0x80000000=rel +end + +flagslist=ATTRTYPES + 0x01=volatile + 0x02=if + 0x04=choose + 0x08=skip + 0x10=sum + 0x20=assign + 0x40=space +end + +shortlist=ATTRSPACETYPES,0,space-before-token,cr-before-token,space-before-open,cr-before-open,space-before-close,cr-before-close,leading-space + +# record names --------------------------------------------------------------- + +multilist=RECORD-NAMES-BIFF2 + # worksheet records + 0x0000=DIMENSION,BLANK,INTEGER,NUMBER,LABEL,BOOLERR,FORMULA,STRING + 0x0008=ROW,BOF,EOF,INDEX,CALCCOUNT,CALCMODE,PRECISION,REFMODE + 0x0010=DELTA,ITERATION,PROTECT,PASSWORD,HEADER,FOOTER,EXTERNCOUNT,EXTERNSHEET + 0x0018=DEFINEDNAME,WINDOWPROTECT,VERTICALPAGEBREAKS,HORIZONTALPAGEBREAKS,NOTE,SELECTION,FORMAT,BUILTINFMTCOUNT + 0x0020=COLUMNDEFAULT,ARRAY,DATEMODE,EXTERNALNAME,COLWIDTH,DEFAULTROWHEIGHT,LEFTMARGIN,RIGHTMARGIN + 0x0028=TOPMARGIN,BOTTOMMARGIN,PRINTHEADERS,PRINTGRIDLINES,,,,FILEPASS + 0x0030=,FONT,FONT2,PRINTSIZE,,INFOOPTS,DATATABLE,DATATABLE2 + 0x0038=WNDESK,,BEGINPREF,ENDPREF,CONTINUE,WINDOW1,WINDOW2, + 0x0040=BACKUP,PANE,CODEPAGE,XF,IXFE,EFONT,SHOWSCROLL,SHOWFORMULA + 0x0048=STATUSBAR,SHORTMENUS,DDEENABLED,AUTODEC,MENUKEY,PLS|ZOOM,MENUUND,MOVESEL + 0x0050=DCON,DCONREF,DCONNAME,,,DEFCOLWIDTH,, + # worksheet records new in BIFF3, but supported in BIFF2 streams + 0x0200=DIMENSION,BLANK,,NUMBER,LABEL,BOOLERR,, + 0x027E=RK + # BIFF5 style BOF + 0x0809=BOF + # chart records + 0x1000=,CHUNITS,CHCHART,CHSERIES,CHSOURCELINK,,CHDATAFORMAT,CHLINEFORMAT + 0x1008=,CHMARKERFORMAT,CHAREAFORMAT,CHPIEFORMAT,CHATTACHEDLABEL,CHSTRING,, + 0x1010=,,,,CHTYPEGROUP,CHLEGEND,CHSERIESLIST,CHBAR + 0x1018=CHLINE,CHPIE,CHAREA,CHSCATTER,CHCHARTLINE,CHAXIS,CHTICK,CHVALUERANGE + 0x1020=CHLABELRANGE,CHAXISLINE,CHFORMATLINK,,CHDEFAULTTEXT,CHTEXT,CHFONT,CHOBJECTLINK + 0x1028=,,,,,CHARROW,,CHARROWHEAD + 0x1030=,,CHFRAME,CHBEGIN,CHEND,CHPLOTFRAME,CHCHARTSIZE,CHRELPOSITION + 0x1038=CHARROWRELPOS,,CHCHART3D,,,,, +end + +multilist=RECORD-NAMES-BIFF3 + include=RECORD-NAMES-BIFF2 + # worksheet records + exclude=0x0006,0x0008,0x0009,0x000B,0x0018,0x0020,0x0021,0x0023,0x0024,0x0025,0x0031,0x0036,0x0037,0x003E,0x0043,0x0044,0x0045 + 0x0050=,,,,,,BUILTINFMTCOUNT, + 0x0058=TOOLBAR,XCT,CRN,FILESHARING,WRITEACCESS,OBJ,UNCALCED,SAFERECALC + 0x0060=TEMPLATE,INTL,,OBJECTPROTECT,,,, + 0x0068=,,,,,,, + 0x0070=,,,,,,, + 0x0078=,,,,,COLINFO,,IMGDATA + 0x0080=GUTS,SHEETPR,GRIDSET,HCENTER,VCENTER,,WRITEPROT,ADDIN + 0x0088=EDG,PUB,NOTEOFF,LH,COUNTRY,HIDEOBJ,, + 0x0090=SORT,SUB,PALETTE,,LHRECORD,LHNGRAPH,, + 0x0200=,,,,,,FORMULA,STRING + 0x0208=ROW,BOF,,INDEX,,,, + 0x0218=DEFINEDNAME + 0x0221=ARRAY + 0x0223=EXTERNALNAME + 0x0225=DEFAULTROWHEIGHT + 0x0231=FONT + 0x0236=DATATABLE + 0x023E=WINDOW2 + 0x0243=XF + 0x0293=STYLE + # chart records + 0x103C=CHPICFORMAT +end + +multilist=RECORD-NAMES-BIFF4 + include=RECORD-NAMES-BIFF3 + # worksheet/workbook records + exclude=0x0206,0x0209,0x001E,0x0243 + 0x0085=SHEET + 0x0088=,,,,,,SHEETSOFFSET,SHEETHEADER + 0x0090=,,,,,SOUND,SYNC + 0x0098=LPR,STANDARDWIDTH,FNGROUPNAME,,FNGROUPCOUNT,,, + 0x00A0=SCL,PAGESETUP,FNPROTO,PROJEXTSHEET,,,, + 0x00A8=DRAGDROP,COORDLIST,,GCW,,,, + 0x0406=FORMULA + 0x0409=BOF + 0x041E=FORMAT + 0x0443=XF + # chart records + 0x1038=,,,CHMULTILINK,,CHDROPBAR,CHRADARLINE,CHSURFACE +end + +multilist=RECORD-NAMES-BIFF5 + include=RECORD-NAMES-BIFF4 + # worksheet/workbook records + exclude=0x0409,0x0218,0x0223,0x0231,0x0443 + 0x0006=FORMULA + 0x0018=DEFINEDNAME + 0x0023=EXTERNALNAME + 0x0031=FONT + 0x0098=,,,FILTERMODE,,AUTOFILTERINFO,AUTOFILTER, + 0x00A8=,,,,,,SCENMAN,SCENARIO + 0x00B0=SXVIEW,SXVD,SXVI,,SXIVD,SXLI,SXPI, + 0x00B8=DOCROUTE,RECIPNAME,,,SHAREDFMLA,MULTRK,MULTBLANK, + 0x00C0=,MMS,ADDMENU,DELMENU,,SXDI,SXDB,SXFIELD + 0x00C8=SXINDEXLIST,SXDOUBLE,SXBOOLEAN,SXERROR,SXINTEGER,SXSTRING,SXDATETIME,SXEMPTY + 0x00D0=SXTBL,SXTBRGITEM,SXTBPG,OBPROJ,,SXIDSTM,RSTRING,DBCELL + 0x00D8=SXNUMGROUP,SXGROUPINFO,BOOKBOOL,REVERT,SXEXT|PARAMQRY,SCENPROTECT,OLESIZE,UDDESC + 0x00E0=XF,INTERFACEHDR,INTERFACEEND,SXVS,,,, + 0x0206=FORMULA + # chart records + exclude=0x1004,0x102D,0x102F,0x1036,0x1037,0x1038,0x103B + 0x1040=CHRADARAREA,CHAXESSET,,CHLEGENDENTRY,CHPROPERTIES,CHSERGROUP,CHUSEDAXESSETS, + 0x1048=CHPIVOTREF,,CHSERPARENT,CHSERTRENDLINE,,,CHFORMAT,CHPOS + 0x1050=CHFORMATRUNS,CHSOURCELINK,,,,,, + 0x1058=,,,CHSERERRORBAR,,CHSERIESFORMAT,, +end + +multilist=RECORD-NAMES-BIFF8 + include=RECORD-NAMES-BIFF5 + # worksheet/workbook records + 0x00E0=,,,,,CELLMERGING,, + 0x00E8=,IMGDATA,,MSODRAWINGGROUP,MSODRAWING,MSODRAWINGSELECTION,,PHONETICPR + 0x00F0=SXRULE,SXEX,SXFILT,,,,SXNAME,SXSELECT + 0x00F8=SXPAIR,SXFMLA,,SXFORMAT,SST,LABELSST,,EXTSST + 0x0100=SXVDEX,,,SXFORMULA,,,, + 0x0120=,,SXDBEX,,,,, + 0x0130=,,,,,,,CHTRINSERT + 0x0138=CHTRINFO,,,CHTRCELLCONTENT,,TABID,, + 0x0140=CHTRMOVERANGE,,,,,,, + 0x0148=,,,,,CHTRINSERTTAB,, + 0x0158=,,,,,,,LABELRANGES + 0x0160=USESELFS,DSF,XL5MODIFY,,,,, + 0x0190=,,,,,,CHTRHEADER, + 0x01A8=,USERBVIEW,USERSVIEWBEGIN,USERSVIEWEND,,QSI,EXTERNALBOOK,PROT4REV + 0x01B0=CFHEADER,CFRULE,DATAVALIDATIONS,,,DCONBIN,TXO,REFRESHALL + 0x01B8=HYPERLINK,NLRDELNAME,CODENAME,SXFDBTYPE,PROT4REVPASS,,DATAVALIDATION, + 0x0800=SCREENTIP,,,WEBQRYSETTINGS,WEBQRYTABLES,,, + 0x0850=,CHWRAPPEDRECORD,,,,,,CHUNITPROPERTIES + 0x0858=CHPIVOTREF,,,,,,, + 0x0860=,,SHEETLAYOUT,,,,,SHEETPROTECTION + # chart records + 0x1058=,,,,,,,CH3DDATAFORMAT + 0x1060=CHFONTBASE,CHPIEEXT,CHLABELRANGE2,CHDATATABLE,CHPLOTGROWTH,CHSERINDEX,CHESCHERFORMAT,CHPIEEXTSETT +end + +# simple records ------------------------------------------------------------- + +constlist=SIMPLE-RECORDS-BIFF2 + 0x000C=uint16,dec,max-iterations + 0x000D=int16,dec,calc-mode,CALCMODE + 0x000E=uint16,bool,calc-precise + 0x000F=uint16,dec,ref-mode,REFMODE + 0x0010=double,dec,epsilon + 0x0011=uint16,bool,iterate-recursive + 0x0012=uint16,bool,contents-protected + 0x0013=uint16,hex,password-hash + 0x0016=uint16,dec,externsheets + 0x0019=uint16,bool,window-protected + 0x001F=uint16,dec,builtin-fmt-count + 0x0022=uint16,dec,null-date,DATEMODE + 0x0025=uint16,hex,rowheight-flags,DEFROWHEIGHT-FLAGS + 0x0026=double,dec,left-margin,CONV-INCH-TO-CM + 0x0027=double,dec,right-margin,CONV-INCH-TO-CM + 0x0028=double,dec,top-margin,CONV-INCH-TO-CM + 0x0029=double,dec,bottom-margin,CONV-INCH-TO-CM + 0x002A=uint16,bool,print-sheet-headers + 0x002B=uint16,bool,print-gridlines + 0x0040=uint16,bool,backup-on-save + 0x0044=uint16,dec,xf-idx + 0x0045=uint16,dec,font-color-idx,COLORS + 0x0055=uint16,dec,base-col-width + 0x100B=uint16,dec,extrusion,CONV-PERCENT + 0x100C=uint16,hex,flags,CHATTACHEDLABEL-FLAGS + 0x1018=uint16,hex,flags,CHLINE-FLAGS + 0x101A=uint16,hex,flags,CHAREA-FLAGS + 0x101C=uint16,dec,line-type,CHCHARTLINE-TYPE + 0x1021=uint16,dec,axisline-id,CHAXISLINE-ID + 0x1024=uint16,dec,text-idx + 0x1026=uint16,dec,font-idx,FONTNAMES + 0x1045=uint16,dec,group-idx + 0x1046=uint16,dec,used-axessets + 0x104A=uint16,dec,series-idx + 0x104E=uint16,dec,fmt-idx,FORMATS +end + +constlist=SIMPLE-RECORDS-BIFF3 + include=SIMPLE-RECORDS-BIFF2 + 0x0056=uint16,dec,builtin-fmt-count + 0x005E=uint16,unused + 0x005F=uint16,bool,recalc-on-save + 0x0063=uint16,bool,objects-protected + 0x0081=uint16,hex,flags,SHEETPR-FLAGS + 0x0082=uint16,bool,print-gridlines-changed + 0x0083=uint16,bool,horizontal-centered + 0x0084=uint16,bool,vertical-centered + 0x008D=uint16,dec,object-mode,HIDEOBJ +end + +constlist=SIMPLE-RECORDS-BIFF4 + include=SIMPLE-RECORDS-BIFF3 + 0x008E=uint32,hex,stream-pos,CONV-DEC + 0x0099=uint16,dec,default-col-width,CONV-COLWIDTH + 0x009C=uint16,dec,func-group-count + 0x103D=uint16,dec,bar-dist + 0x103E=uint16,hex,flags,CHRADAR-FLAGS + 0x103F=uint16,hex,flags,CHSURFACE-FLAGS +end + +constlist=SIMPLE-RECORDS-BIFF5 + include=SIMPLE-RECORDS-BIFF4 + 0x00C9=double,dec,value + 0x00CA=uint16,bool,value + 0x00CB=uint16,hex,error-code,ERRORCODES + 0x00CC=int16,dec,value + 0x00D5=uint16,hex,pivotcache-stream-id + 0x00D8=uint16,hex,flags,SXNUMGROUP-FLAGS + 0x00DA=uint16,bool,strip-cached-values + 0x00DD=uint16,bool,scenarios-protected + 0x00E3=uint16,dec,source-type,SXVS-TYPE + 0x1040=uint16,hex,flags,CHRADAR-FLAGS + 0x105D=uint16,hex,flags,CHSERIESFORMAT-FLAGS +end + +constlist=SIMPLE-RECORDS-BIFF8 + include=SIMPLE-RECORDS-BIFF5 + 0x00E1=uint16,dec,codepage,CODEPAGES + 0x0160=uint16,bool,use-nat-lang-refs + 0x0161=uint16,bool,double-stream + 0x01AF=uint16,bool,revlog-protected + 0x01B7=uint16,bool,refresh-all + 0x01BB=uint16,dec,sql-data-type,SXFDBTYPE-DATATYPE + 0x01BC=uint16,hex,password-hash + 0x1065=uint16,dec,series-idx +end + +# ARRAY ---------------------------------------------------------------------- + +flagslist=ARRAY-FLAGS-BIFF2 + 0x0001=recalc-always +end + +flagslist=ARRAY-FLAGS-BIFF3 + include=ARRAY-FLAGS-BIFF2 + 0x0002=recalc-onload +end + +# BOF ------------------------------------------------------------------------ + +constlist=BOF-BIFFTYPE + 0x0000=from-id + 0x0007=biff2 + 0x0200=biff2 + 0x0300=biff3 + 0x0400=biff4 + 0x0500=biff5 + 0x0600=biff8 +end + +constlist=BOF-SHEETTYPE + 0x0005=globals + 0x0006=vb-module + 0x0010=sheet + 0x0020=chart + 0x0040=macro + 0x0100=workspace +end + +flagslist=BOF-HISTORY-FLAGS + 0x00000001=windows + 0x00000002=risc + 0x00000004=beta + 0x00000008=win-any + 0x00000010=mac-any + 0x00000020=beta-any + 0x00000100=risc-any + # missing mac here? +end + +# CALCMODE ------------------------------------------------------------------- + +shortlist=CALCMODE,-1,automatic-no-table,manual,automatic + +# CFRULE --------------------------------------------------------------------- + +shortlist=CFRULE-TYPE,1,value,formula +shortlist=CFRULE-OPERATOR,0,none,between,not-between,equal,not-equal,greater-than,less-than,greater-equal,less-equal + +flagslist=CFRULE-FLAGS + ignore=0x00380080 + 0x00000001=!hor-align-used + 0x00000002=!vert-align-used + 0x00000004=!text-wrap-used + 0x00000008=!rotation-used + 0x00000010=!justify-lastline-used + 0x00000020=!indent-used + 0x00000040=!shrinktofit-used + 0x00000100=!cell-locked-used + 0x00000200=!cell-hidden-used + 0x00000400=!left-border-used + 0x00000800=!right-border-used + 0x00001000=!top-border-used + 0x00002000=!bottom-border-used + 0x00004000=!tl-to-br-used + 0x00008000=!bl-to-tr-used + 0x00010000=!fill-pattern-used + 0x00020000=!fg-color-idx-used + 0x00040000=!bg-color-idx-used + 0x04000000=font-block + 0x08000000=alignment-block + 0x10000000=border-block + 0x20000000=pattern-block + 0x40000000=protection-block + 0x80000000=!text-dir-used +end + +combilist=CFRULE-ALIGNMENT + 0x07=uint8,dec,hor-align,XF-HORALIGN + 0x08=text-wrap + 0x70=uint8,dec,ver-align,XF-VERALIGN + 0x80=justify-lastline +end + +combilist=CFRULE-INDENT + 0x000F=uint8,dec,indent + 0x0010=shrink-to-fit + 0x00C0=uint8,dec,text-dir,XF-TEXTDIRECTION +end + +flagslist=CFRULE-FONTFLAGS + 0x00000002=italic + 0x00000008=outline + 0x00000010=shadow + 0x00000020=condense + 0x00000040=extend + 0x00000080=strikeout +end + +flagslist=CFRULE-FONTUSEDFLAGS + 0x00000002=!italic-used + 0x00000008=!outline-used + 0x00000010=!shadow-used + 0x00000020=!condense-used + 0x00000040=!extend-used + 0x00000080=!strikeout-used +end + +constlist=CFRULE-FONTUSED + 0=used + 1=not-used +end + +combilist=CFRULE-BORDERCOLOR2 + 0x0000007F=uint8,dec,top-color,COLORS + 0x00003F80=uint8,dec,bottom-color,COLORS + 0x001FC000=uint8,dec,diag-color,COLORS + 0x01E00000=uint8,dec,diag-style,BORDERSTYLES +end + +combilist=CFRULE-FILLBLOCK + 0x0000FC00=uint8,dec,fill-pattern,FILLPATTERNS + 0x007F0000=uint8,dec,fg-color-idx,COLORS + 0x3F800000=uint8,dec,bg-color-idx,COLORS +end + +flagslist=CFRULE-PROTECTION-FLAGS + 0x0001=locked + 0x0002=formula-hidden +end + +# CH3DDATAFORMAT ------------------------------------------------------------- + +shortlist=CH3DDATAFORMAT-BASE,0,rectangular,circular +shortlist=CH3DDATAFORMAT-TOP,0,straight,sharp,trunc + +# CHAREA --------------------------------------------------------------------- + +flagslist=CHAREA-FLAGS + 0x0001=stacked + 0x0002=percent + 0x0004=shadow +end + +# CHAREAFORMAT --------------------------------------------------------------- + +flagslist=CHAREAFORMAT-FLAGS + 0x0001=auto + 0x0002=swap-negative +end + +# CHATTACHEDLABEL ------------------------------------------------------------ + +flagslist=CHATTACHEDLABEL-FLAGS + 0x0001=show-value + 0x0002=show-percent + 0x0004=show-categ-percent + 0x0008=smoothed + 0x0010=show-categ + 0x0020=show-bubble +end + +# CHAXESSET ------------------------------------------------------------------ + +shortlist=CHAXESSET-ID,0,primary,secondary + +# CHAXIS --------------------------------------------------------------------- + +shortlist=CHAXIS-TYPE,0,x-axis,y-axis,z-axis + +# CHAXISLINE ----------------------------------------------------------------- + +shortlist=CHAXISLINE-ID,0,axisline,major-grid,minor-grid,wall + +# CHBAR ---------------------------------------------------------------------- + +flagslist=CHBAR-FLAGS + 0x0001=horizontal + 0x0002=stacked + 0x0004=percent + 0x0008=shadow +end + +# CHCHART3D ------------------------------------------------------------------ + +flagslist=CHCHART3D-FLAGS + ignore=0x0010 + 0x0001=real3d + 0x0002=clustered + 0x0004=auto-height + 0x0020=2d-plotarea +end + +# CHTYPEGROUP ---------------------------------------------------------------- + +flagslist=CHTYPEGROUP-FLAGS + 0x0001=varied-colors +end + +# CHCHARTLINE ---------------------------------------------------------------- + +shortlist=CHCHARTLINE-TYPE,0,drop-line,hi-lo-line,series-connector + +# CHDATAFORMAT --------------------------------------------------------------- + +constlist=CHDATAFORMAT-POINTIDX + default= + -1=all-points +end + +constlist=CHDATAFORMAT-FORMATIDX + default= + -3=axesset-global +end + +flagslist=CHDATAFORMAT-FLAGS + 0x0001=excel4-colors +end + +# CHFRAME -------------------------------------------------------------------- + +shortlist=CHFRAME-FORMAT,0,standard,,,,shadow + +flagslist=CHFRAME-FLAGS + 0x0001=auto-size + 0x0002=auto-pos +end + +# CHFRAMEPOS ----------------------------------------------------------------- + +shortlist=CHFRAMEPOS-OBJTYPE,2,any,,,legend +shortlist=CHFRAMEPOS-SIZEMODE,1,manual,auto + +# CHLABELRANGE --------------------------------------------------------------- + +flagslist=CHLABELRANGE-FLAGS + 0x0001=cross-between-categ + 0x0002=maximum-axis-cross + 0x0004=reverse-order +end + +# CHLABELRANGE2 -------------------------------------------------------------- + +flagslist=CHLABELRANGE2-FLAGS + 0x0001=auto-minimum + 0x0002=auto-maximum + 0x0004=auto-major + 0x0008=auto-minor + 0x0010=date-axis + 0x0020=auto-base + 0x0040=auto-axis-cross + 0x0080=auto-date +end + +# CHLEGEND ------------------------------------------------------------------- + +shortlist=CHLEGEND-DOCKPOS,0,bottom,top-left,top,right,left,,,manual +shortlist=CHLEGEND-SPACING,0,close,medium,open + +flagslist=CHLEGEND-FLAGS + 0x0001=docked + 0x0002=auto-series + 0x0004=auto-pos-x + 0x0008=auto-pos-y + 0x0010=stacked + 0x0020=data-table +end + +# CHLINE --------------------------------------------------------------------- + +flagslist=CHLINE-FLAGS + 0x0001=stacked + 0x0002=percent + 0x0004=shadow +end + +# CHLINEFORMAT --------------------------------------------------------------- + +shortlist=CHLINEFORMAT-LINETYPE,0,solid,dash,dot,dash-dot,dash-dot-dot,none,25%-pattern,50%-pattern,75%-pattern +shortlist=CHLINEFORMAT-LINEWEIGHT,-1,hair,thin,medium,thick + +flagslist=CHLINEFORMAT-FLAGS + 0x0001=auto + 0x0004=axis-enabled +end + +# CHMARKERFORMAT ------------------------------------------------------------- + +shortlist=CHMARKERFORMAT-TYPE,0,none,square,diamond,triangle,cross,star,dow-jones,std-dev,circle,plus + +flagslist=CHMARKERFORMAT-FLAGS + 0x0001=auto + 0x0010=no-fill + 0x0020=no-border +end + +# CHOBJECTLINK --------------------------------------------------------------- + +shortlist=CHOBJECTLINK-TARGET,0,none,title,y-axis,x-axis,datapoint,legend,none,z-axis,,,,,axis-unit + +constlist=CHOBJECTLINK-POINT + default= + -2=unknown + -1=all-points +end + +# CHPICFORMAT ---------------------------------------------------------------- + +shortlist=CHPICFORMAT-BITMAP-MODE,1,stretched,stacked,stacked-scaled + +constlist=CHPICFORMAT-IMAGE-FORMAT + 2=wmf + 9=bmp + 19=?emf +end + +shortlist=CHPICFORMAT-ENV,1,windows,apple + +combilist=CHPICFORMAT-FLAGS + 0x00FF=uint16,dec,environment,CHPICFORMAT-ENV + 0x0100=format-only + 0x0200=top-bottom + 0x0400=front-back + 0x0800=left-right +end + +# CHPIE ---------------------------------------------------------------------- + +flagslist=CHPIE-FLAGS + 0x0001=shadow + 0x0002=connectors +end + +# CHRADAR, CHRADARAREA ------------------------------------------------------- + +flagslist=CHRADAR-FLAGS + 0x0001=axis-labels + 0x0002=shadow +end + +# CHPROPERTIES --------------------------------------------------------------- + +shortlist=CHPROPERTIES-EMPTYCELLS,0,do-not-plot,as-zero,interpolated + +flagslist=CHPROPERTIES-FLAGS + 0x0001=manual-format + 0x0002=plot-visible-only + 0x0004=fixed-size + 0x0008=manual-plotarea +end + +# CHSCATTER ------------------------------------------------------------------ + +shortlist=CHSCATTER-SIZETYPE,0,none,area,width + +flagslist=CHSCATTER-FLAGS + 0x0001=bubbles + 0x0002=show-negative + 0x0004=shadow +end + +# CHSERERRORBAR -------------------------------------------------------------- + +shortlist=CHSERERRORBAR-TYPE,1,x-plus,x-minus,y-plus,y-minus +shortlist=CHSERERRORBAR-SOURCE,1,percent,fixed,std-deviation,custom,std-error + +# CHSERIES ------------------------------------------------------------------- + +shortlist=CHSERIES-TYPE,0,date,numeric,sequence,text + +# CHSERIESFORMAT ------------------------------------------------------------- + +flagslist=CHSERIESFORMAT-FLAGS + 0x0001=spline + 0x0002=bubbles-3d + 0x0004=shadow +end + +# CHSERTRENDLINE ------------------------------------------------------------- + +shortlist=CHSERTRENDLINE-TYPE,0,poynomial,exponential,logarithmic,power,moving-average + +# CHSOURCELINK --------------------------------------------------------------- + +shortlist=CHSOURCELINK-TARGET,0,title,values,category,bubbles +shortlist=CHSOURCELINK-TYPE,0,default,constant,sheet-link + +flagslist=CHSOURCELINK-FLAGS + 0x0001=custom-numfmt +end + +# CHSTRING ------------------------------------------------------------------- + +shortlist=CHSTRING-TYPE,0,text,category-default,value-default,x-prefix,x-postfix,y-prefix,y-postfix,comment + +# CHSURFACE ------------------------------------------------------------------ + +flagslist=CHSURFACE-FLAGS + 0x0001=filled + 0x0002=shadow +end + +# CHTEXT --------------------------------------------------------------------- + +shortlist=CHTEXT-HORALIGN,1,left,center,right,block,distribute +shortlist=CHTEXT-VERALIGN,1,top,center,bottom,block,distribute +shortlist=CHTEXT-FILLMODE,1,transparent,opaque + +combilist=CHTEXT-FLAGS-BIFF2 + 0x0001=auto-color + 0x0002=show-symbol + 0x0004=show-value + 0x0008=vertical + 0x0010=auto-text + 0x0020=default-format + 0x0040=deleted + 0x0080=auto-fill +end + +combilist=CHTEXT-FLAGS-BIFF3 + include=CHTEXT-FLAGS-BIFF2 + 0x0700=uint8,dec,orientation,TEXTORIENTATION +end + +combilist=CHTEXT-FLAGS-BIFF5 + include=CHTEXT-FLAGS-BIFF3 + 0x0800=show-categ-percent + 0x1000=show-percent +end + +combilist=CHTEXT-FLAGS-BIFF8 + include=CHTEXT-FLAGS-BIFF5 + 0x2000=show-bubble-size + 0x4000=show-categ +end + +multilist=CHTEXT-PLACEMENT + default= + 0=context,outside,inside,center,axis,above,below,left,right,auto,manual +end + +# CHTICK --------------------------------------------------------------------- + +shortlist=CHTICK-TYPE,0,none,inside,outside,both +# TODO: really different label positions in BIFF2-BIFF4? +shortlist=CHTICK-LABELPOS-BIFF2,0,none,near,below,above +shortlist=CHTICK-LABELPOS-BIFF5,0,none,below,above,near + +flagslist=CHTICK-FLAGS-BIFF2 + 0x0001=auto-color + 0x0002=auto-fill +end + +combilist=CHTICK-FLAGS-BIFF3 + include=CHTICK-FLAGS-BIFF2 + 0x001C=uint8,dec,orientation,TEXTORIENTATION + 0x0020=auto-rotation +end + +# CHUNITPROPERTIES ----------------------------------------------------------- + +shortlist=CHUNITPROPERTIES-PRESET,-1,manual,none,hundred,thousand,(10000),(100000),million,(10million),(100million),billion,trillion + +flagslist=CHUNITPROPERTIES-FLAGS + 0x0002=show-unit +end + +# CHVALUERANGE --------------------------------------------------------------- + +flagslist=CHVALUERANGE-FLAGS + ignore=0x0100 + 0x0001=auto-minimum + 0x0002=auto-maximum + 0x0004=auto-major + 0x0008=auto-minor + 0x0010=auto-axis-cross + 0x0020=logarithmic + 0x0040=reverse-order + 0x0080=maximum-axis-cross +end + +# COLINFO -------------------------------------------------------------------- + +combilist=COLINFO-FLAGS + 0x0001=hidden + 0x0002=custom-width + 0x0004=best-fit + 0x0008=show-phonetic + 0x0700=uint8,dec,outline-level + 0x1000=outline-collapsed +end + +# DATATABLE ------------------------------------------------------------------ + +flagslist=DATATABLE-FLAGS-BIFF3 + 0x0001=recalc-always + 0x0002=recalc-on-load + 0x0004=row-table + 0x0008=table-2d +end + +flagslist=DATATABLE-FLAGS-BIFF8 + include=DATATABLE-FLAGS-BIFF3 + 0x0010=ref1-deleted + 0x0020=ref2-deleted +end + +# DATAVALIDATION ------------------------------------------------------------- + +combilist=DATAVALIDATION-FLAGS + 0x0000000F=uint8,dec,type,DATAVALIDATION-TYPE + 0x00000070=uint8,dec,error-style,DATAVALIDATION-ERRORSTYLE + 0x00000080=string-list + 0x00000100=ignore-empty + 0x00000200=no-dropdown + 0x00040000=show-input-box + 0x00080000=show-error-box + 0x00F00000=uint8,dec,operator,DATAVALIDATION-OPERATOR +end + +shortlist=DATAVALIDATION-TYPE,0,any,whole,decimal,list,date,time,text-length,custom +shortlist=DATAVALIDATION-OPERATOR,0,between,not-between,equal,not-equal,greater-than,less-than,greater-equal,less-equal +shortlist=DATAVALIDATION-ERRORSTYLE,0,error,warning,info + +# DATAVALIDATIONS ------------------------------------------------------------ + +flagslist=DATAVALIDATIONS-FLAGS + 0x0001=input-box-visible + 0x0002=input-box-at-cell + 0x0004=cached +end + +# DATEMODE ------------------------------------------------------------------- + +shortlist=DATEMODE,0,1899-12-31,1904-01-01 + +# DEFINEDNAME ---------------------------------------------------------------- + +flagslist=DEFINEDNAME-FLAGS-BIFF2 + 0x02=macro + 0x04=complex +end + +shortlist=DEFINEDNAME-MACROTYPE-BIFF2,0,none,function,procedure + +flagslist=DEFINEDNAME-FLAGS-BIFF3 + 0x0001=hidden + 0x0002=function + 0x0004=command + 0x0008=macro + 0x0010=complex + 0x0020=builtin +end + +combilist=DEFINEDNAME-FLAGS-BIFF4 + include=DEFINEDNAME-FLAGS-BIFF3 + 0x0FC0=uint16,dec,func-group,DEFINEDNAME-FUNCGROUP +end + +combilist=DEFINEDNAME-FLAGS-BIFF5 + include=DEFINEDNAME-FLAGS-BIFF4 + 0x0004=vba + 0x1000=binary +end + +shortlist=DEFINEDNAME-FUNCGROUP,0,none,financial,date-time,math-trig,statistical,lookup-ref,database,text,logical,information,commands,customizing,macro-control,dde-external,user-definded + +constlist=DEFINEDNAME-SHEETIDX + default= + 0=global +end + +# DEFROWHEIGHT --------------------------------------------------------------- + +combilist=DEFROWHEIGHT-FLAGS-BIFF2 + 0x7FFF=uint16,dec,row-height,CONV-TWIP-TO-PT + 0x8000=unchanged +end + +flagslist=DEFROWHEIGHT-FLAGS-BIFF3 + 0x0001=custom-height + 0x0002=hidden + 0x0004=thick-top + 0x0008=thick-bottom +end + +# EXTERNALBOOK --------------------------------------------------------------- + +constlist=EXTERNALBOOK-KEY + 0x0401=self-reference + 0x3A01=analysis-addin +end + +# EXTERNALNAME --------------------------------------------------------------- + +flagslist=EXTERNALNAME-FLAGS-BIFF3 + 0x0001=builtin + 0x0002=automatic + 0x0004=pic-link + 0x0008=dde-stddocumentname +end + +combilist=EXTERNALNAME-FLAGS-BIFF5 + include=EXTERNALNAME-FLAGS-BIFF3 + 0x0010=ole-link + 0x7FE0=uint16,dec,clipboard-format + 0x8000=iconified +end + +# EXTERNSHEET ---------------------------------------------------------------- + +constlist=EXTERNSHEET-IDX-BIFF8 + default= + -1=deleted + -2=special +end + +# FONT ----------------------------------------------------------------------- + +flagslist=FONT-FLAGS + 0x0001=bold + 0x0002=italic + 0x0004=underline + 0x0008=strikeout + 0x0010=outline + 0x0020=shadow + 0x0040=condense + 0x0080=extend +end + +multilist=FONT-UNDERLINE + 0x00=none,single,double + 0x21=single-acc,double-acc +end + +shortlist=FONT-ESCAPEMENT,0,none,superscript,subscript + +# FORMULA -------------------------------------------------------------------- + +flagslist=FORMULA-FLAGS-BIFF2 + 0x0001=recalc-always +end + +flagslist=FORMULA-FLAGS-BIFF3 + include=FORMULA-FLAGS-BIFF2 + 0x0002=recalc-onload +end + +flagslist=FORMULA-FLAGS-BIFF5 + include=FORMULA-FLAGS-BIFF3 + 0x0008=shared-fmla +end + +shortlist=FORMULA-RESULTTYPE,0,string,boolean,error,empty + +# HIDEOBJ -------------------------------------------------------------------- + +shortlist=HIDEOBJ,0,show,placeholder,hide + +# IMGDATA -------------------------------------------------------------------- + +constlist=IMGDATA-FORMAT + -1=none + 2=wmf-pict + 9=bmp + 14=native +end + +shortlist=IMGDATA-ENV,1,windows,apple + +# NOTE ----------------------------------------------------------------------- + +flagslist=NOTE-FLAGS-BIFF8 + 0x0002=visible +end + +# OBJ ------------------------------------------------------------------------ + +# object types --- + +multilist=OBJ-TYPE-BIFF3 + 0=group,line,rectangle,oval,arc,chart,textbox,button,picture +end + +multilist=OBJ-TYPE-BIFF4 + include=OBJ-TYPE-BIFF3 + 9=polygon +end + +multilist=OBJ-TYPE-BIFF5 + include=OBJ-TYPE-BIFF4 + 10=,checkbox,optionbutton,edit,label,dialog,spin,scrollbar,listbox,groupbox + 20=dropdown +end + +multilist=OBJ-TYPE-BIFF8 + include=OBJ-TYPE-BIFF5 + 25=note + 30=drawing +end + +# flags and constants --- + +flagslist=OBJ-FLAGS-BIFF3 + 0x0001=selected + 0x0002=auto-size + 0x0004=auto-move + 0x0010=protected + 0x0080=grouped + 0x0100=hidden + 0x0200=visible +end + +flagslist=OBJ-FLAGS-BIFF4 + include=OBJ-FLAGS-BIFF3 + 0x0400=printable +end + +flagslist=OBJ-AUTO-FLAGS + 0x01=auto +end + +multilist=OBJ-LINETYPE + 0=solid,dash,dot,dash-dot,dash-dot-dot,25%-pattern,50%-pattern,75%-pattern + 255=none +end + +shortlist=OBJ-LINEWEIGHT,0,hair,thin,medium,thick + +shortlist=OBJ-ARROWHEAD-TYPE,0,none,open,filled,double-end-open,double-end-filled +shortlist=OBJ-ARROWHEAD-WIDTH,0,narrow,medium,wide +shortlist=OBJ-ARROWHEAD-LENGTH,0,short,medium,long + +combilist=OBJ-LINEENDS + 0x000F=uint8,dec,arrowhead-type,OBJ-ARROWHEAD-TYPE + 0x00F0=uint8,dec,arrowhead-width,OBJ-ARROWHEAD-WIDTH + 0x0F00=uint8,dec,arrowhead-length,OBJ-ARROWHEAD-LENGTH +end + +shortlist=OBJ-LINEDIR,0,topleft-to-bottomright,topright-to-bottomleft,bottomright-to-topleft,bottomleft-to-topright + +shortlist=OBJ-ARC-QUADRANT,0,upper-right,upper-left,lower-left,lower-right + +combilist=OBJ-FRAMESTYLE-FLAGS + 0x0001=rounded + 0x0002=shadow + 0x03FC=uint16,dec,rounded-diameter +end + +shortlist=OBJ-HORALIGN,0,none,left,center,right,justify +shortlist=OBJ-VERALIGN,0,none,top,center,bottom,justify + +combilist=OBJ-TEXT-FLAGS + 0x000E=uint16,dec,hor-align,OBJ-HORALIGN + 0x0070=uint16,dec,ver-align,OBJ-VERALIGN + 0x0080=auto-size + 0x0200=text-locked + 0x0400=selected +end + +flagslist=OBJ-PICTURE-FLAGS + 0x0001=auto-size + 0x0002=linked + 0x0008=symbol +end + +flagslist=OBJ-POLYGON-FLAGS + 0x0100=closed +end + +flagslist=OBJ-CHART-FLAGS-BIFF5 + 0x0001=linked-to-sheet +end + +flagslist=OBJ-BUTTON-FLAGS-BIFF5 + 0x0001=default-btn + 0x0002=help-btn + 0x0004=cancel-btn + 0x0008=close-btn +end + +shortlist=OBJ-CHECKBOX-STATE-BIFF5,0,unchecked,checked,tristate + +flagslist=OBJ-CHECKBOX-FLAGS-BIFF5 + 0x0001=flat + 0x0002=box-only +end + +shortlist=OBJ-EDIT-TYPE-BIFF5,0,text,integer,double,reference,formula + +flagslist=OBJ-SCROLLBAR-FLAGS-BIFF5 + 0x0001=visible + 0x0002=slider-only + 0x0004=tracking + 0x0008=flat +end + +combilist=OBJ-LISTBOX-FLAGS-BIFF5 + 0x0004=linked-edit + 0x0008=flat + 0x0030=uint8,dec,selection-type,OBJ-LISTBOX-SELTYPE-BIFF5 +end + +shortlist=OBJ-LISTBOX-SELTYPE-BIFF5,0,single,multi,range + +flagslist=OBJ-GROUPBOX-FLAGS-BIFF5 + 0x0001=flat +end + +combilist=OBJ-DROPDOWN-FLAGS-BIFF5 + 0x0003=uint8,dec,type,OBJ-DROPDOWN-TYPE-BIFF5 + 0x0008=filtered +end + +shortlist=OBJ-DROPDOWN-TYPE-BIFF5,0,listbox,combobox,simple,max + +multilist=OBJ-RECNAMES-BIFF8 + 0x0000=OBJEND,,,,OBJMACRO,,OBJGMO,OBJCF + 0x0008=OBJFLAGS,OBJPICTFMLA,OBJCBLS,OBJRBO,OBJSBS,OBJNTS,OBJSBSFMLA,OBJGBODATA + 0x0010=OBJEDODATA,OBJRBODATA,OBJCBLSDATA,OBJLBSDATA,OBJCBLSFMLA,OBJCMO,, +end + +flagslist=OBJFLAGS-FLAGS + 0x0001=manual-size + 0x0002=linked + 0x0004=update-on-print + 0x0008=symbol + 0x0010=control + 0x0020=ctls-stream + 0x0080=camera-pic + 0x0100=default-size + 0x0200=auto-load +end + +flagslist=OBJCMO-FLAGS + 0x0001=locked + 0x0004=default-size + 0x0008=published + 0x0010=printable + 0x0080=disabled + 0x0100=auxiliary + 0x0200=recalc-on-load + 0x1000=recalc-always + 0x2000=auto-line + 0x4000=auto-area +end + +# PAGESETUP ------------------------------------------------------------------ + +multilist=PAGESETUP-PAPERSIZE + 0=undefined,letter,letter-small,tabloid,ledger,legal,statement,executive,a3,a4 + 10=a4-small,a5,b4,b5,folio,quarto,10x14,11x17,note,envelope-9 + 20=envelope-10,envelope-11,envelope-12,envelope-14,c,d,e,envelope-dl,envelope-c5,envelope-c3 + 30=envelope-c4,envelope-c6,envelope-c65,envelope-b4,envelope-b5,envelope-b6,envelope-italy,envelope-monarch,envelope-6-3/4,us-standard-fanfold + 40=german-standard-fanfold,german-legal-fanfold,b4,japanese-dbl-postcaed,9x11,10x11,15x11,, + 50=envelope-invite,letter-extra,legal-extra,tabloid-extra,a4-extra,letter-transverse,a4-transverse,letter-extra-transverse,super-a-a4,super-b-a3,letter-plus + 60=a4-plus,a5-transverse,jis-b5-transverse,a3-extra,a5-extra,b5-extra,a2,a3-transverse,a3-extra-transverse +end + +constlist=PAGESETUP-SCALETOPAGES + default= + 0=automatic +end + +flagslist=PAGESETUP-FLAGS-BIFF4 + 0x0001=print-in-rows + 0x0002=portrait + 0x0004=uninitialized + 0x0008=black-and-white +end + +flagslist=PAGESETUP-FLAGS-BIFF5 + include=PAGESETUP-FLAGS-BIFF4 + 0x0010=draft-quality + 0x0020=print-notes + 0x0040=default-orientation + 0x0080=use-first-page +end + +combilist=PAGESETUP-FLAGS-BIFF8 + include=PAGESETUP-FLAGS-BIFF5 + 0x0200=print-notes-at-end + 0x0C00=uint8,dec,print-errors,PAGESETUP-PRINTERRORS +end + +shortlist=PAGESETUP-PRINTERRORS,0,displayed,none,as-dashes,as-na + +unitconverter=PAGESETUP-DPI,1,dpi + +# PANE ----------------------------------------------------------------------- + +shortlist=PANE-ID,0,bottom-right,top-right,bottom-left,top-left + +# PHONETICPR ----------------------------------------------------------------- + +shortlist=PHONETICPR-TYPE,0,halfwidth-katakana,fullwidth-katakana,hiragana,no-conversion +shortlist=PHONETICPR-ALIGNMENT,0,no-control,left,center,distributed + +combilist=PHONETICPR-FLAGS + ignore=0x0030 + 0x0003=uint8,dec,type,PHONETICPR-TYPE + 0x000C=uint8,dec,alignment,PHONETICPR-ALIGNMENT +end + +# PROJEXTSHEET --------------------------------------------------------------- + +shortlist=PROJEXTSHEET-TYPE,0,sheet,macro,chart + +# REFMODE -------------------------------------------------------------------- + +shortlist=REFMODE,0,R1C1,A1 + +# ROW ------------------------------------------------------------------------ + +combilist=ROW-HEIGHT + 0x7FFF=uint16,dec,height,CONV-TWIP-TO-PT + 0x8000=default-height +end + +combilist=ROW-FLAGS + ignore=0x00000100 + 0x00000007=uint8,dec,outline-level + 0x00000010=outline-collapsed + 0x00000020=hidden + 0x00000040=custom-height + 0x00000080=custom-format + 0x0FFF0000=uint16,dec,custom-xf-idx + 0x10000000=thick-top + 0x20000000=thick-bottom + 0x40000000=show-phonetic +end + +# SHEET ---------------------------------------------------------------------- + +shortlist=SHEET-STATE,0,visible,hidden,very-hidden +shortlist=SHEET-TYPE,0,worksheet,macrosheet,chartsheet,,,,vb-module + +# SHEETPR -------------------------------------------------------------------- + +shortlist=SHEETPR-WINDOWPOS,0,tiled,horizontal,vertical,cascaded + +flagslist=SHEETPR-FLAGS-BIFF3 + 0x0001=show-autopagebreaks + 0x0020=outline-auto-style + 0x0040=outline-symbols-below + 0x0080=outline-symbols-right + 0x0100=fit-to-pages + 0x0200=skip-linked-values + 0x0400=show-row-outline + 0x0800=show-column-outline +end + +flagslist=SHEETPR-FLAGS-BIFF4 + include=SHEETPR-FLAGS-BIFF3 + 0x3000=uint8,dec,window-pos,SHEETPR-WINDOWPOS + 0x4000=lotus-expr-eval + 0x8000=lotus-formula-edit +end + +flagslist=SHEETPR-FLAGS-BIFF5 + include=SHEETPR-FLAGS-BIFF4 + exclude=0x0200,0x3000 + 0x0010=dialog-sheet +end + +# SHEETPROTECTION ------------------------------------------------------------ + +flagslist=SHEETPROTECTION-FLAGS + 0x0001=edit-object + 0x0002=edit-scenario + 0x0004=format-cell + 0x0008=format-column + 0x0010=format-row + 0x0020=insert-column + 0x0040=insert-row + 0x0080=insert-hyperlink + 0x0100=delete-column + 0x0200=delete-row + 0x0400=select-locked + 0x0800=sort + 0x1000=use-autofilter + 0x2000=pivottable-report + 0x4000=select-unlocked +end + +# STYLE ---------------------------------------------------------------------- + +combilist=STYLE-FLAGS + 0x0FFF=uint16,dec,xf-idx + 0x8000=builtin +end + +shortlist=STYLE-BUILTIN,0,normal,rowlevel,collevel,comma,currency,percent,comma-0,currency-0,hyperlink,followed-hyperlink + +# common for pivot tables ---------------------------------------------------- + +constlist=SX-NAMELEN + default= + 0xFFFF=name-in-cache +end + +# SXDB ----------------------------------------------------------------------- + +flagslist=SXDB-FLAGS + 0x0001=save-data + 0x0002=invalid + 0x0004=refresh-on-load + 0x0008=opt-cache + 0x0010=backgr-query + 0x0020=enable-refresh +end + +constlist=SXDB-TYPE + 1=worksheet + 2=external + 4=consolidation + 8=scenario +end + +# SXDI ----------------------------------------------------------------------- + +shortlist=SXDI-FUNC,0,sum,count-all,average,max,min,product,count-num,std-dev,std-dev-p,variance,variance-p +shortlist=SXDI-FORMAT,0,normal,diff-from,percent-of,percent-diff-from,running-total-in,percent-of-row,percent-of-column,percent-of-total,index + +multilist=SXDI-BASEITEM + default= + 0x7FFB=previous-item,next-item +end + +# SXEXT ---------------------------------------------------------------------- + +combilist=SXEXT-FLAGS + 0x0007=uint8,dec,source-type,SXEXT-SOURCETYPE + 0x0008=odbc-connection + 0x0010=odbc-sql + 0x0020=server-pagefields + 0x0040=webquery + 0x0080=save-password + 0x0100=tables-html-only +end + +shortlist=SXEXT-SOURCETYPE,1,odbc,dao,,webquery + +# SXFDBTYPE ------------------------------------------------------------------ + +shortlist=SXFDBTYPE-DATATYPE,0,unknown,char,numeric,decimal,integer,small-int,float,real,double,datetime,,,var-char + +# SXFIELD -------------------------------------------------------------------- + +combilist=SXFIELD-FLAGS + 0x0001=has-items + 0x0002=postpone-items + 0x0004=calculated + 0x0008=has-child + 0x0010=numeric-group + 0x0020=16bit-indexes + 0x0DE0=uint16,hex,data-type,SXFIELD-TYPE,noshift +end + +constlist=SXFIELD-TYPE + 0x0000=none + 0x0480=string-only + 0x0520=integer-optdouble + 0x0560=double-only + 0x05A0=string-integer-optdouble + 0x05E0=string-double-only + 0x0900=date-only + 0x0980=date-empty-only + 0x0D00=date-number + 0x0D80=date-string-optnumber +end + +# SXLI ----------------------------------------------------------------------- + +shortlist=SXLI-ITEMTYPE,0,data,default,sum,count-num,average,max,min,product,count-num,std-dev,std-dev-p,variance,variance-p,grandtotal,blank-line + +combilist=SXLI-FLAGS + 0x0001=field-name + 0x01FE=uint16,dec,data-field-idx + 0x0200=subtotal + 0x0400=blocktotal + 0x0800=grandtotal + 0x1000=multi-data +end + +# SXNUMGROUP ----------------------------------------------------------------- + +combilist=SXNUMGROUP-FLAGS + 0x0001=auto-min + 0x0002=auto-max + 0x003C=uint8,dec,data-type,SXNUMGROUP-TYPE +end + +shortlist=SXNUMGROUP-TYPE,1,second,minute,hour,day,month,quarter,year,numeric + +# SXVD ----------------------------------------------------------------------- + +flagslist=SXVD-AXISTYPE + 0x0001=row + 0x0002=column + 0x0004=page + 0x0008=data +end + +flagslist=SXVD-SUBTOTALS + 0x0001=default + 0x0002=sum + 0x0004=count-all + 0x0008=average + 0x0010=max + 0x0020=min + 0x0040=product + 0x0080=count-num + 0x0100=std-dev + 0x0200=std-dev-p + 0x0400=variance + 0x0800=variance-p +end + +# SXVDEX --------------------------------------------------------------------- + +combilist=SXVDEX-FLAGS + 0x00000001=show-all-items + 0x00000002=drag-to-row + 0x00000004=drag-to-column + 0x00000008=drag-to-page + 0x00000010=drag-to-hide + 0x00000080=server-based + 0x00000200=autosort + 0x00000400=autosort-ascending + 0x00000800=autoshow + 0x00001000=autoshow-top-values + 0x00002000=calculated + 0x00200000=layout-report + 0x00400000=layout-blank + 0x00800000=layout-top + 0xFF000000=uint8,dec,autoshow-item-count +end + +# SXVI ----------------------------------------------------------------------- + +multilist=SXVI-ITEMTYPE + 0=data,default,sum,count-num,average,max,min,product,count-num,std-dev,std-dev-p,variance,variance-p,grandtotal + 254=page,none +end + +flagslist=SXVI-FLAGS + 0x0001=hidden + 0x0002=hide-detail + 0x0004=calculated + 0x0008=missing +end + +# SXVIEW --------------------------------------------------------------------- + +flagslist=SXVIEW-FLAGS + 0x0001=row-grandtotals + 0x0002=column-grandtotals + 0x0008=auto-format + 0x0010=size-auto-format + 0x0020=font-auto-format + 0x0040=align-auto-format + 0x0080=border-auto-format + 0x0100=pattern-auto-format + 0x0200=number-auto-format +end + +# SXVS ----------------------------------------------------------------------- + +flagslist=SXVS-TYPE + 0x0001=spreadsheet + 0x0002=extern + 0x0004=consolidation-area + 0x0008=pivot-table + 0x0010=scenario +end + +# TXO ------------------------------------------------------------------------ + +combilist=TXO-FLAGS + 0x000E=uint16,dec,hor-align,OBJ-HORALIGN + 0x0070=uint16,dec,ver-align,OBJ-VERALIGN + 0x0200=text-locked +end + +# WINDOW1 -------------------------------------------------------------------- + +flagslist=WINDOW1-FLAGS + 0x0001=hidden + 0x0002=minimized + 0x0008=show-horizontal-scroll + 0x0010=show-vertical-scroll + 0x0020=show-tabbar +end + +unitconverter=WINDOW1-TABBARRATIO,/10,% + +# WINDOW2 -------------------------------------------------------------------- + +flagslist=WINDOW2-FLAGS-BIFF3 + 0x0001=show-formulas + 0x0002=show-gridlines + 0x0004=show-headings + 0x0008=frozen-panes + 0x0010=show-zeros + 0x0020=default-gridcolor + 0x0040=right-to-left + 0x0080=show-outline-symbols + 0x0100=remove-split-with-freeze +end + +flagslist=WINDOW2-FLAGS-BIFF5 + include=WINDOW2-FLAGS-BIFF3 + 0x0200=sheet-selected + 0x0400=sheet-active +end + +flagslist=WINDOW2-FLAGS-BIFF8 + include=WINDOW2-FLAGS-BIFF5 + 0x0800=pagebreak-mode +end + +# XF ------------------------------------------------------------------------- + +shortlist=XF-HORALIGN,0,general,left,center,right,fill,block,center-across-sel,distribute +shortlist=XF-VERALIGN,0,top,center,bottom,justify,distribute +shortlist=XF-TEXTDIRECTION,0,context,left-to-right,right-to-left + +flagslist=XF-PROTECTION-FLAGS + 0x01=locked + 0x02=formula-hidden + 0x04=style-xf +end + +flagslist=XF-USEDATTRIBS-FLAGS + 0x04=format + 0x08=font + 0x10=alignment + 0x20=border + 0x40=area + 0x80=protection +end + +combilist=XF-STYLEFLAGS-BIFF2 + 0x07=uint8,dec,hor-align,XF-HORALIGN + 0x08=left-border + 0x10=right-border + 0x20=top-border + 0x40=bottom-border + 0x80=fill +end + +combilist=XF-TYPEFLAGS-BIFF2 + 0x3F=uint8,dec,fmt-idx,FORMATS + 0x40=locked + 0x80=formula-hidden +end + +flagslist=XF-TYPEFLAGS-BIFF3 + include=XF-PROTECTION-FLAGS +end + +combilist=XF-TYPEFLAGS-BIFF4 + include=XF-TYPEFLAGS-BIFF3 + 0xFFF0=uint16,dec,parent-xf-idx +end + +combilist=XF-ALIGNMENT-BIFF3 + 0x0007=uint8,dec,hor-align,XF-HORALIGN + 0x0008=text-wrap + 0xFFF0=uint16,dec,parent-xf-idx +end + +combilist=XF-ALIGNMENT-BIFF4 + 0x07=uint8,dec,hor-align,XF-HORALIGN + 0x08=text-wrap + 0x30=uint8,dec,ver-align,XF-VERALIGN + 0xC0=uint8,dec,orientation,TEXTORIENTATION +end + +combilist=XF-ALIGNMENT-BIFF5 + 0x07=uint8,dec,hor-align,XF-HORALIGN + 0x08=text-wrap + 0x70=uint8,dec,ver-align,XF-VERALIGN + 0x80=justify-lastline +end + +combilist=XF-ORIENTATTRIBS-BIFF5 + include=XF-USEDATTRIBS-FLAGS + 0x03=uint8,dec,orientation,TEXTORIENTATION +end + +combilist=XF-TEXTFLAGS-BIFF8 + 0x0F=uint8,dec,indent + 0x10=shrink-to-fit + 0xC0=uint8,dec,text-dir,XF-TEXTDIRECTION +end + +combilist=XF-FILL-BIFF3 + 0x003F=uint8,dec,fill-pattern,FILLPATTERNS + 0x07C0=uint8,dec,fg-color-idx,COLORS + 0xF800=uint8,dec,bg-color-idx,COLORS +end + +combilist=XF-BORDER-BIFF3 + 0x00000007=uint8,dec,top-style,BORDERSTYLES + 0x000000F8=uint8,dec,top-color,COLORS + 0x00000700=uint8,dec,left-style,BORDERSTYLES + 0x0000F800=uint8,dec,left-color,COLORS + 0x00070000=uint8,dec,bottom-style,BORDERSTYLES + 0x00F80000=uint8,dec,bottom-color,COLORS + 0x07000000=uint8,dec,right-style,BORDERSTYLES + 0xF8000000=uint8,dec,right-color,COLORS +end + +combilist=XF-FILL-BIFF5 + 0x0000007F=uint8,dec,fg-color-idx,COLORS + 0x00003F80=uint8,dec,bg-color-idx,COLORS + 0x003F0000=uint8,dec,fill-pattern,FILLPATTERNS + 0x01C00000=uint8,dec,bottom-style,BORDERSTYLES + 0xFE000000=uint8,dec,bottom-color,COLORS +end + +combilist=XF-BORDER-BIFF5 + 0x00000007=uint8,dec,top-style,BORDERSTYLES + 0x00000038=uint8,dec,left-style,BORDERSTYLES + 0x000001C0=uint8,dec,right-style,BORDERSTYLES + 0x0000FE00=uint8,dec,top-color,COLORS + 0x007F0000=uint8,dec,left-color,COLORS + 0x3F800000=uint8,dec,right-color,COLORS +end + +combilist=XF-BORDERSTYLE-BIFF8 + 0x000F=uint8,dec,left-style,BORDERSTYLES + 0x00F0=uint8,dec,right-style,BORDERSTYLES + 0x0F00=uint8,dec,top-style,BORDERSTYLES + 0xF000=uint8,dec,bottom-style,BORDERSTYLES +end + +combilist=XF-BORDERCOLOR1-BIFF8 + 0x007F=uint8,dec,left-color,COLORS + 0x3F80=uint8,dec,right-color,COLORS + 0x4000=diag-tl-to-br + 0x8000=diag-bl-to-tr +end + +combilist=XF-BORDERCOLOR2-BIFF8 + 0x0000007F=uint8,dec,top-color,COLORS + 0x00003F80=uint8,dec,bottom-color,COLORS + 0x001FC000=uint8,dec,diag-color,COLORS + 0x01E00000=uint8,dec,diag-style,BORDERSTYLES + 0xFC000000=uint8,dec,fill-pattern,FILLPATTERNS +end + +combilist=XF-FILLCOLOR-BIFF8 + 0x007F=uint8,dec,fg-color-idx,COLORS + 0x3F80=uint8,dec,bg-color-idx,COLORS +end + +# BIFF2 XF index field ------------------------------------------------------- + +constlist=XFINDEX-BIFF2 + default= + 63=from-ixfe +end + +combilist=CELL-XFINDEX-BIFF2 + 0x3F=uint8,dec,xf-idx,XFINDEX-BIFF2 + 0x40=locked + 0x80=formula-hidden +end + +combilist=CELL-XFFORMAT-BIFF2 + 0x3F=uint8,dec,fmt-idx,FORMATS + 0xC0=uint8,dec,font-idx,FONTNAMES +end + +combilist=CELL-XFSTYLE-BIFF2 + include=XF-STYLEFLAGS-BIFF2 +end + +# ============================================================================ + diff --git a/oox/source/dump/biffdumperconfig.dat b/oox/source/dump/biffdumperconfig.dat index ed0b02b0a6a8..e69de29bb2d1 100644 --- a/oox/source/dump/biffdumperconfig.dat +++ b/oox/source/dump/biffdumperconfig.dat @@ -1,1796 +0,0 @@ - -# dumper settings ============================================================ - -# Path to additional configuration data, relative to this file. -include-config-file=dumperconfig.dat -include-config-file=dffdumperconfig.dat -include-config-file=olestoragedumperconfig.dat - -# Enable entire dumper (default=off). This option does not affect the option -# 'enable-import'. -# 0=off, 1=on -enable-dumper=1 - -# Enable import after dumping (default=on). Disabling this option allows -# to dump a file without loading it. This option is independent from the -# 'enable-dumper' option. -# 0=off, 1=on -enable-import=1 - -# BIFF record settings ------------------------------------------------------- - -# Show total stream position of the record (default=on). -# 0=off, 1=on -show-record-pos=0 - -# Show total record size in bytes (including CONTINUE records, if enabled, -# see 'merge-continue-record' option) (default=on). -# 0=off, 1=on -show-record-size=1 - -# Show record identifier (default=on). -# 0=off, 1=on -show-record-id=1 - -# Show record name, if known (default=on). -# 0=off, 1=on -show-record-name=1 - -# Show record contents (default=on). -# 0=off, 1=on -show-record-body=1 - -# Merge CONTINUE records with leading record (default=on). -# 0=off - show CONTINUE records separately (hex dump) -# 1=on - show contents of leading record together with following CONTINUE -merge-continue-record=1 - -# name maps ================================================================== -# -# List of constants -# ----------------- -# Defines names for specific values. -# -# constlist = <LISTNAME> -# default = <constname> (default=?err:no-name) -# include = <LISTNAME>[,<LISTNAME>...] -# exclude = <value>[,<value>...] -# quote-names = 0|1|false|true (default=0) -# <value> = <constname> -# end -# -# List of multiple contants per line -# ---------------------------------- -# Defines names for contiguous ranges of values. -# -# multilist = <LISTNAME> -# default = <constname> (default=?err:no-name) -# ignore-empty = 0|1|false|true (default=1) -# include = <LISTNAME>[,<LISTNAME>...] -# exclude = <value>[,<value>...] -# <firstvalue> = <constname>[,<constname>...] -# end -# -# List of multiple contants, shortened format -# ------------------------------------------- -# Defines names for a contiguous range of values. The entire list definition -# is given in a single text line. -# -# shortlist = <LISTNAME>,<firstvalue>,<constname>[,<constname>...] -# -# List of flags -# ------------- -# Defines names for single bits in a bit field. -# -# flagslist = <LISTNAME> -# ignore = <bitfield> (default=0) -# include = <LISTNAME>[,<LISTNAME>...] -# exclude = <bitfield>[,<bitfield>...] -# <bitmask> = [!]<constname> -# end -# -# List of flags and values in a bitfield -# -------------------------------------- -# Defines names for single bits and for embedded values in a bit field. -# -# combilist = <LISTNAME> -# ignore = <bitfield> (default=0) -# include = <LISTNAME>[,<LISTNAME>...] -# exclude = <bitmask>[,<bitmask>...] -# <bitmask> = [!]<constname> -# <bitfield> = <datatype>,<dataformat>,<constname>[,<LISTNAME>] -# end -# -# Unit converter -# -------------- -# Converts values and appends a unit name. -# -# unitconverter = <LISTNAME>,[/]<factor>,<unitname> - -# common --------------------------------------------------------------------- - -unitconverter=CONV-PERCENT-NEG,-1,% -unitconverter=CONV-COLWIDTH,/256,chars - -shortlist=BIFF,0,biff2,biff3,biff4,biff5,biff8 - -constlist=ERRORCODES - 0x00=#NULL! - 0x07=#DIV/0! - 0x0F=#VALUE! - 0x17=#REF! - 0x1D=#NAME? - 0x24=#NUM! - 0x2A=#N/A -end - -shortlist=EGA-COLORS,0,ega-black,ega-white,ega-red,ega-green,ega-blue,ega-yellow,ega-magenta,ega-cyan - -constlist=COLORS-BIFF2 - include=EGA-COLORS - default= - 24=sys-window-text - 25=sys-window-bg - 0x7FFF=sys-window-text -end - -constlist=COLORS-BIFF5 - include=EGA-COLORS - default= - 64=sys-window-text - 65=sys-window-bg - 67=sys-button-face - 77=sys-window-text-chart - 78=sys-window-bg-chart - 79=auto-border-chart - 80=sys-tooltip-bg - 81=sys-tooltip-text - 0x7FFF=sys-window-text -end - -shortlist=BORDERSTYLES-BIFF3,0,none,thin,medium,dash,dot,thick,double,hair - -multilist=BORDERSTYLES-BIFF8 - include=BORDERSTYLES-BIFF3 - 8=medium-dash,thin-dash-dot,medium-dash-dot,thin-dash-dot-dot,medium-dash-dot-dot,slant-dash-dot -end - -multilist=FILLPATTERNS-BIFF3 - 0=no-fill,solid-fill,50%-grey,75%-grey,25%-grey - 5=hor-stripe,ver-stripe,rev-diag-stripe,diag-stripe,diag-crosshatch - 10=thick-diag-crosshatch,thin-hor-stripe,thin-ver-stripe,thin-rev-diag-stripe,thin-diag-stripe - 15=thin-hor-crosshatch,thin-diag-crosshatch,12.5%-grey,6.25%-grey -end - -shortlist=TEXTORIENTATION,0,horizontal,stacked,90°-ccw,90°-cw - -constlist=TEXTROTATION-BIFF8 - default= - 255=stacked -end - -multilist=BUILTIN-FORMATS - quote-names=1 - 0=General,0,0.00,'#,##0','#,##0.00' - 5='"$"#,##0_);\("$"#,##0\)','"$"#,##0_);[Red]\("$"#,##0\)','"$"#,##0.00_);\("$"#,##0.00\)','"$"#,##0.00_);[Red]\("$"#,##0.00\)',0% - 10=0.00%,0.00E+00,# ?/?,# ??/??,M/D/YYYY - 15=D-MMM-YY,D-MMM,MMM-YY,h:mm AM/PM,h:mm:ss AM/PM - 20=h:mm,h:mm:ss,M/D/YYYY h:mm,General,General - 25=General,General,M/D/YYYY,M/D/YYYY,M/D/YYYY - 30=M/D/YYYY,M/D/YYYY,h:mm:ss,h:mm:ss,h:mm:ss - 35=h:mm:ss,M/D/YYYY,'#,##0_);(#,##0)','#,##0_);[Red](#,##0)','#,##0.00_);(#,##0.00)' - 40='#,##0.00_);[Red](#,##0.00)' - 41='_(* #,##0_);_(* \(#,##0\);_(* "-"_);_(@_)' - 42='_("$"* #,##0_);_("$"* \(#,##0\);_("$"* "-"_);_(@_)' - 43='_(* #,##0.00_);_(* \(#,##0.00\);_(* "-"??_);_(@_)' - 44='_("$"* #,##0.00_);_("$"* \(#,##0.00\);_("$"* "-"??_);_(@_)' - 45=mm:ss,[h]:mm:ss,mm:ss.0,##0.0E+0,@ - 50=M/D/YYYY,M/D/YYYY,M/D/YYYY,M/D/YYYY,M/D/YYYY - 55=M/D/YYYY,M/D/YYYY,M/D/YYYY,M/D/YYYY,0 - 60=0.00,'#,##0','#,##0.00','$#,##0_);($#,##0)','$#,##0_);[Red]($#,##0)' - 65='$#,##0.00_);($#,##0.00)','$#,##0.00_);[Red]($#,##0.00)',0%,0.00%,# ?/? - 70=# ??/??,M/D/YYYY,M/D/YYYY,D-MMM-YY,D-MMM - 75=MMM-YY,h:mm,h:mm:ss,M/D/YYYY h:mm,mm:ss - 80=[h]:mm:ss,mm:ss.0 -end - -constlist=CONSTVALUE-TYPE - 0=empty - 1=number - 2=string - 4=boolean - 16=error -end - -# formulas ------------------------------------------------------------------- - -multilist=BASETOKENS-BIFF2 - 0x00=,tExp,tTbl,tAdd,tSub,tMul,tDiv,tPower - 0x08=tConcat,tLT,tLE,tEQ,tGE,tGT,tNE,tIsect - 0x10=tList,tRange,tUplus,tUminus,tPercent,tParen,tMissArg,tStr - 0x18=,tAttr,tSheet,tEndSheet,tErr,tBool,tInt,tNum -end - -constlist=BASETOKENS-BIFF5 - include=BASETOKENS-BIFF2 - exclude=0x1A,0x1B -end - -constlist=BASETOKENS-BIFF8 - include=BASETOKENS-BIFF5 - 0x18=tNlr -end - -constlist=TOKENCLASSES - 0x20=R - 0x40=V - 0x60=A -end - -multilist=CLASSTOKENS-BIFF2 - 0x00=tArray,tFunc,tFuncVar,tName,tRef,tArea,tMemArea,tMemErr - 0x08=tMemNoMem,tMemFunc,tRefErr,tAreaErr,tRefN,tAreaN,tMemAreaN,tMemNoMemN - 0x18=tFuncCE -end - -constlist=CLASSTOKENS-BIFF4 - include=CLASSTOKENS-BIFF2 - exclude=0x18 -end - -multilist=CLASSTOKENS-BIFF5 - include=CLASSTOKENS-BIFF4 - 0x19=tNameX,tRef3d,tArea3d,tRefErr3d,tAreaErr3d -end - -combilist=FUNCID - 0x7FFF=uint16,dec,func-id - 0x8000=command -end - -combilist=PARAMCOUNT-CMD - 0x7F=uint8,dec,count - 0x80=prompt -end - -combilist=REFRELFLAGS - 0x3FFF=uint16,dec,value - 0x4000=col-rel - 0x8000=row-rel -end - -multilist=NLRTYPES - 0x00=,tNlrErr,tNlrRowR,tNlrColR,,,tNlrRowV,tNlrColV - 0x08=,,tNlrRange,tNlrSRange,tNlrSRowR,tNlrSColR,tNlrSRowV,tNlrSColV - 0x10=tNlrRangeErr,,,,,,, - 0x18=,,,,,tNlrSxName,, -end - -combilist=NLRADDFLAGS - 0x3FFFFFFF=uint32,dec,count - 0x80000000=rel -end - -flagslist=ATTRTYPES - 0x01=volatile - 0x02=if - 0x04=choose - 0x08=skip - 0x10=sum - 0x20=assign - 0x40=space -end - -shortlist=ATTRSPACETYPES,0,space-before-token,cr-before-token,space-before-open,cr-before-open,space-before-close,cr-before-close,leading-space - -# record names --------------------------------------------------------------- - -multilist=RECORD-NAMES-BIFF2 - # worksheet records - 0x0000=DIMENSION,BLANK,INTEGER,NUMBER,LABEL,BOOLERR,FORMULA,STRING - 0x0008=ROW,BOF,EOF,INDEX,CALCCOUNT,CALCMODE,PRECISION,REFMODE - 0x0010=DELTA,ITERATION,PROTECT,PASSWORD,HEADER,FOOTER,EXTERNCOUNT,EXTERNSHEET - 0x0018=DEFINEDNAME,WINDOWPROTECT,VERTICALPAGEBREAKS,HORIZONTALPAGEBREAKS,NOTE,SELECTION,FORMAT,BUILTINFMTCOUNT - 0x0020=COLUMNDEFAULT,ARRAY,DATEMODE,EXTERNALNAME,COLWIDTH,DEFAULTROWHEIGHT,LEFTMARGIN,RIGHTMARGIN - 0x0028=TOPMARGIN,BOTTOMMARGIN,PRINTHEADERS,PRINTGRIDLINES,,,,FILEPASS - 0x0030=,FONT,FONT2,PRINTSIZE,,INFOOPTS,DATATABLE,DATATABLE2 - 0x0038=WNDESK,,BEGINPREF,ENDPREF,CONTINUE,WINDOW1,WINDOW2, - 0x0040=BACKUP,PANE,CODEPAGE,XF,IXFE,EFONT,SHOWSCROLL,SHOWFORMULA - 0x0048=STATUSBAR,SHORTMENUS,DDEENABLED,AUTODEC,MENUKEY,PLS|ZOOM,MENUUND,MOVESEL - 0x0050=DCON,DCONREF,DCONNAME,,,DEFCOLWIDTH,, - # worksheet records new in BIFF3, but supported in BIFF2 streams - 0x0200=DIMENSION,BLANK,,NUMBER,LABEL,BOOLERR,, - 0x027E=RK - # BIFF5 style BOF - 0x0809=BOF - # chart records - 0x1000=,CHUNITS,CHCHART,CHSERIES,CHSOURCELINK,,CHDATAFORMAT,CHLINEFORMAT - 0x1008=,CHMARKERFORMAT,CHAREAFORMAT,CHPIEFORMAT,CHATTACHEDLABEL,CHSTRING,, - 0x1010=,,,,CHTYPEGROUP,CHLEGEND,CHSERIESLIST,CHBAR - 0x1018=CHLINE,CHPIE,CHAREA,CHSCATTER,CHCHARTLINE,CHAXIS,CHTICK,CHVALUERANGE - 0x1020=CHLABELRANGE,CHAXISLINE,CHFORMATLINK,,CHDEFAULTTEXT,CHTEXT,CHFONT,CHOBJECTLINK - 0x1028=,,,,,CHARROW,,CHARROWHEAD - 0x1030=,,CHFRAME,CHBEGIN,CHEND,CHPLOTFRAME,CHCHARTSIZE,CHRELPOSITION - 0x1038=CHARROWRELPOS,,CHCHART3D,,,,, -end - -multilist=RECORD-NAMES-BIFF3 - include=RECORD-NAMES-BIFF2 - # worksheet records - exclude=0x0006,0x0008,0x0009,0x000B,0x0018,0x0020,0x0021,0x0023,0x0024,0x0025,0x0031,0x0036,0x0037,0x003E,0x0043,0x0044,0x0045 - 0x0050=,,,,,,BUILTINFMTCOUNT, - 0x0058=TOOLBAR,XCT,CRN,FILESHARING,WRITEACCESS,OBJ,UNCALCED,SAFERECALC - 0x0060=TEMPLATE,INTL,,OBJECTPROTECT,,,, - 0x0068=,,,,,,, - 0x0070=,,,,,,, - 0x0078=,,,,,COLINFO,,IMDATA - 0x0080=GUTS,SHEETPR,GRIDSET,HCENTER,VCENTER,,WRITEPROT,ADDIN - 0x0088=EDG,PUB,NOTEOFF,LH,COUNTRY,HIDEOBJ,, - 0x0090=SORT,SUB,PALETTE,,LHRECORD,LHNGRAPH,, - 0x0200=,,,,,,FORMULA,STRING - 0x0208=ROW,BOF,,INDEX,,,, - 0x0218=DEFINEDNAME - 0x0221=ARRAY - 0x0223=EXTERNALNAME - 0x0225=DEFAULTROWHEIGHT - 0x0231=FONT - 0x0236=DATATABLE - 0x023E=WINDOW2 - 0x0243=XF - 0x0293=STYLE - # chart records - 0x103C=CHPICFORMAT -end - -multilist=RECORD-NAMES-BIFF4 - include=RECORD-NAMES-BIFF3 - # worksheet/workbook records - exclude=0x0206,0x0209,0x001E,0x0243 - 0x0085=SHEET - 0x0088=,,,,,,SHEETSOFFSET,SHEETHEADER - 0x0090=,,,,,SOUND,SYNC - 0x0098=LPR,STANDARDWIDTH,FNGROUPNAME,,FNGROUPCOUNT,,, - 0x00A0=SCL,PAGESETUP,FNPROTO,PROJEXTSHEET,,,, - 0x00A8=DRAGDROP,COORDLIST,,GCW,,,, - 0x0406=FORMULA - 0x0409=BOF - 0x041E=FORMAT - 0x0443=XF - # chart records - 0x1038=,,,CHMULTILINK,,CHDROPBAR,CHRADARLINE,CHSURFACE -end - -multilist=RECORD-NAMES-BIFF5 - include=RECORD-NAMES-BIFF4 - # worksheet/workbook records - exclude=0x0409,0x0218,0x0223,0x0231,0x0443 - 0x0006=FORMULA - 0x0018=DEFINEDNAME - 0x0023=EXTERNALNAME - 0x0031=FONT - 0x0098=,,,FILTERMODE,,AUTOFILTERINFO,AUTOFILTER, - 0x00A8=,,,,,,SCENMAN,SCENARIO - 0x00B0=SXVIEW,SXVD,SXVI,,SXIVD,SXLI,SXPI, - 0x00B8=DOCROUTE,RECIPNAME,,,SHAREDFMLA,MULTRK,MULTBLANK, - 0x00C0=,MMS,ADDMENU,DELMENU,,SXDI,SXDB,SXFIELD - 0x00C8=SXINDEXLIST,SXDOUBLE,SXBOOLEAN,SXERROR,SXINTEGER,SXSTRING,SXDATETIME,SXEMPTY - 0x00D0=SXTBL,SXTBRGITEM,SXTBPG,OBPROJ,,SXIDSTM,RSTRING,DBCELL - 0x00D8=SXNUMGROUP,SXGROUPINFO,BOOKBOOL,REVERT,SXEXT|PARAMQRY,SCENPROTECT,OLESIZE,UDDESC - 0x00E0=XF,INTERFACEHDR,INTERFACEEND,SXVS,,,, - 0x0206=FORMULA - # chart records - exclude=0x1004,0x102D,0x102F,0x1036,0x1037,0x1038,0x103B - 0x1040=CHRADARAREA,CHAXESSET,,CHLEGENDENTRY,CHPROPERTIES,CHSERGROUP,CHUSEDAXESSETS, - 0x1048=CHPIVOTREF,,CHSERPARENT,CHSERTRENDLINE,,,CHFORMAT,CHPOS - 0x1050=CHFORMATRUNS,CHSOURCELINK,,,,,, - 0x1058=,,,CHSERERRORBAR,,CHSERIESFORMAT,, -end - -multilist=RECORD-NAMES-BIFF8 - include=RECORD-NAMES-BIFF5 - # worksheet/workbook records - 0x00E0=,,,,,CELLMERGING,, - 0x00E8=,PICTURE,,MSODRAWINGGROUP,MSODRAWING,MSODRAWINGSELECTION,,PHONETICPR - 0x00F0=SXRULE,SXEX,SXFILT,,,,SXNAME,SXSELECT - 0x00F8=SXPAIR,SXFMLA,,SXFORMAT,SST,LABELSST,,EXTSST - 0x0100=SXVDEX,,,SXFORMULA,,,, - 0x0120=,,SXDBEX,,,,, - 0x0130=,,,,,,,CHTRINSERT - 0x0138=CHTRINFO,,,CHTRCELLCONTENT,,TABID,, - 0x0140=CHTRMOVERANGE,,,,,,, - 0x0148=,,,,,CHTRINSERTTAB,, - 0x0158=,,,,,,,LABELRANGES - 0x0160=USESELFS,DSF,XL5MODIFY,,,,, - 0x0190=,,,,,,CHTRHEADER, - 0x01A8=,USERBVIEW,USERSVIEWBEGIN,USERSVIEWEND,,QSI,EXTERNALBOOK,PROT4REV - 0x01B0=CFHEADER,CFRULE,DATAVALIDATIONS,,,DCONBIN,TXO,REFRESHALL - 0x01B8=HYPERLINK,NLRDELNAME,CODENAME,SXFDBTYPE,PROT4REVPASS,,DATAVALIDATION, - 0x0800=SCREENTIP,,,WEBQRYSETTINGS,WEBQRYTABLES,,, - 0x0850=,CHWRAPPEDRECORD,,,,,,CHUNITPROPERTIES - 0x0858=CHPIVOTREF,,,,,,, - 0x0860=,,SHEETLAYOUT,,,,,SHEETPROTECTION - # chart records - 0x1058=,,,,,,,CH3DDATAFORMAT - 0x1060=CHFONTBASE,CHPIEEXT,CHLABELRANGE2,CHDATATABLE,CHPLOTGROWTH,CHSERINDEX,CHESCHERFORMAT,CHPIEEXTSETT -end - -# simple records ------------------------------------------------------------- - -constlist=SIMPLE-RECORDS-BIFF2 - 0x000C=uint16,dec,max-iterations - 0x000D=int16,dec,calc-mode,CALCMODE - 0x000E=uint16,bool,calc-precise - 0x000F=uint16,dec,ref-mode,REFMODE - 0x0010=double,dec,epsilon - 0x0011=uint16,bool,iterate-recursive - 0x0012=uint16,bool,workbook-protected - 0x0013=uint16,hex,password-hash - 0x0016=uint16,dec,externsheets - 0x0019=uint16,bool,window-protected - 0x001F=uint16,dec,builtin-fmt-count - 0x0022=uint16,dec,null-date,DATEMODE - 0x0025=uint16,hex,rowheight-flags,DEFROWHEIGHT-FLAGS - 0x0026=double,dec,left-margin,CONV-INCH-TO-CM - 0x0027=double,dec,right-margin,CONV-INCH-TO-CM - 0x0028=double,dec,top-margin,CONV-INCH-TO-CM - 0x0029=double,dec,bottom-margin,CONV-INCH-TO-CM - 0x002A=uint16,bool,print-sheet-headers - 0x002B=uint16,bool,print-gridlines - 0x0040=uint16,bool,backup-on-save - 0x0044=uint16,dec,xf-idx - 0x0045=uint16,dec,font-color-idx,COLORS - 0x0055=uint16,dec,base-col-width - 0x100B=uint16,dec,extrusion,CONV-PERCENT - 0x100C=uint16,hex,flags,CHATTACHEDLABEL-FLAGS - 0x1018=uint16,hex,flags,CHLINE-FLAGS - 0x101A=uint16,hex,flags,CHAREA-FLAGS - 0x101C=uint16,dec,line-type,CHCHARTLINE-TYPE - 0x1021=uint16,dec,axisline-id,CHAXISLINE-ID - 0x1024=uint16,dec,text-idx - 0x1026=uint16,dec,font-idx,FONTNAMES - 0x1045=uint16,dec,group-idx - 0x1046=uint16,dec,used-axessets - 0x104A=uint16,dec,series-idx - 0x104E=uint16,dec,fmt-idx,FORMATS -end - -constlist=SIMPLE-RECORDS-BIFF3 - include=SIMPLE-RECORDS-BIFF2 - 0x0056=uint16,dec,builtin-fmt-count - 0x005E=uint16,unused - 0x005F=uint16,bool,recalc-on-save - 0x0063=uint16,bool,objects-protected - 0x0081=uint16,hex,flags,SHEETPR-FLAGS - 0x0082=uint16,bool,print-gridlines-changed - 0x0083=uint16,bool,horizontal-centered - 0x0084=uint16,bool,vertical-centered - 0x008D=uint16,dec,object-mode,HIDEOBJ -end - -constlist=SIMPLE-RECORDS-BIFF4 - include=SIMPLE-RECORDS-BIFF3 - 0x008E=uint32,hex,stream-pos,CONV-DEC - 0x0099=uint16,dec,default-col-width,CONV-COLWIDTH - 0x009C=uint16,dec,func-group-count - 0x103D=uint16,dec,bar-dist - 0x103E=uint16,hex,flags,CHRADAR-FLAGS - 0x103F=uint16,hex,flags,CHSURFACE-FLAGS -end - -constlist=SIMPLE-RECORDS-BIFF5 - include=SIMPLE-RECORDS-BIFF4 - 0x00C9=double,dec,value - 0x00CA=uint16,bool,value - 0x00CB=uint16,hex,error-code,ERRORCODES - 0x00CC=int16,dec,value - 0x00D5=uint16,hex,pivotcache-stream-id - 0x00D8=uint16,hex,flags,SXNUMGROUP-FLAGS - 0x00DA=uint16,bool,strip-cached-values - 0x00DD=uint16,bool,scenarios-protected - 0x00E3=uint16,dec,source-type,SXVS-TYPE - 0x1040=uint16,hex,flags,CHRADAR-FLAGS - 0x105D=uint16,hex,flags,CHSERIESFORMAT-FLAGS -end - -constlist=SIMPLE-RECORDS-BIFF8 - include=SIMPLE-RECORDS-BIFF5 - 0x00E1=uint16,dec,codepage,CODEPAGES - 0x0160=uint16,bool,use-nat-lang-refs - 0x0161=uint16,bool,double-stream - 0x01AF=uint16,bool,revlog-protected - 0x01B7=uint16,bool,refresh-all - 0x01BB=uint16,dec,sql-data-type,SXFDBTYPE-DATATYPE - 0x01BC=uint16,hex,password-hash - 0x1065=uint16,dec,series-idx -end - -# ARRAY ---------------------------------------------------------------------- - -flagslist=ARRAY-FLAGS-BIFF2 - 0x0001=recalc-always -end - -flagslist=ARRAY-FLAGS-BIFF3 - include=ARRAY-FLAGS-BIFF2 - 0x0002=recalc-onload -end - -# BOF ------------------------------------------------------------------------ - -constlist=BOF-BIFFTYPE - 0x0000=from-id - 0x0007=biff2 - 0x0200=biff2 - 0x0300=biff3 - 0x0400=biff4 - 0x0500=biff5 - 0x0600=biff8 -end - -constlist=BOF-SHEETTYPE - 0x0005=globals - 0x0006=vb-module - 0x0010=sheet - 0x0020=chart - 0x0040=macro - 0x0100=workspace -end - -flagslist=BOF-HISTORY-FLAGS - 0x00000001=windows - 0x00000002=risc - 0x00000004=beta - 0x00000008=win-any - 0x00000010=mac-any - 0x00000020=beta-any - 0x00000100=risc-any - # missing mac here? -end - -# CALCMODE ------------------------------------------------------------------- - -shortlist=CALCMODE,-1,automatic-no-table,manual,automatic - -# CFRULE --------------------------------------------------------------------- - -shortlist=CFRULE-TYPE,1,value,formula -shortlist=CFRULE-OPERATOR,0,none,between,not-between,equal,not-equal,greater-than,less-than,greater-equal,less-equal - -flagslist=CFRULE-FLAGS - ignore=0x00380080 - 0x00000001=!hor-align-used - 0x00000002=!vert-align-used - 0x00000004=!text-wrap-used - 0x00000008=!rotation-used - 0x00000010=!justify-lastline-used - 0x00000020=!indent-used - 0x00000040=!shrinktofit-used - 0x00000100=!cell-locked-used - 0x00000200=!cell-hidden-used - 0x00000400=!left-border-used - 0x00000800=!right-border-used - 0x00001000=!top-border-used - 0x00002000=!bottom-border-used - 0x00004000=!tl-to-br-used - 0x00008000=!bl-to-tr-used - 0x00010000=!fill-pattern-used - 0x00020000=!fg-color-idx-used - 0x00040000=!bg-color-idx-used - 0x04000000=font-block - 0x08000000=alignment-block - 0x10000000=border-block - 0x20000000=pattern-block - 0x40000000=protection-block - 0x80000000=!text-dir-used -end - -combilist=CFRULE-ALIGNMENT - 0x07=uint8,dec,hor-align,XF-HORALIGN - 0x08=text-wrap - 0x70=uint8,dec,ver-align,XF-VERALIGN - 0x80=justify-lastline -end - -combilist=CFRULE-INDENT - 0x000F=uint8,dec,indent - 0x0010=shrink-to-fit - 0x00C0=uint8,dec,text-dir,XF-TEXTDIRECTION -end - -flagslist=CFRULE-FONTFLAGS - 0x00000002=italic - 0x00000008=outline - 0x00000010=shadow - 0x00000020=condense - 0x00000040=extend - 0x00000080=strikeout -end - -flagslist=CFRULE-FONTUSEDFLAGS - 0x00000002=!italic-used - 0x00000008=!outline-used - 0x00000010=!shadow-used - 0x00000020=!condense-used - 0x00000040=!extend-used - 0x00000080=!strikeout-used -end - -constlist=CFRULE-FONTUSED - 0=used - 1=not-used -end - -combilist=CFRULE-BORDERCOLOR2 - 0x0000007F=uint8,dec,top-color,COLORS - 0x00003F80=uint8,dec,bottom-color,COLORS - 0x001FC000=uint8,dec,diag-color,COLORS - 0x01E00000=uint8,dec,diag-style,BORDERSTYLES -end - -combilist=CFRULE-FILLBLOCK - 0x0000FC00=uint8,dec,fill-pattern,FILLPATTERNS - 0x007F0000=uint8,dec,fg-color-idx,COLORS - 0x3F800000=uint8,dec,bg-color-idx,COLORS -end - -flagslist=CFRULE-PROTECTION-FLAGS - 0x0001=locked - 0x0002=formula-hidden -end - -# CH3DDATAFORMAT ------------------------------------------------------------- - -shortlist=CH3DDATAFORMAT-BASE,0,rectangular,circular -shortlist=CH3DDATAFORMAT-TOP,0,straight,sharp,trunc - -# CHAREA --------------------------------------------------------------------- - -flagslist=CHAREA-FLAGS - 0x0001=stacked - 0x0002=percent - 0x0004=shadow -end - -# CHAREAFORMAT --------------------------------------------------------------- - -flagslist=CHAREAFORMAT-FLAGS - 0x0001=auto - 0x0002=swap-negative -end - -# CHATTACHEDLABEL ------------------------------------------------------------ - -flagslist=CHATTACHEDLABEL-FLAGS - 0x0001=show-value - 0x0002=show-percent - 0x0004=show-categ-percent - 0x0008=smoothed - 0x0010=show-categ - 0x0020=show-bubble -end - -# CHAXESSET ------------------------------------------------------------------ - -shortlist=CHAXESSET-ID,0,primary,secondary - -# CHAXIS --------------------------------------------------------------------- - -shortlist=CHAXIS-TYPE,0,x-axis,y-axis,z-axis - -# CHAXISLINE ----------------------------------------------------------------- - -shortlist=CHAXISLINE-ID,0,axisline,major-grid,minor-grid,wall - -# CHBAR ---------------------------------------------------------------------- - -flagslist=CHBAR-FLAGS - 0x0001=horizontal - 0x0002=stacked - 0x0004=percent - 0x0008=shadow -end - -# CHCHART3D ------------------------------------------------------------------ - -flagslist=CHCHART3D-FLAGS - ignore=0x0010 - 0x0001=real3d - 0x0002=clustered - 0x0004=auto-height - 0x0020=2d-plotarea -end - -# CHTYPEGROUP ---------------------------------------------------------------- - -flagslist=CHTYPEGROUP-FLAGS - 0x0001=varied-colors -end - -# CHCHARTLINE ---------------------------------------------------------------- - -shortlist=CHCHARTLINE-TYPE,0,drop-line,hi-lo-line,series-connector - -# CHDATAFORMAT --------------------------------------------------------------- - -constlist=CHDATAFORMAT-POINTIDX - default= - -1=all-points -end - -constlist=CHDATAFORMAT-FORMATIDX - default= - -3=axesset-global -end - -flagslist=CHDATAFORMAT-FLAGS - 0x0001=excel4-colors -end - -# CHFRAME -------------------------------------------------------------------- - -shortlist=CHFRAME-FORMAT,0,standard,,,,shadow - -flagslist=CHFRAME-FLAGS - 0x0001=auto-size - 0x0002=auto-pos -end - -# CHFRAMEPOS ----------------------------------------------------------------- - -shortlist=CHFRAMEPOS-OBJTYPE,2,any,,,legend -shortlist=CHFRAMEPOS-SIZEMODE,1,manual,auto - -# CHLABELRANGE --------------------------------------------------------------- - -flagslist=CHLABELRANGE-FLAGS - 0x0001=cross-between-categ - 0x0002=maximum-axis-cross - 0x0004=reverse-order -end - -# CHLABELRANGE2 -------------------------------------------------------------- - -flagslist=CHLABELRANGE2-FLAGS - 0x0001=auto-minimum - 0x0002=auto-maximum - 0x0004=auto-major - 0x0008=auto-minor - 0x0010=date-axis - 0x0020=auto-base - 0x0040=auto-axis-cross - 0x0080=auto-date -end - -# CHLEGEND ------------------------------------------------------------------- - -shortlist=CHLEGEND-DOCKPOS,0,bottom,top-left,top,right,left,,,manual -shortlist=CHLEGEND-SPACING,0,close,medium,open - -flagslist=CHLEGEND-FLAGS - 0x0001=docked - 0x0002=auto-series - 0x0004=auto-pos-x - 0x0008=auto-pos-y - 0x0010=stacked - 0x0020=data-table -end - -# CHLINE --------------------------------------------------------------------- - -flagslist=CHLINE-FLAGS - 0x0001=stacked - 0x0002=percent - 0x0004=shadow -end - -# CHLINEFORMAT --------------------------------------------------------------- - -shortlist=CHLINEFORMAT-LINETYPE,0,solid,dash,dot,dash-dot,dash-dot-dot,none,25%-pattern,50%-pattern,75%-pattern -shortlist=CHLINEFORMAT-LINEWEIGHT,-1,hair,thin,medium,thick - -flagslist=CHLINEFORMAT-FLAGS - 0x0001=auto - 0x0004=axis-enabled -end - -# CHMARKERFORMAT ------------------------------------------------------------- - -shortlist=CHMARKERFORMAT-TYPE,0,none,square,diamond,triangle,cross,star,dow-jones,std-dev,circle,plus - -flagslist=CHMARKERFORMAT-FLAGS - 0x0001=auto - 0x0010=no-fill - 0x0020=no-border -end - -# CHOBJECTLINK --------------------------------------------------------------- - -shortlist=CHOBJECTLINK-TARGET,0,none,title,y-axis,x-axis,datapoint,legend,none,z-axis,,,,,axis-unit - -constlist=CHOBJECTLINK-POINT - default= - -2=unknown - -1=all-points -end - -# CHPICFORMAT ---------------------------------------------------------------- - -shortlist=CHPICFORMAT-BITMAP-MODE,1,stretched,stacked,stacked-scaled - -constlist=CHPICFORMAT-IMAGE-FORMAT - 2=wmf - 9=bmp - 19=?emf -end - -shortlist=CHPICFORMAT-ENV,1,windows,apple - -combilist=CHPICFORMAT-FLAGS - 0x00FF=uint16,dec,environment,CHPICFORMAT-ENV - 0x0100=format-only - 0x0200=top-bottom - 0x0400=front-back - 0x0800=left-right -end - -# CHPIE ---------------------------------------------------------------------- - -flagslist=CHPIE-FLAGS - 0x0001=shadow - 0x0002=connectors -end - -# CHRADAR, CHRADARAREA ------------------------------------------------------- - -flagslist=CHRADAR-FLAGS - 0x0001=axis-labels - 0x0002=shadow -end - -# CHPROPERTIES --------------------------------------------------------------- - -shortlist=CHPROPERTIES-EMPTYCELLS,0,do-not-plot,as-zero,interpolated - -flagslist=CHPROPERTIES-FLAGS - 0x0001=manual-format - 0x0002=plot-visible-only - 0x0004=fixed-size - 0x0008=manual-plotarea -end - -# CHSCATTER ------------------------------------------------------------------ - -shortlist=CHSCATTER-SIZETYPE,0,none,area,width - -flagslist=CHSCATTER-FLAGS - 0x0001=bubbles - 0x0002=show-negative - 0x0004=shadow -end - -# CHSERERRORBAR -------------------------------------------------------------- - -shortlist=CHSERERRORBAR-TYPE,1,x-plus,x-minus,y-plus,y-minus -shortlist=CHSERERRORBAR-SOURCE,1,percent,fixed,std-deviation,custom,std-error - -# CHSERIES ------------------------------------------------------------------- - -shortlist=CHSERIES-TYPE,0,date,numeric,sequence,text - -# CHSERIESFORMAT ------------------------------------------------------------- - -flagslist=CHSERIESFORMAT-FLAGS - 0x0001=spline - 0x0002=bubbles-3d - 0x0004=shadow -end - -# CHSERTRENDLINE ------------------------------------------------------------- - -shortlist=CHSERTRENDLINE-TYPE,0,poynomial,exponential,logarithmic,power,moving-average - -# CHSOURCELINK --------------------------------------------------------------- - -shortlist=CHSOURCELINK-TARGET,0,title,values,category,bubbles -shortlist=CHSOURCELINK-TYPE,0,default,constant,sheet-link - -flagslist=CHSOURCELINK-FLAGS - 0x0001=custom-numfmt -end - -# CHSTRING ------------------------------------------------------------------- - -shortlist=CHSTRING-TYPE,0,text,category-default,value-default,x-prefix,x-postfix,y-prefix,y-postfix,comment - -# CHSURFACE ------------------------------------------------------------------ - -flagslist=CHSURFACE-FLAGS - 0x0001=filled - 0x0002=shadow -end - -# CHTEXT --------------------------------------------------------------------- - -shortlist=CHTEXT-HORALIGN,1,left,center,right,block,distribute -shortlist=CHTEXT-VERALIGN,1,top,center,bottom,block,distribute -shortlist=CHTEXT-FILLMODE,1,transparent,opaque - -combilist=CHTEXT-FLAGS-BIFF2 - 0x0001=auto-color - 0x0002=show-symbol - 0x0004=show-value - 0x0008=vertical - 0x0010=auto-text - 0x0020=default-format - 0x0040=deleted - 0x0080=auto-fill -end - -combilist=CHTEXT-FLAGS-BIFF3 - include=CHTEXT-FLAGS-BIFF2 - 0x0700=uint8,dec,orientation,TEXTORIENTATION -end - -combilist=CHTEXT-FLAGS-BIFF5 - include=CHTEXT-FLAGS-BIFF3 - 0x0800=show-categ-percent - 0x1000=show-percent -end - -combilist=CHTEXT-FLAGS-BIFF8 - include=CHTEXT-FLAGS-BIFF5 - 0x2000=show-bubble-size - 0x4000=show-categ -end - -multilist=CHTEXT-PLACEMENT - default= - 0=context,outside,inside,center,axis,above,below,left,right,auto,manual -end - -# CHTICK --------------------------------------------------------------------- - -shortlist=CHTICK-TYPE,0,none,inside,outside,both -# TODO: really different label positions in BIFF2-BIFF4? -shortlist=CHTICK-LABELPOS-BIFF2,0,none,near,below,above -shortlist=CHTICK-LABELPOS-BIFF5,0,none,below,above,near - -flagslist=CHTICK-FLAGS-BIFF2 - 0x0001=auto-color - 0x0002=auto-fill -end - -combilist=CHTICK-FLAGS-BIFF3 - include=CHTICK-FLAGS-BIFF2 - 0x001C=uint8,dec,orientation,TEXTORIENTATION - 0x0020=auto-rotation -end - -# CHUNITPROPERTIES ----------------------------------------------------------- - -shortlist=CHUNITPROPERTIES-PRESET,-1,manual,none,hundred,thousand,(10000),(100000),million,(10million),(100million),billion,trillion - -flagslist=CHUNITPROPERTIES-FLAGS - 0x0002=show-unit -end - -# CHVALUERANGE --------------------------------------------------------------- - -flagslist=CHVALUERANGE-FLAGS - ignore=0x0100 - 0x0001=auto-minimum - 0x0002=auto-maximum - 0x0004=auto-major - 0x0008=auto-minor - 0x0010=auto-axis-cross - 0x0020=logarithmic - 0x0040=reverse-order - 0x0080=maximum-axis-cross -end - -# COLINFO -------------------------------------------------------------------- - -combilist=COLINFO-FLAGS - 0x0001=hidden - 0x0002=custom-width - 0x0004=best-fit - 0x0008=show-phonetic - 0x0700=uint8,dec,outline-level - 0x1000=outline-collapsed -end - -# DATATABLE ------------------------------------------------------------------ - -flagslist=DATATABLE-FLAGS-BIFF3 - 0x0001=recalc-always - 0x0002=recalc-on-load - 0x0004=row-table - 0x0008=table-2d -end - -flagslist=DATATABLE-FLAGS-BIFF8 - include=DATATABLE-FLAGS-BIFF3 - 0x0010=ref1-deleted - 0x0020=ref2-deleted -end - -# DATAVALIDATION ------------------------------------------------------------- - -combilist=DATAVALIDATION-FLAGS - 0x0000000F=uint8,dec,type,DATAVALIDATION-TYPE - 0x00000070=uint8,dec,error-style,DATAVALIDATION-ERRORSTYLE - 0x00000080=string-list - 0x00000100=ignore-empty - 0x00000200=no-dropdown - 0x00040000=show-input-box - 0x00080000=show-error-box - 0x00F00000=uint8,dec,operator,DATAVALIDATION-OPERATOR -end - -shortlist=DATAVALIDATION-TYPE,0,any,whole,decimal,list,date,time,text-length,custom -shortlist=DATAVALIDATION-OPERATOR,0,between,not-between,equal,not-equal,greater-than,less-than,greater-equal,less-equal -shortlist=DATAVALIDATION-ERRORSTYLE,0,error,warning,info - -# DATAVALIDATIONS ------------------------------------------------------------ - -flagslist=DATAVALIDATIONS-FLAGS - 0x0001=input-box-visible - 0x0002=input-box-at-cell - 0x0004=cached -end - -# DATEMODE ------------------------------------------------------------------- - -shortlist=DATEMODE,0,1899-12-31,1904-01-01 - -# DEFINEDNAME ---------------------------------------------------------------- - -flagslist=DEFINEDNAME-FLAGS-BIFF2 - 0x02=macro - 0x04=complex -end - -shortlist=DEFINEDNAME-MACROTYPE-BIFF2,0,none,function,procedure - -flagslist=DEFINEDNAME-FLAGS-BIFF3 - 0x0001=hidden - 0x0002=function - 0x0004=command - 0x0008=macro - 0x0010=complex - 0x0020=builtin -end - -combilist=DEFINEDNAME-FLAGS-BIFF4 - include=DEFINEDNAME-FLAGS-BIFF3 - 0x0FC0=uint16,dec,func-group,DEFINEDNAME-FUNCGROUP -end - -combilist=DEFINEDNAME-FLAGS-BIFF5 - include=DEFINEDNAME-FLAGS-BIFF4 - 0x0004=vba - 0x1000=binary -end - -shortlist=DEFINEDNAME-FUNCGROUP,0,none,financial,date-time,math-trig,statistical,lookup-ref,database,text,logical,information,commands,customizing,macro-control,dde-external,user-definded - -constlist=DEFINEDNAME-SHEETIDX - default= - 0=global -end - -# DEFROWHEIGHT --------------------------------------------------------------- - -combilist=DEFROWHEIGHT-FLAGS-BIFF2 - 0x7FFF=uint16,dec,row-height,CONV-TWIP-TO-PT - 0x8000=unchanged -end - -flagslist=DEFROWHEIGHT-FLAGS-BIFF3 - 0x0001=custom-height - 0x0002=hidden - 0x0004=thick-top - 0x0008=thick-bottom -end - -# EXTERNALBOOK --------------------------------------------------------------- - -constlist=EXTERNALBOOK-KEY - 0x0401=self-reference - 0x3A01=analysis-addin -end - -# EXTERNALNAME --------------------------------------------------------------- - -flagslist=EXTERNALNAME-FLAGS-BIFF3 - 0x0001=builtin - 0x0002=automatic - 0x0004=pic-link -end - -combilist=EXTERNALNAME-FLAGS-BIFF5 - include=EXTERNALNAME-FLAGS-BIFF3 - 0x0008=dde-stddocumentname - 0x0010=ole-link - 0x7FE0=uint16,dec,clipboard-format - 0x8000=iconified -end - -# EXTERNSHEET ---------------------------------------------------------------- - -constlist=EXTERNSHEET-IDX-BIFF8 - default= - -1=deleted - -2=special -end - -# FONT ----------------------------------------------------------------------- - -flagslist=FONT-FLAGS - 0x0001=bold - 0x0002=italic - 0x0004=underline - 0x0008=strikeout - 0x0010=outline - 0x0020=shadow - 0x0040=condense - 0x0080=extend -end - -constlist=FONT-WEIGHT - 400=normal - 700=bold -end - -multilist=FONT-UNDERLINE - 0x00=none,single,double - 0x21=single-acc,double-acc -end - -shortlist=FONT-ESCAPEMENT,0,none,superscript,subscript -shortlist=FONT-FAMILY,0,none,roman,swiss,modern,script,decorative - -# FORMULA -------------------------------------------------------------------- - -flagslist=FORMULA-FLAGS-BIFF2 - 0x0001=recalc-always -end - -flagslist=FORMULA-FLAGS-BIFF3 - include=FORMULA-FLAGS-BIFF2 - 0x0002=recalc-onload -end - -flagslist=FORMULA-FLAGS-BIFF5 - include=FORMULA-FLAGS-BIFF3 - 0x0008=shared-fmla -end - -shortlist=FORMULA-RESULTTYPE,0,string,boolean,error,empty - -# HIDEOBJ -------------------------------------------------------------------- - -shortlist=HIDEOBJ,0,show,placeholder,hide - -# HYPERLINK ------------------------------------------------------------------ - -79EAC9D0-BAF9-11CE-8C82-00AA004BA90B=StdHlink -00000303-0000-0000-C000-000000000046=FileMoniker -79EAC9E0-BAF9-11CE-8C82-00AA004BA90B=URLMoniker - -flagslist=HYPERLINK-FLAGS - 0x00000001=target - 0x00000002=absolute - 0x00000004=display-1 - 0x00000008=location - 0x00000010=display-2 - 0x00000080=frame - 0x00000100=unc-path -end - -# OBJ ------------------------------------------------------------------------ - -multilist=OBJ-TYPE-BIFF5 - 0=group,line,rect,oval,arc,chart,textbox,button,pic,polygon - 10=,checkbox,optbutton,edit,label,dialog,spin,scrollbar,listbox,groupbox - 20=dropdown -end - -flagslist=OBJ-FLAGS-BIFF5 - 0x0001=selected - 0x0002=auto-size - 0x0004=auto-move - 0x0010=protected - 0x0080=grouped - 0x0100=hidden - 0x0200=visible - 0x0400=printable -end - -flagslist=OBJ-FLAGS-AUTO-BIFF5 - 0x0001=auto -end - -shortlist=OBJ-LINETYPE,0,solid,dash,dot,dash-dot,dash-dot-dot,25%-pattern,50%-pattern,75%-pattern -shortlist=OBJ-LINEWEIGHT,0,hair,thin,medium,thick - -shortlist=OBJ-ARROWHEAD-TYPE-BIFF5,0,none,open,filled,double-end-open,double-end-filled -shortlist=OBJ-ARROWHEAD-WIDTH-BIFF5,0,narrow,medium,wide -shortlist=OBJ-ARROWHEAD-LENGTH-BIFF5,0,short,medium,long - -combilist=OBJ-LINEENDS-BIFF5 - 0x000F=uint8,dec,arrowhead-type,OBJ-ARROWHEAD-TYPE - 0x00F0=uint8,dec,arrowhead-width,OBJ-ARROWHEAD-WIDTH - 0x0F00=uint8,dec,arrowhead-length,OBJ-ARROWHEAD-LENGTH -end - -shortlist=OBJ-LINEDIR-BIFF5,0,topleft-to-bottomright,topright-to-bottomleft,bottomright-to-topleft,bottomleft-to-topright - -combilist=OBJ-FRAMESTYLE-FLAGS-BIFF5 - 0x0001=rounded - 0x0002=shadow - 0x03FC=uint16,dec,rounded-diameter -end - -flagslist=OBJ-CHART-FLAGS-BIFF5 - 0x0001=linked-to-sheet -end - -multilist=OBJ-RECNAMES-BIFF8 - 0x0000=OBJEND,,,,OBJMACRO,,OBJGMO,OBJCF - 0x0008=OBJPIOGRBIT,OBJPICTFMLA,OBJCBLS,,OBJSBS,,OBJSBSFMLA,OBJGBODATA - 0x0010=,,,OBJLBSDATA,OBJCBLSFMLA,OBJCMO,, -end - -flagslist=OBJPIOGRBIT-FLAGS - 0x0001=manual-size - 0x0002=linked - 0x0008=symbol - 0x0010=control - 0x0020=ctls-stream - 0x0200=auto-load -end - -shortlist=OBJPICTFMLA-HASCLASSNAME,0,false,,,true - -multilist=OBJCMO-TYPE - include=OBJ-TYPE-BIFF5 - 25=note - 30=drawing -end - -flagslist=OBJCMO-FLAGS - 0x0001=locked - 0x0010=printable - 0x2000=auto-line - 0x4000=auto-area -end - -# PAGESETUP ------------------------------------------------------------------ - -multilist=PAGESETUP-PAPERSIZE - 0=undefined,letter,letter-small,tabloid,ledger,legal,statement,executive,a3,a4 - 10=a4-small,a5,b4,b5,folio,quarto,10x14,11x17,note,envelope-9 - 20=envelope-10,envelope-11,envelope-12,envelope-14,c,d,e,envelope-dl,envelope-c5,envelope-c3 - 30=envelope-c4,envelope-c6,envelope-c65,envelope-b4,envelope-b5,envelope-b6,envelope-italy,envelope-monarch,envelope-6-3/4,us-standard-fanfold - 40=german-standard-fanfold,german-legal-fanfold,b4,japanese-dbl-postcaed,9x11,10x11,15x11,, - 50=envelope-invite,letter-extra,legal-extra,tabloid-extra,a4-extra,letter-transverse,a4-transverse,letter-extra-transverse,super-a-a4,super-b-a3,letter-plus - 60=a4-plus,a5-transverse,jis-b5-transverse,a3-extra,a5-extra,b5-extra,a2,a3-transverse,a3-extra-transverse -end - -constlist=PAGESETUP-SCALETOPAGES - default= - 0=automatic -end - -flagslist=PAGESETUP-FLAGS-BIFF4 - 0x0001=print-in-rows - 0x0002=portrait - 0x0004=uninitialized - 0x0008=black-and-white -end - -flagslist=PAGESETUP-FLAGS-BIFF5 - include=PAGESETUP-FLAGS-BIFF4 - 0x0010=draft-quality - 0x0020=print-notes - 0x0040=default-orientation - 0x0080=use-first-page -end - -combilist=PAGESETUP-FLAGS-BIFF8 - include=PAGESETUP-FLAGS-BIFF5 - 0x0200=print-notes-at-end - 0x0C00=uint8,dec,print-errors,PAGESETUP-PRINTERRORS -end - -shortlist=PAGESETUP-PRINTERRORS,0,displayed,none,as-dashes,as-na - -unitconverter=PAGESETUP-DPI,1,dpi - -# PANE ----------------------------------------------------------------------- - -shortlist=PANE-ID,0,bottom-right,top-right,bottom-left,top-left - -# PHONETICPR ----------------------------------------------------------------- - -shortlist=PHONETICPR-TYPE,0,halfwidth-katakana,fullwidth-katakana,hiragana,no-conversion -shortlist=PHONETICPR-ALIGNMENT,0,no-control,left,center,distributed - -combilist=PHONETICPR-FLAGS - ignore=0x0030 - 0x0003=uint8,dec,type,PHONETICPR-TYPE - 0x000C=uint8,dec,alignment,PHONETICPR-ALIGNMENT -end - -# PROJEXTSHEET --------------------------------------------------------------- - -shortlist=PROJEXTSHEET-TYPE,0,sheet,macro,chart - -# REFMODE -------------------------------------------------------------------- - -shortlist=REFMODE,0,R1C1,A1 - -# ROW ------------------------------------------------------------------------ - -combilist=ROW-HEIGHT - 0x7FFF=uint16,dec,height,CONV-TWIP-TO-PT - 0x8000=default-height -end - -combilist=ROW-FLAGS - ignore=0x00000100 - 0x00000007=uint8,dec,outline-level - 0x00000010=outline-collapsed - 0x00000020=hidden - 0x00000040=custom-height - 0x00000080=custom-format - 0x0FFF0000=uint16,dec,custom-xf-idx - 0x10000000=thick-top - 0x20000000=thick-bottom - 0x40000000=show-phonetic -end - -# SHEET ---------------------------------------------------------------------- - -shortlist=SHEET-STATE,0,visible,hidden,very-hidden -shortlist=SHEET-TYPE,0,worksheet,macrosheet,chartsheet,,,,vb-module - -# SHEETPR -------------------------------------------------------------------- - -shortlist=SHEETPR-WINDOWPOS,0,tiled,horizontal,vertical,cascaded - -flagslist=SHEETPR-FLAGS-BIFF3 - 0x0001=show-autopagebreaks - 0x0020=outline-auto-style - 0x0040=outline-symbols-below - 0x0080=outline-symbols-right - 0x0100=fit-to-pages - 0x0200=skip-linked-values - 0x0400=show-row-outline - 0x0800=show-column-outline -end - -flagslist=SHEETPR-FLAGS-BIFF4 - include=SHEETPR-FLAGS-BIFF3 - 0x3000=uint8,dec,window-pos,SHEETPR-WINDOWPOS - 0x4000=lotus-expr-eval - 0x8000=lotus-formula-edit -end - -flagslist=SHEETPR-FLAGS-BIFF5 - include=SHEETPR-FLAGS-BIFF4 - exclude=0x0200,0x3000 - 0x0010=dialog-sheet -end - -# SHEETPROTECTION ------------------------------------------------------------ - -flagslist=SHEETPROTECTION-FLAGS - 0x0001=edit-object - 0x0002=edit-scenario - 0x0004=format-cell - 0x0008=format-column - 0x0010=format-row - 0x0020=insert-column - 0x0040=insert-row - 0x0080=insert-hyperlink - 0x0100=delete-column - 0x0200=delete-row - 0x0400=select-locked - 0x0800=sort - 0x1000=use-autofilter - 0x2000=pivottable-report - 0x4000=select-unlocked -end - -# STYLE ---------------------------------------------------------------------- - -combilist=STYLE-FLAGS - 0x0FFF=uint16,dec,xf-idx - 0x8000=builtin -end - -shortlist=STYLE-BUILTIN,0,normal,rowlevel,collevel,comma,currency,percent,comma-0,currency-0,hyperlink,followed-hyperlink - -# common for pivot tables ---------------------------------------------------- - -constlist=SX-NAMELEN - default= - 0xFFFF=name-in-cache -end - -# SXDB ----------------------------------------------------------------------- - -flagslist=SXDB-FLAGS - 0x0001=save-data - 0x0002=invalid - 0x0004=refresh-on-load - 0x0008=opt-cache - 0x0010=backgr-query - 0x0020=enable-refresh -end - -constlist=SXDB-TYPE - 1=worksheet - 2=external - 4=consolidation - 8=scenario -end - -# SXDI ----------------------------------------------------------------------- - -shortlist=SXDI-FUNC,0,sum,count-all,average,max,min,product,count-num,std-dev,std-dev-p,variance,variance-p -shortlist=SXDI-FORMAT,0,normal,diff-from,percent-of,percent-diff-from,running-total-in,percent-of-row,percent-of-column,percent-of-total,index - -multilist=SXDI-BASEITEM - default= - 0x7FFB=previous-item,next-item -end - -# SXEXT ---------------------------------------------------------------------- - -combilist=SXEXT-FLAGS - 0x0007=uint8,dec,source-type,SXEXT-SOURCETYPE - 0x0008=odbc-connection - 0x0010=odbc-sql - 0x0020=server-pagefields - 0x0040=webquery - 0x0080=save-password - 0x0100=tables-html-only -end - -shortlist=SXEXT-SOURCETYPE,1,odbc,dao,,webquery - -# SXFDBTYPE ------------------------------------------------------------------ - -shortlist=SXFDBTYPE-DATATYPE,0,unknown,char,numeric,decimal,integer,small-int,float,real,double,datetime,,,var-char - -# SXFIELD -------------------------------------------------------------------- - -combilist=SXFIELD-FLAGS - 0x0001=has-items - 0x0002=postpone-items - 0x0004=calculated - 0x0008=has-child - 0x0010=numeric-group - 0x0020=16bit-indexes - 0x0DE0=uint16,hex,data-type,SXFIELD-TYPE,noshift -end - -constlist=SXFIELD-TYPE - 0x0000=none - 0x0480=string-only - 0x0520=integer-optdouble - 0x0560=double-only - 0x05A0=string-integer-optdouble - 0x05E0=string-double-only - 0x0900=date-only - 0x0980=date-empty-only - 0x0D00=date-number - 0x0D80=date-string-optnumber -end - -# SXLI ----------------------------------------------------------------------- - -shortlist=SXLI-ITEMTYPE,0,data,default,sum,count-num,average,max,min,product,count-num,std-dev,std-dev-p,variance,variance-p,grandtotal,blank-line - -combilist=SXLI-FLAGS - 0x0001=field-name - 0x01FE=uint16,dec,data-field-idx - 0x0200=subtotal - 0x0400=blocktotal - 0x0800=grandtotal - 0x1000=multi-data -end - -# SXNUMGROUP ----------------------------------------------------------------- - -combilist=SXNUMGROUP-FLAGS - 0x0001=auto-min - 0x0002=auto-max - 0x003C=uint8,dec,data-type,SXNUMGROUP-TYPE -end - -shortlist=SXNUMGROUP-TYPE,1,second,minute,hour,day,month,quarter,year,numeric - -# SXVD ----------------------------------------------------------------------- - -flagslist=SXVD-AXISTYPE - 0x0001=row - 0x0002=column - 0x0004=page - 0x0008=data -end - -flagslist=SXVD-SUBTOTALS - 0x0001=default - 0x0002=sum - 0x0004=count-all - 0x0008=average - 0x0010=max - 0x0020=min - 0x0040=product - 0x0080=count-num - 0x0100=std-dev - 0x0200=std-dev-p - 0x0400=variance - 0x0800=variance-p -end - -# SXVDEX --------------------------------------------------------------------- - -combilist=SXVDEX-FLAGS - 0x00000001=show-all-items - 0x00000002=drag-to-row - 0x00000004=drag-to-column - 0x00000008=drag-to-page - 0x00000010=drag-to-hide - 0x00000080=server-based - 0x00000200=autosort - 0x00000400=autosort-ascending - 0x00000800=autoshow - 0x00001000=autoshow-top-values - 0x00002000=calculated - 0x00200000=layout-report - 0x00400000=layout-blank - 0x00800000=layout-top - 0xFF000000=uint8,dec,autoshow-item-count -end - -# SXVI ----------------------------------------------------------------------- - -multilist=SXVI-ITEMTYPE - 0=data,default,sum,count-num,average,max,min,product,count-num,std-dev,std-dev-p,variance,variance-p,grandtotal - 254=page,none -end - -flagslist=SXVI-FLAGS - 0x0001=hidden - 0x0002=hide-detail - 0x0004=calculated - 0x0008=missing -end - -# SXVIEW --------------------------------------------------------------------- - -flagslist=SXVIEW-FLAGS - 0x0001=row-grandtotals - 0x0002=column-grandtotals - 0x0008=auto-format - 0x0010=size-auto-format - 0x0020=font-auto-format - 0x0040=align-auto-format - 0x0080=border-auto-format - 0x0100=pattern-auto-format - 0x0200=number-auto-format -end - -# SXVS ----------------------------------------------------------------------- - -flagslist=SXVS-TYPE - 0x0001=spreadsheet - 0x0002=extern - 0x0004=consolidation-area - 0x0008=pivot-table - 0x0010=scenario -end - -# WINDOW1 -------------------------------------------------------------------- - -flagslist=WINDOW1-FLAGS - 0x0001=hidden - 0x0002=minimized - 0x0008=show-horizontal-scroll - 0x0010=show-vertical-scroll - 0x0020=show-tabbar -end - -unitconverter=WINDOW1-TABBARRATIO,/10,% - -# WINDOW2 -------------------------------------------------------------------- - -flagslist=WINDOW2-FLAGS-BIFF3 - 0x0001=show-formulas - 0x0002=show-gridlines - 0x0004=show-headings - 0x0008=frozen-panes - 0x0010=show-zeros - 0x0020=default-gridcolor - 0x0040=right-to-left - 0x0080=show-outline-symbols - 0x0100=remove-split-with-freeze -end - -flagslist=WINDOW2-FLAGS-BIFF5 - include=WINDOW2-FLAGS-BIFF3 - 0x0200=sheet-selected - 0x0400=sheet-active -end - -flagslist=WINDOW2-FLAGS-BIFF8 - include=WINDOW2-FLAGS-BIFF5 - 0x0800=pagebreak-mode -end - -# XF ------------------------------------------------------------------------- - -shortlist=XF-HORALIGN,0,general,left,center,right,fill,block,center-across-sel,distribute -shortlist=XF-VERALIGN,0,top,center,bottom,justify,distribute -shortlist=XF-TEXTDIRECTION,0,context,left-to-right,right-to-left - -flagslist=XF-PROTECTION-FLAGS - 0x01=locked - 0x02=formula-hidden - 0x04=style-xf -end - -flagslist=XF-USEDATTRIBS-FLAGS - 0x04=format - 0x08=font - 0x10=alignment - 0x20=border - 0x40=area - 0x80=protection -end - -combilist=XF-STYLEFLAGS-BIFF2 - 0x07=uint8,dec,hor-align,XF-HORALIGN - 0x08=left-border - 0x10=right-border - 0x20=top-border - 0x40=bottom-border - 0x80=fill -end - -combilist=XF-TYPEFLAGS-BIFF2 - 0x3F=uint8,dec,fmt-idx,FORMATS - 0x40=locked - 0x80=formula-hidden -end - -flagslist=XF-TYPEFLAGS-BIFF3 - include=XF-PROTECTION-FLAGS -end - -combilist=XF-TYPEFLAGS-BIFF4 - include=XF-TYPEFLAGS-BIFF3 - 0xFFF0=uint16,dec,parent-xf-idx -end - -combilist=XF-ALIGNMENT-BIFF3 - 0x0007=uint8,dec,hor-align,XF-HORALIGN - 0x0008=text-wrap - 0xFFF0=uint16,dec,parent-xf-idx -end - -combilist=XF-ALIGNMENT-BIFF4 - 0x07=uint8,dec,hor-align,XF-HORALIGN - 0x08=text-wrap - 0x30=uint8,dec,ver-align,XF-VERALIGN - 0xC0=uint8,dec,orientation,TEXTORIENTATION -end - -combilist=XF-ALIGNMENT-BIFF5 - 0x07=uint8,dec,hor-align,XF-HORALIGN - 0x08=text-wrap - 0x70=uint8,dec,ver-align,XF-VERALIGN - 0x80=justify-lastline -end - -combilist=XF-ORIENTATTRIBS-BIFF5 - include=XF-USEDATTRIBS-FLAGS - 0x03=uint8,dec,orientation,TEXTORIENTATION -end - -combilist=XF-TEXTFLAGS-BIFF8 - 0x0F=uint8,dec,indent - 0x10=shrink-to-fit - 0xC0=uint8,dec,text-dir,XF-TEXTDIRECTION -end - -combilist=XF-FILL-BIFF3 - 0x003F=uint8,dec,fill-pattern,FILLPATTERNS - 0x07C0=uint8,dec,fg-color-idx,COLORS - 0xF800=uint8,dec,bg-color-idx,COLORS -end - -combilist=XF-BORDER-BIFF3 - 0x00000007=uint8,dec,top-style,BORDERSTYLES - 0x000000F8=uint8,dec,top-color,COLORS - 0x00000700=uint8,dec,left-style,BORDERSTYLES - 0x0000F800=uint8,dec,left-color,COLORS - 0x00070000=uint8,dec,bottom-style,BORDERSTYLES - 0x00F80000=uint8,dec,bottom-color,COLORS - 0x07000000=uint8,dec,right-style,BORDERSTYLES - 0xF8000000=uint8,dec,right-color,COLORS -end - -combilist=XF-FILL-BIFF5 - 0x0000007F=uint8,dec,fg-color-idx,COLORS - 0x00003F80=uint8,dec,bg-color-idx,COLORS - 0x003F0000=uint8,dec,fill-pattern,FILLPATTERNS - 0x01C00000=uint8,dec,bottom-style,BORDERSTYLES - 0xFE000000=uint8,dec,bottom-color,COLORS -end - -combilist=XF-BORDER-BIFF5 - 0x00000007=uint8,dec,top-style,BORDERSTYLES - 0x00000038=uint8,dec,left-style,BORDERSTYLES - 0x000001C0=uint8,dec,right-style,BORDERSTYLES - 0x0000FE00=uint8,dec,top-color,COLORS - 0x007F0000=uint8,dec,left-color,COLORS - 0x3F800000=uint8,dec,right-color,COLORS -end - -combilist=XF-BORDERSTYLE-BIFF8 - 0x000F=uint8,dec,left-style,BORDERSTYLES - 0x00F0=uint8,dec,right-style,BORDERSTYLES - 0x0F00=uint8,dec,top-style,BORDERSTYLES - 0xF000=uint8,dec,bottom-style,BORDERSTYLES -end - -combilist=XF-BORDERCOLOR1-BIFF8 - 0x007F=uint8,dec,left-color,COLORS - 0x3F80=uint8,dec,right-color,COLORS - 0x4000=diag-tl-to-br - 0x8000=diag-bl-to-tr -end - -combilist=XF-BORDERCOLOR2-BIFF8 - 0x0000007F=uint8,dec,top-color,COLORS - 0x00003F80=uint8,dec,bottom-color,COLORS - 0x001FC000=uint8,dec,diag-color,COLORS - 0x01E00000=uint8,dec,diag-style,BORDERSTYLES - 0xFC000000=uint8,dec,fill-pattern,FILLPATTERNS -end - -combilist=XF-FILLCOLOR-BIFF8 - 0x007F=uint8,dec,fg-color-idx,COLORS - 0x3F80=uint8,dec,bg-color-idx,COLORS -end - -# BIFF2 XF index field ------------------------------------------------------- - -constlist=XFINDEX-BIFF2 - default= - 63=from-ixfe -end - -combilist=CELL-XFINDEX-BIFF2 - 0x3F=uint8,dec,xf-idx,XFINDEX-BIFF2 - 0x40=locked - 0x80=formula-hidden -end - -combilist=CELL-XFFORMAT-BIFF2 - 0x3F=uint8,dec,fmt-idx,FORMATS - 0xC0=uint8,dec,font-idx,FONTNAMES -end - -combilist=CELL-XFSTYLE-BIFF2 - include=XF-STYLEFLAGS-BIFF2 -end - -# ============================================================================ - diff --git a/oox/source/dump/dffdumper.cxx b/oox/source/dump/dffdumper.cxx index 9c82fe19d7b4..4ce96bdd24a3 100644 --- a/oox/source/dump/dffdumper.cxx +++ b/oox/source/dump/dffdumper.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: dffdumper.cxx,v $ - * $Revision: 1.3 $ + * $Revision: 1.3.22.10 $ * * This file is part of OpenOffice.org. * @@ -32,143 +32,101 @@ #if OOX_INCLUDE_DUMPER +using ::rtl::OUString; + namespace oox { namespace dump { // ============================================================================ -DffRecordHeaderObject::DffRecordHeaderObject( const InputObjectBase& rParent ) -{ - static const RecordHeaderConfigInfo saHeaderCfgInfo = - { - "DFFREC", - "DFF-RECORD-NAMES", - "show-dff-record-pos", - "show-dff-record-size", - "show-dff-record-id", - "show-dff-record-name", - "show-dff-record-body", - }; - RecordHeaderBase< sal_uInt16, sal_uInt32 >::construct( rParent, saHeaderCfgInfo ); - if( RecordHeaderBase< sal_uInt16, sal_uInt32 >::implIsValid() ) - { - mxRecInst = cfg().getNameList( "DFF-RECORD-INST" ); - mnBodyStart = mnBodyEnd = 0; - mnInstVer = 0; - } -} - -bool DffRecordHeaderObject::implIsValid() const -{ - return isValid( mxRecInst ) && RecordHeaderBase< sal_uInt16, sal_uInt32 >::implIsValid(); -} - -bool DffRecordHeaderObject::implReadHeader( sal_Int64& ornRecPos, sal_uInt16& ornRecId, sal_uInt32& ornRecSize ) +void DffStreamObject::construct( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName ) { - ornRecPos = in().tell(); - if( ornRecPos >= in().getSize() ) return false; - in() >> mnInstVer >> ornRecId >> ornRecSize; - mnBodyStart = in().tell(); - mnBodyEnd = ::std::min< sal_Int64 >( mnBodyStart + ornRecSize, in().getSize() ); - return in().isValidPos(); + SequenceRecordObjectBase::construct( rParent, rxStrm, rSysFileName, "DFF-RECORD-NAMES" ); + constructDffObj(); } -void DffRecordHeaderObject::implWriteExtHeader() +void DffStreamObject::construct( const OutputObjectBase& rParent, const BinaryInputStreamRef& rxStrm ) { - writeHexItem( "instance", mnInstVer, mxRecInst ); + SequenceRecordObjectBase::construct( rParent, rxStrm, "DFF-RECORD-NAMES" ); + constructDffObj(); } -// ============================================================================ - -DffDumpObject::DffDumpObject( const InputObjectBase& rParent ) +bool DffStreamObject::implReadRecordHeader( BinaryInputStream& rBaseStrm, sal_Int64& ornRecId, sal_Int64& ornRecSize ) { - InputObjectBase::construct( rParent ); - if( InputObjectBase::implIsValid() ) - mxHdrObj.reset( new DffRecordHeaderObject( *this ) ); + sal_uInt16 nRecId; + rBaseStrm >> mnInstVer >> nRecId >> mnRealSize; + ornRecId = nRecId; + ornRecSize = isContainer() ? 0 : mnRealSize; + return !rBaseStrm.isEof(); } -DffDumpObject::~DffDumpObject() -{ -} - -void DffDumpObject::dumpDffClientPos( const sal_Char* pcName, sal_Int32 nSubScale ) +void DffStreamObject::implWriteExtHeader() { + const sal_Char* pcListName = "DFF-RECORD-INST"; + switch( getRecId() ) + { + case 0xF001: pcListName = "DFFBSTORECONT-RECORD-INST"; break; // DFFBSTORECONTAINER contains BLIP count + case 0xF007: pcListName = "DFFBSE-RECORD-INST"; break; // DFFBSE contains BLIP type + case 0xF00A: pcListName = "DFFSP-RECORD-INST"; break; // DFFSP contains shape type + case 0xF00B: pcListName = "DFFOPT-RECORD-INST"; break; // DFFOPT contains property count + } MultiItemsGuard aMultiGuard( out() ); - TableGuard aTabGuard( out(), 17 ); - dumpDec< sal_uInt16 >( pcName ); - ItemGuard aItem( out(), "sub-units" ); - sal_uInt16 nSubUnits; - in() >> nSubUnits; - out().writeDec( nSubUnits ); - out().writeChar( '/' ); - out().writeDec( nSubScale ); + writeHexItem( "instance", mnInstVer, pcListName ); + if( isContainer() ) writeDecItem( "container-size", mnRealSize ); } -void DffDumpObject::dumpDffClientRect() +void DffStreamObject::implDumpRecordBody() { - dumpDffClientPos( "start-col", 1024 ); - dumpDffClientPos( "start-row", 256 ); - dumpDffClientPos( "end-col", 1024 ); - dumpDffClientPos( "end-row", 256 ); -} + switch( getRecId() ) + { + case 0xF007: // DFFBSE + dumpDec< sal_uInt8 >( "win-type", "DFFBSE-TYPE" ); + dumpDec< sal_uInt8 >( "mac-type", "DFFBSE-TYPE" ); + dumpGuid( "guid" ); + dumpDec< sal_uInt16 >( "tag" ); + dumpDec< sal_uInt32 >( "blip-size" ); + dumpDec< sal_uInt32 >( "blip-refcount" ); + dumpDec< sal_uInt32 >( "blip-streampos" ); + dumpDec< sal_uInt8 >( "blip-usage", "DFFBSE-USAGE" ); + dumpDec< sal_uInt8 >( "blip-name-len" ); + dumpUnused( 2 ); + break; -bool DffDumpObject::implIsValid() const -{ - return isValid( mxHdrObj ) && InputObjectBase::implIsValid(); -} + case 0xF00A: // DFFSP + dumpHex< sal_uInt32 >( "shape-id", "CONV-DEC" ); + dumpHex< sal_uInt32 >( "shape-flags", "DFFSP-FLAGS" ); + break; -void DffDumpObject::implDump() -{ - while( mxHdrObj->startNextRecord() ) - { - if( mxHdrObj->getVer() != 0x0F ) + case 0xF00B: // DFFOPT { - if( mxHdrObj->isShowRecBody() ) - dumpRecordBody(); - in().seek( mxHdrObj->getBodyEnd() ); + sal_uInt16 nPropCount = getInst(); + out().resetItemIndex(); + for( sal_uInt16 nPropIdx = 0; !in().isEof() && (nPropIdx < nPropCount); ++nPropIdx ) + { + sal_uInt16 nPropId = dumpDffOptPropHeader(); + IndentGuard aIndent( out() ); + dumpDffOptPropValue( nPropId, in().readuInt32() ); + } } - out().emptyLine(); - } -} - -void DffDumpObject::dumpRecordBody() -{ - IndentGuard aIndGuard( out() ); - - // record contents - if( mxHdrObj->hasRecName() ) switch( mxHdrObj->getRecId() ) - { - case 0xF00B: - dumpDffOptRec(); break; - case 0xF010: - dumpHex< sal_uInt16 >( "flags", "DFFCLIENTANCHOR-FLAGS" ); - dumpDffClientRect(); + + case 0xF010: // DFFCLIENTANCHOR + implDumpClientAnchor(); break; } +} - // remaining undumped data - sal_Int64 nPos = in().tell(); - if( nPos == mxHdrObj->getBodyStart() ) - dumpRawBinary( mxHdrObj->getRecSize(), false ); - else if( nPos < mxHdrObj->getBodyEnd() ) - dumpRemaining( static_cast< sal_Int32 >( mxHdrObj->getBodyEnd() - nPos ) ); +void DffStreamObject::implDumpClientAnchor() +{ } -void DffDumpObject::dumpDffOptRec() +void DffStreamObject::constructDffObj() { - sal_uInt16 nInst = mxHdrObj->getInst(); - sal_Int64 nBodyEnd = mxHdrObj->getBodyEnd(); - out().resetItemIndex(); - for( sal_uInt16 nIdx = 0; (nIdx < nInst) && (in().tell() < nBodyEnd); ++nIdx ) - { - sal_uInt16 nPropId = dumpDffOptPropHeader(); - IndentGuard aIndent( out() ); - dumpDffOptPropValue( nPropId, in().readValue< sal_uInt32 >() ); - } + mnInstVer = 0; + mnRealSize = 0; } -sal_uInt16 DffDumpObject::dumpDffOptPropHeader() +sal_uInt16 DffStreamObject::dumpDffOptPropHeader() { MultiItemsGuard aMultiGuard( out() ); TableGuard aTabGuard( out(), 11 ); @@ -176,7 +134,7 @@ sal_uInt16 DffDumpObject::dumpDffOptPropHeader() return dumpHex< sal_uInt16 >( "id", "DFFOPT-PROPERTY-ID" ); } -void DffDumpObject::dumpDffOptPropValue( sal_uInt16 nPropId, sal_uInt32 nValue ) +void DffStreamObject::dumpDffOptPropValue( sal_uInt16 nPropId, sal_uInt32 nValue ) { switch( nPropId & 0x3FFF ) { diff --git a/oox/source/dump/dffdumper.ini b/oox/source/dump/dffdumper.ini new file mode 100644 index 000000000000..9c3184b275e5 --- /dev/null +++ b/oox/source/dump/dffdumper.ini @@ -0,0 +1,311 @@ + +# dumper settings ============================================================ + +# Path to additional configuration data, relative to this file. +include-config-file=dumperbase.ini + +# name lists ================================================================= + +multilist=DFF-RECORD-NAMES + 0xF000=DFFDGGCONTAINER,DFFBSTORECONTAINER,DFFDGCONTAINER,DFFSPGRCONTAINER,DFFSPCONTAINER,DFFSOLVERCONTAINER,DFFDGG,DFFBSE + 0xF008=DFFDG,DFFSPGR,DFFSP,DFFOPT,DFFTEXTBOX,DFFCLIENTTEXTBOX,DFFANCHOR,DFFCHILDANCHOR + 0xF010=DFFCLIENTANCHOR,DFFCLIENTDATA,DFFCONNECTORRULE,DFFALIGNRULE,DFFARCRULE,DFFCLIENTRULE,DFFCLASSID,DFFCALLOUTRULE + # 0xF018-0xF117 reserved for pictures + 0xF118=DFFREGROUPITEM,DFFSELECTION,DFFCOLORMRU,,,DFFDELETEDPSPL,DFFSPLITMENUCOLORS,DFFOLEOBJECT + 0xF120=DFFCOLORSCHEME,,DFFUSERDEFPROP +end + +combilist=DFF-RECORD-INST + 0x000F=uint8,hex,version,DFF-RECORD-VERSION + 0xFFF0=uint16,dec,instance +end + +constlist=DFF-RECORD-VERSION + default= + 15=container +end + +# DFFBSTORECONTAINER --------------------------------------------------------- + +combilist=DFFBSTORECONT-RECORD-INST + include=DFF-RECORD-INST + 0xFFF0=uint16,dec,blip-count +end + +# DFFBSE --------------------------------------------------------------------- + +combilist=DFFBSE-RECORD-INST + include=DFF-RECORD-INST + 0xFFF0=uint16,dec,blip-type,DFFBSE-TYPE +end + +multilist=DFFBSE-TYPE + 0=error,unknown,emf,wmf,pict,jpeg,png,dib + 17=tiff,cmyk-jpeg +end + +shortlist=DFFBSE-USAGE,0,default,texture + +# DFFSP ---------------------------------------------------------------------- + +combilist=DFFSP-RECORD-INST + include=DFF-RECORD-INST + 0xFFF0=uint16,dec,shape-type,DFFSP-TYPE +end + +multilist=DFFSP-TYPE + 0=not-primitive,rectangle,round-rectangle,ellipse,diamond,isoceles-triangle,right-triangle,parallelogram,trapezoid,hexagon + 10=octagon,plus,star,arrow,thick-arrow,home-plate,cube,balloon,seal,arc + 20=line,plaque,can,donut,text-simple,text-octagon,text-hexagon,text-curve,text-wave,text-ring + 30=text-on-curve,text-on-ring,straight-connector-1,bent-connector-2,bent-connector-3,bent-connector-4,bent-connector-5,curved-connector-2,curved-connector-3,curved-connector-4 + 40=curved-connector-5,callout-1,callout-2,callout-3,accent-callout-1,accent-callout-2,accent-callout-3,border-callout-1,border-callout-2,border-callout-3 + 50=accent-border-callout-1,accent-border-callout-2,accent-border-callout-3,ribbon,ribbon-2,chevron,pentagon,no-smoking,seal-8,seal-16 + 60=seal-32,wedge-rect-callout,wedge-rrect-callout,wedge-ellipse-callout,wave,folded-corner,left-arrow,down-arrow,up-arrow,left-right-arrow + 70=up-down-arrow,irregular-seal-1,irregular-seal-2,lightning-bolt,heart,picture-frame,quad-arrow,left-arrow-callout,right-arrow-callout,up-arrow-callout + 80=down-arrow-callout,left-right-arrow-callout,up-down-arrow-callout,quad-arrow-callout,bevel,left-bracket,right-bracket,left-brace,right-brace,left-up-arrow + 90=bent-up-arrow,bent-arrow,seal-24,striped-right-arrow,notched-right-arrow,block-arc,smiley-face,vertical-scroll,horizontal-scroll,circular-arrow + 100=notched-circular-arrow,uturn-arrow,curved-right-arrow,curved-left-arrow,curved-up-arrow,curved-down-arrow,cloud-callout,ellipse-ribbon,ellipse-ribbon-2,flow-chart-process + 110=flow-chart-decision,flow-chart-input-output,flow-chart-predefined-process,flow-chart-internal-storage,flow-chart-document,flow-chart-multidocument,flow-chart-terminator,flow-chart-preparation,flow-chart-manual-input,flow-chart-manual-operation + 120=flow-chart-connector,flow-chart-punched-card,flow-chart-punched-tape,flow-chart-summing-junction,flow-chart-or,flow-chart-collate,flow-chart-sort,flow-chart-extract,flow-chart-merge,flow-chart-offline-storage + 130=flow-chart-online-storage,flow-chart-magnetic-tape,flow-chart-magnetic-disk,flow-chart-magnetic-drum,flow-chart-display,flow-chart-delay,text-plain-text,text-stop,text-triangle,text-triangle-inverted + 140=text-chevron,text-chevron-inverted,text-ring-inside,text-ring-outside,text-arch-up-curve,text-arch-down-curve,text-circle-curve,text-button-curve,text-arch-up-pour,text-arch-down-pour + 150=text-circle-pour,text-button-pour,text-curve-up,text-curve-down,text-cascade-up,text-cascade-down,text-wave-1,text-wave-2,text-wave-3,text-wave-4 + 160=text-inflate,text-deflate,text-inflate-bottom,text-deflate-bottom,text-inflate-top,text-deflate-top,text-deflate-inflate,text-deflate-inflate-deflate,text-fade-right,text-fade-left + 170=text-fade-up,text-fade-down,text-slant-up,text-slant-down,text-can-up,text-can-down,flow-chart-alternate-process,flow-chart-offpage-connector,callout-90,accent-callout-90 + 180=border-callout-90,accent-border-callout-90,left-right-up-arrow,sun,moon,bracket-pair,brace-pair,seal-4,double-wave,action-button-blank + 190=action-button-home,action-button-help,action-button-information,action-button-forward-next,action-button-back-previous,action-button-end,action-button-beginning,action-button-return,action-button-document,action-button-sound + 200=action-button-movie,host-control,text-box +end + +flagslist=DFFSP-FLAGS + 0x00000001=group + 0x00000002=child + 0x00000004=patriarch + 0x00000008=deleted + 0x00000010=ole + 0x00000020=has-master + 0x00000040=flip-horizontal + 0x00000080=flip-vertical + 0x00000100=connector + 0x00000200=has-anchor + 0x00000400=background + 0x00000800=has-shape-type +end + +# DFFOPT --------------------------------------------------------------------- + +combilist=DFFOPT-RECORD-INST + include=DFF-RECORD-INST + 0xFFF0=uint16,dec,property-count +end + +combilist=DFFOPT-PROPERTY-ID + 0x3FFF=uint16,dec,id,DFFOPT-PROPERTY-NAMES + 0x4000=picture + 0x8000=complex +end + +multilist=DFFOPT-PROPERTY-NAMES + # transform + 0x0004=rotation + # protection + 0x007F=lock-flags + # text + 0x0080=text-id,text-left,text-top,text-right,text-bottom,text-wrap-mode,text-scale,text-anchor-mode + 0x0088=text-flow,text-font-rotation,text-next-shape,text-bidi + 0x00BF=text-flags + # text geometry + 0x00C0=text-unicode-string,text-rtf-string,text-curve-align,text-def-size,text-spacing,text-font-family + 0x00FF=text-geometry-flags + # picture + 0x0100=pic-crop-top,pic-crop-bottom,pic-crop-left,pic-crop-right,pic-data,pic-file-name,pic-flags,pic-transparency-color + 0x0108=pic-contrast,pic-brightness,pic-gamma,pic-id,pic-double-cr-mod,pic-fill-cr-mod,pic-line-cr-mod,pic-data-print + 0x0110=pic-name-print,pic-flags-print + 0x013F=pic-flags + # geometry + 0x0140=geo-left,geo-top,geo-right,geo-bottom,geo-shape-path,geo-vertices,geo-segment-info,geo-adjust-1 + 0x0148=geo-adjust-2,geo-adjust-3,geo-adjust-4,geo-adjust-5,geo-adjust-6,geo-adjust-7,geo-adjust-8,geo-adjust-9 + 0x0150=geo-adjust-10,geo-connect-points,geo-stretch-x,geo-stretch-y,geo-handles,geo-formulas,geo-text-recs + 0x0158=geo-connector-type + 0x017F=geo-flags + # fill style + 0x0180=fill-type,fill-color,fill-opacity,fill-back-color,fill-back-opacity,fill-cr-mod,fill-blip,fill-blip-name + 0x0188=fill-blip-flags,fill-width,fill-height,fill-angle,fill-focus,fill-to-left,fill-to-top,fill-to-right + 0x0190=fill-to-bottom,fill-rect-left,fill-rect-top,fill-rect-right,fill-rect-bottom,fill-dz-type,fill-shade-preset,fill-shade-colors + 0x0198=fill-origin-x,fill-origin-y,fill-shape-origin-x,fill-shape-origin-y,fill-shade-type + 0x01BF=fill-flags + # line style + 0x01C0=line-color,line-opacity,line-back-color,line-cr-mod,line-type,line-fill-blip,line-fill-blip-name,line-fill-blip-flags + 0x01C8=line-fill-width,line-fill-height,line-fill-dz-type,line-width,line-miter-limit,line-style,line-dash,line-dash-style + 0x01D0=line-start-arrow-head,line-end-arrow-head,line-start-arrow-width,line-start-arrow-length,line-end-arrow-width,line-end-arrow-length,line-join-style,line-end-cap-style + 0x01FF=line-flags + # shadow style + 0x0200=shadow-type,shadow-color,shadow-highlight,shadow-cr-mod,shadow-opacity,shadow-offset-x,shadow-offset-y,shadow-2nd-offset-x + 0x0208=shadow-2nd-offset-y,shadow-scale-x-to-x,shadow-scale-y-to-x,shadow-scale-x-to-y,shadow-scale-y-to-y,shadow-persp-x,shadow-persp-y,shadow-weight + 0x0210=shadow-origin-x,shadow-origin-y + 0x023F=shadow-flags + # perspective + 0x0240=persp-type,persp-offset-x,persp-offsety,persp-scale-x-to-x,persp-scale-y-to-x,persp-scale-x-to-y,persp-scale-y-to-y,persp-persp-x + 0x0248=persp-persp-y,persp-weight,persp-origin-x,persp-origin-y + 0x027F=persp-flags + # 3d object + 0x0280=3dobj-specular-amt,3dobj-diffuse-amt,3dobj-shininess,3dobj-edge-thickness,3dobj-extrude-forward,3dobj-extrude-backward,3dobj-extrude-plane,3dobj-extrusion-color + 0x0288=3dobj-cr-mod + 0x02BF=3dobj-flags + # 3d style + 0x02C0=3dstyle-y-rotation,3dstyle-x-rotation,3dstyle-rotation-axis-x,3dstyle-rotation-axis-y,3dstyle-rotation-axis-z,3dstyle-rotation,3dstyle-rotation-center-x,3dstyle-rotation-center-y + 0x02C8=3dstyle-rotation-center-z,3dstyle-render-mode,3dstyle-tolerance,3dstyle-view-point-x,3dstyle-view-point-y,3dstyle-view-point-z,3dstyle-origin-x,3dstyle-origin-y + 0x02D0=3dstyle-skew-angle,3dstyle-skew-amount,3dstyle-ambient-intensity,3dstyle-key-light-x,3dstyle-key-light-y,3dstyle-key-light-z,3dstyle-key-light-intensity,3dstyle-fill-light-x + 0x02D8=3dstyle-fill-light-y,3dstyle-fill-light-z,3dstyle-fill-light-intensity + 0x02FF=3dstyle-flags + # shape 1 + 0x0301=,shape-master,,shape-connect-style,shape-bw-mod,shape-bw-mode-pure-bw,shape-bw-mode-bw + 0x033F=shape1-flags + # callout + 0x0340=callout-type,callout-box-distance,callout-angle,callout-drop-type,callout-drop-distance,callout-length + 0x037F=callout-flags + # shape 2 + 0x0380=shape-name,shape-description,shape-hyperlink,shape-wrap-polygon-vertices,shape-wrap-left,shape-wrap-top,shape-wrap-right,shape-wrap-bottom + 0x0388=shape-regroup-id + 0x03BF=shape2-flags +end + +flagslist=DFFOPT-LOCK-FLAGS + 0x00000001=lock-against-grouping + 0x00000002=lock-adjust-handles + 0x00000004=lock-text + 0x00000008=lock-vertices + 0x00000010=lock-cropping + 0x00000020=lock-against-select + 0x00000040=lock-position + 0x00000080=lock-aspect-ratio + 0x00000100=lock-rotation + ignore=0xFFFF0000 +end + +flagslist=DFFOPT-TEXT-FLAGS + 0x00000001=fit-text-to-shape + 0x00000002=fit-shape-to-text + 0x00000004=rotate-text + 0x00000008=auto-text-margin + 0x00000010=select-text + ignore=0xFFFF0000 +end + +flagslist=DFFOPT-TEXTGEO-FLAGS + 0x00000001=strike-through + 0x00000002=small-caps + 0x00000004=shadow + 0x00000008=underline + 0x00000010=italic + 0x00000020=bold + 0x00000040=no-measure-along-path + 0x00000080=stretch-height + 0x00000100=scale-on-path + 0x00000200=shrink-to-fit + 0x00000400=stretch-to-fit + 0x00000800=tightening + 0x00001000=kerning + 0x00002000=vertical + 0x00004000=has-effect + 0x00008000=reverse-rows + ignore=0xFFFF0000 +end + +flagslist=DFFOPT-PICTURE-FLAGS + 0x00000001=ole-alive + 0x00000002=bi-level-display + 0x00000004=grayscale + 0x00000008=no-hit-test + ignore=0xFFFF0000 +end + +flagslist=DFFOPT-GEO-FLAGS + 0x00000001=fill-support + 0x00000002=fill-shade-shape-support + 0x00000004=fontwork-support + 0x00000008=line-support + 0x00000010=3d-support + 0x00000020=shadow-support + ignore=0xFFFF0000 +end + +flagslist=DFFOPT-FILL-FLAGS + 0x00000001=no-fill-hit-test + 0x00000002=use-large-rect + 0x00000004=register-pattern + 0x00000008=hit-test-fill + 0x00000010=has-fill + ignore=0xFFFF0000 +end + +flagslist=DFFOPT-LINE-FLAGS + 0x00000001=draw-dash-for-invisible + 0x00000002=register-pattern + 0x00000004=hit-test-line + 0x00000008=has-line + 0x00000010=arrowhead-support + ignore=0xFFFF0000 +end + +flagslist=DFFOPT-SHADOW-FLAGS + 0x00000001=excel5-style + 0x00000002=has-shadow + ignore=0xFFFF0000 +end + +flagslist=DFFOPT-PERSP-FLAGS + 0x00000001=has-perspective + ignore=0xFFFF0000 +end + +flagslist=DFFOPT-3DOBJ-FLAGS + 0x00000001=light-face + 0x00000002=extrusion-color + 0x00000004=metallic + 0x00000008=has-3d + ignore=0xFFFF0000 +end + +flagslist=DFFOPT-3DSTYLE-FLAGS + 0x00000001=fill-color-harsh + 0x00000002=key-color-harsh + 0x00000004=parallel + 0x00000008=rotation-center-auto + 0x00000010=constrain-rotation + ignore=0xFFFF0000 +end + +flagslist=DFFOPT-SHAPE1-FLAGS + 0x00000001=background + 0x00000002=delete-attached-object + 0x00000008=lock-shape-type + 0x00000010=prefer-rel-resize + 0x00000020=ole-iconified + ignore=0xFFFF0000 +end + +flagslist=DFFOPT-CALLOUT-FLAGS + 0x00000001=length-specified + 0x00000002=drop-auto + 0x00000004=minus-y + 0x00000008=minus-x + 0x00000010=has-text-border + 0x00000020=has-accent-bar + 0x00000040=is-callout + ignore=0xFFFF0000 +end + +flagslist=DFFOPT-SHAPE2-FLAGS + 0x00000001=print + 0x00000002=hidden + 0x00000004=1d-adjustment + 0x00000008=action-attached + 0x00000010=notify-double-click + 0x00000020=behind-text + 0x00000040=wrap-edited + ignore=0xFFFF0000 +end + +# ============================================================================ + diff --git a/oox/source/dump/dffdumperconfig.dat b/oox/source/dump/dffdumperconfig.dat index caf1c28c4171..e69de29bb2d1 100644 --- a/oox/source/dump/dffdumperconfig.dat +++ b/oox/source/dump/dffdumperconfig.dat @@ -1,250 +0,0 @@ - -# dumper settings ============================================================ - -# Path to additional configuration data, relative to this file. -include-config-file=dumperconfig.dat - -# DFF record settings ======================================================== - -# Show total stream position of the DFF record (default=on). -# 0=off, 1=on -show-dff-record-pos=0 - -# Show total DFF record size in bytes (default=on). -# 0=off, 1=on -show-dff-record-size=1 - -# Show DFF record identifier (default=on). -# 0=off, 1=on -show-dff-record-id=1 - -# Show DFF record name, if known (default=on). -# 0=off, 1=on -show-dff-record-name=1 - -# Show DFF record contents (default=on). -# 0=off, 1=on -show-dff-record-body=1 - -# name lists ================================================================= - -multilist=DFF-RECORD-NAMES - 0xF000=DFFDGGCONTAINER,DFFBSTORECONTAINER,DFFDGCONTAINER,DFFSPGRCONTAINER,DFFSPCONTAINER,DFFSOLVERCONTAINER,DFFDGG,DFFBSE - 0xF008=DFFDG,DFFSPGR,DFFSP,DFFOPT,DFFTEXTBOX,DFFCLIENTTEXTBOX,DFFANCHOR,DFFCHILDANCHOR - 0xF010=DFFCLIENTANCHOR,DFFCLIENTDATA,DFFCONNECTORRULE,DFFALIGNRULE,DFFARCRULE,DFFCLIENTRULE,DFFCLASSID,DFFCALLOUTRULE - # 0xF018-0xF117 reserved for pictures - 0xF118=DFFREGROUPITEM,DFFSELECTION,DFFCOLORMRU,,,DFFDELETEDPSPL,DFFSPLITMENUCOLORS,DFFOLEOBJECT - 0xF120=DFFCOLORSCHEME,,DFFUSERDEFPROP -end - -combilist=DFF-RECORD-INST - 0x000F=uint8,hex,version,DFF-RECORD-VERSION - 0xFFF0=uint16,dec,instance -end - -constlist=DFF-RECORD-VERSION - default= - 15=container -end - -flagslist=DFFCLIENTANCHOR-FLAGS - 0x0001=pos-locked - 0x0002=size-locked -end - -combilist=DFFOPT-PROPERTY-ID - 0x3FFF=uint16,dec,id,DFFOPT-PROPERTY-NAMES - 0x4000=picture - 0x8000=complex -end - -multilist=DFFOPT-PROPERTY-NAMES - # transform - 0x0004=rotation - # protection - 0x007F=lock-flags - # text - 0x0080=text-id,text-left,text-top,text-right,text-bottom,text-wrap-mode,text-scale,text-anchor-mode - 0x0088=text-flow,text-font-rotation,text-next-shape,text-bidi - 0x00BF=text-flags - # text geometry - 0x00C0=text-unicode-string,text-rtf-string,text-curve-align,text-def-size,text-spacing,text-font-family - 0x00FF=text-geometry-flags - # picture - 0x0100=pic-crop-top,pic-crop-bottom,pic-crop-left,pic-crop-right,pic-data,pic-file-name,pic-flags,pic-transparency-color - 0x0108=pic-contrast,pic-brightness,pic-gamma,pic-id,pic-double-cr-mod,pic-fill-cr-mod,pic-line-cr-mod,pic-data-print - 0x0110=pic-name-print,pic-flags-print - 0x013F=pic-flags - # geometry - 0x0140=geo-left,geo-top,geo-right,geo-bottom,geo-shape-path,geo-vertices,geo-segment-info,geo-adjust-1 - 0x0148=geo-adjust-2,geo-adjust-3,geo-adjust-4,geo-adjust-5,geo-adjust-6,geo-adjust-7,geo-adjust-8,geo-adjust-9 - 0x0150=geo-adjust-10,geo-connect-points,geo-stretch-x,geo-stretch-y,geo-handles,geo-formulas,geo-text-recs - 0x0158=geo-connector-type - 0x017F=geo-flags - # fill style - 0x0180=fill-type,fill-color,fill-opacity,fill-back-color,fill-back-opacity,fill-cr-mod,fill-blip,fill-blip-name - 0x0188=fill-blip-flags,fill-width,fill-height,fill-angle,fill-focus,fill-to-left,fill-to-top,fill-to-right - 0x0190=fill-to-bottom,fill-rect-left,fill-rect-top,fill-rect-right,fill-rect-bottom,fill-dz-type,fill-shade-preset,fill-shade-colors - 0x0198=fill-origin-x,fill-origin-y,fill-shape-origin-x,fill-shape-origin-y,fill-shade-type - 0x01BF=fill-flags - # line style - 0x01C0=line-color,line-opacity,line-back-color,line-cr-mod,line-type,line-fill-blip,line-fill-blip-name,line-fill-blip-flags - 0x01C8=line-fill-width,line-fill-height,line-fill-dz-type,line-width,line-miter-limit,line-style,line-dash,line-dash-style - 0x01D0=line-start-arrow-head,line-end-arrow-head,line-start-arrow-width,line-start-arrow-length,line-end-arrow-width,line-end-arrow-length,line-join-style,line-end-cap-style - 0x01FF=line-flags - # shadow style - 0x0200=shadow-type,shadow-color,shadow-highlight,shadow-cr-mod,shadow-opacity,shadow-offset-x,shadow-offset-y,shadow-2nd-offset-x - 0x0208=shadow-2nd-offset-y,shadow-scale-x-to-x,shadow-scale-y-to-x,shadow-scale-x-to-y,shadow-scale-y-to-y,shadow-persp-x,shadow-persp-y,shadow-weight - 0x0210=shadow-origin-x,shadow-origin-y - 0x023F=shadow-flags - # perspective - 0x0240=persp-type,persp-offset-x,persp-offsety,persp-scale-x-to-x,persp-scale-y-to-x,persp-scale-x-to-y,persp-scale-y-to-y,persp-persp-x - 0x0248=persp-persp-y,persp-weight,persp-origin-x,persp-origin-y - 0x027F=persp-flags - # 3d object - 0x0280=3dobj-specular-amt,3dobj-diffuse-amt,3dobj-shininess,3dobj-edge-thickness,3dobj-extrude-forward,3dobj-extrude-backward,3dobj-extrude-plane,3dobj-extrusion-color - 0x0288=3dobj-cr-mod - 0x02BF=3dobj-flags - # 3d style - 0x02C0=3dstyle-y-rotation,3dstyle-x-rotation,3dstyle-rotation-axis-x,3dstyle-rotation-axis-y,3dstyle-rotation-axis-z,3dstyle-rotation,3dstyle-rotation-center-x,3dstyle-rotation-center-y - 0x02C8=3dstyle-rotation-center-z,3dstyle-render-mode,3dstyle-tolerance,3dstyle-view-point-x,3dstyle-view-point-y,3dstyle-view-point-z,3dstyle-origin-x,3dstyle-origin-y - 0x02D0=3dstyle-skew-angle,3dstyle-skew-amount,3dstyle-ambient-intensity,3dstyle-key-light-x,3dstyle-key-light-y,3dstyle-key-light-z,3dstyle-key-light-intensity,3dstyle-fill-light-x - 0x02D8=3dstyle-fill-light-y,3dstyle-fill-light-z,3dstyle-fill-light-intensity - 0x02FF=3dstyle-flags - # shape 1 - 0x0301=,shape-master,,shape-connect-style,shape-bw-mod,shape-bw-mode-pure-bw,shape-bw-mode-bw - 0x033F=shape1-flags - # callout - 0x0340=callout-type,callout-box-distance,callout-angle,callout-drop-type,callout-drop-distance,callout-length - 0x037F=callout-flags - # shape 2 - 0x0380=shape-name,shape-description,shape-hyperlink,shape-wrap-polygon-vertices,shape-wrap-left,shape-wrap-top,shape-wrap-right,shape-wrap-bottom - 0x0388=shape-regroup-id - 0x03BF=shape2-flags -end - -flagslist=DFFOPT-LOCK-FLAGS - 0x00000001=lock-against-grouping - 0x00000002=lock-adjust-handles - 0x00000004=lock-text - 0x00000008=lock-vertices - 0x00000010=lock-cropping - 0x00000020=lock-against-select - 0x00000040=lock-position - 0x00000080=lock-aspect-ratio - 0x00000100=lock-rotation -end - -flagslist=DFFOPT-TEXT-FLAGS - 0x00000001=fit-text-to-shape - 0x00000002=fit-shape-to-text - 0x00000004=rotate-text - 0x00000008=auto-text-margin - 0x00000010=select-text -end - -flagslist=DFFOPT-TEXTGEO-FLAGS - 0x00000001=strike-through - 0x00000002=small-caps - 0x00000004=shadow - 0x00000008=underline - 0x00000010=italic - 0x00000020=bold - 0x00000040=no-measure-along-path - 0x00000080=stretch-height - 0x00000100=scale-on-path - 0x00000200=shrink-to-fit - 0x00000400=stretch-to-fit - 0x00000800=tightening - 0x00001000=kerning - 0x00002000=vertical - 0x00004000=has-effect - 0x00008000=reverse-rows -end - -flagslist=DFFOPT-PICTURE-FLAGS - 0x00000001=ole-alive - 0x00000002=bi-level-display - 0x00000004=grayscale - 0x00000008=no-hit-test -end - -flagslist=DFFOPT-GEO-FLAGS - 0x00000001=fill-support - 0x00000002=fill-shade-shape-support - 0x00000004=fontwork-support - 0x00000008=line-support - 0x00000010=3d-support - 0x00000020=shadow-support -end - -flagslist=DFFOPT-FILL-FLAGS - 0x00000001=no-fill-hit-test - 0x00000002=use-large-rect - 0x00000004=register-pattern - 0x00000008=hit-test-fill - 0x00000010=has-fill -end - -flagslist=DFFOPT-LINE-FLAGS - 0x00000001=draw-dash-for-invisible - 0x00000002=register-pattern - 0x00000004=hit-test-line - 0x00000008=has-line - 0x00000010=arrowhead-support -end - -flagslist=DFFOPT-SHADOW-FLAGS - 0x00000001=excel5-style - 0x00000002=has-shadow -end - -flagslist=DFFOPT-PERSP-FLAGS - 0x00000001=has-perspective -end - -flagslist=DFFOPT-3DOBJ-FLAGS - 0x00000001=light-face - 0x00000002=extrusion-color - 0x00000004=metallic - 0x00000008=has-3d -end - -flagslist=DFFOPT-3DSTYLE-FLAGS - 0x00000001=fill-color-harsh - 0x00000002=key-color-harsh - 0x00000004=parallel - 0x00000008=rotation-center-auto - 0x00000010=constrain-rotation -end - -flagslist=DFFOPT-SHAPE1-FLAGS - 0x00000001=background - 0x00000002=delete-attached-object - 0x00000008=lock-shape-type - 0x00000010=prefer-rel-resize - 0x00000020=ole-iconified -end - -flagslist=DFFOPT-CALLOUT-FLAGS - 0x00000001=length-specified - 0x00000002=drop-auto - 0x00000004=minus-y - 0x00000008=minus-x - 0x00000010=has-text-border - 0x00000020=has-accent-bar - 0x00000040=is-callout -end - -flagslist=DFFOPT-SHAPE2-FLAGS - 0x00000001=print - 0x00000002=hidden - 0x00000004=1d-adjustment - 0x00000008=action-attached - 0x00000010=notify-double-click - 0x00000020=behind-text - 0x00000040=wrap-edited -end - -# ============================================================================ - diff --git a/oox/source/dump/dumperbase.cxx b/oox/source/dump/dumperbase.cxx index c1afec609480..fdea7c9c6e8d 100644 --- a/oox/source/dump/dumperbase.cxx +++ b/oox/source/dump/dumperbase.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: dumperbase.cxx,v $ - * $Revision: 1.4 $ + * $Revision: 1.4.20.13 $ * * This file is part of OpenOffice.org. * @@ -31,25 +31,26 @@ #include "oox/dump/dumperbase.hxx" #include <algorithm> -#include <rtl/math.hxx> -#include <rtl/tencinfo.h> -#include <osl/file.hxx> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/ucb/XSimpleFileAccess.hpp> #include <com/sun/star/io/XActiveDataSink.hpp> #include <com/sun/star/io/XActiveDataSource.hpp> #include <com/sun/star/io/XTextInputStream.hpp> #include <com/sun/star/io/XTextOutputStream.hpp> -#include <comphelper/processfactory.hxx> +#include <rtl/math.hxx> +#include <osl/file.hxx> #include "oox/helper/binaryoutputstream.hxx" #include "oox/core/filterbase.hxx" #include "oox/xls/biffhelper.hxx" #if OOX_INCLUDE_DUMPER +using ::rtl::OString; +using ::rtl::OStringBuffer; +using ::rtl::OStringToOUString; using ::rtl::OUString; using ::rtl::OUStringBuffer; -using ::rtl::OString; +using ::rtl::OUStringToOString; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Exception; using ::com::sun::star::uno::UNO_QUERY_THROW; @@ -76,7 +77,7 @@ const sal_Unicode OOX_DUMP_CFG_QUOTE = '\''; const sal_Unicode OOX_DUMP_LF = '\n'; const sal_Unicode OOX_DUMP_ITEMSEP = '='; const sal_Int32 OOX_DUMP_BYTESPERLINE = 16; -const sal_Int32 OOX_DUMP_MAXARRAY = 16; +const sal_Int64 OOX_DUMP_MAXARRAY = 16; // ============================================================================ // ============================================================================ @@ -106,13 +107,22 @@ OUString InputOutputHelper::getFileNameExtension( const OUString& rFileUrl ) return OUString(); } -Reference< XInputStream > InputOutputHelper::openInputStream( const OUString& rFileName ) +// input streams -------------------------------------------------------------- + +Reference< XInputStream > InputOutputHelper::getXInputStream( BinaryInputStream& rStrm ) +{ + if( BinaryXInputStream* pXStrm = dynamic_cast< BinaryXInputStream* >( &rStrm ) ) + return pXStrm->getXInputStream(); + return 0; +} + +Reference< XInputStream > InputOutputHelper::openInputStream( + const Reference< XMultiServiceFactory >& rxFactory, const OUString& rFileName ) { Reference< XInputStream > xInStrm; - try + if( rxFactory.is() ) try { - Reference< XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory(); - Reference< XSimpleFileAccess > xFileAccess( xFactory->createInstance( CREATE_OUSTRING( "com.sun.star.ucb.SimpleFileAccess" ) ), UNO_QUERY_THROW ); + Reference< XSimpleFileAccess > xFileAccess( rxFactory->createInstance( CREATE_OUSTRING( "com.sun.star.ucb.SimpleFileAccess" ) ), UNO_QUERY_THROW ); xInStrm = xFileAccess->openFileRead( rFileName ); } catch( Exception& ) @@ -121,13 +131,13 @@ Reference< XInputStream > InputOutputHelper::openInputStream( const OUString& rF return xInStrm; } -Reference< XTextInputStream > InputOutputHelper::openTextInputStream( const Reference< XInputStream >& rxInStrm, const OUString& rEncoding ) +Reference< XTextInputStream > InputOutputHelper::openTextInputStream( + const Reference< XMultiServiceFactory >& rxFactory, const Reference< XInputStream >& rxInStrm, const OUString& rEncoding ) { Reference< XTextInputStream > xTextInStrm; - if( rxInStrm.is() ) try + if( rxFactory.is() && rxInStrm.is() ) try { - Reference< XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory(); - Reference< XActiveDataSink > xDataSink( xFactory->createInstance( CREATE_OUSTRING( "com.sun.star.io.TextInputStream" ) ), UNO_QUERY_THROW ); + Reference< XActiveDataSink > xDataSink( rxFactory->createInstance( CREATE_OUSTRING( "com.sun.star.io.TextInputStream" ) ), UNO_QUERY_THROW ); xDataSink->setInputStream( rxInStrm ); xTextInStrm.set( xDataSink, UNO_QUERY_THROW ); } @@ -139,23 +149,22 @@ Reference< XTextInputStream > InputOutputHelper::openTextInputStream( const Refe return xTextInStrm; } -Reference< XTextInputStream > InputOutputHelper::openTextInputStream( const OUString& rFileName, const OUString& rEncoding ) +Reference< XTextInputStream > InputOutputHelper::openTextInputStream( + const Reference< XMultiServiceFactory >& rxFactory, const OUString& rFileName, const OUString& rEncoding ) { - return openTextInputStream( openInputStream( rFileName ), rEncoding ); + return openTextInputStream( rxFactory, openInputStream( rxFactory, rFileName ), rEncoding ); } -Reference< XOutputStream > InputOutputHelper::openOutputStream( const OUString& rFileName ) +// output streams ------------------------------------------------------------- + +Reference< XOutputStream > InputOutputHelper::openOutputStream( + const Reference< XMultiServiceFactory >& rxFactory, const OUString& rFileName ) { Reference< XOutputStream > xOutStrm; - try + if( rxFactory.is() ) try { - Reference< XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory(); - Reference< XSimpleFileAccess > xFileAccess( xFactory->createInstance( CREATE_OUSTRING( "com.sun.star.ucb.SimpleFileAccess" ) ), UNO_QUERY_THROW ); - if( !xFileAccess->isFolder( rFileName ) ) - { - try { xFileAccess->kill( rFileName ); } catch( Exception& ) {} - xOutStrm = xFileAccess->openFileWrite( rFileName ); - } + Reference< XSimpleFileAccess > xFileAccess( rxFactory->createInstance( CREATE_OUSTRING( "com.sun.star.ucb.SimpleFileAccess" ) ), UNO_QUERY_THROW ); + xOutStrm = xFileAccess->openFileWrite( rFileName ); } catch( Exception& ) { @@ -163,13 +172,13 @@ Reference< XOutputStream > InputOutputHelper::openOutputStream( const OUString& return xOutStrm; } -Reference< XTextOutputStream > InputOutputHelper::openTextOutputStream( const Reference< XOutputStream >& rxOutStrm, const OUString& rEncoding ) +Reference< XTextOutputStream > InputOutputHelper::openTextOutputStream( + const Reference< XMultiServiceFactory >& rxFactory, const Reference< XOutputStream >& rxOutStrm, const OUString& rEncoding ) { Reference< XTextOutputStream > xTextOutStrm; - if( rxOutStrm.is() ) try + if( rxFactory.is() && rxOutStrm.is() ) try { - Reference< XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory(); - Reference< XActiveDataSource > xDataSource( xFactory->createInstance( CREATE_OUSTRING( "com.sun.star.io.TextOutputStream" ) ), UNO_QUERY_THROW ); + Reference< XActiveDataSource > xDataSource( rxFactory->createInstance( CREATE_OUSTRING( "com.sun.star.io.TextOutputStream" ) ), UNO_QUERY_THROW ); xDataSource->setOutputStream( rxOutStrm ); xTextOutStrm.set( xDataSource, UNO_QUERY_THROW ); } @@ -181,9 +190,10 @@ Reference< XTextOutputStream > InputOutputHelper::openTextOutputStream( const Re return xTextOutStrm; } -Reference< XTextOutputStream > InputOutputHelper::openTextOutputStream( const OUString& rFileName, const OUString& rEncoding ) +Reference< XTextOutputStream > InputOutputHelper::openTextOutputStream( + const Reference< XMultiServiceFactory >& rxFactory, const OUString& rFileName, const OUString& rEncoding ) { - return openTextOutputStream( openOutputStream( rFileName ), rEncoding ); + return openTextOutputStream( rxFactory, openOutputStream( rxFactory, rFileName ), rEncoding ); } // ============================================================================ @@ -247,7 +257,7 @@ OUStringVector ItemFormat::parse( const OUString& rFormatStr ) // append string to string ---------------------------------------------------- -void StringHelper::appendChar( ::rtl::OUStringBuffer& rStr, sal_Unicode cChar, sal_Int32 nCount ) +void StringHelper::appendChar( OUStringBuffer& rStr, sal_Unicode cChar, sal_Int32 nCount ) { for( sal_Int32 nIndex = 0; nIndex < nCount; ++nIndex ) rStr.append( cChar ); @@ -370,21 +380,20 @@ void StringHelper::appendHex( OUStringBuffer& rStr, double fData, bool bPrefix ) void StringHelper::appendShortHex( OUStringBuffer& rStr, sal_uInt8 nData, bool bPrefix ) { - if( nData != 0 ) - appendHex( rStr, nData, bPrefix ); + appendHex( rStr, nData, bPrefix ); } void StringHelper::appendShortHex( OUStringBuffer& rStr, sal_Int8 nData, bool bPrefix ) { - appendShortHex( rStr, static_cast< sal_uInt8 >( nData ), bPrefix ); + appendHex( rStr, nData, bPrefix ); } void StringHelper::appendShortHex( OUStringBuffer& rStr, sal_uInt16 nData, bool bPrefix ) { - if( nData > 0xFF ) + if( nData > SAL_MAX_UINT8 ) appendHex( rStr, nData, bPrefix ); else - appendShortHex( rStr, static_cast< sal_uInt8 >( nData ), bPrefix ); + appendHex( rStr, static_cast< sal_uInt8 >( nData ), bPrefix ); } void StringHelper::appendShortHex( OUStringBuffer& rStr, sal_Int16 nData, bool bPrefix ) @@ -394,7 +403,7 @@ void StringHelper::appendShortHex( OUStringBuffer& rStr, sal_Int16 nData, bool b void StringHelper::appendShortHex( OUStringBuffer& rStr, sal_uInt32 nData, bool bPrefix ) { - if( nData > 0xFFFF ) + if( nData > SAL_MAX_UINT16 ) appendHex( rStr, nData, bPrefix ); else appendShortHex( rStr, static_cast< sal_uInt16 >( nData ), bPrefix ); @@ -407,7 +416,7 @@ void StringHelper::appendShortHex( OUStringBuffer& rStr, sal_Int32 nData, bool b void StringHelper::appendShortHex( OUStringBuffer& rStr, sal_uInt64 nData, bool bPrefix ) { - if( nData > 0xFFFFFFFF ) + if( nData > SAL_MAX_UINT32 ) appendHex( rStr, nData, bPrefix ); else appendShortHex( rStr, static_cast< sal_uInt32 >( nData ), bPrefix ); @@ -418,6 +427,11 @@ void StringHelper::appendShortHex( OUStringBuffer& rStr, sal_Int64 nData, bool b appendShortHex( rStr, static_cast< sal_uInt64 >( nData ), bPrefix ); } +void StringHelper::appendShortHex( OUStringBuffer& rStr, double fData, bool bPrefix ) +{ + appendHex( rStr, fData, bPrefix ); +} + // append binary -------------------------------------------------------------- void StringHelper::appendBin( OUStringBuffer& rStr, sal_uInt8 nData, bool bDots ) @@ -763,7 +777,7 @@ OUString StringHelper::trimSpaces( const OUString& rStr ) OString StringHelper::convertToUtf8( const OUString& rStr ) { - return ::rtl::OUStringToOString( rStr, RTL_TEXTENCODING_UTF8 ); + return OUStringToOString( rStr, RTL_TEXTENCODING_UTF8 ); } DataType StringHelper::convertToDataType( const OUString& rStr ) @@ -799,6 +813,8 @@ FormatType StringHelper::convertToFormatType( const OUString& rStr ) eType = FORMATTYPE_DEC; else if( rStr.equalsAscii( "hex" ) ) eType = FORMATTYPE_HEX; + else if( rStr.equalsAscii( "shorthex" ) ) + eType = FORMATTYPE_SHORTHEX; else if( rStr.equalsAscii( "bin" ) ) eType = FORMATTYPE_BIN; else if( rStr.equalsAscii( "fix" ) ) @@ -912,32 +928,32 @@ FormulaStack::FormulaStack() : { } -void FormulaStack::pushOperand( const StringWrapper& rOp, const OUString& rTokClass ) +void FormulaStack::pushOperand( const String& rOp, const OUString& rTokClass ) { - maFmlaStack.push( rOp.getString() ); + maFmlaStack.push( rOp ); maClassStack.push( rTokClass ); } -void FormulaStack::pushOperand( const StringWrapper& rOp ) +void FormulaStack::pushOperand( const String& rOp ) { pushOperand( rOp, OUString( OOX_DUMP_BASECLASS ) ); } -void FormulaStack::pushUnaryOp( const StringWrapper& rLOp, const StringWrapper& rROp ) +void FormulaStack::pushUnaryOp( const String& rLOp, const String& rROp ) { - pushUnaryOp( maFmlaStack, rLOp.getString(), rROp.getString() ); - pushUnaryOp( maClassStack, rLOp.getString(), rROp.getString() ); + pushUnaryOp( maFmlaStack, rLOp, rROp ); + pushUnaryOp( maClassStack, rLOp, rROp ); } -void FormulaStack::pushBinaryOp( const StringWrapper& rOp ) +void FormulaStack::pushBinaryOp( const String& rOp ) { - pushBinaryOp( maFmlaStack, rOp.getString() ); - pushBinaryOp( maClassStack, rOp.getString() ); + pushBinaryOp( maFmlaStack, rOp ); + pushBinaryOp( maClassStack, rOp ); } -void FormulaStack::pushFuncOp( const StringWrapper& rFunc, const OUString& rTokClass, sal_uInt8 nParamCount ) +void FormulaStack::pushFuncOp( const String& rFunc, const OUString& rTokClass, sal_uInt8 nParamCount ) { - pushFuncOp( maFmlaStack, rFunc.getString(), nParamCount ); + pushFuncOp( maFmlaStack, rFunc, nParamCount ); pushFuncOp( maClassStack, rTokClass, nParamCount ); } @@ -1097,18 +1113,18 @@ NameListBase::~NameListBase() { } -void NameListBase::setName( sal_Int64 nKey, const StringWrapper& rNameWrp ) +void NameListBase::setName( sal_Int64 nKey, const String& rName ) { - implSetName( nKey, rNameWrp.getString() ); + implSetName( nKey, rName ); } -void NameListBase::includeList( NameListRef xList ) +void NameListBase::includeList( const NameListRef& rxList ) { - if( xList.get() ) + if( rxList.get() ) { - for( const_iterator aIt = xList->begin(), aEnd = xList->end(); aIt != aEnd; ++aIt ) + for( const_iterator aIt = rxList->begin(), aEnd = rxList->end(); aIt != aEnd; ++aIt ) maMap[ aIt->first ] = aIt->second; - implIncludeList( *xList ); + implIncludeList( *rxList ); } } @@ -1285,8 +1301,22 @@ OUString FlagsList::implGetName( const Config& /*rCfg*/, sal_Int64 nKey ) const sal_Int64 nMask = aIt->first; const OUString& rFlagName = aIt->second; bool bNegated = (rFlagName.getLength() > 0) && (rFlagName[ 0 ] == '!'); - if( getFlag( nFlags, nMask ) != bNegated ) - StringHelper::appendToken( aName, bNegated ? rFlagName.copy( 1 ) : rFlagName ); + sal_Int32 nBothSep = bNegated ? rFlagName.indexOf( '!', 1 ) : -1; + bool bFlag = getFlag( nFlags, nMask ); + if( bFlag ) + { + if( !bNegated ) + StringHelper::appendToken( aName, rFlagName ); + else if( nBothSep > 0 ) + StringHelper::appendToken( aName, rFlagName.copy( nBothSep + 1 ) ); + } + else if( bNegated ) + { + if( nBothSep > 0 ) + StringHelper::appendToken( aName, rFlagName.copy( 1, nBothSep - 1 ) ); + else + StringHelper::appendToken( aName, rFlagName.copy( 1 ) ); + } setFlag( nFound, nMask ); } // add unknown flags @@ -1430,24 +1460,19 @@ void UnitConverter::implIncludeList( const NameListBase& /*rList*/ ) NameListRef NameListWrapper::getNameList( const Config& rCfg ) const { - return mxList.get() ? mxList : (mxList = rCfg.getNameList( maNameWrp.getString() )); + return mxList.get() ? mxList : (mxList = rCfg.getNameList( maName )); } // ============================================================================ // ============================================================================ -SharedConfigData::SharedConfigData( const OUString& rFileName ) +SharedConfigData::SharedConfigData( const OUString& rFileName, + const Reference< XMultiServiceFactory >& rxFactory, const StorageRef& rxRootStrg, const OUString& rSysFileName ) : + mxFactory( rxFactory ), + mxRootStrg( rxRootStrg ), + maSysFileName( rSysFileName ), + mbLoaded( false ) { - construct( rFileName ); -} - -SharedConfigData::~SharedConfigData() -{ -} - -void SharedConfigData::construct( const OUString& rFileName ) -{ - mbLoaded = false; OUString aFileUrl = InputOutputHelper::convertFileNameToUrl( rFileName ); if( aFileUrl.getLength() > 0 ) { @@ -1457,6 +1482,10 @@ void SharedConfigData::construct( const OUString& rFileName ) } } +SharedConfigData::~SharedConfigData() +{ +} + void SharedConfigData::setOption( const OUString& rKey, const OUString& rData ) { maConfigData[ rKey ] = rData; @@ -1468,10 +1497,10 @@ const OUString* SharedConfigData::getOption( const OUString& rKey ) const return (aIt == maConfigData.end()) ? 0 : &aIt->second; } -void SharedConfigData::setNameList( const OUString& rListName, NameListRef xList ) +void SharedConfigData::setNameList( const OUString& rListName, const NameListRef& rxList ) { if( rListName.getLength() > 0 ) - maNameLists[ rListName ] = xList; + maNameLists[ rListName ] = rxList; } void SharedConfigData::eraseNameList( const OUString& rListName ) @@ -1490,7 +1519,7 @@ NameListRef SharedConfigData::getNameList( const OUString& rListName ) const bool SharedConfigData::implIsValid() const { - return mbLoaded; + return mbLoaded && mxFactory.is() && mxRootStrg.get() && (maSysFileName.getLength() > 0); } void SharedConfigData::implProcessConfigItemStr( @@ -1520,7 +1549,7 @@ bool SharedConfigData::readConfigFile( const OUString& rFileUrl ) if( !bLoaded ) { Reference< XTextInputStream > xTextInStrm = - InputOutputHelper::openTextInputStream( rFileUrl, CREATE_OUSTRING( "UTF-8" ) ); + InputOutputHelper::openTextInputStream( mxFactory, rFileUrl, CREATE_OUSTRING( "UTF-8" ) ); if( xTextInStrm.is() ) { maConfigFiles.insert( rFileUrl ); @@ -1582,14 +1611,14 @@ Config::Config( const Config& rParent ) : construct( rParent ); } -Config::Config( const OUString& rFileName ) +Config::Config( const sal_Char* pcEnvVar, const FilterBase& rFilter ) { - construct( rFileName ); + construct( pcEnvVar, rFilter ); } -Config::Config( const sal_Char* pcEnvVar ) +Config::Config( const sal_Char* pcEnvVar, const Reference< XMultiServiceFactory >& rxFactory, const StorageRef& rxRootStrg, const OUString& rSysFileName ) { - construct( pcEnvVar ); + construct( pcEnvVar, rxFactory, rxRootStrg, rSysFileName ); } Config::~Config() @@ -1601,32 +1630,33 @@ void Config::construct( const Config& rParent ) *this = rParent; } -void Config::construct( const OUString& rFileName ) +void Config::construct( const sal_Char* pcEnvVar, const FilterBase& rFilter ) { - mxCfgData.reset( new SharedConfigData( rFileName ) ); + if( rFilter.getFileUrl().getLength() > 0 ) + construct( pcEnvVar, rFilter.getGlobalFactory(), rFilter.getStorage(), rFilter.getFileUrl() ); } -void Config::construct( const sal_Char* pcEnvVar ) +void Config::construct( const sal_Char* pcEnvVar, const Reference< XMultiServiceFactory >& rxFactory, const StorageRef& rxRootStrg, const OUString& rSysFileName ) { - if( pcEnvVar ) + if( pcEnvVar && rxRootStrg.get() && (rSysFileName.getLength() > 0) ) if( const sal_Char* pcFileName = ::getenv( pcEnvVar ) ) - construct( OUString::createFromAscii( pcFileName ) ); + mxCfgData.reset( new SharedConfigData( OUString::createFromAscii( pcFileName ), rxFactory, rxRootStrg, rSysFileName ) ); } -void Config::setStringOption( const StringWrapper& rKey, const StringWrapper& rData ) +void Config::setStringOption( const String& rKey, const String& rData ) { - mxCfgData->setOption( rKey.getString(), rData.getString() ); + mxCfgData->setOption( rKey, rData ); } -const OUString& Config::getStringOption( const StringWrapper& rKey, const OUString& rDefault ) const +const OUString& Config::getStringOption( const String& rKey, const OUString& rDefault ) const { - const OUString* pData = implGetOption( rKey.getString() ); + const OUString* pData = implGetOption( rKey ); return pData ? *pData : rDefault; } -bool Config::getBoolOption( const StringWrapper& rKey, bool bDefault ) const +bool Config::getBoolOption( const String& rKey, bool bDefault ) const { - const OUString* pData = implGetOption( rKey.getString() ); + const OUString* pData = implGetOption( rKey ); return pData ? StringHelper::convertStringToBool( *pData ) : bDefault; } @@ -1640,19 +1670,19 @@ bool Config::isImportEnabled() const return getBoolOption( "enable-import", true ); } -void Config::setNameList( const StringWrapper& rListName, NameListRef xList ) +void Config::setNameList( const String& rListName, const NameListRef& rxList ) { - mxCfgData->setNameList( rListName.getString(), xList ); + mxCfgData->setNameList( rListName, rxList ); } -void Config::eraseNameList( const StringWrapper& rListName ) +void Config::eraseNameList( const String& rListName ) { - mxCfgData->eraseNameList( rListName.getString() ); + mxCfgData->eraseNameList( rListName ); } -NameListRef Config::getNameList( const StringWrapper& rListName ) const +NameListRef Config::getNameList( const String& rListName ) const { - return implGetNameList( rListName.getString() ); + return implGetNameList( rListName ); } bool Config::implIsValid() const @@ -1673,78 +1703,14 @@ NameListRef Config::implGetNameList( const OUString& rListName ) const // ============================================================================ // ============================================================================ -bool Input::implIsValid() const -{ - return true; -} - -Input& operator>>( Input& rIn, sal_Int64& rnData ) -{ - return rIn >> *reinterpret_cast< double* >( &rnData ); -} - -Input& operator>>( Input& rIn, sal_uInt64& rnData ) -{ - return rIn >> *reinterpret_cast< double* >( &rnData ); -} - -// ============================================================================ - -BinaryInput::BinaryInput( BinaryInputStream& rStrm ) : - mrStrm( rStrm ) -{ -} - -sal_Int64 BinaryInput::getSize() const -{ - return mrStrm.getLength(); -} - -sal_Int64 BinaryInput::tell() const -{ - return mrStrm.tell(); -} - -void BinaryInput::seek( sal_Int64 nPos ) -{ - mrStrm.seek( nPos ); -} - -void BinaryInput::skip( sal_Int32 nBytes ) -{ - mrStrm.skip( nBytes ); -} - -sal_Int32 BinaryInput::read( void* pBuffer, sal_Int32 nBytes ) -{ - return mrStrm.read( pBuffer, nBytes ); -} - -bool BinaryInput::implIsValid() const -{ - return mrStrm.is() && Input::implIsValid(); -} - -BinaryInput& BinaryInput::operator>>( sal_Int8& rnData ) { mrStrm >> rnData; return *this; } -BinaryInput& BinaryInput::operator>>( sal_uInt8& rnData ) { mrStrm >> rnData; return *this; } -BinaryInput& BinaryInput::operator>>( sal_Int16& rnData ) { mrStrm >> rnData; return *this; } -BinaryInput& BinaryInput::operator>>( sal_uInt16& rnData ) { mrStrm >> rnData; return *this; } -BinaryInput& BinaryInput::operator>>( sal_Int32& rnData ) { mrStrm >> rnData; return *this; } -BinaryInput& BinaryInput::operator>>( sal_uInt32& rnData ) { mrStrm >> rnData; return *this; } -BinaryInput& BinaryInput::operator>>( float& rfData ) { mrStrm >> rfData; return *this; } -BinaryInput& BinaryInput::operator>>( double& rfData ) { mrStrm >> rfData; return *this; } - -// ============================================================================ -// ============================================================================ - Output::Output( const Reference< XTextOutputStream >& rxStrm ) { construct( rxStrm ); } -Output::Output( const ::rtl::OUString& rFileName ) +Output::Output( const Reference< XMultiServiceFactory >& rxFactory, const OUString& rFileName ) { - construct( InputOutputHelper::openTextOutputStream( rFileName, CREATE_OUSTRING( "UTF-8" ) ) ); + construct( InputOutputHelper::openTextOutputStream( rxFactory, rFileName, CREATE_OUSTRING( "UTF-8" ) ) ); } // ---------------------------------------------------------------------------- @@ -1860,15 +1826,15 @@ void Output::resetItemIndex( sal_Int64 nIdx ) mnItemIdx = nIdx; } -void Output::startItem( const sal_Char* pcName ) +void Output::startItem( const String& rItemName ) { if( mnItemLevel == 0 ) { if( (mnMultiLevel > 0) && (maLine.getLength() > 0) ) tab(); - if( pcName ) + if( rItemName.has() ) { - writeItemName( pcName ); + writeItemName( rItemName ); writeChar( OOX_DUMP_ITEMSEP ); } } @@ -1951,16 +1917,16 @@ void Output::writeBool( bool bData ) StringHelper::appendBool( maLine, bData ); } -void Output::writeColor( sal_Int32 nColor ) +void Output::writeColorABGR( sal_Int32 nColor ) { writeChar( 'a' ); writeDec( static_cast< sal_uInt8 >( nColor >> 24 ) ); writeAscii( ",r" ); - writeDec( static_cast< sal_uInt8 >( nColor >> 16 ) ); + writeDec( static_cast< sal_uInt8 >( nColor ) ); writeAscii( ",g" ); writeDec( static_cast< sal_uInt8 >( nColor >> 8 ) ); writeAscii( ",b" ); - writeDec( static_cast< sal_uInt8 >( nColor ) ); + writeDec( static_cast< sal_uInt8 >( nColor >> 16 ) ); } void Output::writeDateTime( const DateTime& rDateTime ) @@ -2035,9 +2001,7 @@ void Output::construct( const Reference< XTextOutputStream >& rxStrm ) if( mxStrm.is() ) { writeChar( OOX_DUMP_BOM ); - writeAscii( "OpenOffice.org binary file dumper v2.0" ); newLine(); - emptyLine(); } } @@ -2046,15 +2010,67 @@ bool Output::implIsValid() const return mxStrm.is(); } -void Output::writeItemName( const sal_Char* pcName ) +void Output::writeItemName( const String& rItemName ) { - if( pcName && (*pcName == '#') ) + if( rItemName.has() && (rItemName[ 0 ] == '#') ) { - writeAscii( pcName + 1 ); + writeString( rItemName.copy( 1 ) ); StringHelper::appendIndex( maLine, mnItemIdx++ ); } else - writeAscii( pcName ); + writeString( rItemName ); +} + +// ============================================================================ + +StorageIterator::StorageIterator( const StorageRef& rxStrg ) : + mxStrg( rxStrg ) +{ + if( mxStrg.get() ) + mxStrg->getElementNames( maNames ); + maIt = maNames.begin(); +} + +StorageIterator::~StorageIterator() +{ +} + +size_t StorageIterator::getElementCount() const +{ + return maNames.size(); +} + +StorageIterator& StorageIterator::operator++() +{ + if( maIt != maNames.end() ) + ++maIt; + return *this; +} + +OUString StorageIterator::getName() const +{ + OUString aName; + if( maIt != maNames.end() ) + aName = *maIt; + return aName; +} + +bool StorageIterator::isStream() const +{ + return isValid() && mxStrg->openInputStream( *maIt ).is(); +} + +bool StorageIterator::isStorage() const +{ + if( !isValid() ) + return false; + StorageRef xStrg = mxStrg->openSubStorage( *maIt, false ); + return xStrg.get() && xStrg->isStorage(); +} + +bool StorageIterator::implIsValid() const +{ + return mxStrg.get() && mxStrg->isStorage() && (maIt != maNames.end()); } // ============================================================================ @@ -2064,10 +2080,9 @@ ObjectBase::~ObjectBase() { } -void ObjectBase::construct( const FilterBase& rFilter, ConfigRef xConfig ) +void ObjectBase::construct( const ConfigRef& rxConfig ) { - mpFilter = &rFilter; - mxConfig = xConfig; + mxConfig = rxConfig; } void ObjectBase::construct( const ObjectBase& rParent ) @@ -2083,141 +2098,149 @@ void ObjectBase::dump() bool ObjectBase::implIsValid() const { - return mpFilter && mpFilter->isImportFilter() && isValid( mxConfig ); -} - -ConfigRef ObjectBase::implReconstructConfig() -{ - return mxConfig; + return isValid( mxConfig ); } void ObjectBase::implDump() { } -void ObjectBase::reconstructConfig() +void ObjectBase::reconstructConfig( const ConfigRef& rxConfig ) { - mxConfig = implReconstructConfig(); + if( isValid( rxConfig ) ) + mxConfig = rxConfig; } // ============================================================================ // ============================================================================ -RootStorageObjectBase::~RootStorageObjectBase() -{ -} - -void RootStorageObjectBase::construct( const ObjectBase& rParent ) +void StorageObjectBase::construct( const ObjectBase& rParent, const StorageRef& rxStrg, const OUString& rSysPath ) { ObjectBase::construct( rParent ); + mxStrg = rxStrg; + maSysPath = rSysPath; } -void RootStorageObjectBase::implDump() +void StorageObjectBase::construct( const ObjectBase& rParent ) { - StorageRef xStrg = getFilter().getStorage(); - if( xStrg.get() && xStrg->isStorage() ) - extractStorage( xStrg, getFilter().getFileUrl() + CREATE_OUSTRING( ".dump" ) ); + ObjectBase::construct( rParent ); + if( ObjectBase::implIsValid() ) + { + mxStrg = cfg().getRootStorage(); + maSysPath = cfg().getSysFileName(); + } } -void RootStorageObjectBase::implDumpStream( BinaryInputStreamRef, const OUString&, const OUString&, const OUString& ) +bool StorageObjectBase::implIsValid() const { + return mxStrg.get() && mxStrg->isStorage() && (maSysPath.getLength() > 0) && ObjectBase::implIsValid(); } -void RootStorageObjectBase::extractStream( StorageBase& rStrg, const OUString& rStrmName, const OUString& rSystemFileName ) +void StorageObjectBase::implDump() { - BinaryInputStream aInStrm( rStrg.openInputStream( rStrmName ), true ); - if( aInStrm.is() ) + try { - BinaryOutputStream aOutStrm( InputOutputHelper::openOutputStream( rSystemFileName ), true ); - if( aOutStrm.is() ) - aOutStrm.copy( aInStrm ); + Reference< XSimpleFileAccess > xFileAccess( getFactory()->createInstance( CREATE_OUSTRING( "com.sun.star.ucb.SimpleFileAccess" ) ), UNO_QUERY_THROW ); + xFileAccess->kill( maSysPath + OOX_DUMP_DUMPEXT ); } - BinaryInputStreamRef xDumpStrm( new BinaryInputStream( InputOutputHelper::openInputStream( rSystemFileName ), true ) ); - if( xDumpStrm->is() ) - implDumpStream( xDumpStrm, rStrg.getPath(), rStrmName, rSystemFileName + CREATE_OUSTRING( ".dump" ) ); -} - -void RootStorageObjectBase::extractStorage( StorageRef xStrg, const OUString& rSystemPath ) -{ - // create directory in file system - ::osl::FileBase::RC eRes = ::osl::Directory::create( rSystemPath ); - if( (eRes == ::osl::FileBase::E_None) || (eRes == ::osl::FileBase::E_EXIST) ) + catch( Exception& ) { - // process children of the storage - for( StorageIterator aIt( xStrg ); aIt.isValid(); ++aIt ) - { - // encode all characters < 0x20 - OUStringBuffer aBuffer; - StringHelper::appendEncString( aBuffer, aIt.getName(), false ); - - // replace all characters reserved in file system - OUString aSystemName = aBuffer.makeStringAndClear(); - static const sal_Unicode spcReserved[] = { '/', '\\', ':', '*', '?', '<', '>', '|' }; - for( const sal_Unicode* pcChar = spcReserved; pcChar < STATIC_ARRAY_END( spcReserved ); ++pcChar ) - aSystemName = aSystemName.replace( *pcChar, '_' ); - - // build full path - OUString aFullSystemName = rSystemPath + OUString( sal_Unicode( '/' ) ) + aSystemName; - - // handle storages and streams - if( aIt.isStorage() ) - extractStorage( xStrg->openSubStorage( aIt.getName(), false ), aFullSystemName ); - else if( aIt.isStream() ) - extractStream( *xStrg, aIt.getName(), aFullSystemName ); - } } + extractStorage( mxStrg, OUString(), maSysPath ); } -// ============================================================================ - -StorageIterator::StorageIterator( StorageRef xStrg ) : - mxStrg( xStrg ) +void StorageObjectBase::implDumpStream( const BinaryInputStreamRef&, const OUString&, const OUString&, const OUString& ) { - if( mxStrg.get() ) - mxStrg->getElementNames( maNames ); - maIt = maNames.begin(); } -StorageIterator::~StorageIterator() +void StorageObjectBase::implDumpStorage( const StorageRef& rxStrg, const OUString& rStrgPath, const OUString& rSysPath ) { + extractStorage( rxStrg, rStrgPath, rSysPath ); } -size_t StorageIterator::getElementCount() const +void StorageObjectBase::addPreferredStream( const String& rStrmName ) { - return maNames.size(); + if( rStrmName.has() ) + maPreferred.push_back( PreferredItem( rStrmName, false ) ); } -StorageIterator& StorageIterator::operator++() +void StorageObjectBase::addPreferredStorage( const String& rStrgPath ) { - if( maIt != maNames.end() ) - ++maIt; - return *this; + if( rStrgPath.has() ) + maPreferred.push_back( PreferredItem( rStrgPath, true ) ); } -OUString StorageIterator::getName() const +OUString StorageObjectBase::getSysFileName( const OUString& rStrmName, const OUString& rSysOutPath ) { - OUString aName; - if( maIt != maNames.end() ) - aName = *maIt; - return aName; + // encode all characters < 0x20 + OUStringBuffer aBuffer; + StringHelper::appendEncString( aBuffer, rStrmName, false ); + + // replace all characters reserved in file system + OUString aFileName = aBuffer.makeStringAndClear(); + static const sal_Unicode spcReserved[] = { '/', '\\', ':', '*', '?', '<', '>', '|' }; + for( const sal_Unicode* pcChar = spcReserved; pcChar < STATIC_ARRAY_END( spcReserved ); ++pcChar ) + aFileName = aFileName.replace( *pcChar, '_' ); + + // build full path + return rSysOutPath + OUString( sal_Unicode( '/' ) ) + aFileName; } -bool StorageIterator::isStream() const +void StorageObjectBase::extractStream( StorageBase& rStrg, const OUString& rStrgPath, const OUString& rStrmName, const OUString& rSysFileName ) { - return isValid() && mxStrg->openInputStream( *maIt ).is(); + BinaryXInputStream aInStrm( rStrg.openInputStream( rStrmName ), true ); + if( !aInStrm.isEof() ) + { + BinaryXOutputStream aOutStrm( InputOutputHelper::openOutputStream( getFactory(), rSysFileName ), true ); + if( !aOutStrm.isEof() ) + aOutStrm.copyStream( aInStrm ); + } + BinaryXInputStreamRef xDumpStrm( new BinaryXInputStream( InputOutputHelper::openInputStream( getFactory(), rSysFileName ), true ) ); + if( !xDumpStrm->isEof() ) + implDumpStream( xDumpStrm, rStrgPath, rStrmName, rSysFileName ); } -bool StorageIterator::isStorage() const +void StorageObjectBase::extractStorage( const StorageRef& rxStrg, const OUString& rStrgPath, const OUString& rSysPath ) { - if( !isValid() ) - return false; - StorageRef xStrg = mxStrg->openSubStorage( *maIt, false ); - return xStrg.get() && xStrg->isStorage(); + OUString aSysOutPath = rSysPath + OOX_DUMP_DUMPEXT; + + // create directory in file system + ::osl::FileBase::RC eRes = ::osl::Directory::create( aSysOutPath ); + if( (eRes != ::osl::FileBase::E_None) && (eRes != ::osl::FileBase::E_EXIST) ) + return; + + // process preferred storages and streams in root storage first + if( rStrgPath.getLength() == 0 ) + for( PreferredItemVector::iterator aIt = maPreferred.begin(), aEnd = maPreferred.end(); aIt != aEnd; ++aIt ) + extractItem( rxStrg, rStrgPath, aIt->maName, aSysOutPath, aIt->mbStorage, !aIt->mbStorage ); + + // process children of the storage + for( StorageIterator aIt( rxStrg ); aIt.isValid(); ++aIt ) + { + // skip processed preferred items + OUString aItemName = aIt.getName(); + bool bFound = false; + if( rStrgPath.getLength() == 0 ) + for( PreferredItemVector::iterator aIIt = maPreferred.begin(), aIEnd = maPreferred.end(); !bFound && (aIIt != aIEnd); ++aIIt ) + bFound = aIIt->maName == aItemName; + if( !bFound ) + extractItem( rxStrg, rStrgPath, aItemName, aSysOutPath, aIt.isStorage(), aIt.isStream() ); + } } -bool StorageIterator::implIsValid() const +void StorageObjectBase::extractItem( const StorageRef& rxStrg, const OUString& rStrgPath, const OUString& rItemName, const OUString& rSysOutPath, bool bIsStrg, bool bIsStrm ) { - return mxStrg.get() && mxStrg->isStorage() && (maIt != maNames.end()); + OUString aSysFileName = getSysFileName( rItemName, rSysOutPath ); + if( bIsStrg ) + { + OUStringBuffer aStrgPath( rStrgPath ); + StringHelper::appendToken( aStrgPath, rItemName, '/' ); + implDumpStorage( rxStrg->openSubStorage( rItemName, false ), aStrgPath.makeStringAndClear(), aSysFileName ); + } + else if( bIsStrm ) + { + extractStream( *rxStrg, rStrgPath, rItemName, aSysFileName ); + } } // ============================================================================ @@ -2227,16 +2250,17 @@ OutputObjectBase::~OutputObjectBase() { } -void OutputObjectBase::construct( const ObjectBase& rParent, const OUString& rOutFileName ) +void OutputObjectBase::construct( const ObjectBase& rParent, const OUString& rSysFileName ) { ObjectBase::construct( rParent ); - mxOut.reset( new Output( rOutFileName ) ); + if( ObjectBase::implIsValid() ) + mxOut.reset( new Output( getFactory(), rSysFileName + OOX_DUMP_DUMPEXT ) ); } -void OutputObjectBase::construct( const ObjectBase& rParent, OutputRef xOut ) +void OutputObjectBase::construct( const ObjectBase& rParent, const OutputRef& rxOut ) { ObjectBase::construct( rParent ); - mxOut = xOut; + mxOut = rxOut; } void OutputObjectBase::construct( const OutputObjectBase& rParent ) @@ -2249,30 +2273,28 @@ bool OutputObjectBase::implIsValid() const return isValid( mxOut ) && ObjectBase::implIsValid(); } -OutputRef OutputObjectBase::implReconstructOutput() -{ - return mxOut; -} - -void OutputObjectBase::reconstructOutput() +void OutputObjectBase::writeEmptyItem( const String& rName ) { - mxOut = implReconstructOutput(); + ItemGuard aItem( *mxOut, rName ); } -void OutputObjectBase::writeEmptyItem( const sal_Char* pcName ) +void OutputObjectBase::writeInfoItem( const String& rName, const String& rData ) { - ItemGuard aItem( *mxOut, pcName ); + ItemGuard aItem( *mxOut, rName ); + mxOut->writeString( rData ); } -void OutputObjectBase::writeInfoItem( const sal_Char* pcName, const StringWrapper& rData ) +void OutputObjectBase::writeCharItem( const String& rName, sal_Unicode cData ) { - ItemGuard aItem( *mxOut, pcName ); - mxOut->writeString( rData.getString() ); + ItemGuard aItem( *mxOut, rName ); + mxOut->writeChar( OOX_DUMP_STRQUOTE ); + mxOut->writeChar( cData ); + mxOut->writeChar( OOX_DUMP_STRQUOTE ); } -void OutputObjectBase::writeStringItem( const sal_Char* pcName, const ::rtl::OUString& rData ) +void OutputObjectBase::writeStringItem( const String& rName, const OUString& rData ) { - ItemGuard aItem( *mxOut, pcName ); + ItemGuard aItem( *mxOut, rName ); mxOut->writeAscii( "(len=" ); mxOut->writeDec( rData.getLength() ); mxOut->writeAscii( ")," ); @@ -2283,127 +2305,127 @@ void OutputObjectBase::writeStringItem( const sal_Char* pcName, const ::rtl::OUS mxOut->writeAscii( ",cut" ); } -void OutputObjectBase::writeArrayItem( const sal_Char* pcName, const sal_uInt8* pnData, sal_Size nSize, sal_Unicode cSep ) +void OutputObjectBase::writeArrayItem( const String& rName, const sal_uInt8* pnData, sal_Size nSize, sal_Unicode cSep ) { - ItemGuard aItem( *mxOut, pcName ); + ItemGuard aItem( *mxOut, rName ); mxOut->writeArray( pnData, nSize, cSep ); } -void OutputObjectBase::writeBoolItem( const sal_Char* pcName, bool bData ) +void OutputObjectBase::writeBoolItem( const String& rName, bool bData ) { - ItemGuard aItem( *mxOut, pcName ); + ItemGuard aItem( *mxOut, rName ); mxOut->writeBool( bData ); } -double OutputObjectBase::writeRkItem( const sal_Char* pcName, sal_Int32 nRk ) +double OutputObjectBase::writeRkItem( const String& rName, sal_Int32 nRk ) { MultiItemsGuard aMultiGuard( out() ); - writeHexItem( pcName, static_cast< sal_uInt32 >( nRk ), "RK-FLAGS" ); + writeHexItem( rName, static_cast< sal_uInt32 >( nRk ), "RK-FLAGS" ); double fValue = ::oox::xls::BiffHelper::calcDoubleFromRk( nRk ); writeDecItem( "decoded", fValue ); return fValue; } -void OutputObjectBase::writeColorItem( const sal_Char* pcName, sal_Int32 nColor ) +void OutputObjectBase::writeColorABGRItem( const String& rName, sal_Int32 nColor ) { - ItemGuard aItem( *mxOut, pcName ); - writeHexItem( pcName, nColor ); - mxOut->writeColor( nColor ); + ItemGuard aItem( *mxOut, rName ); + writeHexItem( rName, nColor ); + mxOut->writeColorABGR( nColor ); } -void OutputObjectBase::writeDateTimeItem( const sal_Char* pcName, const DateTime& rDateTime ) +void OutputObjectBase::writeDateTimeItem( const String& rName, const DateTime& rDateTime ) { - ItemGuard aItem( *mxOut, pcName ); + ItemGuard aItem( *mxOut, rName ); mxOut->writeDateTime( rDateTime ); } -void OutputObjectBase::writeGuidItem( const sal_Char* pcName, const OUString& rGuid ) +void OutputObjectBase::writeGuidItem( const String& rName, const OUString& rGuid ) { - ItemGuard aItem( *mxOut, pcName ); + ItemGuard aItem( *mxOut, rName ); mxOut->writeString( rGuid ); aItem.cont(); mxOut->writeString( cfg().getStringOption( rGuid, OUString() ) ); } -void OutputObjectBase::writeColIndexItem( const sal_Char* pcName, sal_Int32 nCol ) +void OutputObjectBase::writeColIndexItem( const String& rName, sal_Int32 nCol ) { Output& rOut = out(); - ItemGuard aItem( rOut, pcName ); + ItemGuard aItem( rOut, rName ); rOut.writeDec( nCol ); aItem.cont(); rOut.writeColIndex( nCol ); } -void OutputObjectBase::writeRowIndexItem( const sal_Char* pcName, sal_Int32 nRow ) +void OutputObjectBase::writeRowIndexItem( const String& rName, sal_Int32 nRow ) { Output& rOut = out(); - ItemGuard aItem( rOut, pcName ); + ItemGuard aItem( rOut, rName ); rOut.writeDec( nRow ); aItem.cont(); rOut.writeRowIndex( nRow ); } -void OutputObjectBase::writeColRangeItem( const sal_Char* pcName, sal_Int32 nCol1, sal_Int32 nCol2 ) +void OutputObjectBase::writeColRangeItem( const String& rName, sal_Int32 nCol1, sal_Int32 nCol2 ) { Output& rOut = out(); - ItemGuard aItem( rOut, pcName ); + ItemGuard aItem( rOut, rName ); rOut.writeColRowRange( nCol1, nCol2 ); aItem.cont(); rOut.writeColRange( nCol1, nCol2 ); } -void OutputObjectBase::writeRowRangeItem( const sal_Char* pcName, sal_Int32 nRow1, sal_Int32 nRow2 ) +void OutputObjectBase::writeRowRangeItem( const String& rName, sal_Int32 nRow1, sal_Int32 nRow2 ) { Output& rOut = out(); - ItemGuard aItem( rOut, pcName ); + ItemGuard aItem( rOut, rName ); rOut.writeColRowRange( nRow1, nRow2 ); aItem.cont(); rOut.writeRowRange( nRow1, nRow2 ); } -void OutputObjectBase::writeAddressItem( const sal_Char* pcName, const Address& rPos ) +void OutputObjectBase::writeAddressItem( const String& rName, const Address& rPos ) { - ItemGuard aItem( out(), pcName ); + ItemGuard aItem( out(), rName ); StringHelper::appendAddress( out().getLine(), rPos ); } -void OutputObjectBase::writeRangeItem( const sal_Char* pcName, const Range& rRange ) +void OutputObjectBase::writeRangeItem( const String& rName, const Range& rRange ) { - ItemGuard aItem( out(), pcName ); + ItemGuard aItem( out(), rName ); StringHelper::appendRange( out().getLine(), rRange ); } -void OutputObjectBase::writeRangeListItem( const sal_Char* pcName, const RangeList& rRanges ) +void OutputObjectBase::writeRangeListItem( const String& rName, const RangeList& rRanges ) { MultiItemsGuard aMultiGuard( out() ); - writeEmptyItem( pcName ); + writeEmptyItem( rName ); writeDecItem( "count", static_cast< sal_uInt16 >( rRanges.size() ) ); ItemGuard aItem( out(), "ranges" ); StringHelper::appendRangeList( out().getLine(), rRanges ); } -void OutputObjectBase::writeTokenAddressItem( const sal_Char* pcName, const TokenAddress& rPos, bool bNameMode ) +void OutputObjectBase::writeTokenAddressItem( const String& rName, const TokenAddress& rPos, bool bNameMode ) { - ItemGuard aItem( out(), pcName ); + ItemGuard aItem( out(), rName ); StringHelper::appendAddress( out().getLine(), rPos, bNameMode ); } -void OutputObjectBase::writeTokenAddress3dItem( const sal_Char* pcName, const OUString& rRef, const TokenAddress& rPos, bool bNameMode ) +void OutputObjectBase::writeTokenAddress3dItem( const String& rName, const OUString& rRef, const TokenAddress& rPos, bool bNameMode ) { - ItemGuard aItem( out(), pcName ); + ItemGuard aItem( out(), rName ); out().writeString( rRef ); StringHelper::appendAddress( out().getLine(), rPos, bNameMode ); } -void OutputObjectBase::writeTokenRangeItem( const sal_Char* pcName, const TokenRange& rRange, bool bNameMode ) +void OutputObjectBase::writeTokenRangeItem( const String& rName, const TokenRange& rRange, bool bNameMode ) { - ItemGuard aItem( out(), pcName ); + ItemGuard aItem( out(), rName ); StringHelper::appendRange( out().getLine(), rRange, bNameMode ); } -void OutputObjectBase::writeTokenRange3dItem( const sal_Char* pcName, const OUString& rRef, const TokenRange& rRange, bool bNameMode ) +void OutputObjectBase::writeTokenRange3dItem( const String& rName, const OUString& rRef, const TokenRange& rRange, bool bNameMode ) { - ItemGuard aItem( out(), pcName ); + ItemGuard aItem( out(), rName ); out().writeString( rRef ); StringHelper::appendRange( out().getLine(), rRange, bNameMode ); } @@ -2415,22 +2437,22 @@ InputObjectBase::~InputObjectBase() { } -void InputObjectBase::construct( const ObjectBase& rParent, const ::rtl::OUString& rOutFileName, InputRef xIn ) +void InputObjectBase::construct( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName ) { - OutputObjectBase::construct( rParent, rOutFileName ); - mxIn = xIn; + OutputObjectBase::construct( rParent, rSysFileName ); + mxStrm = rxStrm; } -void InputObjectBase::construct( const ObjectBase& rParent, OutputRef xOut, InputRef xIn ) +void InputObjectBase::construct( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OutputRef& rxOut ) { - OutputObjectBase::construct( rParent, xOut ); - mxIn = xIn; + OutputObjectBase::construct( rParent, rxOut ); + mxStrm = rxStrm; } -void InputObjectBase::construct( const OutputObjectBase& rParent, InputRef xIn ) +void InputObjectBase::construct( const OutputObjectBase& rParent, const BinaryInputStreamRef& rxStrm ) { OutputObjectBase::construct( rParent ); - mxIn = xIn; + mxStrm = rxStrm; } void InputObjectBase::construct( const InputObjectBase& rParent ) @@ -2440,31 +2462,21 @@ void InputObjectBase::construct( const InputObjectBase& rParent ) bool InputObjectBase::implIsValid() const { - return isValid( mxIn ) && OutputObjectBase::implIsValid(); -} - -InputRef InputObjectBase::implReconstructInput() -{ - return mxIn; -} - -void InputObjectBase::reconstructInput() -{ - mxIn = implReconstructInput(); + return mxStrm.get() && OutputObjectBase::implIsValid(); } -void InputObjectBase::skipBlock( sal_Int32 nBytes, bool bShowSize ) +void InputObjectBase::skipBlock( sal_Int64 nBytes, bool bShowSize ) { - sal_Int64 nEndPos = ::std::min< sal_Int64 >( mxIn->tell() + nBytes, mxIn->getSize() ); - if( mxIn->tell() < nEndPos ) + sal_Int64 nEndPos = ::std::min< sal_Int64 >( mxStrm->tell() + nBytes, mxStrm->getLength() ); + if( mxStrm->tell() < nEndPos ) { if( bShowSize ) - writeDecItem( "skipped-data-size", static_cast< sal_uInt64 >( nEndPos - mxIn->tell() ) ); - mxIn->seek( nEndPos ); + writeDecItem( "skipped-data-size", static_cast< sal_uInt64 >( nEndPos - mxStrm->tell() ) ); + mxStrm->seek( nEndPos ); } } -void InputObjectBase::dumpRawBinary( sal_Int32 nBytes, bool bShowOffset, bool bStream ) +void InputObjectBase::dumpRawBinary( sal_Int64 nBytes, bool bShowOffset, bool bStream ) { Output& rOut = out(); TableGuard aTabGuard( rOut, @@ -2473,13 +2485,13 @@ void InputObjectBase::dumpRawBinary( sal_Int32 nBytes, bool bShowOffset, bool bS 3 * OOX_DUMP_BYTESPERLINE / 2 + 1, OOX_DUMP_BYTESPERLINE / 2 + 1 ); - sal_Int32 nMaxShowSize = cfg().getIntOption< sal_Int32 >( - bStream ? "max-binary-stream-size" : "max-binary-data-size", SAL_MAX_INT32 ); + sal_Int64 nMaxShowSize = cfg().getIntOption< sal_Int64 >( + bStream ? "max-binary-stream-size" : "max-binary-data-size", SAL_MAX_INT64 ); - bool bSeekable = mxIn->getSize() >= 0; - sal_Int64 nEndPos = bSeekable ? ::std::min< sal_Int64 >( mxIn->tell() + nBytes, mxIn->getSize() ) : 0; - sal_Int64 nDumpEnd = bSeekable ? ::std::min< sal_Int64 >( mxIn->tell() + nMaxShowSize, nEndPos ) : nMaxShowSize; - sal_Int64 nPos = bSeekable ? mxIn->tell() : 0; + bool bSeekable = mxStrm->getLength() >= 0; + sal_Int64 nEndPos = bSeekable ? ::std::min< sal_Int64 >( mxStrm->tell() + nBytes, mxStrm->getLength() ) : 0; + sal_Int64 nDumpEnd = bSeekable ? ::std::min< sal_Int64 >( mxStrm->tell() + nMaxShowSize, nEndPos ) : nMaxShowSize; + sal_Int64 nPos = bSeekable ? mxStrm->tell() : 0; bool bLoop = true; while( bLoop && (nPos < nDumpEnd) ) @@ -2488,8 +2500,8 @@ void InputObjectBase::dumpRawBinary( sal_Int32 nBytes, bool bShowOffset, bool bS rOut.tab(); sal_uInt8 pnLineData[ OOX_DUMP_BYTESPERLINE ]; - sal_Int32 nLineSize = bSeekable ? ::std::min( static_cast< sal_Int32 >( nDumpEnd - mxIn->tell() ), OOX_DUMP_BYTESPERLINE ) : OOX_DUMP_BYTESPERLINE; - sal_Int32 nReadSize = mxIn->read( pnLineData, nLineSize ); + sal_Int32 nLineSize = bSeekable ? ::std::min( static_cast< sal_Int32 >( nDumpEnd - mxStrm->tell() ), OOX_DUMP_BYTESPERLINE ) : OOX_DUMP_BYTESPERLINE; + sal_Int32 nReadSize = mxStrm->readMemory( pnLineData, nLineSize ); bLoop = nReadSize == nLineSize; nPos += nReadSize; @@ -2505,7 +2517,7 @@ void InputObjectBase::dumpRawBinary( sal_Int32 nBytes, bool bShowOffset, bool bS } aTabGuard.tab( 3 ); - for( pnByte = pnLineData, pnEnd = pnLineData + nLineSize; pnByte != pnEnd; ++pnByte ) + for( pnByte = pnLineData, pnEnd = pnLineData + nReadSize; pnByte != pnEnd; ++pnByte ) { if( (pnByte - pnLineData) == (OOX_DUMP_BYTESPERLINE / 2) ) rOut.tab(); rOut.writeChar( static_cast< sal_Unicode >( (*pnByte < 0x20) ? '.' : *pnByte ) ); @@ -2516,108 +2528,221 @@ void InputObjectBase::dumpRawBinary( sal_Int32 nBytes, bool bShowOffset, bool bS // skip undumped data if( bSeekable ) - skipBlock( static_cast< sal_Int32 >( nEndPos - mxIn->tell() ) ); + skipBlock( nEndPos - mxStrm->tell() ); } -void InputObjectBase::dumpBinary( const sal_Char* pcName, sal_Int32 nBytes, bool bShowOffset ) +void InputObjectBase::dumpBinary( const String& rName, sal_Int64 nBytes, bool bShowOffset ) { { MultiItemsGuard aMultiGuard( out() ); - writeEmptyItem( pcName ); + writeEmptyItem( rName ); writeDecItem( "size", nBytes ); } IndentGuard aIndGuard( out() ); dumpRawBinary( nBytes, bShowOffset ); } -void InputObjectBase::dumpArray( const sal_Char* pcName, sal_Int32 nBytes, sal_Unicode cSep ) +void InputObjectBase::dumpRemaining( sal_Int64 nBytes ) { - sal_Int32 nDumpSize = getLimitedValue< sal_Int32, sal_Int64 >( mxIn->getSize() - mxIn->tell(), 0, nBytes ); + if( nBytes > 0 ) + { + if( cfg().getBoolOption( "show-trailing-unknown", true ) ) + dumpBinary( "remaining-data", nBytes, false ); + else + skipBlock( nBytes ); + } +} + +void InputObjectBase::dumpRemainingTo( sal_Int64 nPos ) +{ + if( mxStrm->isEof() ) + writeInfoItem( "stream-state", OOX_DUMP_ERR_STREAM ); + else + dumpRemaining( nPos - mxStrm->tell() ); + mxStrm->seek( nPos ); +} + +void InputObjectBase::dumpRemainingStream() +{ + dumpRemainingTo( mxStrm->getLength() ); +} + +void InputObjectBase::dumpArray( const String& rName, sal_Int32 nBytes, sal_Unicode cSep ) +{ + sal_Int32 nDumpSize = getLimitedValue< sal_Int32, sal_Int64 >( mxStrm->getLength() - mxStrm->tell(), 0, nBytes ); if( nDumpSize > OOX_DUMP_MAXARRAY ) { - dumpBinary( pcName, nBytes, false ); + dumpBinary( rName, nBytes, false ); } else if( nDumpSize > 1 ) { sal_uInt8 pnData[ OOX_DUMP_MAXARRAY ]; - mxIn->read( pnData, nDumpSize ); - writeArrayItem( pcName, pnData, nDumpSize, cSep ); + mxStrm->readMemory( pnData, nDumpSize ); + writeArrayItem( rName, pnData, nDumpSize, cSep ); } else if( nDumpSize == 1 ) - dumpHex< sal_uInt8 >( pcName ); + dumpHex< sal_uInt8 >( rName ); } -void InputObjectBase::dumpRemaining( sal_Int32 nBytes ) +sal_Unicode InputObjectBase::dumpChar( const String& rName, rtl_TextEncoding eTextEnc ) { - if( nBytes > 0 ) - { - if( cfg().getBoolOption( "show-trailing-unknown", true ) ) - dumpBinary( "remaining-data", nBytes, false ); - else - skipBlock( nBytes ); - } + sal_uInt8 nChar; + *mxStrm >> nChar; + OUString aChar = OStringToOUString( OString( static_cast< sal_Char >( nChar ) ), eTextEnc ); + sal_Unicode cChar = (aChar.getLength() > 0) ? aChar[ 0 ] : 0; + writeCharItem( rName( "char" ), cChar ); + return cChar; } -OUString InputObjectBase::dumpCharArray( const sal_Char* pcName, sal_Int32 nSize, rtl_TextEncoding eTextEnc ) +sal_Unicode InputObjectBase::dumpUnicode( const String& rName ) { - sal_Int32 nDumpSize = getLimitedValue< sal_Int32, sal_Int64 >( mxIn->getSize() - mxIn->tell(), 0, nSize ); + sal_uInt16 nChar; + *mxStrm >> nChar; + sal_Unicode cChar = static_cast< sal_Unicode >( nChar ); + writeCharItem( rName( "char" ), cChar ); + return cChar; +} + +OUString InputObjectBase::dumpCharArray( const String& rName, sal_Int32 nLen, rtl_TextEncoding eTextEnc ) +{ + sal_Int32 nDumpSize = getLimitedValue< sal_Int32, sal_Int64 >( mxStrm->getLength() - mxStrm->tell(), 0, nLen ); OUString aString; if( nDumpSize > 0 ) { - ::std::vector< sal_Char > aBuffer( static_cast< sal_Size >( nSize ) + 1 ); - sal_Int32 nCharsRead = mxIn->read( &aBuffer.front(), nSize ); + ::std::vector< sal_Char > aBuffer( static_cast< sal_Size >( nLen ) + 1 ); + sal_Int32 nCharsRead = mxStrm->readMemory( &aBuffer.front(), nLen ); aBuffer[ nCharsRead ] = 0; aString = OStringToOUString( OString( &aBuffer.front() ), eTextEnc ); } - writeStringItem( pcName, aString ); + writeStringItem( rName( "text" ), aString ); return aString; } -OUString InputObjectBase::dumpUnicodeArray( const sal_Char* pcName, sal_Int32 nSize ) +OUString InputObjectBase::dumpUnicodeArray( const String& rName, sal_Int32 nLen ) { OUStringBuffer aBuffer; - for( sal_Int32 nIndex = 0; mxIn->isValidPos() && (nIndex < nSize); ++nIndex ) - aBuffer.append( static_cast< sal_Unicode >( mxIn->readValue< sal_uInt16 >() ) ); + for( sal_Int32 nIndex = 0; !mxStrm->isEof() && (nIndex < nLen); ++nIndex ) + aBuffer.append( static_cast< sal_Unicode >( mxStrm->readuInt16() ) ); OUString aString = aBuffer.makeStringAndClear(); - writeStringItem( pcName, aString ); + writeStringItem( rName( "text" ), aString ); return aString; } -double InputObjectBase::dumpRk( const sal_Char* pcName ) +OUString InputObjectBase::dumpNullCharArray( const String& rName, rtl_TextEncoding eTextEnc ) { - sal_Int32 nRk; - *mxIn >> nRk; - return writeRkItem( pcName ? pcName : "rk-value", nRk ); + OStringBuffer aBuffer; + sal_uInt8 nChar; + for( *mxStrm >> nChar; !mxStrm->isEof() && (nChar > 0); *mxStrm >> nChar ) + aBuffer.append( static_cast< sal_Char >( nChar ) ); + OUString aString = OStringToOUString( aBuffer.makeStringAndClear(), eTextEnc ); + writeStringItem( rName( "text" ), aString ); + return aString; } -OUString InputObjectBase::dumpGuid( const sal_Char* pcName ) +OUString InputObjectBase::dumpNullUnicodeArray( const String& rName ) +{ + OUStringBuffer aBuffer; + sal_uInt16 nChar; + for( *mxStrm >> nChar; !mxStrm->isEof() && (nChar > 0); *mxStrm >> nChar ) + aBuffer.append( static_cast< sal_Unicode >( nChar ) ); + OUString aString = aBuffer.makeStringAndClear(); + writeStringItem( rName( "text" ), aString ); + return aString; +} + +double InputObjectBase::dumpRk( const String& rName ) +{ + sal_Int32 nRk; + *mxStrm >> nRk; + return writeRkItem( rName( "rk-value" ), nRk ); +} + +sal_Int32 InputObjectBase::dumpColorABGR( const String& rName ) +{ + sal_Int32 nColor; + *mxStrm >> nColor; + writeColorABGRItem( rName( "color" ), nColor ); + return nColor; +} + +DateTime InputObjectBase::dumpFileTime( const String& rName ) +{ + DateTime aDateTime; + + ItemGuard aItem( out(), rName( "file-time" ) ); + sal_Int64 nFileTime = dumpDec< sal_Int64 >( EMPTY_STRING ); + // file time is in 10^-7 seconds (100 nanoseconds), convert to 1/100 seconds + nFileTime /= 100000; + // entire days + sal_Int64 nDays = nFileTime / sal_Int64( 360000 * 24 ); + // number of entire years + sal_Int64 nYears = (nDays - (nDays / (4 * 365)) + (nDays / (100 * 365)) - (nDays / (400 * 365))) / 365; + // remaining days in the year + sal_Int64 nDaysInYear = nDays - (nYears * 365 + nYears / 4 - nYears / 100 + nYears / 400); + // the year (file dates start from 1601-01-01) + aDateTime.Year = static_cast< sal_uInt16 >( 1601 + nYears ); + // leap year? + bool bLeap = ((aDateTime.Year % 4 == 0) && (aDateTime.Year % 100 != 0)) || (aDateTime.Year % 400 == 0); + // static arrays with number of days in month + static const sal_Int64 spnDaysInMonth[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; + static const sal_Int64 spnDaysInMonthL[] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; + const sal_Int64* pnDaysInMonth = bLeap ? spnDaysInMonthL : spnDaysInMonth; + // the month + aDateTime.Month = 1; + while( nDaysInYear >= *pnDaysInMonth ) + { + nDaysInYear -= *pnDaysInMonth++; + ++aDateTime.Month; + } + // the day + aDateTime.Day = static_cast< sal_uInt16 >( nDaysInYear + 1 ); + // number of 1/100 seconds in the day + sal_Int64 nTimeInDay = nFileTime % sal_Int64( 360000 * 24 ); + // 1/100 seconds + aDateTime.HundredthSeconds = static_cast< sal_uInt16 >( nTimeInDay % 100 ); + nTimeInDay /= 100; + // seconds + aDateTime.Seconds = static_cast< sal_uInt16 >( nTimeInDay % 60 ); + nTimeInDay /= 60; + // minutes + aDateTime.Minutes = static_cast< sal_uInt16 >( nTimeInDay % 60 ); + nTimeInDay /= 60; + // hours + aDateTime.Hours = static_cast< sal_uInt16 >( nTimeInDay ); + + writeDateTimeItem( EMPTY_STRING, aDateTime ); + return aDateTime; +} + +OUString InputObjectBase::dumpGuid( const String& rName ) { OUStringBuffer aBuffer; sal_uInt32 nData32; sal_uInt16 nData16; sal_uInt8 nData8; - *mxIn >> nData32; + *mxStrm >> nData32; StringHelper::appendHex( aBuffer, nData32, false ); aBuffer.append( sal_Unicode( '-' ) ); - *mxIn >> nData16; + *mxStrm >> nData16; StringHelper::appendHex( aBuffer, nData16, false ); aBuffer.append( sal_Unicode( '-' ) ); - *mxIn >> nData16; + *mxStrm >> nData16; StringHelper::appendHex( aBuffer, nData16, false ); aBuffer.append( sal_Unicode( '-' ) ); - *mxIn >> nData8; + *mxStrm >> nData8; StringHelper::appendHex( aBuffer, nData8, false ); - *mxIn >> nData8; + *mxStrm >> nData8; StringHelper::appendHex( aBuffer, nData8, false ); aBuffer.append( sal_Unicode( '-' ) ); for( int nIndex = 0; nIndex < 6; ++nIndex ) { - *mxIn >> nData8; + *mxStrm >> nData8; StringHelper::appendHex( aBuffer, nData8, false ); } + StringHelper::enclose( aBuffer, '{', '}' ); OUString aGuid = aBuffer.makeStringAndClear(); - writeGuidItem( pcName ? pcName : "guid", aGuid ); + writeGuidItem( rName( "guid" ), aGuid ); return aGuid; } @@ -2641,70 +2766,100 @@ void InputObjectBase::dumpItem( const ItemFormat& rItemFmt ) } // ============================================================================ +// ============================================================================ -InputStreamObject::InputStreamObject( const ObjectBase& rParent, const OUString& rOutFileName, BinaryInputStreamRef xStrm ) +BinaryStreamObject::BinaryStreamObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName ) { - construct( rParent, rOutFileName, xStrm ); + InputObjectBase::construct( rParent, rxStrm, rSysFileName ); } -InputStreamObject::~InputStreamObject() +BinaryStreamObject::BinaryStreamObject( const OutputObjectBase& rParent, const BinaryInputStreamRef& rxStrm ) { + InputObjectBase::construct( rParent, rxStrm ); } -void InputStreamObject::construct( const ObjectBase& rParent, const OUString& rOutFileName, BinaryInputStreamRef xStrm ) +void BinaryStreamObject::dumpBinaryStream( bool bShowOffset ) { - mxStrm = xStrm; - if( mxStrm.get() ) - InputObjectBase::construct( rParent, rOutFileName, InputRef( new BinaryInput( *mxStrm ) ) ); + in().seek( 0 ); + dumpRawBinary( in().getLength(), bShowOffset, true ); + out().emptyLine(); } -sal_Int64 InputStreamObject::getStreamSize() const +void BinaryStreamObject::implDump() { - return mxStrm.get() ? mxStrm->getLength() : -1; + dumpBinaryStream(); } -void InputStreamObject::dumpBinaryStream( bool bShowOffset ) +// ============================================================================ + +namespace { + +bool lclIsEof( BinaryInputStream& rStrm ) { - in().seek( 0 ); - dumpRawBinary( getLimitedValue< sal_Int32, sal_Int64 >( in().getSize(), 0, SAL_MAX_INT32 ), bShowOffset, true ); - out().emptyLine(); + return rStrm.isEof() || (rStrm.isSeekable() && (rStrm.tell() >= rStrm.getLength())); } -bool InputStreamObject::implIsValid() const +template< typename BufferType, typename CharType > +CharType lclAppendChar( BufferType& orBuffer, CharType cChar ) { - return mxStrm.get() && mxStrm->is() && InputObjectBase::implIsValid(); + if( (cChar == 0x0A) || (cChar == 0x0D) ) + return cChar; + orBuffer.append( cChar ); + return 0; } -void InputStreamObject::implDump() +template< typename BufferType, typename CharType, typename StreamDataType > +bool lclReadLine( BufferType& orBuffer, sal_Unicode& orcNextLineChar, BinaryInputStream& rStrm ) { - dumpBinaryStream(); + CharType cLineEndChar = (orcNextLineChar == 0) ? 0 : lclAppendChar( orBuffer, static_cast< CharType >( orcNextLineChar ) ); + orcNextLineChar = 0; + + // read chars until EOF or line end character (LF or CR) + bool bIsEof = lclIsEof( rStrm ); + while( !bIsEof && (cLineEndChar == 0) ) + { + CharType cChar = static_cast< CharType >( rStrm.readValue< StreamDataType >() ); + bIsEof = rStrm.isEof(); + cLineEndChar = bIsEof ? 0 : lclAppendChar( orBuffer, cChar ); + } + + // try to skip LF following CR, or CR following LF + if( !lclIsEof( rStrm ) && (cLineEndChar != 0) ) + { + CharType cChar = static_cast< CharType >( rStrm.readValue< StreamDataType >() ); + bool bLineEnd = ((cChar == 0x0A) || (cChar == 0x0D)) && (cChar != cLineEndChar); + if( !rStrm.isEof() && !bLineEnd ) + orcNextLineChar = static_cast< sal_Unicode >( cChar ); + } + + return (cLineEndChar != 0) || (orBuffer.getLength() > 0); } -// ============================================================================ -// ============================================================================ +} // namespace + +// ---------------------------------------------------------------------------- TextStreamObject::TextStreamObject( const ObjectBase& rParent, - const OUString& rOutFileName, BinaryInputStreamRef xStrm, rtl_TextEncoding eTextEnc ) : - InputStreamObject( rParent, rOutFileName, xStrm ), + const BinaryInputStreamRef& rxStrm, rtl_TextEncoding eTextEnc, const OUString& rSysFileName ) : meTextEnc( eTextEnc ) { + InputObjectBase::construct( rParent, rxStrm, rSysFileName ); +} + +TextStreamObject::TextStreamObject( const OutputObjectBase& rParent, + const BinaryInputStreamRef& rxStrm, rtl_TextEncoding eTextEnc ) : + meTextEnc( eTextEnc ) +{ + InputObjectBase::construct( rParent, rxStrm ); } void TextStreamObject::implDump() { - const sal_Char* pcTextEnc = rtl_getBestMimeCharsetFromTextEncoding( meTextEnc ); - OUString aEncoding = OUString::createFromAscii( pcTextEnc ? pcTextEnc : "UTF-8" ); - Reference< XTextInputStream > xTextStrm = InputOutputHelper::openTextInputStream( getStream().getXInputStream(), aEncoding ); - if( xTextStrm.is() ) try - { - sal_uInt32 nLine = 0; - while( !xTextStrm->isEOF() ) - implDumpLine( xTextStrm->readLine(), ++nLine ); - } - catch( Exception& ) - { - writeInfoItem( "stream-state", OOX_DUMP_ERR_STREAM ); - } + OUString aLine; + sal_Unicode cNextLineChar = 0; + sal_uInt32 nLine = 0; + while( readLine( aLine, cNextLineChar ) ) + implDumpLine( aLine, ++nLine ); out().emptyLine(); } @@ -2718,10 +2873,35 @@ void TextStreamObject::implDumpLine( const OUString& rLine, sal_uInt32 nLine ) rOut.newLine(); } +bool TextStreamObject::readCharLine( OUString& orLine, sal_Unicode& orcNextLineChar ) +{ + OStringBuffer aBuffer; + bool bHasData = lclReadLine< OStringBuffer, sal_Char, sal_uInt8 >( aBuffer, orcNextLineChar, in() ); + if( bHasData ) + orLine = OStringToOUString( aBuffer.makeStringAndClear(), meTextEnc ); + return bHasData; +} + +bool TextStreamObject::readUcs2Line( OUString& orLine, sal_Unicode& orcNextLineChar ) +{ + OUStringBuffer aBuffer; + bool bHasData = lclReadLine< OUStringBuffer, sal_Unicode, sal_uInt16 >( aBuffer, orcNextLineChar, in() ); + if( bHasData ) + orLine = aBuffer.makeStringAndClear(); + return bHasData; +} + +bool TextStreamObject::readLine( OUString& orLine, sal_Unicode& orcNextLineChar ) +{ + return (meTextEnc == RTL_TEXTENCODING_UCS2) ? + readUcs2Line( orLine, orcNextLineChar ) : + readCharLine( orLine, orcNextLineChar ); +} + // ============================================================================ -XmlStreamObject::XmlStreamObject( const ObjectBase& rParent, const OUString& rOutFileName, BinaryInputStreamRef xStrm ) : - TextStreamObject( rParent, rOutFileName, xStrm, RTL_TEXTENCODING_UTF8 ) +XmlStreamObject::XmlStreamObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName ) : + TextStreamObject( rParent, rxStrm, RTL_TEXTENCODING_UTF8, rSysFileName ) { } @@ -2832,60 +3012,164 @@ void XmlStreamObject::implDumpLine( const OUString& rLine, sal_uInt32 ) // ============================================================================ // ============================================================================ -RecordHeaderImplBase::~RecordHeaderImplBase() +void RecordObjectBase::construct( const ObjectBase& rParent, + const BinaryInputStreamRef& rxBaseStrm, const OUString& rSysFileName, + const BinaryInputStreamRef& rxRecStrm, const String& rRecNames, const String& rSimpleRecs ) +{ + InputObjectBase::construct( rParent, rxRecStrm, rSysFileName ); + constructRecObjBase( rxBaseStrm, rRecNames, rSimpleRecs ); +} + +void RecordObjectBase::construct( const OutputObjectBase& rParent, const BinaryInputStreamRef& rxBaseStrm, + const BinaryInputStreamRef& rxRecStrm, const String& rRecNames, const String& rSimpleRecs ) +{ + InputObjectBase::construct( rParent, rxRecStrm ); + constructRecObjBase( rxBaseStrm, rRecNames, rSimpleRecs ); +} + +bool RecordObjectBase::implIsValid() const { + return mxBaseStrm.get() && InputObjectBase::implIsValid(); } -void RecordHeaderImplBase::construct( const InputObjectBase& rParent, const RecordHeaderConfigInfo& rCfgInfo ) +void RecordObjectBase::implDump() { - InputObjectBase::construct( rParent ); - if( InputObjectBase::implIsValid() ) + NameListRef xRecNames = getRecNames(); + + typedef ::std::map< sal_Int64, ItemFormat > ItemFormatMap; + ItemFormatMap aSimpleRecs; + if( NameListBase* pSimpleRecs = maSimpleRecs.getNameList( cfg() ).get() ) + for( NameListBase::const_iterator aIt = pSimpleRecs->begin(), aEnd = pSimpleRecs->end(); aIt != aEnd; ++aIt ) + aSimpleRecs[ aIt->first ].parse( aIt->second ); + + while( implStartRecord( *mxBaseStrm, mnRecPos, mnRecId, mnRecSize ) ) { - const Config& rCfg = cfg(); - mpcTitle = rCfgInfo.mpcTitle; - mxRecNames = rCfg.getNameList( rCfgInfo.mpcRecNames ); - mbShowRecPos = rCfg.getBoolOption( rCfgInfo.mpcShowRecPos, true ); - mbShowRecSize = rCfg.getBoolOption( rCfgInfo.mpcShowRecSize, true ); - mbShowRecId = rCfg.getBoolOption( rCfgInfo.mpcShowRecId, true ); - mbShowRecName = rCfg.getBoolOption( rCfgInfo.mpcShowRecName, true ); - mbShowRecBody = rCfg.getBoolOption( rCfgInfo.mpcShowRecBody, true ); + // record header + out().emptyLine(); + writeHeader(); + implWriteExtHeader(); + IndentGuard aIndGuard( out() ); + sal_Int64 nRecPos = in().tell(); + + // record body + if( cfg().hasName( xRecNames, mnRecId ) ) + { + ItemFormatMap::const_iterator aIt = aSimpleRecs.find( mnRecId ); + if( aIt != aSimpleRecs.end() ) + dumpItem( aIt->second ); + else + implDumpRecordBody(); + } + + // remaining undumped data + else if( !in().isEof() && (in().tell() == nRecPos) ) + dumpRawBinary( mnRecSize, false ); + else + dumpRemainingTo( nRecPos + mnRecSize ); } } -bool RecordHeaderImplBase::implIsValid() const +void RecordObjectBase::implWriteExtHeader() { - return isValid( mxRecNames ) && InputObjectBase::implIsValid(); } -// ============================================================================ +void RecordObjectBase::implDumpRecordBody() +{ +} + +void RecordObjectBase::constructRecObjBase( const BinaryInputStreamRef& rxBaseStrm, const String& rRecNames, const String& rSimpleRecs ) +{ + mxBaseStrm = rxBaseStrm; + maRecNames = rRecNames; + maSimpleRecs = rSimpleRecs; + mnRecPos = mnRecId = mnRecSize = 0; +} + +void RecordObjectBase::writeHeader() +{ + MultiItemsGuard aMultiGuard( out() ); + writeEmptyItem( "REC" ); + if( mxBaseStrm->isSeekable() ) + writeShortHexItem( "pos", mnRecPos, "CONV-DEC" ); + writeShortHexItem( "size", mnRecSize, "CONV-DEC" ); + ItemGuard aItem( out(), "id" ); + out().writeShortHex( mnRecId ); + addNameToItem( mnRecId, "CONV-DEC" ); + addNameToItem( mnRecId, maRecNames ); +} + // ============================================================================ -DumperBase::~DumperBase() +void SequenceRecordObjectBase::construct( + const ObjectBase& rParent, const BinaryInputStreamRef& rxBaseStrm, const ::rtl::OUString& rSysFileName, + const BinaryInputStreamRef& rxRecStrm, const String& rRecNames, const String& rSimpleRecs ) { + RecordObjectBase::construct( rParent, rxBaseStrm, rSysFileName, rxRecStrm, rRecNames, rSimpleRecs ); } -bool DumperBase::isImportEnabled() const +void SequenceRecordObjectBase::construct( const OutputObjectBase& rParent, + const BinaryInputStreamRef& rxBaseStrm, const BinaryInputStreamRef& rxRecStrm, + const String& rRecNames, const String& rSimpleRecs ) { - return !isValid() || cfg().isImportEnabled(); + RecordObjectBase::construct( rParent, rxBaseStrm, rxRecStrm, rRecNames, rSimpleRecs ); } -StorageRef DumperBase::getRootStorage() const +void SequenceRecordObjectBase::construct( const ObjectBase& rParent, + const BinaryInputStreamRef& rxBaseStrm, const ::rtl::OUString& rSysFileName, + const String& rRecNames, const String& rSimpleRecs ) { - return getFilter().getStorage(); + BinaryInputStreamRef xRecStrm( new SequenceInputStream( *mxRecData ) ); + RecordObjectBase::construct( rParent, rxBaseStrm, rSysFileName, xRecStrm, rRecNames, rSimpleRecs ); } -BinaryInputStreamRef DumperBase::getRootStream() const +void SequenceRecordObjectBase::construct( const OutputObjectBase& rParent, + const BinaryInputStreamRef& rxBaseStrm, const String& rRecNames, const String& rSimpleRecs ) { - BinaryInputStreamRef xStrm; - if( StorageBase* pStrg = getRootStorage().get() ) - xStrm.reset( new BinaryInputStream( pStrg->openInputStream( OUString() ), false ) ); - return xStrm; + BinaryInputStreamRef xRecStrm( new SequenceInputStream( *mxRecData ) ); + RecordObjectBase::construct( rParent, rxBaseStrm, xRecStrm, rRecNames, rSimpleRecs ); +} + +bool SequenceRecordObjectBase::implStartRecord( BinaryInputStream& rBaseStrm, sal_Int64& ornRecPos, sal_Int64& ornRecId, sal_Int64& ornRecSize ) +{ + bool bValid = true; + if( rBaseStrm.isSeekable() ) + { + ornRecPos = rBaseStrm.tell(); + // do not try to overread seekable streams, may cause assertions + bValid = ornRecPos < rBaseStrm.getLength(); + } + + // read the record header + if( bValid ) + bValid = implReadRecordHeader( rBaseStrm, ornRecId, ornRecSize ) && !rBaseStrm.isEof() && (0 <= ornRecSize) && (ornRecSize <= 0x00100000); + + // read record contents into data sequence + if( bValid ) + { + sal_Int32 nRecSize = static_cast< sal_Int32 >( ornRecSize ); + mxRecData->realloc( nRecSize ); + bValid = (nRecSize == 0) || (rBaseStrm.readData( *mxRecData, nRecSize ) == nRecSize); + in().seekToStart(); + } + return bValid; +} + +// ============================================================================ +// ============================================================================ + +DumperBase::~DumperBase() +{ +} + +bool DumperBase::isImportEnabled() const +{ + return !isValid() || cfg().isImportEnabled(); } -void DumperBase::construct( const FilterBase& rFilter, ConfigRef xConfig ) +void DumperBase::construct( const ConfigRef& rxConfig ) { - if( rFilter.isImportFilter() && isValid( xConfig ) && xConfig->isDumperEnabled() ) - ObjectBase::construct( rFilter, xConfig ); + if( isValid( rxConfig ) && rxConfig->isDumperEnabled() ) + ObjectBase::construct( rxConfig ); } // ============================================================================ diff --git a/oox/source/dump/dumperbase.ini b/oox/source/dump/dumperbase.ini new file mode 100644 index 000000000000..03ecb9a6b514 --- /dev/null +++ b/oox/source/dump/dumperbase.ini @@ -0,0 +1,349 @@ + +# dumper settings ============================================================ +# +# Basic concepts +# +# - Character encoding of dumper ini files is UTF-8. +# - Whitespace characters are generally stripped, e.g. at start and end of +# lines, before/after equal signs, commas, etc. +# - Comments start with the hash (#) or semicolon (;) character. Leading +# whitespace characters are ignored. +# +# ---------------------------------------------------------------------------- + +# Enable entire dumper (default=off). This option does not affect the option +# 'enable-import'. +# 0=off, 1=on +enable-dumper=1 + +# Enable import after dumping (default=on). Disabling this option allows +# to dump a file without loading it. This option is independent from the +# 'enable-dumper' option. +# 0=off, 1=on +enable-import=1 + +# Maximum size of binary stream dumps (default=infinite). +max-binary-stream-size=65536 + +# Maximum size of binary data blocks in content dumps (default=infinite). +max-binary-data-size=128 + +# Shows unknown trailing data as binary dump (default=on). +# 0=off, 1=on +show-trailing-unknown=1 + +# name lists ================================================================= +# +# Syntax descriptions +# +# - Optional items are enclosed in brackets []. +# - Optional items that may be repeated are marked with an ellipsis (...). +# - Items in a set to choose from are separated by vertical lines (|). +# - <LISTNAME> denotes the name of a list. List names may consist of any non- +# whitespace characters. +# - <value>, <firstvalue>, <bitfield>, <bitmask> etc. denote integer values. +# Decimal and hexadecimal notation is supported, using C/C++ notation. +# - <bool> denotes a boolean value. Possible values are 0|1|false|true. +# - <constname> denotes a literal name for a constant or bit. +# +# ---------------------------------------------------------------------------- +# +# constlist +# +# Defines names for a list of specific values. +# +# Syntax: +# +# constlist = <LISTNAME> +# default = <constname> +# include = <LISTNAME>[,<LISTNAME>...] +# exclude = <value>[,<value>...] +# quote-names = <bool> +# <value> = <constname> +# end +# +# - default (optional): Declares <constname> as a default name for values not +# specified in the name list. <constname> may be the empty string. If not +# set, the literal string '?err:no-name' (unquoted) is the default name. +# - include (optional): Includes the specified name list(s) into the own list. +# - exclude (optional): Removes values from the name lists, useful e.g. after +# a name list has been included. +# - quote-names (optional): Specifies whether to return the contained names +# enclosed in single quote (') characters. Default is false. +# +# The order of the declarations is important, later declarations may overwrite +# names generated from earlier declarations. +# +# Example: +# +# constlist = EXAMPLE-CONSTLIST +# 1 = my-value +# include = OTHER-LIST +# exclude = 2,3 +# 0x0004 = other-value +# end +# +# - Defines the name 'my-value' for the constant 1. +# - Includes 'OTHER-LIST' which may overwrite the name of the constant 1. +# - Excludes the names of constants 2 and 3, which may have been included from +# the name list 'OTHER-LIST'. +# - Defines the name 'other-value' for the constant 4, which may overwrite the +# name of this constant included from the name list 'OTHER-LIST'. +# +# ---------------------------------------------------------------------------- +# +# multilist +# +# Defines names for contiguous ranges of values. +# +# Syntax: +# +# multilist = <LISTNAME> +# default = <constname> +# include = <LISTNAME>[,<LISTNAME>...] +# exclude = <value>[,<value>...] +# ignore-empty = <bool> +# <firstvalue> = <constname>[,<constname>...] +# end +# +# - default (optional): See constlist above. +# - include (optional): See constlist above. +# - exclude (optional): See constlist above. +# - ignore-empty (optional): Specifies whether to skip empty names in a list. +# - True = skips an empty entry, the default name will be generated. +# - False = creates an empty string for the entry. +# Default is true (skip empty entries). +# +# Examples: +# +# multilist = EXAMPLE-MULTILIST +# 0 = value0,value1,,value3 +# 8 = value8 +# end +# +# - Defines the names 'value0' for the constant 0, 'value1' for the constant +# 1, 'value3' for the constant 3, and 'value8' for the constant 8. +# +# multilist = EXAMPLE-MULTILIST-2 +# include = EXAMPLE-MULTILIST +# ignore-empty = false +# default = other +# end +# +# - Same as example above (includes EXAMPLE-MULTILIST), but defines the empty +# string for the constant 2. Other constants (less than 0 or greater than 3 +# and not equal to 8) get the default name 'other'. +# +# ---------------------------------------------------------------------------- +# +# shortlist +# +# Defines names for a contiguous range of values. The entire list definition +# is given in a single text line. +# +# Syntax: +# +# shortlist = <LISTNAME>,<firstvalue>,<constname>[,<constname>...] +# +# Uses default settings of the multi-list (i.e. skips empty entries). +# +# ---------------------------------------------------------------------------- +# +# flagslist +# +# Defines names for single bits in a bit field. +# +# Syntax: +# +# flagslist = <LISTNAME> +# include = <LISTNAME>[,<LISTNAME>...] +# exclude = <bitfield>[,<bitfield>...] +# ignore = <bitfield> +# <bitmask> = <constname> | !<constname> | !<constname0>!<constname1> +# end +# +# - include (optional): See constlist above. +# - exclude (optional): See constlist above. +# - ignore (optional): Specifies bits to be ignored. Bits without an explicit +# name and not set in this declaration will be shown as unknown. Default is +# to not ignore a bit. +# - <bitmask>: The bit to be named. Must be a value with a single bit set. +# - <constname>: sets a name for the bit that will be shown if it is set. +# - !<constname>: sets a name for the bit that will be shown if it is cleared. +# - !<constname0>!<constname1>: sets a name for the cleared bit (constname0), +# and for the set bit (constname1). +# +# ---------------------------------------------------------------------------- +# +# combilist +# +# Defines names for single bits and for embedded values in a bit field. This +# is an extension of the flagslist described above. +# +# Syntax: +# +# combilist = <LISTNAME> +# include = <LISTNAME>[,<LISTNAME>...] +# exclude = <bitmask>[,<bitmask>...] +# ignore = <bitfield> +# <bitmask> = <constname> | !<constname> | !<constname0>!<constname1> +# <bitfield> = <datatype>,<dataformat>,<bitfieldname>[,<LISTNAME>] +# end +# +# - include (optional): See constlist above. +# - exclude (optional): See constlist above. +# - ignore (optional): See flagslist above. +# - <bitmask>: See flagslist above. +# - <bitfield>: The mask of the embedded bitfield. Must be a value with +# exactly one sequence of at least 2 consecutive bits. +# - <datatype>: [u]int8 | [u]int16 | [u]int32 | [u]int64 | float | double +# - <dataformat>: dec | hex | shorthex | bin | fix | bool +# - <bitfieldname>: The name of the embedded bitfield. +# - <LISTAME>: Optional name list with names for the values of the embedded +# bitfield. +# +# ---------------------------------------------------------------------------- +# +# unitconverter +# +# Converts values and appends a unit name. +# +# Syntax: +# +# unitconverter = <LISTNAME>,[/]<factor>[,<unitname>] +# +# ---------------------------------------------------------------------------- + +unitconverter=CONV-DEC,1 +unitconverter=CONV-PERCENT,1,% +unitconverter=CONV-DEG,1,° +unitconverter=CONV-HMM-TO-CM,/1000,cm +unitconverter=CONV-INCH-TO-CM,2.54,cm +unitconverter=CONV-PT-TO-CM,/28.346457,cm +unitconverter=CONV-PT1616-TO-CM,/1857713.4,cm +unitconverter=CONV-TWIP-TO-CM,/566.92913,cm +unitconverter=CONV-TWIP-TO-PT,/20,pt + +constlist=BOOLEAN + 0=FALSE + default=TRUE +end + +combilist=RK-FLAGS + 0x00000001=div-100 + 0x00000002=integer + 0xFFFFFFFC=int32,dec,value +end + +constlist=CHARSET + 0=win-1252-latin-1 + 1=system-default + 2=symbol + 77=apple-roman + 128=win-932-japanese-shift-jis + 129=win-949-korean-hangul + 130=win-1361-korean-johab + 134=win-936-chinese-simplified-gbk + 136=win-950-chinese-traditional-big5 + 161=win-1253-greek + 162=win-1254-turkish + 163=win-1258-vietnamese + 177=win-1255-hebrew + 178=win-1256-arabic + 186=win-1257-baltic + 204=win-1251-cyrillic + 222=win-874-thai + 238=win-1250-latin-2-central-european + 255=ibm-850-latin-1 +end + +combilist=FONT-PITCHFAMILY + 0x0F=uint8,dec,pitch,FONT-PITCH + 0xF0=uint8,dec,family,FONT-FAMILY +end + +constlist=FONT-WEIGHT + 400=normal + 700=bold +end + +shortlist=FONT-PITCH,0,unknown,fixed,variable +shortlist=FONT-FAMILY,0,unknown,roman,swiss,modern,script,decorative + +constlist=CODEPAGES + 367=ascii + 437=ibm-437-us + 708=iso-8859-6 + 720=ibm-720-arabic + 737=ibm-737-greek + 775=ibm-775-baltic + 850=ibm-850-latin-1 + 852=ibm-852-latin-2-central-european + 855=ibm-855-cyrillic + 857=ibm-857-turkish + 858=ibm-858-multilingual-latin-1-with-euro + 860=ibm-860-portuguese + 861=ibm-861-icelandic + 862=ibm-862-hebrew + 863=ibm-863-canadian-french + 864=ibm-864-arabic + 865=ibm-865-nordic + 866=ibm-866-cyrillic-russian + 869=ibm-869-greek-modern + 874=win-874-thai + 932=win-932-japanese-shift-jis + 936=win-936-chinese-simplified-gbk + 949=win-949-korean-wansung + 950=win-950-chinese-traditional-big5 + 1200=utf-16 + 1250=win-1250-latin-2-central-european + 1251=win-1251-cyrillic + 1252=win-1252-latin-1 + 1253=win-1253-greek + 1254=win-1254-turkish + 1255=win-1255-hebrew + 1256=win-1256-arabic + 1257=win-1257-baltic + 1258=win-1258-vietnamese + 1361=win-1361-korean-johab + 10000=apple-roman + 10001=apple-japanese + 10002=apple-chinese-traditional + 10003=apple-korean + 10004=apple-arabic + 10005=apple-hebrew + 10006=apple-greek + 10007=apple-cyrillic + 10008=apple-chinese-simplified + 10010=apple-romanian + 10017=apple-ukrainian + 10029=apple-central-european-with-euro + 10079=apple-icelandic + 10081=apple-turkish + 10082=apple-croatian + 20127=ascii + 20866=koi8-r + 21866=koi8-u + 28591=iso-8859-1 + 28592=iso-8859-2 + 28593=iso-8859-3 + 28594=iso-8859-4 + 28595=iso-8859-5 + 28596=iso-8859-6 + 28597=iso-8859-7 + 28598=iso-8859-8 + 28599=iso-8859-9 + 28605=iso-8859-15 + 32768=apple-romanian + 32769=win-1252-latin-1 + 50220=iso-2022-jp + 50225=iso-2022-kr + 51932=euc-jp + 51936=euc-cn + 51949=euc-kr + 65000=utf-7 + 65001=utf-8 +end + +# ============================================================================ + diff --git a/oox/source/dump/dumperconfig.dat b/oox/source/dump/dumperconfig.dat index bdfd48fa833c..e69de29bb2d1 100644 --- a/oox/source/dump/dumperconfig.dat +++ b/oox/source/dump/dumperconfig.dat @@ -1,193 +0,0 @@ - -# dumper settings ============================================================ - -# Enable entire dumper (default=off). This option does not affect the option -# 'enable-import'. -# 0=off, 1=on -# enable-dumper=0 - -# Enable import after dumping (default=on). Disabling this option allows -# to dump a file without loading it. This option is independent from the -# 'enable-dumper' option. -# 0=off, 1=on -# enable-import=1 - -# Maximum size of binary stream dumps (default=infinite). -max-binary-stream-size=0x1000 - -# Maximum size of binary data blocks in content dumps (default=infinite). -max-binary-data-size=0x0200 - -# Shows unknown trailing data as binary dump (default=on). -# 0=off, 1=on -show-trailing-unknown=1 - -# name lists ================================================================= - -unitconverter=CONV-DEC,1 -unitconverter=CONV-PERCENT,1,% -unitconverter=CONV-DEG,1,° -unitconverter=CONV-INCH-TO-CM,2.54,cm -unitconverter=CONV-TWIP-TO-PT,/20,pt -unitconverter=CONV-PT-TO-CM,/28.346457,cm -unitconverter=CONV-PT1616-TO-CM,/1857713.4,cm -unitconverter=CONV-TWIP-TO-CM,/566.92913,cm - -constlist=BOOLEAN - 0=FALSE - default=TRUE -end - -combilist=RK-FLAGS - 0x00000001=div-100 - 0x00000002=integer - 0xFFFFFFFC=int32,dec,value -end - -constlist=CHARSET - 0=win-1252-latin-1 - 1=system-default - 2=symbol - 77=apple-roman - 128=win-932-japanese-shift-jis - 129=win-949-korean-hangul - 130=win-1361-korean-johab - 134=win-936-chinese-simplified-gbk - 136=win-950-chinese-traditional-big5 - 161=win-1253-greek - 162=win-1254-turkish - 163=win-1258-vietnamese - 177=win-1255-hebrew - 178=win-1256-arabic - 186=win-1257-baltic - 204=win-1251-cyrillic - 222=win-874-thai - 238=win-1250-latin-2-central-european - 255=ibm-850-latin-1 -end - -constlist=CODEPAGES - 367=ascii - 437=ibm-437-us - 708=iso-8859-6 - 720=ibm-720-arabic - 737=ibm-737-greek - 775=ibm-775-baltic - 850=ibm-850-latin-1 - 852=ibm-852-latin-2-central-european - 855=ibm-855-cyrillic - 857=ibm-857-turkish - 858=ibm-858-multilingual-latin-1-with-euro - 860=ibm-860-portuguese - 861=ibm-861-icelandic - 862=ibm-862-hebrew - 863=ibm-863-canadian-french - 864=ibm-864-arabic - 865=ibm-865-nordic - 866=ibm-866-cyrillic-russian - 869=ibm-869-greek-modern - 874=win-874-thai - 932=win-932-japanese-shift-jis - 936=win-936-chinese-simplified-gbk - 949=win-949-korean-wansung - 950=win-950-chinese-traditional-big5 - 1200=utf-16 - 1250=win-1250-latin-2-central-european - 1251=win-1251-cyrillic - 1252=win-1252-latin-1 - 1253=win-1253-greek - 1254=win-1254-turkish - 1255=win-1255-hebrew - 1256=win-1256-arabic - 1257=win-1257-baltic - 1258=win-1258-vietnamese - 1361=win-1361-korean-johab - 10000=apple-roman - 10001=apple-japanese - 10002=apple-chinese-traditional - 10003=apple-korean - 10004=apple-arabic - 10005=apple-hebrew - 10006=apple-greek - 10007=apple-cyrillic - 10008=apple-chinese-simplified - 10010=apple-romanian - 10017=apple-ukrainian - 10029=apple-central-european-with-euro - 10079=apple-icelandic - 10081=apple-turkish - 10082=apple-croatian - 20127=ascii - 20866=koi8-r - 21866=koi8-u - 28591=iso-8859-1 - 28592=iso-8859-2 - 28593=iso-8859-3 - 28594=iso-8859-4 - 28595=iso-8859-5 - 28596=iso-8859-6 - 28597=iso-8859-7 - 28598=iso-8859-8 - 28599=iso-8859-9 - 28605=iso-8859-15 - 32768=apple-romanian - 32769=win-1252-latin-1 - 50220=iso-2022-jp - 50225=iso-2022-kr - 51932=euc-jp - 51936=euc-cn - 51949=euc-kr - 65000=utf-7 - 65001=utf-8 -end - -# OLE property stream -------------------------------------------------------- - -F29F85E0-4FF9-1068-AB91-08002B27B3D9=GlobalDocProp -D5CDD502-2E9C-101B-9397-08002B2CF9AE=BuiltinDocProp -D5CDD505-2E9C-101B-9397-08002B2CF9AE=CustomDocProp - -constlist=OLEPROP-BYTE-ORDER - 0xFEFF=big-endian - 0xFFFE=little-endian -end - -shortlist=OLEPROP-OSTYPE,0,dos,mac,win32,unix - -multilist=OLEPROP-BASEIDS - quote-names=1 - default= - 0=dictionary,codepage -end - -multilist=OLEPROP-GLOBALIDS - include=OLEPROP-BASEIDS - 2=title,subject,author,keywords,comments,template,last-author,rev-number - 10=edit-time,last-printed,create-time,last-saved,page-count,word-count,char-count,thumbnail,appname,security -end - -multilist=OLEPROP-BUILTINIDS - include=OLEPROP-BASEIDS - 2=category,pres-target,byte-count,line-count,para-count,slide-count,note-count,hidden-slide-count - 10=clips,scale-crop,heading-pairs,part-titles,manager,company,links-uptodate -end - -multilist=OLEPROP-TYPE-SIMPLE - 0=empty,null,int16,int32,float,double,fixed,date,string8,dispatch - 10=error,bool,variant,unknown,decimal,int8,uint8,uint16,uint32 - 20=int64,uint64,int,uint,void,hresult,ptr,savearray,c-array,userdef - 30=string8,string16 - 64=time-stamp,blob,stream,storage,stream-obj,storage-obj - 70=blob-obj,clip-fmt,guid,vers-stream - 0x0FFF=str8-blob -end - -combilist=OLEPROP-TYPE - 0x0FFF=int32,dec,base-type,OLEPROP-TYPE-SIMPLE - 0x1000=vector - 0x2000=array - 0x4000=byref -end - -# ============================================================================ - diff --git a/oox/source/dump/makefile.mk b/oox/source/dump/makefile.mk index db13bee5c12a..6c7fd2257a58 100644 --- a/oox/source/dump/makefile.mk +++ b/oox/source/dump/makefile.mk @@ -1,14 +1,14 @@ #************************************************************************* # # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# +# # Copyright 2008 by Sun Microsystems, Inc. # # OpenOffice.org - a multi-platform office productivity suite # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.4 $ +# $Revision: 1.4.20.1 $ # # This file is part of OpenOffice.org. # @@ -44,12 +44,12 @@ ENABLE_EXCEPTIONS=TRUE # --- Files -------------------------------------------------------- -SLOFILES = \ - $(SLO)$/biffdumper.obj \ - $(SLO)$/dffdumper.obj \ - $(SLO)$/dumperbase.obj \ - $(SLO)$/olestoragedumper.obj \ - $(SLO)$/pptxdumper.obj \ +SLOFILES = \ + $(SLO)$/biffdumper.obj \ + $(SLO)$/dffdumper.obj \ + $(SLO)$/dumperbase.obj \ + $(SLO)$/oledumper.obj \ + $(SLO)$/pptxdumper.obj \ $(SLO)$/xlsbdumper.obj # --- Targets ------------------------------------------------------- diff --git a/oox/source/dump/oledumper.cxx b/oox/source/dump/oledumper.cxx new file mode 100644 index 000000000000..d168d1a8749a --- /dev/null +++ b/oox/source/dump/oledumper.cxx @@ -0,0 +1,1850 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: oledumper.cxx,v $ + * $Revision: 1.1.2.13 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "oox/dump/oledumper.hxx" +#include <com/sun/star/io/XInputStream.hpp> +#include <com/sun/star/io/XOutputStream.hpp> +#include <osl/thread.h> +#include <osl/file.hxx> +#include <rtl/tencinfo.h> +#include "oox/helper/binaryoutputstream.hxx" +#include "oox/core/filterbase.hxx" +#include "oox/ole/vbainputstream.hxx" +#include "oox/xls/biffhelper.hxx" + +#if OOX_INCLUDE_DUMPER + +using ::rtl::OUString; +using ::rtl::OUStringBuffer; +using ::rtl::OString; +using ::rtl::OStringToOUString; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::io::XInputStream; +using ::com::sun::star::io::XOutputStream; + +namespace oox { +namespace dump { + +// ============================================================================ +// ============================================================================ + +StdFontObject::StdFontObject( const InputObjectBase& rParent ) : + InputObjectBase( rParent ) +{ +} + +void StdFontObject::implDump() +{ + dumpDec< sal_uInt8 >( "version" ); + dumpDec< sal_uInt16 >( "charset", "CHARSET" ); + dumpHex< sal_uInt8 >( "flags", "STDFONT-FLAGS" ); + dumpDec< sal_uInt16 >( "weight", "FONT-WEIGHT" ); + dumpDec< sal_uInt32 >( "height", "STDFONT-HEIGHT" ); + dumpCharArray( "name", in().readuInt8(), RTL_TEXTENCODING_ASCII_US ); +} + +// ============================================================================ + +StdPicObject::StdPicObject( const InputObjectBase& rParent ) : + InputObjectBase( rParent ) +{ +} + +void StdPicObject::implDump() +{ + dumpHex< sal_uInt32 >( "identifier" ); + sal_uInt32 nSize = dumpHex< sal_uInt32 >( "image-size", "CONV-DEC" ); + dumpBinary( "image-data", nSize ); +} + +// ============================================================================ + +namespace { + +const sal_uInt32 STDHLINK_HASTARGET = 0x00000001; /// Has hyperlink moniker. +const sal_uInt32 STDHLINK_ABSOLUTE = 0x00000002; /// Absolute path. +const sal_uInt32 STDHLINK_HASLOCATION = 0x00000008; /// Has target location. +const sal_uInt32 STDHLINK_HASDISPLAY = 0x00000010; /// Has display string. +const sal_uInt32 STDHLINK_HASGUID = 0x00000020; /// Has identification GUID. +const sal_uInt32 STDHLINK_HASTIME = 0x00000040; /// Has creation time. +const sal_uInt32 STDHLINK_HASFRAME = 0x00000080; /// Has frame. +const sal_uInt32 STDHLINK_ASSTRING = 0x00000100; /// Hyperlink as simple string. + +} // namespace + +StdHlinkObject::StdHlinkObject( const InputObjectBase& rParent ) : + InputObjectBase( rParent ) +{ +} + +void StdHlinkObject::implDump() +{ + dumpDec< sal_uInt32 >( "stream-version" ); + sal_uInt32 nFlags = dumpHex< sal_uInt32 >( "flags", "STDHLINK-FLAGS" ); + if( getFlag( nFlags, STDHLINK_HASDISPLAY ) ) + dumpHyperlinkString( "display", true ); + if( getFlag( nFlags, STDHLINK_HASFRAME ) ) + dumpHyperlinkString( "frame", true ); + if( getFlag( nFlags, STDHLINK_HASTARGET ) ) + { + if( getFlag( nFlags, STDHLINK_ASSTRING ) ) + dumpHyperlinkString( "filename", true ); + else if( !dumpGuidAndMoniker() ) + return; + } + if( getFlag( nFlags, STDHLINK_HASLOCATION ) ) + dumpHyperlinkString( "location", true ); + if( getFlag( nFlags, STDHLINK_HASGUID ) ) + dumpGuid( "id-guid" ); + if( getFlag( nFlags, STDHLINK_HASTIME ) ) + dumpFileTime( "creation-time" ); +} + +OUString StdHlinkObject::dumpHyperlinkString( const String& rName, bool bUnicode ) +{ + sal_Int32 nLen = in().readInt32(); + return bUnicode ? dumpUnicodeArray( rName, nLen ) : dumpCharArray( rName, nLen, osl_getThreadTextEncoding() ); +} + +bool StdHlinkObject::dumpGuidAndMoniker() +{ + bool bValidMoniker = true; + OUString aGuid = cfg().getStringOption( dumpGuid( "moniker" ), OUString() ); + IndentGuard aIndGuard( out() ); + if( aGuid.equalsAscii( "URLMoniker" ) ) + dumpUrlMoniker(); + else if( aGuid.equalsAscii( "FileMoniker" ) ) + dumpFileMoniker(); + else if( aGuid.equalsAscii( "ItemMoniker" ) ) + dumpItemMoniker(); + else if( aGuid.equalsAscii( "AntiMoniker" ) ) + dumpAntiMoniker(); + else if( aGuid.equalsAscii( "CompositeMoniker" ) ) + dumpCompositeMoniker(); + else + bValidMoniker = false; + return bValidMoniker; +} + +void StdHlinkObject::dumpUrlMoniker() +{ + sal_Int32 nBytes = dumpDec< sal_Int32 >( "url-bytes" ); + sal_Int64 nEndPos = in().tell() + ::std::max< sal_Int32 >( nBytes, 0 ); + dumpNullUnicodeArray( "url" ); + if( in().tell() + 24 == nEndPos ) + { + dumpGuid( "implementation-id" ); + dumpDec< sal_uInt32 >( "version" ); + dumpHex< sal_uInt32 >( "flags", "STDHLINK-URL-FLAGS" ); + } + dumpRemainingTo( nEndPos ); +} + +void StdHlinkObject::dumpFileMoniker() +{ + dumpDec< sal_Int16 >( "up-levels" ); + dumpHyperlinkString( "ansi-filename", false ); + dumpDec< sal_Int16 >( "server-path-len" ); + dumpHex< sal_uInt16 >( "version" ); + dumpUnused( 20 ); + sal_Int32 nBytes = dumpDec< sal_Int32 >( "total-bytes" ); + sal_Int64 nEndPos = in().tell() + ::std::max< sal_Int32 >( nBytes, 0 ); + if( nBytes > 0 ) + { + sal_Int32 nFileBytes = dumpDec< sal_Int32 >( "uni-filename-bytes" ); + dumpDec< sal_uInt16 >( "key-value" ); + dumpUnicodeArray( "unicode-filename", nFileBytes / 2 ); + } + dumpRemainingTo( nEndPos ); +} + +void StdHlinkObject::dumpItemMoniker() +{ + sal_Int32 nBytes = dumpDec< sal_Int32 >( "delimiter-bytes" ); + sal_Int64 nEndPos = in().tell() + ::std::max< sal_Int32 >( nBytes, 0 ); + dumpNullCharArray( "ansi-delimiter", osl_getThreadTextEncoding() ); + if( in().tell() < nEndPos ) + dumpUnicodeArray( "unicode-delimiter", (nEndPos - in().tell()) / 2 ); + in().seek( nEndPos ); + + nBytes = dumpDec< sal_Int32 >( "item-bytes" ); + nEndPos = in().tell() + ::std::max< sal_Int32 >( nBytes, 0 ); + dumpNullCharArray( "ansi-item", osl_getThreadTextEncoding() ); + if( in().tell() < nEndPos ) + dumpUnicodeArray( "unicode-item", (nEndPos - in().tell()) / 2 ); + in().seek( nEndPos ); +} + +void StdHlinkObject::dumpAntiMoniker() +{ + dumpDec< sal_Int32 >( "count" ); +} + +void StdHlinkObject::dumpCompositeMoniker() +{ + sal_Int32 nCount = dumpDec< sal_Int32 >( "moniker-count" ); + for( sal_Int32 nIndex = 0; !in().isEof() && (nIndex < nCount); ++nIndex ) + dumpGuidAndMoniker(); +} + +// ============================================================================ +// ============================================================================ + +namespace { + +const sal_Int32 OLEPROP_ID_DICTIONARY = 0; +const sal_Int32 OLEPROP_ID_CODEPAGE = 1; + +const sal_Int32 OLEPROP_TYPE_INT16 = 2; +const sal_Int32 OLEPROP_TYPE_INT32 = 3; +const sal_Int32 OLEPROP_TYPE_FLOAT = 4; +const sal_Int32 OLEPROP_TYPE_DOUBLE = 5; +const sal_Int32 OLEPROP_TYPE_DATE = 7; +const sal_Int32 OLEPROP_TYPE_STRING = 8; +const sal_Int32 OLEPROP_TYPE_STATUS = 10; +const sal_Int32 OLEPROP_TYPE_BOOL = 11; +const sal_Int32 OLEPROP_TYPE_VARIANT = 12; +const sal_Int32 OLEPROP_TYPE_INT8 = 16; +const sal_Int32 OLEPROP_TYPE_UINT8 = 17; +const sal_Int32 OLEPROP_TYPE_UINT16 = 18; +const sal_Int32 OLEPROP_TYPE_UINT32 = 19; +const sal_Int32 OLEPROP_TYPE_INT64 = 20; +const sal_Int32 OLEPROP_TYPE_UINT64 = 21; +const sal_Int32 OLEPROP_TYPE_STRING8 = 30; +const sal_Int32 OLEPROP_TYPE_STRING16 = 31; +const sal_Int32 OLEPROP_TYPE_FILETIME = 64; +const sal_Int32 OLEPROP_TYPE_BLOB = 65; +const sal_Int32 OLEPROP_TYPE_STREAM = 66; +const sal_Int32 OLEPROP_TYPE_STORAGE = 67; +const sal_Int32 OLEPROP_TYPE_CLIPFMT = 71; + +const sal_uInt16 CODEPAGE_UNICODE = 1200; + +const sal_uInt32 OCX_STRING_COMPRESSED = 0x80000000; + +} // namespace + +// ============================================================================ + +OlePropertyStreamObject::OlePropertyStreamObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName ) : + BinaryStreamObject( rParent, rxStrm, rSysFileName ) +{ +} + +void OlePropertyStreamObject::implDump() +{ + BinaryInputStream& rStrm = in(); + Output& rOut = out(); + + OUStringVector aGuidVec; + ::std::vector< sal_uInt32 > aStartPosVec; + + // dump header + writeEmptyItem( "HEADER" ); + { + IndentGuard aIndGuard( rOut ); + dumpHex< sal_uInt16 >( "byte-order", "OLEPROP-BYTE-ORDER" ); + dumpDec< sal_uInt16 >( "version" ); + dumpDec< sal_uInt16 >( "os-minor" ); + dumpDec< sal_uInt16 >( "os-type", "OLEPROP-OSTYPE" ); + dumpGuid( "guid" ); + sal_Int32 nSectCount = dumpDec< sal_Int32 >( "section-count" ); + + // dump table of section positions + { + TableGuard aTabGuard( rOut, 15, 60 ); + rOut.resetItemIndex(); + for( sal_Int32 nSectIdx = 0; !rStrm.isEof() && (nSectIdx < nSectCount); ++nSectIdx ) + { + MultiItemsGuard aMultiGuard( rOut ); + writeEmptyItem( "#section" ); + aGuidVec.push_back( dumpGuid( "guid" ) ); + aStartPosVec.push_back( dumpHex< sal_uInt32 >( "start-pos", "CONV-DEC" ) ); + } + } + } + rOut.emptyLine(); + + // dump sections + for( size_t nSectIdx = 0; !rStrm.isEof() && (nSectIdx < aStartPosVec.size()); ++nSectIdx ) + dumpSection( aGuidVec[ nSectIdx ], aStartPosVec[ nSectIdx ] ); +} + +void OlePropertyStreamObject::dumpSection( const OUString& rGuid, sal_uInt32 nStartPos ) +{ + BinaryInputStream& rStrm = in(); + Output& rOut = out(); + + // property ID names + mxPropIds = cfg().createNameList< ConstList >( "OLEPROP-IDS" ); + OUString aGuidName = cfg().getStringOption( rGuid, OUString() ); + if( aGuidName.equalsAscii( "GlobalDocProp" ) ) + mxPropIds->includeList( cfg().getNameList( "OLEPROP-GLOBALIDS" ) ); + else if( aGuidName.equalsAscii( "BuiltinDocProp" ) ) + mxPropIds->includeList( cfg().getNameList( "OLEPROP-BUILTINIDS" ) ); + else + mxPropIds->includeList( cfg().getNameList( "OLEPROP-BASEIDS" ) ); + + // property ID/position map + typedef ::std::map< sal_Int32, sal_uInt32 > PropertyPosMap; + PropertyPosMap aPropMap; + + // dump section header line + writeSectionHeader( rGuid, nStartPos ); + + // seek to section + IndentGuard aIndGuard( rOut ); + if( startElement( nStartPos ) ) + { + // dump section header + dumpDec< sal_Int32 >( "size" ); + sal_Int32 nPropCount = dumpDec< sal_Int32 >( "property-count" ); + + // dump table of property positions + { + TableGuard aTabGuard( rOut, 15, 25 ); + rOut.resetItemIndex(); + for( sal_Int32 nPropIdx = 0; !rStrm.isEof() && (nPropIdx < nPropCount); ++nPropIdx ) + { + MultiItemsGuard aMultiGuard( rOut ); + writeEmptyItem( "#property" ); + sal_Int32 nPropId = dumpDec< sal_Int32 >( "id", mxPropIds ); + sal_uInt32 nPropPos = nStartPos + dumpHex< sal_uInt32 >( "start-pos", "CONV-DEC" ); + aPropMap[ nPropId ] = nPropPos; + } + } + } + rOut.emptyLine(); + + // code page property + meTextEnc = osl_getThreadTextEncoding(); + mbIsUnicode = false; + PropertyPosMap::iterator aCodePageIt = aPropMap.find( OLEPROP_ID_CODEPAGE ); + if( aCodePageIt != aPropMap.end() ) + { + dumpCodePageProperty( aCodePageIt->second ); + aPropMap.erase( aCodePageIt ); + } + + // dictionary property + PropertyPosMap::iterator aDictIt = aPropMap.find( OLEPROP_ID_DICTIONARY ); + if( aDictIt != aPropMap.end() ) + { + dumpDictionaryProperty( aDictIt->second ); + aPropMap.erase( aDictIt ); + } + + // other properties + for( PropertyPosMap::const_iterator aIt = aPropMap.begin(), aEnd = aPropMap.end(); aIt != aEnd; ++aIt ) + dumpProperty( aIt->first, aIt->second ); + + // remove the user defined list of property ID names + cfg().eraseNameList( "OLEPROP-IDS" ); +} + +void OlePropertyStreamObject::dumpProperty( sal_Int32 nPropId, sal_uInt32 nStartPos ) +{ + writePropertyHeader( nPropId, nStartPos ); + IndentGuard aIndGuard( out() ); + if( startElement( nStartPos ) ) + dumpPropertyContents( nPropId ); + out().emptyLine(); +} + +void OlePropertyStreamObject::dumpCodePageProperty( sal_uInt32 nStartPos ) +{ + writePropertyHeader( OLEPROP_ID_CODEPAGE, nStartPos ); + IndentGuard aIndGuard( out() ); + if( startElement( nStartPos ) ) + { + sal_Int32 nType = dumpPropertyType(); + if( nType == OLEPROP_TYPE_INT16 ) + { + sal_uInt16 nCodePage = dumpDec< sal_uInt16 >( "codepage", "CODEPAGES" ); + rtl_TextEncoding nNewTextEnc = rtl_getTextEncodingFromWindowsCodePage( nCodePage ); + if( nNewTextEnc != RTL_TEXTENCODING_DONTKNOW ) + meTextEnc = nNewTextEnc; + mbIsUnicode = nCodePage == CODEPAGE_UNICODE; + } + else + dumpPropertyContents( OLEPROP_ID_CODEPAGE ); + } + out().emptyLine(); +} + +void OlePropertyStreamObject::dumpDictionaryProperty( sal_uInt32 nStartPos ) +{ + writePropertyHeader( OLEPROP_ID_DICTIONARY, nStartPos ); + IndentGuard aIndGuard( out() ); + if( startElement( nStartPos ) ) + { + sal_Int32 nCount = dumpDec< sal_Int32 >( "count" ); + for( sal_Int32 nIdx = 0; !in().isEof() && (nIdx < nCount); ++nIdx ) + { + MultiItemsGuard aMultiGuard( out() ); + TableGuard aTabGuard( out(), 10, 20 ); + sal_Int32 nId = dumpDec< sal_Int32 >( "id" ); + OUString aName = dumpString8( "name" ); + if( mxPropIds.get() ) + mxPropIds->setName( nId, aName ); + } + } + out().emptyLine(); +} + +void OlePropertyStreamObject::dumpPropertyContents( sal_Int32 nPropId ) +{ + sal_Int32 nType = dumpPropertyType(); + if( getFlag< sal_Int32 >( nType, 0x1000 ) ) // vector + { + sal_Int32 nBaseType = nType & 0x0FFF; + sal_Int32 nElemCount = dumpDec< sal_Int32 >( "element-count" ); + for( sal_Int32 nElemIdx = 0; !in().isEof() && (nElemIdx < nElemCount); ++nElemIdx ) + { + out().resetItemIndex( nElemIdx ); + writeEmptyItem( "#element" ); + IndentGuard aIndGuard( out() ); + dumpPropertyValue( nPropId, nBaseType ); + } + } + else if( !getFlag< sal_Int32 >( nType, 0x7000 ) ) + { + dumpPropertyValue( nPropId, nType ); + } +} + +void OlePropertyStreamObject::dumpPropertyValue( sal_Int32 nPropId, sal_Int32 nBaseType ) +{ + switch( nBaseType ) + { + case OLEPROP_TYPE_INT16: dumpDec< sal_Int16 >( "value" ); break; + case OLEPROP_TYPE_INT32: dumpDec< sal_Int32 >( "value" ); break; + case OLEPROP_TYPE_FLOAT: dumpDec< float >( "value" ); break; + case OLEPROP_TYPE_DOUBLE: dumpDec< double >( "value" ); break; + case OLEPROP_TYPE_DATE: dumpDec< double >( "date" ); break; + case OLEPROP_TYPE_STRING: dumpString8( "value" ); break; + case OLEPROP_TYPE_STATUS: dumpHex< sal_Int32 >( "status" ); break; + case OLEPROP_TYPE_BOOL: dumpBool< sal_Int16 >( "value" ); break; + case OLEPROP_TYPE_VARIANT: dumpPropertyContents( nPropId ); break; + case OLEPROP_TYPE_INT8: dumpDec< sal_Int8 >( "value" ); break; + case OLEPROP_TYPE_UINT8: dumpDec< sal_uInt8 >( "value" ); break; + case OLEPROP_TYPE_UINT16: dumpDec< sal_uInt16 >( "value" ); break; + case OLEPROP_TYPE_UINT32: dumpDec< sal_uInt32 >( "value" ); break; + case OLEPROP_TYPE_INT64: dumpDec< sal_Int64 >( "value" ); break; + case OLEPROP_TYPE_UINT64: dumpDec< sal_uInt64 >( "value" ); break; + case OLEPROP_TYPE_STRING8: dumpString8( "value" ); break; + case OLEPROP_TYPE_STRING16: dumpString16( "value" ); break; + case OLEPROP_TYPE_FILETIME: dumpFileTime( "file-time" ); break; + case OLEPROP_TYPE_BLOB: dumpBlob( "data" ); break; + case OLEPROP_TYPE_STREAM: dumpString8( "stream-name" ); break; + case OLEPROP_TYPE_STORAGE: dumpString8( "storage-name" ); break; + case OLEPROP_TYPE_CLIPFMT: dumpBlob( "clip-data" ); break; + } +} + +sal_Int32 OlePropertyStreamObject::dumpPropertyType() +{ + return dumpHex< sal_Int32 >( "type", "OLEPROP-TYPE" ); +} + +void OlePropertyStreamObject::dumpBlob( const String& rName ) +{ + sal_Int32 nSize = dumpDec< sal_Int32 >( "data-size" ); + if( nSize > 0 ) + dumpBinary( rName, nSize ); +} + +OUString OlePropertyStreamObject::dumpString8( const String& rName ) +{ + sal_Int32 nLen = dumpDec< sal_Int32 >( "string-len" ); + return mbIsUnicode ? dumpCharArray16( rName, nLen ) : dumpCharArray8( rName, nLen ); +} + +OUString OlePropertyStreamObject::dumpCharArray8( const String& rName, sal_Int32 nLen ) +{ + OUString aData; + size_t nNewLen = getLimitedValue< size_t, sal_Int32 >( nLen, 0, 1024 ); + if( nNewLen > 0 ) + { + ::std::vector< sal_Char > aBuffer( nNewLen + 1 ); + in().readMemory( &aBuffer.front(), nNewLen ); + aBuffer[ nNewLen ] = 0; + aData = OStringToOUString( OString( &aBuffer.front() ), meTextEnc ); + } + writeStringItem( rName, aData ); + return aData; +} + +OUString OlePropertyStreamObject::dumpString16( const String& rName ) +{ + sal_Int32 nLen = dumpDec< sal_Int32 >( "string-len" ); + return dumpCharArray16( rName, nLen ); +} + +OUString OlePropertyStreamObject::dumpCharArray16( const String& rName, sal_Int32 nLen ) +{ + size_t nNewLen = getLimitedValue< size_t, sal_Int32 >( nLen, 0, 1024 ); + ::std::vector< sal_Unicode > aBuffer; + aBuffer.reserve( nNewLen + 1 ); + for( size_t nIdx = 0; nIdx < nNewLen; ++nIdx ) + aBuffer.push_back( static_cast< sal_Unicode >( in().readuInt16() ) ); + aBuffer.push_back( 0 ); + OUString aData( &aBuffer.front() ); + writeStringItem( rName, aData ); + if( nNewLen & 1 ) dumpUnused( 2 ); // always padding to 32bit + return aData; +} + +bool OlePropertyStreamObject::startElement( sal_uInt32 nStartPos ) +{ + in().seek( nStartPos ); + if( in().isEof() ) + writeInfoItem( "stream-state", OOX_DUMP_ERR_STREAM ); + return !in().isEof(); +} + +void OlePropertyStreamObject::writeSectionHeader( const OUString& rGuid, sal_uInt32 nStartPos ) +{ + MultiItemsGuard aMultiGuard( out() ); + writeEmptyItem( "SECTION" ); + writeHexItem( "pos", nStartPos, "CONV-DEC" ); + writeGuidItem( "guid", rGuid ); +} + +void OlePropertyStreamObject::writePropertyHeader( sal_Int32 nPropId, sal_uInt32 nStartPos ) +{ + MultiItemsGuard aMultiGuard( out() ); + writeEmptyItem( "PROPERTY" ); + writeHexItem( "pos", nStartPos, "CONV-DEC" ); + writeDecItem( "id", nPropId, mxPropIds ); +} + +// ============================================================================ + +OleStorageObject::OleStorageObject( const ObjectBase& rParent, const StorageRef& rxStrg, const OUString& rSysPath ) +{ + construct( rParent, rxStrg, rSysPath ); +} + +void OleStorageObject::construct( const ObjectBase& rParent, const StorageRef& rxStrg, const OUString& rSysPath ) +{ + StorageObjectBase::construct( rParent, rxStrg, rSysPath ); +} + +void OleStorageObject::construct( const ObjectBase& rParent ) +{ + StorageObjectBase::construct( rParent ); +} + +void OleStorageObject::implDumpStream( const BinaryInputStreamRef& rxStrm, const OUString& /*rStrgPath*/, const OUString& rStrmName, const OUString& rSysFileName ) +{ + if( rStrmName.equalsAscii( "\005SummaryInformation" ) || rStrmName.equalsAscii( "\005DocumentSummaryInformation" ) ) + OlePropertyStreamObject( *this, rxStrm, rSysFileName ).dump(); + else + BinaryStreamObject( *this, rxStrm, rSysFileName ).dump(); +} + +// ============================================================================ +// ============================================================================ + +void OcxPropertyObjectBase::construct( const ObjectBase& rParent, + const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName, const String& rPropNameList, bool b64BitPropFlags ) +{ + InputObjectBase::construct( rParent, rxStrm, rSysFileName ); + constructOcxPropObj( rPropNameList, b64BitPropFlags ); +} + +void OcxPropertyObjectBase::construct( const OutputObjectBase& rParent, + const BinaryInputStreamRef& rxStrm, const String& rPropNameList, bool b64BitPropFlags ) +{ + InputObjectBase::construct( rParent, rxStrm ); + constructOcxPropObj( rPropNameList, b64BitPropFlags ); +} + +void OcxPropertyObjectBase::construct( const InputObjectBase& rParent, + const String& rPropNameList, bool b64BitPropFlags ) +{ + InputObjectBase::construct( rParent ); + constructOcxPropObj( rPropNameList, b64BitPropFlags ); +} + +bool OcxPropertyObjectBase::implIsValid() const +{ + return InputObjectBase::implIsValid() && in().isSeekable(); +} + +void OcxPropertyObjectBase::implDump() +{ + mbValid = true; + // header + setAlignAnchor(); + dumpVersion(); + sal_uInt16 nSize = dumpDec< sal_uInt16 >( "size" ); + mnPropertiesEnd = in().tell() + nSize; + // property flags + maLargeProps.clear(); + maStreamProps.clear(); + mnPropFlags = dumpHex< sal_Int64, sal_uInt32 >( mb64BitPropFlags, "properties", mxPropNames ); + mnCurrProp = 0; + // properties + dumpShortProperties(); + dumpLargeProperties(); + setAlignAnchor(); + if( ensureValid() ) + implDumpExtended(); +} + +void OcxPropertyObjectBase::implDumpShortProperties() +{ +} + +void OcxPropertyObjectBase::implDumpExtended() +{ +} + +bool OcxPropertyObjectBase::ensureValid( bool bCondition ) +{ + if( mbValid && (!bCondition || in().isEof()) ) + { + if( !bCondition ) + writeInfoItem( "state", OOX_DUMP_ERRASCII( "format-error" ) ); + mbValid = false; + } + return mbValid; +} + +void OcxPropertyObjectBase::setAlignAnchor() +{ + mnPropertiesStart = in().tell(); +} + +bool OcxPropertyObjectBase::startNextProperty() +{ + if( mnCurrProp == 0 ) mnCurrProp = 1; else mnCurrProp <<= 1; + bool bHasProp = getFlag( mnPropFlags, mnCurrProp ); + setFlag( mnPropFlags, mnCurrProp, false ); + return ensureValid() && bHasProp; +} + +OUString OcxPropertyObjectBase::getPropertyName() const +{ + return cfg().getName( mxPropNames, mnCurrProp ); +} + +sal_uInt32 OcxPropertyObjectBase::dumpFlagsProperty( sal_uInt32 nDefault, const sal_Char* pcNameList ) +{ + if( startNextProperty() ) + { + alignInput< sal_uInt32 >(); + return dumpHex< sal_uInt32 >( getPropertyName(), pcNameList ); + } + return nDefault; +} + +sal_uInt32 OcxPropertyObjectBase::dumpColorProperty( sal_uInt32 nDefault ) +{ + if( startNextProperty() ) + { + MultiItemsGuard aMultiGuard( out() ); + alignInput< sal_uInt32 >(); + sal_uInt32 nColor = dumpHex< sal_uInt32 >( getPropertyName(), "OCX-COLOR" ); + switch( extractValue< sal_uInt8 >( nColor, 24, 8 ) ) + { + case 0x00: writeColorABGRItem( "rgb", extractValue< sal_Int32 >( nColor, 0, 24 ) ); break; + case 0x01: writeDecItem( "palette-index", extractValue< sal_uInt16 >( nColor, 0, 16 ) ); break; + case 0x02: writeColorABGRItem( "rgb", extractValue< sal_Int32 >( nColor, 0, 24 ) ); break; + case 0x80: writeDecItem( "sys-color", extractValue< sal_uInt16 >( nColor, 0, 16 ), "OCX-SYSTEMCOLOR" ); break; + } + return nColor; + } + return nDefault; +} + +sal_Unicode OcxPropertyObjectBase::dumpUnicodeProperty() +{ + if( startNextProperty() ) + { + alignInput< sal_uInt16 >(); + return dumpUnicode( getPropertyName() ); + } + return '\0'; +} + +void OcxPropertyObjectBase::dumpUnknownProperty() +{ + if( startNextProperty() ) + ensureValid( false ); +} + +void OcxPropertyObjectBase::dumpPosProperty() +{ + if( startNextProperty() ) + maLargeProps.push_back( LargeProperty( PROPTYPE_POS, getPropertyName(), 8 ) ); +} + +void OcxPropertyObjectBase::dumpSizeProperty() +{ + if( startNextProperty() ) + maLargeProps.push_back( LargeProperty( PROPTYPE_SIZE, getPropertyName(), 8 ) ); +} + +void OcxPropertyObjectBase::dumpGuidProperty( OUString* pValue ) +{ + if( startNextProperty() ) + maLargeProps.push_back( LargeProperty( PROPTYPE_GUID, getPropertyName(), 16, pValue ) ); +} + +void OcxPropertyObjectBase::dumpStringProperty( OUString* pValue ) +{ + if( startNextProperty() ) + { + alignInput< sal_uInt32 >(); + sal_uInt32 nLen = dumpHex< sal_uInt32 >( getPropertyName(), "OCX-STRINGLEN" ); + maLargeProps.push_back( LargeProperty( PROPTYPE_STRING, getPropertyName(), nLen, pValue ) ); + } +} + +void OcxPropertyObjectBase::dumpStringArrayProperty() +{ + if( startNextProperty() ) + { + alignInput< sal_uInt32 >(); + sal_uInt32 nLen = dumpHex< sal_uInt32 >( getPropertyName(), "CONV-DEC" ); + maLargeProps.push_back( LargeProperty( PROPTYPE_STRINGARRAY, getPropertyName(), nLen ) ); + } +} + +void OcxPropertyObjectBase::dumpStreamProperty() +{ + if( startNextProperty() ) + { + alignInput< sal_uInt16 >(); + sal_uInt16 nData = dumpHex< sal_uInt16 >( getPropertyName() ); + maStreamProps.push_back( StreamProperty( getPropertyName(), nData ) ); + } +} + +void OcxPropertyObjectBase::dumpEmbeddedFont() +{ + if( ensureValid() ) + { + writeEmptyItem( "embedded-fontdata" ); + IndentGuard aIndGuard( out() ); + OcxCFontNewObject( *this ).dump(); + } +} + +void OcxPropertyObjectBase::dumpToPosition( sal_Int64 nPos ) +{ + dumpRemainingTo( nPos ); + mbValid = true; + ensureValid(); +} + +void OcxPropertyObjectBase::constructOcxPropObj( const String& rPropNameList, bool b64BitPropFlags ) +{ + if( InputObjectBase::implIsValid() ) + { + mxPropNames = cfg().getNameList( rPropNameList ); + mb64BitPropFlags = b64BitPropFlags; + mbValid = true; + } +} + +void OcxPropertyObjectBase::dumpVersion() +{ + ItemGuard aItem( out(), "version" ); + sal_uInt8 nMinor, nMajor; + in() >> nMinor >> nMajor; + out().writeDec( nMajor ); + out().writeChar( '.' ); + out().writeDec( nMinor ); +} + +OUString OcxPropertyObjectBase::dumpString( const String& rName, sal_uInt32 nSize, bool bArray ) +{ + bool bCompressed = getFlag( nSize, OCX_STRING_COMPRESSED ); + sal_uInt32 nBufSize = extractValue< sal_uInt32 >( nSize, 0, 31 ); + OUString aString = bCompressed ? + dumpCharArray( rName, nBufSize, RTL_TEXTENCODING_ISO_8859_1 ) : + dumpUnicodeArray( rName, bArray ? nBufSize : (nBufSize / 2) ); + alignInput< sal_Int32 >(); + return aString; +} + +void OcxPropertyObjectBase::dumpShortProperties() +{ + if( ensureValid() ) + { + writeEmptyItem( "short-properties" ); + IndentGuard aIndGuard( out() ); + implDumpShortProperties(); + alignInput< sal_uInt32 >(); + } +} + +void OcxPropertyObjectBase::dumpLargeProperties() +{ + if( ensureValid( mnPropFlags == 0 ) && !maLargeProps.empty() ) + { + writeEmptyItem( "large-properties" ); + IndentGuard aIndGuard( out() ); + for( LargePropertyVector::iterator aIt = maLargeProps.begin(), aEnd = maLargeProps.end(); ensureValid() && (aIt != aEnd); ++aIt ) + { + switch( aIt->mePropType ) + { + case PROPTYPE_POS: + { + MultiItemsGuard aMultiGuard( out() ); + writeEmptyItem( aIt->maItemName ); + dumpDec< sal_Int32 >( "top", "CONV-HMM-TO-CM" ); + dumpDec< sal_Int32 >( "left", "CONV-HMM-TO-CM" ); + } + break; + case PROPTYPE_SIZE: + { + MultiItemsGuard aMultiGuard( out() ); + writeEmptyItem( aIt->maItemName ); + dumpDec< sal_Int32 >( "width", "CONV-HMM-TO-CM" ); + dumpDec< sal_Int32 >( "height", "CONV-HMM-TO-CM" ); + } + break; + case PROPTYPE_GUID: + { + OUString aGuid = dumpGuid( aIt->maItemName ); + if( aIt->mpItemValue ) + *aIt->mpItemValue = cfg().getStringOption( aGuid, OUString() ); + } + break; + case PROPTYPE_STRING: + { + OUString aString = dumpString( aIt->maItemName, aIt->mnDataSize, false ); + if( aIt->mpItemValue ) + *aIt->mpItemValue = aString; + } + break; + case PROPTYPE_STRINGARRAY: + { + writeEmptyItem( aIt->maItemName ); + IndentGuard aIndGuard2( out() ); + out().resetItemIndex(); + sal_Int64 nEndPos = in().tell() + aIt->mnDataSize; + while( in().tell() < nEndPos ) + { + MultiItemsGuard aMultiGuard( out() ); + sal_uInt32 nDataSize = dumpHex< sal_uInt32 >( "#flags", "OCX-ARRAYSTRINGLEN" ); + dumpString( "string", nDataSize, true ); + } + dumpToPosition( nEndPos ); + } + break; + } + } + } + dumpToPosition( mnPropertiesEnd ); + + if( ensureValid() && !maStreamProps.empty() ) + { + writeEmptyItem( "stream-properties" ); + IndentGuard aIndGuard( out() ); + for( StreamPropertyVector::iterator aIt = maStreamProps.begin(), aEnd = maStreamProps.end(); ensureValid() && (aIt != aEnd); ++aIt ) + { + writeEmptyItem( aIt->maItemName ); + if( ensureValid( aIt->mnData == 0xFFFF ) ) + { + IndentGuard aIndGuard( out() ); + OUString aClassName = cfg().getStringOption( dumpGuid(), OUString() ); + if( aClassName.equalsAscii( "StdFont" ) ) + StdFontObject( *this ).dump(); + else if( aClassName.equalsAscii( "StdPic" ) ) + StdPicObject( *this ).dump(); + else if( aClassName.equalsAscii( "CFontNew" ) ) + OcxCFontNewObject( *this ).dump(); + else + ensureValid( false ); + } + } + } +} + +// ============================================================================ + +OcxCFontNewObject::OcxCFontNewObject( const InputObjectBase& rParent ) +{ + OcxPropertyObjectBase::construct( rParent, "OCX-CFONTNEW-PROPERTIES" ); +} + +void OcxCFontNewObject::implDumpShortProperties() +{ + dumpStringProperty(); + dumpFlagsProperty( 0, "OCX-CFONTNEW-FLAGS" ); + dumpDecProperty< sal_Int32 >( 160 ); + dumpDecProperty< sal_Int32 >( 0 ); + dumpDecProperty< sal_uInt8 >( 1, "CHARSET" ); + dumpDecProperty< sal_uInt8 >( 0, "FONT-PITCHFAMILY" ); + dumpDecProperty< sal_uInt8 >( 1, "OCX-CFONTNEW-ALIGNMENT" ); + dumpDecProperty< sal_uInt16 >( 400, "FONT-WEIGHT" ); +} + +// ============================================================================ + +OcxColumnInfoObject::OcxColumnInfoObject( const InputObjectBase& rParent ) +{ + OcxPropertyObjectBase::construct( rParent, "OCX-COLUMNINFO-PROPERTIES" ); +} + +void OcxColumnInfoObject::implDumpShortProperties() +{ + dumpDecProperty< sal_Int32 >( -1, "CONV-HMM-TO-CM" ); +} + +// ============================================================================ + +OcxCommandButtonObject::OcxCommandButtonObject( const InputObjectBase& rParent ) +{ + OcxPropertyObjectBase::construct( rParent, "OCX-COMMANDBUTTON-PROPERTIES" ); +} + +void OcxCommandButtonObject::implDumpShortProperties() +{ + dumpColorProperty( 0x80000012 ); + dumpColorProperty( 0x80000008 ); + dumpFlagsProperty( 0x0000001B ); + dumpStringProperty(); + dumpImagePosProperty(); + dumpSizeProperty(); + dumpMousePtrProperty(); + dumpStreamProperty(); + dumpUnicodeProperty(); + dumpBoolProperty(); + dumpStreamProperty(); +} + +void OcxCommandButtonObject::implDumpExtended() +{ + dumpEmbeddedFont(); +} + +// ============================================================================ + +OcxMorphControlObject::OcxMorphControlObject( const InputObjectBase& rParent ) +{ + OcxPropertyObjectBase::construct( rParent, "OCX-MORPH-PROPERTIES", true ); +} + +void OcxMorphControlObject::implDumpShortProperties() +{ + dumpFlagsProperty( 0x2C80081B ); + dumpColorProperty( 0x80000005 ); + dumpColorProperty( 0x80000008 ); + dumpDecProperty< sal_uInt32 >( 0 ); + dumpBorderStyleProperty< sal_uInt8 >( 0 ); + dumpDecProperty< sal_uInt8 >( 0, "OCX-MORPH-SCROLLBARS" ); + mnCtrlType = dumpDecProperty< sal_uInt8 >( 1, "OCX-MORPH-CONTROLTYPE" ); + dumpMousePtrProperty(); + dumpSizeProperty(); + dumpUnicodeProperty(); + dumpDecProperty< sal_uInt32 >( 0, "CONV-HMM-TO-CM" ); + dumpDecProperty< sal_uInt16 >( 1, "OCX-MORPH-BOUNDCOLUMN" ); + dumpDecProperty< sal_Int16 >( -1, "OCX-MORPH-TEXTCOLUMN" ); + dumpDecProperty< sal_Int16 >( 1, "OCX-MORPH-COLUMNCOUNT" ); + dumpDecProperty< sal_uInt16 >( 8 ); + mnColInfoCount = dumpDecProperty< sal_uInt16 >( 1 ); + dumpDecProperty< sal_uInt8 >( 2, "OCX-MORPH-MATCHENTRYTYPE" ); + dumpDecProperty< sal_uInt8 >( 0, "OCX-MORPH-LISTSTYLE" ); + dumpDecProperty< sal_uInt8 >( 0, "OCX-MORPH-SHOWDROPDOWNMODE" ); + dumpUnknownProperty(); + dumpDecProperty< sal_uInt8 >( 1, "OCX-MORPH-DROPDOWNSTYLE" ); + dumpDecProperty< sal_uInt8 >( 0, "OCX-MORPH-SELECTIONTYPE" ); + dumpStringProperty(); + dumpStringProperty(); + dumpImagePosProperty(); + dumpColorProperty( 0x80000006 ); + dumpSpecialEffectProperty< sal_uInt32 >( 2 ); + dumpStreamProperty(); + dumpStreamProperty(); + dumpUnicodeProperty(); + dumpUnknownProperty(); + dumpBoolProperty(); + dumpStringProperty(); +} + +void OcxMorphControlObject::implDumpExtended() +{ + dumpEmbeddedFont(); + dumpColumnInfos(); +} + +void OcxMorphControlObject::dumpColumnInfos() +{ + if( ensureValid() && (mnColInfoCount > 0) && ((mnCtrlType == 2) || (mnCtrlType == 3)) ) + { + out().resetItemIndex(); + for( sal_uInt16 nIdx = 0; ensureValid() && (nIdx < mnColInfoCount); ++nIdx ) + { + writeEmptyItem( "#column-info" ); + IndentGuard aIndGuard( out() ); + OcxColumnInfoObject( *this ).dump(); + } + } +} + +// ============================================================================ + +OcxLabelObject::OcxLabelObject( const InputObjectBase& rParent ) +{ + OcxPropertyObjectBase::construct( rParent, "OCX-LABEL-PROPERTIES" ); +} + +void OcxLabelObject::implDumpShortProperties() +{ + dumpColorProperty( 0x80000012 ); + dumpColorProperty( 0x8000000F ); + dumpFlagsProperty( 0x0080001B ); + dumpStringProperty(); + dumpImagePosProperty(); + dumpSizeProperty(); + dumpMousePtrProperty(); + dumpColorProperty( 0x80000006 ); + dumpBorderStyleProperty< sal_uInt16 >( 0 ); + dumpSpecialEffectProperty< sal_uInt16 >( 0 ); + dumpStreamProperty(); + dumpUnicodeProperty(); + dumpBoolProperty(); + dumpStreamProperty(); +} + +void OcxLabelObject::implDumpExtended() +{ + dumpEmbeddedFont(); +} + +// ============================================================================ + +OcxImageObject::OcxImageObject( const InputObjectBase& rParent ) +{ + OcxPropertyObjectBase::construct( rParent, "OCX-IMAGE-PROPERTIES" ); +} + +void OcxImageObject::implDumpShortProperties() +{ + dumpUnknownProperty(); + dumpUnknownProperty(); + dumpBoolProperty(); + dumpColorProperty( 0x80000006 ); + dumpColorProperty( 0x8000000F ); + dumpBorderStyleProperty< sal_uInt8 >( 1 ); + dumpMousePtrProperty(); + dumpImageSizeModeProperty(); + dumpSpecialEffectProperty< sal_uInt8 >( 0 ); + dumpSizeProperty(); + dumpStreamProperty(); + dumpImageAlignProperty(); + dumpBoolProperty(); + dumpFlagsProperty( 0x0000001B ); + dumpStreamProperty(); +} + +// ============================================================================ + +OcxScrollBarObject::OcxScrollBarObject( const InputObjectBase& rParent ) +{ + OcxPropertyObjectBase::construct( rParent, "OCX-SCROLLBAR-PROPERTIES" ); +} + +void OcxScrollBarObject::implDumpShortProperties() +{ + dumpColorProperty( 0x80000012 ); + dumpColorProperty( 0x8000000F ); + dumpFlagsProperty( 0x0000001B ); + dumpSizeProperty(); + dumpMousePtrProperty(); + dumpDecProperty< sal_Int32 >( 0 ); + dumpDecProperty< sal_Int32 >( 32767 ); + dumpDecProperty< sal_Int32 >( 0 ); + dumpHexProperty< sal_uInt32 >( 0 ); + dumpEnabledProperty(); + dumpEnabledProperty(); + dumpDecProperty< sal_Int32 >( 1 ); + dumpDecProperty< sal_Int32 >( 1 ); + dumpOrientationProperty(); + dumpDecProperty< sal_Int16 >( -1, "OCX-SCROLLBAR-PROPTHUMB" ); + dumpDelayProperty(); + dumpStreamProperty(); +} + +// ============================================================================ + +OcxSpinButtonObject::OcxSpinButtonObject( const InputObjectBase& rParent ) +{ + OcxPropertyObjectBase::construct( rParent, "OCX-SPINBUTTON-PROPERTIES" ); +} + +void OcxSpinButtonObject::implDumpShortProperties() +{ + dumpColorProperty( 0x80000012 ); + dumpColorProperty( 0x8000000F ); + dumpFlagsProperty( 0x0000001B ); + dumpSizeProperty(); + dumpHexProperty< sal_uInt32 >( 0 ); + dumpDecProperty< sal_Int32 >( 0 ); + dumpDecProperty< sal_Int32 >( 100 ); + dumpDecProperty< sal_Int32 >( 0 ); + dumpEnabledProperty(); + dumpEnabledProperty(); + dumpDecProperty< sal_Int32 >( 1 ); + dumpOrientationProperty(); + dumpDelayProperty(); + dumpStreamProperty(); + dumpMousePtrProperty(); +} + +// ============================================================================ + +OcxTabStripObject::OcxTabStripObject( const InputObjectBase& rParent ) +{ + OcxPropertyObjectBase::construct( rParent, "OCX-TABSTRIP-PROPERTIES" ); +} + +void OcxTabStripObject::implDumpShortProperties() +{ + dumpDecProperty< sal_Int32 >( -1 ); + dumpColorProperty( 0x8000000F ); + dumpColorProperty( 0x80000012 ); + dumpUnknownProperty(); + dumpSizeProperty(); + dumpStringArrayProperty(); + dumpMousePtrProperty(); + dumpUnknownProperty(); + dumpDecProperty< sal_uInt32 >( 0, "OCX-TABSTRIP-ORIENTATION" ); + dumpDecProperty< sal_uInt32 >( 0, "OCX-TABSTRIP-TABSTYLE" ); + dumpBoolProperty(); + dumpHmmProperty(); + dumpHmmProperty(); + dumpBoolProperty(); + dumpUnknownProperty(); + dumpStringArrayProperty(); + dumpUnknownProperty(); + dumpStringArrayProperty(); + dumpFlagsProperty( 0x0000001B ); + dumpBoolProperty(); + dumpDecProperty< sal_uInt32 >( 0 ); + dumpStringArrayProperty(); + mnTabFlagCount = dumpDecProperty< sal_Int32 >( 0 ); + dumpStringArrayProperty(); + dumpStreamProperty(); +} + +void OcxTabStripObject::implDumpExtended() +{ + dumpEmbeddedFont(); + if( mnTabFlagCount > 0 ) + { + writeEmptyItem( "tab-flags" ); + IndentGuard aIndGuard( out() ); + out().resetItemIndex(); + for( sal_Int32 nIdx = 0; ensureValid() && (nIdx < mnTabFlagCount); ++nIdx ) + dumpHex< sal_uInt32 >( "#flags", "OCX-TABSTRIP-FLAGS" ); + } +} + +// ============================================================================ + +OcxControlObject::OcxControlObject( const InputObjectBase& rParent, const OUString& rProgId, sal_Int64 nLength ) : + maProgId( rProgId ), + mnLength( nLength ) +{ + InputObjectBase::construct( rParent ); +} + +void OcxControlObject::implDump() +{ + sal_Int64 nEndPos = in().tell() + ::std::max< sal_Int64 >( mnLength, 0 ); + if( (maProgId.getLength() > 0) && (mnLength > 0) && !in().isEof() ) + { + if( maProgId.equalsAscii( "Forms.CommandButton.1" ) ) + OcxCommandButtonObject( *this ).dump(); + else if( maProgId.equalsAscii( "Forms.TextBox.1" ) || + maProgId.equalsAscii( "Forms.ListBox.1" ) || + maProgId.equalsAscii( "Forms.ComboBox.1" ) || + maProgId.equalsAscii( "Forms.CheckBox.1" ) || + maProgId.equalsAscii( "Forms.OptionButton.1" ) || + maProgId.equalsAscii( "Forms.ToggleButton.1" ) || + maProgId.equalsAscii( "RefEdit.Ctrl" ) ) + OcxMorphControlObject( *this ).dump(); + else if( maProgId.equalsAscii( "Forms.Label.1" ) ) + OcxLabelObject( *this ).dump(); + else if( maProgId.equalsAscii( "Forms.Image.1" ) ) + OcxImageObject( *this ).dump(); + else if( maProgId.equalsAscii( "Forms.ScrollBar.1" ) ) + OcxScrollBarObject( *this ).dump(); + else if( maProgId.equalsAscii( "Forms.SpinButton.1" ) ) + OcxSpinButtonObject( *this ).dump(); + else if( maProgId.equalsAscii( "Forms.TabStrip.1" ) ) + OcxTabStripObject( *this ).dump(); + } + dumpRemainingTo( nEndPos ); +} + +// ============================================================================ + +OcxGuidControlObject::OcxGuidControlObject( const InputObjectBase& rParent, sal_Int64 nLength ) : + mnLength( nLength ) +{ + InputObjectBase::construct( rParent ); +} + +void OcxGuidControlObject::implDump() +{ + OUString aProgId = cfg().getStringOption( dumpGuid(), OUString() ); + OcxControlObject( *this, aProgId, mnLength - 16 ).dump(); +} + +// ============================================================================ + +OcxControlsStreamObject::OcxControlsStreamObject( const ObjectBase& rParent, + const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName, OcxFormSharedData& rFormData ) : + mrFormData( rFormData ) +{ + InputObjectBase::construct( rParent, rxStrm, rSysFileName ); +} + +void OcxControlsStreamObject::implDump() +{ + for( OcxFormSiteInfoVector::iterator aIt = mrFormData.maSiteInfos.begin(), aEnd = mrFormData.maSiteInfos.end(); !in().isEof() && (aIt != aEnd); ++aIt ) + { + if( (aIt->mbInStream) && (aIt->mnLength > 0) ) + { + out().emptyLine(); + writeDecItem( "control-id", aIt->mnId ); + writeInfoItem( "prog-id", aIt->maProgId ); + IndentGuard aIndGuard( out() ); + OcxControlObject( *this, aIt->maProgId, aIt->mnLength ).dump(); + } + } + dumpRemainingStream(); +} + +// ============================================================================ +// ============================================================================ + +OcxPageObject::OcxPageObject( const InputObjectBase& rParent ) +{ + OcxPropertyObjectBase::construct( rParent, "OCX-PAGE-PROPERTIES" ); +} + +void OcxPageObject::implDumpShortProperties() +{ + dumpUnknownProperty(); + dumpDecProperty< sal_uInt32 >( 0, "OCX-PAGE-TRANSITIONEFFECT" ); + dumpDecProperty< sal_uInt32 >( 0, "OCX-CONV-MS" ); +} + +// ============================================================================ + +OcxMultiPageObject::OcxMultiPageObject( const InputObjectBase& rParent ) +{ + OcxPropertyObjectBase::construct( rParent, "OCX-MULTIPAGE-PROPERTIES" ); +} + +void OcxMultiPageObject::implDumpShortProperties() +{ + dumpUnknownProperty(); + mnPageCount = dumpDecProperty< sal_Int32 >( 0 ); + dumpDecProperty< sal_Int32 >( 0 ); + dumpBoolProperty(); +} + +void OcxMultiPageObject::implDumpExtended() +{ + if( ensureValid() && (mnPageCount > 0) ) + { + writeEmptyItem( "page-ids" ); + IndentGuard aIndGuard( out() ); + out().resetItemIndex(); + for( sal_Int32 nIdx = 0; ensureValid() && (nIdx < mnPageCount); ++nIdx ) + dumpDec< sal_Int32 >( "#id" ); + } +} + +// ============================================================================ + +OcxMultiPageStreamObject::OcxMultiPageStreamObject( const ObjectBase& rParent, + const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName, OcxFormSharedData& rFormData ) : + mrFormData( rFormData ) +{ + InputObjectBase::construct( rParent, rxStrm, rSysFileName ); +} + +void OcxMultiPageStreamObject::implDump() +{ + for( size_t nIdx = 0, nCount = mrFormData.maSiteInfos.size(); !in().isEof() && (nIdx < nCount); ++nIdx ) + { + out().emptyLine(); + writeEmptyItem( "page" ); + IndentGuard aIndGuard( out() ); + OcxPageObject( *this ).dump(); + } + if( !in().isEof() ) + { + out().emptyLine(); + writeEmptyItem( "multi-page" ); + IndentGuard aIndGuard( out() ); + OcxMultiPageObject( *this ).dump(); + } + dumpRemainingStream(); +} + +// ============================================================================ +// ============================================================================ + +OcxFormClassInfoObject::OcxFormClassInfoObject( const InputObjectBase& rParent, OcxFormSharedData& rFormData ) : + mrFormData( rFormData ) +{ + OcxPropertyObjectBase::construct( rParent, "OCX-CLASSINFO-PROPERTIES" ); +} + +void OcxFormClassInfoObject::implDumpShortProperties() +{ + mrFormData.maClassInfoProgIds.push_back( OUString() ); + dumpGuidProperty( &mrFormData.maClassInfoProgIds.back() ); + dumpGuidProperty(); + dumpUnknownProperty(); + dumpGuidProperty(); + dumpFlagsProperty( 0, "OCX-CLASSINFO-FLAGS" ); + dumpDecProperty< sal_Int32 >( -1 ); + dumpDecProperty< sal_uInt16 >( 0 ); + dumpDecProperty< sal_uInt16 >( 0 ); + dumpDecProperty< sal_uInt16 >( 0, "OLEPROP-TYPE" ); + dumpDecProperty< sal_uInt16 >( 0 ); + dumpDecProperty< sal_uInt16 >( 0 ); + dumpDecProperty< sal_uInt16 >( 0, "OLEPROP-TYPE" ); + dumpDecProperty< sal_Int32 >( -1 ); + dumpDecProperty< sal_uInt16 >( 0 ); +} + +// ============================================================================ + +namespace { + +const sal_uInt32 OCX_FORMSITE_OBJSTREAM = 0x0010; + +const sal_uInt16 OCX_FORMSITE_CLASSTABLEINDEX = 0x8000; +const sal_uInt16 OCX_FORMSITE_CLASSTABLEMASK = 0x7FFF; + +} // namespace + +// ---------------------------------------------------------------------------- + +OcxFormSiteObject::OcxFormSiteObject( const InputObjectBase& rParent, OcxFormSharedData& rFormData ) : + mrFormData( rFormData ) +{ + OcxPropertyObjectBase::construct( rParent, "OCX-FORMSITE-PROPERTIES" ); +} + +void OcxFormSiteObject::implDumpShortProperties() +{ + OcxFormSiteInfo aSiteInfo; + dumpStringProperty(); + dumpStringProperty(); + sal_Int32 nId = dumpDecProperty< sal_Int32 >( 0 ); + dumpDecProperty< sal_Int32 >( 0 ); + sal_uInt32 nFlags = dumpFlagsProperty( 0x00000033, "OCX-FORMSITE-FLAGS" ); + sal_uInt32 nLength = dumpDecProperty< sal_uInt32 >( 0 ); + dumpDecProperty< sal_Int16 >( -1 ); + sal_uInt16 nClassId = dumpHexProperty< sal_uInt16 >( 0x7FFF, "OCX-FORMSITE-CLASSIDCACHE" ); + dumpPosProperty(); + dumpDecProperty< sal_uInt16 >( 0 ); + dumpUnknownProperty(); + dumpStringProperty(); + dumpStringProperty(); + dumpStringProperty(); + dumpStringProperty(); + + sal_uInt16 nIndex = nClassId & OCX_FORMSITE_CLASSTABLEMASK; + if( getFlag( nClassId, OCX_FORMSITE_CLASSTABLEINDEX ) ) + { + if( nIndex < mrFormData.maClassInfoProgIds.size() ) + aSiteInfo.maProgId = mrFormData.maClassInfoProgIds[ nIndex ]; + } + else + { + if( cfg().hasName( "OCX-FORMSITE-CLASSNAMES", nIndex ) ) + aSiteInfo.maProgId = cfg().getName( "OCX-FORMSITE-CLASSNAMES", nIndex ); + } + aSiteInfo.mnId = nId; + aSiteInfo.mnLength = nLength; + aSiteInfo.mbInStream = getFlag( nFlags, OCX_FORMSITE_OBJSTREAM ); + + mrFormData.maSiteInfos.push_back( aSiteInfo ); +} + +// ============================================================================ + +OcxFormDesignExtObject::OcxFormDesignExtObject( const InputObjectBase& rParent ) +{ + OcxPropertyObjectBase::construct( rParent, "OCX-FORMDESIGNEXT-PROPERTIES" ); +} + +void OcxFormDesignExtObject::implDumpShortProperties() +{ + dumpFlagsProperty( 0x00015F55, "OCX-FORMDESIGNEXT-FLAGS" ); + dumpHmmProperty(); + dumpHmmProperty(); + dumpDecProperty< sal_Int8 >( 0, "OCX-FORMDESIGNEXT-CLICKCTRLMODE" ); + dumpDecProperty< sal_Int8 >( 0, "OCX-FORMDESIGNEXT-DBLCLICKCTRLMODE" ); +} + +// ============================================================================ + +namespace { + +const sal_uInt32 OCX_FORM_HASDESIGNEXTENDER = 0x00004000; +const sal_uInt32 OCX_FORM_SKIPCLASSTABLE = 0x00008000; + +const sal_uInt8 OCX_FORM_SITECOUNTTYPE_COUNT = 0x80; +const sal_uInt8 OCX_FORM_SITECOUNTTYPE_MASK = 0x7F; + +} // namespace + +// ---------------------------------------------------------------------------- + +OcxFormObject::OcxFormObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName, OcxFormSharedData& rFormData ) : + mrFormData( rFormData ) +{ + OcxPropertyObjectBase::construct( rParent, rxStrm, rSysFileName, "OCX-FORM-PROPERTIES" ); +} + +void OcxFormObject::implDumpShortProperties() +{ + dumpUnknownProperty(); + dumpColorProperty( 0x8000000F ); + dumpColorProperty( 0x80000012 ); + dumpDecProperty< sal_uInt32 >( 0 ); + dumpUnknownProperty(); + dumpUnknownProperty(); + mnFlags = dumpFlagsProperty( 0x00000004, "OCX-FORM-FLAGS" ); + dumpBorderStyleProperty< sal_uInt8 >( 0 ); + dumpMousePtrProperty(); + dumpHexProperty< sal_uInt8 >( 0x0C, "OCX-FORM-SCROLLBARS" ); + dumpSizeProperty(); + dumpSizeProperty(); + dumpPosProperty(); + dumpDecProperty< sal_uInt32 >( 0 ); + dumpUnknownProperty(); + dumpStreamProperty(); + dumpDecProperty< sal_uInt8 >( 0, "OCX-FORM-CYCLE" ); + dumpSpecialEffectProperty< sal_uInt8 >( 0 ); + dumpColorProperty( 0x80000012 ); + dumpStringProperty(); + dumpStreamProperty(); + dumpStreamProperty(); + dumpDecProperty< sal_Int32 >( 100, "CONV-PERCENT" ); + dumpImageAlignProperty(); + dumpBoolProperty(); + dumpImageSizeModeProperty(); + dumpDecProperty< sal_uInt32 >( 0 ); + dumpDecProperty< sal_uInt32 >( 0 ); +} + +void OcxFormObject::implDumpExtended() +{ + dumpClassInfos(); + dumpSiteData(); + dumpDesignExtender(); + dumpRemainingStream(); +} + +void OcxFormObject::dumpClassInfos() +{ + if( ensureValid() && !getFlag( mnFlags, OCX_FORM_SKIPCLASSTABLE ) ) + { + out().emptyLine(); + sal_uInt16 nCount = dumpDec< sal_uInt16 >( "class-info-count" ); + out().resetItemIndex(); + for( sal_uInt16 nIdx = 0; ensureValid() && (nIdx < nCount); ++nIdx ) + { + writeEmptyItem( "#class-info" ); + IndentGuard aIndGuard( out() ); + OcxFormClassInfoObject( *this, mrFormData ).dump(); + } + } +} + +void OcxFormObject::dumpFormSites( sal_uInt32 nCount ) +{ + out().resetItemIndex(); + for( sal_uInt32 nIdx = 0; ensureValid() && (nIdx < nCount); ++nIdx ) + { + out().emptyLine(); + writeEmptyItem( "#form-site" ); + IndentGuard aIndGuard( out() ); + OcxFormSiteObject( *this, mrFormData ).dump(); + } +} + +void OcxFormObject::dumpSiteData() +{ + if( ensureValid() ) + { + out().emptyLine(); + setAlignAnchor(); + sal_uInt32 nSiteCount = dumpDec< sal_uInt32 >( "site-count" ); + sal_uInt32 nSiteLength = dumpDec< sal_uInt32 >( "site-data-size" ); + sal_Int64 nEndPos = in().tell() + nSiteLength; + if( ensureValid( nEndPos <= in().getLength() ) ) + { + out().resetItemIndex(); + sal_uInt32 nSiteIdx = 0; + while( ensureValid() && (nSiteIdx < nSiteCount) ) + { + out().emptyLine(); + writeEmptyItem( "#site-info" ); + IndentGuard aIndGuard( out() ); + dumpDec< sal_uInt8 >( "depth" ); + sal_uInt8 nTypeCount = dumpHex< sal_uInt8 >( "type-count", "OCX-FORM-SITE-TYPECOUNT" ); + if( getFlag( nTypeCount, OCX_FORM_SITECOUNTTYPE_COUNT ) ) + { + dumpDec< sal_uInt8 >( "repeated-type" ); + nSiteIdx += (nTypeCount & OCX_FORM_SITECOUNTTYPE_MASK); + } + else + { + ++nSiteIdx; + } + } + alignInput< sal_uInt32 >(); + dumpFormSites( nSiteCount ); + dumpToPosition( nEndPos ); + } + } +} + +void OcxFormObject::dumpDesignExtender() +{ + if( ensureValid() && getFlag( mnFlags, OCX_FORM_HASDESIGNEXTENDER ) ) + { + out().emptyLine(); + writeEmptyItem( "design-extender" ); + IndentGuard aIndGuard( out() ); + OcxFormDesignExtObject( *this ).dump(); + } +} + +// ============================================================================ + +OcxFormStorageObject::OcxFormStorageObject( const ObjectBase& rParent, const StorageRef& rxStrg, const OUString& rSysPath ) : + OleStorageObject( rParent, rxStrg, rSysPath ) +{ + addPreferredStream( "f" ); +} + +void OcxFormStorageObject::implDumpStream( const BinaryInputStreamRef& rxStrm, const OUString& rStrgPath, const OUString& rStrmName, const OUString& rSysFileName ) +{ + if( rStrmName.equalsAscii( "f" ) ) + OcxFormObject( *this, rxStrm, rSysFileName, maFormData ).dump(); + else if( rStrmName.equalsAscii( "o" ) ) + OcxControlsStreamObject( *this, rxStrm, rSysFileName, maFormData ).dump(); + else if( rStrmName.equalsAscii( "x" ) ) + OcxMultiPageStreamObject( *this, rxStrm, rSysFileName, maFormData ).dump(); + else + OleStorageObject::implDumpStream( rxStrm, rStrgPath, rStrmName, rSysFileName ); +} + +void OcxFormStorageObject::implDumpStorage( const StorageRef& rxStrg, const OUString& rStrgPath, const OUString& rSysPath ) +{ + if( isFormStorage( rStrgPath ) ) + OcxFormStorageObject( *this, rxStrg, rSysPath ).dump(); + else + OleStorageObject( *this, rxStrg, rSysPath ).dump(); +} + +bool OcxFormStorageObject::isFormStorage( const OUString& rStrgPath ) const +{ + if( (rStrgPath.getLength() >= 3) && (rStrgPath[ 0 ] == 'i') ) + { + OUString aId = rStrgPath.copy( 1 ); + if( (aId.getLength() == 2) && (aId[ 0 ] == '0') ) + aId = aId.copy( 1 ); + sal_Int32 nId = aId.toInt32(); + if( (nId > 0) && (OUString::valueOf( nId ) == aId) ) + for( OcxFormSiteInfoVector::const_iterator aIt = maFormData.maSiteInfos.begin(), aEnd = maFormData.maSiteInfos.end(); aIt != aEnd; ++aIt ) + if( aIt->mnId == nId ) + return true; + } + return false; +} + +// ============================================================================ +// ============================================================================ + +VbaSharedData::VbaSharedData() : + meTextEnc( osl_getThreadTextEncoding() ) +{ +} + +bool VbaSharedData::isModuleStream( const ::rtl::OUString& rStrmName ) const +{ + return maStrmOffsets.count( rStrmName ) > 0; +} + +sal_Int32 VbaSharedData::getStreamOffset( const OUString& rStrmName ) const +{ + StreamOffsetMap::const_iterator aIt = maStrmOffsets.find( rStrmName ); + return (aIt == maStrmOffsets.end()) ? 0 : aIt->second; +} + +// ============================================================================ + +VbaDirStreamObject::VbaDirStreamObject( const ObjectBase& rParent, + const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName, VbaSharedData& rVbaData ) : + mrVbaData( rVbaData ) +{ + mxInStrm = rxStrm; + if( mxInStrm.get() ) + { + BinaryInputStreamRef xVbaStrm( new ::oox::ole::VbaInputStream( *mxInStrm ) ); + SequenceRecordObjectBase::construct( rParent, xVbaStrm, rSysFileName, "VBA-DIR-RECORD-NAMES", "VBA-DIR-SIMPLE-RECORDS" ); + } +} + +bool VbaDirStreamObject::implIsValid() const +{ + return mxInStrm.get() && SequenceRecordObjectBase::implIsValid(); +} + +bool VbaDirStreamObject::implReadRecordHeader( BinaryInputStream& rBaseStrm, sal_Int64& ornRecId, sal_Int64& ornRecSize ) +{ + ornRecId = rBaseStrm.readuInt16(); + ornRecSize = rBaseStrm.readInt32(); + + // for no obvious reason, PROJECTVERSION record contains size field of 4, but is 6 bytes long + if( ornRecId == 9 ) + ornRecSize = 6; + + return !rBaseStrm.isEof(); +} + +void VbaDirStreamObject::implDumpRecordBody() +{ + switch( getRecId() ) + { + case 0x0003: + mrVbaData.meTextEnc = ::oox::xls::BiffHelper::calcTextEncodingFromCodePage( dumpDec< sal_uInt16 >( "codepage", "CODEPAGES" ) ); + break; + case 0x0004: + dumpByteString( "name" ); + break; + case 0x0005: + dumpByteString( "description" ); + break; + case 0x0006: + dumpByteString( "helpfile-path" ); + break; + case 0x0009: + dumpDec< sal_uInt32 >( "major" ); + dumpDec< sal_uInt16 >( "minor" ); + break; + case 0x000C: + dumpByteString( "constants" ); + break; + case 0x000D: + dumpByteStringWithLength( "lib-id" ); + dumpUnused( 6 ); + break; + case 0x000E: + dumpByteStringWithLength( "lib-id-absolute" ); + dumpByteStringWithLength( "lib-id-relative" ); + dumpDec< sal_uInt32 >( "major" ); + dumpDec< sal_uInt16 >( "minor" ); + break; + case 0x0016: + dumpByteString( "name" ); + break; + case 0x0019: + dumpByteString( "name" ); + maCurrStream = OUString(); + mnCurrOffset = 0; + break; + case 0x001A: + maCurrStream = dumpByteString( "stream-name" ); + break; + case 0x001C: + dumpByteString( "description" ); + break; + case 0x002B: + if( maCurrStream.getLength() > 0 ) + mrVbaData.maStrmOffsets[ maCurrStream ] = mnCurrOffset; + maCurrStream = OUString(); + mnCurrOffset = 0; + break; + case 0x002F: + dumpByteStringWithLength( "lib-id-twiddled" ); + dumpUnused( 6 ); + break; + case 0x0030: + dumpByteStringWithLength( "lib-id-extended" ); + dumpUnused( 6 ); + dumpGuid( "original-typelib" ); + dumpDec< sal_uInt32 >( "cookie" ); + break; + case 0x0031: + mnCurrOffset = dumpHex< sal_Int32 >( "stream-offset", "CONV-DEC" ); + break; + case 0x0032: + dumpUniString( "stream-name" ); + break; + case 0x0033: + dumpByteString( "lib-id-original" ); + break; + case 0x003C: + dumpUniString( "constants" ); + break; + case 0x003D: + dumpUniString( "helpfile-path" ); + break; + case 0x003E: + dumpUniString( "name" ); + break; + case 0x0040: + dumpUniString( "description" ); + break; + case 0x0047: + dumpUniString( "name" ); + break; + case 0x0048: + dumpUniString( "description" ); + break; + } +} + +OUString VbaDirStreamObject::dumpByteString( const String& rName ) +{ + return dumpCharArray( rName, static_cast< sal_Int32 >( getRecSize() ), mrVbaData.meTextEnc ); +} + +OUString VbaDirStreamObject::dumpUniString( const String& rName ) +{ + return dumpUnicodeArray( rName, static_cast< sal_Int32 >( getRecSize() / 2 ) ); +} + +OUString VbaDirStreamObject::dumpByteStringWithLength( const String& rName ) +{ + return dumpCharArray( rName, in().readInt32(), mrVbaData.meTextEnc ); +} + +// ============================================================================ + +VbaModuleStreamObject::VbaModuleStreamObject( + const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, + const OUString& rSysFileName, VbaSharedData& rVbaData, sal_Int32 nStrmOffset ) : + mrVbaData( rVbaData ), + mnStrmOffset( nStrmOffset ) +{ + InputObjectBase::construct( rParent, rxStrm, rSysFileName ); +} + +void VbaModuleStreamObject::implDump() +{ + dumpBinary( "perf-cache", mnStrmOffset ); + out().emptyLine(); + writeEmptyItem( "source-code" ); + IndentGuard aIndGuard( out() ); + BinaryInputStreamRef xVbaStrm( new ::oox::ole::VbaInputStream( in() ) ); + TextStreamObject( *this, xVbaStrm, mrVbaData.meTextEnc ).dump(); +} + +// ============================================================================ + +VbaStorageObject::VbaStorageObject( const ObjectBase& rParent, const StorageRef& rxStrg, const OUString& rSysPath, VbaSharedData& rVbaData ) : + OleStorageObject( rParent, rxStrg, rSysPath ), + mrVbaData( rVbaData ) +{ + addPreferredStream( "dir" ); +} + +void VbaStorageObject::implDumpStream( const BinaryInputStreamRef& rxStrm, const OUString& rStrgPath, const OUString& rStrmName, const OUString& rSysFileName ) +{ + if( (rStrgPath.getLength() == 0) && rStrmName.equalsAscii( "dir" ) ) + VbaDirStreamObject( *this, rxStrm, rSysFileName, mrVbaData ).dump(); + else if( mrVbaData.isModuleStream( rStrmName ) ) + VbaModuleStreamObject( *this, rxStrm, rSysFileName, mrVbaData, mrVbaData.getStreamOffset( rStrmName ) ).dump(); + else + OleStorageObject::implDumpStream( rxStrm, rStrgPath, rStrmName, rSysFileName ); +} + +// ============================================================================ + +VbaFormStorageObject::VbaFormStorageObject( const ObjectBase& rParent, const StorageRef& rxStrg, const OUString& rSysPath, VbaSharedData& rVbaData ) : + OcxFormStorageObject( rParent, rxStrg, rSysPath ), + mrVbaData( rVbaData ) +{ +} + +void VbaFormStorageObject::implDumpStream( const BinaryInputStreamRef& rxStrm, const OUString& rStrgPath, const OUString& rStrmName, const OUString& rSysFileName ) +{ + if( rStrmName.equalsAscii( "\003VBFrame" ) ) + TextStreamObject( *this, rxStrm, mrVbaData.meTextEnc, rSysFileName ).dump(); + else + OcxFormStorageObject::implDumpStream( rxStrm, rStrgPath, rStrmName, rSysFileName ); +} + +// ============================================================================ + +VbaProjectStorageObject::VbaProjectStorageObject( const ObjectBase& rParent, const StorageRef& rxStrg, const OUString& rSysPath ) : + OleStorageObject( rParent, rxStrg, rSysPath ) +{ + addPreferredStorage( "VBA" ); +} + +void VbaProjectStorageObject::implDumpStream( const BinaryInputStreamRef& rxStrm, const OUString& rStrgPath, const OUString& rStrmName, const OUString& rSysFileName ) +{ + if( (rStrgPath.getLength() == 0) && rStrmName.equalsAscii( "PROJECT" ) ) + TextStreamObject( *this, rxStrm, maVbaData.meTextEnc, rSysFileName ).dump(); + else + OleStorageObject::implDumpStream( rxStrm, rStrgPath, rStrmName, rSysFileName ); +} + +void VbaProjectStorageObject::implDumpStorage( const StorageRef& rxStrg, const OUString& rStrgPath, const OUString& rSysPath ) +{ + if( rStrgPath.equalsAscii( "VBA" ) ) + VbaStorageObject( *this, rxStrg, rSysPath, maVbaData ).dump(); + else + VbaFormStorageObject( *this, rxStrg, rSysPath, maVbaData ).dump(); +} + +// ============================================================================ +// ============================================================================ + +} // namespace dump +} // namespace oox + +#endif + diff --git a/oox/source/dump/oledumper.ini b/oox/source/dump/oledumper.ini new file mode 100644 index 000000000000..fe38d201c329 --- /dev/null +++ b/oox/source/dump/oledumper.ini @@ -0,0 +1,689 @@ + +# dumper settings ============================================================ + +# Path to additional configuration data, relative to this file. +include-config-file=dumperbase.ini + +# StdFont ==================================================================== + +{0BE35203-8F91-11CE-9DE3-00AA004BB851}=StdFont + +flagslist=STDFONT-FLAGS + 0x01=bold + 0x02=italic + 0x04=underline + 0x08=strikeout +end + +unitconverter=STDFONT-HEIGHT,/10000,pt + +# StdPic ===================================================================== + +{0BE35204-8F91-11CE-9DE3-00AA004BB851}=StdPic + +# StdHlink =================================================================== + +{79EAC9D0-BAF9-11CE-8C82-00AA004BA90B}=StdHlink +{79EAC9E0-BAF9-11CE-8C82-00AA004BA90B}=URLMoniker +{00000303-0000-0000-C000-000000000046}=FileMoniker +{00000304-0000-0000-C000-000000000046}=ItemMoniker +{00000305-0000-0000-C000-000000000046}=AntiMoniker +{00000309-0000-0000-C000-000000000046}=CompositeMoniker + +flagslist=STDHLINK-FLAGS + 0x00000001=has-target + 0x00000002=!relative!absolute + 0x00000004=display-specified + 0x00000008=has-location + 0x00000010=has-display + 0x00000020=has-guid + 0x00000040=has-creation-time + 0x00000080=has-frame + 0x00000100=!as-guid!as-string + 0x00000200=has-abs-from-rel +end + +flagslist=STDHLINK-URL-FLAGS + 0x00000001=allow-relative + 0x00000002=wildcard-scheme + 0x00000004=implicit-file-scheme + 0x00000008=no-fragment + 0x00000010=no-canonicalize + 0x00000020=canonicalize + 0x00000040=dos-path + 0x00000080=decode-extra-info + 0x00000100=no-decode-extra-info + 0x00000200=crack-unknown-schemes + 0x00000400=no-crack-unknown-schemes + 0x00000800=preprocess-html + 0x00001000=no-preprocess-html + 0x00002000=registry-settings + 0x00004000=no-registry-settings + 0x00008000=no-encode-forbidden-chars +end + +# OLE name lists ============================================================= + +{F29F85E0-4FF9-1068-AB91-08002B27B3D9}=GlobalDocProp +{D5CDD502-2E9C-101B-9397-08002B2CF9AE}=BuiltinDocProp +{D5CDD505-2E9C-101B-9397-08002B2CF9AE}=CustomDocProp + +constlist=OLEPROP-BYTE-ORDER + 0xFEFF=big-endian + 0xFFFE=little-endian +end + +shortlist=OLEPROP-OSTYPE,0,dos,mac,win32,unix + +multilist=OLEPROP-BASEIDS + quote-names=1 + default= + 0=dictionary,codepage +end + +multilist=OLEPROP-GLOBALIDS + include=OLEPROP-BASEIDS + 2=title,subject,author,keywords,comments,template,last-author,rev-number + 10=edit-time,last-printed,create-time,last-saved,page-count,word-count,char-count,thumbnail,appname,security +end + +multilist=OLEPROP-BUILTINIDS + include=OLEPROP-BASEIDS + 2=category,pres-target,byte-count,line-count,para-count,slide-count,note-count,hidden-slide-count + 10=clips,scale-crop,heading-pairs,part-titles,manager,company,links-uptodate +end + +multilist=OLEPROP-TYPE-SIMPLE + 0=empty,null,int16,int32,float,double,currency,date,string8,dispatch + 10=error,bool,variant,unknown,decimal,int8,uint8,uint16,uint32 + 20=int64,uint64,int,uint,void,hresult,ptr,savearray,c-array,userdef + 30=string8,string16,,,,,record,intptr,uintptr + 64=time-stamp,blob,stream,storage,stream-obj,storage-obj + 70=blob-obj,clip-fmt,guid,vers-stream + 0x0FFF=str8-blob +end + +combilist=OLEPROP-TYPE + 0x0FFF=int32,dec,base-type,OLEPROP-TYPE-SIMPLE + 0x1000=vector + 0x2000=array + 0x4000=byref +end + +# OCX name lists ============================================================= + +{0713E8D2-850A-101B-AFC0-4210102A8DA7}=COMCTL.ProgCtrl.1 + +combilist=OCX-COLOR + 0xFF000000=uint8,dec,type,OCX-COLORTYPE + 0x00FFFFFF=uint32,hex,value +end + +constlist=OCX-COLORTYPE + 0x00=default + 0x01=palette + 0x02=rgb + 0x80=system-color +end + +multilist=OCX-SYSTEMCOLOR + 0x00=scrollbar,desktop,active-title,inactive-title,menubar,window-back,window-frame,menu-text + 0x08=window-text,active-title-text,active-border,inactive-border,app-workspace,highlight,highlight-text,button-face + 0x10=button-shadow,disabled-text,button-text,inactive-title-text,button-highlight,button-dark-shadow,button-light-shadow,tooltip-text + 0x18=tooltip-back +end + +combilist=OCX-STRINGLEN + 0x80000000=!unicode!compressed + 0x7FFFFFFF=int32,dec,buffer-size +end + +combilist=OCX-ARRAYSTRINGLEN + 0x80000000=!unicode!compressed + 0x7FFFFFFF=int32,dec,len +end + +combilist=OCX-FLAGS + 0x00000001=reserved-1 + 0x00000002=enabled + 0x00000004=locked + 0x00000008=opaque + 0x00000010=reserved-2 + 0x00000400=column-heads + 0x00000800=entire-rows + 0x00001000=existing-entries-only + 0x00002000=caption-left + 0x00004000=editable + 0x00078000=uint8,dec,ime-mode,OCX-IMEMODE + 0x00080000=drag-enabled + 0x00100000=enter-as-newline + 0x00200000=keep-selection + 0x00400000=tab-as-character + 0x00800000=word-wrap + 0x02000000=borders-suppressed + 0x04000000=select-line + 0x08000000=single-char-select + 0x10000000=auto-size + 0x20000000=hide-selection + 0x40000000=maxlength-autotab + 0x80000000=multi-line +end + +multilist=OCX-IMEMODE + 0=no-control,on,off,disabled + 4=hiragana,fillwidth-katakana,halfwidth-katakana + 7=fullwidth-alpha,halfwidth-alpha + 9=fullwidth-hangul,halfwidth-hangul + 11=fullwidth-hanzi,halfwidth-hanzi +end + +multilist=OCX-MOUSEPTR + 0=default,arrow,cross,i-beam + 6=size-diag-down,size-vert,size-diag-up,size-hor + 10=up-arrow,hour-glass,no-drop,app-starting,help,size-all + 99=custom +end + +combilist=OCX-IMAGEPOS + 0x0000FFFF=uint16,dec,image,OCX-POS + 0xFFFF0000=uint16,dec,label,OCX-POS +end + +unitconverter=OCX-CONV-MS,1,ms + +shortlist=OCX-ENABLED,0,disabled,enabled +shortlist=OCX-BORDERSTYLE,0,none,single +shortlist=OCX-SPECIALEFFECT,0,flat,raised,sunken,etched,,,bump +shortlist=OCX-ORIENTATION,-1,auto,vertical,horizontal +shortlist=OCX-POS,0,top-left,top,top-right,left,center,right,bottom-left,bottom,bottom-right +shortlist=OCX-IMAGEALIGN,0,lop-left,top-right,center,bottom-left,bottom-right +shortlist=OCX-IMAGESIZEMODE,0,clip,stretch,,stretch-ratio + +# CFontNew ------------------------------------------------------------------- + +{AFC20920-DA4E-11CE-B94300AA006887B4}=CFontNew + +flagslist=OCX-CFONTNEW-PROPERTIES + 0x0001=font-name + 0x0002=flags + 0x0004=font-size + 0x0008=font-offset + 0x0010=charset + 0x0020=pitch-family + 0x0040=alignment + 0x0080=font-weight +end + +flagslist=OCX-CFONTNEW-FLAGS + 0x0001=bold + 0x0002=italic + 0x0004=underline + 0x0008=strikeout + 0x2000=sunken +end + +shortlist=OCX-CFONTNEW-ALIGNMENT,1,left,right,center + +# column info ---------------------------------------------------------------- + +flagslist=OCX-COLUMNINFO-PROPERTIES + 0x00000001=column-width +end + +# command button ------------------------------------------------------------- + +{D7053240-CE69-11CD-A777-00DD01143C57}=Forms.CommandButton.1 + +flagslist=OCX-COMMANDBUTTON-PROPERTIES + 0x00000001=text-color + 0x00000002=fill-color + 0x00000004=flags + 0x00000008=caption + 0x00000010=image-pos + 0x00000020=size + 0x00000040=mouse-ptr + 0x00000080=image + 0x00000100=accelerator + 0x00000200=no-take-focus + 0x00000400=mouse-icon +end + +# toggle button, check box, option button, text box, list box, combo box ----- + +{8BD21D10-EC42-11CE-9E0D-00AA006002F3}=Forms.TextBox.1 +{8BD21D20-EC42-11CE-9E0D-00AA006002F3}=Forms.ListBox.1 +{8BD21D30-EC42-11CE-9E0D-00AA006002F3}=Forms.ComboBox.1 +{8BD21D40-EC42-11CE-9E0D-00AA006002F3}=Forms.CheckBox.1 +{8BD21D50-EC42-11CE-9E0D-00AA006002F3}=Forms.OptionButton.1 +{8BD21D60-EC42-11CE-9E0D-00AA006002F3}=Forms.ToggleButton.1 +{00024512-0000-0000-C000-000000000046}=RefEdit.Ctrl + +flagslist=OCX-MORPH-PROPERTIES + 0x0000000000000001=flags + 0x0000000000000002=fill-color + 0x0000000000000004=text-color + 0x0000000000000008=max-length + 0x0000000000000010=border-style + 0x0000000000000020=scrollbars + 0x0000000000000040=control-type + 0x0000000000000080=mouse-ptr + 0x0000000000000100=size + 0x0000000000000200=password-char + 0x0000000000000400=list-width + 0x0000000000000800=bound-column + 0x0000000000001000=text-column + 0x0000000000002000=column-count + 0x0000000000004000=list-rowcount + 0x0000000000008000=column-info-count + 0x0000000000010000=match-entry-mode + 0x0000000000020000=list-style + 0x0000000000040000=show-dropdown-mode + 0x0000000000100000=dropdown-style + 0x0000000000200000=selection-type + 0x0000000000400000=value + 0x0000000000800000=caption + 0x0000000001000000=image-pos + 0x0000000002000000=border-color + 0x0000000004000000=special-effect + 0x0000000008000000=mouse-icon + 0x0000000010000000=image + 0x0000000020000000=accelerator + 0x0000000080000000=reserved + 0x0000000100000000=groupname +end + +shortlist=OCX-MORPH-SCROLLBARS,0,none,horizontal,vertical,both +shortlist=OCX-MORPH-CONTROLTYPE,1,edit,listbox,combobox,checkbox,optionbutton,togglebutton,dropdown-listbox +shortlist=OCX-MORPH-MATCHENTRYTYPE,0,first-letter,complete,none +shortlist=OCX-MORPH-LISTSTYLE,0,plain,with-buttons +shortlist=OCX-MORPH-SHOWDROPDOWNMODE,0,never,on-focus,always +shortlist=OCX-MORPH-DROPDOWNSTYLE,0,no-symbol,arrow,ellipsis,underline +shortlist=OCX-MORPH-SELECTIONTYPE,0,single,multi,range + +constlist=OCX-MORPH-BOUNDCOLUMN + default= + 0=value-is-row-index +end + +constlist=OCX-MORPH-TEXTCOLUMN + default= + -1=first-column-with-width + 0=row-numbers +end + +constlist=OCX-MORPH-COLUMNCOUNT + default= + -1=all-columns +end + +# label ---------------------------------------------------------------------- + +{978C9E23-D4B0-11CE-BF2D-00AA003F40D0}=Forms.Label.1 + +flagslist=OCX-LABEL-PROPERTIES + 0x00000001=text-color + 0x00000002=fill-color + 0x00000004=flags + 0x00000008=caption + 0x00000010=image-pos + 0x00000020=size + 0x00000040=mouse-ptr + 0x00000080=border-color + 0x00000100=border-style + 0x00000200=special-effect + 0x00000400=image + 0x00000800=accelerator + 0x00001000=mouse-icon +end + +# image ---------------------------------------------------------------------- + +{4C599241-6926-101B-9992-00000B65C6F9}=Forms.Image.1 + +flagslist=OCX-IMAGE-PROPERTIES + 0x00000004=auto-size + 0x00000008=border-color + 0x00000010=fill-color + 0x00000020=border-style + 0x00000040=mouse-ptr + 0x00000080=image-size-mode + 0x00000100=special-effect + 0x00000200=size + 0x00000400=image + 0x00000800=image-align + 0x00001000=image-tiling + 0x00002000=flags + 0x00004000=mouse-icon +end + +# scroll bar ----------------------------------------------------------------- + +{DFD181E0-5E2F-11CE-A449-00AA004A803D}=Forms.ScrollBar.1 + +flagslist=OCX-SCROLLBAR-PROPERTIES + 0x00000001=arrow-color + 0x00000002=fill-color + 0x00000004=flags + 0x00000008=size + 0x00000010=mouse-ptr + 0x00000020=min + 0x00000040=max + 0x00000080=value + 0x00000100=unused + 0x00000200=prev-enabled + 0x00000400=next-enabled + 0x00000800=step + 0x00001000=page-step + 0x00002000=orientation + 0x00004000=prop-thumb + 0x00008000=delay + 0x00010000=mouse-icon +end + +shortlist=OCX-SCROLLBAR-PROPTHUMB,-1,proportional,fixed + +# spin button ---------------------------------------------------------------- + +{79176FB0-B7F2-11CE-97EF-00AA006D2776}=Forms.SpinButton.1 + +flagslist=OCX-SPINBUTTON-PROPERTIES + 0x00000001=arrow-color + 0x00000002=fill-color + 0x00000004=flags + 0x00000008=size + 0x00000010=unused + 0x00000020=min + 0x00000040=max + 0x00000080=value + 0x00000100=prev-enabled + 0x00000200=next-enabled + 0x00000400=step + 0x00000800=orientation + 0x00001000=delay + 0x00002000=mouse-icon + 0x00004000=mouse-ptr +end + +# tab strip ------------------------------------------------------------------ + +{EAE50EB0-4A62-11CE-BED6-00AA00611080}=Forms.TabStrip.1 + +flagslist=OCX-TABSTRIP-PROPERTIES + 0x00000001=selected-tab + 0x00000002=fill-color + 0x00000004=text-color + 0x00000010=size + 0x00000020=tab-captions + 0x00000040=mouse-ptr + 0x00000100=tab-orientation + 0x00000200=tab-style + 0x00000400=multi-row + 0x00000800=tab-fixed-width + 0x00001000=tab-fixed-height + 0x00002000=tooltips + 0x00008000=tooltip-strings + 0x00020000=tab-names + 0x00040000=flags + 0x00080000=new-version + 0x00100000=tabs-allocated + 0x00200000=tags + 0x00400000=tab-flag-count + 0x00800000=accelerators + 0x01000000=mouse-icon +end + +shortlist=OCX-TABSTRIP-ORIENTATION,0,top,bottom,left,right +shortlist=OCX-TABSTRIP-TABSTYLE,0,tabs,buttons,none + +flagslist=OCX-TABSTRIP-FLAGS + 0x00000001=visible + 0x00000002=enabled +end + +# frame ---------------------------------------------------------------------- + +{6E182020-F460-11CE-9BCD-00AA00608E01}=Forms.Frame.1 + +# page ----------------------------------------------------------------------- + +flagslist=OCX-PAGE-PROPERTIES + 0x00000002=transition-effect + 0x00000004=transition-period +end + +shortlist=OCX-PAGE-TRANSITIONEFFECT,0,none,cover-up,cover-right-up,cover-right,cover-right-down,cover-down,cover-left-down,cover-left,cover-left-up,push-up,push-right,push-down,push-left + +# multi page ----------------------------------------------------------------- + +{46E31370-3F7A-11CE-BED6-00AA00611080}=Forms.MultiPage.1 + +flagslist=OCX-MULTIPAGE-PROPERTIES + 0x00000002=page-count + 0x00000004=id + 0x00000008=enabled +end + +# form class info ------------------------------------------------------------ + +flagslist=OCX-CLASSINFO-PROPERTIES + 0x00000001=class-id + 0x00000002=disp-event + 0x00000008=default-prog + 0x00000010=class-flags + 0x00000020=method-count + 0x00000040=dispatch-id-bind + 0x00000080=get-bind-index + 0x00000100=put-bind-index + 0x00000200=bind-type + 0x00000400=get-value-index + 0x00000800=put-value-index + 0x00001000=value-type + 0x00002000=dispatch-id-rowset + 0x00004000=set-rowset +end + +combilist=OCX-CLASSINFO-FLAGS + 0x0000FFFF=uint16,hex,classtable-flags,OCX-CLASSTABLE-CLASSFLAGS + 0xFFFF0000=uint16,hex,var-flags,OCX-CLASSTABLE-VARFLAGS +end + +flagslist=OCX-CLASSTABLE-CLASSFLAGS + 0x0001=exclusive-value + 0x0002=dual-interface + 0x0004=no-aggregation +end + +flagslist=OCX-CLASSTABLE-VARFLAGS + 0x0001=read-only + 0x0002=source + 0x0004=bindable + 0x0008=request-edit + 0x0010=display-bind + 0x0020=default-bind + 0x0040=hidden + 0x0080=restricted + 0x0100=default-coll-elem + 0x0200=ui-default + 0x0400=non-browsable + 0x0800=replaceable + 0x1000=immediate-bind +end + +# form site ------------------------------------------------------------------ + +flagslist=OCX-FORMSITE-PROPERTIES + 0x00000001=name + 0x00000002=tag + 0x00000004=id + 0x00000008=help-context-id + 0x00000010=flags + 0x00000020=stream-size + 0x00000040=tab-index + 0x00000080=class-id-cache-index + 0x00000100=pos + 0x00000200=group-id + 0x00000800=tool-tip + 0x00001000=licence-key + 0x00002000=control-source + 0x00004000=row-source +end + +flagslist=OCX-FORMSITE-FLAGS + 0x00000001=tabstop + 0x00000002=visible + 0x00000004=default + 0x00000008=cancel + 0x00000010=!storage!obj-stream + 0x00000020=auto-size + 0x00000100=preserve-height + 0x00000200=fit-to-parent + 0x00002000=select-child + 0x00040000=container +end + +combilist=OCX-FORMSITE-CLASSIDCACHE + 0x7FFF=uint16,dec,cache-idx,OCX-FORMSITE-CLASSIDCACHEINDEX + 0x8000=!predefined-class-id!class-table-index +end + +constlist=OCX-FORMSITE-CLASSIDCACHEINDEX + default= + 0x7FFF=invalid +end + +constlist=OCX-FORMSITE-CLASSNAMES + 7=Forms.Form.1 + 12=Forms.Image.1 + 14=Forms.Frame.1 + 15=Internal.MorphData + 16=Forms.SpinButton.1 + 17=Forms.CommandButton.1 + 18=Forms.TabStrip.1 + 21=Forms.Label.1 + 23=Forms.TextBox.1 + 24=Forms.ListBox.1 + 25=Forms.ComboBox.1 + 26=Forms.CheckBox.1 + 27=Forms.OptionButton.1 + 28=Forms.ToggleButton.1 + 47=Forms.ScrollBar.1 + 57=Forms.MultiPage.1 +end + +# form design extender ------------------------------------------------------ + +flagslist=OCX-FORMDESIGNEXT-PROPERTIES + 0x00000001=flags + 0x00000002=grid-x + 0x00000004=grid-y + 0x00000008=click-control-mode + 0x00000010=dblclick-control-mode +end + +flagslist=OCX-FORMDESIGNEXT-FLAGS + 0x00000001=inherit-design-mode + 0x00000002=design-mode + 0x00000004=inherit-show-toolbox + 0x00000008=show-toolbox + 0x00000010=inherit-show-grid + 0x00000020=show-grid + 0x00000040=inherit-snap-to-grid + 0x00000080=snap-to-grid + 0x00000100=inherit-grid-x + 0x00000200=inherit-grid-y + 0x00000400=inherit-click-control-mode + 0x00000800=inherit-dblclick-control-mode + 0x00001000=inherit-show-invisible + 0x00002000=show-invisible + 0x00004000=inherit-show-tooltips + 0x00008000=show-tooltips + 0x00010000=inherit-immediate-layout + 0x00020000=immediate-layout +end + +shortlist=OCX-FORMDESIGNEXT-CLICKCTRLMODE,-2,inherit,default,insertion-point,select-then-insert +shortlist=OCX-FORMDESIGNEXT-DBLCLICKCTRLMODE,-2,inherit,,select-text,edit-code,edit-properties + +# form ----------------------------------------------------------------------- + +{C62A69F0-16DC-11CE-9E98-00AA00574A4F}=Forms.Form.1 + +flagslist=OCX-FORM-PROPERTIES + 0x00000002=fill-color + 0x00000004=text-color + 0x00000008=next-available-id + 0x00000040=flags + 0x00000080=border-style + 0x00000100=mouse-ptr + 0x00000200=scrollbars + 0x00000400=display-size + 0x00000800=logical-size + 0x00001000=scroll-pos + 0x00002000=group-count + 0x00008000=mouse-icon + 0x00010000=cycle + 0x00020000=special-effect + 0x00040000=border-color + 0x00080000=caption + 0x00100000=font + 0x00200000=image + 0x00400000=zoom + 0x00800000=image-align + 0x01000000=image-tiling + 0x02000000=image-sizemode + 0x04000000=shape-cookie + 0x08000000=draw-buffer +end + +flagslist=OCX-FORM-FLAGS + 0x00000004=enabled + 0x00004000=has-design-extender + 0x00008000=!has-class-table!skip-class-table +end + +flagslist=OCX-FORM-SCROLLBARS + 0x01=horizontal + 0x02=vertical + 0x04=keep-horizontal + 0x08=keep-vertical + 0x10=vertical-left +end + +shortlist=OCX-FORM-CYCLE,0,all-forms,,current-form + +combilist=OCX-FORM-SITE-TYPECOUNT + 0x7F=uint8,dec,type-count + 0x80=!type!count +end + +# VBA name lists ============================================================= + +multilist=VBA-DIR-RECORD-NAMES + 0x0000=,PROJECTSYSKIND,PROJECTLCID,PROJECTCODEPAGE,PROJECTNAME,PROJECTDOCSTRING,PROJECTHELPFILEPATH,PROJECTHELPCONTEXT + 0x0008=PROJECTLIBFLAGS,PROJECTVERSION,,,PROJECTCONSTANTS,REFERENCEREGISTERED,REFERENCEPROJECT,PROJECTMODULES + 0x0010=PROJECTEND,,,PROJECTCOOKIE,PROJECTLCIDINVOKE,,REFERENCENAME, + 0x0018=,MODULENAME,MODULESTREAMNAME,,MODULEDOCSTRING,,MODULEHELPCONTEXT, + 0x0020=,PROCEDURALMODULE,DOCUMENTMODULE,,,MODULEREADONLY,, + 0x0028=MODULEPRIVATE,,,MODULEEND,MODULECOOKIE,,,REFERENCECONTROL + 0x0030=REFERENCEEXTENDED,MODULEOFFSET,MODULESTREAMNAMEUNICODE,REFERENCEORIGINAL,,,, + 0x0038=,,,,PROJECTCONSTANTSUNICODE,PROJECTHELPFILEPATHUNICODE,REFERENCENAMEUNICODE, + 0x0040=PROJECTDOCSTRINGUNICODE,,,,,,,MODULENAMEUNICODE + 0x0048=MODULEDOCSTRINGUNICODE,,,,,,, +end + +constlist=VBA-DIR-SIMPLE-RECORDS + 0x0001=uint32,dec,platform,VBA-DIR-PROJECTSYSKIND-PLATFORM + 0x0002=uint32,hex,lang-id + 0x0007=uint32,dec,help-context-id + 0x0008=uint32,hex,libflags + 0x000F=uint16,dec,module-count + 0x0013=int16,dec,cookie + 0x0014=uint32,hex,lang-id + 0x001E=uint32,dec,help-context-id + 0x002C=int16,dec,cookie +end + +shortlist=VBA-DIR-PROJECTSYSKIND-PLATFORM,0,16-bit-windows,32-bit-windows,macintosh + +# ============================================================================ + diff --git a/oox/source/dump/olestoragedumper.cxx b/oox/source/dump/olestoragedumper.cxx index 0bf58875cce0..e69de29bb2d1 100644 --- a/oox/source/dump/olestoragedumper.cxx +++ b/oox/source/dump/olestoragedumper.cxx @@ -1,444 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: olestoragedumper.cxx,v $ - * $Revision: 1.3 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "oox/dump/olestoragedumper.hxx" -#include <osl/thread.h> -#include <osl/file.hxx> -#include <rtl/tencinfo.h> -#include <com/sun/star/util/DateTime.hpp> -#include <com/sun/star/io/XInputStream.hpp> -#include <com/sun/star/io/XOutputStream.hpp> -#include "oox/helper/binaryoutputstream.hxx" -#include "oox/core/filterbase.hxx" - -#if OOX_INCLUDE_DUMPER - -using ::rtl::OUString; -using ::rtl::OUStringBuffer; -using ::rtl::OString; -using ::rtl::OStringToOUString; -using ::com::sun::star::uno::Reference; -using ::com::sun::star::util::DateTime; -using ::com::sun::star::io::XInputStream; -using ::com::sun::star::io::XOutputStream; - -namespace oox { -namespace dump { - -// ============================================================================ - -namespace { - -const sal_Int32 OLEPROP_ID_DICTIONARY = 0; -const sal_Int32 OLEPROP_ID_CODEPAGE = 1; - -const sal_Int32 OLEPROP_TYPE_INT16 = 2; -const sal_Int32 OLEPROP_TYPE_INT32 = 3; -const sal_Int32 OLEPROP_TYPE_FLOAT = 4; -const sal_Int32 OLEPROP_TYPE_DOUBLE = 5; -const sal_Int32 OLEPROP_TYPE_DATE = 7; -const sal_Int32 OLEPROP_TYPE_STRING = 8; -const sal_Int32 OLEPROP_TYPE_STATUS = 10; -const sal_Int32 OLEPROP_TYPE_BOOL = 11; -const sal_Int32 OLEPROP_TYPE_VARIANT = 12; -const sal_Int32 OLEPROP_TYPE_INT8 = 16; -const sal_Int32 OLEPROP_TYPE_UINT8 = 17; -const sal_Int32 OLEPROP_TYPE_UINT16 = 18; -const sal_Int32 OLEPROP_TYPE_UINT32 = 19; -const sal_Int32 OLEPROP_TYPE_INT64 = 20; -const sal_Int32 OLEPROP_TYPE_UINT64 = 21; -const sal_Int32 OLEPROP_TYPE_STRING8 = 30; -const sal_Int32 OLEPROP_TYPE_STRING16 = 31; -const sal_Int32 OLEPROP_TYPE_FILETIME = 64; -const sal_Int32 OLEPROP_TYPE_BLOB = 65; -const sal_Int32 OLEPROP_TYPE_STREAM = 66; -const sal_Int32 OLEPROP_TYPE_STORAGE = 67; -const sal_Int32 OLEPROP_TYPE_CLIPFMT = 71; - -const sal_uInt16 CODEPAGE_UNICODE = 1200; - -} // namespace - -// ============================================================================ - -OlePropertyStreamObject::OlePropertyStreamObject( const ObjectBase& rParent, const OUString& rOutFileName, BinaryInputStreamRef xStrm ) : - InputStreamObject( rParent, rOutFileName, xStrm ) -{ -} - -void OlePropertyStreamObject::implDump() -{ - Input& rIn = in(); - Output& rOut = out(); - - OUStringVector aGuidVec; - ::std::vector< sal_uInt32 > aStartPosVec; - - // dump header - writeEmptyItem( "HEADER" ); - { - IndentGuard aIndGuard( rOut ); - dumpHex< sal_uInt16 >( "byte-order", "OLEPROP-BYTE-ORDER" ); - dumpDec< sal_uInt16 >( "version" ); - dumpDec< sal_uInt16 >( "os-minor" ); - dumpDec< sal_uInt16 >( "os-type", "OLEPROP-OSTYPE" ); - dumpGuid( "guid" ); - sal_Int32 nSectCount = dumpDec< sal_Int32 >( "section-count" ); - - // dump table of section positions - { - TableGuard aTabGuard( rOut, 15, 60 ); - rOut.resetItemIndex(); - for( sal_Int32 nSectIdx = 0; (nSectIdx < nSectCount) && rIn.isValidPos(); ++nSectIdx ) - { - MultiItemsGuard aMultiGuard( rOut ); - writeEmptyItem( "#section" ); - aGuidVec.push_back( dumpGuid( "guid" ) ); - aStartPosVec.push_back( dumpHex< sal_uInt32 >( "start-pos" ) ); - } - } - } - rOut.emptyLine(); - - // dump sections - for( size_t nSectIdx = 0; (nSectIdx < aStartPosVec.size()) && rIn.isValidPos(); ++nSectIdx ) - dumpSection( aGuidVec[ nSectIdx ], aStartPosVec[ nSectIdx ] ); -} - -void OlePropertyStreamObject::dumpSection( const OUString& rGuid, sal_uInt32 nStartPos ) -{ - Input& rIn = in(); - Output& rOut = out(); - - // property ID names - mxPropIds = cfg().createNameList< ConstList >( "OLEPROP-IDS" ); - OUString aGuidName = cfg().getStringOption( rGuid, OUString() ); - if( aGuidName.equalsAscii( "GlobalDocProp" ) ) - mxPropIds->includeList( cfg().getNameList( "OLEPROP-GLOBALIDS" ) ); - else if( aGuidName.equalsAscii( "BuiltinDocProp" ) ) - mxPropIds->includeList( cfg().getNameList( "OLEPROP-BUILTINIDS" ) ); - else - mxPropIds->includeList( cfg().getNameList( "OLEPROP-BASEIDS" ) ); - - // property ID/position map - typedef ::std::map< sal_Int32, sal_uInt32 > PropertyPosMap; - PropertyPosMap aPropMap; - - // dump section header line - writeSectionHeader( rGuid, nStartPos ); - - // seek to section - IndentGuard aIndGuard( rOut ); - if( startElement( nStartPos ) ) - { - // dump section header - dumpDec< sal_Int32 >( "size" ); - sal_Int32 nPropCount = dumpDec< sal_Int32 >( "property-count" ); - - // dump table of property positions - { - TableGuard aTabGuard( rOut, 15, 25 ); - rOut.resetItemIndex(); - for( sal_Int32 nPropIdx = 0; (nPropIdx < nPropCount) && rIn.isValidPos(); ++nPropIdx ) - { - MultiItemsGuard aMultiGuard( rOut ); - writeEmptyItem( "#property" ); - sal_Int32 nPropId = dumpDec< sal_Int32 >( "id", mxPropIds ); - sal_uInt32 nPropPos = nStartPos + dumpHex< sal_uInt32 >( "start-pos" ); - aPropMap[ nPropId ] = nPropPos; - } - } - } - rOut.emptyLine(); - - // code page property - meTextEnc = osl_getThreadTextEncoding(); - mbIsUnicode = false; - PropertyPosMap::iterator aCodePageIt = aPropMap.find( OLEPROP_ID_CODEPAGE ); - if( aCodePageIt != aPropMap.end() ) - { - dumpCodePageProperty( aCodePageIt->second ); - aPropMap.erase( aCodePageIt ); - } - - // dictionary property - PropertyPosMap::iterator aDictIt = aPropMap.find( OLEPROP_ID_DICTIONARY ); - if( aDictIt != aPropMap.end() ) - { - dumpDictionaryProperty( aDictIt->second ); - aPropMap.erase( aDictIt ); - } - - // other properties - for( PropertyPosMap::const_iterator aIt = aPropMap.begin(), aEnd = aPropMap.end(); aIt != aEnd; ++aIt ) - dumpProperty( aIt->first, aIt->second ); - - // remove the user defined list of property ID names - cfg().eraseNameList( "OLEPROP-IDS" ); -} - -void OlePropertyStreamObject::dumpProperty( sal_Int32 nPropId, sal_uInt32 nStartPos ) -{ - writePropertyHeader( nPropId, nStartPos ); - IndentGuard aIndGuard( out() ); - if( startElement( nStartPos ) ) - dumpPropertyContents( nPropId ); - out().emptyLine(); -} - -void OlePropertyStreamObject::dumpCodePageProperty( sal_uInt32 nStartPos ) -{ - writePropertyHeader( OLEPROP_ID_CODEPAGE, nStartPos ); - IndentGuard aIndGuard( out() ); - if( startElement( nStartPos ) ) - { - sal_Int32 nType = dumpPropertyType(); - if( nType == OLEPROP_TYPE_INT16 ) - { - sal_uInt16 nCodePage = dumpDec< sal_uInt16 >( "codepage", "CODEPAGES" ); - rtl_TextEncoding nNewTextEnc = rtl_getTextEncodingFromWindowsCodePage( nCodePage ); - if( nNewTextEnc != RTL_TEXTENCODING_DONTKNOW ) - meTextEnc = nNewTextEnc; - mbIsUnicode = nCodePage == CODEPAGE_UNICODE; - } - else - dumpPropertyContents( OLEPROP_ID_CODEPAGE ); - } - out().emptyLine(); -} - -void OlePropertyStreamObject::dumpDictionaryProperty( sal_uInt32 nStartPos ) -{ - writePropertyHeader( OLEPROP_ID_DICTIONARY, nStartPos ); - IndentGuard aIndGuard( out() ); - if( startElement( nStartPos ) ) - { - sal_Int32 nCount = dumpDec< sal_Int32 >( "count" ); - for( sal_Int32 nIdx = 0; (nIdx < nCount) && in().isValidPos(); ++nIdx ) - { - MultiItemsGuard aMultiGuard( out() ); - TableGuard aTabGuard( out(), 10, 20 ); - sal_Int32 nId = dumpDec< sal_Int32 >( "id" ); - OUString aName = dumpString8( "name" ); - if( mxPropIds.get() ) - mxPropIds->setName( nId, aName ); - } - } - out().emptyLine(); -} - -void OlePropertyStreamObject::dumpPropertyContents( sal_Int32 nPropId ) -{ - sal_Int32 nType = dumpPropertyType(); - if( getFlag< sal_Int32 >( nType, 0x1000 ) ) // vector - { - sal_Int32 nBaseType = nType & 0x0FFF; - sal_Int32 nElemCount = dumpDec< sal_Int32 >( "element-count" ); - for( sal_Int32 nElemIdx = 0; (nElemIdx < nElemCount) && in().isValidPos(); ++nElemIdx ) - { - out().resetItemIndex( nElemIdx ); - writeEmptyItem( "#element" ); - IndentGuard aIndGuard( out() ); - dumpPropertyValue( nPropId, nBaseType ); - } - } - else if( !getFlag< sal_Int32 >( nType, 0x7000 ) ) - { - dumpPropertyValue( nPropId, nType ); - } -} - -void OlePropertyStreamObject::dumpPropertyValue( sal_Int32 nPropId, sal_Int32 nBaseType ) -{ - switch( nBaseType ) - { - case OLEPROP_TYPE_INT16: dumpDec< sal_Int16 >( "value" ); break; - case OLEPROP_TYPE_INT32: dumpDec< sal_Int32 >( "value" ); break; - case OLEPROP_TYPE_FLOAT: dumpDec< float >( "value" ); break; - case OLEPROP_TYPE_DOUBLE: dumpDec< double >( "value" ); break; - case OLEPROP_TYPE_DATE: dumpDec< double >( "date" ); break; - case OLEPROP_TYPE_STRING: dumpString8( "value" ); break; - case OLEPROP_TYPE_STATUS: dumpHex< sal_Int32 >( "status" ); break; - case OLEPROP_TYPE_BOOL: dumpBool< sal_Int16 >( "value" ); break; - case OLEPROP_TYPE_VARIANT: dumpPropertyContents( nPropId ); break; - case OLEPROP_TYPE_INT8: dumpDec< sal_Int8 >( "value" ); break; - case OLEPROP_TYPE_UINT8: dumpDec< sal_uInt8 >( "value" ); break; - case OLEPROP_TYPE_UINT16: dumpDec< sal_uInt16 >( "value" ); break; - case OLEPROP_TYPE_UINT32: dumpDec< sal_uInt32 >( "value" ); break; - case OLEPROP_TYPE_INT64: dumpDec< sal_Int64 >( "value" ); break; - case OLEPROP_TYPE_UINT64: dumpDec< sal_uInt64 >( "value" ); break; - case OLEPROP_TYPE_STRING8: dumpString8( "value" ); break; - case OLEPROP_TYPE_STRING16: dumpString16( "value" ); break; - case OLEPROP_TYPE_FILETIME: dumpFileTime( "file-time" ); break; - case OLEPROP_TYPE_BLOB: dumpBlob( "data" ); break; - case OLEPROP_TYPE_STREAM: dumpString8( "stream-name" ); break; - case OLEPROP_TYPE_STORAGE: dumpString8( "storage-name" ); break; - case OLEPROP_TYPE_CLIPFMT: dumpBlob( "clip-data" ); break; - } -} - -sal_Int32 OlePropertyStreamObject::dumpPropertyType() -{ - return dumpHex< sal_Int32 >( "type", "OLEPROP-TYPE" ); -} - -void OlePropertyStreamObject::dumpBlob( const sal_Char* pcName ) -{ - sal_Int32 nSize = dumpDec< sal_Int32 >( "data-size" ); - if( nSize > 0 ) - dumpBinary( pcName, nSize ); -} - -OUString OlePropertyStreamObject::dumpString8( const sal_Char* pcName ) -{ - sal_Int32 nLen = dumpDec< sal_Int32 >( "string-len" ); - return mbIsUnicode ? dumpCharArray16( pcName, nLen ) : dumpCharArray8( pcName, nLen ); -} - -OUString OlePropertyStreamObject::dumpCharArray8( const sal_Char* pcName, sal_Int32 nCharCount ) -{ - OUString aData; - size_t nLen = getLimitedValue< size_t, sal_Int32 >( nCharCount, 0, 1024 ); - if( nLen > 0 ) - { - ::std::vector< sal_Char > aBuffer( nLen + 1 ); - in().read( &aBuffer.front(), nLen ); - aBuffer[ nLen ] = 0; - aData = OStringToOUString( OString( &aBuffer.front() ), meTextEnc ); - } - writeStringItem( pcName, aData ); - return aData; -} - -OUString OlePropertyStreamObject::dumpString16( const sal_Char* pcName ) -{ - sal_Int32 nLen = dumpDec< sal_Int32 >( "string-len" ); - return dumpCharArray16( pcName, nLen ); -} - -OUString OlePropertyStreamObject::dumpCharArray16( const sal_Char* pcName, sal_Int32 nCharCount ) -{ - size_t nLen = getLimitedValue< size_t, sal_Int32 >( nCharCount, 0, 1024 ); - ::std::vector< sal_Unicode > aBuffer; - aBuffer.reserve( nLen + 1 ); - for( size_t nIdx = 0; nIdx < nLen; ++nIdx ) - aBuffer.push_back( static_cast< sal_Unicode >( in().readValue< sal_uInt16 >() ) ); - aBuffer.push_back( 0 ); - OUString aData( &aBuffer.front() ); - writeStringItem( pcName, aData ); - if( nLen & 1 ) dumpUnused( 2 ); // always padding to 32bit - return aData; -} - -DateTime OlePropertyStreamObject::dumpFileTime( const sal_Char* pcName ) -{ - DateTime aDateTime; - - ItemGuard aItem( out(), pcName ); - sal_Int64 nFileTime = dumpDec< sal_Int64 >( 0 ); - // file time is in 10^-7 seconds (100 nanoseconds), convert to 1/100 seconds - nFileTime /= 100000; - // entire days - sal_Int64 nDays = nFileTime / sal_Int64( 360000 * 24 ); - // number of entire years - sal_Int64 nYears = (nDays - (nDays / (4 * 365)) + (nDays / (100 * 365)) - (nDays / (400 * 365))) / 365; - // remaining days in the year - sal_Int64 nDaysInYear = nDays - (nYears * 365 + nYears / 4 - nYears / 100 + nYears / 400); - // the year (file dates start from 1601-01-01) - aDateTime.Year = static_cast< sal_uInt16 >( 1601 + nYears ); - // leap year? - bool bLeap = ((aDateTime.Year % 4 == 0) && (aDateTime.Year % 100 != 0)) || (aDateTime.Year % 400 == 0); - // static arrays with number of days in month - static const sal_Int64 spnDaysInMonth[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; - static const sal_Int64 spnDaysInMonthL[] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; - const sal_Int64* pnDaysInMonth = bLeap ? spnDaysInMonthL : spnDaysInMonth; - // the month - aDateTime.Month = 1; - while( nDaysInYear >= *pnDaysInMonth ) - { - nDaysInYear -= *pnDaysInMonth++; - ++aDateTime.Month; - } - // the day - aDateTime.Day = static_cast< sal_uInt16 >( nDaysInYear + 1 ); - // number of 1/100 seconds in the day - sal_Int64 nTimeInDay = nFileTime % sal_Int64( 360000 * 24 ); - // 1/100 seconds - aDateTime.HundredthSeconds = static_cast< sal_uInt16 >( nTimeInDay % 100 ); - nTimeInDay /= 100; - // seconds - aDateTime.Seconds = static_cast< sal_uInt16 >( nTimeInDay % 60 ); - nTimeInDay /= 60; - // minutes - aDateTime.Minutes = static_cast< sal_uInt16 >( nTimeInDay % 60 ); - nTimeInDay /= 60; - // hours - aDateTime.Hours = static_cast< sal_uInt16 >( nTimeInDay ); - -// aDateTime.convertToLocalTime(); - writeDateTimeItem( 0, aDateTime ); - return aDateTime; -} - -bool OlePropertyStreamObject::startElement( sal_uInt32 nStartPos ) -{ - sal_Int64 nStartPos64 = static_cast< sal_Int64>( nStartPos ); - bool bPosOk = nStartPos64 < in().getSize(); - if( bPosOk ) - in().seek( nStartPos64 ); - else - writeInfoItem( "stream-state", OOX_DUMP_ERR_STREAM ); - return bPosOk; -} - -void OlePropertyStreamObject::writeSectionHeader( const OUString& rGuid, sal_uInt32 nStartPos ) -{ - MultiItemsGuard aMultiGuard( out() ); - writeEmptyItem( "SECTION" ); - writeGuidItem( "guid", rGuid ); - writeHexItem( "pos", nStartPos ); -} - -void OlePropertyStreamObject::writePropertyHeader( sal_Int32 nPropId, sal_uInt32 nStartPos ) -{ - MultiItemsGuard aMultiGuard( out() ); - writeEmptyItem( "PROPERTY" ); - writeDecItem( "id", nPropId, mxPropIds ); - writeHexItem( "pos", nStartPos ); -} - -// ============================================================================ -// ============================================================================ - -} // namespace dump -} // namespace oox - -#endif - diff --git a/oox/source/dump/olestoragedumperconfig.dat b/oox/source/dump/olestoragedumperconfig.dat index cddda95c7091..e69de29bb2d1 100644 --- a/oox/source/dump/olestoragedumperconfig.dat +++ b/oox/source/dump/olestoragedumperconfig.dat @@ -1,56 +0,0 @@ - -# dumper settings ============================================================ - -# Path to additional configuration data, relative to this file. -include-config-file=dumperconfig.dat - -# name lists ================================================================= - -F29F85E0-4FF9-1068-AB91-08002B27B3D9=GlobalDocProp -D5CDD502-2E9C-101B-9397-08002B2CF9AE=BuiltinDocProp -D5CDD505-2E9C-101B-9397-08002B2CF9AE=CustomDocProp - -constlist=OLEPROP-BYTE-ORDER - 0xFEFF=big-endian - 0xFFFE=little-endian -end - -shortlist=OLEPROP-OSTYPE,0,dos,mac,win32,unix - -multilist=OLEPROP-BASEIDS - quote-names=1 - default= - 0=dictionary,codepage -end - -multilist=OLEPROP-GLOBALIDS - include=OLEPROP-BASEIDS - 2=title,subject,author,keywords,comments,template,last-author,rev-number - 10=edit-time,last-printed,create-time,last-saved,page-count,word-count,char-count,thumbnail,appname,security -end - -multilist=OLEPROP-BUILTINIDS - include=OLEPROP-BASEIDS - 2=category,pres-target,byte-count,line-count,para-count,slide-count,note-count,hidden-slide-count - 10=clips,scale-crop,heading-pairs,part-titles,manager,company,links-uptodate -end - -multilist=OLEPROP-TYPE-SIMPLE - 0=empty,null,int16,int32,float,double,fixed,date,string8,dispatch - 10=error,bool,variant,unknown,decimal,int8,uint8,uint16,uint32 - 20=int64,uint64,int,uint,void,hresult,ptr,savearray,c-array,userdef - 30=string8,string16 - 64=time-stamp,blob,stream,storage,stream-obj,storage-obj - 70=blob-obj,clip-fmt,guid,vers-stream - 0x0FFF=str8-blob -end - -combilist=OLEPROP-TYPE - 0x0FFF=int32,dec,base-type,OLEPROP-TYPE-SIMPLE - 0x1000=vector - 0x2000=array - 0x4000=byref -end - -# ============================================================================ - diff --git a/oox/source/dump/pptxdumper.cxx b/oox/source/dump/pptxdumper.cxx index 71cc936255ec..a59960d42103 100644 --- a/oox/source/dump/pptxdumper.cxx +++ b/oox/source/dump/pptxdumper.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: pptxdumper.cxx,v $ - * $Revision: 1.3 $ + * $Revision: 1.3.20.5 $ * * This file is part of OpenOffice.org. * @@ -29,10 +29,14 @@ ************************************************************************/ #include "oox/dump/pptxdumper.hxx" +#include "oox/helper/zipstorage.hxx" #if OOX_INCLUDE_DUMPER using ::rtl::OUString; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::lang::XMultiServiceFactory; +using ::com::sun::star::io::XInputStream; using ::oox::core::FilterBase; namespace oox { @@ -43,26 +47,38 @@ namespace pptx { RootStorageObject::RootStorageObject( const DumperBase& rParent ) { - RootStorageObjectBase::construct( rParent ); + StorageObjectBase::construct( rParent ); } -void RootStorageObject::implDumpStream( BinaryInputStreamRef xStrm, const OUString& /*rStrgPath*/, const OUString& rStrmName, const OUString& rSystemFileName ) +void RootStorageObject::implDumpStream( const BinaryInputStreamRef& rxStrm, const OUString& /*rStrgPath*/, const OUString& rStrmName, const OUString& rSysFileName ) { OUString aExt = InputOutputHelper::getFileNameExtension( rStrmName ); if( aExt.equalsIgnoreAsciiCaseAscii( "xml" ) || aExt.equalsIgnoreAsciiCaseAscii( "vml" ) || aExt.equalsIgnoreAsciiCaseAscii( "rels" ) ) { - XmlStreamObject( *this, rSystemFileName, xStrm ).dump(); + XmlStreamObject( *this, rxStrm, rSysFileName ).dump(); } } // ============================================================================ +#define DUMP_PPTX_CONFIG_ENVVAR "OOO_PPTXDUMPER" + Dumper::Dumper( const FilterBase& rFilter ) { - ConfigRef xCfg( new Config( "OOO_PPTXDUMPER" ) ); - DumperBase::construct( rFilter, xCfg ); + ConfigRef xCfg( new Config( DUMP_PPTX_CONFIG_ENVVAR, rFilter ) ); + DumperBase::construct( xCfg ); +} + +Dumper::Dumper( const Reference< XMultiServiceFactory >& rxFactory, const Reference< XInputStream >& rxInStrm, const OUString& rSysFileName ) +{ + if( rxFactory.is() && rxInStrm.is() ) + { + StorageRef xStrg( new ZipStorage( rxFactory, rxInStrm ) ); + ConfigRef xCfg( new Config( DUMP_PPTX_CONFIG_ENVVAR, rxFactory, xStrg, rSysFileName ) ); + DumperBase::construct( xCfg ); + } } void Dumper::implDump() diff --git a/oox/source/dump/pptxdumper.ini b/oox/source/dump/pptxdumper.ini new file mode 100644 index 000000000000..fa03953b7113 --- /dev/null +++ b/oox/source/dump/pptxdumper.ini @@ -0,0 +1,19 @@ + +# dumper settings ============================================================ + +# Path to additional configuration data, relative to this file. +include-config-file=dumperbase.ini + +# Enable entire dumper (default=off). This option does not affect the option +# 'enable-import'. +# 0=off, 1=on, missing: setting from dumperbase.ini +# enable-dumper=1 + +# Enable import after dumping (default=on). Disabling this option allows +# to dump a file without loading it. This option is independent from the +# 'enable-dumper' option. +# 0=off, 1=on, missing: setting from dumperbase.ini +# enable-import=1 + +# ============================================================================ + diff --git a/oox/source/dump/pptxdumperconfig.dat b/oox/source/dump/pptxdumperconfig.dat index c69df029aaca..e69de29bb2d1 100644 --- a/oox/source/dump/pptxdumperconfig.dat +++ b/oox/source/dump/pptxdumperconfig.dat @@ -1,19 +0,0 @@ - -# dumper settings ============================================================ - -# Path to additional configuration data, relative to this file. -include-config-file=dumperconfig.dat - -# Enable entire dumper (default=off). This option does not affect the option -# 'enable-import'. -# 0=off, 1=on -enable-dumper=1 - -# Enable import after dumping (default=on). Disabling this option allows -# to dump a file without loading it. This option is independent from the -# 'enable-dumper' option. -# 0=off, 1=on -enable-import=1 - -# ============================================================================ - diff --git a/oox/source/dump/xlsbdumper.cxx b/oox/source/dump/xlsbdumper.cxx index 9d652a14e451..682e2357595b 100644 --- a/oox/source/dump/xlsbdumper.cxx +++ b/oox/source/dump/xlsbdumper.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: xlsbdumper.cxx,v $ - * $Revision: 1.4 $ + * $Revision: 1.4.20.10 $ * * This file is part of OpenOffice.org. * @@ -30,7 +30,10 @@ #include "oox/dump/xlsbdumper.hxx" #include <com/sun/star/io/XTextInputStream.hpp> -#include <com/sun/star/sheet/XSpreadsheetDocument.hpp> +#include "oox/dump/biffdumper.hxx" +#include "oox/dump/oledumper.hxx" +#include "oox/helper/olestorage.hxx" +#include "oox/helper/zipstorage.hxx" #include "oox/core/filterbase.hxx" #include "oox/xls/biffhelper.hxx" #include "oox/xls/formulabase.hxx" @@ -41,8 +44,8 @@ using ::rtl::OUString; using ::rtl::OUStringBuffer; using ::com::sun::star::uno::Reference; -using ::com::sun::star::uno::UNO_QUERY; -using ::com::sun::star::sheet::XSpreadsheetDocument; +using ::com::sun::star::lang::XMultiServiceFactory; +using ::com::sun::star::io::XInputStream; using ::oox::core::FilterBase; using namespace ::oox::xls; @@ -63,62 +66,9 @@ const sal_uInt8 OOBIN_TOK_ARRAY_STRING = 1; const sal_uInt8 OOBIN_TOK_ARRAY_BOOL = 2; const sal_uInt8 OOBIN_TOK_ARRAY_ERROR = 4; -} // namespace - -// ============================================================================ - -RecordStreamInput::RecordStreamInput() : - mxStrm( new RecordInputStream( RecordDataSequence() ) ) -{ -} - -RecordStreamInput::~RecordStreamInput() -{ -} - -bool RecordStreamInput::implIsValid() const -{ - return mxStrm.get() && Input::implIsValid(); -} - -void RecordStreamInput::createStream( const RecordDataSequence& rData ) -{ - mxStrm.reset( new RecordInputStream( rData ) ); -} - -sal_Int64 RecordStreamInput::getSize() const -{ - return mxStrm->getRecSize(); -} +const sal_uInt16 OOBIN_OLEOBJECT_LINKED = 0x0001; -sal_Int64 RecordStreamInput::tell() const -{ - return mxStrm->getRecPos(); -} - -void RecordStreamInput::seek( sal_Int64 nPos ) -{ - mxStrm->seek( static_cast< sal_Int32 >( nPos ) ); -} - -void RecordStreamInput::skip( sal_Int32 nBytes ) -{ - mxStrm->skip( nBytes ); -} - -sal_Int32 RecordStreamInput::read( void* pBuffer, sal_Int32 nSize ) -{ - return mxStrm->read( pBuffer, nSize ); -} - -RecordStreamInput& RecordStreamInput::operator>>( sal_Int8& rnData ) { *mxStrm >> rnData; return *this; } -RecordStreamInput& RecordStreamInput::operator>>( sal_uInt8& rnData ) { *mxStrm >> rnData; return *this; } -RecordStreamInput& RecordStreamInput::operator>>( sal_Int16& rnData ) { *mxStrm >> rnData; return *this; } -RecordStreamInput& RecordStreamInput::operator>>( sal_uInt16& rnData ) { *mxStrm >> rnData; return *this; } -RecordStreamInput& RecordStreamInput::operator>>( sal_Int32& rnData ) { *mxStrm >> rnData; return *this; } -RecordStreamInput& RecordStreamInput::operator>>( sal_uInt32& rnData ) { *mxStrm >> rnData; return *this; } -RecordStreamInput& RecordStreamInput::operator>>( float& rfData ) { *mxStrm >> rfData; return *this; } -RecordStreamInput& RecordStreamInput::operator>>( double& rfData ) { *mxStrm >> rfData; return *this; } +} // namespace // ============================================================================ @@ -130,11 +80,12 @@ RecordObjectBase::~RecordObjectBase() { } -void RecordObjectBase::construct( const OutputObjectBase& rParent ) +void RecordObjectBase::construct( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName ) { - mxStrmIn.reset( new RecordStreamInput ); - InputObjectBase::construct( rParent, mxStrmIn ); - constructRecObjBase(); + mxStrm.reset( new RecordInputStream( getRecordDataSequence() ) ); + SequenceRecordObjectBase::construct( rParent, rxStrm, rSysFileName, mxStrm, "RECORD-NAMES", "SIMPLE-RECORDS" ); + if( SequenceRecordObjectBase::implIsValid() ) + mxErrCodes = cfg().getNameList( "ERRORCODES" ); } void RecordObjectBase::construct( const RecordObjectBase& rParent ) @@ -142,14 +93,13 @@ void RecordObjectBase::construct( const RecordObjectBase& rParent ) *this = rParent; } -bool RecordObjectBase::implIsValid() const -{ - return isValid( mxStrmIn ) && InputObjectBase::implIsValid(); -} - -void RecordObjectBase::createRecordStream( const RecordDataSequence& rData ) +bool RecordObjectBase::implReadRecordHeader( BinaryInputStream& rBaseStrm, sal_Int64& ornRecId, sal_Int64& ornRecSize ) { - mxStrmIn->createStream( rData ); + sal_Int32 nRecId = 0, nRecSize = 0; + bool bValid = readCompressedInt( rBaseStrm, nRecId ) && (nRecId >= 0) && readCompressedInt( rBaseStrm, nRecSize ) && (nRecSize >= 0); + ornRecId = nRecId; + ornRecSize = nRecSize; + return bValid; } OUString RecordObjectBase::getErrorName( sal_uInt8 nErrCode ) const @@ -176,7 +126,7 @@ void RecordObjectBase::readRangeList( RangeList& orRanges ) if( nCount >= 0 ) { orRanges.resize( getLimitedValue< size_t, sal_Int32 >( nCount, 0, SAL_MAX_UINT16 ) ); - for( RangeList::iterator aIt = orRanges.begin(), aEnd = orRanges.end(); in().isValidPos() && (aIt != aEnd); ++aIt ) + for( RangeList::iterator aIt = orRanges.begin(), aEnd = orRanges.end(); !in().isEof() && (aIt != aEnd); ++aIt ) readRange( *aIt ); } else @@ -185,14 +135,14 @@ void RecordObjectBase::readRangeList( RangeList& orRanges ) // ---------------------------------------------------------------------------- -void RecordObjectBase::writeBooleanItem( const sal_Char* pcName, sal_uInt8 nBool ) +void RecordObjectBase::writeBooleanItem( const String& rName, sal_uInt8 nBool ) { - writeDecItem( pcName, nBool, "BOOLEAN" ); + writeDecItem( rName, nBool, "BOOLEAN" ); } -void RecordObjectBase::writeErrorCodeItem( const sal_Char* pcName, sal_uInt8 nErrCode ) +void RecordObjectBase::writeErrorCodeItem( const String& rName, sal_uInt8 nErrCode ) { - writeHexItem( pcName, nErrCode, mxErrCodes ); + writeHexItem( rName, nErrCode, mxErrCodes ); } void RecordObjectBase::writeFontPortions( const BinFontPortionList& rPortions ) @@ -230,35 +180,35 @@ void RecordObjectBase::writePhoneticPortions( const BinPhoneticPortionList& rPor // ---------------------------------------------------------------------------- -sal_uInt8 RecordObjectBase::dumpBoolean( const sal_Char* pcName ) +sal_uInt8 RecordObjectBase::dumpBoolean( const String& rName ) { sal_uInt8 nBool; in() >> nBool; - writeBooleanItem( pcName ? pcName : "boolean", nBool ); + writeBooleanItem( rName( "boolean" ), nBool ); return nBool; } -sal_uInt8 RecordObjectBase::dumpErrorCode( const sal_Char* pcName ) +sal_uInt8 RecordObjectBase::dumpErrorCode( const String& rName ) { sal_uInt8 nErrCode; in() >> nErrCode; - writeErrorCodeItem( pcName ? pcName : "errorcode", nErrCode ); + writeErrorCodeItem( rName( "error-code" ), nErrCode ); return nErrCode; } -OUString RecordObjectBase::dumpString( const sal_Char* pcName, bool bRich, bool b32BitLen ) +OUString RecordObjectBase::dumpString( const String& rName, bool bRich, bool b32BitLen ) { sal_uInt8 nFlags = bRich ? dumpHex< sal_uInt8 >( "flags", "STRING-FLAGS" ) : 0; - OUString aString = getRecordStream().readString( b32BitLen ); - writeStringItem( pcName ? pcName : "text", aString ); + OUString aString = mxStrm->readString( b32BitLen ); + writeStringItem( rName( "text" ), aString ); // --- formatting --- if( getFlag( nFlags, OOBIN_STRINGFLAG_FONTS ) ) { IndentGuard aIndGuard( out() ); BinFontPortionList aPortions; - aPortions.importPortions( getRecordStream() ); + aPortions.importPortions( *mxStrm ); writeFontPortions( aPortions ); } @@ -268,7 +218,7 @@ OUString RecordObjectBase::dumpString( const sal_Char* pcName, bool bRich, bool IndentGuard aIndGuard( out() ); dumpString( "phonetic-text" ); BinPhoneticPortionList aPortions; - aPortions.importPortions( getRecordStream() ); + aPortions.importPortions( *mxStrm ); writePhoneticPortions( aPortions ); dumpDec< sal_uInt16 >( "font-id", "FONTNAMES" ); dumpHex< sal_uInt16 >( "flags", "PHONETIC-FLAGS" ); @@ -277,10 +227,10 @@ OUString RecordObjectBase::dumpString( const sal_Char* pcName, bool bRich, bool return aString; } -void RecordObjectBase::dumpColor( const sal_Char* pcName ) +void RecordObjectBase::dumpColor( const String& rName ) { MultiItemsGuard aMultiGuard( out() ); - writeEmptyItem( pcName ? pcName : "color" ); + writeEmptyItem( rName( "color" ) ); switch( extractValue< sal_uInt8 >( dumpDec< sal_uInt8 >( "flags", "COLOR-FLAGS" ), 1, 7 ) ) { case 0: dumpUnused( 1 ); break; @@ -290,78 +240,93 @@ void RecordObjectBase::dumpColor( const sal_Char* pcName ) default: dumpUnknown( 1 ); } dumpDec< sal_Int16 >( "tint", "CONV-TINT" ); - sal_uInt8 nR, nG, nB, nA; - in() >> nR >> nG >> nB >> nA; - writeColorItem( "rgb", (((((static_cast< sal_Int32 >( nA ) << 8) | nR) << 8) | nG) << 8) | nB ); + dumpColorABGR(); } -sal_Int32 RecordObjectBase::dumpColIndex( const sal_Char* pcName ) +sal_Int32 RecordObjectBase::dumpColIndex( const String& rName ) { sal_Int32 nCol; in() >> nCol; - writeColIndexItem( pcName ? pcName : "col-idx", nCol ); + writeColIndexItem( rName( "col-idx" ), nCol ); return nCol; } -sal_Int32 RecordObjectBase::dumpRowIndex( const sal_Char* pcName ) +sal_Int32 RecordObjectBase::dumpRowIndex( const String& rName ) { sal_Int32 nRow; in() >> nRow; - writeRowIndexItem( pcName ? pcName : "row-idx", nRow ); + writeRowIndexItem( rName( "row-idx" ), nRow ); return nRow; } -sal_Int32 RecordObjectBase::dumpColRange( const sal_Char* pcName ) +sal_Int32 RecordObjectBase::dumpColRange( const String& rName ) { sal_Int32 nCol1, nCol2; in() >> nCol1 >> nCol2; - writeColRangeItem( pcName ? pcName : "col-range", nCol1, nCol2 ); + writeColRangeItem( rName( "col-range" ), nCol1, nCol2 ); return nCol2 - nCol1 + 1; } -sal_Int32 RecordObjectBase::dumpRowRange( const sal_Char* pcName ) +sal_Int32 RecordObjectBase::dumpRowRange( const String& rName ) { sal_Int32 nRow1, nRow2; in() >> nRow1 >> nRow2; - writeRowRangeItem( pcName ? pcName : "row-range", nRow1, nRow2 ); + writeRowRangeItem( rName( "row-range" ), nRow1, nRow2 ); return nRow2 - nRow1 + 1; } -Address RecordObjectBase::dumpAddress( const sal_Char* pcName ) +Address RecordObjectBase::dumpAddress( const String& rName ) { Address aPos; readAddress( aPos ); - writeAddressItem( pcName ? pcName : "addr", aPos ); + writeAddressItem( rName( "addr" ), aPos ); return aPos; } -Range RecordObjectBase::dumpRange( const sal_Char* pcName ) +Range RecordObjectBase::dumpRange( const String& rName ) { Range aRange; readRange( aRange ); - writeRangeItem( pcName ? pcName : "range", aRange ); + writeRangeItem( rName( "range" ), aRange ); return aRange; } -void RecordObjectBase::dumpRangeList( const sal_Char* pcName ) +void RecordObjectBase::dumpRangeList( const String& rName ) { RangeList aRanges; readRangeList( aRanges ); - writeRangeListItem( pcName ? pcName : "range-list", aRanges ); + writeRangeListItem( rName( "range-list" ), aRanges ); } -// ---------------------------------------------------------------------------- +// private -------------------------------------------------------------------- -void RecordObjectBase::constructRecObjBase() +bool RecordObjectBase::readCompressedInt( BinaryInputStream& rStrm, sal_Int32& ornValue ) { - if( RecordObjectBase::implIsValid() ) - mxErrCodes = cfg().getNameList( "ERRORCODES" ); + ornValue = 0; + sal_uInt8 nByte; + rStrm >> nByte; + ornValue = nByte & 0x7F; + if( (nByte & 0x80) != 0 ) + { + rStrm >> nByte; + ornValue |= sal_Int32( nByte & 0x7F ) << 7; + if( (nByte & 0x80) != 0 ) + { + rStrm >> nByte; + ornValue |= sal_Int32( nByte & 0x7F ) << 14; + if( (nByte & 0x80) != 0 ) + { + rStrm >> nByte; + ornValue |= sal_Int32( nByte & 0x7F ) << 21; + } + } + } + return !rStrm.isEof(); } // ============================================================================ FormulaObject::FormulaObject( const RecordObjectBase& rParent ) : - mpcName( 0 ), mnSize( 0 ) { RecordObjectBase::construct( rParent ); @@ -372,28 +337,28 @@ FormulaObject::~FormulaObject() { } -void FormulaObject::dumpCellFormula( const sal_Char* pcName ) +void FormulaObject::dumpCellFormula( const String& rName ) { - dumpFormula( pcName, false ); + dumpFormula( rName, false ); } -void FormulaObject::dumpNameFormula( const sal_Char* pcName ) +void FormulaObject::dumpNameFormula( const String& rName ) { - dumpFormula( pcName, true ); + dumpFormula( rName, true ); } void FormulaObject::implDump() { { MultiItemsGuard aMultiGuard( out() ); - writeEmptyItem( mpcName ); + writeEmptyItem( maName ); writeDecItem( "formula-size", mnSize ); } if( mnSize < 0 ) return; - Input& rIn = in(); - sal_Int64 nStartPos = rIn.tell(); - sal_Int64 nEndPos = ::std::min< sal_Int64 >( nStartPos + mnSize, rIn.getSize() ); + BinaryInputStream& rStrm = in(); + sal_Int64 nStartPos = rStrm.tell(); + sal_Int64 nEndPos = ::std::min< sal_Int64 >( nStartPos + mnSize, rStrm.getLength() ); bool bValid = mxTokens.get(); mxStack.reset( new FormulaStack ); @@ -401,11 +366,11 @@ void FormulaObject::implDump() IndentGuard aIndGuard( out() ); { TableGuard aTabGuard( out(), 8, 18 ); - while( bValid && (rIn.tell() < nEndPos) ) + while( bValid && (rStrm.tell() < nEndPos) ) { MultiItemsGuard aMultiGuard( out() ); - writeHexItem( 0, static_cast< sal_uInt16 >( rIn.tell() - nStartPos ) ); - sal_uInt8 nTokenId = dumpHex< sal_uInt8 >( 0, mxTokens ); + writeHexItem( EMPTY_STRING, static_cast< sal_uInt16 >( rStrm.tell() - nStartPos ) ); + sal_uInt8 nTokenId = dumpHex< sal_uInt8 >( EMPTY_STRING, mxTokens ); bValid = mxTokens->hasName( nTokenId ); if( bValid ) { @@ -479,7 +444,7 @@ void FormulaObject::implDump() } } - if( nEndPos == rIn.tell() ) + if( nEndPos == rStrm.tell() ) { dumpAddTokenData(); if( mnSize > 0 ) @@ -490,18 +455,17 @@ void FormulaObject::implDump() } else { - dumpBinary( OOX_DUMP_ERRASCII( "formula-error" ), static_cast< sal_Int32 >( nEndPos - rIn.tell() ), false ); + dumpBinary( OOX_DUMP_ERRASCII( "formula-error" ), static_cast< sal_Int32 >( nEndPos - rStrm.tell() ), false ); sal_Int32 nAddDataSize = dumpDec< sal_Int32 >( "add-data-size" ); dumpBinary( "add-data", nAddDataSize, false ); } - mpcName = 0; mnSize = 0; } -void FormulaObject::dumpFormula( const sal_Char* pcName, bool bNameMode ) +void FormulaObject::dumpFormula( const String& rName, bool bNameMode ) { - mpcName = pcName ? pcName : "formula"; + maName = rName( "formula" ); in() >> mnSize; mbNameMode = bNameMode; dump(); @@ -513,8 +477,7 @@ void FormulaObject::constructFmlaObj() { if( RecordObjectBase::implIsValid() ) { - Reference< XSpreadsheetDocument > xDocument( getFilter().getModel(), UNO_QUERY ); - mxFuncProv.reset( new FunctionProvider( xDocument, true ) ); + mxFuncProv.reset( new FunctionProvider( FILTER_OOX, BIFF_UNKNOWN, true ) ); Config& rCfg = cfg(); mxClasses = rCfg.getNameList( "TOKENCLASSES" ); @@ -590,7 +553,7 @@ OUString FormulaObject::createPlaceHolder() const OUString FormulaObject::writeFuncIdItem( sal_uInt16 nFuncId, const FunctionInfo** oppFuncInfo ) { ItemGuard aItemGuard( out(), "func-id" ); - writeHexItem( 0, nFuncId, "FUNCID" ); + writeHexItem( EMPTY_STRING, nFuncId, "FUNCID" ); OUStringBuffer aBuffer; const FunctionInfo* pFuncInfo = mxFuncProv->getFuncInfoFromOobFuncId( nFuncId ); if( pFuncInfo ) @@ -603,23 +566,25 @@ OUString FormulaObject::writeFuncIdItem( sal_uInt16 nFuncId, const FunctionInfo* } OUString aFuncName = aBuffer.makeStringAndClear(); aItemGuard.cont(); + out().writeChar( OOX_DUMP_STRQUOTE ); out().writeString( aFuncName ); + out().writeChar( OOX_DUMP_STRQUOTE ); if( oppFuncInfo ) *oppFuncInfo = pFuncInfo; return aFuncName; } -sal_Int32 FormulaObject::dumpTokenCol( const sal_Char* pcName, bool& rbRelC, bool& rbRelR ) +sal_Int32 FormulaObject::dumpTokenCol( const String& rName, bool& rbRelC, bool& rbRelR ) { - sal_uInt16 nCol = dumpHex< sal_uInt16 >( pcName, mxRelFlags ); + sal_uInt16 nCol = dumpHex< sal_uInt16 >( rName, mxRelFlags ); rbRelC = getFlag( nCol, OOBIN_TOK_REF_COLREL ); rbRelR = getFlag( nCol, OOBIN_TOK_REF_ROWREL ); nCol &= OOBIN_TOK_REF_COLMASK; return nCol; } -sal_Int32 FormulaObject::dumpTokenRow( const sal_Char* pcName ) +sal_Int32 FormulaObject::dumpTokenRow( const String& rName ) { - return dumpDec< sal_Int32 >( pcName ); + return dumpDec< sal_Int32 >( rName ); } TokenAddress FormulaObject::dumpTokenAddress( bool bNameMode ) @@ -772,22 +737,22 @@ void FormulaObject::dumpMemAreaToken( const OUString& rTokClass, bool bAddData ) maAddData.push_back( ADDDATA_MEMAREA ); } -void FormulaObject::dumpExpToken( const StringWrapper& rName ) +void FormulaObject::dumpExpToken( const String& rName ) { Address aPos; dumpRowIndex( "base-row" ); - OUStringBuffer aOp( rName.getString() ); + OUStringBuffer aOp( rName ); StringHelper::appendIndex( aOp, createPlaceHolder() + out().getLastItemValue() ); mxStack->pushOperand( aOp.makeStringAndClear() ); maAddData.push_back( ADDDATA_EXP ); } -void FormulaObject::dumpUnaryOpToken( const StringWrapper& rLOp, const StringWrapper& rROp ) +void FormulaObject::dumpUnaryOpToken( const String& rLOp, const String& rROp ) { mxStack->pushUnaryOp( rLOp, rROp ); } -void FormulaObject::dumpBinaryOpToken( const StringWrapper& rOp ) +void FormulaObject::dumpBinaryOpToken( const String& rOp ) { mxStack->pushBinaryOp( rOp ); } @@ -916,10 +881,10 @@ void FormulaObject::dumpAddTokenData() { Output& rOut = out(); rOut.resetItemIndex(); - Input& rIn = in(); - sal_Int32 nAddDataSize = (in().getSize() - in().tell() >= 4) ? dumpDec< sal_Int32 >( "add-data-size" ) : 0; - sal_Int64 nEndPos = ::std::min< sal_Int64 >( rIn.tell() + nAddDataSize, rIn.getSize() ); - for( AddDataTypeVec::const_iterator aIt = maAddData.begin(), aEnd = maAddData.end(); (aIt != aEnd) && rIn.isValidPos() && (rIn.tell() < nEndPos); ++aIt ) + BinaryInputStream& rStrm = in(); + sal_Int32 nAddDataSize = (in().getLength() - in().tell() >= 4) ? dumpDec< sal_Int32 >( "add-data-size" ) : 0; + sal_Int64 nEndPos = ::std::min< sal_Int64 >( rStrm.tell() + nAddDataSize, rStrm.getLength() ); + for( AddDataTypeVec::const_iterator aIt = maAddData.begin(), aEnd = maAddData.end(); (aIt != aEnd) && !rStrm.isEof() && (rStrm.tell() < nEndPos); ++aIt ) { AddDataType eType = *aIt; @@ -1018,61 +983,21 @@ OUString FormulaObject::dumpaddDataArrayValue() // ============================================================================ -RecordObject::RecordObject( OutputObjectBase& rParent ) +RecordStreamObject::RecordStreamObject( ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName ) { - RecordObjectBase::construct( rParent ); + RecordObjectBase::construct( rParent, rxStrm, rSysFileName ); if( RecordObjectBase::implIsValid() ) - { mxFmlaObj.reset( new FormulaObject( *this ) ); - mxSimpleRecs = cfg().getNameList( "SIMPLE-RECORDS" ); - } } -void RecordObject::dumpRecord( const RecordDataSequence& rData, sal_Int32 nRecId ) -{ - createRecordStream( rData ); - mnRecId = nRecId; - dump(); -} - -bool RecordObject::implIsValid() const +bool RecordStreamObject::implIsValid() const { return isValid( mxFmlaObj ) && RecordObjectBase::implIsValid(); } -void RecordObject::implDump() +void RecordStreamObject::implDumpRecordBody() { - if( cfg().hasName( mxSimpleRecs, mnRecId ) ) - dumpSimpleRecord( cfg().getName( mxSimpleRecs, mnRecId ) ); - else - dumpRecordBody(); - - // remaining undumped data - RecordInputStream& rStrm = getRecordStream(); - if( rStrm.getRecPos() == 0 ) - dumpRawBinary( rStrm.getRecSize(), false ); - else - dumpRemaining( rStrm.getRecLeft() ); - if( !rStrm.isValid() ) - writeInfoItem( "stream-state", OOX_DUMP_ERR_STREAM ); -} - -void RecordObject::dumpCellHeader( bool bWithColumn ) -{ - if( bWithColumn ) dumpColIndex(); - dumpHex< sal_uInt32 >( "xf-id", "CELL-XFID" ); -} - -void RecordObject::dumpSimpleRecord( const OUString& rRecData ) -{ - ItemFormat aItemFmt; - aItemFmt.parse( rRecData ); - dumpItem( aItemFmt ); -} - -void RecordObject::dumpRecordBody() -{ - switch( mnRecId ) + switch( getRecId() ) { case OOBIN_ID_ARRAY: dumpRange( "array-range" ); @@ -1212,11 +1137,11 @@ void RecordObject::dumpRecordBody() dumpDec< sal_Int32 >( "formula2-size" ); dumpDec< sal_Int32 >( "formula3-size" ); dumpString( "text" ); - if( in().getSize() - in().tell() >= 8 ) + if( in().getLength() - in().tell() >= 8 ) mxFmlaObj->dumpNameFormula( "formula1" ); - if( in().getSize() - in().tell() >= 8 ) + if( in().getLength() - in().tell() >= 8 ) mxFmlaObj->dumpNameFormula( "formula2" ); - if( in().getSize() - in().tell() >= 8 ) + if( in().getLength() - in().tell() >= 8 ) mxFmlaObj->dumpNameFormula( "formula3" ); } break; @@ -1272,6 +1197,12 @@ void RecordObject::dumpRecordBody() dumpRangeList(); break; + case OOBIN_ID_CONTROL: + dumpDec< sal_Int32 >( "shape-id" ); + dumpString( "rel-id" ); + dumpString( "name" ); + break; + case OOBIN_ID_DATATABLE: dumpRange( "table-range" ); dumpAddress( "ref1" ); @@ -1309,15 +1240,15 @@ void RecordObject::dumpRecordBody() case OOBIN_ID_DEFINEDNAME: dumpHex< sal_uInt32 >( "flags", "DEFINEDNAME-FLAGS" ); - dumpHex< sal_uInt8 >( "keyboard-shortcut" ); + dumpChar( "accelerator", RTL_TEXTENCODING_ISO_8859_1 ); dumpDec< sal_Int32 >( "sheet-id", "DEFINEDNAME-SHEETID" ); dumpString( "name" ); mxFmlaObj->dumpNameFormula(); dumpString( "comment" ); - if( in().getSize() - in().tell() >= 4 ) dumpString( "menu-text" ); - if( in().getSize() - in().tell() >= 4 ) dumpString( "description-text" ); - if( in().getSize() - in().tell() >= 4 ) dumpString( "help-text" ); - if( in().getSize() - in().tell() >= 4 ) dumpString( "statusbar-text" ); + if( in().getLength() - in().tell() >= 4 ) dumpString( "menu-text" ); + if( in().getLength() - in().tell() >= 4 ) dumpString( "description-text" ); + if( in().getLength() - in().tell() >= 4 ) dumpString( "help-text" ); + if( in().getLength() - in().tell() >= 4 ) dumpString( "statusbar-text" ); break; case OOBIN_ID_DIMENSION: @@ -1330,7 +1261,7 @@ void RecordObject::dumpRecordBody() case OOBIN_ID_DXF: dumpHex< sal_uInt32 >( "flags", "DXF-FLAGS" ); - for( sal_uInt16 nIndex = 0, nCount = dumpDec< sal_uInt16 >( "subrec-count" ); in().isValidPos() && (nIndex < nCount); ++nIndex ) + for( sal_uInt16 nIndex = 0, nCount = dumpDec< sal_uInt16 >( "subrec-count" ); !in().isEof() && (nIndex < nCount); ++nIndex ) { out().startMultiItems(); sal_Int64 nStartPos = in().tell(); @@ -1445,9 +1376,7 @@ void RecordObject::dumpRecordBody() dumpBoolean( "value" ); break; } - if( in().tell() < nEndPos ) - dumpRemaining( static_cast< sal_Int32 >( nEndPos - in().tell() ) ); - in().seek( nEndPos ); + dumpRemainingTo( nEndPos ); } break; @@ -1508,7 +1437,7 @@ void RecordObject::dumpRecordBody() sal_Int32 nCount = dumpDec< sal_Int32 >( "ref-count" ); TableGuard aTabGuard( out(), 13, 17, 24 ); out().resetItemIndex(); - for( sal_Int32 nRefId = 0; in().isValidPos() && (nRefId < nCount); ++nRefId ) + for( sal_Int32 nRefId = 0; !in().isEof() && (nRefId < nCount); ++nRefId ) { MultiItemsGuard aMultiGuard( out() ); writeEmptyItem( "#ref" ); @@ -1530,7 +1459,7 @@ void RecordObject::dumpRecordBody() case OOBIN_ID_EXTSHEETNAMES: out().resetItemIndex(); - for( sal_Int32 nSheet = 0, nCount = dumpDec< sal_Int32 >( "sheet-count" ); in().isValidPos() && (nSheet < nCount); ++nSheet ) + for( sal_Int32 nSheet = 0, nCount = dumpDec< sal_Int32 >( "sheet-count" ); !in().isEof() && (nSheet < nCount); ++nSheet ) dumpString( "#sheet-name" ); break; @@ -1545,7 +1474,7 @@ void RecordObject::dumpRecordBody() dumpDec< double >( "pos-top" ); dumpDec< double >( "pos-bottom" ); out().resetItemIndex(); - for( sal_Int32 nStop = 0, nStopCount = dumpDec< sal_Int32 >( "stop-count" ); (nStop < nStopCount) && in().isValidPos(); ++nStop ) + for( sal_Int32 nStop = 0, nStopCount = dumpDec< sal_Int32 >( "stop-count" ); (nStop < nStopCount) && !in().isEof(); ++nStop ) { writeEmptyItem( "#stop" ); IndentGuard aIndGuard( out() ); @@ -1626,6 +1555,10 @@ void RecordObject::dumpRecordBody() dumpString( "display" ); break; + case OOBIN_ID_LEGACYDRAWING: + dumpString( "rel-id" ); + break; + case OOBIN_ID_MERGECELL: dumpRange(); break; @@ -1674,6 +1607,20 @@ void RecordObject::dumpRecordBody() dumpString( "format" ); break; + case OOBIN_ID_OLEOBJECT: + { + dumpDec< sal_Int32 >( "aspect", "OLEOBJECT-ASPECT" ); + dumpDec< sal_Int32 >( "update", "OLEOBJECT-UPDATE" ); + dumpDec< sal_Int32 >( "shape-id" ); + sal_uInt16 nFlags = dumpHex< sal_uInt16 >( "flags", "OLEOBJECT-FLAGS" ); + dumpString( "prog-id" ); + if( getFlag( nFlags, OOBIN_OLEOBJECT_LINKED ) ) + mxFmlaObj->dumpNameFormula( "link" ); + else + dumpString( "rel-id" ); + } + break; + case OOBIN_ID_PAGEMARGINS: dumpDec< double >( "left-margin" ); dumpDec< double >( "right-margin" ); @@ -1721,7 +1668,7 @@ void RecordObject::dumpRecordBody() dumpHex< sal_uInt16 >( "flags", "ROW-FLAGS1" ); dumpHex< sal_uInt8 >( "flags", "ROW-FLAGS2" ); out().resetItemIndex(); - for( sal_Int32 nSpan = 0, nSpanCount = dumpDec< sal_Int32 >( "row-spans-count" ); in().isValidPos() && (nSpan < nSpanCount); ++nSpan ) + for( sal_Int32 nSpan = 0, nSpanCount = dumpDec< sal_Int32 >( "row-spans-count" ); !in().isEof() && (nSpan < nSpanCount); ++nSpan ) dumpRowRange( "#row-spans" ); break; @@ -1881,112 +1828,63 @@ void RecordObject::dumpRecordBody() } } -// ============================================================================ - -RecordHeaderObject::RecordHeaderObject( const InputObjectBase& rParent ) -{ - static const RecordHeaderConfigInfo saHeaderCfgInfo = - { - "REC", - "RECORD-NAMES", - "show-record-pos", - "show-record-size", - "show-record-id", - "show-record-name", - "show-record-body", - }; - RecordHeaderBase< sal_Int32, sal_Int32 >::construct( rParent, saHeaderCfgInfo ); -} - -RecordHeaderObject::~RecordHeaderObject() -{ -} - -bool RecordHeaderObject::implReadHeader( sal_Int64& ornRecPos, sal_Int32& ornRecId, sal_Int32& ornRecSize ) +void RecordStreamObject::dumpCellHeader( bool bWithColumn ) { - bool bValidRec = readCompressedInt( ornRecPos, ornRecId ) && (ornRecId >= 0) && readCompressedInt( ornRecPos, ornRecSize ) && (ornRecSize >= 0); - if( bValidRec ) - { - maData.realloc( ornRecSize ); - bValidRec = (ornRecSize == 0) || (in().read( maData.getArray(), ornRecSize ) == ornRecSize); - ornRecPos += ornRecSize; - } - return bValidRec; + if( bWithColumn ) dumpColIndex(); + dumpHex< sal_uInt32 >( "xf-id", "CELL-XFID" ); } -bool RecordHeaderObject::readByte( sal_Int64& ornRecPos, sal_uInt8& ornByte ) -{ - ++ornRecPos; - return in().read( &ornByte, 1 ) == 1; -} +// ============================================================================ -bool RecordHeaderObject::readCompressedInt( sal_Int64& ornRecPos, sal_Int32& ornValue ) +RootStorageObject::RootStorageObject( const DumperBase& rParent ) { - ornValue = 0; - sal_uInt8 nByte; - if( !readByte( ornRecPos, nByte ) ) return false; - ornValue = nByte & 0x7F; - if( (nByte & 0x80) == 0 ) return true; - if( !readByte( ornRecPos, nByte ) ) return false; - ornValue |= sal_Int32( nByte & 0x7F ) << 7; - if( (nByte & 0x80) == 0 ) return true; - if( !readByte( ornRecPos, nByte ) ) return false; - ornValue |= sal_Int32( nByte & 0x7F ) << 14; - if( (nByte & 0x80) == 0 ) return true; - if( !readByte( ornRecPos, nByte ) ) return false; - ornValue |= sal_Int32( nByte & 0x7F ) << 21; - return true; + StorageObjectBase::construct( rParent ); } -// ============================================================================ - -RecordStreamObject::RecordStreamObject( const ObjectBase& rParent, const OUString& rOutFileName, BinaryInputStreamRef xStrm ) +void RootStorageObject::implDumpStream( const BinaryInputStreamRef& rxStrm, const OUString& rStrgPath, const OUString& rStrmName, const OUString& rSysFileName ) { - InputStreamObject::construct( rParent, rOutFileName, xStrm ); - if( InputStreamObject::implIsValid() ) + OUString aExt = InputOutputHelper::getFileNameExtension( rStrmName ); + Reference< XInputStream > xInStrm = InputOutputHelper::getXInputStream( *rxStrm ); + if( + aExt.equalsIgnoreAsciiCaseAscii( "xlsb" ) || + aExt.equalsIgnoreAsciiCaseAscii( "xlsm" ) || + aExt.equalsIgnoreAsciiCaseAscii( "xlsx" ) || + aExt.equalsIgnoreAsciiCaseAscii( "xltm" ) || + aExt.equalsIgnoreAsciiCaseAscii( "xltx" ) ) { - mxHdrObj.reset( new RecordHeaderObject( *this ) ); - mxRecObj.reset( new RecordObject( *this ) ); + Dumper( getFactory(), xInStrm, rSysFileName ).dump(); } -} - -bool RecordStreamObject::implIsValid() const -{ - return isValid( mxHdrObj ) && isValid( mxRecObj ) && InputStreamObject::implIsValid(); -} - -void RecordStreamObject::implDump() -{ - while( mxHdrObj->startNextRecord() ) + else if( + aExt.equalsIgnoreAsciiCaseAscii( "xla" ) || + aExt.equalsIgnoreAsciiCaseAscii( "xlc" ) || + aExt.equalsIgnoreAsciiCaseAscii( "xlm" ) || + aExt.equalsIgnoreAsciiCaseAscii( "xls" ) || + aExt.equalsIgnoreAsciiCaseAscii( "xlt" ) || + aExt.equalsIgnoreAsciiCaseAscii( "xlw" ) ) { - if( mxHdrObj->isShowRecBody() ) - { - IndentGuard aIndGuard( out() ); - mxRecObj->dumpRecord( mxHdrObj->getRecordData(), mxHdrObj->getRecId() ); - } - out().emptyLine(); + ::oox::dump::biff::Dumper( getFactory(), xInStrm, rSysFileName ).dump(); } -} - -// ============================================================================ - -RootStorageObject::RootStorageObject( const DumperBase& rParent ) -{ - RootStorageObjectBase::construct( rParent ); -} - -void RootStorageObject::implDumpStream( BinaryInputStreamRef xStrm, const OUString& rStrgPath, const OUString& rStrmName, const OUString& rSystemFileName ) -{ - OUString aExt = InputOutputHelper::getFileNameExtension( rStrmName ); - if( aExt.equalsIgnoreAsciiCaseAscii( "xml" ) || + else if( + aExt.equalsIgnoreAsciiCaseAscii( "xml" ) || aExt.equalsIgnoreAsciiCaseAscii( "vml" ) || aExt.equalsIgnoreAsciiCaseAscii( "rels" ) ) { - XmlStreamObject( *this, rSystemFileName, xStrm ).dump(); + XmlStreamObject( *this, rxStrm, rSysFileName ).dump(); } else if( aExt.equalsIgnoreAsciiCaseAscii( "bin" ) ) { - if( rStrgPath.equalsAscii( "xl" ) || + if( rStrgPath.equalsAscii( "xl" ) && rStrmName.equalsAscii( "vbaProject.bin" ) ) + { + StorageRef xStrg( new OleStorage( getFactory(), xInStrm, false ) ); + VbaProjectStorageObject( *this, xStrg, rSysFileName ).dump(); + } + else if( rStrgPath.equalsAscii( "xl/embeddings" ) ) + { + StorageRef xStrg( new OleStorage( getFactory(), xInStrm, false ) ); + OleStorageObject( *this, xStrg, rSysFileName ).dump(); + } + else if( + rStrgPath.equalsAscii( "xl" ) || rStrgPath.equalsAscii( "xl/chartsheets" ) || rStrgPath.equalsAscii( "xl/dialogsheets" ) || rStrgPath.equalsAscii( "xl/externalLinks" ) || @@ -1994,17 +1892,33 @@ void RootStorageObject::implDumpStream( BinaryInputStreamRef xStrm, const OUStri rStrgPath.equalsAscii( "xl/tables" ) || rStrgPath.equalsAscii( "xl/worksheets" ) ) { - RecordStreamObject( *this, rSystemFileName, xStrm ).dump(); + RecordStreamObject( *this, rxStrm, rSysFileName ).dump(); + } + else + { + BinaryStreamObject( *this, rxStrm, rSysFileName ).dump(); } } } // ============================================================================ +#define DUMP_XLSB_CONFIG_ENVVAR "OOO_XLSBDUMPER" + Dumper::Dumper( const FilterBase& rFilter ) { - ConfigRef xCfg( new Config( "OOO_XLSBDUMPER" ) ); - DumperBase::construct( rFilter, xCfg ); + ConfigRef xCfg( new Config( DUMP_XLSB_CONFIG_ENVVAR, rFilter ) ); + DumperBase::construct( xCfg ); +} + +Dumper::Dumper( const Reference< XMultiServiceFactory >& rxFactory, const Reference< XInputStream >& rxInStrm, const OUString& rSysFileName ) +{ + if( rxFactory.is() && rxInStrm.is() ) + { + StorageRef xStrg( new ZipStorage( rxFactory, rxInStrm ) ); + ConfigRef xCfg( new Config( DUMP_XLSB_CONFIG_ENVVAR, rxFactory, xStrg, rSysFileName ) ); + DumperBase::construct( xCfg ); + } } void Dumper::implDump() diff --git a/oox/source/dump/xlsbdumper.ini b/oox/source/dump/xlsbdumper.ini new file mode 100644 index 000000000000..f8253ab40351 --- /dev/null +++ b/oox/source/dump/xlsbdumper.ini @@ -0,0 +1,716 @@ + +# dumper settings ============================================================ + +# Path to additional configuration data, relative to this file. +include-config-file=dumperbase.ini +include-config-file=oledumper.ini + +# Enable entire dumper (default=off). This option does not affect the option +# 'enable-import'. +# 0=off, 1=on, missing: setting from dumperbase.ini +# enable-dumper=1 + +# Enable import after dumping (default=on). Disabling this option allows +# to dump a file without loading it. This option is independent from the +# 'enable-dumper' option. +# 0=off, 1=on, missing: setting from dumperbase.ini +# enable-import=1 + +# name lists ================================================================= + +# common --------------------------------------------------------------------- + +unitconverter=CONV-TINT,/327.67,% +unitconverter=CONV-COLWIDTH,/256,chars + +constlist=ERRORCODES + 0x00=#NULL! + 0x07=#DIV/0! + 0x0F=#VALUE! + 0x17=#REF! + 0x1D=#NAME? + 0x24=#NUM! + 0x2A=#N/A +end + +flagslist=STRING-FLAGS + 0x01=rich-string + 0x02=phonetic-text +end + +combilist=CELL-XFID + 0x00FFFFFF=int32,dec,xf-id + 0x01000000=show-phonetic +end + +combilist=PHONETIC-FLAGS + ignore=0x0030 + 0x0003=uint8,dec,type,PHONETICPR-TYPE + 0x000C=uint8,dec,alignment,PHONETICPR-ALIGNMENT +end + +shortlist=COLOR-TYPE,0,auto,indexed,rgb,theme + +combilist=COLOR-FLAGS + 0x01=rgb-valid + 0xFE=uint8,dec,type,COLOR-TYPE +end + +multilist=PALETTE-COLORS + default= + 0=ega-black,ega-white,ega-red,ega-green,ega-blue,ega-yellow,ega-magenta,ega-cyan + 64=sys-window-text + 65=sys-window-bg + 67=sys-button-face + 77=sys-window-text-chart + 78=sys-window-bg-chart + 79=auto-border-chart + 80=sys-tooltip-bg + 81=sys-tooltip-text +end + +constlist=TEXTROTATION + default= + 255=stacked +end + +multilist=BORDERSTYLES + 0=none,thin,medium,dash,dot + 5=thick,double,hair,medium-dash,thin-dash-dot + 10=medium-dash-dot,thin-dash-dot-dot,medium-dash-dot-dot,slant-dash-dot +end + +multilist=FILLPATTERNS + 0=no-fill,solid-fill,50%-grey,75%-grey,25%-grey + 5=hor-stripe,ver-stripe,rev-diag-stripe,diag-stripe,diag-crosshatch + 10=thick-diag-crosshatch,thin-hor-stripe,thin-ver-stripe,thin-rev-diag-stripe,thin-diag-stripe + 15=thin-hor-crosshatch,thin-diag-crosshatch,12.5%-grey,6.25%-grey + 40=gradient +end + +# formulas ------------------------------------------------------------------- + +flagslist=FORMULA-FLAGS + 0x0002=recalc-always +end + +multilist=BASETOKENS + 0x00=,tExp,tTbl,tAdd,tSub,tMul,tDiv,tPower + 0x08=tConcat,tLT,tLE,tEQ,tGE,tGT,tNE,tIsect + 0x10=tList,tRange,tUplus,tUminus,tPercent,tParen,tMissArg,tStr + 0x18=tTable,tAttr,,,tErr,tBool,tInt,tNum +end + +constlist=TOKENCLASSES + 0x20=R + 0x40=V + 0x60=A +end + +multilist=CLASSTOKENS + 0x00=tArray,tFunc,tFuncVar,tName,tRef,tArea,tMemArea,tMemErr + 0x08=tMemNoMem,tMemFunc,tRefErr,tAreaErr,tRefN,tAreaN,tMemAreaN,tMemNoMemN + 0x18=,tNameX,tRef3d,tArea3d,tRefErr3d,tAreaErr3d +end + +combilist=FUNCID + 0x7FFF=uint16,dec,func-id + 0x8000=command +end + +combilist=PARAMCOUNT-CMD + 0x7F=uint8,dec,count + 0x80=prompt +end + +combilist=REFRELFLAGS + 0x3FFF=uint16,dec,value + 0x4000=col-rel + 0x8000=row-rel +end + +flagslist=TABLEFLAGS + 0x0001=single-column + 0x0002=column-range + 0x0004=#all + 0x0008=#headers + 0x0010=#data + 0x0020=#totals + 0x0040=#this-row + 0x0080=bracket-spaces + 0x0100=sep-spaces + 0x0200=single-row + 0x0400=single-cell +end + +flagslist=ATTRTYPES + 0x01=volatile + 0x02=if + 0x04=choose + 0x08=skip + 0x10=sum + 0x20=assign + 0x40=space + 0x80=iferror +end + +shortlist=ATTRSPACETYPES,0,space-before-token,cr-before-token,space-before-open,cr-before-open,space-before-close,cr-before-close,leading-space + +shortlist=ARRAYVALUE-TYPE,0,number,string,boolean,,error + +# record names --------------------------------------------------------------- + +multilist=RECORD-NAMES + 0x0000=ROW,CELL_BLANK,CELL_RK,CELL_ERROR,CELL_BOOL,CELL_DOUBLE,CELL_STRING,CELL_SI + 0x0008=FORMULA_STRING,FORMULA_DOUBLE,FORMULA_BOOL,FORMULA_ERROR,MULTCELL_BLANK,MULTCELL_RK,MULTCELL_ERROR,MULTCELL_BOOL + 0x0010=MULTCELL_DOUBLE,MULTCELL_STRING,MULTCELL_SI,SI,,,, + + 0x0020=,,,,,,,DEFINEDNAME + 0x0028=BINARYINDEXROWS,,BINARYINDEXBLOCK,FONT,NUMFMT,FILL,BORDER,XF + 0x0030=CELLSTYLE,,,,,,, + 0x0038=,,,,COL,MULTCELL_RSTRING,CELL_RSTRING,CALCCHAINCELL + 0x0040=DATAVALIDATION,,,,,,, + + 0x0080=FILEVERSION,WORKSHEET,WORKSHEET_END,WORKBOOK,WORKBOOK_END,SHEETVIEWS,SHEETVIEWS_END,BOOKVIEWS + 0x0088=BOOKVIEWS_END,SHEETVIEW,SHEETVIEW_END,CHARTSHEETVIEWS,CHARTSHEETVIEWS_END,CHARTSHEETVIEW,CHARTSHEETVIEW_END,SHEETS + 0x0090=SHEETS_END,SHEETDATA,SHEETDATA_END,SHEETPR,DIMENSION,,,PANE + 0x0098=SELECTION,WORKBOOKPR,SMARTTAGPR,FILERECOVERYPR,SHEET,CALCPR,WORKBOOKVIEW,SST + 0x00A0=SST_END,AUTOFILTER,AUTOFILTER_END,FILTERCOLUMN,FILTERCOLUMN_END,,, + + 0x00B0=,MERGECELLS,MERGECELLS_END,,,,, + + 0x0110=,,,,,BINARYINDEX_END,STYLESHEET,STYLESHEET_END + + 0x0150=,,,,,,,TABLE + 0x0158=TABLE_END,TABLECOLUMNS,TABLECOLUMNS_END,TABLECOLUMN,TABLECOLUMN_END,,,CALCEDCOLUMNFMLA + 0x0160=,EXTERNALREFS,EXTERNALREFS_END,EXTERNALREF,,EXTERNALSELF,EXTERNALSAME,EXTSHEETNAMES + 0x0168=EXTERNALBOOK,,EXTERNALSHEETS,EXTSHEETDATA,EXTSHEETDATA_END,,EXTROW,EXTCELL_BLANK + 0x0170=EXTCELL_DOUBLE,EXTCELL_BOOL,EXTCELL_ERROR,EXTCELL_STRING,,,, + + 0x0180=,,,,,,COLS,COLS_END + 0x0188=ROWBREAKS,ROWBREAKS_END,COLBREAKS,COLBREAKS_END,BRK,CUSTOMWORKBOOKVIEW,, + + 0x01A0=,,,,,,CUSTOMSHEETVIEWS,CUSTOMSHEETVIEW + 0x01A8=CUSTOMSHEETVIEW_END,CUSTOMSHEETVIEWS_END,ARRAY,SHAREDFMLA,DATATABLE,,, + + 0x01C8=,,,,,CONDFORMATTING,CONDFORMATTING_END,CFRULE + 0x01D0=CFRULE_END,ICONSET,ICONSET_END,DATABAR,DATABAR_END,COLORSCALE,COLORSCALE_END,CFVO + 0x01D8=,COLORS,COLORS_END,RGBCOLOR,PAGEMARGINS,PRINTOPTIONS,PAGESETUP,HEADERFOOTER + 0x01E0=HEADERFOOTER_END,,,,,SHEETFORMATPR,, + 0x01E8=,,,,,,HYPERLINK, + + 0x01F8=,DXFS,DXFS_END,DXF,TABLESTYLES,TABLESTYLES_END,, + 0x0200=,TABLESTYLEINFO,VOLTYPES,VOLTYPES_END,VOLTYPE,VOLTYPE_END,VOLTYPEMAIN,VOLTYPEMAIN_END + 0x0208=VOLTYPETP,VOLTYPETP_END,VOLTYPESTP,VOLTYPETR,,VOLTYPE_ERROR,, + 0x0210=CALCCHAIN,CALCCHAIN_END,,,,,,SHEETPROTECTION + 0x0218=,PHONETICPR,,,,,, + 0x0220=,,,,,,DRAWING,LEGACYDRAWING + + 0x0230=,,PICTURE,,CFCOLOR,INDEXEDCOLORS,INDEXEDCOLORS_END, + 0x0238=,MRUCOLORS,MRUCOLORS_END,,COLOR,DATAVALIDATIONS,DATAVALIDATIONS_END, + 0x0240=,EXTERNALNAME,DDEITEMVALUES,DDEITEMVALUES_END,DDEITEM_DOUBLE,DDEITEM_ERROR,DDEITEM_STRING,DDEITEM_EMPTY + 0x0248=DDEITEM_BOOL,EXTERNALNAMEREF,EXTERNALNAMEFLAGS,EXTERNALNAME_END,EXTERNALBOOK_END,,, + + 0x0258=,,,FILLS,FILLS_END,,, + 0x0260=,,,FONTS,FONTS_END,BORDERS,BORDERS_END,NUMFMTS + 0x0268=NUMFMTS_END,CELLXFS,CELLXFS_END,CELLSTYLES,CELLSTYLES_END,,, + 0x0270=,,CELLSTYLEXFS,CELLSTYLEXFS_END + 0x0278=,,,,,,OLEOBJECTS,OLEOBJECT + 0x0280=OLEOBJECTS_END,,,CONTROLS,CONTROL,CONTROLS_END,, + 0x0288=,,,CHARTSHEETPR,CHARTPAGESETUP,CUSTOMCHARTVIEWS,CUSTOMCHARTVIEWS_END,CUSTOMCHARTVIEW + 0x0290=CUSTOMCHARTVIEW_END,,,,TABLEPARTS,TABLEPART,TABLEPARTS_END,SHEETCALCPR + 0x0298=FUNCTIONGROUPS,FUNCTIONGROUP,FUNCTIONGROUPS_END,EXTERNALADDIN,,CHARTPROTECTION,, +end + +# simple records ------------------------------------------------------------- + +constlist=SIMPLE-RECORDS + 0x0159=int32,dec,count + 0x01DD=uint16,hex,flags,PRINTOPTIONS-FLAGS + 0x01F9=int32,dec,count + 0x0204=int32,dec,type,VOLTYPE-TYPE + 0x020D=uint8,dec,error-code,ERRORCODES + 0x0244=double,dec,value + 0x0245=uint8,dec,error-code,ERRORCODES + 0x0248=uint8,dec,value,BOOLEAN + 0x025B=int32,dec,count + 0x0263=int32,dec,count + 0x0265=int32,dec,count + 0x0267=int32,dec,count + 0x0269=int32,dec,count + 0x026B=int32,dec,count + 0x0272=int32,dec,count + 0x0294=int32,dec,count + 0x0297=uint8,hex,flags,SHEETCALCPR-FLAGS + 0x0298=uint8,dec,builtin-count +end + +# ARRAY ---------------------------------------------------------------------- + +flagslist=ARRAY-FLAGS + 0x01=recalc-always +end + +# BORDER --------------------------------------------------------------------- + +flagslist=BORDER-FLAGS + 0x01=diag-tl-to-br + 0x02=diag-bl-to-tr +end + +# CALCPR --------------------------------------------------------------------- + +shortlist=CALCPR-CALCMODE,0,manual,auto,auto-no-tables + +flagslist=CALCPR-FLAGS + 0x0001=calc-on-load + 0x0002=a1 + 0x0004=iterate + 0x0008=full-precision + 0x0010=calc-complete + 0x0020=calc-on-save + 0x0040=concurrent + 0x0080=manual-processors + 0x0100=force-full-calc +end + +# CELLSTYLE ------------------------------------------------------------------ + +flagslist=CELLSTYLE-FLAGS + 0x0001=builtin + 0x0002=hidden + 0x0004=custom +end + +multilist=CELLSTYLE-BUILTIN + 0=normal,rowlevel,collevel,comma,currency,percent,comma-0,currency-0,hyperlink,followed-hyperlink + 10=note,warning-text,,,,title,heading-1,heading-2,heading-3,heading-4 + 20=input,output,calculation,check-cell,linked-cell,total,good,bad,neutral,accent1 + 30=20%-accent1,40%-accent1,60%-accent1,accent2,20%-accent2,40%-accent2,60%-accent2,accent3,20%-accent3,40%-accent3 + 40=60%-accent3,accent4,20%-accent4,40%-accent4,60%-accent4,accent5,20%-accent5,40%-accent5,60%-accent5,accent6 + 50=20%-accent6,40%-accent6,60%-accent6,explanatory-text +end + +# CFRULE --------------------------------------------------------------------- + +shortlist=CFRULE-TYPE,1,cell-is,expression,color-scale,data-bar,top-ten,icon-set + +multilist=CFRULE-SUBTYPE + 0=cell-is,expression,color-scale,data-bar,icon-set,top-ten,,unique-values,contains-text,contains-blanks + 10=not-contains-blanks,contains-errors,not-contains-errors,,,today,tomorrow,yesterday,last-7-days,last-month + 20=next-month,this-week,next-week,last-week,this-month,above-average,below-average,duplicate-values,,equal-above-average + 30=equal-below-average +end + +shortlist=CFRULE-CELL-OPERATOR,1,between,not-between,equal,not-equal,greater-than,less-than,greater-equal,less-equal +shortlist=CFRULE-TEXT-OPERATOR,0,contains,not-contains,begins-with,ends-with +shortlist=CFRULE-TIME-OPERATOR,0,today,yesterday,last-7-days,this-week,last-week,last-month,tomorrow,next-week,next-month,this-month +shortlist=CFRULE-OTHER-OPERATOR,0,none + +flagslist=CFRULE-FLAGS + 0x0001=table-row + 0x0002=stop-if-true + 0x0004=avove-average + 0x0008=bottom + 0x0010=percent +end + +# CHARTPAGESETUP ------------------------------------------------------------------ + +combilist=CHARTPAGESETUP-FLAGS + 0x0001=landscape + 0x0002=uninitialized + 0x0004=black-and-white + 0x0008=default-orientation + 0x0010=use-first-page + 0x0020=draft-quality +end + +# CHARTSHEETPR --------------------------------------------------------------- + +flagslist=CHARTSHEETPR-FLAGS + 0x0001=published +end + +# CHARTSHEETVIEW ------------------------------------------------------------- + +flagslist=CHARTSHEETVIEW-FLAGS + 0x0001=selected + 0x0002=zoom-to-fit +end + +# COL ------------------------------------------------------------------------ + +combilist=COL-FLAGS + 0x0001=hidden + 0x0002=custom-width + 0x0004=best-fit + 0x0008=show-phonetic + 0x0700=uint8,dec,outline-level + 0x1000=outline-collapsed +end + +# DATATABLE ------------------------------------------------------------------ + +flagslist=DATATABLE-FLAGS + 0x01=row-table + 0x02=table-2d + 0x04=ref1-deleted + 0x08=ref2-deleted + 0x10=recalc-always +end + +# DATAVALIDATION ------------------------------------------------------------- + +combilist=DATAVALIDATION-FLAGS + 0x0000000F=uint8,dec,type,DATAVALIDATION-TYPE + 0x00000070=uint8,dec,error-style,DATAVALIDATION-ERRORSTYLE + 0x00000080=string-list + 0x00000100=ignore-empty + 0x00000200=no-dropdown + 0x00040000=show-input-box + 0x00080000=show-error-box + 0x00F00000=uint8,dec,operator,DATAVALIDATION-OPERATOR +end + +shortlist=DATAVALIDATION-TYPE,0,any,whole,decimal,list,date,time,text-length,custom +shortlist=DATAVALIDATION-OPERATOR,0,between,not-between,equal,not-equal,greater-than,less-than,greater-equal,less-equal +shortlist=DATAVALIDATION-ERRORSTYLE,0,error,warning,info + +# DATAVALIDATIONS ------------------------------------------------------------ + +combilist=DATAVALIDATIONS-FLAGS + 0x0001=disable-prompts +end + +# DEFINEDNAME ---------------------------------------------------------------- + +combilist=DEFINEDNAME-FLAGS + 0x00000001=hidden + 0x00000002=function + 0x00000004=vba + 0x00000008=macro + 0x00000010=complex + 0x00000020=built-in + 0x00007FC0=int32,dec,func-group,DEFINEDNAME-FUNCGROUP + 0x00008000=published + 0x00010000=workbook-param +end + +shortlist=DEFINEDNAME-FUNCGROUP,0,none,financial,date-time,math-trig,statistical,lookup-ref,database,text,logical,information,commands,customizing,macro-control,dde-external,user-definded + +constlist=DEFINEDNAME-SHEETID + default= + -1=global +end + +# DXF ------------------------------------------------------------------------ + +flagslist=DXF-FLAGS + 0x00008000=border-outline +end + +multilist=DXF-SUBREC + 0=FILL-PATTERN,FILL-FGCOLOR,FILL-BGCOLOR,FILL-GRADIENT,FILL-STOP + 5=FONT-COLOR,BORDER-TOP,BORDER-BOTTOM,BORDER-LEFT,BORDER-RIGHT + 10=BORDER-DIAGONAL,BORDER-VERTICAL,BORDER-HORIZONTAL,BORDER-DIAGUP,BORDER-DIAGDOWN + 15=ALIGN-HORIZONTAL,ALIGN-VERTICAL,ALIGN-ROTATION,ALIGN-INDENT,ALIGN-READINGORDER + 20=ALIGN-WRAPTEXT,ALIGN-JUSTLASTLINE,ALIGN-SHRINKTOFIT,,FONT-NAME + 25=FONT-WEIGHT,FONT-UNDERLINE,FONT-ESCAPEMENT,FONT-ITALIC,FONT-STRIKE + 30=FONT-OUTLINE,FONT-SHADOW,FONT-CONDENSE,FONT-EXTEND,FONT-CHARSET + 35=FONT-PITCHFAMILY,FONT-HEIGHT,FONT-SCHEME,NUMFMT-CODE, + 40=,NUMFMT-ID,ALIGN-RELINDENT,PROT-LOCKED,PROT-HIDDEN +end + +# EXTERNALBOOK --------------------------------------------------------------- + +shortlist=EXTERNALBOOK-TYPE,0,book,dde-link,ole-link + +# EXTERNALNAMEFLAGS ---------------------------------------------------------- + +flagslist=EXTERNALNAMEFLAGS-FLAGS + 0x0002=automatic + 0x0004=pic-link + 0x0008=dde-stddocumentname + 0x0010=ole-link + 0x0020=iconified +end + +# EXTERNALSHEETS ------------------------------------------------------------- + +constlist=EXTERNALSHEETS-ID + default= + -1=deleted + -2=special +end + +# EXTSHEETDATA --------------------------------------------------------------- + +flagslist=EXTSHEETDATA-FLAGS + 0x01=refresh-error +end + +# FILL ----------------------------------------------------------------------- + +shortlist=FILL-GRADIENTTYPE,0,linear,path + +# FONT ----------------------------------------------------------------------- + +flagslist=FONT-FLAGS + 0x0001=bold + 0x0002=italic + 0x0004=underline + 0x0008=strikeout + 0x0010=outline + 0x0020=shadow + 0x0040=condense + 0x0080=extend +end + +multilist=FONT-UNDERLINE + 0x00=none,single,double + 0x21=single-acc,double-acc +end + +shortlist=FONT-SCHEME,0,none,major,minor +shortlist=FONT-ESCAPEMENT,0,none,superscript,subscript + +# HEADERFOOTER --------------------------------------------------------------- + +flagslist=HEADERFOOTER-FLAGS + 0x0001=diff-odd-even + 0x0002=diff-dirst + 0x0004=scale-with-doc + 0x0008=align-with-margins +end + +# OLEOBJECT ------------------------------------------------------------------ + +shortlist=OLEOBJECT-ASPECT,1,content,,,icon +shortlist=OLEOBJECT-UPDATE,0,na,automatic,,manual + +flagslist=OLEOBJECT-FLAGS + 0x0001=linked + 0x0002=auto-load +end + +# PAGESETUP ------------------------------------------------------------------ + +multilist=PAGESETUP-PAPERSIZE + 0=undefined,letter,letter-small,tabloid,ledger,legal,statement,executive,a3,a4 + 10=a4-small,a5,b4,b5,folio,quarto,10x14,11x17,note,envelope-9 + 20=envelope-10,envelope-11,envelope-12,envelope-14,c,d,e,envelope-dl,envelope-c5,envelope-c3 + 30=envelope-c4,envelope-c6,envelope-c65,envelope-b4,envelope-b5,envelope-b6,envelope-italy,envelope-monarch,envelope-6-3/4,us-standard-fanfold + 40=german-standard-fanfold,german-legal-fanfold,b4,japanese-dbl-postcaed,9x11,10x11,15x11,, + 50=envelope-invite,letter-extra,legal-extra,tabloid-extra,a4-extra,letter-transverse,a4-transverse,letter-extra-transverse,super-a-a4,super-b-a3,letter-plus + 60=a4-plus,a5-transverse,jis-b5-transverse,a3-extra,a5-extra,b5-extra,a2,a3-transverse,a3-extra-transverse +end + +constlist=PAGESETUP-SCALETOPAGES + default= + 0=automatic +end + +combilist=PAGESETUP-FLAGS + 0x0001=print-in-rows + 0x0002=landscape + 0x0004=uninitialized + 0x0008=black-and-white + 0x0010=draft-quality + 0x0020=print-notes + 0x0040=default-orientation + 0x0080=use-first-page + 0x0100=print-notes-at-end + 0x0600=uint8,dec,print-errors,PAGESETUP-PRINTERRORS +end + +shortlist=PAGESETUP-PRINTERRORS,0,displayed,none,as-dashes,as-na + +unitconverter=PAGESETUP-DPI,1,dpi + +# PANE ----------------------------------------------------------------------- + +shortlist=PANE-ID,0,bottom-right,top-right,bottom-left,top-left + +flagslist=PANE-FLAGS + 0x01=frozen + 0x02=remove-split-with-freeze +end + +# PHONETICPR ----------------------------------------------------------------- + +shortlist=PHONETICPR-TYPE,0,halfwidth-katakana,fullwidth-katakana,hiragana,no-conversion +shortlist=PHONETICPR-ALIGNMENT,0,no-control,left,center,distributed + +# PRINTOPTIONS --------------------------------------------------------------- + +flagslist=PRINTOPTIONS-FLAGS + 0x0001=horizontal-centered + 0x0002=vertical-centered + 0x0004=print-headings + 0x0008=print-gridlines + 0x0010=gridlines-set +end + +# ROW ------------------------------------------------------------------------ + +combilist=ROW-FLAGS1 + 0x0001=thick-top + 0x0002=thick-bottom + 0x0700=uint8,dec,outline-level + 0x0800=outline-collapsed + 0x1000=hidden + 0x2000=custom-height + 0x4000=custom-format +end + +flagslist=ROW-FLAGS2 + 0x01=show-phonetic +end + +# SHEET ---------------------------------------------------------------------- + +shortlist=SHEET-STATE,0,visible,hidden,very-hidden + +# SHEETCALCPR ---------------------------------------------------------------- + +flagslist=SHEETCALCPR-FLAGS + 0x01=calc-on-load +end + +# SHEETFORMATPR -------------------------------------------------------------- + +flagslist=SHEETFORMATPR-FLAGS + 0x0001=custom-row-height + 0x0002=rows-hidden +end + +# SHEETPR -------------------------------------------------------------------- + +flagslist=SHEETPR-FLAGS1 + 0x0001=show-autopagebreaks + 0x0008=published + 0x0010=dialog-sheet + 0x0020=outline-auto-style + 0x0040=row-symbols-below + 0x0080=column-symbols-right + 0x0100=fit-to-pages + 0x0400=show-outline-symbols + 0x1000=is-row-synched + 0x2000=is-col-synched + 0x4000=lotus-formula-eval + 0x8000=lotus-formula-entry +end + +flagslist=SHEETPR-FLAGS2 + 0x01=is-filtered + 0x02=eval-cond-formats +end + +# SHEETVIEW ------------------------------------------------------------------ + +flagslist=SHEETVIEW-FLAGS + 0x0001=window-protected + 0x0002=show-formulas + 0x0004=show-gridlines + 0x0008=show-headings + 0x0010=show-zeros + 0x0020=right-to-left + 0x0040=selected + 0x0080=show-ruler + 0x0100=show-outline-symbols + 0x0200=default-gridcolor + 0x0400=show-whitespace +end + +shortlist=SHEETVIEW-TYPE,0,normal,pagebreak-preview,page-layout + +# TABLE ---------------------------------------------------------------------- + +shortlist=TABLE-TYPE,0,worksheet,,,query-table + +flagslist=TABLE-FLAGS + 0x00000001=totals-row-shown + 0x00000002=published + 0x00000004=insert-row + 0x00000008=insert-row-shift +end + +# TABLESTYLEINFO ------------------------------------------------------------- + +flagslist=TABLESTYLEINFO-FLAGS + 0x0001=show-first-column + 0x0002=show-last-column + 0x0004=show-row-stripes + 0x0008=show-column-stripes +end + +# VOLTYPE -------------------------------------------------------------------- + +shortlist=VOLTYPE-TYPE,0,realtime-data,olap-functions + +# WORKBBOKPR ----------------------------------------------------------------- + +combilist=WORKBBOKPR-FLAGS + 0x00000001=date-1904 + 0x00000004=hide-border-unsel-tables + 0x00000008=filter-privacy + 0x00000010=prompted-solutions + 0x00000020=show-ink-annotation + 0x00000040=backup-file + 0x00000080=strip-extlink-values + 0x00000300=uint8,dec,update-links,WORKBBOKPR-UPDATELINKS + 0x00000400=hide-pivot-fieldlist + 0x00000800=publish-items + 0x00001000=check-compatibility + 0x00006000=uint8,dec,show-objects,WORKBBOKPR-SHOWOBJECTS + 0x00008000=show-pivotchart-filter + 0x00010000=autocompress-pic + 0x00020000=refresh-all-links +end + +shortlist=WORKBBOKPR-UPDATELINKS,0,ask-user,never,always +shortlist=WORKBBOKPR-SHOWOBJECTS,0,show,placeholder,hide + +# WORKBOOKVIEW --------------------------------------------------------------- + +flagslist=WORKBOOKVIEW-FLAGS + 0x01=hidden + 0x02=minimized + 0x08=show-horizontal-scroll + 0x10=show-vertical-scroll + 0x20=show-tabbar + 0x40=autofilter-date-grouping +end + +# XF ------------------------------------------------------------------------- + +shortlist=XF-HORALIGN,0,general,left,center,right,fill,block,center-across-sel,distribute +shortlist=XF-VERALIGN,0,top,center,bottom,justify,distribute +shortlist=XF-TEXTDIRECTION,0,context,left-to-right,right-to-left + +combilist=XF-ALIGNMENT + 0x000000FF=uint8,dec,rotation,TEXTROTATION + 0x0000FF00=uint8,dec,indent + 0x00070000=uint8,dec,hor-align,XF-HORALIGN + 0x00380000=uint8,dec,ver-align,XF-VERALIGN + 0x00400000=text-wrap + 0x00800000=justify-lastline + 0x01000000=shrink-to-fit + 0x0C000000=uint8,dec,text-dir,XF-TEXTDIRECTION + 0x10000000=locked + 0x20000000=formula-hidden + 0x80000000=quote-prefix +end + +flagslist=XF-USEDFLAGS + 0x0001=format + 0x0002=font + 0x0004=alignment + 0x0008=border + 0x0010=fill + 0x0020=protection +end + +# ============================================================================ + diff --git a/oox/source/dump/xlsbdumperconfig.dat b/oox/source/dump/xlsbdumperconfig.dat index 4a5a0d335207..e69de29bb2d1 100644 --- a/oox/source/dump/xlsbdumperconfig.dat +++ b/oox/source/dump/xlsbdumperconfig.dat @@ -1,731 +0,0 @@ - -# dumper settings ============================================================ - -# Path to additional configuration data, relative to this file. -include-config-file=dumperconfig.dat - -# Enable entire dumper (default=off). This option does not affect the option -# 'enable-import'. -# 0=off, 1=on -enable-dumper=1 - -# Enable import after dumping (default=on). Disabling this option allows -# to dump a file without loading it. This option is independent from the -# 'enable-dumper' option. -# 0=off, 1=on -enable-import=1 - -# XLSB record settings ------------------------------------------------------- - -# Show total stream position of the record (default=on). -# 0=off, 1=on -show-record-pos=0 - -# Show total record size in bytes (default=on). -# 0=off, 1=on -show-record-size=1 - -# Show record identifier (default=on). -# 0=off, 1=on -show-record-id=1 - -# Show record name, if known (default=on). -# 0=off, 1=on -show-record-name=1 - -# Show record contents (default=on). -# 0=off, 1=on -show-record-body=1 - -# common --------------------------------------------------------------------- - -unitconverter=CONV-TINT,/327.67,% -unitconverter=CONV-COLWIDTH,/256,chars - -constlist=ERRORCODES - 0x00=#NULL! - 0x07=#DIV/0! - 0x0F=#VALUE! - 0x17=#REF! - 0x1D=#NAME? - 0x24=#NUM! - 0x2A=#N/A -end - -flagslist=STRING-FLAGS - 0x01=rich-string - 0x02=phonetic-text -end - -combilist=CELL-XFID - 0x00FFFFFF=int32,dec,xf-id - 0x01000000=show-phonetic -end - -combilist=PHONETIC-FLAGS - ignore=0x0030 - 0x0003=uint8,dec,type,PHONETICPR-TYPE - 0x000C=uint8,dec,alignment,PHONETICPR-ALIGNMENT -end - -shortlist=COLOR-TYPE,0,auto,indexed,rgb,theme - -combilist=COLOR-FLAGS - 0x01=rgb-valid - 0xFE=uint8,dec,type,COLOR-TYPE -end - -multilist=PALETTE-COLORS - default= - 0=ega-black,ega-white,ega-red,ega-green,ega-blue,ega-yellow,ega-magenta,ega-cyan - 64=sys-window-text - 65=sys-window-bg - 67=sys-button-face - 77=sys-window-text-chart - 78=sys-window-bg-chart - 79=auto-border-chart - 80=sys-tooltip-bg - 81=sys-tooltip-text -end - -constlist=TEXTROTATION - default= - 255=stacked -end - -multilist=BORDERSTYLES - 0=none,thin,medium,dash,dot - 5=thick,double,hair,medium-dash,thin-dash-dot - 10=medium-dash-dot,thin-dash-dot-dot,medium-dash-dot-dot,slant-dash-dot -end - -multilist=FILLPATTERNS - 0=no-fill,solid-fill,50%-grey,75%-grey,25%-grey - 5=hor-stripe,ver-stripe,rev-diag-stripe,diag-stripe,diag-crosshatch - 10=thick-diag-crosshatch,thin-hor-stripe,thin-ver-stripe,thin-rev-diag-stripe,thin-diag-stripe - 15=thin-hor-crosshatch,thin-diag-crosshatch,12.5%-grey,6.25%-grey - 40=gradient -end - -# formulas ------------------------------------------------------------------- - -flagslist=FORMULA-FLAGS - 0x0002=recalc-always -end - -multilist=BASETOKENS - 0x00=,tExp,tTbl,tAdd,tSub,tMul,tDiv,tPower - 0x08=tConcat,tLT,tLE,tEQ,tGE,tGT,tNE,tIsect - 0x10=tList,tRange,tUplus,tUminus,tPercent,tParen,tMissArg,tStr - 0x18=tTable,tAttr,,,tErr,tBool,tInt,tNum -end - -constlist=TOKENCLASSES - 0x20=R - 0x40=V - 0x60=A -end - -multilist=CLASSTOKENS - 0x00=tArray,tFunc,tFuncVar,tName,tRef,tArea,tMemArea,tMemErr - 0x08=tMemNoMem,tMemFunc,tRefErr,tAreaErr,tRefN,tAreaN,tMemAreaN,tMemNoMemN - 0x18=,tNameX,tRef3d,tArea3d,tRefErr3d,tAreaErr3d -end - -combilist=FUNCID - 0x7FFF=uint16,dec,func-id - 0x8000=command -end - -combilist=PARAMCOUNT-CMD - 0x7F=uint8,dec,count - 0x80=prompt -end - -combilist=REFRELFLAGS - 0x3FFF=uint16,dec,value - 0x4000=col-rel - 0x8000=row-rel -end - -flagslist=TABLEFLAGS - 0x0001=single-column - 0x0002=column-range - 0x0004=#all - 0x0008=#headers - 0x0010=#data - 0x0020=#totals - 0x0040=#this-row - 0x0080=bracket-spaces - 0x0100=sep-spaces - 0x0200=single-row - 0x0400=single-cell -end - -flagslist=ATTRTYPES - 0x01=volatile - 0x02=if - 0x04=choose - 0x08=skip - 0x10=sum - 0x20=assign - 0x40=space - 0x80=iferror -end - -shortlist=ATTRSPACETYPES,0,space-before-token,cr-before-token,space-before-open,cr-before-open,space-before-close,cr-before-close,leading-space - -shortlist=ARRAYVALUE-TYPE,0,number,string,boolean,,error - -# record names --------------------------------------------------------------- - -multilist=RECORD-NAMES - 0x0000=ROW,CELL_BLANK,CELL_RK,CELL_ERROR,CELL_BOOL,CELL_DOUBLE,CELL_STRING,CELL_SI - 0x0008=FORMULA_STRING,FORMULA_DOUBLE,FORMULA_BOOL,FORMULA_ERROR,MULTCELL_BLANK,MULTCELL_RK,MULTCELL_ERROR,MULTCELL_BOOL - 0x0010=MULTCELL_DOUBLE,MULTCELL_STRING,MULTCELL_SI,SI,,,, - - 0x0020=,,,,,,,DEFINEDNAME - 0x0028=BINARYINDEXROWS,,BINARYINDEXBLOCK,FONT,NUMFMT,FILL,BORDER,XF - 0x0030=CELLSTYLE,,,,,,, - 0x0038=,,,,COL,MULTCELL_RSTRING,CELL_RSTRING,CALCCHAINCELL - 0x0040=DATAVALIDATION,,,,,,, - - 0x0080=FILEVERSION,WORKSHEET,WORKSHEET_END,WORKBOOK,WORKBOOK_END,SHEETVIEWS,SHEETVIEWS_END,BOOKVIEWS - 0x0088=BOOKVIEWS_END,SHEETVIEW,SHEETVIEW_END,CHARTSHEETVIEWS,CHARTSHEETVIEWS_END,CHARTSHEETVIEW,CHARTSHEETVIEW_END,SHEETS - 0x0090=SHEETS_END,SHEETDATA,SHEETDATA_END,SHEETPR,DIMENSION,,,PANE - 0x0098=SELECTION,WORKBOOKPR,SMARTTAGPR,FILERECOVERYPR,SHEET,CALCPR,WORKBOOKVIEW,SST - 0x00A0=SST_END,AUTOFILTER,AUTOFILTER_END,FILTERCOLUMN,FILTERCOLUMN_END,,, - - 0x00B0=,MERGECELLS,MERGECELLS_END,,,,, - - 0x0110=,,,,,BINARYINDEX_END,STYLESHEET,STYLESHEET_END - - 0x0150=,,,,,,,TABLE - 0x0158=TABLE_END,TABLECOLUMNS,TABLECOLUMNS_END,TABLECOLUMN,TABLECOLUMN_END,,,CALCEDCOLUMNFMLA - 0x0160=,EXTERNALREFS,EXTERNALREFS_END,EXTERNALREF,,EXTERNALSELF,EXTERNALSAME,EXTSHEETNAMES - 0x0168=EXTERNALBOOK,,EXTERNALSHEETS,EXTSHEETDATA,EXTSHEETDATA_END,,EXTROW,EXTCELL_BLANK - 0x0170=EXTCELL_DOUBLE,EXTCELL_BOOL,EXTCELL_ERROR,EXTCELL_STRING,,,, - - 0x0180=,,,,,,COLS,COLS_END - 0x0188=ROWBREAKS,ROWBREAKS_END,COLBREAKS,COLBREAKS_END,BRK,CUSTOMWORKBOOKVIEW,, - - 0x01A0=,,,,,,CUSTOMSHEETVIEWS,CUSTOMSHEETVIEW - 0x01A8=CUSTOMSHEETVIEW_END,CUSTOMSHEETVIEWS_END,ARRAY,SHAREDFMLA,DATATABLE,,, - - 0x01C8=,,,,,CONDFORMATTING,CONDFORMATTING_END,CFRULE - 0x01D0=CFRULE_END,ICONSET,ICONSET_END,DATABAR,DATABAR_END,COLORSCALE,COLORSCALE_END,CFVO - 0x01D8=,COLORS,COLORS_END,RGBCOLOR,PAGEMARGINS,PRINTOPTIONS,PAGESETUP,HEADERFOOTER - 0x01E0=HEADERFOOTER_END,,,,,SHEETFORMATPR,, - 0x01E8=,,,,,,HYPERLINK, - - 0x01F8=,DXFS,DXFS_END,DXF,TABLESTYLES,TABLESTYLES_END,, - 0x0200=,TABLESTYLEINFO,VOLTYPES,VOLTYPES_END,VOLTYPE,VOLTYPE_END,VOLTYPEMAIN,VOLTYPEMAIN_END - 0x0208=VOLTYPETP,VOLTYPETP_END,VOLTYPESTP,VOLTYPETR,,VOLTYPE_ERROR,, - 0x0210=CALCCHAIN,CALCCHAIN_END,,,,,,SHEETPROTECTION - 0x0218=,PHONETICPR,,,,,, - 0x0220=,,,,,,DRAWING,LEGACYDRAWING - - 0x0230=,,PICTURE,,CFCOLOR,INDEXEDCOLORS,INDEXEDCOLORS_END, - 0x0238=,MRUCOLORS,MRUCOLORS_END,,COLOR,DATAVALIDATIONS,DATAVALIDATIONS_END, - 0x0240=,EXTERNALNAME,DDEITEMVALUES,DDEITEMVALUES_END,DDEITEM_DOUBLE,DDEITEM_ERROR,DDEITEM_STRING,DDEITEM_EMPTY - 0x0248=DDEITEM_BOOL,EXTERNALNAMEREF,EXTERNALNAMEFLAGS,EXTERNALNAME_END,EXTERNALBOOK_END,,, - - 0x0258=,,,FILLS,FILLS_END,,, - 0x0260=,,,FONTS,FONTS_END,BORDERS,BORDERS_END,NUMFMTS - 0x0268=NUMFMTS_END,CELLXFS,CELLXFS_END,CELLSTYLES,CELLSTYLES_END,,, - 0x0270=,,CELLSTYLEXFS,CELLSTYLEXFS_END - 0x0278=,,,,,,,OLEOBJECT - - 0x0288=,,,CHARTSHEETPR,CHARTPAGESETUP,CUSTOMCHARTVIEWS,CUSTOMCHARTVIEWS_END,CUSTOMCHARTVIEW - 0x0290=CUSTOMCHARTVIEW_END,,,,TABLEPARTS,TABLEPART,TABLEPARTS_END,SHEETCALCPR - 0x0298=FUNCTIONGROUPS,FUNCTIONGROUP,FUNCTIONGROUPS_END,EXTERNALADDIN,,CHARTPROTECTION,, -end - -# simple records ------------------------------------------------------------- - -constlist=SIMPLE-RECORDS - 0x0159=int32,dec,count - 0x01DD=uint16,hex,flags,PRINTOPTIONS-FLAGS - 0x01F9=int32,dec,count - 0x0204=int32,dec,type,VOLTYPE-TYPE - 0x020D=uint8,dec,error-code,ERRORCODES - 0x0244=double,dec,value - 0x0245=uint8,dec,error-code,ERRORCODES - 0x0248=uint8,dec,value,BOOLEAN - 0x025B=int32,dec,count - 0x0263=int32,dec,count - 0x0265=int32,dec,count - 0x0267=int32,dec,count - 0x0269=int32,dec,count - 0x026B=int32,dec,count - 0x0272=int32,dec,count - 0x0294=int32,dec,count - 0x0297=uint8,hex,flags,SHEETCALCPR-FLAGS - 0x0298=uint8,dec,builtin-count -end - -# ARRAY ---------------------------------------------------------------------- - -flagslist=ARRAY-FLAGS - 0x01=recalc-always -end - -# BORDER --------------------------------------------------------------------- - -flagslist=BORDER-FLAGS - 0x01=diag-tl-to-br - 0x02=diag-bl-to-tr -end - -# CALCPR --------------------------------------------------------------------- - -shortlist=CALCPR-CALCMODE,0,manual,auto,auto-no-tables - -flagslist=CALCPR-FLAGS - 0x0001=calc-on-load - 0x0002=a1 - 0x0004=iterate - 0x0008=full-precision - 0x0010=calc-complete - 0x0020=calc-on-save - 0x0040=concurrent - 0x0080=manual-processors - 0x0100=force-full-calc -end - -# CELLSTYLE ------------------------------------------------------------------ - -flagslist=CELLSTYLE-FLAGS - 0x0001=builtin - 0x0002=hidden - 0x0004=custom -end - -multilist=CELLSTYLE-BUILTIN - 0=normal,rowlevel,collevel,comma,currency,percent,comma-0,currency-0,hyperlink,followed-hyperlink - 10=note,warning-text,,,,title,heading-1,heading-2,heading-3,heading-4 - 20=input,output,calculation,check-cell,linked-cell,total,good,bad,neutral,accent1 - 30=20%-accent1,40%-accent1,60%-accent1,accent2,20%-accent2,40%-accent2,60%-accent2,accent3,20%-accent3,40%-accent3 - 40=60%-accent3,accent4,20%-accent4,40%-accent4,60%-accent4,accent5,20%-accent5,40%-accent5,60%-accent5,accent6 - 50=20%-accent6,40%-accent6,60%-accent6,explanatory-text -end - -# CFRULE --------------------------------------------------------------------- - -shortlist=CFRULE-TYPE,1,cell-is,expression,color-scale,data-bar,top-ten,icon-set - -multilist=CFRULE-SUBTYPE - 0=cell-is,expression,color-scale,data-bar,icon-set,top-ten,,unique-values,contains-text,contains-blanks - 10=not-contains-blanks,contains-errors,not-contains-errors,,,today,tomorrow,yesterday,last-7-days,last-month - 20=next-month,this-week,next-week,last-week,this-month,above-average,below-average,duplicate-values,,equal-above-average - 30=equal-below-average -end - -shortlist=CFRULE-CELL-OPERATOR,1,between,not-between,equal,not-equal,greater-than,less-than,greater-equal,less-equal -shortlist=CFRULE-TEXT-OPERATOR,0,contains,not-contains,begins-with,ends-with -shortlist=CFRULE-TIME-OPERATOR,0,today,yesterday,last-7-days,this-week,last-week,last-month,tomorrow,next-week,next-month,this-month -shortlist=CFRULE-OTHER-OPERATOR,0,none - -flagslist=CFRULE-FLAGS - 0x0001=table-row - 0x0002=stop-if-true - 0x0004=avove-average - 0x0008=bottom - 0x0010=percent -end - -# CHARTPAGESETUP ------------------------------------------------------------------ - -combilist=CHARTPAGESETUP-FLAGS - 0x0001=landscape - 0x0002=uninitialized - 0x0004=black-and-white - 0x0008=default-orientation - 0x0010=use-first-page - 0x0020=draft-quality -end - -# CHARTSHEETPR --------------------------------------------------------------- - -flagslist=CHARTSHEETPR-FLAGS - 0x0001=published -end - -# CHARTSHEETVIEW ------------------------------------------------------------- - -flagslist=CHARTSHEETVIEW-FLAGS - 0x0001=selected - 0x0002=zoom-to-fit -end - -# COL ------------------------------------------------------------------------ - -combilist=COL-FLAGS - 0x0001=hidden - 0x0002=custom-width - 0x0004=best-fit - 0x0008=show-phonetic - 0x0700=uint8,dec,outline-level - 0x1000=outline-collapsed -end - -# DATATABLE ------------------------------------------------------------------ - -flagslist=DATATABLE-FLAGS - 0x01=row-table - 0x02=table-2d - 0x04=ref1-deleted - 0x08=ref2-deleted - 0x10=recalc-always -end - -# DATAVALIDATION ------------------------------------------------------------- - -combilist=DATAVALIDATION-FLAGS - 0x0000000F=uint8,dec,type,DATAVALIDATION-TYPE - 0x00000070=uint8,dec,error-style,DATAVALIDATION-ERRORSTYLE - 0x00000080=string-list - 0x00000100=ignore-empty - 0x00000200=no-dropdown - 0x00040000=show-input-box - 0x00080000=show-error-box - 0x00F00000=uint8,dec,operator,DATAVALIDATION-OPERATOR -end - -shortlist=DATAVALIDATION-TYPE,0,any,whole,decimal,list,date,time,text-length,custom -shortlist=DATAVALIDATION-OPERATOR,0,between,not-between,equal,not-equal,greater-than,less-than,greater-equal,less-equal -shortlist=DATAVALIDATION-ERRORSTYLE,0,error,warning,info - -# DATAVALIDATIONS ------------------------------------------------------------ - -combilist=DATAVALIDATIONS-FLAGS - 0x0001=disable-prompts -end - -# DEFINEDNAME ---------------------------------------------------------------- - -combilist=DEFINEDNAME-FLAGS - 0x00000001=hidden - 0x00000002=function - 0x00000004=command - 0x00000008=macro - 0x00000010=complex - 0x00000020=built-in - 0x00007FC0=int32,dec,func-group,DEFINEDNAME-FUNCGROUP - 0x00008000=published - 0x00010000=workbook-param -end - -shortlist=DEFINEDNAME-FUNCGROUP,0,none,financial,date-time,math-trig,statistical,lookup-ref,database,text,logical,information,commands,customizing,macro-control,dde-external,user-definded - -constlist=DEFINEDNAME-SHEETID - default= - -1=global -end - -# DXF ------------------------------------------------------------------------ - -flagslist=DXF-FLAGS - 0x00008000=border-outline -end - -multilist=DXF-SUBREC - 0=FILL-PATTERN,FILL-FGCOLOR,FILL-BGCOLOR,FILL-GRADIENT,FILL-STOP - 5=FONT-COLOR,BORDER-TOP,BORDER-BOTTOM,BORDER-LEFT,BORDER-RIGHT - 10=BORDER-DIAGONAL,BORDER-VERTICAL,BORDER-HORIZONTAL,BORDER-DIAGUP,BORDER-DIAGDOWN - 15=ALIGN-HORIZONTAL,ALIGN-VERTICAL,ALIGN-ROTATION,ALIGN-INDENT,ALIGN-READINGORDER - 20=ALIGN-WRAPTEXT,ALIGN-JUSTLASTLINE,ALIGN-SHRINKTOFIT,,FONT-NAME - 25=FONT-WEIGHT,FONT-UNDERLINE,FONT-ESCAPEMENT,FONT-ITALIC,FONT-STRIKE - 30=FONT-OUTLINE,FONT-SHADOW,FONT-CONDENSE,FONT-EXTEND,FONT-CHARSET - 35=FONT-FAMILY,FONT-HEIGHT,FONT-SCHEME,NUMFMT-CODE, - 40=,NUMFMT-ID,ALIGN-RELINDENT,PROT-LOCKED,PROT-HIDDEN -end - -# EXTERNALBOOK --------------------------------------------------------------- - -shortlist=EXTERNALBOOK-TYPE,0,book,dde-link,ole-link - -# EXTERNALNAMEFLAGS ---------------------------------------------------------- - -flagslist=EXTERNALNAMEFLAGS-FLAGS - 0x0002=automatic - 0x0004=pic-link - 0x0008=dde-stddocumentname - 0x0010=ole-link - 0x0020=iconified -end - -# EXTERNALSHEETS ------------------------------------------------------------- - -constlist=EXTERNALSHEETS-ID - default= - -1=deleted - -2=special -end - -# EXTSHEETDATA --------------------------------------------------------------- - -flagslist=EXTSHEETDATA-FLAGS - 0x01=refresh-error -end - -# FILL ----------------------------------------------------------------------- - -shortlist=FILL-GRADIENTTYPE,0,linear,path - -# FONT ----------------------------------------------------------------------- - -flagslist=FONT-FLAGS - 0x0001=bold - 0x0002=italic - 0x0004=underline - 0x0008=strikeout - 0x0010=outline - 0x0020=shadow - 0x0040=condense - 0x0080=extend -end - -constlist=FONT-WEIGHT - 400=normal - 700=bold -end - -multilist=FONT-UNDERLINE - 0x00=none,single,double - 0x21=single-acc,double-acc -end - -shortlist=FONT-SCHEME,0,none,major,minor -shortlist=FONT-ESCAPEMENT,0,none,superscript,subscript -shortlist=FONT-FAMILY,0,none,roman,swiss,modern,script,decorative - -# HEADERFOOTER --------------------------------------------------------------- - -flagslist=HEADERFOOTER-FLAGS - 0x0001=diff-odd-even - 0x0002=diff-dirst - 0x0004=scale-with-doc - 0x0008=align-with-margins -end - -# PAGESETUP ------------------------------------------------------------------ - -multilist=PAGESETUP-PAPERSIZE - 0=undefined,letter,letter-small,tabloid,ledger,legal,statement,executive,a3,a4 - 10=a4-small,a5,b4,b5,folio,quarto,10x14,11x17,note,envelope-9 - 20=envelope-10,envelope-11,envelope-12,envelope-14,c,d,e,envelope-dl,envelope-c5,envelope-c3 - 30=envelope-c4,envelope-c6,envelope-c65,envelope-b4,envelope-b5,envelope-b6,envelope-italy,envelope-monarch,envelope-6-3/4,us-standard-fanfold - 40=german-standard-fanfold,german-legal-fanfold,b4,japanese-dbl-postcaed,9x11,10x11,15x11,, - 50=envelope-invite,letter-extra,legal-extra,tabloid-extra,a4-extra,letter-transverse,a4-transverse,letter-extra-transverse,super-a-a4,super-b-a3,letter-plus - 60=a4-plus,a5-transverse,jis-b5-transverse,a3-extra,a5-extra,b5-extra,a2,a3-transverse,a3-extra-transverse -end - -constlist=PAGESETUP-SCALETOPAGES - default= - 0=automatic -end - -combilist=PAGESETUP-FLAGS - 0x0001=print-in-rows - 0x0002=landscape - 0x0004=uninitialized - 0x0008=black-and-white - 0x0010=draft-quality - 0x0020=print-notes - 0x0040=default-orientation - 0x0080=use-first-page - 0x0100=print-notes-at-end - 0x0600=uint8,dec,print-errors,PAGESETUP-PRINTERRORS -end - -shortlist=PAGESETUP-PRINTERRORS,0,displayed,none,as-dashes,as-na - -unitconverter=PAGESETUP-DPI,1,dpi - -# PANE ----------------------------------------------------------------------- - -shortlist=PANE-ID,0,bottom-right,top-right,bottom-left,top-left - -flagslist=PANE-FLAGS - 0x01=frozen - 0x02=remove-split-with-freeze -end - -# PHONETICPR ----------------------------------------------------------------- - -shortlist=PHONETICPR-TYPE,0,halfwidth-katakana,fullwidth-katakana,hiragana,no-conversion -shortlist=PHONETICPR-ALIGNMENT,0,no-control,left,center,distributed - -# PRINTOPTIONS --------------------------------------------------------------- - -flagslist=PRINTOPTIONS-FLAGS - 0x0001=horizontal-centered - 0x0002=vertical-centered - 0x0004=print-headings - 0x0008=print-gridlines - 0x0010=gridlines-set -end - -# ROW ------------------------------------------------------------------------ - -combilist=ROW-FLAGS1 - 0x0001=thick-top - 0x0002=thick-bottom - 0x0700=uint8,dec,outline-level - 0x0800=outline-collapsed - 0x1000=hidden - 0x2000=custom-height - 0x4000=custom-format -end - -flagslist=ROW-FLAGS2 - 0x01=show-phonetic -end - -# SHEET ---------------------------------------------------------------------- - -shortlist=SHEET-STATE,0,visible,hidden,very-hidden - -# SHEETCALCPR ---------------------------------------------------------------- - -flagslist=SHEETCALCPR-FLAGS - 0x01=calc-on-load -end - -# SHEETFORMATPR -------------------------------------------------------------- - -flagslist=SHEETFORMATPR-FLAGS - 0x0001=custom-row-height - 0x0002=rows-hidden -end - -# SHEETPR -------------------------------------------------------------------- - -flagslist=SHEETPR-FLAGS1 - 0x0001=show-autopagebreaks - 0x0008=published - 0x0010=dialog-sheet - 0x0020=outline-auto-style - 0x0040=row-symbols-below - 0x0080=column-symbols-right - 0x0100=fit-to-pages - 0x0400=show-outline-symbols - 0x1000=is-row-synched - 0x2000=is-col-synched - 0x4000=lotus-formula-eval - 0x8000=lotus-formula-entry -end - -flagslist=SHEETPR-FLAGS2 - 0x01=is-filtered - 0x02=eval-cond-formats -end - -# SHEETVIEW ------------------------------------------------------------------ - -flagslist=SHEETVIEW-FLAGS - 0x0001=window-protected - 0x0002=show-formulas - 0x0004=show-gridlines - 0x0008=show-headings - 0x0010=show-zeros - 0x0020=right-to-left - 0x0040=selected - 0x0080=show-ruler - 0x0100=show-outline-symbols - 0x0200=default-gridcolor - 0x0400=show-whitespace -end - -shortlist=SHEETVIEW-TYPE,0,normal,pagebreak-preview,page-layout - -# TABLE ---------------------------------------------------------------------- - -shortlist=TABLE-TYPE,0,worksheet,,,query-table - -flagslist=TABLE-FLAGS - 0x00000001=totals-row-shown - 0x00000002=published - 0x00000004=insert-row - 0x00000008=insert-row-shift -end - -# TABLESTYLEINFO ------------------------------------------------------------- - -flagslist=TABLESTYLEINFO-FLAGS - 0x0001=show-first-column - 0x0002=show-last-column - 0x0004=show-row-stripes - 0x0008=show-column-stripes -end - -# VOLTYPE -------------------------------------------------------------------- - -shortlist=VOLTYPE-TYPE,0,realtime-data,olap-functions - -# WORKBBOKPR ----------------------------------------------------------------- - -combilist=WORKBBOKPR-FLAGS - 0x00000001=date-1904 - 0x00000004=hide-border-unsel-tables - 0x00000008=filter-privacy - 0x00000010=prompted-solutions - 0x00000020=show-ink-annotation - 0x00000040=backup-file - 0x00000080=strip-extlink-values - 0x00000300=uint8,dec,update-links,WORKBBOKPR-UPDATELINKS - 0x00000400=hide-pivot-fieldlist - 0x00000800=publish-items - 0x00001000=check-compatibility - 0x00006000=uint8,dec,show-objects,WORKBBOKPR-SHOWOBJECTS - 0x00008000=show-pivotchart-filter - 0x00010000=autocompress-pic - 0x00020000=refresh-all-links -end - -shortlist=WORKBBOKPR-UPDATELINKS,0,ask-user,never,always -shortlist=WORKBBOKPR-SHOWOBJECTS,0,show,placeholder,hide - -# WORKBOOKVIEW --------------------------------------------------------------- - -flagslist=WORKBOOKVIEW-FLAGS - 0x01=hidden - 0x02=minimized - 0x08=show-horizontal-scroll - 0x10=show-vertical-scroll - 0x20=show-tabbar - 0x40=autofilter-date-grouping -end - -# XF ------------------------------------------------------------------------- - -shortlist=XF-HORALIGN,0,general,left,center,right,fill,block,center-across-sel,distribute -shortlist=XF-VERALIGN,0,top,center,bottom,justify,distribute -shortlist=XF-TEXTDIRECTION,0,context,left-to-right,right-to-left - -combilist=XF-ALIGNMENT - 0x000000FF=uint8,dec,rotation,TEXTROTATION - 0x0000FF00=uint8,dec,indent - 0x00070000=uint8,dec,hor-align,XF-HORALIGN - 0x00380000=uint8,dec,ver-align,XF-VERALIGN - 0x00400000=text-wrap - 0x00800000=justify-lastline - 0x01000000=shrink-to-fit - 0x0C000000=uint8,dec,text-dir,XF-TEXTDIRECTION - 0x10000000=locked - 0x20000000=formula-hidden - 0x80000000=quote-prefix -end - -flagslist=XF-USEDFLAGS - 0x0001=format - 0x0002=font - 0x0004=alignment - 0x0008=border - 0x0010=fill - 0x0020=protection -end - -# ============================================================================ - diff --git a/oox/source/helper/binaryinputstream.cxx b/oox/source/helper/binaryinputstream.cxx index 72485b117009..4675372b497b 100644 --- a/oox/source/helper/binaryinputstream.cxx +++ b/oox/source/helper/binaryinputstream.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: binaryinputstream.cxx,v $ - * $Revision: 1.4 $ + * $Revision: 1.4.22.2 $ * * This file is part of OpenOffice.org. * @@ -29,77 +29,149 @@ ************************************************************************/ #include "oox/helper/binaryinputstream.hxx" -#include <com/sun/star/io/XInputStream.hpp> #include <osl/diagnose.h> #include <string.h> +using ::com::sun::star::uno::UNO_QUERY; using ::com::sun::star::uno::Reference; -using ::com::sun::star::uno::Sequence; using ::com::sun::star::uno::Exception; using ::com::sun::star::io::XInputStream; +using ::com::sun::star::io::XSeekable; namespace oox { +const sal_Int32 INPUTSTREAM_BUFFERSIZE = 0x8000; + +// ============================================================================ + +void BinaryInputStream::readAtom( void* opMem, sal_uInt8 nSize ) +{ + readMemory( opMem, nSize ); +} + // ============================================================================ -BinaryInputStream::BinaryInputStream( const Reference< XInputStream >& rxInStrm, bool bAutoClose ) : - BinaryStreamBase( rxInStrm ), +BinaryXInputStream::BinaryXInputStream( const Reference< XInputStream >& rxInStrm, bool bAutoClose ) : + BinaryXSeekableStream( Reference< XSeekable >( rxInStrm, UNO_QUERY ) ), + maBuffer( INPUTSTREAM_BUFFERSIZE ), mxInStrm( rxInStrm ), mbAutoClose( bAutoClose ) { + mbEof = !mxInStrm.is(); } -BinaryInputStream::~BinaryInputStream() +BinaryXInputStream::~BinaryXInputStream() { if( mbAutoClose ) close(); } -void BinaryInputStream::skip( sal_Int32 nBytes ) +sal_Int32 BinaryXInputStream::readData( StreamDataSequence& orData, sal_Int32 nBytes ) { - try + sal_Int32 nRet = 0; + if( !mbEof && (nBytes > 0) ) try { - OSL_ENSURE( mxInStrm.is(), "BinaryInputStream::skip - invalid call" ); - mxInStrm->skipBytes( nBytes ); + OSL_ENSURE( mxInStrm.is(), "BinaryXInputStream::readData - invalid call" ); + nRet = mxInStrm->readBytes( orData, nBytes ); + mbEof = nRet != nBytes; } catch( Exception& ) { - OSL_ENSURE( false, "BinaryInputStream::skip - exception caught" ); + mbEof = true; } + return nRet; } -sal_Int32 BinaryInputStream::read( Sequence< sal_Int8 >& orBuffer, sal_Int32 nBytes ) +sal_Int32 BinaryXInputStream::readMemory( void* opMem, sal_Int32 nBytes ) { sal_Int32 nRet = 0; - try - { - OSL_ENSURE( mxInStrm.is(), "BinaryInputStream::read - invalid call" ); - nRet = mxInStrm->readBytes( orBuffer, nBytes ); - } - catch( Exception& ) + if( !mbEof && (nBytes > 0) ) { - OSL_ENSURE( false, "BinaryInputStream::read - stream read error" ); + sal_Int32 nBufferSize = getLimitedValue< sal_Int32, sal_Int32 >( nBytes, 0, INPUTSTREAM_BUFFERSIZE ); + sal_uInt8* opnMem = reinterpret_cast< sal_uInt8* >( opMem ); + while( !mbEof && (nBytes > 0) ) + { + sal_Int32 nReadSize = getLimitedValue< sal_Int32, sal_Int32 >( nBytes, 0, nBufferSize ); + sal_Int32 nBytesRead = readData( maBuffer, nReadSize ); + if( nBytesRead > 0 ) + memcpy( opnMem, maBuffer.getConstArray(), static_cast< size_t >( nBytesRead ) ); + opnMem += nBytesRead; + nBytes -= nBytesRead; + nRet += nBytesRead; + } } return nRet; } -sal_Int32 BinaryInputStream::read( void* opBuffer, sal_Int32 nBytes ) +void BinaryXInputStream::skip( sal_Int32 nBytes ) { - sal_Int32 nRet = read( maBuffer, nBytes ); - if( nRet > 0 ) - memcpy( opBuffer, maBuffer.getConstArray(), static_cast< size_t >( nRet ) ); - return nRet; + if( !mbEof ) try + { + OSL_ENSURE( mxInStrm.is(), "BinaryXInputStream::skip - invalid call" ); + mxInStrm->skipBytes( nBytes ); + } + catch( Exception& ) + { + mbEof = true; + } } -void BinaryInputStream::close() +void BinaryXInputStream::close() { if( mxInStrm.is() ) try { mxInStrm->closeInput(); + mxInStrm.clear(); } catch( Exception& ) { - OSL_ENSURE( false, "BinaryInputStream::close - closing input stream failed" ); + OSL_ENSURE( false, "BinaryXInputStream::close - closing input stream failed" ); + } +} + +// ============================================================================ + +SequenceInputStream::SequenceInputStream( StreamDataSequence& rData ) : + SequenceSeekableStream( rData ) +{ +} + +sal_Int32 SequenceInputStream::readData( StreamDataSequence& orData, sal_Int32 nBytes ) +{ + sal_Int32 nReadBytes = 0; + if( !mbEof ) + { + nReadBytes = getLimitedValue< sal_Int32, sal_Int32 >( nBytes, 0, mrData.getLength() - mnPos ); + orData.realloc( nReadBytes ); + if( nReadBytes > 0 ) + memcpy( orData.getArray(), mrData.getConstArray() + mnPos, static_cast< size_t >( nReadBytes ) ); + mnPos += nReadBytes; + mbEof = nReadBytes < nBytes; + } + return nReadBytes; +} + +sal_Int32 SequenceInputStream::readMemory( void* opMem, sal_Int32 nBytes ) +{ + sal_Int32 nReadBytes = 0; + if( !mbEof ) + { + nReadBytes = ::std::min< sal_Int32 >( nBytes, mrData.getLength() - mnPos ); + if( nReadBytes > 0 ) + memcpy( opMem, mrData.getConstArray() + mnPos, static_cast< size_t >( nReadBytes ) ); + mnPos += nReadBytes; + mbEof = nReadBytes < nBytes; + } + return nReadBytes; +} + +void SequenceInputStream::skip( sal_Int32 nBytes ) +{ + if( !mbEof ) + { + sal_Int32 nSkipBytes = ::std::min< sal_Int32 >( nBytes, mrData.getLength() - mnPos ); + mnPos += nSkipBytes; + mbEof = nSkipBytes < nBytes; } } diff --git a/oox/source/helper/binaryoutputstream.cxx b/oox/source/helper/binaryoutputstream.cxx index 946f50d97d48..c61b005029ba 100644 --- a/oox/source/helper/binaryoutputstream.cxx +++ b/oox/source/helper/binaryoutputstream.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: binaryoutputstream.cxx,v $ - * $Revision: 1.4 $ + * $Revision: 1.4.22.2 $ * * This file is part of OpenOffice.org. * @@ -30,75 +30,94 @@ #include "oox/helper/binaryoutputstream.hxx" #include <osl/diagnose.h> -#include <com/sun/star/io/XOutputStream.hpp> #include "oox/helper/binaryinputstream.hxx" #include <string.h> +using ::com::sun::star::uno::UNO_QUERY; using ::com::sun::star::uno::Reference; -using ::com::sun::star::uno::Sequence; using ::com::sun::star::uno::Exception; using ::com::sun::star::io::XOutputStream; +using ::com::sun::star::io::XSeekable; namespace oox { +const sal_Int32 OUTPUTSTREAM_BUFFERSIZE = 0x8000; + +// ============================================================================ + +void BinaryOutputStream::copyStream( BinaryInputStream& rInStrm, sal_Int64 nBytes ) +{ + if( nBytes > 0 ) + { + sal_Int32 nBufferSize = getLimitedValue< sal_Int32, sal_Int64 >( nBytes, 0, OUTPUTSTREAM_BUFFERSIZE ); + StreamDataSequence aBuffer( nBufferSize ); + while( nBytes > 0 ) + { + sal_Int32 nReadSize = getLimitedValue< sal_Int32, sal_Int64 >( nBytes, 0, nBufferSize ); + sal_Int32 nBytesRead = rInStrm.readData( aBuffer, nReadSize ); + writeData( aBuffer ); + if( nReadSize == nBytesRead ) + nBytes -= nReadSize; + else + nBytes = 0; + } + } +} + +void BinaryOutputStream::writeAtom( const void* pMem, sal_uInt8 nSize ) +{ + writeMemory( pMem, nSize ); +} + // ============================================================================ -BinaryOutputStream::BinaryOutputStream( const Reference< XOutputStream >& rxOutStrm, bool bAutoClose ) : - BinaryStreamBase( rxOutStrm ), +BinaryXOutputStream::BinaryXOutputStream( const Reference< XOutputStream >& rxOutStrm, bool bAutoClose ) : + BinaryXSeekableStream( Reference< XSeekable >( rxOutStrm, UNO_QUERY ) ), + maBuffer( OUTPUTSTREAM_BUFFERSIZE ), mxOutStrm( rxOutStrm ), mbAutoClose( bAutoClose ) { + mbEof = !mxOutStrm.is(); } -BinaryOutputStream::~BinaryOutputStream() +BinaryXOutputStream::~BinaryXOutputStream() { if( mbAutoClose ) close(); } -void BinaryOutputStream::write( const Sequence< sal_Int8 >& rBuffer ) +void BinaryXOutputStream::writeData( const StreamDataSequence& rData ) { try { - OSL_ENSURE( mxOutStrm.is(), "BinaryOutputStream::write - invalid call" ); - mxOutStrm->writeBytes( rBuffer ); + OSL_ENSURE( mxOutStrm.is(), "BinaryXOutputStream::writeData - invalid call" ); + mxOutStrm->writeBytes( rData ); } catch( Exception& ) { - OSL_ENSURE( false, "BinaryOutputStream::write - stream read error" ); + OSL_ENSURE( false, "BinaryXOutputStream::writeData - stream read error" ); } } -void BinaryOutputStream::write( const void* pBuffer, sal_Int32 nBytes ) +void BinaryXOutputStream::writeMemory( const void* pMem, sal_Int32 nBytes ) { if( nBytes > 0 ) { - maBuffer.realloc( nBytes ); - memcpy( maBuffer.getArray(), pBuffer, static_cast< size_t >( nBytes ) ); - write( maBuffer ); - } -} - -void BinaryOutputStream::copy( BinaryInputStream& rInStrm, sal_Int64 nBytes ) -{ - if( rInStrm.is() && (nBytes > 0) ) - { - sal_Int32 nBufferSize = getLimitedValue< sal_Int32, sal_Int64 >( nBytes, 0, 0x8000 ); - Sequence< sal_Int8 > aBuffer( nBufferSize ); + sal_Int32 nBufferSize = getLimitedValue< sal_Int32, sal_Int32 >( nBytes, 0, OUTPUTSTREAM_BUFFERSIZE ); + const sal_uInt8* pnMem = reinterpret_cast< const sal_uInt8* >( pMem ); while( nBytes > 0 ) { - sal_Int32 nReadSize = getLimitedValue< sal_Int32, sal_Int64 >( nBytes, 0, nBufferSize ); - sal_Int32 nBytesRead = rInStrm.read( aBuffer, nReadSize ); - write( aBuffer ); - if( nReadSize == nBytesRead ) - nBytes -= nReadSize; - else - nBytes = 0; + sal_Int32 nWriteSize = getLimitedValue< sal_Int32, sal_Int32 >( nBytes, 0, nBufferSize ); + maBuffer.realloc( nWriteSize ); + memcpy( maBuffer.getArray(), pnMem, static_cast< size_t >( nWriteSize ) ); + writeData( maBuffer ); + pnMem += nWriteSize; + nBytes -= nWriteSize; } } } -void BinaryOutputStream::close() +void BinaryXOutputStream::close() { if( mxOutStrm.is() ) try { @@ -107,7 +126,31 @@ void BinaryOutputStream::close() } catch( Exception& ) { - OSL_ENSURE( false, "BinaryOutputStream::close - closing output stream failed" ); + OSL_ENSURE( false, "BinaryXOutputStream::close - closing output stream failed" ); + } +} + +// ============================================================================ + +SequenceOutputStream::SequenceOutputStream( StreamDataSequence& rData ) : + SequenceSeekableStream( rData ) +{ +} + +void SequenceOutputStream::writeData( const StreamDataSequence& rData ) +{ + if( rData.hasElements() ) + writeMemory( rData.getConstArray(), rData.getLength() ); +} + +void SequenceOutputStream::writeMemory( const void* pMem, sal_Int32 nBytes ) +{ + if( nBytes > 0 ) + { + if( mrData.getLength() - mnPos < nBytes ) + mrData.realloc( mnPos + nBytes ); + memcpy( mrData.getArray() + mnPos, pMem, static_cast< size_t >( nBytes ) ); + mnPos += nBytes; } } diff --git a/oox/source/helper/binarystreambase.cxx b/oox/source/helper/binarystreambase.cxx index 0497e8274591..238baded3434 100644 --- a/oox/source/helper/binarystreambase.cxx +++ b/oox/source/helper/binarystreambase.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: binarystreambase.cxx,v $ - * $Revision: 1.3 $ + * $Revision: 1.3.22.2 $ * * This file is part of OpenOffice.org. * @@ -31,7 +31,9 @@ #include "oox/helper/binarystreambase.hxx" #include <osl/diagnose.h> +using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Exception; +using ::com::sun::star::io::XSeekable; namespace oox { @@ -41,46 +43,105 @@ BinaryStreamBase::~BinaryStreamBase() { } +bool BinaryStreamBase::isSeekable() const +{ + return false; +} + sal_Int64 BinaryStreamBase::getLength() const { - try + return -1; +} + +sal_Int64 BinaryStreamBase::tell() const +{ + return -1; +} + +void BinaryStreamBase::seek( sal_Int64 ) +{ +} + +sal_Int64 BinaryStreamBase::getRemaining() const +{ + return isSeekable() ? ::std::max< sal_Int64 >( getLength() - tell(), 0 ) : -1; +} + +// ============================================================================ + +BinaryXSeekableStream::BinaryXSeekableStream( const Reference< XSeekable >& rxSeekable ) : + mxSeekable( rxSeekable ) +{ +} + +bool BinaryXSeekableStream::isSeekable() const +{ + return mxSeekable.is(); +} + +sal_Int64 BinaryXSeekableStream::getLength() const +{ + if( mxSeekable.is() ) try { - return mxSeekable.is() ? mxSeekable->getLength() : -1; + return mxSeekable->getLength(); } catch( Exception& ) { - OSL_ENSURE( false, "BinaryStreamBase::getLength - exception caught" ); + OSL_ENSURE( false, "BinaryXSeekableStream::getLength - exception caught" ); } return -1; } -sal_Int64 BinaryStreamBase::tell() const +sal_Int64 BinaryXSeekableStream::tell() const { - try + if( mxSeekable.is() ) try { - return mxSeekable.is() ? mxSeekable->getPosition() : -1; + return mxSeekable->getPosition(); } catch( Exception& ) { - OSL_ENSURE( false, "BinaryStreamBase::tell - exception caught" ); + OSL_ENSURE( false, "BinaryXSeekableStream::tell - exception caught" ); } return -1; } -void BinaryStreamBase::seek( sal_Int64 nPos ) +void BinaryXSeekableStream::seek( sal_Int64 nPos ) { - try + if( mxSeekable.is() ) try { - if( mxSeekable.is() ) - mxSeekable->seek( nPos ); + mbEof = false; + mxSeekable->seek( nPos ); } catch( Exception& ) { - OSL_ENSURE( false, "BinaryStreamBase::seek - exception caught" ); + mbEof = true; } } // ============================================================================ +bool SequenceSeekableStream::isSeekable() const +{ + return true; +} + +sal_Int64 SequenceSeekableStream::getLength() const +{ + return mrData.getLength(); +} + +sal_Int64 SequenceSeekableStream::tell() const +{ + return mnPos; +} + +void SequenceSeekableStream::seek( sal_Int64 nPos ) +{ + mnPos = getLimitedValue< sal_Int32, sal_Int64 >( nPos, 0, mrData.getLength() ); + mbEof = mnPos < nPos; +} + +// ============================================================================ + } // namespace oox diff --git a/oox/source/helper/containerhelper.cxx b/oox/source/helper/containerhelper.cxx index 9d4327e12d31..e09fe77bcc2f 100644 --- a/oox/source/helper/containerhelper.cxx +++ b/oox/source/helper/containerhelper.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: containerhelper.cxx,v $ - * $Revision: 1.4 $ + * $Revision: 1.4.6.1 $ * * This file is part of OpenOffice.org. * @@ -33,7 +33,6 @@ #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/container/XIndexContainer.hpp> #include <com/sun/star/container/XNameContainer.hpp> -#include <comphelper/processfactory.hxx> #include "oox/helper/helper.hxx" using ::rtl::OUString; @@ -52,13 +51,12 @@ namespace oox { // ============================================================================ -Reference< XIndexContainer > ContainerHelper::createIndexContainer() +Reference< XIndexContainer > ContainerHelper::createIndexContainer( const Reference< XMultiServiceFactory >& rxFactory ) { Reference< XIndexContainer > xContainer; - try + if( rxFactory.is() ) try { - Reference< XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory(); - xContainer.set( xFactory->createInstance( CREATE_OUSTRING( "com.sun.star.document.IndexedPropertyValues" ) ), UNO_QUERY_THROW ); + xContainer.set( rxFactory->createInstance( CREATE_OUSTRING( "com.sun.star.document.IndexedPropertyValues" ) ), UNO_QUERY_THROW ); } catch( Exception& ) { @@ -85,13 +83,12 @@ bool ContainerHelper::insertByIndex( return bRet; } -Reference< XNameContainer > ContainerHelper::createNameContainer() +Reference< XNameContainer > ContainerHelper::createNameContainer( const Reference< XMultiServiceFactory >& rxFactory ) { Reference< XNameContainer > xContainer; - try + if( rxFactory.is() ) try { - Reference< XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory(); - xContainer.set( xFactory->createInstance( CREATE_OUSTRING( "com.sun.star.document.NamedPropertyValues" ) ), UNO_QUERY_THROW ); + xContainer.set( rxFactory->createInstance( CREATE_OUSTRING( "com.sun.star.document.NamedPropertyValues" ) ), UNO_QUERY_THROW ); } catch( Exception& ) { diff --git a/oox/source/helper/makefile.mk b/oox/source/helper/makefile.mk index 900c3c8d4605..d584c14d2c07 100644 --- a/oox/source/helper/makefile.mk +++ b/oox/source/helper/makefile.mk @@ -1,14 +1,14 @@ #************************************************************************* # # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# +# # Copyright 2008 by Sun Microsystems, Inc. # # OpenOffice.org - a multi-platform office productivity suite # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.3 $ +# $Revision: 1.3.22.1 $ # # This file is part of OpenOffice.org. # diff --git a/oox/source/helper/recordinputstream.cxx b/oox/source/helper/recordinputstream.cxx index 8ab942e4898d..4b2ad21fc5c2 100644 --- a/oox/source/helper/recordinputstream.cxx +++ b/oox/source/helper/recordinputstream.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: recordinputstream.cxx,v $ - * $Revision: 1.4 $ + * $Revision: 1.4.22.1 $ * * This file is part of OpenOffice.org. * @@ -38,62 +38,36 @@ namespace oox { // ============================================================================ -RecordInputStream::RecordInputStream( const RecordDataSequence& rData ) : - maData( rData ), - mnRecSize( rData.getLength() ), - mnRecPos( 0 ), - mbValid( true ) +RecordInputStream::RecordInputStream( StreamDataSequence& rData ) : + SequenceInputStream( rData ) { } -sal_Int32 RecordInputStream::read( void* opData, sal_Int32 nBytes ) -{ - sal_Int32 nReadSize = ::std::min( nBytes, getRecLeft() ); - OSL_ENSURE( !mbValid || (nReadSize == nBytes), "RecordInputStream::read - buffer overflow" ); - mbValid = nReadSize == nBytes; - if( mbValid && opData && (nReadSize > 0) ) - memcpy( opData, maData.getConstArray() + mnRecPos, nReadSize ); - mnRecPos += nReadSize; - return nReadSize; -} - OUString RecordInputStream::readString( bool b32BitLen ) { OUString aString; - sal_Int32 nCharCount = b32BitLen ? readValue< sal_Int32 >() : readValue< sal_Int16 >(); - // string length -1 is often used to indicate a missing string - OSL_ENSURE( !mbValid || (nCharCount >= -1), "RecordInputStream::readString - invalid string length" ); - if( mbValid && (nCharCount >= 0) ) + if( !isEof() ) { - ::std::vector< sal_Unicode > aBuffer; - aBuffer.reserve( getLimitedValue< size_t, sal_Int32 >( nCharCount + 1, 0, 0xFFFF ) ); - for( sal_Int32 nCharIdx = 0; mbValid && (nCharIdx < nCharCount); ++nCharIdx ) + sal_Int32 nCharCount = b32BitLen ? readValue< sal_Int32 >() : readValue< sal_Int16 >(); + // string length -1 is often used to indicate a missing string + OSL_ENSURE( !isEof() && (nCharCount >= -1), "RecordInputStream::readString - invalid string length" ); + if( !isEof() && (nCharCount > 0) ) { - sal_uInt16 nChar; - readValue( nChar ); - aBuffer.push_back( static_cast< sal_Unicode >( nChar ) ); + ::std::vector< sal_Unicode > aBuffer; + aBuffer.reserve( getLimitedValue< size_t, sal_Int32 >( nCharCount + 1, 0, 0xFFFF ) ); + for( sal_Int32 nCharIdx = 0; !isEof() && (nCharIdx < nCharCount); ++nCharIdx ) + { + sal_uInt16 nChar; + readValue( nChar ); + aBuffer.push_back( static_cast< sal_Unicode >( nChar ) ); + } + aBuffer.push_back( 0 ); + aString = OUString( &aBuffer.front() ); } - aBuffer.push_back( 0 ); - aString = OUString( &aBuffer.front() ); } return aString; } -void RecordInputStream::seek( sal_Int32 nRecPos ) -{ - mnRecPos = getLimitedValue< sal_Int32, sal_Int32 >( nRecPos, 0, mnRecSize ); - OSL_ENSURE( !mbValid || (nRecPos == mnRecPos), "RecordInputStream::seek - invalid position" ); - mbValid = nRecPos == mnRecPos; -} - -void RecordInputStream::skip( sal_Int32 nBytes ) -{ - sal_Int32 nSkipSize = getLimitedValue< sal_Int32, sal_Int32 >( nBytes, 0, getRecLeft() ); - OSL_ENSURE( !mbValid || (nSkipSize == nBytes), "RecordInputStream::skip - buffer overflow" ); - mbValid = nSkipSize == nBytes; - mnRecPos += nSkipSize; -} - // ============================================================================ } // namespace oox diff --git a/oox/source/ole/makefile.mk b/oox/source/ole/makefile.mk new file mode 100644 index 000000000000..14575fd6450f --- /dev/null +++ b/oox/source/ole/makefile.mk @@ -0,0 +1,53 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2008 by Sun Microsystems, Inc. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.2.1 $ +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ=..$/.. + +PRJNAME=oox +TARGET=ole +AUTOSEG=true + +ENABLE_EXCEPTIONS=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk +.INCLUDE: $(PRJ)$/util$/makefile.pmk + +# --- Files -------------------------------------------------------- + +SLOFILES = \ + $(SLO)$/vbainputstream.obj + +# --- Targets ------------------------------------------------------- + +.INCLUDE : target.mk + diff --git a/oox/source/ole/vbainputstream.cxx b/oox/source/ole/vbainputstream.cxx new file mode 100644 index 000000000000..ba6032940155 --- /dev/null +++ b/oox/source/ole/vbainputstream.cxx @@ -0,0 +1,188 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: vbainputstream.cxx,v $ + * $Revision: 1.1.2.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "oox/ole/vbainputstream.hxx" +#include <osl/diagnose.h> + +namespace oox { +namespace ole { + +namespace { + +const sal_uInt8 VBASTREAM_SIGNATURE = 1; + +const sal_uInt16 VBACHUNK_SIGMASK = 0x7000; +const sal_uInt16 VBACHUNK_SIG = 0x3000; +const sal_uInt16 VBACHUNK_COMPRESSED = 0x8000; +const sal_uInt16 VBACHUNK_LENMASK = 0x0FFF; + +} // namespace + +// ============================================================================ + +VbaInputStream::VbaInputStream( BinaryInputStream& rInStrm ) : + mrInStrm( rInStrm ), + mnChunkPos( 0 ) +{ + maChunk.reserve( 4096 ); + + sal_uInt8 nSig = mrInStrm.readuInt8(); + OSL_ENSURE( nSig == VBASTREAM_SIGNATURE, "VbaInputStream::VbaInputStream - wrong signature" ); + mbEof = nSig != VBASTREAM_SIGNATURE; +} + +sal_Int32 VbaInputStream::readData( StreamDataSequence& orData, sal_Int32 nBytes ) +{ + sal_Int32 nRet = 0; + if( !mbEof ) + { + orData.realloc( ::std::max< sal_Int32 >( nBytes, 0 ) ); + if( nBytes > 0 ) + { + nRet = readMemory( orData.getArray(), nBytes ); + if( nRet < nBytes ) + orData.realloc( nRet ); + } + } + return nRet; +} + +sal_Int32 VbaInputStream::readMemory( void* opMem, sal_Int32 nBytes ) +{ + sal_Int32 nRet = 0; + sal_uInt8* opnMem = reinterpret_cast< sal_uInt8* >( opMem ); + while( (nBytes > 0) && updateChunk() ) + { + sal_Int32 nChunkLeft = static_cast< sal_Int32 >( maChunk.size() - mnChunkPos ); + sal_Int32 nReadBytes = ::std::min( nBytes, nChunkLeft ); + memcpy( opnMem, &*(maChunk.begin() + mnChunkPos), nReadBytes ); + opnMem += nReadBytes; + mnChunkPos += static_cast< size_t >( nReadBytes ); + nBytes -= nReadBytes; + nRet += nReadBytes; + } + return nRet; +} + +void VbaInputStream::skip( sal_Int32 nBytes ) +{ + while( (nBytes > 0) && updateChunk() ) + { + sal_Int32 nChunkLeft = static_cast< sal_Int32 >( maChunk.size() - mnChunkPos ); + sal_Int32 nSkipBytes = ::std::min( nBytes, nChunkLeft ); + mnChunkPos += static_cast< size_t >( nSkipBytes ); + nBytes -= nSkipBytes; + } +} + +// private -------------------------------------------------------------------- + +bool VbaInputStream::updateChunk() +{ + if( mbEof || (mnChunkPos < maChunk.size()) ) return !mbEof; + + // try to read next chunk header, this may trigger EOF + sal_uInt16 nHeader = mrInStrm.readuInt16(); + mbEof = mrInStrm.isEof(); + if( mbEof ) return false; + + // check header signature + OSL_ENSURE( (nHeader & VBACHUNK_SIGMASK) == VBACHUNK_SIG, "VbaInputStream::readChunk - invalid chunk signature" ); + mbEof = (nHeader & VBACHUNK_SIGMASK) != VBACHUNK_SIG; + if( mbEof ) return false; + + // decode length of chunk data and compression flag + bool bCompressed = getFlag( nHeader, VBACHUNK_COMPRESSED ); + sal_uInt16 nChunkLen = (nHeader & VBACHUNK_LENMASK) + 1; + OSL_ENSURE( bCompressed || (nChunkLen == 4096), "VbaInputStream::readChunk - invalid uncompressed chunk size" ); + if( bCompressed ) + { + maChunk.clear(); + sal_uInt8 nBitCount = 4; + sal_uInt16 nChunkPos = 0; + while( !mbEof && !mrInStrm.isEof() && (nChunkPos < nChunkLen) ) + { + sal_uInt8 nTokenFlags = mrInStrm.readuInt8(); + ++nChunkPos; + for( int nBit = 0; !mbEof && !mrInStrm.isEof() && (nBit < 8) && (nChunkPos < nChunkLen); ++nBit, nTokenFlags >>= 1 ) + { + if( nTokenFlags & 1 ) + { + sal_uInt16 nCopyToken = mrInStrm.readuInt16(); + nChunkPos = nChunkPos + 2; + // update bit count used for offset/length in the token + while( static_cast< size_t >( 1 << nBitCount ) < maChunk.size() ) ++nBitCount; + // extract length from lower (16-nBitCount) bits, plus 3 + sal_uInt16 nLength = extractValue< sal_uInt16 >( nCopyToken, 0, 16 - nBitCount ) + 3; + // extract offset from high nBitCount bits, plus 1 + sal_uInt16 nOffset = extractValue< sal_uInt16 >( nCopyToken, 16 - nBitCount, nBitCount ) + 1; + mbEof = (nOffset > maChunk.size()) || (maChunk.size() + nLength > 4096); + OSL_ENSURE( !mbEof, "VbaInputStream::readChunk - invalid offset or size in copy token" ); + if( !mbEof ) + { + // append data to buffer + maChunk.resize( maChunk.size() + nLength ); + sal_uInt8* pnTo = &*(maChunk.end() - nLength); + const sal_uInt8* pnEnd = pnTo + nLength; + const sal_uInt8* pnFrom = pnTo - nOffset; + // offset may be less than length, effectively duplicating source data several times + size_t nRunLen = ::std::min< size_t >( nLength, nOffset ); + while( pnTo < pnEnd ) + { + size_t nStepLen = ::std::min< size_t >( nRunLen, pnEnd - pnTo ); + memcpy( pnTo, pnFrom, nStepLen ); + pnTo += nStepLen; + } + } + } + else + { + maChunk.resize( maChunk.size() + 1 ); + mrInStrm >> maChunk.back(); + ++nChunkPos; + } + } + } + } + else + { + maChunk.resize( nChunkLen ); + mrInStrm.readMemory( &maChunk.front(), nChunkLen ); + } + + mnChunkPos = 0; + return !mbEof; +} + +// ============================================================================ + +} // namespace ole +} // namespace oox + diff --git a/oox/source/ppt/commonbehaviorcontext.cxx b/oox/source/ppt/commonbehaviorcontext.cxx index 9dbf3607a0be..8590b16d73e1 100644 --- a/oox/source/ppt/commonbehaviorcontext.cxx +++ b/oox/source/ppt/commonbehaviorcontext.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: commonbehaviorcontext.cxx,v $ - * $Revision: 1.5 $ + * $Revision: 1.5.20.1 $ * * This file is part of OpenOffice.org. * @@ -30,7 +30,6 @@ #include "comphelper/anytostring.hxx" #include "cppuhelper/exc_hlp.hxx" -#include <comphelper/processfactory.hxx> #include <osl/diagnose.h> #include <rtl/ustrbuf.hxx> diff --git a/oox/source/ppt/pptimport.cxx b/oox/source/ppt/pptimport.cxx index 65dac255ab44..27074a436b49 100644 --- a/oox/source/ppt/pptimport.cxx +++ b/oox/source/ppt/pptimport.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: pptimport.cxx,v $ - * $Revision: 1.8 $ + * $Revision: 1.8.6.1 $ * * This file is part of OpenOffice.org. * @@ -72,7 +72,7 @@ bool PowerPointImport::importDocument() throw() { /* to activate the PPTX dumper, define the environment variable OOO_PPTXDUMPER and insert the full path to the file - file:///<path-to-oox-module>/source/dump/pptxdumperconfig.dat. */ + file:///<path-to-oox-module>/source/dump/pptxdumper.ini. */ OOX_DUMP_FILE( ::oox::dump::pptx::Dumper ); OUString aFragmentPath = getFragmentPathFromType( CREATE_OFFICEDOC_RELATIONSTYPE( "officeDocument" ) ); diff --git a/oox/source/ppt/slidepersist.cxx b/oox/source/ppt/slidepersist.cxx index 9dac075db38c..468d6547a25e 100644 --- a/oox/source/ppt/slidepersist.cxx +++ b/oox/source/ppt/slidepersist.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: slidepersist.cxx,v $ - * $Revision: 1.7 $ + * $Revision: 1.7.6.1 $ * * This file is part of OpenOffice.org. * @@ -163,7 +163,7 @@ void SlidePersist::createXShapes( const XmlFilterBase& rFilterBase ) TimeNodePtr pNode(maTimeNodeList.front()); OSL_ENSURE( pNode, "pNode" ); - pNode->setNode( rFilterBase.getModel(), xNode, pSlidePtr ); + pNode->setNode( rFilterBase, xNode, pSlidePtr ); } } } diff --git a/oox/source/ppt/timenode.cxx b/oox/source/ppt/timenode.cxx index 0c1babc11897..3c85ad77ba66 100644 --- a/oox/source/ppt/timenode.cxx +++ b/oox/source/ppt/timenode.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: timenode.cxx,v $ - * $Revision: 1.4 $ + * $Revision: 1.4.6.1 $ * * This file is part of OpenOffice.org. * @@ -32,8 +32,6 @@ #include <boost/bind.hpp> -#include <comphelper/processfactory.hxx> - #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/beans/NamedValue.hpp> #include <com/sun/star/container/XEnumerationAccess.hpp> @@ -52,6 +50,7 @@ #include <com/sun/star/presentation/EffectNodeType.hpp> #include "oox/helper/helper.hxx" +#include "oox/core/xmlfilterbase.hxx" using ::rtl::OUString; using namespace ::oox::core; @@ -216,13 +215,12 @@ namespace oox { namespace ppt { // END CUT&PASTE - void TimeNode::addNode( const Reference< XModel > &rxModel, - const Reference< XAnimationNode >& rxNode, const SlidePersistPtr & pSlide ) + void TimeNode::addNode( const XmlFilterBase& rFilter, const Reference< XAnimationNode >& rxNode, const SlidePersistPtr & pSlide ) { try { OUString sServiceName = getServiceName( mnNodeType ); - Reference< XAnimationNode > xNode = createAndInsert(sServiceName, rxModel, rxNode ); - setNode( rxModel, xNode, pSlide ); + Reference< XAnimationNode > xNode = createAndInsert( rFilter, sServiceName, rxNode ); + setNode( rFilter, xNode, pSlide ); } catch( const Exception& e ) { @@ -231,8 +229,7 @@ namespace oox { namespace ppt { } } - void TimeNode::setNode( const Reference< XModel > &rxModel, - const Reference< XAnimationNode >& xNode, const SlidePersistPtr & pSlide ) + void TimeNode::setNode( const XmlFilterBase& rFilter, const Reference< XAnimationNode >& xNode, const SlidePersistPtr & pSlide ) { OSL_ENSURE( xNode.is(), "null node passed" ); @@ -549,7 +546,7 @@ namespace oox { namespace ppt { } std::for_each( maChildren.begin(), maChildren.end(), - boost::bind(&TimeNode::addNode, _1, rxModel, boost::ref(xNode), + boost::bind(&TimeNode::addNode, _1, boost::cref(rFilter), boost::ref(xNode), boost::ref(pSlide) ) ); switch( mnNodeType ) @@ -583,12 +580,13 @@ namespace oox { namespace ppt { } - Reference< XAnimationNode > TimeNode::createAndInsert( const OUString& rServiceName, const Reference< XModel > &/*rxModel*/, - const Reference< XAnimationNode >& rxNode ) + Reference< XAnimationNode > TimeNode::createAndInsert( + const XmlFilterBase& rFilter, + const OUString& rServiceName, + const Reference< XAnimationNode >& rxNode ) { try { - Reference< XAnimationNode > xNode ( ::comphelper::getProcessServiceFactory()->createInstance(rServiceName ), - UNO_QUERY_THROW ); + Reference< XAnimationNode > xNode ( rFilter.getGlobalFactory()->createInstance(rServiceName ), UNO_QUERY_THROW ); Reference< XTimeContainer > xParentContainer( rxNode, UNO_QUERY_THROW ); xParentContainer->appendChild( xNode ); diff --git a/oox/source/ppt/timenodelistcontext.cxx b/oox/source/ppt/timenodelistcontext.cxx index 87d7411d6479..7199afac01f4 100644 --- a/oox/source/ppt/timenodelistcontext.cxx +++ b/oox/source/ppt/timenodelistcontext.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: timenodelistcontext.cxx,v $ - * $Revision: 1.4 $ + * $Revision: 1.4.20.1 $ * * This file is part of OpenOffice.org. * @@ -32,7 +32,6 @@ #include "comphelper/anytostring.hxx" #include "cppuhelper/exc_hlp.hxx" -#include <comphelper/processfactory.hxx> #include <osl/diagnose.h> #include <rtl/math.hxx> diff --git a/oox/source/xls/addressconverter.cxx b/oox/source/xls/addressconverter.cxx index 69b25275290a..16d57b3c80ff 100644 --- a/oox/source/xls/addressconverter.cxx +++ b/oox/source/xls/addressconverter.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: addressconverter.cxx,v $ - * $Revision: 1.4 $ + * $Revision: 1.4.20.1 $ * * This file is part of OpenOffice.org. * @@ -201,7 +201,7 @@ BinRange BinRangeList::getEnclosingRange() const void BinRangeList::read( RecordInputStream& rStrm ) { sal_Int32 nCount = rStrm.readInt32(); - resize( getLimitedValue< size_t, sal_Int32 >( nCount, 0, rStrm.getRecLeft() / 16 ) ); + resize( getLimitedValue< size_t, sal_Int64 >( nCount, 0, rStrm.getRemaining() / 16 ) ); for( iterator aIt = begin(), aEnd = end(); aIt != aEnd; ++aIt ) aIt->read( rStrm ); } @@ -209,7 +209,7 @@ void BinRangeList::read( RecordInputStream& rStrm ) void BinRangeList::read( BiffInputStream& rStrm, bool bCol16Bit, bool bRow32Bit ) { sal_uInt16 nCount = rStrm.readuInt16(); - resize( getLimitedValue< size_t, sal_uInt32 >( nCount, 0, rStrm.getRecLeft() / lclGetBiffRangeSize( bCol16Bit, bRow32Bit ) ) ); + resize( getLimitedValue< size_t, sal_Int64 >( nCount, 0, rStrm.getRemaining() / lclGetBiffRangeSize( bCol16Bit, bRow32Bit ) ) ); for( iterator aIt = begin(), aEnd = end(); aIt != aEnd; ++aIt ) aIt->read( rStrm, bCol16Bit, bRow32Bit ); } diff --git a/oox/source/xls/autofiltercontext.cxx b/oox/source/xls/autofiltercontext.cxx index cd13953edd0a..e36818504f30 100644 --- a/oox/source/xls/autofiltercontext.cxx +++ b/oox/source/xls/autofiltercontext.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: autofiltercontext.cxx,v $ - * $Revision: 1.5 $ + * $Revision: 1.5.4.1 $ * * This file is part of OpenOffice.org. * @@ -29,11 +29,7 @@ ************************************************************************/ #include "oox/xls/autofiltercontext.hxx" -#include "oox/helper/attributelist.hxx" -#include "oox/helper/propertyset.hxx" -#include "oox/xls/addressconverter.hxx" #include <rtl/ustrbuf.hxx> -#include <comphelper/processfactory.hxx> #include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/container/XNamed.hpp> #include <com/sun/star/table/XCellRange.hpp> @@ -44,6 +40,10 @@ #include <com/sun/star/sheet/FilterConnection.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/i18n/XLocaleData.hpp> +#include "oox/helper/attributelist.hxx" +#include "oox/helper/propertyset.hxx" +#include "oox/core/filterbase.hxx" +#include "oox/xls/addressconverter.hxx" #define DEBUG_OOX_AUTOFILTER 0 @@ -80,7 +80,6 @@ using ::com::sun::star::sheet::XDatabaseRanges; using ::com::sun::star::sheet::XSheetFilterDescriptor; using ::com::sun::star::i18n::LocaleDataItem; using ::com::sun::star::i18n::XLocaleData; -using ::com::sun::star::lang::XMultiServiceFactory; using ::com::sun::star::lang::Locale; namespace oox { @@ -704,8 +703,7 @@ void OoxAutoFilterContext::importCustomFilter( const AttributeList& rAttribs ) case XML_equal: case XML_notEqual: { - Reference< XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory(); - Reference< XLocaleData > xLocale( xFactory->createInstance( + Reference< XLocaleData > xLocale( getBaseFilter().getGlobalFactory()->createInstance( CREATE_OUSTRING("com.sun.star.i18n.LocaleData") ), UNO_QUERY ); if ( !xLocale.is() ) diff --git a/oox/source/xls/biffdetector.cxx b/oox/source/xls/biffdetector.cxx index 87b64a716061..c7c466f067e6 100644 --- a/oox/source/xls/biffdetector.cxx +++ b/oox/source/xls/biffdetector.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: biffdetector.cxx,v $ - * $Revision: 1.3 $ + * $Revision: 1.3.22.1 $ * * This file is part of OpenOffice.org. * @@ -85,7 +85,7 @@ BiffDetector::~BiffDetector() BiffType BiffDetector::detectStreamBiffVersion( BinaryInputStream& rInStream ) { BiffType eBiff = BIFF_UNKNOWN; - if( rInStream.is() && rInStream.isSeekable() && (rInStream.getLength() > 4) ) + if( !rInStream.isEof() && rInStream.isSeekable() && (rInStream.getLength() > 4) ) { sal_Int64 nOldPos = rInStream.tell(); rInStream.seek( 0 ); @@ -146,11 +146,11 @@ BiffType BiffDetector::detectStorageBiffVersion( OUString& orWorkbookStreamName, if( xStorage->isStorage() ) { // try to open the "Book" stream - BinaryInputStream aBookStrm5( xStorage->openInputStream( saBookName ), true ); + BinaryXInputStream aBookStrm5( xStorage->openInputStream( saBookName ), true ); BiffType eBookStrm5Biff = detectStreamBiffVersion( aBookStrm5 ); // try to open the "Workbook" stream - BinaryInputStream aBookStrm8( xStorage->openInputStream( saWorkbookName ), true ); + BinaryXInputStream aBookStrm8( xStorage->openInputStream( saWorkbookName ), true ); BiffType eBookStrm8Biff = detectStreamBiffVersion( aBookStrm8 ); // decide which stream to use @@ -172,7 +172,7 @@ BiffType BiffDetector::detectStorageBiffVersion( OUString& orWorkbookStreamName, else { // no storage, try plain input stream from medium (even for BIFF5+) - BinaryInputStream aStrm( xStorage->openInputStream( OUString() ), false ); + BinaryXInputStream aStrm( xStorage->openInputStream( OUString() ), false ); eBiff = detectStreamBiffVersion( aStrm ); orWorkbookStreamName = OUString(); } diff --git a/oox/source/xls/bifffragmenthandler.cxx b/oox/source/xls/bifffragmenthandler.cxx index ed32008ea66d..e69de29bb2d1 100644 --- a/oox/source/xls/bifffragmenthandler.cxx +++ b/oox/source/xls/bifffragmenthandler.cxx @@ -1,165 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: bifffragmenthandler.cxx,v $ - * $Revision: 1.4 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "oox/xls/bifffragmenthandler.hxx" -#include "oox/xls/biffhelper.hxx" -#include "oox/xls/biffinputstream.hxx" - -namespace oox { -namespace xls { - -// ============================================================================ - -namespace { - -const sal_uInt16 BIFF_BOF_GLOBALS = 0x0005; /// BIFF5-BIFF8 workbook globals. -const sal_uInt16 BIFF_BOF_MODULE = 0x0006; /// BIFF5-BIFF8 Visual Basic module. -const sal_uInt16 BIFF_BOF_SHEET = 0x0010; /// BIFF2-BIFF8 worksheet/dialog sheet. -const sal_uInt16 BIFF_BOF_CHART = 0x0020; /// BIFF2-BIFF8 chart sheet. -const sal_uInt16 BIFF_BOF_MACRO = 0x0040; /// BIFF4-BIFF8 macro sheet. -const sal_uInt16 BIFF_BOF_WORKSPACE = 0x0100; /// BIFF3-BIFF8 workspace. - -} // namespace - -// ============================================================================ - -BiffFragmentHandler::~BiffFragmentHandler() -{ -} - -bool BiffFragmentHandler::importFragment( BiffInputStream& rStrm ) -{ - // default implementation: skip the entire fragment - return skipFragment( rStrm ); -} - -bool BiffFragmentHandler::isBofRecord( sal_uInt16 nRecId ) -{ - return (nRecId == BIFF2_ID_BOF) || (nRecId == BIFF3_ID_BOF) || (nRecId == BIFF4_ID_BOF) || (nRecId == BIFF5_ID_BOF); -} - -BiffFragmentType BiffFragmentHandler::startFragment( BiffInputStream& rStrm, BiffType eBiff ) -{ - BiffFragmentType eFragment = BIFF_FRAGMENT_UNKNOWN; - if( rStrm.startNextRecord() ) - { - /* #i23425# Don't rely on BOF record ID to read BOF contents, but on - the detected BIFF version. */ - if( isBofRecord( rStrm.getRecId() ) ) - { - // BOF is always written unencrypted - rStrm.enableDecoder( false ); - sal_uInt16 nType = rStrm.skip( 2 ).readuInt16(); - - // decide which fragment types are valid for current BIFF version - switch( eBiff ) - { - case BIFF2: switch( nType ) - { - case BIFF_BOF_CHART: eFragment = BIFF_FRAGMENT_EMPTYSHEET; break; - case BIFF_BOF_MACRO: eFragment = BIFF_FRAGMENT_MACROSHEET; break; - // #i51490# Excel interprets invalid types as worksheet - default: eFragment = BIFF_FRAGMENT_WORKSHEET; - } - break; - - case BIFF3: switch( nType ) - { - case BIFF_BOF_CHART: eFragment = BIFF_FRAGMENT_EMPTYSHEET; break; - case BIFF_BOF_MACRO: eFragment = BIFF_FRAGMENT_MACROSHEET; break; - case BIFF_BOF_WORKSPACE:eFragment = BIFF_FRAGMENT_UNKNOWN; break; - // #i51490# Excel interprets invalid types as worksheet - default: eFragment = BIFF_FRAGMENT_WORKSHEET; - }; - break; - - case BIFF4: switch( nType ) - { - case BIFF_BOF_CHART: eFragment = BIFF_FRAGMENT_EMPTYSHEET; break; - case BIFF_BOF_MACRO: eFragment = BIFF_FRAGMENT_MACROSHEET; break; - case BIFF_BOF_WORKSPACE:eFragment = BIFF_FRAGMENT_WORKSPACE; break; - // #i51490# Excel interprets invalid types as worksheet - default: eFragment = BIFF_FRAGMENT_WORKSHEET; - }; - break; - - case BIFF5: - case BIFF8: switch( nType ) - { - case BIFF_BOF_GLOBALS: eFragment = BIFF_FRAGMENT_GLOBALS; break; - case BIFF_BOF_CHART: eFragment = BIFF_FRAGMENT_CHARTSHEET; break; - case BIFF_BOF_MACRO: eFragment = BIFF_FRAGMENT_MACROSHEET; break; - case BIFF_BOF_MODULE: eFragment = BIFF_FRAGMENT_MODULESHEET; break; - case BIFF_BOF_WORKSPACE:eFragment = BIFF_FRAGMENT_UNKNOWN; break; - // #i51490# Excel interprets invalid types as worksheet - default: eFragment = BIFF_FRAGMENT_WORKSHEET; - }; - break; - - case BIFF_UNKNOWN: break; - } - } - } - return eFragment; -} - -bool BiffFragmentHandler::skipFragment( BiffInputStream& rStrm ) -{ - while( rStrm.startNextRecord() && (rStrm.getRecId() != BIFF_ID_EOF) ) - if( isBofRecord( rStrm.getRecId() ) ) - skipFragment( rStrm ); - return rStrm.isValid() && (rStrm.getRecId() == BIFF_ID_EOF); -} - -// ============================================================================ - -BiffWorkbookFragmentBase::BiffWorkbookFragmentBase( const WorkbookHelper& rHelper ) : - WorkbookHelper( rHelper ) -{ -} - -// ============================================================================ - -BiffWorksheetFragmentBase::BiffWorksheetFragmentBase( const WorkbookHelper& rHelper, - ISegmentProgressBarRef xProgressBar, WorksheetType eSheetType, sal_Int32 nSheet ) : - WorksheetHelperRoot( rHelper, xProgressBar, eSheetType, nSheet ) -{ -} - -BiffWorksheetFragmentBase::BiffWorksheetFragmentBase( const WorksheetHelper& rHelper ) : - WorksheetHelperRoot( rHelper ) -{ -} - -// ============================================================================ - -} // namespace xls -} // namespace oox - diff --git a/oox/source/xls/biffhelper.cxx b/oox/source/xls/biffhelper.cxx index 1caca16d082e..6a12bf48d5a4 100644 --- a/oox/source/xls/biffhelper.cxx +++ b/oox/source/xls/biffhelper.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: biffhelper.cxx,v $ - * $Revision: 1.3 $ + * $Revision: 1.3.22.1 $ * * This file is part of OpenOffice.org. * @@ -81,15 +81,13 @@ bool operator<( const BiffGuid& rGuid1, const BiffGuid& rGuid2 ) BiffInputStream& operator>>( BiffInputStream& rStrm, BiffGuid& rGuid ) { - rStrm.read( rGuid.mpnData, 16 ); // mpnData always in little endian + rStrm.readMemory( rGuid.mpnData, 16 ); // mpnData always in little endian return rStrm; } BiffOutputStream& operator<<( BiffOutputStream& rStrm, const BiffGuid& rGuid ) { - rStrm.setPortionSize( 16 ); - rStrm.write( rGuid.mpnData, 16 ); // mpnData already in little endian - rStrm.setPortionSize( 0 ); + rStrm.writeBlock( rGuid.mpnData, 16 ); // mpnData already in little endian return rStrm; } diff --git a/oox/source/xls/biffinputstream.cxx b/oox/source/xls/biffinputstream.cxx index 940955a22c76..1d9a3c0b0bbf 100644 --- a/oox/source/xls/biffinputstream.cxx +++ b/oox/source/xls/biffinputstream.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: biffinputstream.cxx,v $ - * $Revision: 1.4 $ + * $Revision: 1.4.20.2 $ * * This file is part of OpenOffice.org. * @@ -31,7 +31,6 @@ #include "oox/xls/biffinputstream.hxx" #include <algorithm> #include <rtl/ustrbuf.hxx> -#include "oox/helper/binaryinputstream.hxx" using ::rtl::OString; using ::rtl::OStringToOUString; @@ -96,7 +95,7 @@ bool BiffInputRecordBuffer::startRecord( sal_Int64 nHeaderPos ) mrInStrm >> mnRecId >> mnRecSize; mnBodyPos = mrInStrm.tell(); mnNextHeaderPos = mnBodyPos + mnRecSize; - mbValidHeader = mnNextHeaderPos <= mrInStrm.getLength(); + mbValidHeader = !mrInStrm.isEof() && (mnNextHeaderPos <= mrInStrm.getLength()); } if( !mbValidHeader ) { @@ -134,7 +133,7 @@ void BiffInputRecordBuffer::read( void* opData, sal_uInt16 nBytes ) mnRecPos = mnRecPos + nBytes; } -inline void BiffInputRecordBuffer::skip( sal_uInt16 nBytes ) +void BiffInputRecordBuffer::skip( sal_uInt16 nBytes ) { OSL_ENSURE( nBytes > 0, "BiffInputRecordBuffer::skip - nothing to skip" ); OSL_ENSURE( nBytes <= getRecLeft(), "BiffInputRecordBuffer::skip - buffer overflow" ); @@ -149,7 +148,7 @@ void BiffInputRecordBuffer::updateBuffer() mrInStrm.seek( mnBodyPos ); maOriginalData.resize( mnRecSize ); if( mnRecSize > 0 ) - mrInStrm.read( &maOriginalData.front(), static_cast< sal_Int32 >( mnRecSize ) ); + mrInStrm.readMemory( &maOriginalData.front(), static_cast< sal_Int32 >( mnRecSize ) ); mnBufferBodyPos = mnBodyPos; updateDecoded(); } @@ -178,13 +177,9 @@ BiffInputStream::BiffInputStream( BinaryInputStream& rInStream, bool bContLookup mnComplRecSize( 0 ), mbHasComplRec( false ), mbCont( bContLookup ), - mbNulChars( false ), - mbValid( false ) -{ -} - -BiffInputStream::~BiffInputStream() + mbNulChars( false ) { + mbEof = true; // EOF will be true if stream is not inside a record } // record control ------------------------------------------------------------- @@ -252,64 +247,87 @@ void BiffInputStream::enableDecoder( bool bEnable ) // stream/record state and info ----------------------------------------------- -sal_uInt32 BiffInputStream::getRecPos() const -{ - return mbValid ? (mnCurrRecSize - maRecBuffer.getRecLeft()) : BIFF_REC_SEEK_TO_END; -} - -sal_uInt32 BiffInputStream::getRecSize() +sal_uInt16 BiffInputStream::getNextRecId() { - if( !mbHasComplRec ) + sal_uInt16 nRecId = BIFF_ID_UNKNOWN; + if( isInRecord() ) { - sal_uInt32 nCurrPos = getRecPos(); // save current position in record - while( jumpToNextContinue() ); // jumpToNextContinue() adds up mnCurrRecSize - mnComplRecSize = mnCurrRecSize; - mbHasComplRec = true; + sal_Int64 nCurrPos = tell(); // save current position in record + while( jumpToNextContinue() ) {} // skip following CONTINUE records + if( maRecBuffer.startNextRecord() ) // read header of next record + nRecId = maRecBuffer.getRecId(); seek( nCurrPos ); // restore position, seek() resets old mbValid state } - return mnComplRecSize; + return nRecId; } -sal_uInt32 BiffInputStream::getRecLeft() +// BinaryStreamBase interface (seeking) --------------------------------------- + +bool BiffInputStream::isSeekable() const { - return mbValid ? (getRecSize() - getRecPos()) : 0; + return true; } -sal_uInt16 BiffInputStream::getNextRecId() +sal_Int64 BiffInputStream::tell() const +{ + return mbEof ? -1 : (mnCurrRecSize - maRecBuffer.getRecLeft()); +} + +sal_Int64 BiffInputStream::getLength() const +{ + if( !mbHasComplRec ) + const_cast< BiffInputStream* >( this )->calcRecordLength(); + return mnComplRecSize; +} + +void BiffInputStream::seek( sal_Int64 nRecPos ) { - sal_uInt16 nRecId = BIFF_ID_UNKNOWN; if( isInRecord() ) { - sal_uInt32 nCurrPos = getRecPos(); // save current position in record - while( jumpToNextContinue() ); // skip following CONTINUE records - if( maRecBuffer.startNextRecord() ) // read header of next record - nRecId = maRecBuffer.getRecId(); - seek( nCurrPos ); // restore position, seek() resets old mbValid state + if( mbEof || (nRecPos < tell()) ) + restartRecord( false ); + if( !mbEof && (nRecPos > tell()) ) + skip( static_cast< sal_Int32 >( nRecPos - tell() ) ); } - return nRecId; } -sal_Int64 BiffInputStream::getCoreStreamPos() const +sal_Int64 BiffInputStream::tellBase() const { - return maRecBuffer.getCoreStream().tell(); + return maRecBuffer.getBaseStream().tell(); } -sal_Int64 BiffInputStream::getCoreStreamSize() const +sal_Int64 BiffInputStream::getBaseLength() const { - return maRecBuffer.getCoreStream().getLength(); + return maRecBuffer.getBaseStream().getLength(); } -// stream read access --------------------------------------------------------- +// BinaryInputStream interface (stream read access) --------------------------- + +sal_Int32 BiffInputStream::readData( StreamDataSequence& orData, sal_Int32 nBytes ) +{ + sal_Int32 nRet = 0; + if( !mbEof ) + { + orData.realloc( ::std::max< sal_Int32 >( nBytes, 0 ) ); + if( nBytes > 0 ) + { + nRet = readMemory( orData.getArray(), nBytes ); + if( nRet < nBytes ) + orData.realloc( nRet ); + } + } + return nRet; +} -sal_uInt32 BiffInputStream::read( void* opData, sal_uInt32 nBytes ) +sal_Int32 BiffInputStream::readMemory( void* opMem, sal_Int32 nBytes ) { - sal_uInt32 nRet = 0; - if( mbValid && opData && (nBytes > 0) ) + sal_Int32 nRet = 0; + if( !mbEof && opMem && (nBytes > 0) ) { - sal_uInt8* pnBuffer = reinterpret_cast< sal_uInt8* >( opData ); - sal_uInt32 nBytesLeft = nBytes; + sal_uInt8* pnBuffer = reinterpret_cast< sal_uInt8* >( opMem ); + sal_Int32 nBytesLeft = nBytes; - while( mbValid && (nBytesLeft > 0) ) + while( !mbEof && (nBytesLeft > 0) ) { sal_uInt16 nReadSize = getMaxRawReadSize( nBytesLeft ); // check nReadSize, stream may already be located at end of a raw record @@ -322,30 +340,16 @@ sal_uInt32 BiffInputStream::read( void* opData, sal_uInt32 nBytes ) } if( nBytesLeft > 0 ) jumpToNextContinue(); - OSL_ENSURE( mbValid, "BiffInputStream::read - record overread" ); + OSL_ENSURE( !mbEof, "BiffInputStream::readMemory - record overread" ); } } return nRet; } -// seeking -------------------------------------------------------------------- - -BiffInputStream& BiffInputStream::seek( sal_uInt32 nRecPos ) -{ - if( isInRecord() ) - { - if( !mbValid || (nRecPos < getRecPos()) ) - restartRecord( false ); - if( mbValid && (nRecPos > getRecPos()) ) - skip( nRecPos - getRecPos() ); - } - return *this; -} - -BiffInputStream& BiffInputStream::skip( sal_uInt32 nBytes ) +void BiffInputStream::skip( sal_Int32 nBytes ) { - sal_uInt32 nBytesLeft = nBytes; - while( mbValid && (nBytesLeft > 0) ) + sal_Int32 nBytesLeft = nBytes; + while( !mbEof && (nBytesLeft > 0) ) { sal_uInt16 nSkipSize = getMaxRawReadSize( nBytesLeft ); // check nSkipSize, stream may already be located at end of a raw record @@ -356,9 +360,8 @@ BiffInputStream& BiffInputStream::skip( sal_uInt32 nBytes ) } if( nBytesLeft > 0 ) jumpToNextContinue(); - OSL_ENSURE( mbValid, "BiffInputStream::skip - record overread" ); + OSL_ENSURE( !mbEof, "BiffInputStream::skip - record overread" ); } - return *this; } // byte strings --------------------------------------------------------------- @@ -369,10 +372,9 @@ OString BiffInputStream::readCharArray( sal_uInt16 nChars ) return OString(); ::std::vector< sal_Char > aBuffer( static_cast< size_t >( nChars ) ); - size_t nCharsRead = static_cast< size_t >( read( &aBuffer.front(), nChars ) ); - aBuffer.resize( nCharsRead ); + size_t nCharsRead = static_cast< size_t >( readMemory( &aBuffer.front(), nChars ) ); if( !mbNulChars ) - ::std::replace( aBuffer.begin(), aBuffer.end(), '\0', '?' ); + ::std::replace( aBuffer.begin(), aBuffer.begin() + nCharsRead, '\0', '?' ); return OString( &aBuffer.front(), nCharsRead ); } @@ -399,6 +401,14 @@ void BiffInputStream::skipByteString( bool b16BitLen ) // Unicode strings ------------------------------------------------------------ +OUString BiffInputStream::readNulUnicodeArray() +{ + OUStringBuffer aBuffer; + for( sal_uInt16 nChar = readuInt16(); !mbEof && (nChar > 0); readValue( nChar ) ) + aBuffer.append( static_cast< sal_Unicode >( nChar ) ); + return aBuffer.makeStringAndClear(); +} + OUString BiffInputStream::readUnicodeArray( sal_uInt16 nChars ) { OUStringBuffer aBuffer; @@ -414,7 +424,7 @@ OUString BiffInputStream::readUniStringChars( sal_uInt16 nChars, bool b16Bit ) /* This function has to react on CONTINUE records to read the repeated flags field, so readUnicodeArray() cannot be used here. */ sal_uInt16 nCharsLeft = nChars; - while( mbValid && (nCharsLeft > 0) ) + while( !mbEof && (nCharsLeft > 0) ) { sal_uInt16 nPortionCount = 0; if( b16Bit ) @@ -443,7 +453,7 @@ OUString BiffInputStream::readUniStringChars( sal_uInt16 nChars, bool b16Bit ) OUString BiffInputStream::readUniString( sal_uInt16 nChars ) { bool b16Bit; - sal_uInt32 nAddSize; + sal_Int32 nAddSize; readUniStringHeader( b16Bit, nAddSize ); OUString aString = readUniStringChars( nChars, b16Bit ); skip( nAddSize ); @@ -458,7 +468,7 @@ OUString BiffInputStream::readUniString() void BiffInputStream::skipUniStringChars( sal_uInt16 nChars, bool b16Bit ) { sal_uInt16 nCharsLeft = nChars; - while( mbValid && (nCharsLeft > 0) ) + while( !mbEof && (nCharsLeft > 0) ) { sal_uInt16 nPortionCount; if( b16Bit ) @@ -484,7 +494,7 @@ void BiffInputStream::skipUniStringChars( sal_uInt16 nChars, bool b16Bit ) void BiffInputStream::skipUniString( sal_uInt16 nChars ) { bool b16Bit; - sal_uInt32 nAddSize; + sal_Int32 nAddSize; readUniStringHeader( b16Bit, nAddSize ); skipUniStringChars( nChars, b16Bit ); skip( nAddSize ); @@ -497,6 +507,13 @@ void BiffInputStream::skipUniString() // private -------------------------------------------------------------------- +void BiffInputStream::readAtom( void* opMem, sal_uInt8 nSize ) +{ + // byte swapping is done in calling BinaryInputStream::readValue() template function + if( ensureRawReadSize( nSize ) ) + maRecBuffer.read( opMem, nSize ); +} + void BiffInputStream::setupRecord() { // initialize class members @@ -505,8 +522,8 @@ void BiffInputStream::setupRecord() mnAltContId = BIFF_ID_UNKNOWN; mnCurrRecSize = mnComplRecSize = maRecBuffer.getRecSize(); mbHasComplRec = !mbCont; - mbValid = isInRecord(); mbNulChars = false; + mbEof = !isInRecord(); // enable decoder in new record enableDecoder( true ); } @@ -522,7 +539,7 @@ void BiffInputStream::restartRecord( bool bInvalidateRecSize ) mnComplRecSize = mnCurrRecSize; mbHasComplRec = !mbCont; } - mbValid = true; + mbEof = false; } } @@ -532,7 +549,7 @@ void BiffInputStream::rewindToRecord( sal_Int64 nRecHandle ) { maRecBuffer.restartAt( nRecHandle ); mnRecHandle = -1; - mbValid = false; + mbEof = true; // as long as the record is not started } } @@ -543,17 +560,17 @@ bool BiffInputStream::isContinueId( sal_uInt16 nRecId ) const bool BiffInputStream::jumpToNextContinue() { - mbValid = mbValid && mbCont && isContinueId( maRecBuffer.getNextRecId() ) && maRecBuffer.startNextRecord(); - if( mbValid ) + mbEof = mbEof || !mbCont || !isContinueId( maRecBuffer.getNextRecId() ) || !maRecBuffer.startNextRecord(); + if( !mbEof ) mnCurrRecSize += maRecBuffer.getRecSize(); - return mbValid; + return !mbEof; } bool BiffInputStream::jumpToNextStringContinue( bool& rb16Bit ) { OSL_ENSURE( maRecBuffer.getRecLeft() == 0, "BiffInputStream::jumpToNextStringContinue - unexpected garbage" ); - if( mbCont && (getRecLeft() > 0) ) + if( mbCont && (getRemaining() > 0) ) { jumpToNextContinue(); } @@ -562,8 +579,8 @@ bool BiffInputStream::jumpToNextStringContinue( bool& rb16Bit ) /* CONTINUE handling is off, but we have started reading in a CONTINUE record -> start next CONTINUE for TXO import. We really start a new record here - no chance to return to string origin. */ - mbValid = mbValid && (maRecBuffer.getNextRecId() == BIFF_ID_CONT) && maRecBuffer.startNextRecord(); - if( mbValid ) + mbEof = mbEof || (maRecBuffer.getNextRecId() != BIFF_ID_CONT) || !maRecBuffer.startNextRecord(); + if( !mbEof ) setupRecord(); } @@ -571,44 +588,53 @@ bool BiffInputStream::jumpToNextStringContinue( bool& rb16Bit ) sal_uInt8 nFlags; readValue( nFlags ); rb16Bit = getFlag( nFlags, BIFF_STRF_16BIT ); - return mbValid; + return !mbEof; +} + +void BiffInputStream::calcRecordLength() +{ + sal_Int64 nCurrPos = tell(); // save current position in record + while( jumpToNextContinue() ) {} // jumpToNextContinue() adds up mnCurrRecSize + mnComplRecSize = mnCurrRecSize; + mbHasComplRec = true; + seek( nCurrPos ); // restore position, seek() resets old mbValid state } bool BiffInputStream::ensureRawReadSize( sal_uInt16 nBytes ) { - if( mbValid && (nBytes > 0) ) + if( !mbEof && (nBytes > 0) ) { - while( mbValid && (maRecBuffer.getRecLeft() == 0) ) jumpToNextContinue(); - mbValid = mbValid && (nBytes <= maRecBuffer.getRecLeft()); - OSL_ENSURE( mbValid, "BiffInputStream::ensureRawReadSize - record overread" ); + while( !mbEof && (maRecBuffer.getRecLeft() == 0) ) jumpToNextContinue(); + mbEof = mbEof || (nBytes > maRecBuffer.getRecLeft()); + OSL_ENSURE( !mbEof, "BiffInputStream::ensureRawReadSize - record overread" ); } - return mbValid; + return !mbEof; } -sal_uInt16 BiffInputStream::getMaxRawReadSize( sal_uInt32 nBytes ) const +sal_uInt16 BiffInputStream::getMaxRawReadSize( sal_Int32 nBytes ) const { - return static_cast< sal_uInt16 >( ::std::min< sal_uInt32 >( nBytes, maRecBuffer.getRecLeft() ) ); + return getLimitedValue< sal_uInt16, sal_Int32 >( nBytes, 0, maRecBuffer.getRecLeft() ); } void BiffInputStream::appendUnicodeArray( OUStringBuffer& orBuffer, sal_uInt16 nChars, bool b16Bit ) { orBuffer.ensureCapacity( orBuffer.getLength() + nChars ); sal_uInt16 nChar; - for( sal_uInt16 nCharIdx = 0; mbValid && (nCharIdx < nChars); ++nCharIdx ) + for( sal_uInt16 nCharIdx = 0; !mbEof && (nCharIdx < nChars); ++nCharIdx ) { if( b16Bit ) readValue( nChar ); else nChar = readuInt8(); orBuffer.append( static_cast< sal_Unicode >( (!mbNulChars && (nChar == 0)) ? '?' : nChar ) ); } } -void BiffInputStream::readUniStringHeader( bool& orb16Bit, sal_uInt32& ornAddSize ) +void BiffInputStream::readUniStringHeader( bool& orb16Bit, sal_Int32& ornAddSize ) { sal_uInt8 nFlags = readuInt8(); OSL_ENSURE( !getFlag( nFlags, BIFF_STRF_UNKNOWN ), "BiffInputStream::readUniStringHeader - unknown flags" ); orb16Bit = getFlag( nFlags, BIFF_STRF_16BIT ); sal_uInt16 nFontCount = getFlag( nFlags, BIFF_STRF_RICH ) ? readuInt16() : 0; - sal_uInt32 nPhoneticSize = getFlag( nFlags, BIFF_STRF_PHONETIC ) ? readuInt32() : 0; - ornAddSize = 4 * nFontCount + nPhoneticSize; + sal_Int32 nPhoneticSize = getFlag( nFlags, BIFF_STRF_PHONETIC ) ? readInt32() : 0; + ornAddSize = 4 * nFontCount + ::std::max< sal_Int32 >( 0, nPhoneticSize ); } // ============================================================================ @@ -616,7 +642,7 @@ void BiffInputStream::readUniStringHeader( bool& orb16Bit, sal_uInt32& ornAddSiz BiffInputStreamPos::BiffInputStreamPos( BiffInputStream& rStrm ) : mrStrm( rStrm ), mnRecHandle( rStrm.getRecHandle() ), - mnRecPos( rStrm.getRecPos() ) + mnRecPos( rStrm.tell() ) { } @@ -625,17 +651,17 @@ bool BiffInputStreamPos::restorePosition() bool bValidRec = mrStrm.startRecordByHandle( mnRecHandle ); if( bValidRec ) mrStrm.seek( mnRecPos ); - return bValidRec && mrStrm.isValid(); + return bValidRec && !mrStrm.isEof(); } // ============================================================================ -BiffInputStreamGuard::BiffInputStreamGuard( BiffInputStream& rStrm ) : +BiffInputStreamPosGuard::BiffInputStreamPosGuard( BiffInputStream& rStrm ) : BiffInputStreamPos( rStrm ) { } -BiffInputStreamGuard::~BiffInputStreamGuard() +BiffInputStreamPosGuard::~BiffInputStreamPosGuard() { restorePosition(); } diff --git a/oox/source/xls/biffoutputstream.cxx b/oox/source/xls/biffoutputstream.cxx index badfbbe282f3..ef17d0e4d103 100644 --- a/oox/source/xls/biffoutputstream.cxx +++ b/oox/source/xls/biffoutputstream.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: biffoutputstream.cxx,v $ - * $Revision: 1.3 $ + * $Revision: 1.3.22.1 $ * * This file is part of OpenOffice.org. * @@ -29,7 +29,6 @@ ************************************************************************/ #include "oox/xls/biffoutputstream.hxx" -#include "oox/helper/binaryoutputstream.hxx" namespace oox { namespace xls { @@ -63,7 +62,7 @@ void BiffOutputRecordBuffer::endRecord() mrOutStrm.seekToEnd(); mrOutStrm << mnRecId << nRecSize; if( nRecSize > 0 ) - mrOutStrm.write( &maData.front(), nRecSize ); + mrOutStrm.writeMemory( &maData.front(), nRecSize ); mbInRec = false; } @@ -95,10 +94,6 @@ BiffOutputStream::BiffOutputStream( BinaryOutputStream& rOutStream, sal_uInt16 n { } -BiffOutputStream::~BiffOutputStream() -{ -} - // record control ------------------------------------------------------------- void BiffOutputStream::startRecord( sal_uInt16 nRecId ) @@ -109,25 +104,43 @@ void BiffOutputStream::startRecord( sal_uInt16 nRecId ) void BiffOutputStream::endRecord() { + setPortionSize( 0 ); maRecBuffer.endRecord(); } void BiffOutputStream::setPortionSize( sal_uInt16 nSize ) { + OSL_ENSURE( mnPortionPos == 0, "BiffOutputStream::setPortionSize - block operation inside portion" ); mnPortionSize = nSize; mnPortionPos = 0; } -// stream/record state and info ----------------------------------------------- +// BinaryStreamBase interface (seeking) --------------------------------------- + +sal_Int64 BiffOutputStream::tellBase() const +{ + return maRecBuffer.getBaseStream().tell(); +} + +sal_Int64 BiffOutputStream::getBaseLength() const +{ + return maRecBuffer.getBaseStream().getLength(); +} -// stream write access -------------------------------------------------------- +// BinaryOutputStream interface (stream write access) ------------------------- -void BiffOutputStream::write( const void* pData, sal_uInt32 nBytes ) +void BiffOutputStream::writeData( const StreamDataSequence& rData ) { - if( pData && (nBytes > 0) ) + if( rData.hasElements() ) + writeMemory( rData.getConstArray(), rData.getLength() ); +} + +void BiffOutputStream::writeMemory( const void* pMem, sal_Int32 nBytes ) +{ + if( pMem && (nBytes > 0) ) { - const sal_uInt8* pnBuffer = reinterpret_cast< const sal_uInt8* >( pData ); - sal_uInt32 nBytesLeft = nBytes; + const sal_uInt8* pnBuffer = reinterpret_cast< const sal_uInt8* >( pMem ); + sal_Int32 nBytesLeft = nBytes; while( nBytesLeft > 0 ) { sal_uInt16 nBlockSize = prepareRawBlock( nBytesLeft ); @@ -138,9 +151,9 @@ void BiffOutputStream::write( const void* pData, sal_uInt32 nBytes ) } } -void BiffOutputStream::fill( sal_uInt8 nValue, sal_uInt32 nBytes ) +void BiffOutputStream::fill( sal_uInt8 nValue, sal_Int32 nBytes ) { - sal_uInt32 nBytesLeft = nBytes; + sal_Int32 nBytesLeft = nBytes; while( nBytesLeft > 0 ) { sal_uInt16 nBlockSize = prepareRawBlock( nBytesLeft ); @@ -149,8 +162,20 @@ void BiffOutputStream::fill( sal_uInt8 nValue, sal_uInt32 nBytes ) } } +void BiffOutputStream::writeBlock( const void* pMem, sal_uInt16 nBytes ) +{ + ensureRawBlock( nBytes ); + maRecBuffer.write( pMem, nBytes ); +} + // private -------------------------------------------------------------------- +void BiffOutputStream::writeAtom( const void* pMem, sal_uInt8 nSize ) +{ + // byte swapping is done in calling BinaryOutputStream::writeValue() template function + writeBlock( pMem, nSize ); +} + void BiffOutputStream::ensureRawBlock( sal_uInt16 nSize ) { if( (maRecBuffer.getRecLeft() < nSize) || @@ -161,12 +186,12 @@ void BiffOutputStream::ensureRawBlock( sal_uInt16 nSize ) } if( mnPortionSize > 0 ) { - OSL_ENSURE( mnPortionPos + nSize <= mnPortionSize, "BiffOutputStreamI::ensureRawBlock - portion overflow" ); + OSL_ENSURE( mnPortionPos + nSize <= mnPortionSize, "BiffOutputStream::ensureRawBlock - portion overflow" ); mnPortionPos = (mnPortionPos + nSize) % mnPortionSize; // prevent compiler warning, do not use operator+=, operator%= } } -sal_uInt16 BiffOutputStream::prepareRawBlock( sal_uInt32 nTotalSize ) +sal_uInt16 BiffOutputStream::prepareRawBlock( sal_Int32 nTotalSize ) { sal_uInt16 nRecLeft = maRecBuffer.getRecLeft(); if( mnPortionSize > 0 ) @@ -175,7 +200,7 @@ sal_uInt16 BiffOutputStream::prepareRawBlock( sal_uInt32 nTotalSize ) OSL_ENSURE( nTotalSize % mnPortionSize == 0, "BiffOutputStream::prepareRawBlock - portion size does not match block size" ); nRecLeft = (nRecLeft / mnPortionSize) * mnPortionSize; } - sal_uInt16 nSize = getLimitedValue< sal_uInt16, sal_uInt32 >( nTotalSize, 0, nRecLeft ); + sal_uInt16 nSize = getLimitedValue< sal_uInt16, sal_Int32 >( nTotalSize, 0, nRecLeft ); ensureRawBlock( nSize ); return nSize; } diff --git a/oox/source/xls/chartsheetfragment.cxx b/oox/source/xls/chartsheetfragment.cxx index 521bbd313ddf..d6fd382ff484 100644 --- a/oox/source/xls/chartsheetfragment.cxx +++ b/oox/source/xls/chartsheetfragment.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: chartsheetfragment.cxx,v $ - * $Revision: 1.4 $ + * $Revision: 1.4.4.2 $ * * This file is part of OpenOffice.org. * @@ -190,12 +190,13 @@ void OoxChartsheetFragment::importDrawing( RecordInputStream& rStrm ) // ============================================================================ -BiffChartsheetFragment::BiffChartsheetFragment( const WorkbookHelper& rHelper, ISegmentProgressBarRef xProgressBar, sal_Int32 nSheet ) : - BiffWorksheetFragmentBase( rHelper, xProgressBar, SHEETTYPE_CHARTSHEET, nSheet ) +BiffChartsheetFragment::BiffChartsheetFragment( const BiffWorkbookFragmentBase& rParent, + ISegmentProgressBarRef xProgressBar, sal_Int32 nSheet ) : + BiffWorksheetFragmentBase( rParent, xProgressBar, SHEETTYPE_CHARTSHEET, nSheet ) { } -bool BiffChartsheetFragment::importFragment( BiffInputStream& rStrm ) +bool BiffChartsheetFragment::importFragment() { // initial processing in base class WorksheetHelper initializeWorksheetImport(); @@ -205,87 +206,91 @@ bool BiffChartsheetFragment::importFragment( BiffInputStream& rStrm ) PageSettings& rPageSett = getPageSettings(); // process all record in this sheet fragment - while( rStrm.startNextRecord() && (rStrm.getRecId() != BIFF_ID_EOF) ) + while( mrStrm.startNextRecord() && (mrStrm.getRecId() != BIFF_ID_EOF) ) { - sal_uInt16 nRecId = rStrm.getRecId(); - - if( isBofRecord( nRecId ) ) + if( isBofRecord() ) { // skip unknown embedded fragments (BOF/EOF blocks) - skipFragment( rStrm ); + skipFragment(); } - else switch( nRecId ) + else { - // records in all BIFF versions - case BIFF_ID_BOTTOMMARGIN: rPageSett.importBottomMargin( rStrm ); break; - case BIFF_ID_FOOTER: rPageSett.importFooter( rStrm ); break; - case BIFF_ID_HEADER: rPageSett.importHeader( rStrm ); break; - case BIFF_ID_LEFTMARGIN: rPageSett.importLeftMargin( rStrm ); break; - case BIFF_ID_PASSWORD: rWorksheetSett.importPassword( rStrm ); break; - case BIFF_ID_PROTECT: rWorksheetSett.importProtect( rStrm ); break; - case BIFF_ID_RIGHTMARGIN: rPageSett.importRightMargin( rStrm ); break; - case BIFF_ID_TOPMARGIN: rPageSett.importTopMargin( rStrm ); break; - - // BIFF specific records - default: switch( getBiff() ) + sal_uInt16 nRecId = mrStrm.getRecId(); + switch( nRecId ) { - case BIFF2: switch( nRecId ) - { - case BIFF2_ID_WINDOW2: rSheetViewSett.importWindow2( rStrm ); break; - } - break; - - case BIFF3: switch( nRecId ) - { - case BIFF_ID_HCENTER: rPageSett.importHorCenter( rStrm ); break; - case BIFF_ID_OBJECTPROTECT: rWorksheetSett.importObjectProtect( rStrm ); break; - case BIFF_ID_VCENTER: rPageSett.importVerCenter( rStrm ); break; - case BIFF3_ID_WINDOW2: rSheetViewSett.importWindow2( rStrm ); break; - - } - break; - - case BIFF4: switch( nRecId ) + // records in all BIFF versions + case BIFF_ID_BOTTOMMARGIN: rPageSett.importBottomMargin( mrStrm ); break; + case BIFF_ID_CHBEGIN: skipRecordBlock( BIFF_ID_CHEND ); break; + case BIFF_ID_FOOTER: rPageSett.importFooter( mrStrm ); break; + case BIFF_ID_HEADER: rPageSett.importHeader( mrStrm ); break; + case BIFF_ID_LEFTMARGIN: rPageSett.importLeftMargin( mrStrm ); break; + case BIFF_ID_PASSWORD: rWorksheetSett.importPassword( mrStrm ); break; + case BIFF_ID_PROTECT: rWorksheetSett.importProtect( mrStrm ); break; + case BIFF_ID_RIGHTMARGIN: rPageSett.importRightMargin( mrStrm ); break; + case BIFF_ID_TOPMARGIN: rPageSett.importTopMargin( mrStrm ); break; + + // BIFF specific records + default: switch( getBiff() ) { - case BIFF_ID_HCENTER: rPageSett.importHorCenter( rStrm ); break; - case BIFF_ID_OBJECTPROTECT: rWorksheetSett.importObjectProtect( rStrm ); break; - case BIFF_ID_PAGESETUP: rPageSett.importPageSetup( rStrm ); break; - case BIFF_ID_VCENTER: rPageSett.importVerCenter( rStrm ); break; - case BIFF3_ID_WINDOW2: rSheetViewSett.importWindow2( rStrm ); break; + case BIFF2: switch( nRecId ) + { + case BIFF2_ID_WINDOW2: rSheetViewSett.importWindow2( mrStrm ); break; + } + break; + + case BIFF3: switch( nRecId ) + { + case BIFF_ID_HCENTER: rPageSett.importHorCenter( mrStrm ); break; + case BIFF_ID_OBJECTPROTECT: rWorksheetSett.importObjectProtect( mrStrm ); break; + case BIFF_ID_VCENTER: rPageSett.importVerCenter( mrStrm ); break; + case BIFF3_ID_WINDOW2: rSheetViewSett.importWindow2( mrStrm ); break; + + } + break; + + case BIFF4: switch( nRecId ) + { + case BIFF_ID_HCENTER: rPageSett.importHorCenter( mrStrm ); break; + case BIFF_ID_OBJECTPROTECT: rWorksheetSett.importObjectProtect( mrStrm ); break; + case BIFF_ID_PAGESETUP: rPageSett.importPageSetup( mrStrm ); break; + case BIFF_ID_VCENTER: rPageSett.importVerCenter( mrStrm ); break; + case BIFF3_ID_WINDOW2: rSheetViewSett.importWindow2( mrStrm ); break; + } + break; + + case BIFF5: switch( nRecId ) + { + case BIFF_ID_HCENTER: rPageSett.importHorCenter( mrStrm ); break; + case BIFF_ID_OBJECTPROTECT: rWorksheetSett.importObjectProtect( mrStrm ); break; + case BIFF_ID_PAGESETUP: rPageSett.importPageSetup( mrStrm ); break; + case BIFF_ID_SCENPROTECT: rWorksheetSett.importScenProtect( mrStrm ); break; + case BIFF_ID_SCL: rSheetViewSett.importScl( mrStrm ); break; + case BIFF_ID_VCENTER: rPageSett.importVerCenter( mrStrm ); break; + case BIFF3_ID_WINDOW2: rSheetViewSett.importWindow2( mrStrm ); break; + } + break; + + case BIFF8: switch( nRecId ) + { + case BIFF_ID_HCENTER: rPageSett.importHorCenter( mrStrm ); break; + case BIFF_ID_OBJECTPROTECT: rWorksheetSett.importObjectProtect( mrStrm ); break; + case BIFF_ID_PICTURE: rPageSett.importPicture( mrStrm ); break; + case BIFF_ID_PAGESETUP: rPageSett.importPageSetup( mrStrm ); break; + case BIFF_ID_SCL: rSheetViewSett.importScl( mrStrm ); break; + case BIFF_ID_VCENTER: rPageSett.importVerCenter( mrStrm ); break; + case BIFF3_ID_WINDOW2: rSheetViewSett.importWindow2( mrStrm ); break; + } + break; + + case BIFF_UNKNOWN: break; } - break; - - case BIFF5: switch( nRecId ) - { - case BIFF_ID_HCENTER: rPageSett.importHorCenter( rStrm ); break; - case BIFF_ID_OBJECTPROTECT: rWorksheetSett.importObjectProtect( rStrm ); break; - case BIFF_ID_PAGESETUP: rPageSett.importPageSetup( rStrm ); break; - case BIFF_ID_SCENPROTECT: rWorksheetSett.importScenProtect( rStrm ); break; - case BIFF_ID_SCL: rSheetViewSett.importScl( rStrm ); break; - case BIFF_ID_VCENTER: rPageSett.importVerCenter( rStrm ); break; - case BIFF3_ID_WINDOW2: rSheetViewSett.importWindow2( rStrm ); break; - } - break; - - case BIFF8: switch( nRecId ) - { - case BIFF_ID_HCENTER: rPageSett.importHorCenter( rStrm ); break; - case BIFF_ID_OBJECTPROTECT: rWorksheetSett.importObjectProtect( rStrm ); break; - case BIFF_ID_PICTURE: rPageSett.importPicture( rStrm ); break; - case BIFF_ID_PAGESETUP: rPageSett.importPageSetup( rStrm ); break; - case BIFF_ID_VCENTER: rPageSett.importVerCenter( rStrm ); break; - case BIFF3_ID_WINDOW2: rSheetViewSett.importWindow2( rStrm ); break; - } - break; - - case BIFF_UNKNOWN: break; } } } // final processing in base class WorksheetHelper finalizeWorksheetImport(); - return rStrm.getRecId() == BIFF_ID_EOF; + return mrStrm.getRecId() == BIFF_ID_EOF; } // ============================================================================ diff --git a/oox/source/xls/condformatbuffer.cxx b/oox/source/xls/condformatbuffer.cxx index 918aea5adac4..f56fb7a3e891 100644 --- a/oox/source/xls/condformatbuffer.cxx +++ b/oox/source/xls/condformatbuffer.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: condformatbuffer.cxx,v $ - * $Revision: 1.6 $ + * $Revision: 1.6.6.2 $ * * This file is part of OpenOffice.org. * @@ -49,7 +49,6 @@ #include "oox/xls/addressconverter.hxx" #include "oox/xls/biffinputstream.hxx" #include "oox/xls/stylesbuffer.hxx" -#include "oox/xls/validationpropertyhelper.hxx" using ::rtl::OUString; using ::rtl::OUStringBuffer; @@ -227,8 +226,8 @@ void CondFormatRule::importCfRule( RecordInputStream& rStrm ) // first formula OSL_ENSURE( (nFmla1Size >= 0) || ((nFmla2Size == 0) && (nFmla3Size == 0)), "CondFormatRule::importCfRule - missing first formula" ); - OSL_ENSURE( (nFmla1Size > 0) == (rStrm.getRecLeft() >= 8), "CondFormatRule::importCfRule - formula size mismatch" ); - if( rStrm.getRecLeft() >= 8 ) + OSL_ENSURE( (nFmla1Size > 0) == (rStrm.getRemaining() >= 8), "CondFormatRule::importCfRule - formula size mismatch" ); + if( rStrm.getRemaining() >= 8 ) { TokensFormulaContext aContext( true, false ); aContext.setBaseAddress( mrCondFormat.getRanges().getBaseAddress() ); @@ -237,15 +236,15 @@ void CondFormatRule::importCfRule( RecordInputStream& rStrm ) // second formula OSL_ENSURE( (nFmla2Size >= 0) || (nFmla3Size == 0), "CondFormatRule::importCfRule - missing second formula" ); - OSL_ENSURE( (nFmla2Size > 0) == (rStrm.getRecLeft() >= 8), "CondFormatRule::importCfRule - formula size mismatch" ); - if( rStrm.getRecLeft() >= 8 ) + OSL_ENSURE( (nFmla2Size > 0) == (rStrm.getRemaining() >= 8), "CondFormatRule::importCfRule - formula size mismatch" ); + if( rStrm.getRemaining() >= 8 ) { getFormulaParser().importFormula( aContext, rStrm ); maOoxData.maFormulas.push_back( aContext ); // third formula - OSL_ENSURE( (nFmla3Size > 0) == (rStrm.getRecLeft() >= 8), "CondFormatRule::importCfRule - formula size mismatch" ); - if( rStrm.getRecLeft() >= 8 ) + OSL_ENSURE( (nFmla3Size > 0) == (rStrm.getRemaining() >= 8), "CondFormatRule::importCfRule - formula size mismatch" ); + if( rStrm.getRemaining() >= 8 ) { getFormulaParser().importFormula( aContext, rStrm ); maOoxData.maFormulas.push_back( aContext ); @@ -469,7 +468,7 @@ void CondFormatRule::finalizeImport( const Reference< XSheetConditionalEntries > switch( maOoxData.mnType ) { case XML_cellIs: - eOperator = ValidationPropertyHelper::convertToApiOperator( maOoxData.mnOperator ); + eOperator = CondFormatBuffer::convertToApiOperator( maOoxData.mnOperator ); break; case XML_expression: eOperator = ::com::sun::star::sheet::ConditionOperator_FORMULA; @@ -753,6 +752,23 @@ void CondFormatBuffer::finalizeImport() maCondFormats.forEachMem( &CondFormat::finalizeImport ); } +ConditionOperator CondFormatBuffer::convertToApiOperator( sal_Int32 nToken ) +{ + using namespace ::com::sun::star::sheet; + switch( nToken ) + { + case XML_between: return ConditionOperator_BETWEEN; + case XML_equal: return ConditionOperator_EQUAL; + case XML_greaterThan: return ConditionOperator_GREATER; + case XML_greaterThanOrEqual: return ConditionOperator_GREATER_EQUAL; + case XML_lessThan: return ConditionOperator_LESS; + case XML_lessThanOrEqual: return ConditionOperator_LESS_EQUAL; + case XML_notBetween: return ConditionOperator_NOT_BETWEEN; + case XML_notEqual: return ConditionOperator_NOT_EQUAL; + } + return ConditionOperator_NONE; +} + // private -------------------------------------------------------------------- CondFormatRef CondFormatBuffer::createCondFormat() diff --git a/oox/source/xls/defnamesbuffer.cxx b/oox/source/xls/defnamesbuffer.cxx index 0128b7d9192a..33715e777309 100644 --- a/oox/source/xls/defnamesbuffer.cxx +++ b/oox/source/xls/defnamesbuffer.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: defnamesbuffer.cxx,v $ - * $Revision: 1.5 $ + * $Revision: 1.5.4.2 $ * * This file is part of OpenOffice.org. * @@ -30,14 +30,12 @@ #include "oox/xls/defnamesbuffer.hxx" #include <rtl/ustrbuf.hxx> -#include <com/sun/star/sheet/XNamedRanges.hpp> -#include <com/sun/star/sheet/XNamedRange.hpp> -#include <com/sun/star/sheet/XFormulaTokens.hpp> -#include <com/sun/star/sheet/XPrintAreas.hpp> -#include <com/sun/star/sheet/ReferenceFlags.hpp> -#include <com/sun/star/sheet/SingleReference.hpp> #include <com/sun/star/sheet/ComplexReference.hpp> #include <com/sun/star/sheet/NamedRangeFlag.hpp> +#include <com/sun/star/sheet/ReferenceFlags.hpp> +#include <com/sun/star/sheet/SingleReference.hpp> +#include <com/sun/star/sheet/XFormulaTokens.hpp> +#include <com/sun/star/sheet/XPrintAreas.hpp> #include "oox/helper/attributelist.hxx" #include "oox/helper/propertyset.hxx" #include "oox/xls/addressconverter.hxx" @@ -49,17 +47,10 @@ using ::rtl::OUString; using ::rtl::OUStringBuffer; using ::com::sun::star::uno::Any; using ::com::sun::star::uno::Reference; -using ::com::sun::star::uno::Sequence; -using ::com::sun::star::uno::Exception; using ::com::sun::star::uno::UNO_QUERY; -using ::com::sun::star::uno::UNO_QUERY_THROW; -using ::com::sun::star::container::XNameAccess; using ::com::sun::star::table::CellAddress; -using ::com::sun::star::table::CellRangeAddress; -using ::com::sun::star::sheet::SingleReference; using ::com::sun::star::sheet::ComplexReference; -using ::com::sun::star::sheet::XNamedRanges; -using ::com::sun::star::sheet::XNamedRange; +using ::com::sun::star::sheet::SingleReference; using ::com::sun::star::sheet::XFormulaTokens; using ::com::sun::star::sheet::XPrintAreas; using namespace ::com::sun::star::sheet::ReferenceFlags; @@ -342,16 +333,16 @@ void DefinedName::importDefinedName( RecordInputStream& rStrm ) maOoxData.mbHidden = false; // store token array data - sal_Int32 nRecPos = rStrm.getRecPos(); + sal_Int64 nRecPos = rStrm.tell(); sal_Int32 nFmlaSize = rStrm.readInt32(); rStrm.skip( nFmlaSize ); sal_Int32 nAddDataSize = rStrm.readInt32(); - if( rStrm.isValid() && (nFmlaSize > 0) && (nAddDataSize >= 0) && (rStrm.getRecLeft() >= nAddDataSize) ) + if( !rStrm.isEof() && (nFmlaSize > 0) && (nAddDataSize >= 0) && (rStrm.getRemaining() >= nAddDataSize) ) { sal_Int32 nTotalSize = 8 + nFmlaSize + nAddDataSize; - mxFormula.reset( new RecordDataSequence( nTotalSize ) ); + mxFormula.reset( new StreamDataSequence ); rStrm.seek( nRecPos ); - rStrm.read( mxFormula->getArray(), nTotalSize ); + rStrm.readData( *mxFormula, nTotalSize ); } } @@ -384,11 +375,13 @@ void DefinedName::importDefinedName( BiffInputStream& rStrm ) break; case BIFF5: rStrm >> nFlags >> nShortCut >> nNameLen >> mnFmlaSize >> nRefId >> nTabId; - maOoxData.maName = rStrm.skip( 4 ).readCharArray( nNameLen, getTextEncoding() ); + rStrm.skip( 4 ); + maOoxData.maName = rStrm.readCharArray( nNameLen, getTextEncoding() ); break; case BIFF8: rStrm >> nFlags >> nShortCut >> nNameLen >> mnFmlaSize >> nRefId >> nTabId; - maOoxData.maName = rStrm.skip( 4 ).readUniString( nNameLen ); + rStrm.skip( 4 ); + maOoxData.maName = rStrm.readUniString( nNameLen ); break; case BIFF_UNKNOWN: break; } @@ -475,9 +468,10 @@ void DefinedName::createNameObject() } // create the name and insert it into the document, maFinalName will be changed to the resulting name - mxNamedRange = getDefinedNames().createDefinedName( maFinalName, nNameFlags ); + mxNamedRange = createNamedRangeObject( maFinalName, nNameFlags ); // index of this defined name used in formula token arrays - mnTokenIndex = getDefinedNames().getTokenIndex( mxNamedRange ); + PropertySet aPropSet( mxNamedRange ); + aPropSet.getProperty( mnTokenIndex, CREATE_OUSTRING( "TokenIndex" ) ); } void DefinedName::convertFormula() @@ -571,7 +565,7 @@ void DefinedName::implImportBiffFormula( FormulaContext& rContext ) { OSL_ENSURE( mxBiffStrm.get(), "DefinedName::importBiffFormula - missing BIFF stream" ); BiffInputStream& rStrm = mxBiffStrm->getStream(); - BiffInputStreamGuard aStrmGuard( rStrm ); + BiffInputStreamPosGuard aStrmGuard( rStrm ); if( mxBiffStrm->restorePosition() ) importBiffFormula( rContext, rStrm, &mnFmlaSize ); } @@ -580,40 +574,10 @@ void DefinedName::implImportBiffFormula( FormulaContext& rContext ) DefinedNamesBuffer::DefinedNamesBuffer( const WorkbookHelper& rHelper ) : WorkbookHelper( rHelper ), - maTokenIndexProp( CREATE_OUSTRING( "TokenIndex" ) ), mnLocalSheet( -1 ) { } -Reference< XNamedRange > DefinedNamesBuffer::createDefinedName( OUString& orName, sal_Int32 nNameFlags ) const -{ - // find an unused name - Reference< XNamedRanges > xNamedRanges = getNamedRanges(); - Reference< XNameAccess > xNameAccess( xNamedRanges, UNO_QUERY ); - if( xNameAccess.is() ) - orName = ContainerHelper::getUnusedName( xNameAccess, orName, '_' ); - - // create the name and insert it into the Calc document - Reference< XNamedRange > xNamedRange; - if( xNamedRanges.is() && (orName.getLength() > 0) ) try - { - xNamedRanges->addNewByName( orName, OUString(), CellAddress( 0, 0, 0 ), nNameFlags ); - xNamedRange.set( xNamedRanges->getByName( orName ), UNO_QUERY ); - } - catch( Exception& ) - { - OSL_ENSURE( false, "DefinedNamesBuffer::createDefinedName - cannot create defined name" ); - } - return xNamedRange; -} - -sal_Int32 DefinedNamesBuffer::getTokenIndex( const Reference< XNamedRange >& rxNamedRange ) const -{ - PropertySet aPropSet( rxNamedRange ); - sal_Int32 nIndex = -1; - return aPropSet.getProperty( nIndex, maTokenIndexProp ) ? nIndex : -1; -} - void DefinedNamesBuffer::setLocalSheetIndex( sal_Int32 nLocalSheet ) { mnLocalSheet = nLocalSheet; @@ -638,8 +602,16 @@ void DefinedNamesBuffer::importDefinedName( BiffInputStream& rStrm ) void DefinedNamesBuffer::finalizeImport() { - /* First insert all names without formula definition into the document. */ - maDefNames.forEachMem( &DefinedName::createNameObject ); + // first insert all names without formula definition into the document + for( DefNameVector::iterator aIt = maDefNames.begin(), aEnd = maDefNames.end(); aIt != aEnd; ++aIt ) + { + DefinedNameRef xDefName = *aIt; + xDefName->createNameObject(); + sal_Int32 nTokenIndex = xDefName->getTokenIndex(); + if( nTokenIndex >= 0 ) + maDefNameMap[ nTokenIndex ] = xDefName; + } + /* Now convert all name formulas, so that the formula parser can find all names in case of circular dependencies. */ maDefNames.forEachMem( &DefinedName::convertFormula ); @@ -650,11 +622,16 @@ DefinedNameRef DefinedNamesBuffer::getByIndex( sal_Int32 nIndex ) const return maDefNames.get( nIndex ); } +DefinedNameRef DefinedNamesBuffer::getByTokenIndex( sal_Int32 nIndex ) const +{ + return maDefNameMap.get( nIndex ); +} + DefinedNameRef DefinedNamesBuffer::getByOoxName( const OUString& rOoxName, sal_Int32 nSheet ) const { DefinedNameRef xGlobalName; // a found global name DefinedNameRef xLocalName; // a found local name - for( DefNameVec::const_iterator aIt = maDefNames.begin(), aEnd = maDefNames.end(); (aIt != aEnd) && !xLocalName; ++aIt ) + for( DefNameVector::const_iterator aIt = maDefNames.begin(), aEnd = maDefNames.end(); (aIt != aEnd) && !xLocalName; ++aIt ) { DefinedNameRef xCurrName = *aIt; if( xCurrName->getOoxName() == rOoxName ) diff --git a/oox/source/xls/drawingfragment.cxx b/oox/source/xls/drawingfragment.cxx index 2a272aca540d..6424f02e26c7 100644 --- a/oox/source/xls/drawingfragment.cxx +++ b/oox/source/xls/drawingfragment.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: drawingfragment.cxx,v $ - * $Revision: 1.4 $ + * $Revision: 1.4.20.1 $ * * This file is part of OpenOffice.org. * @@ -443,7 +443,7 @@ void OoxDrawingFragment::onEndElement( const OUString& rChars ) { Rectangle aLoc = mxAnchor->calcEmuLocation( maEmuSheetSize ); if( (aLoc.X >= 0) && (aLoc.Y >= 0) && (aLoc.Width >= 0) && (aLoc.Height >= 0) ) - mxShape->addShape( getOoxFilter(), getTheme().getCoreThemePtr(), mxDrawPage, &aLoc ); + mxShape->addShape( getOoxFilter(), getThemeRef(), mxDrawPage, &aLoc ); } mxShape.reset(); mxAnchor.reset(); diff --git a/oox/source/xls/excelfilter.cxx b/oox/source/xls/excelfilter.cxx index 5bff8ebeaeb5..cb02ba32279d 100644 --- a/oox/source/xls/excelfilter.cxx +++ b/oox/source/xls/excelfilter.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: excelfilter.cxx,v $ - * $Revision: 1.7 $ + * $Revision: 1.6.6.7 $ * * This file is part of OpenOffice.org. * @@ -39,6 +39,7 @@ #include "oox/dump/xlsbdumper.hxx" using ::rtl::OUString; +using ::com::sun::star::uno::Any; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Sequence; using ::com::sun::star::uno::Exception; @@ -92,7 +93,7 @@ bool ExcelFilter::importDocument() throw() { /* to activate the XLSX/XLSB dumper, define the environment variable OOO_XLSBDUMPER and insert the full path to the file - file:///<path-to-oox-module>/source/dump/xlsbdumperconfig.dat. */ + file:///<path-to-oox-module>/source/dump/xlsbdumper.ini. */ OOX_DUMP_FILE( ::oox::dump::xlsb::Dumper ); bool bRet = false; @@ -117,7 +118,7 @@ bool ExcelFilter::exportDocument() throw() const ::oox::drawingml::Theme* ExcelFilter::getCurrentTheme() const { - return mpHelper->getTheme().getCoreThemePtr().get(); + return &mpHelper->getTheme(); } sal_Int32 ExcelFilter::getSchemeClr( sal_Int32 nColorSchemeToken ) const @@ -182,25 +183,33 @@ bool ExcelBiffFilter::importDocument() throw() { /* to activate the BIFF dumper, define the environment variable OOO_BIFFDUMPER and insert the full path to the file - file:///<path-to-oox-module>/source/dump/biffdumperconfig.dat. */ + file:///<path-to-oox-module>/source/dump/biffdumper.ini. */ OOX_DUMP_FILE( ::oox::dump::biff::Dumper ); + /* A boolean argument passed through XInitialisation decides whether to + use the BIFF file dumper implemented in this filter only, or to really + import/export the document. */ + const Sequence< Any >& rArgs = getArguments(); + bool bDumperOnly = false; + if( (rArgs.getLength() >= 2) && (rArgs[ 1 ] >>= bDumperOnly) && bDumperOnly ) + return true; + bool bRet = false; // detect BIFF version and workbook stream name OUString aWorkbookName; BiffType eBiff = BiffDetector::detectStorageBiffVersion( aWorkbookName, getStorage() ); - BinaryInputStream aInStrm( getStorage()->openInputStream( aWorkbookName ), aWorkbookName.getLength() > 0 ); - OSL_ENSURE( (eBiff != BIFF_UNKNOWN) && aInStrm.is(), "ExcelBiffFilter::ExcelBiffFilter - invalid file format" ); + BinaryXInputStream aInStrm( getStorage()->openInputStream( aWorkbookName ), aWorkbookName.getLength() > 0 ); + OSL_ENSURE( (eBiff != BIFF_UNKNOWN) && !aInStrm.isEof(), "ExcelBiffFilter::ExcelBiffFilter - invalid file format" ); - if( (eBiff != BIFF_UNKNOWN) && aInStrm.is() ) + if( (eBiff != BIFF_UNKNOWN) && !aInStrm.isEof() ) { WorkbookHelperRoot aHelper( *this, eBiff ); if( aHelper.isValid() ) { - BiffWorkbookFragment aFragment( aHelper ); BiffInputStream aBiffStream( aInStrm ); - bRet = aFragment.importFragment( aBiffStream ); + BiffWorkbookFragment aFragment( aHelper, aBiffStream ); + bRet = aFragment.importFragment(); } } return bRet; diff --git a/oox/source/xls/excelhandlers.cxx b/oox/source/xls/excelhandlers.cxx index e3f6dd1cb9a6..a3db6c284416 100644 --- a/oox/source/xls/excelhandlers.cxx +++ b/oox/source/xls/excelhandlers.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: excelhandlers.cxx,v $ - * $Revision: 1.3 $ + * $Revision: 1.3.20.2 $ * * This file is part of OpenOffice.org. * @@ -29,19 +29,20 @@ ************************************************************************/ #include "oox/xls/excelhandlers.hxx" +#include "oox/xls/biffinputstream.hxx" using ::rtl::OUString; -using ::oox::core::FragmentHandler2; using ::oox::core::XmlFilterBase; namespace oox { namespace xls { // ============================================================================ +// ============================================================================ OoxWorkbookFragmentBase::OoxWorkbookFragmentBase( const WorkbookHelper& rHelper, const OUString& rFragmentPath ) : - FragmentHandler2( rHelper.getOoxFilter(), rFragmentPath ), + OoxFragmentHandler( rHelper.getOoxFilter(), rFragmentPath ), WorkbookHelper( rHelper ) { } @@ -50,19 +51,182 @@ OoxWorkbookFragmentBase::OoxWorkbookFragmentBase( OoxWorksheetFragmentBase::OoxWorksheetFragmentBase( const WorkbookHelper& rHelper, const OUString& rFragmentPath, ISegmentProgressBarRef xProgressBar, WorksheetType eSheetType, sal_Int32 nSheet ) : - FragmentHandler2( rHelper.getOoxFilter(), rFragmentPath ), + OoxFragmentHandler( rHelper.getOoxFilter(), rFragmentPath ), WorksheetHelperRoot( rHelper, xProgressBar, eSheetType, nSheet ) { } OoxWorksheetFragmentBase::OoxWorksheetFragmentBase( const WorksheetHelper& rHelper, const OUString& rFragmentPath ) : - FragmentHandler2( rHelper.getOoxFilter(), rFragmentPath ), + OoxFragmentHandler( rHelper.getOoxFilter(), rFragmentPath ), WorksheetHelperRoot( rHelper ) { } // ============================================================================ +// ============================================================================ + +namespace { + +const sal_uInt16 BIFF_BOF_GLOBALS = 0x0005; /// BIFF5-BIFF8 workbook globals. +const sal_uInt16 BIFF_BOF_MODULE = 0x0006; /// BIFF5-BIFF8 Visual Basic module. +const sal_uInt16 BIFF_BOF_SHEET = 0x0010; /// BIFF2-BIFF8 worksheet/dialog sheet. +const sal_uInt16 BIFF_BOF_CHART = 0x0020; /// BIFF2-BIFF8 chart sheet. +const sal_uInt16 BIFF_BOF_MACRO = 0x0040; /// BIFF4-BIFF8 macro sheet. +const sal_uInt16 BIFF_BOF_WORKSPACE = 0x0100; /// BIFF3-BIFF8 workspace. + +} // namespace + +// ============================================================================ + +BiffHandlerBase::~BiffHandlerBase() +{ +} + +bool BiffHandlerBase::skipRecordBlock( sal_uInt16 nEndRecId ) +{ + sal_uInt16 nStartRecId = mrStrm.getRecId(); + while( mrStrm.startNextRecord() && (mrStrm.getRecId() != nEndRecId) ) + if( mrStrm.getRecId() == nStartRecId ) + skipRecordBlock( nEndRecId ); + return !mrStrm.isEof() && (mrStrm.getRecId() == nEndRecId); +} + +bool BiffHandlerBase::isBofRecord() const +{ + return + (mrStrm.getRecId() == BIFF2_ID_BOF) || + (mrStrm.getRecId() == BIFF3_ID_BOF) || + (mrStrm.getRecId() == BIFF4_ID_BOF) || + (mrStrm.getRecId() == BIFF5_ID_BOF); +} + +// ============================================================================ + +BiffContextHandler::BiffContextHandler( const BiffHandlerBase& rParent ) : + BiffHandlerBase( rParent ) +{ +} + +// ============================================================================ + +BiffFragmentHandler::BiffFragmentHandler( BiffInputStream& rStrm ) : + BiffHandlerBase( rStrm ) +{ +} + +BiffFragmentType BiffFragmentHandler::startFragment( BiffType eBiff ) +{ + BiffFragmentType eFragment = BIFF_FRAGMENT_UNKNOWN; + if( mrStrm.startNextRecord() ) + { + /* #i23425# Don't rely on BOF record ID to read BOF contents, but on + the detected BIFF version. */ + if( isBofRecord() ) + { + // BOF is always written unencrypted + mrStrm.enableDecoder( false ); + mrStrm.skip( 2 ); + sal_uInt16 nType = mrStrm.readuInt16(); + + // decide which fragment types are valid for current BIFF version + switch( eBiff ) + { + case BIFF2: switch( nType ) + { + case BIFF_BOF_CHART: eFragment = BIFF_FRAGMENT_EMPTYSHEET; break; + case BIFF_BOF_MACRO: eFragment = BIFF_FRAGMENT_MACROSHEET; break; + // #i51490# Excel interprets invalid types as worksheet + default: eFragment = BIFF_FRAGMENT_WORKSHEET; + } + break; + + case BIFF3: switch( nType ) + { + case BIFF_BOF_CHART: eFragment = BIFF_FRAGMENT_EMPTYSHEET; break; + case BIFF_BOF_MACRO: eFragment = BIFF_FRAGMENT_MACROSHEET; break; + case BIFF_BOF_WORKSPACE:eFragment = BIFF_FRAGMENT_UNKNOWN; break; + // #i51490# Excel interprets invalid types as worksheet + default: eFragment = BIFF_FRAGMENT_WORKSHEET; + }; + break; + + case BIFF4: switch( nType ) + { + case BIFF_BOF_CHART: eFragment = BIFF_FRAGMENT_EMPTYSHEET; break; + case BIFF_BOF_MACRO: eFragment = BIFF_FRAGMENT_MACROSHEET; break; + case BIFF_BOF_WORKSPACE:eFragment = BIFF_FRAGMENT_WORKSPACE; break; + // #i51490# Excel interprets invalid types as worksheet + default: eFragment = BIFF_FRAGMENT_WORKSHEET; + }; + break; + + case BIFF5: + case BIFF8: switch( nType ) + { + case BIFF_BOF_GLOBALS: eFragment = BIFF_FRAGMENT_GLOBALS; break; + case BIFF_BOF_CHART: eFragment = BIFF_FRAGMENT_CHARTSHEET; break; + case BIFF_BOF_MACRO: eFragment = BIFF_FRAGMENT_MACROSHEET; break; + case BIFF_BOF_MODULE: eFragment = BIFF_FRAGMENT_MODULESHEET; break; + case BIFF_BOF_WORKSPACE:eFragment = BIFF_FRAGMENT_UNKNOWN; break; + // #i51490# Excel interprets invalid types as worksheet + default: eFragment = BIFF_FRAGMENT_WORKSHEET; + }; + break; + + case BIFF_UNKNOWN: break; + } + } + } + return eFragment; +} + +bool BiffFragmentHandler::skipFragment() +{ + while( mrStrm.startNextRecord() && (mrStrm.getRecId() != BIFF_ID_EOF) ) + if( isBofRecord() ) + skipFragment(); + return !mrStrm.isEof() && (mrStrm.getRecId() == BIFF_ID_EOF); +} + +// ============================================================================ + +BiffWorkbookFragmentBase::BiffWorkbookFragmentBase( const WorkbookHelper& rHelper, BiffInputStream& rStrm ) : + BiffFragmentHandler( rStrm ), + WorkbookHelper( rHelper ) +{ +} + +// ============================================================================ + +BiffWorksheetFragmentBase::BiffWorksheetFragmentBase( const BiffWorkbookFragmentBase& rParent, + ISegmentProgressBarRef xProgressBar, WorksheetType eSheetType, sal_Int32 nSheet ) : + BiffFragmentHandler( rParent ), + WorksheetHelperRoot( rParent, xProgressBar, eSheetType, nSheet ) +{ +} + +BiffWorksheetFragmentBase::BiffWorksheetFragmentBase( const WorksheetHelper& rHelper, BiffInputStream& rStrm ) : + BiffFragmentHandler( rStrm ), + WorksheetHelperRoot( rHelper ) +{ +} + +// ============================================================================ + +BiffSkipWorksheetFragment::BiffSkipWorksheetFragment( + const BiffWorkbookFragmentBase& rParent, ISegmentProgressBarRef xProgressBar, sal_Int32 nSheet ) : + BiffWorksheetFragmentBase( rParent, xProgressBar, SHEETTYPE_EMPTYSHEET, nSheet ) +{ +} + +bool BiffSkipWorksheetFragment::importFragment() +{ + return skipFragment(); +} + +// ============================================================================ +// ============================================================================ } // namespace xls } // namespace oox diff --git a/oox/source/xls/externallinkbuffer.cxx b/oox/source/xls/externallinkbuffer.cxx index 0ad1b70f1d98..0ebfffb8a984 100644 --- a/oox/source/xls/externallinkbuffer.cxx +++ b/oox/source/xls/externallinkbuffer.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: externallinkbuffer.cxx,v $ - * $Revision: 1.5 $ + * $Revision: 1.5.4.1 $ * * This file is part of OpenOffice.org. * @@ -209,7 +209,8 @@ void ExternalName::importExternalName( BiffInputStream& rStrm ) else { // get sheet index for sheet-local names - sal_Int16 nRefId = rStrm.skip( 2 ).readuInt16(); + rStrm.skip( 2 ); + sal_Int16 nRefId = rStrm.readuInt16(); switch( getBiff() ) { case BIFF2: @@ -245,7 +246,7 @@ void ExternalName::importExternalName( BiffInputStream& rStrm ) case LINKTYPE_INTERNAL: case LINKTYPE_EXTERNAL: // cell references that are stored in hidden external names (seen in BIFF3-BIFF4) - if( (getBiff() <= BIFF4) && (maOoxData.maName.getLength() > 0) && (maOoxData.maName[ 0 ] == '\x01') && (rStrm.getRecLeft() > 2) ) + if( (getBiff() <= BIFF4) && (maOoxData.maName.getLength() > 0) && (maOoxData.maName[ 0 ] == '\x01') && (rStrm.getRemaining() > 2) ) { TokensFormulaContext aContext( true, true ); importBiffFormula( aContext, rStrm ); @@ -257,7 +258,7 @@ void ExternalName::importExternalName( BiffInputStream& rStrm ) case LINKTYPE_OLE: case LINKTYPE_MAYBE_DDE_OLE: // DDE/OLE link results - if( rStrm.getRecLeft() > 3 ) + if( rStrm.getRemaining() > 3 ) { bool bBiff8 = getBiff() == BIFF8; sal_Int32 nCols = rStrm.readuInt8(); @@ -266,7 +267,7 @@ void ExternalName::importExternalName( BiffInputStream& rStrm ) setResultSize( nCols, nRows ); bool bLoop = true; - while( bLoop && rStrm.isValid() && (maCurrIt != maResults.end()) ) + while( bLoop && !rStrm.isEof() && (maCurrIt != maResults.end()) ) { switch( rStrm.readuInt8() ) { @@ -292,7 +293,7 @@ void ExternalName::importExternalName( BiffInputStream& rStrm ) bLoop = false; } } - OSL_ENSURE( bLoop && rStrm.isValid() && (maCurrIt == maResults.end()), + OSL_ENSURE( bLoop && !rStrm.isEof() && (maCurrIt == maResults.end()), "ExternalName::importExternalName - stream error in result set" ); } break; @@ -462,7 +463,7 @@ void ExternalLink::importExtSheetNames( RecordInputStream& rStrm ) if( meLinkType == LINKTYPE_EXTERNAL ) { WorksheetBuffer& rWorksheets = getWorksheets(); - for( sal_Int32 nSheet = 0, nCount = rStrm.readInt32(); rStrm.isValid() && (nSheet < nCount); ++nSheet ) + for( sal_Int32 nSheet = 0, nCount = rStrm.readInt32(); !rStrm.isEof() && (nSheet < nCount); ++nSheet ) { OUString aSheetName = rStrm.readString(); OSL_ENSURE( aSheetName.getLength() > 0, "ExternalLink::importExtSheetNames - empty sheet name" ); @@ -506,7 +507,7 @@ void ExternalLink::importExternalBook( BiffInputStream& rStrm ) OUString aTarget; sal_uInt16 nSheetCount; rStrm >> nSheetCount; - if( rStrm.getRecLeft() == 2 ) + if( rStrm.getRemaining() == 2 ) { if( rStrm.readuInt8() == 1 ) { @@ -515,7 +516,7 @@ void ExternalLink::importExternalBook( BiffInputStream& rStrm ) aTarget = OStringToOUString( OString( cChar ), getTextEncoding() ); } } - else if( rStrm.getRecLeft() >= 3 ) + else if( rStrm.getRemaining() >= 3 ) { // NUL characters may occur rStrm.enableNulChars( true ); @@ -532,7 +533,7 @@ void ExternalLink::importExternalBook( BiffInputStream& rStrm ) if( meLinkType == LINKTYPE_EXTERNAL ) { WorksheetBuffer& rWorksheets = getWorksheets(); - for( sal_uInt16 nSheet = 0; rStrm.isValid() && (nSheet < nSheetCount); ++nSheet ) + for( sal_uInt16 nSheet = 0; !rStrm.isEof() && (nSheet < nSheetCount); ++nSheet ) { OUString aSheetName = rStrm.readUniString(); OSL_ENSURE( aSheetName.getLength() > 0, "ExternalLink::importExternalBook - empty sheet name" ); @@ -750,9 +751,9 @@ void ExternalLinkBuffer::importExternalSheets( RecordInputStream& rStrm ) maRefSheets.clear(); sal_Int32 nRefCount; rStrm >> nRefCount; - size_t nMaxCount = getLimitedValue< size_t, sal_Int32 >( nRefCount, 0, rStrm.getRecLeft() / 12 ); + size_t nMaxCount = getLimitedValue< size_t, sal_Int64 >( nRefCount, 0, rStrm.getRemaining() / 12 ); maRefSheets.reserve( nMaxCount ); - for( size_t nRefId = 0; rStrm.isValid() && (nRefId < nMaxCount); ++nRefId ) + for( size_t nRefId = 0; !rStrm.isEof() && (nRefId < nMaxCount); ++nRefId ) { OoxRefSheets aRefSheets; aRefSheets.readOobData( rStrm ); @@ -789,7 +790,7 @@ void ExternalLinkBuffer::importExternSheet8( BiffInputStream& rStrm ) sal_uInt16 nRefCount; rStrm >> nRefCount; maRefSheets.reserve( nRefCount ); - for( sal_uInt16 nRefId = 0; rStrm.isValid() && (nRefId < nRefCount); ++nRefId ) + for( sal_uInt16 nRefId = 0; !rStrm.isEof() && (nRefId < nRefCount); ++nRefId ) { OoxRefSheets aRefSheets; aRefSheets.readBiff8Data( rStrm ); diff --git a/oox/source/xls/externallinkfragment.cxx b/oox/source/xls/externallinkfragment.cxx index 8c0909657350..e195222b2c0b 100644 --- a/oox/source/xls/externallinkfragment.cxx +++ b/oox/source/xls/externallinkfragment.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: externallinkfragment.cxx,v $ - * $Revision: 1.4 $ + * $Revision: 1.4.20.2 $ * * This file is part of OpenOffice.org. * @@ -75,7 +75,7 @@ ContextWrapper OoxExternalLinkFragment::onCreateContext( sal_Int32 nElement, con return (nElement == XLS_TOKEN( definedName )); case XLS_TOKEN( sheetDataSet ): if( (nElement == XLS_TOKEN( sheetData )) && (mrExtLink.getLinkType() == LINKTYPE_EXTERNAL) ) - return createSheetDataContext( rAttribs.getInteger( XML_sheetId, -1 ) ).get(); + return createSheetDataContext( rAttribs.getInteger( XML_sheetId, -1 ) ); break; case XLS_TOKEN( ddeLink ): return (nElement == XLS_TOKEN( ddeItems )); @@ -148,7 +148,7 @@ ContextWrapper OoxExternalLinkFragment::onCreateRecordContext( sal_Int32 nRecId, return (nRecId == OOBIN_ID_EXTERNALBOOK); case OOBIN_ID_EXTERNALBOOK: if( (nRecId == OOBIN_ID_EXTSHEETDATA) && (mrExtLink.getLinkType() == LINKTYPE_EXTERNAL) ) - return createSheetDataContext( rStrm.readInt32() ).get(); + return createSheetDataContext( rStrm.readInt32() ); return (nRecId == OOBIN_ID_EXTSHEETNAMES) || (nRecId == OOBIN_ID_EXTERNALNAME); case OOBIN_ID_EXTERNALNAME: @@ -179,14 +179,13 @@ void OoxExternalLinkFragment::onStartRecord( RecordInputStream& rStrm ) } } -::rtl::Reference< OoxExternalSheetDataContext > OoxExternalLinkFragment::createSheetDataContext( sal_Int32 nSheetId ) +ContextWrapper OoxExternalLinkFragment::createSheetDataContext( sal_Int32 nSheetId ) { sal_Int32 nSheet = mrExtLink.getSheetIndex( nSheetId ); - ::rtl::Reference< OoxExternalSheetDataContext > xContext( - new OoxExternalSheetDataContext( *this, SHEETTYPE_WORKSHEET, nSheet ) ); + ::rtl::Reference< OoxWorksheetContextBase > xContext( new OoxExternalSheetDataContext( *this, nSheet ) ); if( xContext->isValidSheet() ) - return xContext; - return 0; + return xContext.get(); + return false; } // oox.core.FragmentHandler2 interface ---------------------------------------- @@ -207,8 +206,8 @@ const RecordInfo* OoxExternalLinkFragment::getRecordInfos() const // ============================================================================ -BiffExternalLinkFragment::BiffExternalLinkFragment( const WorkbookHelper& rHelper, bool bImportDefNames ) : - BiffWorkbookFragmentBase( rHelper ), +BiffExternalLinkFragment::BiffExternalLinkFragment( const BiffWorkbookFragmentBase& rParent, bool bImportDefNames ) : + BiffWorkbookFragmentBase( rParent ), mbImportDefNames( bImportDefNames ) { } @@ -217,66 +216,66 @@ BiffExternalLinkFragment::~BiffExternalLinkFragment() { } -bool BiffExternalLinkFragment::importFragment( BiffInputStream& rStrm ) +bool BiffExternalLinkFragment::importFragment() { // process all record in this sheet fragment - while( rStrm.startNextRecord() && (rStrm.getRecId() != BIFF_ID_EOF) ) + while( mrStrm.startNextRecord() && (mrStrm.getRecId() != BIFF_ID_EOF) ) { - if( isBofRecord( rStrm.getRecId() ) ) - skipFragment( rStrm ); // skip unknown embedded fragments + if( isBofRecord() ) + skipFragment(); // skip unknown embedded fragments else - importRecord( rStrm ); + importRecord(); } - return rStrm.isValid() && (rStrm.getRecId() == BIFF_ID_EOF); + return !mrStrm.isEof() && (mrStrm.getRecId() == BIFF_ID_EOF); } -void BiffExternalLinkFragment::importRecord( BiffInputStream& rStrm ) +void BiffExternalLinkFragment::importRecord() { - sal_uInt16 nRecId = rStrm.getRecId(); + sal_uInt16 nRecId = mrStrm.getRecId(); switch( getBiff() ) { case BIFF2: switch( nRecId ) { - case BIFF2_ID_EXTERNALNAME: importExternalName( rStrm ); break; - case BIFF_ID_EXTERNSHEET: importExternSheet( rStrm ); break; - case BIFF2_ID_DEFINEDNAME: importDefinedName( rStrm ); break; + case BIFF2_ID_EXTERNALNAME: importExternalName(); break; + case BIFF_ID_EXTERNSHEET: importExternSheet(); break; + case BIFF2_ID_DEFINEDNAME: importDefinedName(); break; } break; case BIFF3: switch( nRecId ) { - case BIFF_ID_CRN: importCrn( rStrm ); break; - case BIFF3_ID_EXTERNALNAME: importExternalName( rStrm ); break; - case BIFF_ID_EXTERNSHEET: importExternSheet( rStrm ); break; - case BIFF3_ID_DEFINEDNAME: importDefinedName( rStrm ); break; - case BIFF_ID_XCT: importXct( rStrm ); break; + case BIFF_ID_CRN: importCrn(); break; + case BIFF3_ID_EXTERNALNAME: importExternalName(); break; + case BIFF_ID_EXTERNSHEET: importExternSheet(); break; + case BIFF3_ID_DEFINEDNAME: importDefinedName(); break; + case BIFF_ID_XCT: importXct(); break; } break; case BIFF4: switch( nRecId ) { - case BIFF_ID_CRN: importCrn( rStrm ); break; - case BIFF3_ID_EXTERNALNAME: importExternalName( rStrm ); break; - case BIFF_ID_EXTERNSHEET: importExternSheet( rStrm ); break; - case BIFF3_ID_DEFINEDNAME: importDefinedName( rStrm ); break; - case BIFF_ID_XCT: importXct( rStrm ); break; + case BIFF_ID_CRN: importCrn(); break; + case BIFF3_ID_EXTERNALNAME: importExternalName(); break; + case BIFF_ID_EXTERNSHEET: importExternSheet(); break; + case BIFF3_ID_DEFINEDNAME: importDefinedName(); break; + case BIFF_ID_XCT: importXct(); break; } break; case BIFF5: switch( nRecId ) { - case BIFF_ID_CRN: importCrn( rStrm ); break; - case BIFF5_ID_EXTERNALNAME: importExternalName( rStrm ); break; - case BIFF_ID_EXTERNSHEET: importExternSheet( rStrm ); break; - case BIFF5_ID_DEFINEDNAME: importDefinedName( rStrm ); break; - case BIFF_ID_XCT: importXct( rStrm ); break; + case BIFF_ID_CRN: importCrn(); break; + case BIFF5_ID_EXTERNALNAME: importExternalName(); break; + case BIFF_ID_EXTERNSHEET: importExternSheet(); break; + case BIFF5_ID_DEFINEDNAME: importDefinedName(); break; + case BIFF_ID_XCT: importXct(); break; } break; case BIFF8: switch( nRecId ) { - case BIFF_ID_CRN: importCrn( rStrm ); break; - case BIFF_ID_EXTERNALBOOK: importExternalBook( rStrm ); break; - case BIFF5_ID_EXTERNALNAME: importExternalName( rStrm ); break; - case BIFF_ID_EXTERNSHEET: importExternSheet( rStrm ); break; - case BIFF5_ID_DEFINEDNAME: importDefinedName( rStrm ); break; - case BIFF_ID_XCT: importXct( rStrm ); break; + case BIFF_ID_CRN: importCrn(); break; + case BIFF_ID_EXTERNALBOOK: importExternalBook(); break; + case BIFF5_ID_EXTERNALNAME: importExternalName(); break; + case BIFF_ID_EXTERNSHEET: importExternSheet(); break; + case BIFF5_ID_DEFINEDNAME: importDefinedName(); break; + case BIFF_ID_XCT: importXct(); break; } break; case BIFF_UNKNOWN: break; @@ -290,28 +289,28 @@ void BiffExternalLinkFragment::finalizeImport() // private -------------------------------------------------------------------- -void BiffExternalLinkFragment::importExternSheet( BiffInputStream& rStrm ) +void BiffExternalLinkFragment::importExternSheet() { mxContext.reset(); if( getBiff() == BIFF8 ) - getExternalLinks().importExternSheet8( rStrm ); + getExternalLinks().importExternSheet8( mrStrm ); else - mxExtLink = getExternalLinks().importExternSheet( rStrm ); + mxExtLink = getExternalLinks().importExternSheet( mrStrm ); } -void BiffExternalLinkFragment::importExternalBook( BiffInputStream& rStrm ) +void BiffExternalLinkFragment::importExternalBook() { mxContext.reset(); - mxExtLink = getExternalLinks().importExternalBook( rStrm ); + mxExtLink = getExternalLinks().importExternalBook( mrStrm ); } -void BiffExternalLinkFragment::importExternalName( BiffInputStream& rStrm ) +void BiffExternalLinkFragment::importExternalName() { if( mxExtLink.get() ) - mxExtLink->importExternalName( rStrm ); + mxExtLink->importExternalName( mrStrm ); } -void BiffExternalLinkFragment::importXct( BiffInputStream& rStrm ) +void BiffExternalLinkFragment::importXct() { mxContext.reset(); if( mxExtLink.get() && (mxExtLink->getLinkType() == LINKTYPE_EXTERNAL) ) @@ -327,29 +326,29 @@ void BiffExternalLinkFragment::importXct( BiffInputStream& rStrm ) nSheet = mxExtLink->getSheetIndex(); break; case BIFF8: - rStrm.skip( 2 ); - nSheet = mxExtLink->getSheetIndex( rStrm.readInt16() ); + mrStrm.skip( 2 ); + nSheet = mxExtLink->getSheetIndex( mrStrm.readInt16() ); break; case BIFF_UNKNOWN: break; } // create a sheet data context to import the CRN records and set the cached cell values - mxContext.reset( new BiffExternalSheetDataContext( *this, SHEETTYPE_WORKSHEET, nSheet ) ); + mxContext.reset( new BiffExternalSheetDataContext( *this, nSheet ) ); if( !mxContext->isValidSheet() ) mxContext.reset(); } } -void BiffExternalLinkFragment::importCrn( BiffInputStream& rStrm ) +void BiffExternalLinkFragment::importCrn() { if( mxContext.get() ) - mxContext->importCrn( rStrm ); + mxContext->importRecord(); } -void BiffExternalLinkFragment::importDefinedName( BiffInputStream& rStrm ) +void BiffExternalLinkFragment::importDefinedName() { if( mbImportDefNames ) - getDefinedNames().importDefinedName( rStrm ); + getDefinedNames().importDefinedName( mrStrm ); } // ============================================================================ diff --git a/oox/source/xls/formulabase.cxx b/oox/source/xls/formulabase.cxx index f53ed2e89a92..87c1fc67adf7 100644 --- a/oox/source/xls/formulabase.cxx +++ b/oox/source/xls/formulabase.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: formulabase.cxx,v $ - * $Revision: 1.7 $ + * $Revision: 1.5.20.7 $ * * This file is part of OpenOffice.org. * @@ -42,7 +42,6 @@ #include <com/sun/star/sheet/FormulaMapGroupSpecialOffset.hpp> #include <com/sun/star/sheet/XFormulaOpCodeMapper.hpp> #include <com/sun/star/sheet/XFormulaTokens.hpp> -#include "oox/helper/containerhelper.hxx" #include "oox/helper/propertyset.hxx" #include "oox/helper/recordinputstream.hxx" #include "oox/core/filterbase.hxx" @@ -172,6 +171,56 @@ void BinComplexRef2d::readBiff8Data( BiffInputStream& rStrm, bool bRelativeAsOff maRef2.setBiff8Data( nCol2, nRow2, bRelativeAsOffset ); } +// token vector, sequence ===================================================== + +ApiTokenVector::ApiTokenVector() +{ +} + +Any& ApiTokenVector::append( sal_Int32 nOpCode ) +{ + resize( size() + 1 ); + back().OpCode = nOpCode; + return back().Data; +} + +// token sequence iterator ==================================================== + +ApiTokenIterator::ApiTokenIterator( const ApiTokenSequence& rTokens, sal_Int32 nSpacesOpCode, bool bSkipSpaces ) : + mpToken( rTokens.getConstArray() ), + mpTokenEnd( rTokens.getConstArray() + rTokens.getLength() ), + mnSpacesOpCode( nSpacesOpCode ), + mbSkipSpaces( bSkipSpaces ) +{ + skipSpaces(); +} + +ApiTokenIterator::ApiTokenIterator( const ApiTokenIterator& rIter, bool bSkipSpaces ) : + mpToken( rIter.mpToken ), + mpTokenEnd( rIter.mpTokenEnd ), + mnSpacesOpCode( rIter.mnSpacesOpCode ), + mbSkipSpaces( bSkipSpaces ) +{ + skipSpaces(); +} + +ApiTokenIterator& ApiTokenIterator::operator++() +{ + if( is() ) + { + ++mpToken; + skipSpaces(); + } + return *this; +} + +void ApiTokenIterator::skipSpaces() +{ + if( mbSkipSpaces ) + while( is() && (mpToken->OpCode == mnSpacesOpCode) ) + ++mpToken; +} + // function data ============================================================== namespace { @@ -183,6 +232,9 @@ const sal_uInt8 FUNCFLAG_IMPORTONLY = 0x02; /// Only used in import const sal_uInt8 FUNCFLAG_EXPORTONLY = 0x04; /// Only used in export filter. const sal_uInt8 FUNCFLAG_MACROCALL = 0x08; /// Function is simulated by macro call in Excel. const sal_uInt8 FUNCFLAG_EXTERNAL = 0x10; /// Function is external in Calc. +const sal_uInt8 FUNCFLAG_MACROFUNC = 0x20; /// Function is a macro sheet function. +const sal_uInt8 FUNCFLAG_MACROCMD = 0x40; /// Function is a macro sheet command. +const sal_uInt8 FUNCFLAG_ALWAYSVAR = 0x80; /// Function is always represented by a tFuncVar token. typedef ::boost::shared_ptr< FunctionInfo > FunctionInfoRef; @@ -208,469 +260,499 @@ inline bool FunctionData::isSupported( bool bImportFilter ) const return !getFlag( mnFlags, bImportFilter ? FUNCFLAG_EXPORTONLY : FUNCFLAG_IMPORTONLY ); } -const sal_uInt8 R = BIFF_TOKCLASS_REF; -const sal_uInt8 V = BIFF_TOKCLASS_VAL; -const sal_uInt8 A = BIFF_TOKCLASS_ARR; -const sal_uInt8 ER = FUNCINFO_PARAM_EXCELONLY | BIFF_TOKCLASS_REF; -const sal_uInt8 EV = FUNCINFO_PARAM_EXCELONLY | BIFF_TOKCLASS_VAL; -const sal_uInt8 EA = FUNCINFO_PARAM_EXCELONLY | BIFF_TOKCLASS_ARR; -const sal_uInt8 C = FUNCINFO_PARAM_CALCONLY; -const sal_uInt8 I = FUNCINFO_PARAM_INVALID; -const sal_uInt16 NOID = SAL_MAX_UINT16; -const sal_uInt8 MX = SAL_MAX_UINT8; +const sal_uInt8 R = BIFF_TOKCLASS_REF; +const sal_uInt8 V = BIFF_TOKCLASS_VAL; +const sal_uInt8 A = BIFF_TOKCLASS_ARR; +const sal_uInt8 ER = FUNCINFO_PARAM_EXCELONLY | BIFF_TOKCLASS_REF; +const sal_uInt8 EV = FUNCINFO_PARAM_EXCELONLY | BIFF_TOKCLASS_VAL; +const sal_uInt8 EA = FUNCINFO_PARAM_EXCELONLY | BIFF_TOKCLASS_ARR; +const sal_uInt8 C = FUNCINFO_PARAM_CALCONLY; +const sal_uInt8 I = FUNCINFO_PARAM_INVALID; +const sal_uInt16 NOID = SAL_MAX_UINT16; +const sal_uInt8 MX = SAL_MAX_UINT8; /** Functions new in BIFF2. */ static const FunctionData saFuncTableBiff2[] = { - { "COUNT", "COUNT", 0, 0, 0, MX, V, { R }, 0 }, - { "IF", "IF", 1, 1, 2, 3, R, { V, R }, 0 }, - { "ISNA", "ISNA", 2, 2, 1, 1, V, { V }, 0 }, - { "ISERROR", "ISERROR", 3, 3, 1, 1, V, { V }, 0 }, - { "SUM", "SUM", 4, 4, 0, MX, V, { R }, 0 }, - { "AVERAGE", "AVERAGE", 5, 5, 1, MX, V, { R }, 0 }, - { "MIN", "MIN", 6, 6, 1, MX, V, { R }, 0 }, - { "MAX", "MAX", 7, 7, 1, MX, V, { R }, 0 }, - { "ROW", "ROW", 8, 8, 0, 1, V, { R }, 0 }, - { "COLUMN", "COLUMN", 9, 9, 0, 1, V, { R }, 0 }, - { "NA", "NA", 10, 10, 0, 0, V, {}, 0 }, - { "NPV", "NPV", 11, 11, 2, MX, V, { V, R }, 0 }, - { "STDEV", "STDEV", 12, 12, 1, MX, V, { R }, 0 }, - { "DOLLAR", "DOLLAR", 13, 13, 1, 2, V, { V }, 0 }, - { "FIXED", "FIXED", 14, 14, 1, 2, V, { V, V, C, I }, 0 }, - { "SIN", "SIN", 15, 15, 1, 1, V, { V }, 0 }, - { "COS", "COS", 16, 16, 1, 1, V, { V }, 0 }, - { "TAN", "TAN", 17, 17, 1, 1, V, { V }, 0 }, - { "COT", "TAN", 17, 17, 1, 1, V, { V }, FUNCFLAG_EXPORTONLY }, - { "ATAN", "ATAN", 18, 18, 1, 1, V, { V }, 0 }, - { "ACOT", "ATAN", 18, 18, 1, 1, V, { V }, FUNCFLAG_EXPORTONLY }, - { "PI", "PI", 19, 19, 0, 0, V, {}, 0 }, - { "SQRT", "SQRT", 20, 20, 1, 1, V, { V }, 0 }, - { "EXP", "EXP", 21, 21, 1, 1, V, { V }, 0 }, - { "LN", "LN", 22, 22, 1, 1, V, { V }, 0 }, - { "LOG10", "LOG10", 23, 23, 1, 1, V, { V }, 0 }, - { "ABS", "ABS", 24, 24, 1, 1, V, { V }, 0 }, - { "INT", "INT", 25, 25, 1, 1, V, { V }, 0 }, - { "SIGN", "SIGN", 26, 26, 1, 1, V, { V }, 0 }, - { "ROUND", "ROUND", 27, 27, 2, 2, V, { V }, 0 }, - { "LOOKUP", "LOOKUP", 28, 28, 2, 3, V, { V, R }, 0 }, - { "INDEX", "INDEX", 29, 29, 2, 4, R, { R, V }, 0 }, - { "REPT", "REPT", 30, 30, 2, 2, V, { V }, 0 }, - { "MID", "MID", 31, 31, 3, 3, V, { V }, 0 }, - { "LEN", "LEN", 32, 32, 1, 1, V, { V }, 0 }, - { "VALUE", "VALUE", 33, 33, 1, 1, V, { V }, 0 }, - { "TRUE", "TRUE", 34, 34, 0, 0, V, {}, 0 }, - { "FALSE", "FALSE", 35, 35, 0, 0, V, {}, 0 }, - { "AND", "AND", 36, 36, 1, MX, V, { R }, 0 }, - { "OR", "OR", 37, 37, 1, MX, V, { R }, 0 }, - { "NOT", "NOT", 38, 38, 1, 1, V, { V }, 0 }, - { "MOD", "MOD", 39, 39, 2, 2, V, { V }, 0 }, - { "DCOUNT", "DCOUNT", 40, 40, 3, 3, V, { R }, 0 }, - { "DSUM", "DSUM", 41, 41, 3, 3, V, { R }, 0 }, - { "DAVERAGE", "DAVERAGE", 42, 42, 3, 3, V, { R }, 0 }, - { "DMIN", "DMIN", 43, 43, 3, 3, V, { R }, 0 }, - { "DMAX", "DMAX", 44, 44, 3, 3, V, { R }, 0 }, - { "DSTDEV", "DSTDEV", 45, 45, 3, 3, V, { R }, 0 }, - { "VAR", "VAR", 46, 46, 1, MX, V, { R }, 0 }, - { "DVAR", "DVAR", 47, 47, 3, 3, V, { R }, 0 }, - { "TEXT", "TEXT", 48, 48, 2, 2, V, { V }, 0 }, - { "LINEST", "LINEST", 49, 49, 1, 2, A, { R, R, C, C, I }, 0 }, - { "TREND", "TREND", 50, 50, 1, 3, A, { R, R, R, C, I }, 0 }, - { "LOGEST", "LOGEST", 51, 51, 1, 2, A, { R, R, C, C, I }, 0 }, - { "GROWTH", "GROWTH", 52, 52, 1, 3, A, { R, R, R, C, I }, 0 }, - { "PV", "PV", 56, 56, 3, 5, V, { V }, 0 }, - { "FV", "FV", 57, 57, 3, 5, V, { V }, 0 }, - { "NPER", "NPER", 58, 58, 3, 5, V, { V }, 0 }, - { "PMT", "PMT", 59, 59, 3, 5, V, { V }, 0 }, - { "RATE", "RATE", 60, 60, 3, 6, V, { V }, 0 }, - { "MIRR", "MIRR", 61, 61, 3, 3, V, { R, V }, 0 }, - { "IRR", "IRR", 62, 62, 1, 2, V, { R, V }, 0 }, - { "RAND", "RAND", 63, 63, 0, 0, V, {}, FUNCFLAG_VOLATILE }, - { "MATCH", "MATCH", 64, 64, 2, 3, V, { V, R }, 0 }, - { "DATE", "DATE", 65, 65, 3, 3, V, { V }, 0 }, - { "TIME", "TIME", 66, 66, 3, 3, V, { V }, 0 }, - { "DAY", "DAY", 67, 67, 1, 1, V, { V }, 0 }, - { "MONTH", "MONTH", 68, 68, 1, 1, V, { V }, 0 }, - { "YEAR", "YEAR", 69, 69, 1, 1, V, { V }, 0 }, - { "WEEKDAY", "WEEKDAY", 70, 70, 1, 1, V, { V, C, I }, 0 }, - { "HOUR", "HOUR", 71, 71, 1, 1, V, { V }, 0 }, - { "MINUTE", "MINUTE", 72, 72, 1, 1, V, { V }, 0 }, - { "SECOND", "SECOND", 73, 73, 1, 1, V, { V }, 0 }, - { "NOW", "NOW", 74, 74, 0, 0, V, {}, FUNCFLAG_VOLATILE }, - { "AREAS", "AREAS", 75, 75, 1, 1, V, { R }, 0 }, - { "ROWS", "ROWS", 76, 76, 1, 1, V, { R }, 0 }, - { "COLUMNS", "COLUMNS", 77, 77, 1, 1, V, { R }, 0 }, - { "OFFSET", "OFFSET", 78, 78, 3, 5, R, { R, V }, FUNCFLAG_VOLATILE }, - { "SEARCH", "SEARCH", 82, 82, 2, 3, V, { V }, 0 }, - { "TRANSPOSE", "TRANSPOSE", 83, 83, 1, 1, A, { A }, 0 }, - { "TYPE", "TYPE", 86, 86, 1, 1, V, { V }, 0 }, - { "ATAN2", "ATAN2", 97, 97, 2, 2, V, { V }, 0 }, - { "ASIN", "ASIN", 98, 98, 1, 1, V, { V }, 0 }, - { "ACOS", "ACOS", 99, 99, 1, 1, V, { V }, 0 }, - { "CHOOSE", "CHOOSE", 100, 100, 2, MX, R, { V, R }, 0 }, - { "HLOOKUP", "HLOOKUP", 101, 101, 3, 3, V, { V, R, R, C, I }, 0 }, - { "VLOOKUP", "VLOOKUP", 102, 102, 3, 3, V, { V, R, R, C, I }, 0 }, - { "ISREF", "ISREF", 105, 105, 1, 1, V, { R }, 0 }, - { "LOG", "LOG", 109, 109, 1, 2, V, { V }, 0 }, - { "CHAR", "CHAR", 111, 111, 1, 1, V, { V }, 0 }, - { "LOWER", "LOWER", 112, 112, 1, 1, V, { V }, 0 }, - { "UPPER", "UPPER", 113, 113, 1, 1, V, { V }, 0 }, - { "PROPER", "PROPER", 114, 114, 1, 1, V, { V }, 0 }, - { "LEFT", "LEFT", 115, 115, 1, 2, V, { V }, 0 }, - { "RIGHT", "RIGHT", 116, 116, 1, 2, V, { V }, 0 }, - { "EXACT", "EXACT", 117, 117, 2, 2, V, { V }, 0 }, - { "TRIM", "TRIM", 118, 118, 1, 1, V, { V }, 0 }, - { "REPLACE", "REPLACE", 119, 119, 4, 4, V, { V }, 0 }, - { "SUBSTITUTE", "SUBSTITUTE", 120, 120, 3, 4, V, { V }, 0 }, - { "CODE", "CODE", 121, 121, 1, 1, V, { V }, 0 }, - { "FIND", "FIND", 124, 124, 2, 3, V, { V }, 0 }, - { "CELL", "CELL", 125, 125, 1, 2, V, { V, R }, FUNCFLAG_VOLATILE }, - { "ISERR", "ISERR", 126, 126, 1, 1, V, { V }, 0 }, - { "ISTEXT", "ISTEXT", 127, 127, 1, 1, V, { V }, 0 }, - { "ISNUMBER", "ISNUMBER", 128, 128, 1, 1, V, { V }, 0 }, - { "ISBLANK", "ISBLANK", 129, 129, 1, 1, V, { V }, 0 }, - { "T", "T", 130, 130, 1, 1, V, { R }, 0 }, - { "N", "N", 131, 131, 1, 1, V, { R }, 0 }, - { "DATEVALUE", "DATEVALUE", 140, 140, 1, 1, V, { V }, 0 }, - { "TIMEVALUE", "TIMEVALUE", 141, 141, 1, 1, V, { V }, 0 }, - { "SLN", "SLN", 142, 142, 3, 3, V, { V }, 0 }, - { "SYD", "SYD", 143, 143, 4, 4, V, { V }, 0 }, - { "DDB", "DDB", 144, 144, 4, 5, V, { V }, 0 }, - { "INDIRECT", "INDIRECT", 148, 148, 1, 2, R, { V }, FUNCFLAG_VOLATILE }, - { "CLEAN", "CLEAN", 162, 162, 1, 1, V, { V }, 0 }, - { "MDETERM", "MDETERM", 163, 163, 1, 1, V, { A }, 0 }, - { "MINVERSE", "MINVERSE", 164, 164, 1, 1, A, { A }, 0 }, - { "MMULT", "MMULT", 165, 165, 2, 2, A, { A }, 0 }, - { "IPMT", "IPMT", 167, 167, 4, 6, V, { V }, 0 }, - { "PPMT", "PPMT", 168, 168, 4, 6, V, { V }, 0 }, - { "COUNTA", "COUNTA", 169, 169, 0, MX, V, { R }, 0 }, - { "PRODUCT", "PRODUCT", 183, 183, 0, MX, V, { R }, 0 }, - { "FACT", "FACT", 184, 184, 1, 1, V, { V }, 0 }, - { "DPRODUCT", "DPRODUCT", 189, 189, 3, 3, V, { R }, 0 }, - { "ISNONTEXT", "ISNONTEXT", 190, 190, 1, 1, V, { V }, 0 }, - { "STDEVP", "STDEVP", 193, 193, 1, MX, V, { R }, 0 }, - { "VARP", "VARP", 194, 194, 1, MX, V, { R }, 0 }, - { "DSTDEVP", "DSTDEVP", 195, 195, 3, 3, V, { R }, 0 }, - { "DVARP", "DVARP", 196, 196, 3, 3, V, { R }, 0 }, - { "TRUNC", "TRUNC", 197, 197, 1, 1, V, { V, C, I }, 0 }, - { "ISLOGICAL", "ISLOGICAL", 198, 198, 1, 1, V, { V }, 0 }, - { "DCOUNTA", "DCOUNTA", 199, 199, 3, 3, V, { R }, 0 }, - { 0, 0, 255, 255, 1, MX, R, { ER, R }, FUNCFLAG_IMPORTONLY } // EXTERNAL + { "COUNT", "COUNT", 0, 0, 0, MX, V, { R }, 0 }, + { "IF", "IF", 1, 1, 2, 3, R, { V, R }, 0 }, + { "ISNA", "ISNA", 2, 2, 1, 1, V, { V }, 0 }, + { "ISERROR", "ISERROR", 3, 3, 1, 1, V, { V }, 0 }, + { "SUM", "SUM", 4, 4, 0, MX, V, { R }, 0 }, + { "AVERAGE", "AVERAGE", 5, 5, 1, MX, V, { R }, 0 }, + { "MIN", "MIN", 6, 6, 1, MX, V, { R }, 0 }, + { "MAX", "MAX", 7, 7, 1, MX, V, { R }, 0 }, + { "ROW", "ROW", 8, 8, 0, 1, V, { R }, 0 }, + { "COLUMN", "COLUMN", 9, 9, 0, 1, V, { R }, 0 }, + { "NA", "NA", 10, 10, 0, 0, V, {}, 0 }, + { "NPV", "NPV", 11, 11, 2, MX, V, { V, R }, 0 }, + { "STDEV", "STDEV", 12, 12, 1, MX, V, { R }, 0 }, + { "DOLLAR", "DOLLAR", 13, 13, 1, 2, V, { V }, 0 }, + { "FIXED", "FIXED", 14, 14, 1, 2, V, { V, V, C, I }, 0 }, + { "SIN", "SIN", 15, 15, 1, 1, V, { V }, 0 }, + { "COS", "COS", 16, 16, 1, 1, V, { V }, 0 }, + { "TAN", "TAN", 17, 17, 1, 1, V, { V }, 0 }, + { "COT", "TAN", 17, 17, 1, 1, V, { V }, FUNCFLAG_EXPORTONLY }, + { "ATAN", "ATAN", 18, 18, 1, 1, V, { V }, 0 }, + { "ACOT", "ATAN", 18, 18, 1, 1, V, { V }, FUNCFLAG_EXPORTONLY }, + { "PI", "PI", 19, 19, 0, 0, V, {}, 0 }, + { "SQRT", "SQRT", 20, 20, 1, 1, V, { V }, 0 }, + { "EXP", "EXP", 21, 21, 1, 1, V, { V }, 0 }, + { "LN", "LN", 22, 22, 1, 1, V, { V }, 0 }, + { "LOG10", "LOG10", 23, 23, 1, 1, V, { V }, 0 }, + { "ABS", "ABS", 24, 24, 1, 1, V, { V }, 0 }, + { "INT", "INT", 25, 25, 1, 1, V, { V }, 0 }, + { "SIGN", "SIGN", 26, 26, 1, 1, V, { V }, 0 }, + { "ROUND", "ROUND", 27, 27, 2, 2, V, { V }, 0 }, + { "LOOKUP", "LOOKUP", 28, 28, 2, 3, V, { V, R }, 0 }, + { "INDEX", "INDEX", 29, 29, 2, 4, R, { R, V }, 0 }, + { "REPT", "REPT", 30, 30, 2, 2, V, { V }, 0 }, + { "MID", "MID", 31, 31, 3, 3, V, { V }, 0 }, + { "LEN", "LEN", 32, 32, 1, 1, V, { V }, 0 }, + { "VALUE", "VALUE", 33, 33, 1, 1, V, { V }, 0 }, + { "TRUE", "TRUE", 34, 34, 0, 0, V, {}, 0 }, + { "FALSE", "FALSE", 35, 35, 0, 0, V, {}, 0 }, + { "AND", "AND", 36, 36, 1, MX, V, { R }, 0 }, + { "OR", "OR", 37, 37, 1, MX, V, { R }, 0 }, + { "NOT", "NOT", 38, 38, 1, 1, V, { V }, 0 }, + { "MOD", "MOD", 39, 39, 2, 2, V, { V }, 0 }, + { "DCOUNT", "DCOUNT", 40, 40, 3, 3, V, { R }, 0 }, + { "DSUM", "DSUM", 41, 41, 3, 3, V, { R }, 0 }, + { "DAVERAGE", "DAVERAGE", 42, 42, 3, 3, V, { R }, 0 }, + { "DMIN", "DMIN", 43, 43, 3, 3, V, { R }, 0 }, + { "DMAX", "DMAX", 44, 44, 3, 3, V, { R }, 0 }, + { "DSTDEV", "DSTDEV", 45, 45, 3, 3, V, { R }, 0 }, + { "VAR", "VAR", 46, 46, 1, MX, V, { R }, 0 }, + { "DVAR", "DVAR", 47, 47, 3, 3, V, { R }, 0 }, + { "TEXT", "TEXT", 48, 48, 2, 2, V, { V }, 0 }, + { "LINEST", "LINEST", 49, 49, 1, 2, A, { R, R, C, C, I }, 0 }, + { "TREND", "TREND", 50, 50, 1, 3, A, { R, R, R, C, I }, 0 }, + { "LOGEST", "LOGEST", 51, 51, 1, 2, A, { R, R, C, C, I }, 0 }, + { "GROWTH", "GROWTH", 52, 52, 1, 3, A, { R, R, R, C, I }, 0 }, + { 0, "RETURN", 55, 55, 0, 1, R, { R }, FUNCFLAG_MACROFUNC }, + { "PV", "PV", 56, 56, 3, 5, V, { V }, 0 }, + { "FV", "FV", 57, 57, 3, 5, V, { V }, 0 }, + { "NPER", "NPER", 58, 58, 3, 5, V, { V }, 0 }, + { "PMT", "PMT", 59, 59, 3, 5, V, { V }, 0 }, + { "RATE", "RATE", 60, 60, 3, 6, V, { V }, 0 }, + { "MIRR", "MIRR", 61, 61, 3, 3, V, { R, V }, 0 }, + { "IRR", "IRR", 62, 62, 1, 2, V, { R, V }, 0 }, + { "RAND", "RAND", 63, 63, 0, 0, V, {}, FUNCFLAG_VOLATILE }, + { "MATCH", "MATCH", 64, 64, 2, 3, V, { V, R }, 0 }, + { "DATE", "DATE", 65, 65, 3, 3, V, { V }, 0 }, + { "TIME", "TIME", 66, 66, 3, 3, V, { V }, 0 }, + { "DAY", "DAY", 67, 67, 1, 1, V, { V }, 0 }, + { "MONTH", "MONTH", 68, 68, 1, 1, V, { V }, 0 }, + { "YEAR", "YEAR", 69, 69, 1, 1, V, { V }, 0 }, + { "WEEKDAY", "WEEKDAY", 70, 70, 1, 1, V, { V, C, I }, 0 }, + { "HOUR", "HOUR", 71, 71, 1, 1, V, { V }, 0 }, + { "MINUTE", "MINUTE", 72, 72, 1, 1, V, { V }, 0 }, + { "SECOND", "SECOND", 73, 73, 1, 1, V, { V }, 0 }, + { "NOW", "NOW", 74, 74, 0, 0, V, {}, FUNCFLAG_VOLATILE }, + { "AREAS", "AREAS", 75, 75, 1, 1, V, { R }, 0 }, + { "ROWS", "ROWS", 76, 76, 1, 1, V, { R }, 0 }, + { "COLUMNS", "COLUMNS", 77, 77, 1, 1, V, { R }, 0 }, + { "OFFSET", "OFFSET", 78, 78, 3, 5, R, { R, V }, FUNCFLAG_VOLATILE }, + { 0, "ABSREF", 79, 79, 2, 2, R, { V, R }, FUNCFLAG_MACROFUNC }, + { "SEARCH", "SEARCH", 82, 82, 2, 3, V, { V }, 0 }, + { "TRANSPOSE", "TRANSPOSE", 83, 83, 1, 1, A, { A }, 0 }, + { "TYPE", "TYPE", 86, 86, 1, 1, V, { V }, 0 }, + { 0, "ACTIVE.CELL", 94, 94, 0, 0, R, {}, FUNCFLAG_MACROFUNC }, + { "ATAN2", "ATAN2", 97, 97, 2, 2, V, { V }, 0 }, + { "ASIN", "ASIN", 98, 98, 1, 1, V, { V }, 0 }, + { "ACOS", "ACOS", 99, 99, 1, 1, V, { V }, 0 }, + { "CHOOSE", "CHOOSE", 100, 100, 2, MX, R, { V, R }, 0 }, + { "HLOOKUP", "HLOOKUP", 101, 101, 3, 3, V, { V, R, R, C, I }, 0 }, + { "VLOOKUP", "VLOOKUP", 102, 102, 3, 3, V, { V, R, R, C, I }, 0 }, + { "ISREF", "ISREF", 105, 105, 1, 1, V, { R }, 0 }, + { "LOG", "LOG", 109, 109, 1, 2, V, { V }, 0 }, + { "CHAR", "CHAR", 111, 111, 1, 1, V, { V }, 0 }, + { "LOWER", "LOWER", 112, 112, 1, 1, V, { V }, 0 }, + { "UPPER", "UPPER", 113, 113, 1, 1, V, { V }, 0 }, + { "PROPER", "PROPER", 114, 114, 1, 1, V, { V }, 0 }, + { "LEFT", "LEFT", 115, 115, 1, 2, V, { V }, 0 }, + { "RIGHT", "RIGHT", 116, 116, 1, 2, V, { V }, 0 }, + { "EXACT", "EXACT", 117, 117, 2, 2, V, { V }, 0 }, + { "TRIM", "TRIM", 118, 118, 1, 1, V, { V }, 0 }, + { "REPLACE", "REPLACE", 119, 119, 4, 4, V, { V }, 0 }, + { "SUBSTITUTE", "SUBSTITUTE", 120, 120, 3, 4, V, { V }, 0 }, + { "CODE", "CODE", 121, 121, 1, 1, V, { V }, 0 }, + { "FIND", "FIND", 124, 124, 2, 3, V, { V }, 0 }, + { "CELL", "CELL", 125, 125, 1, 2, V, { V, R }, FUNCFLAG_VOLATILE }, + { "ISERR", "ISERR", 126, 126, 1, 1, V, { V }, 0 }, + { "ISTEXT", "ISTEXT", 127, 127, 1, 1, V, { V }, 0 }, + { "ISNUMBER", "ISNUMBER", 128, 128, 1, 1, V, { V }, 0 }, + { "ISBLANK", "ISBLANK", 129, 129, 1, 1, V, { V }, 0 }, + { "T", "T", 130, 130, 1, 1, V, { R }, 0 }, + { "N", "N", 131, 131, 1, 1, V, { R }, 0 }, + { "DATEVALUE", "DATEVALUE", 140, 140, 1, 1, V, { V }, 0 }, + { "TIMEVALUE", "TIMEVALUE", 141, 141, 1, 1, V, { V }, 0 }, + { "SLN", "SLN", 142, 142, 3, 3, V, { V }, 0 }, + { "SYD", "SYD", 143, 143, 4, 4, V, { V }, 0 }, + { "DDB", "DDB", 144, 144, 4, 5, V, { V }, 0 }, + { "INDIRECT", "INDIRECT", 148, 148, 1, 2, R, { V }, FUNCFLAG_VOLATILE }, + { 0, "ADD.BAR", 151, 151, 0, 0, V, {}, FUNCFLAG_MACROFUNC | FUNCFLAG_ALWAYSVAR }, + { 0, "ADD.MENU", 152, 152, 2, 2, V, { V, R }, FUNCFLAG_MACROFUNC | FUNCFLAG_ALWAYSVAR }, + { 0, "ADD.COMMAND", 153, 153, 3, 3, V, { V, R }, FUNCFLAG_MACROFUNC | FUNCFLAG_ALWAYSVAR }, + { "CLEAN", "CLEAN", 162, 162, 1, 1, V, { V }, 0 }, + { "MDETERM", "MDETERM", 163, 163, 1, 1, V, { A }, 0 }, + { "MINVERSE", "MINVERSE", 164, 164, 1, 1, A, { A }, 0 }, + { "MMULT", "MMULT", 165, 165, 2, 2, A, { A }, 0 }, + { "IPMT", "IPMT", 167, 167, 4, 6, V, { V }, 0 }, + { "PPMT", "PPMT", 168, 168, 4, 6, V, { V }, 0 }, + { "COUNTA", "COUNTA", 169, 169, 0, MX, V, { R }, 0 }, + { "PRODUCT", "PRODUCT", 183, 183, 0, MX, V, { R }, 0 }, + { "FACT", "FACT", 184, 184, 1, 1, V, { V }, 0 }, + { "DPRODUCT", "DPRODUCT", 189, 189, 3, 3, V, { R }, 0 }, + { "ISNONTEXT", "ISNONTEXT", 190, 190, 1, 1, V, { V }, 0 }, + { "STDEVP", "STDEVP", 193, 193, 1, MX, V, { R }, 0 }, + { "VARP", "VARP", 194, 194, 1, MX, V, { R }, 0 }, + { "DSTDEVP", "DSTDEVP", 195, 195, 3, 3, V, { R }, 0 }, + { "DVARP", "DVARP", 196, 196, 3, 3, V, { R }, 0 }, + { "TRUNC", "TRUNC", 197, 197, 1, 1, V, { V, C, I }, 0 }, + { "ISLOGICAL", "ISLOGICAL", 198, 198, 1, 1, V, { V }, 0 }, + { "DCOUNTA", "DCOUNTA", 199, 199, 3, 3, V, { R }, 0 }, + { 0, "EXTERN.CALL", 255, 255, 1, MX, R, { ER, R }, FUNCFLAG_IMPORTONLY }, + + // *** macro sheet commands *** + + { 0, "A1.R1C1", 30, 30, 0, 1, V, { V }, FUNCFLAG_MACROCMD }, + { 0, "ADD.ARROW", 81, 81, 0, 0, V, {}, FUNCFLAG_MACROCMD }, + { 0, "ACTIVATE", 103, 103, 0, 2, V, { V }, FUNCFLAG_MACROCMD }, + { 0, "ACTIVATE.NEXT", 104, 104, 0, 0, V, {}, FUNCFLAG_MACROCMD }, + { 0, "ACTIVATE.PREV", 105, 105, 0, 0, V, {}, FUNCFLAG_MACROCMD } }; /** Functions new in BIFF3. */ static const FunctionData saFuncTableBiff3[] = { - { "LINEST", "LINEST", 49, 49, 1, 4, A, { R, R, V, V }, 0 }, // BIFF2: 1-2, BIFF3: 1-4, - { "TREND", "TREND", 50, 50, 1, 4, A, { R, R, R, V }, 0 }, // BIFF2: 1-3, BIFF3: 1-4 - { "LOGEST", "LOGEST", 51, 51, 1, 4, A, { R, R, V, V }, 0 }, // BIFF2: 1-2, BIFF3: 1-4, - { "GROWTH", "GROWTH", 52, 52, 1, 4, A, { R, R, R, V }, 0 }, // BIFF2: 1-3, BIFF3: 1-4 - { "TRUNC", "TRUNC", 197, 197, 1, 2, V, { V }, 0 }, // BIFF2: 1, BIFF3: 1-2 - { "DOLLAR", "USDOLLAR", 204, 204, 1, 2, V, { V }, FUNCFLAG_IMPORTONLY }, - { 0/*"FIND"*/, "FINDB", 205, 205, 2, 3, V, { V }, 0 }, - { 0/*"SEARCH"*/, "SEARCHB", 206, 206, 2, 3, V, { V }, 0 }, - { 0/*"REPLACE"*/, "REPLACEB", 207, 207, 4, 4, V, { V }, 0 }, - { 0/*"LEFT"*/, "LEFTB", 208, 208, 1, 2, V, { V }, 0 }, - { 0/*"RIGHT"*/, "RIGHTB", 209, 209, 1, 2, V, { V }, 0 }, - { 0/*"MID"*/, "MIDB", 210, 210, 3, 3, V, { V }, 0 }, - { 0/*"LEN"*/, "LENB", 211, 211, 1, 1, V, { V }, 0 }, - { "ROUNDUP", "ROUNDUP", 212, 212, 2, 2, V, { V }, 0 }, - { "ROUNDDOWN", "ROUNDDOWN", 213, 213, 2, 2, V, { V }, 0 }, - { "ASC", "ASC", 214, 214, 1, 1, V, { V }, 0 }, - { "JIS", "DBCS", 215, 215, 1, 1, V, { V }, 0 }, - { "ADDRESS", "ADDRESS", 219, 219, 2, 5, V, { V }, 0 }, - { "DAYS360", "DAYS360", 220, 220, 2, 2, V, { V, V, C, I }, 0 }, - { "TODAY", "TODAY", 221, 221, 0, 0, V, {}, FUNCFLAG_VOLATILE }, - { "VDB", "VDB", 222, 222, 5, 7, V, { V }, 0 }, - { "MEDIAN", "MEDIAN", 227, 227, 1, MX, V, { R }, 0 }, - { "SUMPRODUCT", "SUMPRODUCT", 228, 228, 1, MX, V, { A }, 0 }, - { "SINH", "SINH", 229, 229, 1, 1, V, { V }, 0 }, - { "COSH", "COSH", 230, 230, 1, 1, V, { V }, 0 }, - { "TANH", "TANH", 231, 231, 1, 1, V, { V }, 0 }, - { "COTH", "TANH", 231, 231, 1, 1, V, { V }, FUNCFLAG_EXPORTONLY }, - { "ASINH", "ASINH", 232, 232, 1, 1, V, { V }, 0 }, - { "ACOSH", "ACOSH", 233, 233, 1, 1, V, { V }, 0 }, - { "ATANH", "ATANH", 234, 234, 1, 1, V, { V }, 0 }, - { "ACOTH", "ATANH", 234, 234, 1, 1, V, { V }, FUNCFLAG_EXPORTONLY }, - { "DGET", "DGET", 235, 235, 3, 3, V, { R }, 0 }, - { "INFO", "INFO", 244, 244, 1, 1, V, { V }, FUNCFLAG_VOLATILE } + { "LINEST", "LINEST", 49, 49, 1, 4, A, { R, R, V, V }, 0 }, // BIFF2: 1-2, BIFF3: 1-4 + { "TREND", "TREND", 50, 50, 1, 4, A, { R, R, R, V }, 0 }, // BIFF2: 1-3, BIFF3: 1-4 + { "LOGEST", "LOGEST", 51, 51, 1, 4, A, { R, R, V, V }, 0 }, // BIFF2: 1-2, BIFF3: 1-4 + { "GROWTH", "GROWTH", 52, 52, 1, 4, A, { R, R, R, V }, 0 }, // BIFF2: 1-3, BIFF3: 1-4 + { 0, "ADD.BAR", 151, 151, 0, 1, V, { V }, FUNCFLAG_MACROFUNC }, // BIFF2: 0, BIFF3: 0-1 + { 0, "ADD.MENU", 152, 152, 2, 3, V, { V, R }, FUNCFLAG_MACROFUNC }, // BIFF2: 2, BIFF3: 2-3 + { 0, "ADD.COMMAND", 153, 153, 3, 4, V, { V, R }, FUNCFLAG_MACROFUNC }, // BIFF2: 3, BIFF3: 3-4 + { "TRUNC", "TRUNC", 197, 197, 1, 2, V, { V }, 0 }, // BIFF2: 1, BIFF3: 1-2 + { "DOLLAR", "USDOLLAR", 204, 204, 1, 2, V, { V }, FUNCFLAG_IMPORTONLY }, + { 0/*"FIND"*/, "FINDB", 205, 205, 2, 3, V, { V }, 0 }, + { 0/*"SEARCH"*/, "SEARCHB", 206, 206, 2, 3, V, { V }, 0 }, + { 0/*"REPLACE"*/, "REPLACEB", 207, 207, 4, 4, V, { V }, 0 }, + { 0/*"LEFT"*/, "LEFTB", 208, 208, 1, 2, V, { V }, 0 }, + { 0/*"RIGHT"*/, "RIGHTB", 209, 209, 1, 2, V, { V }, 0 }, + { 0/*"MID"*/, "MIDB", 210, 210, 3, 3, V, { V }, 0 }, + { 0/*"LEN"*/, "LENB", 211, 211, 1, 1, V, { V }, 0 }, + { "ROUNDUP", "ROUNDUP", 212, 212, 2, 2, V, { V }, 0 }, + { "ROUNDDOWN", "ROUNDDOWN", 213, 213, 2, 2, V, { V }, 0 }, + { "ASC", "ASC", 214, 214, 1, 1, V, { V }, 0 }, + { "JIS", "DBCS", 215, 215, 1, 1, V, { V }, 0 }, + { "ADDRESS", "ADDRESS", 219, 219, 2, 5, V, { V }, 0 }, + { "DAYS360", "DAYS360", 220, 220, 2, 2, V, { V, V, C, I }, 0 }, + { "TODAY", "TODAY", 221, 221, 0, 0, V, {}, FUNCFLAG_VOLATILE }, + { "VDB", "VDB", 222, 222, 5, 7, V, { V }, 0 }, + { "MEDIAN", "MEDIAN", 227, 227, 1, MX, V, { R }, 0 }, + { "SUMPRODUCT", "SUMPRODUCT", 228, 228, 1, MX, V, { A }, 0 }, + { "SINH", "SINH", 229, 229, 1, 1, V, { V }, 0 }, + { "COSH", "COSH", 230, 230, 1, 1, V, { V }, 0 }, + { "TANH", "TANH", 231, 231, 1, 1, V, { V }, 0 }, + { "COTH", "TANH", 231, 231, 1, 1, V, { V }, FUNCFLAG_EXPORTONLY }, + { "ASINH", "ASINH", 232, 232, 1, 1, V, { V }, 0 }, + { "ACOSH", "ACOSH", 233, 233, 1, 1, V, { V }, 0 }, + { "ATANH", "ATANH", 234, 234, 1, 1, V, { V }, 0 }, + { "ACOTH", "ATANH", 234, 234, 1, 1, V, { V }, FUNCFLAG_EXPORTONLY }, + { "DGET", "DGET", 235, 235, 3, 3, V, { R }, 0 }, + { "INFO", "INFO", 244, 244, 1, 1, V, { V }, FUNCFLAG_VOLATILE } }; /** Functions new in BIFF4. */ static const FunctionData saFuncTableBiff4[] = { - { "FIXED", "FIXED", 14, 14, 1, 3, V, { V }, 0 }, // BIFF2-3: 1-2, BIFF4: 1-3 - { "RANK", "RANK", 216, 216, 2, 3, V, { V, R, V }, 0 }, - { "DB", "DB", 247, 247, 4, 5, V, { V }, 0 }, - { "FREQUENCY", "FREQUENCY", 252, 252, 2, 2, A, { R }, 0 }, - { "ORG.OPENOFFICE.ERRORTYPE","ERROR.TYPE", 261, 261, 1, 1, V, { V }, 0 }, - { "AVEDEV", "AVEDEV", 269, 269, 1, MX, V, { R }, 0 }, - { "BETADIST", "BETADIST", 270, 270, 3, 5, V, { V }, 0 }, - { "GAMMALN", "GAMMALN", 271, 271, 1, 1, V, { V }, 0 }, - { "BETAINV", "BETAINV", 272, 272, 3, 5, V, { V }, 0 }, - { "BINOMDIST", "BINOMDIST", 273, 273, 4, 4, V, { V }, 0 }, - { "LEGACY.CHIDIST", "CHIDIST", 274, 274, 2, 2, V, { V }, 0 }, - { "LEGACY.CHIINV", "CHIINV", 275, 275, 2, 2, V, { V }, 0 }, - { "COMBIN", "COMBIN", 276, 276, 2, 2, V, { V }, 0 }, - { "CONFIDENCE", "CONFIDENCE", 277, 277, 3, 3, V, { V }, 0 }, - { "CRITBINOM", "CRITBINOM", 278, 278, 3, 3, V, { V }, 0 }, - { "EVEN", "EVEN", 279, 279, 1, 1, V, { V }, 0 }, - { "EXPONDIST", "EXPONDIST", 280, 280, 3, 3, V, { V }, 0 }, - { "LEGACY.FDIST", "FDIST", 281, 281, 3, 3, V, { V }, 0 }, - { "LEGACY.FINV", "FINV", 282, 282, 3, 3, V, { V }, 0 }, - { "FISHER", "FISHER", 283, 283, 1, 1, V, { V }, 0 }, - { "FISHERINV", "FISHERINV", 284, 284, 1, 1, V, { V }, 0 }, - { "FLOOR", "FLOOR", 285, 285, 2, 2, V, { V, V, C, I }, 0 }, - { "GAMMADIST", "GAMMADIST", 286, 286, 4, 4, V, { V }, 0 }, - { "GAMMAINV", "GAMMAINV", 287, 287, 3, 3, V, { V }, 0 }, - { "CEILING", "CEILING", 288, 288, 2, 2, V, { V, V, C, I }, 0 }, - { "HYPGEOMDIST", "HYPGEOMDIST", 289, 289, 4, 4, V, { V }, 0 }, - { "LOGNORMDIST", "LOGNORMDIST", 290, 290, 3, 3, V, { V }, 0 }, - { "LOGINV", "LOGINV", 291, 291, 3, 3, V, { V }, 0 }, - { "NEGBINOMDIST", "NEGBINOMDIST", 292, 292, 3, 3, V, { V }, 0 }, - { "NORMDIST", "NORMDIST", 293, 293, 4, 4, V, { V }, 0 }, - { "LEGACY.NORMSDIST", "NORMSDIST", 294, 294, 1, 1, V, { V }, 0 }, - { "NORMINV", "NORMINV", 295, 295, 3, 3, V, { V }, 0 }, - { "LEGACY.NORMSINV", "NORMSINV", 296, 296, 1, 1, V, { V }, 0 }, - { "STANDARDIZE", "STANDARDIZE", 297, 297, 3, 3, V, { V }, 0 }, - { "ODD", "ODD", 298, 298, 1, 1, V, { V }, 0 }, - { "PERMUT", "PERMUT", 299, 299, 2, 2, V, { V }, 0 }, - { "POISSON", "POISSON", 300, 300, 3, 3, V, { V }, 0 }, - { "TDIST", "TDIST", 301, 301, 3, 3, V, { V }, 0 }, - { "WEIBULL", "WEIBULL", 302, 302, 4, 4, V, { V }, 0 }, - { "SUMXMY2", "SUMXMY2", 303, 303, 2, 2, V, { A }, 0 }, - { "SUMX2MY2", "SUMX2MY2", 304, 304, 2, 2, V, { A }, 0 }, - { "SUMX2PY2", "SUMX2PY2", 305, 305, 2, 2, V, { A }, 0 }, - { "LEGACY.CHITEST", "CHITEST", 306, 306, 2, 2, V, { A }, 0 }, - { "CORREL", "CORREL", 307, 307, 2, 2, V, { A }, 0 }, - { "COVAR", "COVAR", 308, 308, 2, 2, V, { A }, 0 }, - { "FORECAST", "FORECAST", 309, 309, 3, 3, V, { V, A }, 0 }, - { "FTEST", "FTEST", 310, 310, 2, 2, V, { A }, 0 }, - { "INTERCEPT", "INTERCEPT", 311, 311, 2, 2, V, { A }, 0 }, - { "PEARSON", "PEARSON", 312, 312, 2, 2, V, { A }, 0 }, - { "RSQ", "RSQ", 313, 313, 2, 2, V, { A }, 0 }, - { "STEYX", "STEYX", 314, 314, 2, 2, V, { A }, 0 }, - { "SLOPE", "SLOPE", 315, 315, 2, 2, V, { A }, 0 }, - { "TTEST", "TTEST", 316, 316, 4, 4, V, { A, A, V }, 0 }, - { "PROB", "PROB", 317, 317, 3, 4, V, { A, A, V }, 0 }, - { "DEVSQ", "DEVSQ", 318, 318, 1, MX, V, { R }, 0 }, - { "GEOMEAN", "GEOMEAN", 319, 319, 1, MX, V, { R }, 0 }, - { "HARMEAN", "HARMEAN", 320, 320, 1, MX, V, { R }, 0 }, - { "SUMSQ", "SUMSQ", 321, 321, 0, MX, V, { R }, 0 }, - { "KURT", "KURT", 322, 322, 1, MX, V, { R }, 0 }, - { "SKEW", "SKEW", 323, 323, 1, MX, V, { R }, 0 }, - { "ZTEST", "ZTEST", 324, 324, 2, 3, V, { R, V }, 0 }, - { "LARGE", "LARGE", 325, 325, 2, 2, V, { R, V }, 0 }, - { "SMALL", "SMALL", 326, 326, 2, 2, V, { R, V }, 0 }, - { "QUARTILE", "QUARTILE", 327, 327, 2, 2, V, { R, V }, 0 }, - { "PERCENTILE", "PERCENTILE", 328, 328, 2, 2, V, { R, V }, 0 }, - { "PERCENTRANK", "PERCENTRANK", 329, 329, 2, 3, V, { R, V, EV, I }, 0 }, - { "MODE", "MODE", 330, 330, 1, MX, V, { A }, 0 }, - { "TRIMMEAN", "TRIMMEAN", 331, 331, 2, 2, V, { R, V }, 0 }, - { "TINV", "TINV", 332, 332, 2, 2, V, { V }, 0 }, + { "FIXED", "FIXED", 14, 14, 1, 3, V, { V }, 0 }, // BIFF2-3: 1-2, BIFF4: 1-3 + { "RANK", "RANK", 216, 216, 2, 3, V, { V, R, V }, 0 }, + { "DB", "DB", 247, 247, 4, 5, V, { V }, 0 }, + { "FREQUENCY", "FREQUENCY", 252, 252, 2, 2, A, { R }, 0 }, + { "ORG.OPENOFFICE.ERRORTYPE","ERROR.TYPE", 261, 261, 1, 1, V, { V }, 0 }, + { "AVEDEV", "AVEDEV", 269, 269, 1, MX, V, { R }, 0 }, + { "BETADIST", "BETADIST", 270, 270, 3, 5, V, { V }, 0 }, + { "GAMMALN", "GAMMALN", 271, 271, 1, 1, V, { V }, 0 }, + { "BETAINV", "BETAINV", 272, 272, 3, 5, V, { V }, 0 }, + { "BINOMDIST", "BINOMDIST", 273, 273, 4, 4, V, { V }, 0 }, + { "LEGACY.CHIDIST", "CHIDIST", 274, 274, 2, 2, V, { V }, 0 }, + { "LEGACY.CHIINV", "CHIINV", 275, 275, 2, 2, V, { V }, 0 }, + { "COMBIN", "COMBIN", 276, 276, 2, 2, V, { V }, 0 }, + { "CONFIDENCE", "CONFIDENCE", 277, 277, 3, 3, V, { V }, 0 }, + { "CRITBINOM", "CRITBINOM", 278, 278, 3, 3, V, { V }, 0 }, + { "EVEN", "EVEN", 279, 279, 1, 1, V, { V }, 0 }, + { "EXPONDIST", "EXPONDIST", 280, 280, 3, 3, V, { V }, 0 }, + { "LEGACY.FDIST", "FDIST", 281, 281, 3, 3, V, { V }, 0 }, + { "LEGACY.FINV", "FINV", 282, 282, 3, 3, V, { V }, 0 }, + { "FISHER", "FISHER", 283, 283, 1, 1, V, { V }, 0 }, + { "FISHERINV", "FISHERINV", 284, 284, 1, 1, V, { V }, 0 }, + { "FLOOR", "FLOOR", 285, 285, 2, 2, V, { V, V, C, I }, 0 }, + { "GAMMADIST", "GAMMADIST", 286, 286, 4, 4, V, { V }, 0 }, + { "GAMMAINV", "GAMMAINV", 287, 287, 3, 3, V, { V }, 0 }, + { "CEILING", "CEILING", 288, 288, 2, 2, V, { V, V, C, I }, 0 }, + { "HYPGEOMDIST", "HYPGEOMDIST", 289, 289, 4, 4, V, { V }, 0 }, + { "LOGNORMDIST", "LOGNORMDIST", 290, 290, 3, 3, V, { V }, 0 }, + { "LOGINV", "LOGINV", 291, 291, 3, 3, V, { V }, 0 }, + { "NEGBINOMDIST", "NEGBINOMDIST", 292, 292, 3, 3, V, { V }, 0 }, + { "NORMDIST", "NORMDIST", 293, 293, 4, 4, V, { V }, 0 }, + { "LEGACY.NORMSDIST", "NORMSDIST", 294, 294, 1, 1, V, { V }, 0 }, + { "NORMINV", "NORMINV", 295, 295, 3, 3, V, { V }, 0 }, + { "LEGACY.NORMSINV", "NORMSINV", 296, 296, 1, 1, V, { V }, 0 }, + { "STANDARDIZE", "STANDARDIZE", 297, 297, 3, 3, V, { V }, 0 }, + { "ODD", "ODD", 298, 298, 1, 1, V, { V }, 0 }, + { "PERMUT", "PERMUT", 299, 299, 2, 2, V, { V }, 0 }, + { "POISSON", "POISSON", 300, 300, 3, 3, V, { V }, 0 }, + { "TDIST", "TDIST", 301, 301, 3, 3, V, { V }, 0 }, + { "WEIBULL", "WEIBULL", 302, 302, 4, 4, V, { V }, 0 }, + { "SUMXMY2", "SUMXMY2", 303, 303, 2, 2, V, { A }, 0 }, + { "SUMX2MY2", "SUMX2MY2", 304, 304, 2, 2, V, { A }, 0 }, + { "SUMX2PY2", "SUMX2PY2", 305, 305, 2, 2, V, { A }, 0 }, + { "LEGACY.CHITEST", "CHITEST", 306, 306, 2, 2, V, { A }, 0 }, + { "CORREL", "CORREL", 307, 307, 2, 2, V, { A }, 0 }, + { "COVAR", "COVAR", 308, 308, 2, 2, V, { A }, 0 }, + { "FORECAST", "FORECAST", 309, 309, 3, 3, V, { V, A }, 0 }, + { "FTEST", "FTEST", 310, 310, 2, 2, V, { A }, 0 }, + { "INTERCEPT", "INTERCEPT", 311, 311, 2, 2, V, { A }, 0 }, + { "PEARSON", "PEARSON", 312, 312, 2, 2, V, { A }, 0 }, + { "RSQ", "RSQ", 313, 313, 2, 2, V, { A }, 0 }, + { "STEYX", "STEYX", 314, 314, 2, 2, V, { A }, 0 }, + { "SLOPE", "SLOPE", 315, 315, 2, 2, V, { A }, 0 }, + { "TTEST", "TTEST", 316, 316, 4, 4, V, { A, A, V }, 0 }, + { "PROB", "PROB", 317, 317, 3, 4, V, { A, A, V }, 0 }, + { "DEVSQ", "DEVSQ", 318, 318, 1, MX, V, { R }, 0 }, + { "GEOMEAN", "GEOMEAN", 319, 319, 1, MX, V, { R }, 0 }, + { "HARMEAN", "HARMEAN", 320, 320, 1, MX, V, { R }, 0 }, + { "SUMSQ", "SUMSQ", 321, 321, 0, MX, V, { R }, 0 }, + { "KURT", "KURT", 322, 322, 1, MX, V, { R }, 0 }, + { "SKEW", "SKEW", 323, 323, 1, MX, V, { R }, 0 }, + { "ZTEST", "ZTEST", 324, 324, 2, 3, V, { R, V }, 0 }, + { "LARGE", "LARGE", 325, 325, 2, 2, V, { R, V }, 0 }, + { "SMALL", "SMALL", 326, 326, 2, 2, V, { R, V }, 0 }, + { "QUARTILE", "QUARTILE", 327, 327, 2, 2, V, { R, V }, 0 }, + { "PERCENTILE", "PERCENTILE", 328, 328, 2, 2, V, { R, V }, 0 }, + { "PERCENTRANK", "PERCENTRANK", 329, 329, 2, 3, V, { R, V, EV, I }, 0 }, + { "MODE", "MODE", 330, 330, 1, MX, V, { A }, 0 }, + { "TRIMMEAN", "TRIMMEAN", 331, 331, 2, 2, V, { R, V }, 0 }, + { "TINV", "TINV", 332, 332, 2, 2, V, { V }, 0 }, // *** Analysis add-in *** - { "HEX2BIN", "HEX2BIN", 384, NOID, 1, 2, V, { V }, FUNCFLAG_EXTERNAL }, - { "HEX2DEC", "HEX2DEC", 385, NOID, 1, 1, V, { V }, FUNCFLAG_EXTERNAL }, - { "HEX2OCT", "HEX2OCT", 386, NOID, 1, 2, V, { V }, FUNCFLAG_EXTERNAL }, - { "DEC2BIN", "DEC2BIN", 387, NOID, 1, 2, V, { V }, FUNCFLAG_EXTERNAL }, - { "DEC2HEX", "DEC2HEX", 388, NOID, 1, 2, V, { V }, FUNCFLAG_EXTERNAL }, - { "DEC2OCT", "DEC2OCT", 389, NOID, 1, 2, V, { V }, FUNCFLAG_EXTERNAL }, - { "OCT2BIN", "OCT2BIN", 390, NOID, 1, 2, V, { V }, FUNCFLAG_EXTERNAL }, - { "OCT2HEX", "OCT2HEX", 391, NOID, 1, 2, V, { V }, FUNCFLAG_EXTERNAL }, - { "OCT2DEC", "OCT2DEC", 392, NOID, 1, 1, V, { V }, FUNCFLAG_EXTERNAL }, - { "BIN2DEC", "BIN2DEC", 393, NOID, 1, 1, V, { V }, FUNCFLAG_EXTERNAL }, - { "BIN2OCT", "BIN2OCT", 394, NOID, 1, 2, V, { V }, FUNCFLAG_EXTERNAL }, - { "BIN2HEX", "BIN2HEX", 395, NOID, 1, 2, V, { V }, FUNCFLAG_EXTERNAL }, - { "IMSUB", "IMSUB", 396, NOID, 2, 2, V, { V }, FUNCFLAG_EXTERNAL }, - { "IMDIV", "IMDIV", 397, NOID, 2, 2, V, { V }, FUNCFLAG_EXTERNAL }, - { "IMPOWER", "IMPOWER", 398, NOID, 2, 2, V, { V }, FUNCFLAG_EXTERNAL }, - { "IMABS", "IMABS", 399, NOID, 1, 1, V, { V }, FUNCFLAG_EXTERNAL }, - { "IMSQRT", "IMSQRT", 400, NOID, 1, 1, V, { V }, FUNCFLAG_EXTERNAL }, - { "IMLN", "IMLN", 401, NOID, 1, 1, V, { V }, FUNCFLAG_EXTERNAL }, - { "IMLOG2", "IMLOG2", 402, NOID, 1, 1, V, { V }, FUNCFLAG_EXTERNAL }, - { "IMLOG10", "IMLOG10", 403, NOID, 1, 1, V, { V }, FUNCFLAG_EXTERNAL }, - { "IMSIN", "IMSIN", 404, NOID, 1, 1, V, { V }, FUNCFLAG_EXTERNAL }, - { "IMCOS", "IMCOS", 405, NOID, 1, 1, V, { V }, FUNCFLAG_EXTERNAL }, - { "IMEXP", "IMEXP", 406, NOID, 1, 1, V, { V }, FUNCFLAG_EXTERNAL }, - { "IMARGUMENT", "IMARGUMENT", 407, NOID, 1, 1, V, { V }, FUNCFLAG_EXTERNAL }, - { "IMCONJUGATE", "IMCONJUGATE", 408, NOID, 1, 1, V, { V }, FUNCFLAG_EXTERNAL }, - { "IMAGINARY", "IMAGINARY", 409, NOID, 1, 1, V, { V }, FUNCFLAG_EXTERNAL }, - { "IMREAL", "IMREAL", 410, NOID, 1, 1, V, { V }, FUNCFLAG_EXTERNAL }, - { "COMPLEX", "COMPLEX", 411, NOID, 2, 3, V, { V }, FUNCFLAG_EXTERNAL }, - { "IMSUM", "IMSUM", 412, NOID, 1, MX, V, { R }, FUNCFLAG_EXTERNAL }, - { "IMPRODUCT", "IMPRODUCT", 413, NOID, 1, MX, V, { R }, FUNCFLAG_EXTERNAL }, - { "SERIESSUM", "SERIESSUM", 414, NOID, 4, 4, V, { V, V, V, R }, FUNCFLAG_EXTERNAL }, - { "FACTDOUBLE", "FACTDOUBLE", 415, NOID, 1, 1, V, { V }, FUNCFLAG_EXTERNAL }, - { "SQRTPI", "SQRTPI", 416, NOID, 1, 1, V, { V }, FUNCFLAG_EXTERNAL }, - { "QUOTIENT", "QUOTIENT", 417, NOID, 2, 2, V, { V }, FUNCFLAG_EXTERNAL }, - { "DELTA", "DELTA", 418, NOID, 1, 2, V, { V }, FUNCFLAG_EXTERNAL }, - { "GESTEP", "GESTEP", 419, NOID, 1, 2, V, { V }, FUNCFLAG_EXTERNAL }, - { "ISEVEN", "ISEVEN", 420, NOID, 1, 1, V, { V }, FUNCFLAG_EXTERNAL }, // Calc: builtin and add-in - { "ISODD", "ISODD", 421, NOID, 1, 1, V, { V }, FUNCFLAG_EXTERNAL }, // Calc: builtin and add-in - { "MROUND", "MROUND", 422, NOID, 2, 2, V, { V }, FUNCFLAG_EXTERNAL }, - { "ERF", "ERF", 423, NOID, 1, 2, V, { V }, FUNCFLAG_EXTERNAL }, - { "ERFC", "ERFC", 424, NOID, 1, 1, V, { V }, FUNCFLAG_EXTERNAL }, - { "BESSELJ", "BESSELJ", 425, NOID, 2, 2, V, { V }, FUNCFLAG_EXTERNAL }, - { "BESSELK", "BESSELK", 426, NOID, 2, 2, V, { V }, FUNCFLAG_EXTERNAL }, - { "BESSELY", "BESSELY", 427, NOID, 2, 2, V, { V }, FUNCFLAG_EXTERNAL }, - { "BESSELI", "BESSELI", 428, NOID, 2, 2, V, { V }, FUNCFLAG_EXTERNAL }, - { "XIRR", "XIRR", 429, NOID, 2, 3, V, { A, R, V }, FUNCFLAG_EXTERNAL }, - { "XNPV", "XNPV", 430, NOID, 3, 3, V, { V, A, R }, FUNCFLAG_EXTERNAL }, - { "PRICEMAT", "PRICEMAT", 431, NOID, 5, 6, V, { V }, FUNCFLAG_EXTERNAL }, - { "YIELDMAT", "YIELDMAT", 432, NOID, 5, 6, V, { V }, FUNCFLAG_EXTERNAL }, - { "INTRATE", "INTRATE", 433, NOID, 4, 5, V, { V }, FUNCFLAG_EXTERNAL }, - { "RECEIVED", "RECEIVED", 434, NOID, 4, 5, V, { V }, FUNCFLAG_EXTERNAL }, - { "DISC", "DISC", 435, NOID, 4, 5, V, { V }, FUNCFLAG_EXTERNAL }, - { "PRICEDISC", "PRICEDISC", 436, NOID, 4, 5, V, { V }, FUNCFLAG_EXTERNAL }, - { "YIELDDISC", "YIELDDISC", 437, NOID, 4, 5, V, { V }, FUNCFLAG_EXTERNAL }, - { "TBILLEQ", "TBILLEQ", 438, NOID, 3, 3, V, { V }, FUNCFLAG_EXTERNAL }, - { "TBILLPRICE", "TBILLPRICE", 439, NOID, 3, 3, V, { V }, FUNCFLAG_EXTERNAL }, - { "TBILLYIELD", "TBILLYIELD", 440, NOID, 3, 3, V, { V }, FUNCFLAG_EXTERNAL }, - { "PRICE", "PRICE", 441, NOID, 6, 7, V, { V }, FUNCFLAG_EXTERNAL }, - { "YIELD", "YIELD", 442, NOID, 6, 7, V, { V }, FUNCFLAG_EXTERNAL }, - { "DOLLARDE", "DOLLARDE", 443, NOID, 2, 2, V, { V }, FUNCFLAG_EXTERNAL }, - { "DOLLARFR", "DOLLARFR", 444, NOID, 2, 2, V, { V }, FUNCFLAG_EXTERNAL }, - { "NOMINAL", "NOMINAL", 445, NOID, 2, 2, V, { V }, FUNCFLAG_EXTERNAL }, // Calc: builtin and add-in - { "EFFECT", "EFFECT", 446, NOID, 2, 2, V, { V }, FUNCFLAG_EXTERNAL }, // Calc: builtin and add-in - { "CUMPRINC", "CUMPRINC", 447, NOID, 6, 6, V, { V }, FUNCFLAG_EXTERNAL }, // Calc: builtin and add-in - { "CUMIPMT", "CUMIPMT", 448, NOID, 6, 6, V, { V }, FUNCFLAG_EXTERNAL }, // Calc: builtin and add-in - { "EDATE", "EDATE", 449, NOID, 2, 2, V, { V }, FUNCFLAG_EXTERNAL }, - { "EOMONTH", "EOMONTH", 450, NOID, 2, 2, V, { V }, FUNCFLAG_EXTERNAL }, - { "YEARFRAC", "YEARFRAC", 451, NOID, 2, 3, V, { V }, FUNCFLAG_EXTERNAL }, - { "COUPDAYBS", "COUPDAYBS", 452, NOID, 3, 4, V, { V }, FUNCFLAG_EXTERNAL }, - { "COUPDAYS", "COUPDAYS", 453, NOID, 3, 4, V, { V }, FUNCFLAG_EXTERNAL }, - { "COUPDAYSNC", "COUPDAYSNC", 454, NOID, 3, 4, V, { V }, FUNCFLAG_EXTERNAL }, - { "COUPNCD", "COUPNCD", 455, NOID, 3, 4, V, { V }, FUNCFLAG_EXTERNAL }, - { "COUPNUM", "COUPNUM", 456, NOID, 3, 4, V, { V }, FUNCFLAG_EXTERNAL }, - { "COUPPCD", "COUPPCD", 457, NOID, 3, 4, V, { V }, FUNCFLAG_EXTERNAL }, - { "DURATION", "DURATION", 458, NOID, 5, 6, V, { V }, FUNCFLAG_EXTERNAL }, // Calc: builtin and add-in - { "MDURATION", "MDURATION", 459, NOID, 5, 6, V, { V }, FUNCFLAG_EXTERNAL }, - { "ODDLPRICE", "ODDLPRICE", 460, NOID, 7, 8, V, { V }, FUNCFLAG_EXTERNAL }, - { "ODDLYIELD", "ODDLYIELD", 461, NOID, 8, 9, V, { V }, FUNCFLAG_EXTERNAL }, - { "ODDFPRICE", "ODDFPRICE", 462, NOID, 8, 9, V, { V }, FUNCFLAG_EXTERNAL }, - { "ODDFYIELD", "ODDFYIELD", 463, NOID, 8, 9, V, { V }, FUNCFLAG_EXTERNAL }, - { "RANDBETWEEN", "RANDBETWEEN", 464, NOID, 2, 2, V, {}, FUNCFLAG_VOLATILE | FUNCFLAG_EXTERNAL }, - { "WEEKNUM", "WEEKNUM", 465, NOID, 1, 2, V, { V }, FUNCFLAG_EXTERNAL }, - { "AMORDEGRC", "AMORDEGRC", 466, NOID, 6, 7, V, { V }, FUNCFLAG_EXTERNAL }, - { "AMORLINC", "AMORLINC", 467, NOID, 6, 7, V, { V }, FUNCFLAG_EXTERNAL }, - { "CONVERT", "CONVERT", 468, NOID, 3, 3, V, { V }, FUNCFLAG_EXTERNAL }, // Calc: builtin and add-in - { "ACCRINT", "ACCRINT", 469, NOID, 6, 7, V, { V }, FUNCFLAG_EXTERNAL }, - { "ACCRINTM", "ACCRINTM", 470, NOID, 4, 5, V, { V }, FUNCFLAG_EXTERNAL }, - { "WORKDAY", "WORKDAY", 471, NOID, 2, 3, V, { V, V, A, C, I }, FUNCFLAG_EXTERNAL }, - { "NETWORKDAYS", "NETWORKDAYS", 472, NOID, 2, 3, V, { V, V, A, C, I }, FUNCFLAG_EXTERNAL }, - { "GCD", "GCD", 473, NOID, 1, MX, V, { R }, FUNCFLAG_EXTERNAL }, // Calc: builtin and add-in - { "MULTINOMIAL", "MULTINOMIAL", 474, NOID, 1, MX, V, { R }, FUNCFLAG_EXTERNAL }, - { "LCM", "LCM", 475, NOID, 1, MX, V, { R }, FUNCFLAG_EXTERNAL }, // Calc: builtin and add-in - { "FVSCHEDULE", "FVSCHEDULE", 476, NOID, 2, 2, V, { V, A }, FUNCFLAG_EXTERNAL } -// { "EUROCONVERT", "EUROCONVERT", NOID, NOID, 3, 5, V, { V }, FUNCFLAG_EXTERNAL }, // Euro conversion add-in + { "HEX2BIN", "HEX2BIN", 384, NOID, 1, 2, V, { V }, FUNCFLAG_EXTERNAL }, + { "HEX2DEC", "HEX2DEC", 385, NOID, 1, 1, V, { V }, FUNCFLAG_EXTERNAL }, + { "HEX2OCT", "HEX2OCT", 386, NOID, 1, 2, V, { V }, FUNCFLAG_EXTERNAL }, + { "DEC2BIN", "DEC2BIN", 387, NOID, 1, 2, V, { V }, FUNCFLAG_EXTERNAL }, + { "DEC2HEX", "DEC2HEX", 388, NOID, 1, 2, V, { V }, FUNCFLAG_EXTERNAL }, + { "DEC2OCT", "DEC2OCT", 389, NOID, 1, 2, V, { V }, FUNCFLAG_EXTERNAL }, + { "OCT2BIN", "OCT2BIN", 390, NOID, 1, 2, V, { V }, FUNCFLAG_EXTERNAL }, + { "OCT2HEX", "OCT2HEX", 391, NOID, 1, 2, V, { V }, FUNCFLAG_EXTERNAL }, + { "OCT2DEC", "OCT2DEC", 392, NOID, 1, 1, V, { V }, FUNCFLAG_EXTERNAL }, + { "BIN2DEC", "BIN2DEC", 393, NOID, 1, 1, V, { V }, FUNCFLAG_EXTERNAL }, + { "BIN2OCT", "BIN2OCT", 394, NOID, 1, 2, V, { V }, FUNCFLAG_EXTERNAL }, + { "BIN2HEX", "BIN2HEX", 395, NOID, 1, 2, V, { V }, FUNCFLAG_EXTERNAL }, + { "IMSUB", "IMSUB", 396, NOID, 2, 2, V, { V }, FUNCFLAG_EXTERNAL }, + { "IMDIV", "IMDIV", 397, NOID, 2, 2, V, { V }, FUNCFLAG_EXTERNAL }, + { "IMPOWER", "IMPOWER", 398, NOID, 2, 2, V, { V }, FUNCFLAG_EXTERNAL }, + { "IMABS", "IMABS", 399, NOID, 1, 1, V, { V }, FUNCFLAG_EXTERNAL }, + { "IMSQRT", "IMSQRT", 400, NOID, 1, 1, V, { V }, FUNCFLAG_EXTERNAL }, + { "IMLN", "IMLN", 401, NOID, 1, 1, V, { V }, FUNCFLAG_EXTERNAL }, + { "IMLOG2", "IMLOG2", 402, NOID, 1, 1, V, { V }, FUNCFLAG_EXTERNAL }, + { "IMLOG10", "IMLOG10", 403, NOID, 1, 1, V, { V }, FUNCFLAG_EXTERNAL }, + { "IMSIN", "IMSIN", 404, NOID, 1, 1, V, { V }, FUNCFLAG_EXTERNAL }, + { "IMCOS", "IMCOS", 405, NOID, 1, 1, V, { V }, FUNCFLAG_EXTERNAL }, + { "IMEXP", "IMEXP", 406, NOID, 1, 1, V, { V }, FUNCFLAG_EXTERNAL }, + { "IMARGUMENT", "IMARGUMENT", 407, NOID, 1, 1, V, { V }, FUNCFLAG_EXTERNAL }, + { "IMCONJUGATE", "IMCONJUGATE", 408, NOID, 1, 1, V, { V }, FUNCFLAG_EXTERNAL }, + { "IMAGINARY", "IMAGINARY", 409, NOID, 1, 1, V, { V }, FUNCFLAG_EXTERNAL }, + { "IMREAL", "IMREAL", 410, NOID, 1, 1, V, { V }, FUNCFLAG_EXTERNAL }, + { "COMPLEX", "COMPLEX", 411, NOID, 2, 3, V, { V }, FUNCFLAG_EXTERNAL }, + { "IMSUM", "IMSUM", 412, NOID, 1, MX, V, { R }, FUNCFLAG_EXTERNAL }, + { "IMPRODUCT", "IMPRODUCT", 413, NOID, 1, MX, V, { R }, FUNCFLAG_EXTERNAL }, + { "SERIESSUM", "SERIESSUM", 414, NOID, 4, 4, V, { V, V, V, R }, FUNCFLAG_EXTERNAL }, + { "FACTDOUBLE", "FACTDOUBLE", 415, NOID, 1, 1, V, { V }, FUNCFLAG_EXTERNAL }, + { "SQRTPI", "SQRTPI", 416, NOID, 1, 1, V, { V }, FUNCFLAG_EXTERNAL }, + { "QUOTIENT", "QUOTIENT", 417, NOID, 2, 2, V, { V }, FUNCFLAG_EXTERNAL }, + { "DELTA", "DELTA", 418, NOID, 1, 2, V, { V }, FUNCFLAG_EXTERNAL }, + { "GESTEP", "GESTEP", 419, NOID, 1, 2, V, { V }, FUNCFLAG_EXTERNAL }, + { "ISEVEN", "ISEVEN", 420, NOID, 1, 1, V, { V }, FUNCFLAG_EXTERNAL }, // Calc: builtin and add-in + { "ISODD", "ISODD", 421, NOID, 1, 1, V, { V }, FUNCFLAG_EXTERNAL }, // Calc: builtin and add-in + { "MROUND", "MROUND", 422, NOID, 2, 2, V, { V }, FUNCFLAG_EXTERNAL }, + { "ERF", "ERF", 423, NOID, 1, 2, V, { V }, FUNCFLAG_EXTERNAL }, + { "ERFC", "ERFC", 424, NOID, 1, 1, V, { V }, FUNCFLAG_EXTERNAL }, + { "BESSELJ", "BESSELJ", 425, NOID, 2, 2, V, { V }, FUNCFLAG_EXTERNAL }, + { "BESSELK", "BESSELK", 426, NOID, 2, 2, V, { V }, FUNCFLAG_EXTERNAL }, + { "BESSELY", "BESSELY", 427, NOID, 2, 2, V, { V }, FUNCFLAG_EXTERNAL }, + { "BESSELI", "BESSELI", 428, NOID, 2, 2, V, { V }, FUNCFLAG_EXTERNAL }, + { "XIRR", "XIRR", 429, NOID, 2, 3, V, { A, R, V }, FUNCFLAG_EXTERNAL }, + { "XNPV", "XNPV", 430, NOID, 3, 3, V, { V, A, R }, FUNCFLAG_EXTERNAL }, + { "PRICEMAT", "PRICEMAT", 431, NOID, 5, 6, V, { V }, FUNCFLAG_EXTERNAL }, + { "YIELDMAT", "YIELDMAT", 432, NOID, 5, 6, V, { V }, FUNCFLAG_EXTERNAL }, + { "INTRATE", "INTRATE", 433, NOID, 4, 5, V, { V }, FUNCFLAG_EXTERNAL }, + { "RECEIVED", "RECEIVED", 434, NOID, 4, 5, V, { V }, FUNCFLAG_EXTERNAL }, + { "DISC", "DISC", 435, NOID, 4, 5, V, { V }, FUNCFLAG_EXTERNAL }, + { "PRICEDISC", "PRICEDISC", 436, NOID, 4, 5, V, { V }, FUNCFLAG_EXTERNAL }, + { "YIELDDISC", "YIELDDISC", 437, NOID, 4, 5, V, { V }, FUNCFLAG_EXTERNAL }, + { "TBILLEQ", "TBILLEQ", 438, NOID, 3, 3, V, { V }, FUNCFLAG_EXTERNAL }, + { "TBILLPRICE", "TBILLPRICE", 439, NOID, 3, 3, V, { V }, FUNCFLAG_EXTERNAL }, + { "TBILLYIELD", "TBILLYIELD", 440, NOID, 3, 3, V, { V }, FUNCFLAG_EXTERNAL }, + { "PRICE", "PRICE", 441, NOID, 6, 7, V, { V }, FUNCFLAG_EXTERNAL }, + { "YIELD", "YIELD", 442, NOID, 6, 7, V, { V }, FUNCFLAG_EXTERNAL }, + { "DOLLARDE", "DOLLARDE", 443, NOID, 2, 2, V, { V }, FUNCFLAG_EXTERNAL }, + { "DOLLARFR", "DOLLARFR", 444, NOID, 2, 2, V, { V }, FUNCFLAG_EXTERNAL }, + { "NOMINAL", "NOMINAL", 445, NOID, 2, 2, V, { V }, FUNCFLAG_EXTERNAL }, // Calc: builtin and add-in + { "EFFECT", "EFFECT", 446, NOID, 2, 2, V, { V }, FUNCFLAG_EXTERNAL }, // Calc: builtin and add-in + { "CUMPRINC", "CUMPRINC", 447, NOID, 6, 6, V, { V }, FUNCFLAG_EXTERNAL }, // Calc: builtin and add-in + { "CUMIPMT", "CUMIPMT", 448, NOID, 6, 6, V, { V }, FUNCFLAG_EXTERNAL }, // Calc: builtin and add-in + { "EDATE", "EDATE", 449, NOID, 2, 2, V, { V }, FUNCFLAG_EXTERNAL }, + { "EOMONTH", "EOMONTH", 450, NOID, 2, 2, V, { V }, FUNCFLAG_EXTERNAL }, + { "YEARFRAC", "YEARFRAC", 451, NOID, 2, 3, V, { V }, FUNCFLAG_EXTERNAL }, + { "COUPDAYBS", "COUPDAYBS", 452, NOID, 3, 4, V, { V }, FUNCFLAG_EXTERNAL }, + { "COUPDAYS", "COUPDAYS", 453, NOID, 3, 4, V, { V }, FUNCFLAG_EXTERNAL }, + { "COUPDAYSNC", "COUPDAYSNC", 454, NOID, 3, 4, V, { V }, FUNCFLAG_EXTERNAL }, + { "COUPNCD", "COUPNCD", 455, NOID, 3, 4, V, { V }, FUNCFLAG_EXTERNAL }, + { "COUPNUM", "COUPNUM", 456, NOID, 3, 4, V, { V }, FUNCFLAG_EXTERNAL }, + { "COUPPCD", "COUPPCD", 457, NOID, 3, 4, V, { V }, FUNCFLAG_EXTERNAL }, + { "DURATION", "DURATION", 458, NOID, 5, 6, V, { V }, FUNCFLAG_EXTERNAL }, // Calc: builtin and add-in + { "MDURATION", "MDURATION", 459, NOID, 5, 6, V, { V }, FUNCFLAG_EXTERNAL }, + { "ODDLPRICE", "ODDLPRICE", 460, NOID, 7, 8, V, { V }, FUNCFLAG_EXTERNAL }, + { "ODDLYIELD", "ODDLYIELD", 461, NOID, 8, 9, V, { V }, FUNCFLAG_EXTERNAL }, + { "ODDFPRICE", "ODDFPRICE", 462, NOID, 8, 9, V, { V }, FUNCFLAG_EXTERNAL }, + { "ODDFYIELD", "ODDFYIELD", 463, NOID, 8, 9, V, { V }, FUNCFLAG_EXTERNAL }, + { "RANDBETWEEN", "RANDBETWEEN", 464, NOID, 2, 2, V, {}, FUNCFLAG_VOLATILE | FUNCFLAG_EXTERNAL }, + { "WEEKNUM", "WEEKNUM", 465, NOID, 1, 2, V, { V }, FUNCFLAG_EXTERNAL }, + { "AMORDEGRC", "AMORDEGRC", 466, NOID, 6, 7, V, { V }, FUNCFLAG_EXTERNAL }, + { "AMORLINC", "AMORLINC", 467, NOID, 6, 7, V, { V }, FUNCFLAG_EXTERNAL }, + { "CONVERT", "CONVERT", 468, NOID, 3, 3, V, { V }, FUNCFLAG_EXTERNAL }, // Calc: builtin and add-in + { "ACCRINT", "ACCRINT", 469, NOID, 6, 7, V, { V }, FUNCFLAG_EXTERNAL }, + { "ACCRINTM", "ACCRINTM", 470, NOID, 4, 5, V, { V }, FUNCFLAG_EXTERNAL }, + { "WORKDAY", "WORKDAY", 471, NOID, 2, 3, V, { V, V, A, C, I }, FUNCFLAG_EXTERNAL }, + { "NETWORKDAYS", "NETWORKDAYS", 472, NOID, 2, 3, V, { V, V, A, C, I }, FUNCFLAG_EXTERNAL }, + { "GCD", "GCD", 473, NOID, 1, MX, V, { R }, FUNCFLAG_EXTERNAL }, // Calc: builtin and add-in + { "MULTINOMIAL", "MULTINOMIAL", 474, NOID, 1, MX, V, { R }, FUNCFLAG_EXTERNAL }, + { "LCM", "LCM", 475, NOID, 1, MX, V, { R }, FUNCFLAG_EXTERNAL }, // Calc: builtin and add-in + { "FVSCHEDULE", "FVSCHEDULE", 476, NOID, 2, 2, V, { V, A }, FUNCFLAG_EXTERNAL }, +// { "EUROCONVERT", "EUROCONVERT", NOID, NOID, 3, 5, V, { V }, FUNCFLAG_EXTERNAL }, // Euro conversion add-in + + // *** macro sheet commands *** + + { 0, "ACTIVATE.NEXT", 104, 104, 0, 1, V, { V }, FUNCFLAG_MACROCMD }, // BIFF2-3: 0, BIFF4: 0-1 + { 0, "ACTIVATE.PREV", 105, 105, 0, 1, V, { V }, FUNCFLAG_MACROCMD } // BIFF2-3: 0, BIFF4: 0-1 }; /** Functions new in BIFF5/BIFF7. */ static const FunctionData saFuncTableBiff5[] = { - { "WEEKDAY", "WEEKDAY", 70, 70, 1, 2, V, { V }, 0 }, // BIFF2-4: 1, BIFF5: 1-2 - { "HLOOKUP", "HLOOKUP", 101, 101, 3, 4, V, { V, R, R, V }, 0 }, // BIFF2-4: 3, BIFF5: 3-4 - { "VLOOKUP", "VLOOKUP", 102, 102, 3, 4, V, { V, R, R, V }, 0 }, // BIFF2-4: 3, BIFF5: 3-4 - { "DAYS360", "DAYS360", 220, 220, 2, 3, V, { V }, 0 }, // BIFF3-4: 2, BIFF5: 2-3 - { 0, 0, 255, 255, 1, MX, R, { ER, R }, FUNCFLAG_EXPORTONLY }, // MACRO or EXTERNAL - { "CONCATENATE", "CONCATENATE", 336, 336, 0, MX, V, { V }, 0 }, - { "POWER", "POWER", 337, 337, 2, 2, V, { V }, 0 }, - { "RADIANS", "RADIANS", 342, 342, 1, 1, V, { V }, 0 }, - { "DEGREES", "DEGREES", 343, 343, 1, 1, V, { V }, 0 }, - { "SUBTOTAL", "SUBTOTAL", 344, 344, 2, MX, V, { V, R }, 0 }, - { "SUMIF", "SUMIF", 345, 345, 2, 3, V, { R, V, R }, 0 }, - { "COUNTIF", "COUNTIF", 346, 346, 2, 2, V, { R, V }, 0 }, - { "COUNTBLANK", "COUNTBLANK", 347, 347, 1, 1, V, { R }, 0 }, - { "ISPMT", "ISPMT", 350, 350, 4, 4, V, { V }, 0 }, - { 0, "DATEDIF", 351, 351, 3, 3, V, { V }, FUNCFLAG_IMPORTONLY }, // not supported in Calc - { 0, "DATESTRING", 352, 352, 1, 1, V, { V }, FUNCFLAG_IMPORTONLY }, // not supported in Calc, missing in OOX spec - { 0, "NUMBERSTRING", 353, 353, 2, 2, V, { V }, FUNCFLAG_IMPORTONLY }, // not supported in Calc, missing in OOX spec - { "ROMAN", "ROMAN", 354, 354, 1, 2, V, { V }, 0 } + { "WEEKDAY", "WEEKDAY", 70, 70, 1, 2, V, { V }, 0 }, // BIFF2-4: 1, BIFF5: 1-2 + { "HLOOKUP", "HLOOKUP", 101, 101, 3, 4, V, { V, R, R, V }, 0 }, // BIFF2-4: 3, BIFF5: 3-4 + { "VLOOKUP", "VLOOKUP", 102, 102, 3, 4, V, { V, R, R, V }, 0 }, // BIFF2-4: 3, BIFF5: 3-4 + { 0, "ADD.MENU", 152, 152, 2, 4, V, { V, R, R, V }, FUNCFLAG_MACROFUNC }, // BIFF3-4: 2-3, BIFF5: 2-4 + { 0, "ADD.COMMAND", 153, 153, 3, 5, V, { V, R, R, R, V }, FUNCFLAG_MACROFUNC }, // BIFF3-4: 3-4, BIFF5: 3-5 + { "DAYS360", "DAYS360", 220, 220, 2, 3, V, { V }, 0 }, // BIFF3-4: 2, BIFF5: 2-3 + { 0, "EXTERN.CALL", 255, 255, 1, MX, R, { ER, R }, FUNCFLAG_EXPORTONLY }, // MACRO or EXTERNAL + { "CONCATENATE", "CONCATENATE", 336, 336, 0, MX, V, { V }, 0 }, + { "POWER", "POWER", 337, 337, 2, 2, V, { V }, 0 }, + { "RADIANS", "RADIANS", 342, 342, 1, 1, V, { V }, 0 }, + { "DEGREES", "DEGREES", 343, 343, 1, 1, V, { V }, 0 }, + { "SUBTOTAL", "SUBTOTAL", 344, 344, 2, MX, V, { V, R }, 0 }, + { "SUMIF", "SUMIF", 345, 345, 2, 3, V, { R, V, R }, 0 }, + { "COUNTIF", "COUNTIF", 346, 346, 2, 2, V, { R, V }, 0 }, + { "COUNTBLANK", "COUNTBLANK", 347, 347, 1, 1, V, { R }, 0 }, + { "ISPMT", "ISPMT", 350, 350, 4, 4, V, { V }, 0 }, + { 0, "DATEDIF", 351, 351, 3, 3, V, { V }, FUNCFLAG_IMPORTONLY }, // not supported in Calc + { 0, "DATESTRING", 352, 352, 1, 1, V, { V }, FUNCFLAG_IMPORTONLY }, // not supported in Calc, missing in OOX spec + { 0, "NUMBERSTRING", 353, 353, 2, 2, V, { V }, FUNCFLAG_IMPORTONLY }, // not supported in Calc, missing in OOX spec + { "ROMAN", "ROMAN", 354, 354, 1, 2, V, { V }, 0 }, + + // *** macro sheet commands *** + + { 0, "ADD.CHART.AUTOFORMAT", 390, 390, 0, 2, V, { V }, FUNCFLAG_MACROCMD }, + { 0, "ADD.LIST.ITEM", 451, 451, 0, 2, V, { V }, FUNCFLAG_MACROCMD }, + { 0, "ACTIVE.CELL.FONT", 476, 476, 0, 14, V, { V }, FUNCFLAG_MACROCMD } }; /** Functions new in BIFF8. */ static const FunctionData saFuncTableBiff8[] = { - { "GETPIVOTDATA", "GETPIVOTDATA", 358, 358, 2, MX, V, { V, R, V }, FUNCFLAG_IMPORTONLY }, - { "HYPERLINK", "HYPERLINK", 359, 359, 1, 2, V, { V }, 0 }, - { 0, "PHONETIC", 360, 360, 1, 1, V, { R }, FUNCFLAG_IMPORTONLY }, - { "AVERAGEA", "AVERAGEA", 361, 361, 1, MX, V, { R }, 0 }, - { "MAXA", "MAXA", 362, 362, 1, MX, V, { R }, 0 }, - { "MINA", "MINA", 363, 363, 1, MX, V, { R }, 0 }, - { "STDEVPA", "STDEVPA", 364, 364, 1, MX, V, { R }, 0 }, - { "VARPA", "VARPA", 365, 365, 1, MX, V, { R }, 0 }, - { "STDEVA", "STDEVA", 366, 366, 1, MX, V, { R }, 0 }, - { "VARA", "VARA", 367, 367, 1, MX, V, { R }, 0 }, - { "COM.MICROSOFT.BAHTTEXT", "BAHTTEXT", 368, 368, 1, 1, V, { V }, FUNCFLAG_MACROCALL }, - { 0, "THAIDAYOFWEEK", 369, 369, 1, 1, V, { V }, FUNCFLAG_MACROCALL }, - { 0, "THAIDIGIT", 370, 370, 1, 1, V, { V }, FUNCFLAG_MACROCALL }, - { 0, "THAIMONTHOFYEAR", 371, 371, 1, 1, V, { V }, FUNCFLAG_MACROCALL }, - { 0, "THAINUMSOUND", 372, 372, 1, 1, V, { V }, FUNCFLAG_MACROCALL }, - { 0, "THAINUMSTRING", 373, 373, 1, 1, V, { V }, FUNCFLAG_MACROCALL }, - { 0, "THAISTRINGLENGTH", 374, 374, 1, 1, V, { V }, FUNCFLAG_MACROCALL }, - { 0, "ISTHAIDIGIT", 375, 375, 1, 1, V, { V }, FUNCFLAG_MACROCALL }, - { 0, "ROUNDBAHTDOWN", 376, 376, 1, 1, V, { V }, FUNCFLAG_MACROCALL }, - { 0, "ROUNDBAHTUP", 377, 377, 1, 1, V, { V }, FUNCFLAG_MACROCALL }, - { 0, "THAIYEAR", 378, 378, 1, 1, V, { V }, FUNCFLAG_MACROCALL }, - { 0, "RTD", 379, 379, 3, 3, A, { V, V, R }, 0 } + { "GETPIVOTDATA", "GETPIVOTDATA", 358, 358, 2, MX, V, { V, R, V }, FUNCFLAG_IMPORTONLY }, + { "HYPERLINK", "HYPERLINK", 359, 359, 1, 2, V, { V }, 0 }, + { 0, "PHONETIC", 360, 360, 1, 1, V, { R }, FUNCFLAG_IMPORTONLY }, + { "AVERAGEA", "AVERAGEA", 361, 361, 1, MX, V, { R }, 0 }, + { "MAXA", "MAXA", 362, 362, 1, MX, V, { R }, 0 }, + { "MINA", "MINA", 363, 363, 1, MX, V, { R }, 0 }, + { "STDEVPA", "STDEVPA", 364, 364, 1, MX, V, { R }, 0 }, + { "VARPA", "VARPA", 365, 365, 1, MX, V, { R }, 0 }, + { "STDEVA", "STDEVA", 366, 366, 1, MX, V, { R }, 0 }, + { "VARA", "VARA", 367, 367, 1, MX, V, { R }, 0 }, + { "COM.MICROSOFT.BAHTTEXT", "BAHTTEXT", 368, 368, 1, 1, V, { V }, FUNCFLAG_MACROCALL }, + { 0, "THAIDAYOFWEEK", 369, 369, 1, 1, V, { V }, FUNCFLAG_MACROCALL }, + { 0, "THAIDIGIT", 370, 370, 1, 1, V, { V }, FUNCFLAG_MACROCALL }, + { 0, "THAIMONTHOFYEAR", 371, 371, 1, 1, V, { V }, FUNCFLAG_MACROCALL }, + { 0, "THAINUMSOUND", 372, 372, 1, 1, V, { V }, FUNCFLAG_MACROCALL }, + { 0, "THAINUMSTRING", 373, 373, 1, 1, V, { V }, FUNCFLAG_MACROCALL }, + { 0, "THAISTRINGLENGTH", 374, 374, 1, 1, V, { V }, FUNCFLAG_MACROCALL }, + { 0, "ISTHAIDIGIT", 375, 375, 1, 1, V, { V }, FUNCFLAG_MACROCALL }, + { 0, "ROUNDBAHTDOWN", 376, 376, 1, 1, V, { V }, FUNCFLAG_MACROCALL }, + { 0, "ROUNDBAHTUP", 377, 377, 1, 1, V, { V }, FUNCFLAG_MACROCALL }, + { 0, "THAIYEAR", 378, 378, 1, 1, V, { V }, FUNCFLAG_MACROCALL }, + { 0, "RTD", 379, 379, 3, 3, A, { V, V, R }, 0 } }; /** Functions new in OOX. */ static const FunctionData saFuncTableOox[] = { - { 0, "IFERROR", 480, NOID, 2, 2, V, { V, R }, 0 }, - { 0, "COUNTIFS", 481, NOID, 3, MX, V, { R, V }, 0 }, - { 0, "SUMIFS", 482, NOID, 3, MX, V, { R, V }, 0 }, - { 0, "AVERAGEIF", 483, NOID, 2, 3, V, { R, V, R }, 0 }, - { 0, "AVERAGEIFS", 484, NOID, 3, MX, V, { R, V }, 0 }, - { 0, "CUBEKPIMEMBER", NOID, NOID, 3, 4, V, { V }, 0 }, - { 0, "CUBEMEMBER", NOID, NOID, 2, 3, V, { V, A, V }, 0 }, - { 0, "CUBEMEMBERPROPERTY",NOID, NOID, 3, 3, V, { V }, 0 }, - { 0, "CUBERANKEDMEMBER", NOID, NOID, 3, 4, V, { V }, 0 }, - { 0, "CUBESET", NOID, NOID, 2, 5, V, { V, R, V }, 0 }, - { 0, "CUBESETCOUNT", NOID, NOID, 1, 1, V, { V }, 0 }, - { 0, "CUBEVALUE", NOID, NOID, 2, 2, V, { V, R }, 0 } + { 0, "IFERROR", 480, NOID, 2, 2, V, { V, R }, 0 }, + { 0, "COUNTIFS", 481, NOID, 3, MX, V, { R, V }, 0 }, + { 0, "SUMIFS", 482, NOID, 3, MX, V, { R, V }, 0 }, + { 0, "AVERAGEIF", 483, NOID, 2, 3, V, { R, V, R }, 0 }, + { 0, "AVERAGEIFS", 484, NOID, 3, MX, V, { R, V }, 0 }, + { 0, "CUBEKPIMEMBER", NOID, NOID, 3, 4, V, { V }, 0 }, + { 0, "CUBEMEMBER", NOID, NOID, 2, 3, V, { V, A, V }, 0 }, + { 0, "CUBEMEMBERPROPERTY", NOID, NOID, 3, 3, V, { V }, 0 }, + { 0, "CUBERANKEDMEMBER", NOID, NOID, 3, 4, V, { V }, 0 }, + { 0, "CUBESET", NOID, NOID, 2, 5, V, { V, R, V }, 0 }, + { 0, "CUBESETCOUNT", NOID, NOID, 1, 1, V, { V }, 0 }, + { 0, "CUBEVALUE", NOID, NOID, 2, 2, V, { V, R }, 0 } }; /** Functions defined by OpenFormula, but not supported by Calc or by Excel. */ static const FunctionData saFuncTableOdf[] = { - { "ARABIC", 0, NOID, NOID, 1, 1, V, { V }, 0 }, - { "B", 0, NOID, NOID, 3, 4, V, { V }, 0 }, - { "BASE", 0, NOID, NOID, 2, 3, V, { V }, 0 }, - { "BITAND", 0, NOID, NOID, 2, 2, V, { V }, 0 }, - { "BITLSHIFT", 0, NOID, NOID, 2, 2, V, { V }, 0 }, - { "BITOR", 0, NOID, NOID, 2, 2, V, { V }, 0 }, - { "BITRSHIFT", 0, NOID, NOID, 2, 2, V, { V }, 0 }, - { "BITXOR", 0, NOID, NOID, 2, 2, V, { V }, 0 }, - { "CHISQDIST", 0, NOID, NOID, 2, 3, V, { V }, 0 }, - { "CHISQINV", 0, NOID, NOID, 2, 2, V, { V }, 0 }, - { "COMBINA", 0, NOID, NOID, 2, 2, V, { V }, 0 }, - { "DAYS", 0, NOID, NOID, 2, 2, V, { V }, 0 }, - { "DDE", 0, NOID, NOID, 3, 4, V, { V }, 0 }, - { "DECIMAL", 0, NOID, NOID, 2, 2, V, { V }, 0 }, - { "FDIST", 0, NOID, NOID, 3, 4, V, { V }, 0 }, - { "FINV", 0, NOID, NOID, 3, 3, V, { V }, 0 }, - { "FORMULA", 0, NOID, NOID, 1, 1, V, { R }, 0 }, - { "GAMMA", 0, NOID, NOID, 1, 1, V, { V }, 0 }, - { "GAUSS", 0, NOID, NOID, 1, 1, V, { V }, 0 }, - { "IFNA", 0, NOID, NOID, 2, 2, V, { V, R }, 0 }, - { "ISFORMULA", 0, NOID, NOID, 1, 1, V, { R }, 0 }, - { "ISOWEEKNUM", 0, NOID, NOID, 1, 2, V, { V }, 0 }, - { "MULTIPLE.OPERATIONS", 0, NOID, NOID, 3, 5, V, { R }, 0 }, - { "MUNIT", 0, NOID, NOID, 1, 1, A, { V }, 0 }, - { "NUMBERVALUE", 0, NOID, NOID, 2, 2, V, { V }, 0 }, - { "PDURATION", 0, NOID, NOID, 3, 3, V, { V }, 0 }, - { "PERMUTATIONA", 0, NOID, NOID, 2, 2, V, { V }, 0 }, - { "PHI", 0, NOID, NOID, 1, 1, V, { V }, 0 }, - { "RRI", 0, NOID, NOID, 3, 3, V, { V }, 0 }, - { "SHEET", 0, NOID, NOID, 1, 1, V, { R }, 0 }, - { "SHEETS", 0, NOID, NOID, 0, 1, V, { R }, 0 }, - { "SKEWP", 0, NOID, NOID, 1, MX, V, { R }, 0 }, - { "UNICHAR", 0, NOID, NOID, 1, 1, V, { V }, 0 }, - { "UNICODE", 0, NOID, NOID, 1, 1, V, { V }, 0 }, - { "XOR", 0, NOID, NOID, 1, MX, V, { R }, 0 } + { "ARABIC", 0, NOID, NOID, 1, 1, V, { V }, 0 }, + { "B", 0, NOID, NOID, 3, 4, V, { V }, 0 }, + { "BASE", 0, NOID, NOID, 2, 3, V, { V }, 0 }, + { "BITAND", 0, NOID, NOID, 2, 2, V, { V }, 0 }, + { "BITLSHIFT", 0, NOID, NOID, 2, 2, V, { V }, 0 }, + { "BITOR", 0, NOID, NOID, 2, 2, V, { V }, 0 }, + { "BITRSHIFT", 0, NOID, NOID, 2, 2, V, { V }, 0 }, + { "BITXOR", 0, NOID, NOID, 2, 2, V, { V }, 0 }, + { "CHISQDIST", 0, NOID, NOID, 2, 3, V, { V }, 0 }, + { "CHISQINV", 0, NOID, NOID, 2, 2, V, { V }, 0 }, + { "COMBINA", 0, NOID, NOID, 2, 2, V, { V }, 0 }, + { "DAYS", 0, NOID, NOID, 2, 2, V, { V }, 0 }, + { "DDE", 0, NOID, NOID, 3, 4, V, { V }, 0 }, + { "DECIMAL", 0, NOID, NOID, 2, 2, V, { V }, 0 }, + { "FDIST", 0, NOID, NOID, 3, 4, V, { V }, 0 }, + { "FINV", 0, NOID, NOID, 3, 3, V, { V }, 0 }, + { "FORMULA", 0, NOID, NOID, 1, 1, V, { R }, 0 }, + { "GAMMA", 0, NOID, NOID, 1, 1, V, { V }, 0 }, + { "GAUSS", 0, NOID, NOID, 1, 1, V, { V }, 0 }, + { "IFNA", 0, NOID, NOID, 2, 2, V, { V, R }, 0 }, + { "ISFORMULA", 0, NOID, NOID, 1, 1, V, { R }, 0 }, + { "ISOWEEKNUM", 0, NOID, NOID, 1, 2, V, { V }, 0 }, + { "MULTIPLE.OPERATIONS", 0, NOID, NOID, 3, 5, V, { R }, 0 }, + { "MUNIT", 0, NOID, NOID, 1, 1, A, { V }, 0 }, + { "NUMBERVALUE", 0, NOID, NOID, 2, 2, V, { V }, 0 }, + { "PDURATION", 0, NOID, NOID, 3, 3, V, { V }, 0 }, + { "PERMUTATIONA", 0, NOID, NOID, 2, 2, V, { V }, 0 }, + { "PHI", 0, NOID, NOID, 1, 1, V, { V }, 0 }, + { "RRI", 0, NOID, NOID, 3, 3, V, { V }, 0 }, + { "SHEET", 0, NOID, NOID, 1, 1, V, { R }, 0 }, + { "SHEETS", 0, NOID, NOID, 0, 1, V, { R }, 0 }, + { "SKEWP", 0, NOID, NOID, 1, MX, V, { R }, 0 }, + { "UNICHAR", 0, NOID, NOID, 1, 1, V, { V }, 0 }, + { "UNICODE", 0, NOID, NOID, 1, 1, V, { V }, 0 }, + { "XOR", 0, NOID, NOID, 1, MX, V, { R }, 0 } }; // ---------------------------------------------------------------------------- @@ -701,133 +783,254 @@ FuncInfoParamClassIterator& FuncInfoParamClassIterator::operator++() return *this; } -// function provider implementation =========================================== - -class FunctionProviderImpl -{ -public: - explicit FunctionProviderImpl( - ApiOpCodes& rOpCodes, - const Reference< XSpreadsheetDocument >& rxDocument, - bool bImportFilter ); - - explicit FunctionProviderImpl( - ApiOpCodes& rOpCodes, - const Reference< XSpreadsheetDocument >& rxDocument, - BiffType eBiff, - bool bImportFilter ); - - const FunctionInfo* getFuncInfoFromApiToken( const ApiToken& rToken ) const; - const FunctionInfo* getFuncInfoFromOoxFuncName( const OUString& rFuncName ) const; - const FunctionInfo* getFuncInfoFromOobFuncId( sal_uInt16 nFuncId ) const; - const FunctionInfo* getFuncInfoFromBiffFuncId( sal_uInt16 nFuncId ) const; - const FunctionInfo* getFuncInfoFromExternCallName( const OUString& rExtCallName ) const; - - Sequence< FormulaOpCodeMapEntry > getOoxParserMap() const; - -private: - typedef ::std::map< OUString, FormulaToken > FormulaTokenMap; - typedef Sequence< FormulaOpCodeMapEntry > OpCodeEntrySequence; - typedef ::std::vector< FormulaOpCodeMapEntry > OpCodeEntryVector; - - static bool fillEntrySeq( OpCodeEntrySequence& orEntrySeq, const Reference< XFormulaOpCodeMapper >& rxMapper, sal_Int32 nMapGroup ); - static bool fillTokenMap( FormulaTokenMap& orTokenMap, OpCodeEntrySequence& orEntrySeq, const Reference< XFormulaOpCodeMapper >& rxMapper, sal_Int32 nMapGroup ); - - static bool initOpCode( sal_Int32& ornOpCode, const OpCodeEntrySequence& rEntrySeq, sal_Int32 nSpecialId ); - static bool initOpCode( OpCodeEntryVector& orParserMap, sal_Int32& ornOpCode, const FormulaTokenMap& rTokenMap, const OUString& rOdfName, const OUString& rOoxName ); - static bool initOpCode( OpCodeEntryVector& orParserMap, sal_Int32& ornOpCode, const FormulaTokenMap& rTokenMap, const sal_Char* pcOdfName, const sal_Char* pcOoxName ); - static bool initOpCode( OpCodeEntryVector& orParserMap, sal_Int32& ornOpCode, const FormulaTokenMap& rTokenMap, sal_Unicode cOdfName, sal_Unicode cOoxName ); - - void construct( const Reference< XSpreadsheetDocument >& rxDocument, bool bImportFilter ); - void construct( const Reference< XSpreadsheetDocument >& rxDocument, BiffType eBiff, bool bImportFilter ); - - bool initFuncNames( const OpCodeEntrySequence& rEntrySeq ); - void initOpCodes( const Reference< XSpreadsheetDocument >& rxDocument ); - - void initFuncOpCode( FunctionInfo& orFuncInfo, const FormulaTokenMap& rFuncTokens ); - void initFuncMaps( const FunctionData* pBeg, const FunctionData* pEnd ); - -private: - typedef RefMap< sal_Int32, FunctionInfo > OpCodeFuncMap; - typedef RefMap< OUString, FunctionInfo > FuncNameMap; - typedef RefMap< sal_uInt16, FunctionInfo > FuncIdMap; - - ApiOpCodes& mrOpCodes; /// All needed API op-codes. - FormulaTokenMap maIntFuncTokens; /// Internal functions keyed by ODFF name. - FormulaTokenMap maExtFuncTokens; /// External functions keyed by ODFF name. - OpCodeFuncMap maOpCodeFuncs; /// Maps API op-codes to function data. - FuncNameMap maOoxFuncs; /// Maps OOXML function names to function data. - FuncNameMap maExtProgFuncs; /// Maps programmatical API function names to function data. - FuncIdMap maOobFuncs; /// Maps OOBIN function indexes to function data. - FuncIdMap maBiffFuncs; /// Maps BIFF function indexes to function data. - FuncNameMap maMacroFuncs; /// Maps BIFF macro function names to function data. - OpCodeEntryVector maParserMap; /// OOXML token mapping for formula parser service. - sal_uInt8 mnMaxParam; /// Maximum parameter count for current file type. - bool mbImportFilter; /// True = import filter, false = export filter. -}; +// function provider ========================================================== -// ---------------------------------------------------------------------------- +FunctionProvider::FunctionProvider( FilterType eFilter, BiffType eBiff, bool bImportFilter ) : + mxFuncs( new FuncVector ), + mxOdfFuncs( new FuncNameMap ), + mxOoxFuncs( new FuncNameMap ), + mxOobFuncs( new FuncIdMap ), + mxBiffFuncs( new FuncIdMap ), + mxMacroFuncs( new FuncNameMap ) +{ + OSL_ENSURE( bImportFilter, "FunctionProvider::FunctionProvider - need special handling for macro call functions" ); + sal_uInt8 nMaxParam = 0; + switch( eFilter ) + { + case FILTER_OOX: + nMaxParam = OOX_MAX_PARAMCOUNT; + eBiff = BIFF8; // insert all BIFF function tables, then the OOX table + break; + case FILTER_BIFF: + nMaxParam = BIFF_MAX_PARAMCOUNT; + break; + case FILTER_UNKNOWN: + OSL_ENSURE( false, "FunctionProvider::FunctionProvider - invalid filter type" ); + break; + } + OSL_ENSURE( eBiff != BIFF_UNKNOWN, "FunctionProvider::FunctionProvider - invalid BIFF type" ); -FunctionProviderImpl::FunctionProviderImpl( ApiOpCodes& rOpCodes, - const Reference< XSpreadsheetDocument >& rxDocument, bool bImportFilter ) : - mrOpCodes( rOpCodes ), - mnMaxParam( OOX_MAX_PARAMCOUNT ) + /* Add functions supported in the current BIFF version only. Function + tables from later BIFF versions may overwrite single functions from + earlier tables. */ + if( eBiff >= BIFF2 ) + initFuncs( saFuncTableBiff2, STATIC_ARRAY_END( saFuncTableBiff2 ), nMaxParam, bImportFilter ); + if( eBiff >= BIFF3 ) + initFuncs( saFuncTableBiff3, STATIC_ARRAY_END( saFuncTableBiff3 ), nMaxParam, bImportFilter ); + if( eBiff >= BIFF4 ) + initFuncs( saFuncTableBiff4, STATIC_ARRAY_END( saFuncTableBiff4 ), nMaxParam, bImportFilter ); + if( eBiff >= BIFF5 ) + initFuncs( saFuncTableBiff5, STATIC_ARRAY_END( saFuncTableBiff5 ), nMaxParam, bImportFilter ); + if( eBiff >= BIFF8 ) + initFuncs( saFuncTableBiff8, STATIC_ARRAY_END( saFuncTableBiff8 ), nMaxParam, bImportFilter ); + if( eFilter == FILTER_OOX ) + initFuncs( saFuncTableOox, STATIC_ARRAY_END( saFuncTableOox ), nMaxParam, bImportFilter ); +} + +FunctionProvider::~FunctionProvider() { - construct( rxDocument, bImportFilter ); } -FunctionProviderImpl::FunctionProviderImpl( ApiOpCodes& rOpCodes, - const Reference< XSpreadsheetDocument >& rxDocument, BiffType eBiff, bool bImportFilter ) : - mrOpCodes( rOpCodes ), - mnMaxParam( BIFF_MAX_PARAMCOUNT ) +const FunctionInfo* FunctionProvider::getFuncInfoFromOdfFuncName( const OUString& rFuncName ) const { - construct( rxDocument, eBiff, bImportFilter ); + return mxOdfFuncs->get( rFuncName ).get(); } -const FunctionInfo* FunctionProviderImpl::getFuncInfoFromApiToken( const ApiToken& rToken ) const +const FunctionInfo* FunctionProvider::getFuncInfoFromOoxFuncName( const OUString& rFuncName ) const { - const FunctionInfo* pFuncInfo = 0; - if( (rToken.OpCode == mrOpCodes.OPCODE_EXTERNAL) && rToken.Data.hasValue() ) - { - OUString aProgFuncName; - if( rToken.Data >>= aProgFuncName ) - pFuncInfo = maExtProgFuncs.get( aProgFuncName ).get(); - } - else - { - pFuncInfo = maOpCodeFuncs.get( rToken.OpCode ).get(); - } - return pFuncInfo; + return mxOoxFuncs->get( rFuncName ).get(); } -const FunctionInfo* FunctionProviderImpl::getFuncInfoFromOoxFuncName( const OUString& rFuncName ) const +const FunctionInfo* FunctionProvider::getFuncInfoFromOobFuncId( sal_uInt16 nFuncId ) const { - return maOoxFuncs.get( rFuncName ).get(); + return mxOobFuncs->get( nFuncId ).get(); } -const FunctionInfo* FunctionProviderImpl::getFuncInfoFromOobFuncId( sal_uInt16 nFuncId ) const +const FunctionInfo* FunctionProvider::getFuncInfoFromBiffFuncId( sal_uInt16 nFuncId ) const { - return maOobFuncs.get( nFuncId ).get(); + return mxBiffFuncs->get( nFuncId ).get(); } -const FunctionInfo* FunctionProviderImpl::getFuncInfoFromBiffFuncId( sal_uInt16 nFuncId ) const +const FunctionInfo* FunctionProvider::getFuncInfoFromMacroName( const OUString& rFuncName ) const { - return maBiffFuncs.get( nFuncId ).get(); + return mxMacroFuncs->get( rFuncName ).get(); } -const FunctionInfo* FunctionProviderImpl::getFuncInfoFromExternCallName( const OUString& rExtCallName ) const +// private -------------------------------------------------------------------- + +void FunctionProvider::initFunc( const FunctionData& rFuncData, sal_uInt8 nMaxParam ) +{ + // create a function info object + FunctionInfoRef xFuncInfo( new FunctionInfo ); + if( rFuncData.mpcOdfFuncName ) + xFuncInfo->maOdfFuncName = OUString::createFromAscii( rFuncData.mpcOdfFuncName ); + if( rFuncData.mpcOoxFuncName ) + xFuncInfo->maOoxFuncName = OUString::createFromAscii( rFuncData.mpcOoxFuncName ); + if( getFlag( rFuncData.mnFlags, FUNCFLAG_MACROCALL ) ) + xFuncInfo->maBiffMacroName = CREATE_OUSTRING( "_xlfn." ) + xFuncInfo->maOoxFuncName; + xFuncInfo->mnApiOpCode = -1; + xFuncInfo->mnOobFuncId = rFuncData.mnOobFuncId; + xFuncInfo->mnBiffFuncId = rFuncData.mnBiffFuncId; + xFuncInfo->mnMinParamCount = rFuncData.mnMinParamCount; + xFuncInfo->mnMaxParamCount = (rFuncData.mnMaxParamCount == MX) ? nMaxParam : rFuncData.mnMaxParamCount; + xFuncInfo->mnRetClass = rFuncData.mnRetClass; + xFuncInfo->mpnParamClass = rFuncData.mpnParamClass; + xFuncInfo->mbVolatile = getFlag( rFuncData.mnFlags, FUNCFLAG_VOLATILE ); + xFuncInfo->mbExternal = getFlag( rFuncData.mnFlags, FUNCFLAG_EXTERNAL ); + bool bMacroCmd = getFlag( rFuncData.mnFlags, FUNCFLAG_MACROCMD ); + xFuncInfo->mbMacroFunc = bMacroCmd || getFlag( rFuncData.mnFlags, FUNCFLAG_MACROFUNC ); + xFuncInfo->mbVarParam = bMacroCmd || (rFuncData.mnMinParamCount != rFuncData.mnMaxParamCount) || getFlag( rFuncData.mnFlags, FUNCFLAG_ALWAYSVAR ); + + setFlag( xFuncInfo->mnOobFuncId, BIFF_TOK_FUNCVAR_CMD, bMacroCmd ); + setFlag( xFuncInfo->mnBiffFuncId, BIFF_TOK_FUNCVAR_CMD, bMacroCmd ); + + // insert the function info into the member maps + mxFuncs->push_back( xFuncInfo ); + if( xFuncInfo->maOdfFuncName.getLength() > 0 ) + (*mxOdfFuncs)[ xFuncInfo->maOdfFuncName ] = xFuncInfo; + if( xFuncInfo->maOoxFuncName.getLength() > 0 ) + (*mxOoxFuncs)[ xFuncInfo->maOoxFuncName ] = xFuncInfo; + if( xFuncInfo->mnOobFuncId != NOID ) + (*mxOobFuncs)[ xFuncInfo->mnOobFuncId ] = xFuncInfo; + if( xFuncInfo->mnBiffFuncId != NOID ) + (*mxBiffFuncs)[ xFuncInfo->mnBiffFuncId ] = xFuncInfo; + if( xFuncInfo->maBiffMacroName.getLength() > 0 ) + (*mxMacroFuncs)[ xFuncInfo->maBiffMacroName ] = xFuncInfo; +} + +void FunctionProvider::initFuncs( const FunctionData* pBeg, const FunctionData* pEnd, sal_uInt8 nMaxParam, bool bImportFilter ) { - return maMacroFuncs.get( rExtCallName ).get(); + for( const FunctionData* pIt = pBeg; pIt != pEnd; ++pIt ) + if( pIt->isSupported( bImportFilter ) ) + initFunc( *pIt, nMaxParam ); } -Sequence< FormulaOpCodeMapEntry > FunctionProviderImpl::getOoxParserMap() const +// op-code and function provider ============================================== + +OpCodeProvider::OpCodeProvider( const WorkbookHelper& rHelper ) : + FunctionProvider( rHelper.getFilterType(), rHelper.getBiff(), rHelper.getBaseFilter().isImportFilter() ), + WorkbookHelper( rHelper ), + mxOpCodeFuncs( new OpCodeFuncMap ), + mxExtProgFuncs( new FuncNameMap ), + mxParserMap( new OpCodeEntryVector ) { - return ContainerHelper::vectorToSequence( maParserMap ); + try + { + Reference< XMultiServiceFactory > xFactory( getDocument(), UNO_QUERY_THROW ); + Reference< XFormulaOpCodeMapper > xMapper( xFactory->createInstance( + CREATE_OUSTRING( "com.sun.star.sheet.FormulaOpCodeMapper" ) ), UNO_QUERY_THROW ); + + // op-codes provided as attributes + OPCODE_UNKNOWN = xMapper->getOpCodeUnknown(); + OPCODE_EXTERNAL = xMapper->getOpCodeExternal(); + + using namespace ::com::sun::star::sheet::FormulaMapGroup; + using namespace ::com::sun::star::sheet::FormulaMapGroupSpecialOffset; + + OpCodeEntrySequence aEntrySeq; + ApiTokenMap aTokenMap, aExtFuncTokenMap; + bool bIsValid = + // special + fillEntrySeq( aEntrySeq, xMapper, SPECIAL ) && + initOpCode( OPCODE_PUSH, aEntrySeq, PUSH ) && + initOpCode( OPCODE_MISSING, aEntrySeq, MISSING ) && + initOpCode( OPCODE_SPACES, aEntrySeq, SPACES ) && + initOpCode( OPCODE_NAME, aEntrySeq, NAME ) && + initOpCode( OPCODE_DBAREA, aEntrySeq, DB_AREA ) && + initOpCode( OPCODE_NLR, aEntrySeq, COL_ROW_NAME ) && + initOpCode( OPCODE_MACRO, aEntrySeq, MACRO ) && + initOpCode( OPCODE_BAD, aEntrySeq, BAD ) && + initOpCode( OPCODE_NONAME, aEntrySeq, NO_NAME ) && + // separators + fillTokenMap( aTokenMap, aEntrySeq, xMapper, SEPARATORS ) && + initOpCode( OPCODE_OPEN, aTokenMap, API_TOKEN_OPEN, '(' ) && + initOpCode( OPCODE_CLOSE, aTokenMap, API_TOKEN_CLOSE, ')' ) && + initOpCode( OPCODE_SEP, aTokenMap, API_TOKEN_SEP, ',' ) && + // array separators + fillTokenMap( aTokenMap, aEntrySeq, xMapper, ARRAY_SEPARATORS ) && + initOpCode( OPCODE_ARRAY_OPEN, aTokenMap, API_TOKEN_ARRAY_OPEN, '{' ) && + initOpCode( OPCODE_ARRAY_CLOSE, aTokenMap, API_TOKEN_ARRAY_CLOSE, '}' ) && + initOpCode( OPCODE_ARRAY_ROWSEP, aTokenMap, API_TOKEN_ARRAY_ROWSEP, ';' ) && + initOpCode( OPCODE_ARRAY_COLSEP, aTokenMap, API_TOKEN_ARRAY_COLSEP, ',' ) && + // unary operators + fillTokenMap( aTokenMap, aEntrySeq, xMapper, UNARY_OPERATORS ) && + initOpCode( OPCODE_PLUS_SIGN, aTokenMap, '+', '\0' ) && // same op-code as OPCODE_ADD + initOpCode( OPCODE_MINUS_SIGN, aTokenMap, '-', '-' ) && + initOpCode( OPCODE_PERCENT, aTokenMap, '%', '%' ) && + // binary operators + fillTokenMap( aTokenMap, aEntrySeq, xMapper, BINARY_OPERATORS ) && + initOpCode( OPCODE_ADD, aTokenMap, '+', '+' ) && + initOpCode( OPCODE_SUB, aTokenMap, '-', '-' ) && + initOpCode( OPCODE_MULT, aTokenMap, '*', '*' ) && + initOpCode( OPCODE_DIV, aTokenMap, '/', '/' ) && + initOpCode( OPCODE_POWER, aTokenMap, '^', '^' ) && + initOpCode( OPCODE_CONCAT, aTokenMap, '&', '&' ) && + initOpCode( OPCODE_EQUAL, aTokenMap, '=', '=' ) && + initOpCode( OPCODE_NOT_EQUAL, aTokenMap, "<>", "<>" ) && + initOpCode( OPCODE_LESS, aTokenMap, '<', '<' ) && + initOpCode( OPCODE_LESS_EQUAL, aTokenMap, "<=", "<=" ) && + initOpCode( OPCODE_GREATER, aTokenMap, '>', '>' ) && + initOpCode( OPCODE_GREATER_EQUAL, aTokenMap, ">=", ">=" ) && + initOpCode( OPCODE_INTERSECT, aTokenMap, '!', ' ' ) && + initOpCode( OPCODE_LIST, aTokenMap, '~', ',' ) && + initOpCode( OPCODE_RANGE, aTokenMap, ':', ':' ) && + // functions + fillFuncTokenMaps( aTokenMap, aExtFuncTokenMap, aEntrySeq, xMapper ) && + initFuncOpCodes( aTokenMap, aExtFuncTokenMap ) && + initOpCode( OPCODE_DDE, aTokenMap, "DDE", 0 ); + + OSL_ENSURE( bIsValid, "OpCodeProvider::OpCodeProvider - opcodes not initialized" ); + (void)bIsValid; + + // OPCODE_PLUS_SIGN and OPCODE_ADD should be equal, otherwise "+" has to be passed above + OSL_ENSURE( OPCODE_PLUS_SIGN == OPCODE_ADD, "OpCodeProvider::OpCodeProvider - need opcode mapping for OPCODE_PLUS_SIGN" ); + } + catch( Exception& ) + { + OSL_ENSURE( false, "OpCodeProvider::OpCodeProvider - cannot receive formula opcode mapper" ); + } +} + +OpCodeProvider::~OpCodeProvider() +{ +} + +const FunctionInfo* OpCodeProvider::getFuncInfoFromApiToken( const ApiToken& rToken ) const +{ + const FunctionInfo* pFuncInfo = 0; + if( (rToken.OpCode == OPCODE_EXTERNAL) && rToken.Data.hasValue() ) + { + OUString aProgFuncName; + if( rToken.Data >>= aProgFuncName ) + pFuncInfo = mxExtProgFuncs->get( aProgFuncName ).get(); + } + else if( (rToken.OpCode == OPCODE_MACRO) && rToken.Data.hasValue() ) + { + OUString aMacroName; + if( rToken.Data >>= aMacroName ) + pFuncInfo = getFuncInfoFromMacroName( aMacroName ); + } + else if( (rToken.OpCode == OPCODE_BAD) && rToken.Data.hasValue() ) + { + OUString aOoxFuncName; + if( rToken.Data >>= aOoxFuncName ) + pFuncInfo = getFuncInfoFromOoxFuncName( aOoxFuncName ); + } + else + { + pFuncInfo = mxOpCodeFuncs->get( rToken.OpCode ).get(); + } + return pFuncInfo; +} + +Sequence< FormulaOpCodeMapEntry > OpCodeProvider::getOoxParserMap() const +{ + return ContainerHelper::vectorToSequence( *mxParserMap ); } // private -------------------------------------------------------------------- -bool FunctionProviderImpl::fillEntrySeq( OpCodeEntrySequence& orEntrySeq, +bool OpCodeProvider::fillEntrySeq( OpCodeEntrySequence& orEntrySeq, const Reference< XFormulaOpCodeMapper >& rxMapper, sal_Int32 nMapGroup ) { try @@ -841,7 +1044,7 @@ bool FunctionProviderImpl::fillEntrySeq( OpCodeEntrySequence& orEntrySeq, return false; } -bool FunctionProviderImpl::fillTokenMap( FormulaTokenMap& orTokenMap, OpCodeEntrySequence& orEntrySeq, +bool OpCodeProvider::fillTokenMap( ApiTokenMap& orTokenMap, OpCodeEntrySequence& orEntrySeq, const Reference< XFormulaOpCodeMapper >& rxMapper, sal_Int32 nMapGroup ) { orTokenMap.clear(); @@ -852,11 +1055,24 @@ bool FunctionProviderImpl::fillTokenMap( FormulaTokenMap& orTokenMap, OpCodeEntr for( ; pEntry != pEntryEnd; ++pEntry ) orTokenMap[ pEntry->Name ] = pEntry->Token; } - return !orTokenMap.empty(); + return orEntrySeq.hasElements(); } -bool FunctionProviderImpl::initOpCode( sal_Int32& ornOpCode, - const OpCodeEntrySequence& rEntrySeq, sal_Int32 nSpecialId ) +bool OpCodeProvider::fillFuncTokenMaps( ApiTokenMap& orIntFuncTokenMap, ApiTokenMap& orExtFuncTokenMap, OpCodeEntrySequence& orEntrySeq, const Reference< XFormulaOpCodeMapper >& rxMapper ) const +{ + orIntFuncTokenMap.clear(); + orExtFuncTokenMap.clear(); + if( fillEntrySeq( orEntrySeq, rxMapper, ::com::sun::star::sheet::FormulaMapGroup::FUNCTIONS ) ) + { + const FormulaOpCodeMapEntry* pEntry = orEntrySeq.getConstArray(); + const FormulaOpCodeMapEntry* pEntryEnd = pEntry + orEntrySeq.getLength(); + for( ; pEntry != pEntryEnd; ++pEntry ) + ((pEntry->Token.OpCode == OPCODE_EXTERNAL) ? orExtFuncTokenMap : orIntFuncTokenMap)[ pEntry->Name ] = pEntry->Token; + } + return orEntrySeq.hasElements(); +} + +bool OpCodeProvider::initOpCode( sal_Int32& ornOpCode, const OpCodeEntrySequence& rEntrySeq, sal_Int32 nSpecialId ) { if( (0 <= nSpecialId) && (nSpecialId < rEntrySeq.getLength()) ) { @@ -864,15 +1080,14 @@ bool FunctionProviderImpl::initOpCode( sal_Int32& ornOpCode, return true; } OSL_ENSURE( false, - OStringBuffer( "FunctionProviderImpl::initOpCode - opcode for special offset " ). + OStringBuffer( "OpCodeProvider::initOpCode - opcode for special offset " ). append( nSpecialId ).append( " not found" ).getStr() ); return false; } -bool FunctionProviderImpl::initOpCode( OpCodeEntryVector& orParserMap, sal_Int32& ornOpCode, - const FormulaTokenMap& rTokenMap, const OUString& rOdfName, const OUString& rOoxName ) +bool OpCodeProvider::initOpCode( sal_Int32& ornOpCode, const ApiTokenMap& rTokenMap, const OUString& rOdfName, const OUString& rOoxName ) { - FormulaTokenMap::const_iterator aIt = rTokenMap.find( rOdfName ); + ApiTokenMap::const_iterator aIt = rTokenMap.find( rOdfName ); if( aIt != rTokenMap.end() ) { ornOpCode = aIt->second.OpCode; @@ -881,347 +1096,106 @@ bool FunctionProviderImpl::initOpCode( OpCodeEntryVector& orParserMap, sal_Int32 FormulaOpCodeMapEntry aEntry; aEntry.Name = rOoxName; aEntry.Token.OpCode = ornOpCode; - orParserMap.push_back( aEntry ); + mxParserMap->push_back( aEntry ); } return true; } OSL_ENSURE( false, - OStringBuffer( "FunctionProviderImpl::initOpCode - opcode for \"" ). + OStringBuffer( "OpCodeProvider::initOpCode - opcode for \"" ). append( OUStringToOString( rOdfName, RTL_TEXTENCODING_ASCII_US ) ). append( "\" not found" ).getStr() ); return false; } -bool FunctionProviderImpl::initOpCode( OpCodeEntryVector& orParserMap, sal_Int32& ornOpCode, - const FormulaTokenMap& rTokenMap, const sal_Char* pcOdfName, const sal_Char* pcOoxName ) +bool OpCodeProvider::initOpCode( sal_Int32& ornOpCode, const ApiTokenMap& rTokenMap, const sal_Char* pcOdfName, const sal_Char* pcOoxName ) { OUString aOoxName; if( pcOoxName ) aOoxName = OUString::createFromAscii( pcOoxName ); - return initOpCode( orParserMap, ornOpCode, rTokenMap, OUString::createFromAscii( pcOdfName ), aOoxName ); + return initOpCode( ornOpCode, rTokenMap, OUString::createFromAscii( pcOdfName ), aOoxName ); } -bool FunctionProviderImpl::initOpCode( OpCodeEntryVector& orParserMap, sal_Int32& ornOpCode, - const FormulaTokenMap& rTokenMap, sal_Unicode cOdfName, sal_Unicode cOoxName ) +bool OpCodeProvider::initOpCode( sal_Int32& ornOpCode, const ApiTokenMap& rTokenMap, sal_Unicode cOdfName, sal_Unicode cOoxName ) { OUString aOoxName; if( cOoxName ) aOoxName = OUString( cOoxName ); - return initOpCode( orParserMap, ornOpCode, rTokenMap, OUString( cOdfName ), aOoxName ); -} - -void FunctionProviderImpl::construct( - const Reference< XSpreadsheetDocument >& rxDocument, bool bImportFilter ) -{ - construct( rxDocument, BIFF8, bImportFilter ); - // additional functions for OOX - initFuncMaps( saFuncTableOox, STATIC_ARRAY_END( saFuncTableOox ) ); -} - -void FunctionProviderImpl::construct( - const Reference< XSpreadsheetDocument >& rxDocument, BiffType eBiff, bool bImportFilter ) -{ - mbImportFilter = bImportFilter; - OSL_ENSURE( mbImportFilter, "FunctionProviderImpl::construct - need special handling for macro call functions" ); - - // operator op-codes, special op-codes, function op-codes - initOpCodes( rxDocument ); - - /* Add functions supported in the current BIFF version only. - Function tables from later BIFF versions may overwrite single - functions from earlier tables. */ - if( eBiff >= BIFF2 ) - initFuncMaps( saFuncTableBiff2, STATIC_ARRAY_END( saFuncTableBiff2 ) ); - if( eBiff >= BIFF3 ) - initFuncMaps( saFuncTableBiff3, STATIC_ARRAY_END( saFuncTableBiff3 ) ); - if( eBiff >= BIFF4 ) - initFuncMaps( saFuncTableBiff4, STATIC_ARRAY_END( saFuncTableBiff4 ) ); - if( eBiff >= BIFF5 ) - initFuncMaps( saFuncTableBiff5, STATIC_ARRAY_END( saFuncTableBiff5 ) ); - if( eBiff >= BIFF8 ) - initFuncMaps( saFuncTableBiff8, STATIC_ARRAY_END( saFuncTableBiff8 ) ); + return initOpCode( ornOpCode, rTokenMap, OUString( cOdfName ), aOoxName ); } -bool FunctionProviderImpl::initFuncNames( const OpCodeEntrySequence& rEntrySeq ) -{ - const FormulaOpCodeMapEntry* pEntry = rEntrySeq.getConstArray(); - const FormulaOpCodeMapEntry* pEntryEnd = pEntry + rEntrySeq.getLength(); - for( ; pEntry != pEntryEnd; ++pEntry ) - { - if( pEntry->Token.OpCode == mrOpCodes.OPCODE_EXTERNAL ) - maExtFuncTokens[ pEntry->Name ] = pEntry->Token; - else - maIntFuncTokens[ pEntry->Name ] = pEntry->Token; - } - return true; -} - -void FunctionProviderImpl::initOpCodes( const Reference< XSpreadsheetDocument >& rxDocument ) +bool OpCodeProvider::initFuncOpCode( FunctionInfo& orFuncInfo, const ApiTokenMap& rFuncTokenMap ) { bool bIsValid = false; - try - { - Reference< XMultiServiceFactory > xFactory( rxDocument, UNO_QUERY_THROW ); - Reference< XFormulaOpCodeMapper > xMapper( xFactory->createInstance( - CREATE_OUSTRING( "com.sun.star.sheet.FormulaOpCodeMapper" ) ), UNO_QUERY_THROW ); - - // op-codes provided as attributes - mrOpCodes.OPCODE_EXTERNAL = xMapper->getOpCodeExternal(); - mrOpCodes.OPCODE_UNKNOWN = xMapper->getOpCodeUnknown(); - - using namespace ::com::sun::star::sheet::FormulaMapGroup; - using namespace ::com::sun::star::sheet::FormulaMapGroupSpecialOffset; - - OpCodeEntrySequence aEntrySeq; - FormulaTokenMap aTokenMap; - bIsValid = - // special - fillEntrySeq( aEntrySeq, xMapper, SPECIAL ) && - initOpCode( mrOpCodes.OPCODE_PUSH, aEntrySeq, PUSH ) && - initOpCode( mrOpCodes.OPCODE_MISSING, aEntrySeq, MISSING ) && - initOpCode( mrOpCodes.OPCODE_SPACES, aEntrySeq, SPACES ) && - initOpCode( mrOpCodes.OPCODE_NAME, aEntrySeq, NAME ) && - initOpCode( mrOpCodes.OPCODE_DBAREA, aEntrySeq, DB_AREA ) && - initOpCode( mrOpCodes.OPCODE_NLR, aEntrySeq, COL_ROW_NAME ) && - initOpCode( mrOpCodes.OPCODE_MACRO, aEntrySeq, MACRO ) && - initOpCode( mrOpCodes.OPCODE_BAD, aEntrySeq, BAD ) && - initOpCode( mrOpCodes.OPCODE_NONAME, aEntrySeq, NO_NAME ) && - // separators - fillTokenMap( aTokenMap, aEntrySeq, xMapper, SEPARATORS ) && - initOpCode( maParserMap, mrOpCodes.OPCODE_OPEN, aTokenMap, API_TOKEN_OPEN, '(' ) && - initOpCode( maParserMap, mrOpCodes.OPCODE_CLOSE, aTokenMap, API_TOKEN_CLOSE, ')' ) && - initOpCode( maParserMap, mrOpCodes.OPCODE_SEP, aTokenMap, API_TOKEN_SEP, ',' ) && - // array separators - fillTokenMap( aTokenMap, aEntrySeq, xMapper, ARRAY_SEPARATORS ) && - initOpCode( maParserMap, mrOpCodes.OPCODE_ARRAY_OPEN, aTokenMap, API_TOKEN_ARRAY_OPEN, '{' ) && - initOpCode( maParserMap, mrOpCodes.OPCODE_ARRAY_CLOSE, aTokenMap, API_TOKEN_ARRAY_CLOSE, '}' ) && - initOpCode( maParserMap, mrOpCodes.OPCODE_ARRAY_ROWSEP, aTokenMap, API_TOKEN_ARRAY_ROWSEP, ';' ) && - initOpCode( maParserMap, mrOpCodes.OPCODE_ARRAY_COLSEP, aTokenMap, API_TOKEN_ARRAY_COLSEP, ',' ) && - // unary operators - fillTokenMap( aTokenMap, aEntrySeq, xMapper, UNARY_OPERATORS ) && - initOpCode( maParserMap, mrOpCodes.OPCODE_PLUS_SIGN, aTokenMap, '+', '\0' ) && // same op-code as OPCODE_ADD - initOpCode( maParserMap, mrOpCodes.OPCODE_MINUS_SIGN, aTokenMap, '-', '-' ) && - initOpCode( maParserMap, mrOpCodes.OPCODE_PERCENT, aTokenMap, '%', '%' ) && - // binary operators - fillTokenMap( aTokenMap, aEntrySeq, xMapper, BINARY_OPERATORS ) && - initOpCode( maParserMap, mrOpCodes.OPCODE_ADD, aTokenMap, '+', '+' ) && - initOpCode( maParserMap, mrOpCodes.OPCODE_SUB, aTokenMap, '-', '-' ) && - initOpCode( maParserMap, mrOpCodes.OPCODE_MULT, aTokenMap, '*', '*' ) && - initOpCode( maParserMap, mrOpCodes.OPCODE_DIV, aTokenMap, '/', '/' ) && - initOpCode( maParserMap, mrOpCodes.OPCODE_POWER, aTokenMap, '^', '^' ) && - initOpCode( maParserMap, mrOpCodes.OPCODE_CONCAT, aTokenMap, '&', '&' ) && - initOpCode( maParserMap, mrOpCodes.OPCODE_EQUAL, aTokenMap, '=', '=' ) && - initOpCode( maParserMap, mrOpCodes.OPCODE_NOT_EQUAL, aTokenMap, "<>", "<>" ) && - initOpCode( maParserMap, mrOpCodes.OPCODE_LESS, aTokenMap, '<', '<' ) && - initOpCode( maParserMap, mrOpCodes.OPCODE_LESS_EQUAL, aTokenMap, "<=", "<=" ) && - initOpCode( maParserMap, mrOpCodes.OPCODE_GREATER, aTokenMap, '>', '>' ) && - initOpCode( maParserMap, mrOpCodes.OPCODE_GREATER_EQUAL, aTokenMap, ">=", ">=" ) && - initOpCode( maParserMap, mrOpCodes.OPCODE_INTERSECT, aTokenMap, '!', ' ' ) && - initOpCode( maParserMap, mrOpCodes.OPCODE_LIST, aTokenMap, '~', ',' ) && - initOpCode( maParserMap, mrOpCodes.OPCODE_RANGE, aTokenMap, ':', ':' ) && - // functions - fillTokenMap( aTokenMap, aEntrySeq, xMapper, FUNCTIONS ) && - initFuncNames( aEntrySeq ) && - initOpCode( maParserMap, mrOpCodes.OPCODE_DDE, aTokenMap, "DDE", 0 ); - - // OPCODE_PLUS_SIGN and OPCODE_ADD should be equal, otherwise "+" has to be passed above - OSL_ENSURE( mrOpCodes.OPCODE_PLUS_SIGN == mrOpCodes.OPCODE_ADD, - "FunctionProviderImpl::initOpCodes - need opcode mapping for OPCODE_PLUS_SIGN" ); - // OPCODE_LIST not supported in Calc core - mrOpCodes.OPCODE_LIST = mrOpCodes.OPCODE_SEP; - } - catch( Exception& ) - { - } - OSL_ENSURE( bIsValid, "FunctionProviderImpl::initOpCodes - opcodes not initialized" ); -} - -void FunctionProviderImpl::initFuncOpCode( FunctionInfo& orFuncInfo, const FormulaTokenMap& rFuncTokens ) -{ - bool bRet = false; - if( orFuncInfo.mnOobFuncId == OOBIN_FUNC_EXTERNCALL ) + if( orFuncInfo.maOdfFuncName.getLength() > 0 ) { - orFuncInfo.mnApiOpCode = mrOpCodes.OPCODE_EXTERNAL; - bRet = true; - } - else if( orFuncInfo.maOdfFuncName.getLength() > 0 ) - { - FormulaTokenMap::const_iterator aIt = rFuncTokens.find( orFuncInfo.maOdfFuncName ); - if( aIt != rFuncTokens.end() ) + ApiTokenMap::const_iterator aIt = rFuncTokenMap.find( orFuncInfo.maOdfFuncName ); + if( aIt != rFuncTokenMap.end() ) { orFuncInfo.mnApiOpCode = aIt->second.OpCode; - OSL_ENSURE( orFuncInfo.mnApiOpCode != mrOpCodes.OPCODE_NONAME, - OStringBuffer( "FunctionProviderImpl::initFuncOpCode - no valid op-code for \"" ). - append( OUStringToOString( orFuncInfo.maOdfFuncName, RTL_TEXTENCODING_ASCII_US ) ). - append( '"' ).getStr() ); - OSL_ENSURE( orFuncInfo.maOoxFuncName.getLength() > 0, - OStringBuffer( "FunctionProviderImpl::initFuncOpCode - no valid OOX function name for \"" ). + bIsValid = + (orFuncInfo.mnApiOpCode >= 0) && + (orFuncInfo.mnApiOpCode != OPCODE_UNKNOWN) && + (orFuncInfo.mnApiOpCode != OPCODE_NONAME) && + (orFuncInfo.maOoxFuncName.getLength() > 0); + OSL_ENSURE( bIsValid, + OStringBuffer( "OpCodeProvider::initFuncOpCode - no valid opcode or missing OOX function name for ODF function \"" ). append( OUStringToOString( orFuncInfo.maOdfFuncName, RTL_TEXTENCODING_ASCII_US ) ). append( '"' ).getStr() ); - bRet = (orFuncInfo.mnApiOpCode != mrOpCodes.OPCODE_EXTERNAL) || - ((aIt->second.Data >>= orFuncInfo.maExtProgName) && (orFuncInfo.maExtProgName.getLength() > 0)); - if( bRet ) + + if( bIsValid && (orFuncInfo.mnApiOpCode == OPCODE_EXTERNAL) ) + { + bIsValid = (aIt->second.Data >>= orFuncInfo.maExtProgName) && (orFuncInfo.maExtProgName.getLength() > 0); + OSL_ENSURE( bIsValid, + OStringBuffer( "OpCodeProvider::initFuncOpCode - no programmatical name for external function \"" ). + append( OUStringToOString( orFuncInfo.maOdfFuncName, RTL_TEXTENCODING_ASCII_US ) ). + append( '"' ).getStr() ); + } + + if( bIsValid ) { // create the parser map entry FormulaOpCodeMapEntry aEntry; aEntry.Name = orFuncInfo.maOoxFuncName; aEntry.Token = aIt->second; - maParserMap.push_back( aEntry ); + mxParserMap->push_back( aEntry ); } } - OSL_ENSURE( bRet, - OStringBuffer( "FunctionProviderImpl::initFuncOpCode - opcode or external name for \"" ). - append( OUStringToOString( orFuncInfo.maOdfFuncName, RTL_TEXTENCODING_ASCII_US ) ). - append( "\" not found" ).getStr() ); } - if( !bRet || (orFuncInfo.mnApiOpCode == mrOpCodes.OPCODE_UNKNOWN) ) - orFuncInfo.mnApiOpCode = mrOpCodes.OPCODE_NONAME; -} - -void FunctionProviderImpl::initFuncMaps( const FunctionData* pBeg, const FunctionData* pEnd ) -{ - for( const FunctionData* pIt = pBeg; pIt != pEnd; ++pIt ) + else if( orFuncInfo.mnBiffFuncId == BIFF_FUNC_EXTERNCALL ) { - if( pIt->isSupported( mbImportFilter ) ) - { - // create a function info object - FunctionInfoRef xFuncInfo( new FunctionInfo ); - if( pIt->mpcOdfFuncName ) - xFuncInfo->maOdfFuncName = OUString::createFromAscii( pIt->mpcOdfFuncName ); - if( pIt->mpcOoxFuncName ) - xFuncInfo->maOoxFuncName = OUString::createFromAscii( pIt->mpcOoxFuncName ); - if( getFlag( pIt->mnFlags, FUNCFLAG_MACROCALL ) ) - xFuncInfo->maExternCallName = CREATE_OUSTRING( "_xlfn." ) + xFuncInfo->maOoxFuncName; - else if( getFlag( pIt->mnFlags, FUNCFLAG_EXTERNAL ) ) - xFuncInfo->maExternCallName = xFuncInfo->maOoxFuncName; - xFuncInfo->mnOobFuncId = pIt->mnOobFuncId; - xFuncInfo->mnBiffFuncId = pIt->mnBiffFuncId; - xFuncInfo->mnMinParamCount = pIt->mnMinParamCount; - xFuncInfo->mnMaxParamCount = (pIt->mnMaxParamCount == MX) ? mnMaxParam : pIt->mnMaxParamCount; - xFuncInfo->mnRetClass = pIt->mnRetClass; - xFuncInfo->mpnParamClass = pIt->mpnParamClass; - xFuncInfo->mbVolatile = getFlag( pIt->mnFlags, FUNCFLAG_VOLATILE ); - - // get API opcode from BIFF function index or function name - initFuncOpCode( *xFuncInfo, getFlag( pIt->mnFlags, FUNCFLAG_EXTERNAL ) ? maExtFuncTokens : maIntFuncTokens ); - - // insert the function info into the maps - if( xFuncInfo->mnApiOpCode != mrOpCodes.OPCODE_NONAME ) - { - if( (xFuncInfo->mnApiOpCode == mrOpCodes.OPCODE_EXTERNAL) && (xFuncInfo->maExtProgName.getLength() > 0) ) - maExtProgFuncs[ xFuncInfo->maExtProgName ] = xFuncInfo; - else - maOpCodeFuncs[ xFuncInfo->mnApiOpCode ] = xFuncInfo; - } - if( xFuncInfo->maOoxFuncName.getLength() > 0 ) - maOoxFuncs[ xFuncInfo->maOoxFuncName ] = xFuncInfo; - if( xFuncInfo->mnOobFuncId != NOID ) - maOobFuncs[ xFuncInfo->mnOobFuncId ] = xFuncInfo; - if( xFuncInfo->mnBiffFuncId != NOID ) - maBiffFuncs[ xFuncInfo->mnBiffFuncId ] = xFuncInfo; - if( xFuncInfo->maExternCallName.getLength() > 0 ) - maMacroFuncs[ xFuncInfo->maExternCallName ] = xFuncInfo; - } + orFuncInfo.mnApiOpCode = OPCODE_EXTERNAL; + bIsValid = true; } -} - -// function provider ========================================================== - -FunctionProvider::FunctionProvider( const WorkbookHelper& rHelper ) -{ - bool bImportFilter = rHelper.getBaseFilter().isImportFilter(); - switch( rHelper.getFilterType() ) + else if( orFuncInfo.maOoxFuncName.getLength() > 0 ) { - case FILTER_OOX: - mxImpl.reset( new FunctionProviderImpl( *this, rHelper.getDocument(), bImportFilter ) ); - break; - case FILTER_BIFF: - mxImpl.reset( new FunctionProviderImpl( *this, rHelper.getDocument(), rHelper.getBiff(), bImportFilter ) ); - break; - case FILTER_UNKNOWN: break; + orFuncInfo.mnApiOpCode = OPCODE_BAD; + bIsValid = true; } -} - -FunctionProvider::FunctionProvider( const Reference< XSpreadsheetDocument >& rxDocument, bool bImportFilter ) -{ - mxImpl.reset( new FunctionProviderImpl( *this, rxDocument, bImportFilter ) ); -} - -FunctionProvider::FunctionProvider( const Reference< XSpreadsheetDocument >& rxDocument, BiffType eBiff, bool bImportFilter ) -{ - mxImpl.reset( new FunctionProviderImpl( *this, rxDocument, eBiff, bImportFilter ) ); -} -FunctionProvider::~FunctionProvider() -{ + if( !bIsValid || (orFuncInfo.mnApiOpCode == OPCODE_UNKNOWN) || (orFuncInfo.mnApiOpCode < 0) ) + orFuncInfo.mnApiOpCode = OPCODE_NONAME; + return bIsValid; } -const FunctionInfo* FunctionProvider::getFuncInfoFromApiToken( const ApiToken& rToken ) const +bool OpCodeProvider::initFuncOpCodes( const ApiTokenMap& rIntFuncTokenMap, const ApiTokenMap& rExtFuncTokenMap ) { - return mxImpl->getFuncInfoFromApiToken( rToken ); -} - -const FunctionInfo* FunctionProvider::getFuncInfoFromOoxFuncName( const OUString& rFuncName ) const -{ - return mxImpl->getFuncInfoFromOoxFuncName( rFuncName ); -} - -const FunctionInfo* FunctionProvider::getFuncInfoFromOobFuncId( sal_uInt16 nFuncId ) const -{ - return mxImpl->getFuncInfoFromOobFuncId( nFuncId ); -} - -const FunctionInfo* FunctionProvider::getFuncInfoFromBiffFuncId( sal_uInt16 nFuncId ) const -{ - return mxImpl->getFuncInfoFromBiffFuncId( nFuncId ); -} - -const FunctionInfo* FunctionProvider::getFuncInfoFromExternCallName( const OUString& rExtCallName ) const -{ - return mxImpl->getFuncInfoFromExternCallName( rExtCallName ); -} - -Sequence< FormulaOpCodeMapEntry > FunctionProvider::getOoxParserMap() const -{ - return mxImpl->getOoxParserMap(); -} - -// token sequence iterator ==================================================== - -ApiTokenIterator::ApiTokenIterator( const ApiTokenSequence& rTokens, sal_Int32 nSpacesOpCode, bool bSkipSpaces ) : - mpToken( rTokens.getConstArray() ), - mpTokenEnd( rTokens.getConstArray() + rTokens.getLength() ), - mnSpacesOpCode( nSpacesOpCode ), - mbSkipSpaces( bSkipSpaces ) -{ - skipSpaces(); -} - -ApiTokenIterator::ApiTokenIterator( const ApiTokenIterator& rIter, bool bSkipSpaces ) : - mpToken( rIter.mpToken ), - mpTokenEnd( rIter.mpTokenEnd ), - mnSpacesOpCode( rIter.mnSpacesOpCode ), - mbSkipSpaces( bSkipSpaces ) -{ - skipSpaces(); -} - -ApiTokenIterator& ApiTokenIterator::operator++() -{ - if( is() ) + bool bIsValid = true; + for( FuncVector::const_iterator aIt = getFuncs().begin(), aEnd = getFuncs().end(); aIt != aEnd; ++aIt ) { - ++mpToken; - skipSpaces(); + FunctionInfoRef xFuncInfo = *aIt; + // set API opcode from ODF function name + bIsValid &= initFuncOpCode( *xFuncInfo, xFuncInfo->mbExternal ? rExtFuncTokenMap : rIntFuncTokenMap ); + // insert the function info into the maps + if( xFuncInfo->mnApiOpCode != OPCODE_NONAME ) + { + if( (xFuncInfo->mnApiOpCode == OPCODE_EXTERNAL) && (xFuncInfo->maExtProgName.getLength() > 0) ) + (*mxExtProgFuncs)[ xFuncInfo->maExtProgName ] = xFuncInfo; + else + (*mxOpCodeFuncs)[ xFuncInfo->mnApiOpCode ] = xFuncInfo; + } } - return *this; + return bIsValid; } -void ApiTokenIterator::skipSpaces() -{ - if( mbSkipSpaces ) - while( is() && (mpToken->OpCode == mnSpacesOpCode) ) - ++mpToken; -} - -// formual contexts =========================================================== +// formula contexts =========================================================== FormulaContext::FormulaContext( bool bRelativeAsOffset, bool b2dRefsAs3dRefs ) : maBaseAddress( 0, 0, 0 ), @@ -1332,8 +1306,7 @@ TokenToRangeListState lclProcessClose( sal_Int32& ornParenLevel ) // ---------------------------------------------------------------------------- FormulaProcessorBase::FormulaProcessorBase( const WorkbookHelper& rHelper ) : - WorkbookHelper( rHelper ), - maFuncProv( rHelper ), + OpCodeProvider( rHelper ), maAbsNameProp( CREATE_OUSTRING( "AbsoluteName" ) ) { } @@ -1478,8 +1451,8 @@ OUString FormulaProcessorBase::generateApiArray( const Matrix< Any >& rMatrix ) Any FormulaProcessorBase::extractReference( const ApiTokenSequence& rTokens ) const { - ApiTokenIterator aTokenIt( rTokens, maFuncProv.OPCODE_SPACES, true ); - if( aTokenIt.is() && (aTokenIt->OpCode == maFuncProv.OPCODE_PUSH) ) + ApiTokenIterator aTokenIt( rTokens, OPCODE_SPACES, true ); + if( aTokenIt.is() && (aTokenIt->OpCode == OPCODE_PUSH) ) { Any aRefAny = aTokenIt->Data; if( !(++aTokenIt).is() && (aRefAny.has< SingleReference >() || aRefAny.has< ComplexReference >()) ) @@ -1494,34 +1467,34 @@ void FormulaProcessorBase::extractCellRangeList( ApiCellRangeList& orRanges, orRanges.clear(); TokenToRangeListState eState = STATE_OPEN; sal_Int32 nParenLevel = 0; - for( ApiTokenIterator aIt( rTokens, maFuncProv.OPCODE_SPACES, true ); aIt.is() && (eState != STATE_ERROR); ++aIt ) + for( ApiTokenIterator aIt( rTokens, OPCODE_SPACES, true ); aIt.is() && (eState != STATE_ERROR); ++aIt ) { sal_Int32 nOpCode = aIt->OpCode; switch( eState ) { case STATE_REF: - if( nOpCode == maFuncProv.OPCODE_LIST ) eState = STATE_SEP; - else if( nOpCode == maFuncProv.OPCODE_CLOSE ) eState = lclProcessClose( nParenLevel ); - else eState = STATE_ERROR; + if( nOpCode == OPCODE_LIST ) eState = STATE_SEP; + else if( nOpCode == OPCODE_CLOSE ) eState = lclProcessClose( nParenLevel ); + else eState = STATE_ERROR; break; case STATE_SEP: - if( nOpCode == maFuncProv.OPCODE_PUSH ) eState = lclProcessRef( orRanges, aIt->Data, nFilterBySheet ); - else if( nOpCode == maFuncProv.OPCODE_LIST ) eState = STATE_SEP; - else if( nOpCode == maFuncProv.OPCODE_OPEN ) eState = lclProcessOpen( nParenLevel ); - else if( nOpCode == maFuncProv.OPCODE_CLOSE ) eState = lclProcessClose( nParenLevel ); - else eState = STATE_ERROR; + if( nOpCode == OPCODE_PUSH ) eState = lclProcessRef( orRanges, aIt->Data, nFilterBySheet ); + else if( nOpCode == OPCODE_LIST ) eState = STATE_SEP; + else if( nOpCode == OPCODE_OPEN ) eState = lclProcessOpen( nParenLevel ); + else if( nOpCode == OPCODE_CLOSE ) eState = lclProcessClose( nParenLevel ); + else eState = STATE_ERROR; break; case STATE_OPEN: - if( nOpCode == maFuncProv.OPCODE_PUSH ) eState = lclProcessRef( orRanges, aIt->Data, nFilterBySheet ); - else if( nOpCode == maFuncProv.OPCODE_LIST ) eState = STATE_SEP; - else if( nOpCode == maFuncProv.OPCODE_OPEN ) eState = lclProcessOpen( nParenLevel ); - else if( nOpCode == maFuncProv.OPCODE_CLOSE ) eState = lclProcessClose( nParenLevel ); - else eState = STATE_ERROR; + if( nOpCode == OPCODE_PUSH ) eState = lclProcessRef( orRanges, aIt->Data, nFilterBySheet ); + else if( nOpCode == OPCODE_LIST ) eState = STATE_SEP; + else if( nOpCode == OPCODE_OPEN ) eState = lclProcessOpen( nParenLevel ); + else if( nOpCode == OPCODE_CLOSE ) eState = lclProcessClose( nParenLevel ); + else eState = STATE_ERROR; break; case STATE_CLOSE: - if( nOpCode == maFuncProv.OPCODE_LIST ) eState = STATE_SEP; - else if( nOpCode == maFuncProv.OPCODE_CLOSE ) eState = lclProcessClose( nParenLevel ); - else eState = STATE_ERROR; + if( nOpCode == OPCODE_LIST ) eState = STATE_SEP; + else if( nOpCode == OPCODE_CLOSE ) eState = lclProcessClose( nParenLevel ); + else eState = STATE_ERROR; break; default:; } @@ -1535,8 +1508,8 @@ void FormulaProcessorBase::extractCellRangeList( ApiCellRangeList& orRanges, bool FormulaProcessorBase::extractString( OUString& orString, const ApiTokenSequence& rTokens ) const { - ApiTokenIterator aTokenIt( rTokens, maFuncProv.OPCODE_SPACES, true ); - return aTokenIt.is() && (aTokenIt->OpCode == maFuncProv.OPCODE_PUSH) && (aTokenIt->Data >>= orString) && !(++aTokenIt).is(); + ApiTokenIterator aTokenIt( rTokens, OPCODE_SPACES, true ); + return aTokenIt.is() && (aTokenIt->OpCode == OPCODE_PUSH) && (aTokenIt->Data >>= orString) && !(++aTokenIt).is(); } void FormulaProcessorBase::convertStringToStringList( @@ -1558,8 +1531,8 @@ void FormulaProcessorBase::convertStringToStringList( aEntry = aEntry.copy( nStart ); } if( !aNewTokens.empty() ) - aNewTokens.push_back( ApiToken( maFuncProv.OPCODE_SEP, Any() ) ); - aNewTokens.push_back( ApiToken( maFuncProv.OPCODE_PUSH, Any( aEntry ) ) ); + aNewTokens.push_back( ApiToken( OPCODE_SEP, Any() ) ); + aNewTokens.push_back( ApiToken( OPCODE_PUSH, Any( aEntry ) ) ); } orTokens = ContainerHelper::vectorToSequence( aNewTokens ); } diff --git a/oox/source/xls/formulaparser.cxx b/oox/source/xls/formulaparser.cxx index 055dd31532eb..8cc2ba879bf3 100644 --- a/oox/source/xls/formulaparser.cxx +++ b/oox/source/xls/formulaparser.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: formulaparser.cxx,v $ - * $Revision: 1.5 $ + * $Revision: 1.5.20.5 $ * * This file is part of OpenOffice.org. * @@ -66,12 +66,10 @@ namespace xls { // parser implementation base ================================================= -class FormulaParserImpl : public WorkbookHelper +class FormulaParserImpl : public OpCodeProvider { public: - explicit FormulaParserImpl( - const WorkbookHelper& rHelper, - const FunctionProvider& rFuncProv ); + explicit FormulaParserImpl( const OpCodeProvider& rOpCodeProv ); /** Converts an XML formula string. */ virtual void importOoxFormula( @@ -95,6 +93,9 @@ public: const ApiTokenSequence& rTokens ); protected: + typedef ::std::pair< sal_Int32, bool > WhiteSpace; + typedef ::std::vector< WhiteSpace > WhiteSpaceVec; + /** Sets the current formula context used for import. */ inline FormulaContext& getFormulaContext() const { return *mpContext; } @@ -111,15 +112,16 @@ protected: // token array ------------------------------------------------------------ bool resetSpaces(); - inline void incLeadingSpaces( sal_Int32 nSpaces ) { mnLeadingSpaces += nSpaces; } - inline void incOpeningSpaces( sal_Int32 nSpaces ) { mnOpeningSpaces += nSpaces; } - inline void incClosingSpaces( sal_Int32 nSpaces ) { mnClosingSpaces += nSpaces; } + static void appendSpaces( WhiteSpaceVec& orSpaces, sal_Int32 nCount, bool bLineFeed ); + void appendLeadingSpaces( sal_Int32 nCount, bool bLineFeed ); + void appendOpeningSpaces( sal_Int32 nCount, bool bLineFeed ); + void appendClosingSpaces( sal_Int32 nCount, bool bLineFeed ); size_t getFormulaSize() const; Any& appendRawToken( sal_Int32 nOpCode ); Any& insertRawToken( sal_Int32 nOpCode, size_t nIndexFromEnd ); - size_t appendSpacesToken( sal_Int32 nSpaces ); - size_t insertSpacesToken( sal_Int32 nSpaces, size_t nIndexFromEnd ); + size_t appendWhiteSpaceTokens( const WhiteSpaceVec* pSpaces ); + size_t insertWhiteSpaceTokens( const WhiteSpaceVec* pSpaces, size_t nIndexFromEnd ); size_t getOperandSize( size_t nOpCountFromEnd, size_t nOpIndex ) const; void pushOperandSize( size_t nSize ); @@ -129,20 +131,20 @@ protected: void removeOperand( size_t nOpCountFromEnd, size_t nOpIndex ); void removeLastOperands( size_t nOpCountFromEnd ); - bool pushOperandToken( sal_Int32 nOpCode, sal_Int32 nSpaces ); - bool pushAnyOperandToken( const Any& rAny, sal_Int32 nOpCode, sal_Int32 nSpaces ); + bool pushOperandToken( sal_Int32 nOpCode, const WhiteSpaceVec* pSpaces = 0 ); + bool pushAnyOperandToken( const Any& rAny, sal_Int32 nOpCode, const WhiteSpaceVec* pSpaces = 0 ); template< typename Type > - bool pushValueOperandToken( const Type& rValue, sal_Int32 nOpCode, sal_Int32 nSpaces ); + bool pushValueOperandToken( const Type& rValue, sal_Int32 nOpCode, const WhiteSpaceVec* pSpaces = 0 ); template< typename Type > - inline bool pushValueOperandToken( const Type& rValue, sal_Int32 nSpaces ) - { return pushValueOperandToken( rValue, mrFuncProv.OPCODE_PUSH, nSpaces ); } - bool pushParenthesesOperandToken( sal_Int32 nOpeningSpaces, sal_Int32 nClosingSpaces ); - bool pushUnaryPreOperatorToken( sal_Int32 nOpCode, sal_Int32 nSpaces ); - bool pushUnaryPostOperatorToken( sal_Int32 nOpCode, sal_Int32 nSpaces ); - bool pushBinaryOperatorToken( sal_Int32 nOpCode, sal_Int32 nSpaces ); - bool pushParenthesesOperatorToken( sal_Int32 nOpeningSpaces, sal_Int32 nClosingSpaces ); - bool pushFunctionOperatorToken( sal_Int32 nOpCode, size_t nParamCount, sal_Int32 nLeadingSpaces, sal_Int32 nClosingSpaces ); - bool pushFunctionOperatorToken( const FunctionInfo& rFuncInfo, size_t nParamCount, sal_Int32 nLeadingSpaces, sal_Int32 nClosingSpaces ); + inline bool pushValueOperandToken( const Type& rValue, const WhiteSpaceVec* pSpaces = 0 ) + { return pushValueOperandToken( rValue, OPCODE_PUSH, pSpaces ); } + bool pushParenthesesOperandToken( const WhiteSpaceVec* pOpeningSpaces = 0, const WhiteSpaceVec* pClosingSpaces = 0 ); + bool pushUnaryPreOperatorToken( sal_Int32 nOpCode, const WhiteSpaceVec* pSpaces = 0 ); + bool pushUnaryPostOperatorToken( sal_Int32 nOpCode, const WhiteSpaceVec* pSpaces = 0 ); + bool pushBinaryOperatorToken( sal_Int32 nOpCode, const WhiteSpaceVec* pSpaces = 0 ); + bool pushParenthesesOperatorToken( const WhiteSpaceVec* pOpeningSpaces = 0, const WhiteSpaceVec* pClosingSpaces = 0 ); + bool pushFunctionOperatorToken( sal_Int32 nOpCode, size_t nParamCount, const WhiteSpaceVec* pLeadingSpaces = 0, const WhiteSpaceVec* pClosingSpaces = 0 ); + bool pushFunctionOperatorToken( const FunctionInfo& rFuncInfo, size_t nParamCount, const WhiteSpaceVec* pLeadingSpaces = 0, const WhiteSpaceVec* pClosingSpaces = 0 ); bool pushOperand( sal_Int32 nOpCode ); bool pushAnyOperand( const Any& rAny, sal_Int32 nOpCode ); @@ -150,9 +152,10 @@ protected: bool pushValueOperand( const Type& rValue, sal_Int32 nOpCode ); template< typename Type > inline bool pushValueOperand( const Type& rValue ) - { return pushValueOperand( rValue, mrFuncProv.OPCODE_PUSH ); } + { return pushValueOperand( rValue, OPCODE_PUSH ); } bool pushBoolOperand( bool bValue ); bool pushErrorOperand( double fEncodedError ); + bool pushBiffBoolOperand( sal_uInt8 nValue ); bool pushBiffErrorOperand( sal_uInt8 nErrorCode ); bool pushParenthesesOperand(); bool pushReferenceOperand( const BinSingleRef2d& rRef, bool bDeleted, bool bRelativeAsOffset ); @@ -160,7 +163,7 @@ protected: bool pushReferenceOperand( const LinkSheetRange& rSheetRange, const BinSingleRef2d& rRef, bool bDeleted, bool bRelativeAsOffset ); bool pushReferenceOperand( const LinkSheetRange& rSheetRange, const BinComplexRef2d& rRef, bool bDeleted, bool bRelativeAsOffset ); bool pushNlrOperand( const BinSingleRef2d& rRef ); - bool pushEmbeddedRefOperand( const DefinedNameBase& rName ); + bool pushEmbeddedRefOperand( const DefinedNameBase& rName, bool bPushBadToken ); bool pushDefinedNameOperand( const DefinedNameRef& rxDefName ); bool pushDdeLinkOperand( const OUString& rDdeServer, const OUString& rDdeTopic, const OUString& rDdeItem ); bool pushExternalNameOperand( const ExternalNameRef& rxExtName, ExternalLinkType eLinkType ); @@ -193,50 +196,50 @@ private: const ApiToken* processParameters( const FunctionInfo& rFuncInfo, const ApiToken* pToken, const ApiToken* pTokenEnd ); bool isEmptyParameter( const ApiToken* pToken, const ApiToken* pTokenEnd ) const; - OUString getExternCallParameter( const ApiToken* pToken, const ApiToken* pTokenEnd ) const; + const ApiToken* getExternCallToken( const ApiToken* pToken, const ApiToken* pTokenEnd ) const; + const FunctionInfo* convertExternCallParam( ApiToken& orFuncToken, const ApiToken& rECToken ) const; const ApiToken* skipParentheses( const ApiToken* pToken, const ApiToken* pTokenEnd ) const; const ApiToken* findParameters( ParameterPosVector& rParams, const ApiToken* pToken, const ApiToken* pTokenEnd ) const; void appendCalcOnlyParameter( const FunctionInfo& rFuncInfo, size_t nParam ); void appendRequiredParameters( const FunctionInfo& rFuncInfo, size_t nParamCount ); void appendFinalToken( const ApiToken& rToken ); - Any& appendFinalToken( sal_Int32 nOpCode ); protected: - const FunctionProvider& mrFuncProv; /// Function info provider. const sal_Int32 mnMaxApiCol; /// Maximum column index in own document. const sal_Int32 mnMaxApiRow; /// Maximum row index in own document. const sal_Int32 mnMaxXlsCol; /// Maximum column index in imported document. const sal_Int32 mnMaxXlsRow; /// Maximum row index in imported document. private: - typedef ::std::vector< ApiToken > ApiTokenVector; - typedef ::std::vector< size_t > SizeTypeVector; + typedef ::std::vector< size_t > SizeTypeVector; ApiTokenVector maTokenStorage; /// Raw unordered token storage. SizeTypeVector maTokenIndexes; /// Indexes into maTokenStorage. SizeTypeVector maOperandSizeStack; /// Stack with token sizes per operand. + WhiteSpaceVec maLeadingSpaces; /// List of whitespaces before next token. + WhiteSpaceVec maOpeningSpaces; /// List of whitespaces before opening parenthesis. + WhiteSpaceVec maClosingSpaces; /// List of whitespaces before closing parenthesis. FormulaContext* mpContext; /// Current formula context. - sal_Int32 mnLeadingSpaces; /// Current number of spaces before next token. - sal_Int32 mnOpeningSpaces; /// Current number of spaces before opening parenthesis. - sal_Int32 mnClosingSpaces; /// Current number of spaces before closing parenthesis. }; // ---------------------------------------------------------------------------- -FormulaParserImpl::FormulaParserImpl( const WorkbookHelper& rHelper, const FunctionProvider& rFuncProv ) : - WorkbookHelper( rHelper ), - mrFuncProv( rFuncProv ), - mnMaxApiCol( rHelper.getAddressConverter().getMaxApiAddress().Column ), - mnMaxApiRow( rHelper.getAddressConverter().getMaxApiAddress().Row ), - mnMaxXlsCol( rHelper.getAddressConverter().getMaxXlsAddress().Column ), - mnMaxXlsRow( rHelper.getAddressConverter().getMaxXlsAddress().Row ), +FormulaParserImpl::FormulaParserImpl( const OpCodeProvider& rOpCodeProv ) : + OpCodeProvider( rOpCodeProv ), + mnMaxApiCol( rOpCodeProv.getAddressConverter().getMaxApiAddress().Column ), + mnMaxApiRow( rOpCodeProv.getAddressConverter().getMaxApiAddress().Row ), + mnMaxXlsCol( rOpCodeProv.getAddressConverter().getMaxXlsAddress().Column ), + mnMaxXlsRow( rOpCodeProv.getAddressConverter().getMaxXlsAddress().Row ), mpContext( 0 ) { + // reserve enough space to make resize(), push_back() etc. cheap maTokenStorage.reserve( 0x2000 ); maTokenIndexes.reserve( 0x2000 ); maOperandSizeStack.reserve( 256 ); - resetSpaces(); + maLeadingSpaces.reserve( 256 ); + maOpeningSpaces.reserve( 256 ); + maClosingSpaces.reserve( 256 ); } void FormulaParserImpl::importOoxFormula( FormulaContext&, const OUString& ) @@ -300,10 +303,34 @@ void FormulaParserImpl::setSharedFormula( const BinAddress& rBaseAddr ) bool FormulaParserImpl::resetSpaces() { - mnLeadingSpaces = mnOpeningSpaces = mnClosingSpaces = 0; + maLeadingSpaces.clear(); + maOpeningSpaces.clear(); + maClosingSpaces.clear(); return true; } +void FormulaParserImpl::appendSpaces( WhiteSpaceVec& orSpaces, sal_Int32 nCount, bool bLineFeed ) +{ + OSL_ENSURE( nCount >= 0, "FormulaParserImpl::appendSpaces - negative count" ); + if( nCount > 0 ) + orSpaces.push_back( WhiteSpace( nCount, bLineFeed ) ); +} + +void FormulaParserImpl::appendLeadingSpaces( sal_Int32 nCount, bool bLineFeed ) +{ + appendSpaces( maLeadingSpaces, nCount, bLineFeed ); +} + +void FormulaParserImpl::appendOpeningSpaces( sal_Int32 nCount, bool bLineFeed ) +{ + appendSpaces( maOpeningSpaces, nCount, bLineFeed ); +} + +void FormulaParserImpl::appendClosingSpaces( sal_Int32 nCount, bool bLineFeed ) +{ + appendSpaces( maClosingSpaces, nCount, bLineFeed ); +} + size_t FormulaParserImpl::getFormulaSize() const { return maTokenIndexes.size(); @@ -311,40 +338,30 @@ size_t FormulaParserImpl::getFormulaSize() const Any& FormulaParserImpl::appendRawToken( sal_Int32 nOpCode ) { - size_t nTokenIndex = maTokenStorage.size(); - maTokenStorage.resize( nTokenIndex + 1 ); - maTokenStorage.back().OpCode = nOpCode; - maTokenIndexes.push_back( nTokenIndex ); - return maTokenStorage.back().Data; + maTokenIndexes.push_back( maTokenStorage.size() ); + return maTokenStorage.append( nOpCode ); } Any& FormulaParserImpl::insertRawToken( sal_Int32 nOpCode, size_t nIndexFromEnd ) { - size_t nTokenIndex = maTokenStorage.size(); - maTokenStorage.resize( nTokenIndex + 1 ); - maTokenStorage.back().OpCode = nOpCode; - maTokenIndexes.insert( maTokenIndexes.end() - nIndexFromEnd, nTokenIndex ); - return maTokenStorage.back().Data; + maTokenIndexes.insert( maTokenIndexes.end() - nIndexFromEnd, maTokenStorage.size() ); + return maTokenStorage.append( nOpCode ); } -size_t FormulaParserImpl::appendSpacesToken( sal_Int32 nSpaces ) +size_t FormulaParserImpl::appendWhiteSpaceTokens( const WhiteSpaceVec* pSpaces ) { - if( nSpaces > 0 ) - { - appendRawToken( mrFuncProv.OPCODE_SPACES ) <<= nSpaces; - return 1; - } - return 0; + if( pSpaces && !pSpaces->empty() ) + for( WhiteSpaceVec::const_iterator aIt = pSpaces->begin(), aEnd = pSpaces->end(); aIt != aEnd; ++aIt ) + appendRawToken( OPCODE_SPACES ) <<= aIt->first; + return pSpaces ? pSpaces->size() : 0; } -size_t FormulaParserImpl::insertSpacesToken( sal_Int32 nSpaces, size_t nIndexFromEnd ) +size_t FormulaParserImpl::insertWhiteSpaceTokens( const WhiteSpaceVec* pSpaces, size_t nIndexFromEnd ) { - if( nSpaces > 0 ) - { - insertRawToken( mrFuncProv.OPCODE_SPACES, nIndexFromEnd ) <<= nSpaces; - return 1; - } - return 0; + if( pSpaces && !pSpaces->empty() ) + for( WhiteSpaceVec::const_iterator aIt = pSpaces->begin(), aEnd = pSpaces->end(); aIt != aEnd; ++aIt ) + insertRawToken( OPCODE_SPACES, nIndexFromEnd ) <<= aIt->first; + return pSpaces ? pSpaces->size() : 0; } size_t FormulaParserImpl::getOperandSize( size_t nOpCountFromEnd, size_t nOpIndex ) const @@ -397,97 +414,97 @@ void FormulaParserImpl::removeLastOperands( size_t nOpCountFromEnd ) removeOperand( 1, 0 ); } -bool FormulaParserImpl::pushOperandToken( sal_Int32 nOpCode, sal_Int32 nSpaces ) +bool FormulaParserImpl::pushOperandToken( sal_Int32 nOpCode, const WhiteSpaceVec* pSpaces ) { - size_t nSpacesSize = appendSpacesToken( nSpaces ); + size_t nSpacesSize = appendWhiteSpaceTokens( pSpaces ); appendRawToken( nOpCode ); pushOperandSize( nSpacesSize + 1 ); return true; } -bool FormulaParserImpl::pushAnyOperandToken( const Any& rAny, sal_Int32 nOpCode, sal_Int32 nSpaces ) +bool FormulaParserImpl::pushAnyOperandToken( const Any& rAny, sal_Int32 nOpCode, const WhiteSpaceVec* pSpaces ) { - size_t nSpacesSize = appendSpacesToken( nSpaces ); + size_t nSpacesSize = appendWhiteSpaceTokens( pSpaces ); appendRawToken( nOpCode ) = rAny; pushOperandSize( nSpacesSize + 1 ); return true; } template< typename Type > -bool FormulaParserImpl::pushValueOperandToken( const Type& rValue, sal_Int32 nOpCode, sal_Int32 nSpaces ) +bool FormulaParserImpl::pushValueOperandToken( const Type& rValue, sal_Int32 nOpCode, const WhiteSpaceVec* pSpaces ) { - size_t nSpacesSize = appendSpacesToken( nSpaces ); + size_t nSpacesSize = appendWhiteSpaceTokens( pSpaces ); appendRawToken( nOpCode ) <<= rValue; pushOperandSize( nSpacesSize + 1 ); return true; } -bool FormulaParserImpl::pushParenthesesOperandToken( sal_Int32 nOpeningSpaces, sal_Int32 nClosingSpaces ) +bool FormulaParserImpl::pushParenthesesOperandToken( const WhiteSpaceVec* pOpeningSpaces, const WhiteSpaceVec* pClosingSpaces ) { - size_t nSpacesSize = appendSpacesToken( nOpeningSpaces ); - appendRawToken( mrFuncProv.OPCODE_OPEN ); - nSpacesSize += appendSpacesToken( nClosingSpaces ); - appendRawToken( mrFuncProv.OPCODE_CLOSE ); + size_t nSpacesSize = appendWhiteSpaceTokens( pOpeningSpaces ); + appendRawToken( OPCODE_OPEN ); + nSpacesSize += appendWhiteSpaceTokens( pClosingSpaces ); + appendRawToken( OPCODE_CLOSE ); pushOperandSize( nSpacesSize + 2 ); return true; } -bool FormulaParserImpl::pushUnaryPreOperatorToken( sal_Int32 nOpCode, sal_Int32 nSpaces ) +bool FormulaParserImpl::pushUnaryPreOperatorToken( sal_Int32 nOpCode, const WhiteSpaceVec* pSpaces ) { bool bOk = maOperandSizeStack.size() >= 1; if( bOk ) { size_t nOpSize = popOperandSize(); - size_t nSpacesSize = insertSpacesToken( nSpaces, nOpSize ); + size_t nSpacesSize = insertWhiteSpaceTokens( pSpaces, nOpSize ); insertRawToken( nOpCode, nOpSize ); pushOperandSize( nOpSize + nSpacesSize + 1 ); } return bOk; } -bool FormulaParserImpl::pushUnaryPostOperatorToken( sal_Int32 nOpCode, sal_Int32 nSpaces ) +bool FormulaParserImpl::pushUnaryPostOperatorToken( sal_Int32 nOpCode, const WhiteSpaceVec* pSpaces ) { bool bOk = maOperandSizeStack.size() >= 1; if( bOk ) { size_t nOpSize = popOperandSize(); - size_t nSpacesSize = appendSpacesToken( nSpaces ); + size_t nSpacesSize = appendWhiteSpaceTokens( pSpaces ); appendRawToken( nOpCode ); pushOperandSize( nOpSize + nSpacesSize + 1 ); } return bOk; } -bool FormulaParserImpl::pushBinaryOperatorToken( sal_Int32 nOpCode, sal_Int32 nSpaces ) +bool FormulaParserImpl::pushBinaryOperatorToken( sal_Int32 nOpCode, const WhiteSpaceVec* pSpaces ) { bool bOk = maOperandSizeStack.size() >= 2; if( bOk ) { size_t nOp2Size = popOperandSize(); size_t nOp1Size = popOperandSize(); - size_t nSpacesSize = insertSpacesToken( nSpaces, nOp2Size ); + size_t nSpacesSize = insertWhiteSpaceTokens( pSpaces, nOp2Size ); insertRawToken( nOpCode, nOp2Size ); pushOperandSize( nOp1Size + nSpacesSize + 1 + nOp2Size ); } return bOk; } -bool FormulaParserImpl::pushParenthesesOperatorToken( sal_Int32 nOpeningSpaces, sal_Int32 nClosingSpaces ) +bool FormulaParserImpl::pushParenthesesOperatorToken( const WhiteSpaceVec* pOpeningSpaces, const WhiteSpaceVec* pClosingSpaces ) { bool bOk = maOperandSizeStack.size() >= 1; if( bOk ) { size_t nOpSize = popOperandSize(); - size_t nSpacesSize = insertSpacesToken( nOpeningSpaces, nOpSize ); - insertRawToken( mrFuncProv.OPCODE_OPEN, nOpSize ); - nSpacesSize += appendSpacesToken( nClosingSpaces ); - appendRawToken( mrFuncProv.OPCODE_CLOSE ); + size_t nSpacesSize = insertWhiteSpaceTokens( pOpeningSpaces, nOpSize ); + insertRawToken( OPCODE_OPEN, nOpSize ); + nSpacesSize += appendWhiteSpaceTokens( pClosingSpaces ); + appendRawToken( OPCODE_CLOSE ); pushOperandSize( nOpSize + nSpacesSize + 2 ); } return bOk; } -bool FormulaParserImpl::pushFunctionOperatorToken( sal_Int32 nOpCode, size_t nParamCount, sal_Int32 nLeadingSpaces, sal_Int32 nClosingSpaces ) +bool FormulaParserImpl::pushFunctionOperatorToken( sal_Int32 nOpCode, size_t nParamCount, const WhiteSpaceVec* pLeadingSpaces, const WhiteSpaceVec* pClosingSpaces ) { /* #i70925# if there are not enough tokens available on token stack, do not exit with error, but reduce parameter count. */ @@ -496,42 +513,48 @@ bool FormulaParserImpl::pushFunctionOperatorToken( sal_Int32 nOpCode, size_t nPa // convert all parameters on stack to a single operand separated with OPCODE_SEP bool bOk = true; for( size_t nParam = 1; bOk && (nParam < nParamCount); ++nParam ) - bOk = pushBinaryOperatorToken( mrFuncProv.OPCODE_SEP, 0 ); + bOk = pushBinaryOperatorToken( OPCODE_SEP ); // add function parentheses and function name return bOk && - ((nParamCount > 0) ? pushParenthesesOperatorToken( 0, nClosingSpaces ) : pushParenthesesOperandToken( 0, nClosingSpaces )) && - pushUnaryPreOperatorToken( nOpCode, nLeadingSpaces ); + ((nParamCount > 0) ? pushParenthesesOperatorToken( 0, pClosingSpaces ) : pushParenthesesOperandToken( 0, pClosingSpaces )) && + pushUnaryPreOperatorToken( nOpCode, pLeadingSpaces ); } -bool FormulaParserImpl::pushFunctionOperatorToken( const FunctionInfo& rFuncInfo, size_t nParamCount, sal_Int32 nLeadingSpaces, sal_Int32 nClosingSpaces ) +bool FormulaParserImpl::pushFunctionOperatorToken( const FunctionInfo& rFuncInfo, size_t nParamCount, const WhiteSpaceVec* pLeadingSpaces, const WhiteSpaceVec* pClosingSpaces ) { - bool bOk = pushFunctionOperatorToken( rFuncInfo.mnApiOpCode, nParamCount, nLeadingSpaces, nClosingSpaces ); - // try to create an external add-in call for the passed built-in function - if( bOk && (rFuncInfo.maExtProgName.getLength() > 0) ) - getOperandToken( 1, 0, 0 ).Data <<= rFuncInfo.maExtProgName; + bool bOk = pushFunctionOperatorToken( rFuncInfo.mnApiOpCode, nParamCount, pLeadingSpaces, pClosingSpaces ); + if( bOk ) + { + // create an external add-in call for the passed built-in function + if( (rFuncInfo.mnApiOpCode == OPCODE_EXTERNAL) && (rFuncInfo.maExtProgName.getLength() > 0) ) + getOperandToken( 1, 0, 0 ).Data <<= rFuncInfo.maExtProgName; + // create a bad token with unsupported function name + else if( (rFuncInfo.mnApiOpCode == OPCODE_BAD) && (rFuncInfo.maOoxFuncName.getLength() > 0) ) + getOperandToken( 1, 0, 0 ).Data <<= rFuncInfo.maOoxFuncName; + } return bOk; } bool FormulaParserImpl::pushOperand( sal_Int32 nOpCode ) { - return pushOperandToken( nOpCode, mnLeadingSpaces ) && resetSpaces(); + return pushOperandToken( nOpCode, &maLeadingSpaces ) && resetSpaces(); } bool FormulaParserImpl::pushAnyOperand( const Any& rAny, sal_Int32 nOpCode ) { - return pushAnyOperandToken( rAny, nOpCode, mnLeadingSpaces ) && resetSpaces(); + return pushAnyOperandToken( rAny, nOpCode, &maLeadingSpaces ) && resetSpaces(); } template< typename Type > bool FormulaParserImpl::pushValueOperand( const Type& rValue, sal_Int32 nOpCode ) { - return pushValueOperandToken( rValue, nOpCode, mnLeadingSpaces ) && resetSpaces(); + return pushValueOperandToken( rValue, nOpCode, &maLeadingSpaces ) && resetSpaces(); } bool FormulaParserImpl::pushBoolOperand( bool bValue ) { - if( const FunctionInfo* pFuncInfo = mrFuncProv.getFuncInfoFromOobFuncId( bValue ? OOBIN_FUNC_TRUE : OOBIN_FUNC_FALSE ) ) + if( const FunctionInfo* pFuncInfo = getFuncInfoFromOobFuncId( bValue ? OOBIN_FUNC_TRUE : OOBIN_FUNC_FALSE ) ) return pushFunctionOperator( pFuncInfo->mnApiOpCode, 0 ); return pushValueOperand< double >( bValue ? 1.0 : 0.0 ); } @@ -540,17 +563,22 @@ bool FormulaParserImpl::pushErrorOperand( double fEncodedError ) { // HACK: enclose all error codes into an 1x1 matrix // start token array with opening brace and leading spaces - pushOperand( mrFuncProv.OPCODE_ARRAY_OPEN ); + pushOperand( OPCODE_ARRAY_OPEN ); size_t nOpSize = popOperandSize(); size_t nOldArraySize = maTokenIndexes.size(); // push a double containing the Calc error code - appendRawToken( mrFuncProv.OPCODE_PUSH ) <<= fEncodedError; + appendRawToken( OPCODE_PUSH ) <<= fEncodedError; // close token array and set resulting operand size - appendRawToken( mrFuncProv.OPCODE_ARRAY_CLOSE ); + appendRawToken( OPCODE_ARRAY_CLOSE ); pushOperandSize( nOpSize + maTokenIndexes.size() - nOldArraySize ); return true; } +bool FormulaParserImpl::pushBiffBoolOperand( sal_uInt8 nValue ) +{ + return pushBoolOperand( nValue != BIFF_TOK_BOOL_FALSE ); +} + bool FormulaParserImpl::pushBiffErrorOperand( sal_uInt8 nErrorCode ) { return pushErrorOperand( BiffHelper::calcDoubleFromError( nErrorCode ) ); @@ -558,7 +586,7 @@ bool FormulaParserImpl::pushBiffErrorOperand( sal_uInt8 nErrorCode ) bool FormulaParserImpl::pushParenthesesOperand() { - return pushParenthesesOperandToken( mnOpeningSpaces, mnClosingSpaces ) && resetSpaces(); + return pushParenthesesOperandToken( &maOpeningSpaces, &maClosingSpaces ) && resetSpaces(); } bool FormulaParserImpl::pushReferenceOperand( const BinSingleRef2d& rRef, bool bDeleted, bool bRelativeAsOffset ) @@ -600,34 +628,38 @@ bool FormulaParserImpl::pushNlrOperand( const BinSingleRef2d& rRef ) { SingleReference aApiRef; convertReference2d( aApiRef, rRef, false, false ); - return pushValueOperand( aApiRef, mrFuncProv.OPCODE_NLR ); + return pushValueOperand( aApiRef, OPCODE_NLR ); } -bool FormulaParserImpl::pushEmbeddedRefOperand( const DefinedNameBase& rName ) +bool FormulaParserImpl::pushEmbeddedRefOperand( const DefinedNameBase& rName, bool bPushBadToken ) { Any aRefAny = rName.getReference( mpContext->getBaseAddress() ); - return aRefAny.hasValue() ? pushAnyOperand( aRefAny, mrFuncProv.OPCODE_PUSH ) : pushBiffErrorOperand( BIFF_ERR_NAME ); + if( aRefAny.hasValue() ) + return pushAnyOperand( aRefAny, OPCODE_PUSH ); + if( bPushBadToken && (rName.getOoxName().getLength() > 0) && (rName.getOoxName()[ 0 ] >= ' ') ) + return pushValueOperand( rName.getOoxName(), OPCODE_BAD ); + return pushBiffErrorOperand( BIFF_ERR_NAME ); } bool FormulaParserImpl::pushDefinedNameOperand( const DefinedNameRef& rxDefName ) { - if( !rxDefName ) + if( !rxDefName || (rxDefName->getOoxName().getLength() == 0) ) return pushBiffErrorOperand( BIFF_ERR_NAME ); - if( rxDefName->isMacroFunc( false ) ) - return pushValueOperand( rxDefName->getOoxName(), mrFuncProv.OPCODE_MACRO ); + if( rxDefName->isMacroFunction() ) + return pushValueOperand( rxDefName->getOoxName(), OPCODE_MACRO ); if( rxDefName->getTokenIndex() >= 0 ) - return pushValueOperand( rxDefName->getTokenIndex(), mrFuncProv.OPCODE_NAME ); - return pushEmbeddedRefOperand( *rxDefName ); + return pushValueOperand( rxDefName->getTokenIndex(), OPCODE_NAME ); + return pushEmbeddedRefOperand( *rxDefName, true ); } bool FormulaParserImpl::pushDdeLinkOperand( const OUString& rDdeServer, const OUString& rDdeTopic, const OUString& rDdeItem ) { // create the function call DDE("server";"topic";"item") return - pushValueOperandToken( rDdeServer, 0 ) && - pushValueOperandToken( rDdeTopic, 0 ) && - pushValueOperandToken( rDdeItem, 0 ) && - pushFunctionOperator( mrFuncProv.OPCODE_DDE, 3 ); + pushValueOperandToken( rDdeServer ) && + pushValueOperandToken( rDdeTopic ) && + pushValueOperandToken( rDdeItem ) && + pushFunctionOperator( OPCODE_DDE, 3 ); } bool FormulaParserImpl::pushExternalNameOperand( const ExternalNameRef& rxExtName, ExternalLinkType eLinkType ) @@ -636,12 +668,12 @@ bool FormulaParserImpl::pushExternalNameOperand( const ExternalNameRef& rxExtNam { case LINKTYPE_INTERNAL: case LINKTYPE_EXTERNAL: - return pushEmbeddedRefOperand( *rxExtName ); + return pushEmbeddedRefOperand( *rxExtName, false ); case LINKTYPE_ANALYSIS: - if( const FunctionInfo* pFuncInfo = mrFuncProv.getFuncInfoFromOoxFuncName( rxExtName->getOoxName() ) ) - if( pFuncInfo->maExternCallName.getLength() > 0 ) - return pushValueOperand( pFuncInfo->maExternCallName, mrFuncProv.OPCODE_MACRO ); + // TODO: need support for localized addin function names + if( const FunctionInfo* pFuncInfo = getFuncInfoFromOoxFuncName( rxExtName->getOoxName() ) ) + return pushValueOperand( pFuncInfo->maExtProgName, OPCODE_EXTERNAL ); break; case LINKTYPE_DDE: @@ -660,32 +692,32 @@ bool FormulaParserImpl::pushExternalNameOperand( const ExternalNameRef& rxExtNam bool FormulaParserImpl::pushUnaryPreOperator( sal_Int32 nOpCode ) { - return pushUnaryPreOperatorToken( nOpCode, mnLeadingSpaces ) && resetSpaces(); + return pushUnaryPreOperatorToken( nOpCode, &maLeadingSpaces ) && resetSpaces(); } bool FormulaParserImpl::pushUnaryPostOperator( sal_Int32 nOpCode ) { - return pushUnaryPostOperatorToken( nOpCode, mnLeadingSpaces ) && resetSpaces(); + return pushUnaryPostOperatorToken( nOpCode, &maLeadingSpaces ) && resetSpaces(); } bool FormulaParserImpl::pushBinaryOperator( sal_Int32 nOpCode ) { - return pushBinaryOperatorToken( nOpCode, mnLeadingSpaces ) && resetSpaces(); + return pushBinaryOperatorToken( nOpCode, &maLeadingSpaces ) && resetSpaces(); } bool FormulaParserImpl::pushParenthesesOperator() { - return pushParenthesesOperatorToken( mnOpeningSpaces, mnClosingSpaces ) && resetSpaces(); + return pushParenthesesOperatorToken( &maOpeningSpaces, &maClosingSpaces ) && resetSpaces(); } bool FormulaParserImpl::pushFunctionOperator( sal_Int32 nOpCode, size_t nParamCount ) { - return pushFunctionOperatorToken( nOpCode, nParamCount, mnLeadingSpaces, mnClosingSpaces ) && resetSpaces(); + return pushFunctionOperatorToken( nOpCode, nParamCount, &maLeadingSpaces, &maClosingSpaces ) && resetSpaces(); } bool FormulaParserImpl::pushFunctionOperator( const FunctionInfo& rFuncInfo, size_t nParamCount ) { - return pushFunctionOperatorToken( rFuncInfo, nParamCount, mnLeadingSpaces, mnClosingSpaces ) && resetSpaces(); + return pushFunctionOperatorToken( rFuncInfo, nParamCount, &maLeadingSpaces, &maClosingSpaces ) && resetSpaces(); } // reference conversion ------------------------------------------------------- @@ -803,7 +835,7 @@ void FormulaParserImpl::processTokens( const ApiToken* pToken, const ApiToken* p // push the current token into the vector appendFinalToken( *pToken ); // try to process a function, otherwise go to next token - if( const FunctionInfo* pFuncInfo = mrFuncProv.getFuncInfoFromApiToken( *pToken ) ) + if( const FunctionInfo* pFuncInfo = getFuncInfoFromApiToken( *pToken ) ) pToken = processParameters( *pFuncInfo, pToken + 1, pTokenEnd ); else ++pToken; @@ -817,11 +849,11 @@ const ApiToken* FormulaParserImpl::processParameters( size_t nFuncNameIdx = maTokenStorage.size() - 1; // process a function, if an OPCODE_OPEN token is following - OSL_ENSURE( (pToken < pTokenEnd) && (pToken->OpCode == mrFuncProv.OPCODE_OPEN), "FormulaParserImpl::processParameters - OPCODE_OPEN expected" ); - if( (pToken < pTokenEnd) && (pToken->OpCode == mrFuncProv.OPCODE_OPEN) ) + OSL_ENSURE( (pToken < pTokenEnd) && (pToken->OpCode == OPCODE_OPEN), "FormulaParserImpl::processParameters - OPCODE_OPEN expected" ); + if( (pToken < pTokenEnd) && (pToken->OpCode == OPCODE_OPEN) ) { // append the OPCODE_OPEN token to the vector - appendFinalToken( mrFuncProv.OPCODE_OPEN ); + maTokenStorage.append( OPCODE_OPEN ); // store positions of OPCODE_OPEN, parameter separators, and OPCODE_CLOSE ParameterPosVector aParams; @@ -841,17 +873,16 @@ const ApiToken* FormulaParserImpl::processParameters( ParameterPosVector::const_iterator aPosIt = aParams.begin(); // preprocess add-ins, first parameter is reference to function name - if( rFuncInfo.mnOobFuncId == OOBIN_FUNC_EXTERNCALL ) + if( rFuncInfo.mnBiffFuncId == BIFF_FUNC_EXTERNCALL ) { - OUString aName = getExternCallParameter( *aPosIt + 1, *(aPosIt + 1) ); - if( const FunctionInfo* pExtFuncInfo = mrFuncProv.getFuncInfoFromExternCallName( aName ) ) + maTokenStorage[ nFuncNameIdx ].OpCode = OPCODE_NONAME; + // try to initialize function token from first parameter + if( const ApiToken* pECToken = getExternCallToken( *aPosIt + 1, *(aPosIt + 1) ) ) + if( const FunctionInfo* pECFuncInfo = convertExternCallParam( maTokenStorage[ nFuncNameIdx ], *pECToken ) ) + pRealFuncInfo = pECFuncInfo; + // on success, ignore first parameter + if( maTokenStorage[ nFuncNameIdx ].OpCode != OPCODE_NONAME ) { - maTokenStorage[ nFuncNameIdx ].OpCode = pExtFuncInfo->mnApiOpCode; - // insert programmatic add-in function name - if( pExtFuncInfo->mnApiOpCode == mrFuncProv.OPCODE_EXTERNAL ) - maTokenStorage[ nFuncNameIdx ].Data <<= pExtFuncInfo->maExtProgName; - // prepare for following parameters - pRealFuncInfo = pExtFuncInfo; --nParamCount; ++aPosIt; } @@ -879,7 +910,7 @@ const ApiToken* FormulaParserImpl::processParameters( // replace empty second and third parameter in IF function with zeros if( (pRealFuncInfo->mnOobFuncId == OOBIN_FUNC_IF) && ((nParam == 1) || (nParam == 2)) && bIsEmpty ) { - appendFinalToken( mrFuncProv.OPCODE_PUSH ) <<= static_cast< double >( 0.0 ); + maTokenStorage.append< double >( OPCODE_PUSH, 0.0 ); bIsEmpty = false; } else @@ -888,7 +919,7 @@ const ApiToken* FormulaParserImpl::processParameters( processTokens( pParamBegin, pParamEnd ); } // append parameter separator token - appendFinalToken( mrFuncProv.OPCODE_SEP ); + maTokenStorage.append( OPCODE_SEP ); } /* #84453# Update size of new token sequence with valid parameters @@ -911,57 +942,92 @@ const ApiToken* FormulaParserImpl::processParameters( appendRequiredParameters( *pRealFuncInfo, nLastValidCount ); // remove last parameter separator token - if( maTokenStorage.back().OpCode == mrFuncProv.OPCODE_SEP ) + if( maTokenStorage.back().OpCode == OPCODE_SEP ) maTokenStorage.pop_back(); } /* Append the OPCODE_CLOSE token to the vector, but only if there is no OPCODE_BAD token at the end, this token already contains the trailing closing parentheses. */ - if( (pTokenEnd - 1)->OpCode != mrFuncProv.OPCODE_BAD ) - appendFinalToken( mrFuncProv.OPCODE_CLOSE ); + if( (pTokenEnd - 1)->OpCode != OPCODE_BAD ) + maTokenStorage.append( OPCODE_CLOSE ); } /* Replace OPCODE_EXTERNAL with OPCODE_NONAME to get #NAME! error in cell, if no matching add-in function was found. */ ApiToken& rFuncNameToken = maTokenStorage[ nFuncNameIdx ]; - if( (rFuncNameToken.OpCode == mrFuncProv.OPCODE_EXTERNAL) && !rFuncNameToken.Data.hasValue() ) - rFuncNameToken.OpCode = mrFuncProv.OPCODE_NONAME; + if( (rFuncNameToken.OpCode == OPCODE_EXTERNAL) && !rFuncNameToken.Data.hasValue() ) + rFuncNameToken.OpCode = OPCODE_NONAME; return pToken; } bool FormulaParserImpl::isEmptyParameter( const ApiToken* pToken, const ApiToken* pTokenEnd ) const { - while( (pToken < pTokenEnd) && (pToken->OpCode == mrFuncProv.OPCODE_SPACES) ) ++pToken; - if( (pToken < pTokenEnd) && (pToken->OpCode == mrFuncProv.OPCODE_MISSING) ) ++pToken; - while( (pToken < pTokenEnd) && (pToken->OpCode == mrFuncProv.OPCODE_SPACES) ) ++pToken; + while( (pToken < pTokenEnd) && (pToken->OpCode == OPCODE_SPACES) ) ++pToken; + if( (pToken < pTokenEnd) && (pToken->OpCode == OPCODE_MISSING) ) ++pToken; + while( (pToken < pTokenEnd) && (pToken->OpCode == OPCODE_SPACES) ) ++pToken; return pToken == pTokenEnd; } -OUString FormulaParserImpl::getExternCallParameter( const ApiToken* pToken, const ApiToken* pTokenEnd ) const +const ApiToken* FormulaParserImpl::getExternCallToken( const ApiToken* pToken, const ApiToken* pTokenEnd ) const +{ + const ApiToken* pECToken = 0; + while( (pToken < pTokenEnd) && (pToken->OpCode == OPCODE_SPACES) ) ++pToken; + if( pToken < pTokenEnd ) pECToken = pToken++; + while( (pToken < pTokenEnd) && (pToken->OpCode == OPCODE_SPACES) ) ++pToken; + return (pToken == pTokenEnd) ? pECToken : 0; +} + +const FunctionInfo* FormulaParserImpl::convertExternCallParam( ApiToken& orFuncToken, const ApiToken& rECToken ) const { - OUString aExtCallName; - while( (pToken < pTokenEnd) && (pToken->OpCode == mrFuncProv.OPCODE_SPACES) ) ++pToken; - if( (pToken < pTokenEnd) && (pToken->OpCode == mrFuncProv.OPCODE_MACRO) ) (pToken++)->Data >>= aExtCallName; - while( (pToken < pTokenEnd) && (pToken->OpCode == mrFuncProv.OPCODE_SPACES) ) ++pToken; - return (pToken == pTokenEnd) ? aExtCallName : OUString(); + if( const FunctionInfo* pFuncInfo = getFuncInfoFromApiToken( rECToken ) ) + { + orFuncToken.OpCode = pFuncInfo->mnApiOpCode; + // programmatic add-in function name + if( (pFuncInfo->mnApiOpCode == OPCODE_EXTERNAL) && (pFuncInfo->maExtProgName.getLength() > 0) ) + orFuncToken.Data <<= pFuncInfo->maExtProgName; + // name of unsupported function, convert to OPCODE_BAD to preserve the name + else if( (pFuncInfo->mnApiOpCode == OPCODE_BAD) && (pFuncInfo->maOoxFuncName.getLength() > 0) ) + orFuncToken.Data <<= pFuncInfo->maOoxFuncName; + return pFuncInfo; + } + + if( (rECToken.OpCode == OPCODE_MACRO) || (rECToken.OpCode == OPCODE_BAD) ) + { + // macro call or unknown function name, move data to function token + orFuncToken = rECToken; + } + else if( rECToken.OpCode == OPCODE_NAME ) + { + // defined name used as function call, convert to OPCODE_BAD to preserve the name + sal_Int32 nTokenIndex = 0; + if( rECToken.Data >>= nTokenIndex ) + { + if( const DefinedName* pDefName = getDefinedNames().getByTokenIndex( nTokenIndex ).get() ) + { + orFuncToken.OpCode = OPCODE_BAD; + orFuncToken.Data <<= pDefName->getDocName(); + } + } + } + return 0; } const ApiToken* FormulaParserImpl::skipParentheses( const ApiToken* pToken, const ApiToken* pTokenEnd ) const { // skip tokens between OPCODE_OPEN and OPCODE_CLOSE - OSL_ENSURE( (pToken < pTokenEnd) && (pToken->OpCode == mrFuncProv.OPCODE_OPEN), "skipParentheses - OPCODE_OPEN expected" ); + OSL_ENSURE( (pToken < pTokenEnd) && (pToken->OpCode == OPCODE_OPEN), "skipParentheses - OPCODE_OPEN expected" ); ++pToken; - while( (pToken < pTokenEnd) && (pToken->OpCode != mrFuncProv.OPCODE_CLOSE) ) + while( (pToken < pTokenEnd) && (pToken->OpCode != OPCODE_CLOSE) ) { - if( pToken->OpCode == mrFuncProv.OPCODE_OPEN ) + if( pToken->OpCode == OPCODE_OPEN ) pToken = skipParentheses( pToken, pTokenEnd ); else ++pToken; } // skip the OPCODE_CLOSE token - OSL_ENSURE( ((pToken < pTokenEnd) && (pToken->OpCode == mrFuncProv.OPCODE_CLOSE)) || ((pTokenEnd - 1)->OpCode == mrFuncProv.OPCODE_BAD), "skipParentheses - OPCODE_CLOSE expected" ); + OSL_ENSURE( ((pToken < pTokenEnd) && (pToken->OpCode == OPCODE_CLOSE)) || ((pTokenEnd - 1)->OpCode == OPCODE_BAD), "skipParentheses - OPCODE_CLOSE expected" ); return (pToken < pTokenEnd) ? (pToken + 1) : pTokenEnd; } @@ -969,22 +1035,22 @@ const ApiToken* FormulaParserImpl::findParameters( ParameterPosVector& rParams, const ApiToken* pToken, const ApiToken* pTokenEnd ) const { // push position of OPCODE_OPEN - OSL_ENSURE( (pToken < pTokenEnd) && (pToken->OpCode == mrFuncProv.OPCODE_OPEN), "FormulaParserImpl::findParameters - OPCODE_OPEN expected" ); + OSL_ENSURE( (pToken < pTokenEnd) && (pToken->OpCode == OPCODE_OPEN), "FormulaParserImpl::findParameters - OPCODE_OPEN expected" ); rParams.push_back( pToken++ ); // find positions of parameter separators - while( (pToken < pTokenEnd) && (pToken->OpCode != mrFuncProv.OPCODE_CLOSE) ) + while( (pToken < pTokenEnd) && (pToken->OpCode != OPCODE_CLOSE) ) { - if( pToken->OpCode == mrFuncProv.OPCODE_OPEN ) + if( pToken->OpCode == OPCODE_OPEN ) pToken = skipParentheses( pToken, pTokenEnd ); - else if( pToken->OpCode == mrFuncProv.OPCODE_SEP ) + else if( pToken->OpCode == OPCODE_SEP ) rParams.push_back( pToken++ ); else ++pToken; } // push position of OPCODE_CLOSE - OSL_ENSURE( ((pToken < pTokenEnd) && (pToken->OpCode == mrFuncProv.OPCODE_CLOSE)) || ((pTokenEnd - 1)->OpCode == mrFuncProv.OPCODE_BAD), "FormulaParserImpl::findParameters - OPCODE_CLOSE expected" ); + OSL_ENSURE( ((pToken < pTokenEnd) && (pToken->OpCode == OPCODE_CLOSE)) || ((pTokenEnd - 1)->OpCode == OPCODE_BAD), "FormulaParserImpl::findParameters - OPCODE_CLOSE expected" ); rParams.push_back( pToken ); return (pToken < pTokenEnd) ? (pToken + 1) : pTokenEnd; } @@ -997,8 +1063,8 @@ void FormulaParserImpl::appendCalcOnlyParameter( const FunctionInfo& rFuncInfo, case OOBIN_FUNC_FLOOR: case OOBIN_FUNC_CEILING: OSL_ENSURE( nParam == 2, "FormulaParserImpl::appendCalcOnlyParameter - unexpected parameter index" ); - appendFinalToken( mrFuncProv.OPCODE_PUSH ) <<= static_cast< double >( 1.0 ); - appendFinalToken( mrFuncProv.OPCODE_SEP ); + maTokenStorage.append< double >( OPCODE_PUSH, 1.0 ); + maTokenStorage.append( OPCODE_SEP ); break; } } @@ -1010,8 +1076,8 @@ void FormulaParserImpl::appendRequiredParameters( const FunctionInfo& rFuncInfo, case OOBIN_FUNC_WEEKNUM: if( nParamCount == 1 ) { - appendFinalToken( mrFuncProv.OPCODE_PUSH ) <<= static_cast< double >( 1.0 ); - appendFinalToken( mrFuncProv.OPCODE_SEP ); + maTokenStorage.append< double >( OPCODE_PUSH, 1.0 ); + maTokenStorage.append( OPCODE_SEP ); } break; } @@ -1019,31 +1085,22 @@ void FormulaParserImpl::appendRequiredParameters( const FunctionInfo& rFuncInfo, void FormulaParserImpl::appendFinalToken( const ApiToken& rToken ) { - if( (rToken.OpCode == mrFuncProv.OPCODE_MACRO) && !rToken.Data.hasValue() ) + if( (rToken.OpCode == OPCODE_MACRO) && !rToken.Data.hasValue() ) { - appendFinalToken( mrFuncProv.OPCODE_ARRAY_OPEN ); - appendFinalToken( mrFuncProv.OPCODE_PUSH ) <<= BiffHelper::calcDoubleFromError( BIFF_ERR_NAME ); - appendFinalToken( mrFuncProv.OPCODE_ARRAY_CLOSE ); + maTokenStorage.append( OPCODE_ARRAY_OPEN ); + maTokenStorage.append( OPCODE_PUSH, BiffHelper::calcDoubleFromError( BIFF_ERR_NAME ) ); + maTokenStorage.append( OPCODE_ARRAY_CLOSE ); } else maTokenStorage.push_back( rToken ); } -Any& FormulaParserImpl::appendFinalToken( sal_Int32 nOpCode ) -{ - maTokenStorage.resize( maTokenStorage.size() + 1 ); - maTokenStorage.back().OpCode = nOpCode; - return maTokenStorage.back().Data; -} - // OOX parser implementation ================================================== class OoxFormulaParserImpl : public FormulaParserImpl { public: - explicit OoxFormulaParserImpl( - const WorkbookHelper& rHelper, - const FunctionProvider& rFuncProv ); + explicit OoxFormulaParserImpl( const OpCodeProvider& rOpCodeProv ); virtual void importOoxFormula( FormulaContext& rContext, @@ -1088,13 +1145,13 @@ private: Reference< XFormulaParser > mxParser; PropertySet maParserProps; const OUString maRefPosProp; - sal_Int32 mnAddDataPos; /// Current stream position for additional data (tExp, tArray, tMemArea). + sal_Int64 mnAddDataPos; /// Current stream position for additional data (tExp, tArray, tMemArea). }; // ---------------------------------------------------------------------------- -OoxFormulaParserImpl::OoxFormulaParserImpl( const WorkbookHelper& rHelper, const FunctionProvider& rFuncProv ) : - FormulaParserImpl( rHelper, rFuncProv ), +OoxFormulaParserImpl::OoxFormulaParserImpl( const OpCodeProvider& rOpCodeProv ) : + FormulaParserImpl( rOpCodeProv ), maRefPosProp( CREATE_OUSTRING( "ReferencePosition" ) ), mnAddDataPos( 0 ) { @@ -1111,7 +1168,7 @@ OoxFormulaParserImpl::OoxFormulaParserImpl( const WorkbookHelper& rHelper, const maParserProps.setProperty( CREATE_OUSTRING( "CompileEnglish" ), true ); maParserProps.setProperty( CREATE_OUSTRING( "FormulaConvention" ), ::com::sun::star::sheet::AddressConvention::XL_A1 ); maParserProps.setProperty( CREATE_OUSTRING( "IgnoreLeadingSpaces" ), false ); - maParserProps.setProperty( CREATE_OUSTRING( "OpCodeMap" ), mrFuncProv.getOoxParserMap() ); + maParserProps.setProperty( CREATE_OUSTRING( "OpCodeMap" ), getOoxParserMap() ); } void OoxFormulaParserImpl::importOoxFormula( @@ -1130,19 +1187,19 @@ void OoxFormulaParserImpl::importOobFormula( FormulaContext& rContext, RecordInp initializeImport( rContext ); sal_Int32 nFmlaSize = rStrm.readInt32(); - sal_Int32 nFmlaPos = rStrm.getRecPos(); - sal_Int32 nFmlaEndPos = nFmlaPos + nFmlaSize; + sal_Int64 nFmlaPos = rStrm.tell(); + sal_Int64 nFmlaEndPos = nFmlaPos + nFmlaSize; rStrm.seek( nFmlaEndPos ); sal_Int32 nAddDataSize = rStrm.readInt32(); - mnAddDataPos = rStrm.getRecPos(); - sal_Int32 nAddDataEndPos = mnAddDataPos + nAddDataSize; + mnAddDataPos = rStrm.tell(); + sal_Int64 nAddDataEndPos = mnAddDataPos + nAddDataSize; rStrm.seek( nFmlaPos ); bool bOk = (nFmlaSize >= 0) && (nAddDataSize >= 0); bool bRelativeAsOffset = getFormulaContext().isRelativeAsOffset(); - while( bOk && rStrm.isValid() && (rStrm.getRecPos() < nFmlaEndPos) ) + while( bOk && !rStrm.isEof() && (rStrm.tell() < nFmlaEndPos) ) { sal_uInt8 nTokenId; rStrm >> nTokenId; @@ -1154,34 +1211,34 @@ void OoxFormulaParserImpl::importOobFormula( FormulaContext& rContext, RecordInp // base tokens switch( nBaseId ) { - case BIFF_TOKID_EXP: bOk = importExpToken( rStrm ); break; - case BIFF_TOKID_ADD: bOk = pushBinaryOperator( mrFuncProv.OPCODE_ADD ); break; - case BIFF_TOKID_SUB: bOk = pushBinaryOperator( mrFuncProv.OPCODE_SUB ); break; - case BIFF_TOKID_MUL: bOk = pushBinaryOperator( mrFuncProv.OPCODE_MULT ); break; - case BIFF_TOKID_DIV: bOk = pushBinaryOperator( mrFuncProv.OPCODE_DIV ); break; - case BIFF_TOKID_POWER: bOk = pushBinaryOperator( mrFuncProv.OPCODE_POWER ); break; - case BIFF_TOKID_CONCAT: bOk = pushBinaryOperator( mrFuncProv.OPCODE_CONCAT ); break; - case BIFF_TOKID_LT: bOk = pushBinaryOperator( mrFuncProv.OPCODE_LESS ); break; - case BIFF_TOKID_LE: bOk = pushBinaryOperator( mrFuncProv.OPCODE_LESS_EQUAL ); break; - case BIFF_TOKID_EQ: bOk = pushBinaryOperator( mrFuncProv.OPCODE_EQUAL ); break; - case BIFF_TOKID_GE: bOk = pushBinaryOperator( mrFuncProv.OPCODE_GREATER_EQUAL ); break; - case BIFF_TOKID_GT: bOk = pushBinaryOperator( mrFuncProv.OPCODE_GREATER ); break; - case BIFF_TOKID_NE: bOk = pushBinaryOperator( mrFuncProv.OPCODE_NOT_EQUAL ); break; - case BIFF_TOKID_ISECT: bOk = pushBinaryOperator( mrFuncProv.OPCODE_INTERSECT ); break; - case BIFF_TOKID_LIST: bOk = pushBinaryOperator( mrFuncProv.OPCODE_LIST ); break; - case BIFF_TOKID_RANGE: bOk = pushBinaryOperator( mrFuncProv.OPCODE_RANGE ); break; - case BIFF_TOKID_UPLUS: bOk = pushUnaryPreOperator( mrFuncProv.OPCODE_PLUS_SIGN ); break; - case BIFF_TOKID_UMINUS: bOk = pushUnaryPreOperator( mrFuncProv.OPCODE_MINUS_SIGN ); break; - case BIFF_TOKID_PERCENT: bOk = pushUnaryPostOperator( mrFuncProv.OPCODE_PERCENT ); break; - case BIFF_TOKID_PAREN: bOk = pushParenthesesOperator(); break; - case BIFF_TOKID_MISSARG: bOk = pushOperand( mrFuncProv.OPCODE_MISSING ); break; - case BIFF_TOKID_STR: bOk = pushValueOperand( rStrm.readString( false ) ); break; - case BIFF_TOKID_NLR: bOk = importTableToken( rStrm ); break; - case BIFF_TOKID_ATTR: bOk = importAttrToken( rStrm ); break; - case BIFF_TOKID_ERR: bOk = pushBiffErrorOperand( rStrm.readuInt8() ); break; - case BIFF_TOKID_BOOL: bOk = pushBoolOperand( rStrm.readuInt8() != BIFF_TOK_BOOL_FALSE ); break; - case BIFF_TOKID_INT: bOk = pushValueOperand< double >( rStrm.readuInt16() ); break; - case BIFF_TOKID_NUM: bOk = pushValueOperand( rStrm.readDouble() ); break; + case BIFF_TOKID_EXP: bOk = importExpToken( rStrm ); break; + case BIFF_TOKID_ADD: bOk = pushBinaryOperator( OPCODE_ADD ); break; + case BIFF_TOKID_SUB: bOk = pushBinaryOperator( OPCODE_SUB ); break; + case BIFF_TOKID_MUL: bOk = pushBinaryOperator( OPCODE_MULT ); break; + case BIFF_TOKID_DIV: bOk = pushBinaryOperator( OPCODE_DIV ); break; + case BIFF_TOKID_POWER: bOk = pushBinaryOperator( OPCODE_POWER ); break; + case BIFF_TOKID_CONCAT: bOk = pushBinaryOperator( OPCODE_CONCAT ); break; + case BIFF_TOKID_LT: bOk = pushBinaryOperator( OPCODE_LESS ); break; + case BIFF_TOKID_LE: bOk = pushBinaryOperator( OPCODE_LESS_EQUAL ); break; + case BIFF_TOKID_EQ: bOk = pushBinaryOperator( OPCODE_EQUAL ); break; + case BIFF_TOKID_GE: bOk = pushBinaryOperator( OPCODE_GREATER_EQUAL ); break; + case BIFF_TOKID_GT: bOk = pushBinaryOperator( OPCODE_GREATER ); break; + case BIFF_TOKID_NE: bOk = pushBinaryOperator( OPCODE_NOT_EQUAL ); break; + case BIFF_TOKID_ISECT: bOk = pushBinaryOperator( OPCODE_INTERSECT ); break; + case BIFF_TOKID_LIST: bOk = pushBinaryOperator( OPCODE_LIST ); break; + case BIFF_TOKID_RANGE: bOk = pushBinaryOperator( OPCODE_RANGE ); break; + case BIFF_TOKID_UPLUS: bOk = pushUnaryPreOperator( OPCODE_PLUS_SIGN ); break; + case BIFF_TOKID_UMINUS: bOk = pushUnaryPreOperator( OPCODE_MINUS_SIGN ); break; + case BIFF_TOKID_PERCENT: bOk = pushUnaryPostOperator( OPCODE_PERCENT ); break; + case BIFF_TOKID_PAREN: bOk = pushParenthesesOperator(); break; + case BIFF_TOKID_MISSARG: bOk = pushOperand( OPCODE_MISSING ); break; + case BIFF_TOKID_STR: bOk = pushValueOperand( rStrm.readString( false ) ); break; + case BIFF_TOKID_NLR: bOk = importTableToken( rStrm ); break; + case BIFF_TOKID_ATTR: bOk = importAttrToken( rStrm ); break; + case BIFF_TOKID_ERR: bOk = pushBiffErrorOperand( rStrm.readuInt8() ); break; + case BIFF_TOKID_BOOL: bOk = pushBiffBoolOperand( rStrm.readuInt8() ); break; + case BIFF_TOKID_INT: bOk = pushValueOperand< double >( rStrm.readuInt16() ); break; + case BIFF_TOKID_NUM: bOk = pushValueOperand( rStrm.readDouble() ); break; default: bOk = false; } } @@ -1217,7 +1274,7 @@ void OoxFormulaParserImpl::importOobFormula( FormulaContext& rContext, RecordInp } // build and finalize the token sequence - if( bOk && (rStrm.getRecPos() == nFmlaEndPos) && (mnAddDataPos == nAddDataEndPos) ) + if( bOk && (rStrm.tell() == nFmlaEndPos) && (mnAddDataPos == nAddDataEndPos) ) finalizeImport(); // seek behind token array @@ -1267,16 +1324,22 @@ bool OoxFormulaParserImpl::importSpaceToken( RecordInputStream& rStrm ) switch( nType ) { case BIFF_TOK_ATTR_SPACE_SP: + appendLeadingSpaces( nCount, false ); + break; case BIFF_TOK_ATTR_SPACE_BR: - incLeadingSpaces( nCount ); + appendLeadingSpaces( nCount, true ); break; case BIFF_TOK_ATTR_SPACE_SP_OPEN: + appendOpeningSpaces( nCount, false ); + break; case BIFF_TOK_ATTR_SPACE_BR_OPEN: - incOpeningSpaces( nCount ); + appendOpeningSpaces( nCount, true ); break; case BIFF_TOK_ATTR_SPACE_SP_CLOSE: + appendClosingSpaces( nCount, false ); + break; case BIFF_TOK_ATTR_SPACE_BR_CLOSE: - incClosingSpaces( nCount ); + appendClosingSpaces( nCount, true ); break; } return true; @@ -1376,31 +1439,31 @@ bool OoxFormulaParserImpl::importTableToken( RecordInputStream& rStrm ) { // push single database area token, if table token refers to entire table if( (nStartCol == 0) && (nEndCol + 1 == nWidth) && (nStartRow == 0) && (nEndRow + 1 == nHeight) ) - return pushValueOperand( nTokenIndex, mrFuncProv.OPCODE_DBAREA ); + return pushValueOperand( nTokenIndex, OPCODE_DBAREA ); // create an OFFSET function call to refer to a subrange of the table - const FunctionInfo* pRowsInfo = mrFuncProv.getFuncInfoFromOobFuncId( OOBIN_FUNC_ROWS ); - const FunctionInfo* pColumnsInfo = mrFuncProv.getFuncInfoFromOobFuncId( OOBIN_FUNC_COLUMNS ); + const FunctionInfo* pRowsInfo = getFuncInfoFromOobFuncId( OOBIN_FUNC_ROWS ); + const FunctionInfo* pColumnsInfo = getFuncInfoFromOobFuncId( OOBIN_FUNC_COLUMNS ); return pRowsInfo && pColumnsInfo && - pushValueOperandToken( nTokenIndex, mrFuncProv.OPCODE_DBAREA, 0 ) && + pushValueOperandToken( nTokenIndex, OPCODE_DBAREA ) && (bFixedStartRow ? - pushValueOperandToken< double >( nStartRow, 0 ) : - (pushValueOperandToken( nTokenIndex, mrFuncProv.OPCODE_DBAREA, 0 ) && - pushFunctionOperatorToken( *pRowsInfo, 1, 0, 0 ) && - pushValueOperandToken< double >( nHeight - nStartRow, 0 ) && - pushBinaryOperatorToken( mrFuncProv.OPCODE_SUB, 0 ))) && - pushValueOperandToken< double >( nStartCol, 0 ) && + pushValueOperandToken< double >( nStartRow ) : + (pushValueOperandToken( nTokenIndex, OPCODE_DBAREA ) && + pushFunctionOperatorToken( *pRowsInfo, 1 ) && + pushValueOperandToken< double >( nHeight - nStartRow ) && + pushBinaryOperatorToken( OPCODE_SUB ))) && + pushValueOperandToken< double >( nStartCol ) && (bFixedHeight ? - pushValueOperandToken< double >( nEndRow - nStartRow + 1, 0 ) : - (pushValueOperandToken( nTokenIndex, mrFuncProv.OPCODE_DBAREA, 0 ) && - pushFunctionOperatorToken( *pRowsInfo, 1, 0, 0 ) && + pushValueOperandToken< double >( nEndRow - nStartRow + 1 ) : + (pushValueOperandToken( nTokenIndex, OPCODE_DBAREA ) && + pushFunctionOperatorToken( *pRowsInfo, 1 ) && (((nStartRow == 0) && (nEndRow + 1 == nHeight)) || - (pushValueOperandToken< double >( nHeight - (nEndRow - nStartRow + 1), 0 ) && - pushBinaryOperatorToken( mrFuncProv.OPCODE_SUB, 0 ))))) && + (pushValueOperandToken< double >( nHeight - (nEndRow - nStartRow + 1) ) && + pushBinaryOperatorToken( OPCODE_SUB ))))) && (((nStartCol == 0) && (nEndCol + 1 == nWidth)) ? - (pushValueOperandToken( nTokenIndex, mrFuncProv.OPCODE_DBAREA, 0 ) && - pushFunctionOperatorToken( *pColumnsInfo, 1, 0, 0 )) : - pushValueOperandToken< double >( nEndCol - nStartCol + 1, 0 )) && + (pushValueOperandToken( nTokenIndex, OPCODE_DBAREA ) && + pushFunctionOperatorToken( *pColumnsInfo, 1 )) : + pushValueOperandToken< double >( nEndCol - nStartCol + 1 )) && pushOobFunction( OOBIN_FUNC_OFFSET, 5 ); } } @@ -1412,7 +1475,7 @@ bool OoxFormulaParserImpl::importArrayToken( RecordInputStream& rStrm ) rStrm.skip( 14 ); // start token array with opening brace and leading spaces - pushOperand( mrFuncProv.OPCODE_ARRAY_OPEN ); + pushOperand( OPCODE_ARRAY_OPEN ); size_t nOpSize = popOperandSize(); size_t nOldArraySize = getFormulaSize(); @@ -1423,39 +1486,39 @@ bool OoxFormulaParserImpl::importArrayToken( RecordInputStream& rStrm ) OSL_ENSURE( (nCols > 0) && (nRows > 0), "OoxFormulaParserImpl::importArrayToken - empty array" ); // read array values and build token array - for( sal_Int32 nRow = 0; rStrm.isValid() && (nRow < nRows); ++nRow ) + for( sal_Int32 nRow = 0; !rStrm.isEof() && (nRow < nRows); ++nRow ) { if( nRow > 0 ) - appendRawToken( mrFuncProv.OPCODE_ARRAY_ROWSEP ); - for( sal_Int32 nCol = 0; rStrm.isValid() && (nCol < nCols); ++nCol ) + appendRawToken( OPCODE_ARRAY_ROWSEP ); + for( sal_Int32 nCol = 0; !rStrm.isEof() && (nCol < nCols); ++nCol ) { if( nCol > 0 ) - appendRawToken( mrFuncProv.OPCODE_ARRAY_COLSEP ); + appendRawToken( OPCODE_ARRAY_COLSEP ); switch( rStrm.readuInt8() ) { case OOBIN_TOK_ARRAY_DOUBLE: - appendRawToken( mrFuncProv.OPCODE_PUSH ) <<= rStrm.readDouble(); + appendRawToken( OPCODE_PUSH ) <<= rStrm.readDouble(); break; case OOBIN_TOK_ARRAY_STRING: - appendRawToken( mrFuncProv.OPCODE_PUSH ) <<= rStrm.readString( false ); + appendRawToken( OPCODE_PUSH ) <<= rStrm.readString( false ); break; case OOBIN_TOK_ARRAY_BOOL: - appendRawToken( mrFuncProv.OPCODE_PUSH ) <<= static_cast< double >( (rStrm.readuInt8() == 0) ? 0.0 : 1.0 ); + appendRawToken( OPCODE_PUSH ) <<= static_cast< double >( (rStrm.readuInt8() == BIFF_TOK_BOOL_FALSE) ? 0.0 : 1.0 ); break; case OOBIN_TOK_ARRAY_ERROR: - appendRawToken( mrFuncProv.OPCODE_PUSH ) <<= BiffHelper::calcDoubleFromError( rStrm.readuInt8() ); + appendRawToken( OPCODE_PUSH ) <<= BiffHelper::calcDoubleFromError( rStrm.readuInt8() ); rStrm.skip( 3 ); break; default: OSL_ENSURE( false, "OoxFormulaParserImpl::importArrayToken - unknown data type" ); - appendRawToken( mrFuncProv.OPCODE_PUSH ) <<= BiffHelper::calcDoubleFromError( BIFF_ERR_NA ); + appendRawToken( OPCODE_PUSH ) <<= BiffHelper::calcDoubleFromError( BIFF_ERR_NA ); } } } swapStreamPosition( rStrm ); // close token array and set resulting operand size - appendRawToken( mrFuncProv.OPCODE_ARRAY_CLOSE ); + appendRawToken( OPCODE_ARRAY_CLOSE ); pushOperandSize( nOpSize + getFormulaSize() - nOldArraySize ); return true; } @@ -1550,7 +1613,7 @@ LinkSheetRange OoxFormulaParserImpl::readSheetRange( RecordInputStream& rStrm ) void OoxFormulaParserImpl::swapStreamPosition( RecordInputStream& rStrm ) { - sal_Int32 nRecPos = rStrm.getRecPos(); + sal_Int64 nRecPos = rStrm.tell(); rStrm.seek( mnAddDataPos ); mnAddDataPos = nRecPos; } @@ -1576,7 +1639,7 @@ bool OoxFormulaParserImpl::pushOobExtName( sal_Int32 nRefId, sal_Int32 nNameId ) { if( pExtLink->getLinkType() == LINKTYPE_SELF ) return pushOobName( nNameId ); - // external name indexes are one-based in OOBIN + // external name indexes are one-based in OOBIN ExternalNameRef xExtName = pExtLink->getNameByIndex( nNameId - 1 ); return pushExternalNameOperand( xExtName, pExtLink->getLinkType() ); } @@ -1585,19 +1648,19 @@ bool OoxFormulaParserImpl::pushOobExtName( sal_Int32 nRefId, sal_Int32 nNameId ) bool OoxFormulaParserImpl::pushOobFunction( sal_uInt16 nFuncId ) { - if( const FunctionInfo* pFuncInfo = mrFuncProv.getFuncInfoFromOobFuncId( nFuncId ) ) + if( const FunctionInfo* pFuncInfo = getFuncInfoFromOobFuncId( nFuncId ) ) if( pFuncInfo->mnMinParamCount == pFuncInfo->mnMaxParamCount ) return pushFunctionOperator( *pFuncInfo, pFuncInfo->mnMinParamCount ); - return pushFunctionOperator( mrFuncProv.OPCODE_NONAME, 0 ); + return pushFunctionOperator( OPCODE_NONAME, 0 ); } bool OoxFormulaParserImpl::pushOobFunction( sal_uInt16 nFuncId, sal_uInt8 nParamCount ) { if( getFlag( nFuncId, BIFF_TOK_FUNCVAR_CMD ) ) nParamCount &= BIFF_TOK_FUNCVAR_COUNTMASK; - if( const FunctionInfo* pFuncInfo = mrFuncProv.getFuncInfoFromOobFuncId( nFuncId ) ) + if( const FunctionInfo* pFuncInfo = getFuncInfoFromOobFuncId( nFuncId ) ) return pushFunctionOperator( *pFuncInfo, nParamCount ); - return pushFunctionOperator( mrFuncProv.OPCODE_NONAME, nParamCount ); + return pushFunctionOperator( OPCODE_NONAME, nParamCount ); } // BIFF parser implementation ================================================= @@ -1653,9 +1716,7 @@ bool lclIsValidNlrRange( const BiffNlr& rNlr, const BinRange& rRange, bool bRow class BiffFormulaParserImpl : public FormulaParserImpl { public: - explicit BiffFormulaParserImpl( - const WorkbookHelper& rHelper, - const FunctionProvider& rFuncProv ); + explicit BiffFormulaParserImpl( const OpCodeProvider& rOpCodeProv ); virtual void importBiffFormula( FormulaContext& rContext, @@ -1744,7 +1805,7 @@ private: ImportTokenFunc mpImportFuncVarToken; /// Pointer to tFuncVar import function (function with variable parameter count). ImportTokenFunc mpImportFuncCEToken; /// Pointer to tFuncCE import function (command macro call). ImportTokenFunc mpImportExpToken; /// Pointer to tExp import function (array/shared formula). - sal_uInt32 mnAddDataPos; /// Current stream position for additional data (tArray, tMemArea, tNlr). + sal_Int64 mnAddDataPos; /// Current stream position for additional data (tArray, tMemArea, tNlr). sal_Int32 mnCurrRefId; /// Current ref-id from tSheet token (BIFF2-BIFF4 only). sal_uInt16 mnAttrDataSize; /// Size of one tAttr data element. sal_uInt16 mnArraySize; /// Size of tArray data. @@ -1756,8 +1817,8 @@ private: // ---------------------------------------------------------------------------- -BiffFormulaParserImpl::BiffFormulaParserImpl( const WorkbookHelper& rHelper, const FunctionProvider& rFuncProv ) : - FormulaParserImpl( rHelper, rFuncProv ), +BiffFormulaParserImpl::BiffFormulaParserImpl( const OpCodeProvider& rOpCodeProv ) : + FormulaParserImpl( rOpCodeProv ), mnAddDataPos( 0 ), mnCurrRefId( 0 ) { @@ -1884,11 +1945,11 @@ void BiffFormulaParserImpl::importBiffFormula( FormulaContext& rContext, mnCurrRefId = 0; sal_uInt16 nFmlaSize = pnFmlaSize ? *pnFmlaSize : ((getBiff() == BIFF2) ? rStrm.readuInt8() : rStrm.readuInt16()); - sal_uInt32 nEndPos = mnAddDataPos = rStrm.getRecPos() + nFmlaSize; + sal_Int64 nEndPos = mnAddDataPos = rStrm.tell() + nFmlaSize; bool bRelativeAsOffset = getFormulaContext().isRelativeAsOffset(); bool bOk = true; - while( bOk && rStrm.isValid() && (rStrm.getRecPos() < nEndPos) ) + while( bOk && !rStrm.isEof() && (rStrm.tell() < nEndPos) ) { sal_uInt8 nTokenId; rStrm >> nTokenId; @@ -1900,37 +1961,37 @@ void BiffFormulaParserImpl::importBiffFormula( FormulaContext& rContext, // base tokens switch( nBaseId ) { - case BIFF_TOKID_EXP: bOk = (this->*mpImportExpToken)( rStrm ); break; - case BIFF_TOKID_TBL: bOk = false; /* multiple op. will be set externally */ break; - case BIFF_TOKID_ADD: bOk = pushBinaryOperator( mrFuncProv.OPCODE_ADD ); break; - case BIFF_TOKID_SUB: bOk = pushBinaryOperator( mrFuncProv.OPCODE_SUB ); break; - case BIFF_TOKID_MUL: bOk = pushBinaryOperator( mrFuncProv.OPCODE_MULT ); break; - case BIFF_TOKID_DIV: bOk = pushBinaryOperator( mrFuncProv.OPCODE_DIV ); break; - case BIFF_TOKID_POWER: bOk = pushBinaryOperator( mrFuncProv.OPCODE_POWER ); break; - case BIFF_TOKID_CONCAT: bOk = pushBinaryOperator( mrFuncProv.OPCODE_CONCAT ); break; - case BIFF_TOKID_LT: bOk = pushBinaryOperator( mrFuncProv.OPCODE_LESS ); break; - case BIFF_TOKID_LE: bOk = pushBinaryOperator( mrFuncProv.OPCODE_LESS_EQUAL ); break; - case BIFF_TOKID_EQ: bOk = pushBinaryOperator( mrFuncProv.OPCODE_EQUAL ); break; - case BIFF_TOKID_GE: bOk = pushBinaryOperator( mrFuncProv.OPCODE_GREATER_EQUAL ); break; - case BIFF_TOKID_GT: bOk = pushBinaryOperator( mrFuncProv.OPCODE_GREATER ); break; - case BIFF_TOKID_NE: bOk = pushBinaryOperator( mrFuncProv.OPCODE_NOT_EQUAL ); break; - case BIFF_TOKID_ISECT: bOk = pushBinaryOperator( mrFuncProv.OPCODE_INTERSECT ); break; - case BIFF_TOKID_LIST: bOk = pushBinaryOperator( mrFuncProv.OPCODE_LIST ); break; - case BIFF_TOKID_RANGE: bOk = pushBinaryOperator( mrFuncProv.OPCODE_RANGE ); break; - case BIFF_TOKID_UPLUS: bOk = pushUnaryPreOperator( mrFuncProv.OPCODE_PLUS_SIGN ); break; - case BIFF_TOKID_UMINUS: bOk = pushUnaryPreOperator( mrFuncProv.OPCODE_MINUS_SIGN ); break; - case BIFF_TOKID_PERCENT: bOk = pushUnaryPostOperator( mrFuncProv.OPCODE_PERCENT ); break; - case BIFF_TOKID_PAREN: bOk = pushParenthesesOperator(); break; - case BIFF_TOKID_MISSARG: bOk = pushOperand( mrFuncProv.OPCODE_MISSING ); break; - case BIFF_TOKID_STR: bOk = (this->*mpImportStrToken)( rStrm ); break; - case BIFF_TOKID_NLR: bOk = (this->*mpImportNlrToken)( rStrm ); break; - case BIFF_TOKID_ATTR: bOk = importAttrToken( rStrm ); break; - case BIFF_TOKID_SHEET: bOk = (this->*mpImportSheetToken)( rStrm ); break; - case BIFF_TOKID_ENDSHEET: bOk = (this->*mpImportEndSheetToken)( rStrm ); break; - case BIFF_TOKID_ERR: bOk = pushBiffErrorOperand( rStrm.readuInt8() ); break; - case BIFF_TOKID_BOOL: bOk = pushBoolOperand( rStrm.readuInt8() != BIFF_TOK_BOOL_FALSE ); break; - case BIFF_TOKID_INT: bOk = pushValueOperand< double >( rStrm.readuInt16() ); break; - case BIFF_TOKID_NUM: bOk = pushValueOperand( rStrm.readDouble() ); break; + case BIFF_TOKID_EXP: bOk = (this->*mpImportExpToken)( rStrm ); break; + case BIFF_TOKID_TBL: bOk = false; /* multiple op. will be set externally */ break; + case BIFF_TOKID_ADD: bOk = pushBinaryOperator( OPCODE_ADD ); break; + case BIFF_TOKID_SUB: bOk = pushBinaryOperator( OPCODE_SUB ); break; + case BIFF_TOKID_MUL: bOk = pushBinaryOperator( OPCODE_MULT ); break; + case BIFF_TOKID_DIV: bOk = pushBinaryOperator( OPCODE_DIV ); break; + case BIFF_TOKID_POWER: bOk = pushBinaryOperator( OPCODE_POWER ); break; + case BIFF_TOKID_CONCAT: bOk = pushBinaryOperator( OPCODE_CONCAT ); break; + case BIFF_TOKID_LT: bOk = pushBinaryOperator( OPCODE_LESS ); break; + case BIFF_TOKID_LE: bOk = pushBinaryOperator( OPCODE_LESS_EQUAL ); break; + case BIFF_TOKID_EQ: bOk = pushBinaryOperator( OPCODE_EQUAL ); break; + case BIFF_TOKID_GE: bOk = pushBinaryOperator( OPCODE_GREATER_EQUAL ); break; + case BIFF_TOKID_GT: bOk = pushBinaryOperator( OPCODE_GREATER ); break; + case BIFF_TOKID_NE: bOk = pushBinaryOperator( OPCODE_NOT_EQUAL ); break; + case BIFF_TOKID_ISECT: bOk = pushBinaryOperator( OPCODE_INTERSECT ); break; + case BIFF_TOKID_LIST: bOk = pushBinaryOperator( OPCODE_LIST ); break; + case BIFF_TOKID_RANGE: bOk = pushBinaryOperator( OPCODE_RANGE ); break; + case BIFF_TOKID_UPLUS: bOk = pushUnaryPreOperator( OPCODE_PLUS_SIGN ); break; + case BIFF_TOKID_UMINUS: bOk = pushUnaryPreOperator( OPCODE_MINUS_SIGN ); break; + case BIFF_TOKID_PERCENT: bOk = pushUnaryPostOperator( OPCODE_PERCENT ); break; + case BIFF_TOKID_PAREN: bOk = pushParenthesesOperator(); break; + case BIFF_TOKID_MISSARG: bOk = pushOperand( OPCODE_MISSING ); break; + case BIFF_TOKID_STR: bOk = (this->*mpImportStrToken)( rStrm ); break; + case BIFF_TOKID_NLR: bOk = (this->*mpImportNlrToken)( rStrm ); break; + case BIFF_TOKID_ATTR: bOk = importAttrToken( rStrm ); break; + case BIFF_TOKID_SHEET: bOk = (this->*mpImportSheetToken)( rStrm ); break; + case BIFF_TOKID_ENDSHEET: bOk = (this->*mpImportEndSheetToken)( rStrm ); break; + case BIFF_TOKID_ERR: bOk = pushBiffErrorOperand( rStrm.readuInt8() ); break; + case BIFF_TOKID_BOOL: bOk = pushBiffBoolOperand( rStrm.readuInt8() ); break; + case BIFF_TOKID_INT: bOk = pushValueOperand< double >( rStrm.readuInt16() ); break; + case BIFF_TOKID_NUM: bOk = pushValueOperand( rStrm.readDouble() ); break; default: bOk = false; } } @@ -1967,7 +2028,7 @@ void BiffFormulaParserImpl::importBiffFormula( FormulaContext& rContext, } // build and finalize the token sequence - if( bOk && (rStrm.getRecPos() == nEndPos) ) + if( bOk && (rStrm.tell() == nEndPos) ) finalizeImport(); // seek behind additional token data of tArray, tMemArea, tNlr tokens @@ -2042,16 +2103,22 @@ bool BiffFormulaParserImpl::importSpaceToken4( BiffInputStream& rStrm ) switch( nType ) { case BIFF_TOK_ATTR_SPACE_SP: + appendLeadingSpaces( nCount, false ); + break; case BIFF_TOK_ATTR_SPACE_BR: - incLeadingSpaces( nCount ); + appendLeadingSpaces( nCount, true ); break; case BIFF_TOK_ATTR_SPACE_SP_OPEN: + appendOpeningSpaces( nCount, false ); + break; case BIFF_TOK_ATTR_SPACE_BR_OPEN: - incOpeningSpaces( nCount ); + appendOpeningSpaces( nCount, true ); break; case BIFF_TOK_ATTR_SPACE_SP_CLOSE: + appendClosingSpaces( nCount, false ); + break; case BIFF_TOK_ATTR_SPACE_BR_CLOSE: - incClosingSpaces( nCount ); + appendClosingSpaces( nCount, true ); break; } return true; @@ -2115,7 +2182,7 @@ bool BiffFormulaParserImpl::importArrayToken( BiffInputStream& rStrm ) rStrm.skip( mnArraySize ); // start token array with opening brace and leading spaces - pushOperand( mrFuncProv.OPCODE_ARRAY_OPEN ); + pushOperand( OPCODE_ARRAY_OPEN ); size_t nOpSize = popOperandSize(); size_t nOldArraySize = getFormulaSize(); bool bBiff8 = getBiff() == BIFF8; @@ -2128,46 +2195,46 @@ bool BiffFormulaParserImpl::importArrayToken( BiffInputStream& rStrm ) OSL_ENSURE( (nCols > 0) && (nRows > 0), "BiffFormulaParserImpl::importArrayToken - empty array" ); // read array values and build token array - for( sal_uInt16 nRow = 0; rStrm.isValid() && (nRow < nRows); ++nRow ) + for( sal_uInt16 nRow = 0; !rStrm.isEof() && (nRow < nRows); ++nRow ) { if( nRow > 0 ) - appendRawToken( mrFuncProv.OPCODE_ARRAY_ROWSEP ); - for( sal_uInt16 nCol = 0; rStrm.isValid() && (nCol < nCols); ++nCol ) + appendRawToken( OPCODE_ARRAY_ROWSEP ); + for( sal_uInt16 nCol = 0; !rStrm.isEof() && (nCol < nCols); ++nCol ) { if( nCol > 0 ) - appendRawToken( mrFuncProv.OPCODE_ARRAY_COLSEP ); + appendRawToken( OPCODE_ARRAY_COLSEP ); switch( rStrm.readuInt8() ) { case BIFF_DATATYPE_EMPTY: - appendRawToken( mrFuncProv.OPCODE_PUSH ) <<= OUString(); + appendRawToken( OPCODE_PUSH ) <<= OUString(); rStrm.skip( 8 ); break; case BIFF_DATATYPE_DOUBLE: - appendRawToken( mrFuncProv.OPCODE_PUSH ) <<= rStrm.readDouble(); + appendRawToken( OPCODE_PUSH ) <<= rStrm.readDouble(); break; case BIFF_DATATYPE_STRING: - appendRawToken( mrFuncProv.OPCODE_PUSH ) <<= bBiff8 ? + appendRawToken( OPCODE_PUSH ) <<= bBiff8 ? rStrm.readUniString() : rStrm.readByteString( false, getTextEncoding() ); break; case BIFF_DATATYPE_BOOL: - appendRawToken( mrFuncProv.OPCODE_PUSH ) <<= static_cast< double >( (rStrm.readuInt8() == 0) ? 0.0 : 1.0 ); + appendRawToken( OPCODE_PUSH ) <<= static_cast< double >( (rStrm.readuInt8() == BIFF_TOK_BOOL_FALSE) ? 0.0 : 1.0 ); rStrm.skip( 7 ); break; case BIFF_DATATYPE_ERROR: - appendRawToken( mrFuncProv.OPCODE_PUSH ) <<= BiffHelper::calcDoubleFromError( rStrm.readuInt8() ); + appendRawToken( OPCODE_PUSH ) <<= BiffHelper::calcDoubleFromError( rStrm.readuInt8() ); rStrm.skip( 7 ); break; default: OSL_ENSURE( false, "BiffFormulaParserImpl::importArrayToken - unknown data type" ); - appendRawToken( mrFuncProv.OPCODE_PUSH ) <<= BiffHelper::calcDoubleFromError( BIFF_ERR_NA ); + appendRawToken( OPCODE_PUSH ) <<= BiffHelper::calcDoubleFromError( BIFF_ERR_NA ); } } } swapStreamPosition( rStrm ); // close token array and set resulting operand size - appendRawToken( mrFuncProv.OPCODE_ARRAY_CLOSE ); + appendRawToken( OPCODE_ARRAY_CLOSE ); pushOperandSize( nOpSize + getFormulaSize() - nOldArraySize ); return true; } @@ -2377,7 +2444,7 @@ LinkSheetRange BiffFormulaParserImpl::readSheetRange8( BiffInputStream& rStrm ) void BiffFormulaParserImpl::swapStreamPosition( BiffInputStream& rStrm ) { - sal_uInt32 nRecPos = rStrm.getRecPos(); + sal_Int64 nRecPos = rStrm.tell(); rStrm.seek( mnAddDataPos ); mnAddDataPos = nRecPos; } @@ -2385,7 +2452,7 @@ void BiffFormulaParserImpl::swapStreamPosition( BiffInputStream& rStrm ) void BiffFormulaParserImpl::skipMemAreaAddData( BiffInputStream& rStrm ) { swapStreamPosition( rStrm ); - sal_uInt32 nCount = rStrm.readuInt16(); + sal_Int32 nCount = rStrm.readuInt16(); rStrm.skip( ((getBiff() == BIFF8) ? 8 : 6) * nCount ); swapStreamPosition( rStrm ); } @@ -2404,7 +2471,7 @@ bool BiffFormulaParserImpl::readNlrSRangeAddData( BiffNlr& orNlr, bool& orbIsRow rStrm >> nCount; bool bRel = getFlag( nCount, BIFF_TOK_NLR_ADDREL ); nCount &= BIFF_TOK_NLR_ADDMASK; - sal_uInt32 nEndPos = rStrm.getRecPos() + 4 * nCount; + sal_Int64 nEndPos = rStrm.tell() + 4 * nCount; // read list of cell addresses bool bValid = false; if( nCount >= 2 ) @@ -2419,7 +2486,7 @@ bool BiffFormulaParserImpl::readNlrSRangeAddData( BiffNlr& orNlr, bool& orbIsRow { aAddr1 = aAddr2; rStrm >> aAddr2; - bValid = rStrm.isValid() && lclIsValidNlrStack( aAddr1, aAddr2, orbIsRow ); + bValid = !rStrm.isEof() && lclIsValidNlrStack( aAddr1, aAddr2, orbIsRow ); } // check that last imported position (aAddr2) is not at the end of the sheet bValid = bValid && (orbIsRow ? (aAddr2.mnCol < mnMaxApiCol) : (aAddr2.mnRow < mnMaxApiRow)); @@ -2518,19 +2585,19 @@ bool BiffFormulaParserImpl::pushBiffExtName( sal_Int32 nRefId, sal_uInt16 nNameI bool BiffFormulaParserImpl::pushBiffFunction( sal_uInt16 nFuncId ) { - if( const FunctionInfo* pFuncInfo = mrFuncProv.getFuncInfoFromBiffFuncId( nFuncId ) ) + if( const FunctionInfo* pFuncInfo = getFuncInfoFromBiffFuncId( nFuncId ) ) if( pFuncInfo->mnMinParamCount == pFuncInfo->mnMaxParamCount ) return pushFunctionOperator( *pFuncInfo, pFuncInfo->mnMinParamCount ); - return pushFunctionOperator( mrFuncProv.OPCODE_NONAME, 0 ); + return pushFunctionOperator( OPCODE_NONAME, 0 ); } bool BiffFormulaParserImpl::pushBiffFunction( sal_uInt16 nFuncId, sal_uInt8 nParamCount ) { if( getFlag( nFuncId, BIFF_TOK_FUNCVAR_CMD ) ) nParamCount &= BIFF_TOK_FUNCVAR_COUNTMASK; - if( const FunctionInfo* pFuncInfo = mrFuncProv.getFuncInfoFromBiffFuncId( nFuncId ) ) + if( const FunctionInfo* pFuncInfo = getFuncInfoFromBiffFuncId( nFuncId ) ) return pushFunctionOperator( *pFuncInfo, nParamCount ); - return pushFunctionOperator( mrFuncProv.OPCODE_NONAME, nParamCount ); + return pushFunctionOperator( OPCODE_NONAME, nParamCount ); } // ============================================================================ @@ -2540,8 +2607,8 @@ FormulaParser::FormulaParser( const WorkbookHelper& rHelper ) : { switch( getFilterType() ) { - case FILTER_OOX: mxImpl.reset( new OoxFormulaParserImpl( rHelper, maFuncProv ) ); break; - case FILTER_BIFF: mxImpl.reset( new BiffFormulaParserImpl( rHelper, maFuncProv ) ); break; + case FILTER_OOX: mxImpl.reset( new OoxFormulaParserImpl( *this ) ); break; + case FILTER_BIFF: mxImpl.reset( new BiffFormulaParserImpl( *this ) ); break; case FILTER_UNKNOWN: break; } } @@ -2569,10 +2636,10 @@ void FormulaParser::convertErrorToFormula( FormulaContext& rContext, sal_uInt8 n { ApiTokenSequence aTokens( 3 ); // HACK: enclose all error codes into an 1x1 matrix - aTokens[ 0 ].OpCode = maFuncProv.OPCODE_ARRAY_OPEN; - aTokens[ 1 ].OpCode = maFuncProv.OPCODE_PUSH; + aTokens[ 0 ].OpCode = OPCODE_ARRAY_OPEN; + aTokens[ 1 ].OpCode = OPCODE_PUSH; aTokens[ 1 ].Data <<= BiffHelper::calcDoubleFromError( nErrorCode ); - aTokens[ 2 ].OpCode = maFuncProv.OPCODE_ARRAY_CLOSE; + aTokens[ 2 ].OpCode = OPCODE_ARRAY_CLOSE; mxImpl->setFormula( rContext, aTokens ); } @@ -2581,7 +2648,7 @@ void FormulaParser::convertNameToFormula( FormulaContext& rContext, sal_Int32 nT if( nTokenIndex >= 0 ) { ApiTokenSequence aTokens( 1 ); - aTokens[ 0 ].OpCode = maFuncProv.OPCODE_NAME; + aTokens[ 0 ].OpCode = OPCODE_NAME; aTokens[ 0 ].Data <<= nTokenIndex; mxImpl->setFormula( rContext, aTokens ); } @@ -2589,6 +2656,24 @@ void FormulaParser::convertNameToFormula( FormulaContext& rContext, sal_Int32 nT convertErrorToFormula( rContext, BIFF_ERR_REF ); } +void FormulaParser::convertNumberToHyperlink( FormulaContext& rContext, const OUString& rUrl, double fValue ) const +{ + OSL_ENSURE( rUrl.getLength() > 0, "FormulaParser::convertNumberToHyperlink - missing URL" ); + if( const FunctionInfo* pFuncInfo = getFuncInfoFromOobFuncId( OOBIN_FUNC_HYPERLINK ) ) + { + ApiTokenSequence aTokens( 6 ); + aTokens[ 0 ].OpCode = pFuncInfo->mnApiOpCode; + aTokens[ 1 ].OpCode = OPCODE_OPEN; + aTokens[ 2 ].OpCode = OPCODE_PUSH; + aTokens[ 2 ].Data <<= rUrl; + aTokens[ 3 ].OpCode = OPCODE_SEP; + aTokens[ 4 ].OpCode = OPCODE_PUSH; + aTokens[ 4 ].Data <<= fValue; + aTokens[ 5 ].OpCode = OPCODE_CLOSE; + mxImpl->setFormula( rContext, aTokens ); + } +} + // ============================================================================ } // namespace xls diff --git a/oox/source/xls/makefile.mk b/oox/source/xls/makefile.mk index a69e9ac49d41..00b47545fc9b 100644 --- a/oox/source/xls/makefile.mk +++ b/oox/source/xls/makefile.mk @@ -1,14 +1,14 @@ #************************************************************************* # # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# +# # Copyright 2008 by Sun Microsystems, Inc. # # OpenOffice.org - a multi-platform office productivity suite # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.5 $ +# $Revision: 1.5.20.2 $ # # This file is part of OpenOffice.org. # @@ -49,7 +49,6 @@ SLOFILES = \ $(SLO)$/autofiltercontext.obj \ $(SLO)$/biffcodec.obj \ $(SLO)$/biffdetector.obj \ - $(SLO)$/bifffragmenthandler.obj \ $(SLO)$/biffhelper.obj \ $(SLO)$/biffinputstream.obj \ $(SLO)$/biffoutputstream.obj \ @@ -87,7 +86,6 @@ SLOFILES = \ $(SLO)$/tablefragment.obj \ $(SLO)$/themebuffer.obj \ $(SLO)$/unitconverter.obj \ - $(SLO)$/validationpropertyhelper.obj \ $(SLO)$/viewsettings.obj \ $(SLO)$/webquerybuffer.obj \ $(SLO)$/workbookfragment.obj \ diff --git a/oox/source/xls/numberformatsbuffer.cxx b/oox/source/xls/numberformatsbuffer.cxx index 74e712a8bd51..5edda6513545 100644 --- a/oox/source/xls/numberformatsbuffer.cxx +++ b/oox/source/xls/numberformatsbuffer.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: numberformatsbuffer.cxx,v $ - * $Revision: 1.5 $ + * $Revision: 1.5.6.2 $ * * This file is part of OpenOffice.org. * @@ -39,9 +39,9 @@ #include <rtl/string.hxx> #include <rtl/strbuf.hxx> #include <rtl/ustrbuf.hxx> -#include <comphelper/processfactory.hxx> #include "oox/helper/attributelist.hxx" #include "oox/helper/recordinputstream.hxx" +#include "oox/core/filterbase.hxx" #include "oox/xls/biffinputstream.hxx" using ::rtl::OString; @@ -1950,10 +1950,8 @@ NumberFormatsBuffer::NumberFormatsBuffer( const WorkbookHelper& rHelper ) : // get the current locale try { - Reference< XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory(); - Reference< XMultiServiceFactory > xConfigProv( - xFactory->createInstance( CREATE_OUSTRING( "com.sun.star.configuration.ConfigurationProvider" ) ), - UNO_QUERY_THROW ); + Reference< XMultiServiceFactory > xConfigProv( getBaseFilter().getGlobalFactory()->createInstance( + CREATE_OUSTRING( "com.sun.star.configuration.ConfigurationProvider" ) ), UNO_QUERY_THROW ); // try user-defined locale setting Sequence< Any > aArgs( 1 ); @@ -2016,8 +2014,8 @@ void NumberFormatsBuffer::importFormat( BiffInputStream& rStrm ) aFmtCode = rStrm.readByteString( false, getTextEncoding() ); break; case BIFF4: - // in BIFF4 the index field exists, but is undefined - aFmtCode = rStrm.skip( 2 ).readByteString( false, getTextEncoding() ); + rStrm.skip( 2 ); // in BIFF4 the index field exists, but is undefined + aFmtCode = rStrm.readByteString( false, getTextEncoding() ); break; case BIFF5: mnNextBiffIndex = rStrm.readuInt16(); diff --git a/oox/source/xls/pagesettings.cxx b/oox/source/xls/pagesettings.cxx index 54b01bc22b68..a06b473cd24c 100644 --- a/oox/source/xls/pagesettings.cxx +++ b/oox/source/xls/pagesettings.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: pagesettings.cxx,v $ - * $Revision: 1.5 $ + * $Revision: 1.5.4.1 $ * * This file is part of OpenOffice.org. * @@ -376,7 +376,7 @@ void PageSettings::importPrintGridLines( BiffInputStream& rStrm ) void PageSettings::importHeader( BiffInputStream& rStrm ) { - if( rStrm.getRecLeft() > 0 ) + if( rStrm.getRemaining() > 0 ) maOoxData.maOddHeader = (getBiff() == BIFF8) ? rStrm.readUniString() : rStrm.readByteString( false, getTextEncoding() ); else maOoxData.maOddHeader = OUString(); @@ -384,7 +384,7 @@ void PageSettings::importHeader( BiffInputStream& rStrm ) void PageSettings::importFooter( BiffInputStream& rStrm ) { - if( rStrm.getRecLeft() > 0 ) + if( rStrm.getRemaining() > 0 ) maOoxData.maOddFooter = (getBiff() == BIFF8) ? rStrm.readUniString() : rStrm.readByteString( false, getTextEncoding() ); else maOoxData.maOddFooter = OUString(); diff --git a/oox/source/xls/richstring.cxx b/oox/source/xls/richstring.cxx index eca56bc553e5..f914b1c818aa 100644 --- a/oox/source/xls/richstring.cxx +++ b/oox/source/xls/richstring.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: richstring.cxx,v $ - * $Revision: 1.4 $ + * $Revision: 1.4.20.2 $ * * This file is part of OpenOffice.org. * @@ -112,17 +112,23 @@ void BinFontPortionData::read( RecordInputStream& rStrm ) mnFontId = rStrm.readuInt16(); } -void BinFontPortionData::read( BiffInputStream& rStrm, bool b16Bit ) +void BinFontPortionData::read( BiffInputStream& rStrm, BiffFontPortionMode eMode ) { - if( b16Bit ) + switch( eMode ) { - mnPos = rStrm.readuInt16(); - mnFontId = rStrm.readuInt16(); - } - else - { - mnPos = rStrm.readuInt8(); - mnFontId = rStrm.readuInt8(); + case BIFF_FONTPORTION_8BIT: + mnPos = rStrm.readuInt8(); + mnFontId = rStrm.readuInt8(); + break; + case BIFF_FONTPORTION_16BIT: + mnPos = rStrm.readuInt16(); + mnFontId = rStrm.readuInt16(); + break; + case BIFF_FONTPORTION_OBJ: + mnPos = rStrm.readuInt16(); + mnFontId = rStrm.readuInt16(); + rStrm.skip( 4 ); + break; } } @@ -144,11 +150,11 @@ void BinFontPortionList::importPortions( RecordInputStream& rStrm ) clear(); if( nCount > 0 ) { - reserve( getLimitedValue< size_t, sal_Int32 >( nCount, 0, rStrm.getRecLeft() / 4 ) ); + reserve( getLimitedValue< size_t, sal_Int64 >( nCount, 0, rStrm.getRemaining() / 4 ) ); /* #i33341# real life -- same character index may occur several times -> use appendPortion() to validate string position. */ BinFontPortionData aPortion; - for( sal_Int32 nIndex = 0; rStrm.isValid() && (nIndex < nCount); ++nIndex ) + for( sal_Int32 nIndex = 0; !rStrm.isEof() && (nIndex < nCount); ++nIndex ) { aPortion.read( rStrm ); appendPortion( aPortion ); @@ -156,16 +162,16 @@ void BinFontPortionList::importPortions( RecordInputStream& rStrm ) } } -void BinFontPortionList::importPortions( BiffInputStream& rStrm, sal_uInt16 nCount, bool b16Bit ) +void BinFontPortionList::importPortions( BiffInputStream& rStrm, sal_uInt16 nCount, BiffFontPortionMode eMode ) { clear(); reserve( nCount ); /* #i33341# real life -- same character index may occur several times -> use appendPortion() to validate string position. */ BinFontPortionData aPortion; - for( sal_uInt16 nIndex = 0; rStrm.isValid() && (nIndex < nCount); ++nIndex ) + for( sal_uInt16 nIndex = 0; !rStrm.isEof() && (nIndex < nCount); ++nIndex ) { - aPortion.read( rStrm, b16Bit ); + aPortion.read( rStrm, eMode ); appendPortion( aPortion ); } } @@ -173,7 +179,7 @@ void BinFontPortionList::importPortions( BiffInputStream& rStrm, sal_uInt16 nCou void BinFontPortionList::importPortions( BiffInputStream& rStrm, bool b16Bit ) { sal_uInt16 nCount = b16Bit ? rStrm.readuInt16() : rStrm.readuInt8(); - importPortions( rStrm, nCount, b16Bit ); + importPortions( rStrm, nCount, b16Bit ? BIFF_FONTPORTION_16BIT : BIFF_FONTPORTION_8BIT ); } // ============================================================================ @@ -309,9 +315,9 @@ void BinPhoneticPortionList::importPortions( RecordInputStream& rStrm ) clear(); if( nCount > 0 ) { - reserve( getLimitedValue< size_t, sal_Int32 >( nCount, 0, rStrm.getRecLeft() / 6 ) ); + reserve( getLimitedValue< size_t, sal_Int64 >( nCount, 0, rStrm.getRemaining() / 6 ) ); BinPhoneticPortionData aPortion; - for( sal_Int32 nIndex = 0; rStrm.isValid() && (nIndex < nCount); ++nIndex ) + for( sal_Int32 nIndex = 0; !rStrm.isEof() && (nIndex < nCount); ++nIndex ) { aPortion.read( rStrm ); appendPortion( aPortion ); @@ -319,7 +325,7 @@ void BinPhoneticPortionList::importPortions( RecordInputStream& rStrm ) } } -OUString BinPhoneticPortionList::importPortions( BiffInputStream& rStrm, sal_uInt32 nPhoneticSize ) +OUString BinPhoneticPortionList::importPortions( BiffInputStream& rStrm, sal_Int32 nPhoneticSize ) { OUString aPhoneticText; sal_uInt16 nPortionCount, nTextLen1, nTextLen2; @@ -327,7 +333,7 @@ OUString BinPhoneticPortionList::importPortions( BiffInputStream& rStrm, sal_uIn OSL_ENSURE( nTextLen1 == nTextLen2, "BinPhoneticPortionList::importPortions - wrong phonetic text length" ); if( (nTextLen1 == nTextLen2) && (nTextLen1 > 0) ) { - sal_uInt32 nMinSize = static_cast< sal_uInt32 >( 2 * nTextLen1 + 6 * nPortionCount + 14 ); + sal_Int32 nMinSize = 2 * nTextLen1 + 6 * nPortionCount + 14; OSL_ENSURE( nMinSize <= nPhoneticSize, "BinPhoneticPortionList::importPortions - wrong size of phonetic data" ); if( nMinSize <= nPhoneticSize ) { @@ -380,7 +386,7 @@ void RichString::importString( RecordInputStream& rStrm, bool bRich ) sal_uInt8 nFlags = bRich ? rStrm.readuInt8() : 0; OUString aBaseText = rStrm.readString(); - if( rStrm.isValid() && getFlag( nFlags, OOBIN_STRINGFLAG_FONTS ) ) + if( !rStrm.isEof() && getFlag( nFlags, OOBIN_STRINGFLAG_FONTS ) ) { BinFontPortionList aPortions; aPortions.importPortions( rStrm ); @@ -391,7 +397,7 @@ void RichString::importString( RecordInputStream& rStrm, bool bRich ) createPortion()->setText( aBaseText ); } - if( rStrm.isValid() && getFlag( nFlags, OOBIN_STRINGFLAG_PHONETICS ) ) + if( !rStrm.isEof() && getFlag( nFlags, OOBIN_STRINGFLAG_PHONETICS ) ) { OUString aPhoneticText = rStrm.readString(); BinPhoneticPortionList aPortions; @@ -409,7 +415,7 @@ void RichString::importByteString( BiffInputStream& rStrm, rtl_TextEncoding eDef OString aBaseText = rStrm.readByteString( !b8BitLength ); - if( rStrm.isValid() && getFlag( nFlags, BIFF_STR_EXTRAFONTS ) ) + if( !rStrm.isEof() && getFlag( nFlags, BIFF_STR_EXTRAFONTS ) ) { BinFontPortionList aPortions; aPortions.importPortions( rStrm, false ); @@ -436,17 +442,17 @@ void RichString::importUniString( BiffInputStream& rStrm, BiffStringFlags nFlags bool bFonts = getFlag( nFlagField, BIFF_STRF_RICH ); bool bPhonetic = getFlag( nFlagField, BIFF_STRF_PHONETIC ); sal_uInt16 nFontCount = bFonts ? rStrm.readuInt16() : 0; - sal_uInt32 nPhoneticSize = bPhonetic ? rStrm.readuInt32() : 0; + sal_Int32 nPhoneticSize = bPhonetic ? rStrm.readInt32() : 0; // --- character array --- OUString aBaseText = rStrm.readUniStringChars( nChars, b16Bit ); // --- formatting --- // #122185# bRich flag may be set, but format runs may be missing - if( rStrm.isValid() && (nFontCount > 0) ) + if( !rStrm.isEof() && (nFontCount > 0) ) { BinFontPortionList aPortions; - aPortions.importPortions( rStrm, nFontCount, true ); + aPortions.importPortions( rStrm, nFontCount, BIFF_FONTPORTION_16BIT ); createFontPortions( aBaseText, aPortions ); } else @@ -456,16 +462,16 @@ void RichString::importUniString( BiffInputStream& rStrm, BiffStringFlags nFlags // --- Asian phonetic information --- // #122185# bPhonetic flag may be set, but phonetic info may be missing - if( rStrm.isValid() && (nPhoneticSize > 0) ) + if( !rStrm.isEof() && (nPhoneticSize > 0) ) { - sal_uInt32 nPhoneticEnd = rStrm.getRecPos() + nPhoneticSize; + sal_Int64 nPhoneticEnd = rStrm.tell() + nPhoneticSize; OSL_ENSURE( nPhoneticSize > 14, "RichString::importUniString - wrong size of phonetic data" ); if( nPhoneticSize > 14 ) { sal_uInt16 nId, nSize; rStrm >> nId >> nSize; OSL_ENSURE( nId == 1, "RichString::importUniString - unknown phonetic data identifier" ); - sal_uInt32 nMinSize = static_cast< sal_uInt32 >( nSize + 4 ); + sal_Int32 nMinSize = nSize + 4; OSL_ENSURE( nMinSize <= nPhoneticSize, "RichString::importUniString - wrong size of phonetic data" ); if( (nId == 1) && (nMinSize <= nPhoneticSize) ) { diff --git a/oox/source/xls/sharedformulabuffer.cxx b/oox/source/xls/sharedformulabuffer.cxx index 24199dba244a..3e0f1ce4a1a3 100644 --- a/oox/source/xls/sharedformulabuffer.cxx +++ b/oox/source/xls/sharedformulabuffer.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: sharedformulabuffer.cxx,v $ - * $Revision: 1.4 $ + * $Revision: 1.4.20.1 $ * * This file is part of OpenOffice.org. * @@ -35,7 +35,6 @@ #include "oox/helper/recordinputstream.hxx" #include "oox/xls/addressconverter.hxx" #include "oox/xls/biffinputstream.hxx" -#include "oox/xls/defnamesbuffer.hxx" #include "oox/xls/formulaparser.hxx" using ::rtl::OUString; @@ -184,11 +183,11 @@ Reference< XNamedRange > SharedFormulaBuffer::createDefinedName( const BinAddres append( static_cast< sal_Int32 >( getSheetIndex() + 1 ) ). append( sal_Unicode( '_' ) ).append( rMapKey.mnRow ). append( sal_Unicode( '_' ) ).append( rMapKey.mnCol ).makeStringAndClear(); - Reference< XNamedRange > xNamedRange = getDefinedNames().createDefinedName( aName ); + Reference< XNamedRange > xNamedRange = createNamedRangeObject( aName ); PropertySet aNameProps( xNamedRange ); aNameProps.setProperty( maIsSharedProp, true ); - sal_Int32 nTokenIndex = getDefinedNames().getTokenIndex( xNamedRange ); - if( nTokenIndex >= 0 ) + sal_Int32 nTokenIndex = -1; + if( aNameProps.getProperty( nTokenIndex, CREATE_OUSTRING( "TokenIndex" ) ) && (nTokenIndex >= 0) ) maIndexMap[ rMapKey ] = nTokenIndex; return xNamedRange; } diff --git a/oox/source/xls/sharedstringsbuffer.cxx b/oox/source/xls/sharedstringsbuffer.cxx index 23c263476967..f122046ac73a 100644 --- a/oox/source/xls/sharedstringsbuffer.cxx +++ b/oox/source/xls/sharedstringsbuffer.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: sharedstringsbuffer.cxx,v $ - * $Revision: 1.3 $ + * $Revision: 1.3.22.1 $ * * This file is part of OpenOffice.org. * @@ -53,12 +53,13 @@ RichStringRef SharedStringsBuffer::createRichString() void SharedStringsBuffer::importSst( BiffInputStream& rStrm ) { - sal_Int32 nStringCount = rStrm.skip( 4 ).readInt32(); + rStrm.skip( 4 ); + sal_Int32 nStringCount = rStrm.readInt32(); if( nStringCount > 0 ) { maStrings.clear(); maStrings.reserve( static_cast< size_t >( nStringCount ) ); - for( ; rStrm.isValid() && (nStringCount > 0); --nStringCount ) + for( ; !rStrm.isEof() && (nStringCount > 0); --nStringCount ) { RichStringRef xString( new RichString( *this ) ); maStrings.push_back( xString ); diff --git a/oox/source/xls/sheetdatacontext.cxx b/oox/source/xls/sheetdatacontext.cxx index f78b673742a2..5540068290b6 100644 --- a/oox/source/xls/sheetdatacontext.cxx +++ b/oox/source/xls/sheetdatacontext.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: sheetdatacontext.cxx,v $ - * $Revision: 1.5 $ + * $Revision: 1.5.4.3 $ * * This file is part of OpenOffice.org. * @@ -109,7 +109,7 @@ const sal_uInt32 BIFF_ROW_THICKTOP = 0x10000000; const sal_uInt32 BIFF_ROW_THICKBOTTOM = 0x20000000; const sal_uInt32 BIFF_ROW_SHOWPHONETIC = 0x40000000; -const sal_Int32 BIFF_XF_EXTENDED_IDS = 63; +const sal_Int32 BIFF2_XF_EXTENDED_IDS = 63; const sal_uInt8 BIFF2_XF_MASK = 0x3F; // ---------------------------------------------------------------------------- @@ -622,9 +622,8 @@ void OoxSheetDataContext::importDataTable( RecordInputStream& rStrm ) // ============================================================================ -OoxExternalSheetDataContext::OoxExternalSheetDataContext( - OoxWorkbookFragmentBase& rFragment, WorksheetType eSheetType, sal_Int32 nSheet ) : - OoxWorksheetContextBase( rFragment, ISegmentProgressBarRef(), eSheetType, nSheet ) +OoxExternalSheetDataContext::OoxExternalSheetDataContext( OoxWorkbookFragmentBase& rFragment, sal_Int32 nSheet ) : + OoxWorksheetContextBase( rFragment, ISegmentProgressBarRef(), SHEETTYPE_WORKSHEET, nSheet ) { } @@ -753,8 +752,8 @@ void OoxExternalSheetDataContext::importExtCellString( RecordInputStream& rStrm // ============================================================================ // ============================================================================ -BiffSheetDataContext::BiffSheetDataContext( const WorksheetHelper& rHelper ) : - WorksheetHelper( rHelper ), +BiffSheetDataContext::BiffSheetDataContext( const BiffWorksheetFragmentBase& rParent ) : + BiffWorksheetContextBase( rParent ), mnBiff2XfId( 0 ) { mnArrayIgnoreSize = (getBiff() == BIFF2) ? 1 : ((getBiff() <= BIFF4) ? 2 : 6); @@ -778,80 +777,80 @@ BiffSheetDataContext::BiffSheetDataContext( const WorksheetHelper& rHelper ) : } } -void BiffSheetDataContext::importRecord( BiffInputStream& rStrm ) +void BiffSheetDataContext::importRecord() { - sal_uInt16 nRecId = rStrm.getRecId(); + sal_uInt16 nRecId = mrStrm.getRecId(); switch( nRecId ) { // records in all BIFF versions case BIFF2_ID_ARRAY: // #i72713# - case BIFF3_ID_ARRAY: importArray( rStrm ); break; + case BIFF3_ID_ARRAY: importArray(); break; case BIFF2_ID_BLANK: - case BIFF3_ID_BLANK: importBlank( rStrm ); break; + case BIFF3_ID_BLANK: importBlank(); break; case BIFF2_ID_BOOLERR: - case BIFF3_ID_BOOLERR: importBoolErr( rStrm ); break; - case BIFF2_ID_INTEGER: importInteger( rStrm ); break; - case BIFF_ID_IXFE: rStrm >> mnBiff2XfId; break; + case BIFF3_ID_BOOLERR: importBoolErr(); break; + case BIFF2_ID_INTEGER: importInteger(); break; + case BIFF_ID_IXFE: mrStrm >> mnBiff2XfId; break; case BIFF2_ID_LABEL: - case BIFF3_ID_LABEL: importLabel( rStrm ); break; + case BIFF3_ID_LABEL: importLabel(); break; case BIFF2_ID_NUMBER: - case BIFF3_ID_NUMBER: importNumber( rStrm ); break; - case BIFF_ID_RK: importRk( rStrm ); break; + case BIFF3_ID_NUMBER: importNumber(); break; + case BIFF_ID_RK: importRk(); break; // BIFF specific records default: switch( getBiff() ) { case BIFF2: switch( nRecId ) { - case BIFF2_ID_DATATABLE: importDataTable( rStrm ); break; - case BIFF2_ID_DATATABLE2: importDataTable( rStrm ); break; - case BIFF2_ID_FORMULA: importFormula( rStrm ); break; - case BIFF2_ID_ROW: importRow( rStrm ); break; + case BIFF2_ID_DATATABLE: importDataTable(); break; + case BIFF2_ID_DATATABLE2: importDataTable(); break; + case BIFF2_ID_FORMULA: importFormula(); break; + case BIFF2_ID_ROW: importRow(); break; } break; case BIFF3: switch( nRecId ) { - case BIFF3_ID_DATATABLE: importDataTable( rStrm ); break; - case BIFF3_ID_FORMULA: importFormula( rStrm ); break; - case BIFF3_ID_ROW: importRow( rStrm ); break; + case BIFF3_ID_DATATABLE: importDataTable(); break; + case BIFF3_ID_FORMULA: importFormula(); break; + case BIFF3_ID_ROW: importRow(); break; } break; case BIFF4: switch( nRecId ) { - case BIFF3_ID_DATATABLE: importDataTable( rStrm ); break; - case BIFF4_ID_FORMULA: importFormula( rStrm ); break; - case BIFF3_ID_ROW: importRow( rStrm ); break; + case BIFF3_ID_DATATABLE: importDataTable(); break; + case BIFF4_ID_FORMULA: importFormula(); break; + case BIFF3_ID_ROW: importRow(); break; } break; case BIFF5: switch( nRecId ) { - case BIFF3_ID_DATATABLE: importDataTable( rStrm ); break; + case BIFF3_ID_DATATABLE: importDataTable(); break; case BIFF3_ID_FORMULA: case BIFF4_ID_FORMULA: - case BIFF5_ID_FORMULA: importFormula( rStrm ); break; - case BIFF_ID_MULTBLANK: importMultBlank( rStrm ); break; - case BIFF_ID_MULTRK: importMultRk( rStrm ); break; - case BIFF3_ID_ROW: importRow( rStrm ); break; - case BIFF_ID_RSTRING: importLabel( rStrm ); break; - case BIFF_ID_SHAREDFMLA: importSharedFmla( rStrm ); break; + case BIFF5_ID_FORMULA: importFormula(); break; + case BIFF_ID_MULTBLANK: importMultBlank(); break; + case BIFF_ID_MULTRK: importMultRk(); break; + case BIFF3_ID_ROW: importRow(); break; + case BIFF_ID_RSTRING: importLabel(); break; + case BIFF_ID_SHAREDFMLA: importSharedFmla(); break; } break; case BIFF8: switch( nRecId ) { - case BIFF3_ID_DATATABLE: importDataTable( rStrm ); break; + case BIFF3_ID_DATATABLE: importDataTable(); break; case BIFF3_ID_FORMULA: case BIFF4_ID_FORMULA: - case BIFF5_ID_FORMULA: importFormula( rStrm ); break; - case BIFF_ID_LABELSST: importLabelSst( rStrm ); break; - case BIFF_ID_MULTBLANK: importMultBlank( rStrm ); break; - case BIFF_ID_MULTRK: importMultRk( rStrm ); break; - case BIFF3_ID_ROW: importRow( rStrm ); break; - case BIFF_ID_RSTRING: importLabel( rStrm ); break; - case BIFF_ID_SHAREDFMLA: importSharedFmla( rStrm ); break; + case BIFF5_ID_FORMULA: importFormula(); break; + case BIFF_ID_LABELSST: importLabelSst(); break; + case BIFF_ID_MULTBLANK: importMultBlank(); break; + case BIFF_ID_MULTRK: importMultRk(); break; + case BIFF3_ID_ROW: importRow(); break; + case BIFF_ID_RSTRING: importLabel(); break; + case BIFF_ID_SHAREDFMLA: importSharedFmla(); break; } break; @@ -868,44 +867,44 @@ void BiffSheetDataContext::setCurrCell( const BinAddress& rAddr ) maCurrCell.mxCell = getCell( rAddr, &maCurrCell.maAddress ); } -void BiffSheetDataContext::importXfId( BiffInputStream& rStrm, bool bBiff2 ) +void BiffSheetDataContext::importXfId( bool bBiff2 ) { if( bBiff2 ) { sal_uInt8 nBiff2XfId; - rStrm >> nBiff2XfId; - rStrm.skip( 2 ); + mrStrm >> nBiff2XfId; + mrStrm.skip( 2 ); maCurrCell.mnXfId = nBiff2XfId & BIFF2_XF_MASK; - if( maCurrCell.mnXfId == BIFF_XF_EXTENDED_IDS ) + if( maCurrCell.mnXfId == BIFF2_XF_EXTENDED_IDS ) maCurrCell.mnXfId = mnBiff2XfId; } else { - maCurrCell.mnXfId = rStrm.readuInt16(); + maCurrCell.mnXfId = mrStrm.readuInt16(); } } -void BiffSheetDataContext::importCellHeader( BiffInputStream& rStrm, bool bBiff2 ) +void BiffSheetDataContext::importCellHeader( bool bBiff2 ) { BinAddress aAddr; - rStrm >> aAddr; + mrStrm >> aAddr; setCurrCell( aAddr ); - importXfId( rStrm, bBiff2 ); + importXfId( bBiff2 ); } -void BiffSheetDataContext::importBlank( BiffInputStream& rStrm ) +void BiffSheetDataContext::importBlank() { - importCellHeader( rStrm, rStrm.getRecId() == BIFF2_ID_BLANK ); + importCellHeader( mrStrm.getRecId() == BIFF2_ID_BLANK ); setCellFormat( maCurrCell ); } -void BiffSheetDataContext::importBoolErr( BiffInputStream& rStrm ) +void BiffSheetDataContext::importBoolErr() { - importCellHeader( rStrm, rStrm.getRecId() == BIFF2_ID_BOOLERR ); + importCellHeader( mrStrm.getRecId() == BIFF2_ID_BOOLERR ); if( maCurrCell.mxCell.is() ) { sal_uInt8 nValue, nType; - rStrm >> nValue >> nType; + mrStrm >> nValue >> nType; switch( nType ) { case BIFF_BOOLERR_BOOL: @@ -925,33 +924,33 @@ void BiffSheetDataContext::importBoolErr( BiffInputStream& rStrm ) setCellFormat( maCurrCell ); } -void BiffSheetDataContext::importFormula( BiffInputStream& rStrm ) +void BiffSheetDataContext::importFormula() { - importCellHeader( rStrm, getBiff() == BIFF2 ); + importCellHeader( getBiff() == BIFF2 ); maCurrCell.mnCellType = XML_n; Reference< XFormulaTokens > xTokens( maCurrCell.mxCell, UNO_QUERY ); if( xTokens.is() ) { - rStrm.skip( mnFormulaIgnoreSize ); + mrStrm.skip( mnFormulaIgnoreSize ); ExtCellFormulaContext aContext( *this, xTokens, maCurrCell.maAddress ); - getFormulaParser().importFormula( aContext, rStrm ); + getFormulaParser().importFormula( aContext, mrStrm ); } setCellFormat( maCurrCell ); } -void BiffSheetDataContext::importInteger( BiffInputStream& rStrm ) +void BiffSheetDataContext::importInteger() { - importCellHeader( rStrm, true ); + importCellHeader( true ); maCurrCell.mnCellType = XML_n; if( maCurrCell.mxCell.is() ) - maCurrCell.mxCell->setValue( rStrm.readuInt16() ); + maCurrCell.mxCell->setValue( mrStrm.readuInt16() ); setCellFormat( maCurrCell ); } -void BiffSheetDataContext::importLabel( BiffInputStream& rStrm ) +void BiffSheetDataContext::importLabel() { - bool bBiff2Xf = rStrm.getRecId() == BIFF2_ID_LABEL; - importCellHeader( rStrm, bBiff2Xf ); + bool bBiff2Xf = mrStrm.getRecId() == BIFF2_ID_LABEL; + importCellHeader( bBiff2Xf ); maCurrCell.mnCellType = XML_inlineStr; Reference< XText > xText( maCurrCell.mxCell, UNO_QUERY ); if( xText.is() ) @@ -966,7 +965,7 @@ void BiffSheetDataContext::importLabel( BiffInputStream& rStrm ) RichString aString( *this ); if( getBiff() == BIFF8 ) { - aString.importUniString( rStrm ); + aString.importUniString( mrStrm ); } else { @@ -975,8 +974,8 @@ void BiffSheetDataContext::importLabel( BiffInputStream& rStrm ) if( const Font* pFont = getStyles().getFontFromCellXf( maCurrCell.mnXfId ).get() ) eTextEnc = pFont->getFontEncoding(); BiffStringFlags nFlags = bBiff2Xf ? BIFF_STR_8BITLENGTH : BIFF_STR_DEFAULT; - setFlag( nFlags, BIFF_STR_EXTRAFONTS, rStrm.getRecId() == BIFF_ID_RSTRING ); - aString.importByteString( rStrm, eTextEnc, nFlags ); + setFlag( nFlags, BIFF_STR_EXTRAFONTS, mrStrm.getRecId() == BIFF_ID_RSTRING ); + aString.importByteString( mrStrm, eTextEnc, nFlags ); } aString.finalizeImport(); aString.convert( xText, maCurrCell.mnXfId ); @@ -984,76 +983,81 @@ void BiffSheetDataContext::importLabel( BiffInputStream& rStrm ) setCellFormat( maCurrCell ); } -void BiffSheetDataContext::importLabelSst( BiffInputStream& rStrm ) +void BiffSheetDataContext::importLabelSst() { - importCellHeader( rStrm, false ); + importCellHeader( false ); maCurrCell.mnCellType = XML_s; if( maCurrCell.mxCell.is() ) - setSharedStringCell( maCurrCell.mxCell, rStrm.readInt32(), maCurrCell.mnXfId ); + setSharedStringCell( maCurrCell.mxCell, mrStrm.readInt32(), maCurrCell.mnXfId ); setCellFormat( maCurrCell ); } -void BiffSheetDataContext::importMultBlank( BiffInputStream& rStrm ) +void BiffSheetDataContext::importMultBlank() { BinAddress aAddr; - for( rStrm >> aAddr; rStrm.getRecLeft() > 2; ++aAddr.mnCol ) + for( mrStrm >> aAddr; mrStrm.getRemaining() > 2; ++aAddr.mnCol ) { setCurrCell( aAddr ); - importXfId( rStrm, false ); + importXfId( false ); setCellFormat( maCurrCell ); } } -void BiffSheetDataContext::importMultRk( BiffInputStream& rStrm ) +void BiffSheetDataContext::importMultRk() { BinAddress aAddr; - for( rStrm >> aAddr; rStrm.getRecLeft() > 2; ++aAddr.mnCol ) + for( mrStrm >> aAddr; mrStrm.getRemaining() > 2; ++aAddr.mnCol ) { setCurrCell( aAddr ); maCurrCell.mnCellType = XML_n; - importXfId( rStrm, false ); - sal_Int32 nRkValue = rStrm.readInt32(); + importXfId( false ); + sal_Int32 nRkValue = mrStrm.readInt32(); if( maCurrCell.mxCell.is() ) maCurrCell.mxCell->setValue( BiffHelper::calcDoubleFromRk( nRkValue ) ); setCellFormat( maCurrCell ); } } -void BiffSheetDataContext::importNumber( BiffInputStream& rStrm ) +void BiffSheetDataContext::importNumber() { - importCellHeader( rStrm, rStrm.getRecId() == BIFF2_ID_NUMBER ); + importCellHeader( mrStrm.getRecId() == BIFF2_ID_NUMBER ); maCurrCell.mnCellType = XML_n; if( maCurrCell.mxCell.is() ) - maCurrCell.mxCell->setValue( rStrm.readDouble() ); + maCurrCell.mxCell->setValue( mrStrm.readDouble() ); setCellFormat( maCurrCell ); } -void BiffSheetDataContext::importRk( BiffInputStream& rStrm ) +void BiffSheetDataContext::importRk() { - importCellHeader( rStrm, false ); + importCellHeader( false ); maCurrCell.mnCellType = XML_n; if( maCurrCell.mxCell.is() ) - maCurrCell.mxCell->setValue( BiffHelper::calcDoubleFromRk( rStrm.readInt32() ) ); + maCurrCell.mxCell->setValue( BiffHelper::calcDoubleFromRk( mrStrm.readInt32() ) ); setCellFormat( maCurrCell ); } -void BiffSheetDataContext::importRow( BiffInputStream& rStrm ) +void BiffSheetDataContext::importRow() { OoxRowData aData; sal_uInt16 nRow, nHeight; - rStrm >> nRow; - rStrm.skip( 4 ); - rStrm >> nHeight; + mrStrm >> nRow; + mrStrm.skip( 4 ); + mrStrm >> nHeight; if( getBiff() == BIFF2 ) { - aData.mbCustomFormat = rStrm.skip( 2 ).readuInt8() == BIFF2_ROW_CUSTOMFORMAT; + mrStrm.skip( 2 ); + aData.mbCustomFormat = mrStrm.readuInt8() == BIFF2_ROW_CUSTOMFORMAT; if( aData.mbCustomFormat ) - aData.mnXfId = rStrm.skip( 5 ).readuInt16(); + { + mrStrm.skip( 5 ); + aData.mnXfId = mrStrm.readuInt16(); + } } else { - sal_uInt32 nFlags = rStrm.skip( 4 ).readuInt32(); + mrStrm.skip( 4 ); + sal_uInt32 nFlags = mrStrm.readuInt32(); aData.mnXfId = extractValue< sal_Int32 >( nFlags, 16, 12 ); aData.mnLevel = extractValue< sal_Int32 >( nFlags, 0, 3 ); aData.mbCustomFormat = getFlag( nFlags, BIFF_ROW_CUSTOMFORMAT ); @@ -1073,52 +1077,52 @@ void BiffSheetDataContext::importRow( BiffInputStream& rStrm ) setRowData( aData ); } -void BiffSheetDataContext::importArray( BiffInputStream& rStrm ) +void BiffSheetDataContext::importArray() { BinRange aRange; - aRange.read( rStrm, false ); // columns always 8-bit + aRange.read( mrStrm, false ); // columns always 8-bit CellRangeAddress aArrayRange; Reference< XCellRange > xRange = getCellRange( aRange, &aArrayRange ); Reference< XArrayFormulaTokens > xTokens( xRange, UNO_QUERY ); if( xRange.is() && xTokens.is() ) { - rStrm.skip( mnArrayIgnoreSize ); + mrStrm.skip( mnArrayIgnoreSize ); ArrayFormulaContext aContext( xTokens, aArrayRange ); - getFormulaParser().importFormula( aContext, rStrm ); + getFormulaParser().importFormula( aContext, mrStrm ); } } -void BiffSheetDataContext::importSharedFmla( BiffInputStream& rStrm ) +void BiffSheetDataContext::importSharedFmla() { - getSharedFormulas().importSharedFmla( rStrm, maCurrCell.maAddress ); + getSharedFormulas().importSharedFmla( mrStrm, maCurrCell.maAddress ); } -void BiffSheetDataContext::importDataTable( BiffInputStream& rStrm ) +void BiffSheetDataContext::importDataTable() { BinRange aRange; - aRange.read( rStrm, false ); // columns always 8-bit + aRange.read( mrStrm, false ); // columns always 8-bit CellRangeAddress aTableRange; if( getAddressConverter().convertToCellRange( aTableRange, aRange, getSheetIndex(), true ) ) { OoxDataTableData aTableData; BinAddress aRef1, aRef2; - switch( rStrm.getRecId() ) + switch( mrStrm.getRecId() ) { case BIFF2_ID_DATATABLE: - rStrm.skip( 1 ); - aTableData.mbRowTable = rStrm.readuInt8() != 0; + mrStrm.skip( 1 ); + aTableData.mbRowTable = mrStrm.readuInt8() != 0; aTableData.mb2dTable = false; - rStrm >> aRef1; + mrStrm >> aRef1; break; case BIFF2_ID_DATATABLE2: - rStrm.skip( 2 ); + mrStrm.skip( 2 ); aTableData.mb2dTable = true; - rStrm >> aRef1 >> aRef2; + mrStrm >> aRef1 >> aRef2; break; case BIFF3_ID_DATATABLE: { sal_uInt16 nFlags; - rStrm >> nFlags >> aRef1 >> aRef2; + mrStrm >> nFlags >> aRef1 >> aRef2; aTableData.mbRowTable = getFlag( nFlags, BIFF_DATATABLE_ROW ); aTableData.mb2dTable = getFlag( nFlags, BIFF_DATATABLE_2D ); aTableData.mbRef1Deleted = getFlag( nFlags, BIFF_DATATABLE_REF1DEL ); @@ -1136,44 +1140,45 @@ void BiffSheetDataContext::importDataTable( BiffInputStream& rStrm ) // ============================================================================ -BiffExternalSheetDataContext::BiffExternalSheetDataContext( - const WorkbookHelper& rHelper, WorksheetType eSheetType, sal_Int32 nSheet ) : - WorksheetHelperRoot( rHelper, ISegmentProgressBarRef(), eSheetType, nSheet ) +BiffExternalSheetDataContext::BiffExternalSheetDataContext( const BiffWorkbookFragmentBase& rParent, sal_Int32 nSheet ) : + BiffWorksheetContextBase( rParent, ISegmentProgressBarRef(), SHEETTYPE_WORKSHEET, nSheet ) { } -void BiffExternalSheetDataContext::importCrn( BiffInputStream& rStrm ) +void BiffExternalSheetDataContext::importRecord() { + OSL_ENSURE( mrStrm.getRecId() == BIFF_ID_CRN, "BiffExternalSheetDataContext::importRecord - no CRN record found" ); + sal_uInt8 nCol2, nCol1; sal_uInt16 nRow; - rStrm >> nCol2 >> nCol1 >> nRow; + mrStrm >> nCol2 >> nCol1 >> nRow; bool bLoop = true; - for( BinAddress aAddr( nCol1, nRow ); bLoop && rStrm.isValid() && (aAddr.mnCol <= nCol2); ++aAddr.mnCol ) + for( BinAddress aAddr( nCol1, nRow ); bLoop && !mrStrm.isEof() && (aAddr.mnCol <= nCol2); ++aAddr.mnCol ) { Reference< XCell > xCell = getCell( aAddr ); bLoop = xCell.is(); - if( bLoop ) switch( rStrm.readuInt8() ) + if( bLoop ) switch( mrStrm.readuInt8() ) { case BIFF_DATATYPE_EMPTY: - rStrm.skip( 8 ); + mrStrm.skip( 8 ); setEmptyStringCell( xCell ); break; case BIFF_DATATYPE_DOUBLE: - xCell->setValue( rStrm.readDouble() ); + xCell->setValue( mrStrm.readDouble() ); break; case BIFF_DATATYPE_STRING: { - OUString aText = (getBiff() == BIFF8) ? rStrm.readUniString() : rStrm.readByteString( false, getTextEncoding() ); + OUString aText = (getBiff() == BIFF8) ? mrStrm.readUniString() : mrStrm.readByteString( false, getTextEncoding() ); setStringCell( xCell, aText, true ); } break; case BIFF_DATATYPE_BOOL: - setBooleanCell( xCell, rStrm.readuInt8() != 0 ); - rStrm.skip( 7 ); + setBooleanCell( xCell, mrStrm.readuInt8() != 0 ); + mrStrm.skip( 7 ); break; case BIFF_DATATYPE_ERROR: - setErrorCell( xCell, rStrm.readuInt8() ); - rStrm.skip( 7 ); + setErrorCell( xCell, mrStrm.readuInt8() ); + mrStrm.skip( 7 ); break; default: OSL_ENSURE( false, "BiffExternalSheetDataContext::importCrn - unknown data type" ); diff --git a/oox/source/xls/stylesbuffer.cxx b/oox/source/xls/stylesbuffer.cxx index 58908830a40b..5627c781ba2a 100644 --- a/oox/source/xls/stylesbuffer.cxx +++ b/oox/source/xls/stylesbuffer.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: stylesbuffer.cxx,v $ - * $Revision: 1.6 $ + * $Revision: 1.5.20.3 $ * * This file is part of OpenOffice.org. * @@ -542,13 +542,12 @@ void ColorPalette::importPalette( BiffInputStream& rStrm ) { sal_uInt16 nCount; rStrm >> nCount; - OSL_ENSURE( rStrm.getRecLeft() == static_cast< sal_uInt32 >( 4 * nCount ), - "ColorPalette::importPalette - wrong palette size" ); + OSL_ENSURE( rStrm.getRemaining() == 4 * nCount, "ColorPalette::importPalette - wrong palette size" ); // fill palette from BIFF_COLOR_USEROFFSET mnAppendIndex = BIFF_COLOR_USEROFFSET; Color aColor; - for( sal_uInt16 nIndex = 0; rStrm.isValid() && (nIndex < nCount); ++nIndex ) + for( sal_uInt16 nIndex = 0; !rStrm.isEof() && (nIndex < nCount); ++nIndex ) { aColor.importColorRgb( rStrm ); appendColor( aColor.getColor( *this ) ); @@ -592,6 +591,26 @@ void ColorPalette::appendColor( sal_Int32 nRGBValue ) // ============================================================================ +namespace { + +void lclSetFontName( ApiScriptFontName& rFontName, const FontDescriptor& rFontDesc, bool bHasGlyphs ) +{ + if( bHasGlyphs ) + { + rFontName.maName = rFontDesc.Name; + rFontName.mnFamily = rFontDesc.Family; + rFontName.mnCharSet = rFontDesc.CharSet; + } + else + { + rFontName = ApiScriptFontName(); + } +} + +} // namespace + +// ---------------------------------------------------------------------------- + OoxFontData::OoxFontData() : mnScheme( XML_none ), mnFamily( OOX_FONTFAMILY_NONE ), @@ -906,11 +925,11 @@ void Font::importCfRule( BiffInputStream& rStrm ) sal_uInt16 nWeight, nEscapement; sal_uInt8 nUnderline; - OSL_ENSURE( rStrm.getRecLeft() >= 118, "Font::importCfRule - missing record data" ); - sal_uInt32 nRecPos = rStrm.getRecPos(); + OSL_ENSURE( rStrm.getRemaining() >= 118, "Font::importCfRule - missing record data" ); + sal_Int64 nRecPos = rStrm.tell(); maOoxData.maName = rStrm.readUniString( rStrm.readuInt8() ); maUsedFlags.mbNameUsed = maOoxData.maName.getLength() > 0; - OSL_ENSURE( rStrm.isValid() && (rStrm.getRecPos() <= nRecPos + 64), "Font::importCfRule - font name too long" ); + OSL_ENSURE( !rStrm.isEof() && (rStrm.tell() <= nRecPos + 64), "Font::importCfRule - font name too long" ); rStrm.seek( nRecPos + 64 ); rStrm >> nHeight >> nStyle >> nWeight >> nEscapement >> nUnderline; rStrm.skip( 3 ); @@ -1020,7 +1039,7 @@ void Font::finalizeImport() if( xFont.is() ) { // #91658# CJK fonts - maApiData.mbHasAsian = + bool bHasAsian = xFont->hasGlyphs( OUString( sal_Unicode( 0x3041 ) ) ) || // 3040-309F: Hiragana xFont->hasGlyphs( OUString( sal_Unicode( 0x30A1 ) ) ) || // 30A0-30FF: Katakana xFont->hasGlyphs( OUString( sal_Unicode( 0x3111 ) ) ) || // 3100-312F: Bopomofo @@ -1035,7 +1054,7 @@ void Font::finalizeImport() xFont->hasGlyphs( OUString( sal_Unicode( 0xF901 ) ) ) || // F900-FAFF: CJK Compatibility Ideographs xFont->hasGlyphs( OUString( sal_Unicode( 0xFF71 ) ) ); // FF00-FFEF: Halfwidth/Fullwidth Forms // #113783# CTL fonts - maApiData.mbHasCmplx = + bool bHasCmplx = xFont->hasGlyphs( OUString( sal_Unicode( 0x05D1 ) ) ) || // 0590-05FF: Hebrew xFont->hasGlyphs( OUString( sal_Unicode( 0x0631 ) ) ) || // 0600-06FF: Arabic xFont->hasGlyphs( OUString( sal_Unicode( 0x0721 ) ) ) || // 0700-074F: Syriac @@ -1045,9 +1064,13 @@ void Font::finalizeImport() xFont->hasGlyphs( OUString( sal_Unicode( 0xFB51 ) ) ) || // FB50-FDFF: Arabic Presentation Forms-A xFont->hasGlyphs( OUString( sal_Unicode( 0xFE71 ) ) ); // FE70-FEFF: Arabic Presentation Forms-B // Western fonts - maApiData.mbHasWstrn = - (!maApiData.mbHasAsian && !maApiData.mbHasCmplx) || + bool bHasLatin = + (!bHasAsian && !bHasCmplx) || xFont->hasGlyphs( OUString( sal_Unicode( 'A' ) ) ); + + lclSetFontName( maApiData.maLatinFont, maApiData.maDesc, bHasLatin ); + lclSetFontName( maApiData.maAsianFont, maApiData.maDesc, bHasAsian ); + lclSetFontName( maApiData.maCmplxFont, maApiData.maDesc, bHasCmplx ); } } } @@ -1678,7 +1701,7 @@ void OoxGradientFillData::readGradientStop( RecordInputStream& rStrm, bool bDxf { rStrm >> aColor >> fPosition; } - if( rStrm.isValid() && (fPosition >= 0.0) ) + if( !rStrm.isEof() && (fPosition >= 0.0) ) maColors[ fPosition ] = aColor; } @@ -1784,7 +1807,7 @@ void Fill::importFill( RecordInputStream& rStrm ) rStrm.skip( 16 ); mxOoxGradData->readGradient( rStrm ); rStrm >> nStopCount; - for( sal_Int32 nStop = 0; (nStop < nStopCount) && rStrm.isValid(); ++nStop ) + for( sal_Int32 nStop = 0; (nStop < nStopCount) && !rStrm.isEof(); ++nStop ) mxOoxGradData->readGradientStop( rStrm, false ); } else @@ -2323,10 +2346,10 @@ void Dxf::importDxf( RecordInputStream& rStrm ) sal_uInt16 nRecCount; rStrm.skip( 4 ); // flags rStrm >> nRecCount; - for( sal_uInt16 nRec = 0; rStrm.isValid() && (nRec < nRecCount); ++nRec ) + for( sal_uInt16 nRec = 0; !rStrm.isEof() && (nRec < nRecCount); ++nRec ) { sal_uInt16 nSubRecId, nSubRecSize; - sal_Int32 nRecEnd = rStrm.getRecPos(); + sal_Int64 nRecEnd = rStrm.tell(); rStrm >> nSubRecId >> nSubRecSize; nRecEnd += nSubRecSize; switch( nSubRecId ) @@ -2356,7 +2379,7 @@ void Dxf::importDxf( RecordInputStream& rStrm ) } rStrm.seek( nRecEnd ); } - OSL_ENSURE( rStrm.isValid() && (rStrm.getRecLeft() == 0), "Dxf::importDxf - unexpected remaining data" ); + OSL_ENSURE( !rStrm.isEof() && (rStrm.getRemaining() == 0), "Dxf::importDxf - unexpected remaining data" ); mxNumFmt = getStyles().createNumFmt( nNumFmtId, aFmtCode ); } diff --git a/oox/source/xls/stylespropertyhelper.cxx b/oox/source/xls/stylespropertyhelper.cxx index 83626bd47876..ae2aa1439b94 100644 --- a/oox/source/xls/stylespropertyhelper.cxx +++ b/oox/source/xls/stylespropertyhelper.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: stylespropertyhelper.cxx,v $ - * $Revision: 1.3 $ + * $Revision: 1.3.22.1 $ * * This file is part of OpenOffice.org. * @@ -41,6 +41,7 @@ #include "oox/xls/stylesbuffer.hxx" using ::rtl::OUString; +using ::com::sun::star::awt::FontDescriptor; namespace oox { namespace xls { @@ -64,6 +65,14 @@ ApiFontUsedFlags::ApiFontUsedFlags( bool bAllUsed ) : // ---------------------------------------------------------------------------- +ApiScriptFontName::ApiScriptFontName() : + mnFamily( ::com::sun::star::awt::FontFamily::DONTKNOW ), + mnCharSet( RTL_TEXTENCODING_DONTKNOW ) +{ +} + +// ---------------------------------------------------------------------------- + ApiFontData::ApiFontData() : maDesc( CREATE_OUSTRING( "Calibri" ), @@ -86,10 +95,9 @@ ApiFontData::ApiFontData() : mnEscapement( API_ESCAPE_NONE ), mnEscapeHeight( API_ESCAPEHEIGHT_NONE ), mbOutline( false ), - mbShadow( false ), - mbHasWstrn( true ), - mbHasAsian( false ) + mbShadow( false ) { + maLatinFont.maName = maDesc.Name; } // ============================================================================ @@ -164,7 +172,7 @@ ApiSolidFillData::ApiSolidFillData() : namespace { /** Property names for Western font name settings. */ -const sal_Char* const sppcWstrnFontNameNames[] = +const sal_Char* const sppcLatinFontNameNames[] = { "CharFontName", "CharFontFamily", @@ -256,13 +264,19 @@ const sal_Char* const sppcSolidFillNames[] = 0 }; +void lclWriteFontName( PropertySet& rPropSet, PropertySequence& rPropSeq, const ApiScriptFontName& rFontName ) +{ + if( rFontName.maName.getLength() > 0 ) + rPropSeq << rFontName.maName << rFontName.mnFamily << rFontName.mnCharSet >> rPropSet; +} + } // namespace // ---------------------------------------------------------------------------- StylesPropertyHelper::StylesPropertyHelper( const WorkbookHelper& rHelper ) : WorkbookHelper( rHelper ), - maWstrnFontNameProps( sppcWstrnFontNameNames ), + maLatinFontNameProps( sppcLatinFontNameNames ), maAsianFontNameProps( sppcAsianFontNameNames ), maCmplxFontNameProps( sppcCmplxFontNameNames ), maFontHeightProps( sppcFontHeightNames ), @@ -289,12 +303,9 @@ void StylesPropertyHelper::writeFontProperties( PropertySet& rPropSet, // font name properties if( rUsedFlags.mbNameUsed ) { - if( rFontData.mbHasWstrn ) - maWstrnFontNameProps << rFontData.maDesc.Name << rFontData.maDesc.Family << rFontData.maDesc.CharSet >> rPropSet; - if( rFontData.mbHasAsian ) - maAsianFontNameProps << rFontData.maDesc.Name << rFontData.maDesc.Family << rFontData.maDesc.CharSet >> rPropSet; - if( rFontData.mbHasCmplx ) - maCmplxFontNameProps << rFontData.maDesc.Name << rFontData.maDesc.Family << rFontData.maDesc.CharSet >> rPropSet; + lclWriteFontName( rPropSet, maLatinFontNameProps, rFontData.maLatinFont ); + lclWriteFontName( rPropSet, maAsianFontNameProps, rFontData.maAsianFont ); + lclWriteFontName( rPropSet, maCmplxFontNameProps, rFontData.maCmplxFont ); } // font height if( rUsedFlags.mbHeightUsed ) diff --git a/oox/source/xls/themebuffer.cxx b/oox/source/xls/themebuffer.cxx index 34eeb797d6e6..65f9a2fcfb15 100644 --- a/oox/source/xls/themebuffer.cxx +++ b/oox/source/xls/themebuffer.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: themebuffer.cxx,v $ - * $Revision: 1.6 $ + * $Revision: 1.5.20.2 $ * * This file is part of OpenOffice.org. * @@ -34,8 +34,6 @@ using ::oox::drawingml::ClrScheme; using ::oox::drawingml::Color; -using ::oox::drawingml::Theme; -using ::oox::drawingml::ThemePtr; namespace oox { namespace xls { @@ -115,20 +113,10 @@ ThemeBuffer::~ThemeBuffer() { } -Theme& ThemeBuffer::getOrCreateCoreTheme() -{ - if( !mxTheme ) - mxTheme.reset( new Theme ); - return *mxTheme; -} - sal_Int32 ThemeBuffer::getColorByToken( sal_Int32 nToken ) const { sal_Int32 nColor = 0; - if( mxTheme.get() ) - if( mxTheme->getClrScheme().getColor( nToken, nColor ) ) - return nColor; - return API_RGB_TRANSPARENT; + return getClrScheme().getColor( nToken, nColor ) ? nColor : API_RGB_TRANSPARENT; } sal_Int32 ThemeBuffer::getColorByIndex( sal_Int32 nIndex ) const diff --git a/oox/source/xls/validationpropertyhelper.cxx b/oox/source/xls/validationpropertyhelper.cxx index 16124f0b02fb..e69de29bb2d1 100644 --- a/oox/source/xls/validationpropertyhelper.cxx +++ b/oox/source/xls/validationpropertyhelper.cxx @@ -1,170 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: validationpropertyhelper.cxx,v $ - * $Revision: 1.4 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "oox/xls/validationpropertyhelper.hxx" -#include <com/sun/star/sheet/ValidationType.hpp> -#include <com/sun/star/sheet/ValidationAlertStyle.hpp> -#include <com/sun/star/sheet/TableValidationVisibility.hpp> -#include <com/sun/star/sheet/XSheetCondition.hpp> -#include <com/sun/star/sheet/XMultiFormulaTokens.hpp> -#include "oox/helper/propertyset.hxx" -#include "oox/xls/excelhandlers.hxx" -#include "oox/xls/worksheethelper.hxx" - -using ::rtl::OUString; -using ::com::sun::star::uno::Reference; -using ::com::sun::star::uno::Exception; -using ::com::sun::star::uno::UNO_QUERY_THROW; -using ::com::sun::star::beans::XPropertySet; -using ::com::sun::star::sheet::ValidationType; -using ::com::sun::star::sheet::ValidationAlertStyle; -using ::com::sun::star::sheet::ConditionOperator; -using ::com::sun::star::sheet::XSheetCondition; -using ::com::sun::star::sheet::XMultiFormulaTokens; - -namespace oox { -namespace xls { - -// ============================================================================ - -namespace { - -const sal_Char* const sppcPropNames[] = -{ - "Type", - "ShowInputMessage", - "InputTitle", - "InputMessage", - "ShowErrorMessage", - "ErrorTitle", - "ErrorMessage", - "ErrorAlertStyle", - "ShowList", - "IgnoreBlankCells", - 0 -}; - -} // namespace - -// ---------------------------------------------------------------------------- - -ValidationPropertyHelper::ValidationPropertyHelper( const WorkbookHelper& rHelper ) : - WorkbookHelper( rHelper ), - maValProps( sppcPropNames ), - maValidationProp( CREATE_OUSTRING( "Validation" ) ) -{ -} - -void ValidationPropertyHelper::writeValidationProperties( PropertySet& rPropSet, const OoxValidationData& rValData ) -{ - Reference< XPropertySet > xValidation; - if( rPropSet.getProperty( xValidation, maValidationProp ) && xValidation.is() ) - { - PropertySet aValProps( xValidation ); - namespace csss = ::com::sun::star::sheet; - - // convert validation type to API enum - ValidationType eType = csss::ValidationType_ANY; - switch( rValData.mnType ) - { - case XML_custom: eType = csss::ValidationType_CUSTOM; break; - case XML_date: eType = csss::ValidationType_DATE; break; - case XML_decimal: eType = csss::ValidationType_DECIMAL; break; - case XML_list: eType = csss::ValidationType_LIST; break; - case XML_none: eType = csss::ValidationType_ANY; break; - case XML_textLength: eType = csss::ValidationType_TEXT_LEN; break; - case XML_time: eType = csss::ValidationType_TIME; break; - case XML_whole: eType = csss::ValidationType_WHOLE; break; - default: OSL_ENSURE( false, "ValidationPropertyHelper::writeValidationProperties - unknown validation type" ); - } - - // convert error alert style to API enum - ValidationAlertStyle nAlertStyle = csss::ValidationAlertStyle_STOP; - switch( rValData.mnErrorStyle ) - { - case XML_information: nAlertStyle = csss::ValidationAlertStyle_INFO; break; - case XML_stop: nAlertStyle = csss::ValidationAlertStyle_STOP; break; - case XML_warning: nAlertStyle = csss::ValidationAlertStyle_WARNING; break; - default: OSL_ENSURE( false, "ValidationPropertyHelper::writeValidationProperties - unknown error style" ); - } - - // convert dropdown style to API visibility constants - sal_Int16 nVisibility = rValData.mbNoDropDown ? csss::TableValidationVisibility::INVISIBLE : csss::TableValidationVisibility::UNSORTED; - - // write all properties - maValProps - << eType - << rValData.mbShowInputMsg << rValData.maInputTitle << rValData.maInputMessage - << rValData.mbShowErrorMsg << rValData.maErrorTitle << rValData.maErrorMessage - << nAlertStyle << nVisibility << rValData.mbAllowBlank - >> aValProps; - - try - { - // condition operator - Reference< XSheetCondition > xSheetCond( xValidation, UNO_QUERY_THROW ); - xSheetCond->setOperator( convertToApiOperator( rValData.mnOperator ) ); - - // condition formulas - Reference< XMultiFormulaTokens > xTokens( xValidation, UNO_QUERY_THROW ); - xTokens->setTokens( 0, rValData.maTokens1 ); - xTokens->setTokens( 1, rValData.maTokens2 ); - } - catch( Exception& ) - { - } - - // write back validation settings to cell range(s) - rPropSet.setProperty( maValidationProp, xValidation ); - } -} - -ConditionOperator ValidationPropertyHelper::convertToApiOperator( sal_Int32 nToken ) -{ - using namespace ::com::sun::star::sheet; - switch( nToken ) - { - case XML_between: return ConditionOperator_BETWEEN; - case XML_equal: return ConditionOperator_EQUAL; - case XML_greaterThan: return ConditionOperator_GREATER; - case XML_greaterThanOrEqual: return ConditionOperator_GREATER_EQUAL; - case XML_lessThan: return ConditionOperator_LESS; - case XML_lessThanOrEqual: return ConditionOperator_LESS_EQUAL; - case XML_notBetween: return ConditionOperator_NOT_BETWEEN; - case XML_notEqual: return ConditionOperator_NOT_EQUAL; - } - return ConditionOperator_NONE; -} - -// ============================================================================ - -} // namespace xls -} // namespace oox - diff --git a/oox/source/xls/viewsettings.cxx b/oox/source/xls/viewsettings.cxx index f287127ddf1b..9613b21c2faa 100644 --- a/oox/source/xls/viewsettings.cxx +++ b/oox/source/xls/viewsettings.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: viewsettings.cxx,v $ - * $Revision: 1.7 $ + * $Revision: 1.5.20.6 $ * * This file is part of OpenOffice.org. * @@ -39,6 +39,7 @@ #include "oox/helper/propertysequence.hxx" #include "oox/helper/propertyset.hxx" #include "oox/helper/recordinputstream.hxx" +#include "oox/core/filterbase.hxx" #include "oox/xls/biffinputstream.hxx" #include "oox/xls/unitconverter.hxx" #include "oox/xls/workbooksettings.hxx" @@ -155,9 +156,6 @@ const sal_Char* const sppcDocNames[] = const sal_Char* const sppcGlobalSheetNames[] = { "GridColor", - "ZoomType", - "ZoomValue", - "PageViewZoomValue", "ShowPageBreakPreview", "ShowFormulas", "ShowGrid", @@ -182,6 +180,9 @@ const sal_Char* const sppcSheetNames[] = "PositionTop", "PositionRight", "PositionBottom", + "ZoomType", + "ZoomValue", + "PageViewZoomValue", 0 }; @@ -449,7 +450,7 @@ void SheetViewSettings::importWindow2( BiffInputStream& rStrm ) rData.maGridColor.importColorId( rStrm ); // zoom data not included in chart sheets - if( (getSheetType() != SHEETTYPE_CHARTSHEET) && (rStrm.getRecLeft() >= 6) ) + if( (getSheetType() != SHEETTYPE_CHARTSHEET) && (rStrm.getRemaining() >= 6) ) { rStrm.skip( 2 ); sal_uInt16 nPageZoom, nNormalZoom; @@ -520,15 +521,29 @@ void SheetViewSettings::importSelection( BiffInputStream& rStrm ) void SheetViewSettings::finalizeImport() { - // special handling for chart sheets - bool bChartSheet = getSheetType() == SHEETTYPE_CHARTSHEET; - // force creation of sheet view data to get the Excel defaults OoxSheetViewDataRef xData = maSheetDatas.empty() ? createSheetViewData() : maSheetDatas.front(); + // #i59590# #158194# special handling for chart sheets (Excel ignores some settings in chart sheets) + if( getSheetType() == SHEETTYPE_CHARTSHEET ) + { + xData->maSelMap.clear(); + xData->maFirstPos = xData->maSecondPos = CellAddress( getSheetIndex(), 0, 0 ); + xData->mnViewType = XML_normal; + xData->mnActivePaneId = XML_topLeft; + xData->mnPaneState = XML_split; + xData->mfSplitX = xData->mfSplitY = 0.0; + xData->mbRightToLeft = false; + xData->mbDefGridColor = true; + xData->mbShowFormulas = false; + xData->mbShowGrid = true; + xData->mbShowHeadings = true; + xData->mbShowZeros = true; + xData->mbShowOutline = true; + } + // mirrored sheet (this is not a view setting in Calc) - // #i59590# real life: Excel ignores mirror flag in chart sheets - if( !bChartSheet && xData->mbRightToLeft ) + if( xData->mbRightToLeft ) { PropertySet aPropSet( getXSpreadsheet() ); aPropSet.setProperty( CREATE_OUSTRING( "TableLayout" ), ::com::sun::star::text::WritingMode2::RL_TB ); @@ -538,14 +553,9 @@ void SheetViewSettings::finalizeImport() bool bSelected = xData->mbSelected || (getSheetIndex() == getViewSettings().getActiveSheetIndex()); // visible area and current cursor position (selection not supported via API) - CellAddress aFirstPos( getSheetIndex(), 0, 0 ); - CellAddress aCursor( getSheetIndex(), 0, 0 ); - if( !bChartSheet ) - { - aFirstPos = xData->maFirstPos; - const OoxSheetSelectionData* pSelData = xData->getActiveSelectionData(); - aCursor = pSelData ? pSelData->maActiveCell : xData->maFirstPos; - } + CellAddress aFirstPos = xData->maFirstPos; + const OoxSheetSelectionData* pSelData = xData->getActiveSelectionData(); + CellAddress aCursor = pSelData ? pSelData->maActiveCell : aFirstPos; // freeze/split position default sal_Int16 nHSplitMode = API_SPLITMODE_NONE; @@ -555,56 +565,53 @@ void SheetViewSettings::finalizeImport() // active pane default sal_Int16 nActivePane = API_SPLITPANE_BOTTOMLEFT; - if( !bChartSheet ) + // freeze/split position + if( (xData->mnPaneState == XML_frozen) || (xData->mnPaneState == XML_frozenSplit) ) { - // freeze/split position - if( (xData->mnPaneState == XML_frozen) || (xData->mnPaneState == XML_frozenSplit) ) - { - /* Frozen panes: handle split position as row/column positions. - #i35812# Excel uses number of visible rows/columns in the - frozen area (rows/columns scolled outside are not incuded), - Calc uses absolute position of first unfrozen row/column. */ - const CellAddress& rMaxApiPos = getAddressConverter().getMaxApiAddress(); - if( (xData->mfSplitX >= 1.0) && (xData->maFirstPos.Column + xData->mfSplitX <= rMaxApiPos.Column) ) - nHSplitPos = static_cast< sal_Int32 >( xData->maFirstPos.Column + xData->mfSplitX ); - nHSplitMode = (nHSplitPos > 0) ? API_SPLITMODE_FREEZE : API_SPLITMODE_NONE; - if( (xData->mfSplitY >= 1.0) && (xData->maFirstPos.Row + xData->mfSplitY <= rMaxApiPos.Row) ) - nVSplitPos = static_cast< sal_Int32 >( xData->maFirstPos.Row + xData->mfSplitY ); - nVSplitMode = (nVSplitPos > 0) ? API_SPLITMODE_FREEZE : API_SPLITMODE_NONE; - } - else if( xData->mnPaneState == XML_split ) - { - // split window: view settings API uses twips... - nHSplitPos = getLimitedValue< sal_Int32, double >( xData->mfSplitX + 0.5, 0, SAL_MAX_INT32 ); - nHSplitMode = (nHSplitPos > 0) ? API_SPLITMODE_SPLIT : API_SPLITMODE_NONE; - nVSplitPos = getLimitedValue< sal_Int32, double >( xData->mfSplitY + 0.5, 0, SAL_MAX_INT32 ); - nVSplitMode = (nVSplitPos > 0) ? API_SPLITMODE_SPLIT : API_SPLITMODE_NONE; - } + /* Frozen panes: handle split position as row/column positions. + #i35812# Excel uses number of visible rows/columns in the + frozen area (rows/columns scolled outside are not incuded), + Calc uses absolute position of first unfrozen row/column. */ + const CellAddress& rMaxApiPos = getAddressConverter().getMaxApiAddress(); + if( (xData->mfSplitX >= 1.0) && (xData->maFirstPos.Column + xData->mfSplitX <= rMaxApiPos.Column) ) + nHSplitPos = static_cast< sal_Int32 >( xData->maFirstPos.Column + xData->mfSplitX ); + nHSplitMode = (nHSplitPos > 0) ? API_SPLITMODE_FREEZE : API_SPLITMODE_NONE; + if( (xData->mfSplitY >= 1.0) && (xData->maFirstPos.Row + xData->mfSplitY <= rMaxApiPos.Row) ) + nVSplitPos = static_cast< sal_Int32 >( xData->maFirstPos.Row + xData->mfSplitY ); + nVSplitMode = (nVSplitPos > 0) ? API_SPLITMODE_FREEZE : API_SPLITMODE_NONE; + } + else if( xData->mnPaneState == XML_split ) + { + // split window: view settings API uses twips... + nHSplitPos = getLimitedValue< sal_Int32, double >( xData->mfSplitX + 0.5, 0, SAL_MAX_INT32 ); + nHSplitMode = (nHSplitPos > 0) ? API_SPLITMODE_SPLIT : API_SPLITMODE_NONE; + nVSplitPos = getLimitedValue< sal_Int32, double >( xData->mfSplitY + 0.5, 0, SAL_MAX_INT32 ); + nVSplitMode = (nVSplitPos > 0) ? API_SPLITMODE_SPLIT : API_SPLITMODE_NONE; + } - // active pane - switch( xData->mnActivePaneId ) - { - // no horizontal split -> always use left panes - // no vertical split -> always use *bottom* panes - case XML_topLeft: - nActivePane = (nVSplitMode == API_SPLITMODE_NONE) ? API_SPLITPANE_BOTTOMLEFT : API_SPLITPANE_TOPLEFT; - break; - case XML_topRight: - nActivePane = (nHSplitMode == API_SPLITMODE_NONE) ? - ((nVSplitMode == API_SPLITMODE_NONE) ? API_SPLITPANE_BOTTOMLEFT : API_SPLITPANE_TOPLEFT) : - ((nVSplitMode == API_SPLITMODE_NONE) ? API_SPLITPANE_BOTTOMRIGHT : API_SPLITPANE_TOPRIGHT); - break; - case XML_bottomLeft: - nActivePane = API_SPLITPANE_BOTTOMLEFT; - break; - case XML_bottomRight: - nActivePane = (nHSplitMode == API_SPLITMODE_NONE) ? API_SPLITPANE_BOTTOMLEFT : API_SPLITPANE_BOTTOMRIGHT; - break; - } + // active pane + switch( xData->mnActivePaneId ) + { + // no horizontal split -> always use left panes + // no vertical split -> always use *bottom* panes + case XML_topLeft: + nActivePane = (nVSplitMode == API_SPLITMODE_NONE) ? API_SPLITPANE_BOTTOMLEFT : API_SPLITPANE_TOPLEFT; + break; + case XML_topRight: + nActivePane = (nHSplitMode == API_SPLITMODE_NONE) ? + ((nVSplitMode == API_SPLITMODE_NONE) ? API_SPLITPANE_BOTTOMLEFT : API_SPLITPANE_TOPLEFT) : + ((nVSplitMode == API_SPLITMODE_NONE) ? API_SPLITPANE_BOTTOMRIGHT : API_SPLITPANE_TOPRIGHT); + break; + case XML_bottomLeft: + nActivePane = API_SPLITPANE_BOTTOMLEFT; + break; + case XML_bottomRight: + nActivePane = (nHSplitMode == API_SPLITMODE_NONE) ? API_SPLITPANE_BOTTOMLEFT : API_SPLITPANE_BOTTOMRIGHT; + break; } // automatic grid color - if( bChartSheet || xData->mbDefGridColor ) + if( xData->mbDefGridColor ) xData->maGridColor.setAuto(); // write the sheet view settings into the property sequence @@ -622,11 +629,11 @@ void SheetViewSettings::finalizeImport() << aFirstPos.Row << xData->maSecondPos.Column << ((nVSplitPos > 0) ? xData->maSecondPos.Row : xData->maFirstPos.Row) - << xData->maGridColor.getColor( *this ) << API_ZOOMTYPE_PERCENT << static_cast< sal_Int16 >( xData->getNormalZoom() ) << static_cast< sal_Int16 >( xData->getPageBreakZoom() ) - << (!bChartSheet && xData->isPageBreakPreview()) + << xData->maGridColor.getColor( *this ) + << xData->isPageBreakPreview() << xData->mbShowFormulas << xData->mbShowGrid << xData->mbShowHeadings @@ -754,7 +761,7 @@ void ViewSettings::finalizeImport() sal_Int16 nShowMode = getWorkbookSettings().getApiShowObjectMode(); // view settings for all sheets - Reference< XNameContainer > xSheetsNC = ContainerHelper::createNameContainer(); + Reference< XNameContainer > xSheetsNC = ContainerHelper::createNameContainer( getBaseFilter().getGlobalFactory() ); if( !xSheetsNC.is() ) return; for( SheetPropertiesMap::const_iterator aIt = maSheetProps.begin(), aEnd = maSheetProps.end(); aIt != aEnd; ++aIt ) ContainerHelper::insertByName( xSheetsNC, rWorksheets.getFinalSheetName( aIt->first ), aIt->second ); @@ -776,9 +783,6 @@ void ViewSettings::finalizeImport() << double( rData.mnTabBarWidth / 1000.0 ) << nShowMode << nShowMode << nShowMode << rxActiveSheetData->maGridColor.getColor( *this ) - << API_ZOOMTYPE_PERCENT - << static_cast< sal_Int16 >( rxActiveSheetData->getNormalZoom() ) - << static_cast< sal_Int16 >( rxActiveSheetData->getPageBreakZoom() ) << rxActiveSheetData->isPageBreakPreview() << rxActiveSheetData->mbShowFormulas << rxActiveSheetData->mbShowGrid @@ -786,7 +790,7 @@ void ViewSettings::finalizeImport() << rxActiveSheetData->mbShowZeros << rxActiveSheetData->mbShowOutline; - Reference< XIndexContainer > xContainer = ContainerHelper::createIndexContainer(); + Reference< XIndexContainer > xContainer = ContainerHelper::createIndexContainer( getBaseFilter().getGlobalFactory() ); if( xContainer.is() ) try { xContainer->insertByIndex( 0, Any( aDocProps.createPropertySequence() ) ); diff --git a/oox/source/xls/workbookfragment.cxx b/oox/source/xls/workbookfragment.cxx index 44251a281e40..38d5fc274808 100644 --- a/oox/source/xls/workbookfragment.cxx +++ b/oox/source/xls/workbookfragment.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: workbookfragment.cxx,v $ - * $Revision: 1.5 $ + * $Revision: 1.4.20.4 $ * * This file is part of OpenOffice.org. * @@ -207,7 +207,7 @@ void OoxWorkbookFragment::finalizeImport() // read the theme substream OUString aThemeFragmentPath = getFragmentPathFromType( CREATE_OFFICEDOC_RELATIONSTYPE( "theme" ) ); if( aThemeFragmentPath.getLength() > 0 ) - importOoxFragment( new ThemeFragmentHandler( getFilter(), aThemeFragmentPath, getTheme().getOrCreateCoreTheme() ) ); + importOoxFragment( new ThemeFragmentHandler( getFilter(), aThemeFragmentPath, getTheme() ) ); xGlobalSegment->setPosition( 0.25 ); // read the styles substream (requires finalized theme buffer) @@ -343,8 +343,8 @@ namespace { BiffDecoderRef lclImportFilePass_XOR( const WorkbookHelper& rHelper, BiffInputStream& rStrm ) { BiffDecoderRef xDecoder; - OSL_ENSURE( rStrm.getRecLeft() == 4, "lclImportFilePass_XOR - wrong record size" ); - if( rStrm.getRecLeft() == 4 ) + OSL_ENSURE( rStrm.getRemaining() == 4, "lclImportFilePass_XOR - wrong record size" ); + if( rStrm.getRemaining() == 4 ) { sal_uInt16 nBaseKey, nHash; rStrm >> nBaseKey >> nHash; @@ -356,15 +356,15 @@ BiffDecoderRef lclImportFilePass_XOR( const WorkbookHelper& rHelper, BiffInputSt BiffDecoderRef lclImportFilePass_RCF( const WorkbookHelper& rHelper, BiffInputStream& rStrm ) { BiffDecoderRef xDecoder; - OSL_ENSURE( rStrm.getRecLeft() == 48, "lclImportFilePass_RCF - wrong record size" ); - if( rStrm.getRecLeft() == 48 ) + OSL_ENSURE( rStrm.getRemaining() == 48, "lclImportFilePass_RCF - wrong record size" ); + if( rStrm.getRemaining() == 48 ) { sal_uInt8 pnDocId[ 16 ]; sal_uInt8 pnSaltData[ 16 ]; sal_uInt8 pnSaltHash[ 16 ]; - rStrm.read( pnDocId, 16 ); - rStrm.read( pnSaltData, 16 ); - rStrm.read( pnSaltHash, 16 ); + rStrm.readMemory( pnDocId, 16 ); + rStrm.readMemory( pnSaltData, 16 ); + rStrm.readMemory( pnSaltHash, 16 ); xDecoder.reset( new BiffDecoder_RCF( rHelper, pnDocId, pnSaltData, pnSaltHash ) ); } return xDecoder; @@ -392,7 +392,8 @@ BiffDecoderRef lclImportFilePass8( const WorkbookHelper& rHelper, BiffInputStrea break; case BIFF_FILEPASS_BIFF8: - switch( rStrm.skip( 2 ).readuInt16() ) + rStrm.skip( 2 ); + switch( rStrm.readuInt16() ) { case BIFF_FILEPASS_BIFF8_RCF: xDecoder = lclImportFilePass_RCF( rHelper, rStrm ); @@ -416,23 +417,23 @@ BiffDecoderRef lclImportFilePass8( const WorkbookHelper& rHelper, BiffInputStrea // ---------------------------------------------------------------------------- -BiffWorkbookFragment::BiffWorkbookFragment( const WorkbookHelper& rHelper ) : - BiffWorkbookFragmentBase( rHelper ) +BiffWorkbookFragment::BiffWorkbookFragment( const WorkbookHelper& rHelper, BiffInputStream& rStrm ) : + BiffWorkbookFragmentBase( rHelper, rStrm ) { } -bool BiffWorkbookFragment::importFragment( BiffInputStream& rStrm ) +bool BiffWorkbookFragment::importFragment() { bool bRet = false; - BiffFragmentType eFragment = startFragment( rStrm, getBiff() ); + BiffFragmentType eFragment = startFragment( getBiff() ); switch( eFragment ) { case BIFF_FRAGMENT_GLOBALS: { // import workbook globals fragment and create sheets in document ISegmentProgressBarRef xGlobalsProgress = getProgressBar().createSegment( PROGRESS_LENGTH_GLOBALS ); - bRet = importGlobalsFragment( rStrm, *xGlobalsProgress ); + bRet = importGlobalsFragment( *xGlobalsProgress ); // load sheet fragments (do not return false in bRet on missing/broken sheets) WorksheetBuffer& rWorksheets = getWorksheets(); bool bNextSheet = bRet; @@ -441,15 +442,15 @@ bool BiffWorkbookFragment::importFragment( BiffInputStream& rStrm ) // try to start a new sheet fragment double fSegmentLength = getProgressBar().getFreeLength() / (nSheetCount - nSheet); ISegmentProgressBarRef xSheetProgress = getProgressBar().createSegment( fSegmentLength ); - BiffFragmentType eSheetFragment = startFragment( rStrm, getBiff() ); - bNextSheet = importSheetFragment( rStrm, *xSheetProgress, eSheetFragment, nSheet ); + BiffFragmentType eSheetFragment = startFragment( getBiff() ); + bNextSheet = importSheetFragment( *xSheetProgress, eSheetFragment, nSheet ); } } break; case BIFF_FRAGMENT_WORKSPACE: { - bRet = importWorkspaceFragment( rStrm ); + bRet = importWorkspaceFragment(); // sheets are embedded in workspace fragment, nothing to do here } break; @@ -462,7 +463,7 @@ bool BiffWorkbookFragment::importFragment( BiffInputStream& rStrm ) - #i62752# possible in all BIFF versions - do not return false in bRet on missing/broken sheets. */ getWorksheets().initializeSingleSheet(); - importSheetFragment( rStrm, getProgressBar(), eFragment, 0 ); + importSheetFragment( getProgressBar(), eFragment, 0 ); // success, even if stream is broken bRet = true; } @@ -477,7 +478,7 @@ bool BiffWorkbookFragment::importFragment( BiffInputStream& rStrm ) return bRet; } -bool BiffWorkbookFragment::importWorkspaceFragment( BiffInputStream& rStrm ) +bool BiffWorkbookFragment::importWorkspaceFragment() { // enable workbook mode, has not been set yet in BIFF4 workspace files setIsWorkbookFile(); @@ -488,14 +489,14 @@ bool BiffWorkbookFragment::importWorkspaceFragment( BiffInputStream& rStrm ) // import the workspace globals ISegmentProgressBarRef xGlobalsProgress = getProgressBar().createSegment( PROGRESS_LENGTH_GLOBALS ); bool bLoop = true; - while( bRet && bLoop && rStrm.startNextRecord() && (rStrm.getRecId() != BIFF_ID_EOF) ) + while( bRet && bLoop && mrStrm.startNextRecord() && (mrStrm.getRecId() != BIFF_ID_EOF) ) { - switch( rStrm.getRecId() ) + switch( mrStrm.getRecId() ) { - case BIFF_ID_SHEET: rWorksheets.importSheet( rStrm ); break; - case BIFF_ID_CODEPAGE: setCodePage( rStrm.readuInt16() ); break; - case BIFF_ID_FILEPASS: bRet = importFilePass( rStrm ); break; - case BIFF_ID_SHEETHEADER: rStrm.rewindRecord(); bLoop = false; break; + case BIFF_ID_SHEET: rWorksheets.importSheet( mrStrm ); break; + case BIFF_ID_CODEPAGE: setCodePage( mrStrm.readuInt16() ); break; + case BIFF_ID_FILEPASS: bRet = importFilePass(); break; + case BIFF_ID_SHEETHEADER: mrStrm.rewindRecord(); bLoop = false; break; } } xGlobalsProgress->setPosition( 1.0 ); @@ -505,18 +506,19 @@ bool BiffWorkbookFragment::importWorkspaceFragment( BiffInputStream& rStrm ) for( sal_Int32 nSheet = 0, nSheetCount = rWorksheets.getInternalSheetCount(); bNextSheet && (nSheet < nSheetCount); ++nSheet ) { // try to start a new sheet fragment (with leading SHEETHEADER record) - bNextSheet = rStrm.startNextRecord() && (rStrm.getRecId() == BIFF_ID_SHEETHEADER); + bNextSheet = mrStrm.startNextRecord() && (mrStrm.getRecId() == BIFF_ID_SHEETHEADER); if( bNextSheet ) { double fSegmentLength = getProgressBar().getFreeLength() / (nSheetCount - nSheet); ISegmentProgressBarRef xSheetProgress = getProgressBar().createSegment( fSegmentLength ); /* Read current sheet name (sheet substreams may not be in the same order as SHEET records are). */ - OUString aSheetName = rStrm.skip( 4 ).readByteString( false, getTextEncoding() ); + mrStrm.skip( 4 ); + OUString aSheetName = mrStrm.readByteString( false, getTextEncoding() ); sal_Int32 nCurrSheet = rWorksheets.getFinalSheetIndex( aSheetName ); // load the sheet fragment records - BiffFragmentType eSheetFragment = startFragment( rStrm, getBiff() ); - bNextSheet = importSheetFragment( rStrm, *xSheetProgress, eSheetFragment, nCurrSheet ); + BiffFragmentType eSheetFragment = startFragment( getBiff() ); + bNextSheet = importSheetFragment( *xSheetProgress, eSheetFragment, nCurrSheet ); // do not return false in bRet on missing/broken sheets } } @@ -524,7 +526,7 @@ bool BiffWorkbookFragment::importWorkspaceFragment( BiffInputStream& rStrm ) return bRet; } -bool BiffWorkbookFragment::importGlobalsFragment( BiffInputStream& rStrm, ISegmentProgressBar& rProgressBar ) +bool BiffWorkbookFragment::importGlobalsFragment( ISegmentProgressBar& rProgressBar ) { WorkbookSettings& rWorkbookSett = getWorkbookSettings(); ViewSettings& rViewSett = getViewSettings(); @@ -538,27 +540,27 @@ bool BiffWorkbookFragment::importGlobalsFragment( BiffInputStream& rStrm, ISegme bool bRet = true; bool bLoop = true; - while( bRet && bLoop && rStrm.startNextRecord() ) + while( bRet && bLoop && mrStrm.startNextRecord() ) { - sal_uInt16 nRecId = rStrm.getRecId(); + sal_uInt16 nRecId = mrStrm.getRecId(); bool bExtLinkRec = false; /* #i56376# BIFF5-BIFF8: If an EOF record for globals is missing, simulate it. The issue is about a document where the sheet fragment starts directly after the EXTSST record, without terminating the globals fragment with an EOF record. */ - if( isBofRecord( nRecId ) || (nRecId == BIFF_ID_EOF) ) + if( isBofRecord() || (nRecId == BIFF_ID_EOF) ) { bLoop = false; } else switch( nRecId ) { // records in all BIFF versions - case BIFF_ID_CODEPAGE: setCodePage( rStrm.readuInt16() ); break; - case BIFF_ID_DATEMODE: rWorkbookSett.importDateMode( rStrm ); break; - case BIFF_ID_FILEPASS: bRet = importFilePass( rStrm ); break; - case BIFF_ID_PRECISION: rWorkbookSett.importPrecision( rStrm ); break; - case BIFF_ID_WINDOW1: rViewSett.importWindow1( rStrm ); break; + case BIFF_ID_CODEPAGE: setCodePage( mrStrm.readuInt16() ); break; + case BIFF_ID_DATEMODE: rWorkbookSett.importDateMode( mrStrm ); break; + case BIFF_ID_FILEPASS: bRet = importFilePass(); break; + case BIFF_ID_PRECISION: rWorkbookSett.importPrecision( mrStrm ); break; + case BIFF_ID_WINDOW1: rViewSett.importWindow1( mrStrm ); break; // BIFF specific records default: switch( getBiff() ) @@ -568,10 +570,10 @@ bool BiffWorkbookFragment::importGlobalsFragment( BiffInputStream& rStrm, ISegme case BIFF2_ID_DEFINEDNAME: bExtLinkRec = true; break; case BIFF2_ID_EXTERNALNAME: bExtLinkRec = true; break; case BIFF_ID_EXTERNSHEET: bExtLinkRec = true; break; - case BIFF2_ID_FONT: rStyles.importFont( rStrm ); break; - case BIFF_ID_FONTCOLOR: rStyles.importFontColor( rStrm ); break; - case BIFF2_ID_FORMAT: rStyles.importFormat( rStrm ); break; - case BIFF2_ID_XF: rStyles.importXf( rStrm ); break; + case BIFF2_ID_FONT: rStyles.importFont( mrStrm ); break; + case BIFF_ID_FONTCOLOR: rStyles.importFontColor( mrStrm ); break; + case BIFF2_ID_FORMAT: rStyles.importFormat( mrStrm ); break; + case BIFF2_ID_XF: rStyles.importXf( mrStrm ); break; } break; @@ -581,13 +583,13 @@ bool BiffWorkbookFragment::importGlobalsFragment( BiffInputStream& rStrm, ISegme case BIFF3_ID_DEFINEDNAME: bExtLinkRec = true; break; case BIFF3_ID_EXTERNALNAME: bExtLinkRec = true; break; case BIFF_ID_EXTERNSHEET: bExtLinkRec = true; break; - case BIFF3_ID_FONT: rStyles.importFont( rStrm ); break; - case BIFF2_ID_FORMAT: rStyles.importFormat( rStrm ); break; - case BIFF_ID_HIDEOBJ: rWorkbookSett.importHideObj( rStrm ); break; - case BIFF_ID_PALETTE: rStyles.importPalette( rStrm ); break; - case BIFF_ID_STYLE: rStyles.importStyle( rStrm ); break; + case BIFF3_ID_FONT: rStyles.importFont( mrStrm ); break; + case BIFF2_ID_FORMAT: rStyles.importFormat( mrStrm ); break; + case BIFF_ID_HIDEOBJ: rWorkbookSett.importHideObj( mrStrm ); break; + case BIFF_ID_PALETTE: rStyles.importPalette( mrStrm ); break; + case BIFF_ID_STYLE: rStyles.importStyle( mrStrm ); break; case BIFF_ID_XCT: bExtLinkRec = true; break; - case BIFF3_ID_XF: rStyles.importXf( rStrm ); break; + case BIFF3_ID_XF: rStyles.importXf( mrStrm ); break; } break; @@ -597,53 +599,53 @@ bool BiffWorkbookFragment::importGlobalsFragment( BiffInputStream& rStrm, ISegme case BIFF3_ID_DEFINEDNAME: bExtLinkRec = true; break; case BIFF3_ID_EXTERNALNAME: bExtLinkRec = true; break; case BIFF_ID_EXTERNSHEET: bExtLinkRec = true; break; - case BIFF3_ID_FONT: rStyles.importFont( rStrm ); break; - case BIFF4_ID_FORMAT: rStyles.importFormat( rStrm ); break; - case BIFF_ID_HIDEOBJ: rWorkbookSett.importHideObj( rStrm ); break; - case BIFF_ID_PALETTE: rStyles.importPalette( rStrm ); break; - case BIFF_ID_STYLE: rStyles.importStyle( rStrm ); break; + case BIFF3_ID_FONT: rStyles.importFont( mrStrm ); break; + case BIFF4_ID_FORMAT: rStyles.importFormat( mrStrm ); break; + case BIFF_ID_HIDEOBJ: rWorkbookSett.importHideObj( mrStrm ); break; + case BIFF_ID_PALETTE: rStyles.importPalette( mrStrm ); break; + case BIFF_ID_STYLE: rStyles.importStyle( mrStrm ); break; case BIFF_ID_XCT: bExtLinkRec = true; break; - case BIFF4_ID_XF: rStyles.importXf( rStrm ); break; + case BIFF4_ID_XF: rStyles.importXf( mrStrm ); break; } break; case BIFF5: switch( nRecId ) { - case BIFF_ID_BOOKBOOL: rWorkbookSett.importBookBool( rStrm ); break; + case BIFF_ID_BOOKBOOL: rWorkbookSett.importBookBool( mrStrm ); break; case BIFF_ID_CRN: bExtLinkRec = true; break; case BIFF5_ID_DEFINEDNAME: bExtLinkRec = true; break; case BIFF5_ID_EXTERNALNAME: bExtLinkRec = true; break; case BIFF_ID_EXTERNSHEET: bExtLinkRec = true; break; - case BIFF5_ID_FONT: rStyles.importFont( rStrm ); break; - case BIFF4_ID_FORMAT: rStyles.importFormat( rStrm ); break; - case BIFF_ID_HIDEOBJ: rWorkbookSett.importHideObj( rStrm ); break; - case BIFF_ID_PALETTE: rStyles.importPalette( rStrm ); break; - case BIFF_ID_SHEET: rWorksheets.importSheet( rStrm ); break; - case BIFF_ID_STYLE: rStyles.importStyle( rStrm ); break; + case BIFF5_ID_FONT: rStyles.importFont( mrStrm ); break; + case BIFF4_ID_FORMAT: rStyles.importFormat( mrStrm ); break; + case BIFF_ID_HIDEOBJ: rWorkbookSett.importHideObj( mrStrm ); break; + case BIFF_ID_PALETTE: rStyles.importPalette( mrStrm ); break; + case BIFF_ID_SHEET: rWorksheets.importSheet( mrStrm ); break; + case BIFF_ID_STYLE: rStyles.importStyle( mrStrm ); break; case BIFF_ID_XCT: bExtLinkRec = true; break; - case BIFF5_ID_XF: rStyles.importXf( rStrm ); break; + case BIFF5_ID_XF: rStyles.importXf( mrStrm ); break; } break; case BIFF8: switch( nRecId ) { - case BIFF_ID_BOOKBOOL: rWorkbookSett.importBookBool( rStrm ); break; - case BIFF_ID_CODENAME: rWorkbookSett.importCodeName( rStrm ); break; + case BIFF_ID_BOOKBOOL: rWorkbookSett.importBookBool( mrStrm ); break; + case BIFF_ID_CODENAME: rWorkbookSett.importCodeName( mrStrm ); break; case BIFF_ID_CRN: bExtLinkRec = true; break; case BIFF5_ID_DEFINEDNAME: bExtLinkRec = true; break; case BIFF_ID_EXTERNALBOOK: bExtLinkRec = true; break; case BIFF5_ID_EXTERNALNAME: bExtLinkRec = true; break; case BIFF_ID_EXTERNSHEET: bExtLinkRec = true; break; - case BIFF5_ID_FONT: rStyles.importFont( rStrm ); break; - case BIFF4_ID_FORMAT: rStyles.importFormat( rStrm ); break; - case BIFF_ID_HIDEOBJ: rWorkbookSett.importHideObj( rStrm ); break; - case BIFF_ID_PALETTE: rStyles.importPalette( rStrm ); break; - case BIFF_ID_SHEET: rWorksheets.importSheet( rStrm ); break; - case BIFF_ID_SST: rSharedStrings.importSst( rStrm ); break; - case BIFF_ID_STYLE: rStyles.importStyle( rStrm ); break; - case BIFF_ID_USESELFS: rWorkbookSett.importUsesElfs( rStrm ); break; + case BIFF5_ID_FONT: rStyles.importFont( mrStrm ); break; + case BIFF4_ID_FORMAT: rStyles.importFormat( mrStrm ); break; + case BIFF_ID_HIDEOBJ: rWorkbookSett.importHideObj( mrStrm ); break; + case BIFF_ID_PALETTE: rStyles.importPalette( mrStrm ); break; + case BIFF_ID_SHEET: rWorksheets.importSheet( mrStrm ); break; + case BIFF_ID_SST: rSharedStrings.importSst( mrStrm ); break; + case BIFF_ID_STYLE: rStyles.importStyle( mrStrm ); break; + case BIFF_ID_USESELFS: rWorkbookSett.importUsesElfs( mrStrm ); break; case BIFF_ID_XCT: bExtLinkRec = true; break; - case BIFF5_ID_XF: rStyles.importXf( rStrm ); break; + case BIFF5_ID_XF: rStyles.importXf( mrStrm ); break; } break; @@ -652,7 +654,7 @@ bool BiffWorkbookFragment::importGlobalsFragment( BiffInputStream& rStrm, ISegme } if( bExtLinkRec ) - aExtLinkRecs.push_back( rStrm.getRecHandle() ); + aExtLinkRecs.push_back( mrStrm.getRecHandle() ); } // finalize global buffers @@ -666,48 +668,40 @@ bool BiffWorkbookFragment::importGlobalsFragment( BiffInputStream& rStrm, ISegme if( bRet && !aExtLinkRecs.empty() ) { // remember current stream position (the EOF record) - sal_Int64 nEofHandle = rStrm.getRecHandle(); + sal_Int64 nEofHandle = mrStrm.getRecHandle(); // this fragment class implements import of external link records BiffExternalLinkFragment aLinkFragment( *this, true ); // import all records by using their cached record handle - for( RecordHandleVec::const_iterator aIt = aExtLinkRecs.begin(), aEnd = aExtLinkRecs.end(); (aIt != aEnd) && rStrm.startRecordByHandle( *aIt ); ++aIt ) - aLinkFragment.importRecord( rStrm ); + for( RecordHandleVec::const_iterator aIt = aExtLinkRecs.begin(), aEnd = aExtLinkRecs.end(); (aIt != aEnd) && mrStrm.startRecordByHandle( *aIt ); ++aIt ) + aLinkFragment.importRecord(); // finalize global buffers aLinkFragment.finalizeImport(); // seek back to the EOF record of the workbook globals fragment - bRet = rStrm.startRecordByHandle( nEofHandle ); + bRet = mrStrm.startRecordByHandle( nEofHandle ); } // #i56376# missing EOF - rewind before worksheet BOF record (see above) - if( bRet && isBofRecord( rStrm.getRecId() ) ) - rStrm.rewindRecord(); + if( bRet && isBofRecord() ) + mrStrm.rewindRecord(); rProgressBar.setPosition( 1.0 ); return bRet; } -bool BiffWorkbookFragment::importSheetFragment( BiffInputStream& rStrm, ISegmentProgressBar& rProgressBar, BiffFragmentType eFragment, sal_Int32 nSheet ) +bool BiffWorkbookFragment::importSheetFragment( ISegmentProgressBar& rProgressBar, BiffFragmentType eFragment, sal_Int32 nSheet ) { // find the sheet type for this fragment - WorksheetType eSheetType = SHEETTYPE_WORKSHEET; - bool bSkipSheet = false; + WorksheetType eSheetType = SHEETTYPE_EMPTYSHEET; switch( eFragment ) { case BIFF_FRAGMENT_WORKSHEET: eSheetType = SHEETTYPE_WORKSHEET; break; case BIFF_FRAGMENT_CHARTSHEET: eSheetType = SHEETTYPE_CHARTSHEET; break; case BIFF_FRAGMENT_MACROSHEET: eSheetType = SHEETTYPE_MACROSHEET; break; case BIFF_FRAGMENT_MODULESHEET: eSheetType = SHEETTYPE_MODULESHEET; break; - case BIFF_FRAGMENT_EMPTYSHEET: bSkipSheet = true; break; + case BIFF_FRAGMENT_EMPTYSHEET: eSheetType = SHEETTYPE_EMPTYSHEET; break; default: return false; } - // skip this worksheet fragment (e.g. fragment type is BIFF_FRAGMENT_EMPTYSHEET) - if( bSkipSheet ) - { - rProgressBar.setPosition( 1.0 ); - return skipFragment( rStrm ); - } - /* #i11183# Clear buffers that are used per-sheet, e.g. external links in BIFF4W and BIFF5 files, or defined names in BIFF4W files. */ createBuffersPerSheet(); @@ -723,12 +717,12 @@ bool BiffWorkbookFragment::importSheetFragment( BiffInputStream& rStrm, ISegment // set sheet index in defined names buffer to handle built-in names correctly getDefinedNames().setLocalSheetIndex( nSheet ); // remember current record to seek back below - sal_Int64 nRecHandle = rStrm.getRecHandle(); + sal_Int64 nRecHandle = mrStrm.getRecHandle(); // import the global records ISegmentProgressBarRef xGlobalsProgress = rProgressBar.createSegment( PROGRESS_LENGTH_GLOBALS ); - importGlobalsFragment( rStrm, *xGlobalsProgress ); + importGlobalsFragment( *xGlobalsProgress ); // rewind stream to fragment BOF record - rStrm.startRecordByHandle( nRecHandle ); + mrStrm.startRecordByHandle( nRecHandle ); } break; @@ -736,11 +730,11 @@ bool BiffWorkbookFragment::importSheetFragment( BiffInputStream& rStrm, ISegment case BIFF5: { // remember current record to seek back below - sal_Int64 nRecHandle = rStrm.getRecHandle(); + sal_Int64 nRecHandle = mrStrm.getRecHandle(); // fragment implementing import of external link records - BiffExternalLinkFragment( *this, false ).importFragment( rStrm ); + BiffExternalLinkFragment( *this, false ).importFragment(); // rewind stream to fragment BOF record - rStrm.startRecordByHandle( nRecHandle ); + mrStrm.startRecordByHandle( nRecHandle ); } break; @@ -758,30 +752,31 @@ bool BiffWorkbookFragment::importSheetFragment( BiffInputStream& rStrm, ISegment { case SHEETTYPE_WORKSHEET: case SHEETTYPE_MACROSHEET: + case SHEETTYPE_DIALOGSHEET: xFragment.reset( new BiffWorksheetFragment( *this, xSheetProgress, eSheetType, nSheet ) ); break; case SHEETTYPE_CHARTSHEET: xFragment.reset( new BiffChartsheetFragment( *this, xSheetProgress, nSheet ) ); break; - case SHEETTYPE_DIALOGSHEET: case SHEETTYPE_MODULESHEET: - xFragment.reset( new BiffWorksheetFragmentBase( *this, xSheetProgress, eSheetType, nSheet ) ); + case SHEETTYPE_EMPTYSHEET: + xFragment.reset( new BiffSkipWorksheetFragment( *this, xSheetProgress, nSheet ) ); break; } // load the sheet fragment records - return xFragment->isValidSheet() && xFragment->importFragment( rStrm ); + return xFragment->isValidSheet() && xFragment->importFragment(); } -bool BiffWorkbookFragment::importFilePass( BiffInputStream& rStrm ) +bool BiffWorkbookFragment::importFilePass() { - rStrm.enableDecoder( false ); + mrStrm.enableDecoder( false ); BiffDecoderRef xDecoder = (getBiff() == BIFF8) ? - lclImportFilePass8( *this, rStrm ) : lclImportFilePass2( *this, rStrm ); + lclImportFilePass8( *this, mrStrm ) : lclImportFilePass2( *this, mrStrm ); // set decoder at import stream - rStrm.setDecoder( xDecoder ); + mrStrm.setDecoder( xDecoder ); //! TODO remember encryption state for export -// rStrm.GetRoot().GetExtDocOptions().GetDocSettings().mbEncrypted = true; +// mrStrm.GetRoot().GetExtDocOptions().GetDocSettings().mbEncrypted = true; return xDecoder.get() && xDecoder->isValid(); } diff --git a/oox/source/xls/workbookhelper.cxx b/oox/source/xls/workbookhelper.cxx index 08ded7681312..6d7ae205c74b 100644 --- a/oox/source/xls/workbookhelper.cxx +++ b/oox/source/xls/workbookhelper.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: workbookhelper.cxx,v $ - * $Revision: 1.6 $ + * $Revision: 1.5.20.4 $ * * This file is part of OpenOffice.org. * @@ -36,8 +36,10 @@ #include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/awt/XDevice.hpp> #include <com/sun/star/document/XActionLockable.hpp> +#include <com/sun/star/table/CellAddress.hpp> #include <com/sun/star/sheet/XSpreadsheetDocument.hpp> #include <com/sun/star/sheet/XSpreadsheet.hpp> +#include <com/sun/star/sheet/XNamedRange.hpp> #include <com/sun/star/sheet/XNamedRanges.hpp> #include <com/sun/star/sheet/XDatabaseRanges.hpp> #include <com/sun/star/style/XStyle.hpp> @@ -46,6 +48,7 @@ #include "oox/helper/propertyset.hxx" #include "oox/core/binaryfilterbase.hxx" #include "oox/core/xmlfilterbase.hxx" +#include "oox/drawingml/theme.hxx" #include "oox/xls/addressconverter.hxx" #include "oox/xls/defnamesbuffer.hxx" #include "oox/xls/excelchartconverter.hxx" @@ -59,7 +62,6 @@ #include "oox/xls/tablebuffer.hxx" #include "oox/xls/themebuffer.hxx" #include "oox/xls/unitconverter.hxx" -#include "oox/xls/validationpropertyhelper.hxx" #include "oox/xls/viewsettings.hxx" #include "oox/xls/webquerybuffer.hxx" #include "oox/xls/workbooksettings.hxx" @@ -78,8 +80,10 @@ using ::com::sun::star::container::XNameContainer; using ::com::sun::star::lang::XMultiServiceFactory; using ::com::sun::star::awt::XDevice; using ::com::sun::star::document::XActionLockable; +using ::com::sun::star::table::CellAddress; using ::com::sun::star::sheet::XSpreadsheetDocument; using ::com::sun::star::sheet::XSpreadsheet; +using ::com::sun::star::sheet::XNamedRange; using ::com::sun::star::sheet::XNamedRanges; using ::com::sun::star::sheet::XDatabaseRanges; using ::com::sun::star::style::XStyle; @@ -88,6 +92,7 @@ using ::oox::core::BinaryFilterBase; using ::oox::core::FilterBase; using ::oox::core::FragmentHandler; using ::oox::core::XmlFilterBase; +using ::oox::drawingml::Theme; // Set this define to 1 to show the load/save time of a document in an assertion. #define OOX_SHOW_LOADSAVE_TIME 0 @@ -180,8 +185,10 @@ public: Reference< XNameContainer > getStyleFamily( bool bPageStyles ) const; /** Returns the specified cell or page style from the Calc document. */ Reference< XStyle > getStyleObject( const OUString& rStyleName, bool bPageStyle ) const; + /** Creates and returns a defined name on-the-fly in the Calc document. */ + Reference< XNamedRange > createNamedRangeObject( OUString& orName, sal_Int32 nNameFlags ) const; /** Creates a com.sun.star.style.Style object and returns its final name. */ - Reference< XStyle > createStyleObject( OUString& orStyleName, bool bPageStyle, bool bRenameOldExisting ); + Reference< XStyle > createStyleObject( OUString& orStyleName, bool bPageStyle, bool bRenameOldExisting ) const; // buffers ---------------------------------------------------------------- @@ -193,6 +200,8 @@ public: inline WorksheetBuffer& getWorksheets() const { return *mxWorksheets; } /** Returns the office theme object read from the theme substorage. */ inline ThemeBuffer& getTheme() const { return *mxTheme; } + /** Returns the office theme object reference read from the theme substorage. */ + inline ::boost::shared_ptr< Theme > getThemeRef() const { return mxTheme; } /** Returns all cell formatting objects read from the styles substream. */ inline StylesBuffer& getStyles() const { return *mxStyles; } /** Returns the shared strings read from the shared strings substream. */ @@ -225,8 +234,6 @@ public: inline StylesPropertyHelper& getStylesPropertyHelper() const { return *mxStylesPropHlp; } /** Returns the converter for properties related to page/print settings. */ inline PageSettingsPropertyHelper& getPageSettingsPropertyHelper() const { return *mxPageSettPropHlp; } - /** Returns the converter for properties related to data validation. */ - inline ValidationPropertyHelper& getValidationPropertyHelper() const { return *mxValidationPropHlp; } // OOX specific ----------------------------------------------------------- @@ -265,7 +272,7 @@ private: typedef ::std::auto_ptr< WorkbookSettings > WorkbookSettPtr; typedef ::std::auto_ptr< ViewSettings > ViewSettingsPtr; typedef ::std::auto_ptr< WorksheetBuffer > WorksheetBfrPtr; - typedef ::std::auto_ptr< ThemeBuffer > ThemeBfrPtr; + typedef ::boost::shared_ptr< ThemeBuffer > ThemeBfrRef; typedef ::std::auto_ptr< StylesBuffer > StylesBfrPtr; typedef ::std::auto_ptr< SharedStringsBuffer > SharedStrBfrPtr; typedef ::std::auto_ptr< ExternalLinkBuffer > ExtLinkBfrPtr; @@ -278,7 +285,6 @@ private: typedef ::std::auto_ptr< ExcelChartConverter > ExcelChartConvPtr; typedef ::std::auto_ptr< StylesPropertyHelper > StylesPropHlpPtr; typedef ::std::auto_ptr< PageSettingsPropertyHelper > PageSettPropHlpPtr; - typedef ::std::auto_ptr< ValidationPropertyHelper > ValidationPropHlpPtr; typedef ::std::auto_ptr< FormulaParser > FormulaParserPtr; OUString maRefDeviceProp; /// Property name for reference device. @@ -300,7 +306,7 @@ private: WorkbookSettPtr mxWorkbookSettings; /// Global workbook settings. ViewSettingsPtr mxViewSettings; /// Workbook and sheet view settings. WorksheetBfrPtr mxWorksheets; /// Sheet info buffer. - ThemeBfrPtr mxTheme; /// Formatting theme from theme substream. + ThemeBfrRef mxTheme; /// Formatting theme from theme substream. StylesBfrPtr mxStyles; /// All cell style objects from styles substream. SharedStrBfrPtr mxSharedStrings; /// All strings from shared strings substream. ExtLinkBfrPtr mxExtLinks; /// All external links. @@ -318,7 +324,6 @@ private: // property helpers StylesPropHlpPtr mxStylesPropHlp; /// Helper for all styles properties. PageSettPropHlpPtr mxPageSettPropHlp; /// Helper for page/print properties. - ValidationPropHlpPtr mxValidationPropHlp; /// Helper for data validation properties. // OOX specific XmlFilterBase* mpOoxFilter; /// Base OOX filter object. @@ -422,7 +427,29 @@ Reference< XStyle > WorkbookData::getStyleObject( const OUString& rStyleName, bo return xStyle; } -Reference< XStyle > WorkbookData::createStyleObject( OUString& orStyleName, bool bPageStyle, bool bRenameOldExisting ) +Reference< XNamedRange > WorkbookData::createNamedRangeObject( OUString& orName, sal_Int32 nNameFlags ) const +{ + // find an unused name + Reference< XNamedRanges > xNamedRanges = getNamedRanges(); + Reference< XNameAccess > xNameAccess( xNamedRanges, UNO_QUERY ); + if( xNameAccess.is() ) + orName = ContainerHelper::getUnusedName( xNameAccess, orName, '_' ); + + // create the name and insert it into the Calc document + Reference< XNamedRange > xNamedRange; + if( xNamedRanges.is() && (orName.getLength() > 0) ) try + { + xNamedRanges->addNewByName( orName, OUString(), CellAddress( 0, 0, 0 ), nNameFlags ); + xNamedRange.set( xNamedRanges->getByName( orName ), UNO_QUERY ); + } + catch( Exception& ) + { + } + OSL_ENSURE( xNamedRange.is(), "WorkbookData::createNamedRangeObject - cannot create defined name" ); + return xNamedRange; +} + +Reference< XStyle > WorkbookData::createStyleObject( OUString& orStyleName, bool bPageStyle, bool bRenameOldExisting ) const { Reference< XStyle > xStyle; Reference< XNameContainer > xStylesNC = getStyleFamily( bPageStyle ); @@ -548,7 +575,6 @@ void WorkbookData::initialize( bool bWorkbookFile ) mxStylesPropHlp.reset( new StylesPropertyHelper( *this ) ); mxPageSettPropHlp.reset( new PageSettingsPropertyHelper( *this ) ); - mxValidationPropHlp.reset( new ValidationPropertyHelper( *this ) ); // set some document properties needed during import if( mrBaseFilter.isImportFilter() ) @@ -712,7 +738,12 @@ Reference< XStyle > WorkbookHelper::getStyleObject( const OUString& rStyleName, return mrBookData.getStyleObject( rStyleName, bPageStyle ); } -Reference< XStyle > WorkbookHelper::createStyleObject( OUString& orStyleName, bool bPageStyle, bool bRenameOldExisting ) +Reference< XNamedRange > WorkbookHelper::createNamedRangeObject( OUString& orName, sal_Int32 nNameFlags ) const +{ + return mrBookData.createNamedRangeObject( orName, nNameFlags ); +} + +Reference< XStyle > WorkbookHelper::createStyleObject( OUString& orStyleName, bool bPageStyle, bool bRenameOldExisting ) const { return mrBookData.createStyleObject( orStyleName, bPageStyle, bRenameOldExisting ); } @@ -739,6 +770,11 @@ ThemeBuffer& WorkbookHelper::getTheme() const return mrBookData.getTheme(); } +::boost::shared_ptr< Theme > WorkbookHelper::getThemeRef() const +{ + return mrBookData.getThemeRef(); +} + StylesBuffer& WorkbookHelper::getStyles() const { return mrBookData.getStyles(); @@ -808,11 +844,6 @@ PageSettingsPropertyHelper& WorkbookHelper::getPageSettingsPropertyHelper() cons return mrBookData.getPageSettingsPropertyHelper(); } -ValidationPropertyHelper& WorkbookHelper::getValidationPropertyHelper() const -{ - return mrBookData.getValidationPropertyHelper(); -} - // OOX specific --------------------------------------------------------------- XmlFilterBase& WorkbookHelper::getOoxFilter() const diff --git a/oox/source/xls/worksheetbuffer.cxx b/oox/source/xls/worksheetbuffer.cxx index 924ee303396c..cf1c196af013 100644 --- a/oox/source/xls/worksheetbuffer.cxx +++ b/oox/source/xls/worksheetbuffer.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: worksheetbuffer.cxx,v $ - * $Revision: 1.6 $ + * $Revision: 1.6.2.1 $ * * This file is part of OpenOffice.org. * @@ -32,11 +32,9 @@ #include <rtl/ustrbuf.hxx> #include <com/sun/star/container/XIndexAccess.hpp> #include <com/sun/star/container/XNamed.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/sheet/XSpreadsheetDocument.hpp> #include <com/sun/star/sheet/XExternalSheetName.hpp> #include <com/sun/star/sheet/XSheetLinkable.hpp> -#include <comphelper/processfactory.hxx> #include "oox/helper/attributelist.hxx" #include "oox/helper/containerhelper.hxx" #include "oox/helper/propertyset.hxx" @@ -54,8 +52,6 @@ using ::com::sun::star::uno::UNO_QUERY_THROW; using ::com::sun::star::container::XIndexAccess; using ::com::sun::star::container::XNameAccess; using ::com::sun::star::container::XNamed; -using ::com::sun::star::lang::XMultiServiceFactory; -using ::com::sun::star::sheet::XSpreadsheetDocument; using ::com::sun::star::sheet::XSpreadsheets; using ::com::sun::star::sheet::XSpreadsheet; using ::com::sun::star::sheet::XExternalSheetName; @@ -93,8 +89,6 @@ WorksheetBuffer::WorksheetBuffer( const WorkbookHelper& rHelper ) : WorkbookHelper( rHelper ), maIsVisibleProp( CREATE_OUSTRING( "IsVisible" ) ) { - // character classification service for conversion to valid sheet names - Reference< XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory(); } void WorksheetBuffer::initializeSingleSheet() diff --git a/oox/source/xls/worksheetfragment.cxx b/oox/source/xls/worksheetfragment.cxx index 1e17f8e4cf84..c93980409b39 100644 --- a/oox/source/xls/worksheetfragment.cxx +++ b/oox/source/xls/worksheetfragment.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: worksheetfragment.cxx,v $ - * $Revision: 1.5 $ + * $Revision: 1.5.4.5 $ * * This file is part of OpenOffice.org. * @@ -81,12 +81,21 @@ const sal_uInt32 BIFF_DATAVAL_NODROPDOWN = 0x00000200; const sal_uInt32 BIFF_DATAVAL_SHOWINPUT = 0x00040000; const sal_uInt32 BIFF_DATAVAL_SHOWERROR = 0x00080000; -const sal_uInt32 BIFF_HYPERLINK_TARGET = 0x00000001; /// File name or URL. -const sal_uInt32 BIFF_HYPERLINK_ABS = 0x00000002; /// Absolute path. -const sal_uInt32 BIFF_HYPERLINK_DISPLAY = 0x00000014; /// Display string. -const sal_uInt32 BIFF_HYPERLINK_LOC = 0x00000008; /// Target location. -const sal_uInt32 BIFF_HYPERLINK_FRAME = 0x00000080; /// Target frame. -const sal_uInt32 BIFF_HYPERLINK_UNC = 0x00000100; /// UNC path. +const sal_uInt32 OLE_HYPERLINK_HASTARGET = 0x00000001; /// Has hyperlink moniker. +const sal_uInt32 OLE_HYPERLINK_ABSOLUTE = 0x00000002; /// Absolute path. +const sal_uInt32 OLE_HYPERLINK_HASLOCATION = 0x00000008; /// Has target location. +const sal_uInt32 OLE_HYPERLINK_HASDISPLAY = 0x00000010; /// Has display string. +const sal_uInt32 OLE_HYPERLINK_HASGUID = 0x00000020; /// Has identification GUID. +const sal_uInt32 OLE_HYPERLINK_HASTIME = 0x00000040; /// Has creation time. +const sal_uInt32 OLE_HYPERLINK_HASFRAME = 0x00000080; /// Has frame. +const sal_uInt32 OLE_HYPERLINK_ASSTRING = 0x00000100; /// Hyperlink as simple string. + +const sal_Int32 OOBIN_OLEOBJECT_CONTENT = 1; +const sal_Int32 OOBIN_OLEOBJECT_ICON = 4; +const sal_Int32 OOBIN_OLEOBJECT_ALWAYS = 1; +const sal_Int32 OOBIN_OLEOBJECT_ONCALL = 3; +const sal_uInt16 OOBIN_OLEOBJECT_AUTOLOAD = 0x0001; +const sal_uInt16 OOBIN_OLEOBJECT_LINKED = 0x0002; } // namespace @@ -113,8 +122,9 @@ ContextWrapper OoxWorksheetFragment::onCreateContext( sal_Int32 nElement, const case SHEETTYPE_WORKSHEET: return (nElement == XLS_TOKEN( worksheet )); case SHEETTYPE_CHARTSHEET: return false; case SHEETTYPE_MACROSHEET: return (nElement == XM_TOKEN( macrosheet )); - case SHEETTYPE_DIALOGSHEET: return false; + case SHEETTYPE_DIALOGSHEET: return (nElement == XM_TOKEN( dialogsheet )); case SHEETTYPE_MODULESHEET: return false; + case SHEETTYPE_EMPTYSHEET: return false; } break; @@ -146,7 +156,10 @@ ContextWrapper OoxWorksheetFragment::onCreateContext( sal_Int32 nElement, const (nElement == XLS_TOKEN( picture )) || (nElement == XLS_TOKEN( rowBreaks )) || (nElement == XLS_TOKEN( colBreaks )) || - (nElement == XLS_TOKEN( drawing )); + (nElement == XLS_TOKEN( drawing )) || + (nElement == XLS_TOKEN( legacyDrawing )) || + (nElement == XLS_TOKEN( oleObjects )) || + (nElement == XLS_TOKEN( controls )); case XLS_TOKEN( sheetPr ): return (nElement == XLS_TOKEN( tabColor )) || @@ -184,6 +197,11 @@ ContextWrapper OoxWorksheetFragment::onCreateContext( sal_Int32 nElement, const case XLS_TOKEN( rowBreaks ): case XLS_TOKEN( colBreaks ): return (nElement == XLS_TOKEN( brk )); + + case XLS_TOKEN( oleObjects ): + return (nElement == XLS_TOKEN( oleObject )); + case XLS_TOKEN( controls ): + return (nElement == XLS_TOKEN( control )); } return false; } @@ -214,6 +232,9 @@ void OoxWorksheetFragment::onStartElement( const AttributeList& rAttribs ) case XLS_TOKEN( picture ): getPageSettings().importPicture( getRelations(), rAttribs ); break; case XLS_TOKEN( brk ): importBrk( rAttribs ); break; case XLS_TOKEN( drawing ): importDrawing( rAttribs ); break; + case XLS_TOKEN( legacyDrawing ): importLegacyDrawing( rAttribs ); break; + case XLS_TOKEN( oleObject ): importOleObject( rAttribs ); break; + case XLS_TOKEN( control ): importControl( rAttribs ); break; } } @@ -295,7 +316,10 @@ ContextWrapper OoxWorksheetFragment::onCreateRecordContext( sal_Int32 nRecId, Re (nRecId == OOBIN_ID_COLBREAKS) || (nRecId == OOBIN_ID_SHEETPROTECTION) || (nRecId == OOBIN_ID_PHONETICPR) || - (nRecId == OOBIN_ID_DRAWING); + (nRecId == OOBIN_ID_DRAWING) || + (nRecId == OOBIN_ID_LEGACYDRAWING) || + (nRecId == OOBIN_ID_OLEOBJECTS) || + (nRecId == OOBIN_ID_CONTROLS); case OOBIN_ID_SHEETVIEWS: return (nRecId == OOBIN_ID_SHEETVIEW); case OOBIN_ID_SHEETVIEW: @@ -310,6 +334,10 @@ ContextWrapper OoxWorksheetFragment::onCreateRecordContext( sal_Int32 nRecId, Re case OOBIN_ID_ROWBREAKS: case OOBIN_ID_COLBREAKS: return (nRecId == OOBIN_ID_BRK); + case OOBIN_ID_OLEOBJECTS: + return (nRecId == OOBIN_ID_OLEOBJECT); + case OOBIN_ID_CONTROLS: + return (nRecId == OOBIN_ID_CONTROL); } return false; } @@ -337,6 +365,9 @@ void OoxWorksheetFragment::onStartRecord( RecordInputStream& rStrm ) case OOBIN_ID_PICTURE: getPageSettings().importPicture( getRelations(), rStrm ); break; case OOBIN_ID_BRK: importBrk( rStrm ); break; case OOBIN_ID_DRAWING: importDrawing( rStrm ); break; + case OOBIN_ID_LEGACYDRAWING: importLegacyDrawing( rStrm ); break; + case OOBIN_ID_OLEOBJECT: importOleObject( rStrm ); break; + case OOBIN_ID_CONTROL: importControl( rStrm ); break; } } @@ -351,6 +382,7 @@ const RecordInfo* OoxWorksheetFragment::getRecordInfos() const { OOBIN_ID_COLORSCALE, OOBIN_ID_COLORSCALE + 1 }, { OOBIN_ID_COLS, OOBIN_ID_COLS + 1 }, { OOBIN_ID_CONDFORMATTING, OOBIN_ID_CONDFORMATTING + 1 }, + { OOBIN_ID_CONTROLS, OOBIN_ID_CONTROLS + 2 }, { OOBIN_ID_CUSTOMSHEETVIEW, OOBIN_ID_CUSTOMSHEETVIEW + 1 }, { OOBIN_ID_CUSTOMSHEETVIEWS, OOBIN_ID_CUSTOMSHEETVIEWS + 3 }, { OOBIN_ID_DATABAR, OOBIN_ID_DATABAR + 1 }, @@ -358,6 +390,7 @@ const RecordInfo* OoxWorksheetFragment::getRecordInfos() const { OOBIN_ID_HEADERFOOTER, OOBIN_ID_HEADERFOOTER + 1 }, { OOBIN_ID_ICONSET, OOBIN_ID_ICONSET + 1 }, { OOBIN_ID_MERGECELLS, OOBIN_ID_MERGECELLS + 1 }, + { OOBIN_ID_OLEOBJECTS, OOBIN_ID_OLEOBJECTS + 2 }, { OOBIN_ID_ROW, -1 }, { OOBIN_ID_ROWBREAKS, OOBIN_ID_ROWBREAKS + 1 }, { OOBIN_ID_SHEETDATA, OOBIN_ID_SHEETDATA + 1 }, @@ -495,6 +528,37 @@ void OoxWorksheetFragment::importDrawing( const AttributeList& rAttribs ) setDrawingPath( getFragmentPathFromRelId( rAttribs.getString( R_TOKEN( id ), OUString() ) ) ); } +void OoxWorksheetFragment::importLegacyDrawing( const AttributeList& rAttribs ) +{ + setVmlDrawingPath( getFragmentPathFromRelId( rAttribs.getString( R_TOKEN( id ), OUString() ) ) ); +} + +void OoxWorksheetFragment::importOleObject( const AttributeList& rAttribs ) +{ + OoxOleObjectData aData; + aData.maProgId = rAttribs.getString( XML_progId, OUString() ); + OSL_ENSURE( rAttribs.hasAttribute( XML_link ) != rAttribs.hasAttribute( R_TOKEN( id ) ), + "OoxWorksheetFragment::importOleObject - either linked or embedded" ); + if( rAttribs.hasAttribute( XML_link ) ) + (void)0; + if( rAttribs.hasAttribute( R_TOKEN( id ) ) ) + aData.maStoragePath = getFragmentPathFromRelId( rAttribs.getString( R_TOKEN( id ), OUString() ) ); + aData.mnAspect = rAttribs.getToken( XML_dvAspect, XML_DVASPECT_CONTENT ); + aData.mnUpdateMode = rAttribs.getToken( XML_oleUpdate, XML_OLEUPDATE_ALWAYS ); + aData.mnShapeId = rAttribs.getInteger( XML_shapeId, 0 ); + aData.mbAutoLoad = rAttribs.getBool( XML_autoLoad, false ); + setOleObject( aData ); +} + +void OoxWorksheetFragment::importControl( const AttributeList& rAttribs ) +{ + OoxFormControlData aData; + aData.maStoragePath = getFragmentPathFromRelId( rAttribs.getString( R_TOKEN( id ), OUString() ) ); + aData.maName = rAttribs.getString( XML_name, OUString() ); + aData.mnShapeId = rAttribs.getInteger( XML_shapeId, 0 ); + setFormControl( aData ); +} + void OoxWorksheetFragment::importDimension( RecordInputStream& rStrm ) { BinRange aBinRange; @@ -621,14 +685,44 @@ void OoxWorksheetFragment::importDrawing( RecordInputStream& rStrm ) setDrawingPath( getFragmentPathFromRelId( rStrm.readString() ) ); } +void OoxWorksheetFragment::importLegacyDrawing( RecordInputStream& rStrm ) +{ + setVmlDrawingPath( getFragmentPathFromRelId( rStrm.readString() ) ); +} + +void OoxWorksheetFragment::importOleObject( RecordInputStream& rStrm ) +{ + OoxOleObjectData aData; + sal_Int32 nAspect, nUpdateMode; + sal_uInt16 nFlags; + rStrm >> nAspect >> nUpdateMode >> aData.mnShapeId >> nFlags >> aData.maProgId; + if( getFlag( nFlags, OOBIN_OLEOBJECT_LINKED ) ) + (void)0; + else + aData.maStoragePath = getFragmentPathFromRelId( rStrm.readString() ); + aData.mnAspect = (nAspect == OOBIN_OLEOBJECT_ICON) ? XML_DVASPECT_ICON : XML_DVASPECT_CONTENT; + aData.mnUpdateMode = (nUpdateMode == OOBIN_OLEOBJECT_ONCALL) ? XML_OLEUPDATE_ONCALL : XML_OLEUPDATE_ALWAYS; + aData.mbAutoLoad = getFlag( nFlags, OOBIN_OLEOBJECT_AUTOLOAD ); + setOleObject( aData ); +} + +void OoxWorksheetFragment::importControl( RecordInputStream& rStrm ) +{ + OoxFormControlData aData; + rStrm >> aData.mnShapeId; + aData.maStoragePath = getFragmentPathFromRelId( rStrm.readString() ); + rStrm >> aData.maName; + setFormControl( aData ); +} + // ============================================================================ -BiffWorksheetFragment::BiffWorksheetFragment( const WorkbookHelper& rHelper, ISegmentProgressBarRef xProgressBar, WorksheetType eSheetType, sal_Int32 nSheet ) : - BiffWorksheetFragmentBase( rHelper, xProgressBar, eSheetType, nSheet ) +BiffWorksheetFragment::BiffWorksheetFragment( const BiffWorkbookFragmentBase& rParent, ISegmentProgressBarRef xProgressBar, WorksheetType eSheetType, sal_Int32 nSheet ) : + BiffWorksheetFragmentBase( rParent, xProgressBar, eSheetType, nSheet ) { } -bool BiffWorksheetFragment::importFragment( BiffInputStream& rStrm ) +bool BiffWorksheetFragment::importFragment() { // initial processing in base class WorksheetHelper initializeWorksheetImport(); @@ -643,133 +737,132 @@ bool BiffWorksheetFragment::importFragment( BiffInputStream& rStrm ) PageSettings& rPageSett = getPageSettings(); // process all record in this sheet fragment - while( rStrm.startNextRecord() && (rStrm.getRecId() != BIFF_ID_EOF) ) + while( mrStrm.startNextRecord() && (mrStrm.getRecId() != BIFF_ID_EOF) ) { - sal_uInt16 nRecId = rStrm.getRecId(); - - if( isBofRecord( nRecId ) ) + if( isBofRecord() ) { // skip unknown embedded fragments (BOF/EOF blocks) - skipFragment( rStrm ); + skipFragment(); } else { - // cache core stream position to detect if record is already processed - sal_Int64 nStrmPos = rStrm.getCoreStreamPos(); + // cache base stream position to detect if record is already processed + sal_Int64 nStrmPos = mrStrm.tellBase(); + sal_uInt16 nRecId = mrStrm.getRecId(); switch( nRecId ) { // records in all BIFF versions - case BIFF_ID_BOTTOMMARGIN: rPageSett.importBottomMargin( rStrm ); break; - case BIFF_ID_CALCCOUNT: rWorkbookSett.importCalcCount( rStrm ); break; - case BIFF_ID_CALCMODE: rWorkbookSett.importCalcMode( rStrm ); break; - case BIFF_ID_DEFCOLWIDTH: importDefColWidth( rStrm ); break; - case BIFF_ID_DELTA: rWorkbookSett.importDelta( rStrm ); break; - case BIFF2_ID_DIMENSION: importDimension( rStrm ); break; - case BIFF3_ID_DIMENSION: importDimension( rStrm ); break; - case BIFF_ID_FOOTER: rPageSett.importFooter( rStrm ); break; - case BIFF_ID_HEADER: rPageSett.importHeader( rStrm ); break; - case BIFF_ID_HORPAGEBREAKS: importPageBreaks( rStrm, true ); break; - case BIFF_ID_ITERATION: rWorkbookSett.importIteration( rStrm ); break; - case BIFF_ID_LEFTMARGIN: rPageSett.importLeftMargin( rStrm ); break; - case BIFF_ID_PANE: rSheetViewSett.importPane( rStrm ); break; - case BIFF_ID_PASSWORD: rWorksheetSett.importPassword( rStrm ); break; - case BIFF_ID_PRINTGRIDLINES: rPageSett.importPrintGridLines( rStrm ); break; - case BIFF_ID_PRINTHEADERS: rPageSett.importPrintHeaders( rStrm ); break; - case BIFF_ID_PROTECT: rWorksheetSett.importProtect( rStrm ); break; - case BIFF_ID_REFMODE: rWorkbookSett.importRefMode( rStrm ); break; - case BIFF_ID_RIGHTMARGIN: rPageSett.importRightMargin( rStrm ); break; - case BIFF_ID_SELECTION: rSheetViewSett.importSelection( rStrm ); break; - case BIFF_ID_TOPMARGIN: rPageSett.importTopMargin( rStrm ); break; - case BIFF_ID_VERPAGEBREAKS: importPageBreaks( rStrm, false ); break; + case BIFF_ID_BOTTOMMARGIN: rPageSett.importBottomMargin( mrStrm ); break; + case BIFF_ID_CALCCOUNT: rWorkbookSett.importCalcCount( mrStrm ); break; + case BIFF_ID_CALCMODE: rWorkbookSett.importCalcMode( mrStrm ); break; + case BIFF_ID_DEFCOLWIDTH: importDefColWidth(); break; + case BIFF_ID_DELTA: rWorkbookSett.importDelta( mrStrm ); break; + case BIFF2_ID_DIMENSION: importDimension(); break; + case BIFF3_ID_DIMENSION: importDimension(); break; + case BIFF_ID_FOOTER: rPageSett.importFooter( mrStrm ); break; + case BIFF_ID_HEADER: rPageSett.importHeader( mrStrm ); break; + case BIFF_ID_HORPAGEBREAKS: importPageBreaks( true ); break; + case BIFF_ID_ITERATION: rWorkbookSett.importIteration( mrStrm ); break; + case BIFF_ID_LEFTMARGIN: rPageSett.importLeftMargin( mrStrm ); break; + case BIFF_ID_PANE: rSheetViewSett.importPane( mrStrm ); break; + case BIFF_ID_PASSWORD: rWorksheetSett.importPassword( mrStrm ); break; + case BIFF_ID_PRINTGRIDLINES: rPageSett.importPrintGridLines( mrStrm ); break; + case BIFF_ID_PRINTHEADERS: rPageSett.importPrintHeaders( mrStrm ); break; + case BIFF_ID_PROTECT: rWorksheetSett.importProtect( mrStrm ); break; + case BIFF_ID_REFMODE: rWorkbookSett.importRefMode( mrStrm ); break; + case BIFF_ID_RIGHTMARGIN: rPageSett.importRightMargin( mrStrm ); break; + case BIFF_ID_SELECTION: rSheetViewSett.importSelection( mrStrm ); break; + case BIFF_ID_TOPMARGIN: rPageSett.importTopMargin( mrStrm ); break; + case BIFF_ID_VERPAGEBREAKS: importPageBreaks( false ); break; // BIFF specific records default: switch( getBiff() ) { case BIFF2: switch( nRecId ) { - case BIFF_ID_COLUMNDEFAULT: importColumnDefault( rStrm ); break; - case BIFF_ID_COLWIDTH: importColWidth( rStrm ); break; - case BIFF2_ID_DEFROWHEIGHT: importDefRowHeight( rStrm ); break; - case BIFF2_ID_WINDOW2: rSheetViewSett.importWindow2( rStrm ); break; + case BIFF_ID_COLUMNDEFAULT: importColumnDefault(); break; + case BIFF_ID_COLWIDTH: importColWidth(); break; + case BIFF2_ID_DEFROWHEIGHT: importDefRowHeight(); break; + case BIFF2_ID_WINDOW2: rSheetViewSett.importWindow2( mrStrm ); break; } break; case BIFF3: switch( nRecId ) { - case BIFF_ID_COLINFO: importColInfo( rStrm ); break; - case BIFF_ID_DEFCOLWIDTH: importDefColWidth( rStrm ); break; - case BIFF3_ID_DEFROWHEIGHT: importDefRowHeight( rStrm ); break; - case BIFF_ID_HCENTER: rPageSett.importHorCenter( rStrm ); break; - case BIFF_ID_OBJECTPROTECT: rWorksheetSett.importObjectProtect( rStrm ); break; - case BIFF_ID_SAVERECALC: rWorkbookSett.importSaveRecalc( rStrm ); break; - case BIFF_ID_SHEETPR: rWorksheetSett.importSheetPr( rStrm ); break; - case BIFF_ID_UNCALCED: rWorkbookSett.importUncalced( rStrm ); break; - case BIFF_ID_VCENTER: rPageSett.importVerCenter( rStrm ); break; - case BIFF3_ID_WINDOW2: rSheetViewSett.importWindow2( rStrm ); break; + case BIFF_ID_COLINFO: importColInfo(); break; + case BIFF_ID_DEFCOLWIDTH: importDefColWidth(); break; + case BIFF3_ID_DEFROWHEIGHT: importDefRowHeight(); break; + case BIFF_ID_HCENTER: rPageSett.importHorCenter( mrStrm ); break; + case BIFF_ID_OBJECTPROTECT: rWorksheetSett.importObjectProtect( mrStrm ); break; + case BIFF_ID_SAVERECALC: rWorkbookSett.importSaveRecalc( mrStrm ); break; + case BIFF_ID_SHEETPR: rWorksheetSett.importSheetPr( mrStrm ); break; + case BIFF_ID_UNCALCED: rWorkbookSett.importUncalced( mrStrm ); break; + case BIFF_ID_VCENTER: rPageSett.importVerCenter( mrStrm ); break; + case BIFF3_ID_WINDOW2: rSheetViewSett.importWindow2( mrStrm ); break; } break; case BIFF4: switch( nRecId ) { - case BIFF_ID_COLINFO: importColInfo( rStrm ); break; - case BIFF3_ID_DEFROWHEIGHT: importDefRowHeight( rStrm ); break; - case BIFF_ID_HCENTER: rPageSett.importHorCenter( rStrm ); break; - case BIFF_ID_OBJECTPROTECT: rWorksheetSett.importObjectProtect( rStrm ); break; - case BIFF_ID_PAGESETUP: rPageSett.importPageSetup( rStrm ); break; - case BIFF_ID_SAVERECALC: rWorkbookSett.importSaveRecalc( rStrm ); break; - case BIFF_ID_SHEETPR: rWorksheetSett.importSheetPr( rStrm ); break; - case BIFF_ID_STANDARDWIDTH: importStandardWidth( rStrm ); break; - case BIFF_ID_UNCALCED: rWorkbookSett.importUncalced( rStrm ); break; - case BIFF_ID_VCENTER: rPageSett.importVerCenter( rStrm ); break; - case BIFF3_ID_WINDOW2: rSheetViewSett.importWindow2( rStrm ); break; + case BIFF_ID_COLINFO: importColInfo(); break; + case BIFF3_ID_DEFROWHEIGHT: importDefRowHeight(); break; + case BIFF_ID_HCENTER: rPageSett.importHorCenter( mrStrm ); break; + case BIFF_ID_OBJECTPROTECT: rWorksheetSett.importObjectProtect( mrStrm ); break; + case BIFF_ID_PAGESETUP: rPageSett.importPageSetup( mrStrm ); break; + case BIFF_ID_SAVERECALC: rWorkbookSett.importSaveRecalc( mrStrm ); break; + case BIFF_ID_SHEETPR: rWorksheetSett.importSheetPr( mrStrm ); break; + case BIFF_ID_STANDARDWIDTH: importStandardWidth(); break; + case BIFF_ID_UNCALCED: rWorkbookSett.importUncalced( mrStrm ); break; + case BIFF_ID_VCENTER: rPageSett.importVerCenter( mrStrm ); break; + case BIFF3_ID_WINDOW2: rSheetViewSett.importWindow2( mrStrm ); break; } break; case BIFF5: switch( nRecId ) { - case BIFF_ID_COLINFO: importColInfo( rStrm ); break; - case BIFF3_ID_DEFROWHEIGHT: importDefRowHeight( rStrm ); break; - case BIFF_ID_HCENTER: rPageSett.importHorCenter( rStrm ); break; - case BIFF_ID_MERGEDCELLS: importMergedCells( rStrm ); break; // #i62300# also in BIFF5 - case BIFF_ID_OBJECTPROTECT: rWorksheetSett.importObjectProtect( rStrm ); break; - case BIFF_ID_PAGESETUP: rPageSett.importPageSetup( rStrm ); break; - case BIFF_ID_SAVERECALC: rWorkbookSett.importSaveRecalc( rStrm ); break; - case BIFF_ID_SCENPROTECT: rWorksheetSett.importScenProtect( rStrm ); break; - case BIFF_ID_SCL: rSheetViewSett.importScl( rStrm ); break; - case BIFF_ID_SHEETPR: rWorksheetSett.importSheetPr( rStrm ); break; - case BIFF_ID_STANDARDWIDTH: importStandardWidth( rStrm ); break; - case BIFF_ID_UNCALCED: rWorkbookSett.importUncalced( rStrm ); break; - case BIFF_ID_VCENTER: rPageSett.importVerCenter( rStrm ); break; - case BIFF3_ID_WINDOW2: rSheetViewSett.importWindow2( rStrm ); break; + case BIFF_ID_COLINFO: importColInfo(); break; + case BIFF3_ID_DEFROWHEIGHT: importDefRowHeight(); break; + case BIFF_ID_HCENTER: rPageSett.importHorCenter( mrStrm ); break; + case BIFF_ID_MERGEDCELLS: importMergedCells(); break; // #i62300# also in BIFF5 + case BIFF_ID_OBJECTPROTECT: rWorksheetSett.importObjectProtect( mrStrm ); break; + case BIFF_ID_PAGESETUP: rPageSett.importPageSetup( mrStrm ); break; + case BIFF_ID_SAVERECALC: rWorkbookSett.importSaveRecalc( mrStrm ); break; + case BIFF_ID_SCENPROTECT: rWorksheetSett.importScenProtect( mrStrm ); break; + case BIFF_ID_SCL: rSheetViewSett.importScl( mrStrm ); break; + case BIFF_ID_SHEETPR: rWorksheetSett.importSheetPr( mrStrm ); break; + case BIFF_ID_STANDARDWIDTH: importStandardWidth(); break; + case BIFF_ID_UNCALCED: rWorkbookSett.importUncalced( mrStrm ); break; + case BIFF_ID_VCENTER: rPageSett.importVerCenter( mrStrm ); break; + case BIFF3_ID_WINDOW2: rSheetViewSett.importWindow2( mrStrm ); break; } break; case BIFF8: switch( nRecId ) { - case BIFF_ID_CFHEADER: rCondFormats.importCfHeader( rStrm ); break; - case BIFF_ID_COLINFO: importColInfo( rStrm ); break; - case BIFF_ID_DATAVALIDATION: importDataValidation( rStrm ); break; - case BIFF_ID_DATAVALIDATIONS: importDataValidations( rStrm ); break; - case BIFF3_ID_DEFROWHEIGHT: importDefRowHeight( rStrm ); break; - case BIFF_ID_HCENTER: rPageSett.importHorCenter( rStrm ); break; - case BIFF_ID_HYPERLINK: importHyperlink( rStrm ); break; - case BIFF_ID_LABELRANGES: importLabelRanges( rStrm ); break; - case BIFF_ID_MERGEDCELLS: importMergedCells( rStrm ); break; - case BIFF_ID_OBJECTPROTECT: rWorksheetSett.importObjectProtect( rStrm ); break; - case BIFF_ID_PICTURE: rPageSett.importPicture( rStrm ); break; - case BIFF_ID_SAVERECALC: rWorkbookSett.importSaveRecalc( rStrm ); break; - case BIFF_ID_SCENPROTECT: rWorksheetSett.importScenProtect( rStrm ); break; - case BIFF_ID_SCL: rSheetViewSett.importScl( rStrm ); break; - case BIFF_ID_SHEETPR: rWorksheetSett.importSheetPr( rStrm ); break; - case BIFF_ID_SHEETPROTECTION: rWorksheetSett.importSheetProtection( rStrm ); break; - case BIFF_ID_PAGESETUP: rPageSett.importPageSetup( rStrm ); break; - case BIFF_ID_PHONETICPR: rWorksheetSett.importPhoneticPr( rStrm ); break; - case BIFF_ID_STANDARDWIDTH: importStandardWidth( rStrm ); break; - case BIFF_ID_UNCALCED: rWorkbookSett.importUncalced( rStrm ); break; - case BIFF_ID_VCENTER: rPageSett.importVerCenter( rStrm ); break; - case BIFF3_ID_WINDOW2: rSheetViewSett.importWindow2( rStrm ); break; + case BIFF_ID_CFHEADER: rCondFormats.importCfHeader( mrStrm ); break; + case BIFF_ID_COLINFO: importColInfo(); break; + case BIFF_ID_DATAVALIDATION: importDataValidation(); break; + case BIFF_ID_DATAVALIDATIONS: importDataValidations(); break; + case BIFF3_ID_DEFROWHEIGHT: importDefRowHeight(); break; + case BIFF_ID_HCENTER: rPageSett.importHorCenter( mrStrm ); break; + case BIFF_ID_HYPERLINK: importHyperlink(); break; + case BIFF_ID_LABELRANGES: importLabelRanges(); break; + case BIFF_ID_MERGEDCELLS: importMergedCells(); break; + case BIFF_ID_OBJECTPROTECT: rWorksheetSett.importObjectProtect( mrStrm ); break; + case BIFF_ID_PICTURE: rPageSett.importPicture( mrStrm ); break; + case BIFF_ID_SAVERECALC: rWorkbookSett.importSaveRecalc( mrStrm ); break; + case BIFF_ID_SCENPROTECT: rWorksheetSett.importScenProtect( mrStrm ); break; + case BIFF_ID_SCL: rSheetViewSett.importScl( mrStrm ); break; + case BIFF_ID_SHEETPR: rWorksheetSett.importSheetPr( mrStrm ); break; + case BIFF_ID_SHEETPROTECTION: rWorksheetSett.importSheetProtection( mrStrm ); break; + case BIFF_ID_PAGESETUP: rPageSett.importPageSetup( mrStrm ); break; + case BIFF_ID_PHONETICPR: rWorksheetSett.importPhoneticPr( mrStrm ); break; + case BIFF_ID_STANDARDWIDTH: importStandardWidth(); break; + case BIFF_ID_UNCALCED: rWorkbookSett.importUncalced( mrStrm ); break; + case BIFF_ID_VCENTER: rPageSett.importVerCenter( mrStrm ); break; + case BIFF3_ID_WINDOW2: rSheetViewSett.importWindow2( mrStrm ); break; } break; @@ -778,22 +871,22 @@ bool BiffWorksheetFragment::importFragment( BiffInputStream& rStrm ) } // record not processed, try cell records - if( rStrm.getCoreStreamPos() == nStrmPos ) - aSheetData.importRecord( rStrm ); + if( mrStrm.tellBase() == nStrmPos ) + aSheetData.importRecord(); } } // final processing in base class WorksheetHelper finalizeWorksheetImport(); - return rStrm.getRecId() == BIFF_ID_EOF; + return mrStrm.getRecId() == BIFF_ID_EOF; } // private -------------------------------------------------------------------- -void BiffWorksheetFragment::importColInfo( BiffInputStream& rStrm ) +void BiffWorksheetFragment::importColInfo() { sal_uInt16 nFirstCol, nLastCol, nWidth, nXfId, nFlags; - rStrm >> nFirstCol >> nLastCol >> nWidth >> nXfId >> nFlags; + mrStrm >> nFirstCol >> nLastCol >> nWidth >> nXfId >> nFlags; OoxColumnData aData; // column indexes are 0-based in BIFF, but OoxColumnData expects 1-based @@ -810,18 +903,18 @@ void BiffWorksheetFragment::importColInfo( BiffInputStream& rStrm ) setColumnData( aData ); } -void BiffWorksheetFragment::importColumnDefault( BiffInputStream& rStrm ) +void BiffWorksheetFragment::importColumnDefault() { sal_uInt16 nFirstCol, nLastCol, nXfId; - rStrm >> nFirstCol >> nLastCol >> nXfId; + mrStrm >> nFirstCol >> nLastCol >> nXfId; convertColumnFormat( nFirstCol, nLastCol, nXfId ); } -void BiffWorksheetFragment::importColWidth( BiffInputStream& rStrm ) +void BiffWorksheetFragment::importColWidth() { sal_uInt8 nFirstCol, nLastCol; sal_uInt16 nWidth; - rStrm >> nFirstCol >> nLastCol >> nWidth; + mrStrm >> nFirstCol >> nLastCol >> nWidth; OoxColumnData aData; // column indexes are 0-based in BIFF, but OoxColumnData expects 1-based @@ -833,20 +926,20 @@ void BiffWorksheetFragment::importColWidth( BiffInputStream& rStrm ) setColumnData( aData ); } -void BiffWorksheetFragment::importDefColWidth( BiffInputStream& rStrm ) +void BiffWorksheetFragment::importDefColWidth() { /* Stored as entire number of characters without padding pixels, which will be added in setBaseColumnWidth(). Call has no effect, if a width has already been set from the STANDARDWIDTH record. */ - setBaseColumnWidth( rStrm.readuInt16() ); + setBaseColumnWidth( mrStrm.readuInt16() ); } -void BiffWorksheetFragment::importDefRowHeight( BiffInputStream& rStrm ) +void BiffWorksheetFragment::importDefRowHeight() { sal_uInt16 nFlags = BIFF_DEFROW_CUSTOMHEIGHT, nHeight; if( getBiff() != BIFF2 ) - rStrm >> nFlags; - rStrm >> nHeight; + mrStrm >> nFlags; + mrStrm >> nHeight; if( getBiff() == BIFF2 ) nHeight &= BIFF2_DEFROW_MASK; // row height is in twips in BIFF, convert to points @@ -858,11 +951,11 @@ void BiffWorksheetFragment::importDefRowHeight( BiffInputStream& rStrm ) getFlag( nFlags, BIFF_DEFROW_THICKBOTTOM ) ); } -void BiffWorksheetFragment::importDataValidations( BiffInputStream& rStrm ) +void BiffWorksheetFragment::importDataValidations() { sal_Int32 nObjId; - rStrm.skip( 10 ); - rStrm >> nObjId; + mrStrm.skip( 10 ); + mrStrm >> nObjId; //! TODO: invalidate object id in drawing object manager } @@ -893,13 +986,13 @@ ApiTokenSequence lclReadDataValFormula( BiffInputStream& rStrm, FormulaParser& r } // namespace -void BiffWorksheetFragment::importDataValidation( BiffInputStream& rStrm ) +void BiffWorksheetFragment::importDataValidation() { OoxValidationData aData; // flags sal_uInt32 nFlags; - rStrm >> nFlags; + mrStrm >> nFlags; aData.setBinType( extractValue< sal_uInt8 >( nFlags, 0, 4 ) ); aData.setBinOperator( extractValue< sal_uInt8 >( nFlags, 20, 4 ) ); aData.setBinErrorStyle( extractValue< sal_uInt8 >( nFlags, 4, 3 ) ); @@ -909,32 +1002,32 @@ void BiffWorksheetFragment::importDataValidation( BiffInputStream& rStrm ) aData.mbShowErrorMsg = getFlag( nFlags, BIFF_DATAVAL_SHOWERROR ); // message strings - aData.maInputTitle = lclReadDataValMessage( rStrm ); - aData.maErrorTitle = lclReadDataValMessage( rStrm ); - aData.maInputMessage = lclReadDataValMessage( rStrm ); - aData.maErrorMessage = lclReadDataValMessage( rStrm ); + aData.maInputTitle = lclReadDataValMessage( mrStrm ); + aData.maErrorTitle = lclReadDataValMessage( mrStrm ); + aData.maInputMessage = lclReadDataValMessage( mrStrm ); + aData.maErrorMessage = lclReadDataValMessage( mrStrm ); // condition formula(s) FormulaParser& rParser = getFormulaParser(); - aData.maTokens1 = lclReadDataValFormula( rStrm, rParser ); - aData.maTokens2 = lclReadDataValFormula( rStrm, rParser ); + aData.maTokens1 = lclReadDataValFormula( mrStrm, rParser ); + aData.maTokens2 = lclReadDataValFormula( mrStrm, rParser ); // process string list of a list validation (convert to list of string tokens) if( (aData.mnType == XML_list) && getFlag( nFlags, BIFF_DATAVAL_STRINGLIST ) ) rParser.convertStringToStringList( aData.maTokens1, '\0', true ); // cell range list BinRangeList aRanges; - rStrm >> aRanges; + mrStrm >> aRanges; getAddressConverter().convertToCellRangeList( aData.maRanges, aRanges, getSheetIndex(), true ); // set validation data setValidation( aData ); } -void BiffWorksheetFragment::importDimension( BiffInputStream& rStrm ) +void BiffWorksheetFragment::importDimension() { BinRange aBinRange; - aBinRange.read( rStrm, true, (rStrm.getRecId() == BIFF3_ID_DIMENSION) && (getBiff() == BIFF8) ); + aBinRange.read( mrStrm, true, (mrStrm.getRecId() == BIFF3_ID_DIMENSION) && (getBiff() == BIFF8) ); // first unused row/column index in BIFF, not last used if( aBinRange.maFirst.mnCol < aBinRange.maLast.mnCol ) --aBinRange.maLast.mnCol; if( aBinRange.maFirst.mnRow < aBinRange.maLast.mnRow ) --aBinRange.maLast.mnRow; @@ -944,56 +1037,37 @@ void BiffWorksheetFragment::importDimension( BiffInputStream& rStrm ) setDimension( aRange ); } -namespace { - -OUString lclReadHyperlinkString( BiffInputStream& rStrm, sal_Int32 nChars, rtl_TextEncoding eTextEnc, bool bUnicode ) +OUString BiffWorksheetFragment::readHyperlinkString( rtl_TextEncoding eTextEnc, bool bUnicode ) { OUString aRet; + sal_Int32 nChars = mrStrm.readInt32(); if( nChars > 0 ) { sal_uInt16 nReadChars = getLimitedValue< sal_uInt16, sal_Int32 >( nChars, 0, SAL_MAX_UINT16 ); - // strings are NUL terminated with trailing garbage - rStrm.enableNulChars( true ); + // strings are NUL terminated + mrStrm.enableNulChars( true ); aRet = bUnicode ? - rStrm.readUnicodeArray( nReadChars ) : - rStrm.readCharArray( nReadChars, eTextEnc ); - rStrm.enableNulChars( false ); - // remove trailing garbage + mrStrm.readUnicodeArray( nReadChars ) : + mrStrm.readCharArray( nReadChars, eTextEnc ); + mrStrm.enableNulChars( false ); + // remove trailing NUL and possible other garbage sal_Int32 nNulPos = aRet.indexOf( '\0' ); if( nNulPos >= 0 ) aRet = aRet.copy( 0, nNulPos ); // skip remaining chars sal_uInt32 nSkip = static_cast< sal_uInt32 >( nChars - nReadChars ); - rStrm.skip( bUnicode ? (nSkip * 2) : nSkip ); + mrStrm.skip( (bUnicode ? 2 : 1) * nSkip ); } return aRet; } -OUString lclReadHyperlinkString( BiffInputStream& rStrm, rtl_TextEncoding eTextEnc, bool bUnicode ) -{ - return lclReadHyperlinkString( rStrm, rStrm.readInt32(), eTextEnc, bUnicode ); -} - -void lclSkipHyperlinkString( BiffInputStream& rStrm, sal_Int32 nChars, bool bUnicode ) -{ - if( nChars > 0 ) - rStrm.skip( static_cast< sal_uInt32 >( bUnicode ? (nChars * 2) : nChars ) ); -} - -void lclSkipHyperlinkString( BiffInputStream& rStrm, bool bUnicode ) -{ - lclSkipHyperlinkString( rStrm, rStrm.readInt32(), bUnicode ); -} - -} // namespace - -void BiffWorksheetFragment::importHyperlink( BiffInputStream& rStrm ) +void BiffWorksheetFragment::importHyperlink() { OoxHyperlinkData aData; // read cell range for the hyperlink BinRange aBiffRange; - rStrm >> aBiffRange; + mrStrm >> aBiffRange; // #i80006# Excel silently ignores invalid hi-byte of column index (TODO: everywhere?) aBiffRange.maFirst.mnCol &= 0xFF; aBiffRange.maLast.mnCol &= 0xFF; @@ -1001,78 +1075,79 @@ void BiffWorksheetFragment::importHyperlink( BiffInputStream& rStrm ) return; BiffGuid aGuid; - sal_uInt32 nId, nFlags; - rStrm >> aGuid >> nId >> nFlags; + sal_uInt32 nVersion, nFlags; + mrStrm >> aGuid >> nVersion >> nFlags; OSL_ENSURE( aGuid == BiffHelper::maGuidStdHlink, "BiffWorksheetFragment::importHyperlink - unexpected header GUID" ); - OSL_ENSURE( nId == 2, "BiffWorksheetFragment::importHyperlink - unexpected header identifier" ); - if( !(aGuid == BiffHelper::maGuidStdHlink) ) + OSL_ENSURE( nVersion == 2, "BiffWorksheetFragment::importHyperlink - unexpected header version" ); + if( !(aGuid == BiffHelper::maGuidStdHlink) || (nVersion != 2) ) return; // display string - if( getFlag( nFlags, BIFF_HYPERLINK_DISPLAY ) ) - aData.maDisplay = lclReadHyperlinkString( rStrm, getTextEncoding(), true ); - // target frame (ignore) !TODO: DISPLAY/FRAME - right order? (never seen them together) - if( getFlag( nFlags, BIFF_HYPERLINK_FRAME ) ) - lclSkipHyperlinkString( rStrm, true ); + if( getFlag( nFlags, OLE_HYPERLINK_HASDISPLAY ) ) + aData.maDisplay = readHyperlinkString( getTextEncoding(), true ); + // frame string + if( getFlag( nFlags, OLE_HYPERLINK_HASFRAME ) ) + aData.maFrame = readHyperlinkString( getTextEncoding(), true ); // target - if( getFlag( nFlags, BIFF_HYPERLINK_TARGET ) ) + if( getFlag( nFlags, OLE_HYPERLINK_HASTARGET ) ) { - if( getFlag( nFlags, BIFF_HYPERLINK_UNC ) ) + if( getFlag( nFlags, OLE_HYPERLINK_ASSTRING ) ) { - // UNC path - OSL_ENSURE( getFlag( nFlags, BIFF_HYPERLINK_ABS ), "BiffWorksheetFragment::importHyperlink - UNC link not absolute" ); - aData.maTarget = lclReadHyperlinkString( rStrm, getTextEncoding(), true ); + OSL_ENSURE( getFlag( nFlags, OLE_HYPERLINK_ABSOLUTE ), "BiffWorksheetFragment::importHyperlink - link not absolute" ); + aData.maTarget = readHyperlinkString( getTextEncoding(), true ); } - else + else // hyperlink moniker { - rStrm >> aGuid; + mrStrm >> aGuid; if( aGuid == BiffHelper::maGuidFileMoniker ) { // file name, maybe relative and with directory up-count sal_Int16 nUpLevels; - rStrm >> nUpLevels; - OSL_ENSURE( (nUpLevels == 0) || !getFlag( nFlags, BIFF_HYPERLINK_ABS ), "BiffWorksheetFragment::importHyperlink - absolute filename with upcount" ); - OUString aShortName = lclReadHyperlinkString( rStrm, getTextEncoding(), false ); - if( rStrm.skip( 24 ).readInt32() > 0 ) + mrStrm >> nUpLevels; + OSL_ENSURE( (nUpLevels == 0) || !getFlag( nFlags, OLE_HYPERLINK_ABSOLUTE ), "BiffWorksheetFragment::importHyperlink - absolute filename with upcount" ); + aData.maTarget = readHyperlinkString( getTextEncoding(), false ); + mrStrm.skip( 24 ); + sal_Int32 nBytes = mrStrm.readInt32(); + if( nBytes > 0 ) { - sal_Int32 nStrLen = rStrm.readInt32() / 2; // byte count to char count - rStrm.skip( 2 ); - aData.maTarget = lclReadHyperlinkString( rStrm, nStrLen, getTextEncoding(), true ); + sal_Int64 nEndPos = mrStrm.tell() + ::std::max< sal_Int32 >( nBytes, 0 ); + sal_uInt16 nChars = getLimitedValue< sal_uInt16, sal_Int32 >( mrStrm.readInt32() / 2, 0, SAL_MAX_UINT16 ); + mrStrm.skip( 2 ); // key value + aData.maTarget = mrStrm.readUnicodeArray( nChars ); // NOT null terminated + mrStrm.seek( nEndPos ); } - if( aData.maTarget.getLength() == 0 ) - aData.maTarget = aShortName; - if( !getFlag( nFlags, BIFF_HYPERLINK_ABS ) ) + if( !getFlag( nFlags, OLE_HYPERLINK_ABSOLUTE ) ) for( sal_Int16 nLevel = 0; nLevel < nUpLevels; ++nLevel ) aData.maTarget = CREATE_OUSTRING( "../" ) + aData.maTarget; } else if( aGuid == BiffHelper::maGuidUrlMoniker ) { // URL, maybe relative and with leading '../' - sal_Int32 nStrLen = rStrm.readInt32() / 2; // byte count to char count - aData.maTarget = lclReadHyperlinkString( rStrm, nStrLen, getTextEncoding(), true ); + sal_Int32 nBytes = mrStrm.readInt32(); + sal_Int64 nEndPos = mrStrm.tell() + ::std::max< sal_Int32 >( nBytes, 0 ); + aData.maTarget = mrStrm.readNulUnicodeArray(); + mrStrm.seek( nEndPos ); } else { - OSL_ENSURE( false, "BiffWorksheetFragment::importHyperlink - unknown content GUID" ); + OSL_ENSURE( false, "BiffWorksheetFragment::importHyperlink - unsupported hyperlink moniker" ); return; } } } // target location - if( getFlag( nFlags, BIFF_HYPERLINK_LOC ) ) - aData.maLocation = lclReadHyperlinkString( rStrm, getTextEncoding(), true ); - - OSL_ENSURE( rStrm.getRecLeft() == 0, "BiffWorksheetFragment::importHyperlink - unknown record data" ); + if( getFlag( nFlags, OLE_HYPERLINK_HASLOCATION ) ) + aData.maLocation = readHyperlinkString( getTextEncoding(), true ); // try to read the SCREENTIP record - if( (rStrm.getNextRecId() == BIFF_ID_SCREENTIP) && rStrm.startNextRecord() ) + if( (mrStrm.getNextRecId() == BIFF_ID_SCREENTIP) && mrStrm.startNextRecord() ) { - rStrm.skip( 2 ); // repeated record id + mrStrm.skip( 2 ); // repeated record id // the cell range, again - rStrm >> aBiffRange; + mrStrm >> aBiffRange; CellRangeAddress aRange; if( getAddressConverter().convertToCellRange( aRange, aBiffRange, getSheetIndex(), true ) && (aRange.StartColumn == aData.maRange.StartColumn) && @@ -1082,7 +1157,7 @@ void BiffWorksheetFragment::importHyperlink( BiffInputStream& rStrm ) { /* This time, we have no string length, no flag field, and a null-terminated 16-bit character array. */ - aData.maTooltip = rStrm.readUnicodeArray( static_cast< sal_uInt16 >( rStrm.getRecLeft() / 2 ) ); + aData.maTooltip = mrStrm.readNulUnicodeArray(); } } @@ -1090,47 +1165,47 @@ void BiffWorksheetFragment::importHyperlink( BiffInputStream& rStrm ) setHyperlink( aData ); } -void BiffWorksheetFragment::importLabelRanges( BiffInputStream& rStrm ) +void BiffWorksheetFragment::importLabelRanges() { BinRangeList aBiffRowRanges, aBiffColRanges; - rStrm >> aBiffRowRanges >> aBiffColRanges; + mrStrm >> aBiffRowRanges >> aBiffColRanges; ApiCellRangeList aColRanges, aRowRanges; getAddressConverter().convertToCellRangeList( aColRanges, aBiffColRanges, getSheetIndex(), true ); getAddressConverter().convertToCellRangeList( aRowRanges, aBiffRowRanges, getSheetIndex(), true ); setLabelRanges( aColRanges, aRowRanges ); } -void BiffWorksheetFragment::importMergedCells( BiffInputStream& rStrm ) +void BiffWorksheetFragment::importMergedCells() { BinRangeList aBiffRanges; - rStrm >> aBiffRanges; + mrStrm >> aBiffRanges; ApiCellRangeList aRanges; getAddressConverter().convertToCellRangeList( aRanges, aBiffRanges, getSheetIndex(), true ); for( ApiCellRangeList::const_iterator aIt = aRanges.begin(), aEnd = aRanges.end(); aIt != aEnd; ++aIt ) setMergedRange( *aIt ); } -void BiffWorksheetFragment::importPageBreaks( BiffInputStream& rStrm, bool bRowBreak ) +void BiffWorksheetFragment::importPageBreaks( bool bRowBreak ) { OoxPageBreakData aData; aData.mbManual = true; // only manual breaks stored in BIFF bool bBiff8 = getBiff() == BIFF8; // skip start/end columns or rows in BIFF8 sal_uInt16 nCount; - rStrm >> nCount; - for( sal_uInt16 nIndex = 0; rStrm.isValid() && (nIndex < nCount); ++nIndex ) + mrStrm >> nCount; + for( sal_uInt16 nIndex = 0; !mrStrm.isEof() && (nIndex < nCount); ++nIndex ) { - aData.mnColRow = rStrm.readuInt16(); + aData.mnColRow = mrStrm.readuInt16(); setPageBreak( aData, bRowBreak ); if( bBiff8 ) - rStrm.skip( 4 ); + mrStrm.skip( 4 ); } } -void BiffWorksheetFragment::importStandardWidth( BiffInputStream& rStrm ) +void BiffWorksheetFragment::importStandardWidth() { sal_uInt16 nWidth; - rStrm >> nWidth; + mrStrm >> nWidth; // width is stored as 1/256th of a character in BIFF, convert to entire character double fWidth = static_cast< double >( nWidth ) / 256.0; // set as default width, will override the width from DEFCOLWIDTH record diff --git a/oox/source/xls/worksheethelper.cxx b/oox/source/xls/worksheethelper.cxx index 7398272f949f..b9abf99d2413 100644 --- a/oox/source/xls/worksheethelper.cxx +++ b/oox/source/xls/worksheethelper.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: worksheethelper.cxx,v $ - * $Revision: 1.5 $ + * $Revision: 1.5.20.7 $ * * This file is part of OpenOffice.org. * @@ -29,6 +29,7 @@ ************************************************************************/ #include "oox/xls/worksheethelper.hxx" +#include <algorithm> #include <utility> #include <list> #include <rtl/ustrbuf.hxx> @@ -37,11 +38,16 @@ #include <com/sun/star/awt/Size.hpp> #include <com/sun/star/util/XMergeable.hpp> #include <com/sun/star/table/XColumnRowRange.hpp> +#include <com/sun/star/sheet/TableValidationVisibility.hpp> +#include <com/sun/star/sheet/ValidationType.hpp> +#include <com/sun/star/sheet/ValidationAlertStyle.hpp> #include <com/sun/star/sheet/XSpreadsheet.hpp> #include <com/sun/star/sheet/XSheetCellRangeContainer.hpp> +#include <com/sun/star/sheet/XSheetCondition.hpp> #include <com/sun/star/sheet/XCellAddressable.hpp> #include <com/sun/star/sheet/XCellRangeAddressable.hpp> #include <com/sun/star/sheet/XFormulaTokens.hpp> +#include <com/sun/star/sheet/XMultiFormulaTokens.hpp> #include <com/sun/star/sheet/XSheetOutline.hpp> #include <com/sun/star/sheet/XMultipleOperation.hpp> #include <com/sun/star/sheet/XLabelRanges.hpp> @@ -59,7 +65,6 @@ #include "oox/xls/sharedstringsbuffer.hxx" #include "oox/xls/stylesbuffer.hxx" #include "oox/xls/unitconverter.hxx" -#include "oox/xls/validationpropertyhelper.hxx" #include "oox/xls/viewsettings.hxx" #include "oox/xls/worksheetbuffer.hxx" #include "oox/xls/worksheetsettings.hxx" @@ -71,26 +76,32 @@ using ::com::sun::star::uno::Exception; using ::com::sun::star::uno::UNO_QUERY; using ::com::sun::star::uno::UNO_QUERY_THROW; using ::com::sun::star::lang::XMultiServiceFactory; +using ::com::sun::star::beans::XPropertySet; using ::com::sun::star::util::XMergeable; using ::com::sun::star::awt::Point; using ::com::sun::star::awt::Size; +using ::com::sun::star::table::BorderLine; using ::com::sun::star::table::CellAddress; using ::com::sun::star::table::CellRangeAddress; -using ::com::sun::star::table::BorderLine; +using ::com::sun::star::table::XCell; +using ::com::sun::star::table::XCellRange; using ::com::sun::star::table::XColumnRowRange; using ::com::sun::star::table::XTableColumns; using ::com::sun::star::table::XTableRows; -using ::com::sun::star::table::XCell; -using ::com::sun::star::table::XCellRange; -using ::com::sun::star::sheet::XSpreadsheet; -using ::com::sun::star::sheet::XSheetCellRanges; -using ::com::sun::star::sheet::XSheetCellRangeContainer; +using ::com::sun::star::sheet::ConditionOperator; +using ::com::sun::star::sheet::ValidationType; +using ::com::sun::star::sheet::ValidationAlertStyle; using ::com::sun::star::sheet::XCellAddressable; using ::com::sun::star::sheet::XCellRangeAddressable; using ::com::sun::star::sheet::XFormulaTokens; -using ::com::sun::star::sheet::XSheetOutline; -using ::com::sun::star::sheet::XMultipleOperation; using ::com::sun::star::sheet::XLabelRanges; +using ::com::sun::star::sheet::XMultiFormulaTokens; +using ::com::sun::star::sheet::XMultipleOperation; +using ::com::sun::star::sheet::XSheetCellRangeContainer; +using ::com::sun::star::sheet::XSheetCellRanges; +using ::com::sun::star::sheet::XSheetCondition; +using ::com::sun::star::sheet::XSheetOutline; +using ::com::sun::star::sheet::XSpreadsheet; using ::com::sun::star::text::XText; using ::com::sun::star::text::XTextContent; using ::com::sun::star::text::XTextRange; @@ -112,6 +123,78 @@ void lclUpdateProgressBar( ISegmentProgressBarRef xProgressBar, const CellRangeA } } +// ---------------------------------------------------------------------------- + +struct ValueRange +{ + sal_Int32 mnFirst; + sal_Int32 mnLast; + + inline explicit ValueRange( sal_Int32 nValue ) : mnFirst( nValue ), mnLast( nValue ) {} + inline explicit ValueRange( sal_Int32 nFirst, sal_Int32 nLast ) : mnFirst( nFirst ), mnLast( nLast ) {} +}; + +typedef ::std::vector< ValueRange > ValueRangeVector; + +// ---------------------------------------------------------------------------- + +struct ValueRangeComp +{ + inline bool operator()( const ValueRange& rRange, sal_Int32 nValue ) const { return rRange.mnLast < nValue; } +}; + +typedef ::std::vector< ValueRange > ValueRangeVector; + +// ---------------------------------------------------------------------------- + +class ValueRangeSet +{ +public: + inline explicit ValueRangeSet() {} + + void insert( sal_Int32 nValue ); + void intersect( ValueRangeVector& orRanges, sal_Int32 nFirst, sal_Int32 nLast ) const; + +private: + ValueRangeVector maData; +}; + +void ValueRangeSet::insert( sal_Int32 nValue ) +{ + // find the first range that contains nValue or that follows nValue + ValueRangeVector::iterator aBeg = maData.begin(); + ValueRangeVector::iterator aEnd = maData.end(); + ValueRangeVector::iterator aNext = ::std::lower_bound( aBeg, aEnd, nValue, ValueRangeComp() ); + + // nothing to do if found range contains nValue + if( (aNext == aEnd) || (nValue < aNext->mnFirst) ) + { + ValueRangeVector::iterator aPrev = (aNext == aBeg) ? aEnd : (aNext - 1); + bool bJoinPrev = (aPrev != aEnd) && (aPrev->mnLast + 1 == nValue); + bool bJoinNext = (aNext != aEnd) && (aNext->mnFirst - 1 == nValue); + if( bJoinPrev && bJoinNext ) + { + aPrev->mnLast = aNext->mnLast; + maData.erase( aNext ); + } + else if( bJoinPrev ) + ++aPrev->mnLast; + else if( bJoinNext ) + --aNext->mnFirst; + else + maData.insert( aNext, ValueRange( nValue ) ); + } +} + +void ValueRangeSet::intersect( ValueRangeVector& orRanges, sal_Int32 nFirst, sal_Int32 nLast ) const +{ + orRanges.clear(); + // find the range that contains nFirst or the first range that follows nFirst + ValueRangeVector::const_iterator aIt = ::std::lower_bound( maData.begin(), maData.end(), nFirst, ValueRangeComp() ); + for( ValueRangeVector::const_iterator aEnd = maData.end(); (aIt != aEnd) && (aIt->mnFirst <= nLast); ++aIt ) + orRanges.push_back( ValueRange( ::std::max( aIt->mnFirst, nFirst ), ::std::min( aIt->mnLast, nLast ) ) ); +} + } // namespace // ============================================================================ @@ -247,6 +330,23 @@ void OoxValidationData::setBinErrorStyle( sal_uInt8 nErrorStyle ) mnErrorStyle = STATIC_ARRAY_SELECT( spnErrorStyles, nErrorStyle, XML_stop ); } +// ---------------------------------------------------------------------------- + +OoxOleObjectData::OoxOleObjectData() : + mnAspect( XML_DVASPECT_CONTENT ), + mnUpdateMode( XML_OLEUPDATE_ALWAYS ), + mnShapeId( 0 ), + mbAutoLoad( false ) +{ +} + +// ---------------------------------------------------------------------------- + +OoxFormControlData::OoxFormControlData() : + mnShapeId( 0 ) +{ +} + // ============================================================================ // ============================================================================ @@ -326,6 +426,12 @@ public: void setValidation( const OoxValidationData& rValData ); /** Sets the path to the DrawingML fragment of this sheet. */ void setDrawingPath( const OUString& rDrawingPath ); + /** Sets the path to the legacy VML drawing fragment of this sheet. */ + void setVmlDrawingPath( const OUString& rVmlDrawingPath ); + /** Sets additional data for an OLE object. */ + void setOleObject( const OoxOleObjectData& rOleObjectData ); + /** Sets additional data for an OCX form control. */ + void setFormControl( const OoxFormControlData& rFormControlData ); /** Sets base width for all columns (without padding pixels). This value is only used, if base width has not been set with setDefaultColumnWidth(). */ @@ -356,11 +462,13 @@ public: void finalizeWorksheetImport(); private: - typedef ::std::vector< sal_Int32 > OutlineLevelVec; - typedef ::std::map< sal_Int32, OoxColumnData > OoxColumnDataMap; - typedef ::std::map< sal_Int32, OoxRowData > OoxRowDataMap; - typedef ::std::list< OoxHyperlinkData > OoxHyperlinkList; - typedef ::std::list< OoxValidationData > OoxValidationList; + typedef ::std::vector< sal_Int32 > OutlineLevelVec; + typedef ::std::map< sal_Int32, OoxColumnData > OoxColumnDataMap; + typedef ::std::map< sal_Int32, OoxRowData > OoxRowDataMap; + typedef ::std::list< OoxHyperlinkData > OoxHyperlinkList; + typedef ::std::list< OoxValidationData > OoxValidationList; + typedef ::std::map< sal_Int32, OoxOleObjectData > OoxOleObjectDataMap; + typedef ::std::map< sal_Int32, OoxFormControlData > OoxFormControlDataMap; struct XfIdRange { @@ -403,9 +511,9 @@ private: void finalizeValidationRanges() const; /** Merges all cached merged ranges and updates right/bottom cell borders. */ - void finalizeMergedRanges() const; + void finalizeMergedRanges(); /** Merges the passed merged range and updates right/bottom cell borders. */ - void finalizeMergedRange( const CellRangeAddress& rRange ) const; + void finalizeMergedRange( const CellRangeAddress& rRange ); /** Imports the drawing layer of the sheet. */ void finalizeDrawing(); @@ -437,10 +545,12 @@ private: const OUString maPositionProp; /// Property name for cell position. const OUString maSizeProp; /// Property name for cell size. const OUString maVisibleProp; /// Property name for column/row visibility. + const OUString maTextWrapProp; /// Property name for automatic text wrap in cells. const OUString maPageBreakProp; /// Property name of a page break. const OUString maUrlTextField; /// Service name for a URL text field. const OUString maUrlProp; /// Property name for the URL string in a URL text field. const OUString maReprProp; /// Property name for the URL representation in a URL text field. + const OUString maValidationProp; /// Property name for data validation settings. const CellAddress& mrMaxApiPos; /// Reference to maximum Calc cell address from address converter. CellRangeAddress maDimension; /// Dimension (used) area of the sheet. OoxColumnData maDefColData; /// Default column formatting. @@ -449,15 +559,19 @@ private: OoxRowDataMap maRowDatas; /// Row data sorted by row index. OoxHyperlinkList maHyperlinks; /// Cell ranges containing hyperlinks. OoxValidationList maValidations; /// Cell ranges containing data validation settings. + OoxOleObjectDataMap maOleObjects; /// OLE object data, mapped to VML shape identifier. + OoxFormControlDataMap maFormControls; /// OCX form control data, mapped to VML shape identifier. XfIdRangeMap maXfIdRanges; /// Collected XF identifiers for cell ranges. MergedRangeList maMergedRanges; /// Merged cell ranges. MergedRangeList maCenterFillRanges; /// Merged cell ranges from 'center across' or 'fill' alignment. + ValueRangeSet maManualRowHeights; /// Rows that need manual height independent from own settings. WorksheetSettings maSheetSett; /// Global settings for this sheet. SharedFormulaBuffer maSharedFmlas; /// Buffer for shared formulas in this sheet. CondFormatBuffer maCondFormats; /// Buffer for conditional formattings. PageSettings maPageSett; /// Page/print settings for this sheet. SheetViewSettings maSheetViewSett; /// View settings for this sheet. OUString maDrawingPath; /// Path to DrawingML fragment. + OUString maVmlDrawingPath; /// Path to legacy VML drawing fragment. ISegmentProgressBarRef mxProgressBar; /// Sheet progress bar. ISegmentProgressBarRef mxRowProgress; /// Progress bar for row/cell processing. ISegmentProgressBarRef mxFinalProgress; /// Progress bar for finalization. @@ -482,10 +596,12 @@ WorksheetData::WorksheetData( const WorkbookHelper& rHelper, ISegmentProgressBar maPositionProp( CREATE_OUSTRING( "Position" ) ), maSizeProp( CREATE_OUSTRING( "Size" ) ), maVisibleProp( CREATE_OUSTRING( "IsVisible" ) ), + maTextWrapProp( CREATE_OUSTRING( "IsTextWrapped" ) ), maPageBreakProp( CREATE_OUSTRING( "IsStartOfNewPage" ) ), maUrlTextField( CREATE_OUSTRING( "com.sun.star.text.TextField.URL" ) ), maUrlProp( CREATE_OUSTRING( "URL" ) ), maReprProp( CREATE_OUSTRING( "Representation" ) ), + maValidationProp( CREATE_OUSTRING( "Validation" ) ), mrMaxApiPos( rHelper.getAddressConverter().getMaxApiAddress() ), maSheetSett( *this ), maSharedFmlas( *this ), @@ -739,6 +855,23 @@ void WorksheetData::setDrawingPath( const OUString& rDrawingPath ) maDrawingPath = rDrawingPath; } +void WorksheetData::setVmlDrawingPath( const OUString& rVmlDrawingPath ) +{ + maVmlDrawingPath = rVmlDrawingPath; +} + +void WorksheetData::setOleObject( const OoxOleObjectData& rOleObjectData ) +{ + if( rOleObjectData.mnShapeId > 0 ) + maOleObjects[ rOleObjectData.mnShapeId ] = rOleObjectData; +} + +void WorksheetData::setFormControl( const OoxFormControlData& rFormControlData ) +{ + if( rFormControlData.mnShapeId > 0 ) + maFormControls[ rFormControlData.mnShapeId ] = rFormControlData; +} + void WorksheetData::setBaseColumnWidth( sal_Int32 nWidth ) { // do not modify width, if setDefaultColumnWidth() has been used @@ -838,6 +971,8 @@ void WorksheetData::initializeWorksheetImport() void WorksheetData::finalizeWorksheetImport() { + if( mxRowProgress.get() ) + mxRowProgress->setPosition( 1.0 ); finalizeXfIdRanges(); finalizeHyperlinkRanges(); finalizeValidationRanges(); @@ -848,6 +983,8 @@ void WorksheetData::finalizeWorksheetImport() convertColumns(); convertRows(); finalizeDrawing(); + if( mxFinalProgress.get() ) + mxFinalProgress->setPosition( 1.0 ); // reset current sheet index in global data setCurrentSheetIndex( -1 ); @@ -1000,47 +1137,137 @@ void WorksheetData::finalizeHyperlinkRanges() const void WorksheetData::finalizeHyperlink( const CellAddress& rAddress, const OUString& rUrl ) const { - Reference< XMultiServiceFactory > xFactory( getDocument(), UNO_QUERY ); Reference< XCell > xCell = getCell( rAddress ); - Reference< XText > xText( xCell, UNO_QUERY ); - // hyperlinks only supported in text cells - if( xFactory.is() && xCell.is() && (xCell->getType() == ::com::sun::star::table::CellContentType_TEXT) && xText.is() ) + if( xCell.is() ) switch( xCell->getType() ) { - // create a URL field object and set its properties - Reference< XTextContent > xUrlField( xFactory->createInstance( maUrlTextField ), UNO_QUERY ); - OSL_ENSURE( xUrlField.is(), "WorksheetData::finalizeHyperlink - cannot create text field" ); - if( xUrlField.is() ) + // #i54261# restrict creation of URL field to text cells + case ::com::sun::star::table::CellContentType_TEXT: { - // properties of the URL field - PropertySet aPropSet( xUrlField ); - aPropSet.setProperty( maUrlProp, rUrl ); - aPropSet.setProperty( maReprProp, xText->getString() ); - try + Reference< XMultiServiceFactory > xFactory( getDocument(), UNO_QUERY ); + Reference< XText > xText( xCell, UNO_QUERY ); + if( xFactory.is() && xText.is() ) { - // insert the field into the cell - xText->setString( OUString() ); - Reference< XTextRange > xRange( xText->createTextCursor(), UNO_QUERY_THROW ); - xText->insertTextContent( xRange, xUrlField, sal_False ); + // create a URL field object and set its properties + Reference< XTextContent > xUrlField( xFactory->createInstance( maUrlTextField ), UNO_QUERY ); + OSL_ENSURE( xUrlField.is(), "WorksheetData::finalizeHyperlink - cannot create text field" ); + if( xUrlField.is() ) + { + // properties of the URL field + PropertySet aPropSet( xUrlField ); + aPropSet.setProperty( maUrlProp, rUrl ); + aPropSet.setProperty( maReprProp, xText->getString() ); + try + { + // insert the field into the cell + xText->setString( OUString() ); + Reference< XTextRange > xRange( xText->createTextCursor(), UNO_QUERY_THROW ); + xText->insertTextContent( xRange, xUrlField, sal_False ); + } + catch( const Exception& ) + { + OSL_ENSURE( false, "WorksheetData::finalizeHyperlink - cannot insert text field" ); + } + } } - catch( const Exception& ) + } + break; + + // fix for #i31050# disabled, HYPERLINK is not able to return numeric value (#i91351#) +#if 0 + // #i31050# replace number with HYPERLINK function + case ::com::sun::star::table::CellContentType_VALUE: + { + Reference< XFormulaTokens > xTokens( xCell, UNO_QUERY ); + OSL_ENSURE( xTokens.is(), "WorksheetHelper::finalizeHyperlink - missing formula interface" ); + if( xTokens.is() ) { - OSL_ENSURE( false, "WorksheetData::finalizeHyperlink - cannot insert text field" ); + SimpleFormulaContext aContext( xTokens, false, false ); + getFormulaParser().convertNumberToHyperlink( aContext, rUrl, xCell->getValue() ); } } + break; +#endif + + default:; } } void WorksheetData::finalizeValidationRanges() const { - ValidationPropertyHelper& rPropHelper = getValidationPropertyHelper(); for( OoxValidationList::const_iterator aIt = maValidations.begin(), aEnd = maValidations.end(); aIt != aEnd; ++aIt ) { PropertySet aPropSet( getCellRangeList( aIt->maRanges ) ); - rPropHelper.writeValidationProperties( aPropSet, *aIt ); + + Reference< XPropertySet > xValidation; + if( aPropSet.getProperty( xValidation, maValidationProp ) && xValidation.is() ) + { + PropertySet aValProps( xValidation ); + namespace csss = ::com::sun::star::sheet; + + // convert validation type to API enum + ValidationType eType = csss::ValidationType_ANY; + switch( aIt->mnType ) + { + case XML_custom: eType = csss::ValidationType_CUSTOM; break; + case XML_date: eType = csss::ValidationType_DATE; break; + case XML_decimal: eType = csss::ValidationType_DECIMAL; break; + case XML_list: eType = csss::ValidationType_LIST; break; + case XML_none: eType = csss::ValidationType_ANY; break; + case XML_textLength: eType = csss::ValidationType_TEXT_LEN; break; + case XML_time: eType = csss::ValidationType_TIME; break; + case XML_whole: eType = csss::ValidationType_WHOLE; break; + default: OSL_ENSURE( false, "WorksheetData::finalizeValidationRanges - unknown validation type" ); + } + aValProps.setProperty( CREATE_OUSTRING( "Type" ), eType ); + + // convert error alert style to API enum + ValidationAlertStyle eAlertStyle = csss::ValidationAlertStyle_STOP; + switch( aIt->mnErrorStyle ) + { + case XML_information: eAlertStyle = csss::ValidationAlertStyle_INFO; break; + case XML_stop: eAlertStyle = csss::ValidationAlertStyle_STOP; break; + case XML_warning: eAlertStyle = csss::ValidationAlertStyle_WARNING; break; + default: OSL_ENSURE( false, "WorksheetData::finalizeValidationRanges - unknown error style" ); + } + aValProps.setProperty( CREATE_OUSTRING( "ErrorAlertStyle" ), eAlertStyle ); + + // convert dropdown style to API visibility constants + sal_Int16 nVisibility = aIt->mbNoDropDown ? csss::TableValidationVisibility::INVISIBLE : csss::TableValidationVisibility::UNSORTED; + aValProps.setProperty( CREATE_OUSTRING( "ShowList" ), nVisibility ); + + // messages + aValProps.setProperty( CREATE_OUSTRING( "ShowInputMessage" ), aIt->mbShowInputMsg ); + aValProps.setProperty( CREATE_OUSTRING( "InputTitle" ), aIt->maInputTitle ); + aValProps.setProperty( CREATE_OUSTRING( "InputMessage" ), aIt->maInputMessage ); + aValProps.setProperty( CREATE_OUSTRING( "ShowErrorMessage" ), aIt->mbShowErrorMsg ); + aValProps.setProperty( CREATE_OUSTRING( "ErrorTitle" ), aIt->maErrorTitle ); + aValProps.setProperty( CREATE_OUSTRING( "ErrorMessage" ), aIt->maErrorMessage ); + + // allow blank cells + aValProps.setProperty( CREATE_OUSTRING( "IgnoreBlankCells" ), aIt->mbAllowBlank ); + + try + { + // condition operator + Reference< XSheetCondition > xSheetCond( xValidation, UNO_QUERY_THROW ); + xSheetCond->setOperator( CondFormatBuffer::convertToApiOperator( aIt->mnOperator ) ); + + // condition formulas + Reference< XMultiFormulaTokens > xTokens( xValidation, UNO_QUERY_THROW ); + xTokens->setTokens( 0, aIt->maTokens1 ); + xTokens->setTokens( 1, aIt->maTokens2 ); + } + catch( Exception& ) + { + } + + // write back validation settings to cell range(s) + aPropSet.setProperty( maValidationProp, xValidation ); + } } } -void WorksheetData::finalizeMergedRanges() const +void WorksheetData::finalizeMergedRanges() { MergedRangeList::const_iterator aIt, aEnd; for( aIt = maMergedRanges.begin(), aEnd = maMergedRanges.end(); aIt != aEnd; ++aIt ) @@ -1049,7 +1276,7 @@ void WorksheetData::finalizeMergedRanges() const finalizeMergedRange( aIt->maRange ); } -void WorksheetData::finalizeMergedRange( const CellRangeAddress& rRange ) const +void WorksheetData::finalizeMergedRange( const CellRangeAddress& rRange ) { bool bMultiCol = rRange.StartColumn < rRange.EndColumn; bool bMultiRow = rRange.StartRow < rRange.EndRow; @@ -1061,24 +1288,41 @@ void WorksheetData::finalizeMergedRange( const CellRangeAddress& rRange ) const xMerge->merge( sal_True ); // if merging this range worked (no overlapping merged ranges), update cell borders - PropertySet aTopLeft( getCell( CellAddress( mnSheet, rRange.StartColumn, rRange.StartRow ) ) ); - - // copy right border of top-right cell to right border of top-left cell - if( bMultiCol ) + Reference< XCell > xTopLeft = getCell( CellAddress( mnSheet, rRange.StartColumn, rRange.StartRow ) ); + if( xTopLeft.is() ) { - PropertySet aTopRight( getCell( CellAddress( mnSheet, rRange.EndColumn, rRange.StartRow ) ) ); - BorderLine aLine; - if( aTopRight.getProperty( aLine, maRightBorderProp ) ) - aTopLeft.setProperty( maRightBorderProp, aLine ); - } + PropertySet aTopLeftProp( xTopLeft ); - // copy bottom border of bottom-left cell to bottom border of top-left cell - if( bMultiRow ) - { - PropertySet aBottomLeft( getCell( CellAddress( mnSheet, rRange.StartColumn, rRange.EndRow ) ) ); - BorderLine aLine; - if( aBottomLeft.getProperty( aLine, maBottomBorderProp ) ) - aTopLeft.setProperty( maBottomBorderProp, aLine ); + // copy right border of top-right cell to right border of top-left cell + if( bMultiCol ) + { + PropertySet aTopRightProp( getCell( CellAddress( mnSheet, rRange.EndColumn, rRange.StartRow ) ) ); + BorderLine aLine; + if( aTopRightProp.getProperty( aLine, maRightBorderProp ) ) + aTopLeftProp.setProperty( maRightBorderProp, aLine ); + } + + // copy bottom border of bottom-left cell to bottom border of top-left cell + if( bMultiRow ) + { + PropertySet aBottomLeftProp( getCell( CellAddress( mnSheet, rRange.StartColumn, rRange.EndRow ) ) ); + BorderLine aLine; + if( aBottomLeftProp.getProperty( aLine, maBottomBorderProp ) ) + aTopLeftProp.setProperty( maBottomBorderProp, aLine ); + } + + // #i93609# merged range in a single row: test if manual row height is needed + if( !bMultiRow ) + { + bool bTextWrap = aTopLeftProp.getBoolProperty( maTextWrapProp ); + if( !bTextWrap && (xTopLeft->getType() == ::com::sun::star::table::CellContentType_TEXT) ) + { + Reference< XText > xText( xTopLeft, UNO_QUERY ); + bTextWrap = xText.is() && (xText->getString().indexOf( '\x0A' ) >= 0); + } + if( bTextWrap ) + maManualRowHeights.insert( rRange.StartRow ); + } } } catch( Exception& ) @@ -1126,21 +1370,20 @@ void WorksheetData::convertColumns() void WorksheetData::convertColumns( OutlineLevelVec& orColLevels, sal_Int32 nFirstCol, sal_Int32 nLastCol, const OoxColumnData& rData ) { - Reference< XTableColumns > xColumns = getColumns( nFirstCol, nLastCol ); - if( xColumns.is() ) - { - PropertySet aPropSet( xColumns ); - // column width: convert 'number of characters' to column width in 1/100 mm - sal_Int32 nWidth = getUnitConverter().scaleToMm100( rData.mfWidth, UNIT_DIGIT ); - // macro sheets have double width - if( meSheetType == SHEETTYPE_MACROSHEET ) - nWidth *= 2; - if( nWidth > 0 ) - aPropSet.setProperty( maWidthProp, nWidth ); - // hidden columns: TODO: #108683# hide columns later? - if( rData.mbHidden ) - aPropSet.setProperty( maVisibleProp, false ); - } + PropertySet aPropSet( getColumns( nFirstCol, nLastCol ) ); + + // column width: convert 'number of characters' to column width in 1/100 mm + sal_Int32 nWidth = getUnitConverter().scaleToMm100( rData.mfWidth, UNIT_DIGIT ); + // macro sheets have double width + if( meSheetType == SHEETTYPE_MACROSHEET ) + nWidth *= 2; + if( nWidth > 0 ) + aPropSet.setProperty( maWidthProp, nWidth ); + + // hidden columns: TODO: #108683# hide columns later? + if( rData.mbHidden ) + aPropSet.setProperty( maVisibleProp, false ); + // outline settings for this column range convertOutlines( orColLevels, nFirstCol, rData.mnLevel, rData.mbCollapsed, false ); } @@ -1177,23 +1420,30 @@ void WorksheetData::convertRows() void WorksheetData::convertRows( OutlineLevelVec& orRowLevels, sal_Int32 nFirstRow, sal_Int32 nLastRow, const OoxRowData& rData, double fDefHeight ) { - Reference< XTableRows > xRows = getRows( nFirstRow, nLastRow ); - if( xRows.is() ) + // row height: convert points to row height in 1/100 mm + double fHeight = (rData.mfHeight >= 0.0) ? rData.mfHeight : fDefHeight; + sal_Int32 nHeight = getUnitConverter().scaleToMm100( fHeight, UNIT_POINT ); + if( nHeight > 0 ) { - PropertySet aPropSet( xRows ); - /* Row height: - - convert points to row height in 1/100 mm - - ignore rData.mbCustomHeight, Excel does not set optimal height - correctly, if a merged cell contains multi-line text. - */ - double fHeight = (rData.mfHeight >= 0.0) ? rData.mfHeight : fDefHeight; - sal_Int32 nHeight = getUnitConverter().scaleToMm100( fHeight, UNIT_POINT ); - if( nHeight > 0 ) + ValueRangeVector aManualRows; + if( rData.mbCustomHeight ) + aManualRows.push_back( ValueRange( nFirstRow, nLastRow ) ); + else + maManualRowHeights.intersect( aManualRows, nFirstRow, nLastRow ); + for( ValueRangeVector::const_iterator aIt = aManualRows.begin(), aEnd = aManualRows.end(); aIt != aEnd; ++aIt ) + { + PropertySet aPropSet( getRows( aIt->mnFirst, aIt->mnLast ) ); aPropSet.setProperty( maHeightProp, nHeight ); - // hidden rows: TODO: #108683# hide rows later? - if( rData.mbHidden ) - aPropSet.setProperty( maVisibleProp, false ); + } } + + // hidden rows: TODO: #108683# hide rows later? + if( rData.mbHidden ) + { + PropertySet aPropSet( getRows( nFirstRow, nLastRow ) ); + aPropSet.setProperty( maVisibleProp, false ); + } + // outline settings for this row range convertOutlines( orRowLevels, nFirstRow, rData.mnLevel, rData.mbCollapsed, true ); } @@ -1474,7 +1724,7 @@ void WorksheetHelper::setErrorCell( const Reference< XCell >& rxCell, const OUSt void WorksheetHelper::setErrorCell( const Reference< XCell >& rxCell, sal_uInt8 nErrorCode ) const { Reference< XFormulaTokens > xTokens( rxCell, UNO_QUERY ); - OSL_ENSURE( xTokens.is(), "WorksheetHelper::setErrorCell - missing cell interface" ); + OSL_ENSURE( xTokens.is(), "WorksheetHelper::setErrorCell - missing formula interface" ); if( xTokens.is() ) { SimpleFormulaContext aContext( xTokens, false, false ); @@ -1654,6 +1904,21 @@ void WorksheetHelper::setDrawingPath( const OUString& rDrawingPath ) mrSheetData.setDrawingPath( rDrawingPath ); } +void WorksheetHelper::setVmlDrawingPath( const OUString& rVmlDrawingPath ) +{ + mrSheetData.setVmlDrawingPath( rVmlDrawingPath ); +} + +void WorksheetHelper::setOleObject( const OoxOleObjectData& rOleObjectData ) +{ + mrSheetData.setOleObject( rOleObjectData ); +} + +void WorksheetHelper::setFormControl( const OoxFormControlData& rFormControlData ) +{ + mrSheetData.setFormControl( rFormControlData ); +} + void WorksheetHelper::setBaseColumnWidth( sal_Int32 nWidth ) { mrSheetData.setBaseColumnWidth( nWidth ); diff --git a/oox/source/xls/worksheetsettings.cxx b/oox/source/xls/worksheetsettings.cxx index 1965f97f19b2..6ab897565c69 100644 --- a/oox/source/xls/worksheetsettings.cxx +++ b/oox/source/xls/worksheetsettings.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: worksheetsettings.cxx,v $ - * $Revision: 1.5 $ + * $Revision: 1.5.4.1 $ * * This file is part of OpenOffice.org. * @@ -285,7 +285,8 @@ void WorksheetSettings::importPassword( BiffInputStream& rStrm ) void WorksheetSettings::importSheetProtection( BiffInputStream& rStrm ) { - sal_uInt16 nFlags = rStrm.skip( 19 ).readuInt16(); + rStrm.skip( 19 ); + sal_uInt16 nFlags = rStrm.readuInt16(); // set flag means protection is disabled maOoxProtData.mbObjects = !getFlag( nFlags, BIFF_SHEETPROT_OBJECTS ); maOoxProtData.mbScenarios = !getFlag( nFlags, BIFF_SHEETPROT_SCENARIOS ); diff --git a/oox/util/makefile.mk b/oox/util/makefile.mk index a60b40034cac..ff47635e1aa3 100644 --- a/oox/util/makefile.mk +++ b/oox/util/makefile.mk @@ -1,14 +1,14 @@ #************************************************************************* # # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# +# # Copyright 2008 by Sun Microsystems, Inc. # # OpenOffice.org - a multi-platform office productivity suite # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.8 $ +# $Revision: 1.8.4.1 $ # # This file is part of OpenOffice.org. # @@ -47,6 +47,7 @@ LIB1FILES= \ $(SLB)$/token.lib\ $(SLB)$/helper.lib\ $(SLB)$/core.lib\ + $(SLB)$/ole.lib\ $(SLB)$/ppt.lib\ $(SLB)$/xls.lib\ $(SLB)$/vml.lib\ |