r14665 by fschmid - Vector Import Plugins: more previews in the Fileselectors for vector images, added them for XFIG and CGM.

scribus-commit scribus-commit at lists.scribus.net
Tue Feb 9 15:11:35 CET 2010


Revision: 14665
Author: fschmid
Date: 2010-02-09T14:03:29.405788Z
Commit message: Vector Import Plugins: more previews in the Fileselectors for vector images, added them for XFIG and CGM.

Changeset: 
M  /trunk/Scribus/scribus/plugins/import/xar/importxarplugin.cpp
M  /trunk/Scribus/scribus/plugins/import/drw/importdrwplugin.cpp
M  /trunk/Scribus/scribus/plugins/import/xfig/importxfigplugin.cpp
M  /trunk/Scribus/scribus/plugins/import/wpg/importwpgplugin.cpp
M  /trunk/Scribus/scribus/plugins/import/idml/importidml.cpp
M  /trunk/Scribus/scribus/plugins/import/cgm/importcgm.cpp
M  /trunk/Scribus/scribus/plugins/import/cvg/importcvgplugin.cpp
M  /trunk/Scribus/scribus/plugins/import/xfig/importxfigplugin.h
M  /trunk/Scribus/scribus/plugins/import/cgm/importcgm.h
M  /trunk/Scribus/scribus/plugins/import/svg/svgplugin.cpp
M  /trunk/Scribus/scribus/plugins/import/ps/importpsplugin.cpp
M  /trunk/Scribus/scribus/plugins/import/xar/importxar.cpp
M  /trunk/Scribus/scribus/ui/customfdialog.cpp
M  /trunk/Scribus/scribus/loadsaveplugin.cpp
M  /trunk/Scribus/scribus/plugins/import/drw/importdrw.cpp
M  /trunk/Scribus/scribus/plugins/import/xfig/importxfig.cpp
M  /trunk/Scribus/scribus/plugins/import/cgm/importcgmplugin.cpp
M  /trunk/Scribus/scribus/plugins/import/pct/importpctplugin.cpp
M  /trunk/Scribus/scribus/loadsaveplugin.h
M  /trunk/Scribus/scribus/plugins/fileloader/oodraw/oodrawimp.cpp
M  /trunk/Scribus/scribus/plugins/import/cvg/importcvg.cpp
M  /trunk/Scribus/scribus/plugins/import/xfig/importxfig.h
M  /trunk/Scribus/scribus/plugins/import/cgm/importcgmplugin.h
M  /trunk/Scribus/scribus/plugins/import/ai/importaiplugin.cpp
M  /trunk/Scribus/scribus/plugins/import/wmf/wmfimportplugin.cpp

Diffs:
Index: scribus/loadsaveplugin.h
===================================================================
--- scribus/loadsaveplugin.h	(revision 14664)
+++ scribus/loadsaveplugin.h	(revision 14665)
@@ -55,6 +55,9 @@
 
 		// Static functions:
 
+		// Return a list of file extensions
+		static const QStringList getExtensionsForImport(const int id = 47);
+
 		// Return a list of format descriptions suitable for use with
 		// QFileDialog.  You can convert it to QString form with
 		// fileDialogSaveFilter().join(";;")
@@ -217,6 +220,8 @@
 		QRegExp nameMatch;
 		// MIME type(s) that should be matched by this format.
 		QStringList mimeTypes;
+		// Extension list supported by format
+		QStringList fileExtensions;
 		// Can we load it?
 		bool load;
 		// Can we save it?
Index: scribus/loadsaveplugin.cpp
===================================================================
--- scribus/loadsaveplugin.cpp	(revision 14664)
+++ scribus/loadsaveplugin.cpp	(revision 14665)
@@ -60,6 +60,38 @@
 	return getDialogFilter(false);
 }
 
