25#include <document.hxx>
34#include <progress.hxx>
49#include <osl/diagnose.h>
56using ::rtl::math::approxEqual;
68 if ( rpArr == pNewArr && nAttrEndRow >= nRow )
82 nAttrEndRow = nRowEnd;
87 : mrDoc(*rContext.mpDoc)
92 , maStartPos(rRange.aStart)
93 , maEndPos(rRange.aEnd)
97 , mnSubTotalFlags(nSubTotalFlags)
100 , bCalcAsShown((*rContext.mpDoc).GetDocOptions().IsCalcAsShown())
101 , bTextAsZero(bTextZero)
163 rErr = FormulaError::NONE;
193 rErr = FormulaError::NONE;
237 rErr = FormulaError::NONE;
284 if (nCol < pTab->GetAllocatedColumnsCount())
315 return &pTab->
aCol[nCol].maCells;
320 assert(nTab < rDoc.
GetTableCount() &&
"index out of bounds, FIX IT");
328 assert(nTab < rDoc.
GetTableCount() &&
"index out of bounds, FIX IT");
330 return queryEvaluator.
ValidQuery(nRow, pCell);
338 , pAttrArray(nullptr)
346 , bCalcAsShown(rDoc.GetDocOptions().IsCalcAsShown())
379 if (maCurPos.first == mpCells->end() || nRow >
mpParam->nRow2)
382 rValue.
mnError = FormulaError::NONE;
394 if (nCol ==
static_cast<SCCOL>(nFirstQueryField))
415 nAttrEndRow, pNewAttrArray, nRow, mrDoc );
416 rValue.
mfValue = mrDoc.RoundValueAsShown( rValue.
mfValue, nNumFormat );
418 nNumFmtType = SvNumFormatType::NUMBER;
420 rValue.
mnError = FormulaError::NONE;
430 mrDoc.GetNumberFormatInfo(
455 rValue.
mnError = FormulaError::NONE;
479 maCurPos = mpCells->position(nRow);
480 return getCurrent(rValue);
485 if (!mpCells || maCurPos.first == mpCells->end())
489 return getCurrent(rValue);
497 nRow = maCurPos.first->position;
502 if (maCurPos.second + 1 < maCurPos.first->size)
530 for ( ;mnCurRow < mnRows; ++mnCurRow)
538 if (bIsStrVal &&
mpParam->mbSkipString)
541 if (isValidQuery(mnCurRow, rMat))
546 rValue.
mnError = FormulaError::NONE;
555 mnCurRow =
mpParam->bHasHeader ? 1 : 0;
556 return getCurrent(rValue);
562 return getCurrent(rValue);
603 vector<bool> aResults;
604 aResults.reserve(nEntryCount);
626 SAL_WARN(
"sc.core",
"Unsupported operator " << rEntry.
eOp
627 <<
" in ScDBQueryDataIterator::DataAccessMatrix::isValidQuery()");
634 if (isQueryByValue(rItem, rMat, nField, nRow))
637 double fMatVal = rMat.
GetDouble(nField, nRow);
638 bool bEqual = approxEqual(fMatVal, rItem.
mfVal);
645 bValid = (fMatVal < rItem.
mfVal) && !bEqual;
648 bValid = (fMatVal > rItem.
mfVal) && !bEqual;
651 bValid = (fMatVal < rItem.
mfVal) || bEqual;
654 bValid = (fMatVal > rItem.
mfVal) || bEqual;
663 else if (isQueryByString(rEntry, rItem, rMat, nField, nRow))
696 bValid = (nCompare < 0);
699 bValid = (nCompare > 0);
702 bValid = (nCompare <= 0);
705 bValid = (nCompare >= 0);
714 if (aResults.empty())
716 aResults.push_back(bValid);
720 size_t n = aResults.size();
721 aResults[
n-1] = aResults[
n-1] && bValid;
725 aResults.push_back(bValid);
729 return std::find(aResults.begin(), aResults.end(),
true) != aResults.end();
733 : mfValue(
std::numeric_limits<double>::quiet_NaN())
759 return mpData->getFirst(rValue);
764 return mpData->getNext(rValue);
821 maStartPos(rRange.aStart),
822 maEndPos(rRange.aEnd),
823 mnSubTotalFlags(nSubTotalFlags)
881 assert(!
"Table not found");
1109 debugiter(
"return col %d row %d\n", (
int)rCol, (
int)rRow);
1111 size_t nOffset =
static_cast<size_t>(
mnRow) - r.
maPos->position;
1140 size_t nRow =
static_cast<size_t>(
mnRow);
1142 if (nRow >= r.
maPos->position)
1147 debugiter(
"found valid cell at column %d, row %d\n",
1154 bool bMoreBlocksInColumn =
false;
1161 bMoreBlocksInColumn =
true;
1165 if (!bMoreBlocksInColumn)
1167 debugiter(
"remove column %d at row %d\n",
1178 debugiter(
"advanced column %d to block starting row %d, retrying\n",
1185 debugiter(
"skip empty cells at column %d, row %d\n",
1194 debugiter(
"no more live columns left - done\n");
1210 nNextRow = std::min (nNextRow,
static_cast<size_t>(r.maPos->position));
1214 debugiter(
"Next non empty row is %d\n", (
int) nRow);
1245 debugiter(
"moved to valid cell in next row (or end)\n");
1252 assert (bCorrect); (void) bCorrect;
1262 nEndTab( rRange.aEnd.
Tab() ),
1263 bCalcAsShown( rDocument.GetDocOptions().IsCalcAsShown() )
1290 nStartRow, nEndCol, nEndRow ) );
1299 bool bFound =
false;
1318 rErr = FormulaError::NONE;
1378 SCCOL nThisHead = 0;
1388 if (bInitialization)
1390 if ( pArray.
Count() )
1416 assert(!
"AttrArray does not range to MAXROW");
1466 return ( nRow1 > nRow2 ) || ( nRow1 == nRow2 && nCol1 > nCol2 );
1471 : aCellIter( rDocument, nTable, nCol1, nRow1, nCol2, nRow2 )
1472 , aAttrIter( rDocument, nTable, nCol1, nRow1, nCol2, nRow2 )
1480 , nFoundStartCol( 0 )
1483 , pFoundPattern( nullptr )
1510 bool bUseCell =
false;
1609 mnTab(nTab), maRanges(nMaxRow)
1627 sal_uInt64 nCellCount = 0;
1630 const SCTAB nTab = rTabRanges.mnTab;
1648 sal_uInt64 nProgressStart = 0;
1651 const SCTAB nTab = rTabRanges.mnTab;
1664 aCxt,
aData.mnRow1,
aData.mnRow2,
true, &aProgress, nProgressStart);
1673 sal_uInt64 nCellCount = 0;
1679 nCellCount +=
mrDoc.
maTabs[nTab]->GetWeightedCount();
1686 sal_uInt64 nProgressStart = 0;
1695 mrDoc.
maTabs[nTab]->SetOptimalHeight(aCxt, 0, nEndRow,
true, &aProgress, nProgressStart);
1696 nProgressStart +=
mrDoc.
maTabs[nTab]->GetWeightedCount();
1708 nIterStartCol( nCol1 ),
1709 nIterEndCol( nCol1 )
bool ValidTab(SCTAB nTab)
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 ...
void PutInOrder(T &nStart, T &nEnd)
const NodeContext & mrContext
sal_Int32 compareString(const OUString &s1, const OUString &s2) const
virtual std::unique_ptr< EditTextObject > Clone() const=0
void IncTab(SCTAB nDelta=1)
void IncCol(SCCOL nDelta=1)
void IncRow(SCROW nDelta=1)
bool Search(SCROW nRow, SCSIZE &nIndex) const
const ScPatternAttr * GetPatternRange(SCROW &rStartRow, SCROW &rEndRow, SCROW nRow) const
Returns if you search for attributes at nRow the range from rStartRow to rEndRow where that attribute...
std::vector< ScAttrEntry > mvData
ScAttrRectIterator(ScDocument &rDocument, SCTAB nTable, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
std::unique_ptr< ScAttrIterator > pColIter
const ScPatternAttr * GetNext(SCCOL &rCol1, SCCOL &rCol2, SCROW &rRow1, SCROW &rRow2)
OUString getString() const
ScCellIterator(ScDocument &rDoc, const ScRange &rRange, SubtotalFlags nSubTotalFlags=SubtotalFlags::NONE)
bool equalsWithoutFormat(const ScAddress &rPos) const
const ScColumn * getColumn() const
SubtotalFlags mnSubTotalFlags
ScCellValue getCellValue() const
std::unique_ptr< ScAttrArray > pAttrArray
std::vector< sc::FormulaGroupEntry > GetFormulaGroupEntries()
Get all non-grouped formula cells and formula cell groups in the whole column.
sc::CellStoreType maCells
ScDocument & GetDoc() const
sal_uInt32 GetNumberFormat(const ScInterpreterContext &rContext, SCROW nRow) const
virtual bool getCurrent(Value &rValue) override
virtual bool getFirst(Value &rValue) override
virtual bool getNext(Value &rValue) override
DataAccessInternal(ScDBQueryParamInternal *pParam, ScDocument &rDoc, const ScInterpreterContext &rContext)
virtual ~DataAccessInternal() override
ScDBQueryParamInternal * mpParam
virtual bool getCurrent(Value &rValue) override
bool isValidQuery(SCROW mnRow, const ScMatrix &rMat) const
virtual bool getFirst(Value &rValue) override
virtual ~DataAccessMatrix() override
DataAccessMatrix(ScDBQueryParamMatrix *pParam)
virtual bool getNext(Value &rValue) override
ScDBQueryParamMatrix * mpParam
::std::unique_ptr< ScDBQueryParamBase > mpParam
static const ScAttrArray * GetAttrArrayByCol(ScDocument &rDoc, SCTAB nTab, SCCOL nCol)
ScDBQueryDataIterator(ScDocument &rDocument, const ScInterpreterContext &rContext, std::unique_ptr< ScDBQueryParamBase > pParam)
bool GetNext(Value &rValue)
Does NOT reset rValue if no value found!
bool GetFirst(Value &rValue)
Does NOT reset rValue if no value found!
static const sc::CellStoreType * GetColumnCellStore(ScDocument &rDoc, SCTAB nTab, SCCOL nCol)
::std::unique_ptr< DataAccess > mpData
static bool IsQueryValid(ScDocument &rDoc, const ScQueryParam &rParam, SCTAB nTab, SCROW nRow, const ScRefCellValue *pCell)
const ScPatternAttr * GetNext(SCCOL &rCol, SCROW &rRow1, SCROW &rRow2)
std::unique_ptr< ScAttrIterator > pColIter
ScDocAttrIterator(ScDocument &rDocument, SCTAB nTable, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
void update(const bool bOnlyUsedRows=false)
const ::std::vector< TabRanges > * mpTabRangesArray
void updateAll(const bool bOnlyUsedRows)
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.
VclPtr< OutputDevice > mpOutDev
SC_DLLPUBLIC SCCOL GetAllocatedColumnsCount(SCTAB nTab) const
SC_DLLPUBLIC ScPatternAttr * GetDefPattern() const
bool ValidRow(SCROW nRow) const
SC_DLLPUBLIC ScTable * FetchTable(SCTAB nTab)
SC_DLLPUBLIC SCCOL MaxCol() const
SC_DLLPUBLIC bool RowFiltered(SCROW nRow, SCTAB nTab, SCROW *pFirstRow=nullptr, SCROW *pLastRow=nullptr) const
SC_DLLPUBLIC SCROW MaxRow() const
SC_DLLPUBLIC double RoundValueAsShown(double fVal, sal_uInt32 nFormat, const ScInterpreterContext *pContext=nullptr) const
SC_DLLPUBLIC bool RowHidden(SCROW nRow, SCTAB nTab, SCROW *pFirstRow=nullptr, SCROW *pLastRow=nullptr) const
SfxObjectShell * GetDocumentShell() const
bool ValidCol(SCCOL nCol) const
SC_DLLPUBLIC SvNumberFormatter * GetFormatTable() const
SC_DLLPUBLIC bool GetPrintArea(SCTAB nTab, SCCOL &rEndCol, SCROW &rEndRow, bool bNotes=true) const
SC_DLLPUBLIC SCTAB GetTableCount() const
bool getFirst(RangeData &rRange)
bool getNext(RangeData &rRange)
static SC_DLLPUBLIC CollatorWrapper & GetCollator()
case-insensitive collator
~ScHorizontalAttrIterator()
std::unique_ptr< SCROW[]> pNextEnd
std::unique_ptr< SCCOL[]> pHorizEnd
std::unique_ptr< SCSIZE[]> pIndices
std::unique_ptr< const ScPatternAttr *[]> ppPatterns
ScHorizontalAttrIterator(ScDocument &rDocument, SCTAB nTable, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
void InitForNextRow(bool bInitialization)
const ScPatternAttr * GetNext(SCCOL &rCol1, SCCOL &rCol2, SCROW &rRow)
void SetTab(SCTAB nTab)
Set a(nother) sheet and (re)init.
bool GetPos(SCCOL &rCol, SCROW &rRow)
ScRefCellValue * GetNext(SCCOL &rCol, SCROW &rRow)
std::vector< ColParam >::iterator maColPos
ScHorizontalCellIterator(ScDocument &rDocument, SCTAB nTable, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
std::vector< ColParam > maColPositions
SCROW FindNextNonEmptyRow()
Find the next row that has some real content in one of its columns.
~ScHorizontalCellIterator()
ScHorizontalValueIterator(ScDocument &rDocument, const ScRange &rRange)
std::unique_ptr< ScHorizontalCellIterator > pCellIter
~ScHorizontalValueIterator()
bool GetNext(double &rValue, FormulaError &rErr)
Does NOT reset rValue if no value found!
const ScAttrArray * pAttrArray
Matrix data type that can store values of mixed types.
svl::SharedString GetString(SCSIZE nC, SCSIZE nR) const
bool IsStringOrEmpty(SCSIZE nIndex) const
bool IsEmpty(SCSIZE nC, SCSIZE nR) const
double GetDouble(SCSIZE nC, SCSIZE nR) const
bool IsValueOrEmpty(SCSIZE nC, SCSIZE nR) const
sal_uInt32 GetNumberFormat(SvNumberFormatter *) const
bool ValidQuery(SCROW nRow, const ScRefCellValue *pCell=nullptr, sc::TableColumnBlockPositionSet *pBlockPos=nullptr)
::std::set< SCROW >::const_iterator maItr
::std::set< SCROW >::const_iterator maEnd
ScRowBreakIterator(::std::set< SCROW > &rBreaks)
static constexpr SCROW NOT_FOUND
::std::set< SCROW > & mrBreaks
ScColumn * FetchColumn(SCCOL nCol)
SCCOL GetAllocatedColumnsCount() const
SCCOL ClampToAllocatedColumns(SCCOL nCol) const
ScHorizontalCellIterator aCellIter
const ScPatternAttr * pFoundPattern
ScHorizontalAttrIterator aAttrIter
const ScPatternAttr * pPattern
ScRefCellValue maFoundCell
ScUsedAreaIterator(ScDocument &rDocument, SCTAB nTable, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
SvNumFormatType nNumFmtType
bool GetFirst(double &rValue, FormulaError &rErr)
Does NOT reset rValue if no value found!
SubtotalFlags mnSubTotalFlags
void GetCurNumFmtInfo(SvNumFormatType &nType, sal_uInt32 &nIndex)
bool GetThis(double &rValue, FormulaError &rErr)
See if the cell at the current position is a non-empty cell.
ScValueIterator(ScInterpreterContext &rContext, const ScRange &rRange, SubtotalFlags nSubTotalFlags=SubtotalFlags::NONE, bool bTextAsZero=false)
ScInterpreterContext & mrContext
const sc::CellStoreType * mpCells
bool GetNext(double &rValue, FormulaError &rErr)
Does NOT reset rValue if no value found!
const ScAttrArray * pAttrArray
const OUString & getString() const
rtl_uString * getDataIgnoreCase()
static void ScAttrArray_IterGetNumberFormat(sal_uInt32 &nFormat, const ScAttrArray *&rpArr, SCROW &nAttrEndRow, const ScAttrArray *pNewArr, SCROW nRow, const ScDocument &rDoc, const ScInterpreterContext *pContext=nullptr)
static bool IsGreater(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
#define SAL_WARN(area, stream)
constexpr OUStringLiteral aData
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
enumrange< T >::Iterator begin(enumrange< T >)
const mdds::mtv::element_t element_type_edittext
const mdds::mtv::element_t element_type_formula
mdds::mtv::soa::multi_type_vector< CellStoreTraits > CellStoreType
Cell container.
ScRefCellValue toRefCell(const sc::CellStoreType::const_iterator &itPos, size_t nOffset)
const mdds::mtv::element_t element_type_numeric
Mapped standard element types (for convenience).
const mdds::mtv::element_t element_type_string
const mdds::mtv::element_t element_type_empty
OUString ScResId(TranslateId aId)
Store arbitrary cell value of any kind.
TabRanges(SCTAB nTab, SCROW nMaxRow)
sc::CellStoreType::const_iterator maEnd
sc::CellStoreType::const_iterator maPos
SvNumFormatType GetNumberFormatType(sal_uInt32 nFIndex) const
svl::SharedString maString
Each instance of this struct represents a single filtering criteria.
const Item & GetQueryItem() const
std::vector< Item > QueryItemsType
QueryItemsType & GetQueryItems()
SC_DLLPUBLIC const ScQueryEntry & GetEntry(SCSIZE n) const
SC_DLLPUBLIC SCSIZE GetEntryCount() const
This is very similar to ScCellValue, except that it references the original value instead of copying ...
ScFormulaCell * getFormula() const
const EditTextObject * getEditText() const
OUString getString(const ScDocument *pDoc) const
Retrieve string value.
bool equalsWithoutFormat(const ScRefCellValue &r) const
const svl::SharedString * getSharedString() const
sal_Int32 SCCOLROW
a type capable of holding either SCCOL or SCROW