LCOV - code coverage report
Current view: top level - libreoffice/sc/source/filter/inc - pivotcachebuffer.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 29 3.4 %
Date: 2012-12-27 Functions: 2 35 5.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #ifndef OOX_XLS_PIVOTCACHEBUFFER_HXX
      21             : #define OOX_XLS_PIVOTCACHEBUFFER_HXX
      22             : 
      23             : #include <com/sun/star/table/CellAddress.hpp>
      24             : #include <com/sun/star/table/CellRangeAddress.hpp>
      25             : #include <com/sun/star/util/DateTime.hpp>
      26             : #include "oox/helper/containerhelper.hxx"
      27             : #include "oox/helper/refvector.hxx"
      28             : #include "workbookhelper.hxx"
      29             : 
      30             : namespace com { namespace sun { namespace star {
      31             :     namespace sheet { class XDataPilotField; }
      32             : } } }
      33             : 
      34             : namespace oox { namespace core { class Relations; } }
      35             : 
      36             : namespace oox {
      37             : namespace xls {
      38             : 
      39             : class WorksheetHelper;
      40             : 
      41             : // ============================================================================
      42             : 
      43             : typedef ::std::pair< sal_Int32, rtl::OUString > IdCaptionPair;
      44             : typedef ::std::vector< IdCaptionPair > IdCaptionPairList;
      45             : 
      46           0 : class PivotCacheItem
      47             : {
      48             : public:
      49             :     explicit            PivotCacheItem();
      50             : 
      51             :     /** Reads the string value from a pivot cache item. */
      52             :     void                readString( const AttributeList& rAttribs );
      53             :     /** Reads the double value from a pivot cache item. */
      54             :     void                readNumeric( const AttributeList& rAttribs );
      55             :     /** Reads the date/time value from a pivot cache item. */
      56             :     void                readDate( const AttributeList& rAttribs );
      57             :     /** Reads the boolean value from a pivot cache item. */
      58             :     void                readBool( const AttributeList& rAttribs );
      59             :     /** Reads the error code value from a pivot cache item. */
      60             :     void                readError( const AttributeList& rAttribs, const UnitConverter& rUnitConverter );
      61             :     /** Reads the index of a shared item. */
      62             :     void                readIndex( const AttributeList& rAttribs );
      63             : 
      64             :     /** Reads the string value from a pivot cache item. */
      65             :     void                readString( SequenceInputStream& rStrm );
      66             :     /** Reads the double value from a pivot cache item. */
      67             :     void                readDouble( SequenceInputStream& rStrm );
      68             :     /** Reads the date/time value from a pivot cache item. */
      69             :     void                readDate( SequenceInputStream& rStrm );
      70             :     /** Reads the boolean value from a pivot cache item. */
      71             :     void                readBool( SequenceInputStream& rStrm );
      72             :     /** Reads the error code value from a pivot cache item. */
      73             :     void                readError( SequenceInputStream& rStrm );
      74             :     /** Reads the index of a shared item. */
      75             :     void                readIndex( SequenceInputStream& rStrm );
      76             : 
      77             :     /** Reads the string value from a pivot cache item. */
      78             :     void                readString( BiffInputStream& rStrm, const WorkbookHelper& rHelper );
      79             :     /** Reads the double value from a pivot cache item. */
      80             :     void                readDouble( BiffInputStream& rStrm );
      81             :     /** Reads the integer value from a pivot cache item. */
      82             :     void                readInteger( BiffInputStream& rStrm );
      83             :     /** Reads the date/time value from a pivot cache item. */
      84             :     void                readDate( BiffInputStream& rStrm );
      85             :     /** Reads the boolean value from a pivot cache item. */
      86             :     void                readBool( BiffInputStream& rStrm );
      87             :     /** Reads the error code value from a pivot cache item. */
      88             :     void                readError( BiffInputStream& rStrm );
      89             : 
      90             :     /** Returns the type of the item. */
      91           0 :     inline sal_Int32    getType() const { return mnType; }
      92             :     /** Returns the value of the item. */
      93           0 :     inline const ::com::sun::star::uno::Any& getValue() const { return maValue; }
      94             :     /** Returns the string representation of the item. */
      95             :     ::rtl::OUString     getName() const;
      96             :     /** Returns true if the item is unused. */
      97           0 :     inline bool         isUnused() const { return mbUnused; }
      98             : 
      99             : private:
     100             : friend class PivotCacheItemList;
     101             :     // #FIXME hack Sets the value of this item to the given string ( and overwrites type if necessary
     102             :     void                setStringValue( const rtl::OUString& sName );
     103             :     ::com::sun::star::uno::Any maValue;     /// Value of the item.
     104             :     sal_Int32           mnType;             /// Value type (OOXML token identifier).
     105             :     bool                mbUnused;
     106             : };
     107             : 
     108             : // ----------------------------------------------------------------------------
     109             : 
     110           0 : class PivotCacheItemList : public WorkbookHelper
     111             : {
     112             : public:
     113             :     explicit            PivotCacheItemList( const WorkbookHelper& rHelper );
     114             : 
     115             :     /** Imports the item from the passed attribute list. */
     116             :     void                importItem( sal_Int32 nElement, const AttributeList& rAttribs );
     117             :     /** Imports the item from the passed stream and record. */
     118             :     void                importItem( sal_Int32 nRecId, SequenceInputStream& rStrm );
     119             :     /** Imports a complete item list from the passed stream. */
     120             :     void                importItemList( BiffInputStream& rStrm, sal_uInt16 nCount );
     121             : 
     122             :     /** Returns true, if this item list is empty. */
     123           0 :     inline bool         empty() const { return maItems.empty(); }
     124             :     /** Returns the size of the item list. */
     125           0 :     inline size_t       size() const { return maItems.size(); }
     126             : 
     127             :     /** Returns the specified item. */
     128             :     const PivotCacheItem* getCacheItem( sal_Int32 nItemIdx ) const;
     129             :     /** Returns the names of all items. */
     130             :     void                getCacheItemNames( ::std::vector< ::rtl::OUString >& orItemNames ) const;
     131             :     void                applyItemCaptions( const IdCaptionPairList& vCaptions );
     132             : 
     133             : private:
     134             :     /** Creates and returns a new item at the end of the items list. */
     135             :     PivotCacheItem&     createItem();
     136             :     /** Imports an array of items from the PCITEM_ARRAY record */
     137             :     void                importArray( SequenceInputStream& rStrm );
     138             : 
     139             : private:
     140             :     typedef ::std::vector< PivotCacheItem > CacheItemVector;
     141             :     CacheItemVector     maItems;            /// All items of this list.
     142             : };
     143             : 
     144             : // ============================================================================
     145             : 
     146           0 : struct PCFieldModel
     147             : {
     148             :     ::rtl::OUString     maName;             /// Fixed name of the cache field.
     149             :     ::rtl::OUString     maCaption;          /// Caption of the ccahe field.
     150             :     ::rtl::OUString     maPropertyName;     /// OLAP property name.
     151             :     ::rtl::OUString     maFormula;          /// Formula of a calculated field.
     152             :     sal_Int32           mnNumFmtId;         /// Number format for all items.
     153             :     sal_Int32           mnSqlType;          /// Data type from ODBC data source.
     154             :     sal_Int32           mnHierarchy;        /// Hierarchy this field is part of.
     155             :     sal_Int32           mnLevel;            /// Hierarchy level this field is part of.
     156             :     sal_Int32           mnMappingCount;     /// Number of property mappings.
     157             :     bool                mbDatabaseField;    /// True = field from source data; false = calculated field.
     158             :     bool                mbServerField;      /// True = ODBC server-based page field.
     159             :     bool                mbUniqueList;       /// True = list of unique ODBC items exists.
     160             :     bool                mbMemberPropField;  /// True = contains OLAP member properties.
     161             : 
     162             :     explicit            PCFieldModel();
     163             : };
     164             : 
     165             : // ----------------------------------------------------------------------------
     166             : 
     167             : struct PCSharedItemsModel
     168             : {
     169             :     bool                mbHasSemiMixed;     /// True = has (blank|string|bool|error) item(s), maybe other types.
     170             :     bool                mbHasNonDate;       /// True = has non-date item(s), maybe date items.
     171             :     bool                mbHasDate;          /// True = has date item(s), maybe other types.
     172             :     bool                mbHasString;        /// True = has (string|bool|error) item(s), maybe other types.
     173             :     bool                mbHasBlank;         /// True = has blank item(s), maybe other types.
     174             :     bool                mbHasMixed;         /// True = has [(string|bool|error) and (number|date)] or (number and date).
     175             :     bool                mbIsNumeric;        /// True = has numeric item(s), maybe other types except date.
     176             :     bool                mbIsInteger;        /// True = has numeric item(s) with only integers, maybe other types except date.
     177             :     bool                mbHasLongText;      /// True = contains strings with >255 charascters.
     178             :     bool                mbHasLongIndexes;   /// True = indexes to shared items are 16-bit (BIFF only).
     179             : 
     180             :     explicit            PCSharedItemsModel();
     181             : };
     182             : 
     183             : // ----------------------------------------------------------------------------
     184             : 
     185             : struct PCFieldGroupModel
     186             : {
     187             :     ::com::sun::star::util::DateTime maStartDate;   /// Manual or calculated start date for range grouping.
     188             :     ::com::sun::star::util::DateTime maEndDate;     /// Manual or calculated end date for range grouping.
     189             :     double              mfStartValue;       /// Manual or calculated start value for range grouping.
     190             :     double              mfEndValue;         /// Manual or calculated end value for range grouping.
     191             :     double              mfInterval;         /// Interval for numeric range grouping.
     192             :     sal_Int32           mnParentField;      /// Index of cache field that contains item groups based on this field.
     193             :     sal_Int32           mnBaseField;        /// Index of cache field this grouped field is based on.
     194             :     sal_Int32           mnGroupBy;          /// Type of numeric or date range grouping.
     195             :     bool                mbRangeGroup;       /// True = items are grouped by numeric ranges or date ranges.
     196             :     bool                mbDateGroup;        /// True = items are grouped by date ranges or by item names.
     197             :     bool                mbAutoStart;        /// True = start value for range groups is calculated from source data.
     198             :     bool                mbAutoEnd;          /// True = end value for range groups is calculated from source data.
     199             : 
     200             :     explicit            PCFieldGroupModel();
     201             : 
     202             :     /** Sets the group-by value for BIFF import. */
     203             :     void                setBiffGroupBy( sal_uInt8 nGroupBy );
     204             : };
     205             : 
     206             : // ----------------------------------------------------------------------------
     207             : 
     208             : /** Helper struct for mapping original item names from/to group item names. */
     209           0 : struct PivotCacheGroupItem
     210             : {
     211             :     ::rtl::OUString     maOrigName;
     212             :     ::rtl::OUString     maGroupName;
     213             : 
     214           0 :     inline explicit     PivotCacheGroupItem( const ::rtl::OUString& rItemName ) :
     215           0 :                             maOrigName( rItemName ), maGroupName( rItemName ) {}
     216             : };
     217             : 
     218             : typedef ::std::vector< PivotCacheGroupItem > PivotCacheGroupItemVector;
     219             : 
     220             : // ----------------------------------------------------------------------------
     221             : 
     222           0 : class PivotCacheField : public WorkbookHelper
     223             : {
     224             : public:
     225             :     explicit            PivotCacheField( const WorkbookHelper& rHelper, bool bIsDatabaseField );
     226             : 
     227             :     /** Imports pivot cache field settings from the cacheField element. */
     228             :     void                importCacheField( const AttributeList& rAttribs );
     229             :     /** Imports shared items settings from the sharedItems element. */
     230             :     void                importSharedItems( const AttributeList& rAttribs );
     231             :     /** Imports a shared item from the passed element. */
     232             :     void                importSharedItem( sal_Int32 nElement, const AttributeList& rAttribs );
     233             :     /** Imports grouping settings from the fieldGroup element. */
     234             :     void                importFieldGroup( const AttributeList& rAttribs );
     235             :     /** Imports numeric grouping settings from the rangePr element. */
     236             :     void                importRangePr( const AttributeList& rAttribs );
     237             :     /** Imports an item of the mapping between group items and base items from the passed element. */
     238             :     void                importDiscretePrItem( sal_Int32 nElement, const AttributeList& rAttribs );
     239             :     /** Imports a group item from the passed element. */
     240             :     void                importGroupItem( sal_Int32 nElement, const AttributeList& rAttribs );
     241             : 
     242             :     /** Imports pivot cache field settings from the PCDFIELD record. */
     243             :     void                importPCDField( SequenceInputStream& rStrm );
     244             :     /** Imports shared items settings from the PCDFSHAREDITEMS record. */
     245             :     void                importPCDFSharedItems( SequenceInputStream& rStrm );
     246             :     /** Imports one or more shared items from the passed record. */
     247             :     void                importPCDFSharedItem( sal_Int32 nRecId, SequenceInputStream& rStrm );
     248             :     /** Imports grouping settings from the PCDFIELDGROUP record. */
     249             :     void                importPCDFieldGroup( SequenceInputStream& rStrm );
     250             :     /** Imports numeric grouping settings from the PCDFRANGEPR record. */
     251             :     void                importPCDFRangePr( SequenceInputStream& rStrm );
     252             :     /** Imports an item of the mapping between group items and base items from the passed record. */
     253             :     void                importPCDFDiscretePrItem( sal_Int32 nRecId, SequenceInputStream& rStrm );
     254             :     /** Imports one or more group items from the passed record. */
     255             :     void                importPCDFGroupItem( sal_Int32 nRecId, SequenceInputStream& rStrm );
     256             : 
     257             :     /** Imports pivot cache field settings from the PCDFIELD record. */
     258             :     void                importPCDField( BiffInputStream& rStrm );
     259             :     /** Imports numeric grouping settings from the PCDFRANGEPR record. */
     260             :     void                importPCDFRangePr( BiffInputStream& rStrm );
     261             :     /** Imports the mapping between group items and base items from the PCDFDISCRETEPR record. */
     262             :     void                importPCDFDiscretePr( BiffInputStream& rStrm );
     263             :     /** Apply user Captions to imported group data */
     264             :     void                applyItemCaptions( const IdCaptionPairList& vCaptions );
     265             : 
     266             :     /** Returns true, if the field is based on source data, or false if it is grouped or calculated. */
     267           0 :     inline bool         isDatabaseField() const { return maFieldModel.mbDatabaseField; }
     268             : 
     269             :     /** Returns true, if the field contains a list of shared items. */
     270           0 :     inline bool         hasSharedItems() const { return !maSharedItems.empty(); }
     271             :     /** Returns true, if the field contains a list of grouping items. */
     272           0 :     inline bool         hasGroupItems() const { return !maGroupItems.empty(); }
     273             :     /** Returns true, if the field has inplace numeric grouping settings. */
     274           0 :     inline bool         hasNumericGrouping() const { return maFieldGroupModel.mbRangeGroup && !maFieldGroupModel.mbDateGroup; }
     275             :     /** Returns true, if the field has inplace date grouping settings. */
     276           0 :     inline bool         hasDateGrouping() const { return maFieldGroupModel.mbRangeGroup && maFieldGroupModel.mbDateGroup; }
     277             :     /** Returns true, if the field has a parent group field that groups the items of this field. */
     278           0 :     inline bool         hasParentGrouping() const { return maFieldGroupModel.mnParentField >= 0; }
     279             : 
     280             :     /** Returns the name of the cache field. */
     281           0 :     inline const ::rtl::OUString& getName() const { return maFieldModel.maName; }
     282             :     /** Returns the index of the parent group field that groups the items of this field. */
     283           0 :     inline sal_Int32    getParentGroupField() const { return maFieldGroupModel.mnParentField; }
     284             :     /** Returns the index of the base field grouping is based on. */
     285           0 :     inline sal_Int32    getGroupBaseField() const { return maFieldGroupModel.mnBaseField; }
     286             : 
     287             :     /** Returns the shared or group item with the specified index. */
     288             :     const PivotCacheItem* getCacheItem( sal_Int32 nItemIdx ) const;
     289             :     /** Returns the names of all shared or group items. */
     290             :     void                getCacheItemNames( ::std::vector< ::rtl::OUString >& orItemNames ) const;
     291             :     /** Returns shared or group items. */
     292             :     PivotCacheItemList  getCacheItems() const;
     293             : 
     294             :     /** Creates inplace numeric grouping settings. */
     295             :     void                convertNumericGrouping(
     296             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XDataPilotField >& rxDPField ) const;
     297             :     /** Creates inplace date grouping settings or a new date group field. */
     298             :     ::rtl::OUString     createDateGroupField(
     299             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XDataPilotField >& rxBaseDPField ) const;
     300             :     /** Creates a new grouped DataPilot field and returns its name. */
     301             :     ::rtl::OUString     createParentGroupField(
     302             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XDataPilotField >& rxBaseDPField,
     303             :                             const PivotCacheField& rBaseCacheField,
     304             :                             PivotCacheGroupItemVector& orItemNames ) const;
     305             : 
     306             :     /** Writes the title of the field into the passed sheet at the passed address. */
     307             :     void                writeSourceHeaderCell( WorksheetHelper& rSheetHelper,
     308             :                             sal_Int32 nCol, sal_Int32 nRow ) const;
     309             :     /** Writes a source field item value into the passed sheet. */
     310             :     void                writeSourceDataCell( WorksheetHelper& rSheetHelper,
     311             :                             sal_Int32 nCol, sal_Int32 nRow,
     312             :                             const PivotCacheItem& rItem ) const;
     313             : 
     314             :     /** Reads an item from the PCRECORD record and writes it to the passed sheet. */
     315             :     void                importPCRecordItem( SequenceInputStream& rStrm,
     316             :                             WorksheetHelper& rSheetHelper, sal_Int32 nCol, sal_Int32 nRow ) const;
     317             :     /** Reads an item index from the PCITEM_INDEXLIST record and writes the item to the passed sheet. */
     318             :     void                importPCItemIndex( BiffInputStream& rStrm,
     319             :                             WorksheetHelper& rSheetHelper, sal_Int32 nCol, sal_Int32 nRow ) const;
     320             : 
     321             : private:
     322             :     /** Tries to write the passed value to the passed sheet position. */
     323             :     void                writeItemToSourceDataCell( WorksheetHelper& rSheetHelper,
     324             :                             sal_Int32 nCol, sal_Int32 nRow, const PivotCacheItem& rItem ) const;
     325             :     /** Tries to write the value of a shared item to the passed sheet position. */
     326             :     void                writeSharedItemToSourceDataCell( WorksheetHelper& rSheetHelper,
     327             :                             sal_Int32 nCol, sal_Int32 nRow, sal_Int32 nItemIdx ) const;
     328             : 
     329             : private:
     330             :     typedef ::std::vector< sal_Int32 > IndexVector;
     331             : 
     332             :     PivotCacheItemList  maSharedItems;      /// All shared items of this field.
     333             :     PivotCacheItemList  maGroupItems;       /// All group items of this field.
     334             :     IndexVector         maDiscreteItems;    /// Mapping between group and base items.
     335             :     PCFieldModel        maFieldModel;       /// Settings for this cache field.
     336             :     PCSharedItemsModel  maSharedItemsModel; /// Settings for shared items.
     337             :     PCFieldGroupModel   maFieldGroupModel;  /// Settings for item grouping.
     338             : };
     339             : 
     340             : // ============================================================================
     341             : 
     342           0 : struct PCDefinitionModel
     343             : {
     344             :     ::rtl::OUString     maRelId;            /// Relation identifier for cache records fragment.
     345             :     ::rtl::OUString     maRefreshedBy;      /// Name of user who last refreshed the cache.
     346             :     double              mfRefreshedDate;    /// Date/time of last refresh.
     347             :     sal_Int32           mnRecords;          /// Number of data records in the cache.
     348             :     sal_Int32           mnMissItemsLimit;   /// Limit for discarding unused items.
     349             :     sal_uInt16          mnDatabaseFields;   /// Number of database (source data) fields (BIFF only).
     350             :     bool                mbInvalid;          /// True = cache needs refresh.
     351             :     bool                mbSaveData;         /// True = cached item values are present.
     352             :     bool                mbRefreshOnLoad;    /// True = try to refresh cache on load.
     353             :     bool                mbOptimizeMemory;   /// True = application may optimize memory usage.
     354             :     bool                mbEnableRefresh;    /// True = refreshing cache is enabled in UI.
     355             :     bool                mbBackgroundQuery;  /// True = application queries data asynchonously.
     356             :     bool                mbUpgradeOnRefresh; /// True = application may upgrade cache version.
     357             :     bool                mbTupleCache;       /// True = cache stores OLAP functions.
     358             :     bool                mbSupportSubquery;  /// True = data source supports subqueries.
     359             :     bool                mbSupportDrill;     /// True = data source supports drilldown.
     360             : 
     361             :     explicit            PCDefinitionModel();
     362             : };
     363             : 
     364             : // ----------------------------------------------------------------------------
     365             : 
     366             : struct PCSourceModel
     367             : {
     368             :     sal_Int32           mnSourceType;       /// Type of the source data (sheet, consolidation, scenario, external).
     369             :     sal_Int32           mnConnectionId;     /// Connection identifier for external data source.
     370             : 
     371             :     explicit            PCSourceModel();
     372             : };
     373             : 
     374             : // ----------------------------------------------------------------------------
     375             : 
     376           0 : struct PCWorksheetSourceModel
     377             : {
     378             :     ::rtl::OUString     maRelId;            /// Relation identifier for an external document URL.
     379             :     ::rtl::OUString     maSheet;            /// Sheet name for cell range or sheet-local defined names.
     380             :     ::rtl::OUString     maDefName;          /// Defined name containing a cell range if present.
     381             :     ::com::sun::star::table::CellRangeAddress
     382             :                         maRange;            /// Source cell range of the data.
     383             : 
     384             :     explicit            PCWorksheetSourceModel();
     385             : };
     386             : 
     387             : // ----------------------------------------------------------------------------
     388             : 
     389           0 : class PivotCache : public WorkbookHelper
     390             : {
     391             : public:
     392             :     explicit            PivotCache( const WorkbookHelper& rHelper );
     393             : 
     394             :     /** Reads pivot cache global settings from the pivotCacheDefinition element. */
     395             :     void                importPivotCacheDefinition( const AttributeList& rAttribs );
     396             :     /** Reads cache source settings from the cacheSource element. */
     397             :     void                importCacheSource( const AttributeList& rAttribs );
     398             :     /** Reads sheet source settings from the worksheetSource element. */
     399             :     void                importWorksheetSource( const AttributeList& rAttribs, const ::oox::core::Relations& rRelations );
     400             : 
     401             :     /** Reads pivot cache global settings from the PCDEFINITION record. */
     402             :     void                importPCDefinition( SequenceInputStream& rStrm );
     403             :     /** Reads cache source settings from the PCDSOURCE record. */
     404             :     void                importPCDSource( SequenceInputStream& rStrm );
     405             :     /** Reads sheet source settings from the PCDSHEETSOURCE record. */
     406             :     void                importPCDSheetSource( SequenceInputStream& rStrm, const ::oox::core::Relations& rRelations );
     407             : 
     408             :     /** Reads pivot cache global settings from the PCDEFINITION record. */
     409             :     void                importPCDefinition( BiffInputStream& rStrm );
     410             : 
     411             :     /** Creates and returns a new pivot cache field. */
     412             :     PivotCacheField&    createCacheField( bool bInitDatabaseField = false );
     413             :     /** Checks validity of source data and creates a dummy data sheet for external sheet sources. */
     414             :     void                finalizeImport();
     415             : 
     416             :     /** Returns true, if the pivot cache is based on a valid data source, so
     417             :         that pivot tables can be created based on this pivot cache. */
     418           0 :     inline bool         isValidDataSource() const { return mbValidSource; }
     419             :     /** Returns true, if the pivot cache is based on a dummy sheet created in finalizeImport. */
     420           0 :     inline bool         isBasedOnDummySheet() const { return mbDummySheet; }
     421             :     /** Returns the internal cell range the cache is based on. */
     422             :     inline const ::com::sun::star::table::CellRangeAddress&
     423           0 :                         getSourceRange() const { return maSheetSrcModel.maRange; }
     424             :     /** Returns the relation identifier of the pivot cache records fragment. */
     425           0 :     inline const ::rtl::OUString& getRecordsRelId() const { return maDefModel.maRelId; }
     426             : 
     427             :     /** Returns the number of pivot cache fields. */
     428             :     sal_Int32           getCacheFieldCount() const;
     429             :     /** Returns the cache field with the specified index. */
     430             :     const PivotCacheField* getCacheField( sal_Int32 nFieldIdx ) const;
     431             :     /** Returns the source column index of the field with the passed index. */
     432             :     sal_Int32           getCacheDatabaseIndex( sal_Int32 nFieldIdx ) const;
     433             : 
     434             :     /** Writes the titles of all source fields into the passed sheet. */
     435             :     void                writeSourceHeaderCells( WorksheetHelper& rSheetHelper ) const;
     436             :     /** Writes a source field item value into the passed sheet. */
     437             :     void                writeSourceDataCell( WorksheetHelper& rSheetHelper,
     438             :                             sal_Int32 nColIdx, sal_Int32 nRowIdx,
     439             :                             const PivotCacheItem& rItem ) const;
     440             : 
     441             :     /** Reads a PCRECORD record and writes all item values to the passed sheet. */
     442             :     void                importPCRecord( SequenceInputStream& rStrm,
     443             :                             WorksheetHelper& rSheetHelper, sal_Int32 nRowIdx ) const;
     444             :     /** Reads a PCITEM_INDEXLIST record and writes all item values to the passed sheet. */
     445             :     void                importPCItemIndexList( BiffInputStream& rStrm,
     446             :                             WorksheetHelper& rSheetHelper, sal_Int32 nRowIdx ) const;
     447             : 
     448             : private:
     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          22 : 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             : 
     486             :     /** Imports and stores a pivot cache definition fragment on first call,
     487             :         returns the imported cache on subsequent calls with the same identifier. */
     488             :     PivotCache*         importPivotCacheFragment( sal_Int32 nCacheId );
     489             : 
     490             : private:
     491             :     /** Creates and returns a new pivot cache object with the passed identifier. */
     492             :     PivotCache&         createPivotCache( sal_Int32 nCacheId );
     493             : 
     494             : private:
     495             :     typedef ::std::map< sal_Int32, ::rtl::OUString >    FragmentPathMap;
     496             :     typedef RefMap< sal_Int32, PivotCache >             PivotCacheMap;
     497             :     typedef ::std::vector< sal_Int32 >                  PivotCacheIdVector;
     498             : 
     499             :     FragmentPathMap     maFragmentPaths;
     500             :     PivotCacheMap       maCaches;
     501             :     PivotCacheIdVector  maCacheIds;
     502             : };
     503             : 
     504             : // ============================================================================
     505             : 
     506             : } // namespace xls
     507             : } // namespace oox
     508             : 
     509             : #endif
     510             : 
     511             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10