r16164 by fschmid - Made the Kivio stencil reading part of the "StencilReader" a proper import plugin.

scribus-commit scribus-commit at lists.scribus.net
Sun Dec 26 19:05:21 CET 2010


Author: fschmid
Date: Sun Dec 26 18:05:21 2010
New Revision: 16164

URL: http://scribus.info/websvn/listing.php?repname=Scribus&sc=1&rev=16164
Log:
Made the Kivio stencil reading part of the "StencilReader" a proper import plugin.

Added:
    trunk/Scribus/scribus/plugins/import/sml/
    trunk/Scribus/scribus/plugins/import/sml/CMakeLists.txt
    trunk/Scribus/scribus/plugins/import/sml/importsml.cpp
    trunk/Scribus/scribus/plugins/import/sml/importsml.h
    trunk/Scribus/scribus/plugins/import/sml/importsmlplugin.cpp
    trunk/Scribus/scribus/plugins/import/sml/importsmlplugin.h
Modified:
    trunk/Scribus/scribus/canvasmode_normal.cpp
    trunk/Scribus/scribus/plugins/import/CMakeLists.txt
    trunk/Scribus/scribus/scribus.cpp
    trunk/Scribus/scribus/scribusview.cpp
    trunk/Scribus/scribus/ui/customfdialog.cpp
    trunk/Scribus/scribus/ui/paintmanager.cpp
    trunk/Scribus/scribus/ui/scrapbookpalette.cpp

Modified: trunk/Scribus/scribus/canvasmode_normal.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16164&path=/trunk/Scribus/scribus/canvasmode_normal.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_normal.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_normal.cpp Sun Dec 26 18:05:21 2010
@@ -1280,11 +1280,9 @@
 		fmt = LoadSavePlugin::getFormatById(fmtCode);
 	}
 	allFormats += "*.sce *.SCE ";
-	allFormats += "*.shape *.SHAPE ";
-	allFormats += "*.sml *.SML);;";
+	allFormats += "*.shape *.SHAPE);;";
 	formats += "Scribus Objects (*.sce *.SCE);;";
-	formats += "Dia Shapes (*.shape *.SHAPE);;";
-	formats += "Kivio Stencils (*.sml *.SML)";
+	formats += "Dia Shapes (*.shape *.SHAPE)";
 	allFormats += formats;
 	PrefsContext* dirs = PrefsManager::instance()->prefsFile->getContext("dirs");
 	QString wdir = dirs->get("pastefile", ".");
@@ -1299,15 +1297,7 @@
 		PrefsManager::instance()->prefsFile->getContext("dirs")->set("pastefile", fileName.left(fileName.lastIndexOf("/")));
 		m_doc->setLoading(true);
 		QFileInfo fi(fileName);
