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 //------------------------------------------------------------------------
45 class ScMultipleReadHeader
;
46 class ScMultipleWriteHeader
;
48 //------------------------------------------------------------------------
50 class ScDBData
: public ScDataObject
, public ScRefreshTimer
68 BOOL bSortNaturalSort
;
72 USHORT nSortUserIndex
;
76 BOOL bDoSort
[MAXSORT
];
77 SCCOLROW nSortField
[MAXSORT
];
78 BOOL bAscending
[MAXSORT
];
79 ::com::sun::star::lang::Locale aSortLocale
;
80 String aSortAlgorithm
;
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
106 BOOL bSubIncludePattern
;
108 USHORT nSubUserIndex
;
109 BOOL bDoSubTotal
[MAXSUBTOTAL
];
110 SCCOL nSubField
[MAXSUBTOTAL
];
111 SCCOL nSubTotals
[MAXSUBTOTAL
];
112 SCCOL
* pSubTotals
[MAXSUBTOTAL
];
113 ScSubTotalFunc
* pFunctions
[MAXSUBTOTAL
];
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==;
130 SC_DLLPUBLIC
ScDBData(const String
& rName
,
132 SCCOL nCol1
, SCROW nRow1
, SCCOL nCol2
, SCROW nRow2
,
133 BOOL bByR
= TRUE
, BOOL bHasH
= TRUE
);
134 ScDBData(const ScDBData
& rData
);
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
207 Link aRefreshHandler
;
209 USHORT nEntryIndex
; // Zaehler fuer die eindeutigen Indizes
212 ScDBCollection(USHORT nLim
= 4, USHORT nDel
= 4, BOOL bDup
= FALSE
, ScDocument
* pDocument
= NULL
) :
213 ScSortedCollection ( nLim
, nDel
, bDup
),
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
; }