From 947b7357cc2bb0bd591e4519fa43c4b4bc3cbf2a Mon Sep 17 00:00:00 2001 From: László Németh Date: Wed, 26 Aug 2020 13:12:21 +0200 Subject: tdf#123354 sw: add table formula ABS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit for DOCX interoperability. See also commit e1aea22f3f4fbf0cc412a8867165a85a3c55f49c (tdf#123354 DOCX import: fix ABS formula). Change-Id: I8633ff4d4727a1e7a596312cdd62e87c07cbe730 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101402 Tested-by: Jenkins Reviewed-by: László Németh --- sw/inc/calc.hxx | 3 ++- sw/qa/extras/ooxmlexport/data/tdf123354.fodt | 40 ++++++++++++++++++++++++++++ sw/qa/extras/ooxmlexport/ooxmlexport15.cxx | 20 ++++++++++++++ sw/source/core/bastyp/calc.cxx | 8 +++++- sw/uiconfig/swriter/ui/inputwinmenu.ui | 14 ++++++++++ 5 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 sw/qa/extras/ooxmlexport/data/tdf123354.fodt (limited to 'sw') diff --git a/sw/inc/calc.hxx b/sw/inc/calc.hxx index 41b3cd0a8cec..99c024bcac35 100644 --- a/sw/inc/calc.hxx +++ b/sw/inc/calc.hxx @@ -55,7 +55,7 @@ enum SwCalcOper CALC_ACOS=278, CALC_ATAN=279, CALC_TDIF=280, CALC_ROUND=281, CALC_DATE=282, CALC_MONTH=283, CALC_DAY=284, CALC_PRODUCT=285, CALC_AVERAGE=286, - CALC_COUNT=287, CALC_SIGN=288 + CALC_COUNT=287, CALC_SIGN=288, CALC_ABS=289 }; // Calculate Operations Strings @@ -92,6 +92,7 @@ extern const char sCalc_Atan[]; extern const char sCalc_Round[]; extern const char sCalc_Date[]; extern const char sCalc_Sign[]; +extern const char sCalc_Abs[]; // Calculate ErrorCodes enum class SwCalcError diff --git a/sw/qa/extras/ooxmlexport/data/tdf123354.fodt b/sw/qa/extras/ooxmlexport/data/tdf123354.fodt new file mode 100644 index 000000000000..5e75b212957e --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/tdf123354.fodt @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + -10 + + + 0 + + + 10 + + + + + 10 + + + 0 + + + 10 + + + + + + diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx index e46f99e0c3e9..e78e7fba8179 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx @@ -139,6 +139,26 @@ DECLARE_OOXMLEXPORT_TEST(testTdf123390, "tdf123390.fodt") CPPUNIT_ASSERT_EQUAL(OUString("0"), xEnumerationAccess3->getPresentation(false).trim()); } +DECLARE_OOXMLEXPORT_TEST(testTdf123354, "tdf123354.fodt") +{ + uno::Reference xTextFieldsSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference xFieldsAccess(xTextFieldsSupplier->getTextFields()); + uno::Reference xFields(xFieldsAccess->createEnumeration()); + + // Tests new cell formula SIGN + uno::Reference xEnumerationAccess1(xFields->nextElement(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("ABS()"), xEnumerationAccess1->getPresentation(true).trim()); + CPPUNIT_ASSERT_EQUAL(OUString("10"), xEnumerationAccess1->getPresentation(false).trim()); + + uno::Reference xEnumerationAccess2(xFields->nextElement(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("ABS()"), xEnumerationAccess2->getPresentation(true).trim()); + CPPUNIT_ASSERT_EQUAL(OUString("10"), xEnumerationAccess2->getPresentation(false).trim()); + + uno::Reference xEnumerationAccess3(xFields->nextElement(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("ABS()"), xEnumerationAccess3->getPresentation(true).trim()); + CPPUNIT_ASSERT_EQUAL(OUString("0"), xEnumerationAccess3->getPresentation(false).trim()); +} + DECLARE_OOXMLEXPORT_TEST(testTdf98000_changePageStyle, "tdf98000_changePageStyle.odt") { uno::Reference xModel(mxComponent, uno::UNO_QUERY); diff --git a/sw/source/core/bastyp/calc.cxx b/sw/source/core/bastyp/calc.cxx index 3750aead867c..17179f472352 100644 --- a/sw/source/core/bastyp/calc.cxx +++ b/sw/source/core/bastyp/calc.cxx @@ -86,7 +86,8 @@ const char sCalc_Date[] = "date"; const char sCalc_Product[] = "product"; const char sCalc_Average[] = "average"; const char sCalc_Count[]= "count"; -const char sCalc_Sign[]= "sign"; +const char sCalc_Sign[] = "sign"; +const char sCalc_Abs[] = "abs"; // ATTENTION: sorted list of all operators struct CalcOp @@ -99,6 +100,7 @@ struct CalcOp }; CalcOp const aOpTable[] = { +/* ABS */ {{sCalc_Abs}, CALC_ABS}, // Abs (since LibreOffice 7.1) /* ACOS */ {{sCalc_Acos}, CALC_ACOS}, // Arc cosine /* ADD */ {{sCalc_Add}, CALC_PLUS}, // Addition /* AND */ {{sCalc_And}, CALC_AND}, // log. AND @@ -1072,6 +1074,10 @@ SwSbxValue SwCalc::PrimFunc(bool &rChkPow) SAL_INFO("sw.calc", "acos"); return StdFunc(&acos, true); break; + case CALC_ABS: + SAL_INFO("sw.calc", "abs"); + return StdFunc(&abs, false); + break; case CALC_SIGN: { SAL_INFO("sw.calc", "sign"); diff --git a/sw/uiconfig/swriter/ui/inputwinmenu.ui b/sw/uiconfig/swriter/ui/inputwinmenu.ui index 947e78697c77..a8cb41547753 100644 --- a/sw/uiconfig/swriter/ui/inputwinmenu.ui +++ b/sw/uiconfig/swriter/ui/inputwinmenu.ui @@ -265,6 +265,20 @@ True + + + True + False + + + + + True + False + Abs + True + + True -- cgit