14 #include <document.hxx>
25 #include <tokenarray.hxx>
30 #include <compiler.hxx>
48 sc::CellStoreType::const_position_type aPos =
maCells.position(nRow1);
49 sc::CellStoreType::const_iterator it = aPos.first;
50 size_t nOffset = aPos.second;
54 for (; it !=
maCells.end() && nRow <= nRow2; ++it)
60 size_t nSize = it->size - nOffset;
62 SCROW nLastRow = nRow + nSize - 1;
65 nSize -= nLastRow - nRow2;
86 nRow += it->size - nOffset;
151 SCROW nClipRowLen = nClipRow2 - nClipRow1 + 1;
155 aSpanSet.
scan(rClipCol, nClipRow1, nClipRow2);
164 std::vector<sc::RowSpan> aDestSpans;
166 bool bContinue =
true;
171 SCROW nDestRow1 = r.mnRow1 + nDestOffset;
172 SCROW nDestRow2 = r.mnRow2 + nDestOffset;
174 if (nDestRow1 > aRange.
mnRow2)
181 if (nDestRow2 > aRange.
mnRow2)
184 nDestRow2 = aRange.
mnRow2;
188 aDestSpans.emplace_back(nDestRow1, nDestRow2);
194 nDestOffset += nClipRowLen;
197 for (
const auto& rDestSpan : aDestSpans)
199 SCROW nRow1 = rDestSpan.mnRow1;
200 SCROW nRow2 = rDestSpan.mnRow2;
205 DeleteCells(*pBlockPos, nRow1, nRow2, nDelFlag, aDeletedRows);
241 assert(nRow1 <= nRow2);
243 size_t nDestSize = nRow2 - nRow1 + 1;
263 auto pNewPattern = std::make_unique<ScPatternAttr>(*pAttr);
264 sal_uInt16 pItems[2];
267 pNewPattern->ClearItems(pItems);
268 pAttrArray->SetPatternArea(nRow1, nRow2, std::move(pNewPattern),
true);
274 std::vector<sc::CellTextAttr> aTextAttrs(nDestSize, rSrcAttr);
280 std::vector<double> aVals(nDestSize, rSrcCell.
mfValue);
297 std::vector<svl::SharedString> aStrs(nDestSize, aStr);
307 std::vector<EditTextObject*> aStrs;
308 aStrs.reserve(nDestSize);
309 for (
size_t i = 0;
i < nDestSize; ++
i)
321 std::vector<sc::RowSpan> aRanges;
323 aRanges.emplace_back(nRow1, nRow2);
345 std::vector<ScPostIt*> aNotes;
346 aNotes.reserve(nDestSize);
347 for (
size_t i = 0;
i < nDestSize; ++
i)
350 aNotes.push_back(pNote->
Clone(aSrcPos, rDocument, aDestPosition, bCloneCaption).release());
356 pBlockPos->
miCellNotePos, nRow1, aNotes.begin(), aNotes.end());
359 aDestPosition.
SetRow(nRow1);
360 for (
size_t i = 0;
i < nDestSize; ++
i)
368 size_t nColOffset,
size_t nDestSize,
ScAddress aDestPosition)
376 auto const& pSparklineGroup = pSparkline->getSparklineGroup();
379 if (!pDuplicatedGroup)
380 pDuplicatedGroup = std::make_shared<sc::SparklineGroup>(*pSparklineGroup);
382 std::vector<sc::SparklineCell*> aSparklines(nDestSize,
nullptr);
383 ScAddress aCurrentPosition = aDestPosition;
384 for (
size_t i = 0;
i < nDestSize; ++
i)
386 auto pNewSparkline = std::make_shared<sc::Sparkline>(aCurrentPosition.
Col(), aCurrentPosition.
Row(), pDuplicatedGroup);
387 pNewSparkline->setInputRange(pSparkline->getInputRange());
389 aCurrentPosition.
IncRow();
401 SCROW nLastRow = nRow + rVals.size() - 1;
402 if (nLastRow >
GetDoc().MaxRow())
406 sc::CellStoreType::position_type aPos =
maCells.position(nRow);
407 std::vector<SCROW> aNewSharedRows;
410 maCells.set(nRow, rVals.begin(), rVals.end());
411 std::vector<sc::CellTextAttr> aDefaults(rVals.size());
418 std::vector<SCROW> aRows;
419 aRows.reserve(rVals.size());
420 for (
SCROW i = nRow;
i <= nLastRow; ++
i)
431 SCROW nLastRow = nRow + nLen - 1;
432 if (nLastRow >
GetDoc().MaxRow())
436 sc::CellStoreType::position_type aPos =
maCells.position(nRow);
443 std::vector<SCROW> aRows;
445 for (
SCROW i = nRow;
i <= nLastRow; ++
i)
457 if (nLastRow >
GetDoc().MaxRow())
461 sc::CellStoreType::position_type aPos =
maCells.position(nRow);
468 std::vector<SCROW> aRows;
469 aRows.reserve(rSrc.
size());
470 for (
SCROW i = nRow;
i <= nLastRow; ++
i)
478 class ConvertFormulaToValueHandler
484 ConvertFormulaToValueHandler(
ScSheetLimits const & rSheetLimits) :
510 bool isModified()
const {
return mbModified; }
523 std::vector<SCROW> aBounds { nRow1 };
524 if (nRow2 <
GetDoc().MaxRow()-1)
525 aBounds.push_back(nRow2+1);
531 ConvertFormulaToValueHandler aFunc(
GetDoc().GetSheetLimits());
533 if (!aFunc.isModified())
541 aFunc.getResValues().swap(aUndoCells);
549 class StartListeningHandler
563 class EndListeningHandler
583 std::vector<SCROW> aBounds { rRange.
aStart.
Row() };
585 aBounds.push_back(rRange.
aEnd.
Row()+1);
592 EndListeningHandler aEndLisFunc(rEndCxt);
593 sc::CellStoreType::iterator itPos =
maCells.begin();
594 for (
const auto& rSpan : aSpans)
596 SCROW nRow1 = rSpan.mnRow1;
597 SCROW nRow2 = rSpan.mnRow2;
605 StartListeningHandler aStartLisFunc(rStartCxt);
607 for (
const auto& rSpan : aSpans)
609 SCROW nRow1 = rSpan.mnRow1;
610 SCROW nRow2 = rSpan.mnRow2;
619 for (
const auto& rSpan : rRanges)
620 DeleteArea(rSpan.mnRow1, rSpan.mnRow2, nDelFlag,
false);
626 const std::vector<sc::RowSpan>& rRanges )
628 SCCOL nMatrixCols = 0;
629 SCROW nMatrixRows = 0;
634 SAL_WARN_IF( nMatrixCols != 1 || nMatrixRows != 1,
"sc.core",
635 "ScColumn::CloneFormulaCell - cloning array/matrix with not exactly one column or row as single cell");
639 std::vector<ScFormulaCell*> aFormulas;
640 for (
const auto& rSpan : rRanges)
642 SCROW nRow1 = rSpan.mnRow1, nRow2 = rSpan.mnRow2;
643 size_t nLen = nRow2 - nRow1 + 1;
646 aFormulas.reserve(nLen);
654 for (
size_t i = 0;
i < nLen; ++
i, aPos.
IncRow())
657 aFormulas.push_back(pCell);
664 xGroup->setCode(*rSrc.
GetCode());
665 xGroup->compileCode(rDocument, aPos, rDocument.
GetGrammar());
666 for (
size_t i = 0;
i < nLen; ++
i, aPos.
IncRow())
673 xGroup->mpTopCell = pCell;
674 xGroup->mnLength = nLen;
676 aFormulas.push_back(pCell);
683 sc::CellStoreType::position_type aPosObj =
maCells.position(rBlockPos.
miCellPos, nRow1);
686 ScFormulaCell* pCell = sc::formula_block::at(*aPosObj.first->data, aPosObj.second);
689 aPosObj =
maCells.position(aPosObj.first, nRow2);
691 pCell = sc::formula_block::at(*aPosObj.first->data, aPosObj.second);
694 std::vector<sc::CellTextAttr> aTextAttrs(nLen, rAttr);
704 const std::vector<sc::RowSpan>& rRanges )
718 return std::unique_ptr<ScPostIt>(p);
724 [](
const size_t& rCount,
const auto& rCellNote) {
727 return rCount + rCellNote.size;
733 class NoteCaptionCreator
737 NoteCaptionCreator(
SCTAB nTab,
SCCOL nCol ) : maPos(nCol,0,nTab) {}
739 void operator() (
size_t nRow,
const ScPostIt* p )
746 class NoteCaptionCleaner
750 explicit NoteCaptionCleaner(
bool bPreserveData ) : mbPreserveData(bPreserveData) {}
752 void operator() (
size_t ,
ScPostIt* p )
762 NoteCaptionCreator aFunc(
nTab,
nCol);
774 NoteCaptionCleaner aFunc(bPreserveData);
775 sc::CellNoteStoreType::iterator it =
maCellNotes.begin();
790 if (nIndex < nCount + rCellNote.size)
793 size_t nOffset = nIndex - nCount;
794 return rCellNote.position + nOffset;
797 nCount += rCellNote.size;
805 class NoteEntryCollector
807 std::vector<sc::NoteEntry>& mrNotes;
813 NoteEntryCollector( std::vector<sc::NoteEntry>& rNotes,
SCTAB nTab,
SCCOL nCol,
815 mrNotes(rNotes), mnTab(nTab), mnCol(nCol),
816 mnStartRow(nStartRow), mnEndRow(nEndRow) {}
818 void operator() (
const sc::CellNoteStoreType::value_type& node)
const
823 size_t nTopRow = node.position;
824 sc::cellnote_block::const_iterator it = sc::cellnote_block::begin(*node.data);
825 sc::cellnote_block::const_iterator itEnd = sc::cellnote_block::end(*node.data);
829 std::advance(it, mnStartRow - nTopRow);
830 nOffset = mnStartRow - nTopRow;
836 ScAddress aPos(mnCol, nTopRow + nOffset, mnTab);
837 mrNotes.emplace_back(aPos, *it);
850 std::vector<sc::NoteEntry>& rNotes )
const
852 std::pair<sc::CellNoteStoreType::const_iterator,size_t> aPos =
maCellNotes.position(nStartRow);
853 sc::CellNoteStoreType::const_iterator it = aPos.first;
858 std::pair<sc::CellNoteStoreType::const_iterator,size_t> aEndPos =
860 sc::CellNoteStoreType::const_iterator itEnd = aEndPos.first;
862 std::for_each(it, ++itEnd, NoteEntryCollector(rNotes,
nTab,
nCol, nStartRow, nEndRow));
867 std::pair<sc::CellNoteStoreType::const_iterator,size_t> aStartPos =
873 std::pair<sc::CellNoteStoreType::const_iterator,size_t> aEndPos =
876 for (sc::CellNoteStoreType::const_iterator it = aStartPos.first; it != aEndPos.first; ++it)
880 size_t nTopRow = it->position;
881 sc::cellnote_block::const_iterator blockIt = sc::cellnote_block::begin(*(it->data));
882 sc::cellnote_block::const_iterator blockItEnd = sc::cellnote_block::end(*(it->data));
886 std::advance(blockIt, nStartRow - nTopRow);
887 nOffset = nStartRow - nTopRow;
899 SCROW nTmpStartRow = nStartRow, nTmpEndRow = nEndRow;
905 if (nTmpStartRow < nStartRow)
906 nTmpStartRow = nStartRow;
907 if (nTmpEndRow > nEndRow)
908 nTmpEndRow = nEndRow;
911 while (nEndRow > nTmpEndRow)
913 nStartRow = nTmpEndRow + 1;
914 pPattern =
pAttrArray->GetPatternRange(nTmpStartRow, nTmpEndRow, nStartRow);
921 if (nTmpEndRow > nEndRow)
922 nTmpEndRow = nEndRow;
930 class RecompileByOpcodeHandler
938 RecompileByOpcodeHandler(
943 mrEndListenCxt(rEndListenCxt),
944 mrCompileFormulaCxt(rCompileCxt) {}
968 OUString aFormula = pTop->
GetFormula(mrCompileFormulaCxt);
969 sal_Int32
n = aFormula.getLength();
972 if (aFormula[0] ==
'{' && aFormula[n-1] ==
'}')
973 aFormula = aFormula.copy(1, n-2);
980 for (; pp != ppEnd; ++pp)
998 class CompileHybridFormulaHandler
1007 mrStartListenCxt(rStartListenCxt),
1008 mrCompileFormulaCxt(rCompileCxt) {}
1017 if (!aFormula.isEmpty())
1022 std::unique_ptr<ScTokenArray> pNewCode = aComp.CompileString(aFormula);
1025 xGroup->setCode(std::move(*pNewCode));
1031 for (; pp != ppEnd; ++pp)
1045 if (!aFormula.isEmpty())
1049 std::unique_ptr<ScTokenArray> pNewCode = aComp.CompileString(aFormula);
1056 pCell->
SetCode(std::move(pNewCode));
1076 RecompileByOpcodeHandler aFunc(&
GetDoc(), aOps, rEndListenCxt, rCompileCxt);
1077 std::for_each(aGroups.begin(), aGroups.end(), aFunc);
1091 RecompileByOpcodeHandler aFunc(&
GetDoc(), aOps, rEndListenCxt, rCompileCxt);
1092 std::for_each(aGroups.begin(), aGroups.end(), aFunc);
1101 CompileHybridFormulaHandler aFunc(
GetDoc(), rStartListenCxt, rCompileCxt);
1102 std::for_each(aGroups.begin(), aGroups.end(), aFunc);
1107 class ScriptTypeUpdater
1111 sc::CellTextAttrStoreType::iterator miPosAttr;
1120 sc::CellTextAttrStoreType::position_type aAttrPos = mrTextAttrs.position(miPosAttr, nRow);
1121 miPosAttr = aAttrPos.first;
1126 sc::CellTextAttr& rAttr = sc::celltextattr_block::at(*aAttrPos.first->data, aAttrPos.second);
1145 const Color* pColor;
1154 explicit ScriptTypeUpdater(
ScColumn& rCol ) :
1156 mrTextAttrs(rCol.GetCellAttrStore()),
1157 miPosAttr(mrTextAttrs.
begin()),
1158 mpCFList(rCol.GetDoc().GetCondFormList(rCol.GetTab())),
1159 mpFormatter(rCol.GetDoc().GetFormatTable()),
1160 maPos(rCol.GetCol(), 0, rCol.GetTab()),
1164 void operator() (
size_t nRow,
double fVal )
1167 updateScriptType(nRow, aCell);
1173 updateScriptType(nRow, aCell);
1179 updateScriptType(nRow, aCell);
1185 updateScriptType(nRow, aCell);
1188 bool isUpdated()
const {
return mbUpdated; }
1198 ScriptTypeUpdater aFunc(*
this);
1200 if (aFunc.isUpdated())
1215 std::map<SCROW, std::vector<SdrObject*>> aThisColRowDrawObjects
1217 std::map<SCROW, std::vector<SdrObject*>> aOtherColRowDrawObjects
1219 for (
SCROW nRow = nRow1; nRow <= nRow2; ++nRow)
1221 std::vector<SdrObject*>& rThisCellDrawObjects = aThisColRowDrawObjects[nRow];
1222 if (!rThisCellDrawObjects.empty())
1224 std::vector<SdrObject*>& rOtherCellDrawObjects = aOtherColRowDrawObjects[nRow];
1225 if (!rOtherCellDrawObjects.empty())
1232 for (
SCROW nRow = nRow1; nRow <= nRow2; ++nRow)
1252 class FormulaColPosSetter
1257 FormulaColPosSetter(
SCCOL nCol,
bool bUpdateRefs ) : mnCol(nCol), mbUpdateRefs(bUpdateRefs) {}
1285 FormulaColPosSetter aFunc(
nCol, bUpdateRefs);
1291 class RelativeRefBoundChecker
1297 explicit RelativeRefBoundChecker(
const ScRange& rBoundRange ) :
1298 maBoundRange(rBoundRange) {}
1309 void swapBounds( std::vector<SCROW>& rBounds )
1311 rBounds.swap(maBounds);
1323 std::vector<SCROW> aBounds;
1326 aBounds.push_back(rBoundRange.
aStart.
Row());
1328 aBounds.push_back(rBoundRange.
aEnd.
Row()+1);
1331 RelativeRefBoundChecker aFunc(rBoundRange);
1334 aFunc.swapBounds(aBounds);
1340 class ListenerCollector
1342 std::vector<SvtListener*>& mrListeners;
1344 explicit ListenerCollector( std::vector<SvtListener*>& rListener ) :
1345 mrListeners(rListener) {}
1350 mrListeners.insert(mrListeners.end(), rLis.begin(), rLis.end());
1354 class FormulaCellCollector
1356 std::vector<ScFormulaCell*>&
mrCells;
1358 explicit FormulaCellCollector( std::vector<ScFormulaCell*>& rCells ) : mrCells(rCells) {}
1362 mrCells.push_back(p);
1373 ListenerCollector aFunc(rListeners);
1382 FormulaCellCollector aFunc(rCells);
1393 struct FindAnyFormula
1411 if (nRow1 == 0 && nRow2 ==
GetDoc().MaxRow())
1414 FindAnyFormula aFunc;
1415 std::pair<sc::CellStoreType::const_iterator, size_t> aRet =
1418 return aRet.first !=
maCells.end();
1425 for (; pp != ppEnd; ++pp)
1432 class StartListeningFormulaCellsHandler
1440 mrStartCxt(rStartCxt), mrEndCxt(rEndCxt), mnStartRow(-1) {}
1442 void operator() (
const sc::CellStoreType::value_type& node,
size_t nOffset,
size_t nDataSize )
1448 mnStartRow = node.position + nOffset;
1450 ScFormulaCell** ppBeg = &sc::formula_block::at(*node.data, nOffset);
1463 if (nBackTrackSize > 0)
1466 for (
SCROW i = 0;
i < nBackTrackSize; ++
i)
1468 endListening(mrEndCxt, pp, ppBeg);
1469 mnStartRow -= nBackTrackSize;
1473 for (; pp != ppEnd; ++pp)
1488 if (nEndGroupPos > nDataSize)
1490 size_t nExcessSize = nEndGroupPos - nDataSize;
1493 endListening(mrEndCxt, ppGrp, ppGrpEnd);
1510 class EndListeningFormulaCellsHandler
1518 mrEndCxt(rEndCxt), mnStartRow(-1), mnEndRow(-1) {}
1520 void operator() (
const sc::CellStoreType::value_type& node,
size_t nOffset,
size_t nDataSize )
1526 mnStartRow = node.position + nOffset;
1528 ScFormulaCell** ppBeg = &sc::formula_block::at(*node.data, nOffset);
1540 if (nBackTrackSize > 0)
1543 for (
SCROW i = 0;
i < nBackTrackSize; ++
i)
1545 mnStartRow -= nBackTrackSize;
1549 for (; pp != ppEnd; ++pp)
1561 mnEndRow = node.position + nOffset + nEndGroupPos - 1;
1564 endListening(mrEndCxt, pp, ppGrpEnd);
1566 if (nEndGroupPos > nDataSize)
1580 SCROW getStartRow()
const
1585 SCROW getEndRow()
const
1600 StartListeningFormulaCellsHandler aFunc(rStartCxt, rEndCxt);
1611 EndListeningFormulaCellsHandler aFunc(rCxt);
1615 *pStartRow = aFunc.getStartRow();
1618 *pEndRow = aFunc.getEndRow();
1627 sc::CellStoreType::position_type aPos =
maCells.position(nRow);
1628 sc::CellStoreType::iterator it = aPos.first;
1633 ScFormulaCell* pFC = sc::formula_block::at(*it->data, aPos.second);
1646 pGroupPos->push_back(xGroup->mpTopCell->aPos);
1649 if (nRow < nGrpLastRow)
1659 sc::CellStoreType::position_type aPos =
maCells.position(nRow1);
1660 sc::CellStoreType::iterator it = aPos.first;
1663 ScFormulaCell* pFC = sc::formula_block::at(*it->data, aPos.second);
1673 pGroupPos->push_back(xGroup->mpTopCell->aPos);
1677 aPos =
maCells.position(it, nRow2);
1682 ScFormulaCell* pFC = sc::formula_block::at(*it->data, aPos.second);
1694 ScAddress aPosLast = xGroup->mpTopCell->aPos;
1695 aPosLast.
IncRow(xGroup->mnLength-1);
1696 pGroupPos->push_back(aPosLast);
1702 sc::CellStoreType::position_type aPos =
maCells.position(nRow);
1707 ScFormulaCell** pp = &sc::formula_block::at(*aPos.first->data, aPos.second);
1713 (*pp)->EndListeningTo(rCxt);
1718 SCROW nTopDelta = (*pp)->aPos.Row() - xGroup->mpTopCell->aPos.Row();
1719 assert(nTopDelta >= 0);
1724 assert(*pp == xGroup->mpTopCell);
1726 for (; pp != ppEnd; ++pp)
1732 sc::CellStoreType::position_type aPos =
maCells.position(nRow);
1737 ScFormulaCell** pp = &sc::formula_block::at(*aPos.first->data, aPos.second);
1743 (*pp)->SetNeedsListening(
true);
1748 SCROW nTopDelta = (*pp)->aPos.Row() - xGroup->mpTopCell->aPos.Row();
1749 assert(nTopDelta >= 0);
1754 assert(*pp == xGroup->mpTopCell);
1756 for (; pp != ppEnd; ++pp)
1771 bAllowThreading =
true;
1773 SCROW nSpanStart = -1;
1774 SCROW nSpanEnd = -1;
1775 sc::formula_block::const_iterator itSpanStart;
1776 bool bAnyDirty =
false;
1777 for (
SCROW nFGOffset = nStartOffset; nFGOffset <= nEndOffset; ++rSpanIter, ++nFGOffset)
1780 if (!pCellStart && bThisDirty)
1782 pCellStart = *rSpanIter;
1783 itSpanStart = rSpanIter;
1784 nSpanStart = nFGOffset;
1788 if (pCellStart && (!bThisDirty || nFGOffset == nEndOffset))
1790 nSpanEnd = bThisDirty ? nFGOffset : nFGOffset - 1;
1791 assert(nSpanStart >= nStartOffset && nSpanStart <= nSpanEnd && nSpanEnd <= nEndOffset);
1794 bool bGroupInterpreted = pCellStart->
Interpret(nSpanStart, nSpanEnd);
1796 if (bGroupInterpreted)
1797 for (
SCROW nIdx = nSpanStart; nIdx <= nSpanEnd; ++nIdx, ++itSpanStart)
1798 assert(!(*itSpanStart)->NeedsInterpret());
1807 if ((mxParentGroup && mxParentGroup->mbPartOfCycle) || !rRecursionHelper.
AreGroupsIndependent())
1809 bAllowThreading =
false;
1813 if (!bGroupInterpreted)
1817 for (
SCROW nIdx = nSpanStart+1; nIdx <= nSpanEnd; ++nIdx, ++itSpanStart)
1819 (*itSpanStart)->Interpret();
1820 if ((*itSpanStart)->NeedsInterpret())
1822 SAL_WARN(
"sc.core.formulagroup",
"Internal error, cell " << (*itSpanStart)->aPos
1823 <<
" failed running Interpret(), not allowing threading");
1824 bAllowThreading =
false;
1829 if ((mxParentGroup && mxParentGroup->mbPartOfCycle) || !rRecursionHelper.
AreGroupsIndependent())
1833 bAllowThreading =
false;
1839 pCellStart =
nullptr;
1848 bool& bIsDirty,
bool& bAllowThreading)
1851 std::pair<sc::CellStoreType::const_iterator,size_t> aPos = rCells.position(nRow1);
1852 sc::CellStoreType::const_iterator it = aPos.first;
1853 size_t nOffset = aPos.second;
1858 for (;it != rCells.end() && nRow <= nRow2; ++it, nOffset = 0)
1865 if (bThreadingDepEval)
1867 bAllowThreading =
false;
1873 size_t nRowsToRead = nRow2 - nRow + 1;
1874 const size_t nEnd = std::min(it->size, nOffset+nRowsToRead);
1875 sc::formula_block::const_iterator itCell = sc::formula_block::begin(*it->data);
1876 std::advance(itCell, nOffset);
1879 size_t nCellIdx = nOffset;
1880 while (nCellIdx < nEnd)
1883 ScFormulaCell* pChildTopCell = mxGroupChild ? mxGroupChild->mpTopCell : *itCell;
1891 bAllowThreading =
false;
1895 if (bSkipRunning && (*itCell)->IsRunning())
1907 const SCROW nFGStartOffset = (*itCell)->aPos.Row() - pChildTopCell->
aPos.
Row();
1908 const SCROW nFGEndOffset = std::min(nFGStartOffset + static_cast<SCROW>(nRowsToRead) - 1, mxGroupChild->mnLength - 1);
1909 assert(nFGEndOffset >= nFGStartOffset);
1910 const SCROW nSpanLen = nFGEndOffset - nFGStartOffset + 1;
1914 bool bAnyDirtyInSpan =
lcl_InterpretSpan(itCell, nFGStartOffset, nFGEndOffset, mxGroup, bAllowThreading, rDoc);
1915 if (!bAllowThreading)
1918 bIsDirty = bIsDirty || bAnyDirtyInSpan;
1922 nCellIdx += nSpanLen;
1924 nRowsToRead -= nSpanLen;
1929 bool bDirtyFlag =
false;
1930 if( (*itCell)->NeedsInterpret())
1933 (*itCell)->Interpret();
1934 if ((*itCell)->NeedsInterpret())
1936 SAL_WARN(
"sc.core.formulagroup",
"Internal error, cell " << (*itCell)->aPos
1937 <<
" failed running Interpret(), not allowing threading");
1938 bAllowThreading =
false;
1942 bIsDirty = bIsDirty || bDirtyFlag;
1949 if (bThreadingDepEval && mxGroup &&
1953 (*itCell)->SetDirtyVar();
1954 bAllowThreading =
false;
1969 nRow += it->size - nOffset;
1974 if (bThreadingDepEval)
1975 bAllowThreading =
true;
1988 bool bAnyDirty =
false, bTmp =
false;
1998 bool bAllowThreading =
true, bTmp =
false;
2001 return bAllowThreading;
2006 class StoreToCacheFunc
2016 void operator() (
const sc::CellStoreType::value_type& node,
size_t nOffset,
size_t nDataSize )
2018 SCROW nStartRow = node.position + nOffset;
2031 sc::numeric_block::const_iterator it = sc::numeric_block::begin(*node.data);
2032 std::advance(it, nOffset);
2033 sc::numeric_block::const_iterator itEnd = it;
2034 std::advance(itEnd, nDataSize);
2036 for (; it != itEnd; ++it)
2045 sc::string_block::const_iterator it = sc::string_block::begin(*node.data);
2046 std::advance(it, nOffset);
2047 sc::string_block::const_iterator itEnd = it;
2048 std::advance(itEnd, nDataSize);
2050 for (; it != itEnd; ++it)
2053 sal_Int32 nStrLength = aStr.getLength();
2062 sc::formula_block::const_iterator it = sc::formula_block::begin(*node.data);
2063 std::advance(it, nOffset);
2064 sc::formula_block::const_iterator itEnd = it;
2065 std::advance(itEnd, nDataSize);
2067 for (; it != itEnd; )
2072 sal_uInt64 nGroupLength = 0;
2075 nGroupLength = xCellGroup->mnLength;
2086 std::advance(it, nGroupLength);
2102 StoreToCacheFunc aFunc(rStrm);
2108 sal_uInt64 nStoredCol = 0;
2110 if (nStoredCol != static_cast<sal_uInt64>(
nCol))
2111 throw std::exception();
2113 sal_uInt64 nLastRow = 0;
2115 sal_uInt64 nReadRow = 0;
2117 while (nReadRow < nLastRow)
2119 sal_uInt64 nStartRow = 0;
2120 sal_uInt64 nDataSize = 0;
2129 maCells.set_empty(nStartRow, nDataSize);
2134 std::vector<double> aValues(nDataSize);
2135 for (
auto& rValue : aValues)
2139 maCells.set(nStartRow, aValues.begin(), aValues.end());
2144 std::vector<svl::SharedString> aStrings(nDataSize);
2146 for (
auto& rString : aStrings)
2148 sal_Int32 nStrLength = 0;
2150 std::unique_ptr<char[]> pStr(
new char[nStrLength]);
2151 rStrm.
ReadBytes(pStr.get(), nStrLength);
2152 OString aOStr(pStr.get(), nStrLength);
2153 OUString aStr = OStringToOUString(aOStr, RTL_TEXTENCODING_UTF8);
2154 rString = rPool.
intern(aStr);
2156 maCells.set(nStartRow, aStrings.begin(), aStrings.end());
2162 std::vector<ScFormulaCell*> aFormulaCells(nDataSize);
2166 for (
SCROW nRow = 0; nRow < static_cast<SCROW>(nDataSize);)
2168 sal_uInt64 nFormulaGroupSize = 0;
2170 sal_Int32 nStrLength = 0;
2172 std::unique_ptr<char[]> pStr(
new char[nStrLength]);
2173 rStrm.
ReadBytes(pStr.get(), nStrLength);
2174 OString aOStr(pStr.get(), nStrLength);
2175 OUString aStr = OStringToOUString(aOStr, RTL_TEXTENCODING_UTF8);
2176 for (sal_uInt64
i = 0;
i < nFormulaGroupSize; ++
i)
2178 aFormulaCells[nRow +
i] =
new ScFormulaCell(rDocument, aAddr, aStr, eGrammar);
2182 nRow += nFormulaGroupSize;
2185 maCells.set(nStartRow, aFormulaCells.begin(), aFormulaCells.end());
2190 nReadRow += nDataSize;
2198 if (pColTest !=
this)
2200 std::ostringstream os;
2201 os <<
"cell store's event handler references wrong column instance (this=" <<
this
2202 <<
"; stored=" << pColTest <<
")";
2203 throw std::runtime_error(os.str());
2212 std::ostringstream os;
2213 os <<
"incorrect cached formula block count (expected=" << nCount <<
"; actual="
2215 throw std::runtime_error(os.str());
void AdjustReferenceOnMovedOrigin(const ScAddress &rOldPos, const ScAddress &rNewPos)
Adjust all internal references on base position change.
std::map< SCROW, std::vector< SdrObject * > > GetObjectsAnchoredToRange(SCTAB nTab, SCCOL nCol, SCROW nStartRow, SCROW nEndRow)
void CellStorageModified()
Called whenever the state of cell array gets modified i.e.
SCROW GetNotePosition(size_t nIndex) const
::boost::intrusive_ptr< ScFormulaCellGroup > ScFormulaCellGroupRef
SvStream & WriteUInt64(sal_uInt64 nuInt64)
void SplitFormulaGroupByRelativeRef(const ScRange &rBoundRange)
OUString getString() const
SharedString intern(const OUString &rStr)
SC_DLLPUBLIC svl::SharedStringPool & GetSharedStringPool()
void DeleteArea(SCROW nStartRow, SCROW nEndRow, InsertDeleteFlags nDelFlag, bool bBroadcast=true, sc::ColumnSpanSet *pBroadcastSpans=nullptr)
void GetAllNoteEntries(std::vector< sc::NoteEntry > &rNotes) const
void CheckIntegrity() const
void StoreToCache(SvStream &rStrm) const
const sc::CellStoreType & mrCells
bool AreGroupsIndependent()
void swap(SCTAB nTab, SCCOL nCol, CellValues &rColValue)
Swap the entire column.
void RestoreFromCache(SvStream &rStrm)
SvStream & WriteInt32(sal_Int32 nInt32)
void ForgetCaption(bool bPreserveData=false)
Forgets the pointer to the note caption object.
void SwapNonEmpty(sc::TableValues &rValues, sc::StartListeningContext &rStartCxt, sc::EndListeningContext &rEndCxt)
void ApplyPatternArea(SCROW nStartRow, SCROW nEndRow, const ScPatternAttr &rPatAttr, ScEditDataArray *pDataArray=nullptr, bool *const pIsChanged=nullptr)
CellTextAttrStoreType::iterator miCellTextAttrPos
const mdds::mtv::element_t element_type_celltextattr
const ScPatternAttr * GetPattern(SCROW nRow) const
sal_uInt32 GetRefCount() const
Think of this as a mini-ScColumn like storage that only stores cell values in a column.
std::unique_ptr< ScPostIt > ReleaseNote(SCROW nRow)
StoreT::const_iterator ParseBlock(const typename StoreT::const_iterator &itPos, const StoreT &rStore, Func &rFunc, typename StoreT::size_type nStart, typename StoreT::size_type nEnd)
Generic algorithm to parse blocks of multi_type_vector either partially or fully. ...
ListenersType & GetAllListeners()
Store position data for column array storage.
void TransferCellValuesTo(SCROW nRow, size_t nLen, sc::CellValues &rDest)
const ContentProperties & rData
InsertDeleteFlags getInsertFlag() const
Stores cell values for multiple tables.
void transferFrom(ScColumn &rCol, SCROW nRow, size_t nLen)
Transfer values from specified column.
CellStoreType::const_iterator ParseAllNonEmpty(const typename CellStoreType::const_iterator &itPos, const CellStoreType &rCells, SCROW nRow1, SCROW nRow2, Func &rFunc)
static const SharedString & getEmptyString()
void CompileHybridFormula(sc::StartListeningContext &rStartListenCxt, sc::CompileFormulaContext &rCompileCxt)
void Swap(ScColumn &rOther, SCROW nRow1, SCROW nRow2, bool bPattern)
bool isTableProtected() const
This is very similar to ScCellValue, except that it references the original value instead of copying ...
constexpr TypedWhichId< ScProtectionAttr > ATTR_PROTECTION(149)
SC_DLLPUBLIC formula::FormulaGrammar::Grammar GetGrammar() const
SCROW GetMaxRowCount() const
SvStream & ReadUInt64(sal_uInt64 &rUInt64)
void DeleteRanges(const std::vector< sc::RowSpan > &rRanges, InsertDeleteFlags nDelFlag)
StoreT::iterator ProcessBlock(const typename StoreT::iterator &itPos, StoreT &rStore, Func &rFunc, typename StoreT::size_type nStart, typename StoreT::size_type nEnd)
Non-const variant of the above function.
SC_DLLPUBLIC SvtScriptType GetStringScriptType(const OUString &rString)
void UpdateDrawObjectsForRow(std::vector< SdrObject * > &pObjects, SCCOL nTargetCol, SCROW nTargetRow)
Internal use only (d&d undo): do not delete caption objects of cell notes.
SC_DLLPUBLIC ScDocumentPool * GetPool()
const mdds::mtv::element_t element_type_cellnote
void ParseFormula(const CellStoreType &rStore, Func &rFunc)
Store arbitrary cell value of any kind.
void PreprocessRangeNameUpdate(sc::EndListeningContext &rEndListenCxt, sc::CompileFormulaContext &rCompileCxt)
void PreprocessDBDataUpdate(sc::EndListeningContext &rEndListenCxt, sc::CompileFormulaContext &rCompileCxt)
virtual void Clear() override
const mdds::mtv::element_t element_type_formula
bool HasFormulaCell() const
void StartListeningFormulaCells(sc::StartListeningContext &rStartCxt, sc::EndListeningContext &rEndCxt, SCROW nRow1, SCROW nRow2)
ScClipParam & GetClipParam()
Keep track of spans in a single column only.
std::vector< SvtListener * > ListenersType
enumrange< T >::Iterator begin(enumrange< T >)
ScFormulaCell * mpFormula
SC_DLLPUBLIC SCROW MaxRow() const
void ForgetNoteCaptions(SCROW nRow1, SCROW nRow2, bool bPreserveData)
Additional class containing cell annotation data.
ScConditionalFormatList * getCondFormatList()
static void LOKCommentNotify(LOKCommentNotificationType nType, const ScDocument *pDocument, const ScAddress &rPos, const ScPostIt *pNote)
void CreateAllNoteCaptions()
void EndListeningFormulaCells(sc::EndListeningContext &rCxt, SCROW nRow1, SCROW nRow2, SCROW *pStartRow, SCROW *pEndRow)
sc::CellStoreType maCells
void ResetFormulaCellPositions(SCROW nRow1, SCROW nRow2, bool bUpdateRefs)
Reset column position of formula cells within specified row range.
void set(const ScDocument &rDoc, SCTAB nTab, SCCOL nCol, SCROW nRow, bool bVal)
SCROW GetLastDataPos() const
void RemoveEditAttribs(sc::ColumnBlockPosition &rBlockPos, SCROW nStartRow, SCROW nEndRow)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
void CheckRelativeReferenceBounds(const sc::RefUpdateContext &rCxt, const ScAddress &rPos, SCROW nGroupLen, std::vector< SCROW > &rBounds) const
void CloneFormulaCell(sc::ColumnBlockPosition &rBlockPos, const ScFormulaCell &rSrc, const sc::CellTextAttr &rAttr, const std::vector< sc::RowSpan > &rRanges)
void swapNonEmpty(ScColumn &rCol)
void setValue(size_t nRow, double fVal)
const SfxPoolItem & GetItem(sal_uInt16 nWhichP) const
void AdjustReferenceOnMovedOriginIfOtherSheet(const ScAddress &rOldPos, const ScAddress &rNewPos)
Adjust all internal references on base position change if they point to a sheet other than the one of...
void DeleteSparklineCells(sc::ColumnBlockPosition &rBlockPos, SCROW nRow1, SCROW nRow2)
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
void getSpans(SpansType &rSpans) const
ScRecursionHelper & GetRecursionHelper()
void InitBlockPosition(sc::ColumnBlockPosition &rBlockPos)
void SetValues(const SCROW nRow, const std::vector< double > &rVals)
std::shared_ptr< sc::Sparkline > const & getSingleSparkline(size_t nColOffset) const
void RegroupFormulaCells(std::vector< ScAddress > *pGroupPos=nullptr)
Regroup formula cells for the entire column.
sc::MultiDataCellState::StateType HasDataCellsInRange(SCROW nRow1, SCROW nRow2, SCROW *pRow1) const
SvtScriptType mnScriptType
bool HasCellNote(SCROW nStartRow, SCROW nEndRow) const
svl::SharedString * mpString
sc::CellTextAttrStoreType maCellTextAttrs
std::unique_ptr< ScPostIt > Clone(const ScAddress &rOwnPos, ScDocument &rDestDoc, const ScAddress &rDestPos, bool bCloneCaption) const
Clones this note and its caption object, if specified.
const ScPatternAttr * SetPattern(SCROW nRow, std::unique_ptr< ScPatternAttr >)
static void JoinNewFormulaCell(const sc::CellStoreType::position_type &aPos, ScFormulaCell &rCell)
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)
void EndListeningGroup(sc::EndListeningContext &rCxt, SCROW nRow)
SfxItemSet & GetItemSet()
ScDocument & GetDoc() const
Structure that stores segments of boolean flags per column, and perform custom action on those segmen...
SparklineStoreType::iterator miSparklinePos
void GetUnprotectedCells(SCROW nStartRow, SCROW nEndRow, ScRangeList &rRangeList) const
const mdds::mtv::element_t element_type_numeric
Mapped standard element types (for convenience).
SdrCaptionObj * GetOrCreateCaption(const ScAddress &rPos) const
Returns the caption object of this note.
const ScRange & getRange() const
SC_DLLPUBLIC std::shared_ptr< sc::SparklineGroup > SearchSparklineGroup(tools::Guid const &rGuid)
void EndListeningIntersectedGroups(sc::EndListeningContext &rCxt, SCROW nRow1, SCROW nRow2, std::vector< ScAddress > *pGroupPos)
void ProcessNote(CellNoteStoreType &rStore, Func &rFunc)
sal_uInt32 GetNumberFormat(SvNumberFormatter *) const
bool EnsureFormulaCellResults(SCROW nRow1, SCROW nRow2, bool bSkipRunning=false)
SvStream & ReadUChar(unsigned char &rChar)
CellStoreType::iterator ProcessFormula(const CellStoreType::iterator &it, CellStoreType &rStore, SCROW nRow1, SCROW nRow2, std::function< void(size_t, ScFormulaCell *)> aFuncElem)
Process formula cells found within specified row range.
void UpdateScriptTypes(SCROW nRow1, SCROW nRow2)
static bool lcl_InterpretSpan(sc::formula_block::const_iterator &rSpanIter, SCROW nStartOffset, SCROW nEndOffset, const ScFormulaCellGroupRef &mxParentGroup, bool &bAllowThreading, ScDocument &rDoc)
void DetachFormulaCells(const sc::CellStoreType::position_type &aPos, size_t nLength, std::vector< SCROW > *pNewSharedRows)
SC_DLLPUBLIC const SfxItemSet * GetCondResult(SCCOL nCol, SCROW nRow, SCTAB nTab, ScRefCellValue *pCell=nullptr) const
SvStream & ReadDouble(double &rDouble)
void CollectFormulaCells(std::vector< ScFormulaCell * > &rCells, SCROW nRow1, SCROW nRow2)
const ScPatternAttr * getSingleCellPattern(size_t nColOffset) const
ScCellValue & getSingleCell(size_t nColOffset)
CellStoreType::iterator miCellPos
std::vector< CellValueSpan > getNonEmptySpans(SCTAB nTab, SCCOL nCol) const
SvStream & ReadInt32(sal_Int32 &rInt32)
mdds::mtv::soa::multi_type_vector< CTAttrFunc > CellTextAttrStoreType
Internal use only (undo etc.): do not copy/delete caption objects of cell notes.
std::size_t ReadBytes(void *pData, std::size_t nSize)
void copyTo(ScColumn &rCol, SCROW nRow) const
const ScPostIt * getSingleCellNote(size_t nColOffset) const
void DeleteCellNotes(sc::ColumnBlockPosition &rBlockPos, SCROW nRow1, SCROW nRow2, bool bForgetCaptionOwnership)
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
bool isSkipEmptyCells() const
Get the flag that indicates whether the "skip empty cells" paste option is selected.
mdds::mtv::soa::multi_type_vector< CellFunc, CellStoreTrait > CellStoreType
ScRange getWholeRange() const
Return a single range that encompasses all individual ranges.
sc::BroadcasterStoreType maBroadcasters
void duplicateSparkline(sc::CopyFromClipContext &rContext, sc::ColumnBlockPosition *pBlockPos, size_t nColOffset, size_t nDestSize, ScAddress aDestPosition)
void CollectListeners(std::vector< SvtListener * > &rListeners, SCROW nRow1, SCROW nRow2)
bool ValidRow(SCROW nRow) const
sc::SparklineStoreType maSparklines
sc::CellNoteStoreType maCellNotes
void CopyCellValuesFrom(SCROW nRow, const sc::CellValues &rSrc)
#define SAL_WARN_IF(condition, area, stream)
SvStream & WriteOString(std::string_view rStr)
void Join(const ScRange &, bool bIsInList=false)
ScPatternAttr * PutInPool(ScDocument *pDestDoc, ScDocument *pSrcDoc) const
const mdds::mtv::element_t element_type_edittext
sc::CellTextAttr & getSingleCellAttr(size_t nColOffset)
SvStream & WriteUChar(unsigned char nChar)
virtual std::unique_ptr< EditTextObject > Clone() const =0
CellNoteStoreType::iterator miCellNotePos
void CopyOneCellFromClip(sc::CopyFromClipContext &rCxt, SCROW nRow1, SCROW nRow2, size_t nColOffset)
const T & Put(std::unique_ptr< T > xItem, sal_uInt16 nWhich=0)
constexpr TypedWhichId< ScCondFormatItem > ATTR_CONDITIONAL(154)
ScDocument * getClipDoc()
std::vector< RowSpan > SpansType
std::vector< sc::FormulaGroupEntry > GetFormulaGroupEntries()
Get all non-grouped formula cells and formula cell groups in the whole column.
EditTextObject * mpEditText
size_t GetNoteCount() const
InsertDeleteFlags getDeleteFlag() const
void ConvertFormulaToValue(sc::EndListeningContext &rCxt, SCROW nRow1, SCROW nRow2, sc::TableValues *pUndo)
std::optional< sc::ColumnIterator > GetColumnIterator(SCROW nRow1, SCROW nRow2) const
void scan(const ScColumn &rColumn)
Scan an entire column and tag all non-empty cell positions.
void BroadcastCells(const std::vector< SCROW > &rRows, SfxHintId nHint)
bool ValidRow(SCROW nRow, SCROW nMaxRow)
bool HandleRefArrayForParallelism(SCROW nRow1, SCROW nRow2, const ScFormulaCellGroupRef &mxGroup)
Range getDestRange() const
std::pair< CellStoreType::const_iterator, size_t > FindFormula(const CellStoreType &rStore, SCROW nRow1, SCROW nRow2, Func &rFunc)
#define SAL_WARN(area, stream)
This iterator lets you iterate over cells over specified range in a single column.
SvStream & WriteDouble(const double &rDouble)
void RemoveFromFormulaTree(ScFormulaCell *pCell)
void DeleteCells(sc::ColumnBlockPosition &rBlockPos, SCROW nRow1, SCROW nRow2, InsertDeleteFlags nDelFlag, sc::SingleColumnSpanSet &rDeleted)
void DeleteBeforeCopyFromClip(sc::CopyFromClipContext &rCxt, const ScColumn &rClipCol, sc::ColumnSpanSet &rBroadcastSpans)
void EndListeningIntersectedGroup(sc::EndListeningContext &rCxt, SCROW nRow, std::vector< ScAddress > *pGroupPos)
std::unique_ptr< ScAttrArray > pAttrArray
void SetNeedsListeningGroup(SCROW nRow)
const mdds::mtv::element_t element_type_string
void GetNotesInRange(SCROW nStartRow, SCROW nEndRow, std::vector< sc::NoteEntry > &rNotes) const
Strings (and string results if InsertDeleteFlags::FORMULA is not set).
::basegfx::B2DRectangle maBounds
void StartListeningUnshared(const std::vector< SCROW > &rNewSharedRows)
Re-establish listeners on unshared formula groups.
ColumnBlockPosition * getBlockPosition(SCTAB nTab, SCCOL nCol)
static void lcl_EvalDirty(sc::CellStoreType &rCells, SCROW nRow1, SCROW nRow2, ScDocument &rDoc, const ScFormulaCellGroupRef &mxGroup, bool bThreadingDepEval, bool bSkipRunning, bool &bIsDirty, bool &bAllowThreading)
void swapNonEmpty(SCTAB nTab, SCCOL nCol, ScColumn &rCol)
Swap non-empty blocks with the column storage.
Hodler of a sparkline, that is connected to a cell specific.
bool m_bDetectedRangeSegmentation false
BroadcasterStoreType::iterator ProcessBroadcaster(const BroadcasterStoreType::iterator &it, BroadcasterStoreType &rStore, SCROW nRow1, SCROW nRow2, FuncElem &rFuncElem)
Sheet / outlining (grouping) information.