sc/source/ui/view/tabvwsh4.cxx | 67 +++++++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 28 deletions(-)
New commits: commit eef514e5c375b50883189fc9383f2394e00f1bc2 Author: Noel Grandin <[email protected]> AuthorDate: Thu Jan 29 17:12:02 2026 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Thu Jan 29 20:52:35 2026 +0100 tdf#166121 split lcl_CheckInArray function to make the different cases easier to optimise Change-Id: I4c59fbf7586d137de5f270b88457ff1880d6adfb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198375 Reviewed-by: Noel Grandin <[email protected]> Tested-by: Jenkins diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx index bcf4be6ab8b3..bff3d4930f1f 100644 --- a/sc/source/ui/view/tabvwsh4.cxx +++ b/sc/source/ui/view/tabvwsh4.cxx @@ -1817,13 +1817,38 @@ ScViewOptiChangesListener::ScViewOptiChangesListener(ScTabViewShell& rViewShell) m_xColorSchemeChangesNotifier->addChangesListener(this); } -/* For rows (bool bRows), I am passing reference to already existing sequence, and comparing the required - * columns, whereas for columns, I am creating a sequence for each, with only the checked entries +/* For rows I am passing reference to already existing sequence, and comparing the required + * columns. + */ +static bool lcl_CheckInArrayRows(std::vector<uno::Sequence<uno::Any>>& nUniqueRecords, + const uno::Sequence<uno::Any>& nCurrentRecord, + const std::vector<int>& rSelectedEntries) +{ + for (size_t m = 0; m < nUniqueRecords.size(); ++m) + { + bool bIsDuplicate = true; + for (size_t n = 0; n < rSelectedEntries.size(); ++n) + { + // when the first different element is found + int nColumn = rSelectedEntries[n]; + if (nUniqueRecords[m][nColumn] != nCurrentRecord[rSelectedEntries[n]]) + { + bIsDuplicate = false; + break; + } + } + + if (bIsDuplicate) + return true; + } + return false; +} +/* For columns, I am creating a sequence for each, with only the checked entries * in the dialog. */ -static bool lcl_CheckInArray(std::vector<uno::Sequence<uno::Any>>& nUniqueRecords, +static bool lcl_CheckInArrayCols(std::vector<uno::Sequence<uno::Any>>& nUniqueRecords, const uno::Sequence<uno::Any>& nCurrentRecord, - const std::vector<int>& rSelectedEntries, bool bRows) + const std::vector<int>& rSelectedEntries) { for (size_t m = 0; m < nUniqueRecords.size(); ++m) { @@ -1831,8 +1856,8 @@ static bool lcl_CheckInArray(std::vector<uno::Sequence<uno::Any>>& nUniqueRecord for (size_t n = 0; n < rSelectedEntries.size(); ++n) { // when the first different element is found - int nColumn = (bRows ? rSelectedEntries[n] : n); - if (nUniqueRecords[m][nColumn] != (bRows ? nCurrentRecord[rSelectedEntries[n]] : nCurrentRecord[n])) + int nColumn = n; + if (nUniqueRecords[m][nColumn] != nCurrentRecord[n]) { bIsDuplicate = false; break; @@ -1956,7 +1981,7 @@ void ScTabViewShell::HandleDuplicateRecordsHighlight(const rtl::Reference<ScTabl while (nRow < lRows) { - if (lcl_CheckInArray(aUnionArray, aDataArray[nRow], rSelectedEntries, true)) + if (lcl_CheckInArrayRows(aUnionArray, aDataArray[nRow], rSelectedEntries)) { for (int nCol = aRange.StartColumn; nCol <= aRange.EndColumn; ++nCol) { @@ -1986,7 +2011,7 @@ void ScTabViewShell::HandleDuplicateRecordsHighlight(const rtl::Reference<ScTabl for (size_t i = 0; i < rSelectedEntries.size(); ++i) aSeq.getArray()[i] = aDataArray[rSelectedEntries[i]][nColumn]; - if (lcl_CheckInArray(aUnionArray, aSeq, rSelectedEntries, false)) + if (lcl_CheckInArrayCols(aUnionArray, aSeq, rSelectedEntries)) { for (int nRow = aRange.StartRow; nRow <= aRange.EndRow; ++nRow) { @@ -2058,7 +2083,7 @@ void ScTabViewShell::HandleDuplicateRecordsRemove(const rtl::Reference<ScTableSh while (nRow < lRows) { - if (lcl_CheckInArray(aUnionArray, aDataArray[nRow], rSelectedEntries, true)) + if (lcl_CheckInArrayRows(aUnionArray, aDataArray[nRow], rSelectedEntries)) { table::CellRangeAddress aCellRange(aRange.Sheet, aRange.StartColumn, aRange.StartRow + nRow - nDeleteCount, @@ -2087,7 +2112,7 @@ void ScTabViewShell::HandleDuplicateRecordsRemove(const rtl::Reference<ScTableSh for (size_t i = 0; i < rSelectedEntries.size(); ++i) aSeq.getArray()[i] = aDataArray[rSelectedEntries[i]][nColumn]; - if (lcl_CheckInArray(aUnionArray, aSeq, rSelectedEntries, false)) + if (lcl_CheckInArrayCols(aUnionArray, aSeq, rSelectedEntries)) { table::CellRangeAddress aCellRange(aRange.Sheet, aRange.StartColumn + nColumn - nDeleteCount, aRange.StartRow, commit 8b2a0bbd246f685f5fe85c7add736f60a110188d Author: Noel Grandin <[email protected]> AuthorDate: Thu Jan 29 17:06:09 2026 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Thu Jan 29 20:52:24 2026 +0100 tdf#166121 inline lcl_RemoveCells to make it easier to optimise Change-Id: If190a8b9f41bcf32fc3c27226d4b21879e190f34 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198374 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx index 7e2cb7ebe91f..bcf4be6ab8b3 100644 --- a/sc/source/ui/view/tabvwsh4.cxx +++ b/sc/source/ui/view/tabvwsh4.cxx @@ -1817,22 +1817,6 @@ ScViewOptiChangesListener::ScViewOptiChangesListener(ScTabViewShell& rViewShell) m_xColorSchemeChangesNotifier->addChangesListener(this); } -static void lcl_RemoveCells(const uno::Reference<sheet::XSpreadsheet>& rSheet, sal_uInt16 nSheet, - sal_uInt32 nStartColumn, sal_uInt32 nStartRow, sal_uInt32 nEndColumn, - sal_uInt32 nEndRow, bool bRows) -{ - table::CellRangeAddress aCellRange(nSheet, nStartColumn, nStartRow, nEndColumn, nEndRow); - uno::Reference<sheet::XCellRangeMovement> xCRM(rSheet, uno::UNO_QUERY); - - if (xCRM.is()) - { - if (bRows) - xCRM->removeRange(aCellRange, sheet::CellDeleteMode_UP); - else - xCRM->removeRange(aCellRange, sheet::CellDeleteMode_LEFT); - } -} - /* For rows (bool bRows), I am passing reference to already existing sequence, and comparing the required * columns, whereas for columns, I am creating a sequence for each, with only the checked entries * in the dialog. @@ -2076,9 +2060,10 @@ void ScTabViewShell::HandleDuplicateRecordsRemove(const rtl::Reference<ScTableSh { if (lcl_CheckInArray(aUnionArray, aDataArray[nRow], rSelectedEntries, true)) { - lcl_RemoveCells(ActiveSheet, aRange.Sheet, aRange.StartColumn, - aRange.StartRow + nRow - nDeleteCount, aRange.EndColumn, - aRange.StartRow + nRow - nDeleteCount, true); + table::CellRangeAddress aCellRange(aRange.Sheet, aRange.StartColumn, + aRange.StartRow + nRow - nDeleteCount, + aRange.EndColumn, aRange.StartRow + nRow - nDeleteCount); + ActiveSheet->removeRange(aCellRange, sheet::CellDeleteMode_UP); ++nDeleteCount; } else @@ -2104,9 +2089,10 @@ void ScTabViewShell::HandleDuplicateRecordsRemove(const rtl::Reference<ScTableSh if (lcl_CheckInArray(aUnionArray, aSeq, rSelectedEntries, false)) { - lcl_RemoveCells(ActiveSheet, aRange.Sheet, - aRange.StartColumn + nColumn - nDeleteCount, aRange.StartRow, - aRange.StartColumn + nColumn - nDeleteCount, aRange.EndRow, false); + table::CellRangeAddress aCellRange(aRange.Sheet, + aRange.StartColumn + nColumn - nDeleteCount, aRange.StartRow, + aRange.StartColumn + nColumn - nDeleteCount, aRange.EndRow); + ActiveSheet->removeRange(aCellRange, sheet::CellDeleteMode_LEFT); ++nDeleteCount; } else
