5 #include "linkablemapobj.h"
6 #include "texteditor.h"
14 void Export::setPath (const QString &p)
19 void Export::setMapCenter(MapCenterObj *mc)
24 QString Export::getSectionString(BranchObj *bostart)
27 BranchObj *bo=bostart;
28 int depth=bo->getDepth();
31 r=QString("%1").arg(1+bo->getNum(),0,10)+"." + r;
32 bo=(BranchObj*)(bo->getParObj());
41 void Export::exportMap()
43 QFile file (filepath);
44 if ( !file.open( IO_WriteOnly ) )
46 // FIXME experimental, testing
47 cout << "Export::exportMap couldn't open "<<filepath<<endl;
50 QTextStream ts( &file ); // use LANG decoding here...
52 // Main loop over all branches
54 QString actIndent("");
58 bo=mapCenter->first();
62 for (i=0;i<bo->getDepth();i++) actIndent+= indentPerDepth;
65 // write (actIndent + getSectionString(bo) + bo->getHeading()+ "\n");
66 if (bo->getDepth()==0)
68 ts << (bo->getHeading()+ "\n");
69 for (j=0;j<bo->getHeading().length();j++) ts<<"=";
71 } else if (bo->getDepth()==1)
72 ts << ("\n"+getSectionString(bo) + bo->getHeading()+ "\n");
73 else if (bo->getDepth()==2)
74 ts << (actIndent + " o " + bo->getHeading()+ "\n");
76 ts << (actIndent + " - " + bo->getHeading()+ "\n");
78 // If necessary, write note
79 if (!bo->getNote().isEmpty())
81 s =textConvertToASCII(bo->getNote());
82 s=s.replace ("\n","\n"+actIndent);
92 // Exports a map to a LaTex file. This file needs to be included or inported into a LaTex document
93 // it will not add a preamble, or anything that makes a full LaTex document.
94 void Export::exportLaTeX()
96 QFile file (filepath);
97 if ( !file.open( IO_WriteOnly ) ) {
99 cout << "Export::exportMap couldn't open "<<filepath<<endl;
102 QTextStream ts( &file ); // use LANG decoding here...
103 ts.setEncoding (QTextStream::UnicodeUTF8); // Force UTF8
105 // Main loop over all branches
107 // QString actIndent("");
110 bo=mapCenter->first();
112 if (bo->getDepth()==0);
113 else if (bo->getDepth()==1) {
114 ts << ("\\chapter{" + bo->getHeading()+ "}\n");
116 else if (bo->getDepth()==2) {
117 ts << ("\\section{" + bo->getHeading()+ "}\n");
119 else if (bo->getDepth()==3) {
120 ts << ("\\subsection{" + bo->getHeading()+ "}\n");
122 else if (bo->getDepth()==4) {
123 ts << ("\\subsubsection{" + bo->getHeading()+ "}\n");
126 ts << ("\\paragraph*{" + bo->getHeading()+ "}\n");
129 // If necessary, write note
130 if (!bo->getNote().isEmpty()) {
131 ts << (textConvertToASCII(bo->getNote()));
140 #include "settings.h"
142 void Export::exportOOPresentation()
144 QString templateDir="oo-test/suse-template/";
145 QString templateContent="content.xml";
146 QString tmpDir="/tmp/vym-ootest/";
153 // Copy template to tmpdir
157 // Read content-template
160 if (!loadStringFromDisk (templateDir+templateContent,content))
162 qWarning ("Export::exportOOPresentation() Couldn't load from "+templateDir+templateContent);
169 QString actIndent("");
173 bo=mapCenter->first();
177 for (i=0;i<bo->getDepth();i++) actIndent+= indentPerDepth;
180 // write (actIndent + getSectionString(bo) + bo->getHeading()+ "\n");
181 if (bo->getDepth()==0)
183 s+= (bo->getHeading()+ "\n");
184 for (j=0;j<bo->getHeading().length();j++) s+="=";
186 } else if (bo->getDepth()==1)
187 s+= ("\n"+getSectionString(bo) + bo->getHeading()+ "\n");
188 else if (bo->getDepth()==2)
189 s+= (actIndent + " o " + bo->getHeading()+ "\n");
191 s+ (actIndent + " - " + bo->getHeading()+ "\n");
194 // If necessary, write note
195 if (!bo->getNote().isEmpty())
197 s =textConvertToASCII(bo->getNote());
198 s=s.replace ("\n","\n"+actIndent);
207 // Insert new content
209 cout <<"\n\ns="<<s<<endl;
210 content.replace ("<!--INSERT PAGES HERE-->",s);
211 cout << "ExportOO: content=\n"<<content<<endl;
213 // zip tmpdir to destination