[poppler] Branch 'poppler-0.12' - 3 commits - qt4/src

Albert Astals Cid aacid at kemper.freedesktop.org
Fri Oct 16 15:51:41 PDT 2009


 qt4/src/poppler-base-converter.cc   |    8 +++++++-
 qt4/src/poppler-converter-private.h |    3 ++-
 qt4/src/poppler-pdf-converter.cc    |   11 ++++++++++-
 qt4/src/poppler-ps-converter.cc     |   14 ++++++++++++--
 qt4/src/poppler-qt4.h               |   14 ++++++++++++++
 5 files changed, 45 insertions(+), 5 deletions(-)

New commits:
commit f530bc721bd23a2461b0cb765a8a6dad88ed3459
Author: Albert Astals Cid <aacid at kde.org>
Date:   Sat Oct 17 00:48:58 2009 +0200

    check the document is not locked when printing

diff --git a/qt4/src/poppler-ps-converter.cc b/qt4/src/poppler-ps-converter.cc
index fd33b49..7a1957b 100644
--- a/qt4/src/poppler-ps-converter.cc
+++ b/qt4/src/poppler-ps-converter.cc
@@ -175,6 +175,12 @@ bool PSConverter::convert()
 	Q_ASSERT(d->paperWidth != -1);
 	Q_ASSERT(d->paperHeight != -1);
 	
