Commit 3f4bf880 authored by Albert Astals Cid's avatar Albert Astals Cid

* qt4/src/Makefile.am:

       * qt4/src/poppler-link-extractor-private.h:
       * qt4/src/poppler-link-extractor.cc:
       * qt4/src/poppler-page-private.h:
       * qt4/src/poppler-page.cc:
       * qt4/src/poppler-private.h:
       * qt4/src/poppler-qt4.h:
       Getting the links of a page now is not more dependant on the current
       output device, and can be done anytime; thus, the doLinks parameter
       of the Page::render() can be dropped.
parent 7f9eec9e
2007-04-28 Pino Toscano <pino@kde.org>
* qt4/src/Makefile.am:
* qt4/src/poppler-link-extractor-private.h:
* qt4/src/poppler-link-extractor.cc:
* qt4/src/poppler-page-private.h:
* qt4/src/poppler-page.cc:
* qt4/src/poppler-private.h:
* qt4/src/poppler-qt4.h:
Getting the links of a page now is not more dependant on the current
output device, and can be done anytime; thus, the doLinks parameter
of the Page::render() can be dropped.
2007-04-28 Albert Astals Cid <aacid@kde.org>
* qt4/*: Stop requyring users to declare UNSTABLE_POPPLER_QT4
......
......@@ -24,9 +24,10 @@ libpoppler_qt4_la_SOURCES = \
poppler-textbox.cc \
poppler-link.cc \
poppler-annotation.cc \
poppler-link-extractor.cc \
../../qt/poppler-page-transition.cc \
poppler-sound.cc \
poppler-form.cc \
poppler-form.cc \
poppler-annotation-helper.h \
poppler-private.h
......
/* poppler-link-extractor_p.h: qt interface to poppler
* Copyright (C) 2007, Pino Toscano <pino@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, 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 _POPPLER_LINK_EXTRACTOR_H_
#define _POPPLER_LINK_EXTRACTOR_H_
#include <OutputDev.h>
#include <QtCore/QList>
namespace Poppler
{
class PageData;
class DocumentData;
class LinkExtractorOutputDev : public OutputDev
{
public:
LinkExtractorOutputDev(PageData *data, DocumentData *doc);
virtual ~LinkExtractorOutputDev();
// inherited from OutputDev
virtual GBool upsideDown() { return gFalse; }
virtual GBool useDrawChar() { return gFalse; }
virtual GBool interpretType3Chars() { return gFalse; }
virtual void processLink(::Link *link, Catalog *catalog);
// our stuff
QList< Link* > links();
private:
PageData *m_data;
DocumentData *m_doc;
QList< Link* > m_links;
};
}
#endif
/* poppler-link-extractor_p.h: qt interface to poppler
* Copyright (C) 2007, Pino Toscano <pino@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, 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.
*/
#include <Object.h>
#include "poppler-qt4.h"
#include "poppler-link-extractor-private.h"
#include "poppler-page-private.h"
#include "poppler-private.h"
namespace Poppler
{
LinkExtractorOutputDev::LinkExtractorOutputDev(PageData *data, DocumentData *doc)
: m_data(data), m_doc(doc)
{
::Page *p = m_doc->doc->getCatalog()->getPage(m_data->index + 1);
GfxState gfxState(72.0, 72.0, p->getMediaBox(), p->getRotate(), gTrue);
setDefaultCTM(gfxState.getCTM());
}
LinkExtractorOutputDev::~LinkExtractorOutputDev()
{
qDeleteAll(m_links);
}
void LinkExtractorOutputDev::processLink(::Link *link, Catalog *catalog)
{
if (!link->isOk() || !m_data)
return;
double left, top, right, bottom;
int leftAux, topAux, rightAux, bottomAux;
link->getRect(&left, &top, &right, &bottom);
QRectF linkArea;
cvtUserToDev(left, top, &leftAux, &topAux);
cvtUserToDev(right, bottom, &rightAux, &bottomAux);
linkArea.setLeft(leftAux);
linkArea.setTop(topAux);
linkArea.setRight(rightAux);
linkArea.setBottom(bottomAux);
Link *popplerLink = m_data->convertLinkActionToLink(link->getAction(), linkArea, m_doc);
if (popplerLink)
{
m_links.append(popplerLink);
}
OutputDev::processLink(link, catalog);
}
QList< Link* > LinkExtractorOutputDev::links()
{
QList< Link* > ret = m_links;
m_links.clear();
return ret;
}
}
/* poppler-page.cc: qt interface to poppler
* Copyright (C) 2005, Net Integration Technologies, Inc.
*
* 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, 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 _POPPLER_PAGE_PRIVATE_H_
#define _POPPLER_PAGE_PRIVATE_H_
#include "poppler-private.h"
namespace Poppler
{
class PageData {
public:
Link* convertLinkActionToLink(::LinkAction * a, const QRectF &linkArea, DocumentData * doc);
const Document *parentDoc;
int index;
PageTransition *transition;
};
}
#endif
......@@ -36,20 +36,13 @@
#include "poppler-private.h"
#include "poppler-page-transition-private.h"
#include "poppler-page-private.h"
#include "poppler-link-extractor-private.h"
#include "poppler-annotation-helper.h"
#include "poppler-form.h"
namespace Poppler {
class PageData {
public:
Link* convertLinkActionToLink(::LinkAction * a, const QRectF &linkArea, DocumentData * doc);
const Document *parentDoc;
int index;
PageTransition *transition;
};
Link* PageData::convertLinkActionToLink(::LinkAction * a, const QRectF &linkArea, DocumentData * doc)
{
if ( !a )
......@@ -165,7 +158,7 @@ Page::~Page()
delete m_page;
}
QImage Page::renderToImage(double xres, double yres, int x, int y, int w, int h, bool doLinks, Rotation rotate) const
QImage Page::renderToImage(double xres, double yres, int x, int y, int w, int h, Rotation rotate) const
{
int rotation = (int)rotate * 90;
QImage img;
......@@ -177,7 +170,7 @@ QImage Page::renderToImage(double xres, double yres, int x, int y, int w, int h,
SplashOutputDev *splash_output = static_cast<SplashOutputDev *>(m_page->parentDoc->m_doc->getOutputDev());
m_page->parentDoc->m_doc->doc->displayPageSlice(splash_output, m_page->index + 1, xres, yres,
rotation, false, true, doLinks, x, y, w, h);
rotation, false, true, false, x, y, w, h);
SplashBitmap *bitmap = splash_output->getBitmap();
int bw = bitmap->getWidth();
......@@ -231,7 +224,7 @@ QImage Page::renderToImage(double xres, double yres, int x, int y, int w, int h,
rotation,
false,
true,
doLinks,
false,
x,
y,
w,
......@@ -463,39 +456,10 @@ void Page::defaultCTM(double *CTM, double dpiX, double dpiY, int rotate, bool up
QList<Link*> Page::links() const
{
QList<Link*> popplerLinks;
OutputDev *output_dev = m_page->parentDoc->m_doc->getOutputDev();
if (output_dev == NULL)
return popplerLinks;
Links *xpdfLinks = m_page->parentDoc->m_doc->doc->getLinks(m_page->index + 1);
for (int i = 0; i < xpdfLinks->getNumLinks(); ++i)
{
::Link *xpdfLink = xpdfLinks->getLink(i);
double left, top, right, bottom;
int leftAux, topAux, rightAux, bottomAux;
xpdfLink->getRect( &left, &top, &right, &bottom );
QRectF linkArea;
output_dev->cvtUserToDev( left, top, &leftAux, &topAux );
output_dev->cvtUserToDev( right, bottom, &rightAux, &bottomAux );
linkArea.setLeft(leftAux);
linkArea.setTop(topAux);
linkArea.setRight(rightAux);
linkArea.setBottom(bottomAux);
LinkExtractorOutputDev link_dev(m_page, m_page->parentDoc->m_doc);
m_page->parentDoc->m_doc->doc->processLinks(&link_dev, m_page->index + 1);
QList<Link*> popplerLinks = link_dev.links();
if (!xpdfLink->isOk()) continue;
Link *popplerLink = m_page->convertLinkActionToLink(xpdfLink->getAction(), linkArea, m_page->parentDoc->m_doc);
if (popplerLink)
{
popplerLinks.append(popplerLink);
}
}
delete xpdfLinks;
return popplerLinks;
}
......
......@@ -20,6 +20,9 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _POPPLER_PRIVATE_H_
#define _POPPLER_PRIVATE_H_
#include <config.h>
#include <GfxState.h>
#include <GlobalParams.h>
......@@ -366,4 +369,4 @@ namespace Poppler {
}
#endif
......@@ -266,8 +266,6 @@ namespace Poppler {
\param yres vertical resolution of the graphics device, in
dots per inch
\param doLinks calculate links
\param rotate how to rotate the page
\warning The parameter (\p x, \p y, \p w, \p h) are not
......@@ -276,7 +274,7 @@ namespace Poppler {
\returns a QImage of the page, or a null image on failure.
*/
QImage renderToImage(double xres=72.0, double yres=72.0, int x=-1, int y=-1, int w=-1, int h=-1, bool doLinks = false, Rotation rotate = Rotate0) const;
QImage renderToImage(double xres=72.0, double yres=72.0, int x=-1, int y=-1, int w=-1, int h=-1, Rotation rotate = Rotate0) const;
/**
Returns the text that is inside a specified rectangle
......
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