24#include <document.hxx>
36#include <tokenarray.hxx>
40#include <progress.hxx>
73#define SC_ROT_BREAK_FACTOR 6
78 return ( nScript != SvtScriptType::LATIN &&
79 nScript != SvtScriptType::ASIAN &&
80 nScript != SvtScriptType::COMPLEX );
89 const ScPatternAttr** ppPatternChange,
bool bInPrintTwips )
const
98 std::pair<sc::CellStoreType::const_iterator,size_t> aPos =
maCells.position(nRow);
99 sc::CellStoreType::const_iterator it = aPos.first;
108 auto conditionalScaleFunc = [bInPrintTwips](
tools::Long nMeasure,
double fScale) {
109 return bInPrintTwips ? nMeasure :
static_cast<tools::Long>(nMeasure * fScale);
146 *ppPatternChange = pPattern;
153 eHorJust = pCondItem->GetValue();
158 if ( eHorJust == SvxCellHorJustify::Block )
161 bBreak = pLineBreakCell->
GetValue();
166 sal_uInt32 nFormat = pPattern->
GetNumberFormat( pFormatter, pCondSet );
177 bCellIsValue = pFCell->
IsValue();
183 *ppPatternChange = pPattern;
189 if (bBreak && bCellIsValue && (pFormatter->
GetType(nFormat) == SvNumFormatType::NUMBER))
198 if (bMayInvalidatePattern)
202 *ppPatternChange = pPattern;
206 if (!bMayInvalidatePattern || pPattern == pOldPattern)
211 if (pFormatter->
GetType(nFormat) == SvNumFormatType::NUMBER)
220 bool bAsianVertical = ( eOrient == SvxCellOrientation::Stacked &&
222 if ( bAsianVertical )
225 if ( bWidth && bBreak )
230 if ( eOrient == SvxCellOrientation::Standard )
235 nRotate = pRotateValueItem->
GetValue();
243 eRotMode = pRotateModeItem->GetValue();
247 if ( nRotate == 18000_deg100 )
252 if ( eHorJust == SvxCellHorJustify::Repeat )
255 eOrient = SvxCellOrientation::Standard;
257 bAsianVertical =
false;
266 sal_uInt16 nIndent = 0;
267 if ( eHorJust == SvxCellHorJustify::Left )
284 Fraction aFontZoom = ( eOrient == SvxCellOrientation::Standard ) ? rZoomX : rZoomY;
287 pPattern->
fillFontOnly(aFont, pDev, &aFontZoom, pCondSet, nScript);
291 bool bAddMargin =
true;
295 eOrient == SvxCellOrientation::Stacked ||
303 aCell, nFormat, &pColor, *pFormatter, rDocument,
true, rOptions.
bFormula);
305 if (!aValStr.isEmpty())
310 if ( eOrient != SvxCellOrientation::Standard )
321 double nCosAbs = fabs( cos( nRealOrient ) );
322 double nSinAbs = fabs( sin( nRealOrient ) );
335 (bInPrintTwips ? 1.0 : nPPT) * nCosAbs / nSinAbs );
344 if ( nHeight > nCmp )
348 aSize =
Size( nWidth, nHeight );
359 nValue += conditionalScaleFunc(nIndent, nPPT);
368 if ( bBreak && !bWidth )
376 nDocSize = (nDocSize * 9) / 10;
377 if ( aSize.
Width() > nDocSize )
388 MapMode aHMMMode( MapUnit::Map100thMM,
Point(), rZoomX, rZoomY );
393 const bool bPrevUpdateLayout = pEngine->SetUpdateLayout(
false );
397 nCtrl |= EEControlBits::FORMAT100;
400 pEngine->SetControlWord( nCtrl );
403 pEngine->SetRefDevice( pDev );
405 SfxItemSet aSet( pEngine->GetEmptyItemSet() );
423 pEngine->SetHyphenator( xXHyphenator );
426 Size aPaper( 1000000, 1000000 );
427 if ( eOrient==SvxCellOrientation::Stacked && !bAsianVertical )
431 double fWidthFactor = bInPrintTwips ? 1.0 :
nPPTX;
445 for (
SCCOL nColAdd=1; nColAdd<nColMerge; nColAdd++)
451 nDocWidth -=
static_cast<tools::Long>( nIndent * fWidthFactor );
464 aPaper = bInPrintTwips ?
469 pEngine->SetPaperSize(aPaper);
473 pEngine->SetTextNewDefaults(*aCell.
getEditText(), std::move(aSet));
479 aCell, nFormat, &pColor, *pFormatter, rDocument,
true,
482 if (!aString.isEmpty())
483 pEngine->SetTextNewDefaults(aString, std::move(aSet));
485 pEngine->SetDefaults(std::move(aSet));
488 bool bEngineVertical = pEngine->IsEffectivelyVertical();
489 pEngine->SetVertical( bAsianVertical );
490 pEngine->SetUpdateLayout( bPrevUpdateLayout );
492 bool bEdWidth = bWidth;
493 if ( eOrient != SvxCellOrientation::Standard && eOrient != SvxCellOrientation::Stacked )
494 bEdWidth = !bEdWidth;
499 Size aSize( pEngine->CalcTextWidth(), pEngine->GetTextHeight() );
501 double nCosAbs = fabs( cos( nRealOrient ) );
502 double nSinAbs = fabs( sin( nRealOrient ) );
513 (bInPrintTwips ? 1.0 : nPPT) * nCosAbs / nSinAbs );
517 aSize =
Size( nWidth, nHeight );
519 Size aTextSize = bInPrintTwips ?
544 sal_uInt32 aTextSize(pEngine->CalcTextWidth());
552 sal_uInt32 aTextSize(pEngine->GetTextHeight());
559 ( pEngine->GetParagraphCount() > 1 || ( bBreak && pEngine->GetLineCount(0) > 1 ) ) )
561 pEngine->SetControlWord( nCtrl | EEControlBits::FORMAT100 );
562 pEngine->QuickFormatDoc(
true );
563 aTextSize = pEngine->GetTextHeight();
567 if ( nSecondValue >
nValue )
572 if (
nValue && bAddMargin )
579 nValue += conditionalScaleFunc(nIndent, nPPT);
590 nValue += conditionalScaleFunc(
598 pEngine->SetVertical( bEngineVertical );
628 OUString maMaxLenStr;
632 void checkLineBreak(
const OUString& aStrVal)
634 sal_Int32 nFromIndex = 0;
635 sal_Int32 nToIndex = aStrVal.indexOf(
'\n', nFromIndex);
639 mnMaxLen = aStrVal.getLength();
640 maMaxLenStr = aStrVal;
644 sal_Int32 nMaxLen = 0;
646 while (nToIndex != -1)
648 if (nMaxLen < nToIndex - nFromIndex)
650 nMaxLen = nToIndex - nFromIndex;
652 nFromIndex = nToIndex + 1;
653 nToIndex = aStrVal.indexOf(
'\n', nFromIndex);
656 nToIndex = aStrVal.getLength() - nFromIndex;
657 if (nMaxLen < nToIndex)
662 if (mnMaxLen < nMaxLen)
665 maMaxLenStr = aStrVal.subView(nFromIndex);
676 if (aValStr.getLength() <= mnMaxLen)
683 mnMaxLen = aValStr.getLength();
684 maMaxLenStr = aValStr;
690 checkLineBreak(aValStr);
695 MaxStrLenFinder(
ScDocument& rDoc, sal_uInt32 nFormat) :
696 mrDoc(rDoc), mnFormat(nFormat), mnMaxLen(0) {}
698 void operator() (
size_t ,
double f)
724 const OUString& getMaxLenStr()
const {
return maMaxLenStr; }
746 aMarkedSpans.emplace_back(0,
GetDoc().MaxRow());
748 sal_uInt16 nWidth =
static_cast<sal_uInt16
>(nOldWidth*
nPPTX);
775 if (pNextPattern != pPattern)
784 aCell, nFormat, &pColor, *pFormatter, rDocument);
789 MaxStrLenFinder aFunc(rDocument, nFormat);
790 sc::CellStoreType::const_iterator itPos =
maCells.begin();
791 for (
const auto& rMarkedSpan : aMarkedSpans)
794 aLongStr = aFunc.getMaxLenStr();
797 if (!aLongStr.isEmpty())
799 nWidth = pDev->
GetTextWidth(aLongStr) +
static_cast<sal_uInt16
>(nMargin);
810 sc::CellStoreType::const_iterator itPos =
maCells.begin();
812 for (
auto [ nRow, nRow2 ] : aMarkedSpans)
814 while (nRow <= nRow2)
817 std::tie(itPos, nOffset) =
maCells.position(itPos, nRow);
821 nRow += itPos->size - nOffset;
825 for (; nOffset < itPos->size && nRow <= nRow2; ++nOffset, ++nRow)
828 if (nScript == SvtScriptType::NONE)
833 aOptions.
bGetFont = (pPattern != pOldPattern || nScript != SvtScriptType::NONE);
834 pOldPattern = pPattern;
836 nRow, pDev,
nPPTX,
nPPTY, rZoomX, rZoomY,
true, aOptions, &pOldPattern));
837 if (nThis && (nThis > nWidth || !bFound))
850 sal_uInt16 nTwips =
static_cast<sal_uInt16
>(
851 std::min(nWidth /
nPPTX, std::numeric_limits<sal_uInt16>::max() / 2.0));
859 sal_uInt16 nMinHeight)
864 sal_uInt16 nHeight = rFontHeight.
GetHeight();
871 nHeight += nHeight / 4;
881 if (nHeight < nMinHeight)
882 nHeight = nMinHeight;
920 bool bStdOnly =
false;
925 SvxCellHorJustify::Block);
942 bool bHasEditCells =
HasEditCells(nStart,nEnd,nEditPos);
949 pPattern = aIter.
Resync( nStart, nStart, nEnd);
950 if (bHasEditCells && nEnd < nEditPos)
951 bHasEditCells =
false;
954 if (nEditPos == nStart)
971 aSpanSet.
scan(*
this, nStart, nEnd);
977 sal_uInt16 nLatHeight = 0;
978 sal_uInt16 nCjkHeight = 0;
979 sal_uInt16 nCtlHeight = 0;
980 sal_uInt16 nDefHeight;
982 if ( nDefScript == SvtScriptType::ASIAN )
984 nOptimalMinRowHeight);
985 else if ( nDefScript == SvtScriptType::COMPLEX )
987 nOptimalMinRowHeight);
990 nOptimalMinRowHeight);
994 SCROW nStdEnd = nEnd;
995 if ( nDefHeight <= nMinHeight && nStdEnd >= nMinStart )
996 nStdEnd = (nMinStart>0) ? nMinStart-1 : 0;
998 if (nStart <= nStdEnd)
1000 SCROW nRow = nStart;
1005 sal_uInt16 nRangeHeight = rHeights.
GetValue(nRow,
nIndex, nRangeEnd);
1006 if (nRangeHeight < nDefHeight)
1007 rHeights.
SetValue(nRow, std::min(nRangeEnd, nStdEnd), nDefHeight);
1008 nRow = nRangeEnd + 1;
1019 sc::CellStoreType::iterator itCells =
maCells.begin();
1020 for (
const auto& rSpan : aSpans)
1022 for (
SCROW nRow = rSpan.mnRow1; nRow <= rSpan.mnRow2; ++nRow)
1025 if (nScript == nDefScript)
1028 if ( nScript == SvtScriptType::ASIAN )
1030 if ( nCjkHeight == 0 )
1033 nOptimalMinRowHeight);
1034 if (nCjkHeight > rHeights.
GetValue(nRow))
1035 rHeights.
SetValue(nRow, nRow, nCjkHeight);
1037 else if ( nScript == SvtScriptType::COMPLEX )
1039 if ( nCtlHeight == 0 )
1042 nOptimalMinRowHeight);
1043 if (nCtlHeight > rHeights.
GetValue(nRow))
1044 rHeights.
SetValue(nRow, nRow, nCtlHeight);
1048 if ( nLatHeight == 0 )
1050 nOptimalMinRowHeight);
1051 if (nLatHeight > rHeights.
GetValue(nRow))
1052 rHeights.
SetValue(nRow, nRow, nLatHeight);
1063 for (
const auto& rSpan : aSpans)
1065 for (
SCROW nRow = rSpan.mnRow1; nRow <= rSpan.mnRow2; ++nRow)
1073 sal_uInt16 nHeight =
static_cast<sal_uInt16
>(
1078 double(std::numeric_limits<sal_uInt16>::max())));
1079 if (nHeight > rHeights.
GetValue(nRow))
1080 rHeights.
SetValue(nRow, nRow, nHeight);
1082 if (pPattern != pOldPattern)
1084 pPattern = aIter.
Resync( nRow, nStart, nEnd);
1100 pPattern = aIter.
Next(nStart,nEnd);
1107 sc::CellStoreType::const_iterator it =
maCells.position(nRow).first;
1108 mdds::mtv::element_t
eType = it->type;
1122 if (!rDocument.
ValidRow(nRow) || nRow > lastDataPos )
1129 it =
maCells.position(it, nRow).first;
1144 it =
maCells.position(it, nRow).first;
1173 std::vector<StrEntry> maStrEntries;
1179 void commitStrings()
1182 sc::CellStoreType::iterator it =
mrCells.begin();
1183 for (
const auto& rStrEntry : maStrEntries)
1184 it =
mrCells.set(it, rStrEntry.mnRow, rPool.
intern(rStrEntry.maStr));
1188class RemoveEditAttribsHandler :
public StrEntries
1190 std::unique_ptr<ScFieldEditEngine> mpEngine;
1207 mpEngine->SetControlWord(mpEngine->GetControlWord() | EEControlBits::ONLINESPELLING);
1210 mpEngine->SetTextCurrentDefaults(*pObj);
1211 sal_Int32 nParCount = mpEngine->GetParagraphCount();
1212 for (sal_Int32 nPar=0; nPar<nParCount; nPar++)
1214 mpEngine->RemoveCharAttribs(nPar);
1215 const SfxItemSet& rOld = mpEngine->GetParaAttribs(nPar);
1219 mpEngine->SetParaAttribs( nPar, aNew );
1223 mpEngine->RemoveFields();
1225 bool bSpellErrors = mpEngine->HasOnlineSpellErrors();
1226 bool bNeedObject = bSpellErrors || nParCount>1;
1232 EEControlBits nWantBig = bSpellErrors ? EEControlBits::ALLOWBIGOBJS : EEControlBits::NONE;
1233 if ( ( nCtrl & EEControlBits::ALLOWBIGOBJS ) != nWantBig )
1234 mpEngine->SetControlWord( (nCtrl & ~EEControlBits::ALLOWBIGOBJS) | nWantBig );
1238 pObj = mpEngine->CreateTextObject().release();
1244 maStrEntries.emplace_back(nRow, aText);
1249class TestTabRefAbsHandler
1254 explicit TestTabRefAbsHandler(
SCTAB nTab) : mnTab(nTab), mbTestResult(false) {}
1258 if (
const_cast<ScFormulaCell*
>(pCell)->TestTabRefAbs(mnTab))
1259 mbTestResult =
true;
1262 bool getTestResult()
const {
return mbTestResult; }
1274 aFunc.commitStrings();
1279 TestTabRefAbsHandler aFunc(nTable);
1281 return aFunc.getTestResult();
1298 const sc::CellStoreType::value_type& node,
size_t ,
size_t nDataSize)
1306 size_t getCount()
const {
return mnCount; }
1315 return aFunc.getCount();
1320 std::pair<sc::CellStoreType::const_iterator,size_t> aPos =
maCells.position(nRow);
1321 sc::CellStoreType::const_iterator it = aPos.first;
1331 std::pair<sc::CellStoreType::const_iterator,size_t> aPos =
maCells.position(nStartRow);
1332 sc::CellStoreType::const_iterator it = aPos.first;
1342 SCROW nNextRow = nStartRow + it->size - aPos.second;
1343 return nEndRow < nNextRow;
1348 std::pair<sc::CellNoteStoreType::const_iterator,size_t> aPos =
maCellNotes.position(nStartRow);
1349 sc::CellNoteStoreType::const_iterator it = aPos.first;
1359 SCROW nNextRow = nStartRow + it->size - aPos.second;
1360 return nEndRow < nNextRow;
1371 size_t nLength = nEndRow - nStartRow + 1;
1372 std::pair<sc::CellStoreType::const_iterator,size_t> aPos =
maCells.position(nStartRow);
1373 sc::CellStoreType::const_iterator it = aPos.first;
1379 size_t nThisLen = it->size - aPos.second;
1380 return std::min(nThisLen,
nLength);
1386 size_t nLength = nEndRow - nStartRow + 1;
1387 std::pair<sc::CellStoreType::const_iterator,size_t> aPos =
maCells.position(nEndRow);
1388 sc::CellStoreType::const_iterator it = aPos.first;
1394 size_t nThisLen = aPos.second + 1;
1395 return std::min(nThisLen,
nLength);
1410 sc::CellStoreType::const_iterator it =
maCells.begin();
1422 sc::CellStoreType::const_reverse_iterator it =
maCells.rbegin();
1431 nLastRow = std::min( nLastRow,
GetDoc().MaxRow());
1433 if (pDataAreaExtras && pDataAreaExtras->
mnEndRow < nLastRow)
1439 pDataAreaExtras->
mnEndRow = nLastRow;
1442 sc::CellStoreType::const_position_type aPos =
maCells.position(nLastRow);
1447 if (aPos.first ==
maCells.begin())
1451 return static_cast<SCROW>(aPos.first->position - 1);
1456 std::pair<sc::CellStoreType::const_iterator,size_t> aPos =
maCells.position(rRow);
1457 sc::CellStoreType::const_iterator it = aPos.first;
1467 rRow -= aPos.second + 1;
1502 std::pair<sc::CellStoreType::const_iterator,size_t> aPos = maCells.position(rRow);
1503 sc::CellStoreType::const_iterator it = aPos.first;
1504 if (it == maCells.end())
1510 rRow += it->size - aPos.second;
1512 if (it == maCells.end())
1520 if (aPos.second < it->size - 1)
1528 rRow += it->size - aPos.second;
1530 if (it == maCells.end())
1539 if (it == maCells.end())
1548 assert(rRowStart <= rRowEnd);
1549 SCROW nRowStartNew = rRowStart, nRowEndNew = rRowEnd;
1552 std::pair<sc::CellStoreType::const_iterator,size_t> aPos =
maCells.position(rRowStart);
1553 sc::CellStoreType::const_iterator it = aPos.first;
1560 nRowStartNew += it->size - aPos.second;
1561 if (nRowStartNew > rRowEnd)
1570 aPos =
maCells.position(rRowEnd);
1574 rRowStart = nRowStartNew;
1581 assert(it !=
maCells.begin());
1583 nRowEndNew -= aPos.second + 1;
1584 assert(nRowStartNew <= nRowEndNew);
1587 rRowStart = nRowStartNew;
1588 rRowEnd = nRowEndNew;
1600 return std::min<SCROW>(
GetDoc().MaxRow(), nEndRow + 1);
1610 return std::max<SCROW>(0, nStartRow - 1);
1617 sc::CellStoreType::const_iterator& itPos,
SCROW nRow,
bool bForward)
const
1626 bool bHidden = rDocument.
RowHidden(nRow,
nTab,
nullptr, &nEndRow);
1630 if(nRow >=
GetDoc().MaxRow())
1634 std::pair<sc::CellStoreType::const_iterator,size_t> aPos =
maCells.position(itPos, nRow);
1644 nRow += itPos->size - aPos.second - 1;
1646 while (nRow <
GetDoc().MaxRow());
1658 nRow = nStartRow - 1;
1663 std::pair<sc::CellStoreType::const_iterator,size_t> aPos =
maCells.position(itPos, nRow);
1673 nRow -= aPos.second;
1689 assert(sal::static_int_cast<SCROW>(
maCells.size()) ==
GetDoc().GetMaxRowCount()
1690 &&
"Size of the cell array is incorrect." );
1693 &&
"Size of the cell text attribute array is incorrect.");
1696 &&
"Size of the broadcaster array is incorrect.");
1698#if DEBUG_COLUMN_STORAGE
1702 auto itCell = std::find_if(
maCells.begin(),
maCells.end(), lIsEmptyType);
1705 while (itCell !=
maCells.end())
1707 if (itCell->position != itAttr->position || itCell->size != itAttr->size)
1709 cout <<
"ScColumn::CellStorageModified: Cell array and cell text attribute array are out of sync." <<
endl;
1710 cout <<
"-- cell array" <<
endl;
1712 cout <<
"-- attribute array" <<
endl;
1720 itCell = std::find_if(itCell,
maCells.end(), lIsEmptyType);
1728#if DUMP_COLUMN_STORAGE
1732#define DUMP_FORMULA_RESULTS 0
1734struct ColumnStorageDumper
1738 ColumnStorageDumper(
const ScDocument& rDoc ) : mrDoc(rDoc) {}
1740 void operator() (
const sc::CellStoreType::value_type& rNode)
const
1745 cout <<
" * numeric block (pos=" << rNode.position <<
", length=" << rNode.size <<
")" <<
endl;
1748 cout <<
" * string block (pos=" << rNode.position <<
", length=" << rNode.size <<
")" <<
endl;
1751 cout <<
" * edit-text block (pos=" << rNode.position <<
", length=" << rNode.size <<
")" <<
endl;
1754 dumpFormulaBlock(rNode);
1757 cout <<
" * empty block (pos=" << rNode.position <<
", length=" << rNode.size <<
")" <<
endl;
1760 cout <<
" * unknown block" <<
endl;
1764 void dumpFormulaBlock(
const sc::CellStoreType::value_type& rNode)
const
1766 cout <<
" * formula block (pos=" << rNode.position <<
", length=" << rNode.size <<
")" <<
endl;
1767 sc::formula_block::const_iterator it = sc::formula_block::begin(*rNode.data);
1768 sc::formula_block::const_iterator itEnd = sc::formula_block::end(*rNode.data);
1770 for (; it != itEnd; ++it)
1775 cout <<
" * row " << pCell->
aPos.
Row() <<
" not shared" <<
endl;
1776 printFormula(pCell);
1783 cout <<
" * row " << pCell->
aPos.
Row() <<
" shared with top row "
1790 cout <<
" * group: start=" << pCell->
aPos.
Row() <<
", length=" << nLen <<
endl;
1791 printFormula(pCell);
1796 for (
SCROW i = 0;
i < nLen-1; ++
i, ++it)
1809 cout <<
" * formula: " << aFormula <<
endl;
1812#if DUMP_FORMULA_RESULTS
1816 cout <<
" * result: ";
1820 cout << aRes.
mfValue <<
" (type: value)";
1826 cout <<
"error (" <<
static_cast<int>(aRes.
mnError) <<
")";
1847 cout <<
"-- table: " <<
nTab <<
"; column: " <<
nCol <<
endl;
1849 cout <<
"--" <<
endl;
1860 size_t nBlockStart = 0, nRowPos =
static_cast<size_t>(nRow1);
1861 itBlk = std::find_if(itBlk, itBlkEnd, [&nRowPos, &nBlockStart](
const auto& rAttr) {
1862 return nBlockStart <= nRowPos && nRowPos < nBlockStart + rAttr.size; });
1864 if (itBlk == itBlkEnd)
1869 size_t nOffsetInBlock = nRowPos - nBlockStart;
1871 nRowPos =
static_cast<size_t>(nRow2);
1874 sc::celltextattr_block::const_iterator itData, itDataEnd;
1875 for (; itBlk != itBlkEnd; ++itBlk, nBlockStart = nBlockEnd, nOffsetInBlock = 0)
1877 nBlockEnd = nBlockStart + itBlk->size;
1881 if (nBlockStart <= nRowPos && nRowPos < nBlockEnd)
1883 rDestCol.
maCellTextAttrs.set_empty(nBlockStart + nOffsetInBlock, nRowPos);
1885 rDestCol.
maCellTextAttrs.set_empty(nBlockStart + nOffsetInBlock, nBlockEnd-1);
1891 itData = sc::celltextattr_block::begin(*itBlk->data);
1892 itDataEnd = sc::celltextattr_block::end(*itBlk->data);
1893 std::advance(itData, nOffsetInBlock);
1895 if (nBlockStart <= nRowPos && nRowPos < nBlockEnd)
1898 size_t nOffset = nRowPos - nBlockStart + 1;
1899 itDataEnd = sc::celltextattr_block::begin(*itBlk->data);
1900 std::advance(itDataEnd, nOffset);
1902 rDestCol.
maCellTextAttrs.set(nBlockStart + nOffsetInBlock, itData, itDataEnd);
1906 rDestCol.
maCellTextAttrs.set(nBlockStart + nOffsetInBlock, itData, itDataEnd);
1912class CopyCellNotesHandler
1916 sc::CellNoteStoreType::iterator miPos;
1922 bool mbCloneCaption;
1925 CopyCellNotesHandler(
const ScColumn& rSrcCol,
ScColumn& rDestCol,
SCROW nDestOffset,
bool bCloneCaption ) :
1926 mrDestCol(rDestCol),
1927 mrDestNotes(rDestCol.GetCellNoteStore()),
1928 miPos(mrDestNotes.
begin()),
1929 mnSrcTab(rSrcCol.GetTab()),
1930 mnSrcCol(rSrcCol.GetCol()),
1931 mnDestTab(rDestCol.GetTab()),
1932 mnDestCol(rDestCol.GetCol()),
1933 mnDestOffset(nDestOffset),
1934 mbCloneCaption(bCloneCaption) {}
1936 void operator() (
size_t nRow,
const ScPostIt* p )
1938 SCROW nDestRow = nRow + mnDestOffset;
1939 ScAddress aSrcPos(mnSrcCol, nRow, mnSrcTab);
1940 ScAddress aDestPos(mnDestCol, nDestRow, mnDestTab);
1941 ScPostIt* pNew =
p->Clone(aSrcPos, mrDestCol.
GetDoc(), aDestPos, mbCloneCaption).release();
1942 miPos = mrDestNotes.set(miPos, nDestRow, pNew);
1958 bool bWasLocked = bool();
1963 bWasLocked = pDrawLayer->
isLocked();
1966 CopyCellNotesHandler aFunc(*
this, rDestCol, nRowOffsetDest, bCloneCaption);
1969 pDrawLayer->
setLock(bWasLocked);
1973 bool bCloneCaption,
SCROW nRowOffsetDest )
const
2001 sc::broadcaster_block::iterator it = sc::broadcaster_block::begin(*rBroadcaster.data);
2002 sc::broadcaster_block::iterator itEnd = sc::broadcaster_block::end(*rBroadcaster.data);
2003 for (; it != itEnd; ++it)
2004 (*it)->PrepareForDestruction();
2011struct BroadcasterNoListenersPredicate
2026 BroadcasterNoListenersPredicate predicate;
2027 sc::SetElementsToEmpty1<sc::broadcaster_block>(
maBroadcasters, predicate );
2036class DeletingSparklinesHandler
2043 : m_rDocument(rDocument)
2070 DeletingSparklinesHandler aFunction(
GetDoc(),
nTab);
2081 DeletingSparklinesHandler aFunction(
GetDoc(),
nTab);
2090 std::pair<sc::SparklineStoreType::const_iterator,size_t> aPos =
maSparklines.position(nStartRow);
2091 sc::SparklineStoreType::const_iterator it = aPos.first;
2099 SCROW nNextRow = nStartRow + it->size - aPos.second;
2100 return nEndRow < nNextRow;
2106class CopySparklinesHandler
2110 sc::SparklineStoreType::iterator miDestPosition;
2114 CopySparklinesHandler(
ScColumn& rDestColumn,
SCROW nDestOffset)
2115 : mrDestColumn(rDestColumn)
2116 , mrDestSparkline(mrDestColumn.GetSparklineStore())
2117 , miDestPosition(mrDestSparkline.
begin())
2118 , mnDestOffset(nDestOffset)
2123 SCROW nDestRow = nRow + mnDestOffset;
2128 auto& rDestDoc = mrDestColumn.
GetDoc();
2130 if (!pDestinationGroup)
2131 pDestinationGroup = std::make_shared<sc::SparklineGroup>(*pGroup);
2132 auto pNewSparkline = std::make_shared<sc::Sparkline>(mrDestColumn.
GetCol(), nDestRow, pDestinationGroup);
2133 pNewSparkline->setInputRange(pSparkline->getInputRange());
2135 auto* pList = rDestDoc.GetSparklineList(mrDestColumn.
GetTab());
2136 pList->addSparkline(pNewSparkline);
2138 miDestPosition = mrDestSparkline.set(miDestPosition, nDestRow,
new sc::SparklineCell(pNewSparkline));
2150 CopySparklinesHandler aFunctor(rDestCol, nRowOffsetDest);
2174 maxRow = rSparkline.position + rSparkline.size - 1;
2183 [](
const auto& rSparkline)
2185 return rSparkline.type == sc::element_type_sparkline;
2188 minRow = it->position;
2212 return sc::cellnote_block::at(*aPos.first->data, aPos.second);
2227 class CellNoteHandler
2231 const bool m_bForgetCaptionOwnership;
2234 CellNoteHandler(
const ScDocument* pDocument,
const ScAddress& rPos,
bool bForgetCaptionOwnership) :
2235 m_pDocument(pDocument),
2237 m_bForgetCaptionOwnership(bForgetCaptionOwnership) {}
2239 void operator() (
size_t nRow,
ScPostIt* p )
2241 if (m_bForgetCaptionOwnership)
2256 CellNoteHandler aFunc(&
GetDoc(), aAddr, bForgetCaptionOwnership);
2282 maxRow = rCellNote.position + rCellNote.size -1;
2291 [](
const auto& rCellNote) { return rCellNote.type == sc::element_type_cellnote; });
2293 minRow = it->position;
2304 sc::CellTextAttrStoreType::position_type aPos =
maCellTextAttrs.position(nRow);
2309 sc::celltextattr_block::at(*aPos.first->data, aPos.second).mnTextWidth = nWidth;
2316 return SvtScriptType::NONE;
2322 sc::CellTextAttrStoreType::iterator& itPos,
SCROW nRow1,
SCROW nRow2,
const sc::CellStoreType::iterator& itrCells_ )
2325 return SvtScriptType::NONE;
2328 std::pair<sc::CellTextAttrStoreType::iterator,size_t> aRet =
2332 sc::CellStoreType::iterator itrCells = itrCells_;
2335 bool bUpdated =
false;
2338 sc::celltextattr_block::iterator it = sc::celltextattr_block::begin(*itPos->data);
2339 sc::celltextattr_block::iterator itEnd = sc::celltextattr_block::end(*itPos->data);
2340 std::advance(it, aRet.second);
2341 for (; it != itEnd; ++it, ++nRow)
2355 nRow += itPos->size - aRet.second;
2358 while (nRow <= nRow2)
2367 nRow += itPos->size;
2371 sc::celltextattr_block::iterator it = sc::celltextattr_block::begin(*itPos->data);
2372 sc::celltextattr_block::iterator itEnd = sc::celltextattr_block::end(*itPos->data);
2373 for (; it != itEnd; ++it, ++nRow)
2397 sc::CellTextAttrStoreType::position_type aPos =
maCellTextAttrs.position(nRow);
2402 sc::celltextattr_block::at(*aPos.first->data, aPos.second).mnScriptType =
nType;
2408 std::pair<sc::CellStoreType::iterator,size_t> aPos =
maCells.position(nRow);
2409 sc::CellStoreType::iterator it = aPos.first;
2418 double fVal = sc::numeric_block::at(*it->data, aPos.second);
2423 ScFormulaCell*
p = sc::formula_block::at(*it->data, aPos.second);
2436 const EditTextObject* pText = sc::edittext_block::at(*it->data, aPos.second);
2450class ToMatrixHandler
2459 mrMat(rMat), mnMatCol(nMatCol), mnTopRow(nTopRow),
2460 mpDoc(pDoc), mrStrPool(pDoc->GetSharedStringPool()) {}
2462 void operator() (
size_t nRow,
double fVal)
2464 mrMat.
PutDouble(fVal, mnMatCol, nRow - mnTopRow);
2479 mrMat.
PutString(rSS, mnMatCol, nRow - mnTopRow);
2495 ToMatrixHandler aFunc(rMat, nMatCol, nRow1, &
GetDoc());
2508 std::vector<double> maNumVals;
2509 std::vector<svl::SharedString> maStrVals;
2511 CellBucket() : mnEmpValStart(0), mnNumValStart(0), mnStrValStart(0), mnEmpValCount(0) {}
2520 else if (!maNumVals.empty())
2522 const double*
p = maNumVals.data();
2523 rMat.
PutDouble(p, maNumVals.size(), nCol, mnNumValStart);
2526 else if (!maStrVals.empty())
2529 rMat.
PutString(p, maStrVals.size(), nCol, mnStrValStart);
2536 mnEmpValStart = mnNumValStart = mnStrValStart = 0;
2543class FillMatrixHandler
2555 mrMat(rMat), mnMatCol(nMatCol), mnTopRow(nTopRow),
2556 mpDoc(pDoc), mrPool(pDoc->GetSharedStringPool()), mpPool(pPool) {}
2558 void operator() (
const sc::CellStoreType::value_type& node,
size_t nOffset,
size_t nDataSize)
2560 size_t nMatRow = node.position + nOffset - mnTopRow;
2566 const double*
p = &sc::numeric_block::at(*node.data, nOffset);
2567 mrMat.
PutDouble(p, nDataSize, mnMatCol, nMatRow);
2575 mrMat.
PutString(p, nDataSize, mnMatCol, nMatRow);
2579 std::vector<svl::SharedString> aStrings;
2580 aStrings.reserve(nDataSize);
2582 for (
size_t i = 0;
i < nDataSize; ++
i)
2584 aStrings.push_back(mpPool->
intern(p[i].getString()));
2586 mrMat.
PutString(aStrings.data(), aStrings.size(), mnMatCol, nMatRow);
2592 std::vector<svl::SharedString> aSSs;
2593 aSSs.reserve(nDataSize);
2594 sc::edittext_block::const_iterator it = sc::edittext_block::begin(*node.data);
2595 std::advance(it, nOffset);
2596 sc::edittext_block::const_iterator itEnd = it;
2597 std::advance(itEnd, nDataSize);
2598 for (; it != itEnd; ++it)
2602 aSSs.push_back(mrPool.
intern(aStr));
2604 aSSs.push_back(mpPool->
intern(aStr));
2608 mrMat.
PutString(p, nDataSize, mnMatCol, nMatRow);
2614 sc::formula_block::const_iterator it = sc::formula_block::begin(*node.data);
2615 std::advance(it, nOffset);
2616 sc::formula_block::const_iterator itEnd = it;
2617 std::advance(itEnd, nDataSize);
2619 size_t nPrevRow = 0, nThisRow = node.position + nOffset;
2620 for (; it != itEnd; ++it, nPrevRow = nThisRow, ++nThisRow)
2626 if (aBucket.mnEmpValCount && nThisRow == nPrevRow + 1)
2629 ++aBucket.mnEmpValCount;
2634 aBucket.flush(mrMat, mnMatCol);
2635 aBucket.mnEmpValStart = nThisRow - mnTopRow;
2636 ++aBucket.mnEmpValCount;
2645 if (nErr != FormulaError::NONE)
2648 if (!aBucket.maNumVals.empty() && nThisRow == nPrevRow + 1)
2651 aBucket.maNumVals.push_back(fVal);
2656 aBucket.flush(mrMat, mnMatCol);
2657 aBucket.mnNumValStart = nThisRow - mnTopRow;
2658 aBucket.maNumVals.push_back(fVal);
2666 if (!aBucket.maStrVals.empty() && nThisRow == nPrevRow + 1)
2669 aBucket.maStrVals.push_back(aStr);
2674 aBucket.flush(mrMat, mnMatCol);
2675 aBucket.mnStrValStart = nThisRow - mnTopRow;
2676 aBucket.maStrVals.push_back(aStr);
2680 aBucket.flush(mrMat, mnMatCol);
2693 FillMatrixHandler aFunc(rMat, nMatCol, nRow1, &
GetDoc(), pPool);
2699template<
typename Blk>
2700void getBlockIterators(
2701 const sc::CellStoreType::iterator& it,
size_t& rLenRemain,
2702 typename Blk::iterator& rData,
typename Blk::iterator& rDataEnd )
2704 rData = Blk::begin(*it->data);
2705 if (rLenRemain >= it->size)
2708 rDataEnd = Blk::end(*it->data);
2709 rLenRemain -= it->size;
2714 std::advance(rDataEnd, rLenRemain);
2721 size_t nPos,
size_t nArrayLen,
const sc::CellStoreType::iterator& _it,
const sc::CellStoreType::iterator& itEnd )
2724 size_t nLenRemain = nArrayLen -
nPos;
2726 for (sc::CellStoreType::iterator it = _it; it != itEnd; ++it)
2732 sc::string_block::iterator itData, itDataEnd;
2733 getBlockIterators<sc::string_block>(it, nLenRemain, itData, itDataEnd);
2736 for (; itData != itDataEnd; ++itData, ++
nPos)
2742 sc::edittext_block::iterator itData, itDataEnd;
2743 getBlockIterators<sc::edittext_block>(it, nLenRemain, itData, itDataEnd);
2746 for (; itData != itDataEnd; ++itData, ++
nPos)
2755 sc::formula_block::iterator itData, itDataEnd;
2756 getBlockIterators<sc::formula_block>(it, nLenRemain, itData, itDataEnd);
2765 bool bTempDisableProgress = pProgress && pProgress->
Enabled();
2766 if (bTempDisableProgress)
2769 for (; itData != itDataEnd; ++itData, ++
nPos)
2777 if (aRes.
mnError == FormulaError::CircularReference)
2798 if (bTempDisableProgress)
2804 if (nLenRemain > it->size)
2807 nLenRemain -= it->size;
2818 sc::numeric_block::iterator itData, itDataEnd;
2819 getBlockIterators<sc::numeric_block>(it, nLenRemain, itData, itDataEnd);
2822 for (; itData != itDataEnd; ++itData, ++
nPos)
2837void copyFirstStringBlock(
2840 sc::FormulaGroupContext::StrArrayType::iterator itArray = rArray.begin();
2842 switch (itBlk->type)
2846 sc::string_block::iterator it = sc::string_block::begin(*itBlk->data);
2847 sc::string_block::iterator itEnd = it;
2848 std::advance(itEnd, nLen);
2849 for (; it != itEnd; ++it, ++itArray)
2850 *itArray = it->getData();
2855 sc::edittext_block::iterator it = sc::edittext_block::begin(*itBlk->data);
2856 sc::edittext_block::iterator itEnd = it;
2857 std::advance(itEnd, nLen);
2860 for (; it != itEnd; ++it, ++itArray)
2874copyFirstFormulaBlock(
2878 size_t nLen = std::min(itBlk->size, nArrayLen);
2880 sc::formula_block::iterator it = sc::formula_block::begin(*itBlk->data);
2881 sc::formula_block::iterator itEnd;
2887 std::advance(itEnd, nLen);
2889 for (; it != itEnd; ++it, ++
nPos)
2895 if (aRes.
mnError == FormulaError::CircularReference)
2909 std::make_unique<sc::FormulaGroupContext::NumArrayType>(nArrayLen,
2910 std::numeric_limits<double>::quiet_NaN()));
2921 std::make_unique<sc::FormulaGroupContext::StrArrayType>(nArrayLen,
nullptr));
2929 if (!pNumArray && !pStrArray)
2936struct NonNullStringFinder
2938 bool operator() (
const rtl_uString* p)
const {
return p !=
nullptr; }
2944 sc::FormulaGroupContext::StrArrayType::const_iterator it = rArray.begin();
2945 std::advance(it, nRow1);
2946 sc::FormulaGroupContext::StrArrayType::const_iterator itEnd = it;
2947 std::advance(itEnd, nRow2-nRow1+1);
2948 return std::any_of(it, itEnd, NonNullStringFinder());
2951struct ProtectFormulaGroupContext
2954 : doc(
d ) { doc->BlockFormulaGroupContextDiscard(
true ); }
2955 ~ProtectFormulaGroupContext()
2956 { doc->BlockFormulaGroupContextDiscard(
false ); }
2973 const double* pNum =
nullptr;
2977 rtl_uString** pStr =
nullptr;
2988 ProtectFormulaGroupContext protectContext(&
GetDoc());
2991 sc::CellStoreType::iterator itBlk =
maCells.begin();
2992 switch (itBlk->type)
2999 const double*
p = &sc::numeric_block::at(*itBlk->data, nRow1);
3004 sc::numeric_block::const_iterator it = sc::numeric_block::begin(*itBlk->data);
3005 sc::numeric_block::const_iterator itEnd = sc::numeric_block::end(*itBlk->data);
3007 std::make_unique<sc::FormulaGroupContext::NumArrayType>(it, itEnd));
3010 rArray.resize(nRow2+1, std::numeric_limits<double>::quiet_NaN());
3018 size_t nPos = itBlk->size;
3020 if (!appendToBlock(&rDocument, rCxt, *pColArray,
nPos, nRow2+1, itBlk,
maCells.end()))
3026 rtl_uString** pStr =
nullptr;
3037 std::make_unique<sc::FormulaGroupContext::StrArrayType>(nRow2+1,
nullptr));
3047 copyFirstStringBlock(rDocument, rArray, nRow2+1, itBlk);
3051 copyFirstStringBlock(rDocument, rArray, itBlk->size, itBlk);
3054 size_t nPos = itBlk->size;
3056 if (!appendToBlock(&rDocument, rCxt, *pColArray,
nPos, nRow2+1, itBlk,
maCells.end()))
3064 rtl_uString** pStr =
nullptr;
3065 if (hasNonEmpty(*pColArray->
mpStrArray, nRow1, nRow2))
3080 pColArray = copyFirstFormulaBlock(rCxt, itBlk, nRow2+1,
nTab,
nCol);
3085 const double* pNum =
nullptr;
3086 rtl_uString** pStr =
nullptr;
3095 pColArray = copyFirstFormulaBlock(rCxt, itBlk, nRow2+1,
nTab,
nCol);
3102 size_t nPos = itBlk->size;
3104 if (!appendToBlock(&rDocument, rCxt, *pColArray,
nPos, nRow2+1, itBlk,
maCells.end()))
3110 const double* pNum =
nullptr;
3111 rtl_uString** pStr =
nullptr;
3124 std::make_unique<sc::FormulaGroupContext::NumArrayType>(nRow2+1,
3125 std::numeric_limits<double>::quiet_NaN()));
3136 size_t nPos = itBlk->size;
3138 if (!appendToBlock(&rDocument, rCxt, *pColArray,
nPos, nRow2+1, itBlk,
maCells.end()))
3159 size_t nOffset,
size_t nDataSize )
3165 sc::formula_block::const_iterator it = sc::formula_block::begin(*node.data);
3166 std::advance(it, nOffset);
3167 sc::formula_block::const_iterator itEnd = it;
3168 std::advance(itEnd, nDataSize);
3169 for (; it != itEnd; ++it)
3180 assert(nRow2 >= nRow1);
3187 sc::CellStoreType::position_type aPos =
maCells.position(nRow);
3188 sc::CellStoreType::iterator it = aPos.first;
3196 size_t nBlockLen = it->size - aPos.second;
3197 if (nBlockLen < nLen)
3204 sc::formula_block::iterator itCell = sc::formula_block::begin(*it->data);
3205 std::advance(itCell, aPos.second);
3207 const double* pResEnd = pResults + nLen;
3208 for (; pResults != pResEnd; ++pResults, ++itCell)
3212 if (nErr != FormulaError::NONE)
3222 unsigned nThisThread,
unsigned nThreadsTotal)
3224 assert(
GetDoc().IsThreadedGroupCalcInProgress());
3226 sc::CellStoreType::position_type aPos =
maCells.position(nRow);
3227 sc::CellStoreType::iterator it = aPos.first;
3235 size_t nBlockLen = it->size - aPos.second;
3236 if (nBlockLen < nLen)
3243 sc::formula_block::iterator itCell = sc::formula_block::begin(*it->data);
3244 std::advance(itCell, aPos.second);
3246 for (
size_t i = 0;
i < nLen; ++
i, ++itCell)
3248 if (nThreadsTotal > 0 && ((
i + nOffset) % nThreadsTotal) != nThisThread)
3262 sc::CellStoreType::position_type aPos =
maCells.position(nRow);
3263 sc::CellStoreType::iterator it = aPos.first;
3271 size_t nBlockLen = it->size - aPos.second;
3272 if (nBlockLen < nLen)
3279 sc::formula_block::iterator itCell = sc::formula_block::begin(*it->data);
3280 std::advance(itCell, aPos.second);
3282 for (
size_t i = 0;
i < nLen; ++
i, ++itCell)
3302 std::pair<sc::CellStoreType::const_iterator,size_t> aPos =
maCells.position(nRow);
3303 sc::CellStoreType::const_iterator it = aPos.first;
3317 rBlockSize = it->size;
3318 return &sc::formula_block::at(*it->data, aPos.second);
3323 size_t nBlockSize = 0;
3325 return pp ? *pp :
nullptr;
3334 std::pair<sc::CellStoreType::const_iterator,size_t> aPos =
maCells.position(rRow);
3335 sc::CellStoreType::const_iterator it = aPos.first;
3349 aPos =
maCells.position(it, nNextRow);
3359 SCROW nLastRow = nNextRow;
3363 if (nNextRow == nLastRow)
3366 aPos =
maCells.position(it, nNextRow);
3369 nLastRow = nNextRow;
3378 if (pDataAreaExtras)
3387 if (pDataAreaExtras)
3390 std::pair<sc::CellStoreType::const_iterator,size_t> aPos =
maCells.position(rBlockPos.
miCellPos, nRow);
3391 if (aPos.first ==
maCells.end())
3400 if (pDataAreaExtras)
3403 std::pair<sc::CellStoreType::iterator,size_t> aPos =
maCells.position(rBlockPos.
miCellPos, nRow);
3404 if (aPos.first ==
maCells.end())
3422 if (rDataAreaExtras.
mnEndRow < nRow)
3429class FindUsedRowsHandler
3431 typedef mdds::flat_segment_tree<SCROW,bool> UsedRowsType;
3432 UsedRowsType& mrUsed;
3433 UsedRowsType::const_iterator miUsed;
3435 explicit FindUsedRowsHandler(UsedRowsType& rUsed) : mrUsed(rUsed), miUsed(rUsed.
begin()) {}
3437 void operator() (
const sc::CellStoreType::value_type& node,
size_t nOffset,
size_t nDataSize)
3442 SCROW nRow1 = node.position + nOffset;
3443 SCROW nRow2 = nRow1 + nDataSize - 1;
3444 miUsed = mrUsed.insert(miUsed, nRow1, nRow2+1,
true).first;
3452 FindUsedRowsHandler aFunc(rUsed);
3462 switch (itBlockPos->type)
3467 SvtBroadcaster* pBC = sc::broadcaster_block::at(*itBlockPos->data, nElemPos);
3476 itBlockPos = rStore.set(itBlockPos, nRow, pBC);
3480 assert(
false &&
"wrong block type encountered in the broadcaster storage.");
3488 std::pair<sc::BroadcasterStoreType::iterator,size_t> aPos =
maBroadcasters.position(nRow);
3489 startListening(
maBroadcasters, aPos.first, aPos.second, nRow, rLst);
3501 if(
GetDoc().IsDelayedDeletingBroadcasters())
3517 sc::BroadcasterStoreType::iterator& it =
p->miBroadcasterPos;
3518 std::pair<sc::BroadcasterStoreType::iterator,size_t> aPos =
maBroadcasters.position(it, rAddress.
Row());
3529 sc::BroadcasterStoreType::iterator& it =
p->miBroadcasterPos;
3530 std::pair<sc::BroadcasterStoreType::iterator,size_t> aPos =
maBroadcasters.position(it, rAddress.
Row());
3535 SvtBroadcaster* pBC = sc::broadcaster_block::at(*it->data, aPos.second);
3546class CompileDBFormulaHandler
3556 p->CompileDBFormula(mrCxt);
3560struct CompileColRowNameFormulaHandler
3568 p->CompileColRowNameFormula(mrCxt);
3576 CompileDBFormulaHandler aFunc(rCxt);
3583 CompileColRowNameFormulaHandler aFunc(rCxt);
3590class UpdateSubTotalHandler
3594 void update(
double fVal,
bool bVal)
3599 switch (
mrData.getFunc())
3613 void operator() (
size_t ,
double fVal)
3635 if (pCell->
GetErrCode() != FormulaError::NONE)
3661 if (aSpanSet.
empty())
3667 while (nRow <=
GetDoc().MaxRow())
3674 aSpanSet.
set(nRow, aRange.
mnRow2,
false);
3676 nRow = aRange.
mnRow2 + 1;
3687 for (
const auto& rSpan : aSpans)
3688 rData.
update( rSpan.mnRow2 - rSpan.mnRow1 + 1);
3694 sc::CellStoreType::const_iterator itCellPos =
maCells.begin();
3695 UpdateSubTotalHandler aFunc(rData);
3696 for (
const auto& rSpan : aSpans)
3699 itCellPos,
maCells, rSpan.mnRow1, rSpan.mnRow2, aFunc);
3706 sc::CellStoreType::const_iterator itCellPos =
maCells.begin();
3707 UpdateSubTotalHandler aFunc(rData);
3708 for (
const auto& rSpan : aSpans)
3711 itCellPos,
maCells, rSpan.mnRow1, rSpan.mnRow2, aFunc);
3719class WeightedCounter
3723 WeightedCounter() :
mnCount(0) {}
3725 void operator() (
const sc::CellStoreType::value_type& node)
3730 static sal_uLong getWeight(
const sc::CellStoreType::value_type& node)
3740 return std::accumulate(sc::formula_block::begin(*node.data), sc::formula_block::end(*node.data),
size_t(0),
3741 [](
const size_t& rCount,
const ScFormulaCell* p) { return rCount + 5 + p->GetCode()->GetCodeLen(); });
3745 return node.size * 50;
3754class WeightedCounterWithRows
3756 const SCROW mnStartRow;
3757 const SCROW mnEndRow;
3761 WeightedCounterWithRows(
SCROW nStartRow,
SCROW nEndRow)
3762 : mnStartRow(nStartRow)
3768 void operator() (
const sc::CellStoreType::value_type& node)
3770 const SCROW nRow1 = node.position;
3771 const SCROW nRow2 = nRow1 + 1;
3773 if ((nRow2 >= mnStartRow) && (nRow1 <= mnEndRow))
3775 mnCount += WeightedCounter::getWeight(node);
3786 const WeightedCounter aFunc = std::for_each(
maCells.begin(),
maCells.end(),
3788 return aFunc.getCount();
3793 const WeightedCounterWithRows aFunc = std::for_each(
maCells.begin(),
maCells.end(),
3794 WeightedCounterWithRows(nStartRow, nEndRow));
3795 return aFunc.getCount();
3808 mnCount +=
p->GetCode()->GetCodeLen();
3811 sal_uInt64 getCount()
const {
return mnCount; }
3820 return aFunc.getCount();
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)
sal_uInt16 GetValue() const
sal_Int32 GetNumerator() const
sal_Int32 GetDenominator() const
static css::uno::Reference< css::linguistic2::XHyphenator > GetHyphenator()
MapUnit GetMapUnit() const
const vcl::Font & GetFont() const
void SetFont(const vcl::Font &rNewFont)
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
tools::Long GetTextWidth(const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, vcl::text::TextLayoutCache const *=nullptr, SalLayoutGlyphs const *const pLayoutCache=nullptr) const
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
const MapMode & GetMapMode() const
tools::Long GetTextHeight() const
OutDevType GetOutDevType() const
const ScPatternAttr * Next(SCROW &rTop, SCROW &rBottom)
const ScPatternAttr * Resync(SCROW nRow, SCROW &rTop, SCROW &rBottom)
std::unique_ptr< ScAttrArray > pAttrArray
bool HasAttrib(SCROW nRow1, SCROW nRow2, HasAttrFlags nMask) const
void DeleteCellNotes(sc::ColumnBlockPosition &rBlockPos, SCROW nRow1, SCROW nRow2, bool bForgetCaptionOwnership)
void DeleteBroadcasters(sc::ColumnBlockPosition &rBlockPos, SCROW nRow1, SCROW nRow2)
void CreateSparklineCell(SCROW nRow, std::shared_ptr< sc::Sparkline > const &pSparkline)
SCROW GetFirstDataPos() const
void CellStorageModified()
Called whenever the state of cell array gets modified i.e.
void CopyCellTextAttrsToDocument(SCROW nRow1, SCROW nRow2, ScColumn &rDestCol) const
void UpdateSelectionFunction(const ScRangeList &rRanges, ScFunctionData &rData, const ScFlatBoolRowSegments &rHiddenRows)
bool IsNotesEmptyBlock(SCROW nStartRow, SCROW nEndRow) const
sc::CellTextAttrStoreType maCellTextAttrs
const ScPatternAttr * GetPattern(SCROW nRow) const
void DuplicateNotes(SCROW nStartRow, size_t nDataSize, ScColumn &rDestCol, sc::ColumnBlockPosition &rDestBlockPos, bool bCloneCaption, SCROW nRowOffsetDest=0) const
bool HasVisibleDataAt(SCROW nRow) const
bool mbEmptyBroadcastersPending
void RegroupFormulaCells(std::vector< ScAddress > *pGroupPos=nullptr)
Regroup formula cells for the entire column.
SCROW FindNextVisibleRowWithContent(sc::CellStoreType::const_iterator &itPos, SCROW nRow, bool bForward) const
ScPostIt * GetCellNote(SCROW nRow)
bool TestTabRefAbs(SCTAB nTable) const
void CompileColRowNameFormula(sc::CompileFormulaContext &rCxt)
SCROW GetSparklinesMinRow() const
SCSIZE VisibleCount(SCROW nStartRow, SCROW nEndRow) const
void DumpColumnStorage() const
void CopyCellSparklinesToDocument(SCROW nRow1, SCROW nRow2, ScColumn &rDestCol, SCROW nRowOffsetDest=0) const
SvtScriptType GetRangeScriptType(sc::CellTextAttrStoreType::iterator &itPos, SCROW nRow1, SCROW nRow2, const sc::CellStoreType::iterator &itr)
Get combined script types of the specified range.
void DuplicateSparklines(SCROW nStartRow, size_t nDataSize, ScColumn &rDestCol, sc::ColumnBlockPosition &rDestBlockPos, SCROW nRowOffsetDest=0) const
void RemoveEditAttribs(sc::ColumnBlockPosition &rBlockPos, SCROW nStartRow, SCROW nEndRow)
sc::CellNoteStoreType maCellNotes
SvtScriptType GetScriptType(SCROW nRow) const
void EndListening(SvtListener &rLst, SCROW nRow)
void FindDataAreaPos(SCROW &rRow, bool bDown) const
bool TrimEmptyBlocks(SCROW &rRowStart, SCROW &rRowEnd) const
void CellNotesDeleting(SCROW nRow1, SCROW nRow2, bool bForgetCaptionOwnership)
void SetNumberFormat(SCROW nRow, sal_uInt32 nNumberFormat)
void AssertNoInterpretNeeded(SCROW nRow1, SCROW nRow2)
void ApplyAttr(SCROW nRow, const SfxPoolItem &rAttr)
void GetOptimalHeight(sc::RowHeightContext &rCxt, SCROW nStartRow, SCROW nEndRow, sal_uInt16 nMinHeight, SCROW nMinStart)
bool HasEditCells(SCROW nStartRow, SCROW nEndRow, SCROW &rFirst)
sal_uInt64 GetWeightedCount() const
void SetFormulaResults(SCROW nRow, const double *pResults, size_t nLen)
void GetDataExtrasAt(SCROW nRow, ScDataAreaExtras &rDataAreaExtras) const
void CompileDBFormula(sc::CompileFormulaContext &rCxt)
tools::Long GetNeededSize(SCROW nRow, OutputDevice *pDev, double nPPTX, double nPPTY, const Fraction &rZoomX, const Fraction &rZoomY, bool bWidth, const ScNeededSizeOptions &rOptions, const ScPatternAttr **pPatternChange, bool bInPrintTwips=false) const
bool HasCellNotes() const
SCROW GetCellNotesMaxRow() const
bool HasSparklines() const
SCROW FindNextVisibleRow(SCROW nRow, bool bForward) const
void CalculateInThread(ScInterpreterContext &rContext, SCROW nRow, size_t nLen, size_t nOffset, unsigned nThisThread, unsigned nThreadsTotal)
bool GetNextDataPos(SCROW &rRow) const
sc::CellStoreType maCells
ScRefCellValue GetCellValue(SCROW nRow) const
formula::VectorRefArray FetchVectorRefArray(SCROW nRow1, SCROW nRow2)
bool UpdateScriptType(sc::CellTextAttr &rAttr, SCROW nRow, sc::CellStoreType::iterator &itr)
bool DeleteSparkline(SCROW nRow)
sal_uInt16 GetOptimalColWidth(OutputDevice *pDev, double nPPTX, double nPPTY, const Fraction &rZoomX, const Fraction &rZoomY, bool bFormula, sal_uInt16 nOldWidth, const ScMarkData *pMarkData, const ScColWidthParam *pParam) const
void CopyCellNotesToDocument(SCROW nRow1, SCROW nRow2, ScColumn &rDestCol, bool bCloneCaption=true, SCROW nRowOffsetDest=0) const
void FillMatrix(ScMatrix &rMat, size_t nMatCol, SCROW nRow1, SCROW nRow2, svl::SharedStringPool *pPool) const
bool IsDrawObjectsEmptyBlock(SCROW nStartRow, SCROW nEndRow) const
void SetCellNote(SCROW nRow, std::unique_ptr< ScPostIt > pNote)
bool GetNextSpellingCell(SCROW &nRow, bool bInSel, const ScMarkData &rData) const
sal_uInt64 GetCodeCount() const
void PrepareBroadcastersForDestruction()
SCROW GetCellNotesMinRow() const
void DeleteEmptyBroadcasters()
void FindUsed(SCROW nStartRow, SCROW nEndRow, mdds::flat_segment_tree< SCROW, bool > &rUsed) const
void DeleteSparklineCells(sc::ColumnBlockPosition &rBlockPos, SCROW nRow1, SCROW nRow2)
bool GetPrevDataPos(SCROW &rRow) const
bool HasVisibleAttrIn(SCROW nStartRow, SCROW nEndRow) const
sc::SparklineCell * GetSparklineCell(SCROW nRow)
formula::FormulaTokenRef ResolveStaticReference(SCROW nRow)
sc::BroadcasterStoreType maBroadcasters
SCROW GetLastDataPos() const
const ScFormulaCell * FetchFormulaCell(SCROW nRow) const
void SetScriptType(SCROW nRow, SvtScriptType nType)
SCROW GetSparklinesMaxRow() const
ScDocument & GetDoc() const
void HandleStuffAfterParallelCalculation(SCROW nRow, size_t nLen, ScInterpreter *pInterpreter)
ScFormulaCell *const * GetFormulaCellBlockAddress(SCROW nRow, size_t &rBlockSize) const
SvtBroadcaster * GetBroadcaster(SCROW nRow)
sc::SparklineStoreType maSparklines
bool HasDataAt(SCROW nRow, ScDataAreaExtras *pDataAreaExtras=nullptr) const
void SetTextWidth(SCROW nRow, sal_uInt16 nWidth)
bool IsSparklinesEmptyBlock(SCROW nStartRow, SCROW nEndRow) const
void StartListening(SvtListener &rLst, SCROW nRow)
sal_uInt16 GetTextWidth(SCROW nRow) const
SCSIZE GetEmptyLinesInBlock(SCROW nStartRow, SCROW nEndRow, ScDirection eDir) const
void SetValue(A nPos, const D &rValue)
const D & GetValue(A nPos) const
static void LOKCommentNotify(LOKCommentNotificationType nType, const ScDocument *pDocument, const ScAddress &rPos, const ScPostIt *pNote)
SC_DLLPUBLIC sal_uInt16 GetRowHeight(SCROW nRow, SCTAB nTab, bool bHiddenAsZero=true) const
SC_DLLPUBLIC sal_uInt16 GetColWidth(SCCOL nCol, SCTAB nTab, bool bHiddenAsZero=true) const
SC_DLLPUBLIC ScPatternAttr * GetDefPattern() const
bool ValidRow(SCROW nRow) const
SC_DLLPUBLIC bool IsTabProtected(SCTAB nTab) const
void DiscardFormulaGroupContext()
SC_DLLPUBLIC SCROW MaxRow() const
std::shared_ptr< sc::FormulaGroupContext > & GetFormulaGroupContext()
sal_uInt16 GetSheetOptimalMinRowHeight(SCTAB nTab) const
SC_DLLPUBLIC SfxItemPool * GetEditPool() const
std::unique_ptr< ScFieldEditEngine > CreateFieldEditEngine()
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
SC_DLLPUBLIC bool RowHidden(SCROW nRow, SCTAB nTab, SCROW *pFirstRow=nullptr, SCROW *pLastRow=nullptr) const
SC_DLLPUBLIC CRFlags GetRowFlags(SCROW nRow, SCTAB nTab) const
SC_DLLPUBLIC std::shared_ptr< sc::SparklineGroup > SearchSparklineGroup(tools::Guid const &rGuid)
void DisposeFieldEditEngine(std::unique_ptr< ScFieldEditEngine > &rpEditEngine)
SC_DLLPUBLIC formula::FormulaGrammar::Grammar GetGrammar() const
SC_DLLPUBLIC svl::SharedStringPool & GetSharedStringPool()
void ApplyAsianEditSettings(ScEditEngineDefaulter &rEngine)
SC_DLLPUBLIC SvtScriptType GetScriptType(SCCOL nCol, SCROW nRow, SCTAB nTab, const ScRefCellValue *pCell=nullptr)
SC_DLLPUBLIC sc::SparklineList * GetSparklineList(SCTAB nTab)
SfxItemSet * GetPreviewFont()
SC_DLLPUBLIC SvNumberFormatter * GetFormatTable() const
SC_DLLPUBLIC sal_uInt16 GetOriginalWidth(SCCOL nCol, SCTAB nTab) const
ScStyleSheet * GetPreviewCellStyle()
SC_DLLPUBLIC const SfxItemSet * GetCondResult(SCCOL nCol, SCROW nRow, SCTAB nTab, ScRefCellValue *pCell=nullptr) const
static OUString GetSpaceDelimitedString(const EditEngine &rEngine)
Retrieves string with paragraphs delimited by spaces.
static SC_DLLPUBLIC OUString GetString(const EditTextObject &rEditText, const ScDocument *pDoc)
Retrieves string with paragraphs delimited by new lines (' ').
bool getRangeData(SCROW nRow, RangeData &rData) const
To calculate a single subtotal function.
ScSubTotalFunc getFunc() const
void update(double fNewVal)
static SC_DLLPUBLIC SvtScriptType GetDefaultScriptType()
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
SCROW GetNextMarked(SCCOL nCol, SCROW nRow, bool bUp) const
May return -1.
bool IsMultiMarked() const
Matrix data type that can store values of mixed types.
void PutString(const svl::SharedString &rStr, SCSIZE nC, SCSIZE nR)
void PutEmptyResultVector(SCSIZE nCount, SCSIZE nC, SCSIZE nR)
Put a column vector of empty results, starting at row nR, must fit into dimensions.
void PutDouble(double fVal, SCSIZE nC, SCSIZE nR)
SCCOL GetColMerge() const
SCROW GetRowMerge() const
bool HasAutoFilter() const
bool IsHorOverlapped() const
bool IsOverlapped() const
bool IsVerOverlapped() const
void SetStyleSheet(ScStyleSheet *pNewStyle, bool bClearDirectFormat=true)
sal_uInt32 GetNumberFormat(SvNumberFormatter *) const
ScRotateDir GetRotateDir(const SfxItemSet *pCondSet) const
static void fillFontOnly(vcl::Font &rFont, const SfxItemSet &rItemSet, const OutputDevice *pOutDev=nullptr, const Fraction *pScale=nullptr, const SfxItemSet *pCondSet=nullptr, SvtScriptType nScript=SvtScriptType::NONE)
Static helper function to fill a font object from the passed item set.
const SfxPoolItem & GetItem(sal_uInt16 nWhichP) const
void FillEditItemSet(SfxItemSet *pEditSet, const SfxItemSet *pCondSet=nullptr) const
Converts all Calc items contained in the own item set to edit engine items and puts them into pEditSe...
static SvxCellOrientation GetCellOrientation(const SfxItemSet &rItemSet, const SfxItemSet *pCondSet)
Additional class containing cell annotation data.
static ScProgress * GetInterpretProgress()
OUString CreateString(sc::TokenStringContext &rCxt, const ScAddress &rPos) const
Create a string representation of formula token array without modifying the internal state of the tok...
Degree100 GetValue() const
const WhichRangesContainer & GetRanges() const
SfxItemPool * GetPool() const
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
constexpr tools::Long Height() const
void setWidth(tools::Long nWidth)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
bool HasListeners() const
bool StartListening(SvtBroadcaster &rBroadcaster)
void EndListening(SvtBroadcaster &rBroadcaster)
sal_uInt32 GetHeight() const
sal_Int16 GetRightMargin() const
sal_Int16 GetTopMargin() const
sal_Int16 GetBottomMargin() const
sal_Int16 GetLeftMargin() const
void addEmptyBroadcasterPosition(SCTAB nTab, SCCOL nCol, SCROW nRow)
ColumnBlockPosition * getBlockPosition(SCTAB nTab, SCCOL nCol)
RowHeightsArray & getHeightArray()
const Fraction & getZoomX() const
OutputDevice * getOutputDevice()
const Fraction & getZoomY() const
bool isForceAutoSize() const
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
bool empty() const
Whether there isn't any row tagged.
void set(SCROW nRow1, SCROW nRow2, bool bVal)
Holder of a sparkline, that is connected to a cell specific.
std::shared_ptr< Sparkline > const & getSparkline() const
std::shared_ptr< SparklineGroup > const & getSparklineGroup() const
void removeSparkline(std::shared_ptr< Sparkline > const &pSparkline)
void addSparkline(std::shared_ptr< Sparkline > const &pSparkline)
ColumnBlockPosition * getBlockPosition(SCTAB nTab, SCCOL nCol)
SharedString intern(const OUString &rStr)
const OUString & getString() const
sal_Int32 getLength() const
const Size & GetFontSize() const
static void assertNoInterpretNeededHelper(const sc::CellStoreType::value_type &node, size_t nOffset, size_t nDataSize)
static sal_uInt16 lcl_GetAttribHeight(const ScPatternAttr &rPattern, sal_uInt16 nFontHeightId, sal_uInt16 nMinHeight)
#define SC_ROT_BREAK_FACTOR
static bool IsAmbiguousScript(SvtScriptType nScript)
constexpr TypedWhichId< SfxBoolItem > EE_PARA_HYPHENATE(EE_PARA_START+6)
double CreateDoubleError(FormulaError nErr)
FormulaError GetDoubleErrorValue(double fVal)
@ SUBTOTAL_FUNC_SELECTION_COUNT
#define STD_ROWHEIGHT_DIFF
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
constexpr auto toTwips(N number, Length from)
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
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)
SparklineStoreType::const_iterator ParseSparkline(const SparklineStoreType::const_iterator &itPos, const SparklineStoreType &rStore, SCROW nStart, SCROW nEnd, Functor &rFunctor)
CellNoteStoreType::const_iterator ParseNote(const CellNoteStoreType::const_iterator &itPos, const CellNoteStoreType &rStore, SCROW nStart, SCROW nEnd, 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.
mdds::mtv::soa::multi_type_vector< CellNodeTraits > CellNoteStoreType
Cell note container.
mdds::mtv::soa::multi_type_vector< SparklineTraits > SparklineStoreType
Sparkline container.
const mdds::mtv::element_t element_type_formula
void ParseFormula(const CellStoreType &rStore, Func &rFunc)
mdds::mtv::soa::multi_type_vector< CellStoreTraits > CellStoreType
Cell container.
const mdds::mtv::element_t element_type_sparkline
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::iterator ProcessEditText(const CellStoreType::iterator &itPos, CellStoreType &rStore, SCROW nRow1, SCROW nRow2, Func &rFunc)
mdds::mtv::soa::multi_type_vector< BroadcasterTraits > BroadcasterStoreType
Broadcaster storage container.
const mdds::mtv::element_t element_type_string
const mdds::mtv::element_t element_type_cellnote
const mdds::mtv::element_t element_type_empty
const mdds::mtv::element_t element_type_broadcaster
Custom element type IDs for multi_type_vector.
const sc::CellStoreType & mrCells
constexpr TypedWhichId< ScIndentItem > ATTR_INDENT(131)
constexpr TypedWhichId< SvxFontHeightItem > ATTR_FONT_HEIGHT(101)
constexpr TypedWhichId< SfxBoolItem > ATTR_VERTICAL_ASIAN(137)
constexpr TypedWhichId< ScMergeFlagAttr > ATTR_MERGE_FLAG(145)
constexpr TypedWhichId< SvxFontHeightItem > ATTR_CJK_FONT_HEIGHT(112)
constexpr TypedWhichId< SvxEmphasisMarkItem > ATTR_FONT_EMPHASISMARK(121)
constexpr TypedWhichId< ScMergeAttr > ATTR_MERGE(144)
constexpr TypedWhichId< ScRotateValueItem > ATTR_ROTATE_VALUE(135)
constexpr TypedWhichId< SvxHorJustifyItem > ATTR_HOR_JUSTIFY(129)
constexpr TypedWhichId< SvxRotateModeItem > ATTR_ROTATE_MODE(136)
constexpr TypedWhichId< SfxUInt32Item > ATTR_VALUE_FORMAT(146)
constexpr TypedWhichId< SvxMarginItem > ATTR_MARGIN(143)
constexpr TypedWhichId< ScLineBreakCell > ATTR_LINEBREAK(139)
constexpr TypedWhichId< SvxFontHeightItem > ATTR_CTL_FONT_HEIGHT(117)
constexpr TypedWhichId< ScCondFormatItem > ATTR_CONDITIONAL(154)
TOOLS_DLLPUBLIC SvStream & endl(SvStream &rStr)
const ScPatternAttr * pPattern
This is very similar to ScCellValue, except that it references the original value instead of copying ...
ScFormulaCell * getFormula() const
const EditTextObject * getEditText() const
SvtScriptType mnScriptType
CellNoteStoreType::const_iterator miCellNotePos
CellStoreType::const_iterator miCellPos
Store position data for column array storage.
SparklineStoreType::iterator miSparklinePos
BroadcasterStoreType::iterator miBroadcasterPos
CellStoreType::iterator miCellPos
CellNoteStoreType::iterator miCellNotePos
StrArrayType * mpStrArray
NumArrayType * mpNumArray
std::vector< rtl_uString * > StrArrayType
std::vector< double, DoubleAllocType > NumArrayType
StrArrayStoreType m_StrArrays
manage life cycle of numeric arrays.
void ensureNumArray(ColArray &rColArray, size_t nArrayLen)
void discardCachedColArray(SCTAB nTab, SCCOL nCol)
ColArray * setCachedColArray(SCTAB nTab, SCCOL nCol, NumArrayType *pNumArray, StrArrayType *pStrArray)
ColArray * getCachedColArray(SCTAB nTab, SCCOL nCol, size_t nSize)
keep track of longest array for each column.
NumArrayStoreType m_NumArrays
void ensureStrArray(ColArray &rColArray, size_t nArrayLen)
Context for creating string from an array of formula tokens, used in ScTokenArray::CreateString().
#define SV_COUNTRY_LANGUAGE_OFFSET