void KWTextImage::load( QDomElement & parentElem ) { // This code is similar to KWPictureFrameSet::load KWDocument * doc = static_cast<KWTextDocument *>(parent)->textFrameSet()->kWordDocument(); // <IMAGE> (KOffice 1.0) or <PICTURE> (KWord 1.2) QDomNode node=parentElem.namedItem( "PICTURE" ); if ( node.isNull() ) { node=parentElem.namedItem( "IMAGE" ); } QDomElement image = node.toElement(); if ( image.isNull() ) image = parentElem; // The data is directly child of <FORMAT> // <KEY> QDomElement keyElement = image.namedItem( "KEY" ).toElement(); if ( !keyElement.isNull() ) { KoPictureKey key; key.loadAttributes( keyElement ); m_image.setKey(key); doc->addTextImageRequest( this ); } else { // <FILENAME> (old format, up to KWord-1.1-beta2) QDomElement filenameElement = image.namedItem( "FILENAME" ).toElement(); if ( !filenameElement.isNull() ) { QString filename = filenameElement.attribute( "value" ); m_image.setKey( KoPictureKey( filename ) ); doc->addTextImageRequest( this ); } else { kdError(32001) << "Missing KEY or FILENAME tag in IMAGE (KWTextImage::load)" << endl; } } }
void KWTextImage::save( QDomElement & parentElem ) { // This code is similar to KWPictureFrameSet::save KWDocument * doc = static_cast<KWTextDocument *>(parent)->textFrameSet()->kWordDocument(); QDomElement imageElem = parentElem.ownerDocument().createElement( "PICTURE" ); parentElem.appendChild( imageElem ); //imageElem.setAttribute( "keepAspectRatio", "true" ); QDomElement elem = parentElem.ownerDocument().createElement( "KEY" ); imageElem.appendChild( elem ); image().getKey().saveAttributes( elem ); // Now we must take care that a <KEY> element will be written as a child of <PICTURES> doc->addTextImageRequest( this ); }