Initial revision
[swftools.git] / pdf2swf / xpdf / Page.h
1 //========================================================================
2 //
3 // Page.h
4 //
5 // Copyright 1996 Derek B. Noonburg
6 //
7 //========================================================================
8
9 #ifndef PAGE_H
10 #define PAGE_H
11
12 #ifdef __GNUC__
13 #pragma interface
14 #endif
15
16 #include "Object.h"
17
18 class Dict;
19 class XRef;
20 class OutputDev;
21 class Links;
22 class Catalog;
23
24 //------------------------------------------------------------------------
25 // PageAttrs
26 //------------------------------------------------------------------------
27
28 class PageAttrs {
29 public:
30
31   // Construct a new PageAttrs object by merging a dictionary
32   // (of type Pages or Page) into another PageAttrs object.  If
33   // <attrs> is NULL, uses defaults.
34   PageAttrs(PageAttrs *attrs, Dict *dict);
35
36   // Destructor.
37   ~PageAttrs();
38
39   // Accessors.
40   double getX1() { return limitToCropBox ? cropX1 : x1; }
41   double getY1() { return limitToCropBox ? cropY1 : y1; }
42   double getX2() { return limitToCropBox ? cropX2 : x2; }
43   double getY2() { return limitToCropBox ? cropY2 : y2; }
44   GBool isCropped() { return cropX2 > cropX1; }
45   double getCropX1() { return cropX1; }
46   double getCropY1() { return cropY1; }
47   double getCropX2() { return cropX2; }
48   double getCropY2() { return cropY2; }
49   int getRotate() { return rotate; }
50   Dict *getResourceDict()
51     { return resources.isDict() ? resources.getDict() : (Dict *)NULL; }
52
53 private:
54
55   double x1, y1, x2, y2;
56   double cropX1, cropY1, cropX2, cropY2;
57   GBool limitToCropBox;
58   int rotate;
59   Object resources;
60 };
61
62 //------------------------------------------------------------------------
63 // Page
64 //------------------------------------------------------------------------
65
66 class Page {
67 public:
68
69   // Constructor.
70   Page(int num1, Dict *pageDict, PageAttrs *attrs1);
71
72   // Destructor.
73   ~Page();
74
75   // Is page valid?
76   GBool isOk() { return ok; }
77
78   // Get page parameters.
79   double getX1() { return attrs->getX1(); }
80   double getY1() { return attrs->getY1(); }
81   double getX2() { return attrs->getX2(); }
82   double getY2() { return attrs->getY2(); }
83   GBool isCropped() { return attrs->isCropped(); }
84   double getCropX1() { return attrs->getCropX1(); }
85   double getCropY1() { return attrs->getCropY1(); }
86   double getCropX2() { return attrs->getCropX2(); }
87   double getCropY2() { return attrs->getCropY2(); }
88   double getWidth() { return attrs->getX2() - attrs->getX1(); }
89   double getHeight() { return attrs->getY2() - attrs->getY1(); }
90   int getRotate() { return attrs->getRotate(); }
91
92   // Get resource dictionary.
93   Dict *getResourceDict() { return attrs->getResourceDict(); }
94
95   // Get annotations array.
96   Object *getAnnots(Object *obj) { return annots.fetch(obj); }
97
98   // Get contents.
99   Object *getContents(Object *obj) { return contents.fetch(obj); }
100
101   // Display a page.
102   void display(OutputDev *out, double dpi, int rotate,
103                Links *links, Catalog *catalog);
104
105 private:
106
107   int num;                      // page number
108   PageAttrs *attrs;             // page attributes
109   Object annots;                // annotations array
110   Object contents;              // page contents
111   GBool ok;                     // true if page is valid
112 };
113
114 #endif