diff -r 544a64d7cbac -r de97201180ea exports.cpp --- a/exports.cpp Tue Jan 24 15:09:49 2006 +0000 +++ b/exports.cpp Wed Jan 25 09:04:00 2006 +0000 @@ -1,3 +1,5 @@ +#include + #include "exports.h" #include "file.h" #include "linkablemapobj.h" @@ -143,15 +145,8 @@ ExportOO::ExportOO() { - // Create tmpdir and set paths + // Create tmpdir tmpDir.setPath (makeUniqueDir("/tmp/vym-XXXXXX")); - templateDir="exports/novell/template/"; - contentTemplateFile=templateDir+"content-template.xml"; - contentFile=tmpDir.path()+"/content.xml"; - pageTemplateFile=templateDir+"page-template.xml"; - chapterTemplateFile=templateDir+"chapter-template.xml"; - - outputFile=tmpDir.currentDirPath()+"/test.odp"; } ExportOO::~ExportOO() @@ -194,7 +189,7 @@ { QString allPages; - bool useChapters=true; + bool useSections=true; // Insert new content content.replace ("",quotemeta(mapCenter->getHeading())); @@ -203,29 +198,29 @@ QString onePage; QString list; - BranchObj *chapterBO=mapCenter->getFirstBranch(); + BranchObj *sectionBO=mapCenter->getFirstBranch(); int i=0; BranchObj *pagesBO; int j=0; - // Walk chapters - while (chapterBO) + // Walk sections + while (sectionBO) { - if (useChapters) + if (useSections) { - // Add page with chapter title - onePage=chapterTemplate; - onePage.replace ("", quotemeta(chapterBO->getHeading() ) ); + // Add page with section title + onePage=sectionTemplate; + onePage.replace ("", quotemeta(sectionBO->getHeading() ) ); allPages+=onePage; } else { i=-2; // only use inner loop to // turn mainbranches into pages - chapterBO=mapCenter; + sectionBO=mapCenter; } // Walk mainpages - pagesBO=chapterBO->getFirstBranch(); + pagesBO=sectionBO->getFirstBranch(); j=0; while (pagesBO) { @@ -236,10 +231,10 @@ onePage.replace ("", list); allPages+=onePage; j++; - pagesBO=chapterBO->getBranchNum(j); + pagesBO=sectionBO->getBranchNum(j); } i++; - chapterBO=mapCenter->getBranchNum(i); + sectionBO=mapCenter->getBranchNum(i); } content.replace ("",allPages); @@ -260,7 +255,7 @@ zipDir (tmpDir,outputFile); } -void ExportOO::setConfigFile (const QString &cf) +bool ExportOO::setConfigFile (const QString &cf) { configFile=cf; int i=cf.findRev ("/"); @@ -271,39 +266,44 @@ // set paths templateDir=configDir+"/"+set.readEntry ("Template"); - //FIXME check if templateDir is really set, otherwise abort + QDir d (templateDir); + if (!d.exists()) + { + QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("Check \"%1\" in\n%2").arg("Template="+set.readEntry ("Template")).arg(configFile)); + return false; + + } contentTemplateFile=templateDir+"content-template.xml"; contentFile=tmpDir.path()+"/content.xml"; pageTemplateFile=templateDir+"page-template.xml"; - chapterTemplateFile=templateDir+"chapter-template.xml"; + sectionTemplateFile=templateDir+"section-template.xml"; - outputFile=tmpDir.currentDirPath()+"/test.odp"; + outputFile=tmpDir.currentDirPath()+"/vym-out.odp"; // Copy template to tmpdir system ("cp -r "+templateDir+"* "+tmpDir.path()); - // Read content-template if (!loadStringFromDisk (contentTemplateFile,content)) { - qWarning ("Export::exportOO() Couldn't load from "+contentTemplateFile); - return; + QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("Could not read %1").arg(contentTemplateFile)); + return false; } // Read page-template if (!loadStringFromDisk (pageTemplateFile,pageTemplate)) { - qWarning ("Export::exportOO() Couldn't load from "+pageTemplateFile); - return; + QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("Could not read %1").arg(pageTemplateFile)); + return false; } - // Read chapter-template - if (!loadStringFromDisk (chapterTemplateFile,chapterTemplate)) + // Read section-template + if (!loadStringFromDisk (sectionTemplateFile,sectionTemplate)) { - qWarning ("Export::exportOO() Couldn't load from "+chapterTemplateFile); - return; + QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("Could not read %1").arg(sectionTemplateFile)); + return false; } - + return true; }