exports.cpp
changeset 824 36eb4b8f409e
parent 823 0bba81dde1bc
child 825 1ad892c1a709
     1.1 --- a/exports.cpp	Fri Feb 19 13:47:03 2010 +0000
     1.2 +++ b/exports.cpp	Thu Feb 25 11:03:52 2010 +0000
     1.3 @@ -8,6 +8,7 @@
     1.4  #include "warningdialog.h"
     1.5  #include "xsltproc.h"
     1.6  
     1.7 +
     1.8  extern Main *mainWindow;
     1.9  extern QDir vymBaseDir;
    1.10  extern QString vymName;
    1.11 @@ -344,14 +345,11 @@
    1.12  	QString s;
    1.13  	QString curIndent("");
    1.14  	int i;
    1.15 -	BranchObj *bo;  //FIXME-3 still needed?
    1.16  	BranchItem *cur=NULL;
    1.17  	BranchItem *prev=NULL;
    1.18  	cur=model->nextBranch (cur,prev);
    1.19  	while (cur) 
    1.20  	{
    1.21 -		bo=(BranchObj*)(cur->getLMO());
    1.22 -
    1.23  		if (!cur->hasHiddenExportParent() )
    1.24  		{
    1.25  			// If necessary, write note
    1.26 @@ -487,6 +485,8 @@
    1.27  	noSingulars=true;	
    1.28  	frameURLs=true;
    1.29  	useMapColors=true;
    1.30 +	cssFileName="vym.css";
    1.31 +	cssOriginalPath="";	// Is set in VymModel, based on default setting in ExportHTMLDialog
    1.32  
    1.33  	if (model &&model->getMapEditor()) 
    1.34  		offset=model->getMapEditor()->getTotalBBox().topLeft();
    1.35 @@ -590,8 +590,37 @@
    1.36      return r;
    1.37  }
    1.38  
    1.39 +void ExportHTML::setCSSPath(const QString &p)
    1.40 +{
    1.41 +	cssOriginalPath=p;
    1.42 +}
    1.43 +
    1.44  void ExportHTML::doExport() 
    1.45  {
    1.46 +	//FIXME-1  check for errors// Copy CSS file
    1.47 +	QFile css_src (cssOriginalPath);
    1.48 +	QFile css_dst (outDir.path()+"/"+cssFileName);
    1.49 +	if (!css_src.open ( QIODevice::ReadOnly))
    1.50 +		QMessageBox::warning( 0, QObject::tr( "Warning","ExportHTML" ),QObject::tr("Could not open %1","ExportHTML").arg(cssOriginalPath));
    1.51 +	else
    1.52 +	{
    1.53 +		if (!css_dst.open( QIODevice::WriteOnly))
    1.54 +			QMessageBox::warning( 0, QObject::tr( "Warning" ), QObject::tr("Could not open %1").arg(css_dst.fileName()));
    1.55 +		else
    1.56 +		{	
    1.57 +		
    1.58 +			QTextStream tsout( &css_dst);
    1.59 +			QTextStream tsin ( &css_src);
    1.60 +			QString s= tsin.read();
    1.61 +			tsout << s;
    1.62 +			css_dst.close();
    1.63 +		}	
    1.64 +		css_src.close();
    1.65 +	}
    1.66 +
    1.67 +
    1.68 +
    1.69 +	// Open file for writing
    1.70  	QFile file (outputFile);
    1.71  	if ( !file.open( QIODevice::WriteOnly ) ) 
    1.72  	{
    1.73 @@ -604,7 +633,7 @@
    1.74  
    1.75  	// Write header
    1.76  	ts<<"<html><title>"+model->getMapName()<<"</title><body>";
    1.77 -	ts<<" <link rel='stylesheet' id='css.stylesheet' href='vym.css' />\n";
    1.78 +	ts<<" <link rel='stylesheet' id='css.stylesheet' href='"<<cssFileName<<"' />\n";
    1.79  
    1.80  	// Include image
    1.81  	ts<<"<center><img src=\""<<model->getMapName()<<".png\" usemap='#imagemap'></center>\n";