kpresenter
KPrTextDocument.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "KPrTextDocument.h"
00022
00023 #include "KPrDocument.h"
00024 #include "KPrTextObject.h"
00025 #include <KoTextParag.h>
00026 #include <kdebug.h>
00027
00028 #include "KPrVariableCollection.h"
00029
00030 #include <KoOasisContext.h>
00031 #include <KoDom.h>
00032 #include <KoXmlNS.h>
00033
00034 KPrTextDocument::KPrTextDocument( KPrTextObject * textobj, KoTextFormatCollection *fc, KoTextFormatter *formatter )
00035 : KoTextDocument( textobj->kPresenterDocument()->zoomHandler(), fc, formatter, true ), m_textobj( textobj )
00036 {
00037
00038 }
00039
00040 KPrTextDocument::~KPrTextDocument()
00041 {
00042 }
00043
00044
00045 bool KPrTextDocument::loadSpanTag( const QDomElement& tag, KoOasisContext& context,
00046 KoTextParag* parag, uint pos,
00047 QString& textData, KoTextCustomItem* & customItem )
00048 {
00049 const QString localName( tag.localName() );
00050 const bool isTextNS = tag.namespaceURI() == KoXmlNS::text;
00051 kdDebug( 32500 ) << "KPrTextDocument::loadSpanTag: " << localName << endl;
00052
00053 if ( isTextNS )
00054 {
00055 if ( localName == "a" )
00056 {
00057 QString href( tag.attributeNS( KoXmlNS::xlink, "href", QString::null ) );
00058 if ( href.startsWith( "#" ) )
00059 {
00060 context.styleStack().save();
00061
00062
00063 parag->loadOasisSpan( tag, context, pos );
00064 context.styleStack().restore();
00065 }
00066 else
00067 {
00068
00069
00070
00071
00072 QDomElement spanElem = KoDom::namedItemNS( tag, KoXmlNS::text, "span" );
00073 QString text;
00074 if ( spanElem.isNull() )
00075 text = tag.text();
00076 if ( spanElem.isNull() )
00077 text = tag.text();
00078 else {
00079
00080
00081
00082 context.fillStyleStack( spanElem, KoXmlNS::text, "style-name", "text" );
00083 text = spanElem.text();
00084 }
00085 textData = KoTextObject::customItemChar();
00086
00087 KoVariableCollection& coll = context.variableCollection();
00088 customItem = new KoLinkVariable( this, text, href,
00089 coll.formatCollection()->format( "STRING" ),
00090 &coll );
00091 }
00092 return true;
00093 }
00094 }
00095 else
00096 {
00097 kdDebug()<<"Extension found tagName : "<< localName <<endl;
00098 }
00099 return false;
00100 }
00101
00102
00103 #include "KPrTextDocument.moc"
|