sc/qa/unit/uicalc/uicalc2.cxx |   25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

New commits:
commit ef6ff2df2e1286974da2f344aa3b8e3ae9093a79
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Tue Jan 9 16:24:50 2024 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Tue Jan 9 23:39:25 2024 +0100

    tdf#158254: sc_uicalc2: Add unittest
    
    Change-Id: Ifc2bac24958cc0330d8174079886851ff1c0c990
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161834
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sc/qa/unit/uicalc/uicalc2.cxx b/sc/qa/unit/uicalc/uicalc2.cxx
index 9be6d83840bb..a488749e9835 100644
--- a/sc/qa/unit/uicalc/uicalc2.cxx
+++ b/sc/qa/unit/uicalc/uicalc2.cxx
@@ -13,6 +13,7 @@
 #include <svx/svdpage.hxx>
 #include <vcl/keycodes.hxx>
 #include <vcl/scheduler.hxx>
+#include <stlsheet.hxx>
 
 #include <comphelper/processfactory.hxx>
 #include <comphelper/propertysequence.hxx>
@@ -87,6 +88,30 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest2, testTdf150499)
     CPPUNIT_ASSERT_EQUAL(static_cast<SCTAB>(1), pDoc->GetTableCount());
 }
 
+CPPUNIT_TEST_FIXTURE(ScUiCalcTest2, testTdf158254)
+{
+    createScDoc();
+    ScDocument* pDoc = getScDoc();
+
+    goToCell("A:G");
+    dispatchCommand(mxComponent,
+                    
".uno:StyleApply?Style:string=Accent%201&FamilyName:string=CellStyles", {});
+
+    const ScPatternAttr* pPattern = pDoc->GetPattern(5, 0, 0);
+    ScStyleSheet* pStyleSheet = 
const_cast<ScStyleSheet*>(pPattern->GetStyleSheet());
+
+    // Without the fix in place, this test would have failed with
+    // - Expected: Accent 1
+    // - Actual  : Default
+    CPPUNIT_ASSERT_EQUAL(OUString("Accent 1"), pStyleSheet->GetName());
+
+    dispatchCommand(mxComponent, ".uno:Undo", {});
+
+    pPattern = pDoc->GetPattern(5, 0, 0);
+    pStyleSheet = const_cast<ScStyleSheet*>(pPattern->GetStyleSheet());
+    CPPUNIT_ASSERT_EQUAL(OUString("Default"), pStyleSheet->GetName());
+}
+
 CPPUNIT_TEST_FIXTURE(ScUiCalcTest2, testTdf133326)
 {
     createScDoc("tdf133326.ods");

Reply via email to