Commit 6b6a1110 authored by Pino Toscano's avatar Pino Toscano

Make the poppler(pdf), spectre(ps), dvi and chm backend calculate and set bounding box of pages.

CCBUG: 161599

svn path=/trunk/KDE/kdegraphics/okular/; revision=809593
parent 2b971b07
......@@ -28,6 +28,7 @@
#include <okular/core/observer.h> //for PAGEVIEW_ID
#include <okular/core/page.h>
#include <okular/core/textpage.h>
#include <okular/core/utils.h>
static KAboutData createAboutData()
{
......@@ -182,6 +183,8 @@ void CHMGenerator::slotCompleted()
Okular::PixmapRequest *req = m_request;
m_request = 0;
if ( !req->page()->isBoundingBoxKnown() )
updatePageBoundingBox( req->page()->number(), Okular::Utils::imageBoundingBox( &image ) );
req->page()->setPixmap( req->id(), new QPixmap( QPixmap::fromImage( image ) ) );
signalPixmapRequestDone( req );
}
......
......@@ -203,6 +203,9 @@ void DviGenerator::generatePixmap( Okular::PixmapRequest *request )
{
kDebug(DviDebug) << "Image OK";
if ( !request->page()->isBoundingBoxKnown() )
updatePageBoundingBox( request->page()->number(), Okular::Utils::imageBoundingBox( &(pageInfo->img) ) );
request->page()->setPixmap( request->id(), new QPixmap( QPixmap::fromImage( pageInfo->img ) ) );
request->page()->setObjectRects( generateDviLinks( pageInfo ) );
......
......@@ -38,6 +38,7 @@
#include <okular/core/sourcereference.h>
#include <okular/core/textpage.h>
#include <okular/core/fileprinter.h>
#include <okular/core/utils.h>
#include <config-okular-poppler.h>
......@@ -736,8 +737,14 @@ void PDFGenerator::generatePixmap( Okular::PixmapRequest * request )
Poppler::Page *p = pdfdoc->page(page->number());
// 2. Take data from outputdev and attach it to the Page
page->setPixmap( request->id(), new QPixmap( QPixmap::fromImage( p->renderToImage(fakeDpiX, fakeDpiY, -1, -1, -1, -1, Poppler::Page::Rotate0 ) ) ) );
{
QImage img( p->renderToImage(fakeDpiX, fakeDpiY, -1, -1, -1, -1, Poppler::Page::Rotate0 ) );
if ( !page->isBoundingBoxKnown() )
updatePageBoundingBox( page->number(), Okular::Utils::imageBoundingBox( &img ) );
page->setPixmap( request->id(), new QPixmap( QPixmap::fromImage( img ) ) );
}
if ( genObjectRects )
{
// TODO previously we extracted Image type rects too, but that needed porting to poppler
......@@ -1573,6 +1580,8 @@ void PDFGenerator::threadFinished()
QList<Poppler::TextBox*> outText = generatorThread->takeText();
QLinkedList< Okular::ObjectRect * > outRects = generatorThread->takeObjectRects();
if ( !request->page()->isBoundingBoxKnown() )
updatePageBoundingBox( request->page()->number(), Okular::Utils::imageBoundingBox( outImage ) );
request->page()->setPixmap( request->id(), new QPixmap( QPixmap::fromImage( *outImage ) ) );
delete outImage;
if ( !outText.isEmpty() )
......
......@@ -26,6 +26,7 @@
#include <okular/core/document.h>
#include <okular/core/page.h>
#include <okular/core/fileprinter.h>
#include <okular/core/utils.h>
#include "ui_gssettingswidget.h"
#include "gssettings.h"
......@@ -180,6 +181,9 @@ void GSGenerator::slotImageGenerated(QImage *img, Okular::PixmapRequest *request
// of all the generators attached to it
if (request != m_request) return;
if ( !request->page()->isBoundingBoxKnown() )
updatePageBoundingBox( request->page()->number(), Okular::Utils::imageBoundingBox( img ) );
m_request = 0;
QPixmap *pix = new QPixmap(QPixmap::fromImage(*img));
delete img;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment