21 sdebug(
"*** HyperDoc::HyperDoc ***");
25 resourceProviders =
new QList<HResourceProvider *>();
26 dtsp =
new QList<HTable *>();
27 dtsn =
new QList<QString>();
28 fts =
new QList<HFloatTables *>();
35 sdebug(
"*** HyperDoc::HyperDoc ***END");
40 sdebug(
"*** HyperDoc::~HyperDoc ***");
43 delete resourceProviders;
47 sdebug(
"*** HyperDoc::~HyperDoc ***END");
67 resourceProviders->clear();
78 if(redefinedName.isEmpty())
81 dtsn->push_back(redefinedName);
86 resourceProviders->push_back(rp);
99 QString HyperDoc::getData(QString data)
107 QList<QString>::iterator namei;
108 QList<HTable *>::iterator datai;
110 tname = data.section(
':',0,0);
111 fname = data.section(
':',1,1);
116 sdebug(QString(
"Data requested from table \"%1\" with name \"%2\"").arg(tname).arg(fname));
117 if(insideIter != NULL)
126 QString mainname,subname;
128 mainname = tname.section(
'.',0,0);
129 subname = tname.section(
'.',1,1);
131 if(subname.isEmpty())
134 sdebug(QString(
"Data requested from table \"%1\" (subnamed:\"%2\") with name \"%3\"")
135 .arg(mainname).arg(subname).arg(fname));
136 req_t = getDataTable(mainname);
147 HTable* HyperDoc::getDataTable(QString data)
149 QList<QString>::iterator namei;
150 QList<HTable *>::iterator datai;
152 namei = dtsn->begin();
153 datai = dtsp->begin();
154 while(namei != dtsn->end())
166 QString HyperDoc::getRes(QString res)
171 QList<HResourceProvider *>::iterator i;
173 i = resourceProviders->begin();
174 while(i != resourceProviders->end())
176 if((*i)->hasResource(res))
177 return (*i)->getResource(res);
188 QList<HFloatTables *>::iterator i;
191 while(i != fts->end())
193 if((*i)->sqlTableName() == res)
204 sdebug(
"*** HyperDoc::generateDoc ***");
207 parserdata.replace(
"[",
"<");
208 parserdata.replace(
"]",
">");
209 parserdata.replace(
"|",
"\"");
210 QXmlInputSource *source =
new QXmlInputSource();
211 source->setData(parserdata);
214 QXmlSimpleReader reader;
215 reader.setContentHandler(
this );
216 reader.setErrorHandler(
this );
223 if(!reader.parse( *source ))
225 emit
errorSignal(
"Error during the XML parsing! \n: " + errorString());
227 sdebug(
"*** HyperDoc::generateDoc ***ERROR");
233 sdebug(
"*** HyperDoc::generateDoc ***");
238 void HyperDoc::out(QString o)
241 preprocessed.append(o);
243 iterbuffer.append(o);
246 bool HyperDoc::startDocument(
void)
252 bool HyperDoc::endDocument(
void)
258 bool HyperDoc::startElement(
const QString& ns,
const QString& ln,
const QString& name,
const QXmlAttributes& atts)
265 if(!buffer.isEmpty())
271 if(ignore && name.toLower() ==
"cond")
274 sdebug(
"------------- Increment skip_cond_deep");
282 if(name.toLower() ==
"data" || name.toLower() ==
"res")
284 att_begin = atts.value(
"begin");
285 att_end = atts.value(
"end");
286 att_notfound= atts.value(
"notfound");
290 if(name.toLower() ==
"iterinside")
293 if(name.toLower() ==
"iter")
296 emit
errorSignal(
"ERROR:Cannot paste an ITER tag into an another ITER!");
298 iter_hft_name = atts.value(
"data");
299 iter_notfound = atts.value(
"notfound");
300 iterbuffer =
"<iterinside>";
306 if(name.toLower() ==
"cond")
310 if(!atts.value(
"res").isEmpty())
311 a = getRes(atts.value(
"res"));
312 if(!atts.value(
"data").isEmpty())
313 a = getData(atts.value(
"data"));
315 b = atts.value(
"to");
317 sdebug(QString(
"HyperDoc-COND \"%1\" with \"%2\" ;").arg(a).arg(b));
319 if(atts.value(
"is") ==
"eq")
323 sdebug(
" - (eq) result:true ");
328 sdebug(
" - (eq) result:false ");
332 else if(atts.value(
"is") ==
"ne")
336 sdebug(
" - (ne) result:true ");
341 sdebug(
" - (ne) result:false ");
353 for(i=0;i < atts.count();++i)
355 out(QString(
" %1=\"%2\"").arg(atts.qName(i)).arg(atts.value(i)));
362 bool HyperDoc::endElement(
const QString& ns,
const QString& ln,
const QString& name)
368 if(!ignore && !itermode)
369 if(name.toLower() ==
"data" || name.toLower() ==
"res")
373 if(name.toLower() ==
"data") data=getData(buffer);
374 if(name.toLower() ==
"res") data=getRes (buffer);
379 out(att_begin+data+att_end);
384 if(!buffer.isEmpty())
391 if(name.toLower() ==
"cond")
393 if(ignore && skip_cond_deep > 0)
396 sdebug(
"------------- Decrement skip_cond_deep");
399 sdebug(
"Reached end of cond: set ingnore to false");
404 if(name.toLower() ==
"iterinside")
407 if(name.toLower() ==
"iter")
413 iterbuffer.append(
"</iterinside>");
417 *(subdoc->resourceProviders) = *resourceProviders;
418 *(subdoc->dtsp) = *dtsp;
419 *(subdoc->dtsn) = *dtsn;
420 *(subdoc->fts) = *fts;
422 subdoc->
set(iterbuffer);
424 flott = getHFT(iter_hft_name);
425 if(flott == NULL || flott->
count() == 0)
429 for(i=0;i<flott->
count();++i)
431 subdoc->insideIter = flott->
getTByNum(i);
446 out(QString(
"</%1>").arg(name));
450 bool HyperDoc::characters(
const QString& ch)
457 bool HyperDoc::processingInstruction(
const QString &target,
const QString &data)
459 sdebug(
"OOOOOOOOOOOOOOOOOOOOOOOOOO"+target+
","+data);
463 bool HyperDoc::skippedEntity(
const QString &name)
465 sdebug(
"IIIIIIIIIIII Skipped entry:"+name);
469 void HyperDoc::clearBuffer()
477 bool HyperDoc::warning(
const QXmlParseException& exception)
479 errstr = QString(
"WARNING!\nLIN:%1 COL:%2\npubID:%3 sysID:%4\nMessage:%5\nSorry :-(")
480 .arg(exception.lineNumber())
481 .arg(exception.columnNumber())
482 .arg(exception.publicId())
483 .arg(exception.systemId())
484 .arg(exception.message());
488 bool HyperDoc::error(
const QXmlParseException& exception)
490 errstr = QString(
"WARNING!\nLIN:%1 COL:%2\npubID:%3 sysID:%4\nMessage:%5\nSorry :-(")
491 .arg(exception.lineNumber())
492 .arg(exception.columnNumber())
493 .arg(exception.publicId())
494 .arg(exception.systemId())
495 .arg(exception.message());
499 bool HyperDoc::fatalError(
const QXmlParseException& exception)
501 errstr = QString(
"WARNING!\nLIN:%1 COL:%2\npubID:%3 sysID:%4\nMessage:%5\nSorry :-(")
502 .arg(exception.lineNumber())
503 .arg(exception.columnNumber())
504 .arg(exception.publicId())
505 .arg(exception.systemId())
506 .arg(exception.message());
HDataField * fieldBySqlName(QString sqln, bool all=false, QString containerSqlTable="")
QString sqlTableName(void)
void addDataSource(HTable *ht, QString redefinedName="")
void addIterDataTables(HFloatTables *ft)
void addResourceProvider(HResourceProvider *rp)
HTable * getTByNum(int idx)
virtual QVariant dbValueToDispValue(QVariant v)
void errorSignal(QString err)
virtual QVariant getValue(void)