[poppler] 2 commits - qt4/src

Pino Toscano pino at kemper.freedesktop.org
Thu Feb 14 12:02:57 PST 2008


 qt4/src/poppler-form.cc    |   13 +++----------
 qt4/src/poppler-private.cc |   21 +++++++++++++++++++++
 qt4/src/poppler-private.h  |    8 +++++++-
 3 files changed, 31 insertions(+), 11 deletions(-)

New commits:
commit 2316455864e9c900c08d051c59b9508eddcb7c34
Author: Pino Toscano <pino at kde.org>
Date:   Thu Feb 14 21:02:20 2008 +0100

    Pipe the poppler error messages through the Qt debug system.

diff --git a/qt4/src/poppler-private.cc b/qt4/src/poppler-private.cc
index 7d4458a..cc6a0eb 100644
--- a/qt4/src/poppler-private.cc
+++ b/qt4/src/poppler-private.cc
@@ -22,8 +22,29 @@
 
 #include "poppler-private.h"
 
+#include <QtCore/QByteArray>
+#include <QtCore/QDebug>
+
 namespace Poppler {
 
+    void qt4ErrorFunction(int pos, char *msg, va_list args)
+    {
+        QString emsg;
+        char buffer[1024]; // should be big enough
+
+        if (pos >= 0)
+        {
+            emsg = QString::fromLatin1("Error (%1): ").arg(pos);
+        }
+        else
+        {
+            emsg = QString::fromLatin1("Error: ");
+        }
+        qvsnprintf(buffer, sizeof(buffer) - 1, msg, args);
+        emsg += QString::fromAscii(buffer);
+        qDebug() << emsg;
+    }
+
     QString unicodeToQString(Unicode* u, int len) {
         QString ret;
         ret.resize(len);
diff --git a/qt4/src/poppler-private.h b/qt4/src/poppler-private.h
index 32981ae..77cb431 100644
--- a/qt4/src/poppler-private.h
+++ b/qt4/src/poppler-private.h
@@ -34,6 +34,7 @@
 #include <PDFDoc.h>
 #include <FontInfo.h>
 #include <OutputDev.h>
+#include <Error.h>
 #if defined(HAVE_SPLASH)
 #include <SplashOutputDev.h>
 #endif
@@ -53,6 +54,7 @@ namespace Poppler {
 
     GooString *QStringToGooString(const QString &s);
 
+    void qt4ErrorFunction(int pos, char *msg, va_list args);
 
     class LinkDestinationData
     {
@@ -96,7 +98,11 @@ namespace Poppler {
 		delete ownerPassword;
 		delete userPassword;
 		
-		if ( count == 0 ) globalParams = new GlobalParams();
+		if ( count == 0 )
+		{
+			globalParams = new GlobalParams();
+			setErrorFunction(qt4ErrorFunction);
+		}
 		count ++;
 	    }
 	
commit d985d3b0cdc57370137865add2a5f3a7802109c7
Author: Pino Toscano <pino at kde.org>
Date:   Thu Feb 14 14:56:18 2008 +0100

    Use what FormWidgetText give us.

diff --git a/qt4/src/poppler-form.cc b/qt4/src/poppler-form.cc
index f206f69..bc63552 100644
--- a/qt4/src/poppler-form.cc
+++ b/qt4/src/poppler-form.cc
@@ -246,16 +246,9 @@ bool FormFieldText::isRichText() const
 
 int FormFieldText::maximumLength() const
 {
-  Object *obj = m_formData->fm->getObj();
-  int maxlen = -1;
-  if (!obj->isDict()) return maxlen;
-  Object tmp;
-  if (obj->dictLookup("MaxLen", &tmp)->isInt())
-  {
-    maxlen = tmp.getInt();
-  }
-  tmp.free();
-  return maxlen;
+  FormWidgetText* fwt = static_cast<FormWidgetText*>(m_formData->fm);
+  const int maxlen = fwt->getMaxLen();
+  return maxlen > 0 ? maxlen : -1;
 }
 
 Qt::Alignment FormFieldText::textAlignment() const


More information about the poppler mailing list