Commit fefefe49 authored by Albert Astals Cid's avatar Albert Astals Cid

* qt4/src/poppler-link-extractor-private.cc:

        * qt4/src/poppler-link-extractor-private.h:
        * qt4/src/poppler-link.cc:
        * qt4/src/poppler-link.h: Return link coordinates in 0..1 range
        instead of 0..size, much more easier to do user<->dev transformations
        * qt4/src/poppler-private.h: Fix indentation
parent ecaeaa95
......@@ -2,6 +2,12 @@
* qt4/src/poppler-link-extractor.cc: Use correct page box to extract
link clickable area
* qt4/src/poppler-link-extractor-private.cc:
* qt4/src/poppler-link-extractor-private.h:
* qt4/src/poppler-link.cc:
* qt4/src/poppler-link.h: Return link coordinates in 0..1 range
instead of 0..size, much more easier to do user<->dev transformations
* qt4/src/poppler-private.h: Fix indentation
2007-05-25 Jeff Muizelaar <jeff@infidigm.net>
......
......@@ -45,6 +45,7 @@ class LinkExtractorOutputDev : public OutputDev
QList< Link* > links();
private:
::Page *m_popplerPage;
PageData *m_data;
DocumentData *m_doc;
QList< Link* > m_links;
......
......@@ -29,8 +29,8 @@ 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->getCropBox(), p->getRotate(), gTrue);
m_popplerPage = m_doc->doc->getCatalog()->getPage(m_data->index + 1);
GfxState gfxState(72.0, 72.0, m_popplerPage->getCropBox(), m_popplerPage->getRotate(), gTrue);
setDefaultCTM(gfxState.getCTM());
}
......@@ -51,10 +51,10 @@ void LinkExtractorOutputDev::processLink(::Link *link, Catalog *catalog)
cvtUserToDev(left, top, &leftAux, &topAux);
cvtUserToDev(right, bottom, &rightAux, &bottomAux);
linkArea.setLeft(leftAux);
linkArea.setTop(topAux);
linkArea.setRight(rightAux);
linkArea.setBottom(bottomAux);
linkArea.setLeft((double)leftAux / (double)m_popplerPage->getCropWidth());
linkArea.setTop((double)topAux / (double)m_popplerPage->getCropHeight());
linkArea.setRight((double)rightAux / (double)m_popplerPage->getCropWidth());
linkArea.setBottom((double)bottomAux / (double)m_popplerPage->getCropHeight());
Link *popplerLink = m_data->convertLinkActionToLink(link->getAction(), linkArea, m_doc);
if (popplerLink)
......
......@@ -27,6 +27,14 @@
namespace Poppler {
static void cvtUserToDev(::Page *page, double xu, double yu, int *xd, int *yd) {
double ctm[6];
page->getDefaultCTM(ctm, 72.0, 72.0, 0, false, true);
*xd = (int)(ctm[0] * xu + ctm[2] * yu + ctm[4] + 0.5);
*yd = (int)(ctm[1] * xu + ctm[3] * yu + ctm[5] + 0.5);
}
LinkDestination::LinkDestination(const LinkDestinationData &data)
{
// sane defaults
......@@ -78,17 +86,14 @@ namespace Poppler {
int leftAux = 0, topAux = 0, rightAux = 0, bottomAux = 0;
OutputDev *sod = data.doc->getOutputDev();
if (sod)
{
sod->cvtUserToDev( left, top, &leftAux, &topAux );
sod->cvtUserToDev( right, bottom, &rightAux, &bottomAux );
}
::Page *page = data.doc->doc->getCatalog()->getPage(m_pageNum);
cvtUserToDev( page, left, top, &leftAux, &topAux );
cvtUserToDev( page, right, bottom, &rightAux, &bottomAux );
m_left = leftAux;
m_top = topAux;
m_right = rightAux;
m_bottom = bottomAux;
m_left = leftAux / (double)page->getCropWidth();
m_top = topAux / (double)page->getCropHeight();
m_right = rightAux/ (double)page->getCropWidth();
m_bottom = bottomAux / (double)page->getCropHeight();
if (deleteDest) delete ld;
}
......
......@@ -29,6 +29,11 @@ namespace Poppler {
class LinkDestinationData;
class SoundObject;
/**
* \short Encapsulates data that describes a link destination.
*
* Coordinates are in 0..1 range
*/
class LinkDestination
{
public:
......@@ -112,7 +117,7 @@ class Link
* The area of a Page where the link should be active.
*
* \note this can be a null rect, in this case the link represents
* a general action
* a general action. The area is given in 0..1 range
*/
QRectF linkArea() const;
......
......@@ -99,13 +99,14 @@ namespace Poppler {
class LinkDestinationData
{
public:
LinkDestinationData( LinkDest *l, GooString *nd, Poppler::DocumentData *pdfdoc ) : ld(l), namedDest(nd), doc(pdfdoc)
{
}
LinkDest *ld;
GooString *namedDest;
Poppler::DocumentData *doc;
LinkDestinationData( LinkDest *l, GooString *nd, Poppler::DocumentData *pdfdoc )
: ld(l), namedDest(nd), doc(pdfdoc)
{
}
LinkDest *ld;
GooString *namedDest;
Poppler::DocumentData *doc;
};
class DocumentData {
......
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