+	if (d->document->locked)
+	{
+		d->lastError = FileLockedError;
+		return false;
+	}
+	
 	QIODevice *dev = d->openDevice();
 	if (!dev)
 	{
commit 65cb34b7c77b95f036306460bcea6681e386afaf
Author: Albert Astals Cid <aacid at kde.org>
Date:   Sat Oct 17 00:48:27 2009 +0200

    fix file name comment

diff --git a/qt4/src/poppler-ps-converter.cc b/qt4/src/poppler-ps-converter.cc
index ca3b63a..fd33b49 100644
--- a/qt4/src/poppler-ps-converter.cc
+++ b/qt4/src/poppler-ps-converter.cc
@@ -1,4 +1,4 @@
-/* poppler-document.cc: qt interface to poppler
+/* poppler-ps-converter.cc: qt interface to poppler
  * Copyright (C) 2007, 2009, Albert Astals Cid <aacid at kde.org>
  * Copyright (C) 2008, Pino Toscano <pino at kde.org>
  *
commit dbd5ba680d846d6a57e3fb7618a64202441c6e76
Author: Albert Astals Cid <aacid at kde.org>
Date:   Sat Oct 17 00:47:34 2009 +0200

    Add a way for converters to return more exact errors they had when converting

diff --git a/qt4/src/poppler-base-converter.cc b/qt4/src/poppler-base-converter.cc
index b5f2035..11ff17c 100644
--- a/qt4/src/poppler-base-converter.cc
+++ b/qt4/src/poppler-base-converter.cc
@@ -1,5 +1,5 @@
 /* poppler-base-converter.cc: qt interface to poppler
- * Copyright (C) 2007, Albert Astals Cid <aacid at kde.org>
+ * Copyright (C) 2007, 2009, Albert Astals Cid <aacid at kde.org>
  * Copyright (C) 2008, Pino Toscano <pino at kde.org>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -96,4 +96,10 @@ void BaseConverter::setOutputDevice(QIODevice *device)
 	d->ownIodev = false;
 }
 
+BaseConverter::Error BaseConverter::lastError() const
+{
+	Q_D(const BaseConverter);
+	return d->lastError;
+}
+
 }
diff --git a/qt4/src/poppler-converter-private.h b/qt4/src/poppler-converter-private.h
index 84ae4d3..dc3e943 100644
--- a/qt4/src/poppler-converter-private.h
+++ b/qt4/src/poppler-converter-private.h
@@ -1,5 +1,5 @@
 /* poppler-converter-private.h: Qt4 interface to poppler
- * Copyright (C) 2007, Albert Astals Cid <aacid at kde.org>
+ * Copyright (C) 2007, 2009, Albert Astals Cid <aacid at kde.org>
  * Copyright (C) 2008, Pino Toscano <pino at kde.org>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -41,6 +41,7 @@ class BaseConverterPrivate
 		QString outputFileName;
 		QIODevice *iodev;
 		bool ownIodev : 1;
+		BaseConverter::Error lastError;
 };
 
 }
diff --git a/qt4/src/poppler-pdf-converter.cc b/qt4/src/poppler-pdf-converter.cc
index d0fed5b..9699b75 100644
--- a/qt4/src/poppler-pdf-converter.cc
+++ b/qt4/src/poppler-pdf-converter.cc
@@ -1,6 +1,6 @@
 /* poppler-pdf-converter.cc: qt4 interface to poppler
  * Copyright (C) 2008, Pino Toscano <pino at kde.org>
- * Copyright (C) 2008, Albert Astals Cid <aacid at kde.org>
+ * Copyright (C) 2008, 2009, Albert Astals Cid <aacid at kde.org>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -69,13 +69,20 @@ PDFConverter::PDFOptions PDFConverter::pdfOptions() const
 bool PDFConverter::convert()
 {
 	Q_D(PDFConverter);
+	d->lastError = NoError;
 
 	if (d->document->locked)
+	{
+		d->lastError = FileLockedError;
 		return false;
+	}
 
 	QIODevice *dev = d->openDevice();
 	if (!dev)
+	{
+		d->lastError = OpenOutputError;
 		return false;
+	}
 
 	bool deleteFile = false;
 	if (QFile *file = qobject_cast<QFile*>(dev))
@@ -98,6 +105,8 @@ bool PDFConverter::convert()
 		{
 			qobject_cast<QFile*>(dev)->remove();
 		}
+		if (errorCode == errOpenFile) d->lastError = OpenOutputError;
+		else d->lastError = NotSupportedInputFileError;
 	}
 
 	return (errorCode == errNone);
diff --git a/qt4/src/poppler-ps-converter.cc b/qt4/src/poppler-ps-converter.cc
index ea3887d..ca3b63a 100644
--- a/qt4/src/poppler-ps-converter.cc
+++ b/qt4/src/poppler-ps-converter.cc
@@ -1,5 +1,5 @@
 /* poppler-document.cc: qt interface to poppler
- * Copyright (C) 2007, Albert Astals Cid <aacid at kde.org>
+ * Copyright (C) 2007, 2009, Albert Astals Cid <aacid at kde.org>
  * Copyright (C) 2008, Pino Toscano <pino at kde.org>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -169,6 +169,7 @@ PSConverter::PSOptions PSConverter::psOptions() const
 bool PSConverter::convert()
 {
 	Q_D(PSConverter);
+	d->lastError = NoError;
 
 	Q_ASSERT(!d->pageList.isEmpty());
 	Q_ASSERT(d->paperWidth != -1);
@@ -176,7 +177,10 @@ bool PSConverter::convert()
 	
 	QIODevice *dev = d->openDevice();
 	if (!dev)
+	{
+		d->lastError = OpenOutputError;
 		return false;
+	}
 
 	QByteArray pstitle8Bit = d->title.toLocal8Bit();
 	char* pstitlechar;
diff --git a/qt4/src/poppler-qt4.h b/qt4/src/poppler-qt4.h
index fcce658..f41e5e3 100644
--- a/qt4/src/poppler-qt4.h
+++ b/qt4/src/poppler-qt4.h
@@ -1227,6 +1227,20 @@ QString subject = m_doc->info("Subject");
               \return whether the conversion succeeded
             */
             virtual bool convert() = 0;
+            
+            enum Error
+            {
+                NoError,
+                FileLockedError,
+                OpenOutputError,
+                NotSupportedInputFileError
+            };
+            
+            /**
+              Returns the last error
+              \since 0.12.1
+            */
+            Error lastError() const;
 
         protected:
             /// \cond PRIVATE


More information about the poppler mailing list