12#include <tokenarray.hxx>
14#include <document.hxx>
26 sc::formula_block::iterator it = sc::formula_block::begin(*aPos.first->data);
27 std::advance(it, aPos.second);
38 SCROW nRow = aPos.first->position + aPos.second;
48 sc::formula_block::iterator it = sc::formula_block::begin(*aPos.first->data);
49 std::advance(it, aPos.second);
61 SCROW nLength2 = xGroup->mpTopCell->aPos.Row() + xGroup->mnLength - nRow;
66 xGroup2->mbInvariant = xGroup->mbInvariant;
67 xGroup2->mpTopCell = &rTop;
68 xGroup2->mnLength = nLength2;
69 xGroup2->mpCode = xGroup->mpCode->CloneValue();
72 xGroup->mnLength = nRow - xGroup->mpTopCell->
aPos.
Row();
73 ScFormulaCell& rPrevTop = *sc::formula_block::at(*aPos.first->data, aPos.second - xGroup->mnLength);
75#if USE_FORMULA_GROUP_LISTENER
96 if (xGroup->mnLength == 1)
104 assert ((xGroup2 ==
nullptr || xGroup2->mpTopCell->aPos.Row() +
size_t(xGroup2->mnLength) <= aPos.first->position + aPos.first->size)
105 &&
"Shared formula region goes beyond the formula block.");
106 sc::formula_block::iterator itEnd = it;
107 std::advance(itEnd, nLength2);
108 for (; it != itEnd; ++it)
123 std::sort(rBounds.begin(), rBounds.end());
124 std::vector<SCROW>::iterator it = std::unique(rBounds.begin(), rBounds.end());
125 rBounds.erase(it, rBounds.end());
127 it = rBounds.begin();
129 CellStoreType::position_type aPos = rCells.position(nRow);
130 if (aPos.first == rCells.end())
134 std::vector<SCROW>::iterator itEnd = rBounds.end();
135 for (++it; it != itEnd; ++it)
140 aPos = rCells.position(aPos.first, nRow);
141 if (aPos.first == rCells.end())
171 if (xGroup1.get() == xGroup2.get())
176 xGroup1->mnLength += xGroup2->mnLength;
177 size_t nOffset = rPos.second + 1;
178 for (
size_t i = 0,
n = xGroup2->mnLength;
i <
n; ++
i)
180 ScFormulaCell& rCell = *sc::formula_block::at(*rPos.first->data, nOffset+
i);
197 xGroup2->mpTopCell = &rCell1;
203 assert(rCell1.
aPos.
Row() ==
static_cast<SCROW>(rPos.first->position + rPos.second));
218 if (aPos.second == 0)
223 ScFormulaCell& rPrev = *sc::formula_block::at(*aPos.first->data, aPos.second-1);
224 ScFormulaCell& rCell = *sc::formula_block::at(*aPos.first->data, aPos.second);
225 sc::CellStoreType::position_type aPosPrev = aPos;
236 sc::CellStoreType::iterator it = aPos.first;
243 if (xGroup->mnLength == 2)
246 assert (aPos.second+1 < aPos.first->size
247 &&
"There is no next formula cell but there should be!");
248 ScFormulaCell& rNext = *sc::formula_block::at(*it->data, aPos.second+1);
254 ScFormulaCell& rNext = *sc::formula_block::at(*it->data, aPos.second+1);
255 xGroup->mpTopCell = &rNext;
263 if (xGroup->mnLength == 2)
266 assert(aPos.second != 0 &&
"There is no previous formula cell but there should be!");
267 ScFormulaCell& rPrev = *sc::formula_block::at(*it->data, aPos.second-1);
280 SCROW nEndRow = xGroup->mpTopCell->aPos.Row() + xGroup->mnLength - 1;
281 xGroup->mnLength = rCell.
aPos.
Row() - xGroup->mpTopCell->aPos.Row();
282 if (xGroup->mnLength == 1)
285 assert(aPos.second != 0 &&
"There is no previous formula cell but there should be!");
286 ScFormulaCell& rPrev = *sc::formula_block::at(*it->data, aPos.second-1);
295 ScFormulaCell& rNext = *sc::formula_block::at(*it->data, aPos.second+1);
296 xGroup2->mpTopCell = &rNext;
297 xGroup2->mnLength = nLength2;
298 xGroup2->mbInvariant = xGroup->mbInvariant;
299 xGroup2->mpCode = xGroup->mpCode->CloneValue();
300 assert(xGroup2->mpTopCell->aPos.Row() +
size_t(xGroup2->mnLength) <= it->position + it->size
301 &&
"Shared formula region goes beyond the formula block.");
302 sc::formula_block::iterator itCell = sc::formula_block::begin(*it->data);
303 std::advance(itCell, aPos.second+1);
304 sc::formula_block::iterator itCellEnd = itCell;
305 std::advance(itCellEnd, xGroup2->mnLength);
306 for (; itCell != itCellEnd; ++itCell)
315 sc::formula_block::iterator itCell = sc::formula_block::begin(*it->data);
316 std::advance(itCell, aPos.second+1);
331 std::sort(rRows.begin(), rRows.end());
332 rRows.erase(std::unique(rRows.begin(), rRows.end()), rRows.end());
335 std::vector<SCROW> aRows2;
336 for (
const auto& rRow : rRows)
341 aRows2.push_back(rRow);
344 aRows2.push_back(rRow+1);
348 aRows2.erase(std::unique(aRows2.begin(), aRows2.end()), aRows2.end());
358#if USE_FORMULA_GROUP_LISTENER
364 assert(&rCode == rTopCell.
GetCode());
374 for (;
p != pEnd; ++
p)
377 switch (
t->GetType())
385 for (; pp != ppEnd; ++pp)
403 ScRange aOrigRange(aPos1, aPos2);
404 ScRange aListenedRange = aOrigRange;
406 aListenedRange.
aEnd.
IncRow(xGroup->mnLength-1);
411 aListenedRange,
true,
412 xGroup->getAreaListener(ppSharedTop, aOrigRange, !rRef1.
IsRowRel(), !rRef2.
IsRowRel()));
423 for (; pp != ppEnd; ++pp)
432 for (; pp != ppEnd; ++pp)
#define BCA_LISTEN_ALWAYS
void IncRow(SCROW nDelta=1)
bool ValidRow(SCROW nRow) const
void SetDetectiveDirty(bool bSet)
SC_DLLPUBLIC SCROW MaxRow() const
bool IsDelayedFormulaGrouping() const
void AddDelayedFormulaGroupingCell(const ScFormulaCell *cell)
To be used only by SharedFormulaUtil::joinFormulaCells().
void StartListeningArea(const ScRange &rRange, bool bGroupListening, SvtListener *pListener)
void StartListeningCell(const ScAddress &rAddress, SvtListener *pListener)
CAUTION! The following defines must be in the same namespace as the respective type.
const mdds::mtv::element_t element_type_formula
mdds::mtv::soa::multi_type_vector< CellStoreTraits > CellStoreType
Cell container.
Single reference (one address) into the sheet.
ScAddress toAbs(const ScSheetLimits &rLimits, const ScAddress &rPos) const
::boost::intrusive_ptr< ScFormulaCellGroup > ScFormulaCellGroupRef