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 tagName( tag.tagName() );
00050 const bool textFoo = tagName.startsWith( "text:" );
00051 kdDebug() << "KWTextDocument::loadSpanTag: " << tagName << endl;
00052
00053 if ( textFoo )
00054 {
00055 if ( tagName == "text: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 else {
00077
00078
00079
00080 context.fillStyleStack( spanElem, KoXmlNS::text, "style-name", "text" );
00081 text = spanElem.text();
00082 }
00083 textData = '#';
00084
00085 KoVariableCollection& coll = context.variableCollection();
00086 customItem = new KoLinkVariable( this, text, href,
00087 coll.formatCollection()->format( "STRING" ),
00088 &coll );
00089 }
00090 return true;
00091 }
00092 }
00093 else
00094 {
00095 kdDebug()<<"Extension found tagName : "<<tagName<<endl;
00096 }
00097 return false;
00098 }
00099
00100
00101 #include "KPrTextDocument.moc"
|