mirror of
https://invent.kde.org/graphics/okular
synced 2024-09-12 20:51:17 +00:00
fixes crash, and implements bookmarks (the latter not yet finished)
svn path=/trunk/KDE/kdegraphics/kdvi/; revision=427872
This commit is contained in:
parent
2da68636d0
commit
a35a86bd01
|
@ -54,7 +54,7 @@
|
|||
|
||||
//#define DEBUG_DVIRENDERER
|
||||
|
||||
QPainter *foreGroundPaint; // QPainter used for text
|
||||
QPainter *foreGroundPainter; // QPainter used for text
|
||||
|
||||
|
||||
//------ now comes the dviRenderer class implementation ----------
|
||||
|
@ -189,11 +189,11 @@ void dviRenderer::drawPage(double resolution, RenderedDocumentPage *page)
|
|||
globalColor = Qt::black;
|
||||
|
||||
QApplication::setOverrideCursor( waitCursor );
|
||||
foreGroundPaint = page->getPainter();
|
||||
if (foreGroundPaint != 0) {
|
||||
foreGroundPainter = page->getPainter();
|
||||
if (foreGroundPainter != 0) {
|
||||
errorMsg = QString::null;
|
||||
draw_page();
|
||||
page->returnPainter(foreGroundPaint);
|
||||
page->returnPainter(foreGroundPainter);
|
||||
}
|
||||
QApplication::restoreOverrideCursor();
|
||||
page->isEmpty = false;
|
||||
|
@ -337,6 +337,8 @@ void dviRenderer::embedPostScript(void)
|
|||
preScanTimer.start();
|
||||
#endif
|
||||
dviFile->numberOfExternalPSFiles = 0;
|
||||
bookMarkTitles.clear();
|
||||
bookMarkAnchors.clear();
|
||||
for(current_page=0; current_page < dviFile->total_pages; current_page++) {
|
||||
PostScriptOutPutString = new QString();
|
||||
|
||||
|
@ -349,6 +351,7 @@ void dviRenderer::embedPostScript(void)
|
|||
memset((char *) &currinf.data, 0, sizeof(currinf.data));
|
||||
currinf.fonttable = &(dviFile->tn_table);
|
||||
currinf._virtual = NULL;
|
||||
|
||||
prescan(&dviRenderer::prescan_parseSpecials);
|
||||
|
||||
if (!PostScriptOutPutString->isEmpty())
|
||||
|
@ -357,6 +360,7 @@ void dviRenderer::embedPostScript(void)
|
|||
}
|
||||
PostScriptOutPutString = NULL;
|
||||
|
||||
|
||||
#ifdef PERFORMANCE_MEASUREMENT
|
||||
kdDebug(4300) << "Time required for prescan phase: " << preScanTimer.restart() << "ms" << endl;
|
||||
#endif
|
||||
|
@ -520,6 +524,8 @@ bool dviRenderer::setFile(const QString &fname)
|
|||
#endif
|
||||
dviFile->numberOfExternalPSFiles = 0;
|
||||
Q_UINT16 currPageSav = current_page;
|
||||
bookMarkAnchors.clear();
|
||||
bookMarkTitles.clear();
|
||||
|
||||
for(current_page=0; current_page < dviFile->total_pages; current_page++) {
|
||||
PostScriptOutPutString = new QString();
|
||||
|
@ -541,6 +547,26 @@ bool dviRenderer::setFile(const QString &fname)
|
|||
}
|
||||
PostScriptOutPutString = NULL;
|
||||
|
||||
|
||||
// Generate the list of bookmarks
|
||||
kdError() << "========================================================" << endl;
|
||||
kdError() << "bookMarkTitles.size() " << bookMarkTitles.size() << endl;
|
||||
if (bookMarkTitles.size() != bookMarkAnchors.size())
|
||||
kdError(4330) << "dviRenderer::setFile(..): Internal corruption in bookmark structures. Disregarding all bookmarks." << endl;
|
||||
else
|
||||
for(unsigned int i=0; i<bookMarkTitles.size(); i++) {
|
||||
Anchor anc = findAnchor(bookMarkAnchors[i]);
|
||||
if (anc.isValid()) {
|
||||
Bookmark *bmk = new Bookmark(bookMarkTitles[i], anc);
|
||||
bookmarks.append(bmk);
|
||||
} else
|
||||
kdError() << bookMarkTitles[i] << " has an invalicd anchor" << endl;
|
||||
}
|
||||
bookMarkAnchors.clear();
|
||||
bookMarkTitles.clear();
|
||||
|
||||
|
||||
|
||||
#ifdef PERFORMANCE_MEASUREMENT
|
||||
kdDebug(4300) << "Time required for prescan phase: " << preScanTimer.restart() << "ms" << endl;
|
||||
#endif
|
||||
|
|
|
@ -188,7 +188,12 @@ private:
|
|||
void prescan_ParsePSFileSpecial(QString cp);
|
||||
void prescan_ParseSourceSpecial(QString cp);
|
||||
void prescan_setChar(unsigned int ch);
|
||||
|
||||
|
||||
/* */
|
||||
QStringList bookMarkTitles;
|
||||
QStringList bookMarkAnchors;
|
||||
|
||||
|
||||
/** Utility fields used by the embedPostScript method*/
|
||||
KProgressDialog *embedPS_progress;
|
||||
Q_UINT16 embedPS_numOfProgressedFiles;
|
||||
|
|
|
@ -70,7 +70,7 @@
|
|||
#include <qpainter.h>
|
||||
#include <qfileinfo.h>
|
||||
|
||||
extern QPainter *foreGroundPaint;
|
||||
extern QPainter *foreGroundPainter;
|
||||
|
||||
|
||||
/** Routine to print characters. */
|
||||
|
@ -96,7 +96,7 @@ void dviRenderer::set_char(unsigned int cmd, unsigned int ch)
|
|||
int y = currinf.data.pxl_v - g->y2;
|
||||
|
||||
// Draw the character.
|
||||
foreGroundPaint->drawPixmap(x, y, pix);
|
||||
foreGroundPainter->drawPixmap(x, y, pix);
|
||||
|
||||
// Are we drawing text for a hyperlink? And are hyperlinks
|
||||
// enabled?
|
||||
|
@ -313,10 +313,10 @@ void dviRenderer::draw_part(double current_dimconv, bool is_vfmacro)
|
|||
int w = ((int) ROUNDUP(b, shrinkfactor * 65536));
|
||||
|
||||
if (colorStack.isEmpty())
|
||||
foreGroundPaint->fillRect( ((int) ((currinf.data.dvi_h) / (shrinkfactor * 65536))),
|
||||
foreGroundPainter->fillRect( ((int) ((currinf.data.dvi_h) / (shrinkfactor * 65536))),
|
||||
currinf.data.pxl_v - h + 1, w?w:1, h?h:1, globalColor );
|
||||
else
|
||||
foreGroundPaint->fillRect( ((int) ((currinf.data.dvi_h) / (shrinkfactor * 65536))),
|
||||
foreGroundPainter->fillRect( ((int) ((currinf.data.dvi_h) / (shrinkfactor * 65536))),
|
||||
currinf.data.pxl_v - h + 1, w?w:1, h?h:1, colorStack.top() );
|
||||
}
|
||||
currinf.data.dvi_h += b;
|
||||
|
@ -335,10 +335,10 @@ void dviRenderer::draw_part(double current_dimconv, bool is_vfmacro)
|
|||
int h = ((int) ROUNDUP(a, shrinkfactor * 65536));
|
||||
int w = ((int) ROUNDUP(b, shrinkfactor * 65536));
|
||||
if (colorStack.isEmpty())
|
||||
foreGroundPaint->fillRect( ((int) ((currinf.data.dvi_h) / (shrinkfactor * 65536))),
|
||||
foreGroundPainter->fillRect( ((int) ((currinf.data.dvi_h) / (shrinkfactor * 65536))),
|
||||
currinf.data.pxl_v - h + 1, w?w:1, h?h:1, globalColor );
|
||||
else
|
||||
foreGroundPaint->fillRect( ((int) ((currinf.data.dvi_h) / (shrinkfactor * 65536))),
|
||||
foreGroundPainter->fillRect( ((int) ((currinf.data.dvi_h) / (shrinkfactor * 65536))),
|
||||
currinf.data.pxl_v - h + 1, w?w:1, h?h:1, colorStack.top() );
|
||||
}
|
||||
break;
|
||||
|
@ -599,12 +599,12 @@ void dviRenderer::draw_page(void)
|
|||
|
||||
if (!accessibilityBackground)
|
||||
{
|
||||
foreGroundPaint->fillRect( foreGroundPaint->viewport(), PS_interface->getBackgroundColor(current_page) );
|
||||
foreGroundPainter->fillRect( foreGroundPainter->viewport(), PS_interface->getBackgroundColor(current_page) );
|
||||
}
|
||||
else
|
||||
{
|
||||
// In accessiblity mode use the custom background color
|
||||
foreGroundPaint->fillRect( foreGroundPaint->viewport(), accessibilityBackgroundColor );
|
||||
foreGroundPainter->fillRect( foreGroundPainter->viewport(), accessibilityBackgroundColor );
|
||||
}
|
||||
|
||||
// Render the PostScript background, if there is one.
|
||||
|
@ -620,7 +620,7 @@ void dviRenderer::draw_page(void)
|
|||
else
|
||||
PS_interface->restoreBackgroundColor(current_page);
|
||||
|
||||
PS_interface->graphics(current_page, resolutionInDPI, dviFile->getMagnification(), foreGroundPaint);
|
||||
PS_interface->graphics(current_page, resolutionInDPI, dviFile->getMagnification(), foreGroundPainter);
|
||||
}
|
||||
|
||||
// Now really write the text
|
||||
|
|
|
@ -340,20 +340,13 @@ void dviRenderer::prescan_ParsePSSpecial(QString cp)
|
|||
anchorList[anchorName] = Anchor(current_page+1, l);
|
||||
}
|
||||
if (cp.contains("/Dest") && cp.contains("/Title")) { // The PostScript code defines a bookmark
|
||||
QString bookmarkTitle = cp.section('(', 1, 1).section(')', 0, 0);
|
||||
QString bookmarkDest = cp.section('(', 2, 2).section(')', 0, 0);
|
||||
|
||||
Length l;
|
||||
l.setLength_in_inch(0);
|
||||
Bookmark *bmk = new Bookmark(bookmarkDest, 1, l);
|
||||
bookmarks.append(bmk);
|
||||
kdError() << bookmarkDest << endl;
|
||||
bookMarkAnchors += cp.section('(', 1, 1).section(')', 0, 0);
|
||||
bookMarkTitles += cp.section('(', 2, 2).section(')', 0, 0);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
double PS_H = (currinf.data.dvi_h*300.0)/(65536*1200)-300;
|
||||
double PS_V = (currinf.data.dvi_v*300.0)/1200 - 300;
|
||||
|
||||
|
|
36
special.cpp
36
special.cpp
|
@ -24,7 +24,7 @@
|
|||
|
||||
//#define DEBUG_SPECIAL
|
||||
|
||||
extern QPainter foreGroundPaint;
|
||||
extern QPainter *foreGroundPainter;
|
||||
|
||||
void dviRenderer::printErrorMsgForSpecials(QString msg)
|
||||
{
|
||||
|
@ -304,7 +304,7 @@ void dviRenderer::epsf_special(QString cp)
|
|||
|
||||
QImage image(EPSfilename);
|
||||
image = image.smoothScale((int)(bbox_width), (int)(bbox_height));
|
||||
foreGroundPaint.drawImage( ((int) ((currinf.data.dvi_h) / (shrinkfactor * 65536))), currinf.data.pxl_v - (int)bbox_height, image);
|
||||
foreGroundPainter->drawImage( ((int) ((currinf.data.dvi_h) / (shrinkfactor * 65536))), currinf.data.pxl_v - (int)bbox_height, image);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -330,19 +330,21 @@ void dviRenderer::epsf_special(QString cp)
|
|||
|
||||
QRect bbox(((int) ((currinf.data.dvi_h) / (shrinkfactor * 65536))), currinf.data.pxl_v - (int)bbox_height,
|
||||
(int)bbox_width, (int)bbox_height);
|
||||
foreGroundPaint.save();
|
||||
|
||||
foreGroundPainter->save();
|
||||
|
||||
if (QFile::exists(EPSfilename))
|
||||
foreGroundPaint.setBrush(Qt::lightGray);
|
||||
foreGroundPainter->setBrush(Qt::lightGray);
|
||||
else
|
||||
foreGroundPaint.setBrush(Qt::red);
|
||||
foreGroundPaint.setPen(Qt::black);
|
||||
foreGroundPaint.drawRoundRect(bbox, 2, 2);
|
||||
foreGroundPainter->setBrush(Qt::red);
|
||||
foreGroundPainter->setPen(Qt::black);
|
||||
foreGroundPainter->drawRoundRect(bbox, 2, 2);
|
||||
if (QFile::exists(EPSfilename))
|
||||
foreGroundPaint.drawText (bbox, (int)(Qt::AlignCenter), EPSfilename, -1);
|
||||
foreGroundPainter->drawText (bbox, (int)(Qt::AlignCenter), EPSfilename, -1);
|
||||
else
|
||||
foreGroundPaint.drawText (bbox, (int)(Qt::AlignCenter),
|
||||
foreGroundPainter->drawText (bbox, (int)(Qt::AlignCenter),
|
||||
i18n("File not found: \n %1").arg(EPSfilename), -1);
|
||||
foreGroundPaint.restore();
|
||||
foreGroundPainter->restore();
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -361,8 +363,8 @@ void dviRenderer::TPIC_flushPath_special(void)
|
|||
}
|
||||
|
||||
QPen pen(Qt::black, (int)(penWidth_in_mInch*resolutionInDPI/1000.0 + 0.5)); // Sets the pen size in milli-inches
|
||||
foreGroundPaint.setPen(pen);
|
||||
foreGroundPaint.drawPolyline(TPIC_path, 0, number_of_elements_in_path);
|
||||
foreGroundPainter->setPen(pen);
|
||||
foreGroundPainter->drawPolyline(TPIC_path, 0, number_of_elements_in_path);
|
||||
number_of_elements_in_path = 0;
|
||||
}
|
||||
|
||||
|
@ -581,11 +583,11 @@ void dviRenderer::applicationDoSpecial(char *cp)
|
|||
int x = ((int) ((currinf.data.dvi_h) / (shrinkfactor * 65536)));
|
||||
int y = currinf.data.pxl_v;
|
||||
|
||||
foreGroundPaint.save();
|
||||
foreGroundPainter->save();
|
||||
// Rotate about the current point
|
||||
foreGroundPaint.translate(x,y);
|
||||
foreGroundPaint.rotate(-angle);
|
||||
foreGroundPaint.translate(-x,-y);
|
||||
foreGroundPainter->translate(x,y);
|
||||
foreGroundPainter->rotate(-angle);
|
||||
foreGroundPainter->translate(-x,-y);
|
||||
} else
|
||||
printErrorMsgForSpecials( i18n("Error in DVIfile '%1', page %2. Could not interpret angle in text rotation special." ).
|
||||
arg(dviFile->filename).arg(current_page));
|
||||
|
@ -594,7 +596,7 @@ void dviRenderer::applicationDoSpecial(char *cp)
|
|||
// The graphicx package marks the end of rotated text with this
|
||||
// special. The state of the painter is restored.
|
||||
if (special_command == "ps: currentpoint grestore moveto") {
|
||||
foreGroundPaint.restore();
|
||||
foreGroundPainter->restore();
|
||||
}
|
||||
|
||||
// The following special commands are not used here; they are of
|
||||
|
|
Loading…
Reference in a new issue