]> www.fi.muni.cz Git - evince.git/blob - dvi/dvilib/dl-dvi-file.hh
New directory with the beginning of a .dvi backend.
[evince.git] / dvi / dvilib / dl-dvi-file.hh
1 #ifndef DL_DVI_FILE_HH
2 #define DL_DVI_FILE_HH
3
4 #include "dl-dvi-program.hh"
5 #include <map>
6 #include <list>
7 #include <algorithm>
8 #include "dl-dvi-fontdefinition.hh"
9 #include "dl-loader.hh"
10
11 namespace DviLib {
12     const uint N_PAGE_COUNTERS = 10;          // \count0 ... \count9
13     
14     class DviPageHeader : public RefCounted {
15     public:
16         int count[N_PAGE_COUNTERS];
17         uint address;          // address of this page, not the preceding
18     };
19     
20     class DviPage : public AbstractDviProgram { 
21         DviProgram& program;
22         int count[N_PAGE_COUNTERS];        // \count0 ... \count9
23     public:
24         DviPage (DviProgram& p, int c[N_PAGE_COUNTERS]) :
25             program (p)
26         {
27             for (uint i=0; i<N_PAGE_COUNTERS; ++i)
28                 count[i] = c[i];
29         }
30         DviPage (DviPageHeader& h, DviProgram& p) :
31             program (p)
32         {
33             for (uint i=0; i<N_PAGE_COUNTERS; ++i)
34                 count[i] = h.count[i];
35         }
36         virtual void execute (DviRuntime& runtime)
37         {
38             program.execute (runtime);
39         }
40         int get_page_count (int i) { return count[i]; }
41     };
42     
43     enum DviType {
44         NORMAL_DVI  = 2, // FIXME: this should be 2
45         TEX_XET_DVI = 2  // FIXME: is this correct?
46     };
47     
48     class DviFilePreamble : public RefCounted {
49     public:
50         // preamble
51         DviType type;
52         uint magnification;
53         uint numerator;
54         uint denominator;
55         string comment;
56     };
57     
58     class DviFilePostamble : public RefCounted {
59     public:
60         // postamble
61         DviType type;
62         uint magnification;
63         uint numerator;
64         uint denominator;
65         
66         uint last_page_address;
67         uint max_height;
68         uint max_width;
69         uint stack_height;
70         map <uint, DviFontdefinition *> fontdefinitions;
71     };
72     
73     class DviFile : public RefCounted {
74         AbstractLoader &loader;
75         
76         DviFilePreamble *preamble;
77         DviFilePostamble *postamble;
78         
79         uint n_pages;
80         map <uint, DviPageHeader *> page_headers;
81         map <uint, DviPage *> pages;
82         
83     public:
84         DviFile (AbstractLoader& l);
85         DviPage *get_page (uint n);     /* unref it when done */
86         ~DviFile (void) {}
87         uint get_n_pages () { return n_pages; }
88         DviFontdefinition *get_fontdefinition (uint n) 
89         {
90             return postamble->fontdefinitions[n];
91         }
92         uint get_numerator () { return postamble->numerator; }
93         uint get_denominator () { return postamble->denominator; }
94         uint get_magnification () { return postamble->magnification; }
95     };
96     
97 }    
98 #endif // DL_DVI_FILE_HH
99