From 98a1e3f36567639344f12932b629e526a8783aa8 Mon Sep 17 00:00:00 2001 From: sandman Date: Sat, 13 Apr 2002 00:47:20 +0000 Subject: CVS import of QPdf --- (limited to 'noncore/unsupported/qpdf/xpdf/Page.h') diff --git a/noncore/unsupported/qpdf/xpdf/Page.h b/noncore/unsupported/qpdf/xpdf/Page.h new file mode 100644 index 0000000..203878f --- a/dev/null +++ b/noncore/unsupported/qpdf/xpdf/Page.h @@ -0,0 +1,125 @@ +//======================================================================== +// +// 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; +class Links; +class Catalog; + +//------------------------------------------------------------------------ + +struct PDFRectangle { + fouble x1, y1, x2, y2; +}; + +//------------------------------------------------------------------------ +// PageAttrs +//------------------------------------------------------------------------ + +class PageAttrs { +public: + + // Construct a new PageAttrs object by merging a dictionary + // (of type Pages or Page) into another PageAttrs object. If + // is NULL, uses defaults. + PageAttrs(PageAttrs *attrs, Dict *dict); + + // Destructor. + ~PageAttrs(); + + // Accessors. + PDFRectangle *getBox() { return limitToCropBox ? &cropBox : &mediaBox; } + PDFRectangle *getMediaBox() { return &mediaBox; } + PDFRectangle *getCropBox() { return &cropBox; } + GBool isCropped() { return haveCropBox; } + PDFRectangle *getBleedBox() { return &bleedBox; } + PDFRectangle *getTrimBox() { return &trimBox; } + PDFRectangle *getArtBox() { return &artBox; } + int getRotate() { return rotate; } + Dict *getResourceDict() + { return resources.isDict() ? resources.getDict() : (Dict *)NULL; } + +private: + + GBool readBox(Dict *dict, char *key, PDFRectangle *box); + + PDFRectangle mediaBox; + PDFRectangle cropBox; + GBool haveCropBox; + GBool limitToCropBox; + PDFRectangle bleedBox; + PDFRectangle trimBox; + PDFRectangle artBox; + int rotate; + Object resources; +}; + +//------------------------------------------------------------------------ +// Page +//------------------------------------------------------------------------ + +class Page { +public: + + // Constructor. + Page(XRef *xrefA, int numA, Dict *pageDict, PageAttrs *attrsA, + GBool printCommandsA); + + // Destructor. + ~Page(); + + // Is page valid? + GBool isOk() { return ok; } + + // Get page parameters. + PDFRectangle *getBox() { return attrs->getBox(); } + PDFRectangle *getMediaBox() { return attrs->getMediaBox(); } + PDFRectangle *getCropBox() { return attrs->getCropBox(); } + GBool isCropped() { return attrs->isCropped(); } + fouble getWidth() { return attrs->getBox()->x2 - attrs->getBox()->x1; } + fouble getHeight() { return attrs->getBox()->y2 - attrs->getBox()->y1; } + PDFRectangle *getBleedBox() { return attrs->getBleedBox(); } + PDFRectangle *getTrimBox() { return attrs->getTrimBox(); } + PDFRectangle *getArtBox() { return attrs->getArtBox(); } + int getRotate() { return attrs->getRotate(); } + + // Get resource dictionary. + Dict *getResourceDict() { return attrs->getResourceDict(); } + + // Get annotations array. + Object *getAnnots(Object *obj) { return annots.fetch(xref, obj); } + + // Get contents. + Object *getContents(Object *obj) { return contents.fetch(xref, obj); } + + // Display a page. + void display(OutputDev *out, fouble dpi, int rotate, + Links *links, Catalog *catalog); + +private: + + XRef *xref; // the xref table for this PDF file + int num; // page number + PageAttrs *attrs; // page attributes + Object annots; // annotations array + Object contents; // page contents + GBool printCommands; // print the drawing commands (for debugging) + GBool ok; // true if page is valid +}; + +#endif -- cgit v0.9.0.2