+const QStringList LoadSavePlugin::getExtensionsForImport(const int id)
+{
+	QList<FileFormat>::const_iterator it(findFormat(id));
+	QList<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
+	// in the list.
+	//First, check if we even have any plugins to load with
+	if (it!=itEnd)
+	{
+		if ((*it).load)
+			filterList.append((*it).fileExtensions);
+		unsigned int lastID = (*it).formatId;
+		++it;
+		for ( ; it != itEnd ; ++it )
+		{
+			// Find the next load/save (as appropriate) plugin for the next format type
+			if (((*it).load) && ((*it).formatId > lastID))
+			{
+				// And add it to the filter list, since we know it's 
+				// the highest priority because of the sort order.
+				filterList.append((*it).fileExtensions);
+				lastID = (*it).formatId;
+			}
+		}
+	}
+	else
+		qDebug("%s", tr("No File Loader Plugins Found").toLocal8Bit().data());
+	return filterList;
+}
+
 const QStringList LoadSavePlugin::getDialogFilter(bool forLoad)
 {
 	QList<FileFormat>::const_iterator it(formats.constBegin());
Index: scribus/ui/customfdialog.cpp
===================================================================
--- scribus/ui/customfdialog.cpp	(revision 14664)
+++ scribus/ui/customfdialog.cpp	(revision 14665)
@@ -41,6 +41,7 @@
 #include "fileloader.h"
 #include "loadsaveplugin.h"
 #include "../plugins/formatidlist.h"
+#include "prefsmanager.h"
 #include "scfilewidget.h"
 #include "cmsettings.h"
 #include "commonstrings.h"
@@ -48,6 +49,7 @@
 #include "scimage.h"
 #include "scribusstructs.h"
 #include "scslainforeader.h"
+#include "units.h"
 #include "util.h"
 #include "util_color.h"
 #include "util_formats.h"
@@ -76,6 +78,7 @@
 
 QIcon ImIconProvider::icon(const QFileInfo &fi) const
 {
+	QStringList allFormatsV = LoadSavePlugin::getExtensionsForImport(FORMATID_ODGIMPORT);
 	QString ext = fi.suffix().toLower();
 	if (ext.isEmpty())
 		return QFileIconProvider::icon(fi);
@@ -98,8 +101,7 @@
 			return oosxdpm;
 		else if (ext.endsWith("sxw", Qt::CaseInsensitive))
 			return oosxwpm;
-		else if (ext.endsWith("svg") || ext.endsWith("svgz") || ext.endsWith("cvg") || ext.endsWith("wpg") || ext.endsWith("fig")
-				 || ext.endsWith("ai") || ext.endsWith("wmf") || ext.endsWith("pct") || ext.endsWith("pict") || ext.endsWith("pic"))
+		else if (allFormatsV.contains(ext))
 			return vectorpm;
 		else
 			return QFileIconProvider::icon(fi);
@@ -144,30 +146,7 @@
  	QStringList formats = formatD.split("|");
 	formats.append("pat");
 	
-	QStringList allFormatsV;
-	int fmtCode = FORMATID_ODGIMPORT;
-	const FileFormat *fmt = LoadSavePlugin::getFormatById(fmtCode);
-	while (fmt != 0)
-	{
-		if (fmt->load)
-		{
-			QString fmC = "";
-			int an = fmt->filter.indexOf("(");
-			int en = fmt->filter.indexOf(")");
-			while (an != -1)
-			{
-				fmC = fmt->filter.mid(an+1, en-an-1);
-				fmC.remove("*.");
-				allFormatsV += fmC.split(" ", QString::SkipEmptyParts);
-				an = fmt->filter.indexOf("(", en);
-				en = fmt->filter.indexOf(")", an);
-			}
-			
-		}
-		fmtCode++;
-		fmt = LoadSavePlugin::getFormatById(fmtCode);
-	}
-	
+	QStringList allFormatsV = LoadSavePlugin::getExtensionsForImport(FORMATID_ODGIMPORT);
 	if (ext.isEmpty())
 		ext = getImageType(name);
 	if (formats.contains(ext.toUtf8()))
@@ -228,13 +207,19 @@
 				QImage im = fmt->readThumbnail(name);
 				if (!im.isNull())
 				{
-					im = im.scaled(w - 5, h - 5, Qt::KeepAspectRatio, Qt::SmoothTransformation);
+					QString desc = tr("Size:")+" ";
+					desc += value2String(im.text("XSize").toDouble(), PrefsManager::instance()->appPrefs.docSetupPrefs.docUnitIndex, true, true);
+					desc += " x ";
+					desc += value2String(im.text("YSize").toDouble(), PrefsManager::instance()->appPrefs.docSetupPrefs.docUnitIndex, true, true);
+					im = im.scaled(w - 5, h - 21, Qt::KeepAspectRatio, Qt::SmoothTransformation);
 					QPainter p;
 					QBrush b(QColor(205,205,205), loadIcon("testfill.png"));
 					pm = *pixmap();
 					p.begin(&pm);
-					p.fillRect(0, 0, w, h, b);
-					p.drawImage((w - im.width()) / 2, (h - im.height()) / 2, im);
+					p.fillRect(0, 0, w, h-21, b);
+					p.fillRect(0, h-21, w, 21, QColor(255, 255, 255));
+					p.drawImage((w - im.width()) / 2, (h - 21 - im.height()) / 2, im);
+					p.drawText(2, h-5, desc);
 					p.end();
 					setPixmap(pm);
 					repaint();
Index: scribus/plugins/fileloader/oodraw/oodrawimp.cpp
===================================================================
--- scribus/plugins/fileloader/oodraw/oodrawimp.cpp	(revision 14664)
+++ scribus/plugins/fileloader/oodraw/oodrawimp.cpp	(revision 14665)
@@ -129,6 +129,7 @@
 	odtformat.formatId = FORMATID_ODGIMPORT;
 	odtformat.filter = odtName + " (*.odg *.ODG)"; // QFileDialog filter
 	odtformat.nameMatch = QRegExp("\\.odg$", Qt::CaseInsensitive);
+	odtformat.fileExtensions = QStringList() << "odg";
 	odtformat.load = true;
 	odtformat.save = false;
 	odtformat.mimeTypes = QStringList("application/vnd.oasis.opendocument.graphics"); // MIME types
@@ -141,6 +142,7 @@
 	sxdformat.formatId = FORMATID_SXDIMPORT;
 	sxdformat.filter = sxdName + " (*.sxd *.SXD)"; // QFileDialog filter
 	sxdformat.nameMatch = QRegExp("\\.sxd$", Qt::CaseInsensitive);
+	sxdformat.fileExtensions = QStringList() << "sxd";
 	sxdformat.load = true;
 	sxdformat.save = false;
 	sxdformat.mimeTypes = QStringList("application/vnd.sun.xml.draw"); // MIME types
Index: scribus/plugins/import/cvg/importcvgplugin.cpp
===================================================================
--- scribus/plugins/import/cvg/importcvgplugin.cpp	(revision 14664)
+++ scribus/plugins/import/cvg/importcvgplugin.cpp	(revision 14665)
@@ -96,6 +96,7 @@
 	fmt.formatId = FORMATID_CVGIMPORT;
 	fmt.filter = FormatsManager::instance()->extensionsForFormat(FormatsManager::CVG); // QFileDialog filter
 	fmt.nameMatch = QRegExp("\\."+FormatsManager::instance()->extensionListForFormat(FormatsManager::CVG, 1)+"$", Qt::CaseInsensitive);
+	fmt.fileExtensions = QStringList() << "cvg";
 	fmt.load = true;
 	fmt.save = false;
 	fmt.mimeTypes = FormatsManager::instance()->mimetypeOfFormat(FormatsManager::CVG); // MIME types
Index: scribus/plugins/import/cvg/importcvg.cpp
===================================================================
--- scribus/plugins/import/cvg/importcvg.cpp	(revision 14664)
+++ scribus/plugins/import/cvg/importcvg.cpp	(revision 14665)
@@ -71,17 +71,14 @@
 	docHeight = h;
 	ScribusView* tempView;
 	progressDialog = NULL;
-	if (!m_Doc)
-	{
-		haveDoc = true;
-		m_Doc = new ScribusDoc();
-		m_Doc->setup(0, 1, 1, 1, 1, "Custom", "Custom");
-		m_Doc->setPage(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false);
-		m_Doc->addPage(0);
-		tempView = new ScribusView(0, ScCore->primaryMainWindow(), m_Doc);
-		tempView->setScale(1);
-		m_Doc->setGUI(false, ScCore->primaryMainWindow(), tempView);
-	}
+	haveDoc = true;
+	m_Doc = new ScribusDoc();
+	m_Doc->setup(0, 1, 1, 1, 1, "Custom", "Custom");
+	m_Doc->setPage(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false);
+	m_Doc->addPage(0);
+	tempView = new ScribusView(0, ScCore->primaryMainWindow(), m_Doc);
+	tempView->setScale(1);
+	m_Doc->setGUI(false, ScCore->primaryMainWindow(), tempView);
 	baseX = m_Doc->currentPage()->xOffset();
 	baseY = m_Doc->currentPage()->yOffset();
 	Elements.clear();
@@ -169,9 +166,13 @@
 				tmpSel->addItem(Elements.at(dre), true);
 			}
 			tmpSel->setGroupRect();
-			double sc = 500.0 / qMax(tmpSel->width(), tmpSel->height());
+			double xs = tmpSel->width();
+			double ys = tmpSel->height();
+			double sc = 500.0 / qMax(xs, ys);
 			m_Doc->scaleGroup(sc, sc, true, tmpSel);
 			tmpImage = Elements.at(0)->DrawObj_toImage();
+			tmpImage.setText("XSize", QString("%1").arg(xs));
+			tmpImage.setText("YSize", QString("%1").arg(ys));
 		}
 		m_Doc->itemSelection_DeleteItem(tmpSel);
 		m_Doc->view()->updatesOn(true);
Index: scribus/plugins/import/svg/svgplugin.cpp
===================================================================
--- scribus/plugins/import/svg/svgplugin.cpp	(revision 14664)
+++ scribus/plugins/import/svg/svgplugin.cpp	(revision 14665)
@@ -125,6 +125,7 @@
 	fmt.formatId = FORMATID_SVGIMPORT;
 	fmt.filter = FormatsManager::instance()->extensionsForFormat(FormatsManager::SVG);
  	fmt.nameMatch = QRegExp("\\."+FormatsManager::instance()->extensionListForFormat(FormatsManager::SVG, 1)+"$", Qt::CaseInsensitive);
+	fmt.fileExtensions = QStringList() << "svg" << "svgz";
 	fmt.load = true;
 	fmt.save = false;
 	fmt.mimeTypes = FormatsManager::instance()->mimetypeOfFormat(FormatsManager::SVG);
Index: scribus/plugins/import/ps/importpsplugin.cpp
===================================================================
--- scribus/plugins/import/ps/importpsplugin.cpp	(revision 14664)
+++ scribus/plugins/import/ps/importpsplugin.cpp	(revision 14665)
@@ -95,6 +95,7 @@
 	fmt.formatId = FORMATID_EPSIMPORT;
 	fmt.filter = FormatsManager::instance()->extensionsForFormat(FormatsManager::EPS);// QFileDialog filter
  	fmt.nameMatch = QRegExp("\\.("+FormatsManager::instance()->extensionListForFormat(FormatsManager::EPS, 1)+")$", Qt::CaseInsensitive);
+	fmt.fileExtensions = QStringList() << "eps" << "epsf" << "epsi" << "eps2" << "eps3" << "epi" << "ept";
 	fmt.load = true;
 	fmt.save = false;
 	fmt.mimeTypes = FormatsManager::instance()->mimetypeOfFormat(FormatsManager::EPS); // MIME types
@@ -106,6 +107,7 @@
 	fmt2.formatId = FORMATID_PSIMPORT;
 	fmt2.filter = FormatsManager::instance()->extensionsForFormat(FormatsManager::PS);// QFileDialog filter
  	fmt2.nameMatch = QRegExp("\\.("+FormatsManager::instance()->extensionListForFormat(FormatsManager::PS, 1)+")$", Qt::CaseInsensitive);
+	fmt.fileExtensions = QStringList() << "ps";
 	fmt2.load = true;
 	fmt2.save = false;
 	fmt2.mimeTypes = FormatsManager::instance()->mimetypeOfFormat(FormatsManager::PS); // MIME types
@@ -117,6 +119,7 @@
 	fmt3.formatId = FORMATID_PDFIMPORT;
 	fmt3.filter = FormatsManager::instance()->extensionsForFormat(FormatsManager::PDF);// QFileDialog filter
 	fmt3.nameMatch = QRegExp("\\."+FormatsManager::instance()->extensionListForFormat(FormatsManager::PDF, 1)+"$", Qt::CaseInsensitive);
+	fmt.fileExtensions = QStringList() << "pdf";
 	fmt3.load = true;
 	fmt3.save = false;
 	fmt3.mimeTypes = FormatsManager::instance()->mimetypeOfFormat(FormatsManager::PDF); // MIME types
Index: scribus/plugins/import/idml/importidml.cpp
===================================================================
--- scribus/plugins/import/idml/importidml.cpp	(revision 14664)
+++ scribus/plugins/import/idml/importidml.cpp	(revision 14665)
@@ -83,6 +83,7 @@
 	fmt.formatId = 0;
 	fmt.filter =idmlName + "(*.idml *.IDML)"; // QFileDialog filter
 	fmt.nameMatch = QRegExp("\\.idml$", Qt::CaseInsensitive);
+	fmt.fileExtensions = QStringList() << "idml";
 	fmt.load = true;
 	fmt.save = false;
 	fmt.mimeTypes = QStringList();
Index: scribus/plugins/import/cgm/importcgmplugin.cpp
===================================================================
--- scribus/plugins/import/cgm/importcgmplugin.cpp	(revision 14664)
+++ scribus/plugins/import/cgm/importcgmplugin.cpp	(revision 14665)
@@ -97,6 +97,7 @@
 	fmt.formatId = 0;
 	fmt.filter = tr("CGM File (*.cgm *.CGM)"); // QFileDialog filter
 	fmt.nameMatch = QRegExp("\\.cgm$", Qt::CaseInsensitive);
+	fmt.fileExtensions = QStringList() << "cgm";
 	fmt.load = true;
 	fmt.save = false;
 	fmt.mimeTypes = QStringList(); // MIME types
@@ -161,3 +162,23 @@
 	delete dia;
 	return true;
 }
