update dev300-m57
[ooovba.git] / sc / inc / dbcolect.hxx
blobe41ccfa3be60678f8bf960043456fcdee31f89a6
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dbcolect.hxx,v $
10 * $Revision: 1.13.32.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SC_DBCOLECT_HXX
32 #define SC_DBCOLECT_HXX
34 #include "scdllapi.h"
35 #include "collect.hxx"
36 #include "global.hxx" // MAXQUERY
37 #include "sortparam.hxx" // MAXSORT
38 #include "refreshtimer.hxx"
39 #include "address.hxx"
40 #include "scdllapi.h"
42 //------------------------------------------------------------------------
44 class ScDocument;
46 //------------------------------------------------------------------------
48 class ScDBData : public ScDataObject, public ScRefreshTimer
51 private:
52 // DBParam
53 String aName;
54 SCTAB nTable;
55 SCCOL nStartCol;
56 SCROW nStartRow;
57 SCCOL nEndCol;
58 SCROW nEndRow;
59 BOOL bByRow;
60 BOOL bHasHeader;
61 BOOL bDoSize;
62 BOOL bKeepFmt;
63 BOOL bStripData;
64 // SortParam
65 BOOL bSortCaseSens;
66 BOOL bSortNaturalSort;
67 BOOL bIncludePattern;
68 BOOL bSortInplace;
69 BOOL bSortUserDef;
70 USHORT nSortUserIndex;
71 SCTAB nSortDestTab;
72 SCCOL nSortDestCol;
73 SCROW nSortDestRow;
74 BOOL bDoSort[MAXSORT];
75 SCCOLROW nSortField[MAXSORT];
76 BOOL bAscending[MAXSORT];
77 ::com::sun::star::lang::Locale aSortLocale;
78 String aSortAlgorithm;
79 // QueryParam
80 BOOL bQueryInplace;
81 BOOL bQueryCaseSens;
82 BOOL bQueryRegExp;
83 BOOL bQueryDuplicate;
84 SCTAB nQueryDestTab;
85 SCCOL nQueryDestCol;
86 SCROW nQueryDestRow;
87 BOOL bDoQuery[MAXQUERY];
88 SCCOLROW nQueryField[MAXQUERY];
89 ScQueryOp eQueryOp[MAXQUERY];
90 BOOL bQueryByString[MAXQUERY];
91 String* pQueryStr[MAXQUERY];
92 double nQueryVal[MAXQUERY];
93 ScQueryConnect eQueryConnect[MAXQUERY];
94 BOOL bIsAdvanced; // TRUE if created by advanced filter
95 ScRange aAdvSource; // source range
96 SCROW nDynamicEndRow;
97 // SubTotalParam
98 BOOL bSubRemoveOnly;
99 BOOL bSubReplace;
100 BOOL bSubPagebreak;
101 BOOL bSubCaseSens;
102 BOOL bSubDoSort;
103 BOOL bSubAscending;
104 BOOL bSubIncludePattern;
105 BOOL bSubUserDef;
106 USHORT nSubUserIndex;
107 BOOL bDoSubTotal[MAXSUBTOTAL];
108 SCCOL nSubField[MAXSUBTOTAL];
109 SCCOL nSubTotals[MAXSUBTOTAL];
110 SCCOL* pSubTotals[MAXSUBTOTAL];
111 ScSubTotalFunc* pFunctions[MAXSUBTOTAL];
112 // Datenbank-Import
113 BOOL bDBImport;
114 String aDBName;
115 String aDBStatement;
116 BOOL bDBNative;
117 BOOL bDBSelection; // nicht im Param: Wenn Selektion, Update sperren
118 BOOL bDBSql; // aDBStatement ist SQL und kein Name
119 BYTE nDBType; // enum DBObject (bisher nur dbTable, dbQuery)
121 USHORT nIndex; // eindeutiger Index fuer Formeln
122 BOOL bAutoFilter; // AutoFilter? (nicht gespeichert)
123 BOOL bModified; // wird bei UpdateReference gesetzt/geloescht
125 using ScRefreshTimer::operator==;
127 public:
128 SC_DLLPUBLIC ScDBData(const String& rName,
129 SCTAB nTab,
130 SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
131 BOOL bByR = TRUE, BOOL bHasH = TRUE);
132 ScDBData(const ScDBData& rData);
133 ~ScDBData();
135 virtual ScDataObject* Clone() const;
137 ScDBData& operator= (const ScDBData& rData);
139 BOOL operator== (const ScDBData& rData) const;
141 const String& GetName() const { return aName; }
142 void GetName(String& rName) const { rName = aName; }
143 void SetName(const String& rName) { aName = rName; }
144 void GetArea(SCTAB& rTab, SCCOL& rCol1, SCROW& rRow1, SCCOL& rCol2, SCROW& rRow2, bool bUseDynamicRange = false) const;
145 SC_DLLPUBLIC void GetArea(ScRange& rRange, bool bUseDynamicRange = false) const;
146 void SetArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2);
147 void SetDynamicEndRow(SCROW nRow);
148 void MoveTo(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2);
149 BOOL IsByRow() const { return bByRow; }
150 void SetByRow(BOOL bByR) { bByRow = bByR; }
151 BOOL HasHeader() const { return bHasHeader; }
152 void SetHeader(BOOL bHasH) { bHasHeader = bHasH; }
153 void SetIndex(USHORT nInd) { nIndex = nInd; }
154 USHORT GetIndex() const { return nIndex; }
155 BOOL IsDoSize() const { return bDoSize; }
156 void SetDoSize(BOOL bSet) { bDoSize = bSet; }
157 BOOL IsKeepFmt() const { return bKeepFmt; }
158 void SetKeepFmt(BOOL bSet) { bKeepFmt = bSet; }
159 BOOL IsStripData() const { return bStripData; }
160 void SetStripData(BOOL bSet) { bStripData = bSet; }
162 //UNUSED2008-05 BOOL IsBeyond(SCROW nMaxRow) const;
164 String GetSourceString() const;
165 String GetOperations() const;
167 void GetSortParam(ScSortParam& rSortParam) const;
168 void SetSortParam(const ScSortParam& rSortParam);
170 SC_DLLPUBLIC void GetQueryParam(ScQueryParam& rQueryParam) const;
171 SC_DLLPUBLIC void SetQueryParam(const ScQueryParam& rQueryParam);
172 SC_DLLPUBLIC BOOL GetAdvancedQuerySource(ScRange& rSource) const;
173 SC_DLLPUBLIC void SetAdvancedQuerySource(const ScRange* pSource);
175 void GetSubTotalParam(ScSubTotalParam& rSubTotalParam) const;
176 void SetSubTotalParam(const ScSubTotalParam& rSubTotalParam);
178 void GetImportParam(ScImportParam& rImportParam) const;
179 void SetImportParam(const ScImportParam& rImportParam);
181 BOOL IsDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, BOOL bStartOnly) const;
182 BOOL IsDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const;
184 BOOL HasImportParam() const { return bDBImport; }
185 BOOL HasQueryParam() const { return bDoQuery[0]; }
186 BOOL HasSortParam() const { return bDoSort[0]; }
187 BOOL HasSubTotalParam() const { return bDoSubTotal[0]; }
189 BOOL HasImportSelection() const { return bDBSelection; }
190 void SetImportSelection(BOOL bSet) { bDBSelection = bSet; }
192 BOOL HasAutoFilter() const { return bAutoFilter; }
193 void SetAutoFilter(BOOL bSet) { bAutoFilter = bSet; }
195 BOOL IsModified() const { return bModified; }
196 void SetModified(BOOL bMod) { bModified = bMod; }
200 //------------------------------------------------------------------------
201 class SC_DLLPUBLIC ScDBCollection : public ScSortedCollection
204 private:
205 Link aRefreshHandler;
206 ScDocument* pDoc;
207 USHORT nEntryIndex; // Zaehler fuer die eindeutigen Indizes
209 public:
210 ScDBCollection(USHORT nLim = 4, USHORT nDel = 4, BOOL bDup = FALSE, ScDocument* pDocument = NULL) :
211 ScSortedCollection ( nLim, nDel, bDup ),
212 pDoc ( pDocument ),
213 nEntryIndex ( SC_START_INDEX_DB_COLL ) // oberhalb der Namen
215 ScDBCollection(const ScDBCollection& rScDBCollection) :
216 ScSortedCollection ( rScDBCollection ),
217 pDoc ( rScDBCollection.pDoc ),
218 nEntryIndex ( rScDBCollection.nEntryIndex)
221 virtual ScDataObject* Clone() const { return new ScDBCollection(*this); }
222 ScDBData* operator[]( const USHORT nIndex) const {return (ScDBData*)At(nIndex);}
223 virtual short Compare(ScDataObject* pKey1, ScDataObject* pKey2) const;
224 virtual BOOL IsEqual(ScDataObject* pKey1, ScDataObject* pKey2) const;
225 ScDBData* GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, BOOL bStartOnly) const;
226 ScDBData* GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const;
228 BOOL SearchName( const String& rName, USHORT& rIndex ) const;
230 void DeleteOnTab( SCTAB nTab );
231 void UpdateReference(UpdateRefMode eUpdateRefMode,
232 SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
233 SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
234 SCsCOL nDx, SCsROW nDy, SCsTAB nDz );
235 void UpdateMoveTab( SCTAB nOldPos, SCTAB nNewPos );
237 ScDBData* FindIndex(USHORT nIndex);
238 USHORT GetEntryIndex() { return nEntryIndex; }
239 void SetEntryIndex(USHORT nInd) { nEntryIndex = nInd; }
240 virtual BOOL Insert(ScDataObject* pScDataObject);
242 void SetRefreshHandler( const Link& rLink )
243 { aRefreshHandler = rLink; }
244 const Link& GetRefreshHandler() const { return aRefreshHandler; }
247 #endif