r18657 by jghali - #11892: "Cancel" doesn't work in page selector for XPS files

scribus-commit scribus-commit at lists.scribus.net
Tue Dec 17 23:06:50 UTC 2013


Author: jghali
Date: Tue Dec 17 23:06:49 2013
New Revision: 18657

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=18657
Log:
#11892: "Cancel" doesn't work in page selector for XPS files

Modified:
    trunk/Scribus/scribus/plugins/import/xps/importxps.cpp
    trunk/Scribus/scribus/plugins/import/xps/importxps.h
    trunk/Scribus/scribus/plugins/import/xps/importxpsplugin.cpp

Modified: trunk/Scribus/scribus/plugins/import/xps/importxps.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18657&path=/trunk/Scribus/scribus/plugins/import/xps/importxps.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/xps/importxps.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/xps/importxps.cpp Tue Dec 17 23:06:49 2013
@@ -364,6 +364,7 @@
 		if (!(flags & LoadSavePlugin::lfLoadAsPattern))
 			m_Doc->view()->updatesOn(true);
 		qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
+		success = false;
 	}
 	if (interactive)
 		m_Doc->setLoading(false);
@@ -412,18 +413,15 @@
 		if (progressDialog)
 			progressDialog->close();
 	}
+
+	retVal = false;
 	if (uz->contains("FixedDocSeq.fdseq"))
-	{
-		parseDocSequence("FixedDocSeq.fdseq");
+		retVal = parseDocSequence("FixedDocSeq.fdseq");
+	else if (uz->contains("FixedDocumentSequence.fdseq"))
+		retVal = parseDocSequence("FixedDocumentSequence.fdseq");
+	if (retVal)
 		resolveLinks();
-	}
-	else if (uz->contains("FixedDocumentSequence.fdseq"))
-	{
-		parseDocSequence("FixedDocumentSequence.fdseq");
-		resolveLinks();
-	}
-	else
-		retVal = false;
+
 	uz->close();
 	delete uz;
 	if (progressDialog)
@@ -431,138 +429,142 @@
 	return retVal;
 }
 
