xref: /aoo41x/main/sc/source/core/inc/doubleref.hxx (revision 38d50f7b)
1*38d50f7bSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*38d50f7bSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*38d50f7bSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*38d50f7bSAndrew Rist  * distributed with this work for additional information
6*38d50f7bSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*38d50f7bSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*38d50f7bSAndrew Rist  * "License"); you may not use this file except in compliance
9*38d50f7bSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*38d50f7bSAndrew Rist  *
11*38d50f7bSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*38d50f7bSAndrew Rist  *
13*38d50f7bSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*38d50f7bSAndrew Rist  * software distributed under the License is distributed on an
15*38d50f7bSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*38d50f7bSAndrew Rist  * KIND, either express or implied.  See the License for the
17*38d50f7bSAndrew Rist  * specific language governing permissions and limitations
18*38d50f7bSAndrew Rist  * under the License.
19*38d50f7bSAndrew Rist  *
20*38d50f7bSAndrew Rist  *************************************************************/
21*38d50f7bSAndrew Rist 
22*38d50f7bSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef SC_DOUBLEREF_HXX
25cdf0e10cSrcweir #define SC_DOUBLEREF_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "address.hxx"
28cdf0e10cSrcweir #include "scmatrix.hxx"
29cdf0e10cSrcweir 
30cdf0e10cSrcweir class ScDocument;
31cdf0e10cSrcweir class ScBaseCell;
32cdf0e10cSrcweir struct ScDBQueryParamBase;
33cdf0e10cSrcweir struct ScQueryParamBase;
34cdf0e10cSrcweir 
35cdf0e10cSrcweir // ============================================================================
36cdf0e10cSrcweir 
37cdf0e10cSrcweir /**
38cdf0e10cSrcweir  * Base class for abstracting range data backends for database functions.
39cdf0e10cSrcweir  */
40cdf0e10cSrcweir class ScDBRangeBase
41cdf0e10cSrcweir {
42cdf0e10cSrcweir public:
43cdf0e10cSrcweir     enum RefType { INTERNAL, EXTERNAL }; // TODO: We may not need this after all... (kohei)
44cdf0e10cSrcweir 
45cdf0e10cSrcweir     virtual ~ScDBRangeBase() = 0;
46cdf0e10cSrcweir 
47cdf0e10cSrcweir     bool fillQueryEntries(ScQueryParamBase* pParam, const ScDBRangeBase* pDBRef) const;
48cdf0e10cSrcweir 
49cdf0e10cSrcweir     virtual SCCOL getColSize() const = 0;
50cdf0e10cSrcweir     virtual SCROW getRowSize() const = 0;
51cdf0e10cSrcweir     virtual SCSIZE getVisibleDataCellCount() const = 0;
52cdf0e10cSrcweir 
53cdf0e10cSrcweir     /**
54cdf0e10cSrcweir      * Get a string value of a specified cell position.  Note that the
55cdf0e10cSrcweir      * position of the upper left cell of the range is always (0, 0) even if
56cdf0e10cSrcweir      * the reference type is of internal range.
57cdf0e10cSrcweir      *
58cdf0e10cSrcweir      * @param nCol column position (0 to column size-1)
59cdf0e10cSrcweir      * @param nRow row position (0 to row size-1)
60cdf0e10cSrcweir      */
61cdf0e10cSrcweir     virtual ::rtl::OUString getString(SCCOL nCol, SCROW nRow) const = 0;
62cdf0e10cSrcweir 
63cdf0e10cSrcweir     virtual SCCOL getFirstFieldColumn() const = 0;
64cdf0e10cSrcweir 
65cdf0e10cSrcweir     /**
66cdf0e10cSrcweir      * Get a <i>0-based</i> column index that corresponds with the passed field
67cdf0e10cSrcweir      * index.  Note that the field index passed as the 1st parameter is
68cdf0e10cSrcweir      * <i>1-based.</i>
69cdf0e10cSrcweir      *
70cdf0e10cSrcweir      * @param nIndex 1-based field index.
71cdf0e10cSrcweir      *
72cdf0e10cSrcweir      * @return 0-based column index
73cdf0e10cSrcweir      */
74cdf0e10cSrcweir     virtual SCCOL findFieldColumn(SCCOL nIndex) const = 0;
75cdf0e10cSrcweir     virtual SCCOL findFieldColumn(const ::rtl::OUString& rStr, sal_uInt16* pErr = NULL) const = 0;
76cdf0e10cSrcweir     virtual ScDBQueryParamBase* createQueryParam(const ScDBRangeBase* pQueryRef) const = 0;
77cdf0e10cSrcweir     virtual bool isRangeEqual(const ScRange& rRange) const = 0;
78cdf0e10cSrcweir 
79cdf0e10cSrcweir protected:
80cdf0e10cSrcweir     ScDBRangeBase(ScDocument* pDoc, RefType eType);
81cdf0e10cSrcweir     ScDocument* getDoc() const;
82cdf0e10cSrcweir 
83cdf0e10cSrcweir     /**
84cdf0e10cSrcweir      * Populate query options that are always the same for all database
85cdf0e10cSrcweir      * queries.
86cdf0e10cSrcweir      */
87cdf0e10cSrcweir     static void fillQueryOptions(ScQueryParamBase* pParam);
88cdf0e10cSrcweir 
89cdf0e10cSrcweir private:
90cdf0e10cSrcweir     ScDBRangeBase(); // disabled
91cdf0e10cSrcweir 
92cdf0e10cSrcweir     ScDocument* mpDoc;
93cdf0e10cSrcweir     RefType meType;
94cdf0e10cSrcweir };
95cdf0e10cSrcweir 
96cdf0e10cSrcweir // ============================================================================
97cdf0e10cSrcweir 
98cdf0e10cSrcweir class ScDBInternalRange : public ScDBRangeBase
99cdf0e10cSrcweir {
100cdf0e10cSrcweir public:
101cdf0e10cSrcweir     explicit ScDBInternalRange(ScDocument* pDoc, const ScRange& rRange);
102cdf0e10cSrcweir     virtual ~ScDBInternalRange();
103cdf0e10cSrcweir 
104cdf0e10cSrcweir     const ScRange& getRange() const;
105cdf0e10cSrcweir 
106cdf0e10cSrcweir     virtual SCCOL getColSize() const;
107cdf0e10cSrcweir     virtual SCROW getRowSize() const;
108cdf0e10cSrcweir     virtual SCSIZE getVisibleDataCellCount() const;
109cdf0e10cSrcweir 
110cdf0e10cSrcweir     /**
111cdf0e10cSrcweir      * Get a string value of a specified cell position.  Note that the
112cdf0e10cSrcweir      * position of the upper left cell of the range is always (0, 0) even if
113cdf0e10cSrcweir      * the reference type is of internal range.
114cdf0e10cSrcweir      *
115cdf0e10cSrcweir      * @param nCol column position (0 to column size-1)
116cdf0e10cSrcweir      * @param nRow row position (0 to row size-1)
117cdf0e10cSrcweir      */
118cdf0e10cSrcweir     virtual ::rtl::OUString getString(SCCOL nCol, SCROW nRow) const;
119cdf0e10cSrcweir 
120cdf0e10cSrcweir     virtual SCCOL getFirstFieldColumn() const;
121cdf0e10cSrcweir     /**
122cdf0e10cSrcweir      * Get a <i>0-based</i> column index that corresponds with the passed field
123cdf0e10cSrcweir      * index.  Note that the field index passed as the 1st parameter is
124cdf0e10cSrcweir      * <i>1-based.</i>
125cdf0e10cSrcweir      *
126cdf0e10cSrcweir      * @param nIndex 1-based field index.
127cdf0e10cSrcweir      *
128cdf0e10cSrcweir      * @return 0-based column index
129cdf0e10cSrcweir      */
130cdf0e10cSrcweir     virtual SCCOL findFieldColumn(SCCOL nIndex) const;
131cdf0e10cSrcweir     virtual SCCOL findFieldColumn(const ::rtl::OUString& rStr, sal_uInt16* pErr = NULL) const;
132cdf0e10cSrcweir     virtual ScDBQueryParamBase* createQueryParam(const ScDBRangeBase* pQueryRef) const;
133cdf0e10cSrcweir     virtual bool isRangeEqual(const ScRange& rRange) const;
134cdf0e10cSrcweir 
135cdf0e10cSrcweir private:
136cdf0e10cSrcweir     ScRange maRange;
137cdf0e10cSrcweir };
138cdf0e10cSrcweir 
139cdf0e10cSrcweir // ============================================================================
140cdf0e10cSrcweir 
141cdf0e10cSrcweir class ScDBExternalRange : public ScDBRangeBase
142cdf0e10cSrcweir {
143cdf0e10cSrcweir public:
144cdf0e10cSrcweir     explicit ScDBExternalRange(ScDocument* pDoc, const ScMatrixRef& pMat);
145cdf0e10cSrcweir     virtual ~ScDBExternalRange();
146cdf0e10cSrcweir 
147cdf0e10cSrcweir     virtual SCCOL getColSize() const;
148cdf0e10cSrcweir     virtual SCROW getRowSize() const;
149cdf0e10cSrcweir     virtual SCSIZE getVisibleDataCellCount() const;
150cdf0e10cSrcweir 
151cdf0e10cSrcweir     /**
152cdf0e10cSrcweir      * Get a string value of a specified cell position.  Note that the
153cdf0e10cSrcweir      * position of the upper left cell of the range is always (0, 0) even if
154cdf0e10cSrcweir      * the reference type is of internal range.
155cdf0e10cSrcweir      *
156cdf0e10cSrcweir      * @param nCol column position (0 to column size-1)
157cdf0e10cSrcweir      * @param nRow row position (0 to row size-1)
158cdf0e10cSrcweir      */
159cdf0e10cSrcweir     virtual ::rtl::OUString getString(SCCOL nCol, SCROW nRow) const;
160cdf0e10cSrcweir 
161cdf0e10cSrcweir     virtual SCCOL getFirstFieldColumn() const;
162cdf0e10cSrcweir 
163cdf0e10cSrcweir     /**
164cdf0e10cSrcweir      * Get a <i>0-based</i> column index that corresponds with the passed field
165cdf0e10cSrcweir      * index.  Note that the field index passed as the 1st parameter is
166cdf0e10cSrcweir      * <i>1-based.</i>
167cdf0e10cSrcweir      *
168cdf0e10cSrcweir      * @param nIndex 1-based field index.
169cdf0e10cSrcweir      *
170cdf0e10cSrcweir      * @return 0-based column index
171cdf0e10cSrcweir      */
172cdf0e10cSrcweir     virtual SCCOL findFieldColumn(SCCOL nIndex) const;
173cdf0e10cSrcweir     virtual SCCOL findFieldColumn(const ::rtl::OUString& rStr, sal_uInt16* pErr = NULL) const;
174cdf0e10cSrcweir     virtual ScDBQueryParamBase* createQueryParam(const ScDBRangeBase* pQueryRef) const;
175cdf0e10cSrcweir     virtual bool isRangeEqual(const ScRange& rRange) const;
176cdf0e10cSrcweir 
177cdf0e10cSrcweir private:
178cdf0e10cSrcweir     const ScMatrixRef mpMatrix;
179cdf0e10cSrcweir     SCCOL mnCols;
180cdf0e10cSrcweir     SCROW mnRows;
181cdf0e10cSrcweir };
182cdf0e10cSrcweir 
183cdf0e10cSrcweir #endif
184