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