14 #include <document.hxx>
25 #include <tokenarray.hxx>
30 #include <compiler.hxx>
50 sc::CellStoreType::const_position_type aPos =
maCells.position(nRow1);
51 sc::CellStoreType::const_iterator it = aPos.first;
52 size_t nOffset = aPos.second;
56 for (; it !=
maCells.end() && nRow <= nRow2; ++it)
62 size_t nSize = it->size - nOffset;
64 SCROW nLastRow = nRow + nSize - 1;
67 nSize -= nLastRow - nRow2;
88 nRow += it->size - nOffset;
106 SCROW nClipRowLen = nClipRow2 - nClipRow1 + 1;
110 aSpanSet.
scan(rClipCol, nClipRow1, nClipRow2);
119 std::vector<sc::RowSpan> aDestSpans;
121 bool bContinue =
true;
126 SCROW nDestRow1 = r.mnRow1 + nDestOffset;
127 SCROW nDestRow2 = r.mnRow2 + nDestOffset;
129 if (nDestRow1 > aRange.
mnRow2)
136 if (nDestRow2 > aRange.
mnRow2)
139 nDestRow2 = aRange.
mnRow2;
143 aDestSpans.emplace_back(nDestRow1, nDestRow2);
149 nDestOffset += nClipRowLen;
156 for (
const auto& rDestSpan : aDestSpans)
158 SCROW nRow1 = rDestSpan.mnRow1;
159 SCROW nRow2 = rDestSpan.mnRow2;
164 DeleteCells(aBlockPos, nRow1, nRow2, nDelFlag, aDeletedRows);
199 size_t nDestSize = nRow2 - nRow1 + 1;
219 auto pNewPattern = std::make_unique<ScPatternAttr>(*pAttr);
220 sal_uInt16 pItems[2];
223 pNewPattern->ClearItems(pItems);
224 pAttrArray->SetPatternArea(nRow1, nRow2, std::move(pNewPattern),
true);
230 std::vector<sc::CellTextAttr> aTextAttrs(nDestSize, rSrcAttr);
236 std::vector<double> aVals(nDestSize, rSrcCell.
mfValue);
253 std::vector<svl::SharedString> aStrs(nDestSize, aStr);
263 std::vector<EditTextObject*> aStrs;
264 aStrs.reserve(nDestSize);
265 for (
size_t i = 0;
i < nDestSize; ++
i)
277 std::vector<sc::RowSpan> aRanges;
279 aRanges.emplace_back(nRow1, nRow2);
296 std::vector<ScPostIt*> aNotes;
298 aNotes.reserve(nDestSize);
299 for (
size_t i = 0;
i < nDestSize; ++
i)
302 aNotes.push_back(pNote->
Clone(aSrcPos, rDocument, aDestPos, bCloneCaption).release());
308 pBlockPos->
miCellNotePos, nRow1, aNotes.begin(), aNotes.end());
316 SCROW nLastRow = nRow + rVals.size() - 1;
317 if (nLastRow >
GetDoc().MaxRow())
321 sc::CellStoreType::position_type aPos =
maCells.position(nRow);
322 std::vector<SCROW> aNewSharedRows;
325 maCells.set(nRow, rVals.begin(), rVals.end());
326 std::vector<sc::CellTextAttr> aDefaults(rVals.size());
333 std::vector<SCROW> aRows;
334 aRows.reserve(rVals.size());
335 for (
SCROW i = nRow;
i <= nLastRow; ++
i)
346 SCROW nLastRow = nRow + nLen - 1;
347 if (nLastRow >
GetDoc().MaxRow())
351 sc::CellStoreType::position_type aPos =
maCells.position(nRow);
358 std::vector<SCROW> aRows;
360 for (
SCROW i = nRow;
i <= nLastRow; ++
i)
372 if (nLastRow >
GetDoc().MaxRow())
376 sc::CellStoreType::position_type aPos =
maCells.position(nRow);
383 std::vector<SCROW> aRows;
384 aRows.reserve(rSrc.
size());
385 for (
SCROW i = nRow;
i <= nLastRow; ++
i)
393 class ConvertFormulaToValueHandler
399 ConvertFormulaToValueHandler(
ScSheetLimits const & rSheetLimits) :
425 bool isModified()
const {
return mbModified; }
438 std::vector<SCROW> aBounds;
439 aBounds.push_back(nRow1);
440 if (nRow2 <
GetDoc().MaxRow()-1)
441 aBounds.push_back(nRow2+1);
447 ConvertFormulaToValueHandler aFunc(
GetDoc().GetSheetLimits());
449 if (!aFunc.isModified())
457 aFunc.getResValues().swap(aUndoCells);
465 class StartListeningHandler
479 class EndListeningHandler
499 std::vector<SCROW> aBounds;
502 aBounds.push_back(rRange.
aEnd.
Row()+1);
509 EndListeningHandler aEndLisFunc(rEndCxt);
510 sc::CellStoreType::iterator itPos =
maCells.begin();
511 for (
const auto& rSpan : aSpans)
513 SCROW nRow1 = rSpan.mnRow1;
514 SCROW nRow2 = rSpan.mnRow2;
522 StartListeningHandler aStartLisFunc(rStartCxt);
524 for (
const auto& rSpan : aSpans)
526 SCROW nRow1 = rSpan.mnRow1;
527 SCROW nRow2 = rSpan.mnRow2;
536 for (
const auto& rSpan : rRanges)
537 DeleteArea(rSpan.mnRow1, rSpan.mnRow2, nDelFlag,
false);
542 const std::vector<sc::RowSpan>& rRanges )
544 sc::CellStoreType::iterator itPos =
maCells.begin();
545 sc::CellTextAttrStoreType::iterator itAttrPos =
maCellTextAttrs.begin();
547 SCCOL nMatrixCols = 0;
548 SCROW nMatrixRows = 0;
553 SAL_WARN_IF( nMatrixCols != 1 || nMatrixRows != 1,
"sc.core",
554 "ScColumn::CloneFormulaCell - cloning array/matrix with not exactly one column or row as single cell");
558 std::vector<ScFormulaCell*> aFormulas;
559 for (
const auto& rSpan : rRanges)
561 SCROW nRow1 = rSpan.mnRow1, nRow2 = rSpan.mnRow2;
562 size_t nLen = nRow2 - nRow1 + 1;
565 aFormulas.reserve(nLen);
573 aFormulas.push_back(pCell);
579 xGroup->setCode(*rSrc.
GetCode());
580 xGroup->compileCode(rDocument, aPos, rDocument.
GetGrammar());
581 for (
size_t i = 0;
i < nLen; ++
i, aPos.
IncRow())
588 xGroup->mpTopCell = pCell;
589 xGroup->mnLength = nLen;
591 aFormulas.push_back(pCell);
595 itPos =
maCells.set(itPos, nRow1, aFormulas.begin(), aFormulas.end());
598 sc::CellStoreType::position_type aPosObj =
maCells.position(itPos, nRow1);
601 ScFormulaCell* pCell = sc::formula_block::at(*aPosObj.first->data, aPosObj.second);
604 aPosObj =
maCells.position(aPosObj.first, nRow2);
606 pCell = sc::formula_block::at(*aPosObj.first->data, aPosObj.second);
609 std::vector<sc::CellTextAttr> aTextAttrs(nLen, rAttr);
610 itAttrPos =
maCellTextAttrs.set(itAttrPos, nRow1, aTextAttrs.begin(), aTextAttrs.end());
623 return std::unique_ptr<ScPostIt>(p);
629 [](
const size_t& rCount,
const auto& rCellNote) {
632 return rCount + rCellNote.size;
638 class NoteCaptionCreator
642 NoteCaptionCreator(
SCTAB nTab,
SCCOL nCol ) : maPos(nCol,0,nTab) {}
644 void operator() (
size_t nRow,
const ScPostIt* p )
651 class NoteCaptionCleaner
655 explicit NoteCaptionCleaner(
bool bPreserveData ) : mbPreserveData(bPreserveData) {}
657 void operator() (
size_t ,
ScPostIt* p )
667 NoteCaptionCreator aFunc(
nTab,
nCol);
679 NoteCaptionCleaner aFunc(bPreserveData);
680 sc::CellNoteStoreType::iterator it =
maCellNotes.begin();
695 if (nIndex < nCount + rCellNote.size)
698 size_t nOffset = nIndex - nCount;
699 return rCellNote.position + nOffset;
702 nCount += rCellNote.size;
710 class NoteEntryCollector
712 std::vector<sc::NoteEntry>& mrNotes;
718 NoteEntryCollector( std::vector<sc::NoteEntry>& rNotes,
SCTAB nTab,
SCCOL nCol,
720 mrNotes(rNotes), mnTab(nTab), mnCol(nCol),
721 mnStartRow(nStartRow), mnEndRow(nEndRow) {}
723 void operator() (
const sc::CellNoteStoreType::value_type& node)
const
728 size_t nTopRow = node.position;
729 sc::cellnote_block::const_iterator it = sc::cellnote_block::begin(*node.data);
730 sc::cellnote_block::const_iterator itEnd = sc::cellnote_block::end(*node.data);
734 std::advance(it, mnStartRow - nTopRow);
735 nOffset = mnStartRow - nTopRow;
741 ScAddress aPos(mnCol, nTopRow + nOffset, mnTab);
742 mrNotes.emplace_back(aPos, *it);
755 std::vector<sc::NoteEntry>& rNotes )
const
757 std::pair<sc::CellNoteStoreType::const_iterator,size_t> aPos =
maCellNotes.position(nStartRow);
758 sc::CellNoteStoreType::const_iterator it = aPos.first;
763 std::pair<sc::CellNoteStoreType::const_iterator,size_t> aEndPos =
765 sc::CellNoteStoreType::const_iterator itEnd = aEndPos.first;
767 std::for_each(it, ++itEnd, NoteEntryCollector(rNotes,
nTab,
nCol, nStartRow, nEndRow));
772 SCROW nTmpStartRow = nStartRow, nTmpEndRow = nEndRow;
778 if (nTmpStartRow < nStartRow)
779 nTmpStartRow = nStartRow;
780 if (nTmpEndRow > nEndRow)
781 nTmpEndRow = nEndRow;
784 while (nEndRow > nTmpEndRow)
786 nStartRow = nTmpEndRow + 1;
787 pPattern =
pAttrArray->GetPatternRange(nTmpStartRow, nTmpEndRow, nStartRow);
794 if (nTmpEndRow > nEndRow)
795 nTmpEndRow = nEndRow;
803 class RecompileByOpcodeHandler
811 RecompileByOpcodeHandler(
816 mrEndListenCxt(rEndListenCxt),
817 mrCompileFormulaCxt(rCompileCxt) {}
841 OUString aFormula = pTop->
GetFormula(mrCompileFormulaCxt);
842 sal_Int32
n = aFormula.getLength();
845 if (aFormula[0] ==
'{' && aFormula[n-1] ==
'}')
846 aFormula = aFormula.copy(1, n-2);
853 for (; pp != ppEnd; ++pp)
871 class CompileHybridFormulaHandler
880 mrStartListenCxt(rStartListenCxt),
881 mrCompileFormulaCxt(rCompileCxt) {}
890 if (!aFormula.isEmpty())
895 std::unique_ptr<ScTokenArray> pNewCode = aComp.CompileString(aFormula);
898 xGroup->setCode(std::move(pNewCode));
904 for (; pp != ppEnd; ++pp)
918 if (!aFormula.isEmpty())
922 std::unique_ptr<ScTokenArray> pNewCode = aComp.CompileString(aFormula);
929 pCell->
SetCode(std::move(pNewCode));
949 RecompileByOpcodeHandler aFunc(&
GetDoc(), aOps, rEndListenCxt, rCompileCxt);
950 std::for_each(aGroups.begin(), aGroups.end(), aFunc);
964 RecompileByOpcodeHandler aFunc(&
GetDoc(), aOps, rEndListenCxt, rCompileCxt);
965 std::for_each(aGroups.begin(), aGroups.end(), aFunc);
974 CompileHybridFormulaHandler aFunc(
GetDoc(), rStartListenCxt, rCompileCxt);
975 std::for_each(aGroups.begin(), aGroups.end(), aFunc);
980 class ScriptTypeUpdater
984 sc::CellTextAttrStoreType::iterator miPosAttr;
993 sc::CellTextAttrStoreType::position_type aAttrPos = mrTextAttrs.position(miPosAttr, nRow);
994 miPosAttr = aAttrPos.first;
999 sc::CellTextAttr& rAttr = sc::celltextattr_block::at(*aAttrPos.first->data, aAttrPos.second);
1019 const Color* pColor;
1028 explicit ScriptTypeUpdater(
ScColumn& rCol ) :
1030 mrTextAttrs(rCol.GetCellAttrStore()),
1031 miPosAttr(mrTextAttrs.
begin()),
1032 mpCFList(rCol.GetDoc().GetCondFormList(rCol.GetTab())),
1033 mpFormatter(rCol.GetDoc().GetFormatTable()),
1034 maPos(rCol.GetCol(), 0, rCol.GetTab()),
1038 void operator() (
size_t nRow,
double fVal )
1041 updateScriptType(nRow, aCell);
1047 updateScriptType(nRow, aCell);
1053 updateScriptType(nRow, aCell);
1059 updateScriptType(nRow, aCell);
1062 bool isUpdated()
const {
return mbUpdated; }
1072 ScriptTypeUpdater aFunc(*
this);
1074 if (aFunc.isUpdated())
1089 std::map<SCROW, std::vector<SdrObject*>> aThisColRowDrawObjects
1091 std::map<SCROW, std::vector<SdrObject*>> aOtherColRowDrawObjects
1093 for (
SCROW nRow = nRow1; nRow <= nRow2; ++nRow)
1095 std::vector<SdrObject*>& rThisCellDrawObjects = aThisColRowDrawObjects[nRow];
1096 if (!rThisCellDrawObjects.empty())
1098 std::vector<SdrObject*>& rOtherCellDrawObjects = aOtherColRowDrawObjects[nRow];
1099 if (!rOtherCellDrawObjects.empty())
1106 for (
SCROW nRow = nRow1; nRow <= nRow2; ++nRow)
1126 class FormulaColPosSetter
1131 FormulaColPosSetter(
SCCOL nCol,
bool bUpdateRefs ) : mnCol(nCol), mbUpdateRefs(bUpdateRefs) {}
1159 FormulaColPosSetter aFunc(
nCol, bUpdateRefs);
1165 class RelativeRefBoundChecker
1171 explicit RelativeRefBoundChecker(
const ScRange& rBoundRange ) :
1172 maBoundRange(rBoundRange) {}
1183 void swapBounds( std::vector<SCROW>& rBounds )
1185 rBounds.swap(maBounds);
1197 std::vector<SCROW> aBounds;
1200 aBounds.push_back(rBoundRange.
aStart.
Row());
1202 aBounds.push_back(rBoundRange.
aEnd.
Row()+1);
1205 RelativeRefBoundChecker aFunc(rBoundRange);
1208 aFunc.swapBounds(aBounds);
1214 class ListenerCollector
1216 std::vector<SvtListener*>& mrListeners;
1218 explicit ListenerCollector( std::vector<SvtListener*>& rListener ) :
1219 mrListeners(rListener) {}
1224 mrListeners.insert(mrListeners.end(), rLis.begin(), rLis.end());
1228 class FormulaCellCollector
1230 std::vector<ScFormulaCell*>& mrCells;
1232 explicit FormulaCellCollector( std::vector<ScFormulaCell*>& rCells ) : mrCells(rCells) {}
1236 mrCells.push_back(p);
1247 ListenerCollector aFunc(rListeners);
1256 FormulaCellCollector aFunc(rCells);
1267 struct FindAnyFormula
1285 if (nRow1 == 0 && nRow2 ==
GetDoc().MaxRow())
1288 FindAnyFormula aFunc;
1289 std::pair<sc::CellStoreType::const_iterator, size_t> aRet =
1292 return aRet.first !=
maCells.end();
1299 for (; pp != ppEnd; ++pp)
1306 class StartListeningFormulaCellsHandler
1314 mrStartCxt(rStartCxt), mrEndCxt(rEndCxt), mnStartRow(-1) {}
1316 void operator() (
const sc::CellStoreType::value_type& node,
size_t nOffset,
size_t nDataSize )
1322 mnStartRow = node.position + nOffset;
1324 ScFormulaCell** ppBeg = &sc::formula_block::at(*node.data, nOffset);
1337 if (nBackTrackSize > 0)
1340 for (
SCROW i = 0;
i < nBackTrackSize; ++
i)
1342 endListening(mrEndCxt, pp, ppBeg);
1343 mnStartRow -= nBackTrackSize;
1347 for (; pp != ppEnd; ++pp)
1362 if (nEndGroupPos > nDataSize)
1364 size_t nExcessSize = nEndGroupPos - nDataSize;
1367 endListening(mrEndCxt, ppGrp, ppGrpEnd);
1384 class EndListeningFormulaCellsHandler
1392 mrEndCxt(rEndCxt), mnStartRow(-1), mnEndRow(-1) {}
1394 void operator() (
const sc::CellStoreType::value_type& node,
size_t nOffset,
size_t nDataSize )
1400 mnStartRow = node.position + nOffset;
1402 ScFormulaCell** ppBeg = &sc::formula_block::at(*node.data, nOffset);
1414 if (nBackTrackSize > 0)
1417 for (
SCROW i = 0;
i < nBackTrackSize; ++
i)
1419 mnStartRow -= nBackTrackSize;
1423 for (; pp != ppEnd; ++pp)
1435 mnEndRow = node.position + nOffset + nEndGroupPos - 1;
1438 endListening(mrEndCxt, pp, ppGrpEnd);
1440 if (nEndGroupPos > nDataSize)
1454 SCROW getStartRow()
const
1459 SCROW getEndRow()
const
1474 StartListeningFormulaCellsHandler aFunc(rStartCxt, rEndCxt);
1485 EndListeningFormulaCellsHandler aFunc(rCxt);
1489 *pStartRow = aFunc.getStartRow();
1492 *pEndRow = aFunc.getEndRow();
1501 sc::CellStoreType::position_type aPos =
maCells.position(nRow);
1502 sc::CellStoreType::iterator it = aPos.first;
1507 ScFormulaCell* pFC = sc::formula_block::at(*it->data, aPos.second);
1520 pGroupPos->push_back(xGroup->mpTopCell->aPos);
1523 if (nRow < nGrpLastRow)
1533 sc::CellStoreType::position_type aPos =
maCells.position(nRow1);
1534 sc::CellStoreType::iterator it = aPos.first;
1537 ScFormulaCell* pFC = sc::formula_block::at(*it->data, aPos.second);
1547 pGroupPos->push_back(xGroup->mpTopCell->aPos);
1551 aPos =
maCells.position(it, nRow2);
1556 ScFormulaCell* pFC = sc::formula_block::at(*it->data, aPos.second);
1568 ScAddress aPosLast = xGroup->mpTopCell->aPos;
1569 aPosLast.
IncRow(xGroup->mnLength-1);
1570 pGroupPos->push_back(aPosLast);
1576 sc::CellStoreType::position_type aPos =
maCells.position(nRow);
1581 ScFormulaCell** pp = &sc::formula_block::at(*aPos.first->data, aPos.second);
1587 (*pp)->EndListeningTo(rCxt);
1592 SCROW nTopDelta = (*pp)->aPos.Row() - xGroup->mpTopCell->aPos.Row();
1598 assert(*pp == xGroup->mpTopCell);
1600 for (; pp != ppEnd; ++pp)
1606 sc::CellStoreType::position_type aPos =
maCells.position(nRow);
1611 ScFormulaCell** pp = &sc::formula_block::at(*aPos.first->data, aPos.second);
1617 (*pp)->SetNeedsListening(
true);
1622 SCROW nTopDelta = (*pp)->aPos.Row() - xGroup->mpTopCell->aPos.Row();
1628 assert(*pp == xGroup->mpTopCell);
1630 for (; pp != ppEnd; ++pp)
1637 return std::unique_ptr<sc::ColumnIterator>();
1639 return std::make_unique<sc::ColumnIterator>(
maCells, nRow1, nRow2);
1645 bAllowThreading =
true;
1647 SCROW nSpanStart = -1;
1648 SCROW nSpanEnd = -1;
1649 sc::formula_block::const_iterator itSpanStart;
1650 bool bAnyDirty =
false;
1651 for (
SCROW nFGOffset = nStartOffset; nFGOffset <= nEndOffset; ++rSpanIter, ++nFGOffset)
1654 if (!pCellStart && bThisDirty)
1656 pCellStart = *rSpanIter;
1657 itSpanStart = rSpanIter;
1658 nSpanStart = nFGOffset;
1662 if (pCellStart && (!bThisDirty || nFGOffset == nEndOffset))
1664 nSpanEnd = bThisDirty ? nFGOffset : nFGOffset - 1;
1665 assert(nSpanStart >= nStartOffset && nSpanStart <= nSpanEnd && nSpanEnd <= nEndOffset);
1668 bool bGroupInterpreted = pCellStart->
Interpret(nSpanStart, nSpanEnd);
1670 if (bGroupInterpreted)
1671 for (
SCROW nIdx = nSpanStart; nIdx <= nSpanEnd; ++nIdx, ++itSpanStart)
1672 assert(!(*itSpanStart)->NeedsInterpret());
1681 if ((mxParentGroup && mxParentGroup->mbPartOfCycle) || !rRecursionHelper.
AreGroupsIndependent())
1683 bAllowThreading =
false;
1687 if (!bGroupInterpreted)
1691 for (
SCROW nIdx = nSpanStart+1; nIdx <= nSpanEnd; ++nIdx, ++itSpanStart)
1693 (*itSpanStart)->Interpret();
1694 if ((*itSpanStart)->NeedsInterpret())
1696 SAL_WARN(
"sc.core.formulagroup",
"Internal error, cell " << (*itSpanStart)->aPos
1697 <<
" failed running Interpret(), not allowing threading");
1698 bAllowThreading =
false;
1703 if ((mxParentGroup && mxParentGroup->mbPartOfCycle) || !rRecursionHelper.
AreGroupsIndependent())
1707 bAllowThreading =
false;
1713 pCellStart =
nullptr;
1722 bool& bIsDirty,
bool& bAllowThreading)
1725 std::pair<sc::CellStoreType::const_iterator,size_t> aPos = rCells.position(nRow1);
1726 sc::CellStoreType::const_iterator it = aPos.first;
1727 size_t nOffset = aPos.second;
1732 for (;it != rCells.end() && nRow <= nRow2; ++it, nOffset = 0)
1739 if (bThreadingDepEval)
1741 bAllowThreading =
false;
1747 size_t nRowsToRead = nRow2 - nRow + 1;
1748 const size_t nEnd = std::min(it->size, nOffset+nRowsToRead);
1749 sc::formula_block::const_iterator itCell = sc::formula_block::begin(*it->data);
1750 std::advance(itCell, nOffset);
1753 size_t nCellIdx = nOffset;
1754 while (nCellIdx < nEnd)
1757 ScFormulaCell* pChildTopCell = mxGroupChild ? mxGroupChild->mpTopCell : *itCell;
1765 bAllowThreading =
false;
1769 if (bSkipRunning && (*itCell)->IsRunning())
1781 const SCROW nFGStartOffset = (*itCell)->aPos.Row() - pChildTopCell->
aPos.
Row();
1782 const SCROW nFGEndOffset = std::min(nFGStartOffset + static_cast<SCROW>(nRowsToRead) - 1, mxGroupChild->mnLength - 1);
1783 assert(nFGEndOffset >= nFGStartOffset);
1784 const SCROW nSpanLen = nFGEndOffset - nFGStartOffset + 1;
1788 bool bAnyDirtyInSpan =
lcl_InterpretSpan(itCell, nFGStartOffset, nFGEndOffset, mxGroup, bAllowThreading, rDoc);
1789 if (!bAllowThreading)
1792 bIsDirty = bIsDirty || bAnyDirtyInSpan;
1796 nCellIdx += nSpanLen;
1798 nRowsToRead -= nSpanLen;
1803 bool bDirtyFlag =
false;
1804 if( (*itCell)->NeedsInterpret())
1807 (*itCell)->Interpret();
1808 if ((*itCell)->NeedsInterpret())
1810 SAL_WARN(
"sc.core.formulagroup",
"Internal error, cell " << (*itCell)->aPos
1811 <<
" failed running Interpret(), not allowing threading");
1812 bAllowThreading =
false;
1816 bIsDirty = bIsDirty || bDirtyFlag;
1823 if (bThreadingDepEval && mxGroup &&
1827 (*itCell)->SetDirtyVar();
1828 bAllowThreading =
false;
1843 nRow += it->size - nOffset;
1848 if (bThreadingDepEval)
1849 bAllowThreading =
true;
1862 bool bAnyDirty =
false, bTmp =
false;
1872 bool bAllowThreading =
true, bTmp =
false;
1875 return bAllowThreading;
1880 class StoreToCacheFunc
1890 void operator() (
const sc::CellStoreType::value_type& node,
size_t nOffset,
size_t nDataSize )
1892 SCROW nStartRow = node.position + nOffset;
1905 sc::numeric_block::const_iterator it = sc::numeric_block::begin(*node.data);
1906 std::advance(it, nOffset);
1907 sc::numeric_block::const_iterator itEnd = it;
1908 std::advance(itEnd, nDataSize);
1910 for (; it != itEnd; ++it)
1919 sc::string_block::const_iterator it = sc::string_block::begin(*node.data);
1920 std::advance(it, nOffset);
1921 sc::string_block::const_iterator itEnd = it;
1922 std::advance(itEnd, nDataSize);
1924 for (; it != itEnd; ++it)
1927 sal_Int32 nStrLength = aStr.getLength();
1936 sc::formula_block::const_iterator it = sc::formula_block::begin(*node.data);
1937 std::advance(it, nOffset);
1938 sc::formula_block::const_iterator itEnd = it;
1939 std::advance(itEnd, nDataSize);
1941 for (; it != itEnd; )
1947 sal_uInt64 nGroupLength = 0;
1950 nGroupLength = xCellGroup->mnLength;
1961 std::advance(it, nGroupLength);
1977 StoreToCacheFunc aFunc(rStrm);
1983 sal_uInt64 nStoredCol = 0;
1985 if (nStoredCol != static_cast<sal_uInt64>(
nCol))
1986 throw std::exception();
1988 sal_uInt64 nLastRow = 0;
1990 sal_uInt64 nReadRow = 0;
1992 while (nReadRow < nLastRow)
1994 sal_uInt64 nStartRow = 0;
1995 sal_uInt64 nDataSize = 0;
2004 maCells.set_empty(nStartRow, nDataSize);
2009 std::vector<double> aValues(nDataSize);
2010 for (
auto&
rValue : aValues)
2014 maCells.set(nStartRow, aValues.begin(), aValues.end());
2019 std::vector<svl::SharedString> aStrings(nDataSize);
2021 for (
auto& rString : aStrings)
2023 sal_Int32 nStrLength = 0;
2025 std::unique_ptr<char[]> pStr(
new char[nStrLength]);
2026 rStrm.
ReadBytes(pStr.get(), nStrLength);
2027 OString aOStr(pStr.get(), nStrLength);
2028 OUString aStr = OStringToOUString(aOStr, RTL_TEXTENCODING_UTF8);
2029 rString = rPool.
intern(aStr);
2031 maCells.set(nStartRow, aStrings.begin(), aStrings.end());
2037 std::vector<ScFormulaCell*> aFormulaCells(nDataSize);
2041 for (
SCROW nRow = 0; nRow < static_cast<SCROW>(nDataSize);)
2043 sal_uInt64 nFormulaGroupSize = 0;
2045 sal_Int32 nStrLength = 0;
2047 std::unique_ptr<char[]> pStr(
new char[nStrLength]);
2048 rStrm.
ReadBytes(pStr.get(), nStrLength);
2049 OString aOStr(pStr.get(), nStrLength);
2050 OUString aStr = OStringToOUString(aOStr, RTL_TEXTENCODING_UTF8);
2051 for (sal_uInt64
i = 0;
i < nFormulaGroupSize; ++
i)
2053 aFormulaCells[nRow +
i] =
new ScFormulaCell(rDocument, aAddr, aStr, eGrammar);
2057 nRow += nFormulaGroupSize;
2060 maCells.set(nStartRow, aFormulaCells.begin(), aFormulaCells.end());
2065 nReadRow += nDataSize;
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
std::unique_ptr< ScAttrArray > pAttrArray
ScDocument & GetDoc() const
const ScPatternAttr * GetPattern(SCROW nRow) const
void StoreToCache(SvStream &rStrm) const
bool AreGroupsIndependent()
void swap(SCTAB nTab, SCCOL nCol, CellValues &rColValue)
Swap the entire column.
Sheet / outlining (grouping) information.
void RestoreFromCache(SvStream &rStrm)
static SharedString getEmptyString()
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)
CellTextAttrStoreType::iterator miCellTextAttrPos
const mdds::mtv::element_t element_type_celltextattr
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.
const SfxItemSet & GetItemSet() const
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.
bool isSkipAttrForEmptyCells() const
CellStoreType::const_iterator ParseAllNonEmpty(const typename CellStoreType::const_iterator &itPos, const CellStoreType &rCells, SCROW nRow1, SCROW nRow2, Func &rFunc)
SvStream & WriteOString(const OString &rStr)
void ApplyPatternArea(SCROW nStartRow, SCROW nEndRow, const ScPatternAttr &rPatAttr, ScEditDataArray *pDataArray=nullptr, bool *const pIsChanged=nullptr)
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
mdds::multi_type_vector< CellFunc, CellStoreEvent > CellStoreType
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)
css::uno::Any const & rValue
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)
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
Additional class containing cell annotation data.
ScConditionalFormatList * getCondFormatList()
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
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 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...
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)
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
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)
Structure that stores segments of boolean flags per column, and perform custom action on those segmen...
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
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)
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)
ScRange getWholeRange() const
Return a single range that encompasses all individual ranges.
sc::BroadcasterStoreType maBroadcasters
void CollectListeners(std::vector< SvtListener * > &rListeners, SCROW nRow1, SCROW nRow2)
bool ValidRow(SCROW nRow) const
bool IsMerged(SCROW nRow) const
sc::CellNoteStoreType maCellNotes
void CopyCellValuesFrom(SCROW nRow, const sc::CellValues &rSrc)
#define SAL_WARN_IF(condition, area, stream)
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)
void RemoveEditAttribs(SCROW nStartRow, SCROW nEndRow)
std::unique_ptr< sc::ColumnIterator > GetColumnIterator(SCROW nRow1, SCROW nRow2) const
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)
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)
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)
std::unique_ptr< EditTextObject > Clone() const
void EndListeningIntersectedGroup(sc::EndListeningContext &rCxt, SCROW nRow, std::vector< ScAddress > *pGroupPos)
void SetNeedsListeningGroup(SCROW nRow)
const mdds::mtv::element_t element_type_string
mdds::multi_type_vector< CTAttrFunc > CellTextAttrStoreType
void CloneFormulaCell(const ScFormulaCell &rSrc, const sc::CellTextAttr &rAttr, const std::vector< sc::RowSpan > &rRanges)
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.
BroadcasterStoreType::iterator ProcessBroadcaster(const BroadcasterStoreType::iterator &it, BroadcasterStoreType &rStore, SCROW nRow1, SCROW nRow2, FuncElem &rFuncElem)