[Issue] Automatic Math Formula Sizing

Writing a book, Automating Document Production - Discuss your special needs here
Post Reply
gvarek
Posts: 4
Joined: Sat Jul 05, 2008 3:37 pm

[Issue] Automatic Math Formula Sizing

Post by gvarek »

Dear OOo community forum,

I am trying to automatically produce documents in Open Document Format (ODF) and to open them in OOo Writer. Everything is working great, except for the size of the mathematical formula.

In the content.xml file, I put a MathML formula as suggested by jlundstocholm in this post http://idippedut.dk/post/2008/03/Now-I- ... athML.aspx:

Code: Select all

<draw:frame 
  draw:name="Objekt1" 
  text:anchor-type="as-char" 
  svg:width="2.972cm" 
  svg:height="1.138cm" 
  draw:z-index="0">
  <draw:object>
    <math:math>
[... MathML content here ...]
    </math:math>
</draw:object>
</draw:frame>
The problem is that I do not know the size of the formula, so I figured I would just remove the svg:width and svg:height attributes. This worked fine with OOo Writer 2.3 in Linux: it would automatically resize all formulas upon loading. Now that I have upgraded to OOo 2.4, it does not work so well anymore: all the equations are tiny and I do not know how to tell OOo Writer to scale them automatically. Nevertheless, the equations are there, and if I double-click on them, they are correctly resized; but I do not want to do that if the document contains hundreds of equations.

Do you know how to solve this problem? Is there a special attribute in draw:frame or draw:object that I can use for this?

Thanks in advance,
gvarek
Last edited by Hagar Delest on Sat Jul 26, 2008 3:41 pm, edited 1 time in total.
Reason: tagged the thread as Issue (link to a bug report).
OOo 2.4.X on openSuse 11 + Windows XP
User avatar
acknak
Moderator
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

Re: Automatic Math Formula Sizing

Post by acknak »

I'm just guessing, but I rather doubt you'll find what you want, because a formula object in a Writer document is not a simple graphic, it's an embedded ("OLE") object. That means that some other application (e.g. OOo Math) is responsible for generating the object content, and that other application will know the correct size for the object. Formula objects are not scalable; they have a specific size determined by the fonts used, spacing settings, and so forth--all of which is know to the Math application but not to OOo Writer.

Again, I'm just guessing here, but you may need to find a way to run your formula through OOo Math to get code that's acceptable for embedding.

Also, the embedded formulas have preview images cached in the Writer document. I don't know what Writer will do if a formula does not have a preview image.

All just my guesses--I surely don't know anything about the internals. Hopefully someone else can be be more definitive.
AOO4/LO5 • Linux • Fedora 23
gvarek
Posts: 4
Joined: Sat Jul 05, 2008 3:37 pm

Re: Automatic Math Formula Sizing

Post by gvarek »

acknak wrote:I'm just guessing, but I rather doubt you'll find what you want, because a formula object in a Writer document is not a simple graphic, it's an embedded ("OLE") object. That means that some other application (e.g. OOo Math) is responsible for generating the object content, and that other application will know the correct size for the object. Formula objects are not scalable; they have a specific size determined by the fonts used, spacing settings, and so forth--all of which is know to the Math application but not to OOo Writer.
Thanks for your answer. Actually, I tend to agree with what you are saying. Since formula objects are not scalable, I thought that OOo Writer would not take for granted the size given by the svg:width/height attributes. Instead, it would query the OOo Math to get the correct size. This is indeed the behavior that I experienced with OOo Writer 2.3.0 (under openSuSE 10.3) but not with OOo Writer 2.4.0.

Here are more information about the problem I am facing and I hope someone who knows the inner workings of OOo can give me some insight.

You will find in attachment the test document SampleOriginal.odt, where the mathematical formulas are expressed without svg:width/attributes.

Code: Select all

