Subversion Repositories Scribus

Compare Revisions

Ignore whitespace Rev 4023 → Rev 4024

/branches/Version13x/Scribus/scribus/fileloader.cpp
27,6 → 27,13
#include "units.h"
#include "loadsaveplugin.h"
 
// We need to include the headers for the plugins we support until we start
// using LoadSavePlugin to pick them for us. We only use these headers to
// get the format IDs, NOTHING ELSE.
#include "plugins/svgimplugin/svgplugin.h"
#include "plugins/psimport/importpsplugin.h"
#include "plugins/fileloader/oodraw/oodrawimp.h"
 
#ifdef HAVE_LIBZ
#include <zlib.h>
#endif
42,14 → 49,15
\retval None
*/
FileLoader::FileLoader(const QString & fileName) :
QObject(0, "FileLoader")
QObject(0, "FileLoader"),
FileName(fileName),
FileType(-1),
formatPS(LoadSavePlugin::getFormatById(FORMATID_PSIMPORT)),
formatSVG(LoadSavePlugin::getFormatById(FORMATID_SVGIMPORT)),
formatSXD(LoadSavePlugin::getFormatById(FORMATID_SXDIMPORT)),
formatODG(LoadSavePlugin::getFormatById(FORMATID_ODGIMPORT)),
prefsManager(PrefsManager::instance())
{
prefsManager=PrefsManager::instance();
FileName = fileName;
FileType = -1;
havePS = ScApp->pluginManager->DLLexists("importps");
haveSVG = ScApp->pluginManager->DLLexists("svgimplugin");
haveSXD = ScApp->pluginManager->DLLexists("oodrawimp");
}
 
// FIXME: This static method is here as a temporary transitional
97,12 → 105,14
QString ext = fi.extension(true).lower();
if ((ext.endsWith("sla.gz")) || (ext.endsWith("sla")) || (ext.endsWith("scd.gz")) || (ext.endsWith("scd")))
ret = CheckScribus();
else if (((ext.endsWith("ps")) || (ext.endsWith("eps"))) && (havePS))
else if (((ext.endsWith("ps")) || (ext.endsWith("eps"))) && (formatPS))
ret = 2;
else if (((ext.endsWith("svg")) || (ext.endsWith("svgz"))) && (haveSVG))
else if (((ext.endsWith("svg")) || (ext.endsWith("svgz"))) && (formatSVG))
ret = 3;
else if ((ext.endsWith("sxd")) && (haveSXD))
else if ((ext.endsWith("sxd")) && (formatSXD))
ret = 5;
else if ((ext.endsWith("odg")) && (formatODG))
ret = 6;
/* if (ext == "pdf")
ret = 4; */
FileType = ret;
375,14 → 385,17
ret = ReadDoc(FileName, prefsManager->appPrefs.AvailFonts, ScApp->doc, ScApp->mainWindowProgressBar);
break;
case 2:
ret = ScApp->pluginManager->callImportExportPlugin("importps", FileName);
ret = formatPS->loadFile(FileName);
break;
case 3:
ret = ScApp->pluginManager->callImportExportPlugin("svgimplugin", FileName);
ret = formatSVG->loadFile(FileName);
break;
case 5:
ret = ScApp->pluginManager->callImportExportPlugin("oodrawimp", FileName);
ret = formatSXD->loadFile(FileName);
break;
case 6:
ret = formatODG->loadFile(FileName);
break;
default:
ret = false;
break;
/branches/Version13x/Scribus/scribus/loadsaveplugin.h
9,6 → 9,8
#include <qvaluelist.h>
#include <qstringlist.h>
 
struct FileFormat;
 