-void XpsPlug::parseDocSequence(QString designMap)
+bool XpsPlug::parseDocSequence(QString designMap)
 {
 	QByteArray f;
 	QDomDocument designMapDom;
 	if (!uz->read(designMap, f))
-		return;
-	if(designMapDom.setContent(f))
-	{
-		QString DocumentReference = "";
-		QDomElement docElem = designMapDom.documentElement();
-		for(QDomNode drawPag = docElem.firstChild(); !drawPag.isNull(); drawPag = drawPag.nextSibling() )
-		{
-			QDomElement dpg = drawPag.toElement();
-			if (dpg.tagName() == "DocumentReference")
-			{
-				if (dpg.hasAttribute("Source"))
-				{
-					DocumentReference = dpg.attribute("Source", "");
-					if (DocumentReference.startsWith("/"))
-						DocumentReference = DocumentReference.mid(1);
-					parseDocReference(DocumentReference);
-				}
-			}
-		}
-	}
-}
-
-void XpsPlug::parseDocReference(QString designMap)
+		return false;
+	if (!designMapDom.setContent(f))
+		return false;
+
+	bool parsed = false;
+	QString DocumentReference = "";
+	QDomElement docElem = designMapDom.documentElement();
+	for(QDomNode drawPag = docElem.firstChild(); !drawPag.isNull(); drawPag = drawPag.nextSibling() )
+	{
+		QDomElement dpg = drawPag.toElement();
+		if (dpg.tagName() == "DocumentReference")
+		{
+			if (dpg.hasAttribute("Source"))
+			{
+				DocumentReference = dpg.attribute("Source", "");
+				if (DocumentReference.startsWith("/"))
+					DocumentReference = DocumentReference.mid(1);
+				parsed = parseDocReference(DocumentReference);
+				if (!parsed) break;
+			}
+		}
+	}
+	return parsed;
+}
+
+bool XpsPlug::parseDocReference(QString designMap)
 {
 	QByteArray f;
 	QFileInfo fi(designMap);
 	QString path = fi.path();
-	if (uz->read(designMap, f))
-	{
-		QDomDocument designMapDom;
-		if(designMapDom.setContent(f))
-		{
-			QString PageReference = "";
-			QDomElement docElem = designMapDom.documentElement();
-			if (importerFlags & LoadSavePlugin::lfCreateThumbnail)
-			{
-				QDomNodeList pgList = docElem.childNodes();
-				QDomNode drawPag = pgList.item(0);
-				QDomElement dpg = drawPag.toElement();
-				if (dpg.tagName() == "PageContent")
-				{
-					if (dpg.hasAttribute("Source"))
-					{
-						PageReference = dpg.attribute("Source", "");
-						if (PageReference.startsWith("/"))
+	if (!uz->read(designMap, f))
+		return false;
+
+	QDomDocument designMapDom;
+	if (!designMapDom.setContent(f))
+		return false;
+
+	QString PageReference = "";
+	QDomElement docElem = designMapDom.documentElement();
+	if (importerFlags & LoadSavePlugin::lfCreateThumbnail)
+	{
+		QDomNodeList pgList = docElem.childNodes();
+		QDomNode drawPag = pgList.item(0);
+		QDomElement dpg = drawPag.toElement();
+		if (dpg.tagName() == "PageContent")
+		{
+			if (dpg.hasAttribute("Source"))
+			{
+				PageReference = dpg.attribute("Source", "");
+				if (PageReference.startsWith("/"))
+				{
+					PageReference = PageReference.mid(1);
+					parsePageReference(PageReference);
+				}
+				else
+				{
+					if (!PageReference.startsWith(path))
+					{
+						PageReference = path + "/" + PageReference;
+						PageReference = QDir::cleanPath(PageReference);
+					}
+					parsePageReference(PageReference);
+				}
+			}
+		}
+	}
+	else
+	{
+		std::vector<int> pageNs;
+		QString pageString = "*";
+		int pgCount = 0;
+		int maxPages = docElem.childNodes().count();
+		if (((interactive) || (importerFlags & LoadSavePlugin::lfCreateDoc)) && (maxPages > 1))
+		{
+			if (progressDialog)
+				progressDialog->hide();
+			qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
+			XpsImportOptions optImp(ScCore->primaryMainWindow());
+			optImp.setUpOptions(m_FileName, 1, maxPages, interactive);
+			if (optImp.exec() != QDialog::Accepted)
+				return false;
+			pageString = optImp.getPagesString();
+			qApp->changeOverrideCursor(QCursor(Qt::WaitCursor));
+			if (progressDialog)
+				progressDialog->show();
+			qApp->processEvents();
+		}
+		parsePagesString(pageString, &pageNs, maxPages);
+		if (pageString != "*")
+			maxPages = pageNs.size();
+		if (progressDialog)
+		{
+			progressDialog->setTotalSteps("GI", maxPages);
+			progressDialog->setProgress("GI", pgCount);
+			qApp->processEvents();
+		}
+		QDomNodeList pgList = docElem.childNodes();
+		for (uint ap = 0; ap < pageNs.size(); ++ap)
+		{
+			QDomNode drawPag = pgList.item(pageNs[ap] - 1);
+			QDomElement dpg = drawPag.toElement();
+			if (dpg.tagName() == "PageContent")
+			{
+				if (dpg.hasAttribute("Source"))
+				{
+					PageReference = dpg.attribute("Source", "");
+					if (PageReference.startsWith("/"))
+					{
+						PageReference = PageReference.mid(1);
+						parsePageReference(PageReference);
+					}
+					else
+					{
+						if (!PageReference.startsWith(path))
 						{
-							PageReference = PageReference.mid(1);
-							parsePageReference(PageReference);
+							PageReference = path + "/" + PageReference;
+							PageReference = QDir::cleanPath(PageReference);
 						}
-						else
-						{
-							if (!PageReference.startsWith(path))
-							{
-								PageReference = path + "/" + PageReference;
-								PageReference = QDir::cleanPath(PageReference);
-							}
-							parsePageReference(PageReference);
-						}
-					}
-				}
-			}
-			else
-			{
-				std::vector<int> pageNs;
-				QString pageString = "*";
-				int pgCount = 0;
-				int maxPages = docElem.childNodes().count();
-				if (((interactive) || (importerFlags & LoadSavePlugin::lfCreateDoc)) && (maxPages > 1))
-				{
-					if (progressDialog)
-						progressDialog->hide();
-					qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
-					XpsImportOptions *optImp = new XpsImportOptions(ScCore->primaryMainWindow());
-					optImp->setUpOptions(m_FileName, 1, maxPages, interactive);
-					optImp->exec();
-					pageString = optImp->getPagesString();
-					delete optImp;
-					qApp->changeOverrideCursor(QCursor(Qt::WaitCursor));
-					if (progressDialog)
-						progressDialog->show();
-					qApp->processEvents();
-				}
-				parsePagesString(pageString, &pageNs, maxPages);
-				if (pageString != "*")
-					maxPages = pageNs.size();
-				if (progressDialog)
-				{
-					progressDialog->setTotalSteps("GI", maxPages);
-					progressDialog->setProgress("GI", pgCount);
-					qApp->processEvents();
-				}
-				QDomNodeList pgList = docElem.childNodes();
-				for (uint ap = 0; ap < pageNs.size(); ++ap)
-				{
-					QDomNode drawPag = pgList.item(pageNs[ap] - 1);
-					QDomElement dpg = drawPag.toElement();
-					if (dpg.tagName() == "PageContent")
-					{
-						if (dpg.hasAttribute("Source"))
-						{
-							PageReference = dpg.attribute("Source", "");
-							if (PageReference.startsWith("/"))
-							{
-								PageReference = PageReference.mid(1);
-								parsePageReference(PageReference);
-							}
-							else
-							{
-								if (!PageReference.startsWith(path))
-								{
-									PageReference = path + "/" + PageReference;
-									PageReference = QDir::cleanPath(PageReference);
-								}
-								parsePageReference(PageReference);
-							}
-						}
-					}
-					pgCount++;
-					if (progressDialog)
-					{
-						progressDialog->setProgress("GI", pgCount);
-						qApp->processEvents();
-					}
-				}
-			}
-		}
-	}
+						parsePageReference(PageReference);
+					}
+				}
+			}
+			pgCount++;
+			if (progressDialog)
+			{
+				progressDialog->setProgress("GI", pgCount);
+				qApp->processEvents();
+			}
+		}
+	}
+	return true;
 }
 
 void XpsPlug::parsePageReference(QString designMap)

