1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2008 by Sun Microsystems, Inc. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * $RCSfile: interpre.hxx,v $ 10 * $Revision: 1.35.44.2 $ 11 * 12 * This file is part of OpenOffice.org. 13 * 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. 17 * 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). 23 * 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. 28 * 29 ************************************************************************/ 30 31 #ifndef SC_DOUBLEREF_HXX 32 #define SC_DOUBLEREF_HXX 33 34 #include "address.hxx" 35 #include "scmatrix.hxx" 36 37 class ScDocument; 38 class ScBaseCell; 39 struct ScDBQueryParamBase; 40 struct ScQueryParamBase; 41 42 // ============================================================================ 43 44 /** 45 * Base class for abstracting range data backends for database functions. 46 */ 47 class ScDBRangeBase 48 { 49 public: 50 enum RefType { INTERNAL, EXTERNAL }; // TODO: We may not need this after all... (kohei) 51 52 virtual ~ScDBRangeBase() = 0; 53 54 bool fillQueryEntries(ScQueryParamBase* pParam, const ScDBRangeBase* pDBRef) const; 55 56 virtual SCCOL getColSize() const = 0; 57 virtual SCROW getRowSize() const = 0; 58 virtual SCSIZE getVisibleDataCellCount() const = 0; 59 60 /** 61 * Get a string value of a specified cell position. Note that the 62 * position of the upper left cell of the range is always (0, 0) even if 63 * the reference type is of internal range. 64 * 65 * @param nCol column position (0 to column size-1) 66 * @param nRow row position (0 to row size-1) 67 */ 68 virtual ::rtl::OUString getString(SCCOL nCol, SCROW nRow) const = 0; 69 70 virtual SCCOL getFirstFieldColumn() const = 0; 71 72 /** 73 * Get a <i>0-based</i> column index that corresponds with the passed field 74 * index. Note that the field index passed as the 1st parameter is 75 * <i>1-based.</i> 76 * 77 * @param nIndex 1-based field index. 78 * 79 * @return 0-based column index 80 */ 81 virtual SCCOL findFieldColumn(SCCOL nIndex) const = 0; 82 virtual SCCOL findFieldColumn(const ::rtl::OUString& rStr, sal_uInt16* pErr = NULL) const = 0; 83 virtual ScDBQueryParamBase* createQueryParam(const ScDBRangeBase* pQueryRef) const = 0; 84 virtual bool isRangeEqual(const ScRange& rRange) const = 0; 85 86 protected: 87 ScDBRangeBase(ScDocument* pDoc, RefType eType); 88 ScDocument* getDoc() const; 89 90 /** 91 * Populate query options that are always the same for all database 92 * queries. 93 */ 94 static void fillQueryOptions(ScQueryParamBase* pParam); 95 96 private: 97 ScDBRangeBase(); // disabled 98 99 ScDocument* mpDoc; 100 RefType meType; 101 }; 102 103 // ============================================================================ 104 105 class ScDBInternalRange : public ScDBRangeBase 106 { 107 public: 108 explicit ScDBInternalRange(ScDocument* pDoc, const ScRange& rRange); 109 virtual ~ScDBInternalRange(); 110 111 const ScRange& getRange() const; 112 113 virtual SCCOL getColSize() const; 114 virtual SCROW getRowSize() const; 115 virtual SCSIZE getVisibleDataCellCount() const; 116 117 /** 118 * Get a string value of a specified cell position. Note that the 119 * position of the upper left cell of the range is always (0, 0) even if 120 * the reference type is of internal range. 121 * 122 * @param nCol column position (0 to column size-1) 123 * @param nRow row position (0 to row size-1) 124 */ 125 virtual ::rtl::OUString getString(SCCOL nCol, SCROW nRow) const; 126 127 virtual SCCOL getFirstFieldColumn() const; 128 /** 129 * Get a <i>0-based</i> column index that corresponds with the passed field 130 * index. Note that the field index passed as the 1st parameter is 131 * <i>1-based.</i> 132 * 133 * @param nIndex 1-based field index. 134 * 135 * @return 0-based column index 136 */ 137 virtual SCCOL findFieldColumn(SCCOL nIndex) const; 138 virtual SCCOL findFieldColumn(const ::rtl::OUString& rStr, sal_uInt16* pErr = NULL) const; 139 virtual ScDBQueryParamBase* createQueryParam(const ScDBRangeBase* pQueryRef) const; 140 virtual bool isRangeEqual(const ScRange& rRange) const; 141 142 private: 143 ScRange maRange; 144 }; 145 146 // ============================================================================ 147 148 class ScDBExternalRange : public ScDBRangeBase 149 { 150 public: 151 explicit ScDBExternalRange(ScDocument* pDoc, const ScMatrixRef& pMat); 152 virtual ~ScDBExternalRange(); 153 154 virtual SCCOL getColSize() const; 155 virtual SCROW getRowSize() const; 156 virtual SCSIZE getVisibleDataCellCount() const; 157 158 /** 159 * Get a string value of a specified cell position. Note that the 160 * position of the upper left cell of the range is always (0, 0) even if 161 * the reference type is of internal range. 162 * 163 * @param nCol column position (0 to column size-1) 164 * @param nRow row position (0 to row size-1) 165 */ 166 virtual ::rtl::OUString getString(SCCOL nCol, SCROW nRow) const; 167 168 virtual SCCOL getFirstFieldColumn() const; 169 170 /** 171 * Get a <i>0-based</i> column index that corresponds with the passed field 172 * index. Note that the field index passed as the 1st parameter is 173 * <i>1-based.</i> 174 * 175 * @param nIndex 1-based field index. 176 * 177 * @return 0-based column index 178 */ 179 virtual SCCOL findFieldColumn(SCCOL nIndex) const; 180 virtual SCCOL findFieldColumn(const ::rtl::OUString& rStr, sal_uInt16* pErr = NULL) const; 181 virtual ScDBQueryParamBase* createQueryParam(const ScDBRangeBase* pQueryRef) const; 182 virtual bool isRangeEqual(const ScRange& rRange) const; 183 184 private: 185 const ScMatrixRef mpMatrix; 186 SCCOL mnCols; 187 SCROW mnRows; 188 }; 189 190 #endif 191