27#include <com/sun/star/i18n/KParseTokens.hpp>
28#include <com/sun/star/i18n/KParseType.hpp>
30#include <osl/diagnose.h>
36#include <document.hxx>
46#include <progress.hxx>
52#include <tokenarray.hxx>
58#include <stlsheet.hxx>
71#include <unordered_set>
73#include <mdds/flat_segment_tree.hpp>
103 OUString &
sPrefix, OUString &sSuffix,
double &fNum )
107 while (
nPos < sWhole.getLength())
110 if (
nType & KCharacterType::DIGIT)
112 sWhole.iterateCodePoints( &
nPos );
116 if (
nPos == sWhole.getLength() )
122 KParseType::ANY_NUMBER, sWhole,
nPos,
123 KParseTokens::ANY_NUMBER,
"", KParseTokens::ANY_NUMBER, sUser );
125 if ( aPRNum.EndPos ==
nPos )
127 SAL_WARN(
"sc.core",
"naturalsort::SplitString - digit found but no number parsed, pos " <<
128 nPos <<
" : " << sWhole);
134 sSuffix = sWhole.copy( aPRNum.EndPos );
162static short Compare(
const OUString &sInput1,
const OUString &sInput2,
165 OUString sStr1( sInput1 ), sStr2( sInput2 ), sPre1, sSuf1, sPre2, sSuf2;
170 bool bNumFound1 =
SplitString( sStr1, sPre1, sSuf1, nNum1 );
171 bool bNumFound2 =
SplitString( sStr2, sPre2, sSuf2, nNum2 );
178 if ( !bNumFound1 || !bNumFound2 )
179 return static_cast<short>(
pData->Compare( sStr1, sStr2 ));
181 nPreRes =
pData->Compare( sPre1, sPre2 );
185 if ( !bNumFound1 || !bNumFound2 )
186 return static_cast<short>(
pData->ICompare( sStr1, sStr2 ));
188 nPreRes =
pData->ICompare( sPre1, sPre2 );
193 if ( !bNumFound1 || !bNumFound2 )
194 return static_cast<short>(pCW->
compareString( sStr1, sStr2 ));
196 nPreRes =
static_cast<short>(pCW->
compareString( sPre1, sPre2 ));
200 if ( nPreRes != 0 )
return nPreRes;
202 if ( nNum1 != nNum2 )
204 if ( nNum1 < nNum2 )
return -1;
205 return (nNum1 > nNum2) ? 1 : 0;
223struct ScSortInfo final
261 std::vector<std::unique_ptr<ScSortInfo[]>>
mvppInfo;
283 for ( sal_uInt16 nSort = 0; nSort < nSorts; nSort++ )
326 for ( sal_uInt16 nSort = 0; nSort < static_cast<sal_uInt16>(
mvppInfo.size()); nSort++ )
329 std::swap(ppInfo[
n1], ppInfo[
n2]);
338 std::swap(rRows[
n1], rRows[
n2]);
358 std::vector<SCCOLROW> aOrderIndices2;
359 aOrderIndices2.reserve(rIndices.size());
362 aRows2.reserve(rRows.size());
364 for (
const auto& rIndex : rIndices)
367 aRows2.push_back(rRows[
nPos]);
405 bool bHiddenFiltered,
bool bPattern,
bool bCellNotes,
bool bCellDrawObjects,
bool bOnlyDataAreaExtras )
411 assert(!bOnlyDataAreaExtras || (rOrderIndices.size() ==
static_cast<size_t>(nRow2 - nRow1 + 1)
415 for (
SCCOL nCol = nCol1; nCol <= nCol2; ++nCol)
424 std::map<SCROW, std::vector<SdrObject*>> aRowDrawObjects;
428 for (
SCROW nR = nRow1; nR <= nRow2; ++nR)
430 const SCROW nRow = (bOnlyDataAreaExtras ? rOrderIndices[nR - rArray.
GetStart()] : nR);
433 if (!bOnlyDataAreaExtras)
443 if (!bUniformPattern && bPattern)
448 if (!bOnlyDataAreaExtras && bHiddenFiltered)
450 for (
SCROW nRow = nRow1; nRow <= nRow2; ++nRow)
463 std::unique_ptr<ScSortInfoArray> pArray;
496 bool bKeepQuery,
bool bUpdateRefs )
498 sal_uInt16 nUsedSorts = 1;
501 std::unique_ptr<ScSortInfoArray> pArray(
new ScSortInfoArray( nUsedSorts, nInd1, nInd2 ));
502 pArray->SetKeepQuery(bKeepQuery);
503 pArray->SetUpdateRefs(bUpdateRefs);
507 for ( sal_uInt16 nSort = 0; nSort < nUsedSorts; nSort++ )
513 for (
SCROW nRow = nInd1; nRow <= nInd2; nRow++ )
515 ScSortInfo & rInfo = pArray->Get( nSort, nRow );
522 initDataRows( *pArray, *
this,
aCol, rSortParam.
nCol1, nInd1, rSortParam.
nCol2, nInd2, bKeepQuery,
527 for ( sal_uInt16 nSort = 0; nSort < nUsedSorts; nSort++ )
531 nCol <= static_cast<SCCOL>(nInd2); nCol++ )
533 ScSortInfo & rInfo = pArray->Get( nSort, nCol );
546 typedef mdds::flat_segment_tree<SCROW, const ScPatternAttr*> PatRangeType;
552 std::vector<std::vector<SdrObject*>> maCellDrawObjects;
554 PatRangeType maPatterns;
555 PatRangeType::const_iterator miPatternPos;
557 SortedColumn(
const SortedColumn&) =
delete;
558 const SortedColumn operator=(
const SortedColumn&) =
delete;
560 explicit SortedColumn(
size_t nTopEmptyRows,
const ScSheetLimits& rSheetLimits ) :
561 maCells(nTopEmptyRows),
562 maCellTextAttrs(nTopEmptyRows),
563 maBroadcasters(nTopEmptyRows),
564 maCellNotes(nTopEmptyRows),
565 maPatterns(0, rSheetLimits.GetMaxRowCount(), nullptr),
566 miPatternPos(maPatterns.
begin()) {}
570 miPatternPos = maPatterns.insert(miPatternPos, nRow, nRow+1, pPat).first;
576 typedef mdds::flat_segment_tree<SCROW,bool> FlagsType;
578 FlagsType maRowsHidden;
579 FlagsType maRowsFiltered;
580 FlagsType::const_iterator miPosHidden;
581 FlagsType::const_iterator miPosFiltered;
584 maRowsHidden(0, rSheetLimits.GetMaxRowCount(), false),
585 maRowsFiltered(0, rSheetLimits.GetMaxRowCount(), false),
586 miPosHidden(maRowsHidden.
begin()),
587 miPosFiltered(maRowsFiltered.
begin()) {}
589 void setRowHidden(
SCROW nRow,
bool b )
591 miPosHidden = maRowsHidden.insert(miPosHidden, nRow, nRow+1, b).first;
594 void setRowFiltered(
SCROW nRow,
bool b )
596 miPosFiltered = maRowsFiltered.insert(miPosFiltered, nRow, nRow+1, b).first;
599 void swap( SortedRowFlags& r )
601 maRowsHidden.swap(r.maRowsHidden);
602 maRowsFiltered.swap(r.maRowsFiltered);
605 miPosHidden = maRowsHidden.begin();
606 miPosFiltered = maRowsFiltered.begin();
617 mnRow1(nRow1), mnRow2(nRow2),
mpPattern(pPat) {}
656template<
typename H
int,
typename ReorderMap,
typename Index>
661 ReorderNotifier(
const ReorderMap& rMap,
SCTAB nTab,
Index nPos1,
Index nPos2 ) :
662 maHint(rMap, nTab, nPos1, nPos2) {}
670class FormulaGroupPosCollector
683void fillSortedColumnArray(
684 std::vector<std::unique_ptr<SortedColumn>>& rSortedCols,
685 SortedRowFlags& rRowFlags,
686 std::vector<SvtListener*>& rCellListeners,
688 bool bOnlyDataAreaExtras )
690 assert(!bOnlyDataAreaExtras || !pArray->
IsUpdateRefs());
696 size_t nColCount = nCol2 - nCol1 + 1;
697 std::vector<std::unique_ptr<SortedColumn>> aSortedCols;
699 aSortedCols.reserve(nColCount);
700 for (
size_t i = 0;
i < nColCount; ++
i)
705 aSortedCols.push_back(std::make_unique<SortedColumn>(nRow1, pTable->
GetDoc().
GetSheetLimits()));
708 for (
size_t i = 0;
i < pRows->size(); ++
i)
710 const SCROW nRow = nRow1 +
i;
713 for (
size_t j = 0; j < rRow.
maCells.size(); ++j)
724 if (!bOnlyDataAreaExtras)
746 const ScAddress aCellPos(nCol1 + j, nRow, nTab);
758 if (!rCellListeners.empty())
763 auto it( ::std::find( rCellListeners.begin(), rCellListeners.end(), rCell.
maCell.
getFormula()));
764 if (it != rCellListeners.end())
768 rCellStore.push_back(pNew);
778 rCellStore.push_back_empty();
783 rAttrStore.push_back(*rCell.
mpAttr);
785 rAttrStore.push_back_empty();
799 rBCStore.push_back_empty();
807 rNoteStore.push_back_empty();
810 aSortedCols.at(j)->maCellDrawObjects.push_back(rCell.
maDrawObjects);
813 aSortedCols.at(j)->setPattern(nRow, rCell.
mpPattern);
819 aRowFlags.setRowHidden(nRow, rRow.
mbHidden);
820 aRowFlags.setRowFiltered(nRow, rRow.
mbFiltered);
827 rSortedCols.swap(aSortedCols);
828 rRowFlags.swap(aRowFlags);
836 if (rRange.
aEnd.
Row() < nBottom)
842 std::vector<ScFormulaCell*>&
mrCells;
846 explicit FormulaCellCollectAction( std::vector<ScFormulaCell*>& rCells ) :
847 mrCells(rCells), mpCol(nullptr) {}
869 std::shared_ptr<sc::ColumnBlockPositionSet> mpPosSet;
874 explicit ListenerStartAction(
ScDocument& rDoc ) :
877 maStartCxt(rDoc, mpPosSet),
878 maEndCxt(rDoc, mpPosSet) {}
906 for (
SCCOL nCol = rDataAreaExtras.
mnStartCol; nCol < nDataCol1; nCol += nChunkCols)
908 const SCCOL nEndCol = std::min<SCCOL>( nCol + nChunkCols - 1, nDataCol1 - 1);
910 initDataRows( *pArray, *
this,
aCol, nCol, nRow1, nEndCol, nLastRow,
false,
915 for (
SCCOL nCol = nDataCol2 + 1; nCol <= rDataAreaExtras.
mnEndCol; nCol += nChunkCols)
917 const SCCOL nEndCol = std::min<SCCOL>( nCol + nChunkCols - 1, rDataAreaExtras.
mnEndCol);
919 initDataRows( *pArray, *
this,
aCol, nCol, nRow1, nEndCol, nLastRow,
false,
932 for (
SCROW nRow = rDataAreaExtras.
mnStartRow; nRow < nDataRow1; nRow += nChunkRows)
934 const SCROW nEndRow = std::min<SCROW>( nRow + nChunkRows - 1, nDataRow1 - 1);
938 for (
SCROW nRow = nDataRow2 + 1; nRow <= rDataAreaExtras.
mnEndRow; nRow += nChunkRows)
940 const SCROW nEndRow = std::min<SCROW>( nRow + nChunkRows - 1, rDataAreaExtras.
mnEndRow);
952 size_t nCount = aIndices.size();
956 for (
SCCOL nCol = nStart; nCol <= static_cast<SCCOL>(nLast); ++nCol)
957 aCol[nCol].SplitFormulaGroupByRelativeRef(aSortRange);
960 std::vector<SvtListener*> aCellListeners;
965 for (
SCCOL nCol = nStart; nCol <= static_cast<SCCOL>(nLast); ++nCol)
966 aCol[nCol].CollectListeners(aCellListeners, nRow1, nRow2);
970 std::sort(aCellListeners.begin(), aCellListeners.end());
971 aCellListeners.erase(std::unique(aCellListeners.begin(), aCellListeners.end()), aCellListeners.end());
978 for (
auto const & l : aCellListeners)
983 std::vector<SCCOLROW> aPosTable(
nCount);
985 aPosTable[aIndices[
i]-nStart] =
i;
988 for (
size_t i = 0;
i <
nCount; ++
i, ++nDest)
993 aCol[nDest].Swap(
aCol[nSrc], nRow1, nRow2, bPattern);
996 size_t nPos = aPosTable[nDest-nStart];
997 aIndices[
nPos] = nSrc;
998 aPosTable[nSrc-nStart] =
nPos;
1007 for (
SCCOL nCol = nStart; nCol <= static_cast<SCCOL>(nLast); ++nCol)
1008 aCol[nCol].ResetFormulaCellPositions(nRow1, nRow2, bUpdateRefs);
1015 for (
size_t i = 0,
n = rOldIndices.size();
i <
n; ++
i)
1018 SCCOL nOld = rOldIndices[
i];
1025 for (
SCCOL nCol = nStart; nCol <= static_cast<SCCOL>(nLast); ++nCol)
1034 for (
auto& rAreaListener : aAreaListeners)
1037 aListeners.push_back( rAreaListener.mpListener);
1046 ReorderNotifier<sc::RefColReorderHint, sc::ColRowReorderMapType, SCCOL> aFunc(aColMap,
nTab, nRow1, nRow2);
1051 for (
auto& rAreaListener : aAreaListeners)
1053 ScRange aNewRange = rAreaListener.maArea;
1055 if (itCol != aColMap.
end())
1068 for (
auto const & l : aCellListeners)
1074 for (
SCCOL nCol = nStart; nCol <= static_cast<SCCOL>(nLast); ++nCol)
1077 sc::CellStoreType::position_type aPos = rCells.position(nRow1);
1081 aPos = rCells.position(aPos.first, nRow2+1);
1088 ScProgress* pProgress,
bool bOnlyDataAreaExtras )
1105 std::vector<SvtListener*> aCellListeners;
1110 if (!bOnlyDataAreaExtras)
1117 for (
SCCOL nCol = nCol1; nCol <= nCol2; ++nCol)
1118 aCol[nCol].CollectListeners(aCellListeners, nRow1, nRow2);
1122 std::sort(aCellListeners.begin(), aCellListeners.end());
1123 aCellListeners.erase(std::unique(aCellListeners.begin(), aCellListeners.end()), aCellListeners.end());
1131 for (
auto const & l : aCellListeners)
1136 if (!bOnlyDataAreaExtras)
1138 std::vector<SCROW> aRowBounds
1143 for (
SCCOL nCol = nCol1; nCol <= nCol2; ++nCol)
1149 std::vector<std::unique_ptr<SortedColumn>> aSortedCols;
1150 SortedRowFlags aRowFlags(
GetDoc().GetSheetLimits());
1151 fillSortedColumnArray(aSortedCols, aRowFlags, aCellListeners, pArray,
nTab, nCol1, nCol2,
1152 pProgress,
this, bOnlyDataAreaExtras);
1154 for (
size_t i = 0,
n = aSortedCols.size();
i <
n; ++
i)
1156 SCCOL nThisCol =
i + nCol1;
1158 if (!bOnlyDataAreaExtras)
1163 rSrc.transfer(nRow1, nRow2, rDest, nRow1);
1169 rSrc.transfer(nRow1, nRow2, rDest, nRow1);
1178 rDest.release_range(nRow1, nRow2);
1179 rSrc.transfer(nRow1, nRow2, rDest, nRow1);
1180 aCol[nThisCol].UpdateNoteCaptions(nRow1, nRow2);
1184 aCol[nThisCol].UpdateDrawObjects(aSortedCols[
i]->maCellDrawObjects, nRow1, nRow2);
1188 std::vector<PatternSpan> aSpans =
1189 sc::toSpanArrayWithValue<SCROW,const ScPatternAttr*,PatternSpan>(
1190 aSortedCols[
i]->maPatterns);
1192 for (
const auto& rSpan : aSpans)
1194 assert(rSpan.mpPattern);
1198 for (
const auto& rSpan : aSpans)
1200 aCol[nThisCol].SetPatternArea(rSpan.mnRow1, rSpan.mnRow2, *rSpan.mpPattern);
1205 aCol[nThisCol].CellStorageModified();
1208 if (!bOnlyDataAreaExtras && pArray->
IsKeepQuery())
1210 aRowFlags.maRowsHidden.build_tree();
1211 aRowFlags.maRowsFiltered.build_tree();
1217 std::vector<sc::RowSpan> aSpans =
1218 sc::toSpanArray<SCROW,sc::RowSpan>(aRowFlags.maRowsHidden, nRow1);
1220 for (
const auto& rSpan : aSpans)
1223 aSpans = sc::toSpanArray<SCROW,sc::RowSpan>(aRowFlags.maRowsFiltered, nRow1);
1225 for (
const auto& rSpan : aSpans)
1232 for (
auto const & l : aCellListeners)
1236 if (!bOnlyDataAreaExtras)
1239 for (
SCCOL i = nCol1;
i <= nCol2; ++
i)
1268 std::vector<sc::AreaListener> aGrpListeners =
1273 for (
const auto& rGrpListener : aGrpListeners)
1275 assert(rGrpListener.mbGroupListening);
1277 pGrpLis->
Query(aQuery);
1288 for (
size_t i = 0,
n = aTmp.
size();
i <
n; ++
i)
1294 aGrpListenerRanges.
set(
GetDoc(), aRange,
true);
1302 aGrpListenerRanges.
set(
GetDoc(), aRange,
true);
1326 aGrpListenerRanges.
set(
GetDoc(), aR1,
true);
1327 aGrpListenerRanges.
set(
GetDoc(), aR2,
true);
1332 std::vector<SCROW> aRowBounds
1337 for (
SCCOL nCol = nCol1; nCol <= nCol2; ++nCol)
1342 std::vector<std::unique_ptr<SortedColumn>> aSortedCols;
1343 SortedRowFlags aRowFlags(
GetDoc().GetSheetLimits());
1344 std::vector<SvtListener*> aListenersDummy;
1345 fillSortedColumnArray(aSortedCols, aRowFlags, aListenersDummy, pArray,
nTab, nCol1, nCol2, pProgress,
this,
false);
1347 for (
size_t i = 0,
n = aSortedCols.size();
i <
n; ++
i)
1349 SCCOL nThisCol =
i + nCol1;
1354 rSrc.transfer(nRow1, nRow2, rDest, nRow1);
1360 rSrc.transfer(nRow1, nRow2, rDest, nRow1);
1368 rDest.release_range(nRow1, nRow2);
1371 rSrc.transfer(nRow1, nRow2, rDest, nRow1);
1379 rDest.release_range(nRow1, nRow2);
1380 rSrc.transfer(nRow1, nRow2, rDest, nRow1);
1381 aCol[nThisCol].UpdateNoteCaptions(nRow1, nRow2);
1385 aCol[nThisCol].UpdateDrawObjects(aSortedCols[
i]->maCellDrawObjects, nRow1, nRow2);
1389 std::vector<PatternSpan> aSpans =
1390 sc::toSpanArrayWithValue<SCROW,const ScPatternAttr*,PatternSpan>(
1391 aSortedCols[
i]->maPatterns);
1393 for (
const auto& rSpan : aSpans)
1395 assert(rSpan.mpPattern);
1399 for (
const auto& rSpan : aSpans)
1401 aCol[nThisCol].SetPatternArea(rSpan.mnRow1, rSpan.mnRow2, *rSpan.mpPattern);
1406 aCol[nThisCol].CellStorageModified();
1411 aRowFlags.maRowsHidden.build_tree();
1412 aRowFlags.maRowsFiltered.build_tree();
1418 std::vector<sc::RowSpan> aSpans =
1419 sc::toSpanArray<SCROW,sc::RowSpan>(aRowFlags.maRowsHidden, nRow1);
1421 for (
const auto& rSpan : aSpans)
1424 aSpans = sc::toSpanArray<SCROW,sc::RowSpan>(aRowFlags.maRowsFiltered, nRow1);
1426 for (
const auto& rSpan : aSpans)
1433 for (
size_t i = 0,
n = rOldIndices.size();
i <
n; ++
i)
1436 SCROW nOld = rOldIndices[
i];
1444 for (
SCCOL nCol = nCol1; nCol <= nCol2; ++nCol)
1452 for (
auto& rAreaListener : aAreaListeners)
1455 aListeners.push_back( rAreaListener.mpListener);
1462 std::vector<ScFormulaCell*> aFCells;
1463 FormulaCellCollectAction aAction(aFCells);
1479 std::for_each(
aListeners.begin(),
aListeners.end(), FormulaGroupPosCollector(aFormulaGroupPos));
1481 for (
const auto& [rTab, rCols] : rGroupTabs)
1483 for (
const auto& [nCol, rCol] : rCols)
1485 std::vector<SCROW> aBounds(rCol);
1491 ReorderNotifier<sc::RefRowReorderHint, sc::ColRowReorderMapType, SCROW> aFunc(aRowMap,
nTab, nCol1, nCol2);
1495 for (
const auto& [rTab, rCols] : rGroupTabs)
1497 for (
const auto& rEntry : rCols)
1502 for (
const auto& rAreaListener : aAreaListeners)
1504 ScRange aNewRange = rAreaListener.maArea;
1506 if (itRow != aRowMap.
end())
1515 for (
SCCOL i = nCol1;
i <= nCol2; ++
i)
1553 if (aTheChosenColor == aColor1)
1555 if (aTheChosenColor == aColor2)
1557 if (aColor1 == aColor2)
1559 if (aColor1 > aColor2)
1561 if (aColor1 < aColor2)
1599 if ( bStr1 && bStr2 )
1606 aStr1 =
GetString(nCell1Col, nCell1Row);
1610 aStr2 =
GetString(nCell2Col, nCell2Row);
1626 nRes = sal::static_int_cast<short>( rData.
Compare(aStr1, aStr2) );
1628 nRes = sal::static_int_cast<short>( rData.
ICompare(aStr1, aStr2) );
1654 else if (bErr1 && bErr2)
1672 else if (nVal1 > nVal2)
1694 sal_uInt16 nSort = 0;
1697 ScSortInfo& rInfo1 = pArray->
Get( nSort, nIndex1 );
1698 ScSortInfo& rInfo2 = pArray->
Get( nSort, nIndex2 );
1707 }
while ( nRes == 0 && ++nSort < pArray->GetUsedSorts() );
1710 ScSortInfo& rInfo1 = pArray->
Get( 0, nIndex1 );
1711 ScSortInfo& rInfo2 = pArray->
Get( 0, nIndex2 );
1712 if( rInfo1.nOrg < rInfo2.nOrg )
1714 else if( rInfo1.nOrg > rInfo2.nOrg )
1722 if ((nHi - nLo) == 1)
1724 if (
Compare(pArray, nLo, nHi) > 0)
1725 pArray->
Swap( nLo, nHi );
1733 while ((ni <= nHi) && (
Compare(pArray, ni, nLo)) < 0)
1735 while ((nj >= nLo) && (
Compare(pArray, nLo, nj)) < 0)
1740 pArray->
Swap( ni, nj );
1745 if ((nj - nLo) < (nHi - ni))
1765 sal_uInt16 nSort = 0;
1777 nRes =
CompareCell(nSort, aCell1, nCol, nIndex1, aCell2, nCol, nIndex2);
1789 aCell1 =
aCol[nIndex1].GetCellValue(nRow);
1791 aCell2 =
aCol[nIndex2].GetCellValue(nRow);
1793 nRow, aCell2,
static_cast<SCCOL>(nIndex2), nRow );
1812 int nMax = nRow2 - nRow1;
1813 for (
SCROW i = nRow1; (
i + 4) <= nRow2;
i += 4)
1816 pArray->
Swap(
i, nRow1 + nRow);
1821 const ScSortParam& rSortParam,
bool bKeepQuery,
bool bUpdateRefs,
1845 if (nRow1 < nLastRow && !
IsSorted(nRow1, nLastRow))
1848 pProgress->
SetState( 0, nLastRow-nRow1 );
1851 aSortParam, nRow1, nLastRow, bKeepQuery, bUpdateRefs));
1853 if ( nLastRow - nRow1 > 255 )
1856 QuickSort(pArray.get(), nRow1, nLastRow);
1857 if (pArray->IsUpdateRefs())
1880 if (nCol1 < nLastCol && !
IsSorted(nCol1, nLastCol))
1883 pProgress->
SetState( 0, nLastCol-nCol1 );
1886 aSortParam, nCol1, nLastCol, bKeepQuery, bUpdateRefs));
1888 QuickSort(pArray.get(), nCol1, nLastCol);
1920 if (pArray->IsUpdateRefs())
1949class SubTotalRowFinder
1956 mrTab(rTab), mrParam(rParam) {}
1968 if (mrTab.
HasData(nCol, nRow))
1973 if (mrTab.
HasData(nCol, nRow))
1989 for (
SCCOL nCol = nStartCol; nCol <= nEndCol; ++nCol)
1992 SubTotalRowFinder aFunc(*
this, rParam);
1993 std::pair<sc::CellStoreType::const_iterator,size_t> aPos =
1995 if (aPos.first != rCells.end())
2003struct RemoveSubTotalsHandler
2005 std::set<SCROW> aRemoved;
2009 if (
p->IsSubTotal())
2010 aRemoved.insert(nRow);
2023 RemoveSubTotalsHandler aFunc;
2024 for (
SCCOL nCol = nStartCol; nCol <= nEndCol; ++nCol)
2030 auto& aRows = aFunc.aRemoved;
2032 std::for_each(aRows.rbegin(), aRows.rend(), [
this](
const SCROW nRow) {
2033 RemoveRowBreak(nRow+1, false, true);
2034 rDocument.DeleteRow(0, nTab, rDocument.MaxCol(), nTab, nRow, 1);
2037 rParam.
nRow2 -= aRows.size();
2046 == SfxItemState::SET )
2048 auto pNewPattern = std::make_unique<ScPatternAttr>( *pPattern );
2052 pTab->
SetPattern( nCol, nRow, std::move(pNewPattern) );
2060 sal_uInt16 nGroupNo;
2086 return STR_EMPTYDATA;
2110 return STR_EMPTYDATA;
2133 sal_uInt16 nLevelCount = 0;
2134 bool bDoThis =
true;
2149 bool bTestPrevSub = ( nLevelCount > 1 );
2151 OUString aSubString;
2160 ScResId(STR_STYLENAME_RESULT), SfxStyleFamily::Para ));
2162 bool bSpaceLeft =
true;
2168 ::std::vector< RowEntry > aRowVector;
2170 for (sal_uInt16 nLevel=0; nLevel<nLevelCount && bSpaceLeft; nLevel++)
2172 aRowEntry.nGroupNo = nLevelCount - nLevel - 1;
2181 for (
i=0;
i<=aRowEntry.nGroupNo;
i++)
2183 aSubString =
GetString( nGroupCol[
i], nStartRow );
2187 aCompString[
i] = aSubString;
2190 bool bBlockVis =
false;
2191 aRowEntry.nSubStartRow = nStartRow;
2192 for (
SCROW nRow=nStartRow; nRow<=nEndRow+1 && bSpaceLeft; nRow++)
2201 for (
i=0;
i<=aRowEntry.nGroupNo && !bChanged;
i++)
2208 bChanged = ( ( !aString.isEmpty() || rParam.
bDoSort ) &&
2209 aString != aCompString[
i] );
2211 if ( bChanged && bTestPrevSub )
2214 bChanged = std::none_of(aRowVector.begin(), aRowVector.end(),
2215 [&nRow](
const RowEntry& rEntry) { return rEntry.nDestRow == nRow; });
2220 aRowEntry.nDestRow = nRow;
2221 aRowEntry.nFuncStart = aRowEntry.nSubStartRow;
2222 aRowEntry.nFuncEnd = nRow-1;
2225 aRowEntry.nDestRow, 1 );
2226 DBShowRow( aRowEntry.nDestRow, bBlockVis );
2228 aRowEntry.nSubStartRow != nStartRow && nLevel == 0)
2233 for (
auto& rRowEntry : aRowVector)
2235 if ( aRowEntry.nDestRow <= rRowEntry.nSubStartRow )
2236 ++rRowEntry.nSubStartRow;
2237 if ( aRowEntry.nDestRow <= rRowEntry.nDestRow )
2238 ++rRowEntry.nDestRow;
2239 if ( aRowEntry.nDestRow <= rRowEntry.nFuncStart )
2240 ++rRowEntry.nFuncStart;
2241 if ( aRowEntry.nDestRow <= rRowEntry.nFuncEnd )
2242 ++rRowEntry.nFuncEnd;
2245 aRowVector.push_back( aRowEntry );
2247 OUString aOutString = aSubString;
2248 if (aOutString.isEmpty())
2249 aOutString =
ScResId( STR_EMPTYDATA );
2252 if ( nResCount == 1 )
2254 aOutString +=
ScResId(pStrId);
2255 SetString( nGroupCol[aRowEntry.nGroupNo], aRowEntry.nDestRow,
nTab, aOutString );
2256 ApplyStyle( nGroupCol[aRowEntry.nGroupNo], aRowEntry.nDestRow, pStyle );
2260 aRowEntry.nSubStartRow = nRow;
2261 for (
i=0;
i<=aRowEntry.nGroupNo;
i++)
2263 aSubString =
GetString( nGroupCol[
i], nRow );
2267 aCompString[
i] = aSubString;
2276 if (!aRowVector.empty())
2279 SCROW nGlobalStartRow = aRowVector[0].nSubStartRow;
2280 SCROW nGlobalStartFunc = aRowVector[0].nFuncStart;
2281 SCROW nGlobalEndRow = 0;
2282 SCROW nGlobalEndFunc = 0;
2283 for (
const auto& rRowEntry : aRowVector)
2285 nGlobalEndRow = (nGlobalEndRow < rRowEntry.nDestRow) ? rRowEntry.nDestRow : nGlobalEndRow;
2286 nGlobalEndFunc = (nGlobalEndFunc < rRowEntry.nFuncEnd) ? rRowEntry.nFuncEnd : nGlobalEndRow;
2289 for (sal_uInt16 nLevel = 0; nLevel<nLevelCount; nLevel++)
2291 const sal_uInt16 nGroupNo = nLevelCount - nLevel - 1;
2304 aRowEntry.nGroupNo = nGroupNo;
2305 aRowEntry.nSubStartRow = nGlobalStartRow;
2306 aRowEntry.nFuncStart = nGlobalStartFunc;
2307 aRowEntry.nDestRow = nGlobalEndRow;
2308 aRowEntry.nFuncEnd = nGlobalEndFunc;
2317 aRowVector.push_back(aRowEntry);
2324 ApplyStyle(nGroupCol[aRowEntry.nGroupNo], aRowEntry.nDestRow, pStyle);
2334 for (
const auto& rRowEntry : aRowVector)
2339 for (
SCCOL nResult=0; nResult < nResCount; ++nResult )
2349 aArr.AddDouble(
static_cast<double>(pResFunc[nResult]) );
2351 aArr.AddDoubleReference( aRef );
2360 if ( nResCols[nResult] != nGroupCol[rRowEntry.nGroupNo] )
2362 ApplyStyle( nResCols[nResult], rRowEntry.nDestRow, pStyle );
2377 rParam.
nRow2 = nEndRow;
2383 bool bSortCollatorInitialized =
false;
2403 if (!bSortCollatorInitialized)
2405 bSortCollatorInitialized =
true;
2411 std::unique_ptr<ScSortInfo[]>
const& ppInfo = pArray->GetFirstArray();
2414 while (nValidCount > 0 && ppInfo[nValidCount - 1].maCell.isEmpty())
2417 while (nValidCount > 0 && ppInfo[nValidCount - 1].maCell.hasString())
2419 if (nValidCount > 0)
2426 SCSIZE nVal = (rItem.mfVal >= 1 ?
static_cast<SCSIZE>(rItem.mfVal) : 1);
2433 if (nVal > nValidCount)
2435 nOffset = nValidCount - nVal;
2441 if (nVal > nValidCount)
2451 nOffset = nValidCount - (nValidCount * nVal / 100);
2452 if (nOffset >= nValidCount)
2453 nOffset = nValidCount - 1;
2461 nOffset = (nValidCount * nVal / 100);
2462 if (nOffset >= nValidCount)
2463 nOffset = nValidCount - 1;
2476 OSL_FAIL(
"TopTenQuery: pCell no ValueData");
2496 if ( bSortCollatorInitialized )
2502bool CanOptimizeQueryStringToNumber(
const SvNumberFormatter* pFormatter, sal_uInt32 nFormatIndex,
bool& bDateFormat )
2512 switch(pEntry->GetType())
2514 case SvNumFormatType::NUMBER:
2515 case SvNumFormatType::FRACTION:
2516 case SvNumFormatType::SCIENTIFIC:
2518 case SvNumFormatType::DATE:
2519 case SvNumFormatType::DATETIME:
2529class PrepareQueryItem
2532 const bool mbRoundForFilter;
2534 explicit PrepareQueryItem(
const ScDocument& rDoc,
bool bRoundForFilter) :
2535 mrDoc(rDoc), mbRoundForFilter(bRoundForFilter) {}
2554 bool bDateFormat =
false;
2555 if (bNumber && CanOptimizeQueryStringToNumber( mrDoc.
GetFormatTable(), nIndex, bDateFormat ))
2563 if (bNumber && ((nIndex % SV_COUNTRY_LANGUAGE_OFFSET) != 0))
2569 if (!(nNumFmtType & SvNumFormatType::DATE) || (nNumFmtType & SvNumFormatType::TIME))
2584 bool bTopTen =
false;
2587 for (
SCSIZE i = 0;
i < nEntryCount; ++
i )
2594 std::for_each(rItems.begin(), rItems.end(), PrepareQueryItem(*pDoc, bRoundForFilter));
2598 switch ( rEntry.
eOp )
2625 lcl_PrepareQuery(&
rDocument,
this, rQueryParam,
false);
2631 typedef std::unordered_set<OUString> StrSetType;
2634 bool bStarted =
false;
2635 bool bOldResult =
true;
2636 SCROW nOldStart = 0;
2643 lcl_PrepareQuery(&
rDocument,
this, aParam,
true);
2647 nOutRow = aParam.
nDestRow + nHeader;
2657 for (
SCROW j = aParam.
nRow1 + nHeader; j <= nRealRow2; ++j)
2660 bool bValid = queryEvaluator.
ValidQuery(j,
nullptr, &blockPos);
2661 if (!bValid && bKeepSub)
2682 OUStringBuffer
aStr;
2686 aStr.append(aCellStr +
u"\x0001");
2689 bResult = aStrSet.insert(
aStr.makeStringAndClear()).second;
2697 if (bResult == bOldResult && bStarted)
2703 nOldStart = nOldEnd = j;
2704 bOldResult = bResult;
2734 std::unique_ptr<SCCOL[]> pFields(
new SCCOL[nCol2-nCol1+1]);
2737 OSL_ENSURE( rQueryParam.
nTab !=
SCTAB_MAX,
"rQueryParam.nTab no value, not bad but no good" );
2742 while (bValid && (nCol <= nCol2))
2745 bool bFound =
false;
2747 while (!bFound && (
i <= nDBCol2))
2749 if (
nTab == nDBTab )
2753 bFound = (aCellStr == aQueryStr);
2757 pFields[nCol - nCol1] =
i;
2766 nVisible +=
aCol[nCol].VisibleCount( nRow1+1, nRow2 );
2770 OSL_FAIL(
"too many filter criteria");
2774 SCSIZE nNewEntries = nVisible;
2775 rQueryParam.
Resize( nNewEntries );
2778 SCROW nRow = nRow1 + 1;
2780 while (nRow <= nRow2)
2783 while (nCol <= nCol2)
2786 if (!aCellStr.isEmpty())
2788 if (
nIndex < nNewEntries)
2793 if (
nIndex < nNewEntries)
2802 if (
nIndex < nNewEntries)
2819 if (nCol2 - nCol1 < 3)
2826 OSL_ENSURE( rQueryParam.
nTab !=
SCTAB_MAX,
"rQueryParam.nTab no value, not bad but no good" );
2831 SCSIZE nNewEntries =
static_cast<SCSIZE>(nRow2-nRow1+1);
2832 rQueryParam.
Resize( nNewEntries );
2844 if ( aCellStr ==
ScResId(STR_TABLE_AND) )
2849 else if ( aCellStr ==
ScResId(STR_TABLE_OR) )
2856 if ((
nIndex < 1) || bValid)
2858 bool bFound =
false;
2860 for (
SCCOL i=rQueryParam.
nCol1; (
i <= nDBCol2) && (!bFound);
i++)
2863 if (
nTab == nDBTab )
2867 bFound = (aCellStr == aFieldStr);
2881 if (aCellStr.startsWith(
"<"))
2883 if (aCellStr[1] ==
'>')
2885 else if (aCellStr[1] ==
'=')
2890 else if (aCellStr.startsWith(
">"))
2892 if (aCellStr[1] ==
'=')
2897 else if (aCellStr.startsWith(
"="))
2911 while (bValid && (nRow <= nRow2) );
2926 bool bValid =
CreateStarQuery(nCol1, nRow1, nCol2, nRow2, rQueryParam);
2942 bool bDateFormat =
false;
2943 rItem.
meType = bNumber && CanOptimizeQueryStringToNumber( pFormatter,
nIndex, bDateFormat )
2957 if (nStartRow == nEndRow)
2963 for (
SCCOL nCol=nStartCol; nCol<=nEndCol; nCol++)
2972 SCROW nTestRow = nStartRow + 1;
2973 for (
SCCOL nCol=nStartCol; nCol<=nEndCol; nCol++)
2986 if (nStartCol == nEndCol)
2992 for (
SCROW nRow=nStartRow; nRow<=nEndRow; nRow++)
3001 SCCOL nTestCol = nStartCol + 1;
3002 for (
SCROW nRow=nStartRow; nRow<=nEndRow; nRow++)
3019 aCol[nCol].InitBlockPosition(aBlockPos);
3020 aCol[nCol].GetFilterEntries(aBlockPos, nRow1, nRow2, rFilterEntries, bFiltering,
false );
3030 aCol[nCol].InitBlockPosition(aBlockPos);
3036 lcl_PrepareQuery(&
rDocument,
this, aParam,
true);
3038 for (
SCROW j = nRow1; j <= nRow2; ++j )
3042 aCol[nCol].GetFilterEntries(aBlockPos, j, j, rFilterEntries, bFiltering,
false);
3046 aCol[nCol].GetFilterEntries(aBlockPos, j, j, rFilterEntries, bFiltering,
true);
3055 return aCol[nCol].GetDataEntries( nRow, rStrings);
3060 sal_uInt64 nCellCount = 0;
3070 sal_uInt64 nCellCount = 0;
3080 sal_uInt64 nCellCount = 0;
3090 sal_uInt64 nCodeCount = 0;
3094 nCodeCount +=
aCol[nCol].GetCodeCount();
3100 SCROW nRowEnd, rtl_TextEncoding eCharSet )
const
3103 return aCol[nCol].GetMaxStringLen( nRowStart, nRowEnd, eCharSet );
3109 sal_uInt16& nPrecision,
SCCOL nCol,
SCROW nRowStart,
SCROW nRowEnd )
const
3112 return aCol[nCol].GetMaxNumberStringLen( nPrecision, nRowStart, nRowEnd );
3127 assert(!
"ScTable::UpdateSelectionFunction - called without anything marked");
3133 for (
SCCOL nCol = nStartCol; nCol <= nEndCol && !rData.
getError(); ++nCol)
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 ...
void PutInOrder(T &nStart, T &nEnd)
OUString uppercase(const OUString &rStr, sal_Int32 nPos, sal_Int32 nCount) const
sal_Int32 getCharacterType(const OUString &rStr, sal_Int32 nPos) const
css::i18n::ParseResult parsePredefinedToken(sal_Int32 nTokenType, const OUString &rStr, sal_Int32 nPos, sal_Int32 nStartCharFlags, const OUString &userDefinedCharactersStart, sal_Int32 nContCharFlags, const OUString &userDefinedCharactersCont) const
sal_Int32 compareString(const OUString &s1, const OUString &s2) const
void loadCollatorAlgorithm(const OUString &rAlgorithm, const css::lang::Locale &rLocale, sal_Int32 nOption)
virtual std::unique_ptr< EditTextObject > Clone() const=0
const OUString & getNumDecimalSep() const
BroadcastAreaSlots and their management, once per document.
std::vector< sc::AreaListener > GetAllListeners(const ScRange &rRange, sc::AreaOverlapType eType, sc::ListenerGroupType eGroup=sc::ListenerGroupType::Both)
void CollectFormulaCells(std::vector< ScFormulaCell * > &rCells, SCROW nRow1, SCROW nRow2)
const ScPatternAttr * GetPattern(SCROW nRow) const
ScPostIt * GetCellNote(SCROW nRow)
void InitBlockPosition(sc::ColumnBlockPosition &rBlockPos)
ScRefCellValue GetCellValue(SCROW nRow) const
void StartListeningFormulaCells(sc::StartListeningContext &rStartCxt, sc::EndListeningContext &rEndCxt, SCROW nRow1, SCROW nRow2)
const sc::CellTextAttr * GetCellTextAttr(SCROW nRow) const
SCSIZE GetPatternCount() const
ScSheetLimits & GetSheetLimits() const
void EndListeningArea(const ScRange &rRange, bool bGroupListening, SvtListener *pListener)
SC_DLLPUBLIC SCCOL MaxCol() const
SC_DLLPUBLIC ScDocumentPool * GetPool()
SC_DLLPUBLIC SCROW MaxRow() const
void UnshareFormulaCells(SCTAB nTab, SCCOL nCol, std::vector< SCROW > &rRows)
Make specified formula cells non-grouped.
OUString GetUpperCellString(SCCOL nCol, SCROW nRow, SCTAB nTab)
ScBroadcastAreaSlotMachine * GetBASM() const
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
void RegroupFormulaCells(SCTAB nTab, SCCOL nCol)
void StartListeningArea(const ScRange &rRange, bool bGroupListening, SvtListener *pListener)
SC_DLLPUBLIC ScStyleSheetPool * GetStyleSheetPool() const
SC_DLLPUBLIC svl::SharedStringPool & GetSharedStringPool()
SC_DLLPUBLIC SvNumberFormatter * GetFormatTable() const
bool InsertRow(SCCOL nStartCol, SCTAB nStartTab, SCCOL nEndCol, SCTAB nEndTab, SCROW nStartRow, SCSIZE nSize, ScDocument *pRefUndoDoc=nullptr, const ScMarkData *pTabMark=nullptr)
std::map< SCROW, std::vector< SdrObject * > > GetObjectsAnchoredToRange(SCTAB nTab, SCCOL nCol, SCROW nStartRow, SCROW nEndRow)
To calculate a single subtotal function.
static SC_DLLPUBLIC CollatorWrapper & GetCollator()
case-insensitive collator
static SC_DLLPUBLIC const LocaleDataWrapper & getLocaleData()
static CollatorWrapper & GetCaseCollator()
case-sensitive collator
static SC_DLLPUBLIC ScUserList * GetUserList()
static SC_DLLPUBLIC const CharClass & getCharClass()
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
ScRangeList GetMarkedRangesForTab(SCTAB nTab) const
Get marked ranges with sheet-tab set to nTab.
const ScRange & GetMultiMarkArea() const
const ScRange & GetMarkArea() const
bool IsMultiMarked() const
SfxItemSet & GetItemSet()
Additional class containing cell annotation data.
void SetState(sal_uInt64 nVal, sal_uInt64 nNewRange=0)
void SetStateOnPercent(sal_uInt64 nVal)
bool ValidQuery(SCROW nRow, const ScRefCellValue *pCell=nullptr, sc::TableColumnBlockPositionSet *pBlockPos=nullptr)
bool Intersects(const ScRange &rRange) const
std::vector< SCCOLROW > maOrderIndices
index of last non-empty cell position.
std::unique_ptr< RowsType > mpRows
bool IsUpdateRefs() const
void ReorderByRow(const std::vector< SCCOLROW > &rIndices)
std::vector< Row > RowsType
void SetUpdateRefs(bool b)
std::unique_ptr< ScSortInfo[]> const & GetFirstArray() const
Call this only during normal sorting, not from reordering.
SCCOLROW GetStart() const
ScSortInfoArray(const ScSortInfoArray &)=delete
const std::vector< SCCOLROW > & GetOrderIndices() const
RowsType & InitDataRows(size_t nRowSize, size_t nColSize)
ScSortInfoArray(sal_uInt16 nSorts, SCCOLROW nInd1, SCCOLROW nInd2)
void Swap(SCCOLROW nInd1, SCCOLROW nInd2)
Call this only during normal sorting, not from reordering.
void SetOrderIndices(std::vector< SCCOLROW > &&rIndices)
const ScSortInfoArray & operator=(const ScSortInfoArray &)=delete
std::vector< std::unique_ptr< ScSortInfo[]> > mvppInfo
row-wise data table for sort by row operation.
sal_uInt16 GetUsedSorts() const
ScSortInfo & Get(sal_uInt16 nSort, SCCOLROW nInd)
Call this only during normal sorting, not from reordering.
void SetKeepQuery(bool b)
bool CreateExcelQuery(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScQueryParam &rQueryParam)
std::unique_ptr< ScSortInfoArray > CreateSortInfoArray(const sc::ReorderParam &rParam)
void Sort(const ScSortParam &rSortParam, bool bKeepQuery, bool bUpdateRefs, ScProgress *pProgress, sc::ReorderParam *pUndo)
Sort a range of data.
bool ValidCol(SCCOL nCol) const
ScRefCellValue GetCellValue(SCCOL nCol, sc::ColumnBlockPosition &rBlockPos, SCROW nRow)
static void DecoladeRow(ScSortInfoArray *, SCROW nRow1, SCROW nRow2)
void PrepareQuery(ScQueryParam &rQueryParam)
ScColumnsRange GetAllocatedColumnsRange(SCCOL begin, SCCOL end) const
void SortReorderByColumn(const ScSortInfoArray *pArray, SCROW nRow1, SCROW nRow2, bool bPattern, ScProgress *pProgress)
void CopyData(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCCOL nDestCol, SCROW nDestRow, SCTAB nDestTab)
bool HasRowHeader(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow) const
void SetDrawPageSize(bool bResetStreamValid=true, bool bUpdateNoteCaptionPos=true, const ScObjectHandling eObjectHandling=ScObjectHandling::RecalcPosMode)
void SetRowFiltered(SCROW nStartRow, SCROW nEndRow, bool bFiltered)
void DoAutoOutline(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow)
CollatorWrapper * pSortCollator
void UpdateSelectionFunction(ScFunctionData &rData, const ScMarkData &rMark)
void DetachFormulaCells(sc::EndListeningContext &rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
ScFormulaCell * SetFormulaCell(SCCOL nCol, SCROW nRow, ScFormulaCell *pCell)
Takes ownership of pCell.
bool CreateStarQuery(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScQueryParam &rQueryParam)
OUString GetString(SCCOL nCol, SCROW nRow, const ScInterpreterContext *pContext=nullptr) const
bool HasData(SCCOL nCol, SCROW nRow) const
ScColumn & CreateColumnIfNotExists(const SCCOL nScCol)
void QuickSort(ScSortInfoArray *, SCCOLROW nLo, SCCOLROW nHi)
bool IsColValid(const SCCOL nScCol) const
std::unique_ptr< ScBitMaskCompressedArray< SCCOL, CRFlags > > mpColFlags
void SortReorderAreaExtrasByColumn(const ScSortInfoArray *pArray, SCROW nDataRow1, SCROW nDataRow2, const ScDataAreaExtras &rDataAreaExtras, ScProgress *pProgress)
bool GetDataEntries(SCCOL nCol, SCROW nRow, std::set< ScTypedStrData > &rStrings)
sal_uInt64 GetWeightedCount() const
bool SetRowHidden(SCROW nStartRow, SCROW nEndRow, bool bHidden)
void ApplyStyle(SCCOL nCol, SCROW nRow, const ScStyleSheet *rStyle)
void SortReorderAreaExtrasByRow(ScSortInfoArray *pArray, SCCOL nDataCol1, SCCOL nDataCol2, const ScDataAreaExtras &rDataAreaExtras, ScProgress *pProgress)
bool ColHidden(SCCOL nCol, SCCOL *pFirstCol=nullptr, SCCOL *pLastCol=nullptr) const
bool HasColHeader(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow) const
sal_uInt64 GetCodeCount() const
short Compare(SCCOLROW nIndex1, SCCOLROW nIndex2) const
void DestroySortCollator()
void AttachFormulaCells(sc::StartListeningContext &rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
void GetFilteredFilterEntries(SCCOL nCol, SCROW nRow1, SCROW nRow2, const ScQueryParam &rParam, ScFilterEntries &rFilterEntries, bool bFiltering)
bool IsSorted(SCCOLROW nStart, SCCOLROW nEnd) const
OUString GetInputString(SCCOL nCol, SCROW nRow, bool bForceSystemLocale=false) const
bool IsSortCollatorGlobal() const
bool DoSubTotals(ScSubTotalParam &rParam)
void DBShowRows(SCROW nRow1, SCROW nRow2, bool bShow)
bool SetString(SCCOL nCol, SCROW nRow, SCTAB nTab, const OUString &rString, const ScSetStringParam *pParam=nullptr)
bool RowHidden(SCROW nRow, SCROW *pFirstRow=nullptr, SCROW *pLastRow=nullptr) const
void SortReorderByRow(ScSortInfoArray *pArray, SCCOL nCol1, SCCOL nCol2, ScProgress *pProgress, bool bOnlyDataAreaExtras)
void SetRowBreak(SCROW nRow, bool bPage, bool bManual)
void DBShowRow(SCROW nRow, bool bShow)
SCSIZE GetEmptyLinesInBlock(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, ScDirection eDir) const
SCCOL GetAllocatedColumnsCount() const
void SplitFormulaGroups(SCCOL nCol, std::vector< SCROW > &rRows)
bool CreateQueryParam(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScQueryParam &rQueryParam)
std::unique_ptr< ScFlatBoolRowSegments > mpHiddenRows
void SortReorderByRowRefUpdate(ScSortInfoArray *pArray, SCCOL nCol1, SCCOL nCol2, ScProgress *pProgress)
bool RowFiltered(SCROW nRow, SCROW *pFirstRow=nullptr, SCROW *pLastRow=nullptr) const
Color GetCellBackgroundColor(ScAddress aPos) const
CellType GetCellType(const ScAddress &rPos) const
void RemoveSubTotals(ScSubTotalParam &rParam)
sal_Int32 GetMaxStringLen(SCCOL nCol, SCROW nRowStart, SCROW nRowEnd, rtl_TextEncoding eCharSet) const
SvtBroadcaster * GetBroadcaster(SCCOL nCol, SCROW nRow)
const ScPatternAttr * GetPattern(SCCOL nCol, SCROW nRow) const
sal_Int32 GetMaxNumberStringLen(sal_uInt16 &nPrecision, SCCOL nCol, SCROW nRowStart, SCROW nRowEnd) const
SCCOL ClampToAllocatedColumns(SCCOL nCol) const
sal_uInt64 GetCellCount() const
void RegroupFormulaCells(SCCOL nCol)
void SetPattern(const ScAddress &rPos, const ScPatternAttr &rAttr)
void GetFilterEntries(SCCOL nCol, SCROW nRow1, SCROW nRow2, ScFilterEntries &rFilterEntries, bool bFiltering=false)
void Reorder(const sc::ReorderParam &rParam)
Color GetCellTextColor(ScAddress aPos) const
OUString GetUpperCellString(SCCOL nCol, SCROW nRow)
bool RefVisible(const ScFormulaCell *pCell)
void InitSortCollator(const ScSortParam &rPar)
short CompareCell(sal_uInt16 nSort, ScRefCellValue &rCell1, SCCOL nCell1Col, SCROW nCell1Row, ScRefCellValue &rCell2, SCCOL nCell2Col, SCROW nCell2Row) const
void TopTenQuery(ScQueryParam &)
SCSIZE Query(const ScQueryParam &rQueryParam, bool bKeepSub)
bool TestRemoveSubTotals(const ScSubTotalParam &rParam)
void AdjustReferenceOnMovedOriginIfOtherSheet(const ScAddress &rOldPos, const ScAddress &rNewPos)
Adjust all internal references on base position change if they point to a sheet other than the one of...
void AdjustReferenceOnMovedOrigin(const ScAddress &rOldPos, const ScAddress &rNewPos)
Adjust all internal references on base position change.
Stores individual user-defined sort list.
sal_Int32 Compare(const OUString &rSubStr1, const OUString &rSubStr2) const
sal_Int32 ICompare(const OUString &rSubStr1, const OUString &rSubStr2) const
Collection of user-defined sort lists.
const T & Put(std::unique_ptr< T > xItem, sal_uInt16 nWhich=0)
void Remove(const SfxPoolItem &)
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
virtual SfxStyleSheetBase * Find(const OUString &, SfxStyleFamily eFam, SfxStyleSearchBits n=SfxStyleSearchBits::All)
void CopyAllBroadcasters(const SvtListener &r)
virtual void Query(QueryBase &rQuery) const
const_iterator end() const
std::pair< iterator, bool > emplace(Args &&... args)
DataType::const_iterator const_iterator
const_iterator find(DataType::key_type key) const
virtual void execute(SCROW nRow1, SCROW nRow2, bool bVal)=0
virtual void startColumn(ScColumn *pCol)=0
Structure that stores segments of boolean flags per column, and perform custom action on those segmen...
void executeColumnAction(ScDocument &rDoc, ColumnAction &ac) const
void set(const ScDocument &rDoc, SCTAB nTab, SCCOL nCol, SCROW nRow, bool bVal)
Wrapper for ScDocument::EnableDelayDeletingBroadcasters()
void swapRanges(ScRangeList &rRanges)
Set of column block positions only for one table.
SharedString intern(const OUString &rStr)
const OUString & getString() const
#define SC_COLLATOR_IGNORES
#define SAL_WARN(area, stream)
std::unique_ptr< sal_Int32[]> pData
int uniform_int_distribution(int a, int b)
Reference< XComponentContext > getProcessComponentContext()
static bool SplitString(const OUString &sWhole, OUString &sPrefix, OUString &sSuffix, double &fNum)
Splits a given string into three parts: the prefix, number string, and the suffix.
static short Compare(const OUString &sInput1, const OUString &sInput2, const bool bCaseSens, const ScUserListData *pData, const CollatorWrapper *pCW)
Naturally compares two given strings.
void swap(cow_wrapper< T, P > &a, cow_wrapper< T, P > &b)
std::shared_ptr< T > make_shared(Args &&... args)
enumrange< T >::Iterator begin(enumrange< T >)
CAUTION! The following defines must be in the same namespace as the respective type.
std::pair< CellStoreType::const_iterator, size_t > FindFormula(const CellStoreType &rStore, SCROW nRow1, SCROW nRow2, Func &rFunc)
mdds::mtv::soa::multi_type_vector< CellNodeTraits > CellNoteStoreType
Cell note container.
void ParseFormula(const CellStoreType &rStore, Func &rFunc)
mdds::mtv::soa::multi_type_vector< CellStoreTraits > CellStoreType
Cell container.
mdds::mtv::soa::multi_type_vector< CellTextAttrTraits > CellTextAttrStoreType
Cell text attribute container.
mdds::mtv::soa::multi_type_vector< BroadcasterTraits > BroadcasterStoreType
Broadcaster storage container.
const sc::CellStoreType & mrCells
OUString ScResId(TranslateId aId)
constexpr TypedWhichId< SvxLanguageItem > ATTR_LANGUAGE_FORMAT(147)
constexpr TypedWhichId< SfxUInt32Item > ATTR_VALUE_FORMAT(146)
Complex reference (a range) into the sheet.
svl::SharedString maString
Each instance of this struct represents a single filtering criteria.
const Item & GetQueryItem() const
std::vector< Item > QueryItemsType
QueryItemsType & GetQueryItems()
void FillInExcelSyntax(svl::SharedStringPool &rPool, const OUString &aCellStr, SCSIZE nIndex, SvNumberFormatter *pFormatter)
SC_DLLPUBLIC const ScQueryEntry & GetEntry(SCSIZE n) const
SC_DLLPUBLIC SCSIZE GetEntryCount() const
SC_DLLPUBLIC bool RemoveEntryByField(SCCOLROW nField)
This is very similar to ScCellValue, except that it references the original value instead of copying ...
ScFormulaCell * getFormula() const
const EditTextObject * getEditText() const
const svl::SharedString * getSharedString() const
void SetAbsCol(SCCOL nVal)
void SetAbsTab(SCTAB nVal)
void SetAbsRow(SCROW nVal)
const ScPatternAttr * mpPattern
std::vector< SdrObject * > maDrawObjects
const sc::CellTextAttr * mpAttr
std::vector< Cell > maCells
::std::vector< ScSortKeyState > maKeyState
OUString aCollatorAlgorithm
ScDataAreaExtras aDataAreaExtras
css::lang::Locale aCollatorLocale
sal_uInt16 GetSortKeyCount() const
bool bPagebreak
page break at change of group
bool bGroupActive[MAXSUBTOTAL]
active groups
SCCOL nField[MAXSUBTOTAL]
associated field
SCCOL nSubTotals[MAXSUBTOTAL]
number of SubTotals
std::unique_ptr< ScSubTotalFunc[]> pFunctions[MAXSUBTOTAL]
array of associated functions
std::unique_ptr< SCCOL[]> pSubTotals[MAXSUBTOTAL]
array of columns to be calculated
bool bIncludePattern
sort formats
ScDataAreaExtras maDataAreaExtras
std::vector< SCCOLROW > maOrderIndices
List of original column / row positions after reordering.
ScRange maSortRange
This sort range already takes into account the presence or absence of header row / column i....
static void lcl_RemoveNumberFormat(ScTable *pTab, SCCOL nCol, SCROW nRow)
static TranslateId lcl_GetGrandSubTotalStrId(int id)
constexpr sal_Int32 kSortCellsChunk
static TranslateId lcl_GetSubTotalStrId(int id)
sal_Int32 SCCOLROW
a type capable of holding either SCCOL or SCROW