From 5a7157d319477830426797532e02ac39d3b859f4 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 15 Apr 2024 11:29:03 +0200 Subject: Merging upstream version 4:24.2.1. Signed-off-by: Daniel Baumann --- sc/source/core/data/colcontainer.cxx | 5 ++-- sc/source/core/data/column3.cxx | 4 +-- sc/source/core/data/dociter.cxx | 2 +- sc/source/core/data/documen3.cxx | 2 ++ sc/source/core/data/document.cxx | 4 +++ sc/source/core/data/document10.cxx | 17 ++++-------- sc/source/core/data/table2.cxx | 9 ++++-- sc/source/core/data/table4.cxx | 2 +- sc/source/core/data/validat.cxx | 3 ++ sc/source/core/tool/compiler.cxx | 10 +++++-- sc/source/core/tool/typedstrdata.cxx | 54 +++++++++++++++++++++++++++++++++--- 11 files changed, 84 insertions(+), 28 deletions(-) (limited to 'sc/source/core') diff --git a/sc/source/core/data/colcontainer.cxx b/sc/source/core/data/colcontainer.cxx index f6ef8ff7da..a0a9d84577 100644 --- a/sc/source/core/data/colcontainer.cxx +++ b/sc/source/core/data/colcontainer.cxx @@ -47,10 +47,9 @@ void ScColContainer::Clear() void ScColContainer::resize( ScSheetLimits const & rSheetLimits, const size_t aNewColSize ) { size_t aOldColSize = aCols.size(); - if (aNewColSize > aCols.capacity()) - aCols.reserve( aNewColSize ); + aCols.resize( aNewColSize ); for ( size_t nCol = aOldColSize; nCol < aNewColSize; ++nCol ) - aCols.emplace_back(new ScColumn(rSheetLimits)); + aCols[nCol].reset(new ScColumn(rSheetLimits)); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx index a0b0c639a0..7902722638 100644 --- a/sc/source/core/data/column3.cxx +++ b/sc/source/core/data/column3.cxx @@ -2584,7 +2584,7 @@ class FilterEntriesHandler { if (!mrFilterEntries.mbHasEmpties) { - mrFilterEntries.push_back(ScTypedStrData(OUString())); + mrFilterEntries.push_back(ScTypedStrData(OUString(), 0.0, 0.0, ScTypedStrData::Standard, false, mbFilteredRow)); mrFilterEntries.mbHasEmpties = true; } return; @@ -2614,7 +2614,7 @@ class FilterEntriesHandler OUString aErr = ScGlobal::GetErrorString(nErr); if (!aErr.isEmpty()) { - mrFilterEntries.push_back(ScTypedStrData(std::move(aErr))); + mrFilterEntries.push_back(ScTypedStrData(std::move(aErr), 0.0, 0.0, ScTypedStrData::Standard, false, mbFilteredRow)); return; } } diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx index b1fca78c86..1fe1f5344d 100644 --- a/sc/source/core/data/dociter.cxx +++ b/sc/source/core/data/dociter.cxx @@ -1683,13 +1683,13 @@ void ScDocRowHeightUpdater::updateAll(const bool bOnlyUsedRows) ScProgress aProgress(mrDoc.GetDocumentShell(), ScResId(STR_PROGRESS_HEIGHTING), nCellCount, true); Fraction aZoom(1, 1); - sc::RowHeightContext aCxt(mrDoc.MaxRow(), mfPPTX, mfPPTY, aZoom, aZoom, mpOutDev); sal_uInt64 nProgressStart = 0; for (SCTAB nTab = 0; nTab < mrDoc.GetTableCount(); ++nTab) { if (!ValidTab(nTab) || !mrDoc.maTabs[nTab]) continue; + sc::RowHeightContext aCxt(mrDoc.MaxRow(), mfPPTX, mfPPTY, aZoom, aZoom, mpOutDev); SCCOL nEndCol = 0; SCROW nEndRow = mrDoc.MaxRow(); if (!bOnlyUsedRows || mrDoc.GetPrintArea(nTab, nEndCol, nEndRow)) diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx index b42a8d36b5..8ae4ff6c4e 100644 --- a/sc/source/core/data/documen3.cxx +++ b/sc/source/core/data/documen3.cxx @@ -89,6 +89,7 @@ void sortAndRemoveDuplicates(std::vector& rStrings, bool bCaseSe std::vector::iterator it = std::unique(rStrings.begin(), rStrings.end(), ScTypedStrData::EqualCaseSensitive()); rStrings.erase(it, rStrings.end()); + std::stable_sort(rStrings.begin(), rStrings.end(), ScTypedStrData::LessSortCaseSensitive()); } else { @@ -96,6 +97,7 @@ void sortAndRemoveDuplicates(std::vector& rStrings, bool bCaseSe std::vector::iterator it = std::unique(rStrings.begin(), rStrings.end(), ScTypedStrData::EqualCaseInsensitive()); rStrings.erase(it, rStrings.end()); + std::stable_sort(rStrings.begin(), rStrings.end(), ScTypedStrData::LessSortCaseInsensitive()); } if (std::any_of(rStrings.begin(), rStrings.end(), [](ScTypedStrData& rString) { return rString.IsHiddenByFilter(); })) { diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index ff6d77b432..15bb28fe61 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -6896,6 +6896,8 @@ void ScDocument::GetNotesInRange( const ScRangeList& rRangeList, std::vectorGetNotesInRange( rRange, rNotes ); } } @@ -6914,6 +6916,8 @@ bool ScDocument::ContainsNotesInRange( const ScRangeList& rRangeList ) const const ScRange & rRange = rRangeList[i]; for( SCTAB nTab = rRange.aStart.Tab(); nTab <= rRange.aEnd.Tab(); ++nTab ) { + if (!maTabs[nTab]) + continue; bool bContainsNote = maTabs[nTab]->ContainsNotesInRange( rRange ); if(bContainsNote) return true; diff --git a/sc/source/core/data/document10.cxx b/sc/source/core/data/document10.cxx index acf0f27672..df50575589 100644 --- a/sc/source/core/data/document10.cxx +++ b/sc/source/core/data/document10.cxx @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include #include @@ -188,17 +188,10 @@ std::set ScDocument::GetDocColors() { std::set aDocColors; ScDocumentPool *pPool = GetPool(); - const sal_uInt16 pAttribs[] = {ATTR_BACKGROUND, ATTR_FONT_COLOR}; - for (sal_uInt16 nAttrib : pAttribs) - { - for (const SfxPoolItem* pItem : pPool->GetItemSurrogates(nAttrib)) - { - const SvxColorItem *pColorItem = static_cast(pItem); - Color aColor( pColorItem->GetValue() ); - if (COL_AUTO != aColor) - aDocColors.insert(aColor); - } - } + + svx::DocumentColorHelper::queryColors(ATTR_BACKGROUND, pPool, aDocColors); + svx::DocumentColorHelper::queryColors(ATTR_FONT_COLOR, pPool, aDocColors); + return aDocColors; } diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index afe2216b1a..6d7c5b0ac8 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -503,6 +503,7 @@ void ScTable::CopyToClip( nCol2 = ClampToAllocatedColumns(nCol2); + pTable->CreateColumnIfNotExists(nCol2); // prevent repeated resizing for ( SCCOL i = nCol1; i <= nCol2; i++) aCol[i].CopyToClip(rCxt, nRow1, nRow2, pTable->CreateColumnIfNotExists(i)); // notes are handled at column level @@ -638,6 +639,9 @@ void ScTable::CopyConditionalFormat( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCRO { ScRange aOldRange( nCol1 - nDx, nRow1 - nDy, pTable->nTab, nCol2 - nDx, nRow2 - nDy, pTable->nTab); ScRange aNewRange( nCol1, nRow1, nTab, nCol2, nRow2, nTab ); + // Don't deduplicate when undoing or creating an Undo document! It would disallow correct undo + bool bUndoContext = rDocument.IsUndo() || pTable->rDocument.IsUndo(); + // Note that Undo documents use same pool as the original document bool bSameDoc = rDocument.GetStyleSheetPool() == pTable->rDocument.GetStyleSheetPool(); for(const auto& rxCondFormat : *pTable->mpCondFormatList) @@ -658,7 +662,7 @@ void ScTable::CopyConditionalFormat( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCRO aRefCxt.mnTabDelta = nTab - pTable->nTab; pNewFormat->UpdateReference(aRefCxt, true); - if (bSameDoc && pTable->nTab == nTab && CheckAndDeduplicateCondFormat(rDocument, mpCondFormatList->GetFormat(rxCondFormat->GetKey()), pNewFormat.get(), nTab)) + if (!bUndoContext && bSameDoc && pTable->nTab == nTab && CheckAndDeduplicateCondFormat(rDocument, mpCondFormatList->GetFormat(rxCondFormat->GetKey()), pNewFormat.get(), nTab)) { continue; } @@ -668,7 +672,7 @@ void ScTable::CopyConditionalFormat( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCRO { // Check if there is the same format in the destination // If there is, then simply expand its range - if (CheckAndDeduplicateCondFormat(rDocument, rxCond.get(), pNewFormat.get(), nTab)) + if (!bUndoContext && CheckAndDeduplicateCondFormat(rDocument, rxCond.get(), pNewFormat.get(), nTab)) { bDuplicate = true; break; @@ -1348,6 +1352,7 @@ void ScTable::CopyToTable( // can lead to repetitive splitting and rejoining of the same formula group, which can get // quadratically expensive with large groups. So do the grouping just once at the end. sc::DelayFormulaGroupingSwitch delayGrouping( pDestTab->rDocument, true ); + pDestTab->CreateColumnIfNotExists(ClampToAllocatedColumns(nCol2)); // avoid repeated resizing for (SCCOL i = nCol1; i <= ClampToAllocatedColumns(nCol2); i++) aCol[i].CopyToColumn(rCxt, nRow1, nRow2, bToUndoDoc ? nFlags : nTempFlags, bMarked, pDestTab->CreateColumnIfNotExists(i), pMarkData, bAsLink, bGlobalNamesToLocal); diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx index 62b9dbb9e0..f8a03dd4c7 100644 --- a/sc/source/core/data/table4.cxx +++ b/sc/source/core/data/table4.cxx @@ -1314,7 +1314,7 @@ void ScTable::GetBackColorArea(SCCOL& rStartCol, SCROW& /*rStartRow*/, const ScPatternAttr* pPattern = ColumnData(nCol).GetPattern(rEndRow + 1); const SvxBrushItem* pBackground = &pPattern->GetItem(ATTR_BACKGROUND); if (!pPattern->GetItem(ATTR_CONDITIONAL).GetCondFormatData().empty() || - pBackground != pDefBackground) + (pBackground->GetColor() != COL_TRANSPARENT && pBackground != pDefBackground)) { bExtend = true; break; diff --git a/sc/source/core/data/validat.cxx b/sc/source/core/data/validat.cxx index a46b09986b..5a569ef944 100644 --- a/sc/source/core/data/validat.cxx +++ b/sc/source/core/data/validat.cxx @@ -381,6 +381,9 @@ bool ScValidationData::DoError(weld::Window* pParent, const OUString& rInput, if ( eErrorStyle == SC_VALERR_MACRO ) return DoMacro(rPos, rInput, nullptr, pParent); + if (!bShowError) + return true; + // Output error message OUString aTitle = aErrorTitle; diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx index 63b1f09692..c9934c26ff 100644 --- a/sc/source/core/tool/compiler.cxx +++ b/sc/source/core/tool/compiler.cxx @@ -4738,6 +4738,7 @@ std::unique_ptr ScCompiler::CompileString( const OUString& rFormul pFunctionStack[0].eOp = ocNone; pFunctionStack[0].nSep = 0; size_t nFunction = 0; + size_t nHighWatermark = 0; short nBrackets = 0; bool bInArray = false; eLastOp = ocOpen; @@ -4757,6 +4758,7 @@ std::unique_ptr ScCompiler::CompileString( const OUString& rFormul ++nFunction; pFunctionStack[ nFunction ].eOp = eLastOp; pFunctionStack[ nFunction ].nSep = 0; + nHighWatermark = nFunction; } } break; @@ -4795,6 +4797,7 @@ std::unique_ptr ScCompiler::CompileString( const OUString& rFormul ++nFunction; pFunctionStack[ nFunction ].eOp = eOp; pFunctionStack[ nFunction ].nSep = 0; + nHighWatermark = nFunction; } } break; @@ -4825,6 +4828,7 @@ std::unique_ptr ScCompiler::CompileString( const OUString& rFormul ++nFunction; pFunctionStack[ nFunction ].eOp = eOp; pFunctionStack[ nFunction ].nSep = 0; + nHighWatermark = nFunction; } } break; @@ -4867,9 +4871,9 @@ std::unique_ptr ScCompiler::CompileString( const OUString& rFormul // Append a parameter for WEEKNUM, all 1.0 // Function is already closed, parameter count is nSep+1 size_t nFunc = nFunction + 1; - if (eOp == ocClose && - (pFunctionStack[ nFunc ].eOp == ocWeek && // 2nd week start - pFunctionStack[ nFunc ].nSep == 0)) + if (eOp == ocClose && nFunc <= nHighWatermark && + pFunctionStack[ nFunc ].nSep == 0 && + pFunctionStack[ nFunc ].eOp == ocWeek) // 2nd week start { if ( !static_cast(pArr)->Add( new FormulaToken( svSep, ocSep)) || !static_cast(pArr)->Add( new FormulaDoubleToken( 1.0))) diff --git a/sc/source/core/tool/typedstrdata.cxx b/sc/source/core/tool/typedstrdata.cxx index e00c1bc18d..4e3f862ae3 100644 --- a/sc/source/core/tool/typedstrdata.cxx +++ b/sc/source/core/tool/typedstrdata.cxx @@ -34,8 +34,31 @@ bool ScTypedStrData::LessCaseSensitive::operator() (const ScTypedStrData& left, if (left.mbIsDate != right.mbIsDate) return left.mbIsDate < right.mbIsDate; - sal_Int32 nEqual = ScGlobal::GetCaseCollator().compareString( - left.maStrValue, right.maStrValue); + sal_Int32 nEqual + = ScGlobal::GetCaseTransliteration().compareString(left.maStrValue, right.maStrValue); + + if (!nEqual) + return left.mbIsHiddenByFilter < right.mbIsHiddenByFilter; + + return nEqual < 0; +} + +bool ScTypedStrData::LessSortCaseSensitive::operator() (const ScTypedStrData& left, const ScTypedStrData& right) const +{ + if (left.meStrType != right.meStrType) + return left.meStrType < right.meStrType; + + if (left.meStrType == Value) + { + if (left.mfValue == right.mfValue) + return left.mbIsHiddenByFilter < right.mbIsHiddenByFilter; + return left.mfValue < right.mfValue; + } + + if (left.mbIsDate != right.mbIsDate) + return left.mbIsDate < right.mbIsDate; + + sal_Int32 nEqual = ScGlobal::GetCaseCollator().compareString(left.maStrValue, right.maStrValue); if (!nEqual) return left.mbIsHiddenByFilter < right.mbIsHiddenByFilter; @@ -58,8 +81,31 @@ bool ScTypedStrData::LessCaseInsensitive::operator() (const ScTypedStrData& left if (left.mbIsDate != right.mbIsDate) return left.mbIsDate < right.mbIsDate; - sal_Int32 nEqual = ScGlobal::GetCollator().compareString( - left.maStrValue, right.maStrValue); + sal_Int32 nEqual + = ScGlobal::GetTransliteration().compareString(left.maStrValue, right.maStrValue); + + if (!nEqual) + return left.mbIsHiddenByFilter < right.mbIsHiddenByFilter; + + return nEqual < 0; +} + +bool ScTypedStrData::LessSortCaseInsensitive::operator() (const ScTypedStrData& left, const ScTypedStrData& right) const +{ + if (left.meStrType != right.meStrType) + return left.meStrType < right.meStrType; + + if (left.meStrType == Value) + { + if (left.mfValue == right.mfValue) + return left.mbIsHiddenByFilter < right.mbIsHiddenByFilter; + return left.mfValue < right.mfValue; + } + + if (left.mbIsDate != right.mbIsDate) + return left.mbIsDate < right.mbIsDate; + + sal_Int32 nEqual = ScGlobal::GetCaseCollator().compareString(left.maStrValue, right.maStrValue); if (!nEqual) return left.mbIsHiddenByFilter < right.mbIsHiddenByFilter; -- cgit v1.2.3