+
+QImage ImportCgmPlugin::readThumbnail(const QString& fileName)
+{
+	bool wasUndo = false;
+	if( fileName.isEmpty() )
+		return QImage();
+	if (UndoManager::undoEnabled())
+	{
+		UndoManager::instance()->setUndoEnabled(false);
+		wasUndo = true;
+	}
+	m_Doc = ScCore->primaryMainWindow()->doc;
+	CgmPlug *dia = new CgmPlug(m_Doc, lfCreateThumbnail);
+	Q_CHECK_PTR(dia);
+	QImage ret = dia->readThumbnail(fileName);
+	if (wasUndo)
+		UndoManager::instance()->setUndoEnabled(true);
+	delete dia;
+	return ret;
+}
Index: scribus/plugins/import/cgm/importcgm.cpp
===================================================================
--- scribus/plugins/import/cgm/importcgm.cpp	(revision 14664)
+++ scribus/plugins/import/cgm/importcgm.cpp	(revision 14665)
@@ -59,9 +59,165 @@
 {
 	tmpSel=new Selection(this, false);
 	m_Doc=doc;
+	importerFlags = flags;
 	interactive = (flags & LoadSavePlugin::lfInteractive);
 }
 
+QImage CgmPlug::readThumbnail(QString fName)
+{
+	QFileInfo fi = QFileInfo(fName);
+	baseFile = QDir::cleanPath(QDir::toNativeSeparators(fi.absolutePath()+"/"));
+	bool haveDoc = false;
+	double b, h;
+	b = PrefsManager::instance()->appPrefs.docSetupPrefs.pageWidth;
+	h = PrefsManager::instance()->appPrefs.docSetupPrefs.pageHeight;
+	docWidth = b;
+	docHeight = h;
+	ScribusView* tempView;
+	progressDialog = NULL;
+	haveDoc = true;
+	m_Doc = new ScribusDoc();
+	m_Doc->setup(0, 1, 1, 1, 1, "Custom", "Custom");
+	m_Doc->setPage(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false);
+	m_Doc->addPage(0);
+	tempView = new ScribusView(0, ScCore->primaryMainWindow(), m_Doc);
+	tempView->setScale(1);
+	m_Doc->setGUI(false, ScCore->primaryMainWindow(), tempView);
+	baseX = m_Doc->currentPage()->xOffset();
+	baseY = m_Doc->currentPage()->yOffset();
+	Elements.clear();
+	m_Doc->setLoading(true);
+	m_Doc->DoDrawing = false;
+	m_Doc->view()->updatesOn(false);
+	m_Doc->scMW()->ScriptRunning = true;
+	qApp->changeOverrideCursor(QCursor(Qt::WaitCursor));
+	QString CurDirP = QDir::currentPath();
+	QDir::setCurrent(fi.path());
+	int groupCount = m_Doc->GroupCounter;
+	int itemCount = m_Doc->TotalItems;
+	if (convert(fName))
+	{
+		tmpSel->clear();
+		QDir::setCurrent(CurDirP);
+		if (Elements.count() > 0)
+		{
+			bool isGroup = true;
+			int firstElem = -1;
+			if (Elements.at(0)->Groups.count() != 0)
+				firstElem = Elements.at(0)->Groups.top();
+			for (int bx = 0; bx < Elements.count(); ++bx)
+			{
+				PageItem* bxi = Elements.at(bx);
+				if (bxi->Groups.count() != 0)
+				{
+					if (bxi->Groups.top() != firstElem)
+						isGroup = false;
+				}
+				else
+					isGroup = false;
+			}
+			if (!isGroup)
+			{
+				double minx = 99999.9;
+				double miny = 99999.9;
+				double maxx = -99999.9;
+				double maxy = -99999.9;
+				uint lowestItem = 999999;
+				uint highestItem = 0;
+				for (int a = 0; a < Elements.count(); ++a)
+				{
+					Elements.at(a)->Groups.push(m_Doc->GroupCounter);
+					PageItem* currItem = Elements.at(a);
+					lowestItem = qMin(lowestItem, currItem->ItemNr);
+					highestItem = qMax(highestItem, currItem->ItemNr);
+					double x1, x2, y1, y2;
+					currItem->getVisualBoundingRect(&x1, &y1, &x2, &y2);
+					minx = qMin(minx, x1);
+					miny = qMin(miny, y1);
+					maxx = qMax(maxx, x2);
+					maxy = qMax(maxy, y2);
+				}
+				double gx = minx;
+				double gy = miny;
+				double gw = maxx - minx;
+				double gh = maxy - miny;
+				PageItem *high = m_Doc->Items->at(highestItem);
+				int z = m_Doc->itemAdd(PageItem::Polygon, PageItem::Rectangle, gx, gy, gw, gh, 0, m_Doc->itemToolPrefs.shapeFillColor, m_Doc->itemToolPrefs.shapeLineColor, true);
+				PageItem *neu = m_Doc->Items->takeAt(z);
+				m_Doc->Items->insert(lowestItem, neu);
+				neu->Groups.push(m_Doc->GroupCounter);
+				neu->setItemName( tr("Group%1").arg(neu->Groups.top()));
+				neu->AutoName = false;
+				neu->isGroupControl = true;
+				neu->groupsLastItem = high;
+				neu->setTextFlowMode(PageItem::TextFlowDisabled);
+				for (int a = 0; a < m_Doc->Items->count(); ++a)
+				{
+					m_Doc->Items->at(a)->ItemNr = a;
+				}
+				Elements.prepend(neu);
+				m_Doc->GroupCounter++;
+			}
+		}
+		m_Doc->DoDrawing = true;
+		qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
+		m_Doc->m_Selection->delaySignalsOn();
+		QImage tmpImage;
+		if (Elements.count() > 0)
+		{
+			for (int dre=0; dre<Elements.count(); ++dre)
+			{
+				tmpSel->addItem(Elements.at(dre), true);
+			}
+			tmpSel->setGroupRect();
+			double xs = tmpSel->width();
+			double ys = tmpSel->height();
+			double sc = 500.0 / qMax(xs, ys);
+			if (sc < 1)
+				m_Doc->scaleGroup(sc, sc, true, tmpSel);
+			tmpImage = Elements.at(0)->DrawObj_toImage();
+			tmpImage.setText("XSize", QString("%1").arg(xs));
+			tmpImage.setText("YSize", QString("%1").arg(ys));
+		}
+		m_Doc->itemSelection_DeleteItem(tmpSel);
+		m_Doc->view()->updatesOn(true);
+		m_Doc->scMW()->ScriptRunning = false;
+		m_Doc->setLoading(false);
+		if (importedColors.count() != 0)
+		{
+			for (int cd = 0; cd < importedColors.count(); cd++)
+			{
+				m_Doc->PageColors.remove(importedColors[cd]);
+			}
+		}
+		m_Doc->m_Selection->delaySignalsOff();
+		if (haveDoc)
+		{
+			delete tempView;
+			delete m_Doc;
+		}
+		m_Doc->GroupCounter = groupCount;
+		m_Doc->TotalItems = itemCount;
+		return tmpImage;
+	}
+	else
+	{
+		QDir::setCurrent(CurDirP);
+		m_Doc->DoDrawing = true;
+		m_Doc->scMW()->ScriptRunning = false;
+		m_Doc->view()->updatesOn(true);
+		qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
+		if (haveDoc)
+		{
+			delete tempView;
+			delete m_Doc;
+		}
+	}
+	m_Doc->GroupCounter = groupCount;
+	m_Doc->TotalItems = itemCount;
+	return QImage();
+}
+
 bool CgmPlug::import(QString fNameIn, const TransactionSettings& trSettings, int flags, bool showProgress)
 {
 	QString fName = fNameIn;
@@ -402,7 +558,8 @@
 				if (paramLen == 31)
 					ts >> paramLen;
 				decodeBinary(ts, elemClass, elemID, paramLen);
-				progressDialog->setProgress("GI", ts.device()->pos());
+				if (progressDialog)
+					progressDialog->setProgress("GI", ts.device()->pos());
 				qApp->processEvents();
 			}
 		}
