Subversion Repositories Scribus

Compare Revisions

Ignore whitespace Rev 414 → Rev 415

/trunk/Scribus/ChangeLogCVS
1,5 → 1,12
Changes since 1.2
 
25.09.2004
* bug # 971: Improvement in the Hyphenation Settings menus
 
24.09.2004
* bug #1002: Many dialog boxes don't remember last settings
* feature #1145: Polish Translation Update
 
22.09.2004
* bug #1019: When fonts are auto removed because of errors, they should be reported in the console
* bug #1103: Scribus exits with a Signal 11 when adding a new page to a document
/trunk/Scribus/scribus/prefsreader.cpp
0,0 → 1,113
/***************************************************************************
* Copyright (C) 2004 by Riku Leino *
* tsoots@welho.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
 
#include "prefsreader.h"
 
PrefsReader::PrefsReader(ContextMap *appContexts, ContextMap *pluginContexts)
{
aContexts = appContexts;
pContexts = pluginContexts;
inApp = false;
rowIndex = 0;
colIndex = 0;
inTable = false;
}
 
bool PrefsReader::startElement(const QString&, const QString&, const QString &name, const QXmlAttributes &attrs)
{
if (name == "context")
{
for (int i = 0; i < attrs.count(); ++i)
if (attrs.localName(i) == "name")
currentContext = new PrefsContext(attrs.value(i));
}
else if (name == "level")
{
bool found = false;
for (int i = 0; i < attrs.count(); ++i)
if ((attrs.localName(i) == "name") && (attrs.value(i) == "application"))
found = true;
inApp = found;
}
else if (name == "attribute")
{
QString key = "";
QString value = "";
for (int i = 0; i < attrs.count(); ++i)
{
if (attrs.localName(i) == "key")
key = attrs.value(i);
else if (attrs.localName(i) == "value")
value = attrs.value(i);
}
currentContext->set(key, value);
}
else if (name == "table")
{
for (int i = 0; i < attrs.count(); ++i)
{
if (attrs.localName(i) == "name")
currentTable = currentContext->getTable(attrs.value(i));
}
}
else if (name == "col")
inTable = true;
 
return true;
}
 
bool PrefsReader::characters (const QString& ch)
{
if (inTable)
currentTable->set(rowIndex, colIndex, ch);
return true;
}
 
bool PrefsReader::endElement(const QString&, const QString&, const QString &name)
{
if (name == "context")
{
if (inApp)
(*aContexts)[currentContext->getName()] = currentContext;
else
(*pContexts)[currentContext->getName()] = currentContext;
}
else if (name == "row")
{
++rowIndex;
colIndex = 0;
}
else if (name == "col")
{
++colIndex;
inTable = false;
}
else if (name == "table")
{
rowIndex = 0;
colIndex = 0;
}
return true;
}
 
PrefsReader::~PrefsReader()
{
 
}
Property changes:
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Index: Scribus/scribus/pdfopts.cpp
===================================================================
--- Scribus/scribus/pdfopts.cpp (revision 414)
+++ Scribus/scribus/pdfopts.cpp (revision 415)
@@ -1,6 +1,7 @@
#include "pdfopts.h"
#include "pdfopts.moc"
#include "customfdialog.h"
+#include "prefsfile.h"
#if (_MSC_VER >= 1200)
#include "win-config.h"
@@ -16,6 +17,7 @@
extern bool CMSuse;
#endif
extern bool CMSavail;
+extern PrefsFile* prefsFile;
PDF_Opts::PDF_Opts( QWidget* parent, QString Fname, QMap<QString,QFont> DocFonts, ScribusView *vie, PDFOpt *Optionen, QValueList<PreSet> Eff, ProfilesL *PDFXProfiles, SCFonts &AllFonts)
: QDialog( parent, "pdf", true, 0 )
@@ -42,8 +44,12 @@
Datei->setText(Optionen->Datei);
else
{
+ PrefsContext* dirs = prefsFile->getContext("dirs");
QFileInfo fi = QFileInfo(Fname);
- Datei->setText(fi.dirPath()+"/"+fi.baseName()+".pdf");
+ QString pdfdir = dirs->get("pdf", fi.dirPath());
+ if (pdfdir.right(1) != "/")
+ pdfdir += "/";
+ Datei->setText(pdfdir+fi.baseName()+".pdf");
}
Name->setBuddy(Datei);
Layout5->addWidget( Datei );
@@ -1216,11 +1222,16 @@
void PDF_Opts::ChangeFile()
{
QString fn;
- CustomFDialog dia(this, tr("Save as"), tr("PDF Files (*.pdf);;All Files (*)"), false, false);
+ PrefsContext* dirs = prefsFile->getContext("dirs");
+ QString wdir = dirs->get("pdf", ".");
+ CustomFDialog dia(this, wdir, tr("Save as"), tr("PDF Files (*.pdf);;All Files (*)"), false, false);
if (Datei->text() != "")
dia.setSelection(Datei->text());
if (dia.exec() == QDialog::Accepted)
+ {
fn = dia.selectedFile();
+ dirs->set("pdf", fn.left(fn.findRev("/")));
+ }
else
return;
Datei->setText(fn);
/trunk/Scribus/scribus/lineformats.cpp
4,7 → 4,9
#include <qmessagebox.h>
#include "customfdialog.h"
#include "scribusXml.h"
#include "prefsfile.h"
extern QPixmap loadIcon(QString nam);
extern PrefsFile* prefsFile;
 
LineFormate::LineFormate( QWidget* parent, ScribusDoc *doc)
: QDialog( parent, "Formate", true, 0)
154,7 → 156,7
{
int exit=QMessageBox::warning(this,
tr("Warning"),
tr("Do you really want do delete this Style?"),
tr("Do you really want to delete this Style?"),
tr("&No"),
tr("&Yes"),
0, 0, 0);
171,10 → 173,12
void LineFormate::loadLStyles()
{
QString fileName;
PrefsContext* dirs = prefsFile->getContext("dirs");
QString wdir = dirs->get("lineformats", ".");
#ifdef HAVE_LIBZ
CustomFDialog dia(this, tr("Open"), tr("Documents (*.sla *.sla.gz *.scd *.scd.gz);;All Files (*)"));
CustomFDialog dia(this, wdir, tr("Open"), tr("Documents (*.sla *.sla.gz *.scd *.scd.gz);;All Files (*)"));
#else
CustomFDialog dia(this, tr("Open"), tr("Documents (*.sla *.scd);;All Files (*)"));
CustomFDialog dia(this, wdir, tr("Open"), tr("Documents (*.sla *.scd);;All Files (*)"));
#endif
if (dia.exec() == QDialog::Accepted)
fileName = dia.selectedFile();
182,6 → 186,7
return;
if (!fileName.isEmpty())
{
dirs->set("lineformats", fileName.left(fileName.findRev("/")));
ScriXmlDoc *ss = new ScriXmlDoc();
if (ss->ReadLStyles(fileName, &TempStyles))
UpdateFList();
/trunk/Scribus/scribus/customfdialog.cpp
164,12 → 164,13
GenPreview(url.path());
}
 
CustomFDialog::CustomFDialog(QWidget *pa, QString cap, QString filter, bool Pre, bool mod, bool comp, bool cod, bool dirOnly)
: QFileDialog(QString::null, filter, pa, 0, true)
CustomFDialog::CustomFDialog(QWidget *pa, QString wDir, QString cap, QString filter,
bool Pre, bool mod, bool comp, bool cod, bool dirOnly)
: QFileDialog(QString::null, filter, pa, 0, true)
{
setIcon(loadIcon("AppIcon.png"));
setCaption(cap);
cDir = QDir();
cDir = QDir(wDir);
setDir(cDir);
setIconProvider(new ImIconProvider(this));
FDialogPreview *pw;
/trunk/Scribus/scribus/gtaction.cpp
19,6 → 19,7
***************************************************************************/
 
#include "gtaction.h"
#include <qcursor.h>
 
extern ScribusApp* ScApp;
 
53,7 → 54,6
ScApp->FMess->setText(QObject::tr("Importing text"));
ScApp->FProg->reset();
ScApp->FProg->setTotalSteps(0);
ScApp->FProg->setProgress(0,0);
}
 
