1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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
35 #include "collect.hxx"
36 #include "global.hxx" // MAXQUERY
37 #include "sortparam.hxx" // MAXSORT
38 #include "refreshtimer.hxx"
39 #include "address.hxx"
42 //------------------------------------------------------------------------
46 //------------------------------------------------------------------------
48 class ScDBData
: public ScDataObject
, public ScRefreshTimer
66 BOOL bSortNaturalSort
;
70 USHORT nSortUserIndex
;
74 BOOL bDoSort
[MAXSORT
];
75 SCCOLROW nSortField
[MAXSORT
];
76 BOOL bAscending
[MAXSORT
];
77 ::com::sun::star::lang::Locale aSortLocale
;
78 String aSortAlgorithm
;
87 BOOL bDoQuery
[MAXQUERY
];
88 SCCOLROW nQueryField
[MAXQUERY
];
89 ScQueryOp eQueryOp
[MAXQUERY
];
90 BOOL bQueryByString
[MAXQUERY
];
91 bool bQueryByDate
[MAXQUERY
];
92 String
* pQueryStr
[MAXQUERY
];
93 double nQueryVal
[MAXQUERY
];
94 ScQueryConnect eQueryConnect
[MAXQUERY
];
95 BOOL bIsAdvanced
; // TRUE if created by advanced filter
96 ScRange aAdvSource
; // source range
105 BOOL bSubIncludePattern
;
107 USHORT nSubUserIndex
;
108 BOOL bDoSubTotal
[MAXSUBTOTAL
];
109 SCCOL nSubField
[MAXSUBTOTAL
];
110 SCCOL nSubTotals
[MAXSUBTOTAL
];
111 SCCOL
* pSubTotals
[MAXSUBTOTAL
];
112 ScSubTotalFunc
* pFunctions
[MAXSUBTOTAL
];
118 BOOL bDBSelection
; // nicht im Param: Wenn Selektion, Update sperren
119 BOOL bDBSql
; // aDBStatement ist SQL und kein Name
120 BYTE nDBType
; // enum DBObject (bisher nur dbTable, dbQuery)
122 USHORT nIndex
; // eindeutiger Index fuer Formeln
123 BOOL bAutoFilter
; // AutoFilter? (nicht gespeichert)
124 BOOL bModified
; // wird bei UpdateReference gesetzt/geloescht
126 using ScRefreshTimer::operator==;
129 SC_DLLPUBLIC
ScDBData(const String
& rName
,
131 SCCOL nCol1
, SCROW nRow1
, SCCOL nCol2
, SCROW nRow2
,
132 BOOL bByR
= TRUE
, BOOL bHasH
= TRUE
);
133 ScDBData(const ScDBData
& rData
);
136 virtual ScDataObject
* Clone() const;
138 ScDBData
& operator= (const ScDBData
& rData
);
140 BOOL
operator== (const ScDBData
& rData
) const;
142 const String
& GetName() const { return aName
; }
143 void GetName(String
& rName
) const { rName
= aName
; }
144 void SetName(const String
& rName
) { aName
= rName
; }
145 void GetArea(SCTAB
& rTab
, SCCOL
& rCol1
, SCROW
& rRow1
, SCCOL
& rCol2
, SCROW
& rRow2
, bool bUseDynamicRange
= false) const;
146 SC_DLLPUBLIC
void GetArea(ScRange
& rRange
, bool bUseDynamicRange
= false) const;
147 void SetArea(SCTAB nTab
, SCCOL nCol1
, SCROW nRow1
, SCCOL nCol2
, SCROW nRow2
);
148 void SetDynamicEndRow(SCROW nRow
);
149 void MoveTo(SCTAB nTab
, SCCOL nCol1
, SCROW nRow1
, SCCOL nCol2
, SCROW nRow2
);
150 BOOL
IsByRow() const { return bByRow
; }
151 void SetByRow(BOOL bByR
) { bByRow
= bByR
; }
152 BOOL
HasHeader() const { return bHasHeader
; }
153 void SetHeader(BOOL bHasH
) { bHasHeader
= bHasH
; }
154 void SetIndex(USHORT nInd
) { nIndex
= nInd
; }
155 USHORT
GetIndex() const { return nIndex
; }
156 BOOL
IsDoSize() const { return bDoSize
; }
157 void SetDoSize(BOOL bSet
) { bDoSize
= bSet
; }
158 BOOL
IsKeepFmt() const { return bKeepFmt
; }
159 void SetKeepFmt(BOOL bSet
) { bKeepFmt
= bSet
; }
160 BOOL
IsStripData() const { return bStripData
; }
161 void SetStripData(BOOL bSet
) { bStripData
= bSet
; }
163 //UNUSED2008-05 BOOL IsBeyond(SCROW nMaxRow) const;
165 String
GetSourceString() const;
166 String
GetOperations() const;
168 void GetSortParam(ScSortParam
& rSortParam
) const;
169 void SetSortParam(const ScSortParam
& rSortParam
);
171 SC_DLLPUBLIC
void GetQueryParam(ScQueryParam
& rQueryParam
) const;
172 SC_DLLPUBLIC
void SetQueryParam(const ScQueryParam
& rQueryParam
);
173 SC_DLLPUBLIC BOOL
GetAdvancedQuerySource(ScRange
& rSource
) const;
174 SC_DLLPUBLIC
void SetAdvancedQuerySource(const ScRange
* pSource
);
176 void GetSubTotalParam(ScSubTotalParam
& rSubTotalParam
) const;
177 void SetSubTotalParam(const ScSubTotalParam
& rSubTotalParam
);
179 void GetImportParam(ScImportParam
& rImportParam
) const;
180 void SetImportParam(const ScImportParam
& rImportParam
);
182 BOOL
IsDBAtCursor(SCCOL nCol
, SCROW nRow
, SCTAB nTab
, BOOL bStartOnly
) const;
183 BOOL
IsDBAtArea(SCTAB nTab
, SCCOL nCol1
, SCROW nRow1
, SCCOL nCol2
, SCROW nRow2
) const;
185 BOOL
HasImportParam() const { return bDBImport
; }
186 BOOL
HasQueryParam() const { return bDoQuery
[0]; }
187 BOOL
HasSortParam() const { return bDoSort
[0]; }
188 BOOL
HasSubTotalParam() const { return bDoSubTotal
[0]; }
190 BOOL
HasImportSelection() const { return bDBSelection
; }
191 void SetImportSelection(BOOL bSet
) { bDBSelection
= bSet
; }
193 BOOL
HasAutoFilter() const { return bAutoFilter
; }
194 void SetAutoFilter(BOOL bSet
) { bAutoFilter
= bSet
; }
196 BOOL
IsModified() const { return bModified
; }
197 void SetModified(BOOL bMod
) { bModified
= bMod
; }
201 //------------------------------------------------------------------------
202 class SC_DLLPUBLIC ScDBCollection
: public ScSortedCollection
206 Link aRefreshHandler
;
208 USHORT nEntryIndex
; // Zaehler fuer die eindeutigen Indizes
211 ScDBCollection(USHORT nLim
= 4, USHORT nDel
= 4, BOOL bDup
= FALSE
, ScDocument
* pDocument
= NULL
) :
212 ScSortedCollection ( nLim
, nDel
, bDup
),
214 nEntryIndex ( SC_START_INDEX_DB_COLL
) // oberhalb der Namen
216 ScDBCollection(const ScDBCollection
& rScDBCollection
) :
217 ScSortedCollection ( rScDBCollection
),
218 pDoc ( rScDBCollection
.pDoc
),
219 nEntryIndex ( rScDBCollection
.nEntryIndex
)
222 virtual ScDataObject
* Clone() const { return new ScDBCollection(*this); }
223 ScDBData
* operator[]( const USHORT nIndex
) const {return (ScDBData
*)At(nIndex
);}
224 virtual short Compare(ScDataObject
* pKey1
, ScDataObject
* pKey2
) const;
225 virtual BOOL
IsEqual(ScDataObject
* pKey1
, ScDataObject
* pKey2
) const;
226 ScDBData
* GetDBAtCursor(SCCOL nCol
, SCROW nRow
, SCTAB nTab
, BOOL bStartOnly
) const;
227 ScDBData
* GetDBAtArea(SCTAB nTab
, SCCOL nCol1
, SCROW nRow1
, SCCOL nCol2
, SCROW nRow2
) const;
229 BOOL
SearchName( const String
& rName
, USHORT
& rIndex
) const;
231 void DeleteOnTab( SCTAB nTab
);
232 void UpdateReference(UpdateRefMode eUpdateRefMode
,
233 SCCOL nCol1
, SCROW nRow1
, SCTAB nTab1
,
234 SCCOL nCol2
, SCROW nRow2
, SCTAB nTab2
,
235 SCsCOL nDx
, SCsROW nDy
, SCsTAB nDz
);
236 void UpdateMoveTab( SCTAB nOldPos
, SCTAB nNewPos
);
238 ScDBData
* FindIndex(USHORT nIndex
);
239 USHORT
GetEntryIndex() { return nEntryIndex
; }
240 void SetEntryIndex(USHORT nInd
) { nEntryIndex
= nInd
; }
241 virtual BOOL
Insert(ScDataObject
* pScDataObject
);
243 void SetRefreshHandler( const Link
& rLink
)
244 { aRefreshHandler
= rLink
; }
245 const Link
& GetRefreshHandler() const { return aRefreshHandler
; }