@@ -1083,30 +1240,36 @@
 	if (elemID == 1)
 	{
 		getBinaryPath(ts, paramLen);
-		Coords.translate(m_Doc->currentPage()->xOffset(), m_Doc->currentPage()->yOffset());
-		if (recordRegion)
-			regionPath.addPath(Coords.toQPainterPath(false));
-		else
+		if (Coords.size() > 3)
 		{
-			int z = m_Doc->itemAdd(PageItem::PolyLine, PageItem::Unspecified, baseX, baseY, 10, 10, lineWidth, CommonStrings::None, lineColor, true);
-			PageItem *ite = m_Doc->Items->at(z);
-			ite->PoLine = Coords.copy();
-			finishItem(ite);
+			Coords.translate(m_Doc->currentPage()->xOffset(), m_Doc->currentPage()->yOffset());
+			if (recordRegion)
+				regionPath.addPath(Coords.toQPainterPath(false));
+			else
+			{
+				int z = m_Doc->itemAdd(PageItem::PolyLine, PageItem::Unspecified, baseX, baseY, 10, 10, lineWidth, CommonStrings::None, lineColor, true);
+				PageItem *ite = m_Doc->Items->at(z);
+				ite->PoLine = Coords.copy();
+				finishItem(ite);
+			}
 		}
 		// qDebug() << "POLYLINE";
 	}
 	else if (elemID == 2)
 	{
 		getBinaryPath(ts, paramLen, true);
-		Coords.translate(m_Doc->currentPage()->xOffset(), m_Doc->currentPage()->yOffset());
-		if (recordRegion)
-			regionPath.addPath(Coords.toQPainterPath(false));
-		else
+		if (Coords.size() > 3)
 		{
-			int z = m_Doc->itemAdd(PageItem::PolyLine, PageItem::Unspecified, baseX, baseY, 10, 10, lineWidth, CommonStrings::None, lineColor, true);
-			PageItem *ite = m_Doc->Items->at(z);
-			ite->PoLine = Coords.copy();
-			finishItem(ite);
+			Coords.translate(m_Doc->currentPage()->xOffset(), m_Doc->currentPage()->yOffset());
+			if (recordRegion)
+				regionPath.addPath(Coords.toQPainterPath(false));
+			else
+			{
+				int z = m_Doc->itemAdd(PageItem::PolyLine, PageItem::Unspecified, baseX, baseY, 10, 10, lineWidth, CommonStrings::None, lineColor, true);
+				PageItem *ite = m_Doc->Items->at(z);
+				ite->PoLine = Coords.copy();
+				finishItem(ite);
+			}
 		}
 		// qDebug() << "DISJOINT POLYLINE";
 	}
