]> www.fi.muni.cz Git - evince.git/blobdiff - pdf/xpdf/PDFDoc.cc
file cursor-hand-open.png was initially added on branch gpdf-modes.
[evince.git] / pdf / xpdf / PDFDoc.cc
index f3b7f799417c272f705b5b8ffeafd92e58afd09e..e156c3f7232e5c247ba1109ffca4e4d1cac86f75 100644 (file)
@@ -2,15 +2,16 @@
 //
 // PDFDoc.cc
 //
-// Copyright 1996-2002 Glyph & Cog, LLC
+// Copyright 1996-2003 Glyph & Cog, LLC
 //
 //========================================================================
 
-#ifdef __GNUC__
+#include <aconf.h>
+
+#ifdef USE_GCC_PRAGMAS
 #pragma implementation
 #endif
 
-#include <aconf.h>
 #include <locale.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -18,6 +19,7 @@
 #include <string.h>
 #include "GString.h"
 #include "config.h"
+#include "GlobalParams.h"
 #include "Page.h"
 #include "Catalog.h"
 #include "Stream.h"
@@ -28,6 +30,9 @@
 #include "ErrorCodes.h"
 #include "Lexer.h"
 #include "Parser.h"
+#ifndef DISABLE_OUTLINE
+#include "Outline.h"
+#endif
 #include "PDFDoc.h"
 
 //------------------------------------------------------------------------
