[poppler] [PATCH] initial clean poppler-qt implementation

Jeff Muizelaar jrmuizel at nit.ca
Thu Mar 31 06:45:46 PST 2005


On Thu, Mar 31, 2005 at 02:13:00AM -0500, Kristian H??gsberg wrote:
> Jeff Muizelaar wrote:
> >+elif test x$enable_poppler_qt = xtry; then
> >+  echo "tryingidie"
> 
> Is this a debug echo?
> 

Yep, good catch.

> >+PopplerDocument *PopplerDocument::load(const QString &filePath)
> >+{
> >+  if (!globalParams) {
> >+    globalParams = new GlobalParams("/etc/xpdfrc");
> >+    globalParams->setupBaseFontsFc(NULL);
> >+  }
> >+
> >+  PDFDoc *doc = new PDFDoc(new GooString(QFile::encodeName(filePath)), 0, 
> >0);
> >+  PopplerDocument *pdoc;
> >+  if (doc->isOk() || doc->getErrorCode() == errEncrypted) {
> >+    pdoc = new PopplerDocument(doc);
> >+    if (doc->getErrorCode() == errEncrypted)
> >+      pdoc->locked = true;
> >+    else
> >+      pdoc->locked = false;
> >+    return pdoc;
> >+  }
> >+  else
> >+    return NULL;
> >+}
> 
> I still think we should pass an error code back to the application here 
> so that it's possible to distinguish between file not found and file not 
> valid pdf.
> 

Yeah I sort of agree, any thoughts from the kpdf people as to whether
they actually want it and what type of interface they want to it?

> >+#ifndef __POPPLER_QT_H__
> >+#define __POPPLER_QT_H__
> >+
> >+#include <qpixmap.h>
> >+
> >+class PDFDoc *doc;
> 
> I think we should try to design the wrapper in a way that completely 
> hides away the xpdf types.  PDFDoc and Page are quite nasty 
> namespace-pollution-wise.  One approach I considered was
> 
> 	class PopplerDocumentData;
> 
> in the header file and
> 
> 	class PopplerDocumentData {
> 		PDFDoc doc;
> 	};
> 
> in the implementation.  The PDFDoc *doc member would then be 
> PopplerDocumentData *data instead.  Could that work?

Yeah, that will work perfectly. 
> 
> Oh, and should we use namespaces?  Poppler::Document, Poppler::Page?  I 
> think that would be nice.

Makes no difference to me, but seems like a sane thing to do. Unless
anyone has any objections I will use them.

> >+class PopplerPage {
> >+  friend class PopplerDocument;
> >+  public:
> >+    int index;
> >+    void renderToPixmap(QPixmap **q);
> >+  private:
> >+    PopplerPage(PopplerDocument *_doc, int _index) {
> >+      index = _index;
> >+      doc = _doc;
> >+    }
> >+    PopplerDocument *doc;
> >+};
> 
> In the glib binding I've chosen to also cache a pointer to the 
> corresponding Page object in the PopplerPage object.
>

Yeah I know, I was holding off on that until I actually neeeded it.

Thanks for the review.

-Jeff


More information about the poppler mailing list