@@ -1133,29 +1296,32 @@
 	else if (elemID == 7)
 	{
 		getBinaryPath(ts, paramLen);
-		Coords.translate(m_Doc->currentPage()->xOffset(), m_Doc->currentPage()->yOffset());
-		if (recordRegion)
-			regionPath.addPath(Coords.toQPainterPath(true));
-		else
+		if (Coords.size() > 3)
 		{
-			int z;
-			if (lineVisible)
-			{
-				if ((fillType != 0) || (fillType != 4))
-					z = m_Doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, baseX, baseY, 10, 10, edgeWidth, fillColor, edgeColor, true);
-				else
-					z = m_Doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, baseX, baseY, 10, 10, edgeWidth, CommonStrings::None, edgeColor, true);
-			}
+			Coords.translate(m_Doc->currentPage()->xOffset(), m_Doc->currentPage()->yOffset());
+			if (recordRegion)
+				regionPath.addPath(Coords.toQPainterPath(true));
 			else
 			{
-				if ((fillType != 0) || (fillType != 4))
-					z = m_Doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, baseX, baseY, 10, 10, edgeWidth, fillColor, CommonStrings::None, true);
+				int z;
+				if (lineVisible)
+				{
+					if ((fillType != 0) || (fillType != 4))
+						z = m_Doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, baseX, baseY, 10, 10, edgeWidth, fillColor, edgeColor, true);
+					else
+						z = m_Doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, baseX, baseY, 10, 10, edgeWidth, CommonStrings::None, edgeColor, true);
+				}
 				else
-					z = m_Doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, baseX, baseY, 10, 10, edgeWidth, CommonStrings::None, CommonStrings::None, true);
+				{
+					if ((fillType != 0) || (fillType != 4))
+						z = m_Doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, baseX, baseY, 10, 10, edgeWidth, fillColor, CommonStrings::None, true);
+					else
+						z = m_Doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, baseX, baseY, 10, 10, edgeWidth, CommonStrings::None, CommonStrings::None, true);
+				}
+				PageItem *ite = m_Doc->Items->at(z);
+				ite->PoLine = Coords.copy();
+				finishItem(ite, false);
 			}
-			PageItem *ite = m_Doc->Items->at(z);
-			ite->PoLine = Coords.copy();
-			finishItem(ite, false);
 		}
 		// qDebug() << "POLYGON";
 	}
@@ -1423,15 +1589,18 @@
 	else if (elemID == 26)
 	{
 		getBinaryBezierPath(ts, paramLen);
-		Coords.translate(m_Doc->currentPage()->xOffset(), m_Doc->currentPage()->yOffset());
-		if (recordRegion)
-			regionPath.addPath(Coords.toQPainterPath(false));
-		else
+		if (Coords.size() > 3)
 		{
-			int z = m_Doc->itemAdd(PageItem::PolyLine, PageItem::Unspecified, baseX, baseY, 10, 10, lineWidth, CommonStrings::None, lineColor, true);
-			PageItem *ite = m_Doc->Items->at(z);
-			ite->PoLine = Coords.copy();
-			finishItem(ite);
+			Coords.translate(m_Doc->currentPage()->xOffset(), m_Doc->currentPage()->yOffset());
+			if (recordRegion)
+				regionPath.addPath(Coords.toQPainterPath(false));
+			else
+			{
+				int z = m_Doc->itemAdd(PageItem::PolyLine, PageItem::Unspecified, baseX, baseY, 10, 10, lineWidth, CommonStrings::None, lineColor, true);
+				PageItem *ite = m_Doc->Items->at(z);
+				ite->PoLine = Coords.copy();
+				finishItem(ite);
+			}
 		}
 		// qDebug() << "POLYBEZIER";
 	}
Index: scribus/plugins/import/cgm/importcgmplugin.h
===================================================================
--- scribus/plugins/import/cgm/importcgmplugin.h	(revision 14664)
+++ scribus/plugins/import/cgm/importcgmplugin.h	(revision 14665)
@@ -40,6 +40,7 @@
 		virtual void languageChange();
 		virtual bool fileSupported(QIODevice* file, const QString & fileName=QString::null) const;
 		virtual bool loadFile(const QString & fileName, const FileFormat & fmt, int flags, int index = 0);
+		virtual QImage readThumbnail(const QString& fileName);
 		virtual void addToMainWindowMenu(ScribusMainWindow *) {};
 
 	public slots:
Index: scribus/plugins/import/cgm/importcgm.h
===================================================================
--- scribus/plugins/import/cgm/importcgm.h	(revision 14664)
+++ scribus/plugins/import/cgm/importcgm.h	(revision 14665)
@@ -60,6 +60,7 @@
 	\retval bool true if import was ok
 	 */
 	bool import(QString fn, const TransactionSettings& trSettings, int flags, bool showProgress = true);
+	QImage readThumbnail(QString fn);
 
 private:
 	void parseHeader(QString fName, double &b, double &h);
Index: scribus/plugins/import/pct/importpctplugin.cpp
===================================================================
--- scribus/plugins/import/pct/importpctplugin.cpp	(revision 14664)
+++ scribus/plugins/import/pct/importpctplugin.cpp	(revision 14665)
@@ -89,6 +89,7 @@
 	fmt.formatId = FORMATID_PCTIMPORT;
 	fmt.filter = FormatsManager::instance()->extensionsForFormat(FormatsManager::PCT); // QFileDialog filter
 	fmt.nameMatch = QRegExp("\\."+FormatsManager::instance()->extensionListForFormat(FormatsManager::PCT, 1)+"$", Qt::CaseInsensitive);
+	fmt.fileExtensions = QStringList() << "pct" << "pic" << "pict";
 	fmt.load = true;
 	fmt.save = false;
 	fmt.mimeTypes = FormatsManager::instance()->mimetypeOfFormat(FormatsManager::PCT); // MIME types
Index: scribus/plugins/import/ai/importaiplugin.cpp
===================================================================
--- scribus/plugins/import/ai/importaiplugin.cpp	(revision 14664)
+++ scribus/plugins/import/ai/importaiplugin.cpp	(revision 14665)
@@ -96,6 +96,7 @@
 	fmt.formatId = FORMATID_AIIMPORT;
 	fmt.filter = FormatsManager::instance()->extensionsForFormat(FormatsManager::AI); // QFileDialog filter
 	fmt.nameMatch = QRegExp("\\."+FormatsManager::instance()->extensionListForFormat(FormatsManager::AI, 1)+"$", Qt::CaseInsensitive);
+	fmt.fileExtensions = QStringList() << "ai";
 	fmt.load = true;
 	fmt.save = false;
 	fmt.mimeTypes = FormatsManager::instance()->mimetypeOfFormat(FormatsManager::AI); // MIME types
