25 #include <document.hxx>
34 #include <progress.hxx>
37 #include <globstr.hrc>
49 #include <osl/diagnose.h>
56 using ::rtl::math::approxEqual;
62 #define debugiter(...)
68 if ( rpArr == pNewArr && nAttrEndRow >= nRow )
82 nAttrEndRow = nRowEnd;
92 , maStartPos(rRange.aStart)
93 , maEndPos(rRange.aEnd)
97 , mnSubTotalFlags(nSubTotalFlags)
100 , bCalcAsShown(rDocument.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");
322 return pCol->pAttrArray.get();
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");
1110 debugiter(
"return col %d row %d\n", (
int)rCol, (
int)rRow);
1112 size_t nOffset =
static_cast<size_t>(
mnRow) - r.
maPos->position;
1141 size_t nRow =
static_cast<size_t>(
mnRow);
1143 if (nRow >= r.
maPos->position)
1148 debugiter(
"found valid cell at column %d, row %d\n",
1155 bool bMoreBlocksInColumn =
false;
1162 bMoreBlocksInColumn =
true;
1166 if (!bMoreBlocksInColumn)
1168 debugiter(
"remove column %d at row %d\n",
1179 debugiter(
"advanced column %d to block starting row %d, retrying\n",
1186 debugiter(
"skip empty cells at column %d, row %d\n",
1195 debugiter(
"no more live columns left - done\n");
1211 nNextRow = std::min (nNextRow, static_cast<size_t>(r.maPos->position));
1214 SCROW nRow = std::max(static_cast<SCROW>(nNextRow),
mnRow);
1215 debugiter(
"Next non empty row is %d\n", (
int) nRow);
1246 debugiter(
"moved to valid cell in next row (or end)\n");
1253 assert (bCorrect); (
void) bCorrect;
1263 nEndTab( rRange.aEnd.
Tab() ),
1264 bCalcAsShown( rDocument.GetDocOptions().IsCalcAsShown() )
1291 nStartRow, nEndCol, nEndRow ) );
1300 bool bFound =
false;
1319 rErr = FormulaError::NONE;
1379 SCCOL nThisHead = 0;
1384 if ( bInitialization ||
pNextEnd[nPos] < nRow )
1389 if (bInitialization)
1391 if ( pArray.
Count() )
1401 if ( !nIndex && !pArray.
Count() )
1404 assert(
pNextEnd[nPos] >= nRow &&
"Sequence out of order" );
1407 else if ( nIndex < pArray.
Count() )
1412 assert(
pNextEnd[nPos] >= nRow &&
"Sequence out of order" );
1417 assert(!
"AttrArray does not range to MAXROW");
1467 return ( nRow1 > nRow2 ) || ( nRow1 == nRow2 && nCol1 > nCol2 );
1472 : aCellIter( rDocument, nTable, nCol1, nRow1, nCol2, nRow2 )
1473 , aAttrIter( rDocument, nTable, nCol1, nRow1, nCol2, nRow2 )
1481 , nFoundStartCol( 0 )
1484 , pFoundPattern( nullptr )
1511 bool bUseCell =
false;
1610 mnTab(nTab), maRanges(nMaxRow)
1628 sal_uInt64 nCellCount = 0;
1631 const SCTAB nTab = rTabRanges.mnTab;
1637 for (
bool bFound = aRangeItr.
getFirst(aData); bFound; bFound = aRangeItr.
getNext(aData))
1649 sal_uInt64 nProgressStart = 0;
1650 for (
const auto& rTabRanges : *mpTabRangesArray)
1652 const SCTAB nTab = rTabRanges.mnTab;
1659 for (
bool bFound = aRangeItr.
getFirst(aData); bFound; bFound = aRangeItr.
getNext(aData))
1665 aCxt, aData.mnRow1, aData.mnRow2,
true, &aProgress, nProgressStart);
1667 nProgressStart +=
mrDoc.
maTabs[nTab]->GetWeightedCount(aData.mnRow1, aData.mnRow2);
1674 sal_uInt64 nCellCount = 0;
1680 nCellCount +=
mrDoc.
maTabs[nTab]->GetWeightedCount();
1687 sal_uInt64 nProgressStart = 0;
1694 nProgressStart +=
mrDoc.
maTabs[nTab]->GetWeightedCount();
1706 nIterStartCol( nCol1 ),
1707 nIterEndCol( nCol1 )
Matrix data type that can store values of mixed types.
ScValueIterator(ScDocument &rDocument, const ScRange &rRange, SubtotalFlags nSubTotalFlags=SubtotalFlags::NONE, bool bTextAsZero=false)
bool getFirst(RangeData &rRange)
ScUsedAreaIterator(ScDocument &rDocument, SCTAB nTable, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
static void ScAttrArray_IterGetNumberFormat(sal_uInt32 &nFormat, const ScAttrArray *&rpArr, SCROW &nAttrEndRow, const ScAttrArray *pNewArr, SCROW nRow, const ScDocument &rDoc, const ScInterpreterContext *pContext=nullptr)
OUString getString() const
OUString getString() const
bool isValidQuery(SCROW mnRow, const ScMatrix &rMat) const
~ScHorizontalAttrIterator()
ScRefCellValue * GetNext(SCCOL &rCol, SCROW &rRow)
sal_Int32 compareString(const OUString &s1, const OUString &s2) const
OUString ScResId(TranslateId aId)
~ScHorizontalValueIterator()
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...
void IncTab(SCTAB nDelta=1)
std::unique_ptr< const ScPatternAttr *[]> ppPatterns
OUString getString(const ScDocument *pDoc) const
Retrieve string value.
const Item & GetQueryItem() const
DataAccessMatrix(ScDBQueryParamMatrix *pParam)
ScTable * FetchTable(SCTAB nTab)
rtl_uString * getDataIgnoreCase()
ScColumn * FetchColumn(SCCOL nCol)
virtual bool getFirst(Value &rValue) override
bool GetPos(SCCOL &rCol, SCROW &rRow)
bool equalsWithoutFormat(const ScAddress &rPos) const
::std::set< SCROW >::const_iterator maEnd
QueryItemsType & GetQueryItems()
std::unique_ptr< ScAttrIterator > pColIter
const ScAttrArray * pAttrArray
bool GetNext(Value &rValue)
Does NOT reset rValue if no value found!
This is very similar to ScCellValue, except that it references the original value instead of copying ...
static bool IsQueryValid(ScDocument &rDoc, const ScQueryParam &rParam, SCTAB nTab, SCROW nRow, const ScRefCellValue *pCell)
SubtotalFlags mnSubTotalFlags
static const sc::CellStoreType * GetColumnCellStore(ScDocument &rDoc, SCTAB nTab, SCCOL nCol)
bool getNext(RangeData &rRange)
DataAccessInternal(ScDBQueryParamInternal *pParam, ScDocument &rDoc, const ScInterpreterContext &rContext)
std::unique_ptr< SCSIZE[]> pIndices
double GetDouble(SCSIZE nC, SCSIZE nR) const
::std::set< SCROW >::const_iterator maItr
const ScPatternAttr * pPattern
bool equalsWithoutFormat(const ScRefCellValue &r) const
Store arbitrary cell value of any kind.
const ScColumn * getColumn() const
const sc::CellStoreType * mpCells
const mdds::mtv::element_t element_type_formula
void SetTab(SCTAB nTab)
Set a(nother) sheet and (re)init.
const EditTextObject * mpEditText
enumrange< T >::Iterator begin(enumrange< T >)
ScFormulaCell * mpFormula
SC_DLLPUBLIC SCROW MaxRow() const
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 ...
sal_Int32 SCCOLROW
a type capable of holding either SCCOL or SCROW
SC_DLLPUBLIC SCTAB GetTableCount() const
virtual ~DataAccessInternal() override
SC_DLLPUBLIC SCSIZE GetEntryCount() const
sc::CellStoreType maCells
SC_DLLPUBLIC const ScQueryEntry & GetEntry(SCSIZE n) const
ScFormulaCell * mpFormula
bool IsStringOrEmpty(SCSIZE nIndex) const
const ::std::vector< TabRanges > * mpTabRangesArray
bool Search(SCROW nRow, SCSIZE &nIndex) const
~ScHorizontalCellIterator()
ScAttrRectIterator(ScDocument &rDocument, SCTAB nTable, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
SC_DLLPUBLIC SCCOL GetAllocatedColumnsCount(SCTAB nTab) const
bool GetNext(double &rValue, FormulaError &rErr)
Does NOT reset rValue if no value found!
void PutInOrder(T &nStart, T &nEnd)
ScDBQueryParamMatrix * mpParam
constexpr OUStringLiteral aData
std::vector< ScAttrEntry > mvData
std::vector< ColParam >::iterator maColPos
SvNumFormatType nNumFmtType
sc::CellStoreType::const_iterator maEnd
SC_DLLPUBLIC SCCOL MaxCol() const
SC_DLLPUBLIC SvNumberFormatter * GetFormatTable() const
std::unique_ptr< SCCOL[]> pHorizEnd
svl::SharedString GetString(SCSIZE nC, SCSIZE nR) const
SC_DLLPUBLIC bool RowFiltered(SCROW nRow, SCTAB nTab, SCROW *pFirstRow=nullptr, SCROW *pLastRow=nullptr) const
void IncCol(SCCOL nDelta=1)
const svl::SharedString * mpString
bool ValidCol(SCCOL nCol) const
virtual bool getFirst(Value &rValue) override
svl::SharedString * mpString
bool GetThis(double &rValue, FormulaError &rErr)
See if the cell at the current position is a non-empty cell.
std::vector< ColParam > maColPositions
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
const mdds::mtv::element_t element_type_empty
void IncRow(SCROW nDelta=1)
ScDocument & GetDoc() const
VclPtr< OutputDevice > mpOutDev
const mdds::mtv::element_t element_type_numeric
Mapped standard element types (for convenience).
sal_uInt32 GetNumberFormat(SvNumberFormatter *) const
SCROW FindNextNonEmptyRow()
Find the next row that has some real content in one of its columns.
bool GetFirst(Value &rValue)
Does NOT reset rValue if no value found!
TabRanges(SCTAB nTab, SCROW nMaxRow)
ScHorizontalAttrIterator(ScDocument &rDocument, SCTAB nTable, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
std::unique_ptr< ScAttrIterator > pColIter
ScCellIterator(ScDocument &rDoc, const ScRange &rRange, SubtotalFlags nSubTotalFlags=SubtotalFlags::NONE)
::std::set< SCROW > & mrBreaks
sal_uInt32 GetNumberFormat(const ScInterpreterContext &rContext, SCROW nRow) const
svl::SharedString maString
enumrange< T >::Iterator end(enumrange< T >)
const NodeContext & mrContext
ScHorizontalCellIterator(ScDocument &rDocument, SCTAB nTable, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
SC_DLLPUBLIC double RoundValueAsShown(double fVal, sal_uInt32 nFormat, const ScInterpreterContext *pContext=nullptr) const
std::unique_ptr< ScHorizontalCellIterator > pCellIter
mdds::mtv::soa::multi_type_vector< CellFunc, CellStoreTrait > CellStoreType
static constexpr SCROW NOT_FOUND
::std::unique_ptr< ScDBQueryParamBase > mpParam
bool ValidRow(SCROW nRow) const
sc::CellStoreType::const_iterator maPos
static SC_DLLPUBLIC CollatorWrapper & GetCollator()
case-insensitive collator
static const ScAttrArray * GetAttrArrayByCol(ScDocument &rDoc, SCTAB nTab, SCCOL nCol)
bool IsEmpty(SCSIZE nC, SCSIZE nR) const
bool GetFirst(double &rValue, FormulaError &rErr)
Does NOT reset rValue if no value found!
void InitForNextRow(bool bInitialization)
const mdds::mtv::element_t element_type_edittext
ScHorizontalValueIterator(ScDocument &rDocument, const ScRange &rRange)
virtual bool getNext(Value &rValue) override
virtual std::unique_ptr< EditTextObject > Clone() const =0
const ScPatternAttr * GetNext(SCCOL &rCol1, SCCOL &rCol2, SCROW &rRow1, SCROW &rRow2)
SvNumFormatType GetNumberFormatType(sal_uInt32 nFIndex) const
const ScPatternAttr * GetNext(SCCOL &rCol, SCROW &rRow1, SCROW &rRow2)
std::vector< sc::FormulaGroupEntry > GetFormulaGroupEntries()
Get all non-grouped formula cells and formula cell groups in the whole column.
SC_DLLPUBLIC ScPatternAttr * GetDefPattern() const
ScHorizontalAttrIterator aAttrIter
EditTextObject * mpEditText
void GetCurNumFmtInfo(const ScInterpreterContext &rContext, SvNumFormatType &nType, sal_uInt32 &nIndex)
bool GetNext(double &rValue, FormulaError &rErr)
Does NOT reset rValue if no value found!
ScCellValue getCellValue() const
SC_DLLPUBLIC bool RowHidden(SCROW nRow, SCTAB nTab, SCROW *pFirstRow=nullptr, SCROW *pLastRow=nullptr) const
ScRefCellValue toRefCell(const sc::CellStoreType::const_iterator &itPos, size_t nOffset)
std::vector< Item > QueryItemsType
virtual bool getCurrent(Value &rValue) override
virtual ~DataAccessMatrix() override
const ScPatternAttr * GetNext(SCCOL &rCol1, SCCOL &rCol2, SCROW &rRow)
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...
SfxObjectShell * GetDocumentShell() const
#define SAL_WARN(area, stream)
ScDocAttrIterator(ScDocument &rDocument, SCTAB nTable, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
virtual bool getCurrent(Value &rValue) override
SubtotalFlags mnSubTotalFlags
const ScPatternAttr * pFoundPattern
ScInterpreterContext * pContext
ScRowBreakIterator(::std::set< SCROW > &rBreaks)
ScHorizontalCellIterator aCellIter
std::unique_ptr< ScAttrArray > pAttrArray
SCCOL GetAllocatedColumnsCount() const
const mdds::mtv::element_t element_type_string
::std::unique_ptr< DataAccess > mpData
virtual bool getNext(Value &rValue) override
ScDBQueryDataIterator(ScDocument &rDocument, const ScInterpreterContext &rContext, std::unique_ptr< ScDBQueryParamBase > pParam)
bool ValidTab(SCTAB nTab)
std::unique_ptr< SCROW[]> pNextEnd
Each instance of this struct represents a single filtering criteria.
ScDBQueryParamInternal * mpParam
const ScAttrArray * pAttrArray
bool IsValueOrEmpty(SCSIZE nC, SCSIZE nR) const
ScRefCellValue maFoundCell
static bool IsGreater(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
bool m_bDetectedRangeSegmentation false