39#include "TagProcessing.h"
41#define DEBUG_KWORD_TAGS
45void ProcessSubtags (
const TQDomNode &parentNode,
46 TQValueList<TagProcessing> &tagProcessingList,
47 KWEFKWordLeader *leader)
53 for ( childNode = parentNode.firstChild (); !childNode.isNull (); childNode = childNode.nextSibling () )
55 if ( childNode.isElement () )
59 TQValueList<TagProcessing>::Iterator tagProcessingIt;
61 for ( tagProcessingIt = tagProcessingList.begin ();
62 tagProcessingIt != tagProcessingList.end ();
65 if ( childNode.nodeName () == (*tagProcessingIt).name )
69 if ( (*tagProcessingIt).processor != NULL )
71 ((*tagProcessingIt).processor) ( childNode, (*tagProcessingIt).data, leader );
73#ifdef DEBUG_KWORD_IGNORED_TAGS
76 kdDebug(30508) <<
"Ignoring " << childNode.nodeName ()
77 <<
" tag in " << parentNode.nodeName () << endl;
86 kdDebug(30508) <<
"Unexpected tag " << childNode.nodeName ()
87 <<
" in " << parentNode.nodeName () <<
"!" << endl;
94void AllowNoSubtags (
const TQDomNode& myNode, KWEFKWordLeader *leader )
96#ifdef DEBUG_KWORD_TAGS
98 TQValueList<TagProcessing> tagProcessingList;
99 ProcessSubtags (myNode, tagProcessingList, leader);
110 else if ( t ==
"TQString" )
112 else if ( t ==
"double" )
114 else if ( t ==
"bool" )
116 else if ( t.isEmpty() )
120 kdWarning(30508) <<
"Unknown type: " << t <<
" for element " << n <<
" assuming NULL" << endl;
126void ProcessAttributes (
const TQDomNode &myNode,
127 TQValueList<AttrProcessing> &attrProcessingList )
131 TQDomNamedNodeMap myAttribs ( myNode.attributes () );
133 for ( uint i = 0; i < myAttribs.length (); i++ )
135 TQDomAttr myAttrib ( myAttribs.item (i).toAttr () );
137 if ( !myAttrib.isNull () )
141 TQValueList<AttrProcessing>::Iterator attrProcessingIt;
143 for ( attrProcessingIt = attrProcessingList.begin ();
144 attrProcessingIt != attrProcessingList.end ();
148 if ( myAttrib.name () == (*attrProcessingIt).name )
152 if ( (*attrProcessingIt).data != NULL )
154 switch ( (*attrProcessingIt).type )
156 case AttrProcessing::AttrTQString:
158 *((TQString *) (*attrProcessingIt).data) = myAttrib.value ();
161 case AttrProcessing::AttrInt:
163 *((
int *) (*attrProcessingIt).data) = myAttrib.value ().toInt ();
166 case AttrProcessing::AttrDouble:
168 *((
double *) (*attrProcessingIt).data) = myAttrib.value ().toDouble ();
171 case AttrProcessing::AttrBool:
173 const TQString strAttr ( myAttrib.value().simplifyWhiteSpace() );
175 if ((strAttr==
"yes")||(strAttr==
"1")||(strAttr==
"true"))
179 else if ((strAttr==
"no")||(strAttr==
"0")||(strAttr==
"false"))
186 kdWarning(30508) <<
"Unknown value for a boolean: " << strAttr
187 <<
" in tag " << myNode.nodeName () <<
", attribute "
188 << myAttrib.name() << endl;
190 *((
bool *) (*attrProcessingIt).data) = flag;
193 case AttrProcessing::AttrNull:
197 kdDebug(30508) <<
"Unexpected data type " << int( (*attrProcessingIt).type )
198 <<
" in " << myNode.nodeName ()
199 <<
" attribute " << (*attrProcessingIt).name
205#ifdef DEBUG_KWORD_IGNORED_TAGS
208 kdDebug(30508) <<
"Ignoring " << myNode.nodeName()
209 <<
" attribute " << (*attrProcessingIt).name
219 kdWarning(30508) <<
"Unexpected attribute " << myAttrib.name ()
220 <<
" in " << myNode.nodeName () <<
"!" << endl;
227void AllowNoAttributes (
const TQDomNode & myNode )
229#ifdef DEBUG_KWORD_TAGS
230 TQValueList<AttrProcessing> attrProcessingList;
231 ProcessAttributes (myNode, attrProcessingList);
The class AttrProcessing and the two functions ProcessAttributes () and AllowNoSubtags () allow for e...