Working on deleting anchored objects in Words

Thorsten Zachmann t.zachmann at zagge.de
Wed Jan 4 06:26:07 GMT 2012


Hello,

I have been looking at the problem that you get when deleting a anchored 
object inside words. I post my findings and patch here and not on reviewboard 
as it make discussion a lot easier.

To see the problem

Open the attached document image.odt
Select the image.
Delete it.

Expected outcome:
The text should flow as there would be nothing that obsures it.

Actual outcome:
The text still thinks that there shape and flows around it.

When you then try to save the document or do other stuff it is quite easy to 
trigger crashes.

The problem is due to the KoTextAnchor which contains the deleted shape is 
actually never removed from the document and therefore it still handles it as 
it where there even when the shape itself is deleted.

What the patch does:
When there is a anchor belonging to the shape, it also removes the anchor from 
the document. This is done by circumventing the command generation of 
KoTextEditor. I do this because there should be no additional commands 
generated besides the DeleteShapeCommand. As the data to recovering the 
deletion is stored in the application data it is not needed that a undo 
command for the actual removal of the anchor is created. 

Stage uses a similar approach when a shape is delete that has a animation.

So what do you think?

Thorsten
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.odt
Type: application/vnd.oasis.opendocument.text
Size: 51042 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/calligra-devel/attachments/20120104/02993f36/attachment.odt>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fix_deleting_anchored_objects.diff
Type: text/x-patch
Size: 5298 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/calligra-devel/attachments/20120104/02993f36/attachment.bin>


More information about the calligra-devel mailing list