Index: scribus/plugins/import/wmf/wmfimportplugin.cpp
===================================================================
--- scribus/plugins/import/wmf/wmfimportplugin.cpp	(revision 14664)
+++ scribus/plugins/import/wmf/wmfimportplugin.cpp	(revision 14665)
@@ -113,6 +113,7 @@
 	fmt.formatId = FORMATID_WMFIMPORT;
 	fmt.filter = FormatsManager::instance()->extensionsForFormat(FormatsManager::WMF);
 	fmt.nameMatch = QRegExp("\\."+FormatsManager::instance()->extensionListForFormat(FormatsManager::WMF, 1)+"$", Qt::CaseInsensitive);
+	fmt.fileExtensions = QStringList() << "wmf";
 	fmt.load = true;
 	fmt.save = false;
 	fmt.mimeTypes = FormatsManager::instance()->mimetypeOfFormat(FormatsManager::WMF);
Index: scribus/plugins/import/xar/importxarplugin.cpp
===================================================================
--- scribus/plugins/import/xar/importxarplugin.cpp	(revision 14664)
+++ scribus/plugins/import/xar/importxarplugin.cpp	(revision 14665)
@@ -90,6 +90,7 @@
 	fmt.formatId = 0;
 	fmt.filter = tr("XARA \"*.xar\" File (*.xar *.XAR)"); // QFileDialog filter
 	fmt.nameMatch = QRegExp("\\.xar$", Qt::CaseInsensitive);
+	fmt.fileExtensions = QStringList() << "xar";
 	fmt.load = true;
 	fmt.save = false;
 	fmt.mimeTypes = QStringList(); // MIME types
Index: scribus/plugins/import/xar/importxar.cpp
===================================================================
--- scribus/plugins/import/xar/importxar.cpp	(revision 14664)
+++ scribus/plugins/import/xar/importxar.cpp	(revision 14665)
@@ -114,6 +114,10 @@
 						tsc.readRawData(data.data(), dataLen);
 						image.loadFromData(data);
 					}
+					else if (opCode == 45)
+						handleSpreadInfo(tsc);
+					else
+						tsc.skipRawData(dataLen);
 				}
 				ts.skipRawData(dataLen+1);
 			}
@@ -125,14 +129,17 @@
 					data.resize(dataLen);
 					ts.readRawData(data.data(), dataLen);
 					image.loadFromData(data);
-					break;
 				}
+				else if (opCode == 45)
+					handleSpreadInfo(ts);
 				else
 					ts.skipRawData(dataLen);
 			}
 		}
 		f.close();
 	}
+	image.setText("XSize", QString("%1").arg(docWidth));
+	image.setText("YSize", QString("%1").arg(docHeight));
 	return image;
 }
 
Index: scribus/plugins/import/drw/importdrwplugin.cpp
===================================================================
--- scribus/plugins/import/drw/importdrwplugin.cpp	(revision 14664)
+++ scribus/plugins/import/drw/importdrwplugin.cpp	(revision 14665)
@@ -60,6 +60,7 @@
 	FileFormat* fmt = getFormatByExt("drw");
 	fmt->trName = tr("Micrografx DRW File");
 	fmt->filter = tr("Micrografx DRW File (*.drw *.DRW)");
+	fmt->fileExtensions = QStringList() << "drw";
 }
 
 ImportDrwPlugin::~ImportDrwPlugin()
@@ -97,6 +98,7 @@
 	fmt.formatId = 0;
 	fmt.filter = tr("Micrografx DRW File (*.drw *.DRW)"); // QFileDialog filter
 	fmt.nameMatch = QRegExp("\\.drw$", Qt::CaseInsensitive);
+	fmt.fileExtensions = QStringList() << "drw";
 	fmt.load = true;
 	fmt.save = false;
 	fmt.mimeTypes = QStringList(); // MIME types
Index: scribus/plugins/import/drw/importdrw.cpp
===================================================================
--- scribus/plugins/import/drw/importdrw.cpp	(revision 14664)
+++ scribus/plugins/import/drw/importdrw.cpp	(revision 14665)
@@ -76,17 +76,14 @@
 	docHeight = h;
 	ScribusView* tempView;
 	progressDialog = NULL;
-	if (!m_Doc)
-	{
-		haveDoc = true;
-		m_Doc = new ScribusDoc();
-		m_Doc->setup(0, 1, 1, 1, 1, "Custom", "Custom");
-		m_Doc->setPage(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false);
-		m_Doc->addPage(0);
-		tempView = new ScribusView(0, ScCore->primaryMainWindow(), m_Doc);
-		tempView->setScale(1);
-		m_Doc->setGUI(false, ScCore->primaryMainWindow(), tempView);
-	}
+	haveDoc = true;
+	m_Doc = new ScribusDoc();
+	m_Doc->setup(0, 1, 1, 1, 1, "Custom", "Custom");
+	m_Doc->setPage(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false);
+	m_Doc->addPage(0);
+	tempView = new ScribusView(0, ScCore->primaryMainWindow(), m_Doc);
+	tempView->setScale(1);
+	m_Doc->setGUI(false, ScCore->primaryMainWindow(), tempView);
 	baseX = m_Doc->currentPage()->xOffset();
 	baseY = m_Doc->currentPage()->yOffset();
 	Elements.clear();
@@ -171,7 +168,11 @@
 		m_Doc->m_Selection->delaySignalsOn();
 		QImage tmpImage;
 		if (thumbRead)
+		{
 			tmpImage = thumbnailImage;
+			tmpImage.setText("XSize", QString("%1").arg(docWidth));
+			tmpImage.setText("YSize", QString("%1").arg(docHeight));
+		}
 		else
 		{
 			if (Elements.count() > 0)
@@ -181,9 +182,13 @@
 					tmpSel->addItem(Elements.at(dre), true);
 				}
 				tmpSel->setGroupRect();
-				double sc = 500.0 / qMax(tmpSel->width(), tmpSel->height());
+				double xs = tmpSel->width();
+				double ys = tmpSel->height();
+				double sc = 500.0 / qMax(xs, ys);
 				m_Doc->scaleGroup(sc, sc, true, tmpSel);
 				tmpImage = Elements.at(0)->DrawObj_toImage();
+				tmpImage.setText("XSize", QString("%1").arg(xs));
+				tmpImage.setText("YSize", QString("%1").arg(ys));
 			}
 		}
 		m_Doc->itemSelection_DeleteItem(tmpSel);
@@ -549,10 +554,9 @@
 			if (cmd == 254)
 				break;
 			if ((importerFlags & LoadSavePlugin::lfCreateThumbnail) && (cmd == 11))
-			{
 				thumbRead = true;
+			if ((importerFlags & LoadSavePlugin::lfCreateThumbnail) && (cmd == 27) && (thumbRead))
 				break;
-			}
 			qApp->processEvents();
 		}
 		if (Elements.count() == 0)
Index: scribus/plugins/import/wpg/importwpgplugin.cpp
===================================================================
--- scribus/plugins/import/wpg/importwpgplugin.cpp	(revision 14664)
+++ scribus/plugins/import/wpg/importwpgplugin.cpp	(revision 14665)
@@ -96,6 +96,7 @@
 	fmt.formatId = FORMATID_WPGIMPORT;
 	fmt.filter = FormatsManager::instance()->extensionsForFormat(FormatsManager::WPG); // QFileDialog filter
 	fmt.nameMatch = QRegExp("\\."+FormatsManager::instance()->extensionListForFormat(FormatsManager::WPG, 1)+"$", Qt::CaseInsensitive);
