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