further source code cleanup

svn path=/trunk/kdegraphics/kdvi/; revision=109834
remotes/origin/kdvi-3.0
Stefan Kebekus 25 years ago
parent b611630f4f
commit 758d8cd3cd
  1. 3
      dviwin.cpp
  2. 47
      dviwin.h
  3. 49
      dviwin_draw.cpp
  4. 3
      special.cpp
  5. 7
      xdvi.h

@ -44,7 +44,6 @@
#define MAXDIM 32767 #define MAXDIM 32767
#define DVI_BUFFER_LEN 512 #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 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}; struct WindowRec currwin = {(Window) 0, 3, 0, 0, 0, 0, MAXDIM, 0, MAXDIM, 0};
extern struct WindowRec alt; extern struct WindowRec alt;
@ -648,7 +647,7 @@ bool dviWindow::setFile( const QString & fname )
currinf.end = dvi_buffer; currinf.end = dvi_buffer;
currinf.pos = dvi_buffer; currinf.pos = dvi_buffer;
currinf._virtual = NULL; currinf._virtual = NULL;
draw_part(current_frame = &frame0, dviFile->dimconv, false); draw_part(dviFile->dimconv, false);
if (!PostScriptOutPutString->isEmpty()) if (!PostScriptOutPutString->isEmpty())
PS_interface->setPostScript(current_page, *PostScriptOutPutString); PS_interface->setPostScript(current_page, *PostScriptOutPutString);

