18#include <document.hxx>
32 explicit Notifier(
const SfxHint& rHint ) : mrHint(rHint) {}
42 const FormulaGroupAreaListener& mrAreaListener;
44 std::vector<ScFormulaCell*> maCells;
47 explicit CollectCellAction(
const FormulaGroupAreaListener& rAreaListener ) :
48 mrAreaListener(rAreaListener) {}
50 virtual void startColumn(
ScColumn* pCol )
override
56 virtual void execute(
SCROW nRow1,
SCROW nRow2,
bool bVal )
override
61 mrAreaListener.collectFormulaCells(maPos.
Tab(), maPos.
Col(), nRow1, nRow2, maCells);
64 void swapCells( std::vector<ScFormulaCell*>& rCells )
70 if( cell1->aPos != cell2->aPos )
71 return cell1->aPos < cell2->aPos;
74 std::vector<ScFormulaCell*>::iterator it = std::unique(maCells.begin(), maCells.end());
75 maCells.erase(it, maCells.end());
84 const ScAddress& rTopCellPos,
SCROW nGroupLen,
bool bStartFixed,
bool bEndFixed ) :
86 mrDocument(rDocument),
88 mnTopCellRow(rTopCellPos.
Row()),
89 mnGroupLen(nGroupLen),
90 mbStartFixed(bStartFixed),
97 SAL_INFO(
"sc.core.grouparealistener",
98 "FormulaGroupAreaListener ctor this " <<
this <<
106 SAL_INFO(
"sc.core.grouparealistener",
107 "FormulaGroupAreaListener dtor this " <<
this);
126 else if (rHint.
GetId() == SfxHintId::ScDataChanged || rHint.
GetId() == SfxHintId::ScTableOpDirty)
128 const ScHint& rScHint =
static_cast<const ScHint&
>(rHint);
135 switch (rQuery.getId())
159 CollectCellAction aAction(*
this);
162 std::vector<ScFormulaCell*> aCells;
163 aAction.swapCells(aCells);
165 std::for_each(aCells.begin(), aCells.end(), Notifier(aHint));
185 SCROW nRow1,
SCROW nRow2, std::vector<ScFormulaCell*>& rCells )
const
187 SAL_INFO(
"sc.core.grouparealistener",
188 "FormulaGroupAreaListener::collectFormulaCells() this " <<
this <<
193 size_t nBlockSize = 0;
197 SAL_WARN(
"sc.core",
"GetFormulaCellBlockAddress not found");
206 if (!(*pp)->IsSharedTop())
208 SCROW nRow = (*pp)->GetSharedTopRow();
210 SAL_WARN(
"sc.core",
"FormulaGroupAreaListener::collectFormulaCells() no shared top");
213 SAL_WARN(
"sc.core",
"FormulaGroupAreaListener::collectFormulaCells() syncing mnTopCellRow from " <<
219 SAL_WARN(
"sc.core",
"GetFormulaCellBlockAddress not found");
224 SCROW nLen = (*pp)->GetSharedLength();
227 SAL_WARN(
"sc.core",
"FormulaGroupAreaListener::collectFormulaCells() syncing mnGroupLen from " <<
243 SAL_WARN(
"sc.core",
"FormulaGroupAreaListener::collectFormulaCells() nBlockSize " <<
244 nBlockSize <<
" < " <<
mnGroupLen <<
" mnGroupLen");
253 assert(!
"something is still messing up the formula group and block size length");
265 if (nRow2 < nRefRow1 || nRefRow2 < nRow1)
268 rCells.insert(rCells.end(), pp, ppEnd);
276 if (nRow2 < nRefRow1 || nMaxRefRow < nRow1)
279 if (nRefRow2 < nRow1)
282 SCROW nSkip = nRow1 - nRefRow2;
287 assert(nRow1 <= nRefRow2);
290 rCells.insert(rCells.end(), pp, ppEnd);
299 if (nRow2 < nRefRow1 || nRefRow2 < nRow1)
302 for (; pp != ppEnd && nRefRow1 <= nRefRow2; ++pp, ++nRefRow1)
303 rCells.push_back(*pp);
311 if (nMaxRefRow < nRow1)
314 if (nRefRow2 < nRow1)
317 SCROW nSkip = nRow1 - nRefRow2;
325 assert(nRow1 <= nRefRow2);
329 for (; pp != ppEnd && nRefRow1 <= nRow2; ++pp, ++nRefRow1, ++nRefRow2)
330 rCells.push_back(*pp);
336 size_t nBlockSize = 0;
338 SAL_WARN_IF(!pp,
"sc.core.grouparealistener",
"GetFormulaCellBlockAddress not found");
339 return pp ? *pp :
nullptr;
345 std::vector<ScFormulaCell*> aCells;
347 std::for_each(aCells.begin(), aCells.end(), Notifier(rHint));
#define BCA_LISTEN_ALWAYS
void PutInOrder(T &nStart, T &nEnd)
void IncRow(SCROW nDelta=1)
ScFormulaCell *const * GetFormulaCellBlockAddress(SCROW nRow, size_t &rBlockSize) const
SC_DLLPUBLIC ScTable * FetchTable(SCTAB nTab)
SCROW GetRowCount() const
const ScAddress & GetStartAddress() const
OUString Format(const ScDocument &rDocument, ScRefFlags nFlags=ScRefFlags::ZERO, const ScAddress::Details &rDetails=ScAddress::detailsOOOa1, bool bFullAddressNotation=false) const
Returns string with formatted cell range from aStart to aEnd, according to provided address conventio...
ScColumn * FetchColumn(SCCOL nCol)
const ColumnSpanSet * getSpans() const
Structure that stores segments of boolean flags per column, and perform custom action on those segmen...
void executeColumnAction(ScDocument &rDoc, ColumnAction &ac) const
void add(const ScRange &rRange)
#define SC_LISTENER_QUERY_FORMULA_GROUP_RANGE
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
CAUTION! The following defines must be in the same namespace as the respective type.