1 // -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; c-brace-offset: 0; -*-
5 // Class that represents a DVI file. Part of KDVI - A DVI previewing
6 // plugin for kviewshell.
8 // (C) 2004-2005 Stefan Kebekus. Distributed under the GPL.
14 #include "bigEndianByteReader.h"
24 class TeXFontDefinition
;
27 class dvifile
: public bigEndianByteReader
30 /** Makes a deep copy of the old DVI file. */
31 dvifile(const dvifile
*old
, fontPool
*fp
);
32 dvifile(const QString
& fname
, class fontPool
* pool
);
38 QString generatorString
;
40 Q3MemArray
<quint32
> page_offset
;
42 /** Saves the DVI file. Returns true on success. */
43 bool saveAs(const QString
&filename
);
45 // Returns a pointer to the DVI file's data, or 0 if no data has yet
47 quint8
* dvi_Data() {return dviData
.data();}
49 QIODevice::Offset size_of_file
;
52 /** This field is set to zero when the DVI file is constructed, and
53 will be modified during the prescan phase (at this time the
54 prescan code still resides in the dviRenderer class) */
55 quint16 numberOfExternalPSFiles
;
57 /** This field is set to zero when the DVI file is constructed, and
58 will be modified during the prescan phase (at this time the
59 prescan code still resides in the dviRenderer class) */
60 quint16 numberOfExternalNONPSFiles
;
62 quint32 beginning_of_postamble
;
64 /** This flag is set to "true" during the construction of the
65 dvifile, and is never changed afterwards by the dvifile
66 class. It is used in kdvi in conjuction with source-specials:
67 the first time a page with source specials is rendered, KDVI
68 shows an info dialog, and the flag is set to false. That way
69 KDVI ensures that the user is only informed once. */
70 bool sourceSpecialMarker
;
72 Q3IntDict
<TeXFontDefinition
> tn_table
;
74 /** Returns the number of centimeters per DVI unit in this DVI
76 double getCmPerDVIunit() const {return cmPerDVIunit
;}
78 /** Returns the magnification of the DVI file, as described in the
80 quint32
getMagnification() const {return _magnification
;}
82 /** This member is set to zero on construction and can be used by
83 other software to count error messages that were printed when
84 the DVI-file was processed. Suggested application: limit the
85 number of error messages to, say, 25. */
88 /** Papersize information read from the dvi-File */
89 pageSize
*suggestedPageSize
;
91 /** Sets new DVI data; all old data is erased. EXPERIMENTAL, use
93 void setNewData(const Q3MemArray
<quint8
>& newData
) {dviData
= newData
;}
95 /** Page numbers that appear in a DVI document need not be
96 ordered. Worse, page numbers need not be unique. This method
97 renumbers the pages. */
100 /** PDF to PS file conversion
102 This utility method takes the name of a PDF-file, and attempts to
103 convert it to a PS file. The dvifile internally keeps a list of
104 converted files, to do two thigs:
106 - convert files only once.
108 - delete all converted files on destruction
110 @warning The internal buffer can lead to difficulties if filenames
111 of PDF-files are not unique: if the content of a PDF file is
112 changed and this method is called a second time with the same file
113 name, the method will then NOT convert the file, but simply return
114 the name from the buffer
116 @returns The name of the PS file, or QString() on failure.
118 QString
convertPDFtoPS(const QString
&PDFFilename
, QString
*converrorms
=0);
121 /** process_preamble reads the information in the preamble and
122 stores it into global variables for later use. */
123 void process_preamble();
124 void find_postamble();
125 /** read_postamble reads the information in the postamble, storing
126 it into global variables. It also takes care of reading in all
127 of the pixel files for the fonts used in the job. */
128 void read_postamble();
129 void prepare_pages();
132 /** Offset in DVI file of last page, set in read_postamble(). */
133 quint32 last_page_offset
;
134 quint32 _magnification
;
138 Q3MemArray
<quint8
> dviData
;
140 /** Map of filenames for converted PDF files
142 This map contains names of PDF files that were converted to
143 PostScript. The key is the name of the PDF file, the data the name
144 of the associated PS file, or QString(), if the file could not
145 be converted. The PS files are deleted when the DVI-file is
147 QMap
<QString
, QString
> convertedFiles
;
149 /** Flag, used so that KDVI complains only once about a missing
150 "PDF2PS" utility. Set to "false" in the constructor. */
151 bool have_complainedAboutMissingPDF2PS
;
154 #endif //ifndef _DVIFILE_H