sc/qa/unit/ucalc_condformat.cxx |   27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

New commits:
commit ad7d161a9e1d18ff2080c5df8affaf58a31fba3d
Author:     Dennis Francis <[email protected]>
AuthorDate: Tue Nov 11 22:57:42 2025 +0530
Commit:     Tomaž Vajngerl <[email protected]>
CommitDate: Wed Nov 19 07:20:21 2025 +0100

    cool#13378: unit test
    
    Signed-off-by: Dennis Francis <[email protected]>
    Change-Id: Iefc327bf57c730a0f50e45745f5735b4349b7bfa
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193817
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Tomaž Vajngerl <[email protected]>

diff --git a/sc/qa/unit/ucalc_condformat.cxx b/sc/qa/unit/ucalc_condformat.cxx
index 56ebcd01e3eb..b43f4e0e241e 100644
--- a/sc/qa/unit/ucalc_condformat.cxx
+++ b/sc/qa/unit/ucalc_condformat.cxx
@@ -1523,6 +1523,33 @@ CPPUNIT_TEST_FIXTURE(TestCondformat, 
testConditionStyleInMergedCell)
     m_pDoc->DeleteTab(0);
 }
 
+CPPUNIT_TEST_FIXTURE(TestCondformat, testWholeSheetCondFormatCopyPaste)
+{
+    // cool#13378
+    // Without the fix, this test will cause OOM and crash.
+    m_pDoc->InsertTab(0, u"Test"_ustr);
+    ScConditionalFormatList* pList = m_pDoc->GetCondFormList(0);
+
+    auto pFormat = std::make_unique<ScConditionalFormat>(1, m_pDoc);
+    ScRangeList aRangeList(ScRange(0, 0, 0, m_pDoc->MaxCol(), 
m_pDoc->MaxRow(), 0));
+    pFormat->SetRange(aRangeList);
+    ScCondFormatEntry* pEntry = new ScCondFormatEntry(ScConditionMode::Direct, 
u"=42"_ustr, u""_ustr,
+            *m_pDoc, ScAddress(0, 0, 0), ScResId(STR_STYLENAME_RESULT));
+    pFormat->AddEntry(pEntry);
+
+    m_pDoc->AddCondFormatData(pFormat->GetRange(), 0, 1);
+    pList->InsertNew(std::move(pFormat));
+
+    // Copy row 1:1
+    ScDocument aClipDoc(SCDOCMODE_CLIP);
+    copyToClip(m_pDoc, ScRange(0, 0, 0, m_pDoc->MaxCol(), 0, 0), &aClipDoc);
+
+    // Paste to row 4:4
+    pasteFromClip(m_pDoc, ScRange(0, 3, 0, m_pDoc->MaxCol(), 3, 0), &aClipDoc);
+
+    m_pDoc->DeleteTab(0);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Reply via email to