Back to index

scribus-ng  1.3.4.dfsg+svn20071115
Public Member Functions | Private Member Functions | Private Attributes
sat Class Reference

#include <satemplate.h>

Collaboration diagram for sat:
Collaboration graph
[legend]

List of all members.

Public Member Functions

void createTmplXml ()
void createImages ()
 sat (ScribusDoc *doc, satdialog *satdia, QString fileName, QString tmplDir)
 ~sat ()

Private Member Functions

void appendTmplXml ()
QString getTemplateTag ()
QString findTemplateXml (QString dir)
void replaceIllegalChars (QString &s)

Private Attributes

ScribusDoc * m_Doc
satdialogdia
QString file
QString dir
QString tmplXmlFile
QString lang

Detailed Description

Definition at line 57 of file satemplate.h.


Constructor & Destructor Documentation

sat::sat ( ScribusDoc *  doc,
satdialog satdia,
QString  fileName,
QString  tmplDir 
)

Definition at line 174 of file satemplate.cpp.

{
       lang = ScCore->getGuiLanguage();
       m_Doc = doc;
       dia = satdia;
       dir = tmplDir;
       if (dir.right(1) == "/")
              dir = tmplDir.left(tmplDir.length() - 1);
       file = fileName;
       tmplXmlFile = findTemplateXml(dir);
}

Here is the call graph for this function:

sat::~sat ( )

Definition at line 342 of file satemplate.cpp.

{
}

Member Function Documentation

void sat::appendTmplXml ( ) [private]

Definition at line 231 of file satemplate.cpp.

