Update ooo320-m1
[ooovba.git] / sc / source / core / inc / doubleref.hxx
blob0aa577b99c45f9b2585023621e00a4c024fc97b1
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: interpre.hxx,v $
10 * $Revision: 1.35.44.2 $
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_DOUBLEREF_HXX
32 #define SC_DOUBLEREF_HXX
34 #include "address.hxx"
35 #include "scmatrix.hxx"
37 class ScDocument;
38 class ScBaseCell;
39 class ScDBQueryParamBase;
40 class ScQueryParamBase;
42 // ============================================================================
44 /**
45 * Base class for abstracting range data backends for database functions.
47 class ScDBRangeBase
49 public:
50 enum RefType { INTERNAL, EXTERNAL };
52 virtual ~ScDBRangeBase() = 0;
54 RefType getType() const;
55 bool fillQueryEntries(ScQueryParamBase* pParam, const ScDBRangeBase* pDBRef) const;
57 virtual SCCOL getColSize() const = 0;
58 virtual SCROW getRowSize() const = 0;
59 virtual SCSIZE getVisibleDataCellCount() const = 0;
61 /**
62 * Get a string value of a specified cell position. Note that the
63 * position of the upper left cell of the range is always (0, 0) even if
64 * the reference type is of internal range.
66 * @param nCol column position (0 to column size-1)
67 * @param nRow row position (0 to row size-1)
69 virtual ::rtl::OUString getString(SCCOL nCol, SCROW nRow) const = 0;
71 virtual SCCOL getFirstFieldColumn() const = 0;
73 /**
74 * Get a <i>0-based</i> column index that corresponds with the passed field
75 * index. Note that the field index passed as the 1st parameter is
76 * <i>1-based.</i>
78 * @param nIndex 1-based field index.
80 * @return 0-based column index
82 virtual SCCOL findFieldColumn(SCCOL nIndex) const = 0;
83 virtual SCCOL findFieldColumn(const ::rtl::OUString& rStr, sal_uInt16* pErr = NULL) const = 0;
84 virtual ScDBQueryParamBase* createQueryParam(const ScDBRangeBase* pQueryRef) const = 0;
85 virtual bool isRangeEqual(const ScRange& rRange) const = 0;
87 protected:
88 ScDBRangeBase(ScDocument* pDoc, RefType eType);
89 ScDocument* getDoc() const;
91 /**
92 * Populate query options that are always the same for all database
93 * queries.
95 static void fillQueryOptions(ScQueryParamBase* pParam);
97 private:
98 ScDBRangeBase(); // disabled
100 ScDocument* mpDoc;
101 RefType meType;
104 // ============================================================================
106 class ScDBInternalRange : public ScDBRangeBase
108 public:
109 explicit ScDBInternalRange(ScDocument* pDoc, const ScRange& rRange);
110 virtual ~ScDBInternalRange();
112 const ScRange& getRange() const;
114 virtual SCCOL getColSize() const;
115 virtual SCROW getRowSize() const;
116 virtual SCSIZE getVisibleDataCellCount() const;
118 /**
119 * Get a string value of a specified cell position. Note that the
120 * position of the upper left cell of the range is always (0, 0) even if
121 * the reference type is of internal range.
123 * @param nCol column position (0 to column size-1)
124 * @param nRow row position (0 to row size-1)
126 virtual ::rtl::OUString getString(SCCOL nCol, SCROW nRow) const;
128 virtual SCCOL getFirstFieldColumn() const;
129 /**
130 * Get a <i>0-based</i> column index that corresponds with the passed field
131 * index. Note that the field index passed as the 1st parameter is
132 * <i>1-based.</i>
134 * @param nIndex 1-based field index.
136 * @return 0-based column index
138 virtual SCCOL findFieldColumn(SCCOL nIndex) const;
139 virtual SCCOL findFieldColumn(const ::rtl::OUString& rStr, sal_uInt16* pErr = NULL) const;
140 virtual ScDBQueryParamBase* createQueryParam(const ScDBRangeBase* pQueryRef) const;
141 virtual bool isRangeEqual(const ScRange& rRange) const;
143 private:
144 sal_uInt16 getCellString(::rtl::OUString& rStr, ScBaseCell* pCell) const;
146 private:
147 ScRange maRange;
150 // ============================================================================
152 class ScDBExternalRange : public ScDBRangeBase
154 public:
155 explicit ScDBExternalRange(ScDocument* pDoc, const ScMatrixRef& pMat);
156 virtual ~ScDBExternalRange();
158 virtual SCCOL getColSize() const;
159 virtual SCROW getRowSize() const;
160 virtual SCSIZE getVisibleDataCellCount() const;
162 /**
163 * Get a string value of a specified cell position. Note that the
164 * position of the upper left cell of the range is always (0, 0) even if
165 * the reference type is of internal range.
167 * @param nCol column position (0 to column size-1)
168 * @param nRow row position (0 to row size-1)
170 virtual ::rtl::OUString getString(SCCOL nCol, SCROW nRow) const;
172 virtual SCCOL getFirstFieldColumn() const;
174 /**
175 * Get a <i>0-based</i> column index that corresponds with the passed field
176 * index. Note that the field index passed as the 1st parameter is
177 * <i>1-based.</i>
179 * @param nIndex 1-based field index.
181 * @return 0-based column index
183 virtual SCCOL findFieldColumn(SCCOL nIndex) const;
184 virtual SCCOL findFieldColumn(const ::rtl::OUString& rStr, sal_uInt16* pErr = NULL) const;
185 virtual ScDBQueryParamBase* createQueryParam(const ScDBRangeBase* pQueryRef) const;
186 virtual bool isRangeEqual(const ScRange& rRange) const;
188 private:
189 const ScMatrixRef mpMatrix;
190 SCCOL mnCols;
191 SCROW mnRows;
194 #endif