xref: /trunk/main/sc/inc/dptablecache.hxx (revision 914d351e5f5b84e4342a86d6ab8d4aca7308b9bd)
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
10cdf0e10cSrcweir  *
1138d50f7bSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
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.
19cdf0e10cSrcweir  *
2038d50f7bSAndrew Rist  *************************************************************/
2138d50f7bSAndrew Rist 
2238d50f7bSAndrew Rist 
23cdf0e10cSrcweir #ifndef DPTABLECACHE_HXX
24cdf0e10cSrcweir #define DPTABLECACHE_HXX
25cdf0e10cSrcweir // Add Data Cache Support.
26cdf0e10cSrcweir #ifndef SC_SCGLOB_HXX
27cdf0e10cSrcweir #include "global.hxx"
28cdf0e10cSrcweir #endif
29cdf0e10cSrcweir #include <svl/zforlist.hxx>
30cdf0e10cSrcweir #include <vector>
31cdf0e10cSrcweir #include "dpglobal.hxx"
32cdf0e10cSrcweir 
33cdf0e10cSrcweir #include <com/sun/star/sdbc/DataType.hpp>
34cdf0e10cSrcweir #include <com/sun/star/sdbc/XRow.hpp>
35cdf0e10cSrcweir #include <com/sun/star/sdbc/XRowSet.hpp>
36cdf0e10cSrcweir 
37cdf0e10cSrcweir class ScDPTableDataCache;
38cdf0e10cSrcweir class TypedStrData;
39cdf0e10cSrcweir struct ScQueryParam;
40cdf0e10cSrcweir 
41cdf0e10cSrcweir // --------------------------------------------------------------------
42cdf0e10cSrcweir //
43cdf0e10cSrcweir //  base class ScDPTableData to allow implementation with tabular data
44cdf0e10cSrcweir //  by deriving only of this
45cdf0e10cSrcweir //
46cdf0e10cSrcweir 
47cdf0e10cSrcweir class SC_DLLPUBLIC ScDPTableDataCache
48cdf0e10cSrcweir {
49cdf0e10cSrcweir     long    mnID;
50cdf0e10cSrcweir     ScDocument* mpDoc;
51cdf0e10cSrcweir 
52cdf0e10cSrcweir     long                         mnColumnCount;     // Column count
53cdf0e10cSrcweir 
54cdf0e10cSrcweir     std::vector<ScDPItemData*>*      mpTableDataValues; //Data Pilot Table's index - value map
55cdf0e10cSrcweir     std::vector<SCROW>*          mpSourceData;      //Data Pilot Table's Source data
56cdf0e10cSrcweir     std::vector<SCROW>*          mpGlobalOrder;     //Sorted members index
57cdf0e10cSrcweir     std::vector<SCROW>*          mpIndexOrder;      //Index the sorted number
58cdf0e10cSrcweir     std::vector<ScDPItemData*>   mrLabelNames;      //Source Label data
59cdf0e10cSrcweir     std::vector<sal_Bool>            mbEmptyRow;        //If empty row?
60cdf0e10cSrcweir     mutable ScDPItemDataPool                 maAdditionalDatas;
61cdf0e10cSrcweir public:
62cdf0e10cSrcweir     SCROW GetOrder( long nDim, SCROW nIndex ) const;
63cdf0e10cSrcweir     SCROW GetIdByItemData( long nDim,  String sItemData  ) const;
64cdf0e10cSrcweir     SCROW GetIdByItemData( long nDim, const ScDPItemData& rData ) const;
65cdf0e10cSrcweir 
66cdf0e10cSrcweir     SCROW GetAdditionalItemID ( String sItemData );
67cdf0e10cSrcweir     SCROW GetAdditionalItemID( const ScDPItemData& rData );
68cdf0e10cSrcweir 
69cdf0e10cSrcweir     SCCOL GetDimensionIndex( String sName) const;
70cdf0e10cSrcweir     const ScDPItemData* GetSortedItemData( SCCOL nDim, SCROW nOrder ) const;
71cdf0e10cSrcweir     sal_uLong GetNumType ( sal_uLong nFormat ) const;
72cdf0e10cSrcweir     sal_uLong GetNumberFormat( long nDim ) const;
73cdf0e10cSrcweir     sal_Bool  IsDateDimension( long nDim ) const ;
74cdf0e10cSrcweir     sal_uLong GetDimNumType( SCCOL nDim) const;
75cdf0e10cSrcweir     SCROW GetDimMemberCount( SCCOL nDim ) const;
76cdf0e10cSrcweir 
77cdf0e10cSrcweir     SCROW GetSortedItemDataId( SCCOL nDim, SCROW nOrder ) const;
78cdf0e10cSrcweir     const std::vector<ScDPItemData*>& GetDimMemberValues( SCCOL nDim )const;
SetId(long nId)79cdf0e10cSrcweir     void    SetId( long nId ){ mnID = nId;}
80cdf0e10cSrcweir     void    AddRow( ScDPItemData* pRow, sal_uInt16 nCount );
81cdf0e10cSrcweir     bool    InitFromDoc(  ScDocument* pDoc, const ScRange& rRange );
82cdf0e10cSrcweir     bool InitFromDataBase (const  ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet>& xRowSet, const Date& rNullDate);
83cdf0e10cSrcweir 
84cdf0e10cSrcweir     SCROW   GetRowCount() const;
85cdf0e10cSrcweir     SCROW   GetItemDataId( sal_uInt16 nDim, SCROW nRow, sal_Bool bRepeatIfEmpty ) const;
86cdf0e10cSrcweir     String  GetDimensionName( sal_uInt16 nColumn ) const;
87cdf0e10cSrcweir     bool    IsEmptyMember( SCROW nRow, sal_uInt16 nColumn ) const;
88cdf0e10cSrcweir     bool    IsRowEmpty( SCROW nRow ) const;
89cdf0e10cSrcweir     bool    IsValid() const;
90cdf0e10cSrcweir     bool    ValidQuery( SCROW nRow, const ScQueryParam& rQueryParam, sal_Bool* pSpecial );
91cdf0e10cSrcweir 
92cdf0e10cSrcweir     ScDocument* GetDoc() const;//ms-cache-core
93cdf0e10cSrcweir     long GetColumnCount() const;
94cdf0e10cSrcweir     long    GetId() const;
95cdf0e10cSrcweir 
96cdf0e10cSrcweir     const ScDPItemData* GetItemDataById( long nDim, SCROW nId ) const;
97cdf0e10cSrcweir 
98cdf0e10cSrcweir     sal_Bool operator== ( const ScDPTableDataCache& r ) const;
99cdf0e10cSrcweir 
100cdf0e10cSrcweir //construction
101cdf0e10cSrcweir     ScDPTableDataCache( ScDocument* pDoc );
102cdf0e10cSrcweir //deconstruction
103cdf0e10cSrcweir     virtual ~ScDPTableDataCache();
104cdf0e10cSrcweir 
105cdf0e10cSrcweir protected:
106cdf0e10cSrcweir private:
107b4df81e3SWang Lei public:
108cdf0e10cSrcweir     void        AddLabel( ScDPItemData* pData);
109*7a6646f1SWang Lei     sal_Bool    AddData( long nDim, ScDPItemData* itemData, bool bCheckDate = true );
110cdf0e10cSrcweir };
111cdf0e10cSrcweir 
112cdf0e10cSrcweir #endif //DPTABLECACHE_HXX
113