exports.cpp
author insilmaril
Tue, 23 Jan 2007 11:50:56 +0000
changeset 423 7019762f8701
parent 404 53efc2562a7d
child 424 d886c77ac0fe
permissions -rw-r--r--
1.8.65 Various fixes
insilmaril@0
     1
#include "exports.h"
insilmaril@171
     2
#include "file.h"
insilmaril@171
     3
#include "linkablemapobj.h"
insilmaril@171
     4
#include "misc.h"
insilmaril@171
     5
#include "mainwindow.h"
insilmaril@311
     6
#include "warningdialog.h"
insilmaril@228
     7
#include "xsltproc.h"
insilmaril@0
     8
insilmaril@171
     9
extern Main *mainWindow;
insilmaril@228
    10
extern QDir vymBaseDir;
insilmaril@404
    11
extern QString vymName;
insilmaril@131
    12
insilmaril@171
    13
ExportBase::ExportBase()
insilmaril@0
    14
{
insilmaril@0
    15
	indentPerDepth="  ";
insilmaril@377
    16
	bool ok;
insilmaril@393
    17
    tmpDir.setPath (makeUniqueDir(ok,"/tmp/vym-export-XXXXXX"));
insilmaril@377
    18
	if (!tmpDir.exists() || !ok)
insilmaril@377
    19
		QMessageBox::critical( 0, QObject::tr( "Error" ),
insilmaril@377
    20
					   QObject::tr("Couldn't access temporary directory\n"));
insilmaril@228
    21
}
insilmaril@228
    22
insilmaril@228
    23
ExportBase::~ExportBase()
insilmaril@228
    24
{
insilmaril@377
    25
	// Cleanup tmpdir
insilmaril@228
    26
	removeDir (tmpDir);
insilmaril@0
    27
}
insilmaril@0
    28
insilmaril@199
    29
void ExportBase::setDir(const QString &p)
insilmaril@0
    30
{
insilmaril@199
    31
	outputDir=p;
insilmaril@199
    32
}
insilmaril@199
    33
insilmaril@199
    34
void ExportBase::setFile (const QString &p)
insilmaril@199
    35
{
insilmaril@199
    36
	outputFile=p;
insilmaril@0
    37
}
insilmaril@0
    38
insilmaril@171
    39
void ExportBase::setMapCenter(MapCenterObj *mc)
insilmaril@0
    40
{
insilmaril@0
    41
	mapCenter=mc;
insilmaril@0
    42
}
insilmaril@0
    43
insilmaril@228
    44
void ExportBase::setCaption (const QString &s)
insilmaril@228
    45
{
insilmaril@228
    46
	caption=s;
insilmaril@228
    47
}
insilmaril@228
    48
insilmaril@228
    49
void ExportBase::addFilter(const QString &s)
insilmaril@228
    50
{
insilmaril@228
    51
	filter=s;
insilmaril@228
    52
}
insilmaril@228
    53
insilmaril@228
    54
