[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - sw/Library_msword.mk sw/qa sw/source
László Németh (via logerrit)
logerrit at kemper.freedesktop.org
Tue Nov 10 12:47:35 UTC 2020
sw/Library_msword.mk | 1
sw/qa/extras/ooxmlexport/data/tdf118682.fodt | 43 +++++++++++++++++++++++++++
sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 14 ++++++++
sw/source/filter/ww8/docxattributeoutput.cxx | 9 +++++
sw/source/filter/ww8/ww8atr.cxx | 7 ++++
5 files changed, 74 insertions(+)
New commits:
commit 8ab544945bf7495ab91020a6f7284acb5c0a324d
Author: László Németh <nemeth at numbertext.org>
AuthorDate: Tue Aug 11 19:32:52 2020 +0200
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Tue Nov 10 13:47:01 2020 +0100
tdf#118682 DOCX: export formula fields
Convert also cell references by removing
parenthesization:
=<A1>+<B1> -> =A1*B1
=SUM(<A1:ZZ99> -> =SUM(A1:ZZ99)
See tdf#133647 for fixing import of cell references.
(cherry picked from commit d42776e01b87f12fddbcf78101bca1e10a6e4f97)
Change-Id: I5082198aaf8230989f99984f8129b54867b77859
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105520
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
diff --git a/sw/Library_msword.mk b/sw/Library_msword.mk
index 7433a839b303..74c66073c83f 100644
--- a/sw/Library_msword.mk
+++ b/sw/Library_msword.mk
@@ -68,6 +68,7 @@ $(eval $(call gb_Library_use_libraries,msword,\
$(eval $(call gb_Library_use_externals,msword,\
boost_headers \
+ icui18n \
icuuc \
icu_headers \
libxml2 \
diff --git a/sw/qa/extras/ooxmlexport/data/tdf118682.fodt b/sw/qa/extras/ooxmlexport/data/tdf118682.fodt
new file mode 100644
index 000000000000..8979d7b2e4d8
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf118682.fodt
@@ -0,0 +1,43 @@
+<?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>
+ <text:sequence-decls>
+ <text:sequence-decl text:display-outline-level="0" text:name="Illustration"/>
+ <text:sequence-decl text:display-outline-level="0" text:name="Table"/>
+ <text:sequence-decl text:display-outline-level="0" text:name="Text"/>
+ <text:sequence-decl text:display-outline-level="0" text:name="Drawing"/>
+ <text:sequence-decl text:display-outline-level="0" text:name="Figure"/>
+ </text:sequence-decls>
+ <table:table>
+ <table:table-column/>
+ <table:table-row>
+ <table:table-cell office:value-type="string">
+ <text:p>1</text:p>
+ </table:table-cell>
+ </table:table-row>
+ <table:table-row>
+ <table:table-cell office:value-type="string">
+ <text:p>2</text:p>
+ </table:table-cell>
+ </table:table-row>
+ <table:table-row>
+ <table:table-cell office:value-type="string">
+ <text:p><text:table-formula text:formula="ooow: <A1>+<A2>" style:data-style-name="N0">3</text:table-formula></text:p>
+ </table:table-cell>
+ </table:table-row>
+ <table:table-row>
+ <table:table-cell office:value-type="string">
+ <text:p><text:table-formula text:formula="ooow:SUM(<A1:A3>)" style:data-style-name="N0">6</text:table-formula></text:p>
+ </table:table-cell>
+ </table:table-row>
+ </table:table>
+ </office:text>
+ </office:body>
+</office:document>
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 9a771a5f81b7..d9fe041ba24b 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -968,6 +968,20 @@ DECLARE_OOXMLEXPORT_TEST(testTdf44986, "tdf44986.docx")
CPPUNIT_ASSERT_EQUAL(OUString(""), uno::Reference<text::XTextRange>(xTable->getCellByName("B1"), uno::UNO_QUERY_THROW)->getString());
}
+DECLARE_OOXMLEXPORT_TEST(testTdf118682, "tdf118682.fodt")
+{
+ // Support cell references in table formulas
+ xmlDocPtr pXmlDoc = parseExport();
+
+ // Formula fields were completely missing.
+ assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[3]/w:tc/w:p/w:r/w:fldChar", 3);
+ assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[4]/w:tc/w:p/w:r/w:fldChar", 3);
+
+ // Cell references were parenthesized: <A1>+<A2> and SUM(<A1:A3>)
+ assertXPathContent(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[3]/w:tc/w:p/w:r[2]/w:instrText", " = A1+A2");
+ assertXPathContent(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[4]/w:tc/w:p/w:r[2]/w:instrText", " = SUM(A1:A3)");
+}
+
DECLARE_OOXMLEXPORT_TEST(testTdf106953, "tdf106953.docx")
{
uno::Reference<container::XIndexAccess> xRules = getProperty< uno::Reference<container::XIndexAccess> >(getStyles("NumberingStyles")->getByName("WWNum1"), "NumberingRules");
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index eefa7b25fd51..f2750d7c08b3 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -151,6 +151,7 @@
#include <stdarg.h>
#include <toolkit/helper/vclunohelper.hxx>
+#include <unicode/regex.h>
using ::editeng::SvxBorderLine;
@@ -2132,6 +2133,14 @@ void DocxAttributeOutput::CmdField_Impl( const SwTextNode* pNode, sal_Int32 nPos
sToken = sToken.replaceAll("NNNN", "dddd");
sToken = sToken.replaceAll("NN", "ddd");
}
+ else if ( rInfos.eType == ww::eEquals )
+ {
+ UErrorCode nErr(U_ZERO_ERROR);
+ icu::UnicodeString sInput(sToken.getStr());
+ // remove < and > around cell references, e.g. <A1> to A1, <A1:B2> to A1:B2
+ icu::RegexMatcher xMatch("<([A-Z]{1,3}[0-9]+(:[A-Z]{1,3}[0-9]+)?)>", sInput, 0, nErr);
+ sToken = xMatch.replaceAll(icu::UnicodeString("$1"), nErr).getTerminatedBuffer();
+ }
// Write the Field command
DoWriteCmd( sToken );
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index 00d69c6cf681..bea6090df892 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -3279,6 +3279,13 @@ void AttributeOutputBase::TextField( const SwFormatField& rField )
GetExport().OutputField( pField, ww::eMACROBUTTON, sStr );
}
break;
+ case SwFieldIds::Table:
+ {
+ ww::eField eField = ww::eEquals;
+ OUString aExpand = FieldString(eField) + pField->GetFieldName();
+ GetExport().OutputField(pField, eField, aExpand);
+ }
+ break;
case SwFieldIds::User:
{
ww::eField eField = ww::eDOCVARIABLE;
More information about the Libreoffice-commits
mailing list