@@ -40,9 +45,9 @@
 //------------------------------------------------------------------------
 
 PDFDoc::PDFDoc(GString *fileNameA, GString *ownerPassword,
-              GString *userPassword, GBool printCommandsA) {
+              GString *userPassword) {
   Object obj;
-  GString *fileName2;
+  GString *fileName1, *fileName2;
 
   ok = gFalse;
   errCode = errNone;
@@ -52,19 +57,24 @@ PDFDoc::PDFDoc(GString *fileNameA, GString *ownerPassword,
   xref = NULL;
   catalog = NULL;
   links = NULL;
-  printCommands = printCommandsA;
+#ifndef DISABLE_OUTLINE
+  outline = NULL;
+#endif
 
-  // try to open file
   fileName = fileNameA;
+  fileName1 = fileName;
+
+
+  // try to open file
   fileName2 = NULL;
 #ifdef VMS
-  if (!(file = fopen(fileName->getCString(), "rb", "ctx=stm"))) {
-    error(-1, "Couldn't open file '%s'", fileName->getCString());
+  if (!(file = fopen(fileName1->getCString(), "rb", "ctx=stm"))) {
+    error(-1, "Couldn't open file '%s'", fileName1->getCString());
     errCode = errOpenFile;
     return;
   }
 #else
-  if (!(file = fopen(fileName->getCString(), "rb"))) {
+  if (!(file = fopen(fileName1->getCString(), "rb"))) {
     fileName2 = fileName->copy();
     fileName2->lowerCase();
     if (!(file = fopen(fileName2->getCString(), "rb"))) {
@@ -88,7 +98,7 @@ PDFDoc::PDFDoc(GString *fileNameA, GString *ownerPassword,
 }
 
 PDFDoc::PDFDoc(BaseStream *strA, GString *ownerPassword,
-              GString *userPassword, GBool printCommandsA) {
+              GString *userPassword) {
   ok = gFalse;
   errCode = errNone;
   fileName = NULL;
@@ -97,11 +107,15 @@ PDFDoc::PDFDoc(BaseStream *strA, GString *ownerPassword,
   xref = NULL;
   catalog = NULL;
   links = NULL;
-  printCommands = printCommandsA;
+#ifndef DISABLE_OUTLINE
+  outline = NULL;
+#endif
   ok = setup(ownerPassword, userPassword);
 }
 
 GBool PDFDoc::setup(GString *ownerPassword, GString *userPassword) {
+  str->reset();
+
   // check header
   checkHeader();
 
@@ -114,18 +128,28 @@ GBool PDFDoc::setup(GString *ownerPassword, GString *userPassword) {
   }
 
   // read catalog
-  catalog = new Catalog(xref, printCommands);
+  catalog = new Catalog(xref);
   if (!catalog->isOk()) {
     error(-1, "Couldn't read page catalog");
     errCode = errBadCatalog;
     return gFalse;
   }
 
+#ifndef DISABLE_OUTLINE
+  // read outline
+  outline = new Outline(catalog->getOutline(), xref);
+#endif
+
   // done
   return gTrue;
 }
 
 PDFDoc::~PDFDoc() {
+#ifndef DISABLE_OUTLINE
+  if (outline) {
+    delete outline;
+  }
+#endif
   if (catalog) {
     delete catalog;
   }
@@ -181,11 +205,15 @@ void PDFDoc::checkHeader() {
   }
 }
 
-void PDFDoc::displayPage(OutputDev *out, int page, double zoom,
-                        int rotate, GBool doLinks) {
+void PDFDoc::displayPage(OutputDev *out, int page, double hDPI, double vDPI,
+                        int rotate, GBool crop, GBool doLinks,
+                        GBool (*abortCheckCbk)(void *data),
+                        void *abortCheckCbkData,
+                         GBool (*annotDisplayDecideCbk)(Annot *annot, void *user_data),
+                         void *annotDisplayDecideCbkData) {
   Page *p;
 
-  if (printCommands) {
+  if (globalParams->getPrintCommands()) {
     printf("***** page %d *****\n", page);
   }
   p = catalog->getPage(page);
@@ -195,21 +223,50 @@ void PDFDoc::displayPage(OutputDev *out, int page, double zoom,
       links = NULL;
     }
     getLinks(p);
-    p->display(out, zoom, rotate, links, catalog);
+    p->display(out, hDPI, vDPI, rotate, crop, links, catalog,
+              abortCheckCbk, abortCheckCbkData,
+               annotDisplayDecideCbk, annotDisplayDecideCbkData);
   } else {
-    p->display(out, zoom, rotate, NULL, catalog);
+    p->display(out, hDPI, vDPI, rotate, crop, NULL, catalog,
+              abortCheckCbk, abortCheckCbkData,
+               annotDisplayDecideCbk, annotDisplayDecideCbkData);
   }
 }
 
 void PDFDoc::displayPages(OutputDev *out, int firstPage, int lastPage,
-                         int zoom, int rotate, GBool doLinks) {
+                         double hDPI, double vDPI, int rotate,
+                         GBool crop, GBool doLinks,
+                         GBool (*abortCheckCbk)(void *data),
+                         void *abortCheckCbkData,
+                          GBool (*annotDisplayDecideCbk)(Annot *annot, void *user_data),
+                          void *annotDisplayDecideCbkData) {
   int page;
 
   for (page = firstPage; page <= lastPage; ++page) {
-    displayPage(out, page, zoom, rotate, doLinks);
+    displayPage(out, page, hDPI, vDPI, rotate, crop, doLinks,
+               abortCheckCbk, abortCheckCbkData,
+                annotDisplayDecideCbk, annotDisplayDecideCbkData);
   }
 }
 
+void PDFDoc::displayPageSlice(OutputDev *out, int page,
+                             double hDPI, double vDPI,
+                             int rotate, GBool crop,
+                             int sliceX, int sliceY, int sliceW, int sliceH,
+                             GBool (*abortCheckCbk)(void *data),
+                             void *abortCheckCbkData,
+                              GBool (*annotDisplayDecideCbk)(Annot *annot, void *user_data),
+                              void *annotDisplayDecideCbkData) {
+  Page *p;
+
+  p = catalog->getPage(page);
+  p->displaySlice(out, hDPI, vDPI, rotate, crop,
+                 sliceX, sliceY, sliceW, sliceH,
+                 NULL, catalog,
+                  abortCheckCbk, abortCheckCbkData,
+                  annotDisplayDecideCbk, annotDisplayDecideCbkData);
+}
+
 GBool PDFDoc::isLinearized() {
   Parser *parser;
   Object obj1, obj2, obj3, obj4, obj5;