bool ExportBase::execDialog()
insilmaril@228
    55
{
insilmaril@228
    56
	if (mapCenter && mapCenter->getMapEditor())
insilmaril@228
    57
	{
insilmaril@228
    58
		QFileDialog *fd=new QFileDialog( mapCenter->getMapEditor(), caption);
insilmaril@366
    59
		fd->setFilter (filter);
insilmaril@228
    60
		fd->setCaption(caption);
insilmaril@228
    61
		fd->setMode( QFileDialog::AnyFile );
insilmaril@228
    62
		fd->show();
insilmaril@228
    63
insilmaril@228
    64
		if ( fd->exec() == QDialog::Accepted )
insilmaril@228
    65
		{
insilmaril@228
    66
			if (QFile (fd->selectedFile()).exists() )
insilmaril@228
    67
			{
insilmaril@404
    68
				QMessageBox mb( vymName,
insilmaril@228
    69
					QObject::tr("The file %1 exists already.\nDo you want to overwrite it?").arg(fd->selectedFile()), 
insilmaril@228
    70
				QMessageBox::Warning,
insilmaril@228
    71
				QMessageBox::Yes | QMessageBox::Default,
insilmaril@228
    72
				QMessageBox::Cancel | QMessageBox::Escape,
insilmaril@366
    73
				Qt::NoButton );
insilmaril@228
    74
				mb.setButtonText( QMessageBox::Yes, QObject::tr("Overwrite") );
insilmaril@228
    75
				mb.setButtonText( QMessageBox::No, QObject::tr("Cancel"));
insilmaril@228
    76
				ExportBase ex;
insilmaril@228
    77
				switch( mb.exec() ) 
insilmaril@228
    78
				{
insilmaril@228
    79
					case QMessageBox::Yes:
insilmaril@228
    80
						// save 
insilmaril@228
    81
						break;;
insilmaril@228
    82
					case QMessageBox::Cancel:
insilmaril@228
    83
						// return, do nothing
insilmaril@228
    84
						return false;
insilmaril@228
    85
						break;
insilmaril@228
    86
				}
insilmaril@228
    87
			}
insilmaril@228
    88
			outputFile=fd->selectedFile();
insilmaril@228
    89
			return true;
insilmaril@228
    90
		}
insilmaril@228
    91
	}
insilmaril@228
    92
	return false;
insilmaril@228
    93
}
insilmaril@228
    94
insilmaril@171
    95
QString ExportBase::getSectionString(BranchObj *bostart)
insilmaril@163
    96
{
insilmaril@205
    97
	// Make prefix like "2.5.3" for "bo:2,bo:5,bo:3"
insilmaril@163
    98
	QString r;
insilmaril@163
    99
	BranchObj *bo=bostart;
insilmaril@163
   100
	int depth=bo->getDepth();
insilmaril@163
   101
	while (depth>0)
insilmaril@163
   102
	{
insilmaril@163
   103
		r=QString("%1").arg(1+bo->getNum(),0,10)+"." + r;
insilmaril@163
   104
		bo=(BranchObj*)(bo->getParObj());
insilmaril@163
   105
		depth=bo->getDepth();
insilmaril@163
   106
	}	
insilmaril@163
   107
	if (r.isEmpty())
insilmaril@163
   108
		return r;
insilmaril@163
   109
	else	
insilmaril@163
   110
		return r + " ";
insilmaril@163
   111
}
insilmaril@163
   112
insilmaril@239
   113
insilmaril@239
   114
////////////////////////////////////////////////////////////////////////
insilmaril@228
   115
