Montag, 24. August 2009

GSOC [KFormula shape] Wrap up

So I should have blogged already a week ago, but Internet connection in Jerusalem (I am doing a Hebrew language course here right now and will continue to study math for one semester beginning in October) is not completely satisfying.

So GSOC is over and here is what I have done:

I worked on the formula (or equation) editor of KOffice. KOffice is based on the flake framework, where every content element type is implemented as a plugin, the flake shape, with one or more associated tools. For mathematical equations the formula shape (and the formula tool) are used and this is what I worked on. With the move from KOffice 1.x to KOffice 2 an almost complete rewrite of the formula shape started. When I started there was already a lot of loading, saving and rendering code and the basic outlines of the tool, but almost no navigation and editing logic.

What has been achieved:

  • mouse and keyboard navigation including selection support
    • this is much more complicate for equations compared to e.g. plain text, because in equation you have a two dimensional layouted tree of nested subexpressions where it is sometimes hard to find out the element, that the user wants to navigate to
    • this was implemented for basically every MathML element that we can load
  • insertion from the keyboard
    • at the moment, when the cursor is in a token element, e.g. a number, that next symbol inserted is always added to the current token. This allows the greatest flexibility and is necessary, as MathML allows numbers like "two", but is a little uncomfortable, because the user has to decide, when to start a new token
  • insertion of symbols and MathML templates
    • you can insert all kind of mathematical symbols (they are just inserted as unicode letters)
    • you can insert MathML templates (fractions,...) , complete with wrapping of the current selected elements
  • Undo/Redo (see the previous post about why this is difficult)
  • loading and saving of MathML files (this was already implemented before but had some bugs that prevented it from working)

What still has to be done:
  • allow the changing of attributes of MathML elements, there is already a command for this, this mainly needs a GUI
  • remove unnecessary redraws (only elements that really changed should be updated)
  • finish rendering support for all MathML elements
  • implement a fast input mode, which starts a new token when e.g. a number is inserted and the cursor is in a identifier element
  • implement copy and paste (almost finished)
  • various bug fixes (some rendering bugs are easy to spot in the screencast below)
  • all kind of goodies: latex like input, ...
How to try it out:
I GSOC work is in KOffice svn trunk, so you just have to get a recent checkout
and ensure to enable the FormulaShape by adding formulashape to
the FlakePlugins setting in ~/.kde4/share/config/kwordrc (or ~/.kde/share/config/kwordrc or whatever your distro uses).

Some last words:
GSOC has been a really great experience, I learnd a lot about C++/QT/KDE Programming and the KOffice codebase is a real pleasure to work with (of cause it has some rough edges sometimes too). So thanks a lot to my great mentor Alfredo Beaumont and to the whole KOffice team. Of cause I will continue hacking on the formula shape and maybe other parts of KOffice.

In other news since a month ago I am engaged to the most beautiful and brilliant girl that ever set his feet on this planet and therefore I am maybe the first student to use his GSOC money mainly for his wedding :)

And here comes a screencast of the formula shape in KWord from trunk in all its glory:



  1. Congrats for your wedding ! And for your work on the flake shape :)

  2. Congrats on the engagement/wedding!

    (The formula flake looks good too)

  3. thanks for your work :)
    (and congrats for your weddings !)