sc/inc/table.hxx | 6 +++++ sc/qa/unit/ucalc_condformat.cxx | 41 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+)
New commits: commit 74f18755cf5230b950ff94749b1c3fa91516b899 Author: Mike Kaganski <[email protected]> AuthorDate: Sun Nov 23 14:13:47 2025 +0500 Commit: Mike Kaganski <[email protected]> CommitDate: Sun Nov 23 11:47:05 2025 +0100 tdf#168943: Handle non-multimarked mark data Add the respective code to ScTable::Apply, which somehow got lost in commit b5da114b67b29c91d16f2cb618cf30e7aa1b068d (Move code applying functor to selection from ScColumnData to ScTable, 2025-03-15). Change-Id: I0a9b6d9695a604c091eaca4c7b4e822c4e8c8781 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194386 Tested-by: Jenkins Reviewed-by: Mike Kaganski <[email protected]> diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx index 3dd474ae86ca..476a98ce9a1b 100644 --- a/sc/inc/table.hxx +++ b/sc/inc/table.hxx @@ -1518,6 +1518,12 @@ void ScTable::Apply(const ScMarkData& rMark, SCCOL nCol, ApplyDataFunc apply) while (aMultiIter.Next(nTop, nBottom)) apply(rCol, nTop, nBottom); } + else if (rMark.IsMarked()) + { + const ScRange& aRange = rMark.GetMarkArea(); + if (aRange.aStart.Col() <= nCol && nCol <= aRange.aEnd.Col()) + apply(GetColumnData(nCol), aRange.aStart.Row(), aRange.aEnd.Row()); + } } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/qa/unit/ucalc_condformat.cxx b/sc/qa/unit/ucalc_condformat.cxx index 86e2749bf2ac..fb7ae74d05d9 100644 --- a/sc/qa/unit/ucalc_condformat.cxx +++ b/sc/qa/unit/ucalc_condformat.cxx @@ -1550,6 +1550,47 @@ CPPUNIT_TEST_FIXTURE(TestCondformat, testWholeSheetCondFormatCopyPaste) m_pDoc->DeleteTab(0); } +CPPUNIT_TEST_FIXTURE(TestCondformat, testTdf168943) +{ + m_pDoc->InsertTab(0, u"test"_ustr); + + for (SCROW nRow = 0; nRow <= 5; ++nRow) + { + // Initial state: no conditional format, so attribute must be default + CPPUNIT_ASSERT(IsDefaultItem(m_pDoc->GetAttr(0, nRow, 0, ATTR_CONDITIONAL))); + } + + auto pEntry = new ScCondFormatEntry(ScConditionMode::Direct, u"=42"_ustr, {}, *m_pDoc, + ScAddress(0, 0, 0), ScResId(STR_STYLENAME_RESULT)); + + auto pFormat = std::make_unique<ScConditionalFormat>(0, *m_pDoc); + pFormat->AddEntry(pEntry); + ScRange aRange(0, 0, 0, 0, 5, 0); + pFormat->SetRange(aRange); + auto key = m_pDoc->AddCondFormat(std::move(pFormat), 0); + m_pDoc->AddCondFormatData(aRange, 0, key); + + for (SCROW nRow = 0; nRow <= 5; ++nRow) + { + // The attribute must be set + CPPUNIT_ASSERT(!IsDefaultItem(m_pDoc->GetAttr(0, nRow, 0, ATTR_CONDITIONAL))); + } + + ScConditionalFormatList* pNewList = new ScConditionalFormatList(); + m_xDocShell->GetDocFunc().SetConditionalFormatList(pNewList, 0); + + for (SCROW nRow = 0; nRow <= 5; ++nRow) + { + // Check if respective attribute has been correctly cleared. + // Before the fix, this failed, because ScConditionalFormatList::RemoveFromDocument, called + // from SetConditionalFormatList, got a non-multimarked single-contiguous-range mark, and + // ScTable::Apply was not prepared for such marks, so did nothing. + CPPUNIT_ASSERT(IsDefaultItem(m_pDoc->GetAttr(0, nRow, 0, ATTR_CONDITIONAL))); + } + + m_pDoc->DeleteTab(0); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
