1.1 Binary file demos/lifeforms.vym has changed
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/exportoofiledialog.cpp Wed Feb 25 12:44:10 2009 +0000
2.3 @@ -0,0 +1,95 @@
2.4 +#include <iostream>
2.5 +
2.6 +#include "exportoofiledialog.h"
2.7 +
2.8 +ExportOOFileDialog::ExportOOFileDialog():QFileDialog()
2.9 +{
2.10 + init();
2.11 +}
2.12 +
2.13 +ExportOOFileDialog::ExportOOFileDialog (QWidget * parent, const QString &caption ):QFileDialog(parent, caption)
2.14 +{
2.15 + init();
2.16 +}
2.17 +
2.18 +bool ExportOOFileDialog::foundConfig()
2.19 +{
2.20 + return !filters.isEmpty();
2.21 +}
2.22 +
2.23 +
2.24 +QString ExportOOFileDialog::selectedConfig()
2.25 +{
2.26 + QStringList::Iterator itpath=configPaths.begin();
2.27 + QStringList::Iterator itf=filters.begin();
2.28 + while (itf != filters.end())
2.29 + {
2.30 + if (*itf==selectedFilter()) return *itpath;
2.31 + itpath++;
2.32 + itf++;
2.33 + }
2.34 + qWarning ("ExportOOFileDialog::selectedConfig No filter found!");
2.35 + return "";
2.36 +}
2.37 +
2.38 +void ExportOOFileDialog::newConfigPath(const QString &s)
2.39 +{
2.40 + lastFilter=s;
2.41 +}
2.42 +
2.43 +QString ExportOOFileDialog::selectedFile()
2.44 +{
2.45 + return QFileDialog::selectedFile();
2.46 +}
2.47 +
2.48 +
2.49 +void ExportOOFileDialog::show()
2.50 +{
2.51 + setFilters (filters);
2.52 + QFileDialog::show();
2.53 +}
2.54 +
2.55 +void ExportOOFileDialog::init()
2.56 +{
2.57 + setMode( QFileDialog::AnyFile );
2.58 + QDir d;
2.59 + d.setPath (vymBaseDir.path()+"/exports");
2.60 + scanExportConfigs(d);
2.61 + d.setPath (d.homeDirPath()+"/.vym/exports");
2.62 + scanExportConfigs(d);
2.63 +
2.64 + connect (
2.65 + this,SIGNAL (filterSelected(const QString&)),
2.66 + this, SLOT( newConfigPath(const QString &)));
2.67 +}
2.68 +
2.69 +void ExportOOFileDialog::addFilter(const QString &f)
2.70 +{
2.71 + lastFilter=f;
2.72 + filters.append (f);
2.73 +}
2.74 +
2.75 +void ExportOOFileDialog::scanExportConfigs(QDir dir)
2.76 +{
2.77 + // Scan existing export configurations
2.78 + SimpleSettings set;
2.79 + QFile f;
2.80 + if (dir.exists())
2.81 + {
2.82 + // Traverse files
2.83 + dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
2.84 +
2.85 + QFileInfoList list = dir.entryInfoList();
2.86 + for (int i = 0; i < list.size(); ++i) {
2.87 + QFileInfo fi = list.at(i);
2.88 +
2.89 + if (fi.fileName().endsWith(".conf") )
2.90 + {
2.91 + configPaths.append (fi.absFilePath());
2.92 + set.clear();
2.93 + set.readSettings (fi.absFilePath());
2.94 + addFilter (set.readEntry(QString("Name")) + " (*.odp)");
2.95 + }
2.96 + }
2.97 + }
2.98 +}
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/exportoofiledialog.h Wed Feb 25 12:44:10 2009 +0000
3.3 @@ -0,0 +1,42 @@
3.4 +#ifndef EXPORTOOFILEDIALOG
3.5 +#define EXPORTOOFILEDIALOG
3.6 +
3.7 +#include <QFileDialog>
3.8 +#include <QStringList>
3.9 +
3.10 +#include "options.h"
3.11 +#include "settings.h"
3.12 +
3.13 +extern Options options;
3.14 +extern QDir vymBaseDir;
3.15 +
3.16 +/*! \brief Dialog to select output file and format for Open Office documents
3.17 +
3.18 +This is an overloaded QFileDialog, which allows to select templates by setting a type.
3.19 +*/
3.20 +
3.21 +class ExportOOFileDialog:public QFileDialog
3.22 +{
3.23 + Q_OBJECT
3.24 +public:
3.25 + ExportOOFileDialog();
3.26 +
3.27 + ExportOOFileDialog (QWidget * parent , const QString &caption=QString());
3.28 + bool foundConfig();
3.29 + QString selectedConfig();
3.30 + QString selectedFile();
3.31 + void show();
3.32 +
3.33 +private slots:
3.34 + void newConfigPath (const QString&f);
3.35 +
3.36 +private:
3.37 + void init();
3.38 + void addFilter(const QString &);
3.39 + void scanExportConfigs(QDir );
3.40 + QStringList configPaths;
3.41 + QStringList filters;
3.42 + QString lastFilter;
3.43 +
3.44 +};
3.45 +#endif
4.1 --- a/exports.cpp Tue Dec 09 16:44:46 2008 +0000
4.2 +++ b/exports.cpp Wed Feb 25 12:44:10 2009 +0000
4.3 @@ -1,87 +1,114 @@
4.4 #include "exports.h"
4.5 +#include "file.h"
4.6 +#include "linkablemapobj.h"
4.7 +#include "misc.h"
4.8 +#include "mainwindow.h"
4.9 +#include "warningdialog.h"
4.10 +#include "xsltproc.h"
4.11
4.12 -#include "linkablemapobj.h"
4.13 +extern Main *mainWindow;
4.14 +extern QDir vymBaseDir;
4.15 +extern QString vymName;
4.16
4.17 -
4.18 -Export::Export()
4.19 +ExportBase::ExportBase()
4.20 {
4.21 indentPerDepth=" ";
4.22 + bool ok;
4.23 + tmpDir.setPath (makeTmpDir(ok,"vym-export"));
4.24 + if (!tmpDir.exists() || !ok)
4.25 + QMessageBox::critical( 0, QObject::tr( "Error" ),
4.26 + QObject::tr("Couldn't access temporary directory\n"));
4.27 + cancelFlag=false;
4.28 }
4.29
4.30 -bool Export::setOutputDir(QString dirname)
4.31 +ExportBase::~ExportBase()
4.32 {
4.33 - outdir.setPath (dirname);
4.34 - if ( outdir.exists() )
4.35 - {
4.36 - // FIXME
4.37 - // ask for confirmation
4.38 - // then delete outdir
4.39 - return true;
4.40 - } else
4.41 - {
4.42 - // try to create directory
4.43 - //return outdir.mkdir (outdir.absPath());
4.44 - // FIXME
4.45 - return true;
4.46 - }
4.47 + // Cleanup tmpdir
4.48 + removeDir (tmpDir);
4.49 }
4.50
4.51 -void Export::setPath (const QString &p)
4.52 +void ExportBase::setDir(const QDir &d)
4.53 {
4.54 - filepath=p;
4.55 + outDir=d;
4.56 }
4.57
4.58 -void Export::setMapCenter(MapCenterObj *mc)
4.59 +void ExportBase::setFile (const QString &p)
4.60 {
4.61 - mapCenter=mc;
4.62 + outputFile=p;
4.63 }
4.64
4.65 -void Export::exportMap()
4.66 +QString ExportBase::getFile ()
4.67 {
4.68 - QFile file (filepath);
4.69 - if ( !file.open( IO_WriteOnly ) )
4.70 - {
4.71 - // FIXME
4.72 - cout << "Export::exportMap couldn't open "<<filepath<<endl;
4.73 - return;
4.74 - }
4.75 - QTextStream ts( &file ); // use LANG decoding here...
4.76 -
4.77 - // Main loop over all branches
4.78 - QString s;
4.79 - QString actIndent("");
4.80 - int i;
4.81 - BranchObj *bo;
4.82 - bo=mapCenter->first();
4.83 - while (bo)
4.84 - {
4.85 - // Make indentstring
4.86 - for (i=0;i<bo->getDepth();i++) actIndent+= indentPerDepth;
4.87 -
4.88 - // Write heading
4.89 - // write (actIndent + getSectionString(bo) + bo->getHeading()+ "\n");
4.90 - if (bo->getDepth()==1)
4.91 - ts << (getSectionString(bo) + bo->getHeading()+ "\n");
4.92 - else
4.93 - ts << (actIndent + " - " + bo->getHeading()+ "\n");
4.94 -
4.95 - // If necessary, write note
4.96 - if (!bo->getNote().isEmpty())
4.97 - {
4.98 - ts << ("-------------------Begin of Note-----------------\n");
4.99 - ts << (bo->getNote());
4.100 - ts << ("\n");
4.101 - ts << ("-------------------End of Note-------------------\n");
4.102 - }
4.103 -
4.104 - bo=bo->next();
4.105 - actIndent="";
4.106 - }
4.107 - file.close();
4.108 + return outputFile;
4.109 }
4.110
4.111 -QString Export::getSectionString(BranchObj *bostart)
4.112 +void ExportBase::setModel(VymModel *m)
4.113 {
4.114 + model=m;
4.115 +}
4.116 +
4.117 +void ExportBase::setCaption (const QString &s)
4.118 +{
4.119 + caption=s;
4.120 +}
4.121 +
4.122 +void ExportBase::addFilter(const QString &s)
4.123 +{
4.124 + filter=s;
4.125 +}
4.126 +
4.127 +bool ExportBase::execDialog()
4.128 +{
4.129 + //MapEditor *me=model.getMapEditor(); FIXME needed?
4.130 + // if (model->mapCenters.count() && me)
4.131 + {
4.132 + QFileDialog *fd=new QFileDialog( 0, caption);
4.133 + fd->setFilter (filter);
4.134 + fd->setCaption(caption);
4.135 + fd->setMode( QFileDialog::AnyFile );
4.136 + fd->setDir (outDir);
4.137 + fd->show();
4.138 +
4.139 + if ( fd->exec() == QDialog::Accepted )
4.140 + {
4.141 + if (QFile (fd->selectedFile()).exists() )
4.142 + {
4.143 + QMessageBox mb( vymName,
4.144 + QObject::tr("The file %1 exists already.\nDo you want to overwrite it?").arg(fd->selectedFile()),
4.145 + QMessageBox::Warning,
4.146 + QMessageBox::Yes | QMessageBox::Default,
4.147 + QMessageBox::Cancel | QMessageBox::Escape,
4.148 + Qt::NoButton );
4.149 + mb.setButtonText( QMessageBox::Yes, QObject::tr("Overwrite") );
4.150 + mb.setButtonText( QMessageBox::No, QObject::tr("Cancel"));
4.151 + ExportBase ex;
4.152 + switch( mb.exec() )
4.153 + {
4.154 + case QMessageBox::Yes:
4.155 + // save
4.156 + break;;
4.157 + case QMessageBox::Cancel:
4.158 + cancelFlag=true;
4.159 + return false;
4.160 + break;
4.161 + }
4.162 + }
4.163 + outputFile=fd->selectedFile();
4.164 + cancelFlag=false;
4.165 + return true;
4.166 + }
4.167 + }
4.168 + return false;
4.169 +}
4.170 +
4.171 +bool ExportBase::canceled()
4.172 +{
4.173 + return cancelFlag;
4.174 +}
4.175 +
4.176 +QString ExportBase::getSectionString(BranchObj *bostart)
4.177 +{
4.178 + // Make prefix like "2.5.3" for "bo:2,bo:5,bo:3"
4.179 QString r;
4.180 BranchObj *bo=bostart;
4.181 int depth=bo->getDepth();
4.182 @@ -97,36 +124,460 @@
4.183 return r + " ";
4.184 }
4.185
4.186 -void Export::exportAsHTML()
4.187 +////////////////////////////////////////////////////////////////////////
4.188 +ExportASCII::ExportASCII()
4.189 {
4.190 - // FIXME just testing...
4.191 + filter="TXT (*.txt)";
4.192 + caption=vymName+ " -" +QObject::tr("Export as ASCII")+" "+QObject::tr("(still experimental)");
4.193 +}
4.194 +
4.195 +void ExportASCII::doExport()
4.196 +{
4.197 + QFile file (outputFile);
4.198 + if ( !file.open( QIODevice::WriteOnly ) )
4.199 + {
4.200 + qWarning ("ExportBase::exportXML couldn't open "+outputFile);
4.201 + return;
4.202 + }
4.203 + QTextStream ts( &file ); // use LANG decoding here...
4.204 +
4.205 // Main loop over all branches
4.206 QString s;
4.207 - QString actIndent("");
4.208 + QString curIndent;
4.209 int i;
4.210 BranchObj *bo;
4.211 - bo=mapCenter->first();
4.212 + bo=model->first();
4.213 while (bo)
4.214 {
4.215 // Make indentstring
4.216 - for (i=0;i<bo->getDepth();i++) actIndent+= indentPerDepth;
4.217 + curIndent="";
4.218 + for (i=0;i<bo->getDepth()-1;i++) curIndent+= indentPerDepth;
4.219
4.220 - // Write heading
4.221 - write (actIndent + getSectionString(bo) + bo->getHeading()+ "\n");
4.222 -
4.223 - // If necessary, write note
4.224 - if (!bo->getNote().isEmpty())
4.225 + if (!bo->hasHiddenExportParent() )
4.226 {
4.227 - write (bo->getNote());
4.228 + switch (bo->getDepth())
4.229 + {
4.230 + case 0:
4.231 + ts << underline (bo->getHeading(),QString("="));
4.232 + ts << "\n";
4.233 + break;
4.234 + case 1:
4.235 + ts << "\n";
4.236 + ts << (underline (getSectionString(bo) + bo->getHeading(), QString("-") ) );
4.237 + ts << "\n";
4.238 + break;
4.239 + case 2:
4.240 + ts << "\n";
4.241 + ts << (curIndent + "* " + bo->getHeading());
4.242 + ts << "\n";
4.243 + break;
4.244 + case 3:
4.245 + ts << (curIndent + "- " + bo->getHeading());
4.246 + ts << "\n";
4.247 + break;
4.248 + default:
4.249 + ts << (curIndent + "- " + bo->getHeading());
4.250 + ts << "\n";
4.251 + break;
4.252 + }
4.253 +
4.254 + // If necessary, write note
4.255 + if (!bo->getNote().isEmpty())
4.256 + {
4.257 + curIndent +=" | ";
4.258 + s=bo->getNoteASCII( curIndent, 80);
4.259 + ts << s;
4.260 + }
4.261 + }
4.262 + bo=model->next(bo);
4.263 + }
4.264 + file.close();
4.265 +}
4.266 +
4.267 +QString ExportASCII::underline (const QString &text, const QString &line)
4.268 +{
4.269 + QString r=text + "\n";
4.270 + for (int j=0;j<text.length();j++) r+=line;
4.271 + return r;
4.272 +}
4.273 +
4.274 +
4.275 +////////////////////////////////////////////////////////////////////////
4.276 +void ExportCSV::doExport()
4.277 +{
4.278 + QFile file (outputFile);
4.279 + if ( !file.open( QIODevice::WriteOnly ) )
4.280 + {
4.281 + qWarning ("ExportBase::exportXML couldn't open "+outputFile);
4.282 + return;
4.283 + }
4.284 + QTextStream ts( &file ); // use LANG decoding here...
4.285 +
4.286 + // Write header
4.287 + ts << "\"Note\"" <<endl;
4.288 +
4.289 + // Main loop over all branches
4.290 + QString s;
4.291 + QString curIndent("");
4.292 + int i;
4.293 + BranchObj *bo;
4.294 + bo=model->first();
4.295 + while (bo)
4.296 + {
4.297 + if (!bo->hasHiddenExportParent() )
4.298 + {
4.299 + // If necessary, write note
4.300 + if (!bo->getNote().isEmpty())
4.301 + {
4.302 + s =bo->getNoteASCII();
4.303 + s=s.replace ("\n","\n"+curIndent);
4.304 + ts << ("\""+s+"\",");
4.305 + } else
4.306 + ts <<"\"\",";
4.307 +
4.308 + // Make indentstring
4.309 + for (i=0;i<bo->getDepth();i++) curIndent+= "\"\",";
4.310 +
4.311 + // Write heading
4.312 + ts << curIndent << "\"" << bo->getHeading()<<"\""<<endl;
4.313 }
4.314
4.315 - bo=bo->next();
4.316 - actIndent="";
4.317 + bo=model->next(bo);
4.318 + curIndent="";
4.319 + }
4.320 + file.close();
4.321 +}
4.322 +
4.323 +////////////////////////////////////////////////////////////////////////
4.324 +void ExportKDEBookmarks::doExport()
4.325 +{
4.326 + MapEditor *me=model->getMapEditor();
4.327 + if (me)
4.328 + {
4.329 + WarningDialog dia;
4.330 + dia.showCancelButton (true);
4.331 + dia.setText(QObject::tr("Exporting the %1 bookmarks will overwrite\nyour existing bookmarks file.").arg("KDE"));
4.332 + dia.setCaption(QObject::tr("Warning: Overwriting %1 bookmarks").arg("KDE"));
4.333 + dia.setShowAgainName("/exports/KDE/overwriteKDEBookmarks");
4.334 + if (dia.exec()==QDialog::Accepted)
4.335 + {
4.336 + me->exportXML(tmpDir.path(),false);
4.337 +
4.338 + XSLTProc p;
4.339 + p.setInputFile (tmpDir.path()+"/"+me->getMapName()+".xml");
4.340 + p.setOutputFile (tmpDir.home().path()+"/.kde/share/apps/konqueror/bookmarks.xml");
4.341 + p.setXSLFile (vymBaseDir.path()+"/styles/vym2kdebookmarks.xsl");
4.342 + p.process();
4.343 +
4.344 + QString ub=vymBaseDir.path()+"/scripts/update-bookmarks";
4.345 + QProcess *proc= new QProcess ;
4.346 + proc->start( ub);
4.347 + if (!proc->waitForStarted())
4.348 + {
4.349 + QMessageBox::warning(0,
4.350 + QObject::tr("Warning"),
4.351 + QObject::tr("Couldn't find script %1\nto notifiy Browsers of changed bookmarks.").arg(ub));
4.352 + }
4.353 + }
4.354 + }
4.355 +
4.356 +}
4.357 +
4.358 +////////////////////////////////////////////////////////////////////////
4.359 +void ExportFirefoxBookmarks::doExport()
4.360 +{
4.361 + MapEditor *me=model->getMapEditor();
4.362 + if (me)
4.363 + {
4.364 + WarningDialog dia;
4.365 + dia.showCancelButton (true);
4.366 + dia.setText(QObject::tr("Exporting the %1 bookmarks will overwrite\nyour existing bookmarks file.").arg("Firefox"));
4.367 + dia.setCaption(QObject::tr("Warning: Overwriting %1 bookmarks").arg("Firefox"));
4.368 + dia.setShowAgainName("/vym/warnings/overwriteImportBookmarks");
4.369 + if (dia.exec()==QDialog::Accepted)
4.370 + {
4.371 + me->exportXML(tmpDir.path(),false);
4.372 +
4.373 +/*
4.374 + XSLTProc p;
4.375 + p.setInputFile (tmpDir.path()+"/"+me->getMapName()+".xml");
4.376 + p.setOutputFile (tmpDir.home().path()+"/.kde/share/apps/konqueror/bookmarks.xml");
4.377 + p.setXSLFile (vymBaseDir.path()+"/styles/vym2kdebookmarks.xsl");
4.378 + p.process();
4.379 +
4.380 + QString ub=vymBaseDir.path()+"/scripts/update-bookmarks";
4.381 + QProcess *proc = new QProcess( );
4.382 + proc->addArgument(ub);
4.383 +
4.384 + if ( !proc->start() )
4.385 + {
4.386 + QMessageBox::warning(0,
4.387 + QObject::tr("Warning"),
4.388 + QObject::tr("Couldn't find script %1\nto notifiy Browsers of changed bookmarks.").arg(ub));
4.389 + }
4.390 +
4.391 +*/
4.392 +
4.393 + }
4.394 }
4.395 }
4.396
4.397 -void Export::write(QString s)
4.398 +////////////////////////////////////////////////////////////////////////
4.399 +void ExportTaskjuggler::doExport()
4.400 {
4.401 - cout << s;
4.402 + MapEditor *me=model->getMapEditor();
4.403 + if (me)
4.404 + {
4.405 + me->exportXML(tmpDir.path(),false);
4.406 +
4.407 + XSLTProc p;
4.408 + p.setInputFile (tmpDir.path()+"/"+me->getMapName()+".xml");
4.409 + p.setOutputFile (outputFile);
4.410 + p.setXSLFile (vymBaseDir.path()+"/styles/vym2taskjuggler.xsl");
4.411 + p.process();
4.412 + }
4.413 +
4.414 }
4.415
4.416 +////////////////////////////////////////////////////////////////////////
4.417 +void ExportLaTeX::doExport()
4.418 +{
4.419 + // Exports a map to a LaTex file.
4.420 + // This file needs to be included
4.421 + // or inported into a LaTex document
4.422 + // it will not add a preamble, or anything
4.423 + // that makes a full LaTex document.
4.424 + QFile file (outputFile);
4.425 + if ( !file.open( QIODevice::WriteOnly ) ) {
4.426 + QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("Could not write %1").arg(outputFile));
4.427 + mainWindow->statusMessage(QString(QObject::tr("Export failed.")));
4.428 + return;
4.429 + }
4.430 + QTextStream ts( &file ); // use LANG decoding here...
4.431 + ts.setEncoding (QTextStream::UnicodeUTF8); // Force UTF8
4.432 +
4.433 + // Main loop over all branches
4.434 + QString s;
4.435 + // QString curIndent("");
4.436 + // int i;
4.437 + BranchObj *bo;
4.438 + bo=model->first();
4.439 + while (bo) {
4.440 + if (!bo->hasHiddenExportParent() )
4.441 + {
4.442 + if (bo->getDepth()==0);
4.443 + else if (bo->getDepth()==1) {
4.444 + ts << ("\\chapter{" + bo->getHeading()+ "}\n");
4.445 + }
4.446 + else if (bo->getDepth()==2) {
4.447 + ts << ("\\section{" + bo->getHeading()+ "}\n");
4.448 + }
4.449 + else if (bo->getDepth()==3) {
4.450 + ts << ("\\subsection{" + bo->getHeading()+ "}\n");
4.451 + }
4.452 + else if (bo->getDepth()==4) {
4.453 + ts << ("\\subsubsection{" + bo->getHeading()+ "}\n");
4.454 + }
4.455 + else {
4.456 + ts << ("\\paragraph*{" + bo->getHeading()+ "}\n");
4.457 + }
4.458 +
4.459 + // If necessary, write note
4.460 + if (!bo->getNote().isEmpty()) {
4.461 + ts << (bo->getNoteASCII());
4.462 + ts << ("\n");
4.463 + }
4.464 + }
4.465 + bo=model->next(bo);
4.466 + }
4.467 + file.close();
4.468 +}
4.469 +
4.470 +////////////////////////////////////////////////////////////////////////
4.471 +ExportOO::ExportOO()
4.472 +{
4.473 + useSections=false;
4.474 +}
4.475 +
4.476 +ExportOO::~ExportOO()
4.477 +{
4.478 +}
4.479 +
4.480 +QString ExportOO::buildList (BranchObj *current)
4.481 +{
4.482 + QString r;
4.483 + BranchObj *bo;
4.484 +
4.485 + uint i=0;
4.486 + bo=current->getFirstBranch();
4.487 + if (bo)
4.488 + {
4.489 + if (!bo->hasHiddenExportParent() )
4.490 + {
4.491 + // Start list
4.492 + r+="<text:list text:style-name=\"vym-list\">\n";
4.493 + while (bo)
4.494 + {
4.495 + r+="<text:list-item><text:p >";
4.496 + r+=quotemeta(bo->getHeading());
4.497 + // If necessary, write note
4.498 + if (!bo->getNote().isEmpty())
4.499 + r+=bo->getNoteOpenDoc();
4.500 + r+="</text:p>";
4.501 + r+=buildList (bo); // recursivly add deeper branches
4.502 + r+="</text:list-item>\n";
4.503 + i++;
4.504 + bo=current->getBranchNum(i);
4.505 + }
4.506 + r+="</text:list>\n";
4.507 + }
4.508 + }
4.509 + return r;
4.510 +}
4.511 +
4.512 +
4.513 +void ExportOO::exportPresentation()
4.514 +{
4.515 + QString allPages;
4.516 +
4.517 + MapCenterObj *firstMCO=(MapCenterObj*)model->first();
4.518 + if (!firstMCO)
4.519 + {
4.520 + QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("No objects in map!"));
4.521 + return;
4.522 + }
4.523 +
4.524 + // Insert new content
4.525 + // FIXME add extra title in mapinfo for vym 1.13.x
4.526 + content.replace ("<!-- INSERT TITLE -->",quotemeta(firstMCO->getHeading()));
4.527 + content.replace ("<!-- INSERT AUTHOR -->",quotemeta(model->getAuthor()));
4.528 +
4.529 + QString onePage;
4.530 + QString list;
4.531 +
4.532 + BranchObj *sectionBO;
4.533 + int i=0;
4.534 + BranchObj *pagesBO;
4.535 + int j=0;
4.536 +
4.537 + int mapcenters=model->countMapCenters();
4.538 +
4.539 + // useSections already has been set in setConfigFile
4.540 + if (mapcenters>1)
4.541 + sectionBO=firstMCO;
4.542 + else
4.543 + sectionBO=firstMCO->getFirstBranch();
4.544 +
4.545 + // Walk sections
4.546 + while (sectionBO && !sectionBO->hasHiddenExportParent() )
4.547 + {
4.548 + if (useSections)
4.549 + {
4.550 + // Add page with section title
4.551 + onePage=sectionTemplate;
4.552 + onePage.replace ("<!-- INSERT PAGE HEADING -->", quotemeta(sectionBO->getHeading() ) );
4.553 + allPages+=onePage;
4.554 + pagesBO=sectionBO->getFirstBranch();
4.555 + } else
4.556 + {
4.557 + //i=-2; // only use inner loop to
4.558 + // turn mainbranches into pages
4.559 + //sectionBO=firstMCO;
4.560 + pagesBO=sectionBO;
4.561 + }
4.562 +
4.563 + j=0;
4.564 + while (pagesBO && !pagesBO->hasHiddenExportParent() )
4.565 + {
4.566 + // Add page with list of items
4.567 + onePage=pageTemplate;
4.568 + onePage.replace ("<!-- INSERT PAGE HEADING -->", quotemeta (pagesBO->getHeading() ) );
4.569 + list=buildList (pagesBO);
4.570 + onePage.replace ("<!-- INSERT LIST -->", list);
4.571 + allPages+=onePage;
4.572 + if (pagesBO!=sectionBO)
4.573 + {
4.574 + j++;
4.575 + pagesBO=((BranchObj*)pagesBO->getParObj())->getBranchNum(j);
4.576 + } else
4.577 + pagesBO=NULL; // We are already iterating over the sectionBOs
4.578 + }
4.579 + i++;
4.580 + if (mapcenters>1 )
4.581 + sectionBO=model->getMapCenterNum (i);
4.582 + else
4.583 + sectionBO=firstMCO->getBranchNum (i);
4.584 + }
4.585 +
4.586 + content.replace ("<!-- INSERT PAGES -->",allPages);
4.587 +
4.588 + // Write modified content
4.589 + QFile f (contentFile);
4.590 + if ( !f.open( QIODevice::WriteOnly ) )
4.591 + {
4.592 + QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("Could not write %1").arg(contentFile));
4.593 + mainWindow->statusMessage(QString(QObject::tr("Export failed.")));
4.594 + return;
4.595 + }
4.596 +
4.597 + QTextStream t( &f );
4.598 + t << content;
4.599 + f.close();
4.600 +
4.601 + // zip tmpdir to destination
4.602 + zipDir (tmpDir,outputFile);
4.603 +}
4.604 +
4.605 +bool ExportOO::setConfigFile (const QString &cf)
4.606 +{
4.607 + configFile=cf;
4.608 + int i=cf.findRev ("/");
4.609 + if (i>=0) configDir=cf.left(i);
4.610 + SimpleSettings set;
4.611 + set.readSettings(configFile);
4.612 +
4.613 + // set paths
4.614 + templateDir=configDir+"/"+set.readEntry ("Template");
4.615 +
4.616 + QDir d (templateDir);
4.617 + if (!d.exists())
4.618 + {
4.619 + QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("Check \"%1\" in\n%2").arg("Template="+set.readEntry ("Template")).arg(configFile));
4.620 + return false;
4.621 +
4.622 + }
4.623 +
4.624 + contentTemplateFile=templateDir+"content-template.xml";
4.625 + contentFile=tmpDir.path()+"/content.xml";
4.626 + pageTemplateFile=templateDir+"page-template.xml";
4.627 + sectionTemplateFile=templateDir+"section-template.xml";
4.628 +
4.629 + if (model->countMapCenters()>1 ||set.readEntry("useSections").contains("yes"))
4.630 + useSections=true;
4.631 +
4.632 + // Copy template to tmpdir
4.633 + system ("cp -r "+templateDir+"* "+tmpDir.path());
4.634 +
4.635 + // Read content-template
4.636 + if (!loadStringFromDisk (contentTemplateFile,content))
4.637 + {
4.638 + QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("Could not read %1").arg(contentTemplateFile));
4.639 + return false;
4.640 + }
4.641 +
4.642 + // Read page-template
4.643 + if (!loadStringFromDisk (pageTemplateFile,pageTemplate))
4.644 + {
4.645 + QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("Could not read %1").arg(pageTemplateFile));
4.646 + return false;
4.647 + }
4.648 +
4.649 + // Read section-template
4.650 + if (useSections && !loadStringFromDisk (sectionTemplateFile,sectionTemplate))
4.651 + {
4.652 + QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("Could not read %1").arg(sectionTemplateFile));
4.653 + return false;
4.654 + }
4.655 + return true;
4.656 +}
4.657 +
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/exports/template-orange-blue/section-template.xml Wed Feb 25 12:44:10 2009 +0000
5.3 @@ -0,0 +1,14 @@
5.4 + <draw:page draw:name="<!-- INSERT PAGE HEADING -->" draw:style-name="dp3" draw:master-page-name="Section_20_Break" presentation:presentation-page-layout-name="AL3T19">
5.5 + <draw:frame presentation:style-name="pr7" draw:text-style-name="P2" draw:layer="layout" svg:width="22.86cm" svg:height="3.436cm" svg:x="1.217cm" svg:y="7.799cm" presentation:class="title" presentation:user-transformed="true">
5.6 + <draw:text-box>
5.7 + <text:p text:style-name="P1"><!-- INSERT PAGE HEADING --> </text:p>
5.8 + </draw:text-box>
5.9 + </draw:frame>
5.10 + <presentation:notes draw:style-name="dp2">
5.11 + <draw:page-thumbnail draw:layer="layout" svg:width="12.982cm" svg:height="9.737cm" svg:x="3.14cm" svg:y="1.905cm" draw:page-number="3" presentation:class="page"/>
5.12 + <draw:frame presentation:style-name="pr8" draw:text-style-name="P5" draw:layer="layout" svg:width="14.182cm" svg:height="11.642cm" svg:x="2.54cm" svg:y="12.277cm" presentation:class="notes" presentation:placeholder="true">
5.13 + <draw:text-box/>
5.14 + </draw:frame>
5.15 + </presentation:notes>
5.16 + </draw:page>
5.17 +
6.1 --- a/tex/vym.changelog Tue Dec 09 16:44:46 2008 +0000
6.2 +++ b/tex/vym.changelog Wed Feb 25 12:44:10 2009 +0000
6.3 @@ -1,3 +1,8 @@
6.4 +-------------------------------------------------------------------
6.5 +Wed Feb 25 13:43:28 CET 2009 - uwedr@suse.de
6.6 +
6.7 +- Bugfix: Enabled multiple mapcenters for export to OpenOffice.org
6.8 +
6.9 -------------------------------------------------------------------
6.10 Mon Dec 8 20:26:41 CET 2008 - uwedr@suse.de
6.11
7.1 --- a/version.h Tue Dec 09 16:44:46 2008 +0000
7.2 +++ b/version.h Wed Feb 25 12:44:10 2009 +0000
7.3 @@ -4,10 +4,10 @@
7.4 #include <QString>
7.5
7.6 #define __VYM_NAME "VYM"
7.7 -#define __VYM_VERSION "1.12.2c"
7.8 +#define __VYM_VERSION "1.12.2d"
7.9 #define __VYM_CODENAME "Maintenance Update "
7.10 //#define __VYM_CODENAME "Codename: development version"
7.11 -#define __VYM_BUILD_DATE "2008-12-08"
7.12 +#define __VYM_BUILD_DATE "2009-02-25"
7.13
7.14
7.15 bool checkVersion(const QString &);
8.1 --- a/vymmodel.cpp Tue Dec 09 16:44:46 2008 +0000
8.2 +++ b/vymmodel.cpp Wed Feb 25 12:44:10 2009 +0000
8.3 @@ -120,6 +120,20 @@
8.4 return NULL;
8.5 }
8.6
8.7 +MapCenterObj *VymModel::getMapCenterNum (int i)
8.8 +{
8.9 + cout << "MCO i="<<i<<" count="<<mapCenters.count()<<endl;
8.10 + if (i>mapCenters.count()-1 || i<0)
8.11 + return NULL;
8.12 + else
8.13 + return mapCenters.at(i);
8.14 +}
8.15 +
8.16 +int VymModel::countMapCenters()
8.17 +{
8.18 + return mapCenters.count();
8.19 +}
8.20 +
8.21 BranchObj* VymModel::first()
8.22 {
8.23 if (mapCenters.count()>0)
9.1 --- a/vymmodel.h Tue Dec 09 16:44:46 2008 +0000
9.2 +++ b/vymmodel.h Wed Feb 25 12:44:10 2009 +0000
9.3 @@ -31,6 +31,8 @@
9.4 MapCenterObj* addMapCenter();
9.5 MapCenterObj* addMapCenter(QPointF absPos);
9.6 MapCenterObj* removeMapCenter(MapCenterObj *mco);
9.7 + MapCenterObj* getMapCenterNum (int i);
9.8 + int countMapCenters ();
9.9
9.10 BranchObj* first(); // FIXME replaced by ModelIndex later
9.11 BranchObj* next(BranchObj *bo); // FIXME replaced by ModelIndex later