1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
22 #include <sal/config.h>
26 #include <address.hxx>
30 struct ScDBQueryParamBase
;
31 struct ScQueryParamBase
;
32 enum class FormulaError
: sal_uInt16
;
35 * Base class for abstracting range data backends for database functions.
40 ScDBRangeBase() = delete;
42 virtual ~ScDBRangeBase() = 0;
44 bool fillQueryEntries(ScQueryParamBase
* pParam
, const ScDBRangeBase
* pDBRef
) const;
46 virtual SCCOL
getColSize() const = 0;
47 virtual SCROW
getRowSize() const = 0;
48 virtual SCSIZE
getVisibleDataCellCount() const = 0;
51 * Get a string value of a specified cell position. Note that the
52 * position of the upper left cell of the range is always (0, 0) even if
53 * the reference type is of internal range.
55 * @param nCol column position (0 to column size-1)
56 * @param nRow row position (0 to row size-1)
58 virtual OUString
getString(SCCOL nCol
, SCROW nRow
) const = 0;
60 virtual SCCOL
getFirstFieldColumn() const = 0;
63 * Get a <i>0-based</i> column index that corresponds with the passed field
64 * index. Note that the field index passed as the 1st parameter is
67 * @param nIndex 1-based field index.
69 * @return 0-based column index
71 virtual SCCOL
findFieldColumn(SCCOL nIndex
) const = 0;
72 virtual SCCOL
findFieldColumn(const OUString
& rStr
, FormulaError
* pErr
= nullptr) const = 0;
73 virtual std::unique_ptr
<ScDBQueryParamBase
>
74 createQueryParam(const ScDBRangeBase
* pQueryRef
) const = 0;
75 virtual bool isRangeEqual(const ScRange
& rRange
) const = 0;
78 ScDBRangeBase(ScDocument
* pDoc
);
79 ScDocument
* getDoc() const { return mpDoc
; }
82 * Populate query options that are always the same for all database
85 static void fillQueryOptions(ScQueryParamBase
* pParam
);
91 class ScDBInternalRange final
: public ScDBRangeBase
94 explicit ScDBInternalRange(ScDocument
* pDoc
, const ScRange
& rRange
);
95 virtual ~ScDBInternalRange() override
;
97 const ScRange
& getRange() const { return maRange
; }
99 virtual SCCOL
getColSize() const override
;
100 virtual SCROW
getRowSize() const override
;
101 virtual SCSIZE
getVisibleDataCellCount() const override
;
104 * Get a string value of a specified cell position. Note that the
105 * position of the upper left cell of the range is always (0, 0) even if
106 * the reference type is of internal range.
108 * @param nCol column position (0 to column size-1)
109 * @param nRow row position (0 to row size-1)
111 virtual OUString
getString(SCCOL nCol
, SCROW nRow
) const override
;
113 virtual SCCOL
getFirstFieldColumn() const override
;
115 * Get a <i>0-based</i> column index that corresponds with the passed field
116 * index. Note that the field index passed as the 1st parameter is
119 * @param nIndex 1-based field index.
121 * @return 0-based column index
123 virtual SCCOL
findFieldColumn(SCCOL nIndex
) const override
;
124 virtual SCCOL
findFieldColumn(const OUString
& rStr
,
125 FormulaError
* pErr
= nullptr) const override
;
126 virtual std::unique_ptr
<ScDBQueryParamBase
>
127 createQueryParam(const ScDBRangeBase
* pQueryRef
) const override
;
128 virtual bool isRangeEqual(const ScRange
& rRange
) const override
;
134 class ScDBExternalRange final
: public ScDBRangeBase
137 explicit ScDBExternalRange(ScDocument
* pDoc
, ScMatrixRef pMat
);
138 virtual ~ScDBExternalRange() override
;
140 virtual SCCOL
getColSize() const override
;
141 virtual SCROW
getRowSize() const override
;
142 virtual SCSIZE
getVisibleDataCellCount() const override
;
145 * Get a string value of a specified cell position. Note that the
146 * position of the upper left cell of the range is always (0, 0) even if
147 * the reference type is of internal range.
149 * @param nCol column position (0 to column size-1)
150 * @param nRow row position (0 to row size-1)
152 virtual OUString
getString(SCCOL nCol
, SCROW nRow
) const override
;
154 virtual SCCOL
getFirstFieldColumn() const override
;
157 * Get a <i>0-based</i> column index that corresponds with the passed field
158 * index. Note that the field index passed as the 1st parameter is
161 * @param nIndex 1-based field index.
163 * @return 0-based column index
165 virtual SCCOL
findFieldColumn(SCCOL nIndex
) const override
;
166 virtual SCCOL
findFieldColumn(const OUString
& rStr
,
167 FormulaError
* pErr
= nullptr) const override
;
168 virtual std::unique_ptr
<ScDBQueryParamBase
>
169 createQueryParam(const ScDBRangeBase
* pQueryRef
) const override
;
170 virtual bool isRangeEqual(const ScRange
& rRange
) const override
;
173 const ScMatrixRef mpMatrix
;
178 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */