View Issue Details

IDProjectCategoryView StatusLast Update
0002800ScribusImport / Exportpublic2005-12-22 13:29
ReporterplinnellAssigned Toringerc 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version1.3.2cvs 
Fixed in Version1.3.2cvs 
Summary0002800: Wanted option to import EPS or SVG into a new document.
DescriptionWhen working with EPS and SVG files it is sometimes preferable to import it into a new doc with the size the bounding box of EPS or SVG. Enabling this eliminates the need to close all open docs.
TagsNo tags attached.
Patch

Relationships

related to 0002931 acknowledged Metabug: SVG 

Activities

fschmid

2005-11-10 16:02

developer   ~0007388

Last edited: 2005-11-10 16:02

Normally you just need to open the .eps or .svg file with File->Open to get the desired behaviour, but Craig Ringer has currently disabled that. Last night i tried to repair that, but the code from Craig isn't finished and i don't want to disturb his plannings.

plinnell

2005-11-30 23:53

viewer   ~0007594

Craig, Its working now. Is your code all sorted ? If so please, resolved fixed. Thanks

ringerc

2005-12-01 09:10

reporter   ~0007596

Having disabled it is news to me, not that I couldn't have screwed up. Because I have little time at the moment one of my goals with the fileloader stuff has been to make each step independent and work fine in CVS, so the transition can be without breaking anything.

Nonetheless, it does appear that something's broken. File->Open of an EPS isn't working, though I'm not sure why. There's also an intermittent segfault in slotFileNew that may be related. I'll check it out.

plinnell

2005-12-02 19:55

viewer   ~0007608

EPS is working here sometimes. Sometime it loops.

After a Crtl-C (running for 10 mins)

run
Starting program: /usr/local/bin/scribus
[Thread debugging using libthread_db enabled]
[New Thread 1073896224 (LWP 7188)]

Program received signal SIGINT, Interrupt.
[Switching to Thread 1073896224 (LWP 7188)]
0xffffe410 in __kernel_vsyscall ()
(gdb) bt
#0 0xffffe410 in __kernel_vsyscall ()
0000001 0x410d6f2d in ___newselect_nocancel () from /lib/tls/libc.so.6
0000002 0x41789293 in QEventLoop::processEvents ()
   from /usr/lib/qt3/lib/libqt-mt.so.3
0000003 0x417f2193 in QEventLoop::enterLoop () from /usr/lib/qt3/lib/libqt-mt.so.3
0000004 0x417f2076 in QEventLoop::exec () from /usr/lib/qt3/lib/libqt-mt.so.3
0000005 0x417dabcf in QApplication::exec () from /usr/lib/qt3/lib/libqt-mt.so.3
0000006 0x08610fd5 in mainApp (argc=1, argv=0xbf80a234) at main_nix.cpp:69
0000007 0x08611022 in main (argc=1, argv=0xbf80a234) at main_nix.cpp:44

ringerc

2005-12-03 19:37

reporter   ~0007621

Are you sure it's in an infinite loop? The backtrace looks to me like it's just in the event loop. Could it just be the cursor staying as the busy cursor?

As for EPS import, it turns out that it shouldn't work via File->Open . That path involves a dynamic_cast<ScActionPlugin*> of a LoadSavePlugin*, which no longer inherits ScActionPlugin . This, naturally, does not work.

I have a patch to fix it, but it hits a reliable segfault due to what looks like some changes cbradney made to page creation. I'll have to talk it over with him so we can get that fixed at the same time as I check my fix in.

2005-12-03 19:37

 

PSIMPORT_FIX.diff (35,384 bytes)   
? .loadsaveplugin.h.swp
? about_builddate.inc
? tocindexprefs.cpp
? tocindexprefs.h
? doc/en/2
? doc/en/plugin_howto_temp.html
? doc/en/plugin_overview.html
Index: fileloader.cpp
===================================================================
RCS file: /cvs/Scribus/scribus/Attic/fileloader.cpp,v
retrieving revision 1.1.2.170
diff -u -r1.1.2.170 fileloader.cpp
--- fileloader.cpp	29 Nov 2005 13:15:36 -0000	1.1.2.170
+++ fileloader.cpp	1 Dec 2005 21:09:27 -0000
@@ -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,13 +385,16 @@
 			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;
Index: fileloader.h
===================================================================
RCS file: /cvs/Scribus/scribus/Attic/fileloader.h,v
retrieving revision 1.1.2.22
diff -u -r1.1.2.22 fileloader.h
--- fileloader.h	7 Nov 2005 20:04:06 -0000	1.1.2.22
+++ fileloader.h	1 Dec 2005 21:09:27 -0000
@@ -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;
Index: loadsaveplugin.cpp
===================================================================
RCS file: /cvs/Scribus/scribus/Attic/loadsaveplugin.cpp,v
retrieving revision 1.1.2.5
diff -u -r1.1.2.5 loadsaveplugin.cpp
--- loadsaveplugin.cpp	24 Oct 2005 16:51:36 -0000	1.1.2.5
+++ loadsaveplugin.cpp	1 Dec 2005 21:09:28 -0000
@@ -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,15 +110,15 @@
 
 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);
 }
 
 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;
+}
Index: loadsaveplugin.h
===================================================================
RCS file: /cvs/Scribus/scribus/Attic/loadsaveplugin.h,v
retrieving revision 1.1.2.4
diff -u -r1.1.2.4 loadsaveplugin.h
--- loadsaveplugin.h	24 Oct 2005 16:51:36 -0000	1.1.2.4
+++ loadsaveplugin.h	1 Dec 2005 21:09:28 -0000
@@ -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,7 +37,18 @@
 		// 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.
@@ -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
Index: pluginmanager.cpp
===================================================================
RCS file: /cvs/Scribus/scribus/Attic/pluginmanager.cpp,v
retrieving revision 1.1.2.29
diff -u -r1.1.2.29 pluginmanager.cpp
--- pluginmanager.cpp	22 Nov 2005 23:02:41 -0000	1.1.2.29
+++ pluginmanager.cpp	1 Dec 2005 21:09:28 -0000
@@ -409,17 +409,7 @@
 }
 
 // Compatability kludge
-bool PluginManager::callImportExportPlugin(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 PluginManager::callSpecialActionPlugin(const QCString pluginName, const QString & arg, QString & retval)
 {
 	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;
 }
 
Index: pluginmanager.h
===================================================================
RCS file: /cvs/Scribus/scribus/Attic/pluginmanager.h,v
retrieving revision 1.1.2.21
diff -u -r1.1.2.21 pluginmanager.h
--- pluginmanager.h	29 Nov 2005 20:27:04 -0000	1.1.2.21
+++ pluginmanager.h	1 Dec 2005 21:09:28 -0000
@@ -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.
 
Index: story.cpp
===================================================================
RCS file: /cvs/Scribus/scribus/story.cpp,v
retrieving revision 1.58.2.102
diff -u -r1.58.2.102 story.cpp
--- story.cpp	12 Nov 2005 13:56:08 -0000	1.58.2.102
+++ story.cpp	1 Dec 2005 21:09:29 -0000
@@ -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");
Index: plugins/fileloader/oldscribusformat/oldscribusformat.cpp
===================================================================
RCS file: /cvs/Scribus/scribus/plugins/fileloader/oldscribusformat/Attic/oldscribusformat.cpp,v
retrieving revision 1.1.2.4
diff -u -r1.1.2.4 oldscribusformat.cpp
--- plugins/fileloader/oldscribusformat/oldscribusformat.cpp	30 Oct 2005 07:07:10 -0000	1.1.2.4
+++ plugins/fileloader/oldscribusformat/oldscribusformat.cpp	1 Dec 2005 21:09:29 -0000
@@ -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;
 }
Index: plugins/fileloader/oldscribusformat/oldscribusformat.h
===================================================================
RCS file: /cvs/Scribus/scribus/plugins/fileloader/oldscribusformat/Attic/oldscribusformat.h,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 oldscribusformat.h
--- plugins/fileloader/oldscribusformat/oldscribusformat.h	24 Oct 2005 16:51:36 -0000	1.1.2.2
+++ plugins/fileloader/oldscribusformat/oldscribusformat.h	1 Dec 2005 21:09:29 -0000
@@ -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);
Index: plugins/fileloader/oodraw/oodrawimp.cpp
===================================================================
RCS file: /cvs/Scribus/scribus/plugins/fileloader/oodraw/oodrawimp.cpp,v
retrieving revision 1.1.2.66
diff -u -r1.1.2.66 oodrawimp.cpp
--- plugins/fileloader/oodraw/oodrawimp.cpp	29 Nov 2005 13:15:36 -0000	1.1.2.66
+++ plugins/fileloader/oodraw/oodrawimp.cpp	1 Dec 2005 21:09:30 -0000
@@ -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,29 +111,27 @@
 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;
 	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;
 	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);
Index: plugins/fileloader/oodraw/oodrawimp.h
===================================================================
RCS file: /cvs/Scribus/scribus/plugins/fileloader/oodraw/oodrawimp.h,v
retrieving revision 1.1.2.15
diff -u -r1.1.2.15 oodrawimp.h
--- plugins/fileloader/oodraw/oodrawimp.h	24 Oct 2005 16:51:36 -0000	1.1.2.15
+++ plugins/fileloader/oodraw/oodrawimp.h	1 Dec 2005 21:09:30 -0000
@@ -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:
Index: plugins/psimport/importpsplugin.cpp
===================================================================
RCS file: /cvs/Scribus/scribus/plugins/psimport/Attic/importpsplugin.cpp,v
retrieving revision 1.1.2.11
diff -u -r1.1.2.11 importpsplugin.cpp
--- plugins/psimport/importpsplugin.cpp	24 Oct 2005 21:11:16 -0000	1.1.2.11
+++ plugins/psimport/importpsplugin.cpp	1 Dec 2005 21:09:32 -0000
@@ -88,16 +88,15 @@
 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;
 	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)
