138d50f7bSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 338d50f7bSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 438d50f7bSAndrew Rist * or more contributor license agreements. See the NOTICE file 538d50f7bSAndrew Rist * distributed with this work for additional information 638d50f7bSAndrew Rist * regarding copyright ownership. The ASF licenses this file 738d50f7bSAndrew Rist * to you under the Apache License, Version 2.0 (the 838d50f7bSAndrew Rist * "License"); you may not use this file except in compliance 938d50f7bSAndrew Rist * with the License. You may obtain a copy of the License at 1038d50f7bSAndrew Rist * 1138d50f7bSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 1238d50f7bSAndrew Rist * 1338d50f7bSAndrew Rist * Unless required by applicable law or agreed to in writing, 1438d50f7bSAndrew Rist * software distributed under the License is distributed on an 1538d50f7bSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 1638d50f7bSAndrew Rist * KIND, either express or implied. See the License for the 1738d50f7bSAndrew Rist * specific language governing permissions and limitations 1838d50f7bSAndrew Rist * under the License. 1938d50f7bSAndrew Rist * 2038d50f7bSAndrew Rist *************************************************************/ 2138d50f7bSAndrew Rist 22cdf0e10cSrcweir #ifndef SC_XIPIVOT_HXX 23cdf0e10cSrcweir #define SC_XIPIVOT_HXX 24cdf0e10cSrcweir 25cdf0e10cSrcweir #include <list> 26cdf0e10cSrcweir #include "xlpivot.hxx" 27cdf0e10cSrcweir #include "xiroot.hxx" 28cdf0e10cSrcweir 29cdf0e10cSrcweir class ScDPSaveData; 30cdf0e10cSrcweir class ScDPSaveDimension; 31cdf0e10cSrcweir 32cdf0e10cSrcweir // ============================================================================ 33cdf0e10cSrcweir // Pivot cache 34cdf0e10cSrcweir // ============================================================================ 35cdf0e10cSrcweir 36cdf0e10cSrcweir /** Represents a data item in a pivot cache. */ 37cdf0e10cSrcweir class XclImpPCItem : public XclPCItem 38cdf0e10cSrcweir { 39cdf0e10cSrcweir public: 40cdf0e10cSrcweir explicit XclImpPCItem( XclImpStream& rStrm ); 41cdf0e10cSrcweir 42cdf0e10cSrcweir /** Inserts the item data into the passed document. */ 43cdf0e10cSrcweir void WriteToSource( const XclImpRoot& rRoot, const ScAddress& rScPos ) const; 44cdf0e10cSrcweir 45cdf0e10cSrcweir private: 46cdf0e10cSrcweir /** Reads an SXDOUBLE record describing a floating-point item. */ 47cdf0e10cSrcweir void ReadSxdouble( XclImpStream& rStrm ); 48cdf0e10cSrcweir /** Reads an SXBOOLEAN record describing a boolean item. */ 49cdf0e10cSrcweir void ReadSxboolean( XclImpStream& rStrm ); 50cdf0e10cSrcweir /** Reads an SXERROR record describing an error code item. */ 51cdf0e10cSrcweir void ReadSxerror( XclImpStream& rStrm ); 52cdf0e10cSrcweir /** Reads an SXINTEGER record describing an integer item. */ 53cdf0e10cSrcweir void ReadSxinteger( XclImpStream& rStrm ); 54cdf0e10cSrcweir /** Reads an SXSTRING record describing a text item. */ 55cdf0e10cSrcweir void ReadSxstring( XclImpStream& rStrm ); 56cdf0e10cSrcweir /** Reads an SXDATETIME record describing a date/time item. */ 57cdf0e10cSrcweir void ReadSxdatetime( XclImpStream& rStrm ); 58cdf0e10cSrcweir /** Reads an SXEMPTY record describing an empty item. */ 59cdf0e10cSrcweir void ReadSxempty( XclImpStream& rStrm ); 60cdf0e10cSrcweir }; 61cdf0e10cSrcweir 62cdf0e10cSrcweir typedef ScfRef< XclImpPCItem > XclImpPCItemRef; 63cdf0e10cSrcweir 64cdf0e10cSrcweir // ============================================================================ 65cdf0e10cSrcweir 66cdf0e10cSrcweir struct ScDPNumGroupInfo; 67cdf0e10cSrcweir class XclImpPivotCache; 68cdf0e10cSrcweir 69cdf0e10cSrcweir /** Represents a field in a pivot cache (a column of data items in the source area). */ 70cdf0e10cSrcweir class XclImpPCField : public XclPCField, protected XclImpRoot 71cdf0e10cSrcweir { 72cdf0e10cSrcweir public: 73cdf0e10cSrcweir /** Creates a pivot cache field by reading an SXFIELD record. */ 74cdf0e10cSrcweir explicit XclImpPCField( const XclImpRoot& rRoot, 75cdf0e10cSrcweir XclImpPivotCache& rPCache, sal_uInt16 nFieldIdx ); 76cdf0e10cSrcweir virtual ~XclImpPCField(); 77cdf0e10cSrcweir 78cdf0e10cSrcweir // general field/item access ---------------------------------------------- 79cdf0e10cSrcweir 80cdf0e10cSrcweir /** Returns the name of the field, uses the passed visible name if supported. */ 81cdf0e10cSrcweir const String& GetFieldName( const ScfStringVec& rVisNames ) const; 82cdf0e10cSrcweir 83cdf0e10cSrcweir /** Returns the base field if this is a grouping field. */ 84cdf0e10cSrcweir const XclImpPCField* GetGroupBaseField() const; 85cdf0e10cSrcweir 86cdf0e10cSrcweir /** Returns the number of items of this field. */ 87cdf0e10cSrcweir sal_uInt16 GetItemCount() const; 88cdf0e10cSrcweir /** Returns the item at the specified position or 0 on error. */ 89cdf0e10cSrcweir const XclImpPCItem* GetItem( sal_uInt16 nItemIdx ) const; 90cdf0e10cSrcweir /** Returns the item representing a limit value in numeric/date/time grouping fields. 91cdf0e10cSrcweir @param nItemIdx One of EXC_SXFIELD_INDEX_MIN, EXC_SXFIELD_INDEX_MAX, or EXC_SXFIELD_INDEX_STEP. */ 92cdf0e10cSrcweir const XclImpPCItem* GetLimitItem( sal_uInt16 nItemIdx ) const; 93cdf0e10cSrcweir 94cdf0e10cSrcweir /** Inserts the field name into the document. */ 95cdf0e10cSrcweir void WriteFieldNameToSource( SCCOL nScCol, SCTAB nScTab ) const; 96cdf0e10cSrcweir /** Inserts the specified item data into the document. */ 97cdf0e10cSrcweir void WriteOrigItemToSource( SCROW nScRow, SCTAB nScTab, sal_uInt16 nItemIdx ) const; 98cdf0e10cSrcweir /** Inserts the data of the last inserted item into the document. */ 99cdf0e10cSrcweir void WriteLastOrigItemToSource( SCROW nScRow, SCTAB nScTab ) const; 100cdf0e10cSrcweir 101cdf0e10cSrcweir // records ---------------------------------------------------------------- 102cdf0e10cSrcweir 103cdf0e10cSrcweir /** Reads the SXFIELD record describing the field. */ 104cdf0e10cSrcweir void ReadSxfield( XclImpStream& rStrm ); 105cdf0e10cSrcweir /** Reads an item data record describing a new item. */ 106cdf0e10cSrcweir void ReadItem( XclImpStream& rStrm ); 107cdf0e10cSrcweir /** Reads the SXNUMGROUP record describing numeric grouping fields. */ 108cdf0e10cSrcweir void ReadSxnumgroup( XclImpStream& rStrm ); 109cdf0e10cSrcweir /** Reads the SXGROUPINFO record describing the item order in grouping fields. */ 110cdf0e10cSrcweir void ReadSxgroupinfo( XclImpStream& rStrm ); 111cdf0e10cSrcweir 112cdf0e10cSrcweir // grouping --------------------------------------------------------------- 113cdf0e10cSrcweir 114cdf0e10cSrcweir /** Inserts grouping information of this field into the passed ScDPSaveData. */ 115cdf0e10cSrcweir void ConvertGroupField( ScDPSaveData& rSaveData, const ScfStringVec& rVisNames ) const; 116cdf0e10cSrcweir 117cdf0e10cSrcweir // ------------------------------------------------------------------------ 118cdf0e10cSrcweir private: 119cdf0e10cSrcweir /** Inserts standard grouping information of this field into the passed ScDPSaveData. */ 120cdf0e10cSrcweir void ConvertStdGroupField( ScDPSaveData& rSaveData, const ScfStringVec& rVisNames ) const; 121cdf0e10cSrcweir /** Inserts numeric grouping information of this field into the passed ScDPSaveData. */ 122cdf0e10cSrcweir void ConvertNumGroupField( ScDPSaveData& rSaveData, const ScfStringVec& rVisNames ) const; 123cdf0e10cSrcweir /** Inserts date grouping information of this field into the passed ScDPSaveData. */ 124cdf0e10cSrcweir void ConvertDateGroupField( ScDPSaveData& rSaveData, const ScfStringVec& rVisNames ) const; 125cdf0e10cSrcweir 126cdf0e10cSrcweir /** Returns a Calc struct with numeric grouping data. */ 127cdf0e10cSrcweir ScDPNumGroupInfo GetScNumGroupInfo() const; 128cdf0e10cSrcweir /** Returns a Calc struct with date grouping data. */ 129cdf0e10cSrcweir ScDPNumGroupInfo GetScDateGroupInfo() const; 130cdf0e10cSrcweir 131cdf0e10cSrcweir /** Returns a limit value for numeric grouping fields. */ 132cdf0e10cSrcweir const double* GetNumGroupLimit( sal_uInt16 nLimitIdx ) const; 133cdf0e10cSrcweir /** Returns a limit value for date grouping fields (minimum/maximum only). */ 134cdf0e10cSrcweir const DateTime* GetDateGroupLimit( sal_uInt16 nLimitIdx ) const; 135cdf0e10cSrcweir /** Returns the step value for date grouping fields. */ 136cdf0e10cSrcweir const sal_Int16* GetDateGroupStep() const; 137cdf0e10cSrcweir 138cdf0e10cSrcweir private: 139cdf0e10cSrcweir typedef ::std::vector< XclImpPCItemRef > XclImpPCItemVec; 140cdf0e10cSrcweir 141cdf0e10cSrcweir XclImpPivotCache& mrPCache; /// Parent pivot cache containing this field. 142cdf0e10cSrcweir XclImpPCItemVec maItems; /// List of all displayed data items. 143cdf0e10cSrcweir XclImpPCItemVec maOrigItems; /// List of all source data items. 144cdf0e10cSrcweir XclImpPCItemVec maNumGroupItems; /// List of items containing numeric grouping limits. 145cdf0e10cSrcweir mutable SCCOL mnSourceScCol; /// Column index of source data for this field. 146cdf0e10cSrcweir bool mbNumGroupInfoRead; /// true = Numeric grouping info read (SXNUMGROUP record). 147cdf0e10cSrcweir }; 148cdf0e10cSrcweir 149cdf0e10cSrcweir typedef ScfRef< XclImpPCField > XclImpPCFieldRef; 150cdf0e10cSrcweir 151cdf0e10cSrcweir // ============================================================================ 152cdf0e10cSrcweir 153cdf0e10cSrcweir class XclImpPivotCache : protected XclImpRoot 154cdf0e10cSrcweir { 155cdf0e10cSrcweir public: 156cdf0e10cSrcweir explicit XclImpPivotCache( const XclImpRoot& rRoot ); 157cdf0e10cSrcweir virtual ~XclImpPivotCache(); 158cdf0e10cSrcweir 159cdf0e10cSrcweir // data access ------------------------------------------------------------ 160cdf0e10cSrcweir 161cdf0e10cSrcweir /** Returns the data source range read from the DCONREF record. */ GetSourceRange() const162cdf0e10cSrcweir inline const ScRange& GetSourceRange() const { return maSrcRange; } 163cdf0e10cSrcweir 164cdf0e10cSrcweir /** Returns the number of pivot cache fields. */ 165cdf0e10cSrcweir sal_uInt16 GetFieldCount() const; 166cdf0e10cSrcweir /** Returns read-only access to a pivot cache field. */ 167cdf0e10cSrcweir const XclImpPCField* GetField( sal_uInt16 nFieldIdx ) const; 168cdf0e10cSrcweir 169cdf0e10cSrcweir // records ---------------------------------------------------------------- 170cdf0e10cSrcweir 171cdf0e10cSrcweir /** Reads an SXIDSTM record containing a pivot cache stream identifier and the pivot cache. */ 172cdf0e10cSrcweir void ReadSxidstm( XclImpStream& rStrm ); 173cdf0e10cSrcweir /** Reads an SXVS record containing the source type of the pivot cache. */ 174cdf0e10cSrcweir void ReadSxvs( XclImpStream& rStrm ); 175cdf0e10cSrcweir /** Reads a DCONREF record containing the source range of the pivot cache. */ 176cdf0e10cSrcweir void ReadDconref( XclImpStream& rStrm ); 177cdf0e10cSrcweir /** Reads the entire pivot cache stream. Uses decrypter from passed stream. */ 178cdf0e10cSrcweir void ReadPivotCacheStream( XclImpStream& rStrm ); 179cdf0e10cSrcweir 180cdf0e10cSrcweir bool IsRefreshOnLoad() const; 181cdf0e10cSrcweir 182cdf0e10cSrcweir private: 183cdf0e10cSrcweir typedef ::std::vector< XclImpPCFieldRef > XclImpPCFieldVec; 184cdf0e10cSrcweir 185cdf0e10cSrcweir XclPCInfo maPCInfo; /// Pivot cache settings (SXDB record). 186cdf0e10cSrcweir XclImpPCFieldVec maFields; /// List of pivot cache fields. 187cdf0e10cSrcweir ScRange maSrcRange; /// Source range in the spreadsheet. 188cdf0e10cSrcweir String maUrl; /// URL of the source data. 189cdf0e10cSrcweir String maTabName; /// Sheet name of the source data. 190cdf0e10cSrcweir sal_uInt16 mnStrmId; /// Pivot cache stream identifier. 191cdf0e10cSrcweir sal_uInt16 mnSrcType; /// Source data type. 192cdf0e10cSrcweir bool mbSelfRef; /// true = Source data from own document. 193cdf0e10cSrcweir }; 194cdf0e10cSrcweir 195cdf0e10cSrcweir typedef ScfRef< XclImpPivotCache > XclImpPivotCacheRef; 196cdf0e10cSrcweir 197cdf0e10cSrcweir // ============================================================================ 198cdf0e10cSrcweir // Pivot table 199cdf0e10cSrcweir // ============================================================================ 200cdf0e10cSrcweir 201cdf0e10cSrcweir class XclImpPivotTable; 202*fd04a84dSJianyuan Li class XclImpPTField; 203cdf0e10cSrcweir 204cdf0e10cSrcweir // ============================================================================ 205cdf0e10cSrcweir 206cdf0e10cSrcweir class XclImpPTItem 207cdf0e10cSrcweir { 208cdf0e10cSrcweir public: 209*fd04a84dSJianyuan Li explicit XclImpPTItem( const XclImpPTField & ); 210cdf0e10cSrcweir 211cdf0e10cSrcweir /** Returns the internal name of the item or 0, if no name could be found. */ 212cdf0e10cSrcweir const String* GetItemName() const; 213cdf0e10cSrcweir /** Returns the displayed name of the item or 0, if no name could be found. */ 214cdf0e10cSrcweir const String* GetVisItemName() const; 215cdf0e10cSrcweir 216cdf0e10cSrcweir /** Reads an SXVI record containing data of this item. */ 217cdf0e10cSrcweir void ReadSxvi( XclImpStream& rStrm ); 218cdf0e10cSrcweir 219cdf0e10cSrcweir /** Inserts this item into the passed ScDPSaveDimension. */ 220cdf0e10cSrcweir void ConvertItem( ScDPSaveDimension& rSaveDim ) const; 221cdf0e10cSrcweir 222cdf0e10cSrcweir private: 223cdf0e10cSrcweir XclPTItemInfo maItemInfo; /// General data for this item. 224*fd04a84dSJianyuan Li //const XclImpPCField* mpCacheField; /// Corresponding pivot cache field. 225*fd04a84dSJianyuan Li const XclImpPTField & mrPTField; 226cdf0e10cSrcweir }; 227cdf0e10cSrcweir 228cdf0e10cSrcweir typedef ScfRef< XclImpPTItem > XclImpPTItemRef; 229cdf0e10cSrcweir 230cdf0e10cSrcweir // ============================================================================ 231cdf0e10cSrcweir 232cdf0e10cSrcweir class XclImpPTField 233cdf0e10cSrcweir { 234cdf0e10cSrcweir public: 235cdf0e10cSrcweir explicit XclImpPTField( const XclImpPivotTable& rPTable, sal_uInt16 nCacheIdx ); 236cdf0e10cSrcweir 237cdf0e10cSrcweir // general field/item access ---------------------------------------------- 238cdf0e10cSrcweir 239cdf0e10cSrcweir /** Returns the corresponding pivot cache field of this field. */ 240cdf0e10cSrcweir const XclImpPCField* GetCacheField() const; 241cdf0e10cSrcweir /** Returns the name of this field that is used to create the Calc dimensions. */ 242cdf0e10cSrcweir const String& GetFieldName() const; 243cdf0e10cSrcweir /** Returns the internally set visible name of this field. */ 244cdf0e10cSrcweir const String& GetVisFieldName() const; 245cdf0e10cSrcweir 246cdf0e10cSrcweir /** Returns the specified item. */ 247cdf0e10cSrcweir const XclImpPTItem* GetItem( sal_uInt16 nItemIdx ) const; 248cdf0e10cSrcweir /** Returns the internal name of the specified item. */ 249cdf0e10cSrcweir const String* GetItemName( sal_uInt16 nItemIdx ) const; 250cdf0e10cSrcweir /** Returns the displayed name of the specified item. */ 251cdf0e10cSrcweir const String* GetVisItemName( sal_uInt16 nItemIdx ) const; 252cdf0e10cSrcweir 253cdf0e10cSrcweir /** Returns the flags of the axes this field is part of. */ GetAxes() const254cdf0e10cSrcweir inline sal_uInt16 GetAxes() const { return maFieldInfo.mnAxes; } 255cdf0e10cSrcweir /** Sets the flags of the axes this field is part of. */ SetAxes(sal_uInt16 nAxes)256cdf0e10cSrcweir inline void SetAxes( sal_uInt16 nAxes ) { maFieldInfo.mnAxes = nAxes; } 257cdf0e10cSrcweir 258cdf0e10cSrcweir // records ---------------------------------------------------------------- 259cdf0e10cSrcweir 260cdf0e10cSrcweir /** Reads an SXVD record describing the field. */ 261cdf0e10cSrcweir void ReadSxvd( XclImpStream& rStrm ); 262cdf0e10cSrcweir /** Reads an SXVDEX record describing extended options of the field. */ 263cdf0e10cSrcweir void ReadSxvdex( XclImpStream& rStrm ); 264cdf0e10cSrcweir /** Reads an SXVI record describing a new item of this field. */ 265cdf0e10cSrcweir void ReadSxvi( XclImpStream& rStrm ); 266cdf0e10cSrcweir 267cdf0e10cSrcweir // row/column fields ------------------------------------------------------ 268cdf0e10cSrcweir 269cdf0e10cSrcweir void ConvertRowColField( ScDPSaveData& rSaveData ) const; 270cdf0e10cSrcweir 271cdf0e10cSrcweir // page fields ------------------------------------------------------------ 272cdf0e10cSrcweir 273cdf0e10cSrcweir void SetPageFieldInfo( const XclPTPageFieldInfo& rPageInfo ); 274cdf0e10cSrcweir void ConvertPageField( ScDPSaveData& rSaveData ) const; 275cdf0e10cSrcweir 276cdf0e10cSrcweir // hidden fields ---------------------------------------------------------- 277cdf0e10cSrcweir 278cdf0e10cSrcweir void ConvertHiddenField( ScDPSaveData& rSaveData ) const; 279cdf0e10cSrcweir 280cdf0e10cSrcweir // data fields ------------------------------------------------------------ 281cdf0e10cSrcweir 282cdf0e10cSrcweir bool HasDataFieldInfo() const; 283cdf0e10cSrcweir void AddDataFieldInfo( const XclPTDataFieldInfo& rDataInfo ); 284cdf0e10cSrcweir void ConvertDataField( ScDPSaveData& rSaveData ) const; 285cdf0e10cSrcweir 286cdf0e10cSrcweir // ------------------------------------------------------------------------ 287cdf0e10cSrcweir private: 288cdf0e10cSrcweir ScDPSaveDimension* ConvertRCPField( ScDPSaveData& rSaveData ) const; 289cdf0e10cSrcweir void ConvertFieldInfo( ScDPSaveDimension& rSaveDim ) const; 290cdf0e10cSrcweir 291cdf0e10cSrcweir void ConvertDataField( ScDPSaveDimension& rSaveDim, const XclPTDataFieldInfo& rDataInfo ) const; 292cdf0e10cSrcweir void ConvertDataFieldInfo( ScDPSaveDimension& rSaveDim, const XclPTDataFieldInfo& rDataInfo ) const; 293cdf0e10cSrcweir void ConvertItems( ScDPSaveDimension& rSaveDim ) const; 294cdf0e10cSrcweir 295cdf0e10cSrcweir private: 296cdf0e10cSrcweir typedef ::std::list< XclPTDataFieldInfo > XclPTDataFieldInfoList; 297cdf0e10cSrcweir typedef ::std::vector< XclImpPTItemRef > XclImpPTItemVec; 298cdf0e10cSrcweir 299cdf0e10cSrcweir const XclImpPivotTable& mrPTable; /// Parent pivot table containing this field. 300cdf0e10cSrcweir XclPTFieldInfo maFieldInfo; /// General field info (SXVD record). 301cdf0e10cSrcweir XclPTFieldExtInfo maFieldExtInfo; /// Extended field info (SXVDEX record). 302cdf0e10cSrcweir XclPTPageFieldInfo maPageInfo; /// Page field info (entry from SXPI record). 303cdf0e10cSrcweir XclPTDataFieldInfoList maDataInfoList; /// List of extended data field info (SXDI records). 304cdf0e10cSrcweir XclImpPTItemVec maItems; /// List of all items of this field. 305cdf0e10cSrcweir }; 306cdf0e10cSrcweir 307cdf0e10cSrcweir typedef ScfRef< XclImpPTField > XclImpPTFieldRef; 308cdf0e10cSrcweir 309cdf0e10cSrcweir // ============================================================================ 310cdf0e10cSrcweir 311cdf0e10cSrcweir class XclImpPivotTable : protected XclImpRoot 312cdf0e10cSrcweir { 313cdf0e10cSrcweir public: 314cdf0e10cSrcweir explicit XclImpPivotTable( const XclImpRoot& rRoot ); 315cdf0e10cSrcweir virtual ~XclImpPivotTable(); 316cdf0e10cSrcweir 317cdf0e10cSrcweir // cache/field access, misc. ---------------------------------------------- 318cdf0e10cSrcweir GetPivotCache() const319cdf0e10cSrcweir inline XclImpPivotCacheRef GetPivotCache() const { return mxPCache; } GetVisFieldNames() const320cdf0e10cSrcweir inline const ScfStringVec& GetVisFieldNames() const { return maVisFieldNames; } 321cdf0e10cSrcweir 322cdf0e10cSrcweir sal_uInt16 GetFieldCount() const; 323cdf0e10cSrcweir const XclImpPTField* GetField( sal_uInt16 nFieldIdx ) const; 324cdf0e10cSrcweir XclImpPTField* GetFieldAcc( sal_uInt16 nFieldIdx ); 325cdf0e10cSrcweir const String& GetFieldName( sal_uInt16 nFieldIdx ) const; 326cdf0e10cSrcweir 327cdf0e10cSrcweir const XclImpPTField* GetDataField( sal_uInt16 nDataFieldIdx ) const; 328cdf0e10cSrcweir const String& GetDataFieldName( sal_uInt16 nDataFieldIdx ) const; 329cdf0e10cSrcweir 330cdf0e10cSrcweir // records ---------------------------------------------------------------- 331cdf0e10cSrcweir 332cdf0e10cSrcweir /** Reads an SXVIEW record starting a new pivot table. */ 333cdf0e10cSrcweir void ReadSxview( XclImpStream& rStrm ); 334cdf0e10cSrcweir /** Reads an SXVD record describing a new field. */ 335cdf0e10cSrcweir void ReadSxvd( XclImpStream& rStrm ); 336cdf0e10cSrcweir /** Reads an SXVI record describing a new item of the current field. */ 337cdf0e10cSrcweir void ReadSxvi( XclImpStream& rStrm ); 338cdf0e10cSrcweir /** Reads an SXVDEX record describing extended options of the current field. */ 339cdf0e10cSrcweir void ReadSxvdex( XclImpStream& rStrm ); 340cdf0e10cSrcweir /** Reads an SXIVD record containing the row field or column field order. */ 341cdf0e10cSrcweir void ReadSxivd( XclImpStream& rStrm ); 342cdf0e10cSrcweir /** Reads an SXPI record containing page field data. */ 343cdf0e10cSrcweir void ReadSxpi( XclImpStream& rStrm ); 344cdf0e10cSrcweir /** Reads an SXDI record containing data field data. */ 345cdf0e10cSrcweir void ReadSxdi( XclImpStream& rStrm ); 346cdf0e10cSrcweir /** Reads an SXEX record containing additional settings for the pivot table. */ 347cdf0e10cSrcweir void ReadSxex( XclImpStream& rStrm ); 348cdf0e10cSrcweir /** Reads an SXVIEWEX9 record that specifies the pivot tables 349cdf0e10cSrcweir * autoformat. */ 350cdf0e10cSrcweir void ReadSxViewEx9( XclImpStream& rStrm ); 351cdf0e10cSrcweir 352cdf0e10cSrcweir // ------------------------------------------------------------------------ 353cdf0e10cSrcweir 354cdf0e10cSrcweir /** Inserts the pivot table into the Calc document. */ 355cdf0e10cSrcweir void Convert(); 356cdf0e10cSrcweir 357cdf0e10cSrcweir void MaybeRefresh(); 358cdf0e10cSrcweir 359cdf0e10cSrcweir void ApplyMergeFlags(const ScRange& rOutRange, const ScDPSaveData& rSaveData); 360cdf0e10cSrcweir GetCacheId() const36196ad0767SWang Lei sal_uInt16 GetCacheId() const { return maPTInfo.mnCacheIdx; }; 36296ad0767SWang Lei 363cdf0e10cSrcweir // ------------------------------------------------------------------------ 364cdf0e10cSrcweir private: 365cdf0e10cSrcweir typedef ::std::vector< XclImpPTFieldRef > XclImpPTFieldVec; 366cdf0e10cSrcweir 367cdf0e10cSrcweir XclImpPivotCacheRef mxPCache; /// Pivot cache containing field/item names. 368cdf0e10cSrcweir 369cdf0e10cSrcweir XclPTInfo maPTInfo; /// General info about the pivot table (SXVIEW record). 370cdf0e10cSrcweir XclPTExtInfo maPTExtInfo; /// Extended info about the pivot table (SXEX record). 371cdf0e10cSrcweir XclPTViewEx9Info maPTViewEx9Info; /// (SXVIEWEX9 record) 372cdf0e10cSrcweir XclImpPTFieldVec maFields; /// Vector containing all fields. 373cdf0e10cSrcweir XclImpPTFieldRef mxCurrField; /// Current field for importing additional info. 374cdf0e10cSrcweir ScfStringVec maVisFieldNames; /// Vector containing all visible field names. 375cdf0e10cSrcweir ScfUInt16Vec maRowFields; /// Row field indexes. 376cdf0e10cSrcweir ScfUInt16Vec maColFields; /// Column field indexes. 377cdf0e10cSrcweir ScfUInt16Vec maPageFields; /// Page field indexes. 378cdf0e10cSrcweir ScfUInt16Vec maOrigDataFields; /// Original data field indexes. 379cdf0e10cSrcweir ScfUInt16Vec maFiltDataFields; /// Filtered data field indexes. 380cdf0e10cSrcweir XclImpPTField maDataOrientField; /// Special data field orientation field. 381cdf0e10cSrcweir ScRange maOutScRange; /// Output range in the Calc document. 382cdf0e10cSrcweir ScDPObject* mpDPObj; 383cdf0e10cSrcweir }; 384cdf0e10cSrcweir 385cdf0e10cSrcweir typedef ScfRef< XclImpPivotTable > XclImpPivotTableRef; 386cdf0e10cSrcweir 387cdf0e10cSrcweir // ============================================================================ 388cdf0e10cSrcweir // ============================================================================ 389cdf0e10cSrcweir 390cdf0e10cSrcweir /** The main class for pivot table import. 391cdf0e10cSrcweir 392cdf0e10cSrcweir This class contains functions to read all records related to pivot tables 393cdf0e10cSrcweir and pivot caches. 394cdf0e10cSrcweir */ 395cdf0e10cSrcweir class XclImpPivotTableManager : protected XclImpRoot 396cdf0e10cSrcweir { 397cdf0e10cSrcweir public: 398cdf0e10cSrcweir explicit XclImpPivotTableManager( const XclImpRoot& rRoot ); 399cdf0e10cSrcweir virtual ~XclImpPivotTableManager(); 400cdf0e10cSrcweir 401cdf0e10cSrcweir // pivot cache records ---------------------------------------------------- 402cdf0e10cSrcweir 403cdf0e10cSrcweir /** Returns the pivot cache with the specified 0-based index. */ 404cdf0e10cSrcweir XclImpPivotCacheRef GetPivotCache( sal_uInt16 nCacheIdx ); 405cdf0e10cSrcweir 406cdf0e10cSrcweir /** Reads an SXIDSTM record containing a pivot cache stream identifier and the pivot cache. */ 407cdf0e10cSrcweir void ReadSxidstm( XclImpStream& rStrm ); 408cdf0e10cSrcweir /** Reads an SXVS record containing the source type of a pivot cache. */ 409cdf0e10cSrcweir void ReadSxvs( XclImpStream& rStrm ); 410cdf0e10cSrcweir /** Reads a DCONREF record containing the source range of a pivot cache. */ 411cdf0e10cSrcweir void ReadDconref( XclImpStream& rStrm ); 412cdf0e10cSrcweir 413cdf0e10cSrcweir // pivot table records ---------------------------------------------------- 414cdf0e10cSrcweir 415cdf0e10cSrcweir /** Reads an SXVIEW record describing a new pivot table. */ 416cdf0e10cSrcweir void ReadSxview( XclImpStream& rStrm ); 417cdf0e10cSrcweir /** Reads an SXVD record describing a new field. */ 418cdf0e10cSrcweir void ReadSxvd( XclImpStream& rStrm ); 419cdf0e10cSrcweir /** Reads an SXVDEX record describing extended options of a field. */ 420cdf0e10cSrcweir void ReadSxvdex( XclImpStream& rStrm ); 421cdf0e10cSrcweir /** Reads an SXIVD record containing the row field or column field order. */ 422cdf0e10cSrcweir void ReadSxivd( XclImpStream& rStrm ); 423cdf0e10cSrcweir /** Reads an SXPI record containing page field data. */ 424cdf0e10cSrcweir void ReadSxpi( XclImpStream& rStrm ); 425cdf0e10cSrcweir /** Reads an SXDI record containing data field data. */ 426cdf0e10cSrcweir void ReadSxdi( XclImpStream& rStrm ); 427cdf0e10cSrcweir /** Reads an SXVI record describing a new item of the current field. */ 428cdf0e10cSrcweir void ReadSxvi( XclImpStream& rStrm ); 429cdf0e10cSrcweir /** Reads an SXEX record containing additional settings for a pivot table. */ 430cdf0e10cSrcweir void ReadSxex( XclImpStream& rStrm ); 431cdf0e10cSrcweir /** Reads an SXVIEWEX9 record that specifies the pivot tables 432cdf0e10cSrcweir * autoformat. */ 433cdf0e10cSrcweir void ReadSxViewEx9( XclImpStream& rStrm ); 434cdf0e10cSrcweir 435cdf0e10cSrcweir // ------------------------------------------------------------------------ 436cdf0e10cSrcweir 437cdf0e10cSrcweir /** Reads all used pivot caches and creates additional sheets for external data sources. */ 43896ad0767SWang Lei // void ReadPivotCaches( XclImpStream& rStrm ); 439cdf0e10cSrcweir /** Inserts all pivot tables into the Calc document. */ 44096ad0767SWang Lei // void ConvertPivotTables(); 44196ad0767SWang Lei void ConvertPivotTables( XclImpStream & ); 44296ad0767SWang Lei // void MaybeRefreshPivotTables(); 443cdf0e10cSrcweir 444cdf0e10cSrcweir private: 445cdf0e10cSrcweir typedef ::std::vector< XclImpPivotCacheRef > XclImpPivotCacheVec; 446cdf0e10cSrcweir typedef ::std::vector< XclImpPivotTableRef > XclImpPivotTableVec; 447cdf0e10cSrcweir 448cdf0e10cSrcweir XclImpPivotCacheVec maPCaches; /// List of all pivot caches. 449cdf0e10cSrcweir XclImpPivotTableVec maPTables; /// List of all pivot tables. 450cdf0e10cSrcweir }; 451cdf0e10cSrcweir 452cdf0e10cSrcweir // ============================================================================ 453cdf0e10cSrcweir 454cdf0e10cSrcweir #endif 455cdf0e10cSrcweir 456