1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef OOX_DUMP_XLSBDUMPER_HXX 25 #define OOX_DUMP_XLSBDUMPER_HXX 26 27 #include "oox/dump/dumperbase.hxx" 28 29 #if OOX_INCLUDE_DUMPER 30 31 namespace oox { namespace xls { 32 class FontPortionModelList; 33 class PhoneticPortionModelList; 34 struct FunctionInfo; 35 class FunctionProvider; 36 } } 37 38 namespace oox { 39 namespace dump { 40 namespace xlsb { 41 42 // ============================================================================ 43 44 class RecordObjectBase : public SequenceRecordObjectBase 45 { 46 protected: 47 explicit RecordObjectBase(); 48 virtual ~RecordObjectBase(); 49 50 using SequenceRecordObjectBase::construct; 51 void construct( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const ::rtl::OUString& rSysFileName ); 52 void construct( const RecordObjectBase& rParent ); 53 54 virtual bool implReadRecordHeader( BinaryInputStream& rBaseStrm, sal_Int64& ornRecId, sal_Int64& ornRecSize ); 55 56 ::rtl::OUString getErrorName( sal_uInt8 nErrCode ) const; 57 58 // ------------------------------------------------------------------------ 59 60 void readAddress( Address& orAddress ); 61 void readRange( Range& orRange ); 62 void readRangeList( RangeList& orRanges ); 63 64 // ------------------------------------------------------------------------ 65 66 void writeBooleanItem( const String& rName, sal_uInt8 nBool ); 67 void writeErrorCodeItem( const String& rName, sal_uInt8 nErrCode ); 68 69 void writeFontPortions( const ::oox::xls::FontPortionModelList& rPortions ); 70 void writePhoneticPortions( const ::oox::xls::PhoneticPortionModelList& rPhonetics ); 71 72 // ------------------------------------------------------------------------ 73 74 sal_uInt8 dumpBoolean( const String& rName = EMPTY_STRING ); 75 sal_uInt8 dumpErrorCode( const String& rName = EMPTY_STRING ); 76 ::rtl::OUString dumpString( const String& rName = EMPTY_STRING, bool bRich = false, bool b32BitLen = true ); 77 void dumpColor( const String& rName = EMPTY_STRING ); 78 ::com::sun::star::util::DateTime dumpPivotDateTime( const String& rName = EMPTY_STRING ); 79 80 sal_Int32 dumpColIndex( const String& rName = EMPTY_STRING ); 81 sal_Int32 dumpRowIndex( const String& rName = EMPTY_STRING ); 82 sal_Int32 dumpColRange( const String& rName = EMPTY_STRING ); 83 sal_Int32 dumpRowRange( const String& rName = EMPTY_STRING ); 84 85 Address dumpAddress( const String& rName = EMPTY_STRING ); 86 Range dumpRange( const String& rName = EMPTY_STRING ); 87 void dumpRangeList( const String& rName = EMPTY_STRING ); 88 89 // ------------------------------------------------------------------------ 90 private: 91 bool readCompressedInt( BinaryInputStream& rStrm, sal_Int32& ornValue ); 92 93 private: 94 typedef ::boost::shared_ptr< SequenceInputStream > SequenceInputStreamRef; 95 96 SequenceInputStreamRef mxBiffStrm; 97 NameListRef mxErrCodes; 98 }; 99 100 // ============================================================================ 101 102 class FormulaObject : public RecordObjectBase 103 { 104 public: 105 explicit FormulaObject( const RecordObjectBase& rParent ); 106 virtual ~FormulaObject(); 107 108 void dumpCellFormula( const String& rName = EMPTY_STRING ); 109 void dumpNameFormula( const String& rName = EMPTY_STRING ); 110 111 protected: 112 virtual void implDump(); 113 114 private: 115 void constructFmlaObj(); 116 117 void dumpFormula( const String& rName, bool bNameMode ); 118 119 TokenAddress createTokenAddress( sal_Int32 nCol, sal_Int32 nRow, bool bRelC, bool bRelR, bool bNameMode ) const; 120 ::rtl::OUString createRef( const ::rtl::OUString& rData ) const; 121 ::rtl::OUString createName( sal_Int32 nNameId ) const; 122 ::rtl::OUString createPlaceHolder( size_t nIdx ) const; 123 ::rtl::OUString createPlaceHolder() const; 124 125 ::rtl::OUString writeFuncIdItem( sal_uInt16 nFuncId, const ::oox::xls::FunctionInfo** oppFuncInfo = 0 ); 126 127 sal_Int32 dumpTokenCol( const String& rName, bool& rbRelC, bool& rbRelR ); 128 sal_Int32 dumpTokenRow( const String& rName ); 129 TokenAddress dumpTokenAddress( bool bNameMode ); 130 TokenRange dumpTokenRange( bool bNameMode ); 131 132 sal_Int16 readTokenRefId(); 133 ::rtl::OUString dumpTokenRefId(); 134 135 void dumpIntToken(); 136 void dumpDoubleToken(); 137 void dumpStringToken(); 138 void dumpBoolToken(); 139 void dumpErrorToken(); 140 void dumpMissArgToken(); 141 142 void dumpArrayToken( const ::rtl::OUString& rTokClass ); 143 void dumpNameToken( const ::rtl::OUString& rTokClass ); 144 void dumpNameXToken( const ::rtl::OUString& rTokClass ); 145 void dumpRefToken( const ::rtl::OUString& rTokClass, bool bNameMode ); 146 void dumpAreaToken( const ::rtl::OUString& rTokClass, bool bNameMode ); 147 void dumpRefErrToken( const ::rtl::OUString& rTokClass, bool bArea ); 148 void dumpRef3dToken( const ::rtl::OUString& rTokClass, bool bNameMode ); 149 void dumpArea3dToken( const ::rtl::OUString& rTokClass, bool bNameMode ); 150 void dumpRefErr3dToken( const ::rtl::OUString& rTokClass, bool bArea ); 151 void dumpMemFuncToken( const ::rtl::OUString& rTokClass ); 152 void dumpMemAreaToken( const ::rtl::OUString& rTokClass, bool bAddData ); 153 154 void dumpExpToken( const String& rName ); 155 void dumpUnaryOpToken( const String& rLOp, const String& rROp ); 156 void dumpBinaryOpToken( const String& rOp ); 157 void dumpFuncToken( const ::rtl::OUString& rTokClass ); 158 void dumpFuncVarToken( const ::rtl::OUString& rTokClass ); 159 bool dumpTableToken(); 160 bool dumpAttrToken(); 161 162 void dumpAddTokenData(); 163 void dumpAddDataExp( size_t nIdx ); 164 void dumpAddDataArray( size_t nIdx ); 165 void dumpAddDataMemArea( size_t nIdx ); 166 167 void dumpaddDataArrayHeader( sal_Int32& rnCols, sal_Int32& rnRows ); 168 ::rtl::OUString dumpaddDataArrayValue(); 169 170 private: 171 enum AddDataType { ADDDATA_EXP, ADDDATA_ARRAY, ADDDATA_MEMAREA }; 172 173 typedef ::boost::shared_ptr< FormulaStack > FormulaStackRef; 174 typedef ::boost::shared_ptr< ::oox::xls::FunctionProvider > FuncProvRef; 175 typedef ::std::vector< AddDataType > AddDataTypeVec; 176 177 NameListRef mxTokens; 178 NameListRef mxClasses; 179 NameListRef mxRelFlags; 180 NameListRef mxAttrTypes; 181 NameListRef mxSpTypes; 182 sal_Int32 mnColCount; 183 sal_Int32 mnRowCount; 184 185 FormulaStackRef mxStack; 186 FuncProvRef mxFuncProv; 187 AddDataTypeVec maAddData; 188 ::rtl::OUString maRefPrefix; 189 ::rtl::OUString maName; 190 sal_Int32 mnSize; 191 bool mbNameMode; 192 }; 193 194 // ============================================================================ 195 196 class RecordStreamObject : public RecordObjectBase 197 { 198 public: 199 explicit RecordStreamObject( ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const ::rtl::OUString& rSysFileName ); 200 201 protected: 202 virtual bool implIsValid() const; 203 virtual void implDumpRecordBody(); 204 205 private: 206 void dumpGradientHead(); 207 void dumpCellHeader( bool bWithColumn ); 208 209 private: 210 typedef ::boost::shared_ptr< FormulaObject > FormulaObjectRef; 211 212 FormulaObjectRef mxFmlaObj; 213 }; 214 215 // ============================================================================ 216 217 class RootStorageObject : public StorageObjectBase 218 { 219 public: 220 explicit RootStorageObject( const DumperBase& rParent ); 221 222 protected: 223 virtual void implDumpStream( 224 const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxStrm, 225 const ::rtl::OUString& rStrgPath, 226 const ::rtl::OUString& rStrmName, 227 const ::rtl::OUString& rSysFileName ); 228 }; 229 230 // ============================================================================ 231 232 class Dumper : public DumperBase 233 { 234 public: 235 explicit Dumper( const ::oox::core::FilterBase& rFilter ); 236 237 explicit Dumper( 238 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext, 239 const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStrm, 240 const ::rtl::OUString& rSysFileName ); 241 242 protected: 243 virtual void implDump(); 244 }; 245 246 // ============================================================================ 247 248 } // namespace xlsb 249 } // namespace dump 250 } // namespace oox 251 252 #endif 253 #endif 254 255