Bump version to 4.3-4
[LibreOffice.git] / sc / inc / dbdata.hxx
blobc42e970435418e4b9ee8ebe7cd64d5e39607e678
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SC_INC_DBDATA_HXX
21 #define INCLUDED_SC_INC_DBDATA_HXX
23 #include "scdllapi.h"
24 #include "refreshtimer.hxx"
25 #include "address.hxx"
26 #include "global.hxx"
28 #include <boost/ptr_container/ptr_vector.hpp>
29 #include <boost/ptr_container/ptr_set.hpp>
30 #include <boost/scoped_ptr.hpp>
32 class ScDocument;
33 struct ScSortParam;
34 struct ScQueryParam;
35 struct ScSubTotalParam;
36 struct ScImportParam;
38 class ScDBData : public ScRefreshTimer
40 private:
41 boost::scoped_ptr<ScSortParam> mpSortParam;
42 boost::scoped_ptr<ScQueryParam> mpQueryParam;
43 boost::scoped_ptr<ScSubTotalParam> mpSubTotal;
44 boost::scoped_ptr<ScImportParam> mpImportParam;
46 /// DBParam
47 const OUString aName;
48 OUString aUpper;
49 SCTAB nTable;
50 SCCOL nStartCol;
51 SCROW nStartRow;
52 SCCOL nEndCol;
53 SCROW nEndRow;
54 bool bByRow;
55 bool bHasHeader;
56 bool bDoSize;
57 bool bKeepFmt;
58 bool bStripData;
60 /// QueryParam
61 bool bIsAdvanced; ///< true if created by advanced filter
62 ScRange aAdvSource; ///< source range
64 bool bDBSelection; ///< not in Param: if selection, block update
66 sal_uInt16 nIndex; ///< unique index formulas
67 bool bAutoFilter; ///< AutoFilter? (not saved)
68 bool bModified; ///< is set/cleared for/by(?) UpdateReference
70 using ScRefreshTimer::operator==;
72 public:
73 struct less : public ::std::binary_function<ScDBData, ScDBData, bool>
75 bool operator() (const ScDBData& left, const ScDBData& right) const;
78 SC_DLLPUBLIC ScDBData(const OUString& rName,
79 SCTAB nTab,
80 SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
81 bool bByR = true, bool bHasH = true);
82 ScDBData(const ScDBData& rData);
83 ScDBData(const OUString& rName, const ScDBData& rData);
84 virtual ~ScDBData();
86 ScDBData& operator= (const ScDBData& rData);
88 bool operator== (const ScDBData& rData) const;
90 const OUString& GetName() const { return aName; }
91 const OUString& GetUpperName() const { return aUpper; }
92 void GetArea(SCTAB& rTab, SCCOL& rCol1, SCROW& rRow1, SCCOL& rCol2, SCROW& rRow2) const;
93 SC_DLLPUBLIC void GetArea(ScRange& rRange) const;
94 void SetArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2);
95 void MoveTo(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2);
96 bool IsByRow() const { return bByRow; }
97 void SetByRow(bool bByR) { bByRow = bByR; }
98 bool HasHeader() const { return bHasHeader; }
99 void SetHeader(bool bHasH) { bHasHeader = bHasH; }
100 void SetIndex(sal_uInt16 nInd) { nIndex = nInd; }
101 sal_uInt16 GetIndex() const { return nIndex; }
102 bool IsDoSize() const { return bDoSize; }
103 void SetDoSize(bool bSet) { bDoSize = bSet; }
104 bool IsKeepFmt() const { return bKeepFmt; }
105 void SetKeepFmt(bool bSet) { bKeepFmt = bSet; }
106 bool IsStripData() const { return bStripData; }
107 void SetStripData(bool bSet) { bStripData = bSet; }
109 OUString GetSourceString() const;
110 OUString GetOperations() const;
112 void GetSortParam(ScSortParam& rSortParam) const;
113 void SetSortParam(const ScSortParam& rSortParam);
115 SC_DLLPUBLIC void GetQueryParam(ScQueryParam& rQueryParam) const;
116 SC_DLLPUBLIC void SetQueryParam(const ScQueryParam& rQueryParam);
117 SC_DLLPUBLIC bool GetAdvancedQuerySource(ScRange& rSource) const;
118 SC_DLLPUBLIC void SetAdvancedQuerySource(const ScRange* pSource);
120 void GetSubTotalParam(ScSubTotalParam& rSubTotalParam) const;
121 void SetSubTotalParam(const ScSubTotalParam& rSubTotalParam);
123 void GetImportParam(ScImportParam& rImportParam) const;
124 void SetImportParam(const ScImportParam& rImportParam);
126 bool IsDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, bool bStartOnly) const;
127 bool IsDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const;
129 bool HasImportParam() const;
130 SC_DLLPUBLIC bool HasQueryParam() const;
131 bool HasSortParam() const;
132 bool HasSubTotalParam() const;
134 bool HasImportSelection() const { return bDBSelection; }
135 void SetImportSelection(bool bSet) { bDBSelection = bSet; }
137 bool HasAutoFilter() const { return bAutoFilter; }
138 void SetAutoFilter(bool bSet) { bAutoFilter = bSet; }
140 bool IsModified() const { return bModified; }
141 void SetModified(bool bMod) { bModified = bMod; }
143 void UpdateMoveTab( SCTAB nOldPos, SCTAB nNewPos );
144 void UpdateReference(ScDocument* pDoc, UpdateRefMode eUpdateRefMode,
145 SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
146 SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
147 SCsCOL nDx, SCsROW nDy, SCsTAB nDz);
149 void ExtendDataArea(ScDocument* pDoc);
152 class SC_DLLPUBLIC ScDBCollection
154 public:
155 enum RangeType { GlobalNamed, GlobalAnonymous, SheetAnonymous };
158 * Stores global named database ranges.
160 class SC_DLLPUBLIC NamedDBs
162 friend class ScDBCollection;
164 typedef ::boost::ptr_set<ScDBData, ScDBData::less> DBsType;
165 DBsType maDBs;
166 ScDBCollection& mrParent;
167 ScDocument& mrDoc;
168 NamedDBs(ScDBCollection& rParent, ScDocument& rDoc);
169 NamedDBs(const NamedDBs& r);
170 public:
171 typedef DBsType::iterator iterator;
172 typedef DBsType::const_iterator const_iterator;
174 iterator begin();
175 iterator end();
176 const_iterator begin() const;
177 const_iterator end() const;
178 ScDBData* findByIndex(sal_uInt16 nIndex);
179 ScDBData* findByUpperName(const OUString& rName);
180 // Takes ownership of p iff it returns true:
181 SAL_WARN_UNUSED_RESULT bool insert(ScDBData* p);
182 void erase(iterator itr);
183 void erase(const ScDBData& r);
184 bool empty() const;
185 size_t size() const;
186 bool operator== (const NamedDBs& r) const;
190 * Stores global anonymous database ranges.
192 class AnonDBs
194 typedef ::boost::ptr_vector<ScDBData> DBsType;
195 DBsType maDBs;
196 public:
197 typedef DBsType::iterator iterator;
198 typedef DBsType::const_iterator const_iterator;
200 iterator begin();
201 iterator end();
202 const_iterator begin() const;
203 const_iterator end() const;
204 const ScDBData* findAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, bool bStartOnly) const;
205 const ScDBData* findByRange(const ScRange& rRange) const;
206 ScDBData* getByRange(const ScRange& rRange);
207 void insert(ScDBData* p);
208 bool empty() const;
209 bool operator== (const AnonDBs& r) const;
212 private:
213 Link aRefreshHandler;
214 ScDocument* pDoc;
215 sal_uInt16 nEntryIndex; ///< counter for unique indices
216 NamedDBs maNamedDBs;
217 AnonDBs maAnonDBs;
219 public:
220 ScDBCollection(ScDocument* pDocument);
221 ScDBCollection(const ScDBCollection& r);
223 NamedDBs& getNamedDBs();
224 const NamedDBs& getNamedDBs() const;
226 AnonDBs& getAnonDBs();
227 const AnonDBs& getAnonDBs() const;
229 const ScDBData* GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, bool bStartOnly) const;
230 ScDBData* GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, bool bStartOnly);
231 const ScDBData* GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const;
232 ScDBData* GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2);
233 ScDBData* GetDBNearCursor(SCCOL nCol, SCROW nRow, SCTAB nTab );
235 void DeleteOnTab( SCTAB nTab );
236 void UpdateReference(UpdateRefMode eUpdateRefMode,
237 SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
238 SCCOL nCol2, SCROW nRow2, SCTAB nTab2,
239 SCsCOL nDx, SCsROW nDy, SCsTAB nDz);
240 void UpdateMoveTab( SCTAB nOldPos, SCTAB nNewPos );
242 sal_uInt16 GetEntryIndex() { return nEntryIndex; }
243 void SetEntryIndex(sal_uInt16 nInd) { nEntryIndex = nInd; }
245 void SetRefreshHandler( const Link& rLink )
246 { aRefreshHandler = rLink; }
247 const Link& GetRefreshHandler() const { return aRefreshHandler; }
249 bool empty() const;
250 bool operator== (const ScDBCollection& r) const;
253 #endif
255 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */