[poppler] poppler/qt4/src: Makefile.am, 1.18, 1.19 poppler-link-extractor-private.h, NONE, 1.1 poppler-link-extractor.cc, NONE, 1.1 poppler-page-private.h, NONE, 1.1 poppler-page.cc, 1.39, 1.40 poppler-private.h, 1.25, 1.26 poppler-qt4.h, 1.49, 1.50

Albert Astals Cid aacid at kemper.freedesktop.org
Sat Apr 28 04:16:52 PDT 2007


Update of /cvs/poppler/poppler/qt4/src
In directory kemper:/tmp/cvs-serv23949/qt4/src

Modified Files:
	Makefile.am poppler-page.cc poppler-private.h poppler-qt4.h 
Added Files:
	poppler-link-extractor-private.h poppler-link-extractor.cc 
	poppler-page-private.h 
Log Message:
       * 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.


Index: Makefile.am
===================================================================
RCS file: /cvs/poppler/poppler/qt4/src/Makefile.am,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- Makefile.am	4 Mar 2007 07:30:32 -0000	1.18
+++ Makefile.am	28 Apr 2007 11:16:49 -0000	1.19
@@ -24,9 +24,10 @@
 	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
 

--- NEW FILE: poppler-link-extractor-private.h ---
/* poppler-link-extractor_p.h: qt interface to poppler
 * Copyright (C) 2007, Pino Toscano <pino at 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

--- NEW FILE: poppler-link-extractor.cc ---
/* poppler-link-extractor_p.h: qt interface to poppler
 * Copyright (C) 2007, Pino Toscano <pino at 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;
}

}

--- NEW FILE: poppler-page-private.h ---
/* 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

Index: poppler-page.cc
===================================================================
RCS file: /cvs/poppler/poppler/qt4/src/poppler-page.cc,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- poppler-page.cc	27 Apr 2007 22:41:10 -0000	1.39
+++ poppler-page.cc	28 Apr 2007 11:16:49 -0000	1.40
@@ -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 @@
   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 @@
       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 @@
 						 rotation,
 						 false,
 						 true,
-						 doLinks,
+						 false,
 						 x,
 						 y,
 						 w,
@@ -463,39 +456,10 @@
 
 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);
-
-    if (!xpdfLink->isOk()) continue;
-
-    Link *popplerLink = m_page->convertLinkActionToLink(xpdfLink->getAction(), linkArea, m_page->parentDoc->m_doc);
-    if (popplerLink)
-    {
-      popplerLinks.append(popplerLink);
-    }
-  }
+  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();
 
-  delete xpdfLinks;
-  
   return popplerLinks;
 }
 

Index: poppler-private.h
===================================================================
RCS file: /cvs/poppler/poppler/qt4/src/poppler-private.h,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- poppler-private.h	25 Apr 2007 21:25:06 -0000	1.25
+++ poppler-private.h	28 Apr 2007 11:16:49 -0000	1.26
@@ -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 @@
 
 }
 
-
+#endif

Index: poppler-qt4.h
===================================================================
RCS file: /cvs/poppler/poppler/qt4/src/poppler-qt4.h,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -d -r1.49 -r1.50
--- poppler-qt4.h	27 Apr 2007 22:41:10 -0000	1.49
+++ poppler-qt4.h	28 Apr 2007 11:16:49 -0000	1.50
@@ -266,8 +266,6 @@
 	   \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 @@
 
 	   \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



More information about the poppler mailing list