mirror of
https://invent.kde.org/graphics/okular
synced 2024-08-25 02:45:38 +00:00
Port the recent changes to kdv, and remove some debug code
(Luigi Toscano) svn path=/trunk/playground/graphics/okular/; revision=556901
This commit is contained in:
parent
0a9a730f9d
commit
aa109c9ef0
|
@ -13,8 +13,8 @@
|
|||
#include "pageNumber.h"
|
||||
#include "hyperlink.h"
|
||||
#include "textBox.h"
|
||||
#include <Q3ValueVector>
|
||||
#include <QPixmap>
|
||||
#include <qvector.h>
|
||||
#include <qpixmap.h>
|
||||
|
||||
class dviPageInfo
|
||||
{
|
||||
|
@ -34,12 +34,12 @@ public:
|
|||
|
||||
/** \brief List of source hyperlinks
|
||||
*/
|
||||
Q3ValueVector<Hyperlink> sourceHyperLinkList;
|
||||
QVector<Hyperlink> sourceHyperLinkList;
|
||||
|
||||
/** \brief Hyperlinks on the document page
|
||||
*/
|
||||
Q3ValueVector<Hyperlink> hyperLinkList;
|
||||
Q3ValueVector<TextBox> textBoxList;
|
||||
QVector<Hyperlink> hyperLinkList;
|
||||
QVector<TextBox> textBoxList;
|
||||
};
|
||||
|
||||
/* quick&dirty hack to cheat the dviRenderer class... */
|
||||
|
|
|
@ -182,6 +182,48 @@ void dviRenderer::drawPage(RenderedDocumentPagePixmap* page)
|
|||
page->img = img;
|
||||
//page->setImage(img);
|
||||
|
||||
// Postprocess hyperlinks
|
||||
// Without that, based on the way TeX draws certain characters like german "Umlaute",
|
||||
// some hyperlinks would be broken into two overlapping parts, in the middle of a word.
|
||||
QVector<Hyperlink>::iterator i = page->hyperLinkList.begin();
|
||||
QVector<Hyperlink>::iterator j;
|
||||
while (i != page->hyperLinkList.end())
|
||||
{
|
||||
// Iterator j always points to the element after i.
|
||||
j = i;
|
||||
j++;
|
||||
|
||||
if (j == page->hyperLinkList.end())
|
||||
break;
|
||||
|
||||
Hyperlink& hi = *i;
|
||||
Hyperlink& hj = *j;
|
||||
|
||||
bool merged = false;
|
||||
|
||||
// Merge all hyperlinks that point to the same target, and have the same baseline.
|
||||
while (hi.linkText == hj.linkText && hi.baseline == hj.baseline)
|
||||
{
|
||||
merged = true;
|
||||
hi.box = hi.box.unite(hj.box);
|
||||
|
||||
j++;
|
||||
if (j == page->hyperLinkList.end())
|
||||
break;
|
||||
|
||||
hj = *j;
|
||||
}
|
||||
|
||||
if (merged)
|
||||
{
|
||||
i = page->hyperLinkList.erase(++i, j);
|
||||
}
|
||||
else
|
||||
{
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
page->isEmpty = false;
|
||||
if (errorMsg.isEmpty() != true) {
|
||||
|
@ -517,18 +559,12 @@ bool dviRenderer::setFile(const QString &fname, const KUrl &base)
|
|||
}
|
||||
PostScriptOutPutString = NULL;
|
||||
|
||||
#if 0
|
||||
Q3ValueVector<PreBookmark>::iterator it;
|
||||
for( it = prebookmarks.begin(); it != prebookmarks.end(); ++it ) {
|
||||
kDebug() << "preb:" << (*it).title << " - " << (*it).anchorName << " - " << (*it).noOfChildren << endl;
|
||||
}
|
||||
#endif
|
||||
#if 0
|
||||
// Generate the list of bookmarks
|
||||
bookmarks.clear();
|
||||
Q3PtrStack<Bookmark> stack;
|
||||
stack.setAutoDelete (false);
|
||||
Q3ValueVector<PreBookmark>::iterator it;
|
||||
QVector<PreBookmark>::iterator it;
|
||||
for( it = prebookmarks.begin(); it != prebookmarks.end(); ++it ) {
|
||||
Bookmark *bmk = new Bookmark((*it).title, findAnchor((*it).anchorName));
|
||||
if (stack.isEmpty())
|
||||
|
@ -552,7 +588,7 @@ bool dviRenderer::setFile(const QString &fname, const KUrl &base)
|
|||
pageSizes.resize(0);
|
||||
if (dviFile->suggestedPageSize != 0) {
|
||||
// Fill the vector pageSizes with total_pages identical entries
|
||||
pageSizes.resize(dviFile->total_pages, *(dviFile->suggestedPageSize));
|
||||
pageSizes.fill(*(dviFile->suggestedPageSize), dviFile->total_pages);
|
||||
}
|
||||
QApplication::restoreOverrideCursor();
|
||||
return true;
|
||||
|
@ -620,8 +656,8 @@ Anchor dviRenderer::parseReference(const QString &reference)
|
|||
// document.
|
||||
bool anchorForRefFileFound = false; // Flag that is set if source file anchors for the refFileName could be found at all
|
||||
|
||||
Q3ValueVector<DVI_SourceFileAnchor>::iterator bestMatch = sourceHyperLinkAnchors.end();
|
||||
Q3ValueVector<DVI_SourceFileAnchor>::iterator it;
|
||||
QVector<DVI_SourceFileAnchor>::iterator bestMatch = sourceHyperLinkAnchors.end();
|
||||
QVector<DVI_SourceFileAnchor>::iterator it;
|
||||
for( it = sourceHyperLinkAnchors.begin(); it != sourceHyperLinkAnchors.end(); ++it )
|
||||
if (refFileName.trimmed() == it->fileName.trimmed()
|
||||
|| refFileName.trimmed() == it->fileName.trimmed() + ".tex"
|
||||
|
|
|
@ -29,8 +29,8 @@
|
|||
#include <kprogressdialog.h>
|
||||
#include <Q3IntDict>
|
||||
#include <Q3PointArray>
|
||||
#include <Q3ValueStack>
|
||||
#include <Q3ValueVector>
|
||||
#include <QStack>
|
||||
#include <QVector>
|
||||
#include <QTimer>
|
||||
#include <QMutex>
|
||||
|
||||
|
@ -170,7 +170,7 @@ public slots:
|
|||
|
||||
SimplePageSize sizeOfPage(const PageNumber& page);
|
||||
|
||||
Q3ValueVector<PreBookmark> getPrebookmarks() const { return prebookmarks; }
|
||||
QVector<PreBookmark> getPrebookmarks() const { return prebookmarks; }
|
||||
|
||||
private slots:
|
||||
/** This method shows a dialog that tells the user that source
|
||||
|
@ -226,7 +226,7 @@ private:
|
|||
void prescan_setChar(unsigned int ch);
|
||||
|
||||
/* */
|
||||
Q3ValueVector<PreBookmark> prebookmarks;
|
||||
QVector<PreBookmark> prebookmarks;
|
||||
|
||||
|
||||
|
||||
|
@ -258,7 +258,7 @@ private:
|
|||
// List of source-hyperlinks on all pages. This vector is generated
|
||||
// when the DVI-file is first loaded, i.e. when draw_part is called
|
||||
// with PostScriptOutPutString != NULL
|
||||
Q3ValueVector<DVI_SourceFileAnchor> sourceHyperLinkAnchors;
|
||||
QVector<DVI_SourceFileAnchor> sourceHyperLinkAnchors;
|
||||
|
||||
// If not NULL, the text currently drawn represents a source
|
||||
// hyperlink to the (relative) URL given in the string;
|
||||
|
@ -273,11 +273,11 @@ 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. */
|
||||
Q3ValueStack<struct framedata> stack;
|
||||
QStack<framedata> stack;
|
||||
|
||||
/** A stack where color are stored, according to the documentation of
|
||||
DVIPS */
|
||||
Q3ValueStack<QColor> colorStack;
|
||||
QStack<QColor> colorStack;
|
||||
|
||||
/** The global color is to be used when the color stack is empty */
|
||||
QColor globalColor;
|
||||
|
@ -325,7 +325,7 @@ private:
|
|||
quint16 numPages;
|
||||
|
||||
//TODO: merge into dviPageInfo
|
||||
Q3ValueVector<SimplePageSize> pageSizes;
|
||||
QVector<SimplePageSize> pageSizes;
|
||||
|
||||
QMap<QString, Anchor> anchorList;
|
||||
};
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include <QX11Info>
|
||||
#include <qstring.h>
|
||||
#include <qurl.h>
|
||||
#include <qvector.h>
|
||||
#include <qstack.h>
|
||||
|
||||
#include <kdebug.h>
|
||||
|
@ -268,8 +269,8 @@ KPDFTextPage *DviGenerator::extractTextFromPage( dviPageInfo *pageInfo, int orie
|
|||
{
|
||||
QList<KPDFTextEntity*> textOfThePage;
|
||||
|
||||
Q3ValueVector<TextBox>::ConstIterator it = pageInfo->textBoxList.constBegin();
|
||||
Q3ValueVector<TextBox>::ConstIterator itEnd = pageInfo->textBoxList.constEnd();
|
||||
QVector<TextBox>::ConstIterator it = pageInfo->textBoxList.constBegin();
|
||||
QVector<TextBox>::ConstIterator itEnd = pageInfo->textBoxList.constEnd();
|
||||
QRect tmpRect;
|
||||
|
||||
int pageWidth = 0, pageHeight = 0;
|
||||
|
@ -331,13 +332,13 @@ const DocumentSynopsis *DviGenerator::generateDocumentSynopsis()
|
|||
|
||||
QStack<QDomElement*> stack;
|
||||
|
||||
Q3ValueVector<PreBookmark> prebookmarks = m_dviRenderer->getPrebookmarks();
|
||||
QVector<PreBookmark> prebookmarks = m_dviRenderer->getPrebookmarks();
|
||||
|
||||
if ( prebookmarks.isEmpty() )
|
||||
return m_docSynopsis;
|
||||
|
||||
Q3ValueVector<PreBookmark>::ConstIterator it = prebookmarks.begin();
|
||||
Q3ValueVector<PreBookmark>::ConstIterator itEnd = prebookmarks.end();
|
||||
QVector<PreBookmark>::ConstIterator it = prebookmarks.begin();
|
||||
QVector<PreBookmark>::ConstIterator itEnd = prebookmarks.end();
|
||||
for( ; it != itEnd; ++it )
|
||||
{
|
||||
QDomElement *domel = new QDomElement;
|
||||
|
|
|
@ -646,7 +646,7 @@ void dviRenderer::applicationDoSpecial(char *cp)
|
|||
if (special_command.startsWith("ps:SDict begin [") && special_command.endsWith(" pdfmark end")) {
|
||||
if (!currentlyDrawnPage->hyperLinkList.isEmpty()) {
|
||||
QString targetName = special_command.section('(', 1, 1).section(')', 0, 0);
|
||||
Q3ValueVector<Hyperlink>::iterator it;
|
||||
QVector<Hyperlink>::iterator it;
|
||||
for( it = currentlyDrawnPage->hyperLinkList.begin(); it != currentlyDrawnPage->hyperLinkList.end(); ++it )
|
||||
if (it->linkText == "glopglyph")
|
||||
it->linkText = targetName;
|
||||
|
|
Loading…
Reference in a new issue