2000-02-29 11:27:53 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1994 Paul Vojta. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* NOTE:
|
|
|
|
* xdvi is based on prior work as noted in the modification history, below.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* DVI previewer for X.
|
|
|
|
*
|
|
|
|
* Eric Cooper, CMU, September 1985.
|
|
|
|
*
|
|
|
|
* Code derived from dvi-imagen.c.
|
|
|
|
*
|
|
|
|
* Modification history:
|
|
|
|
* 1/1986 Modified for X.10 --Bob Scheifler, MIT LCS.
|
|
|
|
* 7/1988 Modified for X.11 --Mark Eichin, MIT
|
|
|
|
* 12/1988 Added 'R' option, toolkit, magnifying glass
|
|
|
|
* --Paul Vojta, UC Berkeley.
|
|
|
|
* 2/1989 Added tpic support --Jeffrey Lee, U of Toronto
|
|
|
|
* 4/1989 Modified for System V --Donald Richardson, Clarkson Univ.
|
|
|
|
* 3/1990 Added VMS support --Scott Allendorf, U of Iowa
|
|
|
|
* 7/1990 Added reflection mode --Michael Pak, Hebrew U of Jerusalem
|
|
|
|
* 1/1992 Added greyscale code --Till Brychcy, Techn. Univ. Muenchen
|
|
|
|
* and Lee Hetherington, MIT
|
|
|
|
* 4/1994 Added DPS support, bounding box
|
|
|
|
* --Ricardo Telichevesky
|
|
|
|
* and Luis Miguel Silveira, MIT RLE.
|
|
|
|
*/
|
|
|
|
|
2001-10-18 16:40:34 +00:00
|
|
|
//#define DEBUG_RENDER 0
|
2000-02-29 11:27:53 +00:00
|
|
|
|
2000-06-07 01:41:55 +00:00
|
|
|
#include "dviwin.h"
|
2000-02-29 11:27:53 +00:00
|
|
|
#include "dvi.h"
|
2000-11-25 15:31:29 +00:00
|
|
|
#include "fontpool.h"
|
2003-04-06 17:32:11 +00:00
|
|
|
#include "performanceMeasurement.h"
|
2003-03-07 11:54:35 +00:00
|
|
|
#include "TeXFont.h"
|
2003-02-05 08:17:23 +00:00
|
|
|
#include "xdvi.h"
|
2000-02-29 11:27:53 +00:00
|
|
|
|
2000-05-26 00:00:15 +00:00
|
|
|
#include <kdebug.h>
|
2001-09-03 08:57:03 +00:00
|
|
|
#include <klocale.h>
|
|
|
|
#include <kmessagebox.h>
|
2000-06-07 01:41:55 +00:00
|
|
|
#include <kprocess.h>
|
2000-02-29 11:27:53 +00:00
|
|
|
#include <qpainter.h>
|
|
|
|
#include <qbitmap.h>
|
|
|
|
#include <qimage.h>
|
|
|
|
#include <qpaintdevice.h>
|
|
|
|
#include <qfileinfo.h>
|
|
|
|
|
2000-06-07 01:41:55 +00:00
|
|
|
extern QPainter foreGroundPaint;
|
2000-02-29 11:27:53 +00:00
|
|
|
|
|
|
|
|
2000-05-27 05:05:03 +00:00
|
|
|
/** Routine to print characters. */
|
2000-02-29 11:27:53 +00:00
|
|
|
|
2000-06-09 05:31:11 +00:00
|
|
|
void dviWindow::set_char(unsigned int cmd, unsigned int ch)
|
2000-02-29 11:27:53 +00:00
|
|
|
{
|
2000-06-09 05:31:11 +00:00
|
|
|
#ifdef DEBUG_RENDER
|
2003-03-07 11:54:35 +00:00
|
|
|
kdDebug(4300) << "set_char #" << ch << endl;
|
2000-06-09 05:31:11 +00:00
|
|
|
#endif
|
2000-05-26 00:00:15 +00:00
|
|
|
|
2003-04-01 11:09:15 +00:00
|
|
|
glyph *g;
|
|
|
|
if (colorStack.isEmpty())
|
|
|
|
g = ((TeXFont *)(currinf.fontp->font))->getGlyph(ch, true, globalColor);
|
|
|
|
else
|
|
|
|
g = ((TeXFont *)(currinf.fontp->font))->getGlyph(ch, true, colorStack.top());
|
2000-05-27 05:05:03 +00:00
|
|
|
if (g == NULL)
|
|
|
|
return;
|
2000-02-29 11:27:53 +00:00
|
|
|
|
2003-02-19 12:54:27 +00:00
|
|
|
long dvi_h_sav = currinf.data.dvi_h;
|
2000-06-09 05:31:11 +00:00
|
|
|
if (PostScriptOutPutString == NULL) {
|
2003-03-07 11:54:35 +00:00
|
|
|
QPixmap pix = g->shrunkenCharacter;
|
|
|
|
int x = ((int) ((currinf.data.dvi_h) / (shrinkfactor * 65536))) - g->x2;
|
|
|
|
int y = currinf.data.pxl_v - g->y2;
|
2000-06-09 05:31:11 +00:00
|
|
|
|
|
|
|
// Draw the character.
|
2001-12-18 10:32:09 +00:00
|
|
|
foreGroundPaint.drawPixmap(x, y, pix);
|
2001-12-14 16:50:02 +00:00
|
|
|
|
2001-07-06 10:14:01 +00:00
|
|
|
// Are we drawing text for a hyperlink? And are hyperlinks
|
|
|
|
// enabled?
|
2000-06-14 04:15:22 +00:00
|
|
|
if (HTML_href != NULL && _showHyperLinks != 0) {
|
2001-07-06 10:14:01 +00:00
|
|
|
// Now set up a rectangle which is checked against every mouse
|
|
|
|
// event.
|
2001-10-27 11:38:16 +00:00
|
|
|
if (line_boundary_encountered == true) {
|
2001-08-20 16:13:34 +00:00
|
|
|
// Set up hyperlink
|
2002-12-23 12:32:25 +00:00
|
|
|
DVI_Hyperlink dhl;
|
2003-02-19 12:54:27 +00:00
|
|
|
dhl.baseline = currinf.data.pxl_v;
|
2002-12-23 12:32:25 +00:00
|
|
|
dhl.box.setRect(x, y, pix.width(), pix.height());
|
|
|
|
dhl.linkText = *HTML_href;
|
|
|
|
hyperLinkList.push_back(dhl);
|
2001-07-06 10:14:01 +00:00
|
|
|
} else {
|
2002-12-23 12:32:25 +00:00
|
|
|
QRect dshunion = hyperLinkList[hyperLinkList.size()-1].box.unite(QRect(x, y, pix.width(), pix.height())) ;
|
|
|
|
hyperLinkList[hyperLinkList.size()-1].box = dshunion;
|
2001-07-06 10:14:01 +00:00
|
|
|
}
|
2000-06-09 05:31:11 +00:00
|
|
|
}
|
2001-08-20 16:13:34 +00:00
|
|
|
|
|
|
|
// Are we drawing text for a source hyperlink? And are source
|
2001-10-18 16:40:34 +00:00
|
|
|
// hyperlinks enabled?
|
2001-10-27 11:38:16 +00:00
|
|
|
if (source_href != 0) {
|
2001-08-20 16:13:34 +00:00
|
|
|
// Now set up a rectangle which is checked against every mouse
|
|
|
|
// event.
|
2001-10-27 11:38:16 +00:00
|
|
|
if (line_boundary_encountered == true) {
|
2001-08-20 16:13:34 +00:00
|
|
|
// Set up source hyperlinks
|
2002-12-23 12:32:25 +00:00
|
|
|
DVI_Hyperlink dhl;
|
2003-02-19 12:54:27 +00:00
|
|
|
dhl.baseline = currinf.data.pxl_v;
|
2002-12-23 12:32:25 +00:00
|
|
|
dhl.box.setRect(x, y, pix.width(), pix.height());
|
2001-10-27 11:38:16 +00:00
|
|
|
if (source_href != NULL)
|
2002-12-23 12:32:25 +00:00
|
|
|
dhl.linkText = *source_href;
|
2001-08-20 16:13:34 +00:00
|
|
|
else
|
2002-12-23 12:32:25 +00:00
|
|
|
dhl.linkText = "";
|
|
|
|
sourceHyperLinkList.push_back(dhl);
|
2001-08-20 16:13:34 +00:00
|
|
|
} else {
|
2002-12-23 12:32:25 +00:00
|
|
|
QRect dshunion = sourceHyperLinkList[sourceHyperLinkList.size()-1].box.unite(QRect(x, y, pix.width(), pix.height())) ;
|
|
|
|
sourceHyperLinkList[sourceHyperLinkList.size()-1].box = dshunion;
|
2001-08-20 16:13:34 +00:00
|
|
|
}
|
|
|
|
}
|
2001-10-27 11:38:16 +00:00
|
|
|
|
2002-01-02 13:38:46 +00:00
|
|
|
// Code for DVI -> text functions (e.g. marking of text, full text
|
|
|
|
// search, etc.). Set up the textLinkList.
|
2001-10-27 11:38:16 +00:00
|
|
|
if (line_boundary_encountered == true) {
|
|
|
|
// Set up source hyperlinks
|
2002-08-07 08:15:17 +00:00
|
|
|
DVI_Hyperlink link;
|
2003-02-19 12:54:27 +00:00
|
|
|
link.baseline = currinf.data.pxl_v;
|
2002-08-07 08:15:17 +00:00
|
|
|
link.box.setRect(x, y, pix.width(), pix.height());
|
|
|
|
link.linkText = "";
|
|
|
|
|
|
|
|
textLinkList.push_back(link);
|
2001-10-27 11:38:16 +00:00
|
|
|
} else { // line boundary encountered
|
2002-08-07 08:15:17 +00:00
|
|
|
QRect dshunion = textLinkList[textLinkList.size()-1].box.unite(QRect(x, y, pix.width(), pix.height())) ;
|
|
|
|
textLinkList[textLinkList.size()-1].box = dshunion;
|
2001-10-27 11:38:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
switch(ch) {
|
|
|
|
case 0x0b:
|
2002-08-07 08:15:17 +00:00
|
|
|
textLinkList[textLinkList.size()-1].linkText += "ff";
|
2001-10-27 11:38:16 +00:00
|
|
|
break;
|
|
|
|
case 0x0c:
|
2002-08-07 08:15:17 +00:00
|
|
|
textLinkList[textLinkList.size()-1].linkText += "fi";
|
2001-10-27 11:38:16 +00:00
|
|
|
break;
|
|
|
|
case 0x0d:
|
2002-08-07 08:15:17 +00:00
|
|
|
textLinkList[textLinkList.size()-1].linkText += "fl";
|
2001-10-27 11:38:16 +00:00
|
|
|
break;
|
|
|
|
case 0x0e:
|
2002-08-07 08:15:17 +00:00
|
|
|
textLinkList[textLinkList.size()-1].linkText += "ffi";
|
2001-10-27 11:38:16 +00:00
|
|
|
break;
|
|
|
|
case 0x0f:
|
2002-08-07 08:15:17 +00:00
|
|
|
textLinkList[textLinkList.size()-1].linkText += "ffl";
|
2001-10-27 11:38:16 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x7b:
|
2002-08-07 08:15:17 +00:00
|
|
|
textLinkList[textLinkList.size()-1].linkText += "-";
|
2001-10-27 11:38:16 +00:00
|
|
|
break;
|
|
|
|
case 0x7c:
|
2002-08-07 08:15:17 +00:00
|
|
|
textLinkList[textLinkList.size()-1].linkText += "---";
|
2001-10-27 11:38:16 +00:00
|
|
|
break;
|
|
|
|
case 0x7d:
|
2002-08-07 08:15:17 +00:00
|
|
|
textLinkList[textLinkList.size()-1].linkText += "\"";
|
2001-10-27 11:38:16 +00:00
|
|
|
break;
|
|
|
|
case 0x7e:
|
2002-08-07 08:15:17 +00:00
|
|
|
textLinkList[textLinkList.size()-1].linkText += "~";
|
2001-10-27 11:38:16 +00:00
|
|
|
break;
|
|
|
|
case 0x7f:
|
2002-08-07 08:15:17 +00:00
|
|
|
textLinkList[textLinkList.size()-1].linkText += "@@"; // @@@ check!
|
2001-10-27 11:38:16 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
if ((ch >= 0x21) && (ch <= 0x7a))
|
2002-08-07 08:15:17 +00:00
|
|
|
textLinkList[textLinkList.size()-1].linkText += QChar(ch);
|
2001-10-27 11:38:16 +00:00
|
|
|
else
|
2002-08-07 08:15:17 +00:00
|
|
|
textLinkList[textLinkList.size()-1].linkText += "?";
|
2001-10-27 11:38:16 +00:00
|
|
|
break;
|
|
|
|
}
|
2000-06-09 05:31:11 +00:00
|
|
|
}
|
2001-12-14 16:50:02 +00:00
|
|
|
|
2000-02-29 11:27:53 +00:00
|
|
|
if (cmd == PUT1)
|
2003-02-19 12:54:27 +00:00
|
|
|
currinf.data.dvi_h = dvi_h_sav;
|
2000-02-29 11:27:53 +00:00
|
|
|
else
|
2003-03-14 17:09:06 +00:00
|
|
|
currinf.data.dvi_h += (int)(currinf.fontp->scaled_size_in_DVI_units * dviFile->cmPerDVIunit * (MFResolutions[font_pool->getMetafontMode()] / 2.54)/16.0 * g->dvi_advance_in_units_of_design_size_by_2e20 + 0.5);
|
2001-07-06 10:14:01 +00:00
|
|
|
|
|
|
|
word_boundary_encountered = false;
|
2001-10-27 11:38:16 +00:00
|
|
|
line_boundary_encountered = false;
|
2000-02-29 11:27:53 +00:00
|
|
|
}
|
|
|
|
|
2001-07-06 10:14:01 +00:00
|
|
|
void dviWindow::set_empty_char(unsigned int, unsigned int)
|
2000-02-29 11:27:53 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2000-06-09 05:31:11 +00:00
|
|
|
void dviWindow::set_vf_char(unsigned int cmd, unsigned int ch)
|
2000-02-29 11:27:53 +00:00
|
|
|
{
|
2000-06-09 05:31:11 +00:00
|
|
|
#ifdef DEBUG_RENDER
|
2000-06-05 10:49:44 +00:00
|
|
|
kdDebug() << "set_vf_char" << endl;
|
2000-06-09 05:31:11 +00:00
|
|
|
#endif
|
2000-02-29 11:27:53 +00:00
|
|
|
|
2000-05-26 00:00:15 +00:00
|
|
|
static unsigned char c;
|
2001-10-18 16:40:34 +00:00
|
|
|
macro *m = &currinf.fontp->macrotable[ch];
|
|
|
|
if (m->pos == NULL) {
|
2000-06-07 01:41:55 +00:00
|
|
|
kdError() << "Character " << ch << " not defined in font" << currinf.fontp->fontname << endl;
|
2000-02-29 11:27:53 +00:00
|
|
|
m->pos = m->end = &c;
|
2000-05-27 05:05:03 +00:00
|
|
|
return;
|
2000-02-29 11:27:53 +00:00
|
|
|
}
|
|
|
|
|
2003-02-19 12:54:27 +00:00
|
|
|
long dvi_h_sav = currinf.data.dvi_h;
|
2000-06-09 05:31:11 +00:00
|
|
|
if (PostScriptOutPutString == NULL) {
|
2001-10-18 16:40:34 +00:00
|
|
|
struct drawinf oldinfo = currinf;
|
2003-02-19 12:54:27 +00:00
|
|
|
currinf.data.w = 0;
|
|
|
|
currinf.data.x = 0;
|
|
|
|
currinf.data.y = 0;
|
|
|
|
currinf.data.z = 0;
|
2000-05-26 00:00:15 +00:00
|
|
|
|
2003-04-27 15:58:38 +00:00
|
|
|
currinf.fonttable = &(currinf.fontp->vf_table);
|
2001-10-18 16:40:34 +00:00
|
|
|
currinf._virtual = currinf.fontp;
|
|
|
|
Q_UINT8 *command_ptr_sav = command_pointer;
|
|
|
|
Q_UINT8 *end_ptr_sav = end_pointer;
|
|
|
|
command_pointer = m->pos;
|
|
|
|
end_pointer = m->end;
|
2003-02-28 08:27:07 +00:00
|
|
|
draw_part(currinf.fontp->scaled_size_in_DVI_units*(dviFile->cmPerDVIunit * MFResolutions[font_pool->getMetafontMode()] / 2.54)/16.0, true);
|
2001-10-18 16:40:34 +00:00
|
|
|
command_pointer = command_ptr_sav;
|
|
|
|
end_pointer = end_ptr_sav;
|
2000-02-29 11:27:53 +00:00
|
|
|
currinf = oldinfo;
|
|
|
|
}
|
|
|
|
if (cmd == PUT1)
|
2003-02-19 12:54:27 +00:00
|
|
|
currinf.data.dvi_h = dvi_h_sav;
|
2000-02-29 11:27:53 +00:00
|
|
|
else
|
2003-03-14 17:09:06 +00:00
|
|
|
currinf.data.dvi_h += (int)(currinf.fontp->scaled_size_in_DVI_units * dviFile->cmPerDVIunit * (MFResolutions[font_pool->getMetafontMode()] / 2.54)/16.0 * m->dvi_advance_in_units_of_design_size_by_2e20 + 0.5);
|
2000-02-29 11:27:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-06-09 05:31:11 +00:00
|
|
|
void dviWindow::set_no_char(unsigned int cmd, unsigned int ch)
|
2000-02-29 11:27:53 +00:00
|
|
|
{
|
2000-06-09 05:31:11 +00:00
|
|
|
#ifdef DEBUG_RENDER
|
2001-10-18 16:40:34 +00:00
|
|
|
kdDebug() << "set_no_char: #" << ch <<endl;
|
2000-06-09 05:31:11 +00:00
|
|
|
#endif
|
2000-05-26 00:00:15 +00:00
|
|
|
|
2000-02-29 11:27:53 +00:00
|
|
|
if (currinf._virtual) {
|
|
|
|
currinf.fontp = currinf._virtual->first_font;
|
|
|
|
if (currinf.fontp != NULL) {
|
|
|
|
currinf.set_char_p = currinf.fontp->set_char_p;
|
2000-06-09 05:31:11 +00:00
|
|
|
(this->*currinf.set_char_p)(cmd, ch);
|
2000-02-29 11:27:53 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2001-11-01 09:53:31 +00:00
|
|
|
|
|
|
|
errorMsg = i18n("The DVI code set a character of unknown font");
|
|
|
|
return;
|
2000-02-29 11:27:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-08-09 07:35:46 +00:00
|
|
|
void dviWindow::draw_part(double current_dimconv, bool is_vfmacro)
|
2000-02-29 11:27:53 +00:00
|
|
|
{
|
2000-06-09 05:31:11 +00:00
|
|
|
#ifdef DEBUG_RENDER
|
2003-02-19 12:54:27 +00:00
|
|
|
kdDebug(4300) << "draw_part" << endl;
|
2000-06-09 05:31:11 +00:00
|
|
|
#endif
|
2000-02-29 11:27:53 +00:00
|
|
|
|
2003-02-13 04:59:49 +00:00
|
|
|
Q_INT32 RRtmp=0, WWtmp=0, XXtmp=0, YYtmp=0, ZZtmp=0;
|
2001-10-12 01:32:07 +00:00
|
|
|
Q_UINT8 ch;
|
2000-02-29 11:27:53 +00:00
|
|
|
|
2000-06-07 01:41:55 +00:00
|
|
|
currinf.fontp = NULL;
|
2000-06-09 05:31:11 +00:00
|
|
|
currinf.set_char_p = &dviWindow::set_no_char;
|
2000-02-29 11:27:53 +00:00
|
|
|
|
|
|
|
for (;;) {
|
2001-10-18 16:40:34 +00:00
|
|
|
ch = readUINT8();
|
|
|
|
if (ch <= (unsigned char) (SETCHAR0 + 127)) {
|
2000-06-09 05:31:11 +00:00
|
|
|
(this->*currinf.set_char_p)(ch, ch);
|
2001-10-18 16:40:34 +00:00
|
|
|
} else
|
2001-11-01 09:53:31 +00:00
|
|
|
if (FNTNUM0 <= ch && ch <= (unsigned char) (FNTNUM0 + 63)) {
|
2003-04-27 15:58:38 +00:00
|
|
|
currinf.fontp = currinf.fonttable->find(ch - FNTNUM0);
|
2001-11-01 09:53:31 +00:00
|
|
|
if (currinf.fontp == NULL) {
|
|
|
|
errorMsg = i18n("The DVI code referred to font #%1, which was not previously defined.").arg(ch - FNTNUM0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
currinf.set_char_p = currinf.fontp->set_char_p;
|
|
|
|
} else {
|
2001-10-12 01:32:07 +00:00
|
|
|
Q_INT32 a, b;
|
2000-02-29 11:27:53 +00:00
|
|
|
|
|
|
|
switch (ch) {
|
|
|
|
case SET1:
|
|
|
|
case PUT1:
|
2001-10-18 16:40:34 +00:00
|
|
|
(this->*currinf.set_char_p)(ch, readUINT8());
|
2000-02-29 11:27:53 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SETRULE:
|
2001-10-27 11:38:16 +00:00
|
|
|
if (is_vfmacro == false) {
|
2001-07-06 10:14:01 +00:00
|
|
|
word_boundary_encountered = true;
|
2001-10-27 11:38:16 +00:00
|
|
|
line_boundary_encountered = true;
|
|
|
|
}
|
2001-08-09 07:35:46 +00:00
|
|
|
/* Be careful, dvicopy outputs rules with height =
|
|
|
|
0x80000000. We don't want any SIGFPE here. */
|
2001-10-18 16:40:34 +00:00
|
|
|
a = readUINT32();
|
|
|
|
b = readUINT32();
|
2003-02-19 12:54:27 +00:00
|
|
|
b = ((long) (b * current_dimconv));
|
|
|
|
if (a > 0 && b > 0 && PostScriptOutPutString == NULL) {
|
2003-03-07 11:54:35 +00:00
|
|
|
int h = ((int) ROUNDUP(((long) (a * current_dimconv)), shrinkfactor * 65536));
|
|
|
|
int w = ((int) ROUNDUP(b, shrinkfactor * 65536));
|
|
|
|
foreGroundPaint.fillRect( ((int) ((currinf.data.dvi_h) / (shrinkfactor * 65536))),
|
|
|
|
currinf.data.pxl_v - h + 1, w?w:1, h?h:1, Qt::black );
|
2003-02-19 12:54:27 +00:00
|
|
|
}
|
|
|
|
currinf.data.dvi_h += b;
|
2000-02-29 11:27:53 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PUTRULE:
|
2001-10-27 11:38:16 +00:00
|
|
|
if (is_vfmacro == false) {
|
2001-07-06 10:14:01 +00:00
|
|
|
word_boundary_encountered = true;
|
2001-10-27 11:38:16 +00:00
|
|
|
line_boundary_encountered = true;
|
|
|
|
}
|
2001-10-18 16:40:34 +00:00
|
|
|
a = readUINT32();
|
|
|
|
b = readUINT32();
|
2003-02-19 12:54:27 +00:00
|
|
|
a = ((long) (a * current_dimconv));
|
|
|
|
b = ((long) (b * current_dimconv));
|
|
|
|
if (a > 0 && b > 0 && PostScriptOutPutString == NULL) {
|
2003-03-07 11:54:35 +00:00
|
|
|
int h = ((int) ROUNDUP(a, shrinkfactor * 65536));
|
|
|
|
int w = ((int) ROUNDUP(b, shrinkfactor * 65536));
|
|
|
|
foreGroundPaint.fillRect( ((int) ((currinf.data.dvi_h) / (shrinkfactor * 65536))),
|
|
|
|
currinf.data.pxl_v - h + 1, w?w:1, h?h:1, Qt::black );
|
2003-02-19 12:54:27 +00:00
|
|
|
}
|
2000-02-29 11:27:53 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NOP:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BOP:
|
2001-10-27 11:38:16 +00:00
|
|
|
if (is_vfmacro == false) {
|
2001-07-06 10:14:01 +00:00
|
|
|
word_boundary_encountered = true;
|
2001-10-27 11:38:16 +00:00
|
|
|
line_boundary_encountered = true;
|
|
|
|
}
|
2001-10-18 16:40:34 +00:00
|
|
|
command_pointer += 11 * 4;
|
2003-03-27 08:20:15 +00:00
|
|
|
currinf.data.dvi_h = MFResolutions[font_pool->getMetafontMode()] << 16; // Reminder: DVI-coordinates start at (1",1") from top of page
|
|
|
|
currinf.data.dvi_v = MFResolutions[font_pool->getMetafontMode()];
|
2003-03-07 11:54:35 +00:00
|
|
|
currinf.data.pxl_v = int(currinf.data.dvi_v/shrinkfactor);
|
2003-02-19 12:54:27 +00:00
|
|
|
currinf.data.w = currinf.data.x = currinf.data.y = currinf.data.z = 0;
|
2000-02-29 11:27:53 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case EOP:
|
2001-08-09 07:35:46 +00:00
|
|
|
// 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.
|
2001-07-06 10:14:01 +00:00
|
|
|
word_boundary_encountered = true;
|
2001-10-27 11:38:16 +00:00
|
|
|
line_boundary_encountered = true;
|
2001-08-09 07:35:46 +00:00
|
|
|
// Sanity check for the dvi-file: The DVI-standard asserts
|
|
|
|
// that at the end of a page, the stack should always be
|
|
|
|
// empty.
|
2001-11-01 09:53:31 +00:00
|
|
|
if (!stack.isEmpty()) {
|
|
|
|
errorMsg = i18n("The stack was not empty when the EOP command was encountered.");
|
|
|
|
return;
|
|
|
|
}
|
2001-08-09 07:35:46 +00:00
|
|
|
}
|
2000-02-29 11:27:53 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
case PUSH:
|
2001-08-09 07:35:46 +00:00
|
|
|
stack.push(currinf.data);
|
2000-02-29 11:27:53 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case POP:
|
2001-11-01 09:53:31 +00:00
|
|
|
if (stack.isEmpty()) {
|
|
|
|
errorMsg = i18n("The stack was empty when a POP command was encountered.");
|
|
|
|
return;
|
|
|
|
} else
|
2001-08-09 07:35:46 +00:00
|
|
|
currinf.data = stack.pop();
|
2002-01-02 13:38:46 +00:00
|
|
|
word_boundary_encountered = true;
|
|
|
|
line_boundary_encountered = true;
|
2000-02-29 11:27:53 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case RIGHT1:
|
|
|
|
case RIGHT2:
|
|
|
|
case RIGHT3:
|
|
|
|
case RIGHT4:
|
2001-10-27 11:38:16 +00:00
|
|
|
RRtmp = readINT(ch - RIGHT1 + 1);
|
|
|
|
|
|
|
|
// A horizontal motion in the range 4 * font space [f] < h <
|
|
|
|
// font space [f] will be treated as a kern that is not
|
|
|
|
// indicated in the printouts that DVItype produces between
|
|
|
|
// brackets. We allow a larger space in the negative
|
|
|
|
// direction than in the positive one, because TEX makes
|
|
|
|
// comparatively large backspaces when it positions
|
|
|
|
// accents. (comments stolen from the source of dvitype)
|
|
|
|
if ((is_vfmacro == false) &&
|
|
|
|
(currinf.fontp != 0) &&
|
2003-02-28 08:27:07 +00:00
|
|
|
((RRtmp >= currinf.fontp->scaled_size_in_DVI_units/6) || (RRtmp <= -4*(currinf.fontp->scaled_size_in_DVI_units/6))) &&
|
2002-08-07 08:15:17 +00:00
|
|
|
(textLinkList.size() > 0))
|
|
|
|
textLinkList[textLinkList.size()-1].linkText += ' ';
|
2003-02-19 12:54:27 +00:00
|
|
|
currinf.data.dvi_h += ((long) (RRtmp * current_dimconv));
|
2000-02-29 11:27:53 +00:00
|
|
|
break;
|
2001-10-27 11:38:16 +00:00
|
|
|
|
2000-02-29 11:27:53 +00:00
|
|
|
case W1:
|
|
|
|
case W2:
|
|
|
|
case W3:
|
|
|
|
case W4:
|
2001-10-27 11:38:16 +00:00
|
|
|
WWtmp = readINT(ch - W0);
|
2003-02-19 12:54:27 +00:00
|
|
|
currinf.data.w = ((long) (WWtmp * current_dimconv));
|
2000-02-29 11:27:53 +00:00
|
|
|
case W0:
|
2001-10-27 11:38:16 +00:00
|
|
|
if ((is_vfmacro == false) &&
|
|
|
|
(currinf.fontp != 0) &&
|
2003-02-28 08:27:07 +00:00
|
|
|
((WWtmp >= currinf.fontp->scaled_size_in_DVI_units/6) || (WWtmp <= -4*(currinf.fontp->scaled_size_in_DVI_units/6))) &&
|
2002-08-07 08:15:17 +00:00
|
|
|
(textLinkList.size() > 0) )
|
|
|
|
textLinkList[textLinkList.size()-1].linkText += ' ';
|
2003-02-19 12:54:27 +00:00
|
|
|
currinf.data.dvi_h += currinf.data.w;
|
2000-02-29 11:27:53 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case X1:
|
|
|
|
case X2:
|
|
|
|
case X3:
|
|
|
|
case X4:
|
2001-10-27 11:38:16 +00:00
|
|
|
XXtmp = readINT(ch - X0);
|
2003-02-19 12:54:27 +00:00
|
|
|
currinf.data.x = ((long) (XXtmp * current_dimconv));
|
2000-02-29 11:27:53 +00:00
|
|
|
case X0:
|
2001-10-27 11:38:16 +00:00
|
|
|
if ((is_vfmacro == false) &&
|
|
|
|
(currinf.fontp != 0) &&
|
2003-02-28 08:27:07 +00:00
|
|
|
((XXtmp >= currinf.fontp->scaled_size_in_DVI_units/6) || (XXtmp <= -4*(currinf.fontp->scaled_size_in_DVI_units/6))) &&
|
2002-08-07 08:15:17 +00:00
|
|
|
(textLinkList.size() > 0))
|
|
|
|
textLinkList[textLinkList.size()-1].linkText += ' ';
|
2003-02-19 12:54:27 +00:00
|
|
|
currinf.data.dvi_h += currinf.data.x;
|
2000-02-29 11:27:53 +00:00
|
|
|
break;
|
2001-10-27 11:38:16 +00:00
|
|
|
|
2000-02-29 11:27:53 +00:00
|
|
|
case DOWN1:
|
|
|
|
case DOWN2:
|
|
|
|
case DOWN3:
|
|
|
|
case DOWN4:
|
2001-10-27 11:38:16 +00:00
|
|
|
{
|
|
|
|
Q_INT32 DDtmp = readINT(ch - DOWN1 + 1);
|
|
|
|
if ((is_vfmacro == false) &&
|
|
|
|
(currinf.fontp != 0) &&
|
2003-02-28 08:27:07 +00:00
|
|
|
(abs(DDtmp) >= 5*(currinf.fontp->scaled_size_in_DVI_units/6)) &&
|
2002-08-07 08:15:17 +00:00
|
|
|
(textLinkList.size() > 0)) {
|
2001-10-27 11:38:16 +00:00
|
|
|
word_boundary_encountered = true;
|
|
|
|
line_boundary_encountered = true;
|
2003-02-28 08:27:07 +00:00
|
|
|
if (abs(DDtmp) >= 10*(currinf.fontp->scaled_size_in_DVI_units/6))
|
2002-08-07 08:15:17 +00:00
|
|
|
textLinkList[textLinkList.size()-1].linkText += '\n';
|
2001-10-27 11:38:16 +00:00
|
|
|
}
|
2003-02-19 12:54:27 +00:00
|
|
|
currinf.data.dvi_v += ((long) (DDtmp * current_dimconv))/65536;
|
2003-03-07 11:54:35 +00:00
|
|
|
currinf.data.pxl_v = int(currinf.data.dvi_v/shrinkfactor);
|
2001-10-27 11:38:16 +00:00
|
|
|
}
|
2000-02-29 11:27:53 +00:00
|
|
|
break;
|
2001-10-27 11:38:16 +00:00
|
|
|
|
2000-02-29 11:27:53 +00:00
|
|
|
case Y1:
|
|
|
|
case Y2:
|
|
|
|
case Y3:
|
|
|
|
case Y4:
|
2001-10-27 11:38:16 +00:00
|
|
|
YYtmp = readINT(ch - Y0);
|
2003-02-19 12:54:27 +00:00
|
|
|
currinf.data.y = ((long) (YYtmp * current_dimconv));
|
2000-02-29 11:27:53 +00:00
|
|
|
case Y0:
|
2001-10-27 11:38:16 +00:00
|
|
|
if ((is_vfmacro == false) &&
|
|
|
|
(currinf.fontp != 0) &&
|
2003-02-28 08:27:07 +00:00
|
|
|
(abs(YYtmp) >= 5*(currinf.fontp->scaled_size_in_DVI_units/6)) &&
|
2002-08-07 08:15:17 +00:00
|
|
|
(textLinkList.size() > 0)) {
|
2001-10-27 11:38:16 +00:00
|
|
|
word_boundary_encountered = true;
|
|
|
|
line_boundary_encountered = true;
|
2003-02-28 08:27:07 +00:00
|
|
|
if (abs(YYtmp) >= 10*(currinf.fontp->scaled_size_in_DVI_units/6))
|
2002-08-07 08:15:17 +00:00
|
|
|
textLinkList[textLinkList.size()-1].linkText += '\n';
|
2001-10-27 11:38:16 +00:00
|
|
|
}
|
2003-02-19 12:54:27 +00:00
|
|
|
currinf.data.dvi_v += currinf.data.y/65536;
|
2003-03-07 11:54:35 +00:00
|
|
|
currinf.data.pxl_v = int(currinf.data.dvi_v/shrinkfactor);
|
2000-02-29 11:27:53 +00:00
|
|
|
break;
|
2001-10-27 11:38:16 +00:00
|
|
|
|
2000-02-29 11:27:53 +00:00
|
|
|
case Z1:
|
|
|
|
case Z2:
|
|
|
|
case Z3:
|
|
|
|
case Z4:
|
2001-10-27 11:38:16 +00:00
|
|
|
ZZtmp = readINT(ch - Z0);
|
2003-02-19 12:54:27 +00:00
|
|
|
currinf.data.z = ((long) (ZZtmp * current_dimconv));
|
2000-02-29 11:27:53 +00:00
|
|
|
case Z0:
|
2001-10-27 11:38:16 +00:00
|
|
|
if ((is_vfmacro == false) &&
|
|
|
|
(currinf.fontp != 0) &&
|
2003-02-28 08:27:07 +00:00
|
|
|
(abs(ZZtmp) >= 5*(currinf.fontp->scaled_size_in_DVI_units/6)) &&
|
2002-08-07 08:15:17 +00:00
|
|
|
(textLinkList.size() > 0)) {
|
2001-07-06 10:14:01 +00:00
|
|
|
word_boundary_encountered = true;
|
2001-10-27 11:38:16 +00:00
|
|
|
line_boundary_encountered = true;
|
2003-02-28 08:27:07 +00:00
|
|
|
if (abs(ZZtmp) >= 10*(currinf.fontp->scaled_size_in_DVI_units/6))
|
2002-08-07 08:15:17 +00:00
|
|
|
textLinkList[textLinkList.size()-1].linkText += '\n';
|
2001-10-27 11:38:16 +00:00
|
|
|
}
|
2003-02-19 12:54:27 +00:00
|
|
|
currinf.data.dvi_v += currinf.data.z/65536;
|
2003-03-07 11:54:35 +00:00
|
|
|
currinf.data.pxl_v = int(currinf.data.dvi_v/shrinkfactor);
|
2000-02-29 11:27:53 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case FNT1:
|
|
|
|
case FNT2:
|
|
|
|
case FNT3:
|
2003-04-27 15:58:38 +00:00
|
|
|
currinf.fontp = currinf.fonttable->find(readUINT(ch - FNT1 + 1));
|
2001-11-01 09:53:31 +00:00
|
|
|
if (currinf.fontp == NULL) {
|
|
|
|
errorMsg = i18n("The DVI code referred to a font which was not previously defined.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
currinf.set_char_p = currinf.fontp->set_char_p;
|
2001-10-18 16:40:34 +00:00
|
|
|
break;
|
|
|
|
|
2000-02-29 11:27:53 +00:00
|
|
|
case FNT4:
|
2003-04-27 15:58:38 +00:00
|
|
|
currinf.fontp = currinf.fonttable->find(readINT(ch - FNT1 + 1));
|
2001-11-01 09:53:31 +00:00
|
|
|
if (currinf.fontp == NULL) {
|
|
|
|
errorMsg = i18n("The DVI code referred to a font which was not previously defined.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
currinf.set_char_p = currinf.fontp->set_char_p;
|
2000-02-29 11:27:53 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case XXX1:
|
|
|
|
case XXX2:
|
|
|
|
case XXX3:
|
|
|
|
case XXX4:
|
2001-10-27 11:38:16 +00:00
|
|
|
if (is_vfmacro == false) {
|
2001-07-06 10:14:01 +00:00
|
|
|
word_boundary_encountered = true;
|
2001-10-27 11:38:16 +00:00
|
|
|
line_boundary_encountered = true;
|
|
|
|
}
|
2001-10-18 16:40:34 +00:00
|
|
|
a = readUINT(ch - XXX1 + 1);
|
|
|
|
if (a > 0) {
|
|
|
|
char *cmd = new char[a+1];
|
|
|
|
strncpy(cmd, (char *)command_pointer, a);
|
|
|
|
command_pointer += a;
|
|
|
|
cmd[a] = '\0';
|
|
|
|
applicationDoSpecial(cmd);
|
|
|
|
delete [] cmd;
|
|
|
|
}
|
2000-02-29 11:27:53 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case FNTDEF1:
|
|
|
|
case FNTDEF2:
|
|
|
|
case FNTDEF3:
|
|
|
|
case FNTDEF4:
|
2001-10-27 11:38:16 +00:00
|
|
|
command_pointer += 12 + ch - FNTDEF1 + 1;
|
|
|
|
command_pointer += readUINT8() + readUINT8();
|
2000-02-29 11:27:53 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PRE:
|
|
|
|
case POST:
|
|
|
|
case POSTPOST:
|
2001-11-01 09:53:31 +00:00
|
|
|
errorMsg = i18n("An illegal command was encountered.");
|
|
|
|
return;
|
2000-02-29 11:27:53 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2001-11-01 09:53:31 +00:00
|
|
|
errorMsg = i18n("The unknown op-code %1 was encountered.").arg(ch);
|
|
|
|
return;
|
2000-02-29 11:27:53 +00:00
|
|
|
} /* end switch*/
|
|
|
|
} /* end else (ch not a SETCHAR or FNTNUM) */
|
|
|
|
} /* end for */
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-06-07 01:41:55 +00:00
|
|
|
void dviWindow::draw_page(void)
|
2000-02-29 11:27:53 +00:00
|
|
|
{
|
2001-09-03 08:57:03 +00:00
|
|
|
// Reset a couple of variables
|
|
|
|
HTML_href = 0;
|
|
|
|
source_href = 0;
|
2002-12-23 12:32:25 +00:00
|
|
|
hyperLinkList.clear();
|
2003-04-18 11:17:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Calling resize() here rather than clear() means that the memory
|
|
|
|
// taken up by the vector is not freed. This is faster than
|
|
|
|
// constantly allocating/freeing memory.
|
|
|
|
textLinkList.resize(0);
|
|
|
|
sourceHyperLinkList.resize(0);
|
2001-09-03 08:57:03 +00:00
|
|
|
|
2001-03-02 21:02:45 +00:00
|
|
|
// Check if all the fonts are loaded. If that is not the case, we
|
|
|
|
// return and do not draw anything. The font_pool will later emit
|
|
|
|
// the signal "fonts_are_loaded" and thus trigger a redraw of the
|
|
|
|
// page.
|
2003-03-21 09:28:51 +00:00
|
|
|
if (font_pool->check_if_fonts_filenames_are_looked_up() == false)
|
2001-03-02 21:02:45 +00:00
|
|
|
return;
|
|
|
|
|
2003-04-06 17:32:11 +00:00
|
|
|
#ifdef PERFORMANCE_MEASUREMENT
|
|
|
|
// If this is the first time a page is drawn, take the time that is
|
|
|
|
// elapsed till the kdvi_multipage was constructed, and print
|
|
|
|
// it. Set the flag so that is message will not be printed again.
|
|
|
|
if (performanceFlag == 0) {
|
|
|
|
kdDebug(4300) << "Time elapsed till the first page is drawn: " << performanceTimer.restart() << "ms" << endl;
|
|
|
|
performanceFlag = 1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2000-06-09 05:31:11 +00:00
|
|
|
#ifdef DEBUG_RENDER
|
2000-06-05 10:49:44 +00:00
|
|
|
kdDebug() <<"draw_page" << endl;
|
2000-06-09 05:31:11 +00:00
|
|
|
#endif
|
2000-03-21 12:36:34 +00:00
|
|
|
|
2003-04-06 17:32:11 +00:00
|
|
|
foreGroundPaint.fillRect(pixmap->rect(), PS_interface->getBackgroundColor(current_page) );
|
|
|
|
|
2000-06-23 00:22:44 +00:00
|
|
|
// Render the PostScript background, if there is one.
|
|
|
|
if (_postscript) {
|
|
|
|
QPixmap *pxm = PS_interface->graphics(current_page);
|
|
|
|
if (pxm != NULL) {
|
|
|
|
foreGroundPaint.drawPixmap(0, 0, *pxm);
|
|
|
|
delete pxm;
|
2001-03-15 15:11:36 +00:00
|
|
|
}
|
|
|
|
}
|
2001-10-18 16:40:34 +00:00
|
|
|
|
2001-07-06 10:14:01 +00:00
|
|
|
// Now really write the text
|
2001-10-18 16:40:34 +00:00
|
|
|
if (dviFile->page_offset == 0)
|
|
|
|
return;
|
|
|
|
if (current_page < dviFile->total_pages) {
|
|
|
|
command_pointer = dviFile->dvi_Data + dviFile->page_offset[current_page];
|
|
|
|
end_pointer = dviFile->dvi_Data + dviFile->page_offset[current_page+1];
|
|
|
|
} else
|
|
|
|
command_pointer = end_pointer = 0;
|
|
|
|
|
2000-07-24 21:21:21 +00:00
|
|
|
memset((char *) &currinf.data, 0, sizeof(currinf.data));
|
2003-04-27 15:58:38 +00:00
|
|
|
currinf.fonttable = &(dviFile->tn_table);
|
2001-09-03 08:57:03 +00:00
|
|
|
currinf._virtual = 0;
|
2003-02-13 21:28:22 +00:00
|
|
|
draw_part(65536.0*fontPixelPerDVIunit(), false);
|
2001-09-03 08:57:03 +00:00
|
|
|
if (HTML_href != 0) {
|
2000-06-09 05:31:11 +00:00
|
|
|
delete HTML_href;
|
2001-09-03 08:57:03 +00:00
|
|
|
HTML_href = 0;
|
|
|
|
}
|
|
|
|
if (source_href != 0) {
|
|
|
|
delete source_href;
|
|
|
|
source_href = 0;
|
2000-06-09 05:31:11 +00:00
|
|
|
}
|
2001-07-06 10:14:01 +00:00
|
|
|
|
|
|
|
// Mark hyperlinks in blue. We draw a blue line under the
|
|
|
|
// character whose width is equivalent to 0.5 mm, but at least
|
|
|
|
// one pixel.
|
2003-03-27 08:20:15 +00:00
|
|
|
int h = (int)(MFResolutions[font_pool->getMetafontMode()]*0.05/(2.54*shrinkfactor) + 0.5);
|
2001-07-06 10:14:01 +00:00
|
|
|
h = (h < 1) ? 1 : h;
|
2003-02-05 08:17:23 +00:00
|
|
|
for(unsigned int i=0; i<hyperLinkList.size(); i++) {
|
2001-07-06 10:14:01 +00:00
|
|
|
int x = hyperLinkList[i].box.left();
|
|
|
|
int w = hyperLinkList[i].box.width();
|
|
|
|
int y = hyperLinkList[i].baseline;
|
|
|
|
foreGroundPaint.fillRect(x, y, w, h, Qt::blue);
|
|
|
|
}
|
2000-02-29 11:27:53 +00:00
|
|
|
}
|