Bug Hunting Session
Bug 105975 - SWriter can't handle formula in field form Word (docx)
Summary: SWriter can't handle formula in field form Word (docx)
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
4.3.5.2 release
Hardware: All All
: medium normal
Assignee: Jean-Sebastien Bevilacqua
URL:
Whiteboard: target:5.4.0
Keywords:
Depends on:
Blocks: expression-is-faulty
  Show dependency treegraph
 
Reported: 2017-02-13 09:32 UTC by Jean-Sebastien Bevilacqua
Modified: 2019-02-12 10:34 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Result file of the defined procedure (12.53 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2017-02-13 09:34 UTC, Jean-Sebastien Bevilacqua
Details
Formula patch error example (12.46 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2017-02-16 10:01 UTC, Jean-Sebastien Bevilacqua
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jean-Sebastien Bevilacqua 2017-02-13 09:32:40 UTC
Description:
This bug affects 5.2.X (probably previous versions too) and can is reproducible on Master.

When you open a docx embedding formula which set the value of a bookmark (like "Set mybookmark 12"), LibreOffice displays 12 whereas it shouldn't display anything at all since it's a value affectation.

Steps to Reproduce:
1. Open MSOffice and type the sentence "This is my test"
2. Select "is" and go to "Insert > Bookmark"
3. Name the bookmark "BM" and click "Add"
4. Select "my" and go to "Insert > QuickPart > Field" and click on "Formula"
5. Remove the "=" and type "SET BM 12", selected "my" disappears.
6. Put your cursor at line end (just after "test") and go to "Insert > QuickPart > Field" and click on "Formula"
7. Enter the formula "=INT(BM)"
8. "12" in now displayed after "test"
9. Save the file as ".docx" and open it with LibreOffice

Actual Results:  
This is 12test12

Expected Results:
This is test12

The formula "SET BM 12" displays "12", it shouldn't.


Reproducible: Always

User Profile Reset: No

Additional Info:


User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:51.0) Gecko/20100101 Firefox/51.0
Comment 1 Jean-Sebastien Bevilacqua 2017-02-13 09:34:33 UTC
Created attachment 131171 [details]
Result file of the defined procedure
Comment 2 Jean-Sebastien Bevilacqua 2017-02-13 09:36:51 UTC
This bug affects 4.3.5.2 too. Probably all LibreOffice versions are concerned by this bug.
Comment 3 Julien Nabet 2017-02-13 10:36:31 UTC
Jean-Sebastien: you assigned yourself the bugtracker, do you want to fix it yourself?
If yes, please put Status to ASSIGNED instead of UNCONFIRMED, otherwise unassign yourself.
Comment 4 Jean-Sebastien Bevilacqua 2017-02-13 10:44:45 UTC
Yes I'm working on it.

LibreOffice doesn't set the field as "field", it may be the problem.
Comment 5 Jean-Sebastien Bevilacqua 2017-02-16 08:05:34 UTC
After a lot of digging, it's not a bug, it's an unimplemented feature.

2 features are missing: parsing of SET property and parsing of FORMULA property (starting with =).

So I will write 2 patches, one for each features.

Jean-Sébastien Bevilacqua
Comment 6 Jean-Sebastien Bevilacqua 2017-02-16 09:39:38 UTC
I have implemented the first feature (SET): https://gerrit.libreoffice.org/#/c/34333
Comment 7 Jean-Sebastien Bevilacqua 2017-02-16 09:58:55 UTC
I have implemented the 2nd feature (FORMULA) but it's not fully working and I need help to make it work. Take a look at the attachment lo_formula.docx.

With this patch, it should display the result of the formula but instead, it displays the formula. If you update the format of the field to Name and update it again to Standard, it makes it work.

Patch gerrit: https://gerrit.libreoffice.org/#/c/34334/
Comment 8 Jean-Sebastien Bevilacqua 2017-02-16 10:01:39 UTC
Created attachment 131267 [details]
Formula patch error example
Comment 9 Julien Nabet 2017-02-16 10:49:30 UTC
(In reply to Jean-Sebastien Bevilacqua from comment #7)
> I have implemented the 2nd feature (FORMULA) but it's not fully working and
> I need help to make it work. Take a look at the attachment lo_formula.docx.
>...
Don't hesitate to ask for some help on IRC #libreoffice-dev (see https://wiki.documentfoundation.org/Website/IRC) or on dev mailing list http://nabble.documentfoundation.org/Dev-f1639786.html
Comment 10 Commit Notification 2017-03-28 07:06:42 UTC
Jean-Sebastien Bevilacqua committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=4d5ce76d894d2335b551f8c2b29437e2049894f0

tdf#105975 Add Set field parsing (docx) in LibreOffice Writer

It will be available in 5.4.0.

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

Affected users are encouraged to test the fix and report feedback.
Comment 11 Commit Notification 2017-03-30 17:39:43 UTC
Jean-Sebastien Bevilacqua committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=c568eb7d3bb4584867f0a1f0a7965f73097f009b

tdf#105975 Add Formula field parsing (docx) in SWriter

It will be available in 5.4.0.

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

Affected users are encouraged to test the fix and report feedback.
Comment 12 Jean-Sebastien Bevilacqua 2017-03-31 08:52:46 UTC
Ok