home *** CD-ROM | disk | FTP | other *** search
- //========================================================================
- //
- // XRef.h
- //
- // Copyright 1996 Derek B. Noonburg
- //
- //========================================================================
- //
- // Ported to EPOC by Sander van der Wal
- //
- // $Id: XRef.h 1.2 2000-09-17 13:38:13+02 svdwal Exp svdwal $
-
- #ifndef XREF_H
- #define XREF_H
-
- #ifdef __GNUC__
- #pragma interface
- #endif
-
- #ifndef __E32BASE_H__
- #include <e32base.h>
- #endif
-
- #ifndef __F32FILE_H__
- #include <f32file.h>
- #endif
-
- // --o C library
- #include <stdio.h>
-
- // --o GooLib
- #include "gtypes.h"
-
- // --o PdfLib
- #include "Object.h"
- class Dict;
- class FileStream;
-
-
- //------------------------------------------------------------------------
- // XRef
- //------------------------------------------------------------------------
-
- struct XRefEntry {
- int offset;
- int gen;
- GBool used;
- };
-
- class XRef: public CBase {
- public:
-
- // Constructor. Read xref table from stream.
- XRef() {}
- void ConstructL(FileStream *str);
-
- // Destructor.
- ~XRef();
-
- // Is xref table valid?
- GBool isOk() { return ok; }
-
- // Is the file encrypted?
- GBool isEncrypted() { return encrypted; }
-
- // Are printing and copying allowed? If not, print an error message.
- GBool okToPrint();
- GBool okToCopy();
- GBool okToChange();
- GBool okToAddNotes();
-
- // Get catalog object.
- Object *getCatalogL(Object *obj) { return fetchL(rootNum, rootGen, obj); }
-
- // Get encryption key
- GString *getEncryptionKey() { return encryptionKey; };
-
- // Fetch an indirect reference.
- Object *fetchL(int num, int gen, Object *obj);
-
- // Return the document's Info dictionary (if any).
- Object *getDocInfoL(Object *obj);
-
- private:
-
- RFile file; // input file
- int start; // offset in file (to allow for garbage
- // at beginning of file)
- XRefEntry *entries; // xref entries
- int size; // size of <entries> array
- int rootNum, rootGen; // catalog dict
- GBool ok; // true if xref table is valid
- Object trailerDict; // trailer dictionary
-
- GBool m_okToPrint;
- GBool m_okToCopy;
- GBool m_okToChange;
- GBool m_okToAddNotes;
- Object encryptionDict; // encryption dictionary
- GBool encrypted;
- GString* encryptionKey;
-
- GBool setupDecryptionL();
- GBool checkUserPasswordL(GString *userPassword);
- GBool MakeEncryptionKeyL(GString *password, GString *encryptionKey);
- GBool preparePasswordL(GString *password, GString *preparedPassword);
-
- int readTrailerL(FileStream *str);
- GBool readXRefL(FileStream *str, int *pos);
- GBool constructXRefL(FileStream *str);
- GBool checkEncryptedL();
- };
-
- //------------------------------------------------------------------------
- // The global xref table
- //------------------------------------------------------------------------
-
- #ifdef __SYMBIAN32__
- struct XRefGlobal {
- XRefGlobal();
- XRef* xref;
- };
- #else
- extern XRef *xref;
- #endif
-
- #endif
-