~ubuntu-branches/ubuntu/precise/ipe/precise

« back to all changes in this revision

Viewing changes to src/xpdflib/pdfdoc.h

  • Committer: Bazaar Package Importer
  • Author(s): Steve M. Robbins
  • Date: 2004-06-08 00:44:02 UTC
  • Revision ID: james.westby@ubuntu.com-20040608004402-72yu51xlh7vt6p9m
Tags: upstream-6.0pre16
ImportĀ upstreamĀ versionĀ 6.0pre16

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// -*- C++ -*-
 
2
//========================================================================
 
3
//
 
4
// PDFDoc.h
 
5
//
 
6
// Copyright 1996-2002 Glyph & Cog, LLC
 
7
//
 
8
//========================================================================
 
9
 
 
10
#ifndef PDFDOC_H
 
11
#define PDFDOC_H
 
12
 
 
13
#include "aconf.h"
 
14
 
 
15
#ifdef USE_GCC_PRAGMAS
 
16
#pragma interface
 
17
#endif
 
18
 
 
19
#include <stdio.h>
 
20
#include "ocfile.h"
 
21
#include "xref.h"
 
22
#include "link.h"
 
23
#include "catalog.h"
 
24
#include "page.h"
 
25
 
 
26
class GString;
 
27
class BaseStream;
 
28
class OutputDev;
 
29
class Links;
 
30
class LinkAction;
 
31
class LinkDest;
 
32
class Outline;
 
33
 
 
34
//------------------------------------------------------------------------
 
35
// PDFDoc
 
36
//------------------------------------------------------------------------
 
37
 
 
38
class PDFDoc {
 
39
public:
 
40
 
 
41
  PDFDoc(GString *fileNameA, GString *ownerPassword = NULL,
 
42
         GString *userPassword = NULL);
 
43
  PDFDoc(BaseStream *strA, GString *ownerPassword = NULL,
 
44
         GString *userPassword = NULL);
 
45
  ~PDFDoc();
 
46
 
 
47
  // Was PDF document successfully opened?
 
48
  GBool isOk() { return ok; }
 
49
 
 
50
  // Get the error code (if isOk() returns false).
 
51
  int getErrorCode() { return errCode; }
 
52
 
 
53
  // Get file name.
 
54
  GString *getFileName() { return fileName; }
 
55
 
 
56
  // Get the xref table.
 
57
  XRef *getXRef() { return xref; }
 
58
 
 
59
  // Get catalog.
 
60
  Catalog *getCatalog() { return catalog; }
 
61
 
 
62
  // Get base stream.
 
63
  BaseStream *getBaseStream() { return str; }
 
64
 
 
65
  // Get page parameters.
 
66
  double getPageWidth(int page)
 
67
    { return catalog->getPage(page)->getWidth(); }
 
68
  double getPageHeight(int page)
 
69
    { return catalog->getPage(page)->getHeight(); }
 
70
  int getPageRotate(int page)
 
71
    { return catalog->getPage(page)->getRotate(); }
 
72
 
 
73
  // Get number of pages.
 
74
  int getNumPages() { return catalog->getNumPages(); }
 
75
 
 
76
  // Return the contents of the metadata stream, or NULL if there is
 
77
  // no metadata.
 
78
  GString *readMetadata() { return catalog->readMetadata(); }
 
79
 
 
80
  // Return the structure tree root object.
 
81
  Object *getStructTreeRoot() { return catalog->getStructTreeRoot(); }
 
82
 
 
83
  // Display a page.
 
84
  void displayPage(OutputDev *out, int page, double zoom,
 
85
                   int rotate, GBool doLinks,
 
86
                   GBool (*abortCheckCbk)(void *data) = NULL,
 
87
                   void *abortCheckCbkData = NULL);
 
88
 
 
89
  // Display a range of pages.
 
90
  void displayPages(OutputDev *out, int firstPage, int lastPage,
 
91
                    int zoom, int rotate, GBool doLinks,
 
92
                    GBool (*abortCheckCbk)(void *data) = NULL,
 
93
                    void *abortCheckCbkData = NULL);
 
94
 
 
95
  // Display part of a page.
 
96
  void displayPageSlice(OutputDev *out, int page, double zoom,
 
97
                        int rotate, int sliceX, int sliceY,
 
98
                        int sliceW, int sliceH,
 
99
                        GBool (*abortCheckCbk)(void *data) = NULL,
 
100
                        void *abortCheckCbkData = NULL);
 
101
 
 
102
  // Find a page, given its object ID.  Returns page number, or 0 if
 
103
  // not found.
 
104
  int findPage(int num, int gen) { return catalog->findPage(num, gen); }
 
105
 
 
106
  // If point <x>,<y> is in a link, return the associated action;
 
107
  // else return NULL.
 
108
  LinkAction *findLink(double x, double y) { return links->find(x, y); }
 
109
 
 
110
  // Return true if <x>,<y> is in a link.
 
111
  GBool onLink(double x, double y) { return links->onLink(x, y); }
 
112
 
 
113
  // Find a named destination.  Returns the link destination, or
 
114
  // NULL if <name> is not a destination.
 
115
  LinkDest *findDest(GString *name)
 
116
    { return catalog->findDest(name); }
 
117
 
 
118
#ifndef DISABLE_OUTLINE
 
119
  // Return the outline object.
 
120
  Outline *getOutline() { return outline; }
 
121
#endif
 
122
 
 
123
  // Is the file encrypted?
 
124
  GBool isEncrypted() { return xref->isEncrypted(); }
 
125
 
 
126
  // Check various permissions.
 
127
  GBool okToPrint(GBool ignoreOwnerPW = gFalse)
 
128
    { return xref->okToPrint(ignoreOwnerPW); }
 
129
  GBool okToChange(GBool ignoreOwnerPW = gFalse)
 
130
    { return xref->okToChange(ignoreOwnerPW); }
 
131
  GBool okToCopy(GBool ignoreOwnerPW = gFalse)
 
132
    { return xref->okToCopy(ignoreOwnerPW); }
 
133
  GBool okToAddNotes(GBool ignoreOwnerPW = gFalse)
 
134
    { return xref->okToAddNotes(ignoreOwnerPW); }
 
135
 
 
136
  // Is this document linearized?
 
137
  GBool isLinearized();
 
138
 
 
139
  // Return the document's Info dictionary (if any).
 
140
  Object *getDocInfo(Object *obj) { return xref->getDocInfo(obj); }
 
141
  Object *getDocInfoNF(Object *obj) { return xref->getDocInfoNF(obj); }
 
142
 
 
143
  // Return the PDF version specified by the file.
 
144
  double getPDFVersion() { return pdfVersion; }
 
145
 
 
146
  // Save this file with another name.
 
147
  GBool saveAs(GString *name);
 
148
 
 
149
 
 
150
private:
 
151
 
 
152
  GBool setup(GString *ownerPassword, GString *userPassword);
 
153
  void checkHeader();
 
154
  void getLinks(Page *page);
 
155
 
 
156
  GString *fileName;
 
157
  OCFILE *file;
 
158
  BaseStream *str;
 
159
  double pdfVersion;
 
160
  XRef *xref;
 
161
  Catalog *catalog;
 
162
  Links *links;
 
163
#ifndef DISABLE_OUTLINE
 
164
  Outline *outline;
 
165
#endif
 
166
 
 
167
 
 
168
  GBool ok;
 
169
  int errCode;
 
170
};
 
171
 
 
172
#endif