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:


Sonntag, 2. August 2009

GSOC [KFormula shape] update

Wow almost 2 months went by without me blogging. So it is urgent time for a status update of my GSOC work. In contrast to blogging I luckily didn't stop coding. So what has been done:
  • working keyboard and mouse navigation
  • inserting stuff from the keyboard
  • inserting symbols and templates from the docker
  • Undo and Redo
Especially implementing the Undo mechanism took me a while and some sleepless nights, because there is a strict separation of the flake part (which is responsible for embedding the formula shape in KOffice and event handling) and the back end part, which will hopefully become a independent MathML library one day (well it actually is code wise right now, but the kformula shape is the only user atm). Since the editing is done in the back end, we need some way to inform the shape and the tool, that its content has changed, we can't rely on the tool being still around when doing undo, ...

I solved this by letting each editing command return an QUndoCommand which is then passed to the tool in KOffice which wraps it in another QUndoCommand that is responsible for calling the first one and then calling update on the shape and tool. Works quite well.

Next things on my list include some refactoring of the movement code and finishing it for the missing elements. Changing some internals that make inserting and removing stuff a lot easier and finally maybe copy and paste.

So the KFormula shape is now able to create this formula.

Sonntag, 7. Juni 2009

KOffice Developer Meeting

I am just back from the KOffice Developer Meeting in Berlin, hosted by the nice folks at KDAB. Jaroslaw, Hanna and Alexandra already blogged about it. Since this was my first open source developer meeting and I am pretty new to the team, it was a very interesting experience. And I have to say, the koffice developers are an extremly nice bunch of people. Meeting all of them in person instead of only knowing them form IRC lets you feel to be a part of the team much more. On Friday there was mostly individual hacking until most people arrived, followed by a dinner in a nice Indian/Singapurian place.

On Saturday many interesting presentations about change tracking, the library organization, the next release, ... Better check out Hannas blog. A lot of hacking and discussion in the evening again, I got fixed a bug in the picture shape (in around 5 minutes after I posted it, thanks Marijn). I myself fixed some bugs in the way the formula shape uses flake, it is really good to have some experts sitting nearby. As a big surprise some guys from Nokia were there and four of us got free N810s. Thanks some much, what a cool device. Today again hacking and discussion, I left relatively early, while sitting in the train home to Dresden I added the ability to select text in the formula shape by double clicking. One item off from my todo list.

GSOC week2 and Hello Planet

Since this is the first post that hoepfully gets aggregated on Planet KDE a big Hello to everybody reading this over there. I am a GSOC student working on KFormula (the formula editor of KOffice). Everything about my project can be read in my last post.

So since already two weeks of GSOC passed without me blogging it is time for a status update. I am quite well in my schedule. There is navigation code now for almost all elements except Sub-/Superscript and Under-/overscript because they have some minor loading problems. avigation in formulas is quite complicated because you don't just have a linear structure like in text but a 2 dimensional one that consists of nested sub expressions. Consider the following example


When I press left, where should the cursor go? Behind the 1 or the 2 (I put it after the 2 and when the cursor is before the fraction and has to move right, I place it before the 1, but this is an relativelyvarbitrary choice).

The last days I worked on selection support. Now it is possible to select elements by clicking with the mouse while holding shift pressed, dragging with the mouse and by moving the cursor with the keyboard while holding shift pressed. A short demonstration can be seen in the following screencast:


The next week I plan to do some refactoring, implement cursor movement by double clicking and implement insertion and deletion at least for elements.

Dienstag, 19. Mai 2009

GSOC 2009

I guess I am really the last GSOC student (at least in KDE land) to blog about my project but better late then never. I will work on the Formula editor in Koffice which sadly got a little bit battered by the transition to Koffice 2. My main focus will be on user interaction, which means keyboard and mouse input and offering a possibility to insert various mathematical elements. When I am not working for KDE I am studying mathematics in the beautiful German city of Dresden, play various instruments and like to do stuff with my girlfriend and the guys from my church. My mentor is Alfredo Beaumont and my full proposal looked like this:


Jeremias Epperlein

Email Address:

Freenode IRC Nick:


Location (City, Country and/or Time Zone):

Aue, Germany, GMT+1

Proposal Name:

Enhance Formula Shape

Motivation for Proposal / Goal:

Being able to add formulas is a requirement for many users of an office suite like teachers or scientists. Although most of the later use LaTeX for this, when you need a lot of manual layout, a program like kword is a better choice.

Koffice in Version 1.6 included a very good formula editor. The port to the new flake architecture in Koffice 2.0 is very incomplete and lacks several features. Especially the user interface needs a lot of work. I would like to add support for navigating and editing a formula, as well as inserting various mathematical elements like Greek letters.

Additionally I would like to work on the loading and saving of MathML, which is used in ODF for storing formulas, or add the possibility to enter a certain subset of LaTeX.

Implementation Details:

For the editing part, I will add the missing logic in FormulaCursor and KoFormulaTool as well as implement the missing methods in the classes, that represent the MathML elements. For inserting mathematical objects I will select useful MathML templates and add a possibility to insert them to the tool docker.

There should be a possibility to insert (this list is not necessarily complete):


  • fractions

  • roots

  • matrices

  • fenced elements (braces, brackets, ...)

  • super- / subscript

  • alignment hints


  • operator symbols (small / big)

  • Greek letters

  • arrows


  • under / over bars

  • boxes

Tentative Timeline:

  • 3 weeks getting keyboard navigation working

  • 3 weeks add mouse interaction, drag&drop, selecting and moving elements

  • 3 weeks design and implementing the ToolWidget for inserting elements and changing there style

    2 weeks improve the loading of MathML, get more unit tests to pass

  • 1 week clean up the code, add missing documentation

Do you have other obligations from late May to early August (school, work, etc.)?:

I will have university until end of July, but I will have a very low course load, basically only one seminar and two lectures.

For the same reason, I would also be able to start coding earlier.

Apart from that I hope to be a guide at the International Mathematical Olympics at the end of July but this will take only one and a half week.

Finally in August I may start a Hebrew course, but this will nevertheless allow me to finish the project.

About Me (let us know who you are!):

the Technical University of Dresden. I have experience programming in C++ with QT from I am a student of mathematics and computer science in my last year at various university projects. I started using Linux and KDE around 7 years ago. Apart from writing a small patch for Canorus ( I have never before programmed for an open source project. But I am already reading koffice-devel for a year andso I think I could find into the project relative easily.

In my free time I like to play trumpet, bike, travel, do stuff with my friends, my girlfriend and the guys from my church.