Bug 117091 - "Import MathML from Clipboard" is broken
Summary: "Import MathML from Clipboard" is broken
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Formula Editor (show other bugs)
Version:
(earliest affected)
6.1.0.0.alpha0+
Hardware: x86-64 (AMD64) Windows (All)
: medium normal
Assignee: Caolán McNamara
URL:
Whiteboard: target:6.3.0 target:6.2.0.1
Keywords: bibisected, bisected, regression
Depends on:
Blocks: MathML
  Show dependency treegraph
 
Reported: 2018-04-18 18:59 UTC by Regina Henschel
Modified: 2019-11-05 13:51 UTC (History)
6 users (show)

See Also:
Crash report or crash signature:


Attachments
MathML file to test the bug (403 bytes, application/mathml+xml)
2018-04-18 18:59 UTC, Regina Henschel
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Regina Henschel 2018-04-18 18:59:50 UTC
Created attachment 141470 [details]
MathML file to test the bug

Open formula editor.
Copy some MathML into clipboard, e.g. the source of the attached file.
Use menu Tools, item "Import MathML from Clipboard".

Notice: nothing happens
Expected: A formula is generated.

It was OK in OK
Version: 6.1.0.0.alpha0+ (x64)
Build ID: d39a8e791618a40328c0f90bece3cc246dcf57f7
CPU threads: 8; OS: Windows 10.0; UI render: GL; 
TinderBox: Win-x86_64@42, Branch:master, Time: 2018-04-06_00:59:07
Locale: de-DE (de_DE); Calc: CL

It is broken in
Version: 6.1.0.0.alpha0+ (x64)
Build ID: 55b9706bea5aa9b654ab39bc7d56339422e17087
CPU threads: 8; OS: Windows 10.0; UI render: GL; 
TinderBox: Win-x86_64@42, Branch:master, Time: 2018-04-18_06:02:46
Locale: de-DE (de_DE); Calc: CL
Comment 1 V Stuart Foote 2018-04-18 20:48:28 UTC
Regina, how would you push the .mml onto clipboard to be seen as MathML (clipboard format 49355)?

Anyhow, if I recreate the formula in Word 2016 and copy, the paste works in 6.0.3.2, and on masters I had handy through 3-13 build:

Version: 6.1.0.0.alpha0+ (x64)
Build ID: 4647057a077824cd6782be82b2d13e06fa76704b
CPU threads: 8; OS: Windows 10.0; UI render: GL; 
TinderBox: Win-x86_64@42, Branch:master, Time: 2018-03-13_02:03:59
Locale: en-US (en_US); Calc: group

but it is not picking it up as of the 3-21 build.

Version: 6.1.0.0.alpha0+ (x64)
Build ID: 3102b8c8b52845ca4584579a7ad2154488943855
CPU threads: 8; OS: Windows 10.0; UI render: GL; 
TinderBox: Win-x86_64@42, Branch:master, Time: 2018-03-21_02:51:57
Locale: en-US (en_US); Calc: group
Comment 2 V Stuart Foote 2018-04-18 21:07:22 UTC
Some STR

1. create simple Equation in MS Word
2. select the equation and copy
3. verify the MathML (Fromat 49355) is present on clipboard **
4. open LibreOffice Formula editor
5. use Tools -> Import MathML from Clipboard

expected that if the MathML is visible on clipboard, it should be parsed into the Formula module's Commands window and show on the canvas.

6. correct on 6.0.3.2 build and 6.1.0 through at least 4647057a077824cd6782be82b2d13e06fa76704b, but for me bad by 3102b8c8b52845ca4584579a7ad2154488943855 and the 2018-04-06 build  d39a8e791618a40328c0f90bece3cc246dcf57f7

Verify the MathML (49355) and MathML Presentation (49356) continue to show available on the clipboard. And are correctly parsed launching the earlier builds.

