mirror of
https://invent.kde.org/graphics/okular
synced 2024-09-12 20:51:17 +00:00
merged up to 428172
svn path=/branches/work/kde4/kdegraphics/kdvi/; revision=428206
This commit is contained in:
commit
9486b9d60f
|
@ -26,6 +26,7 @@
|
|||
//Added by qt3to4:
|
||||
#include <QHBoxLayout>
|
||||
#include <QMouseEvent>
|
||||
#include <qptrstack.h>
|
||||
|
||||
#include <kapplication.h>
|
||||
#include <kmessagebox.h>
|
||||
|
@ -57,7 +58,7 @@
|
|||
|
||||
//#define DEBUG_DVIRENDERER
|
||||
|
||||
QPainter *foreGroundPaint; // QPainter used for text
|
||||
QPainter *foreGroundPainter; // QPainter used for text
|
||||
|
||||
|
||||
//------ now comes the dviRenderer class implementation ----------
|
||||
|
@ -192,11 +193,11 @@ void dviRenderer::drawPage(double resolution, RenderedDocumentPage *page)
|
|||
globalColor = Qt::black;
|
||||
|
||||
QApplication::setOverrideCursor( Qt::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;
|
||||
|
@ -340,6 +341,7 @@ void dviRenderer::embedPostScript(void)
|
|||
preScanTimer.start();
|
||||
#endif
|
||||
dviFile->numberOfExternalPSFiles = 0;
|
||||
prebookmarks.clear();
|
||||
for(current_page=0; current_page < dviFile->total_pages; current_page++) {
|
||||
PostScriptOutPutString = new QString();
|
||||
|
||||
|
@ -352,6 +354,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())
|
||||
|
@ -360,6 +363,7 @@ void dviRenderer::embedPostScript(void)
|
|||
}
|
||||
PostScriptOutPutString = NULL;
|
||||
|
||||
|
||||
#ifdef PERFORMANCE_MEASUREMENT
|
||||
kdDebug(4300) << "Time required for prescan phase: " << preScanTimer.restart() << "ms" << endl;
|
||||
#endif
|
||||
|
@ -523,6 +527,7 @@ bool dviRenderer::setFile(const QString &fname)
|
|||
#endif
|
||||
dviFile->numberOfExternalPSFiles = 0;
|
||||
Q_UINT16 currPageSav = current_page;
|
||||
prebookmarks.clear();
|
||||
|
||||
for(current_page=0; current_page < dviFile->total_pages; current_page++) {
|
||||
PostScriptOutPutString = new QString();
|
||||
|
@ -544,6 +549,30 @@ bool dviRenderer::setFile(const QString &fname)
|
|||
}
|
||||
PostScriptOutPutString = NULL;
|
||||
|
||||
|
||||
// Generate the list of bookmarks
|
||||
kdError() << "========================================================" << endl;
|
||||
|
||||
QPtrStack<Bookmark> stack;
|
||||
stack.setAutoDelete (false);
|
||||
|
||||
QValueVector<PreBookmark>::iterator it;
|
||||
for( it = prebookmarks.begin(); it != prebookmarks.end(); ++it ) {
|
||||
kdError() << (*it).title << " has an count " << (*it).noOfChildren << endl;
|
||||
Bookmark *bmk = new Bookmark((*it).title, findAnchor((*it).anchorName));
|
||||
if (stack.isEmpty())
|
||||
bookmarks.append(bmk);
|
||||
else {
|
||||
stack.top()->subordinateBookmarks.append(bmk);
|
||||
stack.remove();
|
||||
}
|
||||
for(int i=0; i<(*it).noOfChildren; i++)
|
||||
stack.push(bmk);
|
||||
|
||||
}
|
||||
prebookmarks.clear();
|
||||
|
||||
|
||||
#ifdef PERFORMANCE_MEASUREMENT
|
||||
kdDebug(4300) << "Time required for prescan phase: " << preScanTimer.restart() << "ms" << endl;
|
||||
#endif
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "fontpool.h"
|
||||
#include "infodialog.h"
|
||||
#include "pageSize.h"
|
||||
#include "prebookmark.h"
|
||||
#include "psgs.h"
|
||||
#include "renderedDocumentPage.h"
|
||||
|
||||
|
@ -191,7 +192,12 @@ private:
|
|||
void prescan_ParsePSFileSpecial(QString cp);
|
||||
void prescan_ParseSourceSpecial(QString cp);
|
||||
void prescan_setChar(unsigned int ch);
|
||||
|
||||
|
||||
/* */
|
||||
QValueVector<PreBookmark> prebookmarks;
|
||||
|
||||
|
||||
|
||||
/** Utility fields used by the embedPostScript method*/
|
||||
KProgressDialog *embedPS_progress;
|
||||
Q_UINT16 embedPS_numOfProgressedFiles;
|
||||
|
|
|
@ -72,7 +72,7 @@
|
|||
//Added by qt3to4:
|
||||
#include <QPixmap>
|
||||
|
||||
extern QPainter *foreGroundPaint;
|
||||
extern QPainter *foreGroundPainter;
|
||||
|
||||
|
||||
/** Routine to print characters. */
|
||||
|
@ -98,7 +98,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?
|
||||
|
@ -315,10 +315,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;
|
||||
|
@ -337,10 +337,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;
|
||||
|
@ -601,12 +601,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.
|
||||
|
@ -622,7 +622,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
|
||||
|
|
|
@ -342,11 +342,16 @@ void dviRenderer::prescan_ParsePSSpecial(QString cp)
|
|||
l.setLength_in_inch(currinf.data.dvi_v/(resolutionInDPI*shrinkfactor));
|
||||
anchorList[anchorName] = Anchor(current_page+1, l);
|
||||
}
|
||||
// The PostScript code defines a bookmark
|
||||
if (cp.contains("/Dest") && cp.contains("/Title"))
|
||||
prebookmarks.append(PreBookmark(cp.section('(', 2, 2).section(')', 0, 0),
|
||||
cp.section('(', 1, 1).section(')', 0, 0),
|
||||
cp.section('-', 1, 1).section(' ', 0, 0).toUInt()
|
||||
));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
double PS_H = (currinf.data.dvi_h*300.0)/(65536*1200)-300;
|
||||
double PS_V = (currinf.data.dvi_v*300.0)/1200 - 300;
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ GenericName[es]=Visor de documentos DVI
|
|||
GenericName[et]=DVI failide vaataja
|
||||
GenericName[fi]=DVI-näytin
|
||||
GenericName[fr]=Afficheur DVI
|
||||
GenericName[ga]=Amharcán DVI
|
||||
GenericName[gl]=Visor de DVI
|
||||
GenericName[he]=מציג DVI
|
||||
GenericName[hi]=डीवीआई प्रदर्शक
|
||||
|
|
49
prebookmark.h
Normal file
49
prebookmark.h
Normal file
|
@ -0,0 +1,49 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2005 by Stefan Kebekus *
|
||||
* kebekus@kde.org *
|
||||
* *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef _PREBOOKMARK_H_
|
||||
#define _PREBOOKMARK_H_
|
||||
|
||||
#include <qstring.h>
|
||||
|
||||
/*! \brief Bookmark representation
|
||||
|
||||
This class presents a bookmark in a format that is used internally by
|
||||
the DVI prescan routines.
|
||||
*/
|
||||
|
||||
class PreBookmark
|
||||
{
|
||||
public:
|
||||
PreBookmark(QString t, QString a, Q_UINT16 n) {title=t; anchorName=a; noOfChildren=n;}
|
||||
PreBookmark() {title=QString::null; anchorName=QString::null; noOfChildren=0;}
|
||||
|
||||
// Title of the bookmark
|
||||
QString title;
|
||||
|
||||
// Name of the anchor
|
||||
QString anchorName;
|
||||
|
||||
// Number of subordinate bookmarks
|
||||
Q_UINT16 noOfChildren;
|
||||
};
|
||||
|
||||
#endif
|
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