+	fmt.fileExtensions = QStringList() << "wpg";
 	fmt.load = true;
 	fmt.save = false;
 	fmt.mimeTypes = FormatsManager::instance()->mimetypeOfFormat(FormatsManager::WPG); // MIME types
Index: scribus/plugins/import/xfig/importxfigplugin.cpp
===================================================================
--- scribus/plugins/import/xfig/importxfigplugin.cpp	(revision 14664)
+++ scribus/plugins/import/xfig/importxfigplugin.cpp	(revision 14665)
@@ -96,6 +96,7 @@
 	fmt.formatId = FORMATID_XFIGIMPORT;
 	fmt.filter = FormatsManager::instance()->extensionsForFormat(FormatsManager::XFIG); // QFileDialog filter
 	fmt.nameMatch = QRegExp("\\."+FormatsManager::instance()->extensionListForFormat(FormatsManager::XFIG, 1)+"$", Qt::CaseInsensitive);
+	fmt.fileExtensions = QStringList() << "fig";
 	fmt.load = true;
 	fmt.save = false;
 	fmt.mimeTypes = FormatsManager::instance()->mimetypeOfFormat(FormatsManager::XFIG); // MIME types
@@ -160,3 +161,23 @@
 	delete dia;
 	return true;
 }
+
+QImage ImportXfigPlugin::readThumbnail(const QString& fileName)
+{
+	bool wasUndo = false;
+	if( fileName.isEmpty() )
+		return QImage();
+	if (UndoManager::undoEnabled())
+	{
+		UndoManager::instance()->setUndoEnabled(false);
+		wasUndo = true;
+	}
+	m_Doc = ScCore->primaryMainWindow()->doc;
+	XfigPlug *dia = new XfigPlug(m_Doc, lfCreateThumbnail);
+	Q_CHECK_PTR(dia);
+	QImage ret = dia->readThumbnail(fileName);
+	if (wasUndo)
+		UndoManager::instance()->setUndoEnabled(true);
+	delete dia;
+	return ret;
+}
Index: scribus/plugins/import/xfig/importxfig.cpp
===================================================================
--- scribus/plugins/import/xfig/importxfig.cpp	(revision 14664)
+++ scribus/plugins/import/xfig/importxfig.cpp	(revision 14665)
@@ -54,9 +54,225 @@
 {
 	tmpSel=new Selection(this, false);
 	m_Doc=doc;
+	importerFlags = flags;
 	interactive = (flags & LoadSavePlugin::lfInteractive);
 }
 