/*
* @brief Superclass for all file import/export/load/save plugins
*
25,55 → 27,8
LoadSavePlugin();
~LoadSavePlugin();
 
// Info on each supported format. A plugin must register a
// FormatSupport structure for every format it knows how to load or
// save. If it both loads and saves a given format, one structure must
// be registered for load and one for save.
// Plugins must unregister formats when being unloaded to ensure that
// no attempt is made to load a file using a plugin that's no longer
// available.
struct FormatSupport
{
// An integer ID code used to idenfify formats. Should be unique
// across all FormatSupport structures except where they implement
// support for the same file format, eg sla 1.2.x, sla 1.3.x and
// "new format" SLA should all have equal IDs (with different
// priorities to control what order they're tried in when a user
// tries to open a file).
// Note that dialog box options are sorted in descending `id' order.
unsigned int formatId;
// The human-readable, translated name of this file format.
QString trName;
// A filter in the format used by QFileDialog that should be used to
// select for this format.
QString filter;
// Regexp to match filenames for this format
QRegExp nameMatch;
// MIME type(s) that should be matched by this format.
QStringList mimeTypes;
// Can we load it?
bool load;
// Can we save it?
bool save;
// Priority of this format from 0 (lowest, tried last) to
// 255 (highest, tried first). 64-128 recommended in general.
// Priority controls the order options are displayed in when a file
// of a given type is selected in a dialog, and controls the order
// loaders are tried in when multiple plugins support the same file
// type.
unsigned short int priority;
// For convenience, a pointer back to the plugin to use to open
// this format.
LoadSavePlugin* plug;
};
 
// Static functions:
 
// Return a list of all formats supported by all currently loaded and
// active plugins. This list is sorted in a very specific order:
// First, by descending order of `id', then descending order of priority.
static const QValueList<FormatSupport> & supportedFormats();
 
// Return a list of format descriptions suitable for use with
// QFileDialog. You can convert it to QString form with
// fileDialogSaveFilter().join(";;")
82,8 → 37,19
// Same deal but for save
static const QStringList fileDialogSaveFilter();
 
// Get the highest priority format of a given id, or 0 if
// not found / not available.
static const FileFormat * getFormatById(const int id);
 
// Non-static members implemented by plugins:
//
// Load the requested format from the specified path.
// Default implementation always reports falure.
virtual bool loadFile(const QString & fileName, const FileFormat & fmt);
 
// Save the requested format to the requested path.
virtual bool saveFile(const QString & fileName, const FileFormat & fmt);
 
// Examine the passed file and test to see whether it appears to be
// loadable with this plugin. This test must be quick and simple.
// It need not verify a file, just confirm that it looks like a supported
90,17 → 56,11
// file type (eg "XML doc with root element SCRIBUSXML and version 1.3.1").
// All plugins must implement this method.
virtual bool fileSupported(QIODevice* file) const = 0;
 
// Load the requested format from the specified path.
// Default implementation always reports falure.
virtual bool loadFile(const QString & fileName, const FormatSupport & fmt);
 
// Save the requested format to the requested path.
virtual bool saveFile(const QString & fileName, const FormatSupport & fmt);
protected:
 
/// Register the passed format so it can be used by the app
void registerFormat(const FormatSupport & fmt);
void registerFormat(const FileFormat & fmt);
 
/// Unregister the format with format ID `id' that references by the calling plugin.
void unregisterFormat(unsigned int id);
108,12 → 68,17
/// Unregister all formats owned by the calling plugin
void unregisterAll();
 
// Return a list of all formats supported by all currently loaded and
// active plugins. This list is sorted in a very specific order:
// First, by descending order of `id', then descending order of priority.
static const QValueList<FileFormat> & supportedFormats();
 
private:
// A list of all supported formats. This is maintained by plugins
// using the protected `registerFormat(...)', `unregisterFormat(...)'
// and `unregisterAll(...)' methods. This is sorted in a very specific
// order - ascending ID, then descending priority.
static QValueList<FormatSupport> formats;
static QValueList<FileFormat> formats;
 
// Return an iterator referencing the first format structure named `name'.
// If specified, only return formats implmented by `plug'.
124,9 → 89,9
// iterator returned by this method will always be to the highest
// priority format of the required ID, and each subsequent call will
// return the next lowest priority format.
QValueList<FormatSupport>::iterator findFormat(unsigned int id,
static QValueList<FileFormat>::iterator findFormat(unsigned int id,
LoadSavePlugin* plug = 0,
QValueList<FormatSupport>::iterator it = formats.begin());
QValueList<FileFormat>::iterator it = formats.begin());
 
// Print out a format list for debugging purposes
static void printFormatList();
135,4 → 100,62
static const QStringList getDialogFilter(bool forLoad);
};
 
// Info on each supported format. A plugin must register a
// FileFormat structure for every format it knows how to load or
// save. If it both loads and saves a given format, one structure must
// be registered for load and one for save.
// Plugins must unregister formats when being unloaded to ensure that
// no attempt is made to load a file using a plugin that's no longer
// available.
//
// This class also provides methods to ask the implementation to load / save a
// file in this format.
struct SCRIBUS_API FileFormat
{
// Default ctor to make QValueList happy
FileFormat() : load(false), save(false), plug(0) {}
// Standard ctor that sets up a valid FileFormat
FileFormat(LoadSavePlugin * plug) : load(false), save(false), plug(plug) {}
// Load a file with this format
bool loadFile(const QString & fileName) const;
// Save a file with this format
bool saveFile(const QString & fileName) const;
//
// Data members
//
// An integer ID code used to idenfify formats. Should be unique
// across all FileFormat structures except where they implement
// support for the same file format, eg sla 1.2.x, sla 1.3.x and
// "new format" SLA should all have equal IDs (with different
// priorities to control what order they're tried in when a user
// tries to open a file).
// Note that dialog box options are sorted in descending `id' order.
unsigned int formatId;
// The human-readable, translated name of this file format.
QString trName;
// A filter in the format used by QFileDialog that should be used to
// select for this format.
QString filter;
// Regexp to match filenames for this format
QRegExp nameMatch;
// MIME type(s) that should be matched by this format.
QStringList mimeTypes;
// Can we load it?
bool load;
// Can we save it?
bool save;
// Priority of this format from 0 (lowest, tried last) to
// 255 (highest, tried first). 64-128 recommended in general.
// Priority controls the order options are displayed in when a file
// of a given type is selected in a dialog, and controls the order
// loaders are tried in when multiple plugins support the same file
// type.
unsigned short int priority;
// For convenience, a pointer back to the plugin to use to open
// this format.
LoadSavePlugin * const plug;
};
 
 
 
#endif
/branches/Version13x/Scribus/scribus/pluginmanager.h
74,22 → 74,13
/*! \brief Return file extension used for shared libs on this platform */
static QCString platformDllExtension();
 