** on Windows the Nirsoft Insideclipboard is pretty functional
http://www.nirsoft.net/utils/inside_clipboard.html
Comment 3 Xisco Faulí 2018-04-19 10:51:31 UTC
(In reply to V Stuart Foote from comment #1)
> Regina, how would you push the .mml onto clipboard to be seen as MathML
> (clipboard format 49355)?

I have the same question...
Comment 4 Regina Henschel 2018-04-19 12:51:25 UTC
(In reply to V Stuart Foote from comment #1)
> Regina, how would you push the .mml onto clipboard to be seen as MathML
> (clipboard format 49355)?

The import should work not only if the clipboard provides mimetype "application/mathml+xml" or "application/mathml-presentation+xml", but also if it is plain text that is in content MathML. So you only need to open the file in an editor and copy it from there.

For the mathml mimetypes it is easier to generate a new equation, e.g. with the "Math Input Panel" (mip.exe) in Windows.
Comment 5 Regina Henschel 2018-07-03 20:17:39 UTC
The bug has been introduced with the change to FastParser in D:\Build_ODF_layers\core\starmath\source\mathmlimport.cxx
Currently
293      // finally, parser the stream
294      try
295      {
296          if( xFastParser.is() )
297              xFastParser->parseStream( aParserInput );
298          else
299              xParser->parseStream( aParserInput );

If I change this to
try
{
      xParser->parseStream( aParserInput );

as it has been before, then clipboard content which is a valid <math>...</math> fragment is detected as MathML and correctly converted. With FastParser is it not detected as MathML but the FastParser needs the <?xml ... ?> prolog. But the problem is, that MathML, which is embedded in an HTML document, do not have such prolog.

The change was
https://cgit.freedesktop.org/libreoffice/core/commit/?h=libreoffice-6-1&id=bf46b46a1d734348096936284fb8a76e977936d0
Mohammed Abdul Azeem <azeemmysore@gmail.com>	2017-10-01 14:11:11 +0530
Moving XSAXDocumentBuilder2 to use XFastDocumentHandler:

@Mohammed: Do you have an idea, how to solve it?
Comment 6 Regina Henschel 2018-07-03 20:21:11 UTC
Ignore "D:\Build_ODF_layers", copy&paste error from my test build.
Comment 7 Caolán McNamara 2018-12-13 16:11:03 UTC
how about we just put one in if its missing, i.e. https://gerrit.libreoffice.org/#/c/65114/
Comment 8 Commit Notification 2018-12-13 19:20:21 UTC
Caolán McNamara committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/+/fc6d5461da366df6fa10561e12923532071af0c8%5E%21

Resolves: tdf#117091 prepend a xml declaration if missing

It will be available in 6.3.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 9 Caolán McNamara 2018-12-13 19:21:02 UTC
going to assume that solves the problem
Comment 10 Regina Henschel 2018-12-13 19:24:33 UTC
Yes, that restores the previous functionality.

[I was just going to put a +2 in Gerrit.]
Comment 11 Commit Notification 2018-12-13 21:09:56 UTC
Caolán McNamara committed a patch related to this issue.
It has been pushed to "libreoffice-6-2":

https://git.libreoffice.org/core/+/87e2d78fe8891faafcf83f38f1368a3122d9352e%5E%21

Resolves: tdf#117091 prepend a xml declaration if missing

It will be available in 6.2.0.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 12 Juang Dse 2019-11-05 12:46:43 UTC
It doesn't work for me.

Neither in

Version: 6.4.0.0.alpha1
Build ID: cc57df8f942f239d29cb575ea5a7cb01405db787
CPU threads: 4; OS: Linux 4.19; UI render: default; VCL: gtk3; 
Locale: de-DE (en_US.utf8); UI-Language: en-US
Calc: threaded

nor in

Version: 6.2.8.2
Build ID: f82ddfca21ebc1e222a662a32b25c0c9d20169ee
CPU threads: 4; OS: Linux 4.19; UI render: default; VCL: gtk3; 
Locale: de-DE (en_US.utf8); UI-Language: en-US
Calc: threaded
Comment 13 Regina Henschel 2019-11-05 13:51:53 UTC
Please write a new bug report, because your problem does not belong to the here fixed problem.

Please paste the clipboard to a simple editor and add that text file to the bug report. It is likely that the MathML has not the needed format. But I need to see it, before I can say more.
And describe in your bug report the source of the MathML. Applications use different methods to put MathML into the clipboard.