+QImage XfigPlug::readThumbnail(QString fName)
+{
+	QFileInfo fi = QFileInfo(fName);
+	baseFile = QDir::cleanPath(QDir::toNativeSeparators(fi.absolutePath()+"/"));
+	bool haveDoc = false;
+	double b, h, x, y;
+	parseHeader(fName, x, y, b, h);
+	docX = x;
+	docY = y;
+	if (b == 0.0)
+		b = PrefsManager::instance()->appPrefs.docSetupPrefs.pageWidth;
+	if (h == 0.0)
+		h = PrefsManager::instance()->appPrefs.docSetupPrefs.pageHeight;
+	docWidth = b - x;
+	docHeight = h - y;
+	ScribusView* tempView;
+	progressDialog = NULL;
+	haveDoc = true;
+	m_Doc = new ScribusDoc();
+	m_Doc->setup(0, 1, 1, 1, 1, "Custom", "Custom");
+	m_Doc->setPage(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false);
+	m_Doc->addPage(0);
+	tempView = new ScribusView(0, ScCore->primaryMainWindow(), m_Doc);
+	tempView->setScale(1);
+	m_Doc->setGUI(false, ScCore->primaryMainWindow(), tempView);
+	baseX = m_Doc->currentPage()->xOffset();
+	baseY = m_Doc->currentPage()->yOffset();
+	Elements.clear();
+	CustColors.clear();
+	importedColors.insert(0, "Black");
+	importedColors.insert(1, "Blue");
+	importedColors.insert(2, "Green");
+	importedColors.insert(3, "Cyan");
+	importedColors.insert(4, "Red");
+	importedColors.insert(5, "Magenta");
+	importedColors.insert(6, "Yellow");
+	importedColors.insert(7, "White");
+	importedColors.insert(8, "Blue4");
+	importedColors.insert(9, "Blue3");
+	importedColors.insert(10, "Blue2");
+	importedColors.insert(11, "LtBlue");
+	importedColors.insert(12, "Green4");
+	importedColors.insert(13, "Green3");
+	importedColors.insert(14, "Green2");
+	importedColors.insert(15, "Cyan4");
+	importedColors.insert(16, "Cyan3");
+	importedColors.insert(17, "Cyan2");
+	importedColors.insert(18, "Red4");
+	importedColors.insert(19, "Red3");
+	importedColors.insert(20, "Red2");
+	importedColors.insert(21, "Magenta4");
+	importedColors.insert(22, "Magenta3");
+	importedColors.insert(23, "Magenta2");
+	importedColors.insert(24, "Brown4");
+	importedColors.insert(25, "Brown3");
+	importedColors.insert(26, "Brown2");
+	importedColors.insert(27, "Pink4");
+	importedColors.insert(28, "Pink3");
+	importedColors.insert(29, "Pink2");
+	importedColors.insert(30, "Pink");
+	importedColors.insert(31, "Gold");
+	CustColors.insert("Blue", ScColor(0, 0, 255));
+	CustColors.insert("Blue4", ScColor(0, 0, 144));
+	CustColors.insert("Blue3", ScColor(0, 0, 176));
+	CustColors.insert("Blue2", ScColor(0, 0, 208));
+	CustColors.insert("LtBlue", ScColor(135, 206, 255));
+	CustColors.insert("Cyan", ScColor(255, 0, 0, 0));
+	CustColors.insert("Cyan4", ScColor(0, 144, 144));
+	CustColors.insert("Cyan3", ScColor(0, 176, 176));
+	CustColors.insert("Cyan2", ScColor(0, 208, 208));
+	CustColors.insert("Green", ScColor(255, 0, 255, 0));
+	CustColors.insert("Green4", ScColor(0, 144, 0));
+	CustColors.insert("Green3", ScColor(0, 176, 0));
+	CustColors.insert("Green2", ScColor(0, 208, 0));
+	CustColors.insert("Red", ScColor(0, 255, 255, 0));
+	CustColors.insert("Red4", ScColor(144, 0, 0));
+	CustColors.insert("Red3", ScColor(176, 0, 0));
+	CustColors.insert("Red2", ScColor(208, 0, 0));
+	CustColors.insert("Yellow", ScColor(0, 0, 255, 0));
+	CustColors.insert("Magenta", ScColor(0, 255, 0, 0));
+	CustColors.insert("Magenta4", ScColor(144, 0, 144));
+	CustColors.insert("Magenta3", ScColor(176, 0, 176));
+	CustColors.insert("Magenta2", ScColor(208, 0, 208));
+	CustColors.insert("Brown4", ScColor(128, 48, 0));
+	CustColors.insert("Brown3", ScColor(160, 64, 0));
+	CustColors.insert("Brown2", ScColor(192, 96, 0));
+	CustColors.insert("Pink4", ScColor(255, 128, 128));
+	CustColors.insert("Pink3", ScColor(255, 160, 160));
+	CustColors.insert("Pink2", ScColor(255, 192, 192));
+	CustColors.insert("Pink", ScColor(255, 224, 224));
+	CustColors.insert("Gold", ScColor(255, 215, 0));
+	m_Doc->setLoading(true);
+	m_Doc->DoDrawing = false;
+	m_Doc->view()->updatesOn(false);
+	m_Doc->scMW()->ScriptRunning = true;
+	qApp->changeOverrideCursor(QCursor(Qt::WaitCursor));
+	QString CurDirP = QDir::currentPath();
+	QDir::setCurrent(fi.path());
+	int groupCount = m_Doc->GroupCounter;
+	int itemCount = m_Doc->TotalItems;
+	if (convert(fName))
+	{
+		tmpSel->clear();
+		QDir::setCurrent(CurDirP);
+		if (Elements.count() > 0)
+		{
+			bool isGroup = true;
+			int firstElem = -1;
+			if (Elements.at(0)->Groups.count() != 0)
+				firstElem = Elements.at(0)->Groups.top();
+			for (int bx = 0; bx < Elements.count(); ++bx)
+			{
+				PageItem* bxi = Elements.at(bx);
+				if (bxi->Groups.count() != 0)
+				{
+					if (bxi->Groups.top() != firstElem)
+						isGroup = false;
+				}
+				else
+					isGroup = false;
+			}
+			if (!isGroup)
+			{
+				double minx = 99999.9;
+				double miny = 99999.9;
+				double maxx = -99999.9;
+				double maxy = -99999.9;
+				uint lowestItem = 999999;
+				uint highestItem = 0;
+				for (int a = 0; a < Elements.count(); ++a)
+				{
+					Elements.at(a)->Groups.push(m_Doc->GroupCounter);
+					PageItem* currItem = Elements.at(a);
+					lowestItem = qMin(lowestItem, currItem->ItemNr);
+					highestItem = qMax(highestItem, currItem->ItemNr);
+					double x1, x2, y1, y2;
+					currItem->getVisualBoundingRect(&x1, &y1, &x2, &y2);
+					minx = qMin(minx, x1);
+					miny = qMin(miny, y1);
+					maxx = qMax(maxx, x2);
+					maxy = qMax(maxy, y2);
+				}
+				double gx = minx;
+				double gy = miny;
+				double gw = maxx - minx;
+				double gh = maxy - miny;
+				PageItem *high = m_Doc->Items->at(highestItem);
+				int z = m_Doc->itemAdd(PageItem::Polygon, PageItem::Rectangle, gx, gy, gw, gh, 0, m_Doc->itemToolPrefs.shapeFillColor, m_Doc->itemToolPrefs.shapeLineColor, true);
+				PageItem *neu = m_Doc->Items->takeAt(z);
+				m_Doc->Items->insert(lowestItem, neu);
+				neu->Groups.push(m_Doc->GroupCounter);
+				neu->setItemName( tr("Group%1").arg(neu->Groups.top()));
+				neu->AutoName = false;
+				neu->isGroupControl = true;
+				neu->groupsLastItem = high;
+				neu->setTextFlowMode(PageItem::TextFlowDisabled);
+				for (int a = 0; a < m_Doc->Items->count(); ++a)
+				{
+					m_Doc->Items->at(a)->ItemNr = a;
+				}
+				Elements.prepend(neu);
+				m_Doc->GroupCounter++;
+			}
+		}
+		m_Doc->DoDrawing = true;
+		qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
+		m_Doc->m_Selection->delaySignalsOn();
+		QImage tmpImage;
+		if (Elements.count() > 0)
+		{
+			for (int dre=0; dre<Elements.count(); ++dre)
+			{
+				tmpSel->addItem(Elements.at(dre), true);
+			}
+			tmpSel->setGroupRect();
+			double xs = tmpSel->width();
+			double ys = tmpSel->height();
+			double sc = 500.0 / qMax(xs, ys);
+			m_Doc->scaleGroup(sc, sc, true, tmpSel);
+			tmpImage = Elements.at(0)->DrawObj_toImage();
+			tmpImage.setText("XSize", QString("%1").arg(xs));
+			tmpImage.setText("YSize", QString("%1").arg(ys));
+		}
+		m_Doc->itemSelection_DeleteItem(tmpSel);
+		m_Doc->view()->updatesOn(true);
+		m_Doc->scMW()->ScriptRunning = false;
+		m_Doc->setLoading(false);
+		m_Doc->m_Selection->delaySignalsOff();
+		if (haveDoc)
+		{
+			delete tempView;
+			delete m_Doc;
+		}
+		m_Doc->GroupCounter = groupCount;
+		m_Doc->TotalItems = itemCount;
+		return tmpImage;
+	}
+	else
+	{
+		QDir::setCurrent(CurDirP);
+		m_Doc->DoDrawing = true;
+		m_Doc->scMW()->ScriptRunning = false;
+		m_Doc->view()->updatesOn(true);
+		qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
+		if (haveDoc)
+		{
+			delete tempView;
+			delete m_Doc;
+		}
+	}
+	m_Doc->GroupCounter = groupCount;
+	m_Doc->TotalItems = itemCount;
+	return QImage();
+}
+
 bool XfigPlug::import(QString fNameIn, const TransactionSettings& trSettings, int flags, bool showProgress)
 {
 	QString fName = fNameIn;
@@ -1578,7 +1794,8 @@
 			if (tmp.startsWith("#"))
 				continue;
 			processData(ts, tmp);
-			progressDialog->setProgress("GI", ts.device()->pos());
+			if (progressDialog)
+				progressDialog->setProgress("GI", ts.device()->pos());
 			qApp->processEvents();
 		}
 		resortItems();
Index: scribus/plugins/import/xfig/importxfigplugin.h
===================================================================
--- scribus/plugins/import/xfig/importxfigplugin.h	(revision 14664)
+++ scribus/plugins/import/xfig/importxfigplugin.h	(revision 14665)
@@ -33,6 +33,7 @@
 		virtual void languageChange();
 		virtual bool fileSupported(QIODevice* file, const QString & fileName=QString::null) const;
 		virtual bool loadFile(const QString & fileName, const FileFormat & fmt, int flags, int index = 0);
+		virtual QImage readThumbnail(const QString& fileName);
 		virtual void addToMainWindowMenu(ScribusMainWindow *) {};
 
 	public slots:
Index: scribus/plugins/import/xfig/importxfig.h
===================================================================
--- scribus/plugins/import/xfig/importxfig.h	(revision 14664)
+++ scribus/plugins/import/xfig/importxfig.h	(revision 14665)
@@ -53,6 +53,7 @@
 	\retval bool true if import was ok
 	 */
 	bool import(QString fn, const TransactionSettings& trSettings, int flags, bool showProgress = true);
+	QImage readThumbnail(QString fn);
 
 private:
 	




More information about the scribus-commit mailing list