LibreOffice Module sc (master) 1
dociter.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 "address.hxx"
23#include "formulagroup.hxx"
24#include "global.hxx"
25#include "scdllapi.h"
26#include "cellvalue.hxx"
27#include "mtvelements.hxx"
28#include "queryparam.hxx"
29#include <vcl/outdev.hxx>
30#include <vcl/vclptr.hxx>
31
32#include <memory>
33#include <set>
34#include <vector>
35
36class ScDocument;
37class ScPatternAttr;
38class ScAttrArray;
39class ScAttrIterator;
41class ScMatrix;
43struct ScQueryParam;
46class ScFormulaCell;
47class OutputDevice;
49enum class SvNumFormatType : sal_Int16;
50
51class ScValueIterator // walk through all values in an area
52{
53 typedef sc::CellStoreType::const_position_type PositionType;
54
58 sal_uInt32 nNumFormat; // for CalcAsShown
59 sal_uInt32 nNumFmtIndex;
70
73
74 SCROW GetRow() const;
75 void IncBlock();
76 void IncPos();
77
82 bool GetThis( double& rValue, FormulaError& rErr );
83
84public:
85
87 const ScRange& rRange, SubtotalFlags nSubTotalFlags = SubtotalFlags::NONE,
88 bool bTextAsZero = false );
89
90 void GetCurNumFmtInfo( SvNumFormatType& nType, sal_uInt32& nIndex );
91
93 bool GetFirst( double& rValue, FormulaError& rErr );
94
96 bool GetNext( double& rValue, FormulaError& rErr );
97};
98
100{
101public:
102 struct Value
103 {
104 OUString maString;
105 double mfValue;
108
109 Value();
110 };
111
112private:
113 static const sc::CellStoreType* GetColumnCellStore(ScDocument& rDoc, SCTAB nTab, SCCOL nCol);
114 static const ScAttrArray* GetAttrArrayByCol(ScDocument& rDoc, SCTAB nTab, SCCOL nCol);
115 static bool IsQueryValid(ScDocument& rDoc, const ScQueryParam& rParam, SCTAB nTab, SCROW nRow, const ScRefCellValue* pCell);
116
118 {
119 public:
120 DataAccess();
121 virtual ~DataAccess() = 0;
122 virtual bool getCurrent(Value& rValue) = 0;
123 virtual bool getFirst(Value& rValue) = 0;
124 virtual bool getNext(Value& rValue) = 0;
125 };
126
127 class DataAccessInternal final : public DataAccess
128 {
129 typedef std::pair<sc::CellStoreType::const_iterator,size_t> PositionType;
130 public:
132 virtual ~DataAccessInternal() override;
133 virtual bool getCurrent(Value& rValue) override;
134 virtual bool getFirst(Value& rValue) override;
135 virtual bool getNext(Value& rValue) override;
136
137 private:
138 void incBlock();
139 void incPos();
140
147 sal_uInt32 nNumFormat; // for CalcAsShown
148 sal_uInt32 nNumFmtIndex;
155 };
156
157 class DataAccessMatrix final : public DataAccess
158 {
159 public:
161 virtual ~DataAccessMatrix() override;
162 virtual bool getCurrent(Value& rValue) override;
163 virtual bool getFirst(Value& rValue) override;
164 virtual bool getNext(Value& rValue) override;
165
166 private:
167 bool isValidQuery(SCROW mnRow, const ScMatrix& rMat) const;
168
172 };
173
174 ::std::unique_ptr<ScDBQueryParamBase> mpParam;
175 ::std::unique_ptr<DataAccess> mpData;
176
177public:
178 ScDBQueryDataIterator(ScDocument& rDocument, const ScInterpreterContext& rContext, std::unique_ptr<ScDBQueryParamBase> pParam);
180 bool GetFirst(Value& rValue);
182 bool GetNext(Value& rValue);
183};
184
186{
187private:
192 size_t mnIndex;
193 std::vector<sc::FormulaGroupEntry> maEntries;
194
195public:
197
200};
201
206{
207 typedef std::pair<sc::CellStoreType::const_iterator, size_t> PositionType;
208
213
216
218
219 void incBlock();
220 void incPos();
221 void setPos(size_t nPos);
222
223 const ScColumn* getColumn() const;
224
225 void init();
226 bool getCurrent();
227
228public:
229 ScCellIterator( ScDocument& rDoc, const ScRange& rRange, SubtotalFlags nSubTotalFlags = SubtotalFlags::NONE );
230
231 const ScAddress& GetPos() const { return maCurPos; }
232
233 CellType getType() const { return maCurCell.getType();}
234 OUString getString() const;
239 const ScRefCellValue& getRefCellValue() const { return maCurCell;}
240
241 bool hasString() const;
242 bool isEmpty() const;
243 bool equalsWithoutFormat( const ScAddress& rPos ) const;
244
245 bool first();
246 bool next();
247};
248
249class ScDocAttrIterator // all attribute areas
250{
251private:
258 std::unique_ptr<ScAttrIterator>
260
261public:
262 ScDocAttrIterator(ScDocument& rDocument, SCTAB nTable,
263 SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2);
265
266 const ScPatternAttr* GetNext( SCCOL& rCol, SCROW& rRow1, SCROW& rRow2 );
267};
268
269class ScAttrRectIterator // all attribute areas, including areas stretching
270 // across more than one column
271{
272private:
280 std::unique_ptr<ScAttrIterator>
282
283public:
284 ScAttrRectIterator(ScDocument& rDocument, SCTAB nTable,
285 SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2);
287
288 void DataChanged();
289 const ScPatternAttr* GetNext( SCCOL& rCol1, SCCOL& rCol2, SCROW& rRow1, SCROW& rRow2 );
290};
291
292class ScHorizontalCellIterator // walk through all non empty cells in an area
293{ // row by row
294 struct ColParam
295 {
296 sc::CellStoreType::const_iterator maPos;
297 sc::CellStoreType::const_iterator maEnd;
299 };
300
301 std::vector<ColParam>::iterator maColPos;
302 std::vector<ColParam> maColPositions;
303
313 bool mbMore;
314
315public:
316 ScHorizontalCellIterator(ScDocument& rDocument, SCTAB nTable,
317 SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2);
319
320 ScRefCellValue* GetNext( SCCOL& rCol, SCROW& rRow );
321 bool GetPos( SCCOL& rCol, SCROW& rRow );
323 void SetTab( SCTAB nTab );
324
325private:
326 void Advance();
327 void SkipInvalid();
328 bool SkipInvalidInRow();
330};
331
334{
335private:
338 std::unique_ptr<ScHorizontalCellIterator>
340 sal_uInt32 nNumFormat; // for CalcAsShown
347
348public:
349
351 const ScRange& rRange );
354 bool GetNext( double& rValue, FormulaError& rErr );
355};
356
358{
359private:
366
367 std::unique_ptr<SCROW[]> pNextEnd;
368 std::unique_ptr<SCCOL[]> pHorizEnd;
369 std::unique_ptr<SCSIZE[]> pIndices;
370 std::unique_ptr<const ScPatternAttr*[]>
375
376 void InitForNextRow(bool bInitialization);
377
378public:
379 ScHorizontalAttrIterator( ScDocument& rDocument, SCTAB nTable,
380 SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
382
383 const ScPatternAttr* GetNext( SCCOL& rCol1, SCCOL& rCol2, SCROW& rRow );
384};
385
386// returns non-empty cells and areas with formatting (horizontal)
387
389{
390private:
393
396
404
405 SCCOL nFoundStartCol; // results after GetNext
409
411
412public:
413 ScUsedAreaIterator( ScDocument& rDocument, SCTAB nTable,
414 SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
416
417 bool GetNext();
418
419 SCCOL GetStartCol() const { return nFoundStartCol; }
420 SCCOL GetEndCol() const { return nFoundEndCol; }
421 SCROW GetRow() const { return nFoundRow; }
422 const ScPatternAttr* GetPattern() const { return pFoundPattern; }
423 const ScRefCellValue& GetCell() const { return maFoundCell;}
424};
425
427{
428public:
429 static constexpr SCROW NOT_FOUND = -1;
430
431 explicit ScRowBreakIterator(::std::set<SCROW>& rBreaks);
432 SCROW first();
433 SCROW next();
434
435private:
436 ::std::set<SCROW>& mrBreaks;
437 ::std::set<SCROW>::const_iterator maItr;
438 ::std::set<SCROW>::const_iterator maEnd;
439};
440
442{
443public:
445 {
448
449 TabRanges(SCTAB nTab, SCROW nMaxRow);
450 };
451
456 explicit ScDocRowHeightUpdater(
457 ScDocument& rDoc, OutputDevice* pOutDev, double fPPTX, double fPPTY,
458 const ::std::vector<TabRanges>* pTabRangesArray);
459
460 void update();
461
462private:
463 void updateAll();
464
465private:
468 double mfPPTX;
469 double mfPPTY;
470 const ::std::vector<TabRanges>* mpTabRangesArray;
471};
472
473/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ScDocument & rDoc
Definition: dociter.hxx:273
ScAttrRectIterator(ScDocument &rDocument, SCTAB nTable, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
Definition: dociter.cxx:1693
std::unique_ptr< ScAttrIterator > pColIter
Definition: dociter.hxx:281
const ScPatternAttr * GetNext(SCCOL &rCol1, SCCOL &rCol2, SCROW &rRow1, SCROW &rRow2)
Definition: dociter.cxx:1727
Walk through all cells in an area.
Definition: dociter.hxx:206
void incBlock()
Definition: dociter.cxx:828
CellType getType() const
Definition: dociter.hxx:233
ScRefCellValue maCurCell
Definition: dociter.hxx:217
ScAddress maEndPos
Definition: dociter.hxx:211
ScAddress maCurPos
Definition: dociter.hxx:212
const EditTextObject * getEditText() const
Definition: dociter.hxx:235
ScFormulaCell * getFormulaCell()
Definition: dociter.hxx:236
bool hasString() const
Definition: dociter.cxx:994
bool getCurrent()
Definition: dociter.cxx:892
void incPos()
Definition: dociter.cxx:836
std::pair< sc::CellStoreType::const_iterator, size_t > PositionType
Definition: dociter.hxx:207
void setPos(size_t nPos)
Definition: dociter.cxx:849
ScAddress maStartPos
Definition: dociter.hxx:210
const ScAddress & GetPos() const
Definition: dociter.hxx:231
const ScRefCellValue & getRefCellValue() const
Definition: dociter.hxx:239
OUString getString() const
Definition: dociter.cxx:968
bool isEmpty() const
Definition: dociter.cxx:999
ScCellIterator(ScDocument &rDoc, const ScRange &rRange, SubtotalFlags nSubTotalFlags=SubtotalFlags::NONE)
Definition: dociter.cxx:819
bool equalsWithoutFormat(const ScAddress &rPos) const
Definition: dociter.cxx:1004
const ScFormulaCell * getFormulaCell() const
Definition: dociter.hxx:237
const ScColumn * getColumn() const
Definition: dociter.cxx:855
PositionType maCurColPos
Definition: dociter.hxx:214
SubtotalFlags mnSubTotalFlags
Definition: dociter.hxx:215
ScCellValue getCellValue() const
Definition: dociter.cxx:973
ScDocument & mrDoc
Definition: dociter.hxx:209
virtual bool getCurrent(Value &rValue) override
Definition: dociter.cxx:367
virtual bool getFirst(Value &rValue) override
Definition: dociter.cxx:470
virtual bool getNext(Value &rValue) override
Definition: dociter.cxx:483
DataAccessInternal(ScDBQueryParamInternal *pParam, ScDocument &rDoc, const ScInterpreterContext &rContext)
Definition: dociter.cxx:333
std::pair< sc::CellStoreType::const_iterator, size_t > PositionType
Definition: dociter.hxx:129
const ScInterpreterContext & mrContext
Definition: dociter.hxx:145
ScDBQueryParamInternal * mpParam
Definition: dociter.hxx:143
const sc::CellStoreType * mpCells
Definition: dociter.hxx:141
virtual bool getCurrent(Value &rValue) override
Definition: dociter.cxx:526
bool isValidQuery(SCROW mnRow, const ScMatrix &rMat) const
Definition: dociter.cxx:600
virtual bool getFirst(Value &rValue) override
Definition: dociter.cxx:553
DataAccessMatrix(ScDBQueryParamMatrix *pParam)
Definition: dociter.cxx:513
virtual bool getNext(Value &rValue) override
Definition: dociter.cxx:559
ScDBQueryParamMatrix * mpParam
Definition: dociter.hxx:169
virtual bool getFirst(Value &rValue)=0
virtual bool getNext(Value &rValue)=0
virtual bool getCurrent(Value &rValue)=0
::std::unique_ptr< ScDBQueryParamBase > mpParam
Definition: dociter.hxx:174
static const ScAttrArray * GetAttrArrayByCol(ScDocument &rDoc, SCTAB nTab, SCCOL nCol)
Definition: dociter.cxx:318
ScDBQueryDataIterator(ScDocument &rDocument, const ScInterpreterContext &rContext, std::unique_ptr< ScDBQueryParamBase > pParam)
Definition: dociter.cxx:738
bool GetNext(Value &rValue)
Does NOT reset rValue if no value found!
Definition: dociter.cxx:762
bool GetFirst(Value &rValue)
Does NOT reset rValue if no value found!
Definition: dociter.cxx:757
static const sc::CellStoreType * GetColumnCellStore(ScDocument &rDoc, SCTAB nTab, SCCOL nCol)
Definition: dociter.cxx:308
::std::unique_ptr< DataAccess > mpData
Definition: dociter.hxx:175
static bool IsQueryValid(ScDocument &rDoc, const ScQueryParam &rParam, SCTAB nTab, SCROW nRow, const ScRefCellValue *pCell)
Definition: dociter.cxx:325
const ScPatternAttr * GetNext(SCCOL &rCol, SCROW &rRow1, SCROW &rRow2)
Definition: dociter.cxx:1584
ScDocument & rDoc
Definition: dociter.hxx:252
std::unique_ptr< ScAttrIterator > pColIter
Definition: dociter.hxx:259
ScDocAttrIterator(ScDocument &rDocument, SCTAB nTable, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
Definition: dociter.cxx:1566
const ::std::vector< TabRanges > * mpTabRangesArray
Definition: dociter.hxx:470
ScDocument & mrDoc
Definition: dociter.hxx:466
ScDocRowHeightUpdater(ScDocument &rDoc, OutputDevice *pOutDev, double fPPTX, double fPPTY, const ::std::vector< TabRanges > *pTabRangesArray)
Passing a NULL pointer to pTabRangesArray forces the heights of all rows in all tables to be updated.
Definition: dociter.cxx:1609
VclPtr< OutputDevice > mpOutDev
Definition: dociter.hxx:467
ScDocument & mrDoc
Definition: dociter.hxx:188
sc::FormulaGroupEntry * first()
Definition: dociter.cxx:784
ScFormulaGroupIterator(ScDocument &rDoc)
Definition: dociter.cxx:767
std::vector< sc::FormulaGroupEntry > maEntries
Definition: dociter.hxx:193
sc::FormulaGroupEntry * next()
Definition: dociter.cxx:789
std::unique_ptr< SCROW[]> pNextEnd
Definition: dociter.hxx:367
std::unique_ptr< SCCOL[]> pHorizEnd
Definition: dociter.hxx:368
std::unique_ptr< SCSIZE[]> pIndices
Definition: dociter.hxx:369
std::unique_ptr< const ScPatternAttr *[]> ppPatterns
Definition: dociter.hxx:371
ScHorizontalAttrIterator(ScDocument &rDocument, SCTAB nTable, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
Definition: dociter.cxx:1344
void InitForNextRow(bool bInitialization)
Definition: dociter.cxx:1371
const ScPatternAttr * GetNext(SCCOL &rCol1, SCCOL &rCol2, SCROW &rRow)
Definition: dociter.cxx:1432
void SetTab(SCTAB nTab)
Set a(nother) sheet and (re)init.
Definition: dociter.cxx:1055
bool GetPos(SCCOL &rCol, SCROW &rRow)
Definition: dociter.cxx:1115
ScRefCellValue * GetNext(SCCOL &rCol, SCROW &rRow)
Definition: dociter.cxx:1092
ScRefCellValue maCurCell
Definition: dociter.hxx:312
std::vector< ColParam >::iterator maColPos
Definition: dociter.hxx:301
ScHorizontalCellIterator(ScDocument &rDocument, SCTAB nTable, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
Definition: dociter.cxx:1028
std::vector< ColParam > maColPositions
Definition: dociter.hxx:302
SCROW FindNextNonEmptyRow()
Find the next row that has some real content in one of its columns.
Definition: dociter.cxx:1199
Row-wise value iterator.
Definition: dociter.hxx:334
ScHorizontalValueIterator(ScDocument &rDocument, const ScRange &rRange)
Definition: dociter.cxx:1255
std::unique_ptr< ScHorizontalCellIterator > pCellIter
Definition: dociter.hxx:339
bool GetNext(double &rValue, FormulaError &rErr)
Does NOT reset rValue if no value found!
Definition: dociter.cxx:1293
const ScAttrArray * pAttrArray
Definition: dociter.hxx:337
Matrix data type that can store values of mixed types.
Definition: scmatrix.hxx:101
::std::set< SCROW >::const_iterator maItr
Definition: dociter.hxx:437
::std::set< SCROW >::const_iterator maEnd
Definition: dociter.hxx:438
ScRowBreakIterator(::std::set< SCROW > &rBreaks)
Definition: dociter.cxx:1756
static constexpr SCROW NOT_FOUND
Definition: dociter.hxx:429
::std::set< SCROW > & mrBreaks
Definition: dociter.hxx:436
SCCOL GetEndCol() const
Definition: dociter.hxx:420
ScRefCellValue * pCell
Definition: dociter.hxx:399
ScHorizontalCellIterator aCellIter
Definition: dociter.hxx:391
const ScRefCellValue & GetCell() const
Definition: dociter.hxx:423
SCCOL GetStartCol() const
Definition: dociter.hxx:419
const ScPatternAttr * GetPattern() const
Definition: dociter.hxx:422
const ScPatternAttr * pFoundPattern
Definition: dociter.hxx:408
ScHorizontalAttrIterator aAttrIter
Definition: dociter.hxx:392
const ScPatternAttr * pPattern
Definition: dociter.hxx:403
ScRefCellValue maFoundCell
Definition: dociter.hxx:410
SCROW GetRow() const
Definition: dociter.hxx:421
SvNumFormatType nNumFmtType
Definition: dociter.hxx:66
const ScDocument & mrDoc
Definition: dociter.hxx:55
bool GetFirst(double &rValue, FormulaError &rErr)
Does NOT reset rValue if no value found!
Definition: dociter.cxx:270
SubtotalFlags mnSubTotalFlags
Definition: dociter.hxx:65
ScAddress maEndPos
Definition: dociter.hxx:61
void GetCurNumFmtInfo(SvNumFormatType &nType, sal_uInt32 &nIndex)
Definition: dociter.cxx:255
bool GetThis(double &rValue, FormulaError &rErr)
See if the cell at the current position is a non-empty cell.
Definition: dociter.cxx:137
bool bTextAsZero
Definition: dociter.hxx:69
sc::CellStoreType::const_position_type PositionType
Definition: dociter.hxx:53
sal_uInt32 nNumFormat
Definition: dociter.hxx:58
ScAddress maStartPos
Definition: dociter.hxx:60
ScValueIterator(ScInterpreterContext &rContext, const ScRange &rRange, SubtotalFlags nSubTotalFlags=SubtotalFlags::NONE, bool bTextAsZero=false)
Definition: dociter.cxx:85
ScInterpreterContext & mrContext
Definition: dociter.hxx:56
sal_uInt32 nNumFmtIndex
Definition: dociter.hxx:59
void IncBlock()
Definition: dociter.cxx:121
SCROW nAttrEndRow
Definition: dociter.hxx:64
const sc::CellStoreType * mpCells
Definition: dociter.hxx:71
bool GetNext(double &rValue, FormulaError &rErr)
Does NOT reset rValue if no value found!
Definition: dociter.cxx:294
const ScAttrArray * pAttrArray
Definition: dociter.hxx:57
bool bCalcAsShown
Definition: dociter.hxx:68
SCROW GetRow() const
Definition: dociter.cxx:114
PositionType maCurPos
Definition: dociter.hxx:72
sal_Int32 mnRow
FormulaError
CellType
Definition: global.hxx:271
SubtotalFlags
Definition: global.hxx:239
mdds::mtv::soa::multi_type_vector< CellFunc, CellStoreTrait > CellStoreType
QPRO_FUNC_TYPE nType
Definition: qproform.cxx:398
#define SC_DLLPUBLIC
Definition: scdllapi.h:27
Store arbitrary cell value of any kind.
Definition: cellvalue.hxx:32
ScFlatBoolRowSegments maRanges
Definition: dociter.hxx:447
TabRanges(SCTAB nTab, SCROW nMaxRow)
Definition: dociter.cxx:1604
sc::CellStoreType::const_iterator maEnd
Definition: dociter.hxx:297
sc::CellStoreType::const_iterator maPos
Definition: dociter.hxx:296
This is very similar to ScCellValue, except that it references the original value instead of copying ...
Definition: cellvalue.hxx:108
ScFormulaCell * getFormula() const
Definition: cellvalue.hxx:137
const EditTextObject * getEditText() const
Definition: cellvalue.hxx:136
CellType getType() const
Definition: cellvalue.hxx:133
sal_Int16 SCTAB
Definition: types.hxx:22
sal_Int16 SCCOL
Definition: types.hxx:21
sal_Int32 SCROW
Definition: types.hxx:17
SvNumFormatType