/*! \brief Call the named plugin with "arg" and return true for success.
*
* Note that failure might be caused by the plug-in being unknown,
* the plug-in not being loaded, the plug-in not being enabled, or
* by by failure of the call its self.
*
* This is a bit of a compatability kludge.
*/
bool callImportExportPlugin(const QCString pluginName, const QString & arg);
 
/*! \brief Call the named plugin with "arg" and return true for success, storing the return string in retval
*
* This is a lot of a compatibility kludge. Avoid using it in new code, you should probably
* prefer to dynamic_cast<> to the plugin class and call a plugin specific method.
* This is a lot of a compatibility kludge for the font preview plugin.
* Avoid using it in new code. You should probably prefer to dynamic_cast<>
* to the plugin class and call a plugin specific method.
*/
bool callImportExportPlugin(const QCString pluginName, const QString & arg, QString & retval);
bool callSpecialActionPlugin(const QCString pluginName, const QString & arg, QString & retval);
 
/*! \brief Return a pointer to this instance.
 
/branches/Version13x/Scribus/scribus/loadsaveplugin.cpp
1,6 → 1,6
#include "loadsaveplugin.h"
 
QValueList<LoadSavePlugin::FormatSupport> LoadSavePlugin::formats;
QValueList<FileFormat> LoadSavePlugin::formats;
 
LoadSavePlugin::LoadSavePlugin()
: ScPlugin()
12,11 → 12,20
}
 
// STATIC method - return a list of all existing formats
const QValueList<LoadSavePlugin::FormatSupport> & LoadSavePlugin::supportedFormats()
const QValueList<FileFormat> & LoadSavePlugin::supportedFormats()
{
return formats;
}
 
const FileFormat * LoadSavePlugin::getFormatById(const int id)
{
QValueList<FileFormat>::iterator it(findFormat(id));
if (it == formats.end())
return 0;
else
return &(*it);
}
 
const QStringList LoadSavePlugin::fileDialogLoadFilter()
{
return getDialogFilter(true);
29,8 → 38,8
 
const QStringList LoadSavePlugin::getDialogFilter(bool forLoad)
{
QValueList<LoadSavePlugin::FormatSupport>::const_iterator it(formats.constBegin());
QValueList<LoadSavePlugin::FormatSupport>::const_iterator itEnd(formats.constEnd());
QValueList<FileFormat>::const_iterator it(formats.constBegin());
QValueList<FileFormat>::const_iterator itEnd(formats.constEnd());
QStringList filterList;
// We know the list is sorted by id, then priority, so we can just take the
// highest priority entry for each ID, and we can start with the first entry
52,18 → 61,18
}
 
bool LoadSavePlugin::saveFile(const QString & /* fileName */,
const LoadSavePlugin::FormatSupport & /* fmt */)
const FileFormat & /* fmt */)
{
return false;
}
 
