[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - sw/inc sw/qa sw/source
László Németh (via logerrit)
logerrit at kemper.freedesktop.org
Wed Sep 2 13:50:08 UTC 2020
sw/inc/cellfml.hxx | 2 -
sw/qa/extras/ooxmlexport/data/tdf118682.fodt | 7 -----
sw/qa/extras/ooxmlexport/data/tdf133163.fodt | 36 +++++++++++++++++++++++++++
sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 14 ++++++++++
sw/source/filter/ww8/docxattributeoutput.cxx | 4 +--
sw/source/filter/ww8/wrtw8nds.cxx | 14 +++++++++-
6 files changed, 66 insertions(+), 11 deletions(-)
New commits:
commit e5480bff53f3bd32fc922544f7d1c15854218ffc
Author: László Németh <nemeth at numbertext.org>
AuthorDate: Thu Aug 13 12:05:20 2020 +0200
Commit: Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Wed Sep 2 15:49:31 2020 +0200
tdf#133163 DOCX: export formula cells
as formula fields instead of exporting only cell
text content.
Only unmodified formula fields were exported from
commit d42776e01b87f12fddbcf78101bca1e10a6e4f97
(tdf#118682 DOCX: export formula fields).
Now newly added Writer formula cells or modified
table formula fields imported from DOCX (which are
converted to formula cells after formula editing)
are exported.
Change-Id: Iecec75b2a36b94c2d3aa998603ac10ea2f2b8d4e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100667
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth at numbertext.org>
Signed-off-by: Xisco Fauli <xiscofauli at libreoffice.org>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101893
diff --git a/sw/inc/cellfml.hxx b/sw/inc/cellfml.hxx
index 67c2cee65d92..e37b9304bc11 100644
--- a/sw/inc/cellfml.hxx
+++ b/sw/inc/cellfml.hxx
@@ -119,7 +119,7 @@ public:
SwTableFormula & operator =(SwTableFormula &&) = default;
/// create from the internal formula (for CORE) the external formula (for UI)
- void PtrToBoxNm( const SwTable* pTable );
+ SW_DLLPUBLIC void PtrToBoxNm( const SwTable* pTable );
/// create from the external formula the internal
void BoxNmToPtr( const SwTable* pTable );
/// create from the external/internal formula the relative formula
diff --git a/sw/qa/extras/ooxmlexport/data/tdf118682.fodt b/sw/qa/extras/ooxmlexport/data/tdf118682.fodt
index 8979d7b2e4d8..b80074592da2 100644
--- a/sw/qa/extras/ooxmlexport/data/tdf118682.fodt
+++ b/sw/qa/extras/ooxmlexport/data/tdf118682.fodt
@@ -8,13 +8,6 @@
</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>
diff --git a/sw/qa/extras/ooxmlexport/data/tdf133163.fodt b/sw/qa/extras/ooxmlexport/data/tdf133163.fodt
new file mode 100644
index 000000000000..8fdda1cdc556
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf133163.fodt
@@ -0,0 +1,36 @@
+<?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-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 table:formula="ooow:<A1>+<A2>" office:value-type="float" office:value="3">
+ <text:p>3</text:p>
+ </table:table-cell>
+ </table:table-row>
+ <table:table-row>
+ <table:table-cell table:formula="ooow:SUM(<A1:A3>)" office:value-type="float" office:value="6">
+ <text:p>6</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 0e66e4055be6..78737104c2e2 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -985,6 +985,20 @@ DECLARE_OOXMLEXPORT_TEST(testTdf118682, "tdf118682.fodt")
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(testTdf133163, "tdf133163.fodt")
+{
+ xmlDocUniquePtr pXmlDoc = parseExport();
+
+ // Formula cells 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 1ab5f3caf43a..d96947dfb743 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -2155,8 +2155,8 @@ void DocxAttributeOutput::CmdField_Impl( const SwTextNode* pNode, sal_Int32 nPos
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();
+ icu::RegexMatcher aMatcher("<([A-Z]{1,3}[0-9]+(:[A-Z]{1,3}[0-9]+)?)>", sInput, 0, nErr);
+ sToken = aMatcher.replaceAll(icu::UnicodeString("$1"), nErr).getTerminatedBuffer();
}
// Write the Field command
diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx
index 8dda14c16677..ec6f63cb222b 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -74,6 +74,7 @@
#include <fmtruby.hxx>
#include <breakit.hxx>
#include <txtatr.hxx>
+#include <cellatr.hxx>
#include <fmtrowsplt.hxx>
#include <com/sun/star/drawing/XShape.hpp>
#include <com/sun/star/i18n/BreakIterator.hpp>
@@ -2245,6 +2246,18 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
if ( pTableNode )
{
const SwTable& rTable = pTableNode->GetTable();
+ const SwTableBox* pBox = rNode.GetTableBox();
+
+ // export formula cell as formula field instead of only its cell content in DOCX
+ if ( pBox->IsFormulaOrValueBox() == RES_BOXATR_FORMULA &&
+ GetExportFormat() == MSWordExportBase::ExportFormat::DOCX )
+ {
+ SwTableBoxFormula* pFormula = pBox->GetFrameFormat()->GetTableBoxFormula().Clone();
+ pFormula->PtrToBoxNm( &pTableNode->GetTable() );
+ OutputField( nullptr, ww::eEquals, " = " + pFormula->GetFormula(),
+ FieldFlags::Start | FieldFlags::CmdStart | FieldFlags::CmdEnd | FieldFlags::Close );
+ }
+
const bool bKeep = rTable.GetFrameFormat()->GetKeep().GetValue();
const bool bDontSplit = !rTable.GetFrameFormat()->GetLayoutSplit().GetValue();
// bKeep handles this a different way later on, so ignore now
@@ -2252,7 +2265,6 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
{
// bDontSplit : set don't split once for the row
// but only for non-complex tables
- const SwTableBox* pBox = rNode.GetTableBox();
const SwTableLine* pLine = pBox ? pBox->GetUpper() : nullptr;
if ( pLine && !pLine->GetUpper() )
{
More information about the Libreoffice-commits
mailing list