1.1 --- a/exports.cpp Mon Sep 05 11:56:31 2005 +0000
1.2 +++ b/exports.cpp Tue Jan 03 09:44:41 2006 +0000
1.3 @@ -21,6 +21,23 @@
1.4 mapCenter=mc;
1.5 }
1.6
1.7 +QString Export::getSectionString(BranchObj *bostart)
1.8 +{
1.9 + QString r;
1.10 + BranchObj *bo=bostart;
1.11 + int depth=bo->getDepth();
1.12 + while (depth>0)
1.13 + {
1.14 + r=QString("%1").arg(1+bo->getNum(),0,10)+"." + r;
1.15 + bo=(BranchObj*)(bo->getParObj());
1.16 + depth=bo->getDepth();
1.17 + }
1.18 + if (r.isEmpty())
1.19 + return r;
1.20 + else
1.21 + return r + " ";
1.22 +}
1.23 +
1.24 void Export::exportMap()
1.25 {
1.26 QFile file (filepath);
1.27 @@ -72,20 +89,129 @@
1.28 file.close();
1.29 }
1.30
1.31 -QString Export::getSectionString(BranchObj *bostart)
1.32 +// Exports a map to a LaTex file. This file needs to be included or inported into a LaTex document
1.33 +// it will not add a preamble, or anything that makes a full LaTex document.
1.34 +void Export::exportLaTeX()
1.35 {
1.36 - QString r;
1.37 - BranchObj *bo=bostart;
1.38 - int depth=bo->getDepth();
1.39 - while (depth>0)
1.40 - {
1.41 - r=QString("%1").arg(1+bo->getNum(),0,10)+"." + r;
1.42 - bo=(BranchObj*)(bo->getParObj());
1.43 - depth=bo->getDepth();
1.44 - }
1.45 - if (r.isEmpty())
1.46 - return r;
1.47 - else
1.48 - return r + " ";
1.49 + QFile file (filepath);
1.50 + if ( !file.open( IO_WriteOnly ) ) {
1.51 + // FIXME
1.52 + cout << "Export::exportMap couldn't open "<<filepath<<endl;
1.53 + return;
1.54 + }
1.55 + QTextStream ts( &file ); // use LANG decoding here...
1.56 + ts.setEncoding (QTextStream::UnicodeUTF8); // Force UTF8
1.57 +
1.58 + // Main loop over all branches
1.59 + QString s;
1.60 + // QString actIndent("");
1.61 + // int i;
1.62 + BranchObj *bo;
1.63 + bo=mapCenter->first();
1.64 + while (bo) {
1.65 + if (bo->getDepth()==0);
1.66 + else if (bo->getDepth()==1) {
1.67 + ts << ("\\chapter{" + bo->getHeading()+ "}\n");
1.68 + }
1.69 + else if (bo->getDepth()==2) {
1.70 + ts << ("\\section{" + bo->getHeading()+ "}\n");
1.71 + }
1.72 + else if (bo->getDepth()==3) {
1.73 + ts << ("\\subsection{" + bo->getHeading()+ "}\n");
1.74 + }
1.75 + else if (bo->getDepth()==4) {
1.76 + ts << ("\\subsubsection{" + bo->getHeading()+ "}\n");
1.77 + }
1.78 + else {
1.79 + ts << ("\\paragraph*{" + bo->getHeading()+ "}\n");
1.80 + }
1.81 +
1.82 + // If necessary, write note
1.83 + if (!bo->getNote().isEmpty()) {
1.84 + ts << (textConvertToASCII(bo->getNote()));
1.85 + ts << ("\n");
1.86 + }
1.87 +
1.88 + bo=bo->next();
1.89 + }
1.90 + file.close();
1.91 }
1.92
1.93 +#include "settings.h"
1.94 +
1.95 +void Export::exportOOPresentation()
1.96 +{
1.97 + QString templateDir="oo-test/suse-template/";
1.98 + QString templateContent="content.xml";
1.99 + QString tmpDir="/tmp/vym-ootest/";
1.100 + QString header="";
1.101 +
1.102 +
1.103 + // Create tmpdir
1.104 + // TODO
1.105 +
1.106 + // Copy template to tmpdir
1.107 + // TODO
1.108 +
1.109 +
1.110 + // Read content-template
1.111 + // TODO
1.112 + QString content;
1.113 + if (!loadStringFromDisk (templateDir+templateContent,content))
1.114 + {
1.115 + qWarning ("Export::exportOOPresentation() Couldn't load from "+templateDir+templateContent);
1.116 + return;
1.117 + }
1.118 +
1.119 +
1.120 + // Walk through map
1.121 + QString s;
1.122 + QString actIndent("");
1.123 + uint j;
1.124 + int i;
1.125 + BranchObj *bo;
1.126 + bo=mapCenter->first();
1.127 + while (bo)
1.128 + {
1.129 + // Make indentstring
1.130 + for (i=0;i<bo->getDepth();i++) actIndent+= indentPerDepth;
1.131 +
1.132 + // Write heading
1.133 + // write (actIndent + getSectionString(bo) + bo->getHeading()+ "\n");
1.134 + if (bo->getDepth()==0)
1.135 + {
1.136 + s+= (bo->getHeading()+ "\n");
1.137 + for (j=0;j<bo->getHeading().length();j++) s+="=";
1.138 + s+= "\n";
1.139 + } else if (bo->getDepth()==1)
1.140 + s+= ("\n"+getSectionString(bo) + bo->getHeading()+ "\n");
1.141 + else if (bo->getDepth()==2)
1.142 + s+= (actIndent + " o " + bo->getHeading()+ "\n");
1.143 + else
1.144 + s+ (actIndent + " - " + bo->getHeading()+ "\n");
1.145 +
1.146 + /*
1.147 + // If necessary, write note
1.148 + if (!bo->getNote().isEmpty())
1.149 + {
1.150 + s =textConvertToASCII(bo->getNote());
1.151 + s=s.replace ("\n","\n"+actIndent);
1.152 + ts << (s+"\n\n");
1.153 + }
1.154 + */
1.155 + bo=bo->next();
1.156 + actIndent="";
1.157 + }
1.158 +
1.159 +
1.160 + // Insert new content
1.161 + // TODO
1.162 + cout <<"\n\ns="<<s<<endl;
1.163 + content.replace ("<!--INSERT PAGES HERE-->",s);
1.164 + cout << "ExportOO: content=\n"<<content<<endl;
1.165 +
1.166 + // zip tmpdir to destination
1.167 + // TODO
1.168 +
1.169 +}
1.170 +