[poppler] poppler/poppler: PDFDoc.cc, 1.6, 1.7 PDFDoc.h, 1.4, 1.5 XRef.cc, 1.7, 1.8 XRef.h, 1.3, 1.4

Marco Pesenti Gritti marco at freedesktop.org
Fri Sep 16 12:33:07 PDT 2005


Update of /cvs/poppler/poppler/poppler
In directory gabe:/tmp/cvs-serv13307/poppler

Modified Files:
	PDFDoc.cc PDFDoc.h XRef.cc XRef.h 
Log Message:
2005-09-16  Marco Pesenti Gritti  <mpg at redhat.com>

        * poppler/PDFDoc.cc:
        * poppler/PDFDoc.h:
        * poppler/XRef.cc:
        * poppler/XRef.h:

        Merge more from 3.01



Index: PDFDoc.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/PDFDoc.cc,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- PDFDoc.cc	16 Sep 2005 18:29:18 -0000	1.6
+++ PDFDoc.cc	16 Sep 2005 19:33:05 -0000	1.7
@@ -46,13 +46,15 @@
 //------------------------------------------------------------------------
 
 PDFDoc::PDFDoc(GooString *fileNameA, GooString *ownerPassword,
-	       GooString *userPassword) {
+	       GooString *userPassword, void *guiDataA) {
   Object obj;
   GooString *fileName1, *fileName2;
 
   ok = gFalse;
   errCode = errNone;
 
+  guiData = guiDataA;
+
   file = NULL;
   str = NULL;
   xref = NULL;
@@ -99,9 +101,10 @@
 }
 
 PDFDoc::PDFDoc(BaseStream *strA, GooString *ownerPassword,
-	       GooString *userPassword) {
+	       GooString *userPassword, void *guiDataA) {
   ok = gFalse;
   errCode = errNone;
+  guiData = guiDataA;
   fileName = NULL;
   file = NULL;
   str = strA;
@@ -124,13 +127,19 @@
   checkHeader();
 
   // read xref table
-  xref = new XRef(str, ownerPassword, userPassword);
+  xref = new XRef(str);
   if (!xref->isOk()) {
     error(-1, "Couldn't read xref table");
     errCode = xref->getErrorCode();
     return gFalse;
   }
 
+  // check for encryption
+  if (!checkEncryption(ownerPassword, userPassword)) {
+    errCode = errEncrypted;
+    return gFalse;
+  }
+
   // read catalog
   catalog = new Catalog(xref);
   if (!catalog->isOk()) {
@@ -232,7 +241,10 @@
     return;
   }
   str->moveStart(i);
-  p = strtok(&hdrBuf[i+5], " \t\n\r");
+  if (!(p = strtok(&hdrBuf[i+5], " \t\n\r"))) {
+    error(-1, "May not be a PDF file (continuing anyway)");
+    return;
+  }
   {
     char *theLocale = setlocale(LC_NUMERIC, "C");
     pdfVersion = atof(p);

Index: PDFDoc.h
===================================================================
RCS file: /cvs/poppler/poppler/poppler/PDFDoc.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- PDFDoc.h	16 Sep 2005 18:29:18 -0000	1.4
+++ PDFDoc.h	16 Sep 2005 19:33:05 -0000	1.5
@@ -15,7 +15,6 @@
 
 #include <stdio.h>
 #include "XRef.h"
-#include "Link.h"
 #include "Catalog.h"
 #include "Page.h"
 #include "Annot.h"
@@ -36,9 +35,9 @@
 public:
 
   PDFDoc(GooString *fileNameA, GooString *ownerPassword = NULL,
-	 GooString *userPassword = NULL);
+	 GooString *userPassword = NULL, void *guiDataA = NULL);
   PDFDoc(BaseStream *strA, GooString *ownerPassword = NULL,
-	 GooString *userPassword = NULL);
+	 GooString *userPassword = NULL, void *guiDataA = NULL);
   ~PDFDoc();
 
   // Was PDF document successfully opened?
@@ -108,13 +107,9 @@
   // not found.
   int findPage(int num, int gen) { return catalog->findPage(num, gen); }
 