void ExportASCII::doExport()
insilmaril@0
   116
{
insilmaril@199
   117
	QFile file (outputFile);
insilmaril@366
   118
	if ( !file.open( QIODevice::WriteOnly ) )
insilmaril@0
   119
	{
insilmaril@228
   120
		qWarning ("ExportBase::exportXML  couldn't open "+outputFile);
insilmaril@0
   121
		return;
insilmaril@0
   122
	}
insilmaril@0
   123
	QTextStream ts( &file );	// use LANG decoding here...
insilmaril@0
   124
insilmaril@0
   125
	// Main loop over all branches
insilmaril@0
   126
	QString s;
insilmaril@0
   127
	QString actIndent("");
insilmaril@366
   128
	int i,j;
insilmaril@0
   129
	BranchObj *bo;
insilmaril@0
   130
	bo=mapCenter->first();
insilmaril@0
   131
	while (bo) 
insilmaril@0
   132
	{
insilmaril@254
   133
		// Make indentstring
insilmaril@254
   134
		for (i=0;i<bo->getDepth();i++) actIndent+= indentPerDepth;
insilmaril@254
   135
insilmaril@254
   136
		if (bo->getDepth()==0)
insilmaril@239
   137
		{
insilmaril@254
   138
			ts << (bo->getHeading()+ "\n");
insilmaril@254
   139
			for (j=0;j<bo->getHeading().length();j++) ts<<"=";
insilmaril@254
   140
			ts << "\n";
insilmaril@254
   141
		} else 	if (bo->getDepth()==1)
insilmaril@254
   142
			ts << ("\n"+getSectionString(bo) + bo->getHeading()+ "\n");
insilmaril@254
   143
		else	if (bo->getDepth()==2)
insilmaril@254
   144
			ts << (actIndent + " o " + bo->getHeading()+ "\n");
insilmaril@254
   145
		else	
insilmaril@254
   146
			ts << (actIndent + " - " + bo->getHeading()+ "\n");
insilmaril@254
   147
		
insilmaril@254
   148
		// If necessary, write note
insilmaril@254
   149
		if (!bo->getNote().isEmpty())
insilmaril@254
   150
		{
insilmaril@254
   151
			s =bo->getNoteASCII();
insilmaril@254
   152
			s=s.replace ("\n","\n"+actIndent);
insilmaril@254
   153
			ts << (s+"\n\n");
insilmaril@0
   154
		}
insilmaril@0
   155
		bo=bo->next();
insilmaril@0
   156
		actIndent="";
insilmaril@0
   157
	}
insilmaril@0
   158
	file.close();
insilmaril@0
   159
}
insilmaril@0
   160
insilmaril@239
   161
////////////////////////////////////////////////////////////////////////
insilmaril@239
   162
void ExportKDEBookmarks::doExport() 
insilmaril@239
   163
{
insilmaril@239
   164
	MapEditor *me=NULL;
insilmaril@239
   165
	if (mapCenter) me=mapCenter->getMapEditor();
insilmaril@239
   166
	if (me)
insilmaril@239
   167
	{
insilmaril@311
   168
		WarningDialog dia;
insilmaril@384
   169
		dia.showCancelButton (true);
insilmaril@311
   170
		dia.setText(QObject::tr("Exporting the %1 bookmarks will overwrite\nyour existing bookmarks file.").arg("KDE"));
insilmaril@311
   171
		dia.setCaption(QObject::tr("Warning: Overwriting %1 bookmarks").arg("KDE"));
insilmaril@311
   172
		dia.setShowAgainName("/vym/warnings/overwriteKDEBookmarks");
insilmaril@311
   173
		if (dia.exec()==QDialog::Accepted)
insilmaril@311
   174
		{
insilmaril@311
   175
			me->exportXML(tmpDir.path());
insilmaril@239
   176
insilmaril@311
   177
			XSLTProc p;
insilmaril@311
   178
			p.setInputFile (tmpDir.path()+"/"+me->getMapName()+".xml");
insilmaril@311
   179
			p.setOutputFile (tmpDir.home().path()+"/.kde/share/apps/konqueror/bookmarks.xml");
insilmaril@311
   180
			p.setXSLFile (vymBaseDir.path()+"/styles/vym2kdebookmarks.xsl");
insilmaril@311
   181
			p.process();
insilmaril@311
   182
insilmaril@311
   183
			QString ub=vymBaseDir.path()+"/scripts/update-bookmarks";
insilmaril@377
   184
			QProcess *proc= new QProcess ;
insilmaril@366
   185
			proc->start( ub);
insilmaril@377
   186
			if (!proc->waitForStarted())
insilmaril@311
   187
			{
insilmaril@311
   188
				QMessageBox::warning(0, 
insilmaril@311
   189
					QObject::tr("Warning"),
insilmaril@311
   190
					QObject::tr("Couldn't find script %1\nto notifiy Browsers of changed bookmarks.").arg(ub));
insilmaril@311
   191
			}	
insilmaril@311
   192
		}
insilmaril@239
   193
	}
insilmaril@239
   194
insilmaril@239
   195
}
insilmaril@239
   196
insilmaril@239
   197
////////////////////////////////////////////////////////////////////////
insilmaril@311
   198
