Bug Hunting Session
Bug 66525 - IMPORT specific formula in a MS Word document is wrong
Summary: IMPORT specific formula in a MS Word document is wrong
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Formula Editor (show other bugs)
(earliest affected) release
Hardware: Other All
: medium major
Assignee: Not Assigned
Depends on:
Blocks: DOC-Formula
  Show dependency treegraph
Reported: 2013-07-03 00:34 UTC by Mike Kaganski
Modified: 2018-12-19 14:43 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:

More formulas to test (33.50 KB, application/msword)
2013-08-11 08:28 UTC, Sergey Pashinin
Formulas to test (35.50 KB, application/msword)
2014-03-04 18:30 UTC, Sergey Pashinin

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Kaganski 2013-07-03 00:34:18 UTC
Testcase: Attachment 81816 [details] from Bug 66463.
Screenshot shownig incorrect rasulting formula: Attachment 80819. Please note the third image showing incorrect curly brace and red question marks.

The internal structure of the imported formula is this:

size 12 {
 alignl {
  stack {
   left lbrace
    {{c}} sup {'} rSub {size 8{1}} left (x right )+ {{c}} sup {'} rSub {size 8{2}} left (x right ) cdot e rSup {size 8{- x}} =0 {} # 
   right none
   left lbrace
    - {{c}} sup {'} rSub {size 8{2}} left (x right )e rSup {size 8{- x}} = {{1} over {e rSup {size 8{x}} +1} } {} # 
   right no

* lbraces positioned incorrectly (inside stack; in each line of the stack; second "left lbrace" is matched by bad-syntax "right no"; extra lbrace in the end without match);
* extra "#" in the end of the second stack line.

Here is the corrected formula:

size 12 {
 left lbrace
  alignl {
   stack {
    {{c}} sup {'} rSub {size 8{1}} left (x right )+ {{c}} sup {'} rSub {size 8{2}} left (x right ) cdot e rSup {size 8{- x}} =0 {} # 
    - {{c}} sup {'} rSub {size 8{2}} left (x right )e rSup {size 8{- x}} = {alignc {1} over {e rSup {size 8{x}} +1} } {}
 right none

Note that I intentionally left unnecesary elements (like empty and redundant braces) to keep resemblance. I had to add alignc to the division in the lower line to restore its correct representation.

I suppose that the possible cause of the problem is that there is only one brace in the formula.
A somewhat related is Bug 62178, that discusses the opposite direction problem.

Affected both LO and AOO, so must be an inherited problem. Still present in 4.0.3 and
Comment 1 Mike Kaganski 2013-07-03 00:48:43 UTC
Excuse me, the screenshot is Attachment 81819 [details].
Comment 2 Jacques Guilleron 2013-07-04 13:56:16 UTC
Hi Mike,

Thank you for this quite clear report.
I already met those problems with imported documents with formulas.
I reproduce with LO
Build ID: ce0383d2950d3b0da2c457c8a406c1229de53571
& Windows 7 Home Premium

I set status to NEW and Importance to MEDIUM HIGH.


Comment 3 Sergey Pashinin 2013-08-11 08:28:25 UTC
Created attachment 83929 [details]
More formulas to test

These formulas are also displayed incorrectly for me.
I think this .doc can also be a testcase for bug https://bugs.freedesktop.org/show_bug.cgi?id=66463
Comment 4 Sergey Pashinin 2014-03-04 18:30:06 UTC
Created attachment 95109 [details]
Formulas to test
Comment 5 Jacques Guilleron 2014-06-15 15:19:40 UTC
Still reproduced with LO
Build ID: 488f31200094d7237d45545ab227014831a1f8e6
TinderBox: Win-x86@39, Branch:master, Time: 2014-06-15_05:02:39
& Windows 7 Home Premium

Comment 6 Yury 2015-04-20 06:54:31 UTC
This is TWO issues in one, actually. One is sizing on msword mathtype objects import (#45284), another is incorrect processing of bracing brace (no pun intended).
Actually, there is the THIRD issue involved -- the automatic re-rendering of all formulas images should be done after importing.
Comment 7 Mike Kaganski 2015-04-20 08:15:23 UTC
(In reply to Yury from comment #6)
> This is TWO issues in one, actually
No, actually here is only ONE issue reported, and its fix awaited: incorrect structure of imported formula (possibly caused by unmatched brace). Other problems that you have mentioned are irrelevant for this specific bug report, though affect the formula. Please don't add irrelevant comments, that may distract developer or make the issue hard to manage. I saw your issue when submitted this one, that's why I haven't create a dupe.

As to "automatic re-rendering of all formulas images should be done after importing", it's questionable. In bug 66463, there's a case when the opposite is preferrable.
Comment 8 QA Administrators 2016-09-20 09:31:53 UTC Comment hidden (obsolete)
Comment 9 Mike Kaganski 2016-09-20 15:42:10 UTC
Still reproducible with Version: (x64)
Build ID: 3c2231d4aa4c68281f28ad35a100c092cff84f5d
Comment 10 Xisco Faulí 2017-09-29 08:50:57 UTC Comment hidden (obsolete)
Comment 11 Roman Kuznetsov 2018-12-19 14:43:11 UTC
still repro in

Build ID: 2b9739b9b009de93efa4f24995469c3bb9d82261
CPU threads: 4; OS: Windows 6.1; UI render: default; VCL: win; 
TinderBox: Win-x86@42, Branch:master, Time: 2018-12-18_23:09:56
Locale: ru-RU (ru_RU); UI-Language: en-US
Calc: threaded