24#include <document.hxx>
38#include <tokenarray.hxx>
52#include <com/sun/star/i18n/LocaleDataItem2.hpp>
53#include <com/sun/star/lang/IllegalArgumentException.hpp>
59#include <rtl/tencinfo.h>
65#include <osl/diagnose.h>
70using ::com::sun::star::i18n::LocaleDataItem2;
88 for (
const auto& rRow : rRows)
100 aSpanSet.
scan(*
this, nStartRow, nEndRow);
101 std::vector<SCROW> aRows;
108class CellInterpreterBase
114 if( !groupCells.empty() &&
p->GetCellGroup() == groupCells.back()->GetCellGroup()
115 &&
p->aPos.Row() == groupCells.back()->aPos.Row() + 1 )
117 assert(
p->aPos.Tab() == groupCells.back()->aPos.Tab()
118 &&
p->aPos.Col() == groupCells.back()->aPos.Col());
119 groupCells.push_back(p);
123 if( !
p->GetCellGroup())
128 groupCells.push_back(p);
131 ~CellInterpreterBase()
138 if(groupCells.empty())
140 SCROW firstRow = groupCells.front()->GetCellGroup()->mpTopCell->aPos.Row();
141 if(!groupCells.front()->Interpret(
142 groupCells.front()->aPos.Row() - firstRow, groupCells.back()->aPos.Row() - firstRow))
152 std::vector<ScFormulaCell*> groupCells;
155class DirtyCellInterpreter :
public CellInterpreterBase
165class NeedsInterpretCellInterpreter :
public CellInterpreterBase
170 if(
p->NeedsInterpret())
176 if(
p->NeedsInterpret())
177 allInterpreted =
false;
180 bool allInterpreted =
true;
190 DirtyCellInterpreter aFunc;
199 NeedsInterpretCellInterpreter aFunc;
201 return aFunc.allInterpreted;
206 sc::CellStoreType::position_type aPos =
maCells.position(nRow);
207 sc::CellStoreType::iterator it = aPos.first;
239 maCells.event_handler().stop();
262class ShiftFormulaPosHandler
278 SCROW nEndRow = nStartRow + nSize - 1;
288 sc::CellStoreType::position_type aPos =
maCells.position(nStartRow);
289 sc::CellStoreType::iterator itCell = aPos.first;
293 sc::CellStoreType::iterator itTest = itCell;
304 bool bShiftCells =
false;
305 if (nEndRow <
GetDoc().MaxRow())
307 aPos =
maCells.position(itCell, nEndRow+1);
312 sc::CellStoreType::iterator itTest = itCell;
328 aNonEmptySpans.
scan(aBlockPos, *
this, nEndRow+1,
GetDoc().MaxRow());
334 maCells.erase(nStartRow, nEndRow);
338 aPos =
maCells.position(nStartRow);
341 ShiftFormulaPosHandler aShiftFormulaFunc;
345 if (bJoined && pGroupPos)
356 bool bInsertFormula )
362 const sc::CellStoreType::position_type& aPos,
ScFormulaCell& rCell )
367 ScFormulaCell& rPrev = *sc::formula_block::at(*aPos.first->data, aPos.second-1);
368 sc::CellStoreType::position_type aPosPrev = aPos;
376 ScFormulaCell& rNext = *sc::formula_block::at(*aPos.first->data, aPos.second+1);
382 const sc::CellStoreType::position_type& aPos,
ScFormulaCell& rCell, std::vector<SCROW>& rNewSharedRows )
384 if (!
GetDoc().IsClipOrUndo())
386#if USE_FORMULA_GROUP_LISTENER
398 if (rCell.
aPos.
Row() == nSharedTopRow)
402 rNewSharedRows.push_back( nSharedTopRow + 1);
403 rNewSharedRows.push_back( nSharedTopRow + nSharedLength - 1);
405 else if (rCell.
aPos.
Row() == nSharedTopRow + nSharedLength - 1)
410 rNewSharedRows.push_back( nSharedTopRow);
411 rNewSharedRows.push_back( rCell.
aPos.
Row() - 1);
418 rNewSharedRows.push_back( nSharedTopRow);
419 rNewSharedRows.push_back( rCell.
aPos.
Row() - 1);
420 rNewSharedRows.push_back( rCell.
aPos.
Row() + 1);
421 rNewSharedRows.push_back( nSharedTopRow + nSharedLength - 1);
436 assert(rNewSharedRows.empty() || rNewSharedRows.size() == 2 || rNewSharedRows.size() == 4);
441 auto pPosSet = std::make_shared<sc::ColumnBlockPositionSet>(rDoc);
444 if (rNewSharedRows.size() >= 2)
449 if (rNewSharedRows.size() >= 4)
458class AttachFormulaCellsHandler
472class DetachFormulaCellsHandler
479 mrDoc(rDoc), mpCxt(pCxt) {}
493 const sc::CellStoreType::position_type& aPos,
size_t nLength, std::vector<SCROW>* pNewSharedRows )
495 const size_t nRow = aPos.first->position + aPos.second;
496 const size_t nNextTopRow = nRow +
nLength;
498 bool bLowerSplitOff =
false;
499 if (pNewSharedRows && !
GetDoc().IsClipOrUndo())
507 if (nTopRow <
static_cast<SCROW>(nRow))
510 pNewSharedRows->push_back(nTopRow);
511 pNewSharedRows->push_back(nRow - 1);
513 if (
static_cast<SCROW>(nNextTopRow) <= nBotRow)
516 pNewSharedRows->push_back(nNextTopRow);
517 pNewSharedRows->push_back(nBotRow);
518 bLowerSplitOff =
true;
528 if (pNewSharedRows && !bLowerSplitOff && !
GetDoc().IsClipOrUndo())
530 sc::CellStoreType::position_type aPos2 =
maCells.position(aPos.first, nNextTopRow-1);
537 if (
static_cast<SCROW>(nNextTopRow) <= nBotRow)
540 pNewSharedRows->push_back(nNextTopRow);
541 pNewSharedRows->push_back(nBotRow);
546 sc::CellStoreType::position_type aPos2 =
maCells.position(aPos.first, nNextTopRow);
550 if (
GetDoc().IsClipOrUndo())
553 DetachFormulaCellsHandler aFunc(
GetDoc(),
nullptr);
559 sc::CellStoreType::position_type aPos =
maCells.position(nRow1);
560 sc::CellStoreType::iterator it = aPos.first;
565 aPos =
maCells.position(it, nRow2+1);
569 if (
GetDoc().IsClipOrUndo())
574 bool bEnlargedDown =
false;
575 aPos =
maCells.position(nRow1);
579 ScFormulaCell& rCell = *sc::formula_block::at(*it->data, aPos.second);
586 bEnlargedDown =
true;
594 aPos =
maCells.position(it, nRow2);
598 ScFormulaCell& rCell = *sc::formula_block::at(*it->data, aPos.second);
606 AttachFormulaCellsHandler aFunc(rCxt);
612 sc::CellStoreType::position_type aPos =
maCells.position(nRow1);
613 sc::CellStoreType::iterator it = aPos.first;
619 aPos =
maCells.position(it, nRow2+1);
623 if (
GetDoc().IsClipOrUndo())
626 DetachFormulaCellsHandler aFunc(
GetDoc(), &rCxt);
631 std::vector<SCROW>& rNewSharedRows )
633 sc::CellStoreType::iterator itRet = rPos.first;
637 ScFormulaCell& rFC = *sc::formula_block::at(*itRet->data, rPos.second);
642 rNewSharedRows.push_back( nSharedTopRow);
643 rNewSharedRows.push_back( nSharedTopRow + nSharedLength - 1);
648 rNewSharedRows.push_back( nRow);
649 rNewSharedRows.push_back( nRow);
654 std::vector<SCROW>& rNewSharedRows,
bool bInsertFormula )
657 sc::CellStoreType::position_type aPos =
maCells.position(it, nRow);
658 sc::CellStoreType::iterator itRet = aPos.first;
662 ScFormulaCell& rCell = *sc::formula_block::at(*itRet->data, aPos.second);
665 else if (bInsertFormula && !
GetDoc().IsClipOrUndo())
669 sc::CellStoreType::position_type aPosBefore =
maCells.position(
maCells.begin(), nRow-1);
672 if (nRow <
GetDoc().MaxRow())
674 sc::CellStoreType::position_type aPosAfter =
maCells.position(
maCells.begin(), nRow+1);
684 const std::vector<SCROW>& rNewSharedRows,
691 const sc::CellStoreType::position_type& aPos,
ScFormulaCell& rCell,
692 const std::vector<SCROW>& rNewSharedRows,
712 auto pPosSet = std::make_shared<sc::ColumnBlockPositionSet>(rDocument);
715 SCROW nStartRow, nEndRow;
716 nStartRow = nEndRow = aPos.first->position + aPos.second;
717 for (
const SCROW nR : rNewSharedRows)
733 if (!rNewSharedRows.empty())
735 assert(rNewSharedRows.size() == 2 || rNewSharedRows.size() == 4);
742 if (rNewSharedRows.size() > 2)
758 std::vector<SCROW>& rNewSharedRows )
764 if (aPos.first->size < aPos.second +
nLength)
769 ScFormulaCell* pCell1 = sc::formula_block::at(*aPos.first->data, aPos.second);
772 sc::CellStoreType::position_type aPosLast = aPos;
773 aPosLast.second +=
nLength - 1;
774 ScFormulaCell* pCell2 = sc::formula_block::at(*aPosLast.first->data, aPosLast.second);
787 if (rNewSharedRows.empty())
789 rNewSharedRows.push_back( nTopRow);
790 rNewSharedRows.push_back( nBotRow);
792 else if (rNewSharedRows.size() == 2)
795 if (rNewSharedRows[0] > nTopRow)
796 rNewSharedRows[0] = nTopRow;
797 if (rNewSharedRows[1] < nBotRow)
798 rNewSharedRows[1] = nBotRow;
800 else if (rNewSharedRows.size() == 4)
804 std::vector<SCROW> aRows { std::min( rNewSharedRows[0], nTopRow), std::max( rNewSharedRows[3], nBotRow) };
805 rNewSharedRows.swap( aRows);
809 assert(!
"rNewSharedRows?");
815 ScFormulaCell** pp = &sc::formula_block::at(*aPos.first->data, aPos.second);
817 for (; pp != ppEnd; ++pp)
820 (*pp)->StartListeningTo(aCxt);
833 if (
GetDoc().IsClipOrUndo() ||
GetDoc().IsInsertingFromOtherDoc() ||
GetDoc().IsCalcingAfterLoad())
851 sc::CellStoreType::position_type
pos =
maCells.position(itr, nRow);
853 size_t nOffset =
pos.second;
865 pCondSet = rDocument.
GetCondResult(aCell, aPos, *pCFList, rData);
881class DeleteAreaHandler
884 std::vector<ScFormulaCell*> maFormulaCells;
896 maDeleteRanges(rDoc.GetSheetLimits()),
903 void operator() (
const sc::CellStoreType::value_type& node,
size_t nOffset,
size_t nDataSize)
909 if (!mbNumeric && !mbDateTime)
913 if (mbNumeric && mbDateTime)
916 deleteNumeric(node, nOffset, nDataSize);
928 sc::formula_block::iterator it = sc::formula_block::begin(*node.data) + nOffset;
929 sc::formula_block::iterator itEnd = it + nDataSize;
930 maFormulaCells.insert(maFormulaCells.end(), it, itEnd);
939 SCROW nRow1 = node.position + nOffset;
940 SCROW nRow2 = nRow1 + nDataSize - 1;
941 maDeleteRanges.
set(nRow1, nRow2,
true);
944 void deleteNumeric(
const sc::CellStoreType::value_type& node,
size_t nOffset,
size_t nDataSize)
946 size_t nStart = node.position + nOffset;
948 bool bLastTypeDateTime = isDateTime(nStart);
949 size_t nCount = nStart + nDataSize;
951 for (
size_t i = nStart + 1;
i <
nCount;
i++)
953 bool bIsDateTime = isDateTime(i);
956 if (bIsDateTime == bLastTypeDateTime)
963 deleteNumberOrDateTime(nStart, nStart + nElements - 1, bLastTypeDateTime);
968 bLastTypeDateTime = bIsDateTime;
972 deleteNumberOrDateTime(nStart, nStart + nElements - 1, bLastTypeDateTime);
975 void deleteNumberOrDateTime(
SCROW nRow1,
SCROW nRow2,
bool dateTime)
977 if (!dateTime && !mbNumeric)
979 if (dateTime && !mbDateTime)
981 maDeleteRanges.
set(nRow1, nRow2,
true);
984 bool isDateTime(
size_t position)
989 return (
nType == SvNumFormatType::DATE) || (
nType == SvNumFormatType::TIME) ||
990 (
nType == SvNumFormatType::DATETIME);
1000 return maDeleteRanges;
1009 static void splitFormulaGrouping(
const sc::CellStoreType::position_type& rPos)
1013 ScFormulaCell& rCell = *sc::formula_block::at(*rPos.first->data, rPos.second);
1020 mrColumn(rColumn),
mrPos(rPos) {}
1028 sc::CellStoreType::position_type aPos = rCells.position(
mrPos.miCellPos, rSpan.
mnRow1);
1029 splitFormulaGrouping(aPos);
1030 aPos = rCells.position(aPos.first, rSpan.
mnRow2);
1031 splitFormulaGrouping(aPos);
1045 DeleteAreaHandler aFunc(
GetDoc(), nDelFlag, *
this);
1046 sc::CellStoreType::iterator itPos =
maCells.position(rBlockPos.
miCellPos, nRow1).first;
1048 aFunc.endFormulas();
1052 aFunc.getSpans().getSpans(aSpans);
1056 std::for_each(aSpans.rbegin(), aSpans.rend(), EmptyCells(rBlockPos, *
this));
1059 aFunc.getSpans().swap(rDeleted);
1079 DeleteCells(aBlockPos, nStartRow, nEndRow, nDelFlag, aDeletedRows);
1080 if (pBroadcastSpans)
1084 for (
const auto& rSpan : aSpans)
1092 DeleteCellNotes(aBlockPos, nStartRow, nEndRow, bForgetCaptionOwnership);
1108 pAttrArray->DeleteArea( nStartRow, nEndRow );
1110 pAttrArray->DeleteHardAttr( nStartRow, nEndRow );
1116 std::vector<SCROW> aRows;
1140class CopyAttrArrayByRange
1147 mrDestAttrArray(rDestAttrArray), mrSrcAttrArray(rSrcAttrArray), mnRowOffset(nRowOffset) {}
1152 rSpan.
mnRow1+mnRowOffset, rSpan.
mnRow2+mnRowOffset, mnRowOffset, mrSrcAttrArray);
1156class CopyCellsFromClipHandler
1170 void insertRefCell(
SCROW nSrcRow,
SCROW nDestRow)
1172 ScAddress aSrcPos(mnSrcCol, nSrcRow, mnSrcTab);
1179 aArr.AddSingleReference(aRef);
1185 void duplicateNotes(
SCROW nStartRow,
size_t nDataSize,
bool bCloneCaption )
1187 mrSrcCol.
DuplicateNotes(nStartRow, nDataSize, mrDestCol, maDestBlockPos, bCloneCaption, mnRowOffset);
1190 void duplicateSparklines(
SCROW nStartRow,
size_t nDataSize)
1192 mrSrcCol.
DuplicateSparklines(nStartRow, nDataSize, mrDestCol, maDestBlockPos, mnRowOffset);
1199 mrDestCol(rDestCol),
1202 mnSrcTab(rSrcCol.GetTab()),
1203 mnSrcCol(rSrcCol.GetCol()),
1204 mnRowOffset(nRowOffset),
1205 mpDestBlockPos(mrCxt.getBlockPosition(nDestTab, nDestCol)),
1206 mpSharedStringPool(pSharedStringPool)
1217 maDestBlockPos = *mpDestBlockPos;
1223 ~CopyCellsFromClipHandler()
1227 *mpDestBlockPos = maDestBlockPos;
1230 void operator() (
const sc::CellStoreType::value_type& node,
size_t nOffset,
size_t nDataSize)
1232 SCROW nSrcRow1 = node.position + nOffset;
1243 duplicateNotes(nSrcRow1, nDataSize, bCloneCaption );
1245 if (bCopySparklines)
1247 duplicateSparklines(nSrcRow1, nDataSize);
1265 sc::numeric_block::const_iterator it = sc::numeric_block::begin(*node.data);
1266 std::advance(it, nOffset);
1267 sc::numeric_block::const_iterator itEnd = it;
1268 std::advance(itEnd, nDataSize);
1269 for (
SCROW nSrcRow = nSrcRow1; it != itEnd; ++it, ++nSrcRow)
1271 bool bCopy = mrCxt.
isDateCell(mrSrcCol, nSrcRow) ? bDateTime : bNumeric;
1276 insertRefCell(nSrcRow, nSrcRow + mnRowOffset);
1278 mrDestCol.
SetValue(maDestBlockPos, nSrcRow + mnRowOffset, *it);
1287 sc::string_block::const_iterator it = sc::string_block::begin(*node.data);
1288 std::advance(it, nOffset);
1289 sc::string_block::const_iterator itEnd = it;
1290 std::advance(itEnd, nDataSize);
1291 for (
SCROW nSrcRow = nSrcRow1; it != itEnd; ++it, ++nSrcRow)
1294 insertRefCell(nSrcRow, nSrcRow + mnRowOffset);
1295 else if (mpSharedStringPool)
1299 mrDestCol.
SetRawString(maDestBlockPos, nSrcRow + mnRowOffset, aInterned);
1302 mrDestCol.
SetRawString(maDestBlockPos, nSrcRow + mnRowOffset, *it);
1311 sc::edittext_block::const_iterator it = sc::edittext_block::begin(*node.data);
1312 std::advance(it, nOffset);
1313 sc::edittext_block::const_iterator itEnd = it;
1314 std::advance(itEnd, nDataSize);
1315 for (
SCROW nSrcRow = nSrcRow1; it != itEnd; ++it, ++nSrcRow)
1319 insertRefCell(nSrcRow, nSrcRow + mnRowOffset);
1321 mrDestCol.
SetEditText(maDestBlockPos, nSrcRow + mnRowOffset, **it);
1327 sc::formula_block::const_iterator it = sc::formula_block::begin(*node.data);
1328 std::advance(it, nOffset);
1329 sc::formula_block::const_iterator itEnd = it;
1330 std::advance(itEnd, nDataSize);
1331 for (
SCROW nSrcRow = nSrcRow1; it != itEnd; ++it, ++nSrcRow)
1334 bool bForceFormula =
false;
1339 if (pCode && pCode->
GetLen() == 1)
1342 if (
p->GetOpCode() == ocTrue ||
p->GetOpCode() == ocFalse)
1344 bForceFormula =
true;
1349 if (bFormula || bForceFormula)
1352 insertRefCell(nSrcRow, nSrcRow + mnRowOffset);
1356 maDestBlockPos, nSrcRow + mnRowOffset,
1362 else if (bNumeric || bDateTime || bString)
1368 if (nErr != FormulaError::NONE)
1374 insertRefCell(nSrcRow, nSrcRow + mnRowOffset);
1380 maDestBlockPos, nSrcRow + mnRowOffset, pErrCell);
1391 bool bCopy = mrCxt.
isDateCell(mrSrcCol, nSrcRow) ? bDateTime : bNumeric;
1396 insertRefCell(nSrcRow, nSrcRow + mnRowOffset);
1398 mrDestCol.
SetValue(maDestBlockPos, nSrcRow + mnRowOffset, rSrcCell.
GetValue());
1408 insertRefCell(nSrcRow, nSrcRow + mnRowOffset);
1416 else if (mpSharedStringPool)
1420 mrDestCol.
SetRawString(maDestBlockPos, nSrcRow + mnRowOffset, aInterned);
1424 mrDestCol.
SetRawString(maDestBlockPos, nSrcRow + mnRowOffset, aStr);
1437 duplicateNotes(nSrcRow1, nDataSize, bCloneCaption );
1439 if (bCopySparklines)
1441 duplicateSparklines(nSrcRow1, nDataSize);
1446class CopyTextAttrsFromClipHandler
1458 mpDestBlockPos(rCxt.getBlockPosition(nDestTab, nDestCol))
1466 ~CopyTextAttrsFromClipHandler()
1473 void operator() (
const sc::CellTextAttrStoreType::value_type& aNode,
size_t nOffset,
size_t nDataSize )
1478 sc::celltextattr_block::const_iterator it = sc::celltextattr_block::begin(*aNode.data);
1479 std::advance(it, nOffset);
1480 sc::celltextattr_block::const_iterator itEnd = it;
1481 std::advance(itEnd, nDataSize);
1483 size_t nPos = aNode.position + nOffset + mnDelta;
1506 aSpanSet.
scan(rColumn, nRow1-nDy, nRow2-nDy);
1534 for (
SCROW nDestRow = nRow1; nDestRow <= nRow2; nDestRow++)
1537 aDestPos.
SetRow( nDestRow );
1540 aArr.AddSingleReference( aRef );
1559 CopyCellsFromClipHandler aFunc(rCxt, rColumn, *
this,
nTab,
nCol, nDy, pSharedStringPool);
1572 bool bSkipEmpty,
const ScColumn& rSrcCol )
1579 while (aIter.
Next( nRow1, nRow2 ))
1580 MixData(rCxt, nRow1, nRow2, nFunction, bSkipEmpty, rSrcCol);
1587bool lcl_DoFunction(
double& rVal1,
double nVal2,
ScPasteFunc nFunction )
1622 pToken = aIter.Next();
1635 sc::CellStoreType::iterator miNewCellsPos;
1642 void doFunction(
size_t nDestRow,
double fVal1,
double fVal2 )
1644 bool bOk = lcl_DoFunction(fVal1, fVal2, mnFunction);
1647 miNewCellsPos = maNewCells.set(miNewCellsPos, nDestRow-mnRowOffset, fVal1);
1655 miNewCellsPos = maNewCells.set(miNewCellsPos, nDestRow-mnRowOffset, pFC);
1665 mrDestColumn(rDestColumn),
1666 mrBlockPos(rBlockPos),
1667 maNewCells(nRow2 - nRow1 + 1),
1668 miNewCellsPos(maNewCells.
begin()),
1670 mnFunction(nFunction),
1671 mbSkipEmpty(bSkipEmpty)
1675 void operator() (
size_t nRow,
double f)
1677 sc::CellStoreType::position_type aPos = mrDestColumn.
GetCellStore().position(mrBlockPos.
miCellPos, nRow);
1679 switch (aPos.first->type)
1684 double fSrcVal = 0.0;
1686 fSrcVal = sc::numeric_block::at(*aPos.first->data, aPos.second);
1689 doFunction(nRow, f, fSrcVal);
1710 aArr.AddOpCode(eOp);
1713 ScFormulaCell* pDest = sc::formula_block::at(*aPos.first->data, aPos.second);
1714 lcl_AddCode(aArr, pDest);
1716 miNewCellsPos = maNewCells.set(
1717 miNewCellsPos, nRow-mnRowOffset,
1726 miNewCellsPos = maNewCells.set(miNewCellsPos, nRow-mnRowOffset, f);
1736 miNewCellsPos = maNewCells.set(miNewCellsPos, nRow-mnRowOffset, rStr);
1741 miNewCellsPos = maNewCells.set(miNewCellsPos, nRow-mnRowOffset,
p->Clone().release());
1746 sc::CellStoreType::position_type aPos = mrDestColumn.
GetCellStore().position(mrBlockPos.
miCellPos, nRow);
1748 switch (aPos.first->type)
1756 lcl_AddCode(aArr, p);
1768 aArr.AddOpCode(eOp);
1771 aArr.AddDouble(sc::numeric_block::at(*aPos.first->data, aPos.second));
1773 miNewCellsPos = maNewCells.set(
1774 miNewCellsPos, nRow-mnRowOffset,
1785 lcl_AddCode(aArr, p);
1797 aArr.AddOpCode(eOp);
1800 ScFormulaCell* pDest = sc::formula_block::at(*aPos.first->data, aPos.second);
1801 lcl_AddCode(aArr, pDest);
1803 miNewCellsPos = maNewCells.set(
1804 miNewCellsPos, nRow-mnRowOffset,
1815 miNewCellsPos = maNewCells.set(
1827 void operator() (mdds::mtv::element_t,
size_t nTopRow,
size_t nDataSize)
1833 for (
size_t i = 0;
i < nDataSize; ++
i)
1835 size_t nDestRow = nTopRow +
i;
1836 sc::CellStoreType::position_type aPos = mrDestColumn.
GetCellStore().position(mrBlockPos.
miCellPos, nDestRow);
1838 switch (aPos.first->type)
1842 double fVal2 = sc::numeric_block::at(*aPos.first->data, aPos.second);
1843 doFunction(nDestRow, 0.0, fVal2);
1848 const svl::SharedString& aVal = sc::string_block::at(*aPos.first->data, aPos.second);
1849 miNewCellsPos = maNewCells.set(
1850 miNewCellsPos, nDestRow-mnRowOffset, aVal);
1855 EditTextObject* pObj = sc::edittext_block::at(*aPos.first->data, aPos.second);
1856 miNewCellsPos = maNewCells.set(
1857 miNewCellsPos, nDestRow-mnRowOffset, pObj->
Clone().release());
1865 ScFormulaCell* pSrc = sc::formula_block::at(*aPos.first->data, aPos.second);
1866 lcl_AddCode( aArr, pSrc);
1879 aArr.AddOpCode(eOp);
1880 aArr.AddDouble(0.0);
1882 miNewCellsPos = maNewCells.set(
1883 miNewCellsPos, nDestRow-mnRowOffset,
1902 sc::CellStoreType::position_type aPos = rDestCells.position(mrBlockPos.
miCellPos, mnRowOffset);
1906 sc::CellStoreType::iterator& itDestPos = mrBlockPos.
miCellPos;
1907 sc::CellTextAttrStoreType::iterator& itDestAttrPos = mrBlockPos.
miCellTextAttrPos;
1909 for (
const auto& rNewCell : maNewCells)
1911 bool bHasContent =
true;
1912 size_t nDestRow = mnRowOffset + rNewCell.position;
1914 switch (rNewCell.type)
1918 sc::numeric_block::iterator itData = sc::numeric_block::begin(*rNewCell.data);
1919 sc::numeric_block::iterator itDataEnd = sc::numeric_block::end(*rNewCell.data);
1920 itDestPos = mrDestColumn.
GetCellStore().set(itDestPos, nDestRow, itData, itDataEnd);
1925 sc::string_block::iterator itData = sc::string_block::begin(*rNewCell.data);
1926 sc::string_block::iterator itDataEnd = sc::string_block::end(*rNewCell.data);
1927 itDestPos = rDestCells.set(itDestPos, nDestRow, itData, itDataEnd);
1932 sc::edittext_block::iterator itData = sc::edittext_block::begin(*rNewCell.data);
1933 sc::edittext_block::iterator itDataEnd = sc::edittext_block::end(*rNewCell.data);
1934 itDestPos = rDestCells.set(itDestPos, nDestRow, itData, itDataEnd);
1939 sc::formula_block::iterator itData = sc::formula_block::begin(*rNewCell.data);
1940 sc::formula_block::iterator itDataEnd = sc::formula_block::end(*rNewCell.data);
1946 itDestPos = rDestCells.set(itDestPos, nDestRow, itData, itDataEnd);
1949 aPos = rDestCells.position(itDestPos, nDestRow);
1953 size_t nNextRow = nDestRow + rNewCell.size;
1956 aPos = rDestCells.position(aPos.first, nNextRow);
1961 std::vector<SCROW> aNewSharedRows;
1962 aPos = rDestCells.position(itDestPos, nDestRow);
1963 size_t nFormulaCells = std::distance(itData, itDataEnd);
1969 itDestPos = rDestCells.set_empty(itDestPos, nDestRow, nDestRow+rNewCell.size-1);
1970 bHasContent =
false;
1981 itDestAttrPos = rDestAttrs.set(itDestAttrPos, nDestRow, aAttrs.begin(), aAttrs.end());
1984 itDestAttrPos = rDestAttrs.set_empty(itDestAttrPos, nDestRow, nDestRow+rNewCell.size-1);
1987 maNewCells.release();
1995 bool bSkipEmpty,
const ScColumn& rSrcCol )
2003 MixDataHandler aFunc(*
p, *
this, nRow1, nRow2, nFunction, bSkipEmpty);
2012 return std::make_unique<ScAttrIterator>(
pAttrArray.get(), nStartRow, nEndRow,
GetDoc().GetDefPattern() );
2017class StartListenersHandler
2020 bool mbAllListeners;
2024 mpCxt(&rCxt), mbAllListeners(bAllListeners) {}
2026 void operator() ( sc::CellStoreType::value_type& aBlk )
2034 for (; pp != ppEnd; ++pp)
2055 std::for_each(
maCells.begin(),
maCells.end(), StartListenersHandler(rCxt, bAll));
2076 if (rString.isEmpty())
2079 bool bNumFmtSet =
false;
2087 sal_uInt32 nOldIndex = 0;
2094 if ( rString.getLength() > 1 )
2097 if ( eNumFormatType != SvNumFormatType::TEXT )
2098 cFirstChar = rString[0];
2103 if ( cFirstChar ==
'=' )
2105 if ( rString.getLength() == 1 )
2123 rCell.
set( pFormulaCell);
2126 else if ( cFirstChar ==
'\'')
2135 rCell.
set(rPool.
intern(rString.copy(1)));
2158 if (eNumFormatType == SvNumFormatType::ALL)
2160 bool bForceFormatDate = (eNumFormatType == SvNumFormatType::DATE
2161 || eNumFormatType == SvNumFormatType::DATETIME);
2164 if (bForceFormatDate)
2175 bForceFormatDate =
false;
2179 aCell.
getValue(), nOldIndex, eNumFormatType, pOldFormat);
2186 bForceFormatDate =
false;
2192 if (bForceFormatDate)
2195 if (!bIsNumberFormat)
2217 if (
nIndex != nOldIndex)
2223 bool bOverwrite =
false;
2227 if ( nOldType == SvNumFormatType::NUMBER || nOldType == SvNumFormatType::DATE ||
2228 nOldType == SvNumFormatType::TIME || nOldType == SvNumFormatType::LOGICAL )
2258 const LocaleDataItem2& aLocaleItem =
pLocale->getLocaleItem();
2259 const OUString& rDecSep = aLocaleItem.decimalSeparator;
2260 const OUString& rGroupSep = aLocaleItem.thousandSeparator;
2261 const OUString& rDecSepAlt = aLocaleItem.decimalSeparatorAlternative;
2262 if (rDecSep.getLength() != 1 || rGroupSep.getLength() != 1 || rDecSepAlt.getLength() > 1)
2310 bool bNumFmtSet =
ParseString(aNewCell, nRow, nTabP, rString, eConv, pParam);
2314 aNewCell.
release(*
this, nRow);
2324 pEditText->NormalizeString(
GetDoc().GetSharedStringPool());
2325 std::vector<SCROW> aNewSharedRows;
2327 maCells.set(it, nRow, pEditText.release());
2338 pEditText->NormalizeString(
GetDoc().GetSharedStringPool());
2339 std::vector<SCROW> aNewSharedRows;
2370 if (pEditPool &&
GetDoc().GetEditPool() == pEditPool)
2388 std::vector<SCROW> aNewSharedRows;
2394 it =
maCells.set(it, nRow, pCell);
2406 std::vector<SCROW> aNewSharedRows;
2412 it =
maCells.set(it, nRow, pCell);
2422 bool bInheritNumFormatIfNeeded )
2424 std::vector<SCROW> aNewSharedRows;
2429 it =
maCells.set(it, nRow, pCell);
2442 bool bInheritNumFormatIfNeeded )
2444 std::vector<SCROW> aNewSharedRows;
2463 SCROW nEndRow = nRow + rCells.size() - 1;
2467 sc::CellStoreType::position_type aPos =
maCells.position(nRow);
2470 std::vector<SCROW> aNewSharedRows;
2473 if (!
GetDoc().IsClipOrUndo())
2475 for (
size_t i = 0,
n = rCells.size();
i <
n; ++
i)
2477 SCROW nThisRow = nRow +
i;
2480 rCells[
i]->SetNeedNumberFormat(
true);
2484 std::vector<sc::CellTextAttr> aDefaults(rCells.size(),
sc::CellTextAttr());
2487 maCells.set(aPos.first, nRow, rCells.begin(), rCells.end());
2493 aPos =
maCells.position(nRow);
2501 sc::CellStoreType::const_position_type aPos =
maCells.position(nRow);
2502 switch (aPos.first->type)
2505 return sc::string_block::at(*aPos.first->data, aPos.second);
2508 const EditTextObject* pObj = sc::edittext_block::at(*aPos.first->data, aPos.second);
2510 if (aSSs.size() != 1)
2525class FilterEntriesHandler
2541 Color backgroundColor;
2542 bool bHasConditionalBackgroundColor =
false;
2545 bool bHasConditionalTextColor =
false;
2557 bHasConditionalTextColor =
true;
2560 backgroundColor = pBackgroundColor->
GetColor();
2561 bHasConditionalBackgroundColor =
true;
2565 if (!bHasConditionalTextColor)
2577 for (
size_t i = 0;
i < pCondFormat->
size();
i++)
2579 auto aEntry = pCondFormat->
GetEntry(i);
2584 std::optional<Color> oColor = pColFormat->
GetColor(aPos);
2587 backgroundColor = *oColor;
2588 bHasConditionalBackgroundColor =
true;
2593 if (!bHasConditionalBackgroundColor)
2596 backgroundColor = pBrush->
GetColor();
2618 if (nErr != FormulaError::NONE)
2622 if (!aErr.isEmpty())
2638 if ((
nType & SvNumFormatType::DATE) && !(
nType & SvNumFormatType::TIME))
2642 fVal = rtl::math::approxFloor(fVal);
2650 else if (
nType == SvNumFormatType::DATETIME)
2659 if ((nFormat % SV_COUNTRY_LANGUAGE_OFFSET) != 0 && !bDate)
2666 FilterEntriesHandler(
ScColumn& rColumn,
ScFilterEntries& rFilterEntries,
bool bFiltering,
bool bFilteredRow) :
2667 mrColumn(rColumn), mrFilterEntries(rFilterEntries), mbFiltering(bFiltering), mbFilteredRow(bFilteredRow) {}
2669 void operator() (
size_t nRow,
double fVal)
2672 processCell(mrColumn, nRow, aCell);
2678 processCell(mrColumn, nRow, aCell);
2684 processCell(mrColumn, nRow, aCell);
2690 processCell(mrColumn, nRow, aCell);
2693 void operator() (
const int nElemType,
size_t nRow,
size_t )
2705 processCell(mrColumn, nRow, aCell);
2715 FilterEntriesHandler aFunc(*
this, rFilterEntries, bFiltering, bFilteredRow);
2725class StrCellIterator
2727 typedef std::pair<sc::CellStoreType::const_iterator,size_t> PosType;
2729 sc::CellStoreType::const_iterator miBeg;
2730 sc::CellStoreType::const_iterator miEnd;
2734 miBeg(rCells.
begin()), miEnd(rCells.
end()), mpDoc(pDoc)
2737 maPos = rCells.position(nStart);
2740 maPos.first = miEnd;
2743 bool valid()
const {
return (maPos.first != miEnd); }
2757 if (maPos.first == miBeg)
2761 maPos.second = maPos.first->size - 1;
2767 if (maPos.second > 0)
2777 if (maPos.first == miBeg)
2782 maPos.second = maPos.first->size - 1;
2798 if (maPos.first == miEnd)
2808 if (maPos.second >= maPos.first->size)
2814 if (maPos.first == miEnd)
2825 OUString
get()
const
2827 switch (maPos.first->type)
2830 return sc::string_block::at(*maPos.first->data, maPos.second).getString();
2833 const EditTextObject*
p = sc::edittext_block::at(*maPos.first->data, maPos.second);
2847 SCROW nStartRow, std::set<ScTypedStrData>& rStrings)
const
2856 bool bMoveUp = aItrUp.valid();
2862 bMoveUp = aItrUp.prev();
2864 bool bMoveDown = aItrDown.valid();
2865 if (bMoveDown && !aItrDown.has())
2866 bMoveDown = aItrDown.next();
2868 bool bFound =
false;
2872 OUString
aStr = aItrUp.get();
2873 if (!
aStr.isEmpty())
2879 bMoveUp = aItrUp.prev();
2885 OUString
aStr = aItrDown.get();
2886 if (!
aStr.isEmpty())
2892 bMoveDown = aItrDown.next();
2900class FormulaToValueHandler
2911 typedef std::vector<Entry> EntriesType;
2912 EntriesType maEntries;
2920 maEntries.emplace_back(nRow, p2->
GetValue());
2922 maEntries.emplace_back(nRow, p2->
GetString());
2925 void commitCells(
ScColumn& rColumn)
2930 for (
const Entry& r : maEntries)
2932 switch (r.maValue.getType())
2935 rColumn.
SetValue(aBlockPos, r.mnRow, r.maValue.getDouble(),
false);
2938 rColumn.
SetRawString(aBlockPos, r.mnRow, *r.maValue.getSharedString(),
false);
2951 FormulaToValueHandler aFunc;
2952 sc::CellStoreType::const_iterator itPos =
maCells.begin();
2969 pPattern = aAttrIter.
Next( nTop, nBottom );
2972 aFunc.commitCells(*
this);
2983 std::vector<SCROW> aNewSharedRows;
2985 it =
maCells.set(it, nRow, pCell);
3010 std::vector<SCROW> aNewSharedRows;
3028 std::vector<SCROW> aNewSharedRows;
3047 std::vector<SCROW> aNewSharedRows;
3065 std::vector<SCROW> aNewSharedRows;
3085 sal_uInt32 nFormat =
GetNumberFormat( pContext ? *pContext :
GetDoc().GetNonThreadedContext(), nRow);
3086 const Color* pColor =
nullptr;
3093 std::pair<sc::CellStoreType::iterator,size_t> aPos =
maCells.position(nRow);
3094 sc::CellStoreType::iterator it = aPos.first;
3101 return &sc::numeric_block::at(*it->data, aPos.second);
3112 std::pair<sc::CellStoreType::const_iterator,size_t> aPos =
maCells.position(nRow);
3113 sc::CellStoreType::const_iterator it = aPos.first;
3117 return sc::numeric_block::at(*it->data, aPos.second);
3120 const ScFormulaCell*
p = sc::formula_block::at(*it->data, aPos.second);
3133 std::pair<sc::CellStoreType::const_iterator,size_t> aPos =
maCells.position(nRow);
3134 sc::CellStoreType::const_iterator it = aPos.first;
3141 return sc::edittext_block::at(*it->data, aPos.second);
3146 std::pair<sc::CellStoreType::iterator,size_t> aPos =
maCells.position(nRow);
3147 sc::CellStoreType::iterator it = aPos.first;
3162 return p->GetFormula();
3178 switch (
maCells.get_type(nRow))
3205 void operator() (
const sc::CellStoreType::value_type& node)
3213 size_t getCount()
const {
return mnCount; }
3222 return aFunc.getCount();
3227 std::pair<sc::CellStoreType::const_iterator,size_t> aPos =
maCells.position(nRow);
3228 sc::CellStoreType::const_iterator it = aPos.first;
3230 return FormulaError::NONE;
3233 return FormulaError::NONE;
3235 const ScFormulaCell*
p = sc::formula_block::at(*it->data, aPos.second);
3241 std::pair<sc::CellStoreType::const_iterator,size_t> aPos =
maCells.position(nRow);
3242 switch (aPos.first->type)
3249 const ScFormulaCell*
p = sc::formula_block::at(*aPos.first->data, aPos.second);
3261 std::pair<sc::CellStoreType::const_iterator,size_t> aPos =
maCells.position(nRow);
3262 switch (aPos.first->type)
3268 const ScFormulaCell*
p = sc::formula_block::at(*aPos.first->data, aPos.second);
3283 std::pair<sc::CellStoreType::const_iterator,size_t> aPos =
maCells.position(nStartRow);
3284 sc::CellStoreType::const_iterator it = aPos.first;
3285 size_t nOffset = aPos.second;
3286 SCROW nRow = nStartRow;
3287 for (; it !=
maCells.end() && nRow <= nEndRow; ++it)
3292 nRow += it->size - nOffset;
3301class MaxStringLenHandler
3306 rtl_TextEncoding meCharSet;
3307 bool mbOctetEncoding;
3311 const Color* pColor;
3315 if (mbOctetEncoding)
3318 if (!aString.convertToString(&aOString, meCharSet,
3319 RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR |
3320 RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR))
3327 nLen = aOString.getLength();
3332 if (mnMaxLen < nLen)
3337 MaxStringLenHandler(
const ScColumn& rColumn, rtl_TextEncoding eCharSet) :
3340 mpFormatter(rColumn.GetDoc().GetFormatTable()),
3341 meCharSet(eCharSet),
3342 mbOctetEncoding(rtl_isOctetTextEncoding(eCharSet))
3346 void operator() (
size_t nRow,
double fVal)
3349 processCell(nRow, aCell);
3355 processCell(nRow, aCell);
3361 processCell(nRow, aCell);
3367 processCell(nRow, aCell);
3370 sal_Int32 getMaxLen()
const {
return mnMaxLen; }
3377 MaxStringLenHandler aFunc(*
this, eCharSet);
3379 return aFunc.getMaxLen();
3384class MaxNumStringLenHandler
3389 sal_uInt16 mnPrecision;
3390 sal_uInt16 mnMaxGeneralPrecision;
3395 sal_uInt16 nCellPrecision = mnMaxGeneralPrecision;
3406 nCellPrecision = mnPrecision;
3408 nCellPrecision = (mnMaxGeneralPrecision >= 15) ? 4 : mnMaxGeneralPrecision;
3412 if (!mbHaveSigned && fVal < 0.0)
3413 mbHaveSigned =
true;
3418 sal_uInt32 nFormat =
3420 if (nFormat % SV_COUNTRY_LANGUAGE_OFFSET)
3427 bool bThousand, bNegRed;
3428 sal_uInt16 nLeading;
3436 if (mnPrecision >= mnMaxGeneralPrecision)
3450 aString = rtl::math::doubleToUString( fVal, rtl_math_StringFormat_F, nCellPrecision,
'.',
true);
3454 sal_Int32 nLen = aString.getLength();
3461 if (nFormat % SV_COUNTRY_LANGUAGE_OFFSET)
3466 aString = rtl::math::doubleToUString( fVal, rtl_math_StringFormat_F, nCellPrecision,
'.',
true);
3467 nLen = aString.getLength();
3469 sal_Int32 nSep = aString.indexOf( aSep);
3471 nPrec = aString.getLength() - nSep - 1;
3476 mnPrecision = nPrec;
3481 sal_Int32 nTmp = aString.indexOf(aSep);
3483 nLen += mnPrecision + aSep.getLength();
3486 nTmp = aString.getLength() - (nTmp + aSep.getLength());
3487 if (nTmp != mnPrecision)
3488 nLen += mnPrecision - nTmp;
3498 if (mbHaveSigned && fVal >= 0.0)
3501 if (mnMaxLen < nLen)
3506 MaxNumStringLenHandler(
const ScColumn& rColumn, sal_uInt16 nMaxGeneralPrecision) :
3507 mrColumn(rColumn), mpFormatter(rColumn.GetDoc().GetFormatTable()),
3508 mnMaxLen(0), mnPrecision(0), mnMaxGeneralPrecision(nMaxGeneralPrecision),
3513 if (mnMaxGeneralPrecision > 15)
3514 mnMaxGeneralPrecision = 15;
3517 void operator() (
size_t nRow,
double fVal)
3520 processCell(nRow, aCell);
3526 processCell(nRow, aCell);
3529 sal_Int32 getMaxLen()
const {
return mnMaxLen; }
3531 sal_uInt16 getPrecision()
const {
return mnPrecision; }
3537 sal_uInt16& nPrecision,
SCROW nRowStart,
SCROW nRowEnd )
const
3540 MaxNumStringLenHandler aFunc(*
this, nMaxGeneralPrecision);
3542 nPrecision = aFunc.getPrecision();
3543 return aFunc.getMaxLen();
3548class GroupFormulaCells
3550 std::vector<ScAddress>* mpGroupPos;
3553 explicit GroupFormulaCells(std::vector<ScAddress>* pGroupPos)
3554 : mpGroupPos(pGroupPos) {}
3556 void operator() (sc::CellStoreType::value_type& node)
3562 size_t nRow = node.position;
3564 sc::formula_block::iterator it = sc::formula_block::begin(*node.data);
3565 sc::formula_block::iterator itEnd = sc::formula_block::end(*node.data);
3574 std::advance(it, xPrevGrp->mnLength);
3575 nRow += xPrevGrp->mnLength;
3585 for (; it != itEnd; pPrev = pCur, xPrevGrp = xCurGrp)
3597 if (xCurGrp->mnLength > std::distance(it, itEnd))
3598 throw css::lang::IllegalArgumentException();
3599 std::advance(it, xCurGrp->mnLength);
3600 nRow += xCurGrp->mnLength;
3618 xPrevGrp->mnLength += xCurGrp->mnLength;
3620 sc::formula_block::iterator itGrpEnd = it;
3621 if (xCurGrp->mnLength > std::distance(itGrpEnd, itEnd))
3622 throw css::lang::IllegalArgumentException();
3623 std::advance(itGrpEnd, xCurGrp->mnLength);
3624 for (++it; it != itGrpEnd; ++it)
3629 nRow += xCurGrp->mnLength;
3635 ++xPrevGrp->mnLength;
3644 nRow += xCurGrp->mnLength;
3645 if (xCurGrp->mnLength > std::distance(it, itEnd))
3646 throw css::lang::IllegalArgumentException();
3647 std::advance(it, xCurGrp->mnLength);
3649 xCurGrp->mpTopCell = pPrev;
3650 ++xCurGrp->mnLength;
3656 assert(pPrev->
aPos.
Row() ==
static_cast<SCROW>(nRow - 1));
3664 mpGroupPos->push_back(pCur->
aPos);
3677 std::for_each(
maCells.begin(),
maCells.end(), GroupFormulaCells(pGroupPos));
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 ...
bool ValidRow(SCROW nRow, SCROW nMaxRow)
std::unique_ptr< EditTextObject > CreateTextObject()
void SetText(const OUString &rStr)
virtual std::vector< svl::SharedString > GetSharedStrings() const=0
virtual const SfxItemPool * GetPool() const=0
virtual std::unique_ptr< EditTextObject > Clone() const=0
void CopyAreaSafe(SCROW nStartRow, SCROW nEndRow, tools::Long nDy, ScAttrArray &rAttrArray)
Leave flags summarized with CopyArea.
const ScPatternAttr * Next(SCROW &rTop, SCROW &rBottom)
std::unique_ptr< ScAttrArray > pAttrArray
ScDocument & GetDoc() const
std::unique_ptr< ScAttrIterator > CreateAttrIterator(SCROW nStartRow, SCROW nEndRow) const
void DeleteCellNotes(sc::ColumnBlockPosition &rBlockPos, SCROW nRow1, SCROW nRow2, bool bForgetCaptionOwnership)
svl::SharedString GetSharedString(SCROW nRow) const
void CellStorageModified()
Called whenever the state of cell array gets modified i.e.
bool HasStringData(SCROW nRow) const
void ApplyPattern(SCROW nRow, const ScPatternAttr &rPatAttr)
FormulaError GetErrCode(SCROW nRow) const
void SetValue(SCROW nRow, double fVal)
sc::CellTextAttrStoreType maCellTextAttrs
void SetFormula(SCROW nRow, const ScTokenArray &rArray, formula::FormulaGrammar::Grammar eGram)
bool HasValueData(SCROW nRow) const
const ScPatternAttr * GetPattern(SCROW nRow) const
void DuplicateNotes(SCROW nStartRow, size_t nDataSize, ScColumn &rDestCol, sc::ColumnBlockPosition &rDestBlockPos, bool bCloneCaption, SCROW nRowOffsetDest=0) const
const SfxPoolItem & GetAttr(SCROW nRow, sal_uInt16 nWhich) const
void RegroupFormulaCells(std::vector< ScAddress > *pGroupPos=nullptr)
Regroup formula cells for the entire column.
void SetError(SCROW nRow, const FormulaError nError)
ScFormulaCell * SetFormulaCell(SCROW nRow, ScFormulaCell *pCell, sc::StartListeningType eListenType=sc::SingleCellListening, bool bInheritNumFormatIfNeeded=true)
Takes ownership of pCell.
void BroadcastCells(const std::vector< SCROW > &rRows, SfxHintId nHint)
bool SetFormulaCells(SCROW nRow, std::vector< ScFormulaCell * > &rCells)
void InterpretDirtyCells(SCROW nRow1, SCROW nRow2)
void InitBlockPosition(sc::ColumnBlockPosition &rBlockPos)
void StartListeners(sc::StartListeningContext &rCxt, bool bAll)
sal_Int32 GetMaxNumberStringLen(sal_uInt16 &nPrecision, SCROW nRowStart, SCROW nRowEnd) const
void DetachFormulaCell(const sc::CellStoreType::position_type &aPos, ScFormulaCell &rCell, std::vector< SCROW > &rNewSharedRows)
Detach a formula cell that's about to be deleted, or removed from document storage (if that ever happ...
OUString GetFormula(SCROW nRow) const
void RemoveProtected(SCROW nStartRow, SCROW nEndRow)
bool ParseString(ScCellValue &rCell, SCROW nRow, SCTAB nTab, const OUString &rString, formula::FormulaGrammar::AddressConvention eConv, const ScSetStringParam *pParam)
void DuplicateSparklines(SCROW nStartRow, size_t nDataSize, ScColumn &rDestCol, sc::ColumnBlockPosition &rDestBlockPos, SCROW nRowOffsetDest=0) const
void GetFilterEntries(sc::ColumnBlockConstPosition &rBlockPos, SCROW nStartRow, SCROW nEndRow, ScFilterEntries &rFilterEntries, bool bFiltering, bool bFilteredRow)
void RemoveEditAttribs(sc::ColumnBlockPosition &rBlockPos, SCROW nStartRow, SCROW nEndRow)
bool HasStringCells(SCROW nStartRow, SCROW nEndRow) const
Return true if there is a string or editcell in the range.
sc::CellNoteStoreType maCellNotes
void AttachNewFormulaCell(const sc::CellStoreType::iterator &itPos, SCROW nRow, ScFormulaCell &rCell, const std::vector< SCROW > &rNewSharedRows, bool bJoin=true, sc::StartListeningType eListenType=sc::SingleCellListening)
const ScFormulaCell * GetFormulaCell(SCROW nRow) const
void DeleteRow(SCROW nStartRow, SCSIZE nSize, std::vector< ScAddress > *pGroupPos)
const EditTextObject * GetEditText(SCROW nRow) const
void MixMarked(sc::MixDocContext &rCxt, const ScMarkData &rMark, ScPasteFunc nFunction, bool bSkipEmpty, const ScColumn &rSrcCol)
void CellNotesDeleting(SCROW nRow1, SCROW nRow2, bool bForgetCaptionOwnership)
bool InterpretCellsIfNeeded(SCROW nRow1, SCROW nRow2)
void CopyFromClip(sc::CopyFromClipContext &rCxt, SCROW nRow1, SCROW nRow2, tools::Long nDy, ScColumn &rColumn)
void DeleteCells(sc::ColumnBlockPosition &rBlockPos, SCROW nRow1, SCROW nRow2, InsertDeleteFlags nDelFlag, sc::SingleColumnSpanSet &rDeleted)
sal_Int32 GetMaxStringLen(SCROW nRowStart, SCROW nRowEnd, rtl_TextEncoding eCharSet) const
void ApplyAttr(SCROW nRow, const SfxPoolItem &rAttr)
void MixData(sc::MixDocContext &rCxt, SCROW nRow1, SCROW nRow2, ScPasteFunc nFunction, bool bSkipEmpty, const ScColumn &rSrcCol)
void BroadcastNewCell(SCROW nRow)
void SetNeedsListeningGroup(SCROW nRow)
OUString GetInputString(SCROW nRow, bool bForceSystemLocale=false) const
bool GetDataEntries(SCROW nRow, std::set< ScTypedStrData > &rStrings) const
sc::CellStoreType maCells
ScRefCellValue GetCellValue(SCROW nRow) const
void DetachFormulaCells(const sc::CellStoreType::position_type &aPos, size_t nLength, std::vector< SCROW > *pNewSharedRows)
bool UpdateScriptType(sc::CellTextAttr &rAttr, SCROW nRow, sc::CellStoreType::iterator &itr)
SCSIZE GetCellCount() const
void StartListeningUnshared(const std::vector< SCROW > &rNewSharedRows)
Re-establish listeners on unshared formula groups.
void StartListeningFormulaCells(sc::StartListeningContext &rStartCxt, sc::EndListeningContext &rEndCxt, SCROW nRow1, SCROW nRow2)
void BroadcastRows(SCROW nStartRow, SCROW nEndRow, SfxHintId nHint)
void Broadcast(SCROW nRow)
sc::CellTextAttrStoreType & GetCellAttrStore()
double * GetValueCell(SCROW nRow)
void DeleteSparklineCells(sc::ColumnBlockPosition &rBlockPos, SCROW nRow1, SCROW nRow2)
void SetEditText(SCROW nRow, std::unique_ptr< EditTextObject > pEditText)
void DeleteContent(SCROW nRow, bool bBroadcast=true)
sc::CellStoreType & GetCellStore()
bool SetString(SCROW nRow, SCTAB nTab, const OUString &rString, formula::FormulaGrammar::AddressConvention eConv, const ScSetStringParam *pParam=nullptr)
Returns true if the cell format was set as well.
void DeleteArea(SCROW nStartRow, SCROW nEndRow, InsertDeleteFlags nDelFlag, bool bBroadcast=true, sc::ColumnSpanSet *pBroadcastSpans=nullptr)
double GetValue(SCROW nRow) const
static void JoinNewFormulaCell(const sc::CellStoreType::position_type &aPos, ScFormulaCell &rCell)
sc::BroadcasterStoreType maBroadcasters
OUString GetString(SCROW nRow, const ScInterpreterContext *pContext=nullptr) const
void SetRawString(SCROW nRow, const OUString &rStr)
void RemoveEditTextCharAttribs(SCROW nRow, const ScPatternAttr &rAttr)
SCROW GetLastDataPos() const
CellType GetCellType(SCROW nRow) const
const ScFormulaCell * FetchFormulaCell(SCROW nRow) const
ScDocument & GetDoc() const
sal_uInt32 GetNumberFormat(const ScInterpreterContext &rContext, SCROW nRow) const
sc::SparklineStoreType maSparklines
void AttachFormulaCells(sc::StartListeningContext &rCxt, SCROW nRow1, SCROW nRow2)
sc::CellStoreType::iterator GetPositionToInsert(SCROW nRow, std::vector< SCROW > &rNewSharedRows, bool bInsertFormula)
void AttachNewFormulaCells(const sc::CellStoreType::position_type &aPos, size_t nLength, std::vector< SCROW > &rNewSharedRows)
sal_uInt16 GetStdPrecision() const
bool IsCalcingAfterLoad() const
bool ValidRow(SCROW nRow) const
SC_DLLPUBLIC SCROW GetMaxRowCount() const
SC_DLLPUBLIC ScDocumentPool * GetPool()
SC_DLLPUBLIC void CheckLinkFormulaNeedingCheck(const ScTokenArray &rCode)
Check token array and set link check if ocDde/ocWebservice is contained.
SC_DLLPUBLIC ScFieldEditEngine & GetEditEngine()
SC_DLLPUBLIC double RoundValueAsShown(double fVal, sal_uInt32 nFormat, const ScInterpreterContext *pContext=nullptr) const
ScInterpreterContext & GetNonThreadedContext() const
SC_DLLPUBLIC SvtScriptType GetStringScriptType(const OUString &rString)
bool IsDelayedFormulaGrouping() const
void Broadcast(const ScHint &rHint)
Broadcast wrapper, calls rHint.GetCell()->Broadcast() and AreaBroadcast() and TrackFormulas() Preferr...
SC_DLLPUBLIC ScConditionalFormat * GetCondFormat(SCCOL nCol, SCROW nRow, SCTAB nTab) const
void EndListeningFormulaCells(std::vector< ScFormulaCell * > &rCells)
bool IsClipOrUndo() const
bool IsInsertingFromOtherDoc() const
SC_DLLPUBLIC svl::SharedStringPool & GetSharedStringPool()
SC_DLLPUBLIC ScConditionalFormatList * GetCondFormList(SCTAB nTab) const
SC_DLLPUBLIC SvNumberFormatter * GetFormatTable() const
bool CanDelayStartListeningFormulaCells(ScColumn *column, SCROW row1, SCROW row2)
If true is returned, ScColumn::StartListeningFormulaCells() for the given cells will be performed lat...
SC_DLLPUBLIC const SfxPoolItem * GetAttr(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt16 nWhich) const
SC_DLLPUBLIC const SfxItemSet * GetCondResult(SCCOL nCol, SCROW nRow, SCTAB nTab, ScRefCellValue *pCell=nullptr) const
SC_DLLPUBLIC const ScPatternAttr * GetPattern(SCCOL nCol, SCROW nRow, SCTAB nTab) const
SC_DLLPUBLIC const ScDocOptions & GetDocOptions() const
void SetTextCurrentDefaults(const EditTextObject &rTextObject)
SetText and apply defaults already set.
static void RemoveCharAttribs(EditTextObject &rEditText, const ScPatternAttr &rAttr)
static SC_DLLPUBLIC OUString GetString(const EditTextObject &rEditText, const ScDocument *pDoc)
Retrieves string with paragraphs delimited by new lines (' ').
static OUString GetErrorString(FormulaError nErrNumber)
void SetAddressRow(SCROW nRow)
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
bool IsMultiMarked() const
const ScMultiSel & GetMultiSelData() const
bool Next(SCROW &rTop, SCROW &rBottom)
sal_uInt32 GetNumberFormat(SvNumberFormatter *) const
const SfxPoolItem & GetItem(sal_uInt16 nWhichP) const
bool GetHideFormula() const
static bool parseSimpleNumber(const OUString &rStr, sal_Unicode dsep, sal_Unicode gsep, sal_Unicode dsepa, double &rVal)
Check if a given string is a simple decimal number (e.g.
virtual formula::FormulaToken * AddOpCode(OpCode eCode) override
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
static bool SafePlus(double &fVal1, double fVal2)
static bool SafeMult(double &fVal1, double fVal2)
static bool SafeDiv(double &fVal1, double fVal2)
const Color & GetColor() const
const Color & GetValue() const
Temporarily switch on/off auto calculation mode.
ColumnBlockPosition * getBlockPosition(SCTAB nTab, SCCOL nCol)
Structure that stores segments of boolean flags per column, and perform custom action on those segmen...
void set(const ScDocument &rDoc, SCTAB nTab, SCCOL nCol, SCROW nRow, bool bVal)
bool isCloneSparklines() const
bool isCloneNotes() const
bool isSkipEmptyCells() const
Get the flag that indicates whether the "skip empty cells" paste option is selected.
InsertDeleteFlags getInsertFlag() const
bool isDateCell(const ScColumn &rCol, SCROW nRow) const
ScDocument * getDestDoc()
Keep track of spans in a single column only.
void scan(const ScColumn &rColumn)
Scan an entire column and tag all non-empty cell positions.
std::vector< RowSpan > SpansType
void getSpans(SpansType &rSpans) const
void getRows(std::vector< SCROW > &rRows) const
void set(SCROW nRow1, SCROW nRow2, bool bVal)
SharedString intern(const OUString &rStr)
static void lcl_AddFormulaGroupBoundaries(const sc::CellStoreType::position_type &rPos, std::vector< SCROW > &rNewSharedRows)
#define suppress_fun_call_w_exception(expr)
@ SPARKLINES
Sheet / outlining (grouping) information.
@ NOTE
Strings (and string results if InsertDeleteFlags::FORMULA is not set).
@ NOCAPTIONS
Sparklines in a cell.
@ SPECIAL_BOOLEAN
Internal use only (copy from clip): do not delete existing cell contents when pasting notes.
@ EDITATTR
Drawing objects.
@ STRING
Dates, times, datetime values.
@ DATETIME
Numeric values (and numeric results if InsertDeleteFlags::FORMULA is not set).
@ ATTRIB
Internal use only (d&d undo): do not delete caption objects of cell notes.
enumrange< T >::Iterator begin(enumrange< T >)
CellStoreType::const_iterator ParseAllNonEmpty(const typename CellStoreType::const_iterator &itPos, const CellStoreType &rCells, SCROW nRow1, SCROW nRow2, Func &rFunc)
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.
const mdds::mtv::element_t element_type_celltextattr
const mdds::mtv::element_t element_type_edittext
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.
const mdds::mtv::element_t element_type_formula
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.
void ParseFormula(const CellStoreType &rStore, Func &rFunc)
mdds::mtv::soa::multi_type_vector< CellStoreTraits > CellStoreType
Cell container.
const mdds::mtv::element_t element_type_numeric
Mapped standard element types (for convenience).
CellStoreType::const_iterator ParseFormulaNumeric(const CellStoreType::const_iterator &itPos, const CellStoreType &rCells, SCROW nRow1, SCROW nRow2, Func &rFunc)
CellStoreType::const_iterator ParseAll(const typename CellStoreType::const_iterator &itPos, const CellStoreType &rCells, SCROW nRow1, SCROW nRow2, FuncElem &rFuncElem, FuncElse &rFuncElse)
@ ConvertToGroupListening
mdds::mtv::soa::multi_type_vector< CellTextAttrTraits > CellTextAttrStoreType
Cell text attribute container.
const mdds::mtv::element_t element_type_string
const mdds::mtv::element_t element_type_empty
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
constexpr TypedWhichId< SvxColorItem > ATTR_FONT_COLOR(109)
constexpr TypedWhichId< SvxBrushItem > ATTR_BACKGROUND(148)
constexpr TypedWhichId< SfxUInt32Item > ATTR_VALUE_FORMAT(146)
constexpr TypedWhichId< ScProtectionAttr > ATTR_PROTECTION(149)
constexpr TypedWhichId< ScCondFormatItem > ATTR_CONDITIONAL(154)
Store arbitrary cell value of any kind.
void release(ScDocument &rDoc, const ScAddress &rPos)
Set cell value at specified position in specified document.
void addBackgroundColor(const Color &aBackgroundColor)
void addTextColor(const Color &aTextColor)
void push_back(const ScTypedStrData &r)
SvNumberFormatter * GetFormatTable() const
This is very similar to ScCellValue, except that it references the original value instead of copying ...
ScFormulaCell * getFormula() const
Store parameters used in the ScDocument::SetString() method.
bool mbHandleApostrophe
When true, treat input with a leading apostrophe as an escape character for all content,...
bool mbCheckLinkFormula
When true and the string results in a compiled formula, check the formula tokens for presence of func...
bool mbDetectNumberFormat
When true, we try to detect special number format (dates etc) from the input string,...
SvNumberFormatter * mpNumFormatter
Stores the pointer to the number formatter instance to be used during number format detection.
@ Always
Set Text number format if the input string can be parsed as a number or formula text.
@ Never
Never set Text number format.
@ SpecialNumberOnly
Set Text number format only when the input string is considered a special number but we only want to ...
TextFormatPolicy meSetTextNumFormat
Determine when to set the 'Text' number format to the cell where the input string is being set.
sc::StartListeningType meStartListening
Single reference (one address) into the sheet.
void SetAbsCol(SCCOL nVal)
void SetAbsTab(SCTAB nVal)
void InitAddress(const ScAddress &rAdr)
InitAddress: InitFlags and set address.
void SetAbsRow(SCROW nVal)
void SetFlag3D(bool bVal)
void InitFlags()
No default ctor, because used in ScRawToken union, set InitFlags!
SvtScriptType mnScriptType
CellNoteStoreType::const_iterator miCellNotePos
CellTextAttrStoreType::const_iterator miCellTextAttrPos
CellStoreType::const_iterator miCellPos
Store position data for column array storage.
SparklineStoreType::iterator miSparklinePos
CellTextAttrStoreType::iterator miCellTextAttrPos
BroadcasterStoreType::iterator miBroadcasterPos
CellStoreType::iterator miCellPos
CellNoteStoreType::iterator miCellNotePos
::boost::intrusive_ptr< ScFormulaCellGroup > ScFormulaCellGroupRef
NF_EVALDATEFORMAT_INTL_FORMAT
NF_EVALDATEFORMAT_FORMAT_INTL
#define SV_COUNTRY_LANGUAGE_OFFSET