-  // If point <x>,<y> is in a link, return the associated action;
-  // else return NULL.
-  LinkAction *findLink(double x, double y)
-    { return links ? links->find(x, y) : (LinkAction *)NULL; }
-
-  // Return true if <x>,<y> is in a link.
-  GBool onLink(double x, double y) { return links->onLink(x, y); }
+  // Returns the links for the current page, transferring ownership to
+  // the caller.
+  Links *takeLinks();
 
   // Find a named destination.  Returns the link destination, or
   // NULL if <name> is not a destination.
@@ -161,6 +156,9 @@
   // Save this file with another name.
   GBool saveAs(GooString *name);
 
+  // Return a pointer to the GUI (XPDFCore or WinPDFCore object).
+  void *getGUIData() { return guiData; }
+
 private:
 
   GBool setup(GooString *ownerPassword, GooString *userPassword);
@@ -172,6 +170,7 @@
   GooString *fileName;
   FILE *file;
   BaseStream *str;
+  void *guiData;
   double pdfVersion;
   XRef *xref;
   Catalog *catalog;

Index: XRef.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/XRef.cc,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- XRef.cc	16 Sep 2005 19:05:00 -0000	1.7
+++ XRef.cc	16 Sep 2005 19:33:05 -0000	1.8
@@ -201,7 +201,7 @@
 // XRef
 //------------------------------------------------------------------------
 
-XRef::XRef(BaseStream *strA, GooString *ownerPassword, GooString *userPassword) {
+XRef::XRef(BaseStream *strA) {
   Guint pos;
   Object obj;
 
@@ -217,6 +217,10 @@
   permFlags = defPermFlags;
   ownerPasswordOk = gFalse;
 
+  encrypted = gFalse;
+  permFlags = defPermFlags;
+  ownerPasswordOk = gFalse;
+
   // read the trailer
   str = strA;
   start = str->getStart();
@@ -466,6 +470,7 @@
     pos2 = (Guint)obj2.getInt();
     readXRef(&pos2);
     if (!ok) {
+      obj2.free();
       goto err1;
     }
   }
@@ -686,7 +691,7 @@
       obj.initNull();
       parser = new Parser(NULL,
 		 new Lexer(NULL,
-		   str->makeSubStream(start + pos + 7, gFalse, 0, &obj)));
+		   str->makeSubStream(pos + 7, gFalse, 0, &obj)));
       parser->getObj(&newTrailerDict);
       if (newTrailerDict.isDict()) {
 	newTrailerDict.dictLookupNF("Root", &obj);
@@ -865,6 +870,10 @@
     if (!obj1.isInt() || obj1.getInt() != num ||
 	!obj2.isInt() || obj2.getInt() != gen ||
 	!obj3.isCmd("obj")) {
+      obj1.free();
+      obj2.free();
+      obj3.free();
+      delete parser;
       goto err;
     }
     parser->getObj(obj, encrypted ? fileKey : (Guchar *)NULL, keyLength,

Index: XRef.h
===================================================================
RCS file: /cvs/poppler/poppler/poppler/XRef.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- XRef.h	16 Sep 2005 18:29:18 -0000	1.3
+++ XRef.h	16 Sep 2005 19:33:05 -0000	1.4
@@ -41,7 +41,7 @@
 public:
 
   // Constructor.  Read xref table from stream.
-  XRef(BaseStream *strA, GooString *ownerPassword, GooString *userPassword);
+  XRef(BaseStream *strA);
 
   // Destructor.
   ~XRef();
@@ -57,6 +57,10 @@
 		     Guchar *fileKeyA, int keyLengthA,
 		     int encVersionA, int encRevisionA);
 
+  // Set the encryption parameters.
+  void setEncryption(int permFlagsA, GBool ownerPasswordOkA,
+		     Guchar *fileKeyA, int keyLengthA, int encVersionA);
+
   // Is the file encrypted?
   GBool isEncrypted() { return encrypted; }
 
@@ -129,7 +133,6 @@
   GBool readXRefStreamSection(Stream *xrefStr, int *w, int first, int n);
   GBool readXRefStream(Stream *xrefStr, Guint *pos);
   GBool constructXRef();
-  GBool checkEncrypted(GooString *ownerPassword, GooString *userPassword);
   Guint strToUnsigned(char *s);
 };
 



More information about the poppler mailing list