@ -15,6 +15,7 @@
#include <qevent.h> #include <qevent.h>
#include <qwidget.h> #include <qwidget.h>
#include <qintdict.h> #include <qintdict.h>
#include <qvaluestack.h>
#include <qvector.h> #include <qvector.h>
#include <kviewpart.h> #include <kviewpart.h>
@ -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 class dviWindow : public QWidget
{ {
Q_OBJECT Q_OBJECT
@ -82,7 +98,7 @@ public:
void mousePressEvent ( QMouseEvent * e ); void mousePressEvent ( QMouseEvent * e );
void mouseMoveEvent ( QMouseEvent * e ); void mouseMoveEvent ( QMouseEvent * e );
void read_postamble(void); 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_vf_char(unsigned int cmd, unsigned int ch);
void set_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); void set_empty_char(unsigned int cmd, unsigned int ch);
@ -142,6 +158,11 @@ protected:
void paintEvent(QPaintEvent *ev); void paintEvent(QPaintEvent *ev);
private: 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<struct framedata> stack;
/** Methods and counters used for the animation to mark the target of /** Methods and counters used for the animation to mark the target of
an hyperlink. */ an hyperlink. */
int timerIdent; int timerIdent;
@ -149,15 +170,16 @@ private:
int animationCounter; int animationCounter;
int flashOffset; 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_w; // basedpi * width(in inch)
unsigned int unshrunk_page_h; // basedpi * height(in inch) unsigned int unshrunk_page_h; // basedpi * height(in inch)
infoDialog *info; infoDialog *info;
// If PostScriptOutPutFile is non-zero, then no rendering takes /** If PostScriptOutPutFile is non-zero, then no rendering takes
// place. Instead, the PostScript code which is generated by the place. Instead, the PostScript code which is generated by the
// \special-commands is written to the PostScriptString \special-commands is written to the PostScriptString */
QString *PostScriptOutPutString; QString *PostScriptOutPutString;
ghostscript_interface *PS_interface; ghostscript_interface *PS_interface;
@ -207,7 +229,6 @@ private:
#include <X11/Xlib.h> #include <X11/Xlib.h>
//#include <X11/Intrinsic.h>
struct WindowRec { struct WindowRec {
Window win; 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;
};

@ -71,16 +71,12 @@
extern char *xmalloc (unsigned, const char *); extern char *xmalloc (unsigned, const char *);
extern FILE *xfopen(const char *filename, char *type); extern FILE *xfopen(const char *filename, char *type);
struct frame frame0; /* dummy head of list */
#ifndef DVI_BUFFER_LEN #ifndef DVI_BUFFER_LEN
#define DVI_BUFFER_LEN 512 #define DVI_BUFFER_LEN 512
#endif #endif
extern QPainter foreGroundPaint; extern QPainter foreGroundPaint;
unsigned char dvi_buffer[DVI_BUFFER_LEN]; unsigned char dvi_buffer[DVI_BUFFER_LEN];
struct frame *current_frame;
#define DIR currinf.dir #define DIR currinf.dir
@ -263,7 +259,7 @@ void dviWindow::set_vf_char(unsigned int cmd, unsigned int ch)
currinf.pos = m->pos; currinf.pos = m->pos;
currinf.end = m->end; currinf.end = m->end;
currinf._virtual = currinf.fontp; currinf._virtual = currinf.fontp;
draw_part(current_frame, currinf.fontp->dimconv, true); draw_part(currinf.fontp->dimconv, true);
if (currinf.pos != currinf.end + 1) if (currinf.pos != currinf.end + 1)
tell_oops("virtual character macro does not end correctly"); tell_oops("virtual character macro does not end correctly");
currinf = oldinfo; currinf = oldinfo;
@ -336,14 +332,13 @@ void dviWindow::special(long nbytes)
#define xspell_conv(n) spell_conv0(n, current_dimconv) #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 #ifdef DEBUG_RENDER
kdDebug() << "draw_part" << endl; kdDebug() << "draw_part" << endl;
#endif #endif
unsigned char ch; unsigned char ch;
struct drawinf oldinfo;
currinf.fontp = NULL; currinf.fontp = NULL;
currinf.set_char_p = &dviWindow::set_no_char; 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: case SETRULE:
if (is_vfmacro == false) if (is_vfmacro == false)
word_boundary_encountered = true; word_boundary_encountered = true;
/* Be careful, dvicopy outputs rules with /* Be careful, dvicopy outputs rules with height =
height = 0x80000000. We don't want any 0x80000000. We don't want any SIGFPE here. */
SIGFPE here. */
a = xsfour(); a = xsfour();
b = xspell_conv(xsfour()); b = xspell_conv(xsfour());
if (a > 0 && b > 0 && PostScriptOutPutString == NULL) if (a > 0 && b > 0 && PostScriptOutPutString == NULL)
set_rule(pixel_round(xspell_conv(a)), set_rule(pixel_round(xspell_conv(a)), pixel_round(b));
pixel_round(b));
DVI_H += DIR * b; DVI_H += DIR * b;
break; break;
@ -395,35 +388,35 @@ void dviWindow::draw_part(struct frame *minframe, double current_dimconv, bool i
if (is_vfmacro == false) if (is_vfmacro == false)
word_boundary_encountered = true; word_boundary_encountered = true;
xskip((long) 11 * 4); 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; DVI_V = basedpi << 16;
PXL_V = pixel_conv(DVI_V); PXL_V = pixel_conv(DVI_V);
WW = XX = YY = ZZ = 0; WW = XX = YY = ZZ = 0;
break; break;
case EOP: 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; word_boundary_encountered = true;
if (current_frame != minframe) // Sanity check for the dvi-file: The DVI-standard asserts
tell_oops("stack not empty at EOP"); // that at the end of a page, the stack should always be
// empty.
if (!stack.isEmpty())
tell_oops("stack not empty at EOP");
}
return; return;
case PUSH: case PUSH:
if (current_frame->next == NULL) { stack.push(currinf.data);
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;
break; break;
case POP: case POP:
if (current_frame == minframe) if (stack.isEmpty())
tell_oops("more POPs than PUSHes"); tell_oops("more POPs than PUSHes");
currinf.data = current_frame->data; else
current_frame = current_frame->prev; currinf.data = stack.pop();
break; break;
case RIGHT1: case RIGHT1:
@ -565,7 +558,7 @@ void dviWindow::draw_page(void)
currinf._virtual = NULL; currinf._virtual = NULL;
HTML_href = NULL; HTML_href = NULL;
num_of_used_hyperlinks = 0; num_of_used_hyperlinks = 0;
draw_part(current_frame = &frame0, dviFile->dimconv, false); draw_part(dviFile->dimconv, false);
if (HTML_href != NULL) { if (HTML_href != NULL) {
delete HTML_href; delete HTML_href;
HTML_href = NULL; HTML_href = NULL;

@ -204,11 +204,8 @@ void dviWindow::epsf_special(QString cp)
bbox_height = rhi; bbox_height = rhi;
} }
kdDebug() << "dimconv: " << dviFile->dimconv << endl;
// @@@@
bbox_width *= 0.1 * dviFile->dimconv / shrink_factor; bbox_width *= 0.1 * dviFile->dimconv / shrink_factor;
bbox_height *= 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); QRect bbox(PXL_H - currwin.base_x, PXL_V - currwin.base_y - (int)bbox_height, (int)bbox_width, (int)bbox_height);
foreGroundPaint.save(); foreGroundPaint.save();

@ -138,9 +138,6 @@ extern struct drawinf currinf;
#define ZZ currinf.data.z #define ZZ currinf.data.z
#define ROUNDUP(x,y) (((x)+(y)-1)/(y)) #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 #define PS 1
extern QIntDict<struct font> tn_table; extern QIntDict<struct font> tn_table;
@ -158,10 +155,6 @@ extern long snum ARGS((FILE *, int));
#define pixels_per_inch _pixels_per_inch #define pixels_per_inch _pixels_per_inch
extern Display *DISP;
extern Screen *SCRN;
extern struct WindowRec mane, alt, currwin; extern struct WindowRec mane, alt, currwin;
#define shrink_factor currwin.shrinkfactor #define shrink_factor currwin.shrinkfactor

Loading…
Cancel
Save