void ExportFirefoxBookmarks::doExport() 
insilmaril@311
   199
{
insilmaril@311
   200
	MapEditor *me=NULL;
insilmaril@311
   201
	if (mapCenter) me=mapCenter->getMapEditor();
insilmaril@311
   202
	if (me)
insilmaril@311
   203
	{
insilmaril@311
   204
		WarningDialog dia;
insilmaril@384
   205
		dia.showCancelButton (true);
insilmaril@311
   206
		dia.setText(QObject::tr("Exporting the %1 bookmarks will overwrite\nyour existing bookmarks file.").arg("Firefox"));
insilmaril@311
   207
		dia.setCaption(QObject::tr("Warning: Overwriting %1 bookmarks").arg("Firefox"));
insilmaril@311
   208
		dia.setShowAgainName("/vym/warnings/overwriteImportBookmarks");
insilmaril@311
   209
		if (dia.exec()==QDialog::Accepted)
insilmaril@311
   210
		{
insilmaril@311
   211
			me->exportXML(tmpDir.path());
insilmaril@311
   212
insilmaril@311
   213
/*
insilmaril@311
   214
			XSLTProc p;
insilmaril@311
   215
			p.setInputFile (tmpDir.path()+"/"+me->getMapName()+".xml");
insilmaril@311
   216
			p.setOutputFile (tmpDir.home().path()+"/.kde/share/apps/konqueror/bookmarks.xml");
insilmaril@311
   217
			p.setXSLFile (vymBaseDir.path()+"/styles/vym2kdebookmarks.xsl");
insilmaril@311
   218
			p.process();
insilmaril@311
   219
insilmaril@311
   220
			QString ub=vymBaseDir.path()+"/scripts/update-bookmarks";
insilmaril@311
   221
			QProcess *proc = new QProcess( );
insilmaril@311
   222
			proc->addArgument(ub);
insilmaril@311
   223
insilmaril@311
   224
			if ( !proc->start() ) 
insilmaril@311
   225
			{
insilmaril@311
   226
				QMessageBox::warning(0, 
insilmaril@311
   227
					QObject::tr("Warning"),
insilmaril@311
   228
					QObject::tr("Couldn't find script %1\nto notifiy Browsers of changed bookmarks.").arg(ub));
insilmaril@311
   229
			}	
insilmaril@311
   230
insilmaril@311
   231
*/
insilmaril@311
   232
insilmaril@311
   233
		}
insilmaril@311
   234
	}
insilmaril@311
   235
}
insilmaril@311
   236
insilmaril@311
   237
////////////////////////////////////////////////////////////////////////
insilmaril@228
   238
void ExportTaskjuggler::doExport() 
insilmaril@228
   239
{
insilmaril@228
   240
	MapEditor *me=NULL;
insilmaril@228
   241
	if (mapCenter) me=mapCenter->getMapEditor();
insilmaril@228
   242
	if (me)
insilmaril@228
   243
	{
insilmaril@228
   244
		me->exportXML(tmpDir.path());
insilmaril@228
   245
insilmaril@228
   246
		XSLTProc p;
insilmaril@228
   247
		p.setInputFile (tmpDir.path()+"/"+me->getMapName()+".xml");
insilmaril@228
   248
		p.setOutputFile (outputFile);
insilmaril@228
   249
		p.setXSLFile (vymBaseDir.path()+"/styles/vym2taskjuggler.xsl");
insilmaril@228
   250
		p.process();
insilmaril@228
   251
	}
insilmaril@228
   252
insilmaril@228
   253
}
insilmaril@228
   254
insilmaril@239
   255
////////////////////////////////////////////////////////////////////////
insilmaril@228
   256