Modified: trunk/Scribus/scribus/plugins/import/xps/importxps.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18657&path=/trunk/Scribus/scribus/plugins/import/xps/importxps.h
==============================================================================
--- trunk/Scribus/scribus/plugins/import/xps/importxps.h (original)
+++ trunk/Scribus/scribus/plugins/import/xps/importxps.h Tue Dec 17 23:06:49 2013
@@ -104,8 +104,8 @@
 		double DashOffset;
 	};
 	bool convert(QString fn);
-	void parseDocSequence(QString designMap);
-	void parseDocReference(QString designMap);
+	bool parseDocSequence(QString designMap);
+	bool parseDocReference(QString designMap);
 	void parsePageReference(QString designMap);
 	PageItem* parseObjectXML(QDomElement& dpg, QString path);
 	void parseOpacityXML(QDomElement &spe, QString path, ObjState &obState);

Modified: trunk/Scribus/scribus/plugins/import/xps/importxpsplugin.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18657&path=/trunk/Scribus/scribus/plugins/import/xps/importxpsplugin.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/xps/importxpsplugin.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/xps/importxpsplugin.cpp Tue Dec 17 23:06:49 2013
@@ -168,7 +168,7 @@
 		activeTransaction = new UndoTransaction(UndoManager::instance()->beginTransaction(trSettings));
 	XpsPlug *dia = new XpsPlug(m_Doc, flags);
 	Q_CHECK_PTR(dia);
-	dia->import(fileName, trSettings, flags);
+	bool ret = dia->import(fileName, trSettings, flags);
 	if (activeTransaction)
 	{
 		activeTransaction->commit();
@@ -178,7 +178,7 @@
 	if (emptyDoc || !(flags & lfInteractive) || !(flags & lfScripted))
 		UndoManager::instance()->setUndoEnabled(true);
 	delete dia;
-	return true;
+	return ret;
 }
 
 QImage ImportXpsPlugin::readThumbnail(const QString& fileName)




More information about the scribus-commit mailing list