diff options
Diffstat (limited to 'kate/xmltools/pseudo_dtd.cpp')
-rw-r--r-- | kate/xmltools/pseudo_dtd.cpp | 158 |
1 files changed, 79 insertions, 79 deletions
diff --git a/kate/xmltools/pseudo_dtd.cpp b/kate/xmltools/pseudo_dtd.cpp index b5c9cd1..05ac58a 100644 --- a/kate/xmltools/pseudo_dtd.cpp +++ b/kate/xmltools/pseudo_dtd.cpp @@ -24,8 +24,8 @@ #include <assert.h> -#include <qdom.h> -#include <qregexp.h> +#include <tqdom.h> +#include <tqregexp.h> #include <klocale.h> #include <kmessagebox.h> @@ -40,9 +40,9 @@ PseudoDTD::~PseudoDTD() { } -void PseudoDTD::analyzeDTD( QString &metaDtdUrl, QString &metaDtd ) +void PseudoDTD::analyzeDTD( TQString &metaDtdUrl, TQString &metaDtd ) { - QDomDocument doc( "dtdIn_xml" ); + TQDomDocument doc( "dtdIn_xml" ); if ( ! doc.setContent( metaDtd) ) { KMessageBox::error(0, i18n("The file '%1' could not be parsed. " @@ -68,7 +68,7 @@ void PseudoDTD::analyzeDTD( QString &metaDtdUrl, QString &metaDtd ) // count this twice, as it will be iterated twice ( TODO: optimize that? ): listLength += doc.elementsByTagName( "attlist" ).count() * 2; - QProgressDialog progress( i18n("Analyzing meta DTD..."), i18n("Cancel"), listLength, + TQProgressDialog progress( i18n("Analyzing meta DTD..."), i18n("Cancel"), listLength, 0, "progress", TRUE ); progress.setMinimumDuration( 400 ); progress.setProgress(0); @@ -97,16 +97,16 @@ void PseudoDTD::analyzeDTD( QString &metaDtdUrl, QString &metaDtd ) * Iterate through the XML to get a mapping which sub-elements are allowed for * all elements. */ -bool PseudoDTD::parseElements( QDomDocument *doc, QProgressDialog *progress ) +bool PseudoDTD::parseElements( TQDomDocument *doc, TQProgressDialog *progress ) { m_elementsList.clear(); // We only display a list, i.e. we pretend that the content model is just // a set, so we use a map. This is necessay e.g. for xhtml 1.0's head element, // which would otherwise display some elements twice. - QMap<QString,bool> subelementList; // the bool is not used + TQMap<TQString,bool> subelementList; // the bool is not used - QDomNodeList list = doc->elementsByTagName( "element" ); + TQDomNodeList list = doc->elementsByTagName( "element" ); uint listLength = list.count(); // speedup (really! ) for( uint i = 0; i < listLength; i++ ) @@ -119,57 +119,57 @@ bool PseudoDTD::parseElements( QDomDocument *doc, QProgressDialog *progress ) //qApp->processEvents(); subelementList.clear(); - QDomNode node = list.item( i ); - QDomElement elem = node.toElement(); + TQDomNode node = list.item( i ); + TQDomElement elem = node.toElement(); if( !elem.isNull() ) { // Enter the expanded content model, which may also include stuff not allowed. // We do not care if it's a <sequence-group> or whatever. - QDomNodeList contentModelList = elem.elementsByTagName( "content-model-expanded" ); - QDomNode contentModelNode = contentModelList.item(0); - QDomElement contentModelElem = contentModelNode.toElement(); + TQDomNodeList contentModelList = elem.elementsByTagName( "content-model-expanded" ); + TQDomNode contentModelNode = contentModelList.item(0); + TQDomElement contentModelElem = contentModelNode.toElement(); if( ! contentModelElem.isNull() ) { // check for <pcdata/>: - QDomNodeList pcdataList = contentModelElem.elementsByTagName( "pcdata" ); + TQDomNodeList pcdataList = contentModelElem.elementsByTagName( "pcdata" ); // check for other sub elements: - QDomNodeList subList = contentModelElem.elementsByTagName( "element-name" ); + TQDomNodeList subList = contentModelElem.elementsByTagName( "element-name" ); uint subListLength = subList.count(); for( uint l = 0; l < subListLength; l++ ) { - QDomNode subNode = subList.item(l); - QDomElement subElem = subNode.toElement(); + TQDomNode subNode = subList.item(l); + TQDomElement subElem = subNode.toElement(); if( !subElem.isNull() ) subelementList[subElem.attribute( "name" )] = true; } // anders: check if this is an EMPTY element, and put "__EMPTY" in the // sub list, so that we can insert tags in empty form if required. - QDomNodeList emptyList = elem.elementsByTagName( "empty" ); + TQDomNodeList emptyList = elem.elementsByTagName( "empty" ); if ( emptyList.count() ) subelementList["__EMPTY"] = true; } // Now remove the elements not allowed (e.g. <a> is explicitely not allowed in <a> // in the HTML 4.01 Strict DTD): - QDomNodeList exclusionsList = elem.elementsByTagName( "exclusions" ); + TQDomNodeList exclusionsList = elem.elementsByTagName( "exclusions" ); if( exclusionsList.length() > 0 ) { // sometimes there are no exclusions ( e.g. in XML DTDs there are never exclusions ) - QDomNode exclusionsNode = exclusionsList.item(0); - QDomElement exclusionsElem = exclusionsNode.toElement(); + TQDomNode exclusionsNode = exclusionsList.item(0); + TQDomElement exclusionsElem = exclusionsNode.toElement(); if( ! exclusionsElem.isNull() ) { - QDomNodeList subList = exclusionsElem.elementsByTagName( "element-name" ); + TQDomNodeList subList = exclusionsElem.elementsByTagName( "element-name" ); uint subListLength = subList.count(); for( uint l = 0; l < subListLength; l++ ) { - QDomNode subNode = subList.item(l); - QDomElement subElem = subNode.toElement(); + TQDomNode subNode = subList.item(l); + TQDomElement subElem = subNode.toElement(); if( !subElem.isNull() ) { - QMap<QString,bool>::Iterator it = subelementList.find( subElem.attribute( "name" ) ); + TQMap<TQString,bool>::Iterator it = subelementList.find( subElem.attribute( "name" ) ); if( it != subelementList.end() ) subelementList.remove(it); } @@ -178,8 +178,8 @@ bool PseudoDTD::parseElements( QDomDocument *doc, QProgressDialog *progress ) } // turn the map into a list: - QStringList subelementListTmp; - QMap<QString,bool>::Iterator it; + TQStringList subelementListTmp; + TQMap<TQString,bool>::Iterator it; for( it = subelementList.begin(); it != subelementList.end(); ++it ) subelementListTmp.append( it.key() ); @@ -196,12 +196,12 @@ bool PseudoDTD::parseElements( QDomDocument *doc, QProgressDialog *progress ) * a list of allowed elements, but it doesn't care about order or if only a certain * number of occurences is allowed. */ -QStringList PseudoDTD::allowedElements( QString parentElement ) +TQStringList PseudoDTD::allowedElements( TQString parentElement ) { if( m_sgmlSupport ) { // find the matching element, ignoring case: - QMap<QString,QStringList>::Iterator it; + TQMap<TQString,TQStringList>::Iterator it; for( it = m_elementsList.begin(); it != m_elementsList.end(); ++it ) { if( it.key().lower() == parentElement.lower() ) @@ -211,18 +211,18 @@ QStringList PseudoDTD::allowedElements( QString parentElement ) else if( m_elementsList.contains(parentElement) ) return m_elementsList[parentElement]; - return QStringList(); + return TQStringList(); } /** * Iterate through the XML to get a mapping which attributes are allowed inside * all elements. */ -bool PseudoDTD::parseAttributes( QDomDocument *doc, QProgressDialog *progress ) +bool PseudoDTD::parseAttributes( TQDomDocument *doc, TQProgressDialog *progress ) { m_attributesList.clear(); -// QStringList allowedAttributes; - QDomNodeList list = doc->elementsByTagName( "attlist" ); +// TQStringList allowedAttributes; + TQDomNodeList list = doc->elementsByTagName( "attlist" ); uint listLength = list.count(); for( uint i = 0; i < listLength; i++ ) @@ -235,16 +235,16 @@ bool PseudoDTD::parseAttributes( QDomDocument *doc, QProgressDialog *progress ) //qApp->processEvents(); ElementAttributes attrs; - QDomNode node = list.item(i); - QDomElement elem = node.toElement(); + TQDomNode node = list.item(i); + TQDomElement elem = node.toElement(); if( !elem.isNull() ) { - QDomNodeList attributeList = elem.elementsByTagName( "attribute" ); + TQDomNodeList attributeList = elem.elementsByTagName( "attribute" ); uint attributeListLength = attributeList.count(); for( uint l = 0; l < attributeListLength; l++ ) { - QDomNode attributeNode = attributeList.item(l); - QDomElement attributeElem = attributeNode.toElement(); + TQDomNode attributeNode = attributeList.item(l); + TQDomElement attributeElem = attributeNode.toElement(); if( ! attributeElem.isNull() ) { @@ -263,12 +263,12 @@ bool PseudoDTD::parseAttributes( QDomDocument *doc, QProgressDialog *progress ) /** Check which attributes are allowed for an element. */ -QStringList PseudoDTD::allowedAttributes( QString element ) +TQStringList PseudoDTD::allowedAttributes( TQString element ) { if( m_sgmlSupport ) { // find the matching element, ignoring case: - QMap<QString,ElementAttributes>::Iterator it; + TQMap<TQString,ElementAttributes>::Iterator it; for( it = m_attributesList.begin(); it != m_attributesList.end(); ++it ) { if( it.key().lower() == element.lower() ) { return it.data().optionalAttributes + it.data().requiredAttributes; @@ -278,14 +278,14 @@ QStringList PseudoDTD::allowedAttributes( QString element ) else if( m_attributesList.contains(element) ) return m_attributesList[element].optionalAttributes + m_attributesList[element].requiredAttributes; - return QStringList(); + return TQStringList(); } -QStringList PseudoDTD::requiredAttributes( const QString &element ) const +TQStringList PseudoDTD::requiredAttributes( const TQString &element ) const { if ( m_sgmlSupport ) { - QMap<QString,ElementAttributes>::ConstIterator it; + TQMap<TQString,ElementAttributes>::ConstIterator it; for( it = m_attributesList.begin(); it != m_attributesList.end(); ++it ) { if( it.key().lower() == element.lower() ) @@ -295,18 +295,18 @@ QStringList PseudoDTD::requiredAttributes( const QString &element ) const else if( m_attributesList.contains(element) ) return m_attributesList[element].requiredAttributes; - return QStringList(); + return TQStringList(); } /** * Iterate through the XML to get a mapping which attribute values are allowed * for all attributes inside all elements. */ -bool PseudoDTD::parseAttributeValues( QDomDocument *doc, QProgressDialog *progress ) +bool PseudoDTD::parseAttributeValues( TQDomDocument *doc, TQProgressDialog *progress ) { m_attributevaluesList.clear(); // 1 element : n possible attributes - QMap<QString,QStringList> attributevaluesTmp; // 1 attribute : n possible values - QDomNodeList list = doc->elementsByTagName( "attlist" ); + TQMap<TQString,TQStringList> attributevaluesTmp; // 1 attribute : n possible values + TQDomNodeList list = doc->elementsByTagName( "attlist" ); uint listLength = list.count(); for( uint i = 0; i < listLength; i++ ) @@ -319,21 +319,21 @@ bool PseudoDTD::parseAttributeValues( QDomDocument *doc, QProgressDialog *progre //qApp->processEvents(); attributevaluesTmp.clear(); - QDomNode node = list.item(i); - QDomElement elem = node.toElement(); + TQDomNode node = list.item(i); + TQDomElement elem = node.toElement(); if( !elem.isNull() ) { // Enter the list of <attribute>: - QDomNodeList attributeList = elem.elementsByTagName( "attribute" ); + TQDomNodeList attributeList = elem.elementsByTagName( "attribute" ); uint attributeListLength = attributeList.count(); for( uint l = 0; l < attributeListLength; l++ ) { - QDomNode attributeNode = attributeList.item(l); - QDomElement attributeElem = attributeNode.toElement(); + TQDomNode attributeNode = attributeList.item(l); + TQDomElement attributeElem = attributeNode.toElement(); if( ! attributeElem.isNull() ) { - QString value = attributeElem.attribute( "value" ); - attributevaluesTmp.insert( attributeElem.attribute("name"), QStringList::split(QRegExp(" "), value) ); + TQString value = attributeElem.attribute( "value" ); + attributevaluesTmp.insert( attributeElem.attribute("name"), TQStringList::split(TQRegExp(" "), value) ); } } m_attributevaluesList.insert( elem.attribute("name"), attributevaluesTmp ); @@ -347,19 +347,19 @@ bool PseudoDTD::parseAttributeValues( QDomDocument *doc, QProgressDialog *progre * (the element is necessary because e.g. "href" inside <a> could be different * to an "href" inside <link>): */ -QStringList PseudoDTD::attributeValues( QString element, QString attribute ) +TQStringList PseudoDTD::attributeValues( TQString element, TQString attribute ) { // Direct access would be faster than iteration of course but not always correct, // because we need to be case-insensitive. if( m_sgmlSupport ) { // first find the matching element, ignoring case: - QMap< QString,QMap<QString,QStringList> >::Iterator it; + TQMap< TQString,TQMap<TQString,TQStringList> >::Iterator it; for( it = m_attributevaluesList.begin(); it != m_attributevaluesList.end(); ++it ) { if( it.key().lower() == element.lower() ) { - QMap<QString,QStringList> attrVals = it.data(); - QMap<QString,QStringList>::Iterator itV; + TQMap<TQString,TQStringList> attrVals = it.data(); + TQMap<TQString,TQStringList>::Iterator itV; // then find the matching attribute for that element, ignoring case: for( itV = attrVals.begin(); itV != attrVals.end(); ++itV ) { @@ -371,23 +371,23 @@ QStringList PseudoDTD::attributeValues( QString element, QString attribute ) } else if( m_attributevaluesList.contains(element) ) { - QMap<QString,QStringList> attrVals = m_attributevaluesList[element]; + TQMap<TQString,TQStringList> attrVals = m_attributevaluesList[element]; if( attrVals.contains(attribute) ) return attrVals[attribute]; } // no predefined values available: - return QStringList(); + return TQStringList(); } /** * Iterate through the XML to get a mapping of all entity names and their expanded * version, e.g. nbsp =>  . Parameter entities are ignored. */ -bool PseudoDTD::parseEntities( QDomDocument *doc, QProgressDialog *progress ) +bool PseudoDTD::parseEntities( TQDomDocument *doc, TQProgressDialog *progress ) { m_entityList.clear(); - QDomNodeList list = doc->elementsByTagName( "entity" ); + TQDomNodeList list = doc->elementsByTagName( "entity" ); uint listLength = list.count(); for( uint i = 0; i < listLength; i++ ) @@ -398,36 +398,36 @@ bool PseudoDTD::parseEntities( QDomDocument *doc, QProgressDialog *progress ) progress->setProgress( progress->progress()+1 ); //FIXME!! //qApp->processEvents(); - QDomNode node = list.item(i); - QDomElement elem = node.toElement(); + TQDomNode node = list.item(i); + TQDomElement elem = node.toElement(); if( !elem.isNull() && elem.attribute( "type" ) != "param" ) { // TODO: what's cdata <-> gen ? - QDomNodeList expandedList = elem.elementsByTagName( "text-expanded" ); - QDomNode expandedNode = expandedList.item(0); - QDomElement expandedElem = expandedNode.toElement(); + TQDomNodeList expandedList = elem.elementsByTagName( "text-expanded" ); + TQDomNode expandedNode = expandedList.item(0); + TQDomElement expandedElem = expandedNode.toElement(); if( ! expandedElem.isNull() ) { - QString exp = expandedElem.text(); + TQString exp = expandedElem.text(); // TODO: support more than one &#...; in the expanded text /* TODO include do this when the unicode font problem is solved: - if( exp.contains(QRegExp("^&#x[a-zA-Z0-9]+;$")) ) { + if( exp.contains(TQRegExp("^&#x[a-zA-Z0-9]+;$")) ) { // hexadecimal numbers, e.g. "ȶ" uint end = exp.find( ";" ); exp = exp.mid( 3, end-3 ); - exp = QChar(); - } else if( exp.contains(QRegExp("^&#[0-9]+;$")) ) { + exp = TQChar(); + } else if( exp.contains(TQRegExp("^&#[0-9]+;$")) ) { // decimal numbers, e.g. "ì" uint end = exp.find( ";" ); exp = exp.mid( 2, end-2 ); - exp = QChar( exp.toInt() ); + exp = TQChar( exp.toInt() ); } */ m_entityList.insert( elem.attribute("name"), exp ); } else { - m_entityList.insert( elem.attribute("name"), QString() ); + m_entityList.insert( elem.attribute("name"), TQString() ); } } } @@ -437,21 +437,21 @@ bool PseudoDTD::parseEntities( QDomDocument *doc, QProgressDialog *progress ) /** * Get a list of all ( non-parameter ) entities that start with a certain string. */ -QStringList PseudoDTD::entities( QString start ) +TQStringList PseudoDTD::entities( TQString start ) { - QStringList entities; - QMap<QString,QString>::Iterator it; + TQStringList entities; + TQMap<TQString,TQString>::Iterator it; for( it = m_entityList.begin(); it != m_entityList.end(); ++it ) { if( (*it).startsWith(start) ) { - QString str = it.key(); + TQString str = it.key(); /* TODO: show entities as unicode character if( !it.data().isEmpty() ) { //str += " -- " + it.data(); - QRegExp re( "&#(\\d+);" ); + TQRegExp re( "&#(\\d+);" ); if( re.search(it.data()) != -1 ) { uint ch = re.cap( 1).toUInt(); - str += " -- " + QChar( ch).decomposition(); + str += " -- " + TQChar( ch).decomposition(); } //kdDebug() << "#" << it.data() << endl; } |