sc/CppunitTest_sc_uicalc.mk | 1 sc/qa/unit/uicalc/uicalc.cxx | 68 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+)
New commits: commit dc5920f7a21a3f347d021d2841bc474e3afebd51 Author: Xisco Fauli <[email protected]> AuthorDate: Wed Jan 28 12:16:35 2026 +0100 Commit: Xisco Fauli <[email protected]> CommitDate: Wed Jan 28 16:05:10 2026 +0100 tdf#168438: sc_uicalc: Add test Change-Id: I6e785036aa79f0107452f6081cb265a0e0a87a2a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198285 Tested-by: Jenkins Reviewed-by: Xisco Fauli <[email protected]> diff --git a/sc/CppunitTest_sc_uicalc.mk b/sc/CppunitTest_sc_uicalc.mk index 97a8291ff66c..021d86a8edfa 100644 --- a/sc/CppunitTest_sc_uicalc.mk +++ b/sc/CppunitTest_sc_uicalc.mk @@ -23,6 +23,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sc_uicalc, \ comphelper \ cppu \ cppuhelper \ + editeng \ i18nlangtag \ sal \ sc \ diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx index 7cba5dc167de..4497d1de214a 100644 --- a/sc/qa/unit/uicalc/uicalc.cxx +++ b/sc/qa/unit/uicalc/uicalc.cxx @@ -15,15 +15,18 @@ #include <comphelper/processfactory.hxx> #include <comphelper/propertysequence.hxx> +#include <comphelper/propertyvalue.hxx> #include <comphelper/scopeguard.hxx> #include <comphelper/servicehelper.hxx> #include <com/sun/star/awt/Key.hpp> #include <com/sun/star/sheet/GlobalSheetSettings.hpp> +#include <com/sun/star/table/BorderLineStyle.hpp> #include <condformathelper.hxx> #include <conditio.hxx> #include <document.hxx> #include <docsh.hxx> #include <dpobject.hxx> +#include <editeng/borderline.hxx> #include <formulaopt.hxx> #include <inputopt.hxx> #include <postit.hxx> @@ -345,6 +348,71 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf113541) CPPUNIT_ASSERT_EQUAL(u"50"_ustr, pDoc->GetString(ScAddress(0, 0, 0))); } +CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf168438_check_LineStyle_uno_command) +{ + auto checkBorder = [](const editeng::SvxBorderLine* pLine) { + CPPUNIT_ASSERT(pLine); + CPPUNIT_ASSERT_EQUAL(COL_LIGHTRED, pLine->GetColor()); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(0), pLine->GetInWidth()); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), pLine->GetOutWidth()); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(0), pLine->GetDistance()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID, pLine->GetBorderLineStyle()); + CPPUNIT_ASSERT_EQUAL(tools::Long(1), pLine->GetWidth()); + }; + + auto checkBorder2 = [](const editeng::SvxBorderLine* pLine) { + CPPUNIT_ASSERT(pLine); + CPPUNIT_ASSERT_EQUAL(COL_LIGHTRED, pLine->GetColor()); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(0), pLine->GetInWidth()); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), pLine->GetOutWidth()); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(2), pLine->GetDistance()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::DOUBLE, pLine->GetBorderLineStyle()); + CPPUNIT_ASSERT_EQUAL(tools::Long(1), pLine->GetWidth()); + }; + + createScDoc(); + ScDocument* pDoc = getScDoc(); + table::BorderLine2 aLine(sal_Int32(COL_LIGHTRED), 0, 1, 0, table::BorderLineStyle::SOLID, 1); + + // see SvxBoxItem::QueryValue for details + uno::Sequence<uno::Any> aOuterSeq{ uno::Any(aLine), // left + uno::Any(aLine), // right + uno::Any(aLine), // bottom + uno::Any(aLine), // top + uno::Any(static_cast<sal_Int32>(0)), + uno::Any(static_cast<sal_Int32>(0)), + uno::Any(static_cast<sal_Int32>(0)), + uno::Any(static_cast<sal_Int32>(0)), + uno::Any(static_cast<sal_Int32>(0)) }; + + uno::Sequence<uno::Any> aInnerSeq{}; + + uno::Sequence aArgs{ comphelper::makePropertyValue(u"OuterBorder"_ustr, aOuterSeq), + comphelper::makePropertyValue(u"InnerBorder"_ustr, aInnerSeq) }; + dispatchCommand(mxComponent, u".uno:SetBorderStyle"_ustr, aArgs); + + const ScPatternAttr* pPat = pDoc->GetPattern(ScAddress(0, 0, 0)); + CPPUNIT_ASSERT(pPat); + SvxBoxItem aBorderItem(pPat->GetItem(ATTR_BORDER)); + checkBorder(aBorderItem.GetLeft()); + checkBorder(aBorderItem.GetRight()); + checkBorder(aBorderItem.GetBottom()); + checkBorder(aBorderItem.GetTop()); + + table::BorderLine2 aLine2(sal_Int32(COL_LIGHTRED), 0, 1, 0, table::BorderLineStyle::DOUBLE, 1); + uno::Sequence aArgs2{ comphelper::makePropertyValue(u"LineStyle"_ustr, uno::Any(aLine2)) }; + + dispatchCommand(mxComponent, u".uno:LineStyle"_ustr, aArgs2); + + pPat = pDoc->GetPattern(ScAddress(0, 0, 0)); + CPPUNIT_ASSERT(pPat); + SvxBoxItem aBorderItem2(pPat->GetItem(ATTR_BORDER)); + checkBorder2(aBorderItem2.GetLeft()); + checkBorder2(aBorderItem2.GetRight()); + checkBorder2(aBorderItem2.GetBottom()); + checkBorder2(aBorderItem2.GetTop()); +} + CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf126577) { createScDoc();