Index: plugins/psimport/importpsplugin.h
===================================================================
RCS file: /cvs/Scribus/scribus/plugins/psimport/Attic/importpsplugin.h,v
retrieving revision 1.1.2.4
diff -u -r1.1.2.4 importpsplugin.h
--- plugins/psimport/importpsplugin.h	24 Oct 2005 16:51:36 -0000	1.1.2.4
+++ plugins/psimport/importpsplugin.h	1 Dec 2005 21:09:32 -0000
@@ -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
Index: plugins/scriptplugin/svgimport.cpp
===================================================================
RCS file: /cvs/Scribus/scribus/plugins/scriptplugin/Attic/svgimport.cpp,v
retrieving revision 1.1.2.4
diff -u -r1.1.2.4 svgimport.cpp
--- plugins/scriptplugin/svgimport.cpp	11 Sep 2005 22:00:31 -0000	1.1.2.4
+++ plugins/scriptplugin/svgimport.cpp	1 Dec 2005 21:09:35 -0000
@@ -1,24 +1,35 @@
 #include "svgimport.h"
 #include "cmdvar.h"
 #include "cmdutil.h"
-#include "pluginmanager.h"
 
-#include <qstring.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;
 
 	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);
Index: plugins/svgimplugin/svgplugin.cpp
===================================================================
RCS file: /cvs/Scribus/scribus/plugins/svgimplugin/svgplugin.cpp,v
retrieving revision 1.31.2.80
diff -u -r1.31.2.80 svgplugin.cpp
--- plugins/svgimplugin/svgplugin.cpp	29 Nov 2005 13:15:36 -0000	1.31.2.80
+++ plugins/svgimplugin/svgplugin.cpp	1 Dec 2005 21:09:37 -0000
@@ -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
Index: plugins/svgimplugin/svgplugin.h
===================================================================
RCS file: /cvs/Scribus/scribus/plugins/svgimplugin/svgplugin.h,v
retrieving revision 1.6.2.18
diff -u -r1.6.2.18 svgplugin.h
--- plugins/svgimplugin/svgplugin.h	5 Nov 2005 15:45:08 -0000	1.6.2.18
+++ plugins/svgimplugin/svgplugin.h	1 Dec 2005 21:09:37 -0000
@@ -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 = "";
 		}
-	int Type;
-	bool typeValid;
-	QString reference;
+	bool CSpace;
+	bool cspaceValid;
 	VGradient gradient;
 	bool gradientValid;
+	QWMatrix matrix;
+	bool matrixValid;
+	QString reference;
+	int Type;
+	bool typeValid;
 	double X1;
 	bool x1Valid;
-	double Y1;
-	bool y1Valid;
 	double X2;
 	bool x2Valid;
+	double Y1;
+	bool y1Valid;
 	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;
-	QString FillCol;
+	bool CSpace;
 	QString CurCol;
+	QValueList<double> dashArray;
+	double dashOffset;
+	QString Family;
+	QString FillCol;
+	int FontSize;
 	QString GCol1;
 	QString GCol2;
+	VGradient	GradCo;
+	int Gradient;
 	double GX1;
-	double GY1;
 	double GX2;
+	double GY1;
 	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
PSIMPORT_FIX.diff (35,384 bytes)   

ringerc

2005-12-03 19:38

reporter   ~0007622

Attached the working copy of the fix (which includes another stage of fileloader/loadsaveplugin work) to make sure it doesn't get lost.

Issue History

Date Modified Username Field Change
2005-11-07 00:22 plinnell New Issue
2005-11-07 00:28 plinnell Summary A close all menu item => Wanted option to import EPS or SVG into a new document.
2005-11-07 00:28 plinnell Description Updated
2005-11-10 16:02 fschmid Note Added: 0007388
2005-11-10 16:02 fschmid Note Edited: 0007388
2005-11-30 23:52 plinnell Status new => assigned
2005-11-30 23:52 plinnell Assigned To => ringerc
2005-11-30 23:53 plinnell Note Added: 0007594
2005-12-01 09:10 ringerc Note Added: 0007596
2005-12-02 19:55 plinnell Note Added: 0007608
2005-12-03 19:37 ringerc Note Added: 0007621
2005-12-03 19:37 ringerc File Added: PSIMPORT_FIX.diff
2005-12-03 19:38 ringerc Note Added: 0007622
2005-12-05 10:49 ringerc Status assigned => resolved
2005-12-05 10:49 ringerc Resolution open => fixed
2005-12-05 10:49 ringerc Category Usability => Import / Export
2005-12-05 10:49 ringerc Fixed in Version => 1.3.2cvs
2005-12-22 13:29 cbradney Status resolved => closed
2006-05-17 19:10 christoph_s Relationship added related to 0002931