void ExportLaTeX::doExport() 
insilmaril@0
   257
{
insilmaril@183
   258
	// Exports a map to a LaTex file.  
insilmaril@183
   259
	// This file needs to be included 
insilmaril@183
   260
	// or inported into a LaTex document
insilmaril@183
   261
	// it will not add a preamble, or anything 
insilmaril@183
   262
	// that makes a full LaTex document.
insilmaril@199
   263
  QFile file (outputFile);
insilmaril@366
   264
  if ( !file.open( QIODevice::WriteOnly ) ) {
insilmaril@205
   265
	QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("Could not write %1").arg(outputFile));
insilmaril@205
   266
	mainWindow->statusMessage(QString(QObject::tr("Export failed.")));
insilmaril@163
   267
    return;
insilmaril@163
   268
  }
insilmaril@163
   269
  QTextStream ts( &file );	// use LANG decoding here...
insilmaril@163
   270
  ts.setEncoding (QTextStream::UnicodeUTF8); // Force UTF8
insilmaril@163
   271
  
insilmaril@163
   272
  // Main loop over all branches
insilmaril@163
   273
  QString s;
insilmaril@163
   274
  // QString actIndent("");
insilmaril@163
   275
  // int i;
insilmaril@163
   276
  BranchObj *bo;
insilmaril@163
   277
  bo=mapCenter->first();
insilmaril@163
   278
  while (bo) {
insilmaril@254
   279
	if (bo->getDepth()==0);
insilmaril@254
   280
	else if (bo->getDepth()==1) {
insilmaril@254
   281
	  ts << ("\\chapter{" + bo->getHeading()+ "}\n");
insilmaril@254
   282
	}
insilmaril@254
   283
	else if (bo->getDepth()==2) {
insilmaril@254
   284
	  ts << ("\\section{" + bo->getHeading()+ "}\n");
insilmaril@254
   285
	}
insilmaril@254
   286
	else if (bo->getDepth()==3) {
insilmaril@254
   287
	  ts << ("\\subsection{" + bo->getHeading()+ "}\n");
insilmaril@254
   288
	}
insilmaril@254
   289
	else if (bo->getDepth()==4) {
insilmaril@254
   290
	  ts << ("\\subsubsection{" + bo->getHeading()+ "}\n");
insilmaril@254
   291
	}
insilmaril@254
   292
	else {
insilmaril@254
   293
	  ts << ("\\paragraph*{" + bo->getHeading()+ "}\n");
insilmaril@254
   294
	}
insilmaril@254
   295
	
insilmaril@254
   296
	// If necessary, write note
insilmaril@254
   297
	if (!bo->getNote().isEmpty()) {
insilmaril@254
   298
	  ts << (bo->getNoteASCII());
insilmaril@254
   299
	  ts << ("\n");
insilmaril@254
   300
	}
insilmaril@163
   301
    bo=bo->next();
insilmaril@163
   302
   }
insilmaril@163
   303
  file.close();
insilmaril@0
   304
}
insilmaril@0
   305
insilmaril@239
   306
////////////////////////////////////////////////////////////////////////
insilmaril@171
   307
ExportOO::ExportOO()
insilmaril@171
   308
{
insilmaril@199
   309
	useSections=false;
insilmaril@171
   310
}
insilmaril@163
   311
insilmaril@171
   312
ExportOO::~ExportOO()
insilmaril@171
   313
{
insilmaril@171
   314
}	
insilmaril@163
   315
insilmaril@171
   316
