diff -r 30b22f7bd009 -r 494e8f40f0f7 exports.cpp --- a/exports.cpp Mon Sep 12 19:52:51 2005 +0000 +++ b/exports.cpp Tue Jan 03 09:44:41 2006 +0000 @@ -1,27 +1,28 @@ #include "exports.h" +#include "file.h" +#include "linkablemapobj.h" +#include "misc.h" +#include "texteditor.h" +#include "mainwindow.h" -#include +extern Main *mainWindow; -#include "linkablemapobj.h" -#include "texteditor.h" - - -Export::Export() +ExportBase::ExportBase() { indentPerDepth=" "; } -void Export::setPath (const QString &p) +void ExportBase::setPath (const QString &p) { filepath=p; } -void Export::setMapCenter(MapCenterObj *mc) +void ExportBase::setMapCenter(MapCenterObj *mc) { mapCenter=mc; } -QString Export::getSectionString(BranchObj *bostart) +QString ExportBase::getSectionString(BranchObj *bostart) { QString r; BranchObj *bo=bostart; @@ -38,13 +39,13 @@ return r + " "; } -void Export::exportMap() +void ExportBase::exportXML() { QFile file (filepath); if ( !file.open( IO_WriteOnly ) ) { // FIXME experimental, testing - cout << "Export::exportMap couldn't open "<first(); - while (bo) - { - // Make indentstring - for (i=0;igetDepth();i++) actIndent+= indentPerDepth; +ExportOO::~ExportOO() +{ + // Remove tmpdir + //FIXME removeDir (tmpDir); + cout << "tmpDir="<getHeading()+ "\n"); - if (bo->getDepth()==0) - { - s+= (bo->getHeading()+ "\n"); - for (j=0;jgetHeading().length();j++) s+="="; - s+= "\n"; - } else if (bo->getDepth()==1) - s+= ("\n"+getSectionString(bo) + bo->getHeading()+ "\n"); - else if (bo->getDepth()==2) - s+= (actIndent + " o " + bo->getHeading()+ "\n"); - else - s+ (actIndent + " - " + bo->getHeading()+ "\n"); - - /* - // If necessary, write note - if (!bo->getNote().isEmpty()) - { - s =textConvertToASCII(bo->getNote()); - s=s.replace ("\n","\n"+actIndent); - ts << (s+"\n\n"); - } - */ - bo=bo->next(); - actIndent=""; - } +QString ExportOO::buildList (BranchObj *current) +{ + QString r; + BranchObj *bo; + int i=0; + bo=current->getFirstBranch(); + if (bo) + { + // Start list + r+="\n"; + while (bo) + { + r+="\n "+ + bo->getHeading()+ + "\n\n"; + } + r+="\n"; + } + return r; +} +QString ExportOO::walkPages (BranchObj *current) +{ + //FIXME Denkfehler: mit current anfangen, nicht mit + // Kind von current. Sonst erwisch ich nur jede 2. Depth + // + + + QString r; + BranchObj *bo; + int i=0; + bo=current->getFirstBranch(); + while(bo) + { + r+=quotemeta(bo->getHeading())+"\n"; + if (bo->getFirstBranch()) + r+=walkPages (bo->getFirstBranch()); + i++; + bo=current->getBranchNum (i); + } + return r; +} + + +void ExportOO::exportPresentation() +{ + QString allPages=walkPages (mapCenter); + + cout << allPages<",s); - cout << "ExportOO: content=\n"<",quotemeta(mapCenter->getHeading())); + content.replace ("",quotemeta(mapCenter->getAuthor())); + content.replace ("",allPages); + + // Write modified content + QFile f (contentFile); + if ( !f.open( IO_WriteOnly ) ) + { + mainWindow->statusMessage(QString(QObject::tr("Could not write to %1")).arg(outputFile)); + return; + } + + QTextStream t( &f ); + t << content; + f.close(); + + mainWindow->statusMessage( QString( QObject::tr("Map exported as %1")).arg( outputFile)); + // zip tmpdir to destination - // TODO + zipDir (tmpDir,outputFile); + /* FIXME not needed + QString onePage; + QString allPages; + QString heading; + + + // Walk through chapters (mainbranches) + QString s; + + QString list; + BranchObj *bo; + BranchObj *boLastPage=NULL; + bo=mapCenter->first(); + int depth; + int lastDepth=-1; + int basePageDepth=2; + while (bo) + { + depth=bo->getDepth(); + heading=quotemeta(bo->getHeading()); + if (depth>1) + { + if (depth==basePageDepth) + { + // Start a new page containing a heading and a list + if (boLastPage==NULL) + { + // Start new single page + boLastPage=bo; + onePage=pageTemplate; + onePage.replace ("", heading); + list=""; + } else + { + // Finish last page, start new one + onePage.replace ("", list); + boLastPage=bo; + allPages+=onePage; + onePage=pageTemplate; + onePage.replace ("", heading); + list=""; + } + } else + { + if (lastDepth==depth-1) + // entering deeper branches, new list + list+=""; + // Just add heading to list on current page + list+=""+heading+"\n"; + if (lastDepth==depth+1) + // returning from deeper branches, finish list + list+=""; + } + } + lastDepth=depth; + bo=bo->next(); + } +*/ }