xref: /aoo41x/main/sc/inc/dptablecache.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright IBM Corporation 2009.
6  * Copyright 2009 by Sun Microsystems, Inc.
7  *
8  * OpenOffice.org - a multi-platform office productivity suite
9  *
10  * $RCSfile: dptablecache.hxx,v $
11  * $Revision: 1.0 $
12  *
13  * This file is part of OpenOffice.org.
14  *
15  * OpenOffice.org is free software: you can redistribute it and/or modify
16  * it under the terms of the GNU Lesser General Public License version 3
17  * only, as published by the Free Software Foundation.
18  *
19  * OpenOffice.org is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  * GNU Lesser General Public License version 3 for more details
23  * (a copy is included in the LICENSE file that accompanied this code).
24  *
25  * You should have received a copy of the GNU Lesser General Public License
26  * version 3 along with OpenOffice.org.  If not, see
27  * <http://www.openoffice.org/license.html>
28  * for a copy of the LGPLv3 License.
29  *
30  ************************************************************************/
31 #ifndef DPTABLECACHE_HXX
32 #define DPTABLECACHE_HXX
33 // Wang Xu Ming -- 12/21/2008
34 // Add Data Cache Support.
35 #ifndef SC_SCGLOB_HXX
36 #include "global.hxx"
37 #endif
38 //Added by PengYunQuan for SODC_16015
39 #include <svl/zforlist.hxx>
40 //end
41 #include <vector>
42 #include "dpglobal.hxx"
43 
44 #include <com/sun/star/sdbc/DataType.hpp>
45 #include <com/sun/star/sdbc/XRow.hpp>
46 #include <com/sun/star/sdbc/XRowSet.hpp>
47 
48 class ScDPTableDataCache;
49 class TypedStrData;
50 struct ScQueryParam;
51 
52 // --------------------------------------------------------------------
53 //
54 //	base class ScDPTableData to allow implementation with tabular data
55 //	by deriving only of this
56 //
57 
58 class SC_DLLPUBLIC ScDPTableDataCache
59 {
60 	long	mnID;
61 	ScDocument* mpDoc;
62 
63 	long						 mnColumnCount;		// Column count
64 
65 	std::vector<ScDPItemData*>* 	 mpTableDataValues; //Data Pilot Table's index - value map
66 	std::vector<SCROW>*			 mpSourceData;		//Data Pilot Table's Source data
67 	std::vector<SCROW>*			 mpGlobalOrder;		//Sorted members index
68 	std::vector<SCROW>*			 mpIndexOrder;		//Index the sorted number
69 	std::vector<ScDPItemData*>	 mrLabelNames;		//Source Label data
70 	std::vector<sal_Bool>			 mbEmptyRow;		//If empty row?
71 	mutable ScDPItemDataPool	  			 maAdditionalDatas;
72 public:
73 	SCROW GetOrder( long nDim, SCROW nIndex ) const;
74 	SCROW GetIdByItemData( long nDim,  String sItemData  ) const;
75 	SCROW GetIdByItemData( long nDim, const ScDPItemData& rData ) const;
76 
77 	SCROW GetAdditionalItemID ( String sItemData );
78 	SCROW GetAdditionalItemID( const ScDPItemData& rData );
79 
80 	SCCOL GetDimensionIndex( String sName) const;
81 	const ScDPItemData* GetSortedItemData( SCCOL nDim, SCROW nOrder ) const;
82 	sal_uLong GetNumType ( sal_uLong nFormat ) const;
83 	sal_uLong GetNumberFormat( long nDim ) const;
84 	sal_Bool  IsDateDimension( long nDim ) const ;
85 	sal_uLong GetDimNumType( SCCOL nDim) const;
86 	SCROW GetDimMemberCount( SCCOL nDim ) const;
87 
88 	SCROW GetSortedItemDataId( SCCOL nDim, SCROW nOrder ) const;
89 	const std::vector<ScDPItemData*>& GetDimMemberValues( SCCOL nDim )const;
90 	void	SetId( long nId ){ mnID = nId;}
91 	void	AddRow( ScDPItemData* pRow, sal_uInt16 nCount );
92 	bool	InitFromDoc(  ScDocument* pDoc, const ScRange& rRange );
93 	bool InitFromDataBase (const  ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet>& xRowSet, const Date& rNullDate);
94 
95 	SCROW	GetRowCount() const;
96 	SCROW	GetItemDataId( sal_uInt16 nDim, SCROW nRow, sal_Bool bRepeatIfEmpty ) const;
97 	String	GetDimensionName( sal_uInt16 nColumn ) const;
98 	bool	IsEmptyMember( SCROW nRow, sal_uInt16 nColumn ) const;
99 	bool	IsRowEmpty( SCROW nRow ) const;
100 	bool	IsValid() const;
101 	bool	ValidQuery( SCROW nRow, const ScQueryParam& rQueryParam, sal_Bool* pSpecial );
102 
103 	ScDocument* GetDoc() const;//ms-cache-core
104 	long GetColumnCount() const;
105 	long	GetId() const;
106 
107 	const ScDPItemData* GetItemDataById( long nDim, SCROW nId ) const;
108 
109 	sal_Bool operator== ( const ScDPTableDataCache& r ) const;
110 
111 //construction
112 	ScDPTableDataCache( ScDocument* pDoc );
113 //deconstruction
114 	virtual ~ScDPTableDataCache();
115 
116 protected:
117 private:
118 	void		AddLabel( ScDPItemData* pData);
119 	sal_Bool	AddData( long nDim, ScDPItemData* itemData );
120 };
121 
122 #endif //DPTABLECACHE_HXX
123