Bug 116394 - DocX Import - Word merge fields lose "=" character
Summary: DocX Import - Word merge fields lose "=" character
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
5.4.0.0.alpha0+
Hardware: All All
: medium major
Assignee: Not Assigned
URL:
Whiteboard: target:7.2.0 target:7.0.5 target:7.1.0
Keywords: bibisected, bisected, regression
Depends on:
Blocks: DOCX-Fields Regressions-expression-is-faulty
  Show dependency treegraph
 
Reported: 2018-03-14 04:12 UTC by Paul
Modified: 2021-01-18 11:17 UTC (History)
7 users (show)

See Also:
Crash report or crash signature:


Attachments
Minimal DOCX file showing 1 affected merge field. (11.27 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2018-03-14 04:18 UTC, Paul
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Paul 2018-03-14 04:12:23 UTC
Description:
DocX files lose the "=" symbol from merge fields when importing.
Works in version 5.3.7.2
Fails in version 5.4.0.3 and later onwards 

Steps to Reproduce:
1.Load attached DocX
2.Examine the tool tip when hovering over the field (the = symbol is missing)
3.Save as ODT, examine content.xml - '=' symbol has been lost from "text:column-name" attribute

Actual Results:  
= symbol is lost

Expected Results:
= symbol is retained


Reproducible: Always


User Profile Reset: No



Additional Info:
This regression also means that when saving to DOCX the merge DocX file shows the incorrect text.


User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:58.0) Gecko/20100101 Firefox/58.0
Comment 1 Paul 2018-03-14 04:18:28 UTC
Created attachment 140626 [details]
Minimal DOCX file showing 1 affected merge field.

Good import (content.xml) looks like:
  <text:database-display ... text:column-name="ab=cd">

Bab import (content.xml) looks like:
  <text:database-display ... text:column-name="abcd">
Comment 2 Xisco Faulí 2018-03-14 10:08:19 UTC
Regression introduced by:

author	Jean-Sebastien Bevilacqua <realitix@gmail.com>	2017-02-16 10:54:33 +0100
committer	Miklos Vajna <vmiklos@collabora.co.uk>	2017-03-30 17:39:00 +0000
commit	c568eb7d3bb4584867f0a1f0a7965f73097f009b (patch)
tree	ea7e6fb1e0d77369a90bc69dd8756f589bb352e4
parent	53c2507bf97867011fd2bfbbac6c86b7fc494338 (diff)
tdf#105975 Add Formula field parsing (docx) in SWriter
Introduction
------------

In MSWord, you can create a formula field (starting with =).
When you save your file as `docx`, this `FORMULA` field is registered
in you file (a field starting with `=`). In its current state,
LibreOffice can't parse the `FORMULA` field in `docx` file.

Context of this fix
-------------------

This fix is entirely located in the `DomainMapper_Impl.cxx` file
because it's where the parsing is done.

How this fix works
------------------

First, we add `FORMULA` support by adding it to the `aFields[]` variable.
Next, to handle the `FORMULA` constant, we add a condition (swith case) in
`DomainMapper_Impl::CloseFieldCommand()` to call `handleFieldFormula`.

Note
----

In function `lcl_ExtractToken`, if command starts with `=`, it's a
`FORMULA` field.


Bisected with: bibisect-linux-64-5.4

Adding Cc: to Jean-Sebastien Bevilacqua
Comment 3 Julien Nabet 2018-03-14 20:48:28 UTC
On pc Debian x86-64 with master sources updated today, I could reproduce this.
The pb is in these lines:
   2525             case '=':
   2526                 if (token.isEmpty())
   2527                 {
   2528                     rHaveToken = true;
   2529                     ++rIndex;
   2530                     return OUString("FORMULA");
   2531                 }
   2532             break;
in writerfilter/source/dmapper/DomainMapper_Impl.cxx

Miklos/Jean-Sebastien: thought you might be interested in this one following Xisco's comment
Comment 4 Commit Notification 2021-01-16 11:33:29 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/b232b422a3cfe3b410bbc75e0fffdfc238fd10e7

tdf#116394 writerfilter: append '=' if not a formula marker

It will be available in 7.2.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 5 Justin L 2021-01-16 11:39:38 UTC
Julien, you did almost all the work, so you deserve the credit for this one.
Comment 6 Julien Nabet 2021-01-16 11:47:59 UTC
(In reply to Justin L from comment #5)
> Julien, you did almost all the work, so you deserve the credit for this one.

Just some great team work, Xisco found the commit, I made some hypothesis, you made the fix! :-)
Thank you!
Comment 7 Commit Notification 2021-01-16 16:42:34 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "libreoffice-7-0":

https://git.libreoffice.org/core/commit/1b5ff41ae250ccd6b0e73b412ab7bd655f489d74

tdf#116394 writerfilter: append '=' if not a formula marker

It will be available in 7.0.5.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 8 Xisco Faulí 2021-01-16 16:43:28 UTC
Verified in

Version: 7.2.0.0.alpha0+ / LibreOffice Community
Build ID: 6ce66560c59470a9eb76fbf80f439b452166d3e4
CPU threads: 4; OS: Linux 5.7; UI render: default; VCL: gtk3
Locale: en-US (en_US.UTF-8); UI: en-US
Calc: threaded

@Justin Luth, thanks for fixing this issue!!
Comment 9 Commit Notification 2021-01-16 16:44:51 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "libreoffice-7-1":

https://git.libreoffice.org/core/commit/d864b799e0460c2c8ada62fd598e7adcb1ac6700

tdf#116394 writerfilter: append '=' if not a formula marker

It will be available in 7.1.1.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 10 Commit Notification 2021-01-16 20:58:21 UTC
Xisco Fauli committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/63239749683ad718e10a5f561f17ca3c41ab4466

tdf#116394: sw_ooxmlexport15: Add unittest

It will be available in 7.2.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 11 Commit Notification 2021-01-18 10:56:23 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "libreoffice-7-1-0":

https://git.libreoffice.org/core/commit/9218b1f71ee522b69d09b9a62a3a2f04a6f9f543

tdf#116394 writerfilter: append '=' if not a formula marker

It will be available in 7.1.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.