As you may remember from my last post, I was cheating in my screencast; the table height was hard-coded and the cell heights were not adjusted to content height. What I needed to do was to handle the following case:
Cell Heights Adjustment
I have just commited the beginnings of this in r997173. TableLayout now has an updateCellContentHeight(QTextTableCell&) API, which is called once the content of a cell has been laid out in Layout::nextParag().
There are a lot of rough edges, and my tests of course broke left and right, but it principally works, fingers crossed Here’s a video demonstration:
I hope everyone had a nice time on Gran Canaria. It seems like it’s been a really successful event from all the posts I’ve read.
I’m not one of the frequent GSoC bloggers here on p.k.o, but as we are in mid-term now I thought I’d make a little summary of my thoughts around the project so far and give a little status report.
Initially my idea was to divide this post into two sections; “The Good” and “The Bad”, with a summary at the end. But then I realized that for almost every bad thing I could think of, I could find a good side to it, and vice versa. There’s always two sides to a coin. So instead I’ve decided to make a table. How appropriate
(The table is styled and probably looks better at my blog page)
GSoC experiences so far
-
+
Table layout is hard. There are just so many things to consider, and a lot of side cases to take care of. Just look at Qt Scribe’s implementation. Lord knows I have
But extremely fun and a very rewarding thing to work on. The feedback is quite immediate, which is very gratifying.
Unit testing is an art. You have to be very careful what you test for and how you go about it. Just writing the tests is not enough, you have to put a lot of thought into it.
But it’s an invaluable tool when starting out and trying to focus on a specific aspect of a complex thing such as table layout. By the way, anyone who can recommend a short little book on unit testing? Preferably something as concise and “hands-on” as e.g. Meyers’ Effective C++.
I have probably over-estimated my abilities as a programmer. I tend to try to consider all the consequences of the changes I do at once and look into the future, instead of focusing on the actual problem at hand, and this tend to be a real show stopper for productivity. As my good mentor Thomas put it; perfection is the enemy of productivity.
But I’ve learnt a lot about my abilities and limitations, and I feel that I’m improving. I’m confident that by the end of this summer, I will have grown as a programmer.
Git can be confusing. Coming from centralized VCSs like SVN and CVS, wrapping your head around this new-fangled distributed VCS can be quite daunting, especially as the user interface is a veritable swiss army knife of funky names and idioms. A text that really helped me understand how Git works was The Git Parable. And for the more technically inclined I’ve heard good things about Git for Computer Scientists
But it is a God-send after all, and I can’t wait until all of KOffice (and KDE) is on Git. Things like cherrypicking, interactive rebasing and extremely easy branching/merging is just too good to say no to. I’d like to make a parallel to when I first learned Vim. No pain no gain right? Recent posts here on the planet, if I understand them correctly, indicates that there are talks about hosting KDE Git repos at Gitorious, which sounds like a good idea to me.
The payment schedule of Summer of Code is kind of unfortunate. At least if you have high fixed expenses every month, as you’ll have to go all through June without any money. This is something to think about if you’re considering participating. I was lucky to be able to loan money for my rent/Internet/electricity/phone bill.
But this is definitely understandable. Having monthly payments would mean having monthly evaluations and a lot more work for both mentors and Google staff members. I guess a lot of students in the program live with their parents and don’t have a lot of expenses. But I’m (almost) an old fart as far as students go Just bringing this up, as it can become an extra stress factor.
All in all, I’m having a great GSoC so far, and I think it can only get better.
Progress
Now on to some information about my progress. What I’ve been working on is getting some first basic table layout working. The design is quite simple so far, and looks very roughly something like this:
Table Layout Design Overview
The Layout class is the innermost class of the text layout engine in KOffice, and is the one responsible for most of the nitty gritty details of text layout. It is declared as an inner class of KoTextDocumentLayout, which has an instance of this class called m_state.
KoTextDocumentLayout in turn is a higher level class that derives from Qt’s abstract document layout class QAbstractTextDocumentLayout. Qt’s own document layout engine, QTextDocumentLayout, which is not shown in the diagram above, derives from this same ABC. I’ve also included KWTextDocumentLayout, which is a specialized KoTextDocumentLayout used in KWord. It adds support for letting text flow around other shapes, among other things.
What this all means is that KOffice’s layout engine, while still working with an underlying QTextDocument, is completely separate from Qt’s. Now, because of poor research on my part in the weeks leading up to the GSoC start, I actually thought I’d be able to leverage at least some of the built-in support for table layout in Qt. But I have only myself to blame for that, and it’s nothing to cry over now. What I do get is QTextTable, which can be considered a blueprint for a table, and my task is to lay out this table according to its properties, which I’ll later have to extend to support ODF features that don’t have a 1:1 equivalent in QTextTable and its associate classes.
I’ve modified Layout to have an instance of the new class TableLayout, which is responsible for doing layout and drawing of tables. It takes a QTextTable and lays it out, storing the layout information, such as table and cell geometries in an associated TableData instance. It actually caches TableData instances per-table internally. TableLayout offers an API to be used from Layout to obtain cell content rectangles to direct the layout engine into, as well as an API for adjusting cell heights based on the cell contents.
It’s a simple design, but one that I think will work out fine for all the requirements that will come later, and I already have ideas on how e.g. cell spanning should be implemented. Things on my TODO are too many to even enumerate, but what I’m working on right this minute is row heights calculations and finding a good way to let the layout process in Layout notify the TableLayout of cell content height changes. After that comes, among other things:
Margins/paddings/borders.
Variable column widths.
Tests, tests and more tests.
Now let’s see, this post has had a table, a diagram and a list. What’s missing? A video of course Take 50 seconds and marvel at me pasting a basic table from Firefox into KWord and editing the cell contents:
Actually I’m cheating in the above video, as the table height is hard coded, but don’t tell anyone!
Finally, I’d like to be honest and admit that progress really haven’t been as fast as I thought it would be, but I do feel that I’m on the right track. And even though the road ahead is longer than what I would have wanted, at least it seems pretty straight, all things considered.
Now if you’ll excuse me, I really need to get back to coding!
I’m probably one of the last GSoC student to blog after the announcement, but I’m just knee high in school work right now
The good news is: Yes! My proposal was accepted and I’ll be working this summer with implementing basic support for tables in KOffice’s text shape. Of course I’m very excited about this and I just wish school was over so I can start hacking.
I’ve been aggregated on the planet for a while now, so maybe some of you have an idea of who I am, though my very infrequent posting surely hasn’t helped. My name is Elvis Stansvik and I’m a 25 year old student from Sweden. A little more about me in my original proposal. I’ve followed the KOffice project with great interest for the past 4 years or so, and when time has allowed I’ve done some bug fixing et.c. I’m looking forward to finally be able to put my heart into the project this summer.
Since support for tables is quite an ambitious task and one that is important to get right, I’m very honored by the confidence put in me by the KOffice mentors and I’ll make sure to work closely with my assigned mentor Thomas and other senior devs within KOffice to bring it to fruition. Don’t be fooled by the word “basic” in my proposal title, tables are a complex thing to implement and although my goals for this summer does not include support for every single detail of the ODF specification of tables, all the requirements of the spec must still be kept in mind in order for my implementation to be able to grow in the future.
As I said, at the moment I’m kind of swamped by school work, but during the little free moments that I actually have, I’m putting my nose in the text layout and loading code of KOffice, and I think that I already have quite a good grasp of how it fits together. School work should ease up a bit in the coming week or two, and during this initial “Community Bonding” period, my plan is to:
Read all the relevant portions of the ODF specification and keep my eye out for things that I need to keep in mind that I haven’t thought of already, and maybe create a short list of “requirements” to get a better overview of what ODF demands when it comes to tables.
Spend more time reading and maybe even poking at some at the text layout code in plugins/textshape and loading code in libs/kotext/opendocument. No better way to learn than to break stuff.
Ask my good’ol mentor quite some questions!
In the beginning of June, I’ll also be attending the KOffice meeting in Berlin, where I’ll be able to meet Thomas and the other KOffice devs.
All in all, I think this summer will be a lot of hard work, but a great opportunity, both for me to grow as a programmer and learn more about the KOffice code, but also for KOffice who will finally be getting a proper implementation of tables for the 2.x series, and I’m very much looking forward to it.
Shame on me for using the planet like this, but I’m currently looking for a part time / temporary job that I can combine with my studies. I’m a free software hacker (duh) in my spare time, and you can find some patches from me sprinkled about projects such as KOffice, The Gimp, Scribus, libxml2 and FreeBSD.
My previous work experiences are quite varied and include running my own book shop and eventually a book café, working as an IT-technician for a small book publishing company and also being leased out as a programming consultant to other Swedish publishing companies. At the moment I’m studying and doing some part time work as a translator of technical manuals and user interfaces for a Spanish localization company.
I’m an agile worker and good at keeping deadlines and delivering on spec, as well as quickly getting up to speed in large existing code bases in a multitude of programming languages.
If you need an extra hand for your project, or just need an additional part time worker on your staff, please don’t hesitate to contact me! Here’s my CV. I’m not picky about which tools or technologies you want me to work with, or afraid of mundane tasks. And the pay just have to be reasonable, not more