[Libreoffice-commits] core.git: sw/inc sw/qa sw/source sw/uiconfig
László Németh (via logerrit)
logerrit at kemper.freedesktop.org
Thu Aug 27 07:18:13 UTC 2020
sw/inc/calc.hxx | 4 ++
sw/qa/extras/ooxmlexport/data/tdf123356.fodt | 40 +++++++++++++++++++++++++++
sw/qa/extras/ooxmlexport/ooxmlexport15.cxx | 16 ++++++++++
sw/source/core/bastyp/calc.cxx | 13 ++++++++
sw/uiconfig/swriter/ui/inputwinmenu.ui | 8 +++++
5 files changed, 80 insertions(+), 1 deletion(-)
New commits:
commit 79681f6a35ebf70293136034d675d312c5b6cdee
Author: László Németh <nemeth at numbertext.org>
AuthorDate: Wed Aug 26 10:59:10 2020 +0200
Commit: László Németh <nemeth at numbertext.org>
CommitDate: Thu Aug 27 09:17:17 2020 +0200
tdf#123356 sw: add table formula COUNT
for DOCX interoperability.
See also commit f1f27b2487ccfb7a03190ff68eadbfb611dd9749
(tdf#123356 DOCX import: fix COUNT formula).
Change-Id: I951944ed92bcbed3388f5d7e364e7ff104f37d1d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101395
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth at numbertext.org>
diff --git a/sw/inc/calc.hxx b/sw/inc/calc.hxx
index a8eb9c18933a..e2b2677a1503 100644
--- a/sw/inc/calc.hxx
+++ b/sw/inc/calc.hxx
@@ -54,7 +54,8 @@ enum SwCalcOper
CALC_COS=274, CALC_TAN=275, CALC_ASIN=276,
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_DAY=284, CALC_PRODUCT=285, CALC_AVERAGE=286,
+ CALC_COUNT=287
};
// Calculate Operations Strings
@@ -79,6 +80,7 @@ extern const char sCalc_Sum[];
extern const char sCalc_Mean[];
extern const char sCalc_Average[];
extern const char sCalc_Product[];
+extern const char sCalc_Count[];
extern const char sCalc_Min[];
extern const char sCalc_Max[];
extern const char sCalc_Sin[];
diff --git a/sw/qa/extras/ooxmlexport/data/tdf123356.fodt b/sw/qa/extras/ooxmlexport/data/tdf123356.fodt
new file mode 100644
index 000000000000..c7dc5d1e61ff
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf123356.fodt
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:officeooo="http://openoffice.org/2009/office" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:ooow="http://openoffice.org/2004/writer" office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.text">
+ <office:styles>
+ <style:style style:name="Standard" style:family="paragraph" style:class="text"/>
+ <style:default-style style:family="paragraph">
+ <style:text-properties fo:language="en" fo:country="US"/>
+ </style:default-style>
+ </office:styles>
+ <office:body>
+ <office:text>
+ <table:table>
+ <table:table-column/>
+ <table:table-column/>
+ <table:table-column/>
+ <table:table-row>
+ <table:table-cell office:value-type="string">
+ <text:p>-10</text:p>
+ </table:table-cell>
+ <table:table-cell office:value-type="string">
+ <text:p>0</text:p>
+ </table:table-cell>
+ <table:table-cell office:value-type="string">
+ <text:p>10</text:p>
+ </table:table-cell>
+ </table:table-row>
+ <table:table-row>
+ <table:table-cell office:value-type="string">
+ <text:p>3</text:p>
+ </table:table-cell>
+ <table:table-cell table:formula="ooow:COUNT(<A1>)" office:value-type="float" office:value="1">
+ <text:p>1</text:p>
+ </table:table-cell>
+ <table:table-cell table:formula="ooow:COUNT(<A1:B2>)" office:value-type="float" office:value="4">
+ <text:p>4</text:p>
+ </table:table-cell>
+ </table:table-row>
+ </table:table>
+ </office:text>
+ </office:body>
+</office:document>
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
index 3661c3f0b973..8436eed13a04 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
@@ -147,6 +147,22 @@ DECLARE_OOXMLEXPORT_TEST(testTdf123401, "tdf123401.fodt")
assertXPathContent(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[4]/w:tc/w:p/w:r[2]/w:instrText", " = AVERAGE(A1:A3)");
}
+DECLARE_OOXMLEXPORT_TEST(testTdf123356, "tdf123356.fodt")
+{
+ uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
+ uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
+
+ // Tests new cell formula COUNT
+ uno::Reference<text::XTextField> xEnumerationAccess1(xFields->nextElement(), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("COUNT(<A1>)"), xEnumerationAccess1->getPresentation(true).trim());
+ CPPUNIT_ASSERT_EQUAL(OUString("1"), xEnumerationAccess1->getPresentation(false).trim());
+
+ uno::Reference<text::XTextField> xEnumerationAccess2(xFields->nextElement(), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("COUNT(<A1:B2>)"), xEnumerationAccess2->getPresentation(true).trim());
+ CPPUNIT_ASSERT_EQUAL(OUString("4"), xEnumerationAccess2->getPresentation(false).trim());
+}
+
DECLARE_OOXMLEXPORT_TEST(testTdf98000_changePageStyle, "tdf98000_changePageStyle.odt")
{
uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
diff --git a/sw/source/core/bastyp/calc.cxx b/sw/source/core/bastyp/calc.cxx
index 6e06fbd52e53..9e206144e13e 100644
--- a/sw/source/core/bastyp/calc.cxx
+++ b/sw/source/core/bastyp/calc.cxx
@@ -85,6 +85,7 @@ const char sCalc_Round[]= "round";
const char sCalc_Date[] = "date";
const char sCalc_Product[] = "product";
const char sCalc_Average[] = "average";
+const char sCalc_Count[]= "count";
// ATTENTION: sorted list of all operators
struct CalcOp
@@ -104,6 +105,7 @@ CalcOp const aOpTable[] = {
/* ATAN */ {{sCalc_Atan}, CALC_ATAN}, // Arc tangent
/* AVERAGE */ {{sCalc_Average}, CALC_MEAN}, // Mean (since LibreOffice 7.1)
/* COS */ {{sCalc_Cos}, CALC_COS}, // Cosine
+/* COUNT */ {{sCalc_Count}, CALC_COUNT}, // Count (since LibreOffice 7.1)
/* DATE */ {{sCalc_Date}, CALC_DATE}, // Date
/* DIV */ {{sCalc_Div}, CALC_DIV}, // Division
/* EQ */ {{sCalc_Eq}, CALC_EQ}, // Equality
@@ -668,6 +670,7 @@ SwCalcOper SwCalc::GetToken()
{
case CALC_SUM:
case CALC_MEAN:
+ case CALC_COUNT:
m_eCurrListOper = CALC_PLUS;
break;
case CALC_MIN:
@@ -1186,6 +1189,16 @@ SwSbxValue SwCalc::PrimFunc(bool &rChkPow)
return nErg;
break;
}
+ case CALC_COUNT:
+ {
+ SAL_INFO("sw.calc", "count");
+ m_nListPor = 1;
+ GetToken();
+ SwSbxValue nErg = Expr();
+ nErg.PutDouble( m_nListPor );
+ return nErg;
+ break;
+ }
case CALC_SQRT:
{
SAL_INFO("sw.calc", "sqrt");
diff --git a/sw/uiconfig/swriter/ui/inputwinmenu.ui b/sw/uiconfig/swriter/ui/inputwinmenu.ui
index 7d1ff261bd07..5edaeefec5fa 100644
--- a/sw/uiconfig/swriter/ui/inputwinmenu.ui
+++ b/sw/uiconfig/swriter/ui/inputwinmenu.ui
@@ -187,6 +187,14 @@
<property name="use_underline">True</property>
</object>
</child>
+ <child>
+ <object class="GtkMenuItem" id="count">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes" context="inputwinmenu|count">Count</property>
+ <property name="use_underline">True</property>
+ </object>
+ </child>
<child>
<object class="GtkMenuItem" id="product">
<property name="visible">True</property>
More information about the Libreoffice-commits
mailing list