diff options
Diffstat (limited to 'Build/source/libs/xpdf/xpdf-src/xpdf/PDFCore.cc')
-rw-r--r-- | Build/source/libs/xpdf/xpdf-src/xpdf/PDFCore.cc | 129 |
1 files changed, 78 insertions, 51 deletions
diff --git a/Build/source/libs/xpdf/xpdf-src/xpdf/PDFCore.cc b/Build/source/libs/xpdf/xpdf-src/xpdf/PDFCore.cc index b833d5dabf0..baf2353de1c 100644 --- a/Build/source/libs/xpdf/xpdf-src/xpdf/PDFCore.cc +++ b/Build/source/libs/xpdf/xpdf-src/xpdf/PDFCore.cc @@ -8,10 +8,6 @@ #include <aconf.h> -#ifdef USE_GCC_PRAGMAS -#pragma implementation -#endif - #include <math.h> #include "gmempp.h" #include "GString.h" @@ -47,9 +43,6 @@ PDFCore::PDFCore(SplashColorMode colorMode, int bitmapRowPad, linksPage = 0; links = NULL; - annotsPage = 0; - annots = NULL; - textPage = 0; textDPI = 0; textRotate = 0; @@ -116,6 +109,7 @@ PDFCore::~PDFCore() { delete state; clearPage(); if (doc) { + aboutToDeleteDoc(); delete doc; } for (i = 0; i < pdfHistorySize; ++i) { @@ -201,6 +195,7 @@ int PDFCore::loadFile2(PDFDoc *newDoc) { // NB: do not delete doc until after DisplayState::setDoc() returns state->setDoc(newDoc); if (doc) { + aboutToDeleteDoc(); delete doc; } doc = newDoc; @@ -219,6 +214,7 @@ void PDFCore::clear() { // no document // NB: do not delete doc until after DisplayState::setDoc() returns state->setDoc(NULL); + aboutToDeleteDoc(); delete doc; doc = NULL; clearPage(); @@ -300,6 +296,8 @@ void PDFCore::displayDest(LinkDest *dest) { page = 1; } + GBool changeZoom = globalParams->getAllowLinksToChangeZoom(); + switch (dest->getKind()) { case destXYZ: cvtUserToDev(page, dest->getLeft(), dest->getTop(), &dx, &dy); @@ -317,7 +315,9 @@ void PDFCore::displayDest(LinkDest *dest) { break; case destFit: case destFitB: - state->setZoom(zoomPage); + if (changeZoom) { + state->setZoom(zoomPage); + } scrollX = tileMap->getPageLeftX(page); scrollY = tileMap->getPageTopY(page); startUpdate(); @@ -326,7 +326,9 @@ void PDFCore::displayDest(LinkDest *dest) { break; case destFitH: case destFitBH: - state->setZoom(zoomWidth); + if (changeZoom) { + state->setZoom(zoomWidth); + } scrollX = tileMap->getPageLeftX(page); scrollY = tileMap->getPageTopY(page); if (dest->getChangeTop()) { @@ -339,7 +341,9 @@ void PDFCore::displayDest(LinkDest *dest) { break; case destFitV: case destFitBV: - state->setZoom(zoomHeight); + if (changeZoom) { + state->setZoom(zoomHeight); + } scrollX = tileMap->getPageLeftX(page); scrollY = tileMap->getPageTopY(page); if (dest->getChangeTop()) { @@ -351,8 +355,13 @@ void PDFCore::displayDest(LinkDest *dest) { finishUpdate(gTrue, gTrue); break; case destFitR: - zoomToRect(page, dest->getLeft(), dest->getTop(), - dest->getRight(), dest->getBottom()); + if (changeZoom) { + zoomToRect(page, dest->getLeft(), dest->getTop(), + dest->getRight(), dest->getBottom()); + } else { + scrollToCentered(page, 0.5 * (dest->getLeft() + dest->getRight()), + 0.5 * (dest->getTop(), dest->getBottom())); + } break; } } @@ -426,9 +435,16 @@ void PDFCore::finishUpdate(GBool addToHist, GBool checkForChangedFile) { // tileDone or tick (incremental update) to avoid "flashing" the // screen (drawing a blank background, followed by the actual // content slightly later) - getWindowBitmap(gTrue); - if (bitmapFinished) { + // - this postponement actually causes flickering in certain cases + // (the Qt QML backend) -- don't do it if alwaysInvalidateOnUpdate() + // returns true + if (alwaysInvalidateOnUpdate()) { invalidateWholeWindow(); + } else { + getWindowBitmap(gTrue); + if (bitmapFinished) { + invalidateWholeWindow(); + } } updateScrollbars(); @@ -1637,6 +1653,50 @@ GList *PDFCore::findAll(Unicode *u, int len, GBool caseSensitive, return results; } +GList *AsyncFindAll::run(PDFDoc *doc, Unicode *u, int len, GBool caseSensitive, + GBool wholeWord, int firstPage, int lastPage) { + GList *results = new GList(); + + TextOutputDev *textOut = new TextOutputDev(NULL, &core->textOutCtrl, gFalse); + if (!textOut->isOk()) { + delete textOut; + return results; + } + + for (int pg = firstPage; pg <= lastPage && !canceled; ++pg) { + doc->displayPage(textOut, pg, 72, 72, 0, gFalse, gTrue, gFalse); + GBool first = gTrue; + while (!canceled) { + double xMin, yMin, xMax, yMax; + if (!textOut->findText(u, len, first, gTrue, !first, gFalse, + caseSensitive, gFalse, wholeWord, + &xMin, &yMin, &xMax, &yMax)) { + break; + } + double uxMin, uyMin, uxMax, uyMax, t; + textOut->cvtDevToUser(xMin, yMin, &uxMin, &uyMin); + textOut->cvtDevToUser(xMax, yMax, &uxMax, &uyMax); + if (uxMin > uxMax) { + t = uxMin; uxMin = uxMax; uxMax = t; + } + if (uyMin > uyMax) { + t = uyMin; uyMin = uyMax; uyMax = t; + } + results->append(new FindResult(pg, uxMin, uyMin, uxMax, uyMax)); + first = gFalse; + } + } + + delete textOut; + + if (canceled) { + deleteGList(results, FindResult); + return NULL; + } + + return results; +} + GBool PDFCore::cvtWindowToUser(int xw, int yw, int *pg, double *xu, double *yu) { @@ -1751,23 +1811,11 @@ LinkAction *PDFCore::findLink(int pg, double x, double y) { } Annot *PDFCore::findAnnot(int pg, double x, double y) { - loadAnnots(pg); - return annots->find(x, y); + return doc->getAnnots()->find(pg, x, y); } int PDFCore::findAnnotIdx(int pg, double x, double y) { - loadAnnots(pg); - return annots->findIdx(x, y); -} - -Annot *PDFCore::getAnnot(int idx) { - if (!annots) { - return NULL; - } - if (idx < 0 || idx >= annots->getNumAnnots()) { - return NULL; - } - return annots->getAnnot(idx); + return doc->getAnnots()->findIdx(pg, x, y); } AcroFormField *PDFCore::findFormField(int pg, double x, double y) { @@ -1816,7 +1864,8 @@ void PDFCore::setWindowSize(int winWidth, int winHeight) { startUpdate(); - wx0 = wy0 = 0; // make gcc happy + page = wx0 = wy0 = 0; // make gcc happy + ux = uy = 0; doScroll = gFalse; if (state->getZoom() < 0 && state->displayModeIsContinuous()) { // save the user coordinates of the appropriate edge of the window @@ -1879,12 +1928,6 @@ void PDFCore::clearPage() { links = NULL; linksPage = 0; - if (annots) { - delete annots; - } - annots = NULL; - annotsPage = 0; - if (text) { delete text; } @@ -1906,22 +1949,6 @@ void PDFCore::loadLinks(int pg) { linksPage = pg; } -// Load the annotations for <pg>. -void PDFCore::loadAnnots(int pg) { - Object annotsObj; - - if (annots && annotsPage == pg) { - return; - } - if (annots) { - delete annots; - } - doc->getCatalog()->getPage(pg)->getAnnots(&annotsObj); - annots = new Annots(doc, &annotsObj); - annotsObj.free(); - annotsPage = pg; -} - // Extract text from <pg>. void PDFCore::loadText(int pg) { TextOutputDev *textOut; |