Friday, May 30, 2008

KOffice can strike out anything

We added a feature in KWord yesterday that lets you strike-out a text, like "wrong word" with any custom text, like "x" or "---x---" instead of the boring "wrong word" style (example odt). You can also use any custom text to fill the whitespace created by a tab (example odt). Rather advanced text editing, I'd say. And it turns out that it you can get it to create some rather funky patterns.


The one on the top is done with 'o's struck-out with with 'O's. And the next one has '/'s struck-out with '| - '. These strings can be specified in an ODT file and read in, but as yet there's no interface in KWord to create such a document directly.

Now that we have this, if there's any artist making ASCII art who wants an alpha channel in his "images", KWord will be his tool of choice. :)

Wednesday, May 21, 2008

Accessing QtScript arrays from C++

Roop was wondering how to access an (QScript) array from C++. I spent sometime trying to figure how to do that, so I thought I will let the world know.

A search on the QScriptValue documentation page yields QScriptValue::isArray(). We can use that to determine if the value is an array or not. Unfortunately, it doesn't really state there how to access contents of the array. My initial reaction was to just convert the value to a QVariant (using toVariant()) and then convert the variant to a QVariantList (toList()). That didn't quite work.

The answer lies in understanding arrays and objects in EcmaScript - Everything is an object. Every object is really a map from properties to values. What that means is that an EcmaScript array is just an object. And the values you put into it are just properties of the array. The [] syntax is EcmaScript is just to make us feel at home and make us believe you are working with arrays and not some fancy objects. So,

array[1] = "foo"; // creates property named "1" with value "foo"

With that revelation, you should be able to find QScriptValue::property(). Just pass the values 0, 1, 2 and so on as arrayIndex and you should receive the values. But, what about the length of the array? Remember, everything is a property in an object. The length is stored in the length property of the array which you can query using the other QScriptValue::property() overload.

P.S 1:
Note that, array indices are not limited to integers (it is a map). So, the below is perfectly fine.

array["one"] = "foo;

I can imagine it to be common to inspect all the properties of an object. You can use QScriptValueIterator for that.


P.S 2:
array[1] is the same thing as array["1"]. The keys in EcmaScript maps are strings.

Update
Roop found a much much easier way to process arrays: qScriptValueToSequence

Saturday, May 17, 2008

38

So, we are at 38 testcases now. After the initial burst, progress has been slow. This was expected because most of the remaining testcases are yet to be implemented in KWord.

Among other news, I made an announcement on the koffice-devel list about the progress. Pinaraf and dipesh who are actively working on adding other ODF features to KWord, had some trouble getting the tests up and running. As a result, I added a README and STATUS file to ease things up. If you are working on anything related to ODF support, give the test suite a shot. It is invaluable when it comes to regression testing.

Wednesday, May 14, 2008

KWord ODF Support

It's been over a month now since Roop and I started working on getting the ODF support in KWord upto shape (Our work is sponsored by the NLNet foundation). To give us direction in pursuit of that holy grail, we started out automating the test suite at OpenDocument Fellowship.

We decided that we would take the tests one by one, make them work in KWord and then commit the test to the KWord repository.

Writing each test is quite a tedious task:

  • Read the specification for the feature. As all specs go, it leaves some details to the imagination of the reader.
  • The test case itself is then analyzed for correctness.
  • We then run the test in KWord and check if it works as expected.
  • If it does not work as expected, we fix KWord. This is the fun part :-)
  • Once the functionality is added/fixed in KWord, we finally get around to automating the testcase. We have a framework that compares the document (QTextDocument) created by a script (QtScript) and the document created by KWord. So, all we have to do to automate the test case is to write a QtScript that generates the expected document.
As it stands, out of a total of 160 test cases, 33 have been automated. So, thats 33 completely working ODF text features in KWord! Not bad for a month, eh? We have been a bit low this month though thanks to my super flaky internet connection (Tata Wimax, a big rant on this later) and Roop being occupied with getting the website up and running.

You can browse the test suite online here: http://websvn.kde.org/trunk/koffice/libs/kotext/opendocument/tests/

Monday, May 5, 2008

And we're on

We launched our website today, a bit under three months since we founded ForwardBias Technologies. While that might be considered a rather long period of sitelessness, on the brighter side, we've been busy. We're onto the endgame of building Spambin, our spam-blocking software for mobile phones (you can register here for beta). And we're neck deep into improving ODF support for KWord 2.0, supported by NLNet Foundation. Girish has been involved in a slew of other Qt-related projects as well.

On the more mundane admin side, we're now, well, a company, officially speaking. One with a consulting agreement with Trolltech for offering Qt services and a developer certificate from Symbian for distributing S60 software.

So, there. We're on.
QED. :)