sync master with lastest vba changes
[ooovba.git] / sc / inc / dbcolect.hxx
blobfeeec81020bb269be296a3c5269418c61c279e0b
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;
45 class ScMultipleReadHeader;
46 class ScMultipleWriteHeader;
48 //------------------------------------------------------------------------
50 class ScDBData : public ScDataObject, public ScRefreshTimer
53 private:
54 // DBParam
55 String aName;
56 SCTAB nTable;
57 SCCOL nStartCol;
58 SCROW nStartRow;
59 SCCOL nEndCol;
60 SCROW nEndRow;
61 BOOL bByRow;
62 BOOL bHasHeader;
63 BOOL bDoSize;
64 BOOL bKeepFmt;
65 BOOL bStripData;
66 // SortParam
67 BOOL bSortCaseSens;
68 BOOL bSortNaturalSort;
69 BOOL bIncludePattern;
70 BOOL bSortInplace;
71 BOOL bSortUserDef;
72 USHORT nSortUserIndex;
73 SCTAB nSortDestTab;
74 SCCOL nSortDestCol;
75 SCROW nSortDestRow;
76 BOOL bDoSort[MAXSORT];
77 SCCOLROW nSortField[MAXSORT];
78 BOOL bAscending[MAXSORT];
79 ::com::sun::star::lang::Locale aSortLocale;
80 String aSortAlgorithm;
81 // QueryParam
82 BOOL bQueryInplace;
83 BOOL bQueryCaseSens;
84 BOOL bQueryRegExp;
85 BOOL bQueryDuplicate;
86 SCTAB nQueryDestTab;
87 SCCOL nQueryDestCol;
88 SCROW nQueryDestRow;
89 BOOL bDoQuery[MAXQUERY];
90 SCCOLROW nQueryField[MAXQUERY];
91 ScQueryOp eQueryOp[MAXQUERY];
92 BOOL bQueryByString[MAXQUERY];
93 String* pQueryStr[MAXQUERY];
94 double nQueryVal[MAXQUERY];
95 ScQueryConnect eQueryConnect[MAXQUERY];
96 BOOL bIsAdvanced; // TRUE if created by advanced filter
97 ScRange aAdvSource; // source range
98 SCROW nDynamicEndRow;
99 // SubTotalParam
100 BOOL bSubRemoveOnly;
101 BOOL bSubReplace;
102 BOOL bSubPagebreak;
103 BOOL bSubCaseSens;
104 BOOL bSubDoSort;
105 BOOL bSubAscending;
106 BOOL bSubIncludePattern;
107 BOOL bSubUserDef;
108 USHORT nSubUserIndex;
109 BOOL bDoSubTotal[MAXSUBTOTAL];
110 SCCOL nSubField[MAXSUBTOTAL];
111 SCCOL nSubTotals[MAXSUBTOTAL];
112 SCCOL* pSubTotals[MAXSUBTOTAL];
113 ScSubTotalFunc* pFunctions[MAXSUBTOTAL];
114 // Datenbank-Import
115 BOOL bDBImport;
116 String aDBName;
117 String aDBStatement;
118 BOOL bDBNative;
119 BOOL bDBSelection; // nicht im Param: Wenn Selektion, Update sperren
120 BOOL bDBSql; // aDBStatement ist SQL und kein Name
121 BYTE nDBType; // enum DBObject (bisher nur dbTable, dbQuery)
123 USHORT nIndex; // eindeutiger Index fuer Formeln
124 BOOL bAutoFilter; // AutoFilter? (nicht gespeichert)
125 BOOL bModified; // wird bei UpdateReference gesetzt/geloescht
127 using ScRefreshTimer::operator==;
129 public:
130 SC_DLLPUBLIC ScDBData(const String& rName,
131 SCTAB nTab,
132 SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
133 BOOL bByR = TRUE, BOOL bHasH = TRUE);
134 ScDBData(const ScDBData& rData);
135 ~ScDBData();
137 virtual ScDataObject* Clone() const;
139 ScDBData& operator= (const ScDBData& rData);
141 BOOL operator== (const ScDBData& rData) const;
143 const String& GetName() const { return aName; }
144 void GetName(String& rName) const { rName = aName; }
145 void SetName(const String& rName) { aName = rName; }
146 void GetArea(SCTAB& rTab, SCCOL& rCol1, SCROW& rRow1, SCCOL& rCol2, SCROW& rRow2, bool bUseDynamicRange = false) const;
147 SC_DLLPUBLIC void GetArea(ScRange& rRange, bool bUseDynamicRange = false) const;
148 void SetArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2);
149 void SetDynamicEndRow(SCROW nRow);
150 void MoveTo(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2);
151 BOOL IsByRow() const { return bByRow; }
152 void SetByRow(BOOL bByR) { bByRow = bByR; }
153 BOOL HasHeader() const { return bHasHeader; }
154 void SetHeader(BOOL bHasH) { bHasHeader = bHasH; }
155 void SetIndex(USHORT nInd) { nIndex = nInd; }
156 USHORT GetIndex() const { return nIndex; }
157 BOOL IsDoSize() const { return bDoSize; }
158 void SetDoSize(BOOL bSet) { bDoSize = bSet; }
159 BOOL IsKeepFmt() const { return bKeepFmt; }
160 void SetKeepFmt(BOOL bSet) { bKeepFmt = bSet; }
161 BOOL IsStripData() const { return bStripData; }
162 void SetStripData(BOOL bSet) { bStripData = bSet; }
164 //UNUSED2008-05 BOOL IsBeyond(SCROW nMaxRow) const;
166 String GetSourceString() const;
167 String GetOperations() const;
169 void GetSortParam(ScSortParam& rSortParam) const;
170 void SetSortParam(const ScSortParam& rSortParam);
172 SC_DLLPUBLIC void GetQueryParam(ScQueryParam& rQueryParam) const;
173 SC_DLLPUBLIC void SetQueryParam(const ScQueryParam& rQueryParam);
174 SC_DLLPUBLIC BOOL GetAdvancedQuerySource(ScRange& rSource) const;
175 SC_DLLPUBLIC void SetAdvancedQuerySource(const ScRange* pSource);
177 void GetSubTotalParam(ScSubTotalParam& rSubTotalParam) const;
178 void SetSubTotalParam(const ScSubTotalParam& rSubTotalParam);
180 void GetImportParam(ScImportParam& rImportParam) const;
181 void SetImportParam(const ScImportParam& rImportParam);
183 BOOL IsDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, BOOL bStartOnly) const;
184 BOOL IsDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const;
186 BOOL HasImportParam() const { return bDBImport; }
187 BOOL HasQueryParam() const { return bDoQuery[0]; }
188 BOOL HasSortParam() const { return bDoSort[0]; }
189 BOOL HasSubTotalParam() const { return bDoSubTotal[0]; }
191 BOOL HasImportSelection() const { return bDBSelection; }
192 void SetImportSelection(BOOL bSet) { bDBSelection = bSet; }
194 BOOL HasAutoFilter() const { return bAutoFilter; }
195 void SetAutoFilter(BOOL bSet) { bAutoFilter = bSet; }
197 BOOL IsModified() const { return bModified; }
198 void SetModified(BOOL bMod) { bModified = bMod; }
202 //------------------------------------------------------------------------
203 class SC_DLLPUBLIC ScDBCollection : public ScSortedCollection
206 private:
207 Link aRefreshHandler;
208 ScDocument* pDoc;
209 USHORT nEntryIndex; // Zaehler fuer die eindeutigen Indizes
211 public:
212 ScDBCollection(USHORT nLim = 4, USHORT nDel = 4, BOOL bDup = FALSE, ScDocument* pDocument = NULL) :
213 ScSortedCollection ( nLim, nDel, bDup ),
214 pDoc ( pDocument ),
215 nEntryIndex ( SC_START_INDEX_DB_COLL ) // oberhalb der Namen
217 ScDBCollection(const ScDBCollection& rScDBCollection) :
218 ScSortedCollection ( rScDBCollection ),
219 pDoc ( rScDBCollection.pDoc ),
220 nEntryIndex ( rScDBCollection.nEntryIndex)
223 virtual ScDataObject* Clone() const { return new ScDBCollection(*this); }
224 ScDBData* operator[]( const USHORT nIndex) const {return (ScDBData*)At(nIndex);}
225 virtual short Compare(ScDataObject* pKey1, ScDataObject* pKey2) const;
226 virtual BOOL IsEqual(ScDataObject* pKey1, ScDataObject* pKey2) const;
227 ScDBData* GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, BOOL bStartOnly) const;
228 ScDBData* GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const;
230 BOOL SearchName( const String& rName, USHORT& rIndex ) const;
232 void DeleteOnTab( SCTAB nTab );
233 void UpdateReference(UpdateRefMode eUpdateRefMode,
234 SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
235 SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
236 SCsCOL nDx, SCsROW nDy, SCsTAB nDz );
237 void UpdateMoveTab( SCTAB nOldPos, SCTAB nNewPos );
239 ScDBData* FindIndex(USHORT nIndex);
240 USHORT GetEntryIndex() { return nEntryIndex; }
241 void SetEntryIndex(USHORT nInd) { nEntryIndex = nInd; }
242 virtual BOOL Insert(ScDataObject* pScDataObject);
244 void SetRefreshHandler( const Link& rLink )
245 { aRefreshHandler = rLink; }
246 const Link& GetRefreshHandler() const { return aRefreshHandler; }
249 #endif