home *** CD-ROM | disk | FTP | other *** search
/ PSION CD 2 / PsionCDVol2.iso / Programs / 720 / PDF090B4-SorceCode / pdf / XRef.h < prev   
Encoding:
C/C++ Source or Header  |  2000-09-30  |  2.9 KB  |  128 lines

  1. //========================================================================
  2. //
  3. // XRef.h
  4. //
  5. // Copyright 1996 Derek B. Noonburg
  6. //
  7. //========================================================================
  8. //
  9. // Ported to EPOC by Sander van der Wal
  10. //
  11. // $Id: XRef.h 1.2 2000-09-17 13:38:13+02 svdwal Exp svdwal $
  12.  
  13. #ifndef XREF_H
  14. #define XREF_H
  15.  
  16. #ifdef __GNUC__
  17. #pragma interface
  18. #endif
  19.  
  20. #ifndef __E32BASE_H__
  21. #include <e32base.h>
  22. #endif
  23.  
  24. #ifndef __F32FILE_H__
  25. #include <f32file.h>
  26. #endif
  27.  
  28. // --o C library
  29. #include <stdio.h>
  30.  
  31. // --o GooLib
  32. #include "gtypes.h"
  33.  
  34. // --o PdfLib
  35. #include "Object.h"
  36. class Dict;
  37. class FileStream;
  38.  
  39.  
  40. //------------------------------------------------------------------------
  41. // XRef
  42. //------------------------------------------------------------------------
  43.  
  44. struct XRefEntry {
  45.   int offset;
  46.   int gen;
  47.   GBool used;
  48. };
  49.  
  50. class XRef: public CBase {
  51. public:
  52.  
  53.   // Constructor.  Read xref table from stream.
  54.   XRef() {}
  55.   void ConstructL(FileStream *str);
  56.  
  57.   // Destructor.
  58.   ~XRef();
  59.  
  60.   // Is xref table valid?
  61.   GBool isOk() { return ok; }
  62.  
  63.   // Is the file encrypted?
  64.   GBool isEncrypted() { return encrypted; }
  65.  
  66.   // Are printing and copying allowed?  If not, print an error message.
  67.   GBool okToPrint();
  68.   GBool okToCopy();
  69.   GBool okToChange();
  70.   GBool okToAddNotes();
  71.  
  72.   // Get catalog object.
  73.   Object *getCatalogL(Object *obj) { return fetchL(rootNum, rootGen, obj); }
  74.  
  75.   // Get encryption key
  76.   GString *getEncryptionKey() { return encryptionKey; };
  77.  
  78.   // Fetch an indirect reference.
  79.   Object *fetchL(int num, int gen, Object *obj);
  80.  
  81.   // Return the document's Info dictionary (if any).
  82.   Object *getDocInfoL(Object *obj);
  83.  
  84. private:
  85.  
  86.   RFile file;            // input file
  87.   int start;            // offset in file (to allow for garbage
  88.                     //   at beginning of file)
  89.   XRefEntry *entries;        // xref entries
  90.   int size;            // size of <entries> array
  91.   int rootNum, rootGen;        // catalog dict
  92.   GBool ok;            // true if xref table is valid
  93.   Object trailerDict;        // trailer dictionary
  94.  
  95.   GBool m_okToPrint;
  96.   GBool m_okToCopy;
  97.   GBool m_okToChange;
  98.   GBool m_okToAddNotes;
  99.   Object encryptionDict;        // encryption dictionary
  100.   GBool encrypted;
  101.   GString* encryptionKey;
  102.  
  103.   GBool setupDecryptionL();
  104.   GBool checkUserPasswordL(GString *userPassword);
  105.   GBool MakeEncryptionKeyL(GString *password, GString *encryptionKey);
  106.   GBool preparePasswordL(GString *password, GString *preparedPassword);
  107.  
  108.   int readTrailerL(FileStream *str);
  109.   GBool readXRefL(FileStream *str, int *pos);
  110.   GBool constructXRefL(FileStream *str);
  111.   GBool checkEncryptedL();
  112. };
  113.  
  114. //------------------------------------------------------------------------
  115. // The global xref table
  116. //------------------------------------------------------------------------
  117.  
  118. #ifdef __SYMBIAN32__
  119. struct XRefGlobal {
  120.   XRefGlobal();
  121.   XRef* xref;
  122. };
  123. #else
  124. extern XRef *xref;
  125. #endif
  126.  
  127. #endif
  128.