{
       QFile tmplXml(tmplXmlFile);
       if (tmplXml.open(IO_ReadOnly))
       {
              QTextStream stream(&tmplXml);
              QString tmp = stream.readLine();
              QString file = "";
              while (tmp != NULL)
              {
                     file += tmp + "\n";
                     tmp = stream.readLine();
                     if (tmp.find("</templates>") != -1)
                            file += getTemplateTag();
              }
              tmplXml.close();
              if ( tmplXml.open( IO_WriteOnly ) )
              {
                     QTextStream stream2(&tmplXml);
                     stream2.setEncoding(QTextStream::UnicodeUTF8);
                     stream2 << file;
                     tmplXml.close();
              }
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 207 of file satemplate.cpp.

{
       QString tnsmallName = dia->nameEdit->text() + "tn.png";
       QString tnlargeName = dia->nameEdit->text() + ".png";
       double pageh = m_Doc->pageHeight;
       double pagew = m_Doc->pageWidth;
       int pageSizeSmall = 0;
       int pageSizeLarge = 0;
       if (pageh > pagew)
       {
              pageSizeSmall = static_cast<int>(pageh / 10);
              pageSizeLarge = static_cast<int>(pageh / 3);
       }
       else
       {
              pageSizeSmall = static_cast<int>(pagew / 10);
              pageSizeLarge = static_cast<int>(pagew / 3);
       }
       QImage tnsmall = m_Doc->view()->PageToPixmap(0,pageSizeSmall);
       QImage tnlarge = m_Doc->view()->PageToPixmap(0,pageSizeLarge);
       tnsmall.save(dir+"/"+tnsmallName,"PNG",70);
       tnlarge.save(dir+"/"+tnlargeName, "PNG", 70);
}

Here is the caller graph for this function:

Definition at line 186 of file satemplate.cpp.

{
       QFile tmplXml(tmplXmlFile);
       if (tmplXml.exists())
       {
              appendTmplXml();
              return; // We don't want to overwrite the template.xml file
       }
       QString xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
       xml += "<templates>\n";
       xml += getTemplateTag();
       xml += "</templates>\n";
       if ( tmplXml.open( IO_WriteOnly ) )
       {
              QTextStream stream(&tmplXml);
              stream.setEncoding(QTextStream::UnicodeUTF8);
              stream << xml;
              tmplXml.close();
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

QString sat::findTemplateXml ( QString  dir) [private]

Definition at line 327 of file satemplate.cpp.

{
       QString tmp = dir + "/template." + lang + ".xml";
       if (QFile(tmp).exists())
              return tmp;

       if (lang.length() > 2)
       {
              tmp = dir + "/template." + lang.left(2) + ".xml";
              if (QFile(tmp).exists())
                     return tmp;
       }
       return dir + "/template.xml";
}

Here is the caller graph for this function:

QString sat::getTemplateTag ( ) [private]

Definition at line 257 of file satemplate.cpp.

{
       QString category = dia->catsCombo->currentText();
       if (category.isEmpty())
              category = QObject::tr("Own Templates");
       else
       {
              for (uint i = 0; i < dia->cats.size(); i++)
              {
                     QString tmp = *dia->cats[i]->second;
                     if (category == tmp)
                     {
                            category = *dia->cats[i]->first;
                            break;
                     }
              }
       }
       QDate now = QDate::currentDate();
       QString cat = QString(category);
       replaceIllegalChars(cat);
       QString tag = "\t<template category=\""+cat+"\">\n";
       QString name = QString(dia->nameEdit->text());
       replaceIllegalChars(name);
       tag += "\t\t<name>"+name+"</name>\n";
       tag += "\t\t<file>"+file+"</file>\n";
       tag += "\t\t<tnail>"+name+"tn.png"+"</tnail>\n";
       tag += "\t\t<img>"+name+".png"+"</img>\n";
       QString psize = QString(dia->psizeEdit->text());
       replaceIllegalChars(psize);
       tag += "\t\t<psize>"+psize+"</psize>\n";
       QString colors = QString(dia->colorsEdit->text());
       replaceIllegalChars(colors);
       tag += "\t\t<color>"+colors+"</color>\n";
       QString descr = QString(dia->descrEdit->text());
       replaceIllegalChars(descr);
       tag += "\t\t<descr>"+descr+"</descr>\n";
       QString usage = QString(dia->usageEdit->text());
       replaceIllegalChars(usage);
       tag += "\t\t<usage>"+usage+"</usage>\n";
       QString scribus_version = QString(VERSION);
       replaceIllegalChars(scribus_version);
       tag += "\t\t<scribus_version>" + scribus_version + "</scribus_version>\n";
       QString date = QString(now.toString(Qt::ISODate));
       replaceIllegalChars(date);
       tag += "\t\t<date>" + date + "</date>\n";
       QString author = QString(dia->authorEdit->text());
       replaceIllegalChars(author);
       tag += "\t\t<author>"+author+"</author>\n";
       QString email = QString(dia->emailEdit->text());
       replaceIllegalChars(email);
       tag += "\t\t<email>"+email+"</email>\n";
       tag += "\t</template>\n";

       return tag;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void sat::replaceIllegalChars ( QString &  s) [private]

Definition at line 313 of file satemplate.cpp.

{
       s.replace("&amp;", "&");
       s.replace("&lt;", "<");
       s.replace("&gt;", ">");
       s.replace("&quot;", "\"");
       s.replace("&apos;", "\'");
       s.replace("&", "&amp;");
       s.replace("<", "&lt;");
       s.replace(">", "&gt;");
       s.replace("\"", "&quot;");
       s.replace("\'", "&apos;");
}

Here is the caller graph for this function:


Member Data Documentation

satdialog* sat::dia [private]

Definition at line 61 of file satemplate.h.

QString sat::dir [private]

Definition at line 63 of file satemplate.h.

QString sat::file [private]

Definition at line 62 of file satemplate.h.

QString sat::lang [private]

Definition at line 65 of file satemplate.h.

ScribusDoc* sat::m_Doc [private]

Definition at line 60 of file satemplate.h.

QString sat::tmplXmlFile [private]

Definition at line 64 of file satemplate.h.


The documentation for this class was generated from the following files: