Bug 66277

Summary: Use columnalign to implement matrix alignment
Product: LibreOffice Reporter: Frédéric Wang <fred.wang>
Component: Formula EditorAssignee: Frédéric Wang <fred.wang>
Status: RESOLVED FIXED    
Severity: normal    
Priority: medium    
Version: 4.2.0.0.alpha0+ Master   
Hardware: All   
OS: All   
See Also: https://bugs.freedesktop.org/show_bug.cgi?id=65765
Whiteboard: target:4.2.0
Crash report or crash signature: Regression By:
Attachments: Sample output

Description Frédéric Wang 2013-06-27 21:12:51 UTC
Two examples from the LibreOffice doc:

matrix{ a =b
a # "=" # alignl{b} ## = c +1
{} # "=" # alignl{c+1} 
} 

stack{ 
'phantom') alignl{a} = b # 
           alignl{phantom{a} = c+1} 
} 

The equal signs are supposed to be aligned but this property is lost when exported to MathML. The mtable@columnalign attribute should be used instead. This will work in MathJax and Firefox (but note the following bug: https://bugzilla.mozilla.org/show_bug.cgi?id=491384).
Comment 1 Frédéric Wang 2013-06-27 21:55:32 UTC
Mass changes to assign bugs to myself.
Comment 2 Frédéric Wang 2013-06-29 20:58:09 UTC
I've submitted a patch for review:

https://gerrit.libreoffice.org/#/c/4625/

Testcases (some are from the user manual):

matrix{
alignr x+y # {}={} # alignl 2 ##
alignr x
# {}={} # alignl 2-y
}

{alignl x^2 - 9} over {alignl x} newline
left(binom { alignr 100} {alignr 7} right)

stack{Hello world # 
alignl(a)} 

matrix{ 
a # &quot;=&quot; # alignl{b} ## 
{} # &quot;=&quot; # alignl{c+1} 
} 

alignl a^2 + b^2 = c^2 newline
alignc 2 * (1 + 2 + 3 + 4 + 5) = 6 * 5 newline
alignr %gamma = x^2 - y^2

Note that StarMath applies alignment recursively: that is if you align some cells in a matrix the same alignment will apply for example to numerator and denominator of fractions inside the matrix cell. That seems a bit weird to me and I don't think that's what we want in general. The MathML output only applies alignment at the specified level. I think it's better and anyway it's easier to handle.
Comment 3 Frédéric Wang 2013-06-29 20:59:17 UTC
Created attachment 81724 [details]
Sample output

As usual, I attach the new output in a Web page that you can open in Firefox. If you see https://bugzilla.mozilla.org/show_bug.cgi?id=491384 try to zoom in/out the page.
Comment 4 Commit Notification 2013-07-09 09:12:18 UTC
Frederic Wang committed a patch related to this issue.
It has been pushed to "master":

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

 fdo#66277 - fix alignment for binom and stack too.



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.