<draw:frame draw:name="idXXX" text:anchor-type="as-char" draw:z-index="0">
<draw:object><math:math>[... MathML content here ...]</math:math></draw:object></draw:frame>
If I open this file with OOo Writer 2.3.0 in openSuSE 10.3, the formulas appear with the correct size (see SampleOriginalOOo23openSuSE103.png). However, if I open this file with OOo Writer 2.4.0, the formula are incorrectly sized (see SampleOriginalOOo24Win.png).

In both cases, I saved the file to see how OOo Writer handles this. In the correct case with OOo Writer 2.3.0, the svg:width/height attributes are added, each formula having a different size, consistently with what appears on screen. OOo Writer 2.4.0 also added the svg:width/height attributes, but all formulas got the same values:

Code: Select all

<draw:frame draw:style-name="fr1" draw:name="id55141" text:anchor-type="as-char" svg:width="0.201cm" svg:height="0.467cm" draw:z-index="0">
For OOo Writer 2.4.0, it seems that all formula should be 0.201cm x 0.467cm, no matter what they are!

I hope this clarifies what I am trying to do and which problem I am encountering.
Many thanks in advance to all.
gvarek
Attachments
SampleOriginalOOo24Win.png
SampleOriginalOOo23openSuSE103.png
SampleOriginal.odt
(2.93 KiB) Downloaded 256 times
OOo 2.4.X on openSuse 11 + Windows XP
User avatar
acknak
Moderator
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

Re: Automatic Math Formula Sizing

Post by acknak »

Ok, thanks. I see what you mean, that the behavior has changed.

In my experience simply as a user of the embedded objects, I've found a number of basic bugs in the way OOo handles the objects. I've reported the bugs I've found, and some of them have been fixed. So I know that changes are being made, and the object-handling code seems to be still very much "in process".

From that, I might suggest that it's not too surprising that things are changing, and also that you probably need to get the developer's input on this issue--the behavior of past versions is maybe not a reliable guide to how things should work.

I do agree with you, though, that it would make sense if Writer would notice whether an embedded formula had a reasonable size, and if not, would pass it off to OOo Math to initialize the object. OTOH, there was a problem, not too far back, where Writer documents with lots of formulas would take several minutes to open, apparently because all the formulas had to go through Math even though there was nothing to be done. So, I suspect there has been some optimization done, to try and avoid activating objects wherever possible.

If you want input from the developers, you'll need to get on one of the mailing lists--I expect the general development list (dev@ooo) would be a reasonable place to ask.
AOO4/LO5 • Linux • Fedora 23
ms777
Volunteer
Posts: 177
Joined: Mon Oct 08, 2007 1:33 am

Re: Automatic Math Formula Sizing

Post by ms777 »

Hi,

you may want to try http://user.services.openoffice.org/en/ ... 758#p14758 for updating the formula size.

Alternatively, you can also try

Code: Select all

s = xxx.formula
xxx.formula = ""
xxx.formula = s
good luck,

ms777
gvarek
Posts: 4
Joined: Sat Jul 05, 2008 3:37 pm

Re: Automatic Math Formula Sizing

Post by gvarek »

Thanks for your suggestion, I will try what you propose.

In the meantime, I've received feedback from the dev mailing list. There are a couple of bugs that display similar symptoms. They have been corrected in the last development snapshot, but that did not correct this one.

I will keep you guys posted.
Attachments
SampleOriginalOOoDEV300m24.png
OOo 2.4.X on openSuse 11 + Windows XP
gvarek
Posts: 4
Joined: Sat Jul 05, 2008 3:37 pm

Re: Automatic Math Formula Sizing

Post by gvarek »

For your information, this has been accepted as an issue to be solved in OOo 3.1. The issue number is 91779. If you find this problem relevant, do not hesitate to vote for it! :)
http://www.openoffice.org/issues/show_bug.cgi?id=91779
OOo 2.4.X on openSuse 11 + Windows XP
User avatar
acknak
Moderator
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

Re: Automatic Math Formula Sizing

Post by acknak »

Thanks for the follow-up info!
AOO4/LO5 • Linux • Fedora 23
Post Reply