words: images with anchoring enabled will be saved twice to odf.

Thorsten Zachmann t.zachmann at zagge.de
Fri Dec 16 12:13:33 GMT 2011


On Friday, December 16, 2011 10:54:22 Silvio Heinrich wrote:
> There is a problem when saving a text document that contains anchored
> images.
> In the saving process the saveOdf method of the shape (the pictureshape
> in this case) is called twice because the shape itself exists twice in
> the document.
> The shape is added to the KWDocument and if it is anchored it is also
> passed to a KoTextAnchor instance that is added as an inline object.
> Now when saving it seems as if first all the shapes and then all the
> inline objects will be saved.
> That leads to an odf output like this:
> 
> // 1. pictureshape is saves
> <frame ...><image .../></frame>
> // 2. inline object (the KoTextAnchor) is saved
> // it puts a paragraph tag around the image and calls the safeOdf method
> of the imageshape again
> <p ...><frame ...><image .../></frame></p>
> 
> So for me it seems when the shape is anchored it should be removed from
> the KWDocument
> but on the other hand it needs to be present in the KWDocument to render
> and interact with the shape.
> 
> Does anyone have a guess how to solve this problem?

There is code in 
KWOdfWriter::save
   
  foreach (KWFrameSet *fs, m_document->frameSets()) {                                                                                                                                       
        // For the purpose of saving to ODF we have 3 types of frames.                                                                                                                        
        //  1) auto-generated frames.  This includes header/footers and the 
main text FS.                                                                                                     
        //  2) frames that are anchored to text.  They have a parent and their 
parent will save them.                                                                                         
        //  3) frames that are not anchored but freely positioned somewhere on 
the page.                                                                                                      
        //     in ODF terms those frames are page-anchored.                                                                                                                                   

if that does not work as it should that is the place that needs fixing.

Thorsten



More information about the calligra-devel mailing list