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 ScDocument& rDocument, const ScRange& rRange, SubtotalFlags nSubTotalFlags = SubtotalFlags::NONE,
88 bool bTextAsZero = false );
89
90 void GetCurNumFmtInfo( const ScInterpreterContext& rContext, SvNumFormatType& nType, sal_uInt32& nIndex );
91
93 bool GetFirst( double& rValue, FormulaError& rErr );
94
96 bool GetNext( double& rValue, FormulaError& rErr );
97
98 void SetInterpreterContext( ScInterpreterContext* context ) { pContext = context; }
99};
100
102{
103public:
104 struct Value
105 {
106 OUString maString;
107 double mfValue;
110
111 Value();
112 };
113
114private:
115 static const sc::CellStoreType* GetColumnCellStore(ScDocument& rDoc, SCTAB nTab, SCCOL nCol);
116 static const ScAttrArray* GetAttrArrayByCol(ScDocument& rDoc, SCTAB nTab, SCCOL nCol);
117 static bool IsQueryValid(ScDocument& rDoc, const ScQueryParam& rParam, SCTAB nTab, SCROW nRow, const ScRefCellValue* pCell);
118
120 {
121 public:
122 DataAccess();
123 virtual ~DataAccess() = 0;
124 virtual bool getCurrent(Value& rValue) = 0;
125 virtual bool getFirst(Value& rValue) = 0;
126 virtual bool getNext(Value& rValue) = 0;
127 };
128
129 class DataAccessInternal final : public DataAccess
130 {
131 typedef std::pair<sc::CellStoreType::const_iterator,size_t> PositionType;
132 public:
134 virtual ~DataAccessInternal() override;
135 virtual bool getCurrent(Value& rValue) override;
136 virtual bool getFirst(Value& rValue) override;
137 virtual bool getNext(Value& rValue) override;
138
139 private:
140 void incBlock();
141 void incPos();
142
149 sal_uInt32 nNumFormat; // for CalcAsShown
150 sal_uInt32 nNumFmtIndex;
157 };
158
159 class DataAccessMatrix final : public DataAccess
160 {
161 public:
163 virtual ~DataAccessMatrix() override;
164 virtual bool getCurrent(Value& rValue) override;
165 virtual bool getFirst(Value& rValue) override;
166 virtual bool getNext(Value& rValue) override;
167
168 private:
169 bool isValidQuery(SCROW mnRow, const ScMatrix& rMat) const;
170
174 };
175
176 ::std::unique_ptr<ScDBQueryParamBase> mpParam;
177 ::std::unique_ptr<DataAccess> mpData;
178
179public:
180 ScDBQueryDataIterator(ScDocument& rDocument, const ScInterpreterContext& rContext, std::unique_ptr<ScDBQueryParamBase> pParam);
182 bool GetFirst(Value& rValue);
184 bool GetNext(Value& rValue);
185};
186
188{
189private:
194 size_t mnIndex;
195 std::vector<sc::FormulaGroupEntry> maEntries;
196
197public:
199
202};
203
208{
209 typedef std::pair<sc::CellStoreType::const_iterator, size_t> PositionType;
210
215
218
220
221 void incBlock();
222 void incPos();
223 void setPos(size_t nPos);
224
225 const ScColumn* getColumn() const;
226
227 void init();
228 bool getCurrent();
229
230public:
231 ScCellIterator( ScDocument& rDoc, const ScRange& rRange, SubtotalFlags nSubTotalFlags = SubtotalFlags::NONE );
232
233 const ScAddress& GetPos() const { return maCurPos; }
234
235 CellType getType() const { return maCurCell.getType();}
236 OUString getString() const;
241 const ScRefCellValue& getRefCellValue() const { return maCurCell;}
242
243 bool hasString() const;
244 bool isEmpty() const;
245 bool equalsWithoutFormat( const ScAddress& rPos ) const;
246
247 bool first();
248 bool next();
249};
250
251class ScDocAttrIterator // all attribute areas
252{
253private:
260 std::unique_ptr<ScAttrIterator>
262
263public:
264 ScDocAttrIterator(ScDocument& rDocument, SCTAB nTable,
265 SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2);
267
268 const ScPatternAttr* GetNext( SCCOL& rCol, SCROW& rRow1, SCROW& rRow2 );
269};
270
271class ScAttrRectIterator // all attribute areas, including areas stretching
272 // across more than one column
273{
274private:
282 std::unique_ptr<ScAttrIterator>
284
285public:
286 ScAttrRectIterator(ScDocument& rDocument, SCTAB nTable,
287 SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2);
289
290 void DataChanged();
291 const ScPatternAttr* GetNext( SCCOL& rCol1, SCCOL& rCol2, SCROW& rRow1, SCROW& rRow2 );
292};
293
294class ScHorizontalCellIterator // walk through all non empty cells in an area
295{ // row by row
296 struct ColParam
297 {
298 sc::CellStoreType::const_iterator maPos;
299 sc::CellStoreType::const_iterator maEnd;
301 };
302
303 std::vector<ColParam>::iterator maColPos;
304 std::vector<ColParam> maColPositions;
305
315 bool mbMore;
316
317public:
318 ScHorizontalCellIterator(ScDocument& rDocument, SCTAB nTable,
319 SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2);
321
322 ScRefCellValue* GetNext( SCCOL& rCol, SCROW& rRow );
323 bool GetPos( SCCOL& rCol, SCROW& rRow );
325 void SetTab( SCTAB nTab );
326
327private:
328 void Advance();
329 void SkipInvalid();
330 bool SkipInvalidInRow();
332};
333
336{
337private:
340 std::unique_ptr<ScHorizontalCellIterator>
342 sal_uInt32 nNumFormat; // for CalcAsShown
349
350public:
351
353 const ScRange& rRange );
356 bool GetNext( double& rValue, FormulaError& rErr );
357};
358
360{
361private:
368
369 std::unique_ptr<SCROW[]> pNextEnd;
370 std::unique_ptr<SCCOL[]> pHorizEnd;
371 std::unique_ptr<SCSIZE[]> pIndices;
372 std::unique_ptr<const ScPatternAttr*[]>
377
378 void InitForNextRow(bool bInitialization);
379
380public:
381 ScHorizontalAttrIterator( ScDocument& rDocument, SCTAB nTable,
382 SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
384
385 const ScPatternAttr* GetNext( SCCOL& rCol1, SCCOL& rCol2, SCROW& rRow );
386};
387
388// returns non-empty cells and areas with formatting (horizontal)
389
391{
392private:
395
398
406
407 SCCOL nFoundStartCol; // results after GetNext
411
413
414public:
415 ScUsedAreaIterator( ScDocument& rDocument, SCTAB nTable,
416 SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
418
419 bool GetNext();
420
421 SCCOL GetStartCol() const { return nFoundStartCol; }
422 SCCOL GetEndCol() const { return nFoundEndCol; }
423 SCROW GetRow() const { return nFoundRow; }
424 const ScPatternAttr* GetPattern() const { return pFoundPattern; }
425 const ScRefCellValue& GetCell() const { return maFoundCell;}
426};
427
429{
430public:
431 static constexpr SCROW NOT_FOUND = -1;
432
433 explicit ScRowBreakIterator(::std::set<SCROW>& rBreaks);
434 SCROW first();
435 SCROW next();
436
437private:
438 ::std::set<SCROW>& mrBreaks;
439 ::std::set<SCROW>::const_iterator maItr;
440 ::std::set<SCROW>::const_iterator maEnd;
441};
442
444{
445public:
447 {
450
451 TabRanges(SCTAB nTab, SCROW nMaxRow);
452 };
453
458 explicit ScDocRowHeightUpdater(
459 ScDocument& rDoc, OutputDevice* pOutDev, double fPPTX, double fPPTY,
460 const ::std::vector<TabRanges>* pTabRangesArray);
461
462 void update();
463
464private:
465 void updateAll();
466
467private:
470 double mfPPTX;
471 double mfPPTY;
472 const ::std::vector<TabRanges>* mpTabRangesArray;
473};
474
475/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ScDocument & rDoc
Definition: dociter.hxx:275
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:283
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:208
void incBlock()
Definition: dociter.cxx:828
CellType getType() const
Definition: dociter.hxx:235
ScRefCellValue maCurCell
Definition: dociter.hxx:219
ScAddress maEndPos
Definition: dociter.hxx:213
ScAddress maCurPos
Definition: dociter.hxx:214
const EditTextObject * getEditText() const
Definition: dociter.hxx:237
ScFormulaCell * getFormulaCell()
Definition: dociter.hxx:238
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:209
void setPos(size_t nPos)
Definition: dociter.cxx:849
ScAddress maStartPos
Definition: dociter.hxx:212
const ScAddress & GetPos() const
Definition: dociter.hxx:233
const ScRefCellValue & getRefCellValue() const
Definition: dociter.hxx:241
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:239
const ScColumn * getColumn() const
Definition: dociter.cxx:855
PositionType maCurColPos
Definition: dociter.hxx:216
SubtotalFlags mnSubTotalFlags
Definition: dociter.hxx:217
ScCellValue getCellValue() const
Definition: dociter.cxx:973
ScDocument & mrDoc
Definition: dociter.hxx:211
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:131
const ScInterpreterContext & mrContext
Definition: dociter.hxx:147
ScDBQueryParamInternal * mpParam
Definition: dociter.hxx:145
const sc::CellStoreType * mpCells
Definition: dociter.hxx:143
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:171
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:176
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:177
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:254
std::unique_ptr< ScAttrIterator > pColIter
Definition: dociter.hxx:261
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:472
ScDocument & mrDoc
Definition: dociter.hxx:468
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:469
ScDocument & mrDoc
Definition: dociter.hxx:190
sc::FormulaGroupEntry * first()
Definition: dociter.cxx:784
ScFormulaGroupIterator(ScDocument &rDoc)
Definition: dociter.cxx:767
std::vector< sc::FormulaGroupEntry > maEntries
Definition: dociter.hxx:195
sc::FormulaGroupEntry * next()
Definition: dociter.cxx:789
std::unique_ptr< SCROW[]> pNextEnd
Definition: dociter.hxx:369
std::unique_ptr< SCCOL[]> pHorizEnd
Definition: dociter.hxx:370
std::unique_ptr< SCSIZE[]> pIndices
Definition: dociter.hxx:371
std::unique_ptr< const ScPatternAttr *[]> ppPatterns
Definition: dociter.hxx:373
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:314
std::vector< ColParam >::iterator maColPos
Definition: dociter.hxx:303
ScHorizontalCellIterator(ScDocument &rDocument, SCTAB nTable, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
Definition: dociter.cxx:1028
std::vector< ColParam > maColPositions
Definition: dociter.hxx:304
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:336
ScHorizontalValueIterator(ScDocument &rDocument, const ScRange &rRange)
Definition: dociter.cxx:1255
std::unique_ptr< ScHorizontalCellIterator > pCellIter
Definition: dociter.hxx:341
bool GetNext(double &rValue, FormulaError &rErr)
Does NOT reset rValue if no value found!
Definition: dociter.cxx:1293
const ScAttrArray * pAttrArray
Definition: dociter.hxx:339
Matrix data type that can store values of mixed types.
Definition: scmatrix.hxx:101
::std::set< SCROW >::const_iterator maItr
Definition: dociter.hxx:439
::std::set< SCROW >::const_iterator maEnd
Definition: dociter.hxx:440
ScRowBreakIterator(::std::set< SCROW > &rBreaks)
Definition: dociter.cxx:1756
static constexpr SCROW NOT_FOUND
Definition: dociter.hxx:431
::std::set< SCROW > & mrBreaks
Definition: dociter.hxx:438
SCCOL GetEndCol() const
Definition: dociter.hxx:422
ScRefCellValue * pCell
Definition: dociter.hxx:401
ScHorizontalCellIterator aCellIter
Definition: dociter.hxx:393
const ScRefCellValue & GetCell() const
Definition: dociter.hxx:425
SCCOL GetStartCol() const
Definition: dociter.hxx:421
const ScPatternAttr * GetPattern() const
Definition: dociter.hxx:424
const ScPatternAttr * pFoundPattern
Definition: dociter.hxx:410
ScHorizontalAttrIterator aAttrIter
Definition: dociter.hxx:394
const ScPatternAttr * pPattern
Definition: dociter.hxx:405
ScRefCellValue maFoundCell
Definition: dociter.hxx:412
SCROW GetRow() const
Definition: dociter.hxx:423
SvNumFormatType nNumFmtType
Definition: dociter.hxx:66
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 SetInterpreterContext(ScInterpreterContext *context)
Definition: dociter.hxx:98
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
ScInterpreterContext * pContext
Definition: dociter.hxx:56
sal_uInt32 nNumFormat
Definition: dociter.hxx:58
ScAddress maStartPos
Definition: dociter.hxx:60
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
ScValueIterator(ScDocument &rDocument, const ScRange &rRange, SubtotalFlags nSubTotalFlags=SubtotalFlags::NONE, bool bTextAsZero=false)
Definition: dociter.cxx:85
const ScAttrArray * pAttrArray
Definition: dociter.hxx:57
bool bCalcAsShown
Definition: dociter.hxx:68
void GetCurNumFmtInfo(const ScInterpreterContext &rContext, SvNumFormatType &nType, sal_uInt32 &nIndex)
Definition: dociter.cxx:255
SCROW GetRow() const
Definition: dociter.cxx:114
ScDocument & mrDoc
Definition: dociter.hxx:55
PositionType maCurPos
Definition: dociter.hxx:72
sal_Int32 mnRow
FormulaError
CellType
Definition: global.hxx:270
SubtotalFlags
Definition: global.hxx:238
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:449
TabRanges(SCTAB nTab, SCROW nMaxRow)
Definition: dociter.cxx:1604
sc::CellStoreType::const_iterator maEnd
Definition: dociter.hxx:299
sc::CellStoreType::const_iterator maPos
Definition: dociter.hxx:298
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