tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / sc / source / core / inc / doubleref.hxx
blobcda9241590e6c7005e23ca3b7cd73342c49ea6cb
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 #pragma once
22 #include <sal/config.h>
24 #include <memory>
26 #include <address.hxx>
27 #include <types.hxx>
29 class ScDocument;
30 struct ScDBQueryParamBase;
31 struct ScQueryParamBase;
32 enum class FormulaError : sal_uInt16;
34 /**
35 * Base class for abstracting range data backends for database functions.
37 class ScDBRangeBase
39 public:
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;
50 /**
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;
62 /**
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
65 * <i>1-based.</i>
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;
77 protected:
78 ScDBRangeBase(ScDocument* pDoc);
79 ScDocument* getDoc() const { return mpDoc; }
81 /**
82 * Populate query options that are always the same for all database
83 * queries.
85 static void fillQueryOptions(ScQueryParamBase* pParam);
87 private:
88 ScDocument* mpDoc;
91 class ScDBInternalRange final : public ScDBRangeBase
93 public:
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
117 * <i>1-based.</i>
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;
130 private:
131 ScRange maRange;
134 class ScDBExternalRange final : public ScDBRangeBase
136 public:
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
159 * <i>1-based.</i>
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;
172 private:
173 const ScMatrixRef mpMatrix;
174 SCCOL mnCols;
175 SCROW mnRows;
178 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */