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)
1568 if ( bStr1 && bStr2 )
1575 aStr1 =
GetString(nCell1Col, nCell1Row);
1579 aStr2 =
GetString(nCell2Col, nCell2Row);
1595 nRes = sal::static_int_cast<short>( rData.
Compare(aStr1, aStr2) );
1597 nRes = sal::static_int_cast<short>( rData.
ICompare(aStr1, aStr2) );
1623 else if (bErr1 && bErr2)
1641 else if (nVal1 > nVal2)
1663 sal_uInt16 nSort = 0;
1666 ScSortInfo& rInfo1 = pArray->
Get( nSort, nIndex1 );
1667 ScSortInfo& rInfo2 = pArray->
Get( nSort, nIndex2 );
1676 }
while ( nRes == 0 && ++nSort < pArray->GetUsedSorts() );
1679 ScSortInfo& rInfo1 = pArray->
Get( 0, nIndex1 );
1680 ScSortInfo& rInfo2 = pArray->
Get( 0, nIndex2 );
1681 if( rInfo1.nOrg < rInfo2.nOrg )
1683 else if( rInfo1.nOrg > rInfo2.nOrg )
1691 if ((nHi - nLo) == 1)
1693 if (
Compare(pArray, nLo, nHi) > 0)
1694 pArray->
Swap( nLo, nHi );
1702 while ((ni <= nHi) && (
Compare(pArray, ni, nLo)) < 0)
1704 while ((nj >= nLo) && (
Compare(pArray, nLo, nj)) < 0)
1709 pArray->
Swap( ni, nj );
1714 if ((nj - nLo) < (nHi - ni))
1734 sal_uInt16 nSort = 0;
1746 nRes =
CompareCell(nSort, aCell1, nCol, nIndex1, aCell2, nCol, nIndex2);
1758 aCell1 =
aCol[nIndex1].GetCellValue(nRow);
1760 aCell2 =
aCol[nIndex2].GetCellValue(nRow);
1762 nRow, aCell2,
static_cast<SCCOL>(nIndex2), nRow );
1781 int nMax = nRow2 - nRow1;
1782 for (
SCROW i = nRow1; (
i + 4) <= nRow2;
i += 4)
1785 pArray->
Swap(
i, nRow1 + nRow);
1790 const ScSortParam& rSortParam,
bool bKeepQuery,
bool bUpdateRefs,
1814 if (nRow1 < nLastRow && !
IsSorted(nRow1, nLastRow))
1817 pProgress->
SetState( 0, nLastRow-nRow1 );
1820 aSortParam, nRow1, nLastRow, bKeepQuery, bUpdateRefs));
1822 if ( nLastRow - nRow1 > 255 )
1825 QuickSort(pArray.get(), nRow1, nLastRow);
1826 if (pArray->IsUpdateRefs())
1849 if (nCol1 < nLastCol && !
IsSorted(nCol1, nLastCol))
1852 pProgress->
SetState( 0, nLastCol-nCol1 );
1855 aSortParam, nCol1, nLastCol, bKeepQuery, bUpdateRefs));
1857 QuickSort(pArray.get(), nCol1, nLastCol);
1889 if (pArray->IsUpdateRefs())
1918class SubTotalRowFinder
1925 mrTab(rTab), mrParam(rParam) {}
1937 if (mrTab.
HasData(nCol, nRow))
1942 if (mrTab.
HasData(nCol, nRow))
1958 for (
SCCOL nCol = nStartCol; nCol <= nEndCol; ++nCol)
1961 SubTotalRowFinder aFunc(*
this, rParam);
1962 std::pair<sc::CellStoreType::const_iterator,size_t> aPos =
1964 if (aPos.first != rCells.end())
1972struct RemoveSubTotalsHandler
1974 std::set<SCROW> aRemoved;
1978 if (
p->IsSubTotal())
1979 aRemoved.insert(nRow);
1992 RemoveSubTotalsHandler aFunc;
1993 for (
SCCOL nCol = nStartCol; nCol <= nEndCol; ++nCol)
1999 auto& aRows = aFunc.aRemoved;
2001 std::for_each(aRows.rbegin(), aRows.rend(), [
this](
const SCROW nRow) {
2002 RemoveRowBreak(nRow+1, false, true);
2003 rDocument.DeleteRow(0, nTab, rDocument.MaxCol(), nTab, nRow, 1);
2006 rParam.
nRow2 -= aRows.size();
2015 == SfxItemState::SET )
2017 auto pNewPattern = std::make_unique<ScPatternAttr>( *pPattern );
2021 pTab->
SetPattern( nCol, nRow, std::move(pNewPattern) );
2029 sal_uInt16 nGroupNo;
2055 return STR_EMPTYDATA;
2079 return STR_EMPTYDATA;
2102 sal_uInt16 nLevelCount = 0;
2103 bool bDoThis =
true;
2118 bool bTestPrevSub = ( nLevelCount > 1 );
2120 OUString aSubString;
2129 ScResId(STR_STYLENAME_RESULT), SfxStyleFamily::Para ));
2131 bool bSpaceLeft =
true;
2137 ::std::vector< RowEntry > aRowVector;
2139 for (sal_uInt16 nLevel=0; nLevel<nLevelCount && bSpaceLeft; nLevel++)
2141 aRowEntry.nGroupNo = nLevelCount - nLevel - 1;
2150 for (
i=0;
i<=aRowEntry.nGroupNo;
i++)
2152 aSubString =
GetString( nGroupCol[
i], nStartRow );
2156 aCompString[
i] = aSubString;
2159 bool bBlockVis =
false;
2160 aRowEntry.nSubStartRow = nStartRow;
2161 for (
SCROW nRow=nStartRow; nRow<=nEndRow+1 && bSpaceLeft; nRow++)
2170 for (
i=0;
i<=aRowEntry.nGroupNo && !bChanged;
i++)
2177 bChanged = ( ( !aString.isEmpty() || rParam.
bDoSort ) &&
2178 aString != aCompString[
i] );
2180 if ( bChanged && bTestPrevSub )
2183 bChanged = std::none_of(aRowVector.begin(), aRowVector.end(),
2184 [&nRow](
const RowEntry& rEntry) { return rEntry.nDestRow == nRow; });
2189 aRowEntry.nDestRow = nRow;
2190 aRowEntry.nFuncStart = aRowEntry.nSubStartRow;
2191 aRowEntry.nFuncEnd = nRow-1;
2194 aRowEntry.nDestRow, 1 );
2195 DBShowRow( aRowEntry.nDestRow, bBlockVis );
2197 aRowEntry.nSubStartRow != nStartRow && nLevel == 0)
2202 for (
auto& rRowEntry : aRowVector)
2204 if ( aRowEntry.nDestRow <= rRowEntry.nSubStartRow )
2205 ++rRowEntry.nSubStartRow;
2206 if ( aRowEntry.nDestRow <= rRowEntry.nDestRow )
2207 ++rRowEntry.nDestRow;
2208 if ( aRowEntry.nDestRow <= rRowEntry.nFuncStart )
2209 ++rRowEntry.nFuncStart;
2210 if ( aRowEntry.nDestRow <= rRowEntry.nFuncEnd )
2211 ++rRowEntry.nFuncEnd;
2214 aRowVector.push_back( aRowEntry );
2216 OUString aOutString = aSubString;
2217 if (aOutString.isEmpty())
2218 aOutString =
ScResId( STR_EMPTYDATA );
2221 if ( nResCount == 1 )
2223 aOutString +=
ScResId(pStrId);
2224 SetString( nGroupCol[aRowEntry.nGroupNo], aRowEntry.nDestRow,
nTab, aOutString );
2225 ApplyStyle( nGroupCol[aRowEntry.nGroupNo], aRowEntry.nDestRow, pStyle );
2229 aRowEntry.nSubStartRow = nRow;
2230 for (
i=0;
i<=aRowEntry.nGroupNo;
i++)
2232 aSubString =
GetString( nGroupCol[
i], nRow );
2236 aCompString[
i] = aSubString;
2245 if (!aRowVector.empty())
2248 SCROW nGlobalStartRow = aRowVector[0].nSubStartRow;
2249 SCROW nGlobalStartFunc = aRowVector[0].nFuncStart;
2250 SCROW nGlobalEndRow = 0;
2251 SCROW nGlobalEndFunc = 0;
2252 for (
const auto& rRowEntry : aRowVector)
2254 nGlobalEndRow = (nGlobalEndRow < rRowEntry.nDestRow) ? rRowEntry.nDestRow : nGlobalEndRow;
2255 nGlobalEndFunc = (nGlobalEndFunc < rRowEntry.nFuncEnd) ? rRowEntry.nFuncEnd : nGlobalEndRow;
2258 for (sal_uInt16 nLevel = 0; nLevel<nLevelCount; nLevel++)
2260 const sal_uInt16 nGroupNo = nLevelCount - nLevel - 1;
2273 aRowEntry.nGroupNo = nGroupNo;
2274 aRowEntry.nSubStartRow = nGlobalStartRow;
2275 aRowEntry.nFuncStart = nGlobalStartFunc;
2276 aRowEntry.nDestRow = nGlobalEndRow;
2277 aRowEntry.nFuncEnd = nGlobalEndFunc;
2286 aRowVector.push_back(aRowEntry);
2293 ApplyStyle(nGroupCol[aRowEntry.nGroupNo], aRowEntry.nDestRow, pStyle);
2303 for (
const auto& rRowEntry : aRowVector)
2308 for (
SCCOL nResult=0; nResult < nResCount; ++nResult )
2318 aArr.AddDouble(
static_cast<double>(pResFunc[nResult]) );
2320 aArr.AddDoubleReference( aRef );
2329 if ( nResCols[nResult] != nGroupCol[rRowEntry.nGroupNo] )
2331 ApplyStyle( nResCols[nResult], rRowEntry.nDestRow, pStyle );
2346 rParam.
nRow2 = nEndRow;
2352 bool bSortCollatorInitialized =
false;
2372 if (!bSortCollatorInitialized)
2374 bSortCollatorInitialized =
true;
2380 std::unique_ptr<ScSortInfo[]>
const& ppInfo = pArray->GetFirstArray();
2383 while (nValidCount > 0 && ppInfo[nValidCount - 1].maCell.isEmpty())
2386 while (nValidCount > 0 && ppInfo[nValidCount - 1].maCell.hasString())
2388 if (nValidCount > 0)
2395 SCSIZE nVal = (rItem.mfVal >= 1 ?
static_cast<SCSIZE>(rItem.mfVal) : 1);
2402 if (nVal > nValidCount)
2404 nOffset = nValidCount - nVal;
2410 if (nVal > nValidCount)
2420 nOffset = nValidCount - (nValidCount * nVal / 100);
2421 if (nOffset >= nValidCount)
2422 nOffset = nValidCount - 1;
2430 nOffset = (nValidCount * nVal / 100);
2431 if (nOffset >= nValidCount)
2432 nOffset = nValidCount - 1;
2445 OSL_FAIL(
"TopTenQuery: pCell no ValueData");
2465 if ( bSortCollatorInitialized )
2471bool CanOptimizeQueryStringToNumber(
const SvNumberFormatter* pFormatter, sal_uInt32 nFormatIndex,
bool& bDateFormat )
2481 switch(pEntry->GetType())
2483 case SvNumFormatType::NUMBER:
2484 case SvNumFormatType::FRACTION:
2485 case SvNumFormatType::SCIENTIFIC:
2487 case SvNumFormatType::DATE:
2488 case SvNumFormatType::DATETIME:
2498class PrepareQueryItem
2501 const bool mbRoundForFilter;
2503 explicit PrepareQueryItem(
const ScDocument& rDoc,
bool bRoundForFilter) :
2504 mrDoc(rDoc), mbRoundForFilter(bRoundForFilter) {}
2523 bool bDateFormat =
false;
2524 if (bNumber && CanOptimizeQueryStringToNumber( mrDoc.
GetFormatTable(), nIndex, bDateFormat ))
2532 if (bNumber && ((nIndex % SV_COUNTRY_LANGUAGE_OFFSET) != 0))
2538 if (!(nNumFmtType & SvNumFormatType::DATE) || (nNumFmtType & SvNumFormatType::TIME))
2553 bool bTopTen =
false;
2556 for (
SCSIZE i = 0;
i < nEntryCount; ++
i )
2563 std::for_each(rItems.begin(), rItems.end(), PrepareQueryItem(*pDoc, bRoundForFilter));
2567 switch ( rEntry.
eOp )
2594 lcl_PrepareQuery(&
rDocument,
this, rQueryParam,
false);
2600 typedef std::unordered_set<OUString> StrSetType;
2603 bool bStarted =
false;
2604 bool bOldResult =
true;
2605 SCROW nOldStart = 0;
2612 lcl_PrepareQuery(&
rDocument,
this, aParam,
true);
2616 nOutRow = aParam.
nDestRow + nHeader;
2626 for (
SCROW j = aParam.
nRow1 + nHeader; j <= nRealRow2; ++j)
2629 bool bValid = queryEvaluator.
ValidQuery(j,
nullptr, &blockPos);
2630 if (!bValid && bKeepSub)
2651 OUStringBuffer
aStr;
2655 aStr.append(aCellStr +
u"\x0001");
2658 bResult = aStrSet.insert(
aStr.makeStringAndClear()).second;
2666 if (bResult == bOldResult && bStarted)
2672 nOldStart = nOldEnd = j;
2673 bOldResult = bResult;
2703 std::unique_ptr<SCCOL[]> pFields(
new SCCOL[nCol2-nCol1+1]);
2706 OSL_ENSURE( rQueryParam.
nTab !=
SCTAB_MAX,
"rQueryParam.nTab no value, not bad but no good" );
2711 while (bValid && (nCol <= nCol2))
2714 bool bFound =
false;
2716 while (!bFound && (
i <= nDBCol2))
2718 if (
nTab == nDBTab )
2722 bFound = (aCellStr == aQueryStr);
2726 pFields[nCol - nCol1] =
i;
2735 nVisible +=
aCol[nCol].VisibleCount( nRow1+1, nRow2 );
2739 OSL_FAIL(
"too many filter criteria");
2743 SCSIZE nNewEntries = nVisible;
2744 rQueryParam.
Resize( nNewEntries );
2747 SCROW nRow = nRow1 + 1;
2749 while (nRow <= nRow2)
2752 while (nCol <= nCol2)
2755 if (!aCellStr.isEmpty())
2757 if (
nIndex < nNewEntries)
2762 if (
nIndex < nNewEntries)
2771 if (
nIndex < nNewEntries)
2788 if (nCol2 - nCol1 < 3)
2795 OSL_ENSURE( rQueryParam.
nTab !=
SCTAB_MAX,
"rQueryParam.nTab no value, not bad but no good" );
2800 SCSIZE nNewEntries =
static_cast<SCSIZE>(nRow2-nRow1+1);
2801 rQueryParam.
Resize( nNewEntries );
2813 if ( aCellStr ==
ScResId(STR_TABLE_AND) )
2818 else if ( aCellStr ==
ScResId(STR_TABLE_OR) )
2825 if ((
nIndex < 1) || bValid)
2827 bool bFound =
false;
2829 for (
SCCOL i=rQueryParam.
nCol1; (
i <= nDBCol2) && (!bFound);
i++)
2832 if (
nTab == nDBTab )
2836 bFound = (aCellStr == aFieldStr);
2850 if (aCellStr.startsWith(
"<"))
2852 if (aCellStr[1] ==
'>')
2854 else if (aCellStr[1] ==
'=')
2859 else if (aCellStr.startsWith(
">"))
2861 if (aCellStr[1] ==
'=')
2866 else if (aCellStr.startsWith(
"="))
2880 while (bValid && (nRow <= nRow2) );
2895 bool bValid =
CreateStarQuery(nCol1, nRow1, nCol2, nRow2, rQueryParam);
2911 bool bDateFormat =
false;
2912 rItem.
meType = bNumber && CanOptimizeQueryStringToNumber( pFormatter,
nIndex, bDateFormat )
2926 if (nStartRow == nEndRow)
2932 for (
SCCOL nCol=nStartCol; nCol<=nEndCol; nCol++)
2941 SCROW nTestRow = nStartRow + 1;
2942 for (
SCCOL nCol=nStartCol; nCol<=nEndCol; nCol++)
2955 if (nStartCol == nEndCol)
2961 for (
SCROW nRow=nStartRow; nRow<=nEndRow; nRow++)
2970 SCCOL nTestCol = nStartCol + 1;
2971 for (
SCROW nRow=nStartRow; nRow<=nEndRow; nRow++)
2988 aCol[nCol].InitBlockPosition(aBlockPos);
2989 aCol[nCol].GetFilterEntries(aBlockPos, nRow1, nRow2, rFilterEntries, bFiltering,
false );
2999 aCol[nCol].InitBlockPosition(aBlockPos);
3005 lcl_PrepareQuery(&
rDocument,
this, aParam,
true);
3007 for (
SCROW j = nRow1; j <= nRow2; ++j )
3011 aCol[nCol].GetFilterEntries(aBlockPos, j, j, rFilterEntries, bFiltering,
false);
3015 aCol[nCol].GetFilterEntries(aBlockPos, j, j, rFilterEntries, bFiltering,
true);
3024 return aCol[nCol].GetDataEntries( nRow, rStrings);
3029 sal_uInt64 nCellCount = 0;
3039 sal_uInt64 nCellCount = 0;
3049 sal_uInt64 nCellCount = 0;
3059 sal_uInt64 nCodeCount = 0;
3063 nCodeCount +=
aCol[nCol].GetCodeCount();
3069 SCROW nRowEnd, rtl_TextEncoding eCharSet )
const
3072 return aCol[nCol].GetMaxStringLen( nRowStart, nRowEnd, eCharSet );
3078 sal_uInt16& nPrecision,
SCCOL nCol,
SCROW nRowStart,
SCROW nRowEnd )
const
3081 return aCol[nCol].GetMaxNumberStringLen( nPrecision, nRowStart, nRowEnd );
3096 assert(!
"ScTable::UpdateSelectionFunction - called without anything marked");
3102 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
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)
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) const
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