diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 09:44:04 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 09:44:04 +0000 |
commit | eb358d77291eba677141bab113dc27d7aabb0f3e (patch) | |
tree | 2e96f3b5d0c79beaeb536bbf05c3b8564846e65f /sc/source/ui | |
parent | Adding debian version 4:24.2.1-4. (diff) | |
download | libreoffice-eb358d77291eba677141bab113dc27d7aabb0f3e.tar.xz libreoffice-eb358d77291eba677141bab113dc27d7aabb0f3e.zip |
Merging upstream version 4:24.2.2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sc/source/ui')
-rw-r--r-- | sc/source/ui/app/inputhdl.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/dbgui/PivotLayoutTreeListBase.cxx | 12 | ||||
-rw-r--r-- | sc/source/ui/docshell/docfunc.cxx | 25 | ||||
-rw-r--r-- | sc/source/ui/docshell/docsh3.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/docshell/impex.cxx | 19 | ||||
-rw-r--r-- | sc/source/ui/inc/undoblk.hxx | 6 | ||||
-rw-r--r-- | sc/source/ui/undo/undoblk.cxx | 26 |
7 files changed, 61 insertions, 32 deletions
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx index a640d71cb2..519ebea36b 100644 --- a/sc/source/ui/app/inputhdl.cxx +++ b/sc/source/ui/app/inputhdl.cxx @@ -3143,7 +3143,7 @@ void ScInputHandler::EnterHandler( ScEnterMode nBlockMode, bool bBeforeSavingInL lcl_RemoveTabs(aString); lcl_RemoveTabs(aPreAutoCorrectString); - if (aString.indexOf('\n') != -1) + if (bModified && aString.indexOf('\n') != -1) { // Cell contains line breaks, enable wrapping ScLineBreakCell aBreakItem(true); diff --git a/sc/source/ui/dbgui/PivotLayoutTreeListBase.cxx b/sc/source/ui/dbgui/PivotLayoutTreeListBase.cxx index 45af29a4f1..672de9559c 100644 --- a/sc/source/ui/dbgui/PivotLayoutTreeListBase.cxx +++ b/sc/source/ui/dbgui/PivotLayoutTreeListBase.cxx @@ -67,6 +67,9 @@ void ScPivotLayoutTreeListBase::PushEntriesToPivotFieldVector(ScPivotFieldVector std::unique_ptr<weld::TreeIter> xEachEntry(mxControl->make_iterator()); if (!mxControl->get_iter_first(*xEachEntry)) return; + + std::optional<ScPivotField> oDataField; + do { ScItemValue* pItemValue = weld::fromId<ScItemValue*>(mxControl->get_id(*xEachEntry)); @@ -78,8 +81,15 @@ void ScPivotLayoutTreeListBase::PushEntriesToPivotFieldVector(ScPivotFieldVector aField.nFuncMask = rFunctionData.mnFuncMask; aField.mnDupCount = rFunctionData.mnDupCount; aField.maFieldRef = rFunctionData.maFieldRef; - rVector.push_back(aField); + + if (aField.nCol == PIVOT_DATA_FIELD) + oDataField = aField; + else + rVector.push_back(aField); } while (mxControl->iter_next(*xEachEntry)); + + if (oDataField) + rVector.push_back(*oDataField); } void ScPivotLayoutTreeListBase::InsertEntryForSourceTarget(weld::TreeView& /*pSource*/, int /*nTarget*/) diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx index 1a8d902bea..4c333b0502 100644 --- a/sc/source/ui/docshell/docfunc.cxx +++ b/sc/source/ui/docshell/docfunc.cxx @@ -5611,26 +5611,12 @@ void ScDocFunc::ReplaceConditionalFormat( sal_uLong nOldFormat, std::unique_ptr< bool bUndo = rDoc.IsUndoEnabled(); ScDocumentUniquePtr pUndoDoc; ScRange aCombinedRange = rRanges.Combine(); - ScRange aCompleteRange; if(bUndo) { pUndoDoc.reset(new ScDocument(SCDOCMODE_UNDO)); pUndoDoc->InitUndo( rDoc, nTab, nTab ); - - if(pFormat) - { - aCompleteRange = aCombinedRange; - } - if(nOldFormat) - { - ScConditionalFormat* pOldFormat = rDoc.GetCondFormList(nTab)->GetFormat(nOldFormat); - if(pOldFormat) - aCompleteRange.ExtendTo(pOldFormat->GetRange().Combine()); - } - - rDoc.CopyToDocument(aCompleteRange.aStart.Col(),aCompleteRange.aStart.Row(),nTab, - aCompleteRange.aEnd.Col(),aCompleteRange.aEnd.Row(),nTab, - InsertDeleteFlags::ALL, false, *pUndoDoc); + if (const auto* pList = rDoc.GetCondFormList(nTab)) + pUndoDoc->SetCondFormList(new ScConditionalFormatList(*pUndoDoc, *pList), nTab); } std::unique_ptr<ScRange> pRepaintRange; @@ -5663,11 +5649,10 @@ void ScDocFunc::ReplaceConditionalFormat( sal_uLong nOldFormat, std::unique_ptr< { ScDocumentUniquePtr pRedoDoc(new ScDocument(SCDOCMODE_UNDO)); pRedoDoc->InitUndo( rDoc, nTab, nTab ); - rDoc.CopyToDocument(aCompleteRange.aStart.Col(),aCompleteRange.aStart.Row(),nTab, - aCompleteRange.aEnd.Col(),aCompleteRange.aEnd.Row(),nTab, - InsertDeleteFlags::ALL, false, *pRedoDoc); + if (const auto* pList = rDoc.GetCondFormList(nTab)) + pRedoDoc->SetCondFormList(new ScConditionalFormatList(*pRedoDoc, *pList), nTab); rDocShell.GetUndoManager()->AddUndoAction( - std::make_unique<ScUndoConditionalFormat>(&rDocShell, std::move(pUndoDoc), std::move(pRedoDoc), aCompleteRange)); + std::make_unique<ScUndoConditionalFormat>(&rDocShell, std::move(pUndoDoc), std::move(pRedoDoc), nTab)); } if(pRepaintRange) diff --git a/sc/source/ui/docshell/docsh3.cxx b/sc/source/ui/docshell/docsh3.cxx index 96546d11a5..4634c5cbf1 100644 --- a/sc/source/ui/docshell/docsh3.cxx +++ b/sc/source/ui/docshell/docsh3.cxx @@ -118,6 +118,9 @@ void ScDocShell::PostPaint( const ScRangeList& rRanges, PaintPartFlags nPart, sa SCROW nRow1 = rRange.aStart.Row(), nRow2 = rRange.aEnd.Row(); SCTAB nTab1 = rRange.aStart.Tab(), nTab2 = std::min<SCTAB>(nMaxTab, rRange.aEnd.Tab()); + if (nTab1 < 0 || nTab2 < 0) + continue; + if (!m_pDocument->ValidCol(nCol1)) nCol1 = m_pDocument->MaxCol(); if (!m_pDocument->ValidRow(nRow1)) nRow1 = m_pDocument->MaxRow(); if (!m_pDocument->ValidCol(nCol2)) nCol2 = m_pDocument->MaxCol(); diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx index 4a585657de..8e6315db94 100644 --- a/sc/source/ui/docshell/impex.cxx +++ b/sc/source/ui/docshell/impex.cxx @@ -1662,6 +1662,7 @@ bool ScImportExport::ExtText2Doc( SvStream& rStrm ) ScDocumentImport aDocImport(rDoc); do { + SCCOL nLastCol = nEndCol; // tdf#129701 preserve value of nEndCol for( ;; ) { aLine = ReadCsvLine(rStrm, !bFixed, aSeps, cStr, cDetectSep); @@ -1745,11 +1746,14 @@ bool ScImportExport::ExtText2Doc( SvStream& rStrm ) SCCOL nSourceCol = 0; sal_uInt16 nInfoStart = 0; const sal_Unicode* p = aLine.getStr(); + // tdf#129701 if there is only one column, and user wants to treat empty cells, + // we need to detect *p = null + bool bIsLastColEmpty = !(*p) && !bSkipEmptyCells && !bDetermineRange; // Yes, the check is nCol<=rDoc.MaxCol()+1, +1 because it is only an // overflow if there is really data following to be put behind // the last column, which doesn't happen if info is // SC_COL_SKIP. - while (*p && nCol <= rDoc.MaxCol()+1) + while ( (*p || bIsLastColEmpty) && nCol <= rDoc.MaxCol()+1) { bool bIsQuoted = false; p = ScImportExport::ScanNextFieldFromString( p, aCell, @@ -1780,9 +1784,18 @@ bool ScImportExport::ExtText2Doc( SvStream& rStrm ) aTransliteration, aCalendar, pEnglishTransliteration.get(), pEnglishCalendar.get()); } - ++nCol; - } + if (bIsLastColEmpty) + { + bIsLastColEmpty = false; // toggle to stop + } + else + { + ++nCol; + // tdf#129701 detect if there is a last empty column when we need it + bIsLastColEmpty = !(*p) && !bSkipEmptyCells && !bDetermineRange && nCol == nLastCol; + } + } ++nSourceCol; } } diff --git a/sc/source/ui/inc/undoblk.hxx b/sc/source/ui/inc/undoblk.hxx index 9bda36a1e1..c6cb432d8e 100644 --- a/sc/source/ui/inc/undoblk.hxx +++ b/sc/source/ui/inc/undoblk.hxx @@ -613,11 +613,13 @@ private: void DoChange( ScDocument* pSrcDoc ) const; }; +// This class only uses conditional format lists in the undo/redo documents; +// no other tab data is needed in the documents class ScUndoConditionalFormat : public ScSimpleUndo { public: ScUndoConditionalFormat( ScDocShell* pNewDocShell, - ScDocumentUniquePtr pUndoDoc, ScDocumentUniquePtr pRedoDoc, const ScRange& rRange); + ScDocumentUniquePtr pUndoDoc, ScDocumentUniquePtr pRedoDoc, SCTAB nTab); virtual ~ScUndoConditionalFormat() override; virtual void Undo() override; @@ -631,7 +633,7 @@ private: void DoChange(ScDocument* pDoc); ScDocumentUniquePtr mpUndoDoc; ScDocumentUniquePtr mpRedoDoc; - ScRange maRange; + SCTAB mnTab; }; class ScUndoConditionalFormatList : public ScSimpleUndo diff --git a/sc/source/ui/undo/undoblk.cxx b/sc/source/ui/undo/undoblk.cxx index d352ba143b..c74d23f6e7 100644 --- a/sc/source/ui/undo/undoblk.cxx +++ b/sc/source/ui/undo/undoblk.cxx @@ -1563,11 +1563,11 @@ bool ScUndoListNames::CanRepeat(SfxRepeatTarget& rTarget) const } ScUndoConditionalFormat::ScUndoConditionalFormat(ScDocShell* pNewDocShell, - ScDocumentUniquePtr pUndoDoc, ScDocumentUniquePtr pRedoDoc, const ScRange& rRange): + ScDocumentUniquePtr pUndoDoc, ScDocumentUniquePtr pRedoDoc, SCTAB nTab): ScSimpleUndo( pNewDocShell ), mpUndoDoc(std::move(pUndoDoc)), mpRedoDoc(std::move(pRedoDoc)), - maRange(rRange) + mnTab(nTab) { } @@ -1594,9 +1594,25 @@ void ScUndoConditionalFormat::DoChange(ScDocument* pSrcDoc) { ScDocument& rDoc = pDocShell->GetDocument(); - rDoc.DeleteAreaTab( maRange, InsertDeleteFlags::ALL ); - pSrcDoc->CopyToDocument(maRange, InsertDeleteFlags::ALL, false, rDoc); - pDocShell->PostPaint( maRange, PaintPartFlags::Grid ); + // Restore all conditional formats in the tab. This is simpler and more reliable, than + // restoring formats in a specific range, and then trying to join selectively the restored + // formats with the other formats in the tab, to get the correct state. + ScRangeList aCombinedRange; + if (const auto* pOldList = rDoc.GetCondFormList(mnTab)) + aCombinedRange = pOldList->GetCombinedRange(); + + if (const auto* pNewList = pSrcDoc->GetCondFormList(mnTab)) + { + for (const auto& cond : *pNewList) + for (const auto& range : cond->GetRange()) + aCombinedRange.Join(range); + rDoc.SetCondFormList(new ScConditionalFormatList(rDoc, *pNewList), mnTab); + } + else + { + rDoc.SetCondFormList(nullptr, mnTab); + } + pDocShell->PostPaint(aCombinedRange, PaintPartFlags::Grid); pDocShell->PostDataChanged(); ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); if (pViewShell) |