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

New commits:
commit 011d3411b167e031a60bfdab1c947ec5633090de
Author:     Dennis Francis <[email protected]>
AuthorDate: Tue Nov 11 22:57:42 2025 +0530
Commit:     Dennis Francis <[email protected]>
CommitDate: Thu Nov 13 06:13:45 2025 +0100

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

diff --git a/sc/qa/unit/ucalc_condformat.cxx b/sc/qa/unit/ucalc_condformat.cxx
index 1dd7477729d6..86e2749bf2ac 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