~ubuntu-branches/ubuntu/maverick/scribus-ng/maverick-backports

« back to all changes in this revision

Viewing changes to scribus/plugins/saveastemplateplugin/satemplate.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Oleksandr Moskalenko
  • Date: 2009-02-09 09:25:18 UTC
  • mfrom: (5.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20090209092518-iqsxmh3pjspgrdyd
Tags: 1.3.5.dfsg~svn20090208-2
debian/control: Use "type-handling -n arm,armel,armeb any" to generate the
list of architectures to build on.

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
 *   Riku Leino, tsoots@gmail.com                                          *
9
9
 ***************************************************************************/
10
10
#include "satemplate.h"
11
 
#include "satemplate.moc"
12
11
#include "satdialog.h"
13
12
 
14
13
#include "scpaths.h"
59
58
        m_actionInfo.menu = "File";
60
59
        m_actionInfo.menuAfterName = "SaveAs";
61
60
        m_actionInfo.enabledOnStartup = true;
 
61
        m_actionInfo.needsNumObjects = -1;
62
62
}
63
63
 
64
64
const QString SaveAsTemplatePlugin::fullTrName() const
117
117
        {
118
118
                templates.mkdir("templates");
119
119
        }
120
 
        QString currentDirPath = QDir::currentDirPath();
121
 
        QString currentFile = doc->DocName;
 
120
        QString currentPath(QDir::currentPath());
 
121
        QString currentFile(doc->DocName);
122
122
        bool hasName = doc->hasName;
123
123
        bool isModified = doc->isModified();
124
124
        QString userTemplatesDir = PrefsManager::instance()->appPrefs.documentTemplatesDir;
139
139
        if (oldCollect != ".")
140
140
                dirs->set("collect", oldCollect);
141
141
        QString docPath = doc->DocName;
142
 
        QString docDir = docPath.left(docPath.findRev('/'));
143
 
        QString docName = docPath.right(docPath.length() - docPath.findRev('/') - 1);
144
 
        docName = docName.left(docName.findRev(".s"));
 
142
        QString docDir = docPath.left(docPath.lastIndexOf('/'));
 
143
        QString docName = docPath.right(docPath.length() - docPath.lastIndexOf('/') - 1);
 
144
        docName = docName.left(docName.lastIndexOf(".s"));
145
145
 
146
146
        if (currentFile !=  doc->DocName)
147
147
        {
150
150
                                          static_cast<int>(doc->pageHeight + 0.5));
151
151
                if (satdia->exec())
152
152
                {
153
 
                        sat* s = new sat(doc, satdia, docPath.right(docPath.length() - docPath.findRev('/') - 1),docDir);
 
153
                        sat* s = new sat(doc, satdia, docPath.right(docPath.length() - docPath.lastIndexOf('/') - 1),docDir);
154
154
                        s->createImages();
155
155
                        s->createTmplXml();
156
156
                        delete s;
164
164
                        newCaption.append('*');
165
165
                doc->scMW()->updateActiveWindowCaption(newCaption);
166
166
                doc->scMW()->removeRecent(docPath);
167
 
                QDir::setCurrent(currentDirPath);
 
167
                QDir::setCurrent(currentPath);
168
168
                delete satdia;
169
169
        }
170
170
}
195
195
        xml += "<templates>\n";
196
196
        xml += getTemplateTag();
197
197
        xml += "</templates>\n";
198
 
        if ( tmplXml.open( IO_WriteOnly ) )
 
198
        if ( tmplXml.open( QIODevice::WriteOnly ) )
199
199
        {
200
200
                QTextStream stream(&tmplXml);
201
 
                stream.setEncoding(QTextStream::UnicodeUTF8);
 
201
                stream.setCodec("UTF-8");
202
202
                stream << xml;
203
203
                tmplXml.close();
204
204
        }
231
231
void sat::appendTmplXml()
232
232
{
233
233
        QFile tmplXml(tmplXmlFile);
234
 
        if (tmplXml.open(IO_ReadOnly))
 
234
        if (tmplXml.open(QIODevice::ReadOnly))
235
235
        {
236
236
                QTextStream stream(&tmplXml);
237
237
                QString tmp = stream.readLine();
238
238
                QString file = "";
239
 
                while (tmp != NULL)
 
239
                while (!tmp.isNull())
240
240
                {
241
241
                        file += tmp + "\n";
242
242
                        tmp = stream.readLine();
243
 
                        if (tmp.find("</templates>") != -1)
 
243
                        if (tmp.indexOf("</templates>") != -1)
244
244
                                file += getTemplateTag();
245
245
                }
246
246
                tmplXml.close();
247
 
                if ( tmplXml.open( IO_WriteOnly ) )
 
247
                if ( tmplXml.open( QIODevice::WriteOnly ) )
248
248
                {
249
249
                        QTextStream stream2(&tmplXml);
250
 
                        stream2.setEncoding(QTextStream::UnicodeUTF8);
 
250
                        stream2.setCodec("UTF-8");
251
251
                        stream2 << file;
252
252
                        tmplXml.close();
253
253
                }
260
260
        if (category.isEmpty())
261
261
                category = QObject::tr("Own Templates");
262
262
        else
263
 
        {
264
 
                for (uint i = 0; i < dia->cats.size(); i++)
265
 
                {
266
 
                        QString tmp = *dia->cats[i]->second;
267
 
                        if (category == tmp)
268
 
                        {
269
 
                                category = *dia->cats[i]->first;
270
 
                                break;
271
 
                        }
272
 
                }
273
 
        }
 
263
                category = dia->cats.key(category, category);
274
264
        QDate now = QDate::currentDate();
275
265
        QString cat = QString(category);
276
266
        replaceIllegalChars(cat);
287
277
        QString colors = QString(dia->colorsEdit->text());
288
278
        replaceIllegalChars(colors);
289
279
        tag += "\t\t<color>"+colors+"</color>\n";
290
 
        QString descr = QString(dia->descrEdit->text());
 
280
        QString descr = QString(dia->descrEdit->toPlainText());
291
281
        replaceIllegalChars(descr);
292
282
        tag += "\t\t<descr>"+descr+"</descr>\n";
293
 
        QString usage = QString(dia->usageEdit->text());
 
283
        QString usage = QString(dia->usageEdit->toPlainText());
294
284
        replaceIllegalChars(usage);
295
285
        tag += "\t\t<usage>"+usage+"</usage>\n";
296
286
        QString scribus_version = QString(VERSION);