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