QString ExportOO::buildList (BranchObj *current)
insilmaril@171
   317
{
insilmaril@171
   318
    QString r;
insilmaril@171
   319
    BranchObj *bo;
insilmaril@183
   320
insilmaril@183
   321
    uint i=0;
insilmaril@171
   322
    bo=current->getFirstBranch();
insilmaril@171
   323
    if (bo)
insilmaril@171
   324
    {
insilmaril@171
   325
        // Start list
insilmaril@234
   326
        r+="<text:list text:style-name=\"vym-list\">\n";
insilmaril@171
   327
        while (bo)
insilmaril@171
   328
        {
insilmaril@254
   329
			r+="<text:list-item><text:p >";
insilmaril@254
   330
			r+=quotemeta(bo->getHeading());
insilmaril@254
   331
			// If necessary, write note
insilmaril@254
   332
			if (!bo->getNote().isEmpty())
insilmaril@254
   333
				r+=bo->getNoteOpenDoc();
insilmaril@254
   334
			r+="</text:p>";
insilmaril@254
   335
			r+=buildList (bo);	// recursivly add deeper branches
insilmaril@254
   336
			r+="</text:list-item>\n";
insilmaril@183
   337
			i++;
insilmaril@183
   338
			bo=current->getBranchNum(i);
insilmaril@171
   339
        }
insilmaril@171
   340
        r+="</text:list>\n";
insilmaril@171
   341
    }
insilmaril@171
   342
    return r;
insilmaril@171
   343
}
insilmaril@163
   344
insilmaril@171
   345
insilmaril@171
   346
void ExportOO::exportPresentation()
insilmaril@171
   347
{
insilmaril@183
   348
	QString allPages;
insilmaril@171
   349
insilmaril@163
   350
	// Insert new content
insilmaril@171
   351
	content.replace ("<!-- INSERT TITLE -->",quotemeta(mapCenter->getHeading()));
insilmaril@171
   352
	content.replace ("<!-- INSERT AUTHOR -->",quotemeta(mapCenter->getAuthor()));
insilmaril@183
   353
insilmaril@183
   354
	QString	onePage;
insilmaril@183
   355
	QString list;
insilmaril@183
   356
	
insilmaril@194
   357
	BranchObj *sectionBO=mapCenter->getFirstBranch();
insilmaril@183
   358
    int i=0;
insilmaril@183
   359
	BranchObj *pagesBO;
insilmaril@183
   360
    int j=0;
insilmaril@183
   361
insilmaril@194
   362
	// Walk sections
insilmaril@194
   363
	while (sectionBO)
insilmaril@183
   364
	{
insilmaril@194
   365
		if (useSections)
insilmaril@183
   366
		{
insilmaril@194
   367
			// Add page with section title
insilmaril@194
   368
			onePage=sectionTemplate;
insilmaril@194
   369
			onePage.replace ("<!-- INSERT PAGE HEADING -->", quotemeta(sectionBO->getHeading() ) );
insilmaril@183
   370
			allPages+=onePage;
insilmaril@183
   371
		} else
insilmaril@183
   372
		{
insilmaril@183
   373
			i=-2;	// only use inner loop to 
insilmaril@183
   374
			        // turn mainbranches into pages
insilmaril@194
   375
			sectionBO=mapCenter;
insilmaril@183
   376
		}
insilmaril@183
   377
insilmaril@183
   378
		// Walk mainpages
insilmaril@194
   379
		pagesBO=sectionBO->getFirstBranch();
insilmaril@183
   380
		j=0;
insilmaril@183
   381
		while (pagesBO)
insilmaril@183
   382
		{
insilmaril@183
   383
			// Add page with list of items
insilmaril@254
   384
			onePage=pageTemplate;
insilmaril@254
   385
			onePage.replace ("<!-- INSERT PAGE HEADING -->", quotemeta (pagesBO->getHeading() ) );
insilmaril@254
   386
			list=buildList (pagesBO);
insilmaril@254
   387
			onePage.replace ("<!-- INSERT LIST -->", list);
insilmaril@254
   388
			allPages+=onePage;
insilmaril@183
   389
			j++;
insilmaril@194
   390
			pagesBO=sectionBO->getBranchNum(j);
insilmaril@183
   391
		}
insilmaril@183
   392
		i++;
insilmaril@194
   393
		sectionBO=mapCenter->getBranchNum(i);
insilmaril@183
   394
	}
insilmaril@183
   395
	
insilmaril@171
   396
	content.replace ("<!-- INSERT PAGES -->",allPages);
insilmaril@171
   397
insilmaril@171
   398
	// Write modified content
insilmaril@171
   399
	QFile f (contentFile);
insilmaril@366
   400
    if ( !f.open( QIODevice::WriteOnly ) ) 
insilmaril@171
   401
	{
insilmaril@205
   402
		QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("Could not write %1").arg(contentFile));
insilmaril@205
   403
		mainWindow->statusMessage(QString(QObject::tr("Export failed.")));
insilmaril@171
   404
		return;
insilmaril@171
   405
    }
