r19322 by fschmid - Part of Bug #12415 libcdr issues, Uniconverter is now fallback importer if libcdr fails

scribus-commit scribus-commit at lists.scribus.net
Sun Jul 6 18:38:34 UTC 2014


Author: fschmid
Date: Sun Jul  6 18:38:34 2014
New Revision: 19322

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=19322
Log:
Part of Bug #12415 libcdr issues, Uniconverter is now fallback importer if libcdr fails

Modified:
    trunk/Scribus/scribus/plugins/import/cdr/importcdr.cpp
    trunk/Scribus/scribus/plugins/import/cdr/importcdrplugin.cpp
    trunk/Scribus/scribus/plugins/import/svg/svgplugin.cpp

Modified: trunk/Scribus/scribus/plugins/import/cdr/importcdr.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19322&path=/trunk/Scribus/scribus/plugins/import/cdr/importcdr.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/cdr/importcdr.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/cdr/importcdr.cpp Sun Jul  6 18:38:34 2014
@@ -339,15 +339,44 @@
 #else
 	WPXFileStream input(QFile::encodeName(fn).data());
 #endif
+	bool fail = false;
 	if (ext == "cdr")
 	{
 		if (!libcdr::CDRDocument::isSupported(&input))
+		{
+			qDebug() << "ERROR: Unsupported file format!";
+			fail = true;
+		}
+		if (!fail)
+		{
+			RawPainter painter(m_Doc, baseX, baseY, docWidth, docHeight, importerFlags, &Elements, &importedColors, &importedPatterns, tmpSel, "cdr");
+			if (!libcdr::CDRDocument::parse(&input, &painter))
+				fail = true;
+		}
+		if (fail)
+		{
+			qDebug() << "ERROR: Parsing failed!";
+			if (progressDialog)
+				progressDialog->close();
+		/*	if (importerFlags & LoadSavePlugin::lfCreateDoc)
+			{
+				ScribusMainWindow* mw=(m_Doc==0) ? ScCore->primaryMainWindow() : m_Doc->scMW();
+				qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
+				QMessageBox::warning(mw, CommonStrings::trWarning, tr("Parsing failed!\n\nPlease submit your file (if possible) to the\nDocument Liberation Project http://www.documentliberation.org"), 1, 0, 0);
+				qApp->changeOverrideCursor(QCursor(Qt::WaitCursor));
+			}*/
+			return false;
+		}
+	}
+	else if (ext == "cmx")
+	{
+		if (!libcdr::CMXDocument::isSupported(&input))
 		{
 			qDebug() << "ERROR: Unsupported file format!";
 			return false;
 		}
-		RawPainter painter(m_Doc, baseX, baseY, docWidth, docHeight, importerFlags, &Elements, &importedColors, &importedPatterns, tmpSel, "cdr");
-		if (!libcdr::CDRDocument::parse(&input, &painter))
+		RawPainter painter(m_Doc, baseX, baseY, docWidth, docHeight, importerFlags, &Elements, &importedColors, &importedPatterns, tmpSel, "cmx");
+		if (!libcdr::CMXDocument::parse(&input, &painter))
 		{
 			qDebug() << "ERROR: Parsing failed!";
 			if (progressDialog)
@@ -362,29 +391,6 @@
 			return false;
 		}
 	}
-	else if (ext == "cmx")
-	{
-		if (!libcdr::CMXDocument::isSupported(&input))
-		{
-			qDebug() << "ERROR: Unsupported file format!";
-			return false;
-		}
-		RawPainter painter(m_Doc, baseX, baseY, docWidth, docHeight, importerFlags, &Elements, &importedColors, &importedPatterns, tmpSel, "cmx");
-		if (!libcdr::CMXDocument::parse(&input, &painter))
-		{
-			qDebug() << "ERROR: Parsing failed!";
-			if (progressDialog)
-				progressDialog->close();
-			if (importerFlags & LoadSavePlugin::lfCreateDoc)
-			{
-				ScribusMainWindow* mw=(m_Doc==0) ? ScCore->primaryMainWindow() : m_Doc->scMW();
-				qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
-				QMessageBox::warning(mw, CommonStrings::trWarning, tr("Parsing failed!\n\nPlease submit your file (if possible) to the\nDocument Liberation Project http://www.documentliberation.org"), 1, 0, 0);
-				qApp->changeOverrideCursor(QCursor(Qt::WaitCursor));
-			}
-			return false;
-		}
-	}
 	else
 		return false;
 	if (Elements.count() == 0)

Modified: trunk/Scribus/scribus/plugins/import/cdr/importcdrplugin.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19322&path=/trunk/Scribus/scribus/plugins/import/cdr/importcdrplugin.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/cdr/importcdrplugin.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/cdr/importcdrplugin.cpp Sun Jul  6 18:38:34 2014
@@ -19,6 +19,7 @@
 
 #include "ui/customfdialog.h"
 #include "ui/scmwmenumanager.h"
+#include <QMessageBox>
 
 int importcdr_getPluginAPIVersion()
 {
@@ -146,7 +147,28 @@
 		activeTransaction = new UndoTransaction(UndoManager::instance()->beginTransaction(trSettings));
 	CdrPlug *dia = new CdrPlug(m_Doc, flags);
 	Q_CHECK_PTR(dia);
-	dia->import(fileName, trSettings, flags);
+	if (!dia->import(fileName, trSettings, flags))
+	{
+		ScribusMainWindow* mw=(m_Doc==0) ? ScCore->primaryMainWindow() : m_Doc->scMW();
+		//Import per Uniconverter
+		qDebug() << "ERROR: Parsing with libcdr failed! Trying now Uniconverter.";
+		const FileFormat *fmt = LoadSavePlugin::getFormatByExt("cdt");
+		if (!fmt)
+		{
+			QMessageBox::warning(mw, CommonStrings::trWarning, tr("The Uniconverter Import plugin could not be found"), 1, 0, 0);
+			return false;
+		}
+		flags &= ~LoadSavePlugin::lfCreateDoc;
+		flags |= LoadSavePlugin::lfInsertPage;
+		if (!fmt->loadFile(fileName, flags))
+		{
+			if (flags & LoadSavePlugin::lfCreateDoc)
+			{
+				QMessageBox::warning(mw, CommonStrings::trWarning, tr("Parsing failed!\n\nPlease submit your file (if possible) to the\nDocument Liberation Project http://www.documentliberation.org"), 1, 0, 0);
+			}
+			return false;
+		}
+	}
 	if (activeTransaction)
 	{
 		activeTransaction->commit();

Modified: trunk/Scribus/scribus/plugins/import/svg/svgplugin.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19322&path=/trunk/Scribus/scribus/plugins/import/svg/svgplugin.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/svg/svgplugin.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/svg/svgplugin.cpp Sun Jul  6 18:38:34 2014
@@ -375,8 +375,11 @@
 	if (!interactive || (flags & LoadSavePlugin::lfInsertPage))
 	{
 		m_Doc->setPage(width, height, 0, 0, 0, 0, 0, 0, false, false);
-		m_Doc->addPage(0);
-		m_Doc->view()->addPage(0);
+		if (m_Doc->Pages->count() == 0)
+		{
+			m_Doc->addPage(0);
+			m_Doc->view()->addPage(0);
+		}
 	}
 	else
 	{




More information about the scribus-commit mailing list