# HG changeset patch # User insilmaril # Date 1136281481 0 # Node ID a98a07994eed1f355ccebb174497f5dcc0691299 # Parent e696dd4a100f658532858a03774a49728b5a6c60 1.7.6 New features for floatimages and fixes diff -r e696dd4a100f -r a98a07994eed exports.cpp --- a/exports.cpp Tue Jan 03 09:44:41 2006 +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(); + } +*/ } diff -r e696dd4a100f -r a98a07994eed exports.h --- a/exports.h Tue Jan 03 09:44:41 2006 +0000 +++ b/exports.h Tue Jan 03 09:44:41 2006 +0000 @@ -6,29 +6,59 @@ #include #include "mapcenterobj.h" +#include "settings.h" -using namespace std; +//using namespace std; ///////////////////////////////////////////////////////////////////////////// -class Export + +class ExportBase { public: - Export(); + ExportBase(); void setPath(const QString &); void setMapCenter (MapCenterObj*); void setIndentPerDepth (QString); protected: QString getSectionString (BranchObj*); public: - void exportMap(); - void exportLaTeX(); - void exportOOPresentation(); + void exportXML(); -private: +protected: QDir outdir; QString filepath; MapCenterObj *mapCenter; QString indentPerDepth; }; +///////////////////////////////////////////////////////////////////////////// +class ExportLaTeX:public ExportBase +{ +public: + void exportLaTeX(); +}; + +///////////////////////////////////////////////////////////////////////////// +class ExportOO:public ExportBase +{ +public: + ExportOO(); + ~ExportOO(); + void exportPresentation(); +private: + QString buildList (BranchObj*); + QString walkPages (BranchObj*); + QDir tmpDir; + bool useChapters; + QString templateDir; + QString content; + QString contentTemplate; + QString contentTemplateFile; + QString contentFile; + QString outputFile; + QString pageTemplate; + QString pageTemplateFile; + QString chapterTemplate; + QString chapterTemplateFile; +}; #endif