void gtAction::setProgressInfoDone()
/trunk/Scribus/scribus/prefscontext.cpp
0,0 → 1,165
/***************************************************************************
* Copyright (C) 2004 by Riku Leino *
* tsoots@welho.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
 
#include "prefscontext.h"
 
PrefsContext::PrefsContext()
{
name = "";
ispersistent = false;
isplugin = false;
}
 
PrefsContext::PrefsContext(QString contextName, bool persistent, bool plugin)
{
name = contextName;
ispersistent = persistent;
isplugin = plugin;
}
 
QString PrefsContext::getName()
{
return name;
}
 
bool PrefsContext::isPersistent()
{
return ispersistent;
}
 
bool PrefsContext::isPlugin()
{
return isplugin;
}
 
bool PrefsContext::isEmpty()
{
return (values.size() == 0 && tables.size() == 0);
}
 
bool PrefsContext::contains(const QString& key)
{
return values.contains(key);
}
 
bool PrefsContext::containsTable(const QString& key)
{
return tables.contains(key);
}
 
QString PrefsContext::get(const QString& key, const QString& defValue)
{
if (!values.contains(key))
values[key] = defValue;
 
return values[key];
}
 
void PrefsContext::set(const QString& key, const char* value)
{
set(key, QString(value));
}
 
void PrefsContext::set(const QString& key, const std::string& value)
{
set(key, QString(value.c_str()));
}
 
void PrefsContext::set(const QString& key, const QString& value)
{
values[key] = value;
}
 
int PrefsContext::getInt(const QString& key, int defValue)
{
if (!values.contains(key))
set(key, defValue);
QString stringValue = values[key];
bool ok = false;
int ivalue = stringValue.toInt(&ok);
if (!ok)
ivalue = defValue;
return ivalue;
}
 
uint PrefsContext::getUInt(const QString& key, uint defValue)
{
if (!values.contains(key))
set(key, QString("%1").arg(defValue));
QString stringValue = values[key];
bool ok = false;
int uivalue = stringValue.toUInt(&ok);
if (!ok)
uivalue = defValue;
return uivalue;
}
 
void PrefsContext::set(const QString& key, int value)
{
set(key, QString("%1").arg(value));
}
 
double PrefsContext::getDouble(const QString& key, double defValue)
{
if (!values.contains(key))
set(key, defValue);
QString stringValue = values[key];
bool ok = false;
double dvalue = stringValue.toDouble(&ok);
if (!ok)
dvalue = defValue;
return dvalue;
}
 
void PrefsContext::set(const QString& key, double value)
{
set(key, QString("%1").arg(value));
}
 
bool PrefsContext::getBool(const QString& key, bool defValue)
{
if (!values.contains(key))
set(key, defValue);
QString stringValue = values[key];
bool ok = false;
int ivalue = stringValue.toInt(&ok);
if (!ok)
ivalue = defValue;
return ivalue;
}
 
void PrefsContext::set(const QString& key, bool value)
{
set(key, QString("%1").arg(value));
}
 
PrefsTable* PrefsContext::getTable(const QString& name)
{
if (!tables.contains(name))
tables[name] = new PrefsTable(name);
return tables[name];
}
 
PrefsContext::~PrefsContext()
{
TableMap::Iterator it;
for (it = tables.begin(); it != tables.end(); ++it)
delete it.data();
}
Property changes:
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Index: Scribus/scribus/gtmeasure.cpp
===================================================================
--- Scribus/scribus/gtmeasure.cpp (revision 414)
+++ Scribus/scribus/gtmeasure.cpp (revision 415)
@@ -30,7 +30,7 @@
ratio = 1.0;
break;
case MM:
- ratio = 0.3527777;
+ ratio = 25.4/72;
break;
case IN:
ratio = 1.0 / 72.0;
@@ -61,7 +61,7 @@
return value * ratio;
}
-double gtMeasure::parse(QString value)
+double gtMeasure::parse(const QString& value)
{
QString lowerValue = value.lower();
QString dbl = "0.0";
@@ -119,7 +119,7 @@
return convert2(tmp);
}
-double gtMeasure::qs2d(QString value, Unit to)
+double gtMeasure::qs2d(const QString& value, Unit to)
{
double tmp = convert(parse(value));
init(to);
/trunk/Scribus/scribus/gtdialogs.h
31,11 → 31,13
#include <qlabel.h>
#include <qlayout.h>
#include <qobject.h>
#include <qpushbutton.h>
#include <qstring.h>
#include <qstringlist.h>
#include <qtextcodec.h>
#include <qtoolbutton.h>
#include <qtooltip.h>
#include "prefscontext.h"
 
class gtFileDialog : public QFileDialog
{
49,7 → 51,7
QToolButton* HomeB;
void createWidgets(const QStringList& importers);
public:
gtFileDialog(const QString& filters, const QStringList& importers);
gtFileDialog(const QString& filters, const QStringList& importers, const QString& wdir);
~gtFileDialog();
QCheckBox* textOnlyCheckBox;
QComboBox* importerCombo;
58,6 → 60,20
void slotHome();
};
 
class gtImporterDialog : public QDialog
{
Q_OBJECT
private:
QComboBox* importerCombo;
QCheckBox* rememberCheck;
QPushButton* okButton;
public:
gtImporterDialog(const QStringList& importers, int currentSelection);
~gtImporterDialog();
bool shouldRemember();
QString getImporter();
};
 
class gtDialogs
{
private:
65,6 → 81,8
QString fileName;
QString encoding;
int importer;
PrefsContext* prefs;
QString pwd;
public:
gtDialogs();
~gtDialogs();
/trunk/Scribus/scribus/mergedoc.cpp
11,6 → 11,7
#include "mergedoc.moc"
#include "customfdialog.h"
#include "scribusXml.h"
#include "prefsfile.h"
 
#if (_MSC_VER >= 1200)
#include "win-config.h"
21,6 → 22,7
#include <qcursor.h>
 
extern QPixmap loadIcon(QString nam);
extern PrefsFile* prefsFile;
 
MergeDoc::MergeDoc( QWidget* parent, bool Mpages, int targetDocPageCount, int activePage ) :
QDialog( parent, "merge", true, 0 )
126,10 → 128,12
int dummy;
bool ret = false;
Count = 0;
PrefsContext* dirs = prefsFile->getContext("dirs");
QString wdir = dirs->get("merge", ".");
#ifdef HAVE_LIBZ
CustomFDialog dia(this, tr("Open"), tr("Documents (*.sla *.sla.gz *.scd *.scd.gz);;All Files (*)"));
CustomFDialog dia(this, wdir, tr("Open"), tr("Documents (*.sla *.sla.gz *.scd *.scd.gz);;All Files (*)"));
#else
CustomFDialog dia(this, tr("Open"), tr("Documents (*.sla *.scd);;All Files (*)"));
CustomFDialog dia(this, wdir, tr("Open"), tr("Documents (*.sla *.scd);;All Files (*)"));
#endif
if (Filename->text() != "")
dia.setSelection(Filename->text());
138,6 → 142,7
fn = dia.selectedFile();
if (!fn.isEmpty())
{
dirs->set("merge", fn.left(fn.findRev("/")));
qApp->setOverrideCursor(QCursor(waitCursor), true);
ScriXmlDoc *ss = new ScriXmlDoc();
if (Mpa)
/trunk/Scribus/scribus/druck.cpp
15,6 → 15,7
#include "config.h"
#endif
 
#include "prefsfile.h"
#include "customfdialog.h"
#include "cupsoptions.h"
#include <qtextstream.h>
31,6 → 32,7
 
extern bool loadText(QString nam, QString *Buffer);
extern QPixmap loadIcon(QString nam);
extern PrefsFile* prefsFile;
 
AdvOptions::AdvOptions(QWidget* parent, bool Hm, bool Vm, bool Ic, int ps, bool DoGcr) : QDialog( parent, "prin", true, 0 )
{
562,11 → 564,17
 
void Druck::SelFile()
{
CustomFDialog dia(this, tr("Save as"), tr("Postscript-Files (*.ps);;All Files (*)"), false, false);
PrefsContext* dirs = prefsFile->getContext("dirs");
QString wdir = dirs->get("druck", ".");
CustomFDialog dia(this, wdir, tr("Save as"), tr("Postscript-Files (*.ps);;All Files (*)"), false, false);
if (LineEdit1->text() != "")
dia.setSelection(LineEdit1->text());
if (dia.exec() == QDialog::Accepted)
LineEdit1->setText(dia.selectedFile());
{
QString selectedFile = dia.selectedFile();
dirs->set("druck", selectedFile.left(selectedFile.findRev("/")));
LineEdit1->setText(selectedFile);
}
}
 
void Druck::setMinMax(int min, int max, int cur)
/trunk/Scribus/scribus/Makefile.am
1,6 → 1,6
bin_PROGRAMS = scribus
 
scribus_SOURCES = art_kmisc.c art_render_misc.c art_render_pattern.c art_rgb.c art_rgb_affine_private.c art_rgb_svp.c art_rgba_affine.c gdk-pixbuf-xlib-drawable.c gdk-pixbuf-xlib-render.c gdk-pixbuf-xlib.c gdk-pixbuf-xlibrgb.c gradienteditor.cpp gtgettext.cpp gtdialogs.cpp gtstyle.cpp gtframestyle.cpp gtparagraphstyle.cpp gtfont.cpp gtwriter.cpp gtaction.cpp gtmeasure.cpp measurements.cpp tabruler.cpp insertTable.cpp pageselector.cpp shadebutton.cpp alignselect.cpp styleselect.cpp search.cpp tabmanager.cpp fparser.cpp autoform.cpp story.cpp vgradient.cpp scpainter.cpp fontcombo.cpp scpreview.cpp lineformats.cpp multiline.cpp splash.cpp mergedoc.cpp bookpalette.cpp rc4.c md5.c cupsoptions.cpp guidemanager.cpp scribuswin.cpp hyphenator.cpp hyphen.c hyask.cpp hnjalloc.c hysettings.cpp seiten.cpp fpointarray.cpp fpoint.cpp annota.cpp buttonicon.cpp javadocs.cpp selfield.cpp editor.cpp page.cpp layers.cpp polyprops.cpp mpalette.cpp werktoolb.cpp keymanager.cpp navigator.cpp annot.cpp bookmwin.cpp cmsprefs.cpp customfdialog.cpp picsearch.cpp picstatus.cpp newtemp.cpp applytemplate.cpp muster.cpp scfonts_ttf.cpp scrap.cpp scfonts.cpp frameedit.cpp spalette.cpp edit1format.cpp editformats.cpp druck.cpp colorchart.cpp util.cpp cmykcolor.cpp cmykfw.cpp scribusXml.cpp linecombo.cpp linkbutton.cpp helpbrowser.cpp mspinbox.cpp movepage.cpp delpages.cpp inspage.cpp pdfopts.cpp tree.cpp missing.cpp fontprefs.cpp fmitem.cpp align.cpp serializer.cpp reformdoc.cpp docinfo.cpp mdup.cpp cpalette.cpp dcolor.cpp query.cpp colorm.cpp vruler.cpp hruler.cpp pageback.cpp pageitem.cpp newfile.cpp scribusview.cpp scribusdoc.cpp scribus.cpp main.cpp
scribus_SOURCES = art_kmisc.c art_render_misc.c art_render_pattern.c art_rgb.c art_rgb_affine_private.c art_rgb_svp.c art_rgba_affine.c gdk-pixbuf-xlib-drawable.c gdk-pixbuf-xlib-render.c gdk-pixbuf-xlib.c gdk-pixbuf-xlibrgb.c gradienteditor.cpp gtgettext.cpp gtdialogs.cpp gtstyle.cpp gtframestyle.cpp gtparagraphstyle.cpp gtfont.cpp gtwriter.cpp gtaction.cpp gtmeasure.cpp prefsfile.cpp prefscontext.cpp prefsreader.cpp prefstable.cpp measurements.cpp tabruler.cpp insertTable.cpp pageselector.cpp shadebutton.cpp alignselect.cpp styleselect.cpp search.cpp tabmanager.cpp fparser.cpp autoform.cpp story.cpp vgradient.cpp scpainter.cpp fontcombo.cpp scpreview.cpp lineformats.cpp multiline.cpp splash.cpp mergedoc.cpp bookpalette.cpp rc4.c md5.c cupsoptions.cpp guidemanager.cpp scribuswin.cpp hyphenator.cpp hyphen.c hyask.cpp hnjalloc.c hysettings.cpp seiten.cpp fpointarray.cpp fpoint.cpp annota.cpp buttonicon.cpp javadocs.cpp selfield.cpp editor.cpp page.cpp layers.cpp polyprops.cpp mpalette.cpp werktoolb.cpp keymanager.cpp navigator.cpp annot.cpp bookmwin.cpp cmsprefs.cpp customfdialog.cpp picsearch.cpp picstatus.cpp newtemp.cpp applytemplate.cpp muster.cpp scfonts_ttf.cpp scrap.cpp scfonts.cpp frameedit.cpp spalette.cpp edit1format.cpp editformats.cpp druck.cpp colorchart.cpp util.cpp cmykcolor.cpp cmykfw.cpp scribusXml.cpp linecombo.cpp linkbutton.cpp helpbrowser.cpp mspinbox.cpp movepage.cpp delpages.cpp inspage.cpp pdfopts.cpp tree.cpp missing.cpp fontprefs.cpp fmitem.cpp align.cpp serializer.cpp reformdoc.cpp docinfo.cpp mdup.cpp cpalette.cpp dcolor.cpp query.cpp colorm.cpp vruler.cpp hruler.cpp pageback.cpp pageitem.cpp newfile.cpp scribusview.cpp scribusdoc.cpp scribus.cpp main.cpp
SOURCES = art_kmisc.c art_render_misc.c art_render_pattern.c art_rgb.c art_rgb_affine_private.c art_rgb_svp.c art_rgba_affine.c gdk-pixbuf-xlib-drawable.c gdk-pixbuf-xlib-render.c gdk-pixbuf-xlib.c gdk-pixbuf-xlibrgb.c gradienteditor.cpp gtgettext.cpp gtdialogs.cpp gtstyle.cpp gtframestyle.cpp gtparagraphstyle.cpp gtfont.cpp gtwriter.cpp gtaction.cpp gtmeasure.cpp measurements.cpp tabruler.cpp insertTable.cpp pageselector.cpp shadebutton.cpp alignselect.cpp styleselect.cpp search.cpp tabmanager.cpp fparser.cpp autoform.cpp story.cpp vgradient.cpp scpainter.cpp libpdf/pdflib.cpp libpostscript/pslib.cpp plugins/libchar/charselect.cpp libprefs/prefs.cpp libabout/about.cpp fontcombo.cpp scpreview.cpp lineformats.cpp multiline.cpp splash.cpp mergedoc.cpp bookpalette.cpp rc4.c md5.c cupsoptions.cpp guidemanager.cpp scribuswin.cpp hyphenator.cpp hyphen.c hyask.cpp hnjalloc.c hysettings.cpp seiten.cpp fpointarray.cpp fpoint.cpp annota.cpp buttonicon.cpp javadocs.cpp selfield.cpp editor.cpp page.cpp layers.cpp polyprops.cpp mpalette.cpp werktoolb.cpp keymanager.cpp navigator.cpp annot.cpp bookmwin.cpp cmsprefs.cpp customfdialog.cpp picsearch.cpp picstatus.cpp newtemp.cpp applytemplate.cpp muster.cpp scfonts_ttf.cpp scrap.cpp scfonts.cpp frameedit.cpp spalette.cpp edit1format.cpp editformats.cpp druck.cpp colorchart.cpp util.cpp cmykcolor.cpp cmykfw.cpp scribusXml.cpp linecombo.cpp linkbutton.cpp helpbrowser.cpp mspinbox.cpp movepage.cpp delpages.cpp inspage.cpp pdfopts.cpp tree.cpp missing.cpp fontprefs.cpp fmitem.cpp align.cpp serializer.cpp reformdoc.cpp docinfo.cpp mdup.cpp cpalette.cpp dcolor.cpp query.cpp colorm.cpp vruler.cpp hruler.cpp pageback.cpp pageitem.cpp newfile.cpp scribusview.cpp scribusdoc.cpp scribus.cpp main.cpp
INTERFACES =
TRANSLATIONS =
7,7 → 7,7
 
SUBDIRS = icons libabout libprefs plugins libpostscript libpdf profiles dicts templates qm
 
EXTRA_DIST = main.cpp scribus.cpp scribus.h scribusdoc.cpp scribusdoc.h scribusview.cpp scribusview.h newfile.h newfile.cpp pageitem.cpp pageitem.h pageback.cpp pageback.h hruler.cpp hruler.h vruler.cpp vruler.h colorm.cpp colorm.h query.cpp query.h dcolor.cpp dcolor.h cpalette.cpp cpalette.h mdup.cpp mdup.h docinfo.cpp docinfo.h reformdoc.cpp reformdoc.h serializer.cpp serializer.h align.cpp align.h fmitem.cpp fmitem.h fontprefs.cpp fontprefs.h missing.cpp missing.h tree.cpp tree.h pdfopts.cpp pdfopts.h inspage.cpp inspage.h delpages.cpp delpages.h movepage.cpp movepage.h mspinbox.cpp mspinbox.h helpbrowser.cpp helpbrowser.h icons5.h linkbutton.cpp linkbutton.h icons6.h linecombo.cpp linecombo.h scribusXml.cpp scribusXml.h cmykfw.cpp cmykfw.h cmykcolor.cpp cmykcolor.h util.cpp colorchart.cpp colorchart.h druck.cpp druck.h editformats.cpp editformats.h edit1format.cpp edit1format.h spalette.cpp spalette.h frameedit.cpp frameedit.h scfonts.cpp scfonts.h scrap.cpp scrap.h scfonts_ttf.cpp scfonts_ttf.h muster.cpp muster.h applytemplate.cpp applytemplate.h newtemp.cpp newtemp.h picstatus.cpp picstatus.h picsearch.cpp picsearch.h customfdialog.cpp customfdialog.h cmsprefs.cpp cmsprefs.h bookmwin.cpp bookmwin.h annot.cpp annot.h navigator.cpp navigator.h keymanager.cpp keymanager.h werktoolb.cpp werktoolb.h mpalette.h mpalette.cpp polyprops.cpp polyprops.h layers.cpp layers.h page.cpp page.h editor.cpp editor.h selfield.cpp selfield.h javadocs.cpp javadocs.h buttonicon.cpp buttonicon.h annota.cpp annota.h fpoint.cpp fpoint.h fpointarray.cpp fpointarray.h seiten.cpp seiten.h hysettings.cpp hysettings.h hnjalloc.c hnjalloc.h hyask.cpp hyask.h hyphen.c hyphen.h hyphenator.cpp hyphenator.h scribuswin.cpp scribuswin.h guidemanager.cpp guidemanager.h cupsoptions.cpp cupsoptions.h md5.c md5.h rc4.c rc4.h mergedoc.cpp mergedoc.h bookpalette.cpp bookpalette.h splash.h fontcombo.h scpainter.cpp scpainter.h vgradient.cpp vgradient.h story.cpp story.h autoform.cpp autoform.h fparser.cpp fparser.h tabmanager.cpp tabmanager.h search.cpp search.h styleselect.cpp styleselect.h alignselect.cpp alignselect.h shadebutton.cpp shadebutton.h pageselector.cpp gtaction.cpp gtaction.h gtwriter.cpp gtwriter.h gtfont.cpp gtfont.h gtdialogs.cpp gtdialogs.h gtstyle.cpp gtstyle.h gtframestyle.cpp gtframestyle.h gtparagraphstyle.cpp gtparagraphstyle.h gtmeasure.cpp gtmeasure.h gradienteditor.cpp gradienteditor.h pageselector.h insertTable.cpp insertTable.h art_kmisc.c art_kmisc.h art_render_misc.c art_render_misc.h art_render_pattern.c art_render_pattern.h art_rgb.c art_rgb.h art_rgb_affine_private.c art_rgb_affine_private.h art_rgb_svp.c art_rgb_svp.h art_rgba_affine.c art_rgba_affine.h gdk-pixbuf-xlib-drawable.c gdk-pixbuf-xlib-private.h gdk-pixbuf-xlib-render.c gdk-pixbuf-xlib.c gdk-pixbuf-xlib.h gdk-pixbuf-xlibrgb.c gdk-pixbuf-xlibrgb.h LoremIpsum.txt rgbscribus.txt rgbscribusgreys.txt rgbscribusgnome.txt rgbsvg.txt
EXTRA_DIST = main.cpp scribus.cpp scribus.h scribusdoc.cpp scribusdoc.h scribusview.cpp scribusview.h newfile.h newfile.cpp pageitem.cpp pageitem.h pageback.cpp pageback.h hruler.cpp hruler.h vruler.cpp vruler.h colorm.cpp colorm.h query.cpp query.h dcolor.cpp dcolor.h cpalette.cpp cpalette.h mdup.cpp mdup.h docinfo.cpp docinfo.h reformdoc.cpp reformdoc.h serializer.cpp serializer.h align.cpp align.h fmitem.cpp fmitem.h fontprefs.cpp fontprefs.h missing.cpp missing.h tree.cpp tree.h pdfopts.cpp pdfopts.h inspage.cpp inspage.h delpages.cpp delpages.h movepage.cpp movepage.h mspinbox.cpp mspinbox.h helpbrowser.cpp helpbrowser.h icons5.h linkbutton.cpp linkbutton.h icons6.h linecombo.cpp linecombo.h scribusXml.cpp scribusXml.h cmykfw.cpp cmykfw.h cmykcolor.cpp cmykcolor.h util.cpp colorchart.cpp colorchart.h druck.cpp druck.h editformats.cpp editformats.h edit1format.cpp edit1format.h spalette.cpp spalette.h frameedit.cpp frameedit.h scfonts.cpp scfonts.h scrap.cpp scrap.h scfonts_ttf.cpp scfonts_ttf.h muster.cpp muster.h applytemplate.cpp applytemplate.h newtemp.cpp newtemp.h picstatus.cpp picstatus.h picsearch.cpp picsearch.h customfdialog.cpp customfdialog.h cmsprefs.cpp cmsprefs.h bookmwin.cpp bookmwin.h annot.cpp annot.h navigator.cpp navigator.h keymanager.cpp keymanager.h werktoolb.cpp werktoolb.h mpalette.h mpalette.cpp polyprops.cpp polyprops.h layers.cpp layers.h page.cpp page.h editor.cpp editor.h selfield.cpp selfield.h javadocs.cpp javadocs.h buttonicon.cpp buttonicon.h annota.cpp annota.h fpoint.cpp fpoint.h fpointarray.cpp fpointarray.h seiten.cpp seiten.h hysettings.cpp hysettings.h hnjalloc.c hnjalloc.h hyask.cpp hyask.h hyphen.c hyphen.h hyphenator.cpp hyphenator.h scribuswin.cpp scribuswin.h guidemanager.cpp guidemanager.h cupsoptions.cpp cupsoptions.h md5.c md5.h rc4.c rc4.h mergedoc.cpp mergedoc.h bookpalette.cpp bookpalette.h splash.h fontcombo.h scpainter.cpp scpainter.h vgradient.cpp vgradient.h story.cpp story.h autoform.cpp autoform.h fparser.cpp fparser.h tabmanager.cpp tabmanager.h search.cpp search.h styleselect.cpp styleselect.h alignselect.cpp alignselect.h shadebutton.cpp shadebutton.h pageselector.cpp gtaction.cpp gtaction.h gtwriter.cpp gtwriter.h gtfont.cpp gtfont.h gtdialogs.cpp gtdialogs.h gtstyle.cpp gtstyle.h gtframestyle.cpp gtframestyle.h gtparagraphstyle.cpp gtparagraphstyle.h gtmeasure.cpp gtmeasure.h prefsfile.cpp prefsfile.h prefscontext.cpp prefscontext.h prefsreader.cpp prefsreader.h prefstable.cpp prefstable.h gradienteditor.cpp gradienteditor.h pageselector.h insertTable.cpp insertTable.h art_kmisc.c art_kmisc.h art_render_misc.c art_render_misc.h art_render_pattern.c art_render_pattern.h art_rgb.c art_rgb.h art_rgb_affine_private.c art_rgb_affine_private.h art_rgb_svp.c art_rgb_svp.h art_rgba_affine.c art_rgba_affine.h gdk-pixbuf-xlib-drawable.c gdk-pixbuf-xlib-private.h gdk-pixbuf-xlib-render.c gdk-pixbuf-xlib.c gdk-pixbuf-xlib.h gdk-pixbuf-xlibrgb.c gdk-pixbuf-xlibrgb.h LoremIpsum.txt rgbscribus.txt rgbscribusgreys.txt rgbscribusgnome.txt rgbsvg.txt
 
install-data-local:
$(mkinstalldirs) $(prefix)/share/scribus/samples/
123,6 → 123,12
$(mkinstalldirs) $(prefix)/include/scribus/
$(INSTALL_DATA) $(srcdir)/gtframestyle.h $(prefix)/include/scribus/gtframestyle.h
$(mkinstalldirs) $(prefix)/include/scribus/
$(INSTALL_DATA) $(srcdir)/prefsfile.h $(prefix)/include/scribus/prefsfile.h
$(mkinstalldirs) $(prefix)/include/scribus/
$(INSTALL_DATA) $(srcdir)/prefscontext.h $(prefix)/include/scribus/prefscontext.h
$(mkinstalldirs) $(prefix)/include/scribus/
$(INSTALL_DATA) $(srcdir)/prefstable.h $(prefix)/include/scribus/prefstable.h
$(mkinstalldirs) $(prefix)/include/scribus/
$(INSTALL_DATA) $(srcdir)/missing.h $(prefix)/include/scribus/missing.h
$(mkinstalldirs) $(prefix)/include/scribus/
$(INSTALL_DATA) $(srcdir)/gradienteditor.h $(prefix)/include/scribus/gradienteditor.h
184,6 → 190,9
-rm -f $(prefix)/include/scribus/pageselector.h
-rm -f $(prefix)/include/scribus/gtaction.h
-rm -f $(prefix)/include/scribus/gtmeasure.h
-rm -f $(prefix)/include/scribus/prefscontext.h
-rm -f $(prefix)/include/scribus/prefsfile.h
-rm -f $(prefix)/include/scribus/prefstable.h
-rm -f $(prefix)/include/scribus/missing.h
-rm -f $(prefix)/include/scribus/gradienteditor.h
 
/trunk/Scribus/scribus/libprefs/prefs.cpp
1217,7 → 1217,7
T6_Layout8_2->addWidget( T6_Slider2 );
T6_Layout9_2->addLayout( T6_Layout8_2 );
T6_Layout10->addLayout( T6_Layout9_2 );
T6_Konvex = new QCheckBox( tr( "Conve&x Polygon" ), ToolFrame6, "Konvex" );
T6_Konvex = new QCheckBox( tr( "Apply &Factor" ), ToolFrame6, "Konvex" );
T6_Konvex->setChecked(Vor->PolyS);
T6_Layout10->addWidget( T6_Konvex );
T6_Layout9 = new QHBoxLayout( 0, 0, 5, "Layout9");
1594,10 → 1594,10
QToolTip::add( T6_Ecken, tr( "Number of corners for polygons" ) );
QToolTip::add( T6_Faktor2, tr( "Degrees of rotation for polygons" ) );
QToolTip::add( T6_Slider2, tr( "Degrees of rotation for polygons" ) );
QToolTip::add( T6_Konvex, tr( "Polygons will be convex rather than concave" ) );
QToolTip::add( T6_Konvex, tr( "Apply Convex/Concave Factor to change shape of Polygons" ) );
QToolTip::add( T6_Preview, tr( "Sample Polygon" ) );
QToolTip::add( T6_Faktor, tr( "Change the angles at which lines of the polygon join" ) );
QToolTip::add( T6_Slider1, tr( "Change the angles at which lines of the polygon join" ) );
QToolTip::add( T6_Faktor, tr( "A negative value will make the polygon concave (or star shaped),\n a positive value will make it convex" ) );
QToolTip::add( T6_Slider1, tr( "A negative value will make the polygon concave (or star shaped),\n a positive value will make it convex" ) );
 
QToolTip::add( PreviewSize, tr( "Choose the size of the preview in the scrapbook palette" ) );
QToolTip::add( SaveAtQuit, tr( "Save the scrapbook contents everytime after a change" ) );
1615,6 → 1615,12
QToolTip::add( GimpName, tr( "Filesystem location for graphics editor" ) );
 
QToolTip::add( ClipMarg, tr( "Do not show objects outside the margins on the printed page or exported file" ) );
QToolTip::add( DoGCR, tr( "A way of switching off some of the gray shades which are composed\n"
"of cyan, yellow and magenta and using black instead.\n"
"UCR most affects parts of images which are neutral and/or dark tones\n"
"which are close to the gray. Use of this may improve printing some images\n"
"and some experimentation and testing is need on a case by case basis.\n"
"UCR reduces the possibility of over saturation with CMY inks." ) );
 
// signals and slots connections
connect( minColor, SIGNAL( clicked() ), this, SLOT( changeMicolor() ) );
/trunk/Scribus/scribus/page.cpp
5399,7 → 5399,7
{
Mpressed = true;
Dxp = Mxp;
Dyp = Mxp;
Dyp = Myp;
}
break;
case 2:
/trunk/Scribus/scribus/annot.cpp
17,9 → 17,11
#include <qdatetime.h>
#include <qimage.h>
#include <qpixmap.h>
#include "prefsfile.h"
 
extern QImage LoadPict(QString fn, bool *gray = 0);
extern QPixmap loadIcon(QString nam);
extern PrefsFile* prefsFile;
 
Annot::Annot(QWidget* parent, PageItem *it, int Seite, int b, int h, CListe Farben, ScribusView* vie)
: QDialog( parent, "AN", true, 0 )
34,6 → 36,7
view = vie;
MaxSeite = Seite;
QStringList tl;
dirs = prefsFile->getContext("dirs");
if ((item->AnActType == 2) || (item->AnActType == 7))
{
QString tm = item->AnAction;
1197,7 → 1200,8
void Annot::GetNIcon()
{
QString fileName;
CustomFDialog dia(this, tr("Open"),
QString wdir = dirs->get("icon", ".");
CustomFDialog dia(this, wdir, tr("Open"),
tr("Images (*.tif *.png *.jpg *.xpm);;Postscript (*.eps);;All Files (*)"), "", true);
if (dia.exec() == QDialog::Accepted)
fileName = dia.selectedFile();
1205,6 → 1209,7
return;
if (!fileName.isEmpty())
{
dirs->set("icon", fileName.left(fileName.findRev("/")));
QPixmap pmI1;
QImage im;
im = LoadPict(fileName);
1229,7 → 1234,8
void Annot::GetPIcon()
{
QString fileName;
CustomFDialog dia(this, tr("Open"),
QString wdir = dirs->get("icon", ".");
CustomFDialog dia(this, wdir, tr("Open"),
tr("Images (*.tif *.png *.jpg *.xpm);;Postscript (*.eps);;All Files (*)"), "", true);
if (dia.exec() == QDialog::Accepted)
fileName = dia.selectedFile();
1237,6 → 1243,7
return;
if (!fileName.isEmpty())
{
dirs->set("icon", fileName.left(fileName.findRev("/")));
QPixmap pmI1;
QImage im;
im = LoadPict(fileName);
1250,7 → 1257,8
void Annot::GetRIcon()
{
QString fileName;
CustomFDialog dia(this, tr("Open"),
QString wdir = dirs->get("icon", ".");
CustomFDialog dia(this, wdir, tr("Open"),
tr("Images (*.tif *.png *.jpg *.xpm);;Postscript (*.eps);;All Files (*)"), "", true);
if (dia.exec() == QDialog::Accepted)
fileName = dia.selectedFile();
1258,6 → 1266,7
return;
if (!fileName.isEmpty())
{
dirs->set("icon", fileName.left(fileName.findRev("/")));
QPixmap pmI1;
QImage im;
im = LoadPict(fileName);
2143,7 → 2152,8
void Annot::GetFile()
{
QString fn;
CustomFDialog dia(this, tr("Open"), tr("PDF Files (*.pdf);;All Files (*)"));
QString wdir = dirs->get("annot_getfile", ".");
CustomFDialog dia(this, wdir, tr("Open"), tr("PDF Files (*.pdf);;All Files (*)"));
if (Destfile->text() != "")
dia.setSelection(Destfile->text());
if (dia.exec() == QDialog::Accepted)
2151,6 → 2161,7
fn = dia.selectedFile();
if (!fn.isEmpty())
{
dirs->set("annot_getfile", fn.left(fn.findRev("/")));
Destfile->setText(fn);
SpinBox11->setValue(1);
SpinBox11->setMaxValue(1000);
/trunk/Scribus/scribus/prefstable.cpp
0,0 → 1,169
/***************************************************************************
* Copyright (C) 2004 by Riku Leino *
* tsoots@welho.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
 
#include "prefstable.h"
 
PrefsTable::PrefsTable(QString tableName)
{
name = tableName;
rowCount = 0;
colCount = 0;
}
 
QString PrefsTable::getName()
{
return name;
}
 
int PrefsTable::height()
{
return rowCount;
}
 
int PrefsTable::getRowCount()
{
return rowCount;
}
 
int PrefsTable::width()
{
return colCount;
}
 
int PrefsTable::getColCount()
{
return colCount;
}
 
QString PrefsTable::get(int row, int col, const QString& defValue)
{
checkSize(row, col, defValue);
if ((*table[row])[col] == "__NOT__SET__")
table[row]->insert(table[row]->at(col), defValue);
 
return (*table[row])[col];
}
 
void PrefsTable::set(int row, int col, const char* value)
{
set(row, col, QString(value));
}
 
void PrefsTable::set(int row, int col, const std::string& value)
{
set(row, col, QString(value.c_str()));
}
 
void PrefsTable::set(int row, int col, const QString& value)
{
checkSize(row, col, value);
table[row]->insert(table[row]->at(col), value);
}
 
int PrefsTable::getInt(int row, int col, int defValue)
{
QString stringValue = get(row, col, QString("%1").arg(defValue));
bool ok = false;
int ivalue = stringValue.toInt(&ok);
if (!ok)
ivalue = defValue;
return ivalue;
}
 
void PrefsTable::set(int row, int col, int value)
{
set(row, col, QString("%1").arg(value));
}
 
uint PrefsTable::getUInt(int row, int col, uint defValue)
{
QString stringValue = get(row, col, QString("%1").arg(defValue));
bool ok = false;
int uivalue = stringValue.toUInt(&ok);
if (!ok)
uivalue = defValue;
return uivalue;
}
 
double PrefsTable::getDouble(int row, int col, double defValue)
{
QString stringValue = get(row, col, QString("%1").arg(defValue));
bool ok = false;
double dvalue = stringValue.toDouble(&ok);
if (!ok)
dvalue = defValue;
return dvalue;
}
 
void PrefsTable::set(int row, int col, double value)
{
set(row, col, QString("%1").arg(value));
}
 
bool PrefsTable::getBool(int row, int col, bool defValue)
{
QString stringValue = get(row, col, QString("%1").arg(defValue));
bool ok = false;
int ivalue = stringValue.toInt(&ok);
if (!ok)
ivalue = defValue;
return ivalue;
}
 
void PrefsTable::set(int row, int col, bool value)
{
set(row, col, QString("%1").arg(value));
}
 
void PrefsTable::checkSize(int rowIndex, int colIndex, QString defValue)
{
checkHeight(rowIndex);
checkWidth(rowIndex, colIndex, defValue);
}
 
void PrefsTable::checkHeight(int rowIndex)
{
if (rowCount < (rowIndex + 1))
{
for (int i = 0; i < ((rowIndex + 1) - rowCount); ++i)
table.push_back(new QStringList());
rowCount = rowIndex + 1;
}
}
 
void PrefsTable::checkWidth(int rowIndex, int colIndex, QString defValue)
{
if (static_cast<int>(table[rowIndex]->size()) <= (colIndex + 1))
{
for (uint i = 0; i < ((colIndex + 1) - table[rowIndex]->size()); ++i)
{
if (i == colIndex - table[rowIndex]->size())
table[rowIndex]->push_back(defValue);
else
table[rowIndex]->push_back("__NOT__SET__");
}
colCount = colIndex + 1;
}
}
 
PrefsTable::~PrefsTable()
{
 
}
Property changes:
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Index: Scribus/scribus/customfdialog.h
===================================================================
--- Scribus/scribus/customfdialog.h (revision 414)
+++ Scribus/scribus/customfdialog.h (revision 415)
@@ -28,6 +28,7 @@
#include <qframe.h>
#include <qtoolbutton.h>
#include <qcombobox.h>
+#include <qstring.h>
/**
*@author Franz Schmid
*/
@@ -40,7 +41,6 @@
QPixmap pspm;
QPixmap pdfpm;
QPixmap txtpm;
-
public:
ImIconProvider(QWidget *pa);
~ImIconProvider() {};
@@ -63,8 +63,9 @@
{
Q_OBJECT
public:
- CustomFDialog(QWidget *pa, QString cap = "", QString filter = "", bool Pre = false, bool mod = true,
- bool comp = false, bool cod = false, bool dirOnly = false);
+ CustomFDialog(QWidget *pa, QString wDir, QString cap = "", QString filter = "",
+ bool Pre = false, bool mod = true, bool comp = false, bool cod = false,
+ bool dirOnly = false);
~CustomFDialog();
QDir cDir;
QCheckBox* SaveZip;
Index: Scribus/scribus/editformats.cpp
===================================================================
--- Scribus/scribus/editformats.cpp (revision 414)
+++ Scribus/scribus/editformats.cpp (revision 415)
@@ -3,8 +3,10 @@
#include "edit1format.h"
#include <qmessagebox.h>
#include "customfdialog.h"
+#include "prefsfile.h"
extern QPixmap loadIcon(QString nam);
+extern PrefsFile* prefsFile;
StilFormate::StilFormate( QWidget* parent, ScribusDoc *doc, preV *avail)
: QDialog( parent, "Formate", true, 0)
@@ -182,7 +184,7 @@
{
int exit=QMessageBox::warning(this,
tr("Warning"),
- tr("Do you really want do delete this Style?"),
+ tr("Do you really want to delete this Style?"),
tr("No"),
tr("Yes"),
0, 0, 0);
@@ -198,14 +200,18 @@
void StilFormate::loadStyles()
{
+ PrefsContext* dirs = prefsFile->getContext("dirs");
+ QString wdir = dirs->get("editformats", ".");
#ifdef HAVE_LIBZ
- CustomFDialog dia(this, tr("Open"), tr("Documents (*.sla *.sla.gz *.scd *.scd.gz);;All Files (*)"));
+ CustomFDialog dia(this, wdir, tr("Open"), tr("Documents (*.sla *.sla.gz *.scd *.scd.gz);;All Files (*)"));
#else
- CustomFDialog dia(this, tr("Open"), tr("Documents (*.sla *.scd);;All Files (*)"));
+ CustomFDialog dia(this, wdir, tr("Open"), tr("Documents (*.sla *.scd);;All Files (*)"));
#endif
if (dia.exec() == QDialog::Accepted)
{
- Docu->loadStylesFromFile(dia.selectedFile(), &TempVorl);
+ QString selectedFile = dia.selectedFile();
+ dirs->set("editformats", selectedFile.left(selectedFile.findRev("/")));
+ Docu->loadStylesFromFile(selectedFile, &TempVorl);
UpdateFList();
}
else
/trunk/Scribus/scribus/prefsfile.h
0,0 → 1,50
/***************************************************************************
* Copyright (C) 2004 by Riku Leino *
* tsoots@welho.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
 
#ifndef PREFSFILE_H
#define PREFSFILE_H
 
#include <qmap.h>
#include <qtextstream.h>
#include "prefscontext.h"
 
typedef QMap<QString, PrefsContext*> ContextMap;
 
class PrefsFile
{
private:
QString prefsFilePath;
ContextMap contexts;
ContextMap pluginContexts;
bool ioEnabled;
void load();
QString replaceIllegalChars(const QString& text);
void writeContexts(ContextMap* contextMap, QTextStream& stream);
public:
PrefsFile();
PrefsFile(const QString& pFilePath);
~PrefsFile();
bool contextExists();
PrefsContext* getContext(const QString& contextName, bool persistent = true);
PrefsContext* getPluginContext(const QString& contextName, bool persistent = true);
void write();
};
 
#endif // PREFSFILE_H
Property changes:
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Index: Scribus/scribus/editor.cpp
===================================================================
--- Scribus/scribus/editor.cpp (revision 414)
+++ Scribus/scribus/editor.cpp (revision 415)
@@ -1,11 +1,13 @@
#include "editor.h"
#include "editor.moc"
#include "selfield.h"
+#include "prefsfile.h"
#include <qfile.h>
#include <qtextstream.h>
#include <qfiledialog.h>
extern QPixmap loadIcon(QString nam);
+extern PrefsFile* prefsFile;
Editor::Editor( QWidget* parent, QString daten, ScribusView* vie)
: QDialog( parent, "editor", true, 0 )
@@ -13,9 +15,10 @@
setCaption( tr( "Editor" ) );
setIcon(loadIcon("AppIcon.png"));
view = vie;
- EditorLayout = new QVBoxLayout( this, 0, 0, "EditorLayout");
+ dirs = prefsFile->getContext("dirs");
+ EditorLayout = new QVBoxLayout( this, 0, 0, "EditorLayout");
EditTex = new QTextEdit( this, "EditTex" );
-
+
fmenu = new QPopupMenu();
fmenu->insertItem(loadIcon("DateiNeu16.png"), tr("&New"), EditTex, SLOT(clear()), CTRL+Key_N);
fmenu->insertItem(loadIcon("DateiOpen16.png"), tr("&Open..."), this, SLOT(OpenScript()));
@@ -56,9 +59,11 @@
void Editor::OpenScript()
{
- QString fileName = QFileDialog::getOpenFileName(0, tr("Javascripts (*.js);;All Files (*)"),this);
+ QString fileName = QFileDialog::getOpenFileName(dirs->get("editor_open", "."),
+ tr("Javascripts (*.js);;All Files (*)"),this);
if (!fileName.isEmpty())
{
+ dirs->set("editor_open", fileName.left(fileName.findRev("/")));
QFile file( fileName );
if ( file.open( IO_ReadOnly ) )
{
@@ -71,9 +76,10 @@
void Editor::SaveAs()
{
- QString fn = QFileDialog::getSaveFileName(0, tr("Javascripts (*.js);;All Files (*)"), this);
+ QString fn = QFileDialog::getSaveFileName(dirs->get("editor_save", "."), tr("Javascripts (*.js);;All Files (*)"), this);
if (!fn.isEmpty())
{
+ dirs->set("editor_save", fn.left(fn.findRev("/")));
QFile file( fn );
if ( file.open( IO_WriteOnly ) )
{
/trunk/Scribus/scribus/po/scribus.pl_PL.ts
25,11 → 25,11
</message>
<message>
<source>Programming:</source>
<translation>Programowanie:</translation>
<translation type="obsolete">Programowanie:</translation>
</message>
<message>
<source>Contributions from:</source>
<translation>Podziękowania:</translation>
<translation>Wkład w rozwój programu:</translation>
</message>
<message>
<source>Windows port:</source>
37,7 → 37,7
</message>
<message>
<source>Documentation:</source>
<translation>Dokumentacja:</translation>
<translation type="obsolete">Dokumentacja:</translation>
</message>
<message>
<source>Authors</source>
105,7 → 105,7
</message>
<message>
<source>English:</source>
<translation>Angielski:</translation>
<translation type="obsolete">Angielski:</translation>
</message>
<message>
<source>Welsh:</source>
137,15 → 137,15
</message>
<message>
<source>Homepage and online reference</source>
<translation>Strona domowa i dokumentacja</translation>
<translation type="obsolete">Strona domowa i dokumentacja</translation>
</message>
<message>
<source>Mailing list</source>
<translation>Lista dyskusyjna</translation>
<translation type="obsolete">Lista dyskusyjna</translation>
</message>
<message>
<source>Bugs and feature requests</source>
<translation>Błędy i życzenia zmian</translation>
<translation type="obsolete">Błędy i życzenia zmian</translation>
</message>
<message>
<source>Online</source>
193,6 → 193,38
<source>Swedish:</source>
<translation>Szwedzki:</translation>
</message>
<message>
<source>Development Team:</source>
<translation>Zespół tworzący program:</translation>
</message>
<message>
<source>Official Documentation:</source>
<translation>Oficjalna dokumentacja:</translation>
</message>
<message>
<source>Other Documentation:</source>
<translation>Inna dokumentacja:</translation>
</message>
<message>
<source>English (British):</source>
<translation>Angielski (Brytyjski):</translation>
</message>
<message>
<source>Homepage</source>
<translation>Strona domowa</translation>
</message>
<message>
<source>Online Reference</source>
<translation>Dokumentacja online</translation>
</message>
<message>
<source>Bugs and Feature Requests</source>
<translation>Błędy i propozycje zmian</translation>
</message>
<message>
<source>Mailing List</source>
<translation>Lista dyskusyjna</translation>
</message>
</context>
<context>
<name>AdvOptions</name>
9401,6 → 9433,18
<source>Apply &amp;Under Color Removal</source>
<translation>Zastosuj &amp;UCR (usuwanie koloru neutralnego)</translation>
</message>
<message>
<source>T&amp;emplates:</source>
<translation>Sza&amp;blony:</translation>
</message>
<message>
<source>Cha&amp;nge...</source>
<translation>Zmień&amp;...</translation>
</message>
<message>
<source>Additional Directory for Document Templates</source>
<translation>Dodatkowy katalog na szablony dokumentów</translation>
</message>
</context>
<context>
<name>QColorDialog</name>
10244,6 → 10288,14
Zewnętrzne dowiązania
</translation>
</message>
<message>
<source>Font %1 is broken, discarding it</source>
<translation>Czcionka %1 jest wadliwa i zostaje wyłączona</translation>
</message>
<message>
<source>OO.o Writer Documents</source>
<translation>Dokumenty w formacie programu OO.o Writer</translation>
</message>
</context>
<context>
<name>QTextEdit</name>
12992,6 → 13044,29
</message>
</context>
<context>
<name>SxwDialog</name>
<message>
<source>OO.o Writer Importer Options</source>
<translation>Ustawienia importu z OO.o Writera</translation>
</message>
<message>
<source>Update paragraph styles</source>
<translation>Aktualizuj style akapitów</translation>
</message>
<message>
<source>If there already exists a paragraph style with the same
name than current OO.o document&apos;s paragraph should the style
in Scribus be edited to match the one being imported
or left untouched</source>
<translation>Zmień właściwości istniejącego stylu akapitu w Scribusie,
jeśli w dokumencie OO.o Writera pojawi się styl o tej samej nazwie</translation>
</message>
<message>
<source>OK</source>
<translation>OK</translation>
</message>
</context>
<context>
<name>TabManager</name>
<message>
<source>Manage Tabulators</source>
/trunk/Scribus/scribus/gtdialogs.cpp
20,18 → 20,21
 
#include "gtdialogs.h"
#include "gtdialogs.moc"
#include "prefsfile.h"
#include <qlabel.h>
 
extern QPixmap loadIcon(QString nam);
extern QString DocDir;
extern PrefsFile* prefsFile;
 
/********* Class gtFileDialog ************************************************************************/
 
gtFileDialog::gtFileDialog(const QString& filters, const QStringList& importers) :
gtFileDialog::gtFileDialog(const QString& filters, const QStringList& importers, const QString& wdir) :
QFileDialog(QString::null, filters, 0, 0, true)
{
// setIcon(loadIcon("AppIcon.png"));
setCaption("Open");
dir = QDir();
dir = QDir(wdir);
setDir(dir);
setMode(QFileDialog::ExistingFile);
createWidgets(importers);
115,6 → 118,67
 
}
 
/********* Class gtImporterDialog*******************************************************************/
 
gtImporterDialog::gtImporterDialog(const QStringList& importers, int currentSelection)
{
setCaption(tr("Choose the importer to use"));
setIcon(loadIcon("AppIcon.png"));
 
QBoxLayout* layout = new QVBoxLayout(this);
 
QBoxLayout* llayout = new QHBoxLayout(0, 5, 5, "llayout");
QLabel* label = new QLabel(tr(""), this, "label");
label->setText(tr("Choose the importer to use"));
llayout->addWidget(label);
layout->addLayout(llayout);
 
QBoxLayout* ilayout = new QHBoxLayout(0, 5, 5, "dlayout2");
importerCombo = new QComboBox(0, this, "importerCombo2");
importerCombo->setMinimumSize(QSize(150, 0));
QToolTip::add(importerCombo, tr("Choose the importer to use"));
importerCombo->insertStringList(importers);
if (static_cast<int>(importers.count()) > currentSelection)
importerCombo->setCurrentItem(currentSelection);
else
importerCombo->setCurrentItem(0);
ilayout->addWidget(importerCombo);
layout->addLayout(ilayout);
 
QBoxLayout* dlayout = new QHBoxLayout(0, 5, 5, "dlayout2");
rememberCheck = new QCheckBox(tr("Remember association"), this, "rememberCheck");
rememberCheck->setChecked(false);
QToolTip::add(rememberCheck, tr("Remember the file extension - importer association\n"
"and do not ask again to select an importer for\n"
"files of this type."));
dlayout->addStretch(10);
dlayout->addWidget(rememberCheck);
layout->addLayout(dlayout);
 
QBoxLayout* blayout = new QHBoxLayout(0, 5, 5, "blayout2");
blayout->addStretch(10);
okButton = new QPushButton(tr("OK"), this, "okButton2");
blayout->addWidget(okButton);
layout->addLayout(blayout);
 
connect(okButton, SIGNAL(clicked()), this, SLOT(accept()));
}
 
bool gtImporterDialog::shouldRemember()
{
return rememberCheck->isChecked();
}
 
QString gtImporterDialog::getImporter()
{
return importerCombo->currentText();
}
 
gtImporterDialog::~gtImporterDialog()
{
 
}
 
/********* Class gtDialogs *************************************************************************/
 
gtDialogs::gtDialogs()
123,12 → 187,17
fileName = "";
encoding = "";
importer = -1;
prefs = prefsFile->getContext("gtDialogs");
pwd = QDir::currentDirPath();
}
 
bool gtDialogs::runFileDialog(const QString& filters, const QStringList& importers)
{
bool accepted = false;
fdia = new gtFileDialog(filters, importers);
PrefsContext* dirs = prefsFile->getContext("dirs");
QString dir = dirs->get("get_text", ".");
fdia = new gtFileDialog(filters, importers, dir);
if (fdia->exec() == QDialog::Accepted)
{
fileName = fdia->selectedFile();
136,23 → 205,71
accepted = true;
encoding = fdia->encodingCombo->currentText();
importer = fdia->importerCombo->currentItem() - 1;
dirs->set("get_text", fileName.left(fileName.findRev("/")));
}
QDir::setCurrent(pwd);
return accepted;
}
 
bool gtDialogs::runImporterDialog(const QStringList& importers)
{
bool ok;
QString res = QInputDialog::getItem(QObject::tr("Importer"),
QObject::tr("Choose the importer to use"),
importers, 0, false, &ok);
int curSel = prefs->getInt("curSel", 0);
QString extension = "";
QString shortName = fileName.right(fileName.length() - fileName.findRev("/") - 1);
if (shortName.find(".") == -1)
extension = ".no_extension";
else
extension = fileName.right(fileName.length() - fileName.findRev("."));
int extensionSel = prefs->getInt(extension, -1);
QString imp = prefs->get("remember"+extension, QString("false"));
QString res = "";
bool shouldRemember = false;
bool ok = false;
if (imp != "false")
{
res = imp;
if (importers.contains(res) > 0)
ok = true;
}
if (!ok)
{
if ((extensionSel > -1) && (extensionSel < static_cast<int>(importers.count())))
curSel = extensionSel;
else
curSel = 0;
gtImporterDialog* idia = new gtImporterDialog(importers, curSel);
if (idia->exec())
{
res = idia->getImporter();
shouldRemember = idia->shouldRemember();
delete idia;
ok = true;
}
}
 
if (ok)
{
QString fileExtension = "";
for (uint i = 0; i < importers.count(); ++i)
{
if (importers[i] == res)
{
importer = i;
prefs->set("curSel", static_cast<int>(i));
if (fileName.find(".") != -1)
{
if (shortName.find(".") == -1)
fileExtension = ".no_extension";
else
fileExtension = fileName.right(fileName.length() - fileName.findRev("."));
if (fileExtension != "")
{
prefs->set(fileExtension, static_cast<int>(i));
if (shouldRemember)
prefs->set("remember"+fileExtension, res);
}
}
break;
}
}
/trunk/Scribus/scribus/cupsoptions.h
25,6 → 25,7
#include <qcombobox.h>
#include <qptrlist.h>
#include <qmap.h>
#include "prefscontext.h"
 
/**
*@author Franz Schmid
36,7 → 37,7
 
public:
CupsOptions(QWidget* parent, QString Geraet);
~CupsOptions() {};
~CupsOptions();
QPushButton* PushButton1;
QPushButton* PushButton2;
QHeader *Header;
52,6 → 53,7
protected:
QVBoxLayout* CupsOptionsLayout;
QHBoxLayout* Layout2;
PrefsContext* prefs;
};
 
#endif
/trunk/Scribus/scribus/qm/scribus.pl.qm
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/Scribus/scribus/story.cpp
29,9 → 29,12
#include "customfdialog.h"
#include "search.h"
#include "scribus.h"
extern ScribusApp* ScApp;
#include "prefscontext.h"
#include "prefsfile.h"
 
extern PrefsFile* prefsFile;
extern QPixmap loadIcon(QString nam);
extern ScribusApp* ScApp;
 
SideBar::SideBar(QWidget *pa) : QLabel(pa)
{
2447,7 → 2450,9
EditorBar->setRepaint(false);
QString LoadEnc = "";
QString fileName = "";
CustomFDialog dia(this, tr("Open"), tr("Text Files (*.txt);;All Files(*)"), false, true, false, true);
PrefsContext* dirs = prefsFile->getContext("dirs");
QString wdir = dirs->get("story_load", ScApp->Prefs.DocDir);
CustomFDialog dia(this, wdir, tr("Open"), tr("Text Files (*.txt);;All Files(*)"), false, true, false, true);
if (dia.exec() != QDialog::Accepted)
return;
LoadEnc = dia.TxCodeM->currentText();
2454,6 → 2459,7
fileName = dia.selectedFile();
if (!fileName.isEmpty())
{
dirs->set("story_load", fileName.left(fileName.findRev("/")));
Serializer *ss = new Serializer(fileName);
if (ss->Read(LoadEnc))
{
2477,7 → 2483,9
{
QString LoadEnc = "";
QString fileName = "";
CustomFDialog dia(this, tr("Save as"), tr("Text Files (*.txt);;All Files(*)"), false, false, false, true);
PrefsContext* dirs = prefsFile->getContext("dirs");
QString wdir = dirs->get("story_save", ScApp->Prefs.DocDir);
CustomFDialog dia(this, wdir, tr("Save as"), tr("Text Files (*.txt);;All Files(*)"), false, false, false, true);
if (dia.exec() != QDialog::Accepted)
return;
LoadEnc = dia.TxCodeM->currentText();
2484,6 → 2492,7
fileName = dia.selectedFile();
if (!fileName.isEmpty())
{
dirs->set("story_save", fileName.left(fileName.findRev("/")));
Serializer *ss = new Serializer(fileName);
ss->Objekt = Editor->text();
ss->Write(LoadEnc);
/trunk/Scribus/scribus/scrap.cpp
16,9 → 16,11
#include <qcursor.h>
#include "query.h"
#include "scpreview.h"
#include "prefsfile.h"
extern QPixmap loadIcon(QString nam);
extern bool loadText(QString nam, QString *Buffer);
extern QString GetAttr(QDomElement *el, QString at, QString def="0");
extern PrefsFile* prefsFile;
 
/* The Scrapbook View Class
* inherited from QIconView */
233,9 → 235,12
 
void Biblio::SaveAs()
{
QString fn = QFileDialog::getSaveFileName(0, tr("Scrapbooks (*.scs);;All Files (*)"), this);
PrefsContext* dirs = prefsFile->getContext("dirs");
QString fn = QFileDialog::getSaveFileName(dirs->get("scrap_saveas", "."),
tr("Scrapbooks (*.scs);;All Files (*)"), this);
if (!fn.isEmpty())
{
dirs->set("scrap_saveas", fn.left(fn.findRev("/")));
BibWin->SaveContents(fn);
ScFilename = fn;
setCaption(fn);
247,9 → 252,12
void Biblio::Load()
{
Save();
QString fileName = QFileDialog::getOpenFileName(0, tr("Scrapbooks (*.scs);;All Files (*)"),this);
PrefsContext* dirs = prefsFile->getContext("dirs");
QString fileName = QFileDialog::getOpenFileName(dirs->get("scrap_load", "."),
tr("Scrapbooks (*.scs);;All Files (*)"),this);
if (!fileName.isEmpty())
{
dirs->set("scrap_load", fileName.left(fileName.findRev("/")));
BibWin->ReadContents(fileName);
ScFilename = fileName;
setCaption(fileName);
/trunk/Scribus/scribus/hysettings.cpp
13,10 → 13,10
setIcon(loadIcon("AppIcon.png"));
HySettingsLayout = new QVBoxLayout( this, 11, 6, "HySettingsLayout");
Layout3 = new QGridLayout( 0, 1, 1, 0, 6, "Layout3");
Verbose = new QCheckBox(tr("&Fully Automatic"), this, "Verbose");
Verbose = new QCheckBox(tr("&Hyphenation Suggestion"), this, "Verbose");
Layout3->addMultiCellWidget(Verbose, 0, 0, 0, 1);
Input = new QCheckBox(tr("Check &During Typing"), this, "inp");
Input = new QCheckBox(tr("Hyphenate Text Automatically &During Typing"), this, "inp");
Layout3->addMultiCellWidget(Input, 1, 1, 0, 1);
Language = new QComboBox( true, this, "Language" );
38,7 → 38,7
MaxCount = new QSpinBox( this, "MaxCount" );
MaxCount->setMinValue( 0 );
Text3 = new QLabel(MaxCount, tr("&Number of Hypenations allowed:"), this, "Text3");
Text3 = new QLabel(MaxCount, tr("Consecutive Hypenations &Allowed:"), this, "Text3");
Layout3->addWidget( Text3, 4, 0 );
Layout3->addWidget( MaxCount, 4, 1);
53,8 → 53,8
Layout1->addWidget( Cancel );
HySettingsLayout->addLayout( Layout1 );
QToolTip::add( Verbose, tr( "If you uncheck this you will get a dialog\neverytime a possible Hyphenation is found." ) );
QToolTip::add(Input, tr("Enables automatic checking of your text while typing."));
QToolTip::add( Verbose, tr( "A dialog box showing all possible hyphens for each word will show up when you use the Extras, Hyphenate Text option." ) );
QToolTip::add( Input, tr("Enables automatic hyphenation of your text while typing."));
QToolTip::add( WordLen, tr( "Length of the smallest word to be hyphenated." ) );
QToolTip::add( MaxCount, tr( "Maximum number of Hyphenations following each other.\nA value of 0 means unlimited hyphenations." ) );
connect(OK, SIGNAL(clicked()), this, SLOT(accept()));
/trunk/Scribus/scribus/muster.cpp
85,7 → 85,7
return;
int exit=QMessageBox::warning(this,
tr("Warning"),
tr("Do you really want do delete this Template?"),
tr("Do you really want to delete this Template?"),
tr("&No"),
tr("&Yes"),
0, QMessageBox::No, QMessageBox::Yes);
/trunk/Scribus/scribus/libabout/about.cpp
56,7 → 56,7
tabLayout1->addWidget( PixmapLabel1 );
BuildID = new QLabel( tab, "BB" );
BuildID->setAlignment(Qt::AlignCenter);
QString bu = tr("%1. %2 %3 ").arg("21").arg("September").arg("2004");
QString bu = tr("%1. %2 %3 ").arg("24").arg("September").arg("2004");
#ifdef HAVE_CMS
bu += "C";
#else
/trunk/Scribus/scribus/scribus.cpp
96,8 → 96,8
#include "tabmanager.h"
#include "search.h"
#include "fontcombo.h"
#include "prefsfile.h"
 
 
extern QPixmap loadIcon(QString nam);
extern bool overwrite(QWidget *parent, QString filename);
extern void CopyPageItem(struct CLBuf *Buffer, PageItem *b);
130,6 → 130,7
double UmReFaktor;
QString DocDir;
ScribusApp* ScApp;
PrefsFile* prefsFile;
 
ScribusApp::ScribusApp()
{} // ScribusApp::ScribusApp()
203,6 → 204,8
if (OldPi3.exists())
moveFile(OldPR3, Pff+"/scrap.scs");
}
prefsFile = new PrefsFile(QDir::convertSeparators(PrefsPfad + "/prefs.xml"));
dirs = prefsFile->getContext("dirs");
/** Erstelle Fontliste */
NoFonts = false;
BuFromApp = false;
1932,6 → 1935,8
}
}
SavePrefs();
prefsFile->write();
delete prefsFile;
if ((Prefs.SaveAtQ) && (ScBook->Changed == true))
{
if (ScBook->ScFilename.isEmpty())
1947,6 → 1952,8
else
{
SavePrefs();
prefsFile->write();
delete prefsFile;
if ((Prefs.SaveAtQ) && (ScBook->Changed == true))
{
if (ScBook->ScFilename.isEmpty())
2981,11 → 2988,18
bool ScribusApp::slotDocOpen()
{
bool ret = false;
PrefsContext* docContext = prefsFile->getContext("docdirs", false);
QString docDir = ".";
if (Prefs.DocDir != "")
docDir = docContext->get("docsopen", Prefs.DocDir);
else
docDir = docContext->get("docsopen", ".");
#ifdef HAVE_LIBZ
QString fileName = CFileDialog( tr("Open"), tr("Documents (*.sla *.sla.gz *.scd *.scd.gz);;All Files (*)"));
QString fileName = CFileDialog( docDir, tr("Open"), tr("Documents (*.sla *.sla.gz *.scd *.scd.gz);;All Files (*)"));
#else
QString fileName = CFileDialog( tr("Open"), tr("Documents (*.sla *.scd);;All Files (*)"));
QString fileName = CFileDialog( docDir, tr("Open"), tr("Documents (*.sla *.scd);;All Files (*)"));
#endif
docContext->set("docsopen", fileName.left(fileName.findRev("/")));
qApp->setOverrideCursor(QCursor(waitCursor), true);
ret = LadeDoc(fileName);
qApp->setOverrideCursor(QCursor(arrowCursor), true);
3493,9 → 3507,15
formats += "EPS (*.eps *.EPS);;PDF (*.pdf *.PDF);;" + tr("All Files (*)");
formatD += " *.eps *.EPS *.pdf *.PDF";
formatD += ");;"+formats;
QString fileName = CFileDialog( tr("Open"), formatD, "", true);
QString docDir = ".";
if (Prefs.DocDir != "")
docDir = dirs->get("images", Prefs.DocDir);
else
docDir = dirs->get("images", ".");
QString fileName = CFileDialog( docDir, tr("Open"), formatD, "", true);
if (!fileName.isEmpty())
{
dirs->set("images", fileName.left(fileName.findRev("/")));
b->EmProfile = "";
b->UseEmbedded = true;
b->IProfile = doc->CMSSettings.DefaultInputProfile;
3628,23 → 3648,34
{
bool ret = false;
QString fna;
PrefsContext* docContext = prefsFile->getContext("docdirs", false);
QString wdir = ".";
if (doc->hasName)
{
QFileInfo fi(doc->DocName);
wdir = fi.dirPath();
fna = fi.dirPath()+"/"+fi.baseName()+".sla";
}
else
{
QDir di = QDir();
fna = di.currentDirPath()+"/"+doc->DocName+".sla";
if (Prefs.DocDir != "")
wdir = docContext->get("save_as", Prefs.DocDir);
else
wdir = docContext->get("save_as", ".");
if (wdir.right(1) != "/")
fna = wdir + "/";
else
fna = wdir;
fna += doc->DocName + ".sla";
}
#ifdef HAVE_LIBZ
QString fn = CFileDialog( tr("Save as"), tr("Documents (*.sla *.sla.gz *.scd *scd.gz);;All Files (*)"), fna, false, false, true);
QString fn = CFileDialog( wdir, tr("Save as"), tr("Documents (*.sla *.sla.gz *.scd *scd.gz);;All Files (*)"), fna, false, false, true);
#else
QString fn = CFileDialog( tr("Save as"), tr("Documents (*.sla *.scd);;All Files (*)"), fna, false, false, false);
QString fn = CFileDialog( wdir, tr("Save as"), tr("Documents (*.sla *.scd);;All Files (*)"), fna, false, false, false);
#endif
if (!fn.isEmpty())
{
docContext->set("save_as", fn.left(fn.findRev("/")));
if ((fn.endsWith(".sla")) || (fn.endsWith(".sla.gz")))
fna = fn;
else
4391,9 → 4422,15
void ScribusApp::SaveText()
{
LoadEnc = "";
QString fn = CFileDialog( tr("Save as"), tr("Text Files (*.txt);;All Files(*)"), "", false, false, false, true);
QString wdir = ".";
if (Prefs.DocDir != "")
wdir = dirs->get("save_text", Prefs.DocDir);
else
wdir = dirs->get("save_text", ".");
QString fn = CFileDialog( wdir, tr("Save as"), tr("Text Files (*.txt);;All Files(*)"), "", false, false, false, true);
if (!fn.isEmpty())
{
dirs->set("save_text", fn.left(fn.findRev("/")));
Serializer *se = new Serializer(fn);
se->PutText(doc->ActPage->SelItem.at(0));
se->Write(LoadEnc);
7079,9 → 7116,15
QDir di = QDir();
fna = di.currentDirPath()+"/"+doc->DocName+".eps";
}
QString fn = CFileDialog( tr("Save as"), tr("EPS-Files (*.eps);;All Files (*)"), "", false, false);
QString wdir = ".";
if (Prefs.DocDir != "")
wdir = dirs->get("eps", Prefs.DocDir);
else
wdir = dirs->get("eps", ".");
QString fn = CFileDialog( wdir, tr("Save as"), tr("EPS-Files (*.eps);;All Files (*)"), "", false, false);
if (!fn.isEmpty())
{
dirs->set("eps", fn.left(fn.findRev("/")));
if (overwrite(this, fn))
{
if (!DoSaveAsEps(fn))
7651,10 → 7694,12
}
}
 
QString ScribusApp::CFileDialog(QString caption, QString filter, QString defNa, bool Pre, bool mod, bool comp, bool cod, bool onlyDirs, bool *docom, bool *doFont)
QString ScribusApp::CFileDialog(QString wDir, QString caption, QString filter, QString defNa,
bool Pre, bool mod, bool comp, bool cod, bool onlyDirs,
bool *docom, bool *doFont)
{
QString retval = "";
CustomFDialog *dia = new CustomFDialog(this, caption, filter, Pre, mod, comp, cod, onlyDirs);
CustomFDialog *dia = new CustomFDialog(this, wDir, caption, filter, Pre, mod, comp, cod, onlyDirs);
if (defNa != "")
dia->setSelection(defNa);
if (onlyDirs)
8737,11 → 8782,18
QString CurDirP = QDir::currentDirPath();
bool compressR = compress;
bool withFontsR = withFonts;
QString s = CFileDialog( tr("Choose a Directory"), "", "", false, false, false, false, true, &compressR, &withFontsR);
QString wdir = ".";
if (Prefs.DocDir != "")
wdir = dirs->get("collect", Prefs.DocDir);
else
wdir = dirs->get("collect", ".");
QString s = CFileDialog(wdir, tr("Choose a Directory"), "", "", false, false,
false, false, true, &compressR, &withFontsR);
if (s != "")
{
if(s.right(1) != "/")
s += "/";
dirs->set("collect", s.left(s.findRev("/",-2)));
QFileInfo fi = QFileInfo(s);
if (fi.exists())
{
/trunk/Scribus/scribus/annota.cpp
9,9 → 9,11
#include "annota.h"
#include "annota.moc"
#include "customfdialog.h"
#include "prefsfile.h"
#include <qstringlist.h>
 
extern QPixmap loadIcon(QString nam);
extern PrefsFile* prefsFile;
 
Annota::Annota(QWidget* parent, PageItem *it, int Seite, int b, int h, CListe Farben, ScribusView* vie)
: QDialog( parent, "AN", true, 0 )
325,7 → 327,9
void Annota::GetFile()
{
QString fn;
CustomFDialog dia(this, tr("Open"), tr("PDF-Documents (*.pdf);;All Files (*)"));
PrefsContext* dirs = prefsFile->getContext("dirs");
QString wdir = dirs->get("annot_getfile", ".");
CustomFDialog dia(this, wdir, tr("Open"), tr("PDF-Documents (*.pdf);;All Files (*)"));
if (Destfile->text() != "")
dia.setSelection(Destfile->text());
if (dia.exec() == QDialog::Accepted)
333,6 → 337,7
fn = dia.selectedFile();
if (!fn.isEmpty())
{
dirs->set("annot_getfile", fn.left(fn.findRev("/")));
Destfile->setText(fn);
SpinBox1->setValue(1);
SpinBox1->setMaxValue(1000);
/trunk/Scribus/scribus/annot.h
29,6 → 29,7
#include "pageitem.h"
#include "navigator.h"
#include "scribusview.h"
#include <prefscontext.h>
 
class Annot : public QDialog
{
307,6 → 308,7
QGridLayout* Layout14;
QGridLayout* Layout15;
QGridLayout* Layout16;
PrefsContext* dirs;
};
 
#endif // ANNOT_H
/trunk/Scribus/scribus/javadocs.cpp
100,7 → 100,7
{
int exit=QMessageBox::warning(this,
tr("Warning"),
tr("Do you really want do delete this Script?"),
tr("Do you really want to delete this Script?"),
tr("&No"),
tr("&Yes"),
0, 0, 0);
/trunk/Scribus/scribus/prefstable.h
0,0 → 1,63
/***************************************************************************
* Copyright (C) 2004 by Riku Leino *
* tsoots@welho.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
 
#ifndef PREFSTABLE_H
#define PREFSTABLE_H
 
#include <string>
#include <vector>
#include <qmap.h>
#include <qstring.h>
#include <qstringlist.h>
 
typedef std::vector<QStringList*> Table;
 
class PrefsTable
{
private:
QString name;
Table table;
int rowCount;
int colCount;
void checkSize(int rowIndex, int colIndex, QString defValue = "");
void checkHeight(int rowIndex);
void checkWidth(int rowIndex, int colIndex, QString defValue = "");
public:
PrefsTable(QString tableName);
~PrefsTable();
QString getName();
int height();
int getRowCount();
int width();
int getColCount();
QString get(int row, int col, const QString& defValue = "");
void set(int row, int col, const char* value);
void set(int row, int col, const std::string& value);
void set(int row, int col, const QString& value);
int getInt(int row, int col, int defValue = -1);
void set(int row, int col, int value);
uint getUInt(int row, int col, uint defValue = 0);
double getDouble(int row, int col, double defValue = -1.0);
void set(int row, int col, double value);
bool getBool(int row, int col, bool defValue = false);
void set(int row, int col, bool value);
};
 
#endif
Property changes:
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Index: Scribus/scribus/plugins/pixmapexport/dialog.cpp
===================================================================
--- Scribus/scribus/plugins/pixmapexport/dialog.cpp (revision 414)
+++ Scribus/scribus/plugins/pixmapexport/dialog.cpp (revision 415)
@@ -14,7 +14,10 @@
#include <qimage.h>
#include <qdir.h>
#include <qfiledialog.h>
+#include <prefsfile.h>
+extern PrefsFile* prefsFile;
+
/*
* Constructs a ExportForm as a child of 'parent', with the
* name 'name' and widget flags set to 'f'.
@@ -25,12 +28,13 @@
ExportForm::ExportForm(QWidget* parent, int size, int quality, QString type)
: QDialog(parent, "ExportForm", true, 0)
{
+ prefs = prefsFile->getPluginContext("pixmapexport");
ExportFormLayout = new QVBoxLayout( this, 10, 5, "ExportFormLayout");
layout1 = new QHBoxLayout( 0, 0, 5, "layout1");
TextLabel1 = new QLabel( this, "TextLabel1" );
layout1->addWidget( TextLabel1 );
OutputDirectory = new QLineEdit( this, "OutputDirectory" );
- OutputDirectory->setText(QDir::currentDirPath());
+ OutputDirectory->setText(prefs->get("wdir", QDir::currentDirPath()));
layout1->addWidget( OutputDirectory );
OutputDirectoryButton = new QPushButton( this, "OutputDirectoryButton" );
OutputDirectoryButton->setDefault( TRUE );
@@ -116,9 +120,13 @@
void ExportForm::OutputDirectoryButton_pressed()
{
- QString d = QFileDialog::getExistingDirectory(QDir::currentDirPath(), this, "d", tr("Choose a Export Directory"), true);
+ QString lastDir = prefs->get("wdir", ".");
+ QString d = QFileDialog::getExistingDirectory(lastDir, this, "d", tr("Choose a Export Directory"), true);
if (d.length()>0)
+ {
OutputDirectory->setText(d);
+ prefs->set("wdir", d);
+ }
}
void ExportForm::OkButton_pressed()
@@ -187,53 +195,23 @@
void ExportForm::readConfig()
{
- QString fname = QDir::convertSeparators(QDir::homeDirPath()+"/.scribus/scribus-pixmap-export2.rc");
- QString value;
- QFile f(fname);
- if (f.open(IO_ReadOnly))
- {
- // cfg exists
- QTextStream of(&f);
- of >> value;
- if (value && value.length()>0)
- SizeBox->setValue(value.toUInt());
- of >> value;
- if (value && value.length()>0)
- QualityBox->setValue(value.toUInt());
- of >> value;
- if (value && value.length()>0)
- {
- ButtonGroup1->setButton(value.toInt());
- if (value.toInt()==2)
- RangeVal->setEnabled(TRUE);
- else
- RangeVal->setEnabled(false);
- }
- of >> value;
- if (value && value.length()>0)
- BitmapType->setCurrentItem(value.toUInt());
- value = of.read().stripWhiteSpace();
- if (value && value.length()>0)
- RangeVal->setText(value);
- f.close();
- }
+ SizeBox->setValue(prefs->getUInt("SizeBox", 72));
+ QualityBox->setValue(prefs->getUInt("QualityBox", 100));
+ ButtonGroup1->setButton(prefs->getUInt("ButtonGroup1", 0));
+ if (prefs->getInt("ButtonGroup1")==2)
+ RangeVal->setEnabled(TRUE);
+ else
+ RangeVal->setEnabled(false);
+ BitmapType->setCurrentItem(prefs->getInt("BitmapType", 4));
+ RangeVal->setText(prefs->get("RangeVal", ""));
}
void ExportForm::writeConfig()
{
- QString fname = QDir::convertSeparators(
- QDir::homeDirPath()+"/.scribus/scribus-pixmap-export2.rc");
- QString value;
- QFile f(fname);
- if (f.open(IO_WriteOnly))
- {
- // cfg exists
- QTextStream of(&f);
- of << SizeBox->value() << endl;
- of << QualityBox->value() << endl;
- of << ButtonGroup1->id(ButtonGroup1->selected()) << endl;
- of << BitmapType->currentItem() << endl;
- of << RangeVal->text() << endl;
- f.close();
- }
+ prefs->set("SizeBox", SizeBox->value());
+ prefs->set("QualityBox", QualityBox->value());
+ prefs->set("ButtonGroup1", ButtonGroup1->id(ButtonGroup1->selected()));
+ prefs->set("BitmapType",BitmapType->currentItem());
+ prefs->set("RangeVal", RangeVal->text());
+
}
/trunk/Scribus/scribus/plugins/pixmapexport/dialog.h
4,6 → 4,7
#include <qvariant.h>
#include <qdialog.h>
#include <qradiobutton.h>
#include <prefscontext.h>
 
class QVBoxLayout;
class QHBoxLayout;
59,6 → 60,7
QVBoxLayout* ButtonGroup1Layout;
QHBoxLayout* layout2;
QHBoxLayout* layout4;
PrefsContext* prefs;
 
protected slots:
virtual void languageChange();
/trunk/Scribus/scribus/plugins/scriptplugin/cmddialog.cpp
28,7 → 28,7
PyErr_SetString(PyExc_Exception, ERRPARAM + QString("FileDialog(caption, filter, defaultname, pre, mode)"));
return NULL;
}
return PyString_FromString(Carrier->CFileDialog(caption, filter, defName, static_cast<bool>(pre), static_cast<bool>(mode), 0, 0));
return PyString_FromString(Carrier->CFileDialog(".", caption, filter, defName, static_cast<bool>(pre), static_cast<bool>(mode), 0, 0));
}
 
PyObject *scribus_mess(PyObject *self, PyObject* args)
/trunk/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp
150,9 → 150,10
{
QString fileName;
QString CurDirP = QDir::currentDirPath();
if (Carrier->Prefs.ScriptDir != "")
QDir::setCurrent(Carrier->Prefs.ScriptDir);
CustomFDialog diaf((QWidget*)parent(), QObject::tr("Open"), QObject::tr("Python Scripts (*.py);; All Files (*)"));
QString scriptDir = Carrier->Prefs.ScriptDir;
if (scriptDir == "")
scriptDir = CurDirP;
CustomFDialog diaf((QWidget*)parent(), scriptDir, QObject::tr("Open"), QObject::tr("Python Scripts (*.py);; All Files (*)"));
if (diaf.exec())
{
fileName = diaf.selectedFile();
/trunk/Scribus/scribus/plugins/gettext/csvim/csvim.cpp
160,7 → 160,7
data += "\t" + tmp.stripWhiteSpace();
++colIndex;
}
else if (end == line.length() - 1)
else if (end == static_cast<int>(line.length()) - 1)
{
QString tmp = line.mid(start, end - 1);
if (isHeader)
/trunk/Scribus/scribus/plugins/gettext/sxwim/sxwdia.cpp
7,7 → 7,7
 
extern QPixmap loadIcon(QString nam);
 
SxwDialog::SxwDialog(bool update) : QDialog(0, "sxwdia", true, 0)
SxwDialog::SxwDialog(bool update, bool prefix) : QDialog(0, "sxwdia", true, 0)
{
setCaption(tr("OO.o Writer Importer Options"));
setIcon(loadIcon("AppIcon.png"));
24,16 → 24,24
hlayout->addWidget(updateCheck);
layout->addLayout(hlayout);
 
// QBoxLayout* dlayout = new QHBoxLayout(0, 5, 5, "dlayout");
// doNotAskCheck = new QCheckBox(tr("Do not ask again"), this, "doNotAskCheck");
// doNotAskCheck->setChecked(false);
// QToolTip::add(doNotAskCheck, tr("Should the importer always use currently\n"
// "set value when importing OO.o document and\n"
// "never ask your confirmation again"));
// dlayout->addStretch(10);
// dlayout->addWidget(doNotAskCheck);
// layout->addLayout(dlayout);
QBoxLayout* playout = new QHBoxLayout(0, 5, 5, "playout");
prefixCheck = new QCheckBox(tr("Use document name as a prefix for paragraph styles"), this, "prefixCheck");
prefixCheck->setChecked(prefix);
QToolTip::add(prefixCheck, tr("Should importer add the name of the document\n"
"on front of the paragraph style name in Scirubs"));
playout->addWidget(prefixCheck);
layout->addLayout(playout);
 
QBoxLayout* dlayout = new QHBoxLayout(0, 5, 5, "dlayout");
doNotAskCheck = new QCheckBox(tr("Do not ask again"), this, "doNotAskCheck");
doNotAskCheck->setChecked(false);
QToolTip::add(doNotAskCheck, tr("Should the importer always use currently\n"
"set value when importing OO.o document and\n"
"never ask your confirmation again"));
dlayout->addStretch(10);
dlayout->addWidget(doNotAskCheck);
layout->addLayout(dlayout);
 
QBoxLayout* blayout = new QHBoxLayout(0, 5, 5, "blayout");
blayout->addStretch(10);
okButton = new QPushButton(tr("OK"), this, "okButton");
48,6 → 56,11
return updateCheck->isChecked();
}
 
bool SxwDialog::usePrefix()
{
return prefixCheck->isChecked();
}
 
bool SxwDialog::askAgain()
{
return !(doNotAskCheck->isChecked());
/trunk/Scribus/scribus/plugins/gettext/sxwim/contentreader.h
27,7 → 27,11
 
#include <utility>
#include <vector>
#include <libxml/SAX2.h>
#ifdef HAVE_XML26
#include <libxml/SAX2.h>
#else
#include <libxml/SAX.h>
#endif
#include <qxml.h>
#include <qmap.h>
#include <gtstyle.h>
/trunk/Scribus/scribus/plugins/gettext/sxwim/sxwdia.h
19,12 → 19,14
Q_OBJECT
 
public:
SxwDialog(bool update);
SxwDialog(bool update, bool prefix);
~SxwDialog();
bool shouldUpdate();
bool usePrefix();
bool askAgain();
private:
QCheckBox* updateCheck;
QCheckBox* prefixCheck;
QCheckBox* doNotAskCheck;
QPushButton* okButton;
};
/trunk/Scribus/scribus/plugins/gettext/sxwim/sxwunzip.cpp
83,6 → 83,7
 
int do_extract_onefile(unzFile uf, const char* filename, int opt_extract_without_path, int opt_overwrite, const char* password)
{
// int err = UNZ_OK;
if (unzLocateFile(uf,filename,CASESENSITIVITY)!=UNZ_OK)
return 2;
 
/trunk/Scribus/scribus/plugins/gettext/sxwim/sxwim.cpp
23,13 → 23,15
 
#ifdef HAVE_XML
 
// #include <prefscontext.h>
#include <prefsfile.h>
#include <prefscontext.h>
#include <prefstable.h>
#include "sxwunzip.h"
#include "stylereader.h"
#include "contentreader.h"
#include "sxwdia.h"
 
extern ScribusApp* ScApp;
extern PrefsFile* prefsFile;
 
QString FileFormatName()
{
51,21 → 53,23
 
SxwIm::SxwIm(QString fileName, gtWriter* w, bool textOnly)
{
bool update = true;
PrefsContext* prefs = prefsFile->getPluginContext("SxwIm");
bool update = prefs->getBool("update", true);
bool prefix = prefs->getBool("prefix", true);
bool ask = prefs->getBool("askAgain", true);
if (!textOnly)
{
// PrefsContext* prefs = ScApp->prefs->getPluginContext("SxwIm");
// update = prefs->getBool("update", false);
// bool ask = prefs->getBool("askAgain", true);
// if (ask)
// {
SxwDialog* sxwdia = new SxwDialog(update);
if (ask)
{
SxwDialog* sxwdia = new SxwDialog(update, prefix);
sxwdia->exec();
update = sxwdia->shouldUpdate();
// prefs->set("update", update);
// prefs->set("askAgain", sxwdia->askAgain());
prefix = sxwdia->usePrefix();
prefs->set("update", update);
prefs->set("prefix", sxwdia->usePrefix());
prefs->set("askAgain", sxwdia->askAgain());
delete sxwdia;
// }
}
}
filename = fileName;
writer = w;
78,7 → 82,7
{
QString docname = filename.right(filename.length() - filename.findRev("/") - 1);
docname = docname.left(docname.findRev("."));
StyleReader *sreader = new StyleReader(docname, writer, textOnly);
StyleReader *sreader = new StyleReader(docname, writer, textOnly, prefix);
sreader->parse(stylePath);
ContentReader *creader = new ContentReader(docname, sreader, writer, textOnly);
creader->parse(contentPath);
/trunk/Scribus/scribus/plugins/gettext/sxwim/stylereader.cpp
1,724 → 1,726
/***************************************************************************
* Copyright (C) 2004 by Riku Leino *
* tsoots@welho.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
 
#include "stylereader.h"
 
#ifdef HAVE_XML
 
#include <gtmeasure.h>
#include <gtparagraphstyle.h>
#include <gtframestyle.h>
#include <gtfont.h>
 
StyleReader* StyleReader::sreader = NULL;
 
extern xmlSAXHandlerPtr sSAXHandler;
 
StyleReader::StyleReader(QString documentName, gtWriter *w, bool textOnly)
/***************************************************************************
* Copyright (C) 2004 by Riku Leino *
* tsoots@welho.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "stylereader.h"
#ifdef HAVE_XML
#include <gtmeasure.h>
#include <gtparagraphstyle.h>
#include <gtframestyle.h>
#include <gtfont.h>
StyleReader* StyleReader::sreader = NULL;
extern xmlSAXHandlerPtr sSAXHandler;
StyleReader::StyleReader(QString documentName, gtWriter *w, bool textOnly, bool prefix)
{
sreader = this;
docname = documentName;
readProperties = false;
writer = w;
importTextOnly = textOnly;
currentStyle = NULL;
parentStyle = NULL;
inList = false;
currentList = "";
sreader = this;
docname = documentName;
readProperties = false;
writer = w;
importTextOnly = textOnly;
usePrefix = prefix;
currentStyle = NULL;
parentStyle = NULL;
inList = false;
currentList = "";
}
 
bool StyleReader::startElement(const QString&, const QString&, const QString &name, const QXmlAttributes &attrs)
{
if (name == "style:default-style")
defaultStyle(attrs);
else if (name == "style:properties")
styleProperties(attrs);
else if (name == "style:style")
{
styleStyle(attrs);
}
else if (name == "style:tab-stop")
tabStop(attrs);
else if (name == "text:list-style")
{
for (int i = 0; i < attrs.count(); ++i)
if (attrs.localName(i) == "style:name")
currentList = attrs.value(i);
inList = true;
}
else if (((name == "text:list-level-style-bullet") ||
(name == "text:list-level-style-number")) && (inList))
{
QString level = "";
for (int i = 0; i < attrs.count(); ++i)
{
if (attrs.localName(i) == "text:level")
{
gtStyle *plist;
if (attrs.value(i) == "1")
{
plist = listParents[currentList];
}
else
{
int level = (attrs.value(i)).toInt();
--level;
plist = styles[QString(currentList + "_%1").arg(level)];
}
gtParagraphStyle *pstyle;
if (plist == NULL)
plist = new gtStyle(*(styles["default-style"]));
 
if (plist->target() == "paragraph")
{
pstyle = dynamic_cast<gtParagraphStyle*>(plist);
gtParagraphStyle* tmp = new gtParagraphStyle(*pstyle);
currentStyle = tmp;
}
else
{
gtParagraphStyle* tmp = new gtParagraphStyle(*plist);
currentStyle = tmp;
}
currentStyle->setName(currentList + "_" + attrs.value(i));
}
}
readProperties = true;
}
else if ((name == "style:drop-cap") && (readProperties))
{
if (currentStyle->target() == "paragraph")
{
for (int i = 0; i < attrs.count(); ++i)
{
if (attrs.localName(i) == "style:lines")
{
bool ok = false;
QString sd = attrs.value(i);
int dh = sd.toInt(&ok);
if (ok)
{
gtParagraphStyle* s = dynamic_cast<gtParagraphStyle*>(currentStyle);
s->setDropCapHeight(dh);
s->setDropCap(true);
}
}
}
}
}
else if (name == "style:font-decl")
{
QString key = "";
QString family = "";
QString style = "";
for (int i = 0; i < attrs.count(); ++i)
{
if (attrs.localName(i) == "style:name")
key = attrs.value(i);
else if (attrs.localName(i) == "fo:font-family")
{
family = attrs.value(i);
family = family.remove("'");
}
else if (attrs.localName(i) == "style:font-style-name")
style += attrs.value(i) + " ";
}
QString name = family + " " + style;
name = name.simplifyWhiteSpace();
fonts[key] = name;
}
return true;
}
 
void StyleReader::defaultStyle(const QXmlAttributes& attrs)
{
currentStyle = NULL;
for (int i = 0; i < attrs.count(); ++i)
if (attrs.localName(i) == "style:family")
if (attrs.value(i) == "paragraph")
{
currentStyle = new gtStyle("default-style");
readProperties = true;
}
}
 
void StyleReader::styleProperties(const QXmlAttributes& attrs)
{
if ((currentStyle == NULL) || (!readProperties))
return;
gtParagraphStyle* pstyle = NULL;
if (currentStyle->target() == "paragraph")
pstyle = dynamic_cast<gtParagraphStyle*>(currentStyle);
else
pstyle = NULL;
QString align = NULL;
QString force = NULL;
for (int i = 0; i < attrs.count(); ++i)
{
if ((attrs.localName(i) == "style:font-name") && (!inList))
currentStyle->getFont()->setName(getFont(attrs.value(i)));
else if (attrs.localName(i) == "fo:font-size")
{
double size = 0;
double psize = 0;
if (parentStyle != NULL)
psize = static_cast<double>(parentStyle->getFont()->getSize());
else if (styles.contains("default-style"))
psize = static_cast<double>(styles["default-style"]->getFont()->getSize());
 
psize = psize / 10;
size = getSize(attrs.value(i), psize);
int nsize = static_cast<int>(size * 10);
currentStyle->getFont()->setSize(nsize);
if ((currentStyle->getName() == "default-style") && (pstyle != NULL))
pstyle->setLineSpacing(writer->getPreferredLineSpacing(nsize));
}
else if ((attrs.localName(i) == "fo:line-height") && (parentStyle != NULL))
{
gtParagraphStyle* ppstyle;
if (parentStyle->target() == "paragraph")
{
ppstyle = dynamic_cast<gtParagraphStyle*>(parentStyle);
pstyle->setLineSpacing(getSize(attrs.value(i), writer->getPreferredLineSpacing(currentStyle->getFont()->getSize())));
}
}
else if ((attrs.localName(i) == "fo:font-weight") && (attrs.value(i) == "bold"))
currentStyle->getFont()->setWeight(BOLD);
else if ((attrs.localName(i) == "fo:font-style") && (attrs.value(i) == "italic"))
currentStyle->getFont()->setSlant(ITALIC);
else if ((attrs.localName(i) == "style:text-underline") && (attrs.value(i) != "none"))
currentStyle->getFont()->toggleEffect(UNDERLINE);
else if ((attrs.localName(i) == "style:text-crossing-out") && (attrs.value(i) != "none"))
currentStyle->getFont()->toggleEffect(STRIKETHROUGH);
else if ((attrs.localName(i) == "fo:font-variant") && (attrs.value(i) == "small-caps"))
currentStyle->getFont()->toggleEffect(SMALL_CAPS);
else if ((attrs.localName(i) == "style:text-outline") && (attrs.value(i) == "true"))
{
currentStyle->getFont()->toggleEffect(OUTLINE);
currentStyle->getFont()->setStrokeColor("Black");
currentStyle->getFont()->setColor("White");
}
else if (attrs.localName(i) == "fo:letter-spacing")
currentStyle->getFont()->setKerning(getSize(attrs.value(i)));
else if (attrs.localName(i) == "style:text-scale")
currentStyle->getFont()->setHscale(static_cast<int>(getSize(attrs.value(i), -1.0)));
else if ((attrs.localName(i) == "style:text-position") &&
(((attrs.value(i)).find("sub") != -1) ||
(((attrs.value(i)).left(1) == "-") && ((attrs.value(i)).left(1) != "0"))))
currentStyle->getFont()->toggleEffect(SUBSCRIPT);
else if ((attrs.localName(i) == "style:text-position") &&
(((attrs.value(i)).find("super") != -1) ||
(((attrs.value(i)).left(1) != "-") && ((attrs.value(i)).left(1) != "0"))))
currentStyle->getFont()->toggleEffect(SUPERSCRIPT);
else if ((attrs.localName(i) == "fo:margin-top") && (pstyle != NULL))
pstyle->setSpaceAbove(getSize(attrs.value(i)));
else if ((attrs.localName(i) == "fo:margin-bottom") && (pstyle != NULL))
pstyle->setSpaceBelow(getSize(attrs.value(i)));
else if ((attrs.localName(i) == "fo:margin-left") && (pstyle != NULL))
{
if (inList)
pstyle->setIndent(pstyle->getIndent() + getSize(attrs.value(i)));
else
pstyle->setIndent(getSize(attrs.value(i)));
}
else if ((attrs.localName(i) == "text:space-before") && (pstyle != NULL))
{
if (inList)
pstyle->setIndent(pstyle->getIndent() + getSize(attrs.value(i)));
else
pstyle->setIndent(getSize(attrs.value(i)));
}
else if ((attrs.localName(i) == "fo:text-indent") && (pstyle != NULL))
pstyle->setFirstLineIndent(getSize(attrs.value(i)));
else if ((attrs.localName(i) == "fo:text-align") && (pstyle != NULL))
align = attrs.value(i);
else if ((attrs.localName(i) == "style:justify-single-word") && (pstyle != NULL))
force = attrs.value(i);
}
if (align != NULL)
{
if (align == "end")
pstyle->setAlignment(RIGHT);
else if (align == "center")
pstyle->setAlignment(CENTER);
else if (align == "justify")
{
if (force == "false")
pstyle->setAlignment(BLOCK);
else
pstyle->setAlignment(FORCED);
}
}
}
 
void StyleReader::styleStyle(const QXmlAttributes& attrs)
{
QString name = "";
QString listName = NULL;
bool isParaStyle = false;
bool create = true;
for (int i = 0; i < attrs.count(); ++i)
{
if (attrs.localName(i) == "style:family")
{
if (attrs.value(i) == "paragraph")
{
isParaStyle = true;
readProperties = true;
}
else if (attrs.value(i) == "text")
{
isParaStyle = false;
readProperties = true;
}
else
{
readProperties = false;
return;
}
}
else if (attrs.localName(i) == "style:name")
name = attrs.value(i);
else if (attrs.localName(i) == "style:parent-style-name")
{
if (styles.contains(attrs.value(i)))
parentStyle = styles[attrs.value(i)];
else
parentStyle = NULL;
}
else if (attrs.localName(i) == "style:list-style-name")
listName = attrs.value(i);
}
if ((parentStyle == NULL) && (styles.contains("default-style")))
parentStyle = styles["default-style"];
 
if (create)
{
if (parentStyle == NULL)
{
parentStyle = new gtStyle("tmp-parent");
}
if (isParaStyle)
{
gtParagraphStyle *tmpP;
if (parentStyle->target() == "paragraph")
{
tmpP = dynamic_cast<gtParagraphStyle*>(parentStyle);
gtParagraphStyle* tmp = new gtParagraphStyle(*tmpP);
// tmp->setAutoLineSpacing(true);
currentStyle = tmp;
}
else
{
gtParagraphStyle* tmp = new gtParagraphStyle(*parentStyle);
// tmp->setAutoLineSpacing(true);
currentStyle = tmp;
}
if (listName != NULL)
{
listParents[listName] = currentStyle;
}
}
else
currentStyle = new gtStyle(*parentStyle);
 
currentStyle->setName(name);
}
else
currentStyle = NULL;
}
 
void StyleReader::tabStop(const QXmlAttributes& attrs)
{
if (currentStyle->target() == "paragraph")
{
gtParagraphStyle* pstyle = dynamic_cast<gtParagraphStyle*>(currentStyle);
QString pos = NULL;
QString type = NULL;
for (int i = 0; i < attrs.count(); ++i)
{
if (attrs.localName(i) == "style:position")
pos = attrs.value(i);
else if (attrs.localName(i) == "style:type")
type = attrs.value(i);
}
if (pos != NULL)
{
if (type == NULL)
type = "left";
double posd = getSize(pos);
if (type == "left")
pstyle->setTabValue(posd, LEFT_T);
else if (type == "right")
pstyle->setTabValue(posd, RIGHT_T);
else if (type == "center")
pstyle->setTabValue(posd, CENTER_T);
else
pstyle->setTabValue(posd, CENTER_T);
}
}
}
 
bool StyleReader::endElement(const QString&, const QString&, const QString &name)
{
if ((name == "style:default-style") && (currentStyle != NULL) && (readProperties))
{
setStyle(currentStyle->getName(), currentStyle);
currentStyle = NULL;
parentStyle = NULL;
readProperties = false;
}
else if (((name == "style:style") ||
(name == "text:list-level-style-bullet") ||
(name == "text:list-level-style-number")) && (currentStyle != NULL))
{
setStyle(currentStyle->getName(), currentStyle);
currentStyle = NULL;
parentStyle = NULL;
readProperties = false;
}
else if (name == "text:list-style")
{
inList = false;
}
return true;
}
 
void StyleReader::parse(QString fileName)
{
xmlSAXParseFile(sSAXHandler, fileName.ascii(), XML_PARSE_RECOVER);
}
 
gtStyle* StyleReader::getStyle(const QString& name)
{
if (styles.contains(name))
{
gtStyle* tmp = styles[name];
QString tname = tmp->getName();
if (tname.find(docname) == -1)
tmp->setName(docname + "_" + tname);
return tmp;
}
else
return styles["default-style"];
}
 
void StyleReader::setStyle(const QString& name, gtStyle* style)
{
gtParagraphStyle *s;
QString tname = style->getName();
if (style->target() == "paragraph")
{
s = dynamic_cast<gtParagraphStyle*>(style);
QString nameByAttrs = QString("%1-").arg(s->getSpaceAbove());
nameByAttrs += QString("%1-").arg(s->getSpaceBelow());
nameByAttrs += QString("%1-").arg(s->getLineSpacing());
nameByAttrs += QString("%1-").arg(s->getIndent());
nameByAttrs += QString("%1-").arg(s->getFirstLineIndent());
nameByAttrs += QString("%1-").arg(s->getAlignment());
nameByAttrs += QString("%1-").arg(s->hasDropCap());
QValueList<double>* tmp = s->getTabValues();
for (uint i = 0; i < tmp->count(); ++i)
{
double td = (*tmp)[i];
nameByAttrs += QString("%1-").arg(td);
}
if (attrsStyles.contains(nameByAttrs))
{
tname = attrsStyles[nameByAttrs]->getName();
++pstyleCounts[nameByAttrs];
style->setName(tname);
}
else
{
attrsStyles[nameByAttrs] = style;
pstyleCounts[nameByAttrs] = 1;
tname = style->getName();
}
}
if (!styles.contains(name))
{
if (tname.find(docname) == -1)
style->setName(docname + "_" + tname);
styles[name] = style;
}
}
 
QString StyleReader::getFont(const QString& key)
{
if (fonts.contains(key))
return fonts[key];
else
return key;
}
 
void StyleReader::setupFrameStyle()
{
QString fstyleName = "";
int count = 0;
CounterMap::Iterator it;
for (it = pstyleCounts.begin(); it != pstyleCounts.end(); ++it)
{
if (it.data() > count)
{
count = it.data();
fstyleName = it.key();
}
}
gtFrameStyle* fstyle;
gtParagraphStyle* pstyle = dynamic_cast<gtParagraphStyle*>(attrsStyles[fstyleName]);
fstyle = new gtFrameStyle(*pstyle);
 
if (!importTextOnly)
writer->setFrameStyle(fstyle);
delete fstyle;
}
 
bool StyleReader::updateStyle(gtStyle* style, gtStyle* parent2Style, const QString& key, const QString& value)
{
gtParagraphStyle* pstyle = NULL;
if (style->target() == "paragraph")
pstyle = dynamic_cast<gtParagraphStyle*>(style);
else
pstyle = NULL;
QString align = NULL;
QString force = NULL;
 
if (key == "style:font-name")
style->getFont()->setName(getFont(value));
else if (key == "fo:font-size")
{
double size = 0;
double psize = 0;
if (parent2Style != NULL)
psize = static_cast<double>(parent2Style->getFont()->getSize());
else if (styles.contains("default-style"))
psize = static_cast<double>(styles["default-style"]->getFont()->getSize());
psize = psize / 10;
size = getSize(value, psize);
int nsize = static_cast<int>(size * 10);
style->getFont()->setSize(nsize);
if ((style->getName() == "default-style") && (pstyle != NULL))
pstyle->setLineSpacing(writer->getPreferredLineSpacing(nsize));
}
else if ((key == "fo:line-height") && (parent2Style != NULL))
{
gtParagraphStyle* ppstyle;
if (parent2Style->target() == "paragraph")
{
ppstyle = dynamic_cast<gtParagraphStyle*>(parent2Style);
pstyle->setLineSpacing(getSize(value, writer->getPreferredLineSpacing(style->getFont()->getSize())));
}
}
else if ((key == "fo:font-weight") && (value == "bold"))
style->getFont()->setWeight(BOLD);
else if ((key == "fo:font-style") && (value == "italic"))
style->getFont()->setSlant(ITALIC);
else if ((key == "style:text-underline") && (value != "none"))
style->getFont()->toggleEffect(UNDERLINE);
else if ((key == "style:text-crossing-out") && (value != "none"))
style->getFont()->toggleEffect(STRIKETHROUGH);
else if ((key == "fo:font-variant") && (value == "small-caps"))
style->getFont()->toggleEffect(SMALL_CAPS);
else if ((key == "style:text-outline") && (value == "true"))
{
style->getFont()->toggleEffect(OUTLINE);
style->getFont()->setStrokeColor("Black");
style->getFont()->setColor("White");
}
else if (key == "fo:letter-spacing")
style->getFont()->setKerning(getSize(value));
else if (key == "style:text-scale")
style->getFont()->setHscale(static_cast<int>(getSize(value, -1.0)));
else if ((key == "style:text-position") &&
(((value).find("sub") != -1) ||
(((value).left(1) == "-") && ((value).left(1) != "0"))))
style->getFont()->toggleEffect(SUBSCRIPT);
else if ((key == "style:text-position") &&
(((value).find("super") != -1) ||
(((value).left(1) != "-") && ((value).left(1) != "0"))))
style->getFont()->toggleEffect(SUPERSCRIPT);
else if ((key == "fo:margin-top") && (pstyle != NULL))
pstyle->setSpaceAbove(getSize(value));
else if ((key == "fo:margin-bottom") && (pstyle != NULL))
pstyle->setSpaceBelow(getSize(value));
else if ((key == "fo:margin-left") && (pstyle != NULL))
{
if (inList)
pstyle->setIndent(pstyle->getIndent() + getSize(value));
else
pstyle->setIndent(getSize(value));
}
else if ((key == "text:space-before") && (pstyle != NULL))
{
if (inList)
pstyle->setIndent(pstyle->getIndent() + getSize(value));
else
pstyle->setIndent(getSize(value));
}
else if ((key == "fo:text-indent") && (pstyle != NULL))
pstyle->setFirstLineIndent(getSize(value));
else if ((key == "fo:text-align") && (pstyle != NULL))
align = value;
else if ((key == "style:justify-single-word") && (pstyle != NULL))
force = value;
 
if (align != NULL)
{
if (align == "end")
pstyle->setAlignment(RIGHT);
else if (align == "center")
pstyle->setAlignment(CENTER);
else if (align == "justify")
{
if (force != "false")
pstyle->setAlignment(FORCED);
else
pstyle->setAlignment(BLOCK);
}
}
return true;
}
 
double StyleReader::getSize(QString s, double parentSize)
{
QString dbl = "0.0";
QString lowerValue = s.lower();
double ret = 0.0;
if (lowerValue.find("pt") != -1)
{
dbl = lowerValue.remove("pt");
ret = gtMeasure::d2d(dbl.toDouble(), PT);
}
else if (lowerValue.find("mm") != -1)
{
dbl = lowerValue.remove("mm");
ret = gtMeasure::d2d(dbl.toDouble(), MM);
}
else if (lowerValue.find("cm") != -1)
{
dbl = lowerValue.remove("cm");
ret = gtMeasure::d2d(dbl.toDouble() * 10, MM);
}
else if (lowerValue.find("in") != -1)
{
dbl = lowerValue.remove("inch");
dbl = lowerValue.remove("in");
ret = gtMeasure::d2d(dbl.toDouble(), IN);
}
else if (lowerValue.find("pi") != -1)
{
dbl = lowerValue.remove("pica");
dbl = lowerValue.remove("pi");
ret = gtMeasure::d2d(dbl.toDouble(), P);
}
else if (lowerValue.find("%") != -1)
{
dbl = lowerValue.remove("%");
double factor = dbl.toDouble();
if (parentSize != -1.0)
{
factor = factor / 100;
ret = factor * parentSize;
}
else
ret = factor;
}
return ret;
}
 
StyleReader::~StyleReader()
{
sreader = NULL;
StyleMap::Iterator it;
for (it = styles.begin(); it != styles.end(); ++it)
{
if (it.data())
{
delete it.data();
it.data() = NULL;
}
}
}
 
xmlSAXHandler sSAXHandlerStruct = {
NULL, // internalSubset,
NULL, // isStandalone,
NULL, // hasInternalSubset,
NULL, // hasExternalSubset,
NULL, // resolveEntity,
NULL, // getEntity,
NULL, // entityDecl,
NULL, // notationDecl,
NULL, // attributeDecl,
NULL, // elementDecl,
NULL, // unparsedEntityDecl,
NULL, // setDocumentLocator,
NULL, // startDocument,
NULL, // endDocument,
StyleReader::startElement,
StyleReader::endElement,
NULL, // reference,
NULL, // characters
NULL, // ignorableWhitespace,
NULL, // processingInstruction,
NULL, // comment,
NULL, // warning,
NULL, // error,
NULL, // fatalError,
NULL, // getParameterEntity,
NULL, // cdata,
NULL,
1
#ifdef HAVE_XML26
,
NULL,
NULL,
NULL,
NULL
#endif
};
 
xmlSAXHandlerPtr sSAXHandler = &sSAXHandlerStruct;
 
void StyleReader::startElement(void *user_data, const xmlChar * fullname, const xmlChar ** atts)
{
QString* name = new QString((const char*) fullname);
name = new QString(name->lower());
QXmlAttributes* attrs = new QXmlAttributes();
if (atts)
{
for(const xmlChar** cur = atts; cur && *cur; cur += 2)
attrs->append(QString((char*)*cur), NULL, QString((char*)*cur), QString((char*)*(cur + 1)));
}
sreader->startElement(NULL, NULL, *name, *attrs);
}
 
void StyleReader::endElement(void *user_data, const xmlChar * name)
{
QString *nname = new QString((const char*) name);
nname = new QString(nname->lower());
sreader->endElement(NULL, NULL, *nname);
}
 
#endif // HAVE_XML
 
bool StyleReader::startElement(const QString&, const QString&, const QString &name, const QXmlAttributes &attrs)
{
if (name == "style:default-style")
defaultStyle(attrs);
else if (name == "style:properties")
styleProperties(attrs);
else if (name == "style:style")
{
styleStyle(attrs);
}
else if (name == "style:tab-stop")
tabStop(attrs);
else if (name == "text:list-style")
{
for (int i = 0; i < attrs.count(); ++i)
if (attrs.localName(i) == "style:name")
currentList = attrs.value(i);
inList = true;
}
else if (((name == "text:list-level-style-bullet") ||
(name == "text:list-level-style-number")) && (inList))
{
QString level = "";
for (int i = 0; i < attrs.count(); ++i)
{
if (attrs.localName(i) == "text:level")
{
gtStyle *plist;
if (attrs.value(i) == "1")
{
plist = listParents[currentList];
}
else
{
int level = (attrs.value(i)).toInt();
--level;
plist = styles[QString(currentList + "_%1").arg(level)];
}
gtParagraphStyle *pstyle;
if (plist == NULL)
plist = new gtStyle(*(styles["default-style"]));
if (plist->target() == "paragraph")
{
pstyle = dynamic_cast<gtParagraphStyle*>(plist);
gtParagraphStyle* tmp = new gtParagraphStyle(*pstyle);
currentStyle = tmp;
}
else
{
gtParagraphStyle* tmp = new gtParagraphStyle(*plist);
currentStyle = tmp;
}
currentStyle->setName(currentList + "_" + attrs.value(i));
}
}
readProperties = true;
}
else if ((name == "style:drop-cap") && (readProperties))
{
if (currentStyle->target() == "paragraph")
{
for (int i = 0; i < attrs.count(); ++i)
{
if (attrs.localName(i) == "style:lines")
{
bool ok = false;
QString sd = attrs.value(i);
int dh = sd.toInt(&ok);
if (ok)
{
gtParagraphStyle* s = dynamic_cast<gtParagraphStyle*>(currentStyle);
s->setDropCapHeight(dh);
s->setDropCap(true);
}
}
}
}
}
else if (name == "style:font-decl")
{
QString key = "";
QString family = "";
QString style = "";
for (int i = 0; i < attrs.count(); ++i)
{
if (attrs.localName(i) == "style:name")
key = attrs.value(i);
else if (attrs.localName(i) == "fo:font-family")
{
family = attrs.value(i);
family = family.remove("'");
}
else if (attrs.localName(i) == "style:font-style-name")
style += attrs.value(i) + " ";
}
QString name = family + " " + style;
name = name.simplifyWhiteSpace();
fonts[key] = name;
}
return true;
}
void StyleReader::defaultStyle(const QXmlAttributes& attrs)
{
currentStyle = NULL;
for (int i = 0; i < attrs.count(); ++i)
if (attrs.localName(i) == "style:family")
if (attrs.value(i) == "paragraph")
{
currentStyle = new gtStyle("default-style");
readProperties = true;
}
}
void StyleReader::styleProperties(const QXmlAttributes& attrs)
{
if ((currentStyle == NULL) || (!readProperties))
return;
gtParagraphStyle* pstyle = NULL;
if (currentStyle->target() == "paragraph")
pstyle = dynamic_cast<gtParagraphStyle*>(currentStyle);
else
pstyle = NULL;
QString align = NULL;
QString force = NULL;
for (int i = 0; i < attrs.count(); ++i)
{
if ((attrs.localName(i) == "style:font-name") && (!inList))
currentStyle->getFont()->setName(getFont(attrs.value(i)));
else if (attrs.localName(i) == "fo:font-size")
{
double size = 0;
double psize = 0;
if (parentStyle != NULL)
psize = static_cast<double>(parentStyle->getFont()->getSize());
else if (styles.contains("default-style"))
psize = static_cast<double>(styles["default-style"]->getFont()->getSize());
psize = psize / 10;
size = getSize(attrs.value(i), psize);
int nsize = static_cast<int>(size * 10);
currentStyle->getFont()->setSize(nsize);
if ((currentStyle->getName() == "default-style") && (pstyle != NULL))
pstyle->setLineSpacing(writer->getPreferredLineSpacing(nsize));
}
else if ((attrs.localName(i) == "fo:line-height") && (parentStyle != NULL))
{
gtParagraphStyle* ppstyle;
if (parentStyle->target() == "paragraph")
{
ppstyle = dynamic_cast<gtParagraphStyle*>(parentStyle);
pstyle->setLineSpacing(getSize(attrs.value(i), writer->getPreferredLineSpacing(currentStyle->getFont()->getSize())));
}
}
else if ((attrs.localName(i) == "fo:font-weight") && (attrs.value(i) == "bold"))
currentStyle->getFont()->setWeight(BOLD);
else if ((attrs.localName(i) == "fo:font-style") && (attrs.value(i) == "italic"))
currentStyle->getFont()->setSlant(ITALIC);
else if ((attrs.localName(i) == "style:text-underline") && (attrs.value(i) != "none"))
currentStyle->getFont()->toggleEffect(UNDERLINE);
else if ((attrs.localName(i) == "style:text-crossing-out") && (attrs.value(i) != "none"))
currentStyle->getFont()->toggleEffect(STRIKETHROUGH);
else if ((attrs.localName(i) == "fo:font-variant") && (attrs.value(i) == "small-caps"))
currentStyle->getFont()->toggleEffect(SMALL_CAPS);
else if ((attrs.localName(i) == "style:text-outline") && (attrs.value(i) == "true"))
{
currentStyle->getFont()->toggleEffect(OUTLINE);
currentStyle->getFont()->setStrokeColor("Black");
currentStyle->getFont()->setColor("White");
}
else if (attrs.localName(i) == "fo:letter-spacing")
currentStyle->getFont()->setKerning(getSize(attrs.value(i)));
else if (attrs.localName(i) == "style:text-scale")
currentStyle->getFont()->setHscale(static_cast<int>(getSize(attrs.value(i), -1.0)));
else if ((attrs.localName(i) == "style:text-position") &&
(((attrs.value(i)).find("sub") != -1) ||
(((attrs.value(i)).left(1) == "-") && ((attrs.value(i)).left(1) != "0"))))
currentStyle->getFont()->toggleEffect(SUBSCRIPT);
else if ((attrs.localName(i) == "style:text-position") &&
(((attrs.value(i)).find("super") != -1) ||
(((attrs.value(i)).left(1) != "-") && ((attrs.value(i)).left(1) != "0"))))
currentStyle->getFont()->toggleEffect(SUPERSCRIPT);
else if ((attrs.localName(i) == "fo:margin-top") && (pstyle != NULL))
pstyle->setSpaceAbove(getSize(attrs.value(i)));
else if ((attrs.localName(i) == "fo:margin-bottom") && (pstyle != NULL))
pstyle->setSpaceBelow(getSize(attrs.value(i)));
else if ((attrs.localName(i) == "fo:margin-left") && (pstyle != NULL))
{
if (inList)
pstyle->setIndent(pstyle->getIndent() + getSize(attrs.value(i)));
else
pstyle->setIndent(getSize(attrs.value(i)));
}
else if ((attrs.localName(i) == "text:space-before") && (pstyle != NULL))
{
if (inList)
pstyle->setIndent(pstyle->getIndent() + getSize(attrs.value(i)));
else
pstyle->setIndent(getSize(attrs.value(i)));
}
else if ((attrs.localName(i) == "fo:text-indent") && (pstyle != NULL))
pstyle->setFirstLineIndent(getSize(attrs.value(i)));
else if ((attrs.localName(i) == "fo:text-align") && (pstyle != NULL))
align = attrs.value(i);
else if ((attrs.localName(i) == "style:justify-single-word") && (pstyle != NULL))
force = attrs.value(i);
}
if (align != NULL)
{
if (align == "end")
pstyle->setAlignment(RIGHT);
else if (align == "center")
pstyle->setAlignment(CENTER);
else if (align == "justify")
{
if (force == "false")
pstyle->setAlignment(BLOCK);
else
pstyle->setAlignment(FORCED);
}
}
}
void StyleReader::styleStyle(const QXmlAttributes& attrs)
{
QString name = "";
QString listName = NULL;
bool isParaStyle = false;
bool create = true;
for (int i = 0; i < attrs.count(); ++i)
{
if (attrs.localName(i) == "style:family")
{
if (attrs.value(i) == "paragraph")
{
isParaStyle = true;
readProperties = true;
}
else if (attrs.value(i) == "text")
{
isParaStyle = false;
readProperties = true;
}
else
{
readProperties = false;
return;
}
}
else if (attrs.localName(i) == "style:name")
name = attrs.value(i);
else if (attrs.localName(i) == "style:parent-style-name")
{
if (styles.contains(attrs.value(i)))
parentStyle = styles[attrs.value(i)];
else
parentStyle = NULL;
}
else if (attrs.localName(i) == "style:list-style-name")
listName = attrs.value(i);
}
if ((parentStyle == NULL) && (styles.contains("default-style")))
parentStyle = styles["default-style"];
if (create)
{
if (parentStyle == NULL)
{
parentStyle = new gtStyle("tmp-parent");
}
if (isParaStyle)
{
gtParagraphStyle *tmpP;
if (parentStyle->target() == "paragraph")
{
tmpP = dynamic_cast<gtParagraphStyle*>(parentStyle);
gtParagraphStyle* tmp = new gtParagraphStyle(*tmpP);
// tmp->setAutoLineSpacing(true);
currentStyle = tmp;
}
else
{
gtParagraphStyle* tmp = new gtParagraphStyle(*parentStyle);
// tmp->setAutoLineSpacing(true);
currentStyle = tmp;
}
if (listName != NULL)
{
listParents[listName] = currentStyle;
}
}
else
currentStyle = new gtStyle(*parentStyle);
currentStyle->setName(name);
}
else
currentStyle = NULL;
}
void StyleReader::tabStop(const QXmlAttributes& attrs)
{
if (currentStyle->target() == "paragraph")
{
gtParagraphStyle* pstyle = dynamic_cast<gtParagraphStyle*>(currentStyle);
QString pos = NULL;
QString type = NULL;
for (int i = 0; i < attrs.count(); ++i)
{
if (attrs.localName(i) == "style:position")
pos = attrs.value(i);
else if (attrs.localName(i) == "style:type")
type = attrs.value(i);
}
if (pos != NULL)
{
if (type == NULL)
type = "left";
double posd = getSize(pos);
if (type == "left")
pstyle->setTabValue(posd, LEFT_T);
else if (type == "right")
pstyle->setTabValue(posd, RIGHT_T);
else if (type == "center")
pstyle->setTabValue(posd, CENTER_T);
else
pstyle->setTabValue(posd, CENTER_T);
}
}
}
bool StyleReader::endElement(const QString&, const QString&, const QString &name)
{
if ((name == "style:default-style") && (currentStyle != NULL) && (readProperties))
{
setStyle(currentStyle->getName(), currentStyle);
currentStyle = NULL;
parentStyle = NULL;
readProperties = false;
}
else if (((name == "style:style") ||
(name == "text:list-level-style-bullet") ||
(name == "text:list-level-style-number")) && (currentStyle != NULL))
{
setStyle(currentStyle->getName(), currentStyle);
currentStyle = NULL;
parentStyle = NULL;
readProperties = false;
}
else if (name == "text:list-style")
{
inList = false;
}
return true;
}
void StyleReader::parse(QString fileName)
{
xmlSAXParseFile(sSAXHandler, fileName.ascii(), XML_PARSE_RECOVER);
}
gtStyle* StyleReader::getStyle(const QString& name)
{
if (styles.contains(name))
{
gtStyle* tmp = styles[name];
QString tname = tmp->getName();
if ((tname.find(docname) == -1) && (usePrefix))
tmp->setName(docname + "_" + tname);
return tmp;
}
else
return styles["default-style"];
}
void StyleReader::setStyle(const QString& name, gtStyle* style)
{
gtParagraphStyle *s;
QString tname = style->getName();
if (style->target() == "paragraph")
{
s = dynamic_cast<gtParagraphStyle*>(style);
QString nameByAttrs = QString("%1-").arg(s->getSpaceAbove());
nameByAttrs += QString("%1-").arg(s->getSpaceBelow());
nameByAttrs += QString("%1-").arg(s->getLineSpacing());
nameByAttrs += QString("%1-").arg(s->getIndent());
nameByAttrs += QString("%1-").arg(s->getFirstLineIndent());
nameByAttrs += QString("%1-").arg(s->getAlignment());
nameByAttrs += QString("%1-").arg(s->hasDropCap());
QValueList<double>* tmp = s->getTabValues();
for (uint i = 0; i < tmp->count(); ++i)
{
double td = (*tmp)[i];
nameByAttrs += QString("%1-").arg(td);
}
if (attrsStyles.contains(nameByAttrs))
{
tname = attrsStyles[nameByAttrs]->getName();
++pstyleCounts[nameByAttrs];
style->setName(tname);
}
else
{
attrsStyles[nameByAttrs] = style;
pstyleCounts[nameByAttrs] = 1;
tname = style->getName();
}
}
if (!styles.contains(name))
{
if ((tname.find(docname) == -1) && (usePrefix))
style->setName(docname + "_" + tname);
styles[name] = style;
}
}
QString StyleReader::getFont(const QString& key)
{
if (fonts.contains(key))
return fonts[key];
else
return key;
}
void StyleReader::setupFrameStyle()
{
QString fstyleName = "";
int count = 0;
CounterMap::Iterator it;
for (it = pstyleCounts.begin(); it != pstyleCounts.end(); ++it)
{
if (it.data() > count)
{
count = it.data();
fstyleName = it.key();
}
}
gtFrameStyle* fstyle;
gtParagraphStyle* pstyle = dynamic_cast<gtParagraphStyle*>(attrsStyles[fstyleName]);
fstyle = new gtFrameStyle(*pstyle);
if (!importTextOnly)
writer->setFrameStyle(fstyle);
delete fstyle;
}
bool StyleReader::updateStyle(gtStyle* style, gtStyle* parent2Style, const QString& key, const QString& value)
{
gtParagraphStyle* pstyle = NULL;
if (style->target() == "paragraph")
pstyle = dynamic_cast<gtParagraphStyle*>(style);
else
pstyle = NULL;
QString align = NULL;
QString force = NULL;
if (key == "style:font-name")
style->getFont()->setName(getFont(value));
else if (key == "fo:font-size")
{
double size = 0;
double psize = 0;
if (parent2Style != NULL)
psize = static_cast<double>(parent2Style->getFont()->getSize());
else if (styles.contains("default-style"))
psize = static_cast<double>(styles["default-style"]->getFont()->getSize());
psize = psize / 10;
size = getSize(value, psize);
int nsize = static_cast<int>(size * 10);
style->getFont()->setSize(nsize);
if ((style->getName() == "default-style") && (pstyle != NULL))
pstyle->setLineSpacing(writer->getPreferredLineSpacing(nsize));
}
else if ((key == "fo:line-height") && (parent2Style != NULL))
{
gtParagraphStyle* ppstyle;
if (parent2Style->target() == "paragraph")
{
ppstyle = dynamic_cast<gtParagraphStyle*>(parent2Style);
pstyle->setLineSpacing(getSize(value, writer->getPreferredLineSpacing(style->getFont()->getSize())));
}
}
else if ((key == "fo:font-weight") && (value == "bold"))
style->getFont()->setWeight(BOLD);
else if ((key == "fo:font-style") && (value == "italic"))
style->getFont()->setSlant(ITALIC);
else if ((key == "style:text-underline") && (value != "none"))
style->getFont()->toggleEffect(UNDERLINE);
else if ((key == "style:text-crossing-out") && (value != "none"))
style->getFont()->toggleEffect(STRIKETHROUGH);
else if ((key == "fo:font-variant") && (value == "small-caps"))
style->getFont()->toggleEffect(SMALL_CAPS);
else if ((key == "style:text-outline") && (value == "true"))
{
style->getFont()->toggleEffect(OUTLINE);
style->getFont()->setStrokeColor("Black");
style->getFont()->setColor("White");
}
else if (key == "fo:letter-spacing")
style->getFont()->setKerning(getSize(value));
else if (key == "style:text-scale")
style->getFont()->setHscale(static_cast<int>(getSize(value, -1.0)));
else if ((key == "style:text-position") &&
(((value).find("sub") != -1) ||
(((value).left(1) == "-") && ((value).left(1) != "0"))))
style->getFont()->toggleEffect(SUBSCRIPT);
else if ((key == "style:text-position") &&
(((value).find("super") != -1) ||
(((value).left(1) != "-") && ((value).left(1) != "0"))))
style->getFont()->toggleEffect(SUPERSCRIPT);
else if ((key == "fo:margin-top") && (pstyle != NULL))
pstyle->setSpaceAbove(getSize(value));
else if ((key == "fo:margin-bottom") && (pstyle != NULL))
pstyle->setSpaceBelow(getSize(value));
else if ((key == "fo:margin-left") && (pstyle != NULL))
{
if (inList)
pstyle->setIndent(pstyle->getIndent() + getSize(value));
else
pstyle->setIndent(getSize(value));
}
else if ((key == "text:space-before") && (pstyle != NULL))
{
if (inList)
pstyle->setIndent(pstyle->getIndent() + getSize(value));
else
pstyle->setIndent(getSize(value));
}
else if ((key == "fo:text-indent") && (pstyle != NULL))
pstyle->setFirstLineIndent(getSize(value));
else if ((key == "fo:text-align") && (pstyle != NULL))
align = value;
else if ((key == "style:justify-single-word") && (pstyle != NULL))
force = value;
if (align != NULL)
{
if (align == "end")
pstyle->setAlignment(RIGHT);
else if (align == "center")
pstyle->setAlignment(CENTER);
else if (align == "justify")
{
if (force != "false")
pstyle->setAlignment(FORCED);
else
pstyle->setAlignment(BLOCK);
}
}
return true;
}
double StyleReader::getSize(QString s, double parentSize)
{
QString dbl = "0.0";
QString lowerValue = s.lower();
double ret = 0.0;
if (lowerValue.find("pt") != -1)
{
dbl = lowerValue.remove("pt");
ret = gtMeasure::d2d(dbl.toDouble(), PT);
}
else if (lowerValue.find("mm") != -1)
{
dbl = lowerValue.remove("mm");
ret = gtMeasure::d2d(dbl.toDouble(), MM);
}
else if (lowerValue.find("cm") != -1)
{
dbl = lowerValue.remove("cm");
ret = gtMeasure::d2d(dbl.toDouble() * 10, MM);
}
else if (lowerValue.find("in") != -1)
{
dbl = lowerValue.remove("inch");
dbl = lowerValue.remove("in");
ret = gtMeasure::d2d(dbl.toDouble(), IN);
}
else if (lowerValue.find("pi") != -1)
{
dbl = lowerValue.remove("pica");
dbl = lowerValue.remove("pi");
ret = gtMeasure::d2d(dbl.toDouble(), P);
}
else if (lowerValue.find("%") != -1)
{
dbl = lowerValue.remove("%");
double factor = dbl.toDouble();
if (parentSize != -1.0)
{
factor = factor / 100;
ret = factor * parentSize;
}
else
ret = factor;
}
return ret;
}
StyleReader::~StyleReader()
{
sreader = NULL;
StyleMap::Iterator it;
for (it = styles.begin(); it != styles.end(); ++it)
{
if (it.data())
{
delete it.data();
it.data() = NULL;
}
}
}
xmlSAXHandler sSAXHandlerStruct = {
NULL, // internalSubset,
NULL, // isStandalone,
NULL, // hasInternalSubset,
NULL, // hasExternalSubset,
NULL, // resolveEntity,
NULL, // getEntity,
NULL, // entityDecl,
NULL, // notationDecl,
NULL, // attributeDecl,
NULL, // elementDecl,
NULL, // unparsedEntityDecl,
NULL, // setDocumentLocator,
NULL, // startDocument,
NULL, // endDocument,
StyleReader::startElement,
StyleReader::endElement,
NULL, // reference,
NULL, // characters
NULL, // ignorableWhitespace,
NULL, // processingInstruction,
NULL, // comment,
NULL, // warning,
NULL, // error,
NULL, // fatalError,
NULL, // getParameterEntity,
NULL, // cdata,
NULL,
1
#ifdef HAVE_XML26
,
NULL,
NULL,
NULL,
NULL
#endif
};
xmlSAXHandlerPtr sSAXHandler = &sSAXHandlerStruct;
void StyleReader::startElement(void *user_data, const xmlChar * fullname, const xmlChar ** atts)
{
QString* name = new QString((const char*) fullname);
name = new QString(name->lower());
QXmlAttributes* attrs = new QXmlAttributes();
if (atts)
{
for(const xmlChar** cur = atts; cur && *cur; cur += 2)
attrs->append(QString((char*)*cur), NULL, QString((char*)*cur), QString((char*)*(cur + 1)));
}
sreader->startElement(NULL, NULL, *name, *attrs);
}
void StyleReader::endElement(void *user_data, const xmlChar * name)
{
QString *nname = new QString((const char*) name);
nname = new QString(nname->lower());
sreader->endElement(NULL, NULL, *nname);
}
#endif // HAVE_XML
/trunk/Scribus/scribus/plugins/gettext/sxwim/stylereader.h
25,7 → 25,11
 
#ifdef HAVE_XML
 
#include <libxml/HTMLparser.h>
#ifdef HAVE_XML26
#include <libxml/SAX2.h>
#else
#include <libxml/SAX.h>
#endif
#include <qmap.h>
#include <qxml.h>
#include <gtstyle.h>
41,6 → 45,7
static StyleReader *sreader;
gtWriter *writer;
bool importTextOnly;
bool usePrefix;
bool readProperties;
QString docname;
StyleMap styles;
59,7 → 64,7
void StyleReader::tabStop(const QXmlAttributes& attrs);
void setupFrameStyle();
public:
StyleReader(QString documentName, gtWriter *wr, bool textOnly);
StyleReader(QString documentName, gtWriter *wr, bool textOnly, bool prefix);
~StyleReader();
bool updateStyle(gtStyle* style, gtStyle* parent2Style, const QString& key, const QString& value);
static void startElement(void *user_data, const xmlChar * fullname, const xmlChar ** atts);
/trunk/Scribus/scribus/plugins/gettext/sxwim/contentreader.cpp
315,4 → 315,3
}
 
#endif // HAVE_XML
 
/trunk/Scribus/scribus/plugins/svgimplugin/svgplugin.cpp
11,6 → 11,7
#include "color.h"
#include "scribusXml.h"
#include "mpalette.h"
#include "prefsfile.h"
#include <qfile.h>
#include <qtextstream.h>
#include <qregexp.h>
25,6 → 26,7
extern QPixmap loadIcon(QString nam);
extern double RealCWidth(ScribusDoc *doc, QString name, QString ch, int Siz);
extern FPoint GetMaxClipF(FPointArray Clip);
extern PrefsFile* prefsFile;
 
/*!
\fn QString Name()
64,13 → 66,18
void Run(QWidget *d, ScribusApp *plug)
{
QString fileName;
PrefsContext* prefs = prefsFile->getPluginContext("SVGPlugin");
QString wdir = prefs->get("wdir", ".");
#ifdef HAVE_LIBZ
CustomFDialog diaf(d, QObject::tr("Open"), QObject::tr("SVG-Images (*.svg *.svgz);;All Files (*)"));
CustomFDialog diaf(d, wdir, QObject::tr("Open"), QObject::tr("SVG-Images (*.svg *.svgz);;All Files (*)"));
#else
CustomFDialog diaf(d, QObject::tr("Open"), QObject::tr("SVG-Images (*.svg);;All Files (*)"));
CustomFDialog diaf(d, wdir, QObject::tr("Open"), QObject::tr("SVG-Images (*.svg);;All Files (*)"));
#endif
if (diaf.exec())
{
fileName = diaf.selectedFile();
prefs->set("wdir", fileName.left(fileName.findRev("/")));
}
else
return;
SVGPlug *dia = new SVGPlug(d, plug, fileName);
/trunk/Scribus/scribus/plugins/svgexplugin/svgexplugin.cpp
29,9 → 29,12
#ifdef HAVE_LIBZ
#include <zlib.h>
#endif
#include <prefsfile.h>
#include <prefscontext.h>
extern void Level2Layer(ScribusDoc *doc, struct Layer *ll, int Level);
extern QString Path2Relative(QString Path);
extern QImage LoadPict(QString fn, bool *gray = 0);
extern PrefsFile* prefsFile;
 
/*!
\fn QString Name()
72,13 → 75,16
{
if (plug->HaveDoc)
{
PrefsContext* prefs = prefsFile->getPluginContext("svgex");
QString wdir = prefs->get("wdir", ".");
#ifdef HAVE_LIBZ
QString fileName = plug->CFileDialog(QObject::tr("Save as"), QObject::tr("SVG-Images (*.svg *.svgz);;All Files (*)"),"", false, false, true);
QString fileName = plug->CFileDialog(wdir, QObject::tr("Save as"), QObject::tr("SVG-Images (*.svg *.svgz);;All Files (*)"),"", false, false, true);
#else
QString fileName = plug->CFileDialog(QObject::tr("Save as"), QObject::tr("SVG-Images (*.svg);;All Files (*)"),"", false, false);
QString fileName = plug->CFileDialog(wdir, QObject::tr("Save as"), QObject::tr("SVG-Images (*.svg);;All Files (*)"),"", false, false);
#endif
if (!fileName.isEmpty())
{
prefs->set("wdir", fileName.left(fileName.findRev("/")));
QFile f(fileName);
if (f.exists())
{
/trunk/Scribus/scribus/plugins/psimport/importps.cpp
9,6 → 9,7
 
#include "customfdialog.h"
#include "mpalette.h"
#include "prefsfile.h"
#include "scribusXml.h"
#include <qfile.h>
#include <qtextstream.h>
19,6 → 20,7
extern QPointArray FlattenPath(FPointArray ina, QValueList<uint> &Segs);
extern QPixmap loadIcon(QString nam);
extern FPoint GetMaxClipF(FPointArray Clip);
extern PrefsFile* prefsFile;
 
/*!
\fn QString Name()
58,11 → 60,16
void Run(QWidget *d, ScribusApp *plug)
{
QString fileName;
PrefsContext* prefs = prefsFile->getPluginContext("importps");
QString wdir = prefs->get("wdir", ".");
QString formats = QObject::tr("All Supported Formats (*.eps *.EPS *.ps *.PS);;");
formats += "EPS (*.eps *.EPS);;PS (*.ps *.PS);;" + QObject::tr("All Files (*)");
CustomFDialog diaf(d, QObject::tr("Open"), formats);
CustomFDialog diaf(d, wdir, QObject::tr("Open"), formats);
if (diaf.exec())
{
fileName = diaf.selectedFile();
prefs->set("wdir", fileName.left(fileName.findRev("/")));
}
else
return;
EPSPlug *dia = new EPSPlug(d, plug, fileName);
/trunk/Scribus/scribus/plugins/saveastemplateplugin/satemplate.cpp
3,7 → 3,9
***************************************************************************/
#include "satemplate.h"
#include "satemplate.moc"
#include <prefsfile.h>
 
extern PrefsFile* prefsFile;
ScribusApp* Carrier;
QWidget* par;
 
54,16 → 56,22
bool hasName = Carrier->doc->hasName;
bool isModified = Carrier->doc->isModified();
QString userTemplatesDir = Carrier->Prefs.TemplateDir;
PrefsContext* dirs = prefsFile->getContext("dirs");
QString oldCollect = dirs->get("collect", ".");
QString templatesDir = ".";
if (userTemplatesDir == "")
QDir::setCurrent(QDir::homeDirPath() + "/.scribus/templates");
templatesDir = QDir::homeDirPath() + "/.scribus/templates";
else
{
if (userTemplatesDir.right(1) == "/")
userTemplatesDir = userTemplatesDir.left(userTemplatesDir.length() - 1);
QDir::setCurrent(userTemplatesDir);
templatesDir = userTemplatesDir;
}
dirs->set("collect", templatesDir);
if (Carrier->Collect() == "")
return;
if (oldCollect != ".")
dirs->set("collect", oldCollect);
QString docPath = Carrier->doc->DocName;
QString docDir = docPath.left(docPath.findRev('/'));
QString docName = docPath.right(docPath.length() - docPath.findRev('/') - 1);
/trunk/Scribus/scribus/plugins/saveastemplateplugin/satdialog.cpp
3,8 → 3,10
***************************************************************************/
#include "satdialog.h"
#include "satdialog.moc"
#include <prefsfile.h>
 
extern QPixmap loadIcon(QString nam);
extern PrefsFile* prefsFile;
 
satdialog::satdialog(QWidget* parent, QString tmplName, int pageW, int pageH) : QDialog(parent, "satdialog", TRUE)
{
187,63 → 189,17
 
void satdialog::readPrefs()
{
author = "";
email = "";
isFullDetail = false;
QFile rc(QDir::convertSeparators(QDir::homeDirPath() + "/.scribus/sat.rc"));
if (rc.exists()) {
if (rc.open(IO_ReadOnly))
{
QTextStream stream(&rc);
QString line = stream.readLine();
QString attribute;
QString value;
while (line != NULL)
{
line = line.stripWhiteSpace();
attribute = line.left(line.find("="));
value = line.right(line.length() - line.find("=") - 1);
if ((line.left(1) != "#") &&
(line.find("=") != -1) &&
(line.right(1) != "="))
{ // If not a comment and '='can be found and is not the last charcter on the line
if (attribute == "author")
{
author = value;
}
else if (attribute == "email")
{
email = value;
}
else if (attribute = "max_detail")
{
if (value == "1")
isFullDetail = true;
else
isFullDetail = false;
}
}
line = stream.readLine();
}
rc.close();
}
}
prefs = prefsFile->getPluginContext("satemplate");
author = prefs->get("author", "");
email = prefs->get("email", "");
isFullDetail = prefs->getBool("isFullDetail", false);
}
 
void satdialog::writePrefs()
{
QString text = "author=" + authorEdit->text();
text += "\nemail=" + emailEdit->text();
text += QString("\nmax_detail=%1").arg(isFullDetail);
QFile rc(QDir::convertSeparators(QDir::homeDirPath() + "/.scribus/sat.rc"));
if ( rc.open( IO_WriteOnly ) )
{
QTextStream stream(&rc);
stream.setEncoding(QTextStream::UnicodeUTF8);
stream << text;
rc.close();
}
prefs->set("author", authorEdit->text());
prefs->set("email", emailEdit->text());
prefs->set("isFullDetail", isFullDetail);
}
 
void satdialog::setupCategories()
/trunk/Scribus/scribus/plugins/saveastemplateplugin/satdialog.h
20,6 → 20,7
#include <qlineedit.h>
#include <qtextedit.h>
#include <qwidget.h>
#include <prefscontext.h>
 
typedef std::pair<QString*,QString*> Pair;
 
28,6 → 29,7
Q_OBJECT
 
private:
PrefsContext* prefs;
QLabel* nameLabel;
QLabel* psizeLabel;
QLabel* colorsLabel;
/trunk/Scribus/scribus/fontprefs.cpp
4,6 → 4,8
#include <qfile.h>
#include <qfileinfo.h>
#include <qfiledialog.h>
#include "prefscontext.h"
#include "prefsfile.h"
 
#if (_MSC_VER >= 1200)
#include "win-config.h"
12,6 → 14,7
#endif
 
extern QPixmap loadIcon(QString nam);
extern PrefsFile* prefsFile;
 
FontPrefs::FontPrefs( QWidget* parent, SCFonts &flist, bool Hdoc, preV *prefs, QString PPath )
: QDialog( parent, "fpre", true, 0 )
274,9 → 277,12
 
void FontPrefs::AddPath()
{
PrefsContext* dirs = prefsFile->getContext("dirs");
CurrentPath = dirs->get("fontprefs", ".");
QString s = QFileDialog::getExistingDirectory(CurrentPath, this, "d", tr("Choose a Directory"), true);
if (s != "")
{
dirs->set("fontprefs", s.left(s.findRev("/", -2)));
s = s.left(s.length()-1);
if (PathList->findItem(s))
return;
/trunk/Scribus/scribus/polyprops.cpp
64,7 → 64,7
Layout10->addLayout( Layout9_2 );
 
Konvex = new QCheckBox( this, "Konvex" );
Konvex->setText( tr( "Conve&x Polygon" ) );
Konvex->setText( tr( "Apply &Factor" ) );
Konvex->setChecked(PolyS);
Layout10->addWidget( Konvex );
Layout9 = new QHBoxLayout( 0, 0, 5, "Layout9");
119,10 → 119,10
QToolTip::add( Ecken, tr( "Number of corners for polygons" ) );
QToolTip::add( Faktor2, tr( "Degrees of rotation for polygons" ) );
QToolTip::add( Slider2, tr( "Degrees of rotation for polygons" ) );
QToolTip::add( Konvex, tr( "Polygons will be convex rather than concave" ) );
QToolTip::add( Konvex, tr( "Apply Convex/Concave Factor to change shape of Polygons" ) );
QToolTip::add( Preview, tr( "Sample Polygon" ) );
QToolTip::add( Faktor, tr( "Change the angles at which lines of the polygon join" ) );
QToolTip::add( Slider1, tr( "Change the angles at which lines of the polygon join" ) );
QToolTip::add( Faktor, tr( "A negative value will make the polygon concave (or star shaped),\n a positive value will make it convex" ) );
QToolTip::add( Slider1, tr( "A negative value will make the polygon concave (or star shaped),\n a positive value will make it convex" ) );
// signals and slots connections
connect(PushButton1, SIGNAL(clicked()), this, SLOT(accept()));
connect(PushButton2, SIGNAL(clicked()), this, SLOT(reject()));
/trunk/Scribus/scribus/scribus.h
60,6 → 60,7
#include "seiten.h"
#include "bookpalette.h"
#include "splash.h"
#include "prefscontext.h"
class Autoforms;
class FontCombo;
class StilFormate;
132,8 → 133,9
void closePSDriver();
bool getPDFDriver(QString fn, QString nam, int Components, std::vector<int> &pageNs, QMap<int,QPixmap> thumbs);
bool DoSaveAsEps(QString fn);
QString CFileDialog(QString caption = "", QString filter = "", QString defNa = "", bool Pre = false,
bool mod = true, bool comp = false, bool cod = false, bool onlyDirs = false, bool *docom = 0, bool *doFont = 0);
QString CFileDialog(QString wDir = ".", QString caption = "", QString filter = "", QString defNa = "",
bool Pre = false, bool mod = true, bool comp = false, bool cod = false,
bool onlyDirs = false, bool *docom = 0, bool *doFont = 0);
void GetCMSProfiles();
void GetCMSProfilesDir(QString pfad);
void RecalcColors(QProgressBar *dia = 0);
158,6 → 160,7
double DispY;
bool NoFonts;
int HaveDoc;
PrefsContext* dirs;
struct preV Prefs;
/** view is the main widget which represents your working area. The View
* class should handle all events of the view widget. It is kept empty so
/trunk/Scribus/scribus/cupsoptions.cpp
17,6 → 17,7
 
#include "cupsoptions.h"
#include "cupsoptions.moc"
#include "prefsfile.h"
 
#if (_MSC_VER >= 1200)
#include "win-config.h"
30,12 → 31,14
#endif
#include <qtooltip.h>
extern QPixmap loadIcon(QString nam);
extern PrefsFile* prefsFile;
 
CupsOptions::CupsOptions(QWidget* parent, QString Geraet) : QDialog( parent, "prin", true, 0 )
{
FlagsOpt.clear();
setCaption( tr( "Printer Options" ) );
setIcon(loadIcon("AppIcon.png"));
setIcon(loadIcon("AppIcon.png"));
prefs = prefsFile->getContext("cups_options");
setSizeGripEnabled(true);
CupsOptionsLayout = new QVBoxLayout( this );
CupsOptionsLayout->setSpacing( 5 );
95,7 → 98,10
Daten.KeyW = QString(option->keyword);
KeyToText[QString(option->text)] = Daten;
item->insertStringList(opts);
item->setCurrentText(Marked);
int lastSelected = prefs->getInt(QString(option->text), 0);
if (lastSelected >= static_cast<int>(opts.count()))
lastSelected = 0;
item->setCurrentItem(lastSelected);
KeyToDefault[QString(option->text)] = Marked;
Table->setCellWidget(Table->numRows()-1, 1, item);
}
116,7 → 122,10
item4->insertItem( tr("All Pages"));
item4->insertItem( tr("Even Pages only"));
item4->insertItem( tr("Odd Pages only"));
item4->setCurrentItem(0);
int lastSelected = prefs->getInt(tr("Page Set"), 0);
if (lastSelected >= 3)
lastSelected = 0;
item4->setCurrentItem(lastSelected);
KeyToDefault["Page Set"] = tr("All Pages");
Table->setCellWidget(Table->numRows()-1, 1, item4);
Table->setNumRows(Table->numRows()+1);
130,6 → 139,10
item2->insertItem( tr("No"));
item2->insertItem( tr("Yes"));
item2->setCurrentItem(0);
lastSelected = prefs->getInt(tr("Mirror"), 0);
if (lastSelected >= 2)
lastSelected = 0;
item2->setCurrentItem(lastSelected);
KeyToDefault["Mirror"] = tr("No");
Table->setCellWidget(Table->numRows()-1, 1, item2);
Table->setNumRows(Table->numRows()+1);
143,6 → 156,10
item5->insertItem( tr("Portrait"));
item5->insertItem( tr("Landscape"));
item5->setCurrentItem(0);
lastSelected = prefs->getInt(tr("Orientation"), 0);
if (lastSelected >= 2)
lastSelected = 0;
item5->setCurrentItem(lastSelected);
KeyToDefault["Orientation"] = tr("Portrait");
Table->setCellWidget(Table->numRows()-1, 1, item5);
Table->setNumRows(Table->numRows()+1);
159,7 → 176,10
item3->insertItem("6 "+ tr("Pages per Sheet"));
item3->insertItem("9 "+ tr("Pages per Sheet"));
item3->insertItem("16 "+ tr("Pages per Sheet"));
item3->setCurrentItem(0);
lastSelected = prefs->getInt(tr("N-Up Printing"), 0);
if (lastSelected >= 6)
lastSelected = 0;
item3->setCurrentItem(lastSelected);
KeyToDefault["N-Up Printing"] = "1 "+ tr("Page per Sheet");
Table->setCellWidget(Table->numRows()-1, 1, item3);
#endif
195,3 → 215,12
connect( PushButton1, SIGNAL( clicked() ), this, SLOT( accept() ) );
}
 
CupsOptions::~CupsOptions()
{
for (int i = 0; i < Table->numRows(); ++i)
{
QComboBox* combo = dynamic_cast<QComboBox*>(Table->cellWidget(i, 1));
if (combo)
prefs->set(Table->text(i, 0), combo->currentItem());
}
}
/trunk/Scribus/scribus/prefscontext.h
0,0 → 1,64
/***************************************************************************
* Copyright (C) 2004 by Riku Leino *
* tsoots@welho.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
 
#ifndef PREFSCONTEXT_H
#define PREFSCONTEXT_H
 
#include <string>
#include <qmap.h>
#include <qstring.h>
#include "prefstable.h"
 
typedef QMap<QString, QString> AttributeMap;
typedef QMap<QString, PrefsTable*> TableMap;
 
class PrefsContext
{
private:
QString name;
bool isplugin;
bool ispersistent;
public:
AttributeMap values;
TableMap tables;
PrefsContext();
PrefsContext(QString contextName, bool persistent = true, bool plugin = false);
~PrefsContext();
QString getName();
bool isPersistent();
bool isPlugin();
bool isEmpty();
bool contains(const QString& key);
bool containsTable(const QString& key);
QString get(const QString& key, const QString& defValue = "");
void set(const QString& key, const char* value);
void set(const QString& key, const std::string& value);
void set(const QString& key, const QString& value);
int getInt(const QString& key, int defValue = -1);
void set(const QString& key, int value);
uint getUInt(const QString& key, uint defValue = 0);
double getDouble(const QString& key, double defValue = -1.0);
void set(const QString& key, double value);
bool getBool(const QString& key, bool defValue = false);
void set(const QString& key, bool value);
PrefsTable* getTable(const QString& name);
};
 
#endif // PREFSCONTEXTS_H
Property changes:
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Index: Scribus/scribus/colorm.cpp
===================================================================
--- Scribus/scribus/colorm.cpp (revision 414)
+++ Scribus/scribus/colorm.cpp (revision 415)
@@ -19,6 +19,7 @@
#include "cmykfw.h"
#include "query.h"
#include "scribus.h"
+#include "prefsfile.h"
#if (_MSC_VER >= 1200)
#include "win-config.h"
@@ -28,6 +29,7 @@
extern QPixmap loadIcon(QString nam);
extern ScribusApp* ScApp;
+extern PrefsFile* prefsFile;
Farbmanager::Farbmanager( QWidget* parent, CListe doco, bool HDoc, QString DcolSet, QStringList Cust )
: QDialog( parent, "dd", true, 0 )
@@ -292,10 +294,12 @@
void Farbmanager::loadFarben()
{
QString fileName;
+ PrefsContext* dirs = prefsFile->getContext("dirs");
+ QString wdir = dirs->get("colors", ".");
#ifdef HAVE_LIBZ
- CustomFDialog dia(this, tr("Open"), tr("Documents (*.sla *.sla.gz *.scd *.scd.gz);;All Files (*)"));
+ CustomFDialog dia(this, wdir, tr("Open"), tr("Documents (*.sla *.sla.gz *.scd *.scd.gz);;All Files (*)"));
#else
- CustomFDialog dia(this, tr("Open"), tr("Documents (*.sla *.scd);;All Files (*)"));
+ CustomFDialog dia(this, wdir, tr("Open"), tr("Documents (*.sla *.scd);;All Files (*)"));
#endif
if (dia.exec() == QDialog::Accepted)
fileName = dia.selectedFile();
@@ -303,6 +307,7 @@
return;
if (!fileName.isEmpty())
{
+ dirs->set("colors", fileName.left(fileName.findRev("/")));
ScriXmlDoc *ss = new ScriXmlDoc();
if (ss->ReadColors(fileName))
{
/trunk/Scribus/scribus/gtmeasure.h
44,13 → 44,13
static double convert(int value);
static double convert2(double value);
static double convert2(int value);
static double parse(QString value);
static double parse(const QString& value);
public:
static double convert(double value, Unit from, Unit to = PT);
static double convert(int value, Unit from, Unit to = PT);
static double d2d(double value, Unit from, Unit to = PT);
static double i2d(int value, Unit from, Unit to = PT);
static double qs2d(QString value, Unit to = PT);
static double qs2d(const QString& value, Unit to = PT);
};
 
#endif // GTMEASURE_H
/trunk/Scribus/scribus/gtgettext.cpp
20,6 → 20,7
 
#include "gtgettext.h"
 
extern QPixmap loadIcon(QString nam);
extern ScribusApp* ScApp;
 
gtGetText::gtGetText()
/trunk/Scribus/scribus/prefsfile.cpp
0,0 → 1,154
/***************************************************************************
* Copyright (C) 2004 by Riku Leino *
* tsoots@welho.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
 
#include <qfile.h>
#include <qstring.h>
#include <qxml.h>
#include "prefsfile.h"
#include "prefsreader.h"
#include "prefstable.h"
 
PrefsFile::PrefsFile()
{
prefsFilePath = "";
ioEnabled = false;
}
 
PrefsFile::PrefsFile(const QString& pFilePath)
{
prefsFilePath = pFilePath;
ioEnabled = true;
load();
}
 
PrefsContext* PrefsFile::getContext(const QString& contextName, bool persistent)
{
if (!contexts.contains(contextName))
contexts[contextName] = new PrefsContext(contextName, persistent);
return contexts[contextName];
}
 
PrefsContext* PrefsFile::getPluginContext(const QString& contextName, bool persistent)
{
if (!pluginContexts.contains(contextName))
pluginContexts[contextName] = new PrefsContext(contextName, persistent);
return pluginContexts[contextName];
}
 
void PrefsFile::load()
{
PrefsReader* handler = new PrefsReader(&contexts, &pluginContexts);
QFile* rc = new QFile(prefsFilePath);
QXmlInputSource* source = new QXmlInputSource(rc);
QXmlSimpleReader* reader = new QXmlSimpleReader();
reader->setContentHandler(handler);
reader->parse(source);
delete reader;
delete source;
delete rc;
delete handler;
}
 
void PrefsFile::write()
{
if ((!ioEnabled) || ((contexts.size() == 0) && (pluginContexts.size() == 0)))
return; // No prefs file path set -> can't write or no prefs to write
QFile* prefsXML = new QFile(prefsFilePath);
if (prefsXML->open(IO_WriteOnly))
{
QTextStream stream(prefsXML);
stream.setEncoding(QTextStream::UnicodeUTF8);
stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
stream << "<preferences>\n";
if (contexts.size() > 0)
{
stream << "\t<level name=\"application\">\n";
writeContexts(&contexts, stream);
stream << "\t</level>\n";
}
if (pluginContexts.size() > 0)
{
stream << "\t<level name=\"plugin\">\n";
writeContexts(&pluginContexts, stream);
stream << "\t</level>\n";
}
stream << "</preferences>\n";
 
prefsXML->close();
}
delete prefsXML;
}
 
void PrefsFile::writeContexts(ContextMap* contextMap, QTextStream& stream)
{
ContextMap::Iterator it;
for (it = contextMap->begin(); it != contextMap->end(); ++it)
{
if ((it.data()->isPersistent()) && (!it.data()->isEmpty()))
{
stream << "\t\t<context name=\"" + it.key() + "\">\n";
AttributeMap::Iterator it2;
PrefsContext* tmpCon = it.data();
for (it2 = tmpCon->values.begin(); it2 != tmpCon->values.end(); ++it2)
{
stream << "\t\t\t<attribute key=\"" + it2.key() + "\" ";
stream << "value=\"" + replaceIllegalChars(it2.data()) + "\"/>\n";
}
TableMap::Iterator it3;
for (it3 = tmpCon->tables.begin(); it3 != tmpCon->tables.end(); ++it3)
{
stream << "\t\t\t<table name=\"" + it3.key() + "\">\n";
PrefsTable* t = it3.data();
for (int i = 0; i < t->height(); ++i)
{
stream << QString("\t\t\t\t<row index=\"%1\">\n").arg(i);
for (int j = 0; j < t->width(); ++j)
{
stream << QString("\t\t\t\t\t<col index=\"%1\">").arg(j);
stream << replaceIllegalChars(t->get(i, j)) << "</col>\n";
}
stream << "\t\t\t\t</row>\n";
}
stream << "\t\t\t</table>\n";
}
stream << "\t\t</context>\n";
}
}
}
 
QString PrefsFile::replaceIllegalChars(const QString& text)
{
QString s = text;
s.replace("&", "&amp;");
s.replace("<", "&lt;");
s.replace(">", "&gt;");
s.replace("\"", "&quot;");
s.replace("\'", "&apos;");
return s;
}
 
PrefsFile::~PrefsFile()
{
ContextMap::Iterator it;
for (it = contexts.begin(); it != contexts.end(); ++it)
delete it.data();
for (it = pluginContexts.begin(); it != pluginContexts.end(); ++it)
delete it.data();
}
Property changes:
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Index: Scribus/scribus/editor.h
===================================================================
--- Scribus/scribus/editor.h (revision 414)
+++ Scribus/scribus/editor.h (revision 415)
@@ -9,6 +9,7 @@
#include <qpopupmenu.h>
#include <qmenubar.h>
#include "scribusview.h"
+#include "prefscontext.h"
class Editor : public QDialog
{
@@ -30,6 +31,7 @@
protected:
QVBoxLayout* EditorLayout;
+ PrefsContext* dirs;
};
#endif // EDITOR_H