Calligra/Words/Tutorials/EditingOdf

From KDE Community Wiki

About

This document describes how editing of ODF documents work in KWord.

Highly recommended that you read Loading ODF

Editing

When the user edits the document, say she marks the text as bold, we manipulate QTextDocument directly using the QTextCursor API. KoTextSelectionHandler (libs/kotext) helps you with making changes to selections. You can ask it make the selection bold or italic and things like that. You will notice that not all the code uses KoTextSelectionHandler, it manipulates QTextDocument directly - this should be fixed, I think.

Wondered how pressing 'enter' in a list style, creates a new paragraph that is part of the list? Styles in ODF has a concept of next-style, which is the style for a new paragraph that follows the style. In the case of a list, the next-style could point to the style itself.

Lets see what happens when enter is pressed in our text shape. Recall how all events are forwarded to the active shape's active tool. For the TextShape, the tool is TextTool.cpp. When it receives a Key_Enter, it uses the KoTextSelectionHandler to create a new paragraph using KoTextSelectionhandler::nextParagraph. KoTextSelectionHandler just looks into the next-style of the current paragraph's style. Getting the current style of a paragraph is made possible using styleManager->paragraphStyle(cursor.blockFormat().intProperty(KoParagraphStyle::StyleId)).

-- Girish Ramakrishnan <[email protected]>