-		if (fi.suffix().toLower() == "sml")
-		{
-			QString f = "";
-			loadText(fileName, &f);
-			StencilReader *pre = new StencilReader();
-			fileName = pre->createObjects(f);
-			delete pre;
-		}
-		else if (fi.suffix().toLower() == "shape")
+		if (fi.suffix().toLower() == "shape")
 		{
 			QString f = "";
 			loadText(fileName, &f);
@@ -1321,7 +1311,7 @@
 		m_doc->SnapGuides = false;
 		if (fi.suffix().toLower() == "sce")
 			m_ScMW->slotElemRead(fileName, pastePoint.x(), pastePoint.y(), true, false, m_doc, m_doc->view());
-		else if ((fi.suffix().toLower() == "shape") || (fi.suffix().toLower() == "sml"))
+		else if (fi.suffix().toLower() == "shape")
 			m_ScMW->slotElemRead(fileName, pastePoint.x(), pastePoint.y(), false, true, m_doc, m_doc->view());
 		else
 		{

Modified: trunk/Scribus/scribus/plugins/import/CMakeLists.txt
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16164&path=/trunk/Scribus/scribus/plugins/import/CMakeLists.txt
==============================================================================
--- trunk/Scribus/scribus/plugins/import/CMakeLists.txt (original)
+++ trunk/Scribus/scribus/plugins/import/CMakeLists.txt Sun Dec 26 18:05:21 2010
@@ -6,10 +6,10 @@
 ADD_SUBDIRECTORY(oodraw)
 ADD_SUBDIRECTORY(pct)
 ADD_SUBDIRECTORY(ps)
+ADD_SUBDIRECTORY(sml)
 ADD_SUBDIRECTORY(svg)
 ADD_SUBDIRECTORY(uniconvertor)
 ADD_SUBDIRECTORY(wmf)
 ADD_SUBDIRECTORY(wpg)
 ADD_SUBDIRECTORY(xar)
 ADD_SUBDIRECTORY(xfig)
-

Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16164&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp (original)
+++ trunk/Scribus/scribus/scribus.cpp Sun Dec 26 18:05:21 2010
@@ -3370,15 +3370,7 @@
 		else
 		{
 			UndoTransaction pasteAction(undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::Create,"",Um::ICreate));
-			if (fi.suffix().toLower() == "sml")
-			{
-				QString f = "";
-				loadText(data, &f);
-				StencilReader *pre = new StencilReader();
-				data = pre->createObjects(f);
-				delete pre;
-			}
-			else if (fi.suffix().toLower() == "shape")
+			if (fi.suffix().toLower() == "shape")
 			{
 				QString f = "";
 				loadText(data, &f);
@@ -3427,6 +3419,7 @@
 	{
 		if (fmt->load)
 		{
+			qDebug() << "Format " << fmt->filter << " Nr " << fmtCode;
 			formats += fmt->filter + ";;";
 			int an = fmt->filter.indexOf("(");
 			int en = fmt->filter.indexOf(")");
@@ -3441,11 +3434,9 @@
 		fmt = LoadSavePlugin::getFormatById(fmtCode);
 	}
 	allFormats += "*.sce *.SCE ";
-	allFormats += "*.shape *.SHAPE ";
-	allFormats += "*.sml *.SML);;";
+	allFormats += "*.shape *.SHAPE);;";
 	formats += "Scribus Objects (*.sce *.SCE);;";
-	formats += "Dia Shapes (*.shape *.SHAPE);;";
-	formats += "Kivio Stencils (*.sml *.SML)";
+	formats += "Dia Shapes (*.shape *.SHAPE)";
 	allFormats += formats;
 	PrefsContext* dirs = PrefsManager::instance()->prefsFile->getContext("dirs");
 	QString wdir = dirs->get("pastefile", ".");
@@ -3459,7 +3450,7 @@
 		PrefsManager::instance()->prefsFile->getContext("dirs")->set("pastefile", fileName.left(fileName.lastIndexOf("/")));
 		QFileInfo fi(fileName);
 		QString suffix = fi.suffix().toLower();
-		if ((suffix == "sce") || (suffix == "sml") || (suffix == "shape"))
+		if ((suffix == "sce") || (suffix == "shape"))
 		{
 			QList<QUrl> urls;
 			QMimeData* md = new QMimeData();
@@ -3469,9 +3460,6 @@
 			dr->setMimeData(md);
 			const QPixmap& dragCursor = loadIcon("DragPix.xpm");
 			dr->setPixmap(dragCursor);
-		//	dr->setDragCursor(dragCursor, Qt::CopyAction);
-		//	dr->setDragCursor(dragCursor, Qt::MoveAction);
-		//	dr->setDragCursor(dragCursor, Qt::LinkAction);
 			dr->exec();
 		}
 		else
@@ -9733,7 +9721,7 @@
 		for( int i = 0; i < fileUrls.count(); ++i )
 		{
 			fileUrl = fileUrls[i].toLocalFile().toLower();
-			if (fileUrl.endsWith(".sla") || fileUrl.endsWith(".sla.gz") || fileUrl.endsWith(".sml") || fileUrl.endsWith(".shape") || fileUrl.endsWith(".sce"))
+			if (fileUrl.endsWith(".sla") || fileUrl.endsWith(".sla.gz") || fileUrl.endsWith(".shape") || fileUrl.endsWith(".sce"))
 			{
 				accepted = true;
 				break;
@@ -9782,7 +9770,7 @@
 					loadDoc( fi.absoluteFilePath() );
 				}
 			}
-			else if ((fileUrl.endsWith(".shape")) || (fileUrl.endsWith(".sml")) || (fileUrl.endsWith(".sce")))
+			else if ((fileUrl.endsWith(".shape")) || (fileUrl.endsWith(".sce")))
 			{
 				QUrl url( fileUrls[i] );
 				QFileInfo fi(url.path());
@@ -9800,8 +9788,6 @@
 						StencilReader *pre = new StencilReader();
 						if (fileUrl.endsWith(".shape"))
 							data = pre->createShape(f);
-						else if (fileUrl.endsWith(".sml"))
-							data = pre->createObjects(f);
 						delete pre;
 					}
 					double gx, gy, gw, gh;

Modified: trunk/Scribus/scribus/scribusview.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16164&path=/trunk/Scribus/scribus/scribusview.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusview.cpp (original)
+++ trunk/Scribus/scribus/scribusview.cpp Sun Dec 26 18:05:21 2010
@@ -915,7 +915,7 @@
 		bool vectorFile = false;
 		if (fi.exists())
 		{
-			if ((fi.suffix().toLower() == "sml") || (fi.suffix().toLower() == "shape") || (fi.suffix().toLower() == "sce"))
+			if ((fi.suffix().toLower() == "shape") || (fi.suffix().toLower() == "sce"))
 				vectorFile = true;
 			else
 			{
@@ -993,17 +993,7 @@
 				if (fi.exists())
 				{
 					QString data;
-					if (fi.suffix().toLower() == "sml")
-					{
-						QByteArray cf;
-						loadRawText(url.toLocalFile(), cf);
-						StencilReader *pre = new StencilReader();
-						QString f = QString::fromUtf8(cf.data());
-						data = pre->createObjects(f);
-						delete pre;
-						emit LoadElem(data, dropPosDoc.x(), dropPosDoc.y(), false, false, Doc, this);
-					}
-					else if (fi.suffix().toLower() == "shape")
+					if (fi.suffix().toLower() == "shape")
 					{
 						QByteArray cf;
 						loadRawText(url.toLocalFile(), cf);

Modified: trunk/Scribus/scribus/ui/customfdialog.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16164&path=/trunk/Scribus/scribus/ui/customfdialog.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/customfdialog.cpp (original)
+++ trunk/Scribus/scribus/ui/customfdialog.cpp Sun Dec 26 18:05:21 2010
@@ -104,7 +104,7 @@
 			return oosxdpm;
 		else if (ext.endsWith("sxw", Qt::CaseInsensitive))
 			return oosxwpm;
-		else if (allFormatsV.contains(ext) || ext.endsWith("sce", Qt::CaseInsensitive) || ext.endsWith("sml", Qt::CaseInsensitive) || ext.endsWith("shape", Qt::CaseInsensitive))
+		else if (allFormatsV.contains(ext) || ext.endsWith("sce", Qt::CaseInsensitive) || ext.endsWith("shape", Qt::CaseInsensitive))
 			return vectorpm;
 		else
 			return QFileIconProvider::icon(fi);
@@ -228,32 +228,6 @@
 					repaint();
 				}
 			}
-		}
-	}
-	else if (ext.toUtf8() == "sml")
-	{
-		QPixmap pmi;
-		QByteArray cf;
-		if (loadRawText(name, cf))
-		{
-			QString f = QString::fromUtf8(cf.data());
-			StencilReader *pre = new StencilReader();
-			pmi = pre->createPreview(f);
-			QImage im = pmi.toImage();
-			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-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);
-			QString desc = tr("Size:")+QString(" %1 x %2").arg(im.width()).arg(im.height());
-			p.drawText(2, h-5, desc);
-			p.end();
-			setPixmap(pm);
-			repaint();
-			delete pre;
 		}
 	}
 	else if (ext.toUtf8() == "shape")

Modified: trunk/Scribus/scribus/ui/paintmanager.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16164&path=/trunk/Scribus/scribus/ui/paintmanager.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/paintmanager.cpp (original)
+++ trunk/Scribus/scribus/ui/paintmanager.cpp Sun Dec 26 18:05:21 2010
@@ -1078,11 +1078,9 @@
 				fmt = LoadSavePlugin::getFormatById(fmtCode);
 			}
 			allFormats += "*.sce *.SCE ";
-			allFormats += "*.shape *.SHAPE ";
-			allFormats += "*.sml *.SML ";
+			allFormats += "*.shape *.SHAPE);;";
 			formats += "Scribus Objects (*.sce *.SCE);;";
-			formats += "Dia Shapes (*.shape *.SHAPE);;";
-			formats += "Kivio Stencils (*.sml *.SML);;";
+			formats += "Dia Shapes (*.shape *.SHAPE)";
 			QString form1 = "";
 			QString form2 = "";
 			QStringList imgFormats;
@@ -1164,7 +1162,7 @@
 				qApp->changeOverrideCursor(QCursor(Qt::WaitCursor));
 				PrefsManager::instance()->prefsFile->getContext("dirs")->set("patterns", fileName.left(fileName.lastIndexOf("/")));
 				QFileInfo fi(fileName);
-				if ((fi.suffix().toLower() == "sml") || (fi.suffix().toLower() == "shape") || (fi.suffix().toLower() == "sce") || (!imgFormats.contains(fi.suffix().toLower())))
+				if ((fi.suffix().toLower() == "shape") || (fi.suffix().toLower() == "sce") || (!imgFormats.contains(fi.suffix().toLower())))
 				{
 					loadVectors(fileName);
 				}
@@ -1233,7 +1231,7 @@
 				qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
 				QFileInfo fi(QDir::cleanPath(QDir::convertSeparators(fileName + "/" + d[dc])));
 				QString ext = fi.suffix().toLower();
-				if ((ext == "sml") || (ext == "shape") || (ext == "sce") || (!formats.contains(ext)))
+				if ((ext == "shape") || (ext == "sce") || (!formats.contains(ext)))
 					loadVectors(QDir::cleanPath(QDir::convertSeparators(fileName + "/" + d[dc])));
 			}
 			for (uint dc = 0; dc < d.count(); ++dc)
@@ -1242,7 +1240,7 @@
 				qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
 				QFileInfo fi(QDir::cleanPath(QDir::convertSeparators(fileName + "/" + d[dc])));
 				QString ext = fi.suffix().toLower();
-				if ((ext == "sml") || (ext == "shape") || (ext == "sce") || (!formats.contains(ext)))
+				if ((ext == "shape") || (ext == "sce") || (!formats.contains(ext)))
 					continue;
 				else if (formats.contains(ext))
 				{
@@ -1277,15 +1275,7 @@
 	m_doc->setLoading(true);
 	QFileInfo fi(data);
 	QString patNam = fi.baseName().trimmed().simplified().replace(" ", "_");
-	if (fi.suffix().toLower() == "sml")
-	{
-		QString f = "";
-		loadText(data, &f);
-		StencilReader *pre = new StencilReader();
-		data = pre->createObjects(f);
-		delete pre;
-	}
-	else if (fi.suffix().toLower() == "shape")
+	if (fi.suffix().toLower() == "shape")
 	{
 		QString f = "";
 		loadText(data, &f);
@@ -1304,7 +1294,7 @@
 		ScriXmlDoc ss;
 		ss.ReadElem(data, PrefsManager::instance()->appPrefs.fontPrefs.AvailFonts, m_doc, m_doc->currentPage()->xOffset(), m_doc->currentPage()->yOffset(), true, true, PrefsManager::instance()->appPrefs.fontPrefs.GFontSub);
 	}
-	else if ((fi.suffix().toLower() == "shape") || (fi.suffix().toLower() == "sml"))
+	else if (fi.suffix().toLower() == "shape")
 	{
 		ScriXmlDoc ss;
 		ss.ReadElem(data, PrefsManager::instance()->appPrefs.fontPrefs.AvailFonts, m_doc, m_doc->currentPage()->xOffset(), m_doc->currentPage()->yOffset(), false, true, PrefsManager::instance()->appPrefs.fontPrefs.GFontSub);

Modified: trunk/Scribus/scribus/ui/scrapbookpalette.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16164&path=/trunk/Scribus/scribus/ui/scrapbookpalette.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/scrapbookpalette.cpp (original)
+++ trunk/Scribus/scribus/ui/scrapbookpalette.cpp Sun Dec 26 18:05:21 2010
@@ -87,17 +87,7 @@
 	QFileInfo fi(dt);
 	QMimeData *mimeData = new QMimeData;
 	QList<QUrl> urlList;
-	if (fi.suffix().toLower() == "sml")
-	{
-		QByteArray cf;
-		loadRawText(dt, cf);
-		QString f = QString::fromUtf8(cf.data());
-		StencilReader *pre = new StencilReader();
-		dt = pre->createObjects(f);
-		delete pre;
-		mimeData->setText(dt);
-	}
-	else if (fi.suffix().toLower() == "shape")
+	if (fi.suffix().toLower() == "shape")
 	{
 		QByteArray cf;
 		loadRawText(dt, cf);
@@ -568,8 +558,6 @@
 	fileCount += dd.count();
 	QDir d(name, "*.sce", QDir::Name, QDir::Files | QDir::Readable | QDir::NoSymLinks);
 	fileCount += d.count();
-	QDir d2(name, "*.sml", QDir::Name, QDir::Files | QDir::Readable | QDir::NoSymLinks);
-	fileCount += d2.count();
 	QDir d3(name, "*.shape", QDir::Name, QDir::Files | QDir::Readable | QDir::NoSymLinks);
 	fileCount += d3.count();
 	QStringList vectorFiles = LoadSavePlugin::getExtensionsForPreview(FORMATID_ODGIMPORT);
@@ -646,42 +634,6 @@
 			}
 			previewFiles.append(fi.baseName()+".png");
 			AddObj(fi.baseName(), QDir::cleanPath(QDir::convertSeparators(name + "/" + d[dc])), pm);
-		}
-	}
-	if ((d2.exists()) && (d2.count() != 0))
-	{
-		for (uint dc = 0; dc < d2.count(); ++dc)
-		{
-			if (pgDia)
-			{
-				pgDia->setValue(readCount);
-				readCount++;
-			}
-			QPixmap pm;
-			QByteArray cf;
-			if (!loadRawText(QDir::cleanPath(QDir::convertSeparators(name + "/" + d2[dc])), cf))
-				continue;
-			QFileInfo fi(QDir::cleanPath(QDir::convertSeparators(name + "/" + d2[dc])));
-			QFileInfo fi2(QDir::cleanPath(QDir::convertSeparators(fi.path()+"/.ScribusThumbs/"+fi.baseName()+".png")));
-			QFileInfo fi3(QDir::cleanPath(QDir::convertSeparators(fi.path()+"/"+fi.baseName()+".png")));
-			if (fi2.exists())
-				pm.load(QDir::cleanPath(QDir::convertSeparators(fi.path()+"/.ScribusThumbs/"+fi.baseName()+".png")));
-			else
-			{
-				if (fi3.exists())
-					pm.load(QDir::cleanPath(QDir::convertSeparators(fi.path()+"/"+fi.baseName()+".png")));
-				else
-				{
-					QString f = QString::fromUtf8(cf.data());
-					StencilReader *pre = new StencilReader();
-					pm = pre->createPreview(f);
-					if ((canWrite) && (PrefsManager::instance()->appPrefs.scrapbookPrefs.writePreviews))
-						pm.save(QDir::cleanPath(QDir::convertSeparators(fi.path()+"/.ScribusThumbs/"+fi.baseName()+".png")), "PNG");
-					delete pre;
-				}
-			}
-			previewFiles.append(fi.baseName()+".png");
-			AddObj(fi.baseName(), QDir::cleanPath(QDir::convertSeparators(name + "/" + d2[dc])), pm);
 		}
 	}
 	if ((d3.exists()) && (d3.count() != 0))




More information about the scribus-commit mailing list