summaryrefslogtreecommitdiffstats
path: root/sc/source/ui/docshell
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 09:44:47 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 09:44:47 +0000
commit91fe6b97952aa6f7cef58327fd085a17db38ad95 (patch)
tree7a4412295bfb80e15a4936fe67d4bd7b96458ce8 /sc/source/ui/docshell
parentReleasing progress-linux version 4:24.2.1-4~progress7.99u1. (diff)
downloadlibreoffice-91fe6b97952aa6f7cef58327fd085a17db38ad95.tar.xz
libreoffice-91fe6b97952aa6f7cef58327fd085a17db38ad95.zip
Merging upstream version 4:24.2.2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sc/source/ui/docshell')
-rw-r--r--sc/source/ui/docshell/docfunc.cxx25
-rw-r--r--sc/source/ui/docshell/docsh3.cxx3
-rw-r--r--sc/source/ui/docshell/impex.cxx19
3 files changed, 24 insertions, 23 deletions
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;
}
}