insilmaril@171
   406
insilmaril@171
   407
    QTextStream t( &f );
insilmaril@171
   408
    t << content;
insilmaril@171
   409
    f.close();
insilmaril@171
   410
insilmaril@163
   411
	// zip tmpdir to destination
insilmaril@171
   412
	zipDir (tmpDir,outputFile);	
insilmaril@163
   413
}
insilmaril@163
   414
insilmaril@194
   415
bool ExportOO::setConfigFile (const QString &cf)
insilmaril@183
   416
{
insilmaril@183
   417
	configFile=cf;
insilmaril@183
   418
	int i=cf.findRev ("/");
insilmaril@183
   419
	if (i>=0) configDir=cf.left(i);
insilmaril@183
   420
	SimpleSettings set;
insilmaril@183
   421
	set.readSettings(configFile);
insilmaril@183
   422
insilmaril@183
   423
	// set paths
insilmaril@183
   424
	templateDir=configDir+"/"+set.readEntry ("Template");
insilmaril@183
   425
insilmaril@194
   426
	QDir d (templateDir);
insilmaril@194
   427
	if (!d.exists())
insilmaril@194
   428
	{
insilmaril@194
   429
		QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("Check \"%1\" in\n%2").arg("Template="+set.readEntry ("Template")).arg(configFile));
insilmaril@194
   430
		return false;
insilmaril@194
   431
insilmaril@194
   432
	}
insilmaril@183
   433
insilmaril@183
   434
	contentTemplateFile=templateDir+"content-template.xml";
insilmaril@183
   435
	contentFile=tmpDir.path()+"/content.xml";
insilmaril@183
   436
	pageTemplateFile=templateDir+"page-template.xml";
insilmaril@194
   437
	sectionTemplateFile=templateDir+"section-template.xml";
insilmaril@183
   438
insilmaril@199
   439
	if (set.readEntry("useSections").contains("yes"))
insilmaril@199
   440
		useSections=true;
insilmaril@199
   441
insilmaril@183
   442
	// Copy template to tmpdir
insilmaril@183
   443
	system ("cp -r "+templateDir+"* "+tmpDir.path());
insilmaril@183
   444
insilmaril@183
   445
	// Read content-template
insilmaril@183
   446
	if (!loadStringFromDisk (contentTemplateFile,content))
insilmaril@183
   447
	{
insilmaril@194
   448
		QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("Could not read %1").arg(contentTemplateFile));
insilmaril@194
   449
		return false;
insilmaril@183
   450
	}
insilmaril@183
   451
insilmaril@183
   452
	// Read page-template
insilmaril@183
   453
	if (!loadStringFromDisk (pageTemplateFile,pageTemplate))
insilmaril@183
   454
	{
insilmaril@194
   455
		QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("Could not read %1").arg(pageTemplateFile));
insilmaril@194
   456
		return false;
insilmaril@183
   457
	}
insilmaril@183
   458
	
insilmaril@194
   459
	// Read section-template
insilmaril@201
   460
	if (useSections && !loadStringFromDisk (sectionTemplateFile,sectionTemplate))
insilmaril@183
   461
	{
insilmaril@194
   462
		QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("Could not read %1").arg(sectionTemplateFile));
insilmaril@194
   463
		return false;
insilmaril@183
   464
	}
insilmaril@194
   465
	return true;
insilmaril@183
   466
}
insilmaril@183
   467