author | insilmaril |
Wed, 15 Mar 2006 13:53:53 +0000 | |
changeset 249 | e7acede0377c |
parent 217 | 375be2baa976 |
child 265 | 96b8406d4a2f |
permissions | -rw-r--r-- |
insilmaril@205 | 1 |
#include "xsltproc.h" |
insilmaril@205 | 2 |
|
insilmaril@205 | 3 |
#include <iostream> |
insilmaril@205 | 4 |
#include <qmessagebox.h> |
insilmaril@205 | 5 |
|
insilmaril@205 | 6 |
#include "process.h" |
insilmaril@205 | 7 |
|
insilmaril@205 | 8 |
|
insilmaril@205 | 9 |
XSLTProc::XSLTProc () |
insilmaril@205 | 10 |
{ |
insilmaril@205 | 11 |
xsltprocessor="xsltproc"; |
insilmaril@205 | 12 |
showOutput=false; |
insilmaril@205 | 13 |
dia=new ShowTextDialog; |
insilmaril@205 | 14 |
} |
insilmaril@205 | 15 |
|
insilmaril@205 | 16 |
XSLTProc::~XSLTProc () |
insilmaril@205 | 17 |
{ |
insilmaril@205 | 18 |
delete (dia); |
insilmaril@205 | 19 |
} |
insilmaril@205 | 20 |
|
insilmaril@205 | 21 |
void XSLTProc::addStringParam (const QString & k, const QString &v) |
insilmaril@205 | 22 |
{ |
insilmaril@205 | 23 |
stringParamKey.append (k); |
insilmaril@205 | 24 |
stringParamVal.append (v); |
insilmaril@205 | 25 |
} |
insilmaril@205 | 26 |
|
insilmaril@205 | 27 |
void XSLTProc::setOutputFile (const QString &s) |
insilmaril@205 | 28 |
{ |
insilmaril@205 | 29 |
outputFile=s; |
insilmaril@205 | 30 |
} |
insilmaril@205 | 31 |
|
insilmaril@205 | 32 |
void XSLTProc::setXSLFile(const QString &s) |
insilmaril@205 | 33 |
{ |
insilmaril@205 | 34 |
xslFile=s; |
insilmaril@205 | 35 |
} |
insilmaril@205 | 36 |
|
insilmaril@205 | 37 |
void XSLTProc::setInputFile (const QString &s) |
insilmaril@205 | 38 |
{ |
insilmaril@205 | 39 |
inputFile=s; |
insilmaril@205 | 40 |
} |
insilmaril@205 | 41 |
|
insilmaril@205 | 42 |
void XSLTProc::addOutput (const QString &s) |
insilmaril@205 | 43 |
{ |
insilmaril@205 | 44 |
dia->append (s); |
insilmaril@205 | 45 |
} |
insilmaril@205 | 46 |
|
insilmaril@205 | 47 |
void XSLTProc::process() |
insilmaril@205 | 48 |
{ |
insilmaril@205 | 49 |
ShowTextDialog dia; |
insilmaril@205 | 50 |
Process *xsltProc=new Process (); |
insilmaril@205 | 51 |
xsltProc->clearArguments(); |
insilmaril@205 | 52 |
xsltProc->addArgument (xsltprocessor); |
insilmaril@205 | 53 |
|
insilmaril@205 | 54 |
QStringList::Iterator itk; |
insilmaril@205 | 55 |
QStringList::Iterator itv=stringParamVal.begin(); |
insilmaril@205 | 56 |
|
insilmaril@205 | 57 |
for ( itk = stringParamKey.begin(); itk != stringParamKey.end(); ++itk ) |
insilmaril@205 | 58 |
{ |
insilmaril@205 | 59 |
xsltProc->addArgument ("--stringparam"); |
insilmaril@205 | 60 |
xsltProc->addArgument (*itk); |
insilmaril@205 | 61 |
xsltProc->addArgument (*itv); |
insilmaril@205 | 62 |
++itv; |
insilmaril@205 | 63 |
} |
insilmaril@205 | 64 |
|
insilmaril@205 | 65 |
xsltProc->addArgument ("--output"); |
insilmaril@205 | 66 |
xsltProc->addArgument (outputFile); |
insilmaril@205 | 67 |
xsltProc->addArgument (xslFile); |
insilmaril@205 | 68 |
xsltProc->addArgument (inputFile); |
insilmaril@205 | 69 |
dia.append ("vym is executing: \n" + xsltProc->arguments().join(" ") ); |
insilmaril@217 | 70 |
//FIXME testing |
insilmaril@217 | 71 |
cout <<QString("vym is executing: \n" + xsltProc->arguments().join(" ")) <<endl; |
insilmaril@205 | 72 |
if (!xsltProc->start() ) |
insilmaril@205 | 73 |
{ |
insilmaril@205 | 74 |
QMessageBox::critical( 0, QObject::tr( "Critical Error" ), |
insilmaril@205 | 75 |
QObject::tr("Could not start %1").arg(xsltprocessor) ); |
insilmaril@205 | 76 |
} else |
insilmaril@205 | 77 |
{ |
insilmaril@205 | 78 |
xsltProc->waitFinished(); |
insilmaril@205 | 79 |
if (!xsltProc->normalExit() ) |
insilmaril@205 | 80 |
QMessageBox::critical( 0, QObject::tr( "Critical Error" ), |
insilmaril@205 | 81 |
QObject::tr("%1 didn't exit normally").arg(xsltprocessor) + |
insilmaril@205 | 82 |
xsltProc->getErrout() ); |
insilmaril@205 | 83 |
else |
insilmaril@205 | 84 |
if (xsltProc->exitStatus()>0) showOutput=true; |
insilmaril@205 | 85 |
|
insilmaril@205 | 86 |
} |
insilmaril@205 | 87 |
dia.append ("\n"); |
insilmaril@205 | 88 |
dia.append (xsltProc->getErrout()); |
insilmaril@205 | 89 |
dia.append (xsltProc->getStdout()); |
insilmaril@205 | 90 |
|
insilmaril@205 | 91 |
if (showOutput) dia.exec(); |
insilmaril@205 | 92 |
} |
insilmaril@205 | 93 |