bool LoadSavePlugin::loadFile(const QString & /* fileName */,
const LoadSavePlugin::FormatSupport & /* fmt */)
const FileFormat & /* fmt */)
{
return false;
}
 
void LoadSavePlugin::registerFormat(const LoadSavePlugin::FormatSupport & fmt)
void LoadSavePlugin::registerFormat(const FileFormat & fmt)
{
// We insert the format in a very specific location so that the formats
// list is sorted by ascending id, then descending priority.
72,8 → 81,8
// - Equal ID and lesser or equal priority; or
// - Greater ID
// If we don't find one, we insert before the end iterator, ie append.
QValueList<LoadSavePlugin::FormatSupport>::iterator it(formats.begin());
QValueList<LoadSavePlugin::FormatSupport>::iterator itEnd(formats.end());
QValueList<FileFormat>::iterator it(formats.begin());
QValueList<FileFormat>::iterator itEnd(formats.end());
while (it != itEnd)
{
if ( ( ((*it).formatId == fmt.formatId) && ((*it).priority <= fmt.priority) ) ||
89,8 → 98,8
void LoadSavePlugin::printFormatList()
{
qDebug("Current format list:");
QValueList<LoadSavePlugin::FormatSupport>::const_iterator it(formats.constBegin());
QValueList<LoadSavePlugin::FormatSupport>::const_iterator itEnd(formats.constEnd());
QValueList<FileFormat>::const_iterator it(formats.constBegin());
QValueList<FileFormat>::const_iterator itEnd(formats.constEnd());
for ( ; it != itEnd ; ++it )
{
qDebug(" Format: Id: %3u, Prio: %3hu, Name: %s",
101,7 → 110,7
 
void LoadSavePlugin::unregisterFormat(unsigned int id)
{
QValueList<LoadSavePlugin::FormatSupport>::iterator it(findFormat(id, this));
QValueList<FileFormat>::iterator it(findFormat(id, this));
Q_ASSERT(it != formats.end());
formats.remove(it);
}
108,8 → 117,8
 
void LoadSavePlugin::unregisterAll()
{
QValueList<LoadSavePlugin::FormatSupport>::iterator it(formats.begin());
QValueList<LoadSavePlugin::FormatSupport>::iterator itEnd(formats.end());
QValueList<FileFormat>::iterator it(formats.begin());
QValueList<FileFormat>::iterator itEnd(formats.end());
while (it != itEnd)
{
if ((*it).plug == this)
119,12 → 128,12
}
}
 
QValueList<LoadSavePlugin::FormatSupport>::iterator
QValueList<FileFormat>::iterator
LoadSavePlugin::findFormat(unsigned int id,
LoadSavePlugin* plug,
QValueList<LoadSavePlugin::FormatSupport>::iterator it)
QValueList<FileFormat>::iterator it)
{
QValueList<LoadSavePlugin::FormatSupport>::iterator itEnd(formats.end());
QValueList<FileFormat>::iterator itEnd(formats.end());
for ( ; it != itEnd ; ++it )
{
if (
135,3 → 144,15
}
return itEnd;
}
 
 
 
bool FileFormat::loadFile(const QString & fileName) const
{
return (plug && load) ? plug->loadFile(fileName, *this) : false;
}
 
bool FileFormat::saveFile(const QString & fileName) const
{
return (plug && save) ? plug->saveFile(fileName, *this) : false;
}
/branches/Version13x/Scribus/scribus/fileloader.h
14,6 → 14,7
class ScribusView;
class SCFonts;
class PrefsManager;
class FileFormat;
 
class SCRIBUS_API FileLoader : public QObject
{
34,9 → 35,10
void informReplacementFonts();
QString FileName;
int FileType;
bool havePS;
bool haveSVG;
bool haveSXD;
const FileFormat * const formatPS;
const FileFormat * const formatSVG;
const FileFormat * const formatSXD;
const FileFormat * const formatODG;
bool newReplacement;
QValueList<int> LFrames;
QMap<QString,QString> ReplacedFonts;
47,6 → 49,7
static const QString getLoadFilterString();
static QString readSLA(const QString & fileName);
private:
 
PrefsManager* prefsManager;
double maximumX;
double maximumY;
/branches/Version13x/Scribus/scribus/story.cpp
2883,7 → 2883,7
QString retval;
if (ScApp->pluginManager->DLLexists("fontpreview"))
{
bool result = ScApp->pluginManager->callImportExportPlugin("fontpreview", Editor->CurrFont, retval);
bool result = ScApp->pluginManager->callSpecialActionPlugin("fontpreview", Editor->CurrFont, retval);
if (result && !retval.isEmpty())
{
sDebug("Got retval");
/branches/Version13x/Scribus/scribus/plugins/scriptplugin/svgimport.cpp
1,14 → 1,16
#include "svgimport.h"
#include "cmdvar.h"
#include "cmdutil.h"
#include "pluginmanager.h"
 
// We need svgplugin.h for the SVG format ID, and for
// the FileFormat interface.
#include "plugins/svgimplugin/svgplugin.h"
 
#include <qstring.h>
 
 
PyObject *scribus_importsvg(PyObject* /* self */, PyObject* args)
{
char *aText;
char *aText = 0;
if (!PyArg_ParseTuple(args, const_cast<char*>("es"), const_cast<char*>("utf-8"), &aText))
return NULL;
 
15,10 → 17,19
if(!checkHaveDocument())
return NULL;
 
if (!ScApp->pluginManager->DLLexists("svgimplugin"))
const FileFormat * fmt
= LoadSavePlugin::getFormatById(FORMATID_SVGIMPORT);
if (!fmt)
{
PyErr_SetString(PyExc_Exception, "SVG Import plugin not available");
return NULL;
}
if (!fmt->loadFile(QString::fromUtf8(aText)))
{
PyErr_SetString(PyExc_Exception, "Import failed");
return NULL;
}
 
ScApp->pluginManager->callImportExportPlugin("svgimplugin", QString::fromUtf8(aText));
ScApp->doc->setLoading(false);
 
Py_INCREF(Py_None);
/branches/Version13x/Scribus/scribus/plugins/svgimplugin/svgplugin.cpp
102,9 → 102,9
void SVGImportPlugin::registerFormats()
{
QString svgName = tr("Scalable Vector Graphics");
FormatSupport fmt;
FileFormat fmt(this);
fmt.trName = svgName;
fmt.formatId = 3;
fmt.formatId = FORMATID_SVGIMPORT;
#ifdef HAVE_LIBZ
fmt.filter = svgName + " (*.svg *.svgz)";
fmt.nameMatch = QRegExp("\\.(svg|svgz)$", false);
116,7 → 116,6
fmt.save = false;
fmt.mimeTypes = QStringList("image/svg+xml");
fmt.priority = 64;
fmt.plug = this;
registerFormat(fmt);
}
 
126,6 → 125,12
return true;
}
 
bool SVGImportPlugin::loadFile(const QString & fileName, const FileFormat & /* fmt */)
{
// For now, "load file" and import are the same thing for this plugin
return import(fileName);
}
 
/*!
\fn void import(QString filename)
\author Franz Schmid
/branches/Version13x/Scribus/scribus/plugins/svgimplugin/svgplugin.h
9,6 → 9,16
 
class ScrAction;
 
/**
* The ID for the SVG Import format. This must be a macro not a static const member
* because it must be available even when the SVGImportPlugin is not linked in
* or even compiled.
*/
#define FORMATID_SVGIMPORT 3
 
/**
* A class providing the plugin interface implementation for this plugin
*/
class PLUGIN_API SVGImportPlugin : public LoadSavePlugin
{
Q_OBJECT
22,6 → 32,7
virtual void deleteAboutData(const AboutData* about) const;
virtual void languageChange();
virtual bool fileSupported(QIODevice* file) const;
virtual bool loadFile(const QString & fileName, const FileFormat & fmt);
 
public slots:
virtual bool import(QString target = QString::null);
44,101 → 55,100
class GradientHelper
{
public:
GradientHelper()
GradientHelper() :
CSpace(false),
cspaceValid(true),
gradient(VGradient::linear),
gradientValid(false),
matrix(),
matrixValid(false),
reference(""),
Type(1),
typeValid(false),
X1(0),
x1Valid(true),
X2(1),
x2Valid(true),
Y1(0),
y1Valid(true),
Y2(0),
y2Valid(true)
{
Type = 1;
typeValid = false;
CSpace = false;
cspaceValid = true;
X1 = 0;
x1Valid = true;
X2 = 1;
x2Valid = true;
Y1 = 0;
y1Valid = true;
Y2 = 0;
y2Valid = true;
gradient = VGradient(VGradient::linear);
gradientValid = false;
matrix = QWMatrix();
matrixValid = false;
reference = "";
}
bool CSpace;
bool cspaceValid;
VGradient gradient;
bool gradientValid;
QWMatrix matrix;
bool matrixValid;
QString reference;
int Type;
bool typeValid;
QString reference;
VGradient gradient;
bool gradientValid;
double X1;
bool x1Valid;
double X2;
bool x2Valid;
double Y1;
bool y1Valid;
double X2;
bool x2Valid;
double Y2;
bool y2Valid;
bool CSpace;
bool cspaceValid;
QWMatrix matrix;
bool matrixValid;
};
 
class SvgStyle
{
public:
SvgStyle()
SvgStyle() :
CSpace(false),
CurCol("None"),
dashOffset(0),
Family(""),
FillCol("Black"),
FontSize(12),
GCol1("Black"),
GCol2("Black"),
GradCo(VGradient::linear),
Gradient(0),
GX1(0),
GX2(0),
GY1(0),
GY2(0),
InherCol(false),
LWidth(1.0),
matrix(),
matrixg(),
PLineArt(Qt::SolidLine),
PLineEnd(Qt::FlatCap),
PLineJoin(Qt::MiterJoin),
StrokeCol("None"),
Transparency(0.0),
TranspStroke(0.0)
{
LWidth = 1.0;
Transparency = 0.0;
TranspStroke = 0.0;
StrokeCol = "None";
FillCol = "Black";
CurCol = "None";
Gradient = 0;
GCol1 = "Black";
GCol2 = "Black";
GX1 = 0;
GY1 = 0;
GX2 = 0;
GY2 = 0;
GradCo = VGradient(VGradient::linear);
CSpace = false;
Family = "";
FontSize = 12;
matrix = QWMatrix();
matrixg = QWMatrix();
PLineArt = Qt::SolidLine;
PLineJoin = Qt::MiterJoin;
PLineEnd = Qt::FlatCap;
InherCol = false;
dashOffset = 0;
dashArray.clear();
}
QWMatrix matrix;
QWMatrix matrixg;
double LWidth;
Qt::PenStyle PLineArt;
Qt::PenJoinStyle PLineJoin;
Qt::PenCapStyle PLineEnd;
QString StrokeCol;
bool CSpace;
QString CurCol;
QValueList<double> dashArray;
double dashOffset;
QString Family;
QString FillCol;
QString CurCol;
int FontSize;
QString GCol1;
QString GCol2;
VGradient GradCo;
int Gradient;
double GX1;
double GX2;
double GY1;
double GX2;
double GY2;
int Gradient;
VGradient GradCo;
bool CSpace;
int FontSize;
QString Family;
bool InherCol;
double LWidth;
QWMatrix matrix;
QWMatrix matrixg;
Qt::PenStyle PLineArt;
Qt::PenCapStyle PLineEnd;
Qt::PenJoinStyle PLineJoin;
QString StrokeCol;
double Transparency;
double TranspStroke;
bool InherCol;
double dashOffset;
QValueList<double> dashArray;
};
 
class SVGPlug : public QObject
/branches/Version13x/Scribus/scribus/plugins/fileloader/oldscribusformat/oldscribusformat.cpp
48,7 → 48,7
 
void OldScribusFormat::registerFormats()
{
FormatSupport fmt;
FileFormat fmt(this);
fmt.trName = tr("Scribus Document");
fmt.formatId = 0;
fmt.load = true;
63,9 → 63,8
fmt.mimeTypes = QStringList();
fmt.mimeTypes.append("application/x-scribus");
fmt.priority = 64;
fmt.plug = this;
registerFormat(fmt);
FormatSupport fmt2;
FileFormat fmt2(this);
fmt2.trName = tr("Scribus 1.2.x Document");
fmt2.formatId = 0;
fmt2.load = true;
82,12 → 81,12
return true;
}
 
bool OldScribusFormat::loadFile(const QString & /* fileName */, const LoadSavePlugin::FormatSupport & /* fmt */)
bool OldScribusFormat::loadFile(const QString & /* fileName */, const FileFormat & /* fmt */)
{
return false;
}
 
bool OldScribusFormat::saveFile(const QString & /* fileName */, const LoadSavePlugin::FormatSupport & /* fmt */)
bool OldScribusFormat::saveFile(const QString & /* fileName */, const FileFormat & /* fmt */)
{
return false;
}
/branches/Version13x/Scribus/scribus/plugins/fileloader/oldscribusformat/oldscribusformat.h
18,8 → 18,8
virtual void languageChange();
virtual bool fileSupported(QIODevice* file) const;
 
virtual bool loadFile(const QString & fileName, const FormatSupport & fmt);
virtual bool saveFile(const QString & fileName, const FormatSupport & fmt);
virtual bool loadFile(const QString & fileName, const FileFormat & fmt);
virtual bool saveFile(const QString & fileName, const FileFormat & fmt);
 
// Special features - .sla page extraction support
bool loadPage(int pageNumber, bool Mpage);
/branches/Version13x/Scribus/scribus/plugins/fileloader/oodraw/oodrawimp.cpp
44,9 → 44,6
return PLUGIN_API_VERSION;
}
 
static const unsigned int formatId_odt = 1;
static const unsigned int formatId_sxd = 2;
 
ScPlugin* oodrawimp_getPlugin()
{
OODrawImportPlugin* plug = new OODrawImportPlugin();
114,9 → 111,9
void OODrawImportPlugin::registerFormats()
{
QString odtName = tr("OpenDocument 1.0 Draw", "Import/export format name");
FormatSupport odtformat;
FileFormat odtformat(this);
odtformat.trName = odtName; // Human readable name
odtformat.formatId = formatId_odt;
odtformat.formatId = FORMATID_ODGIMPORT;
odtformat.filter = odtName + " (*.odg)"; // QFileDialog filter
odtformat.nameMatch = QRegExp("\\.odg$", false);
odtformat.load = true;
123,13 → 120,12
odtformat.save = false;
odtformat.mimeTypes = QStringList("application/vnd.oasis.opendocument.graphics"); // MIME types
odtformat.priority = 64; // Priority
odtformat.plug = this;
registerFormat(odtformat);
 
QString sxdName = tr("OpenOffice.org 1.x Draw", "Import/export format name");
FormatSupport sxdformat;
FileFormat sxdformat(this);
sxdformat.trName = sxdName; // Human readable name
sxdformat.formatId = formatId_sxd;
sxdformat.formatId = FORMATID_SXDIMPORT;
sxdformat.filter = sxdName + " (*.sxd)"; // QFileDialog filter
sxdformat.nameMatch = QRegExp("\\.sxd$", false);
sxdformat.load = true;
136,7 → 132,6
sxdformat.save = false;
sxdformat.mimeTypes = QStringList("application/vnd.sun.xml.draw"); // MIME types
sxdformat.priority = 64; // Priority
sxdformat.plug = this;
registerFormat(sxdformat);
}
 
146,7 → 141,7
return true;
}
 
bool OODrawImportPlugin::loadFile(const QString & fileName, const LoadSavePlugin::FormatSupport & fmt)
bool OODrawImportPlugin::loadFile(const QString & fileName, const FileFormat & fmt)
{
// For this plugin, right now "load" and "import" are the same thing
return import(fileName);
/branches/Version13x/Scribus/scribus/plugins/fileloader/oodraw/oodrawimp.h
10,6 → 10,9
#include "pageitem.h"
#include "scribusstructs.h"
 
#define FORMATID_ODGIMPORT 1
#define FORMATID_SXDIMPORT 2
 
class ScrAction;
 
class PLUGIN_API OODrawImportPlugin : public LoadSavePlugin
25,7 → 28,7
virtual void deleteAboutData(const AboutData* about) const;
virtual void languageChange();
virtual bool fileSupported(QIODevice* file) const;
virtual bool loadFile(const QString & fileName, const FormatSupport & fmt);
virtual bool loadFile(const QString & fileName, const FileFormat & fmt);
 
// Special features - File->Import slot
public slots:
/branches/Version13x/Scribus/scribus/plugins/psimport/importpsplugin.h
6,6 → 6,8
 
class ScrAction;
 
#define FORMATID_PSIMPORT 4
 
class PLUGIN_API ImportPSPlugin : public LoadSavePlugin
{
Q_OBJECT
19,6 → 21,7
virtual void deleteAboutData(const AboutData* about) const;
virtual void languageChange();
virtual bool fileSupported(QIODevice* file) const;
virtual bool loadFile(const QString & fileName, const FileFormat & fmt);
 
public slots:
// Import menu item
/branches/Version13x/Scribus/scribus/plugins/psimport/importpsplugin.cpp
88,9 → 88,9
void ImportPSPlugin::registerFormats()
{
QString psName = tr("PostScript");
FormatSupport fmt;
FileFormat fmt(this);
fmt.trName = psName; // Human readable name
fmt.formatId = 4;
fmt.formatId = FORMATID_PSIMPORT;
fmt.filter = psName + " (*.ps *.PS *.eps *.EPS)"; // QFileDialog filter
fmt.nameMatch = QRegExp("\\.(ps|eps)$", false);
fmt.load = true;
97,7 → 97,6
fmt.save = false;
fmt.mimeTypes = QStringList("application/postscript"); // MIME types
fmt.priority = 64; // Priority
fmt.plug = this;
registerFormat(fmt);
}
 
107,6 → 106,11
return true;
}
 
bool ImportPSPlugin::loadFile(const QString & fileName, const FileFormat & fmt)
{
// There's only one format to handle, so we just call import(...)
return import(fileName);
}
 
/*!
\fn void import(QString fileName)
/branches/Version13x/Scribus/scribus/pluginmanager.cpp
409,18 → 409,8
}
 
// Compatability kludge
bool PluginManager::callImportExportPlugin(const QCString pluginName, const QString & arg, QString & retval)
bool PluginManager::callSpecialActionPlugin(const QCString pluginName, const QString & arg, QString & retval)
{
if (callImportExportPlugin(pluginName, arg))
{
retval = dynamic_cast<ScActionPlugin*>(pluginMap[pluginName].plugin)->runResult();
return true;
}
return false;
}
 
bool PluginManager::callImportExportPlugin(const QCString pluginName, const QString & arg)
{
bool result = false;
if (DLLexists(pluginName))
{
429,6 → 419,11
if (plugin)
result = plugin->run(arg);
}
if (result)
{
retval = dynamic_cast<ScActionPlugin*>(pluginMap[pluginName].plugin)->runResult();
result = true;
}
return result;
}