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