LibreOffice Module sc (master)  1
doubleref.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #pragma once
21 
22 #include <sal/config.h>
23 
24 #include <memory>
25 
26 #include <address.hxx>
27 #include <types.hxx>
28 
29 class ScDocument;
30 struct ScDBQueryParamBase;
31 struct ScQueryParamBase;
32 enum class FormulaError : sal_uInt16;
33 
38 {
39 public:
40  ScDBRangeBase() = delete;
41 
42  virtual ~ScDBRangeBase() = 0;
43 
44  bool fillQueryEntries(ScQueryParamBase* pParam, const ScDBRangeBase* pDBRef) const;
45 
46  virtual SCCOL getColSize() const = 0;
47  virtual SCROW getRowSize() const = 0;
48  virtual SCSIZE getVisibleDataCellCount() const = 0;
49 
58  virtual OUString getString(SCCOL nCol, SCROW nRow) const = 0;
59 
60  virtual SCCOL getFirstFieldColumn() const = 0;
61 
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;
76 
77 protected:
79  ScDocument* getDoc() const { return mpDoc; }
80 
85  static void fillQueryOptions(ScQueryParamBase* pParam);
86 
87 private:
89 };
90 
91 class ScDBInternalRange final : public ScDBRangeBase
92 {
93 public:
94  explicit ScDBInternalRange(ScDocument* pDoc, const ScRange& rRange);
95  virtual ~ScDBInternalRange() override;
96 
97  const ScRange& getRange() const { return maRange; }
98 
99  virtual SCCOL getColSize() const override;
100  virtual SCROW getRowSize() const override;
101  virtual SCSIZE getVisibleDataCellCount() const override;
102 
111  virtual OUString getString(SCCOL nCol, SCROW nRow) const override;
112 
113  virtual SCCOL getFirstFieldColumn() const override;
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;
129 
130 private:
132 };
133 
134 class ScDBExternalRange final : public ScDBRangeBase
135 {
136 public:
137  explicit ScDBExternalRange(ScDocument* pDoc, const ScMatrixRef& pMat);
138  virtual ~ScDBExternalRange() override;
139 
140  virtual SCCOL getColSize() const override;
141  virtual SCROW getRowSize() const override;
142  virtual SCSIZE getVisibleDataCellCount() const override;
143 
152  virtual OUString getString(SCCOL nCol, SCROW nRow) const override;
153 
154  virtual SCCOL getFirstFieldColumn() const override;
155 
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;
171 
172 private:
176 };
177 
178 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ScDBInternalRange(ScDocument *pDoc, const ScRange &rRange)
Definition: doubleref.cxx:275
virtual SCCOL getColSize() const override
Definition: doubleref.cxx:284
virtual SCCOL getFirstFieldColumn() const =0
sal_Int32 nIndex
const ScRange & getRange() const
Definition: doubleref.hxx:97
static void fillQueryOptions(ScQueryParamBase *pParam)
Populate query options that are always the same for all database queries.
Definition: doubleref.cxx:265
virtual SCCOL getColSize() const =0
virtual std::unique_ptr< ScDBQueryParamBase > createQueryParam(const ScDBRangeBase *pQueryRef) const override
Definition: doubleref.cxx:457
virtual SCSIZE getVisibleDataCellCount() const override
Definition: doubleref.cxx:294
ScDBRangeBase()=delete
const ScMatrixRef mpMatrix
Definition: doubleref.hxx:173
virtual SCCOL findFieldColumn(SCCOL nIndex) const override
Get a 0-based column index that corresponds with the passed field index.
Definition: doubleref.cxx:320
size_t SCSIZE
size_t typedef to be able to find places where code was changed from USHORT to size_t and is used to ...
Definition: address.hxx:44
virtual SCSIZE getVisibleDataCellCount() const =0
::boost::intrusive_ptr< ScMatrix > ScMatrixRef
Definition: types.hxx:25
virtual OUString getString(SCCOL nCol, SCROW nRow) const override
Get a string value of a specified cell position.
Definition: doubleref.cxx:304
virtual bool isRangeEqual(const ScRange &rRange) const override
Definition: doubleref.cxx:470
virtual SCROW getRowSize() const override
Definition: doubleref.cxx:289
sal_Int16 SCCOL
Definition: types.hxx:21
Base class for abstracting range data backends for database functions.
Definition: doubleref.hxx:37
virtual ~ScDBRangeBase()=0
Definition: doubleref.cxx:253
virtual SCSIZE getVisibleDataCellCount() const override
Definition: doubleref.cxx:412
virtual bool isRangeEqual(const ScRange &rRange) const override
Definition: doubleref.cxx:384
virtual ~ScDBExternalRange() override
Definition: doubleref.cxx:398
virtual std::unique_ptr< ScDBQueryParamBase > createQueryParam(const ScDBRangeBase *pQueryRef) const override
Definition: doubleref.cxx:362
ScDocument * getDoc() const
Definition: doubleref.hxx:79
FormulaError
sal_Int32 SCROW
Definition: types.hxx:17
virtual SCCOL getFirstFieldColumn() const override
Definition: doubleref.cxx:430
virtual SCCOL findFieldColumn(SCCOL nIndex) const override
Get a 0-based column index that corresponds with the passed field index.
Definition: doubleref.cxx:435
virtual SCCOL getFirstFieldColumn() const override
Definition: doubleref.cxx:315
virtual SCCOL findFieldColumn(SCCOL nIndex) const =0
Get a 0-based column index that corresponds with the passed field index.
virtual SCROW getRowSize() const =0
bool fillQueryEntries(ScQueryParamBase *pParam, const ScDBRangeBase *pDBRef) const
Definition: doubleref.cxx:257
virtual SCCOL getColSize() const override
Definition: doubleref.cxx:402
virtual std::unique_ptr< ScDBQueryParamBase > createQueryParam(const ScDBRangeBase *pQueryRef) const =0
ScDocument * mpDoc
Definition: doubleref.hxx:88
virtual ~ScDBInternalRange() override
Definition: doubleref.cxx:280
ScDBExternalRange(ScDocument *pDoc, const ScMatrixRef &pMat)
Definition: doubleref.cxx:389
virtual OUString getString(SCCOL nCol, SCROW nRow) const =0
Get a string value of a specified cell position.
virtual bool isRangeEqual(const ScRange &rRange) const =0
virtual SCROW getRowSize() const override
Definition: doubleref.cxx:407
virtual OUString getString(SCCOL nCol, SCROW nRow) const override
Get a string value of a specified cell position.
Definition: doubleref.cxx:422