User:MSpisiak
From Wiki.ooo4kids.org
This is a page containing information about Google Summer of Code project for Go Open Office (and EducOOo) by Michal Spisiak.
Wiki page about the project: Base Alignment Equations
Improving Math Equation Editor
Project description
(copied from proposal)
Starmath - Open Office equation editor is in need of significant improvement which could help satisfy expectations of the user. Currently the main issue is baseline miscalculation that causes wrong alignment hence giving bad impression. The aim of this project is to identify the problem, fix it and thus help Open Office to be more acceptable in education, together with solving other issues concerning adding new symbols which could be beneficial and surely welcomed by all users of Starmath.
Tasks
- understand starmath code organization
- classify arrange methods
- check calculation of alignment info
- fix bugs or rewrite completely the calculation
- find and understand implementation of graphical symbols
- implement missing ones
Task clarification
Our objective is to correctly align equation if it's anchored as character. For the other cases, user sets the position himself. For equations anchored as character, user can set the vertical position also, so our aim is only to provide options that might be convenient for most of the cases. Currently equation is placed into the middle of the line, which appears to be wrongly aligned with respect to the text around. So now the task is to find the code that handles the calculation of the object position and implement options for aligning (eg middle of the line, baseline).
Diary
I'll be writing here essential outlines of daily work.
tasks for 20.-27.5.
I should build Writer with symbols and trace everything about what determines the position of the object in Writer. Hopefully make any graphical debugger work.
21.5.
I added everything what I've done and understood while searching in arrange methods to the wiki page about the project. The reason is that now when the aim of study is moved essentially to Writer code, I had to do a clear recap of what I've understood, so when I'll need it in future, it will be comprehensible. I've also tried to make beaverdbg working, but there is still the null pointer coming in.
24.5.
I started on 'Alignment of Sm objects in Writer' describing the user options with objects in Writer. I got to work beaverdbg, but I wasn't very satisfied, because it can't really do everything what gdb can and it crashes. Well, my gdb started to crash either, my build is probably quite messed up by now.
25.5.
Firstly I was trying to find out where is the difference in position of object applied in Sm code when drawing. Then I had a look at access to Sm. I'm a bit struggling with finding out the objects handling the window position, so I built Writer with symbols.
26.5.
I traced how is calculated the position of object anchored as character in Writer. I wrote something about it on the project page, explaining that now the main thing is to decide on strategy which we should take to actually implement the change.
28.5.
Backtraced from Sm SmDocShell constructor and SwAsCharAnchoredObjectPosition. I'll write things worth it tomorrow on project site.
29.5.
I did tracing the alignment function. Not very successfully, from the Sm side. Hopefully from Sw side it will be better.
31.5.
Together with Eric we did quite exhaustive search for function that sets Alignment value eVertOrient for the SwFmtVertOrient object. Everything explained in "From Sw side" part.
1.6.
I got to examine backtrace of SwFmtVertOrient constructor breakpoint and found function which passes the value of eOrient set in object dialog to SwFmtVertOrient object.
2.6.
Found function that differentiates between Sm objects and other objects and sets the initial value of eVertOrient to CHAR_CENTER.
5.6.
I rewrote observations from traces that I've done in the past about alignment setting function.
7.6.
I wrote an introduction to implementation.
8.6.
Tracing a bit more around I sort of made up my mind how to implement it. Still open to suggestions of course. What bothers me is that I don't know how to put watch point so it doesn't get destroyed immediately after leaving the function (it should be possible because the object remains on the same position). Second thing is how to print object when I know just address. Third thing is whether there isn't a way to put bp on all functions of some object at the same time (not having to do it manually for every one). Will have a look at access to Sm tomorrow.
10.6.
I'm currently looking for how to retrieve values from Sm object. We know that there are values that has to be retrieved for instance BoundRect in CalcPosition. So I traced where it's get from. SwAnchoredObject stores the values, but after getting down the backtrace few steps it wasn't possible to find out where does it come from. So I set the bp on SwAnchoredObject constructor and it gets hit exactly once when new object is created, but at that point the values are not put in and what bothers me is that there is no method that would set the value and so I can't just put bp on it to track down what function puts the value in. The SwAnchoredObject gets constructed by SwFlyFrm constructor. SwFlyFrm inherited from SwFrm that has rectangle aFrm that can be possibly copied there, but I can't find any specific method that would set it either (there are some for moving the aFrm).
14.6.
Last couple of days I've been sorting out the access to Sm discussing it with ericb, mba, tl. It should finally work. I also had a look at a problem with borders, looks like it can be sorted within CalcPosition. Although it should be done at the moment when the border values are written into something in Sw. We basically need to move the equation a bit (by width of the border). IMHO this should be sorted for all objects, because it does for any. The problem is that for "From Bottom" vertical orientation there is value stored how far is the top from baseline, now enlarging the object by the border makes it to move down because the value of how top is from baseline doesn't change.
15.6.
After long trace I finally found function which is responsible for changing size of the object and therefore something I can jump of to find the one which deals with borders and where could I set the vertical position.
22.6.
Last few days I spent tracing around SwFEShell::RequestObjectResize, but now I start to think about new way of implementing it into SmDocShell::Parse or somewhere around into Sm if possible.
23.6.
Today I messed around Sm objects trying to figure out whether we could get pointer on SwAttrSet from some of them. Later, being sick of all useless tracing I made a small experiment, trying to change the alignment inside RequestObjectResize, which had no effect. Needs to be investigated why. More general understanding of Sw code might be needed.
27.6.
I did an experiment with changing the alignment of the object inside RequestObjectResize. Worked well, which means that we could implement it, but I'm not satisfied with placing it there. Still trying to find a better place to put it in.
28.6. - 3.7.
My dear diary, I was a very bad kid, because I didn't write every day, here is what happend for the last week.
- 28.6. RequestObjectResize was reimplemented to retrieve the baseline and align the equation
- 29.6. Other files were adjusted to retrieve the baseline at the first time formula is inserted
- 30.6. I traced through Sm to find out for which equations the baseline might not be defined, finding some strange errors
- 31.6. completing the changes, which finally worked well on ooo-build
- 1.7. trying to reimplement current implementation using SwOleClient
- 2.7. some combination of the previous and trying to figure out why it doesn't work for OOo4Kids
- 3.7. building OOo4Kids applying the changes manually and getting complete diff for OOo4Kids
Good night...
2.8.
Oh no, the difference in dates is like a month. What happened was:
- Baseline patch improved
- Fixed error for adding equations using highlighting
- Fixed moving of formula when adding borders
- Patches created for OOo4Kids and OOo
this is described in various sections which has links at the top of project site: here
and what still needs to be done is:
- get patches accepted by go-oo
- get patches accepted by OOo
and what I want to still do is:
- implement feature to resize formulas from writer
- get some sort of UI working, to align properly formulas created in older files
3.8. 4.8.
I firstly built OOo, upstream version, to be able to produce patches for it and also worked on writing methods for UI implementation. They are almost done. I also tidied up a bit the code, because I found there lots of tabs instead of space, which got there probably by copying some pieces of code.
5.8.
Today I was trying firstly to fix new method to align all formulas, there was a problem to get them invalidated, there is a bug in EndAllAction probably. Then I was trying to create a new method that returns all selected objects, for which I had to trace like stupid because none of already created methods could do so and the node system in Writer seems a bit crazy to me as I see it first time. Now the method seems to be working loosely, it needs lots of tidying up.
6.8.
I managed to get setting the font size working :). It's really amazing, you just highlight the text with the formula, change the text size and the formula changes too. The code needs lots of modifications though and I want to get this feature also for text font and other things not just size.
8.8.
I was checking some documentation to see how to implement change of font size for Math in Writer, but I didn't get much info, so I'll write a simple method in SwFEShell to do it. Very interesting was one wiki page Writer - core and layout, I guessed most of that already from tracing, but if someone was starting now I would recommend reading it.
9.8.
Today I spent tracing... I want to get a feature implemented that would set the font size in formula depending on font size of text when inserting the formula, not just when changing it using highlighting.
11.8.
Third day of tracing to get the font hight. And here we go, it's done. So some recap again:
- resizing the formula is done, just if you use inserting the formula using highlighting the font size taken for the formula is the one at the point where the formula is inserted, not the one highlighted, but I think this way it's better
- methods used by UI (which is not yet there) are written
to do:
- one of the UI methods, AlignAllFormulas, doesn't work properly because the formatter doesn't format them, I already spent some days tracing, but it's really complex
- I want to discuss the problem about SwFlyInCntFrm::MakeObjPos with Cedric, the problem is described here.
- I want to rename the methods, because for instance SetBaselineFromSm looks like a setter, and it's not, I want to start the name of the method with Align rather than Set.
finishing off:
- well, at the end I need to implement it to OOo and OOo4Kids, which might not be trivial, but I leave it for the weekend to fix everything I can before
12.8.
- AlignAllFormulas works now...
- I changed a bit types that were used because I remembered that I read Vetoed Conventions which is quite useful
- I needed to include cross the code subtrees from sw/source/ui/wrtsh/wrtsh1.cxx to <../../core/inc/flyfrm.hxx> which has to be avoided
- still need to find suitable names for new methods
- I remembered that there is a problem with copying of formulas, described here
13.8.
- I changed the names of methods SetBaselineFromSm -> AlignFormula , SetBaselineToBaseline -> AlignFormulaToBaseline , AlignAllFormulas -> AlignAllFormulasToBaseline , ChangeFormulaInSelHeight -> ChangeFormulaInSelFontSize
- I traced around to figure out what is SwFlyInCntFrm::MakeObjPos for...
14.8.
- For SwFlyInCntFrm::MakeObjPos I decided to use bool that disables it if the position wasn't calculated yet from CalcPosition
- I fixed copying formulas (that were resizable after copy) by giving them SwOleClient inside SwWrtShell::CalcAndSetScale
- Fridrich helped me with including flyfrm.hxx hrom wrtsh1.cxx so to not use ../../ in the path, instead I had to put "INCPRE+=$(PRJ)$/source$/core$/inc"
15.8.
- I created diffs for OOo and OOo4Kids, built them to see whether it works...
- I discovered there is a problem when changing the size from dialog...
16.8.
- I managed to fix the problem, so now the size of the formula is changed using either format dialog or FontSize combo box, or in OOo4Kids the buttons to change font-size.
- and updated the diffs...