1.1 --- a/exports.cpp Tue Jan 03 09:44:41 2006 +0000
1.2 +++ b/exports.cpp Tue Jan 24 15:09:48 2006 +0000
1.3 @@ -79,7 +79,7 @@
1.4 // If necessary, write note
1.5 if (!bo->getNote().isEmpty())
1.6 {
1.7 - s =textConvertToASCII(bo->getNote());
1.8 + s =bo->getNoteASCII();
1.9 s=s.replace ("\n","\n"+actIndent);
1.10 ts << (s+"\n\n");
1.11 }
1.12 @@ -90,10 +90,13 @@
1.13 file.close();
1.14 }
1.15
1.16 -// Exports a map to a LaTex file. This file needs to be included or inported into a LaTex document
1.17 -// it will not add a preamble, or anything that makes a full LaTex document.
1.18 void ExportLaTeX::exportLaTeX()
1.19 {
1.20 + // Exports a map to a LaTex file.
1.21 + // This file needs to be included
1.22 + // or inported into a LaTex document
1.23 + // it will not add a preamble, or anything
1.24 + // that makes a full LaTex document.
1.25 QFile file (filepath);
1.26 if ( !file.open( IO_WriteOnly ) ) {
1.27 // FIXME
1.28 @@ -129,7 +132,7 @@
1.29
1.30 // If necessary, write note
1.31 if (!bo->getNote().isEmpty()) {
1.32 - ts << (textConvertToASCII(bo->getNote()));
1.33 + ts << (bo->getNoteASCII());
1.34 ts << ("\n");
1.35 }
1.36
1.37 @@ -142,102 +145,103 @@
1.38 {
1.39 // Create tmpdir and set paths
1.40 tmpDir.setPath (makeUniqueDir("/tmp/vym-XXXXXX"));
1.41 - templateDir="oo-test/suse-template/";
1.42 + templateDir="exports/novell/template/";
1.43 contentTemplateFile=templateDir+"content-template.xml";
1.44 contentFile=tmpDir.path()+"/content.xml";
1.45 pageTemplateFile=templateDir+"page-template.xml";
1.46 chapterTemplateFile=templateDir+"chapter-template.xml";
1.47
1.48 - outputFile=tmpDir.currentDirPath()+"/out.odp";
1.49 -
1.50 - // Copy template to tmpdir
1.51 - system ("cp -r "+templateDir+"* "+tmpDir.path());
1.52 -
1.53 -
1.54 - // Read content-template
1.55 - if (!loadStringFromDisk (contentTemplateFile,content))
1.56 - {
1.57 - qWarning ("Export::exportOOPresentation() Couldn't load from "+contentTemplateFile);
1.58 - return;
1.59 - }
1.60 -
1.61 - // Read page-template
1.62 - QString pageTemplate;
1.63 - if (!loadStringFromDisk (pageTemplateFile,pageTemplate))
1.64 - {
1.65 - qWarning ("Export::exportOOPresentation() Couldn't load from "+pageTemplateFile);
1.66 - return;
1.67 - }
1.68 -
1.69 - // Read chapter-template
1.70 - QString chapterTemplate;
1.71 - if (!loadStringFromDisk (chapterTemplateFile,chapterTemplate))
1.72 - {
1.73 - qWarning ("Export::exportOOPresentation() Couldn't load from "+chapterTemplateFile);
1.74 - return;
1.75 - }
1.76 + outputFile=tmpDir.currentDirPath()+"/test.odp";
1.77 }
1.78
1.79 ExportOO::~ExportOO()
1.80 {
1.81 // Remove tmpdir
1.82 - //FIXME removeDir (tmpDir);
1.83 - cout << "tmpDir="<<tmpDir.path()<<endl;
1.84 + removeDir (tmpDir);
1.85 }
1.86
1.87 QString ExportOO::buildList (BranchObj *current)
1.88 {
1.89 QString r;
1.90 BranchObj *bo;
1.91 - int i=0;
1.92 +
1.93 + uint i=0;
1.94 bo=current->getFirstBranch();
1.95 if (bo)
1.96 {
1.97 // Start list
1.98 - r+="<text:list>\n";
1.99 + r+="<text:list text:style-name=\"L4\">\n";
1.100 while (bo)
1.101 {
1.102 - r+="<text:list-item><text:p text:style-name=\"P7\">\n "+
1.103 - bo->getHeading()+
1.104 - "\n</text:p></text:list-item>\n";
1.105 + r+="<text:list-item><text:p >";
1.106 + r+=quotemeta(bo->getHeading());
1.107 + // If necessary, write note
1.108 + if (!bo->getNote().isEmpty())
1.109 + r+=bo->getNoteOpenDoc();
1.110 + r+="</text:p>";
1.111 + r+=buildList (bo); // recursivly add deeper branches
1.112 + r+="</text:list-item>\n";
1.113 + i++;
1.114 + bo=current->getBranchNum(i);
1.115 }
1.116 r+="</text:list>\n";
1.117 }
1.118 return r;
1.119 }
1.120
1.121 -QString ExportOO::walkPages (BranchObj *current)
1.122 -{
1.123 - //FIXME Denkfehler: mit current anfangen, nicht mit
1.124 - // Kind von current. Sonst erwisch ich nur jede 2. Depth
1.125 - //
1.126 -
1.127 -
1.128 - QString r;
1.129 - BranchObj *bo;
1.130 - int i=0;
1.131 - bo=current->getFirstBranch();
1.132 - while(bo)
1.133 - {
1.134 - r+=quotemeta(bo->getHeading())+"\n";
1.135 - if (bo->getFirstBranch())
1.136 - r+=walkPages (bo->getFirstBranch());
1.137 - i++;
1.138 - bo=current->getBranchNum (i);
1.139 - }
1.140 - return r;
1.141 -}
1.142 -
1.143
1.144 void ExportOO::exportPresentation()
1.145 {
1.146 - QString allPages=walkPages (mapCenter);
1.147 + QString allPages;
1.148
1.149 - cout << allPages<<endl;
1.150 -
1.151 + bool useChapters=true;
1.152 +
1.153 // Insert new content
1.154 content.replace ("<!-- INSERT TITLE -->",quotemeta(mapCenter->getHeading()));
1.155 content.replace ("<!-- INSERT AUTHOR -->",quotemeta(mapCenter->getAuthor()));
1.156 +
1.157 + QString onePage;
1.158 + QString list;
1.159 +
1.160 + BranchObj *chapterBO=mapCenter->getFirstBranch();
1.161 + int i=0;
1.162 + BranchObj *pagesBO;
1.163 + int j=0;
1.164 +
1.165 + // Walk chapters
1.166 + while (chapterBO)
1.167 + {
1.168 + if (useChapters)
1.169 + {
1.170 + // Add page with chapter title
1.171 + onePage=chapterTemplate;
1.172 + onePage.replace ("<!-- INSERT PAGE HEADING -->", quotemeta(chapterBO->getHeading() ) );
1.173 + allPages+=onePage;
1.174 + } else
1.175 + {
1.176 + i=-2; // only use inner loop to
1.177 + // turn mainbranches into pages
1.178 + chapterBO=mapCenter;
1.179 + }
1.180 +
1.181 + // Walk mainpages
1.182 + pagesBO=chapterBO->getFirstBranch();
1.183 + j=0;
1.184 + while (pagesBO)
1.185 + {
1.186 + // Add page with list of items
1.187 + onePage=pageTemplate;
1.188 + onePage.replace ("<!-- INSERT PAGE HEADING -->", quotemeta (pagesBO->getHeading() ) );
1.189 + list=buildList (pagesBO);
1.190 + onePage.replace ("<!-- INSERT LIST -->", list);
1.191 + allPages+=onePage;
1.192 + j++;
1.193 + pagesBO=chapterBO->getBranchNum(j);
1.194 + }
1.195 + i++;
1.196 + chapterBO=mapCenter->getBranchNum(i);
1.197 + }
1.198 +
1.199 content.replace ("<!-- INSERT PAGES -->",allPages);
1.200
1.201 // Write modified content
1.202 @@ -252,69 +256,54 @@
1.203 t << content;
1.204 f.close();
1.205
1.206 - mainWindow->statusMessage( QString( QObject::tr("Map exported as %1")).arg( outputFile));
1.207 -
1.208 -
1.209 // zip tmpdir to destination
1.210 zipDir (tmpDir,outputFile);
1.211 -
1.212 - /* FIXME not needed
1.213 - QString onePage;
1.214 - QString allPages;
1.215 - QString heading;
1.216 -
1.217 -
1.218 - // Walk through chapters (mainbranches)
1.219 - QString s;
1.220 -
1.221 - QString list;
1.222 - BranchObj *bo;
1.223 - BranchObj *boLastPage=NULL;
1.224 - bo=mapCenter->first();
1.225 - int depth;
1.226 - int lastDepth=-1;
1.227 - int basePageDepth=2;
1.228 - while (bo)
1.229 - {
1.230 - depth=bo->getDepth();
1.231 - heading=quotemeta(bo->getHeading());
1.232 - if (depth>1)
1.233 - {
1.234 - if (depth==basePageDepth)
1.235 - {
1.236 - // Start a new page containing a heading and a list
1.237 - if (boLastPage==NULL)
1.238 - {
1.239 - // Start new single page
1.240 - boLastPage=bo;
1.241 - onePage=pageTemplate;
1.242 - onePage.replace ("<!-- INSERT PAGE HEADING -->", heading);
1.243 - list="";
1.244 - } else
1.245 - {
1.246 - // Finish last page, start new one
1.247 - onePage.replace ("<!-- INSERT LIST -->", list);
1.248 - boLastPage=bo;
1.249 - allPages+=onePage;
1.250 - onePage=pageTemplate;
1.251 - onePage.replace ("<!-- INSERT PAGE HEADING -->", heading);
1.252 - list="";
1.253 - }
1.254 - } else
1.255 - {
1.256 - if (lastDepth==depth-1)
1.257 - // entering deeper branches, new list
1.258 - list+="<text:list>";
1.259 - // Just add heading to list on current page
1.260 - list+="<text:list-item><text:p text:style-name=\"P7\">"+heading+"</text:p></text:list-item>\n";
1.261 - if (lastDepth==depth+1)
1.262 - // returning from deeper branches, finish list
1.263 - list+="</text:list>";
1.264 - }
1.265 - }
1.266 - lastDepth=depth;
1.267 - bo=bo->next();
1.268 - }
1.269 -*/
1.270 }
1.271
1.272 +void ExportOO::setConfigFile (const QString &cf)
1.273 +{
1.274 + configFile=cf;
1.275 + int i=cf.findRev ("/");
1.276 + if (i>=0) configDir=cf.left(i);
1.277 + SimpleSettings set;
1.278 + set.readSettings(configFile);
1.279 +
1.280 + // set paths
1.281 + templateDir=configDir+"/"+set.readEntry ("Template");
1.282 +
1.283 + //FIXME check if templateDir is really set, otherwise abort
1.284 +
1.285 + contentTemplateFile=templateDir+"content-template.xml";
1.286 + contentFile=tmpDir.path()+"/content.xml";
1.287 + pageTemplateFile=templateDir+"page-template.xml";
1.288 + chapterTemplateFile=templateDir+"chapter-template.xml";
1.289 +
1.290 + outputFile=tmpDir.currentDirPath()+"/test.odp";
1.291 +
1.292 + // Copy template to tmpdir
1.293 + system ("cp -r "+templateDir+"* "+tmpDir.path());
1.294 +
1.295 +
1.296 + // Read content-template
1.297 + if (!loadStringFromDisk (contentTemplateFile,content))
1.298 + {
1.299 + qWarning ("Export::exportOO() Couldn't load from "+contentTemplateFile);
1.300 + return;
1.301 + }
1.302 +
1.303 + // Read page-template
1.304 + if (!loadStringFromDisk (pageTemplateFile,pageTemplate))
1.305 + {
1.306 + qWarning ("Export::exportOO() Couldn't load from "+pageTemplateFile);
1.307 + return;
1.308 + }
1.309 +
1.310 + // Read chapter-template
1.311 + if (!loadStringFromDisk (chapterTemplateFile,chapterTemplate))
1.312 + {
1.313 + qWarning ("Export::exportOO() Couldn't load from "+chapterTemplateFile);
1.314 + return;
1.315 + }
1.316 +
1.317 +}
1.318 +