21#include "KWDocument.h"
22#include "KWTextDocument.h"
23#include "KWTextFrameSet.h"
24#include "KWTextParag.h"
25#include "KWLoadingInfo.h"
26#include "KWVariable.h"
28#include "KWOasisLoader.h"
29#include "KWTableFrameSet.h"
31#include <KoOasisContext.h>
36#include <tdeglobalsettings.h>
40 : KoTextDocument( textfs->kWordDocument(), fc, formatter, false ), m_textfs( textfs )
46 : KoTextDocument( zoomHandler, new KoTextFormatCollection( TDEGlobalSettings::generalFont() , TQColor(), TDEGlobal::locale()->language(), false), 0L, false ),
52void KWTextDocument::init()
58KWTextDocument::~KWTextDocument()
62KoTextParag * KWTextDocument::createParag( KoTextDocument *d, KoTextParag *pr, KoTextParag *nx, bool updateIds )
64 return new KWTextParag( static_cast<KoTextDocument * >(d), static_cast<KoTextParag * >(pr), static_cast<KoTextParag * >(nx), updateIds );
67KoTextDocCommand *KWTextDocument::deleteTextCommand( KoTextDocument *textdoc, int id, int index, const TQMemArray<KoTextStringChar> & str, const CustomItemsMap & customItemsMap, const TQValueList<KoParagLayout> & oldParagLayouts )
70 return new KWTextDeleteCommand( textdoc, id, index, str, customItemsMap, oldParagLayouts );
73void KWTextDocument::loadOasisTOC( const TQDomElement& tag, KoOasisContext& context, KoTextParag* & lastParagraph, KoStyleCollection * styleColl, KoTextParag* nextParagraph )
84 TQDomElement tocIndexBody = KoDom::namedItemNS( tag, KoXmlNS::text, "index-body" );
86 forEachElement( t, tocIndexBody )
88 context.styleStack().save();
89 const TQString localName = t.localName();
91 bool isTextNS = tag.namespaceURI() == KoXmlNS::text;
92 if ( isTextNS && localName == "index-title" ) {
93 lastParagraph = loadOasisText( t, context, lastParagraph, styleColl, nextParagraph );
94 lastParagraph->setPartOfTableOfContents( true );
95 } else if ( isTextNS && localName == "p" ) {
96 context.fillStyleStack( t, KoXmlNS::text, "style-name", "paragraph" );
97 lastParagraph = createParag( this, lastParagraph, nextParagraph );
99 lastParagraph->loadOasis( t, context, styleColl, pos );
100 lastParagraph->setPartOfTableOfContents( true );
102 kdWarning() << "OASIS TOC loading: unknown tag " << t.tagName() << " found in index-body" << endl;
103 context.styleStack().restore();
106 m_textfs->kWordDocument()->setTocPresent( true );
110 KoTextParag* & lastParagraph, KoStyleCollection* styleColl,
111 KoTextParag* nextParagraph )
113 const TQString localName( tag.localName() );
115 if ( localName == "frame" && tag.namespaceURI() == KoXmlNS::draw )
117 KWDocument* doc = m_textfs->kWordDocument();
118 KWOasisLoader loader( doc );
119 KWFrame* frame = loader.loadFrame( tag, context, KoPoint() );
125 else if ( localName == "table" && tag.namespaceURI() == KoXmlNS::table )
127 KWDocument* doc = m_textfs->kWordDocument();
128 KWOasisLoader loader( doc );
132 KoTextParag *parag = createParag( this, lastParagraph, nextParagraph );
133 if ( !lastParagraph )
134 setFirstParag( parag );
135 lastParagraph = parag;
137 parag->insert( 0, KoTextObject::customItemChar() );
139 parag->setCustomItem( 0, table-> createAnchor( m_textfs->textDocument(), 0 ), 0 );
142 else if ( localName == "table-of-content" && tag.namespaceURI() == KoXmlNS::text )
144 loadOasisTOC( tag, context, lastParagraph, styleColl, nextParagraph );
151void KWTextDocument::appendBookmark( KoTextParag* parag, int pos, KoTextParag* endParag, int endPos, const TQString& name )
155 m_textfs->kWordDocument()->insertBookmark( name, parag, endParag, pos, endPos );
158void KWTextDocument::loadOasisFootnote( const TQDomElement& tag, KoOasisContext& context,
159 KoTextCustomItem* & customItem )
161 const TQString frameName( tag.attributeNS( KoXmlNS::text, "id", TQString()) );
162 const TQString localName( tag.localName() );
163 const TQDomElement citationElem = tag.namedItem( localName + "-citation" ).toElement();
165 bool endnote = localName == "endnote" && tag.namespaceURI() == KoXmlNS::text;
167 TQString label = citationElem.attributeNS( KoXmlNS::text, "label", TQString() );
168 bool autoNumbered = label.isEmpty();
170 KWFootNoteFrameSet *fs = m_textfs->insertFootNote(
171 endnote ? EndNote : FootNote,
172 autoNumbered ? KWFootNoteVariable::Auto : KWFootNoteVariable::Manual,
174 customItem = fs->footNoteVariable();
176 fs->createInitialFrame( 0 );
179 const TQDomElement bodyElem = KoDom::namedItemNS( tag, KoXmlNS::text, TQCString( localName.latin1() ) + "-body" ).toElement();
184 KoTextParag* parag, uint pos,
185 TQString& textData, KoTextCustomItem* & customItem )
187 const TQString localName( tag.localName() );
188 const bool isTextNS = tag.namespaceURI() == KoXmlNS::text;
189 kdDebug(32500) << "KWTextDocument::loadSpanTag: " << localName << endl;
193 if ( localName == "a" )
195 TQString href( tag.attributeNS( KoXmlNS::xlink, "href", TQString()) );
196 if ( href.startsWith( "#") )
198 context.styleStack().save();
201 parag->loadOasisSpan( tag, context, pos );
202 context.styleStack().restore();
210 TQDomElement spanElem = KoDom::namedItemNS( tag, KoXmlNS::text, "span" );
212 if( spanElem.isNull() )
218 context.fillStyleStack( spanElem, KoXmlNS::text, "style-name", "text" );
219 text = spanElem.text();
221 textData = KoTextObject::customItemChar();
223 KoVariableCollection& coll = context.variableCollection();
224 customItem = new KoLinkVariable( this, text, href,
225 coll.formatCollection()->format( "STRING" ),
230 else if ( localName == "bookmark" )
232 appendBookmark( parag, pos, parag, pos, tag.attributeNS( KoXmlNS::text, "name", TQString() ) );
235 else if ( localName == "bookmark-start" ) {
236 KWLoadingInfo* loadingInfo = m_textfs->kWordDocument()->loadingInfo();
237 loadingInfo->m_bookmarkStarts.insert( tag.attributeNS( KoXmlNS::text, "name", TQString() ),
241 else if ( localName == "bookmark-end" ) {
242 KWLoadingInfo* loadingInfo = m_textfs->kWordDocument()->loadingInfo();
243 TQString bkName = tag.attributeNS( KoXmlNS::text, "name", TQString() );
244 KWLoadingInfo::BookmarkStartsMap::iterator it = loadingInfo->m_bookmarkStarts.find( bkName );
245 if ( it == loadingInfo->m_bookmarkStarts.end() ) {
247 appendBookmark( parag, pos, parag, pos, tag.attributeNS( KoXmlNS::text, "name", TQString() ) );
249 if ( (*it).doc != this ) {
251 kdWarning(32500) << "Cross-frameset bookmark! Not supported." << endl;
253 appendBookmark( (*it).parag, (*it).pos, parag, pos, it.key() );
255 loadingInfo->m_bookmarkStarts.remove( it );
259 else if ( localName == "footnote" || localName == "endnote" )
261 textData = KoTextObject::customItemChar();
262 loadOasisFootnote( tag, context, customItem );
268 if ( tag.namespaceURI() == KoXmlNS::draw && localName == "frame" )
270 if ( tag.attributeNS( KoXmlNS::koffice, "is-wrapper-frame", TQString() )
273 TQDomElement textbox = KoDom::namedItemNS( tag, KoXmlNS::draw, "text-box" );
274 if ( !textbox.isNull() )
276 int numberOfElements = 0;
278 TQDomElement firstElem;
279 forEachElement( elem, textbox )
284 if ( numberOfElements == 1 )
286 kdDebug(32001) << "Wrapper frame removed, loading " << firstElem.tagName() << " directly" << endl;
288 return loadSpanTag( firstElem, context, parag, pos, textData, customItem );
294 KWDocument* doc = m_textfs->kWordDocument();
295 KWOasisLoader loader( doc );
296 KWFrame* frame = loader.loadFrame( tag, context, KoPoint() );
304 textData = KoTextObject::customItemChar();
306 customItem = fs-> createAnchor( m_textfs->textDocument(), 0 );
312 else if ( tag.namespaceURI() == KoXmlNS::table && localName == "table" )
314 KWDocument* doc = m_textfs->kWordDocument();
315 KWOasisLoader loader( doc );
318 textData = KoTextObject::customItemChar();
320 customItem = table-> createAnchor( m_textfs->textDocument(), 0 );
327#include "KWTextDocument.moc"
Class: KWFrameSet Base type, a frameset holds content as well as frames to show that content.
virtual KWAnchor * createAnchor(KoTextDocument *txt, int frameNum) Create an anchor for the floating frame identified by frameNum.
void setAnchorFrameset(KWTextFrameSet *textfs) Sets the frameset in which we are about to become inline. Used for OASIS loading.
This class represents a single frame.
KWFrameSet * frameSet() const Data stucture methods.
Temporary information used only during loading.
This class implements tables by acting as the manager for the frame(set)s which make up the table cel...
virtual void finalize() Called once the frameset has been completely loaded or constructed.
virtual KWAnchor * createAnchor(KoTextDocument *txt, int frameNum) Create an anchor for the floating frame identified by frameNum.
virtual bool loadOasisBodyTag(const TQDomElement &tag, KoOasisContext &context, KoTextParag *&lastParagraph, KoStyleCollection *styleColl, KoTextParag *nextParagraph) Extensions to KoTextDocument::loadOasisText.
KWTextDocument(KWTextFrameSet *textfs, KoTextFormatCollection *fc, KoTextFormatter *formatter=0L) A real text document inside a frameset.
virtual bool loadSpanTag(const TQDomElement &tag, KoOasisContext &context, KoTextParag *parag, uint pos, TQString &textData, KoTextCustomItem *&customItem) Extensions to KoTextParag::loadOasisSpan.
Class: KWTextFrameSet Contains text (KoTextObject) and frames to display that text.
void loadOasisContent(const TQDomElement &bodyElem, KoOasisContext &context) Load the contents of a frame (i.e. the text).
Bookmarks (OASIS XML). Only need to store bookmark starts, until hitting bookmark ends.
|