Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/pdf/xpdf/Page.h
blob: 6c020c7dc04d6dd5ed0a6c921220a2aad2debee4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
//========================================================================
//
// Page.h
//
// Copyright 1996 Derek B. Noonburg
//
//========================================================================

#ifndef PAGE_H
#define PAGE_H

#ifdef __GNUC__
#pragma interface
#endif

#include "Object.h"

class Dict;
class XRef;
class OutputDev;

//------------------------------------------------------------------------
// PageAttrs
//------------------------------------------------------------------------

class PageAttrs {
public:

  // Construct a new PageAttrs object by merging a dictionary
  // (of type Pages or Page) into another PageAttrs object.  If
  // <attrs> is NULL, uses defaults.
  PageAttrs(PageAttrs *attrs, Dict *dict);

  // Destructor.
  ~PageAttrs();

  // Accessors.
  double getX1() { return limitToCropBox ? cropX1 : x1; }
  double getY1() { return limitToCropBox ? cropY1 : y1; }
  double getX2() { return limitToCropBox ? cropX2 : x2; }
  double getY2() { return limitToCropBox ? cropY2 : y2; }
  GBool isCropped() { return cropX2 > cropX1; }
  double getCropX1() { return cropX1; }
  double getCropY1() { return cropY1; }
  double getCropX2() { return cropX2; }
  double getCropY2() { return cropY2; }
  int getRotate() { return rotate; }
  Dict *getResourceDict()
    { return resources.isDict() ? resources.getDict() : (Dict *)NULL; }

private:

  double x1, y1, x2, y2;
  double cropX1, cropY1, cropX2, cropY2;
  GBool limitToCropBox;
  int rotate;
  Object resources;
};

//------------------------------------------------------------------------
// Page
//------------------------------------------------------------------------

class Page {
public:

  // Constructor.
  Page(int num1, Dict *pageDict, PageAttrs *attrs1);

  // Destructor.
  ~Page();

  // Is page valid?
  GBool isOk() { return ok; }

  // Get page parameters.
  double getX1() { return attrs->getX1(); }
  double getY1() { return attrs->getY1(); }
  double getX2() { return attrs->getX2(); }
  double getY2() { return attrs->getY2(); }
  GBool isCropped() { return attrs->isCropped(); }
  double getCropX1() { return attrs->getCropX1(); }
  double getCropY1() { return attrs->getCropY1(); }
  double getCropX2() { return attrs->getCropX2(); }
  double getCropY2() { return attrs->getCropY2(); }
  double getWidth() { return attrs->getX2() - attrs->getX1(); }
  double getHeight() { return attrs->getY2() - attrs->getY1(); }
  int getRotate() { return attrs->getRotate(); }

  // Get resource
  Dict *getResourceDict() { return attrs->getResourceDict(); }

  // Get annotations array.
  Object *getAnnots(Object *obj) { return annots.fetch(obj); }

  // Get contents.
  Object *getContents(Object *obj) { return contents.fetch(obj); }

  // Display a page.
  void display(OutputDev *out, int dpi, int rotate);

private:

  int num;			// page number
  PageAttrs *attrs;		// page attributes
  Object annots;		// annotations array
  Object contents;		// page contents
  GBool ok;			// true if page is valid
};

#endif