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