diff --git a/dviwin.cpp b/dviwin.cpp index a54a45a3a..851d9932c 100644 --- a/dviwin.cpp +++ b/dviwin.cpp @@ -44,7 +44,6 @@ #define MAXDIM 32767 #define DVI_BUFFER_LEN 512 -extern struct frame *current_frame; struct WindowRec mane = {(Window) 0, 3, 0, 0, 0, 0, MAXDIM, 0, MAXDIM, 0}; struct WindowRec currwin = {(Window) 0, 3, 0, 0, 0, 0, MAXDIM, 0, MAXDIM, 0}; extern struct WindowRec alt; @@ -648,7 +647,7 @@ bool dviWindow::setFile( const QString & fname ) currinf.end = dvi_buffer; currinf.pos = dvi_buffer; currinf._virtual = NULL; - draw_part(current_frame = &frame0, dviFile->dimconv, false); + draw_part(dviFile->dimconv, false); if (!PostScriptOutPutString->isEmpty()) PS_interface->setPostScript(current_page, *PostScriptOutPutString); diff --git a/dviwin.h b/dviwin.h index d31fb7c19..a90df1ef1 100644 --- a/dviwin.h +++ b/dviwin.h @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -45,6 +46,21 @@ class DVI_Hyperlink { }; +/** Compound of registers, as defines in section 2.6.2 of the DVI + driver standard, Level 0, published by the TUG DVI driver + standards committee. */ + +struct framedata { + long dvi_h; + long dvi_v; + long w; + long x; + long y; + long z; + int pxl_v; +}; + + class dviWindow : public QWidget { Q_OBJECT @@ -82,7 +98,7 @@ public: void mousePressEvent ( QMouseEvent * e ); void mouseMoveEvent ( QMouseEvent * e ); void read_postamble(void); - void draw_part(struct frame *minframe, double current_dimconv, bool is_vfmacro); + void draw_part(double current_dimconv, bool is_vfmacro); void set_vf_char(unsigned int cmd, unsigned int ch); void set_char(unsigned int cmd, unsigned int ch); void set_empty_char(unsigned int cmd, unsigned int ch); @@ -142,6 +158,11 @@ protected: void paintEvent(QPaintEvent *ev); private: + /** Stack for register compounds, used for the DVI-commands PUSH/POP + as explained in section 2.5 and 2.6.2 of the DVI driver standard, + Level 0, published by the TUG DVI driver standards committee. */ + QValueStack stack; + /** Methods and counters used for the animation to mark the target of an hyperlink. */ int timerIdent; @@ -149,16 +170,17 @@ private: int animationCounter; int flashOffset; - // These fields contain information about the geometry of the page. + /** These fields contain information about the geometry of the + page. */ unsigned int unshrunk_page_w; // basedpi * width(in inch) unsigned int unshrunk_page_h; // basedpi * height(in inch) infoDialog *info; - // If PostScriptOutPutFile is non-zero, then no rendering takes - // place. Instead, the PostScript code which is generated by the - // \special-commands is written to the PostScriptString - QString *PostScriptOutPutString; + /** If PostScriptOutPutFile is non-zero, then no rendering takes + place. Instead, the PostScript code which is generated by the + \special-commands is written to the PostScriptString */ + QString *PostScriptOutPutString; ghostscript_interface *PS_interface; @@ -207,7 +229,6 @@ private: #include -//#include struct WindowRec { Window win; @@ -223,21 +244,7 @@ struct WindowRec { }; -struct framedata { - long dvi_h; - long dvi_v; - long w; - long x; - long y; - long z; - int pxl_v; -}; - -struct frame { - struct framedata data; - struct frame *next, *prev; -}; diff --git a/dviwin_draw.cpp b/dviwin_draw.cpp index f2c7f0348..a456ed954 100644 --- a/dviwin_draw.cpp +++ b/dviwin_draw.cpp @@ -71,16 +71,12 @@ extern char *xmalloc (unsigned, const char *); extern FILE *xfopen(const char *filename, char *type); -struct frame frame0; /* dummy head of list */ - - #ifndef DVI_BUFFER_LEN #define DVI_BUFFER_LEN 512 #endif extern QPainter foreGroundPaint; unsigned char dvi_buffer[DVI_BUFFER_LEN]; -struct frame *current_frame; #define DIR currinf.dir @@ -263,7 +259,7 @@ void dviWindow::set_vf_char(unsigned int cmd, unsigned int ch) currinf.pos = m->pos; currinf.end = m->end; currinf._virtual = currinf.fontp; - draw_part(current_frame, currinf.fontp->dimconv, true); + draw_part(currinf.fontp->dimconv, true); if (currinf.pos != currinf.end + 1) tell_oops("virtual character macro does not end correctly"); currinf = oldinfo; @@ -336,14 +332,13 @@ void dviWindow::special(long nbytes) #define xspell_conv(n) spell_conv0(n, current_dimconv) -void dviWindow::draw_part(struct frame *minframe, double current_dimconv, bool is_vfmacro) +void dviWindow::draw_part(double current_dimconv, bool is_vfmacro) { #ifdef DEBUG_RENDER kdDebug() << "draw_part" << endl; #endif unsigned char ch; - struct drawinf oldinfo; currinf.fontp = NULL; currinf.set_char_p = &dviWindow::set_no_char; @@ -368,14 +363,12 @@ void dviWindow::draw_part(struct frame *minframe, double current_dimconv, bool i case SETRULE: if (is_vfmacro == false) word_boundary_encountered = true; - /* Be careful, dvicopy outputs rules with - height = 0x80000000. We don't want any - SIGFPE here. */ + /* Be careful, dvicopy outputs rules with height = + 0x80000000. We don't want any SIGFPE here. */ a = xsfour(); b = xspell_conv(xsfour()); if (a > 0 && b > 0 && PostScriptOutPutString == NULL) - set_rule(pixel_round(xspell_conv(a)), - pixel_round(b)); + set_rule(pixel_round(xspell_conv(a)), pixel_round(b)); DVI_H += DIR * b; break; @@ -395,35 +388,35 @@ void dviWindow::draw_part(struct frame *minframe, double current_dimconv, bool i if (is_vfmacro == false) word_boundary_encountered = true; xskip((long) 11 * 4); - DVI_H = basedpi << 16; // Reminder: DVI-coords. start at (1",1") from top of page + DVI_H = basedpi << 16; // Reminder: DVI-coordinates start at (1",1") from top of page DVI_V = basedpi << 16; PXL_V = pixel_conv(DVI_V); WW = XX = YY = ZZ = 0; break; case EOP: - if (is_vfmacro == false) + // Check if we are just at the end of a virtual font macro. + if (is_vfmacro == false) { + // This is really the end of a page, and not just the end + // of a macro. Mark the end of the current word. word_boundary_encountered = true; - if (current_frame != minframe) - tell_oops("stack not empty at EOP"); + // Sanity check for the dvi-file: The DVI-standard asserts + // that at the end of a page, the stack should always be + // empty. + if (!stack.isEmpty()) + tell_oops("stack not empty at EOP"); + } return; case PUSH: - if (current_frame->next == NULL) { - struct frame *newp = (struct frame *)xmalloc(sizeof(struct frame), "stack frame"); - current_frame->next = newp; - newp->prev = current_frame; - newp->next = NULL; - } - current_frame = current_frame->next; - current_frame->data = currinf.data; + stack.push(currinf.data); break; case POP: - if (current_frame == minframe) + if (stack.isEmpty()) tell_oops("more POPs than PUSHes"); - currinf.data = current_frame->data; - current_frame = current_frame->prev; + else + currinf.data = stack.pop(); break; case RIGHT1: @@ -565,7 +558,7 @@ void dviWindow::draw_page(void) currinf._virtual = NULL; HTML_href = NULL; num_of_used_hyperlinks = 0; - draw_part(current_frame = &frame0, dviFile->dimconv, false); + draw_part(dviFile->dimconv, false); if (HTML_href != NULL) { delete HTML_href; HTML_href = NULL; diff --git a/special.cpp b/special.cpp index e11690902..14ad1bbf5 100644 --- a/special.cpp +++ b/special.cpp @@ -204,11 +204,8 @@ void dviWindow::epsf_special(QString cp) bbox_height = rhi; } - kdDebug() << "dimconv: " << dviFile->dimconv << endl; - // @@@@ bbox_width *= 0.1 * dviFile->dimconv / shrink_factor; bbox_height *= 0.1 * dviFile->dimconv / shrink_factor; - kdDebug() << "bbox_width: " << (int)bbox_width << endl; QRect bbox(PXL_H - currwin.base_x, PXL_V - currwin.base_y - (int)bbox_height, (int)bbox_width, (int)bbox_height); foreGroundPaint.save(); diff --git a/vf.cpp b/vf.cpp index 360c5af46..7bab22eef 100644 --- a/vf.cpp +++ b/vf.cpp @@ -109,7 +109,7 @@ void font::read_VF_index(void) // (pixels_per_inch * 2**16) / (72.27 * 2**20). struct font *newfontp = font_pool->appendx(fontname, checksum, scale, design, (72.27 * (1<<4)) * dimconv * scale / design, dimconv); - + // Insert font in dictionary and make sure the dictionary is big // enough. if (vf_table.size()-2 <= vf_table.count()) diff --git a/xdvi.h b/xdvi.h index 7a4f59bf7..6cd02c580 100644 --- a/xdvi.h +++ b/xdvi.h @@ -138,9 +138,6 @@ extern struct drawinf currinf; #define ZZ currinf.data.z #define ROUNDUP(x,y) (((x)+(y)-1)/(y)) -//extern int total_pages; -extern int n_files_left; /* for LRU closing of fonts */ - #define PS 1 extern QIntDict tn_table; @@ -158,10 +155,6 @@ extern long snum ARGS((FILE *, int)); #define pixels_per_inch _pixels_per_inch - - -extern Display *DISP; -extern Screen *SCRN; extern struct WindowRec mane, alt, currwin; #define shrink_factor currwin.shrinkfactor