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_XLS_PIVOTCACHEBUFFER_HXX 25 #define OOX_XLS_PIVOTCACHEBUFFER_HXX 26 27 #include <com/sun/star/table/CellAddress.hpp> 28 #include <com/sun/star/table/CellRangeAddress.hpp> 29 #include <com/sun/star/util/DateTime.hpp> 30 #include "oox/helper/containerhelper.hxx" 31 #include "oox/helper/refvector.hxx" 32 #include "oox/xls/workbookhelper.hxx" 33 34 namespace com { namespace sun { namespace star { 35 namespace sheet { class XDataPilotField; } 36 } } } 37 38 namespace oox { namespace core { class Relations; } } 39 40 namespace oox { 41 namespace xls { 42 43 class WorksheetHelper; 44 45 // ============================================================================ 46 47 class PivotCacheItem 48 { 49 public: 50 explicit PivotCacheItem(); 51 52 /** Reads the string value from a pivot cache item. */ 53 void readString( const AttributeList& rAttribs ); 54 /** Reads the double value from a pivot cache item. */ 55 void readNumeric( const AttributeList& rAttribs ); 56 /** Reads the date/time value from a pivot cache item. */ 57 void readDate( const AttributeList& rAttribs ); 58 /** Reads the boolean value from a pivot cache item. */ 59 void readBool( const AttributeList& rAttribs ); 60 /** Reads the error code value from a pivot cache item. */ 61 void readError( const AttributeList& rAttribs, const UnitConverter& rUnitConverter ); 62 /** Reads the index of a shared item. */ 63 void readIndex( const AttributeList& rAttribs ); 64 65 /** Reads the string value from a pivot cache item. */ 66 void readString( SequenceInputStream& rStrm ); 67 /** Reads the double value from a pivot cache item. */ 68 void readDouble( SequenceInputStream& rStrm ); 69 /** Reads the date/time value from a pivot cache item. */ 70 void readDate( SequenceInputStream& rStrm ); 71 /** Reads the boolean value from a pivot cache item. */ 72 void readBool( SequenceInputStream& rStrm ); 73 /** Reads the error code value from a pivot cache item. */ 74 void readError( SequenceInputStream& rStrm ); 75 /** Reads the index of a shared item. */ 76 void readIndex( SequenceInputStream& rStrm ); 77 78 /** Reads the string value from a pivot cache item. */ 79 void readString( BiffInputStream& rStrm, const WorkbookHelper& rHelper ); 80 /** Reads the double value from a pivot cache item. */ 81 void readDouble( BiffInputStream& rStrm ); 82 /** Reads the integer value from a pivot cache item. */ 83 void readInteger( BiffInputStream& rStrm ); 84 /** Reads the date/time value from a pivot cache item. */ 85 void readDate( BiffInputStream& rStrm ); 86 /** Reads the boolean value from a pivot cache item. */ 87 void readBool( BiffInputStream& rStrm ); 88 /** Reads the error code value from a pivot cache item. */ 89 void readError( BiffInputStream& rStrm ); 90 91 /** Returns the type of the item. */ getType() const92 inline sal_Int32 getType() const { return mnType; } 93 /** Returns the value of the item. */ getValue() const94 inline const ::com::sun::star::uno::Any& getValue() const { return maValue; } 95 /** Returns the string representation of the item. */ 96 ::rtl::OUString getName() const; 97 98 private: 99 ::com::sun::star::uno::Any maValue; /// Value of the item. 100 sal_Int32 mnType; /// Value type (OOXML token identifier). 101 }; 102 103 // ---------------------------------------------------------------------------- 104 105 class PivotCacheItemList : public WorkbookHelper 106 { 107 public: 108 explicit PivotCacheItemList( const WorkbookHelper& rHelper ); 109 110 /** Imports the item from the passed attribute list. */ 111 void importItem( sal_Int32 nElement, const AttributeList& rAttribs ); 112 /** Imports the item from the passed stream and record. */ 113 void importItem( sal_Int32 nRecId, SequenceInputStream& rStrm ); 114 /** Imports a complete item list from the passed stream. */ 115 void importItemList( BiffInputStream& rStrm, sal_uInt16 nCount ); 116 117 /** Returns true, if this item list is empty. */ empty() const118 inline bool empty() const { return maItems.empty(); } 119 /** Returns the size of the item list. */ size() const120 inline size_t size() const { return maItems.size(); } 121 122 /** Returns the specified item. */ 123 const PivotCacheItem* getCacheItem( sal_Int32 nItemIdx ) const; 124 /** Returns the names of all items. */ 125 void getCacheItemNames( ::std::vector< ::rtl::OUString >& orItemNames ) const; 126 127 private: 128 /** Creates and returns a new item at the end of the items list. */ 129 PivotCacheItem& createItem(); 130 /** Imports an array of items from the PCITEM_ARRAY record */ 131 void importArray( SequenceInputStream& rStrm ); 132 133 private: 134 typedef ::std::vector< PivotCacheItem > CacheItemVector; 135 CacheItemVector maItems; /// All items of this list. 136 }; 137 138 // ============================================================================ 139 140 struct PCFieldModel 141 { 142 ::rtl::OUString maName; /// Fixed name of the cache field. 143 ::rtl::OUString maCaption; /// Caption of the ccahe field. 144 ::rtl::OUString maPropertyName; /// OLAP property name. 145 ::rtl::OUString maFormula; /// Formula of a calculated field. 146 sal_Int32 mnNumFmtId; /// Number format for all items. 147 sal_Int32 mnSqlType; /// Data type from ODBC data source. 148 sal_Int32 mnHierarchy; /// Hierarchy this field is part of. 149 sal_Int32 mnLevel; /// Hierarchy level this field is part of. 150 sal_Int32 mnMappingCount; /// Number of property mappings. 151 bool mbDatabaseField; /// True = field from source data; false = calculated field. 152 bool mbServerField; /// True = ODBC server-based page field. 153 bool mbUniqueList; /// True = list of unique ODBC items exists. 154 bool mbMemberPropField; /// True = contains OLAP member properties. 155 156 explicit PCFieldModel(); 157 }; 158 159 // ---------------------------------------------------------------------------- 160 161 struct PCSharedItemsModel 162 { 163 bool mbHasSemiMixed; /// True = has (blank|string|bool|error) item(s), maybe other types. 164 bool mbHasNonDate; /// True = has non-date item(s), maybe date items. 165 bool mbHasDate; /// True = has date item(s), maybe other types. 166 bool mbHasString; /// True = has (string|bool|error) item(s), maybe other types. 167 bool mbHasBlank; /// True = has blank item(s), maybe other types. 168 bool mbHasMixed; /// True = has [(string|bool|error) and (number|date)] or (number and date). 169 bool mbIsNumeric; /// True = has numeric item(s), maybe other types except date. 170 bool mbIsInteger; /// True = has numeric item(s) with only integers, maybe other types except date. 171 bool mbHasLongText; /// True = contains strings with >255 charascters. 172 bool mbHasLongIndexes; /// True = indexes to shared items are 16-bit (BIFF only). 173 174 explicit PCSharedItemsModel(); 175 }; 176 177 // ---------------------------------------------------------------------------- 178 179 struct PCFieldGroupModel 180 { 181 ::com::sun::star::util::DateTime maStartDate; /// Manual or calculated start date for range grouping. 182 ::com::sun::star::util::DateTime maEndDate; /// Manual or calculated end date for range grouping. 183 double mfStartValue; /// Manual or calculated start value for range grouping. 184 double mfEndValue; /// Manual or calculated end value for range grouping. 185 double mfInterval; /// Interval for numeric range grouping. 186 sal_Int32 mnParentField; /// Index of cache field that contains item groups based on this field. 187 sal_Int32 mnBaseField; /// Index of cache field this grouped field is based on. 188 sal_Int32 mnGroupBy; /// Type of numeric or date range grouping. 189 bool mbRangeGroup; /// True = items are grouped by numeric ranges or date ranges. 190 bool mbDateGroup; /// True = items are grouped by date ranges or by item names. 191 bool mbAutoStart; /// True = start value for range groups is calculated from source data. 192 bool mbAutoEnd; /// True = end value for range groups is calculated from source data. 193 194 explicit PCFieldGroupModel(); 195 196 /** Sets the group-by value for BIFF import. */ 197 void setBiffGroupBy( sal_uInt8 nGroupBy ); 198 }; 199 200 // ---------------------------------------------------------------------------- 201 202 /** Helper struct for mapping original item names from/to group item names. */ 203 struct PivotCacheGroupItem 204 { 205 ::rtl::OUString maOrigName; 206 ::rtl::OUString maGroupName; 207 PivotCacheGroupItemoox::xls::PivotCacheGroupItem208 inline explicit PivotCacheGroupItem( const ::rtl::OUString& rItemName ) : 209 maOrigName( rItemName ), maGroupName( rItemName ) {} 210 }; 211 212 typedef ::std::vector< PivotCacheGroupItem > PivotCacheGroupItemVector; 213 214 // ---------------------------------------------------------------------------- 215 216 class PivotCacheField : public WorkbookHelper 217 { 218 public: 219 explicit PivotCacheField( const WorkbookHelper& rHelper, bool bIsDatabaseField ); 220 221 /** Imports pivot cache field settings from the cacheField element. */ 222 void importCacheField( const AttributeList& rAttribs ); 223 /** Imports shared items settings from the sharedItems element. */ 224 void importSharedItems( const AttributeList& rAttribs ); 225 /** Imports a shared item from the passed element. */ 226 void importSharedItem( sal_Int32 nElement, const AttributeList& rAttribs ); 227 /** Imports grouping settings from the fieldGroup element. */ 228 void importFieldGroup( const AttributeList& rAttribs ); 229 /** Imports numeric grouping settings from the rangePr element. */ 230 void importRangePr( const AttributeList& rAttribs ); 231 /** Imports an item of the mapping between group items and base items from the passed element. */ 232 void importDiscretePrItem( sal_Int32 nElement, const AttributeList& rAttribs ); 233 /** Imports a group item from the passed element. */ 234 void importGroupItem( sal_Int32 nElement, const AttributeList& rAttribs ); 235 236 /** Imports pivot cache field settings from the PCDFIELD record. */ 237 void importPCDField( SequenceInputStream& rStrm ); 238 /** Imports shared items settings from the PCDFSHAREDITEMS record. */ 239 void importPCDFSharedItems( SequenceInputStream& rStrm ); 240 /** Imports one or more shared items from the passed record. */ 241 void importPCDFSharedItem( sal_Int32 nRecId, SequenceInputStream& rStrm ); 242 /** Imports grouping settings from the PCDFIELDGROUP record. */ 243 void importPCDFieldGroup( SequenceInputStream& rStrm ); 244 /** Imports numeric grouping settings from the PCDFRANGEPR record. */ 245 void importPCDFRangePr( SequenceInputStream& rStrm ); 246 /** Imports an item of the mapping between group items and base items from the passed record. */ 247 void importPCDFDiscretePrItem( sal_Int32 nRecId, SequenceInputStream& rStrm ); 248 /** Imports one or more group items from the passed record. */ 249 void importPCDFGroupItem( sal_Int32 nRecId, SequenceInputStream& rStrm ); 250 251 /** Imports pivot cache field settings from the PCDFIELD record. */ 252 void importPCDField( BiffInputStream& rStrm ); 253 /** Imports numeric grouping settings from the PCDFRANGEPR record. */ 254 void importPCDFRangePr( BiffInputStream& rStrm ); 255 /** Imports the mapping between group items and base items from the PCDFDISCRETEPR record. */ 256 void importPCDFDiscretePr( BiffInputStream& rStrm ); 257 258 /** Returns true, if the field is based on source data, or false if it is grouped or calculated. */ isDatabaseField() const259 inline bool isDatabaseField() const { return maFieldModel.mbDatabaseField; } 260 261 /** Returns true, if the field contains a list of shared items. */ hasSharedItems() const262 inline bool hasSharedItems() const { return !maSharedItems.empty(); } 263 /** Returns true, if the field contains a list of grouping items. */ hasGroupItems() const264 inline bool hasGroupItems() const { return !maGroupItems.empty(); } 265 /** Returns true, if the field has inplace numeric grouping settings. */ hasNumericGrouping() const266 inline bool hasNumericGrouping() const { return maFieldGroupModel.mbRangeGroup && !maFieldGroupModel.mbDateGroup; } 267 /** Returns true, if the field has inplace date grouping settings. */ hasDateGrouping() const268 inline bool hasDateGrouping() const { return maFieldGroupModel.mbRangeGroup && maFieldGroupModel.mbDateGroup; } 269 /** Returns true, if the field has a parent group field that groups the items of this field. */ hasParentGrouping() const270 inline bool hasParentGrouping() const { return maFieldGroupModel.mnParentField >= 0; } 271 272 /** Returns the name of the cache field. */ getName() const273 inline const ::rtl::OUString& getName() const { return maFieldModel.maName; } 274 /** Returns the index of the parent group field that groups the items of this field. */ getParentGroupField() const275 inline sal_Int32 getParentGroupField() const { return maFieldGroupModel.mnParentField; } 276 /** Returns the index of the base field grouping is based on. */ getGroupBaseField() const277 inline sal_Int32 getGroupBaseField() const { return maFieldGroupModel.mnBaseField; } 278 279 /** Returns the shared or group item with the specified index. */ 280 const PivotCacheItem* getCacheItem( sal_Int32 nItemIdx ) const; 281 /** Returns the names of all shared or group items. */ 282 void getCacheItemNames( ::std::vector< ::rtl::OUString >& orItemNames ) const; 283 284 /** Creates inplace numeric grouping settings. */ 285 void convertNumericGrouping( 286 const ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XDataPilotField >& rxDPField ) const; 287 /** Creates inplace date grouping settings or a new date group field. */ 288 ::rtl::OUString createDateGroupField( 289 const ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XDataPilotField >& rxBaseDPField ) const; 290 /** Creates a new grouped DataPilot field and returns its name. */ 291 ::rtl::OUString createParentGroupField( 292 const ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XDataPilotField >& rxBaseDPField, 293 PivotCacheGroupItemVector& orItemNames ) const; 294 295 /** Writes the title of the field into the passed sheet at the passed address. */ 296 void writeSourceHeaderCell( WorksheetHelper& rSheetHelper, 297 sal_Int32 nCol, sal_Int32 nRow ) const; 298 /** Writes a source field item value into the passed sheet. */ 299 void writeSourceDataCell( WorksheetHelper& rSheetHelper, 300 sal_Int32 nCol, sal_Int32 nRow, 301 const PivotCacheItem& rItem ) const; 302 303 /** Reads an item from the PCRECORD record and writes it to the passed sheet. */ 304 void importPCRecordItem( SequenceInputStream& rStrm, 305 WorksheetHelper& rSheetHelper, sal_Int32 nCol, sal_Int32 nRow ) const; 306 /** Reads an item index from the PCITEM_INDEXLIST record and writes the item to the passed sheet. */ 307 void importPCItemIndex( BiffInputStream& rStrm, 308 WorksheetHelper& rSheetHelper, sal_Int32 nCol, sal_Int32 nRow ) const; 309 310 311 private: 312 /** Tries to write the passed value to the passed sheet position. */ 313 void writeItemToSourceDataCell( WorksheetHelper& rSheetHelper, 314 sal_Int32 nCol, sal_Int32 nRow, const PivotCacheItem& rItem ) const; 315 /** Tries to write the value of a shared item to the passed sheet position. */ 316 void writeSharedItemToSourceDataCell( WorksheetHelper& rSheetHelper, 317 sal_Int32 nCol, sal_Int32 nRow, sal_Int32 nItemIdx ) const; 318 319 private: 320 typedef ::std::vector< sal_Int32 > IndexVector; 321 322 PivotCacheItemList maSharedItems; /// All shared items of this field. 323 PivotCacheItemList maGroupItems; /// All group items of this field. 324 IndexVector maDiscreteItems; /// Mapping between group and base items. 325 PCFieldModel maFieldModel; /// Settings for this cache field. 326 PCSharedItemsModel maSharedItemsModel; /// Settings for shared items. 327 PCFieldGroupModel maFieldGroupModel; /// Settings for item grouping. 328 }; 329 330 // ============================================================================ 331 332 struct PCDefinitionModel 333 { 334 ::rtl::OUString maRelId; /// Relation identifier for cache records fragment. 335 ::rtl::OUString maRefreshedBy; /// Name of user who last refreshed the cache. 336 double mfRefreshedDate; /// Date/time of last refresh. 337 sal_Int32 mnRecords; /// Number of data records in the cache. 338 sal_Int32 mnMissItemsLimit; /// Limit for discarding unused items. 339 sal_uInt16 mnDatabaseFields; /// Number of database (source data) fields (BIFF only). 340 bool mbInvalid; /// True = cache needs refresh. 341 bool mbSaveData; /// True = cached item values are present. 342 bool mbRefreshOnLoad; /// True = try to refresh cache on load. 343 bool mbOptimizeMemory; /// True = application may optimize memory usage. 344 bool mbEnableRefresh; /// True = refreshing cache is enabled in UI. 345 bool mbBackgroundQuery; /// True = application queries data asynchonously. 346 bool mbUpgradeOnRefresh; /// True = application may upgrade cache version. 347 bool mbTupleCache; /// True = cache stores OLAP functions. 348 bool mbSupportSubquery; /// True = data source supports subqueries. 349 bool mbSupportDrill; /// True = data source supports drilldown. 350 351 explicit PCDefinitionModel(); 352 }; 353 354 // ---------------------------------------------------------------------------- 355 356 struct PCSourceModel 357 { 358 sal_Int32 mnSourceType; /// Type of the source data (sheet, consolidation, scenario, external). 359 sal_Int32 mnConnectionId; /// Connection identifier for external data source. 360 361 explicit PCSourceModel(); 362 }; 363 364 // ---------------------------------------------------------------------------- 365 366 struct PCWorksheetSourceModel 367 { 368 ::rtl::OUString maRelId; /// Relation identifier for an external document URL. 369 ::rtl::OUString maSheet; /// Sheet name for cell range or sheet-local defined names. 370 ::rtl::OUString maDefName; /// Defined name containing a cell range if present. 371 ::com::sun::star::table::CellRangeAddress 372 maRange; /// Source cell range of the data. 373 374 explicit PCWorksheetSourceModel(); 375 }; 376 377 // ---------------------------------------------------------------------------- 378 379 class PivotCache : public WorkbookHelper 380 { 381 public: 382 explicit PivotCache( const WorkbookHelper& rHelper ); 383 384 /** Reads pivot cache global settings from the pivotCacheDefinition element. */ 385 void importPivotCacheDefinition( const AttributeList& rAttribs ); 386 /** Reads cache source settings from the cacheSource element. */ 387 void importCacheSource( const AttributeList& rAttribs ); 388 /** Reads sheet source settings from the worksheetSource element. */ 389 void importWorksheetSource( const AttributeList& rAttribs, const ::oox::core::Relations& rRelations ); 390 391 /** Reads pivot cache global settings from the PCDEFINITION record. */ 392 void importPCDefinition( SequenceInputStream& rStrm ); 393 /** Reads cache source settings from the PCDSOURCE record. */ 394 void importPCDSource( SequenceInputStream& rStrm ); 395 /** Reads sheet source settings from the PCDSHEETSOURCE record. */ 396 void importPCDSheetSource( SequenceInputStream& rStrm, const ::oox::core::Relations& rRelations ); 397 398 /** Reads cache source settings from the PCDSOURCE record. */ 399 void importPCDSource( BiffInputStream& rStrm ); 400 /** Reads pivot cache global settings from the PCDEFINITION record. */ 401 void importPCDefinition( BiffInputStream& rStrm ); 402 403 /** Creates and returns a new pivot cache field. */ 404 PivotCacheField& createCacheField( bool bInitDatabaseField = false ); 405 /** Checks validity of source data and creates a dummy data sheet for external sheet sources. */ 406 void finalizeImport(); 407 408 /** Returns true, if the pivot cache is based on a valid data source, so 409 that pivot tables can be created based on this pivot cache. */ isValidDataSource() const410 inline bool isValidDataSource() const { return mbValidSource; } 411 /** Returns true, if the pivot cache is based on a dummy sheet created in finalizeImport. */ isBasedOnDummySheet() const412 inline bool isBasedOnDummySheet() const { return mbDummySheet; } 413 /** Returns the internal cell range the cache is based on. */ 414 inline const ::com::sun::star::table::CellRangeAddress& getSourceRange() const415 getSourceRange() const { return maSheetSrcModel.maRange; } 416 /** Returns the relation identifier of the pivot cache records fragment. */ getRecordsRelId() const417 inline const ::rtl::OUString& getRecordsRelId() const { return maDefModel.maRelId; } 418 419 /** Returns the number of pivot cache fields. */ 420 sal_Int32 getCacheFieldCount() const; 421 /** Returns the cache field with the specified index. */ 422 const PivotCacheField* getCacheField( sal_Int32 nFieldIdx ) const; 423 /** Returns the source column index of the field with the passed index. */ 424 sal_Int32 getCacheDatabaseIndex( sal_Int32 nFieldIdx ) const; 425 426 /** Writes the titles of all source fields into the passed sheet. */ 427 void writeSourceHeaderCells( WorksheetHelper& rSheetHelper ) const; 428 /** Writes a source field item value into the passed sheet. */ 429 void writeSourceDataCell( WorksheetHelper& rSheetHelper, 430 sal_Int32 nColIdx, sal_Int32 nRowIdx, 431 const PivotCacheItem& rItem ) const; 432 433 /** Reads a PCRECORD record and writes all item values to the passed sheet. */ 434 void importPCRecord( SequenceInputStream& rStrm, 435 WorksheetHelper& rSheetHelper, sal_Int32 nRowIdx ) const; 436 /** Reads a PCITEM_INDEXLIST record and writes all item values to the passed sheet. */ 437 void importPCItemIndexList( BiffInputStream& rStrm, 438 WorksheetHelper& rSheetHelper, sal_Int32 nRowIdx ) const; 439 440 private: 441 /** Reads the worksheet source range from the DCONREF record. */ 442 void importDConRef( BiffInputStream& rStrm ); 443 /** Reads the defined name used for source data from the DCONNAME record. */ 444 void importDConName( BiffInputStream& rStrm ); 445 /** Reads the built-in defined name used for source data from the DCONBINAME record. */ 446 void importDConBIName( BiffInputStream& rStrm ); 447 /** Reads the sheet name and URL from the DCONREF, DCONNAME, or DCONBINAME records. */ 448 void importDConUrl( BiffInputStream& rStrm ); 449 450 /** Finalizes the pivot cache if it is based on internal sheet data. */ 451 void finalizeInternalSheetSource(); 452 /** Finalizes the pivot cache if it is based on sheet data of an external spreadsheet document. */ 453 void finalizeExternalSheetSource(); 454 /** Creates a dummy sheet that will be filled with the pivot cache data. */ 455 void prepareSourceDataSheet(); 456 /** Checks, if the row index has changed since last call, and initializes the sheet data buffer. */ 457 void updateSourceDataRow( WorksheetHelper& rSheetHelper, sal_Int32 nRow ) const; 458 459 private: 460 typedef RefVector< PivotCacheField > PivotCacheFieldVector; 461 typedef ::std::vector< sal_Int32 > IndexVector; 462 463 PivotCacheFieldVector maFields; /// All pivot cache fields. 464 PivotCacheFieldVector maDatabaseFields; /// All cache fields that are based on source data. 465 IndexVector maDatabaseIndexes; /// Database field index for all fields. 466 PCDefinitionModel maDefModel; /// Global pivot cache settings. 467 PCSourceModel maSourceModel; /// Pivot cache source settings. 468 PCWorksheetSourceModel maSheetSrcModel; /// Sheet source data if cache type is sheet. 469 ValueRangeSet maColSpans; /// Column spans used by SheetDataBuffer for optimized cell import. 470 ::rtl::OUString maTargetUrl; /// URL of an external source document. 471 mutable sal_Int32 mnCurrRow; /// Current row index in dummy sheet. 472 bool mbValidSource; /// True = pivot cache is based on supported data source. 473 bool mbDummySheet; /// True = pivot cache is based on a dummy sheet. 474 }; 475 476 // ============================================================================ 477 478 class PivotCacheBuffer : public WorkbookHelper 479 { 480 public: 481 explicit PivotCacheBuffer( const WorkbookHelper& rHelper ); 482 483 /** Registers a pivot cache definition fragment. The fragment will be loaded on demand (OOXML/BIFF12 only). */ 484 void registerPivotCacheFragment( sal_Int32 nCacheId, const ::rtl::OUString& rFragmentPath ); 485 /** Reads the reference to a pivot cache stream. The stream will be loaded on demand (BIFF2-BIFF8 only). */ 486 void importPivotCacheRef( BiffInputStream& rStrm ); 487 488 /** Imports and stores a pivot cache definition fragment on first call, 489 returns the imported cache on subsequent calls with the same identifier. */ 490 PivotCache* importPivotCacheFragment( sal_Int32 nCacheId ); 491 492 private: 493 /** Creates and returns a new pivot cache object with the passed identifier. */ 494 PivotCache& createPivotCache( sal_Int32 nCacheId ); 495 496 private: 497 typedef ::std::map< sal_Int32, ::rtl::OUString > FragmentPathMap; 498 typedef RefMap< sal_Int32, PivotCache > PivotCacheMap; 499 typedef ::std::vector< sal_Int32 > PivotCacheIdVector; 500 501 FragmentPathMap maFragmentPaths; 502 PivotCacheMap maCaches; 503 PivotCacheIdVector maCacheIds; 504 }; 505 506 // ============================================================================ 507 508 } // namespace xls 509 } // namespace oox 510 511 #endif 512