xref: /aoo41x/main/sc/inc/dbcolect.hxx (revision 22407013)
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
1038d50f7bSAndrew Rist  *
1138d50f7bSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
1238d50f7bSAndrew Rist  *
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.
1938d50f7bSAndrew Rist  *
2038d50f7bSAndrew Rist  *************************************************************/
2138d50f7bSAndrew Rist 
2238d50f7bSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef SC_DBCOLECT_HXX
25cdf0e10cSrcweir #define SC_DBCOLECT_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "scdllapi.h"
28cdf0e10cSrcweir #include "collect.hxx"
29cdf0e10cSrcweir #include "global.hxx"		// MAXQUERY
30cdf0e10cSrcweir #include "sortparam.hxx"	// MAXSORT
31cdf0e10cSrcweir #include "refreshtimer.hxx"
32cdf0e10cSrcweir #include "address.hxx"
33cdf0e10cSrcweir #include "scdllapi.h"
34cdf0e10cSrcweir 
35cdf0e10cSrcweir //------------------------------------------------------------------------
36cdf0e10cSrcweir 
37cdf0e10cSrcweir class ScDocument;
38cdf0e10cSrcweir 
39cdf0e10cSrcweir //------------------------------------------------------------------------
40cdf0e10cSrcweir 
41cdf0e10cSrcweir class ScDBData : public ScDataObject, public ScRefreshTimer
42cdf0e10cSrcweir {
43cdf0e10cSrcweir friend class ScDBCollection;
44cdf0e10cSrcweir private:
45cdf0e10cSrcweir 	// DBParam
46cdf0e10cSrcweir 	String			aName;
47cdf0e10cSrcweir 	SCTAB			nTable;
48cdf0e10cSrcweir 	SCCOL      	    nStartCol;
49cdf0e10cSrcweir 	SCROW			nStartRow;
50cdf0e10cSrcweir 	SCCOL			nEndCol;
51cdf0e10cSrcweir 	SCROW			nEndRow;
52cdf0e10cSrcweir 	sal_Bool			bByRow;
53cdf0e10cSrcweir 	sal_Bool			bHasHeader;
54cdf0e10cSrcweir 	sal_Bool			bDoSize;
55cdf0e10cSrcweir 	sal_Bool			bKeepFmt;
56cdf0e10cSrcweir 	sal_Bool			bStripData;
57cdf0e10cSrcweir 	// SortParam
58cdf0e10cSrcweir 	sal_Bool			bSortCaseSens;
59cdf0e10cSrcweir 	sal_Bool			bIncludePattern;
60cdf0e10cSrcweir 	sal_Bool			bSortInplace;
61cdf0e10cSrcweir 	sal_Bool			bSortUserDef;
62cdf0e10cSrcweir 	sal_uInt16			nSortUserIndex;
63cdf0e10cSrcweir 	SCTAB			nSortDestTab;
64cdf0e10cSrcweir 	SCCOL			nSortDestCol;
65cdf0e10cSrcweir 	SCROW			nSortDestRow;
66cdf0e10cSrcweir 	sal_Bool			bDoSort[MAXSORT];
67cdf0e10cSrcweir 	SCCOLROW		nSortField[MAXSORT];
68cdf0e10cSrcweir 	sal_Bool			bAscending[MAXSORT];
69cdf0e10cSrcweir 	::com::sun::star::lang::Locale aSortLocale;
70cdf0e10cSrcweir 	String			aSortAlgorithm;
71cdf0e10cSrcweir 	// QueryParam
72cdf0e10cSrcweir 	sal_Bool			bQueryInplace;
73cdf0e10cSrcweir 	sal_Bool			bQueryCaseSens;
74cdf0e10cSrcweir 	sal_Bool			bQueryRegExp;
75cdf0e10cSrcweir 	sal_Bool			bQueryDuplicate;
76cdf0e10cSrcweir 	SCTAB			nQueryDestTab;
77cdf0e10cSrcweir 	SCCOL			nQueryDestCol;
78cdf0e10cSrcweir 	SCROW			nQueryDestRow;
79cdf0e10cSrcweir 	sal_Bool			bDoQuery[MAXQUERY];
80cdf0e10cSrcweir 	SCCOLROW		nQueryField[MAXQUERY];
81cdf0e10cSrcweir 	ScQueryOp		eQueryOp[MAXQUERY];
82cdf0e10cSrcweir 	sal_Bool			bQueryByString[MAXQUERY];
83cdf0e10cSrcweir     bool            bQueryByDate[MAXQUERY];
84cdf0e10cSrcweir 	String*			pQueryStr[MAXQUERY];
85cdf0e10cSrcweir 	double			nQueryVal[MAXQUERY];
86cdf0e10cSrcweir 	ScQueryConnect  eQueryConnect[MAXQUERY];
87cdf0e10cSrcweir 	sal_Bool			bIsAdvanced;		// sal_True if created by advanced filter
88cdf0e10cSrcweir 	ScRange			aAdvSource;			// source range
89cdf0e10cSrcweir 	// SubTotalParam
90cdf0e10cSrcweir 	sal_Bool			bSubRemoveOnly;
91cdf0e10cSrcweir 	sal_Bool			bSubReplace;
92cdf0e10cSrcweir 	sal_Bool			bSubPagebreak;
93cdf0e10cSrcweir 	sal_Bool			bSubCaseSens;
94cdf0e10cSrcweir 	sal_Bool			bSubDoSort;
95cdf0e10cSrcweir 	sal_Bool			bSubAscending;
96cdf0e10cSrcweir 	sal_Bool			bSubIncludePattern;
97cdf0e10cSrcweir 	sal_Bool			bSubUserDef;
98cdf0e10cSrcweir 	sal_uInt16			nSubUserIndex;
99cdf0e10cSrcweir 	sal_Bool			bDoSubTotal[MAXSUBTOTAL];
100cdf0e10cSrcweir 	SCCOL			nSubField[MAXSUBTOTAL];
101cdf0e10cSrcweir 	SCCOL			nSubTotals[MAXSUBTOTAL];
102cdf0e10cSrcweir 	SCCOL*			pSubTotals[MAXSUBTOTAL];
103cdf0e10cSrcweir 	ScSubTotalFunc*	pFunctions[MAXSUBTOTAL];
104cdf0e10cSrcweir 	// Datenbank-Import
105cdf0e10cSrcweir 	sal_Bool			bDBImport;
106cdf0e10cSrcweir 	String			aDBName;
107cdf0e10cSrcweir 	String			aDBStatement;
108cdf0e10cSrcweir 	sal_Bool			bDBNative;
109cdf0e10cSrcweir 	sal_Bool			bDBSelection;		// nicht im Param: Wenn Selektion, Update sperren
110cdf0e10cSrcweir 	sal_Bool			bDBSql;				// aDBStatement ist SQL und kein Name
111cdf0e10cSrcweir 	sal_uInt8			nDBType;			// enum DBObject (bisher nur dbTable, dbQuery)
112cdf0e10cSrcweir 
113cdf0e10cSrcweir 	sal_uInt16			nIndex; 			// eindeutiger Index fuer Formeln
114cdf0e10cSrcweir 	sal_Bool			bAutoFilter;		// AutoFilter? (nicht gespeichert)
115cdf0e10cSrcweir 	sal_Bool			bModified;			// wird bei UpdateReference gesetzt/geloescht
116cdf0e10cSrcweir 
117cdf0e10cSrcweir     using ScRefreshTimer::operator==;
118cdf0e10cSrcweir 
119cdf0e10cSrcweir public:
120cdf0e10cSrcweir 			SC_DLLPUBLIC ScDBData(const String& rName,
121cdf0e10cSrcweir 					 SCTAB nTab,
122cdf0e10cSrcweir 					 SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
123cdf0e10cSrcweir 					 sal_Bool bByR = sal_True, sal_Bool bHasH = sal_True);
124cdf0e10cSrcweir 			ScDBData(const ScDBData& rData);
125cdf0e10cSrcweir 			~ScDBData();
126cdf0e10cSrcweir 
127cdf0e10cSrcweir 	virtual	ScDataObject*	Clone() const;
128cdf0e10cSrcweir 
129cdf0e10cSrcweir 			ScDBData&	operator= (const ScDBData& rData);
130cdf0e10cSrcweir 
131cdf0e10cSrcweir 			sal_Bool		operator== (const ScDBData& rData) const;
132cdf0e10cSrcweir 
GetName() const133cdf0e10cSrcweir 			const String& GetName() const				{ return aName; }
GetName(String & rName) const134cdf0e10cSrcweir 			void		GetName(String& rName) const	{ rName = aName; }
SetName(const String & rName)135cdf0e10cSrcweir 			void		SetName(const String& rName)	{ aName = rName; }
136cdf0e10cSrcweir 			void		GetArea(SCTAB& rTab, SCCOL& rCol1, SCROW& rRow1, SCCOL& rCol2, SCROW& rRow2) const;
137cdf0e10cSrcweir 			SC_DLLPUBLIC void		GetArea(ScRange& rRange) const;
138cdf0e10cSrcweir 			void		SetArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2);
139*22407013SOliver-Rainer Wittmann 
140*22407013SOliver-Rainer Wittmann             bool IsInternalUnnamed() const;
141*22407013SOliver-Rainer Wittmann             bool IsInternalForAutoFilter() const;
142*22407013SOliver-Rainer Wittmann 
143*22407013SOliver-Rainer Wittmann             void		MoveTo(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2);
IsByRow() const144cdf0e10cSrcweir 			sal_Bool		IsByRow() const 				{ return bByRow; }
SetByRow(sal_Bool bByR)145cdf0e10cSrcweir 			void		SetByRow(sal_Bool bByR) 			{ bByRow = bByR; }
HasHeader() const146cdf0e10cSrcweir 			sal_Bool		HasHeader() const 				{ return bHasHeader; }
SetHeader(sal_Bool bHasH)147cdf0e10cSrcweir 			void		SetHeader(sal_Bool bHasH) 			{ bHasHeader = bHasH; }
SetIndex(sal_uInt16 nInd)148cdf0e10cSrcweir             void        SetIndex(sal_uInt16 nInd)           { nIndex = nInd; }
GetIndex() const149cdf0e10cSrcweir 			sal_uInt16		GetIndex() const				{ return nIndex; }
IsDoSize() const150cdf0e10cSrcweir 			sal_Bool		IsDoSize() const				{ return bDoSize; }
SetDoSize(sal_Bool bSet)151cdf0e10cSrcweir 			void		SetDoSize(sal_Bool bSet)			{ bDoSize = bSet; }
IsKeepFmt() const152cdf0e10cSrcweir 			sal_Bool		IsKeepFmt() const				{ return bKeepFmt; }
SetKeepFmt(sal_Bool bSet)153cdf0e10cSrcweir 			void		SetKeepFmt(sal_Bool bSet)			{ bKeepFmt = bSet; }
IsStripData() const154cdf0e10cSrcweir 			sal_Bool		IsStripData() const				{ return bStripData; }
SetStripData(sal_Bool bSet)155cdf0e10cSrcweir 			void		SetStripData(sal_Bool bSet)			{ bStripData = bSet; }
156cdf0e10cSrcweir 
157cdf0e10cSrcweir //UNUSED2008-05  sal_Bool		IsBeyond(SCROW nMaxRow) const;
158cdf0e10cSrcweir 
159cdf0e10cSrcweir 			String		GetSourceString() const;
160cdf0e10cSrcweir 			String		GetOperations() const;
161cdf0e10cSrcweir 
162cdf0e10cSrcweir 			void		GetSortParam(ScSortParam& rSortParam) const;
163cdf0e10cSrcweir 			void		SetSortParam(const ScSortParam& rSortParam);
164cdf0e10cSrcweir 
165cdf0e10cSrcweir 			SC_DLLPUBLIC void		GetQueryParam(ScQueryParam& rQueryParam) const;
166cdf0e10cSrcweir 			SC_DLLPUBLIC void		SetQueryParam(const ScQueryParam& rQueryParam);
167cdf0e10cSrcweir 			SC_DLLPUBLIC sal_Bool		GetAdvancedQuerySource(ScRange& rSource) const;
168cdf0e10cSrcweir 			SC_DLLPUBLIC void		SetAdvancedQuerySource(const ScRange* pSource);
169cdf0e10cSrcweir 
170cdf0e10cSrcweir 			void		GetSubTotalParam(ScSubTotalParam& rSubTotalParam) const;
171cdf0e10cSrcweir 			void		SetSubTotalParam(const ScSubTotalParam& rSubTotalParam);
172cdf0e10cSrcweir 
173cdf0e10cSrcweir 			void		GetImportParam(ScImportParam& rImportParam) const;
174cdf0e10cSrcweir 			void		SetImportParam(const ScImportParam& rImportParam);
175cdf0e10cSrcweir 
176cdf0e10cSrcweir 			sal_Bool		IsDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_Bool bStartOnly) const;
177cdf0e10cSrcweir 			sal_Bool		IsDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const;
178cdf0e10cSrcweir 
HasImportParam() const179cdf0e10cSrcweir 			sal_Bool		HasImportParam() const	 { return bDBImport; }
HasQueryParam() const180cdf0e10cSrcweir 			sal_Bool		HasQueryParam() const	 { return bDoQuery[0]; }
HasSortParam() const181cdf0e10cSrcweir 			sal_Bool		HasSortParam() const	 { return bDoSort[0]; }
HasSubTotalParam() const182cdf0e10cSrcweir 			sal_Bool		HasSubTotalParam() const { return bDoSubTotal[0]; }
183cdf0e10cSrcweir 
HasImportSelection() const184cdf0e10cSrcweir 			sal_Bool		HasImportSelection() const		{ return bDBSelection; }
SetImportSelection(sal_Bool bSet)185cdf0e10cSrcweir 			void		SetImportSelection(sal_Bool bSet)	{ bDBSelection = bSet; }
186cdf0e10cSrcweir 
HasAutoFilter() const187cdf0e10cSrcweir 			sal_Bool		HasAutoFilter() const 		{ return bAutoFilter; }
SetAutoFilter(sal_Bool bSet)188cdf0e10cSrcweir 			void		SetAutoFilter(sal_Bool bSet)	{ bAutoFilter = bSet; }
189cdf0e10cSrcweir 
IsModified() const190cdf0e10cSrcweir 			sal_Bool		IsModified() const			{ return bModified; }
SetModified(sal_Bool bMod)191cdf0e10cSrcweir 			void		SetModified(sal_Bool bMod)		{ bModified = bMod; }
192cdf0e10cSrcweir };
193cdf0e10cSrcweir 
194cdf0e10cSrcweir 
195cdf0e10cSrcweir //------------------------------------------------------------------------
196cdf0e10cSrcweir class SC_DLLPUBLIC ScDBCollection : public ScSortedCollection
197cdf0e10cSrcweir {
198cdf0e10cSrcweir 
199cdf0e10cSrcweir private:
200cdf0e10cSrcweir 	Link		aRefreshHandler;
201cdf0e10cSrcweir 	ScDocument* pDoc;
202cdf0e10cSrcweir 	sal_uInt16 nEntryIndex;			// Zaehler fuer die eindeutigen Indizes
203cdf0e10cSrcweir 
204cdf0e10cSrcweir public:
ScDBCollection(sal_uInt16 nLim=4,sal_uInt16 nDel=4,sal_Bool bDup=sal_False,ScDocument * pDocument=NULL)205cdf0e10cSrcweir 	ScDBCollection(sal_uInt16 nLim = 4, sal_uInt16 nDel = 4, sal_Bool bDup = sal_False, ScDocument* pDocument = NULL) :
206cdf0e10cSrcweir 					ScSortedCollection	( nLim, nDel, bDup ),
207cdf0e10cSrcweir 					pDoc				( pDocument ),
208cdf0e10cSrcweir 					nEntryIndex			( SC_START_INDEX_DB_COLL )	// oberhalb der Namen
209cdf0e10cSrcweir 					{}
ScDBCollection(const ScDBCollection & rScDBCollection)210cdf0e10cSrcweir 	ScDBCollection(const ScDBCollection& rScDBCollection) :
211cdf0e10cSrcweir 					ScSortedCollection	( rScDBCollection ),
212cdf0e10cSrcweir 					pDoc 				( rScDBCollection.pDoc ),
213cdf0e10cSrcweir 					nEntryIndex			( rScDBCollection.nEntryIndex)
214cdf0e10cSrcweir 					{}
215cdf0e10cSrcweir 
Clone() const216cdf0e10cSrcweir 	virtual	ScDataObject*	Clone() const { return new ScDBCollection(*this); }
operator [](const sal_uInt16 nIndex) const217cdf0e10cSrcweir 			ScDBData*	operator[]( const sal_uInt16 nIndex) const {return (ScDBData*)At(nIndex);}
218cdf0e10cSrcweir 	virtual	short		Compare(ScDataObject* pKey1, ScDataObject* pKey2) const;
219cdf0e10cSrcweir 	virtual	sal_Bool		IsEqual(ScDataObject* pKey1, ScDataObject* pKey2) const;
220cdf0e10cSrcweir 			ScDBData*	GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_Bool bStartOnly) const;
221*22407013SOliver-Rainer Wittmann             ScDBData* GetDBAtArea(
222*22407013SOliver-Rainer Wittmann                 const SCTAB nTab,
223*22407013SOliver-Rainer Wittmann                 const SCCOL nCol1,
224*22407013SOliver-Rainer Wittmann                 const SCROW nRow1,
225*22407013SOliver-Rainer Wittmann                 const SCCOL nCol2,
226*22407013SOliver-Rainer Wittmann                 const SCROW nRow2 ) const;
227cdf0e10cSrcweir 			ScDBData*       GetFilterDBAtTable(SCTAB nTab) const;
228cdf0e10cSrcweir 
229cdf0e10cSrcweir 	sal_Bool	SearchName( const String& rName, sal_uInt16& rIndex ) const;
230cdf0e10cSrcweir 
231cdf0e10cSrcweir     void    DeleteOnTab( SCTAB nTab );
232cdf0e10cSrcweir 	void	UpdateReference(UpdateRefMode eUpdateRefMode,
233cdf0e10cSrcweir 								SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
234cdf0e10cSrcweir 								SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
235cdf0e10cSrcweir 								SCsCOL nDx, SCsROW nDy, SCsTAB nDz );
236cdf0e10cSrcweir 	void	UpdateMoveTab( SCTAB nOldPos, SCTAB nNewPos );
237cdf0e10cSrcweir 
238cdf0e10cSrcweir 	ScDBData* FindIndex(sal_uInt16 nIndex);
GetEntryIndex()239cdf0e10cSrcweir 	sal_uInt16 	GetEntryIndex()					{ return nEntryIndex; }
SetEntryIndex(sal_uInt16 nInd)240cdf0e10cSrcweir 	void 	SetEntryIndex(sal_uInt16 nInd)		{ nEntryIndex = nInd; }
241cdf0e10cSrcweir 	virtual sal_Bool Insert(ScDataObject* pScDataObject);
242cdf0e10cSrcweir 
SetRefreshHandler(const Link & rLink)243cdf0e10cSrcweir 	void			SetRefreshHandler( const Link& rLink )
244cdf0e10cSrcweir 						{ aRefreshHandler = rLink; }
GetRefreshHandler() const245cdf0e10cSrcweir 	const Link&		GetRefreshHandler() const	{ return aRefreshHandler; }
24657b4fa3cSWang Lei     String      GetNewDefaultDBName();
24757b4fa3cSWang Lei     /*sal_Bool        IsFiltered(SCTAB nTab, SCROW nRow);*/
248cdf0e10cSrcweir };
249cdf0e10cSrcweir 
250cdf0e10cSrcweir #endif
251