insilmaril@0: #include "exports.h" insilmaril@0: insilmaril@131: #include insilmaril@131: insilmaril@0: #include "linkablemapobj.h" insilmaril@131: #include "texteditor.h" insilmaril@0: insilmaril@0: insilmaril@0: Export::Export() insilmaril@0: { insilmaril@0: indentPerDepth=" "; insilmaril@0: } insilmaril@0: insilmaril@0: void Export::setPath (const QString &p) insilmaril@0: { insilmaril@0: filepath=p; insilmaril@0: } insilmaril@0: insilmaril@0: void Export::setMapCenter(MapCenterObj *mc) insilmaril@0: { insilmaril@0: mapCenter=mc; insilmaril@0: } insilmaril@0: insilmaril@163: QString Export::getSectionString(BranchObj *bostart) insilmaril@163: { insilmaril@163: QString r; insilmaril@163: BranchObj *bo=bostart; insilmaril@163: int depth=bo->getDepth(); insilmaril@163: while (depth>0) insilmaril@163: { insilmaril@163: r=QString("%1").arg(1+bo->getNum(),0,10)+"." + r; insilmaril@163: bo=(BranchObj*)(bo->getParObj()); insilmaril@163: depth=bo->getDepth(); insilmaril@163: } insilmaril@163: if (r.isEmpty()) insilmaril@163: return r; insilmaril@163: else insilmaril@163: return r + " "; insilmaril@163: } insilmaril@163: insilmaril@0: void Export::exportMap() insilmaril@0: { insilmaril@0: QFile file (filepath); insilmaril@0: if ( !file.open( IO_WriteOnly ) ) insilmaril@0: { insilmaril@131: // FIXME experimental, testing insilmaril@0: cout << "Export::exportMap couldn't open "<first(); insilmaril@0: while (bo) insilmaril@0: { insilmaril@0: // Make indentstring insilmaril@0: for (i=0;igetDepth();i++) actIndent+= indentPerDepth; insilmaril@0: insilmaril@0: // Write heading insilmaril@0: // write (actIndent + getSectionString(bo) + bo->getHeading()+ "\n"); insilmaril@131: if (bo->getDepth()==0) insilmaril@131: { insilmaril@131: ts << (bo->getHeading()+ "\n"); insilmaril@160: for (j=0;jgetHeading().length();j++) ts<<"="; insilmaril@131: ts << "\n"; insilmaril@131: } else if (bo->getDepth()==1) insilmaril@131: ts << ("\n"+getSectionString(bo) + bo->getHeading()+ "\n"); insilmaril@131: else if (bo->getDepth()==2) insilmaril@131: ts << (actIndent + " o " + bo->getHeading()+ "\n"); insilmaril@0: else insilmaril@0: ts << (actIndent + " - " + bo->getHeading()+ "\n"); insilmaril@0: insilmaril@0: // If necessary, write note insilmaril@0: if (!bo->getNote().isEmpty()) insilmaril@0: { insilmaril@131: s =textConvertToASCII(bo->getNote()); insilmaril@131: s=s.replace ("\n","\n"+actIndent); insilmaril@131: ts << (s+"\n\n"); insilmaril@0: } insilmaril@0: insilmaril@0: bo=bo->next(); insilmaril@0: actIndent=""; insilmaril@0: } insilmaril@0: file.close(); insilmaril@0: } insilmaril@0: insilmaril@163: // Exports a map to a LaTex file. This file needs to be included or inported into a LaTex document insilmaril@163: // it will not add a preamble, or anything that makes a full LaTex document. insilmaril@163: void Export::exportLaTeX() insilmaril@0: { insilmaril@163: QFile file (filepath); insilmaril@163: if ( !file.open( IO_WriteOnly ) ) { insilmaril@163: // FIXME insilmaril@163: cout << "Export::exportMap couldn't open "<first(); insilmaril@163: while (bo) { insilmaril@163: if (bo->getDepth()==0); insilmaril@163: else if (bo->getDepth()==1) { insilmaril@163: ts << ("\\chapter{" + bo->getHeading()+ "}\n"); insilmaril@163: } insilmaril@163: else if (bo->getDepth()==2) { insilmaril@163: ts << ("\\section{" + bo->getHeading()+ "}\n"); insilmaril@163: } insilmaril@163: else if (bo->getDepth()==3) { insilmaril@163: ts << ("\\subsection{" + bo->getHeading()+ "}\n"); insilmaril@163: } insilmaril@163: else if (bo->getDepth()==4) { insilmaril@163: ts << ("\\subsubsection{" + bo->getHeading()+ "}\n"); insilmaril@163: } insilmaril@163: else { insilmaril@163: ts << ("\\paragraph*{" + bo->getHeading()+ "}\n"); insilmaril@163: } insilmaril@163: insilmaril@163: // If necessary, write note insilmaril@163: if (!bo->getNote().isEmpty()) { insilmaril@163: ts << (textConvertToASCII(bo->getNote())); insilmaril@163: ts << ("\n"); insilmaril@163: } insilmaril@163: insilmaril@163: bo=bo->next(); insilmaril@163: } insilmaril@163: file.close(); insilmaril@0: } insilmaril@0: insilmaril@163: #include "settings.h" insilmaril@163: insilmaril@163: void Export::exportOOPresentation() insilmaril@163: { insilmaril@163: QString templateDir="oo-test/suse-template/"; insilmaril@163: QString templateContent="content.xml"; insilmaril@163: QString tmpDir="/tmp/vym-ootest/"; insilmaril@163: QString header=""; insilmaril@163: insilmaril@163: insilmaril@163: // Create tmpdir insilmaril@163: // TODO insilmaril@163: insilmaril@163: // Copy template to tmpdir insilmaril@163: // TODO insilmaril@163: insilmaril@163: insilmaril@163: // Read content-template insilmaril@163: // TODO insilmaril@163: QString content; insilmaril@163: if (!loadStringFromDisk (templateDir+templateContent,content)) insilmaril@163: { insilmaril@163: qWarning ("Export::exportOOPresentation() Couldn't load from "+templateDir+templateContent); insilmaril@163: return; insilmaril@163: } insilmaril@163: insilmaril@163: insilmaril@163: // Walk through map insilmaril@163: QString s; insilmaril@163: QString actIndent(""); insilmaril@163: uint j; insilmaril@163: int i; insilmaril@163: BranchObj *bo; insilmaril@163: bo=mapCenter->first(); insilmaril@163: while (bo) insilmaril@163: { insilmaril@163: // Make indentstring insilmaril@163: for (i=0;igetDepth();i++) actIndent+= indentPerDepth; insilmaril@163: insilmaril@163: // Write heading insilmaril@163: // write (actIndent + getSectionString(bo) + bo->getHeading()+ "\n"); insilmaril@163: if (bo->getDepth()==0) insilmaril@163: { insilmaril@163: s+= (bo->getHeading()+ "\n"); insilmaril@163: for (j=0;jgetHeading().length();j++) s+="="; insilmaril@163: s+= "\n"; insilmaril@163: } else if (bo->getDepth()==1) insilmaril@163: s+= ("\n"+getSectionString(bo) + bo->getHeading()+ "\n"); insilmaril@163: else if (bo->getDepth()==2) insilmaril@163: s+= (actIndent + " o " + bo->getHeading()+ "\n"); insilmaril@163: else insilmaril@163: s+ (actIndent + " - " + bo->getHeading()+ "\n"); insilmaril@163: insilmaril@163: /* insilmaril@163: // If necessary, write note insilmaril@163: if (!bo->getNote().isEmpty()) insilmaril@163: { insilmaril@163: s =textConvertToASCII(bo->getNote()); insilmaril@163: s=s.replace ("\n","\n"+actIndent); insilmaril@163: ts << (s+"\n\n"); insilmaril@163: } insilmaril@163: */ insilmaril@163: bo=bo->next(); insilmaril@163: actIndent=""; insilmaril@163: } insilmaril@163: insilmaril@163: insilmaril@163: // Insert new content insilmaril@163: // TODO insilmaril@163: cout <<"\n\ns="<",s); insilmaril@163: cout << "ExportOO: content=\n"<