[poppler] Branch 'poppler-0.12' - configure.ac qt4/src splash/SplashMath.h splash/SplashScreen.cc splash/SplashScreen.h utils/pdftoppm.cc

Albert Astals Cid aacid at kemper.freedesktop.org
Tue Nov 17 11:35:09 PST 2009


 configure.ac                  |   60 ++++++++++++++----------------
 qt4/src/poppler-annotation.cc |   82 +++++++++++++++++++++---------------------
 splash/SplashMath.h           |    5 +-
 splash/SplashScreen.cc        |   21 +++++++++-
 splash/SplashScreen.h         |    2 +
 utils/pdftoppm.cc             |    8 ++++
 6 files changed, 102 insertions(+), 76 deletions(-)

New commits:
commit 3e59f5666c0521db85b3a8a6f05ecb07e45c1b87
Author: Albert Astals Cid <aacid at kde.org>
Date:   Tue Nov 17 20:34:24 2009 +0100

    do not use setAttribute with doubles
    
    it is evil and locale dependant, we do NOT want that so use QString::number

diff --git a/configure.ac b/configure.ac
index 6593cfd..608467d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -109,6 +109,35 @@ fi
 dnl ##### Checks for library functions.
 AC_CHECK_FUNCS(popen mkstemp mkstemps)
 
+dnl Test for libopenjpeg
+AC_ARG_ENABLE(libopenjpeg,
+	      AC_HELP_STRING([--disable-libopenjpeg],
+	                     [Don't build against libopenjpeg.]),
+              enable_libopenjpeg=$enableval,
+              enable_libopenjpeg="try")
+if test x$enable_libopenjpeg = xyes; then
+  AC_CHECK_LIB([openjpeg], [opj_cio_open],,
+	       AC_MSG_ERROR("*** libopenjpeg library not found ***"))
+  AC_CHECK_HEADERS([openjpeg.h],,
+		   AC_MSG_ERROR("*** libopenjpeg headers not found ***"))
+elif test x$enable_libopenjpeg = xtry; then
+  AC_CHECK_LIB([openjpeg], [opj_cio_open],
+               [enable_libopenjpeg="yes"],
+	       [enable_libopenjpeg="no"])
+  AC_CHECK_HEADERS([openjpeg.h],,
+		   [enable_libopenjpeg="no"])
+fi
+
+if test x$enable_libopenjpeg = xyes; then
+  LIBOPENJPEG_LIBS="-lopenjpeg"
+  AC_SUBST(LIBOPENJPEG_LIBS)
+  AC_DEFINE(ENABLE_LIBOPENJPEG)
+fi
+
+AM_CONDITIONAL(BUILD_LIBOPENJPEG, test x$enable_libopenjpeg = xyes)
+AH_TEMPLATE([ENABLE_LIBOPENJPEG],
+	    [Use libopenjpeg instead of builtin jpeg2000 decoder.])
+
 dnl ##### Back to C for the library tests.
 AC_LANG_C
 
@@ -150,37 +179,6 @@ AH_TEMPLATE([ENABLE_ZLIB],
 	    [Use zlib instead of builtin zlib decoder.])
 
 
-dnl Test for libopenjpeg
-AC_ARG_ENABLE(libopenjpeg,
-	      AC_HELP_STRING([--disable-libopenjpeg],
-	                     [Don't build against libopenjpeg.]),
-              enable_libopenjpeg=$enableval,
-              enable_libopenjpeg="try")
-if test x$enable_libopenjpeg = xyes; then
-  AC_CHECK_LIB([openjpeg], [opj_cio_open],,
-	       AC_MSG_ERROR("*** libopenjpeg library not found ***"))
-  AC_CHECK_HEADERS([openjpeg.h],,
-		   AC_MSG_ERROR("*** libopenjpeg headers not found ***"))
-elif test x$enable_libopenjpeg = xtry; then
-  AC_CHECK_LIB([openjpeg], [opj_cio_open],
-               [enable_libopenjpeg="yes"],
-	       [enable_libopenjpeg="no"])
-  AC_CHECK_HEADERS([openjpeg.h],,
-		   [enable_libopenjpeg="no"])
-fi
-
-if test x$enable_libopenjpeg = xyes; then
-  LIBOPENJPEG_LIBS="-lopenjpeg"
-  AC_SUBST(LIBOPENJPEG_LIBS)
-  AC_DEFINE(ENABLE_LIBOPENJPEG)
-fi
-
-AM_CONDITIONAL(BUILD_LIBOPENJPEG, test x$enable_libopenjpeg = xyes)
-AH_TEMPLATE([ENABLE_LIBOPENJPEG],
-	    [Use libopenjpeg instead of builtin jpeg2000 decoder.])
-
-
-
 dnl Test for libjpeg
 AC_ARG_ENABLE(libjpeg,
 	      AC_HELP_STRING([--disable-libjpeg],
diff --git a/qt4/src/poppler-annotation.cc b/qt4/src/poppler-annotation.cc
index b8b6a52..22f1e6a 100644
--- a/qt4/src/poppler-annotation.cc
+++ b/qt4/src/poppler-annotation.cc
@@ -1,5 +1,5 @@
 /* poppler-annotation.cc: qt interface to poppler
- * Copyright (C) 2006, Albert Astals Cid <aacid at kde.org>
+ * Copyright (C) 2006, 2009 Albert Astals Cid <aacid at kde.org>
  * Copyright (C) 2006, 2008 Pino Toscano <pino at kde.org>
  * Adapting code from
  *   Copyright (C) 2004 by Enrico Ros <eros.kde at email.it>
@@ -267,15 +267,15 @@ void Annotation::store( QDomNode & annNode, QDomDocument & document ) const
     if ( style.color.isValid() && style.color != Qt::black )
         e.setAttribute( "color", style.color.name() );
     if ( style.opacity != 1.0 )
-        e.setAttribute( "opacity", style.opacity );
+        e.setAttribute( "opacity", QString::number( style.opacity ) );
 
     // Sub-Node-1 - boundary
     QDomElement bE = document.createElement( "boundary" );
     e.appendChild( bE );
-    bE.setAttribute( "l", (double)d->boundary.left() );
-    bE.setAttribute( "t", (double)d->boundary.top() );
-    bE.setAttribute( "r", (double)d->boundary.right() );
-    bE.setAttribute( "b", (double)d->boundary.bottom() );
+    bE.setAttribute( "l", QString::number( (double)d->boundary.left() ) );
+    bE.setAttribute( "t", QString::number( (double)d->boundary.top() ) );
+    bE.setAttribute( "r", QString::number( (double)d->boundary.right() ) );
+    bE.setAttribute( "b", QString::number( (double)d->boundary.bottom() ) );
 
     // Sub-Node-2 - penStyle
     if ( style.width != 1 || style.style != Solid || style.xCorners != 0 ||
@@ -283,10 +283,10 @@ void Annotation::store( QDomNode & annNode, QDomDocument & document ) const
     {
         QDomElement psE = document.createElement( "penStyle" );
         e.appendChild( psE );
-        psE.setAttribute( "width", style.width );
+        psE.setAttribute( "width", QString::number( style.width ) );
         psE.setAttribute( "style", (int)style.style );
-        psE.setAttribute( "xcr", style.xCorners );
-        psE.setAttribute( "ycr", style.yCorners );
+        psE.setAttribute( "xcr", QString::number( style.xCorners ) );
+        psE.setAttribute( "ycr", QString::number( style.yCorners ) );
         psE.setAttribute( "marks", style.marks );
         psE.setAttribute( "spaces", style.spaces );
     }
@@ -297,7 +297,7 @@ void Annotation::store( QDomNode & annNode, QDomDocument & document ) const
         QDomElement peE = document.createElement( "penEffect" );
         e.appendChild( peE );
         peE.setAttribute( "effect", (int)style.effect );
-        peE.setAttribute( "intensity", style.effectIntensity );
+        peE.setAttribute( "intensity", QString::number( style.effectIntensity ) );
     }
 
     // Sub-Node-4 - window
@@ -307,8 +307,8 @@ void Annotation::store( QDomNode & annNode, QDomDocument & document ) const
         QDomElement wE = document.createElement( "window" );
         e.appendChild( wE );
         wE.setAttribute( "flags", window.flags );
-        wE.setAttribute( "top", window.topLeft.x() );
-        wE.setAttribute( "left", window.topLeft.y() );
+        wE.setAttribute( "top", QString::number( window.topLeft.x() ) );
+        wE.setAttribute( "left", QString::number( window.topLeft.y() ) );
         wE.setAttribute( "width", window.width );
         wE.setAttribute( "height", window.height );
         wE.setAttribute( "title", window.title );
@@ -563,12 +563,12 @@ void TextAnnotation::store( QDomNode & node, QDomDocument & document ) const
     {
         QDomElement calloutElement = document.createElement( "callout" );
         textElement.appendChild( calloutElement );
-        calloutElement.setAttribute( "ax", d->inplaceCallout[0].x() );
-        calloutElement.setAttribute( "ay", d->inplaceCallout[0].y() );
-        calloutElement.setAttribute( "bx", d->inplaceCallout[1].x() );
-        calloutElement.setAttribute( "by", d->inplaceCallout[1].y() );
-        calloutElement.setAttribute( "cx", d->inplaceCallout[2].x() );
-        calloutElement.setAttribute( "cy", d->inplaceCallout[2].y() );
+        calloutElement.setAttribute( "ax", QString::number( d->inplaceCallout[0].x() ) );
+        calloutElement.setAttribute( "ay", QString::number( d->inplaceCallout[0].y() ) );
+        calloutElement.setAttribute( "bx", QString::number( d->inplaceCallout[1].x() ) );
+        calloutElement.setAttribute( "by", QString::number( d->inplaceCallout[1].y() ) );
+        calloutElement.setAttribute( "cx", QString::number( d->inplaceCallout[2].x() ) );
+        calloutElement.setAttribute( "cy", QString::number( d->inplaceCallout[2].y() ) );
     }
 }
 
@@ -774,9 +774,9 @@ void LineAnnotation::store( QDomNode & node, QDomDocument & document ) const
     if ( d->lineInnerColor.isValid() )
         lineElement.setAttribute( "innerColor", d->lineInnerColor.name() );
     if ( d->lineLeadingFwdPt != 0.0 )
-        lineElement.setAttribute( "leadFwd", d->lineLeadingFwdPt );
+        lineElement.setAttribute( "leadFwd", QString::number( d->lineLeadingFwdPt ) );
     if ( d->lineLeadingBackPt != 0.0 )
-        lineElement.setAttribute( "leadBack", d->lineLeadingBackPt );
+        lineElement.setAttribute( "leadBack", QString::number( d->lineLeadingBackPt ) );
     if ( d->lineShowCaption )
         lineElement.setAttribute( "showCaption", d->lineShowCaption );
     if ( d->lineIntent != Unknown )
@@ -792,8 +792,8 @@ void LineAnnotation::store( QDomNode & node, QDomDocument & document ) const
             const QPointF & p = *it;
             QDomElement pElement = document.createElement( "point" );
             lineElement.appendChild( pElement );
-            pElement.setAttribute( "x", p.x() );
-            pElement.setAttribute( "y", p.y() );
+            pElement.setAttribute( "x", QString::number( p.x() ) );
+            pElement.setAttribute( "y", QString::number( p.y() ) );
             ++it;
         }
     }
@@ -1122,19 +1122,19 @@ void HighlightAnnotation::store( QDomNode & node, QDomDocument & document ) cons
         QDomElement quadElement = document.createElement( "quad" );
         hlElement.appendChild( quadElement );
         const Quad & q = *it;
-        quadElement.setAttribute( "ax", q.points[0].x() );
-        quadElement.setAttribute( "ay", q.points[0].y() );
-        quadElement.setAttribute( "bx", q.points[1].x() );
-        quadElement.setAttribute( "by", q.points[1].y() );
-        quadElement.setAttribute( "cx", q.points[2].x() );
-        quadElement.setAttribute( "cy", q.points[2].y() );
-        quadElement.setAttribute( "dx", q.points[3].x() );
-        quadElement.setAttribute( "dy", q.points[3].y() );
+        quadElement.setAttribute( "ax", QString::number( q.points[0].x() ) );
+        quadElement.setAttribute( "ay", QString::number( q.points[0].y() ) );
+        quadElement.setAttribute( "bx", QString::number( q.points[1].x() ) );
+        quadElement.setAttribute( "by", QString::number( q.points[1].y() ) );
+        quadElement.setAttribute( "cx", QString::number( q.points[2].x() ) );
+        quadElement.setAttribute( "cy", QString::number( q.points[2].y() ) );
+        quadElement.setAttribute( "dx", QString::number( q.points[3].x() ) );
+        quadElement.setAttribute( "dy", QString::number( q.points[3].y() ) );
         if ( q.capStart )
             quadElement.setAttribute( "start", 1 );
         if ( q.capEnd )
             quadElement.setAttribute( "end", 1 );
-        quadElement.setAttribute( "feather", q.feather );
+        quadElement.setAttribute( "feather", QString::number( q.feather ) );
     }
 }
 
@@ -1345,8 +1345,8 @@ void InkAnnotation::store( QDomNode & node, QDomDocument & document ) const
             const QPointF & point = *iIt;
             QDomElement pointElement = document.createElement( "point" );
             pathElement.appendChild( pointElement );
-            pointElement.setAttribute( "x", point.x() );
-            pointElement.setAttribute( "y", point.y() );
+            pointElement.setAttribute( "x", QString::number( point.x() ) );
+            pointElement.setAttribute( "y", QString::number( point.y() ) );
         }
     }
 }
@@ -1522,14 +1522,14 @@ void LinkAnnotation::store( QDomNode & node, QDomDocument & document ) const
     // saving region
     QDomElement quadElement = document.createElement( "quad" );
     linkElement.appendChild( quadElement );
-    quadElement.setAttribute( "ax", d->linkRegion[0].x() );
-    quadElement.setAttribute( "ay", d->linkRegion[0].y() );
-    quadElement.setAttribute( "bx", d->linkRegion[1].x() );
-    quadElement.setAttribute( "by", d->linkRegion[1].y() );
-    quadElement.setAttribute( "cx", d->linkRegion[2].x() );
-    quadElement.setAttribute( "cy", d->linkRegion[2].y() );
-    quadElement.setAttribute( "dx", d->linkRegion[3].x() );
-    quadElement.setAttribute( "dy", d->linkRegion[3].y() );
+    quadElement.setAttribute( "ax", QString::number( d->linkRegion[0].x() ) );
+    quadElement.setAttribute( "ay", QString::number( d->linkRegion[0].y() ) );
+    quadElement.setAttribute( "bx", QString::number( d->linkRegion[1].x() ) );
+    quadElement.setAttribute( "by", QString::number( d->linkRegion[1].y() ) );
+    quadElement.setAttribute( "cx", QString::number( d->linkRegion[2].x() ) );
+    quadElement.setAttribute( "cy", QString::number( d->linkRegion[2].y() ) );
+    quadElement.setAttribute( "dx", QString::number( d->linkRegion[3].x() ) );
+    quadElement.setAttribute( "dy", QString::number( d->linkRegion[3].y() ) );
 
     // saving link
     QDomElement hyperlinkElement = document.createElement( "link" );
diff --git a/splash/SplashMath.h b/splash/SplashMath.h
index 7a8c8e3..3b72f74 100644
--- a/splash/SplashMath.h
+++ b/splash/SplashMath.h
@@ -26,7 +26,8 @@ static inline int splashFloor(SplashCoord x) {
   #if USE_FIXEDPOINT
     return FixedPoint::floor(x);
   #else
-    return (int)floor(x);
+    if (x > 0) return (int)x;
+    else return (int)floor(x);
   #endif
 }
 
@@ -42,7 +43,7 @@ static inline int splashRound(SplashCoord x) {
 #if USE_FIXEDPOINT
   return FixedPoint::round(x);
 #else
-  return (int)floor(x + 0.5);
+  return (int)splashFloor(x + 0.5);
 #endif
 }
 
diff --git a/splash/SplashScreen.cc b/splash/SplashScreen.cc
index 4fa8488..168022f 100644
--- a/splash/SplashScreen.cc
+++ b/splash/SplashScreen.cc
@@ -46,12 +46,24 @@ static int cmpDistances(const void *p0, const void *p1) {
 // threshold matrix using recursive tesselation.  Gamma correction
 // (gamma = 1 / 1.33) is also computed here.
 SplashScreen::SplashScreen(SplashScreenParams *params) {
-  Guchar u, black, white;
-  int i;
 
   if (!params) {
     params = &defaultParams;
   }
+  
+  screenParams = params;
+  mat = NULL;
+  size = 0;
+  maxVal = 0;
+  minVal = 0;
+}
+
+void SplashScreen::createMatrix()
+{
+  Guchar u, black, white;
+  int i;
+  
+  SplashScreenParams *params = screenParams;
 
   switch (params->type) {
 
@@ -349,6 +361,7 @@ void SplashScreen::buildSCDMatrix(int r) {
 }
 
 SplashScreen::SplashScreen(SplashScreen *screen) {
+  screenParams = screen->screenParams;
   size = screen->size;
   mat = (Guchar *)gmallocn(size * size, sizeof(Guchar));
   memcpy(mat, screen->mat, size * size * sizeof(Guchar));
@@ -362,6 +375,8 @@ SplashScreen::~SplashScreen() {
 
 int SplashScreen::test(int x, int y, Guchar value) {
   int xx, yy;
+  
+  if (mat == NULL) createMatrix();
 
   if (value < minVal) {
     return 0;
@@ -379,5 +394,7 @@ int SplashScreen::test(int x, int y, Guchar value) {
 }
 
 GBool SplashScreen::isStatic(Guchar value) {
+  if (mat == NULL) createMatrix();
+  
   return value < minVal || value >= maxVal;
 }
diff --git a/splash/SplashScreen.h b/splash/SplashScreen.h
index 4174c80..07243ef 100644
--- a/splash/SplashScreen.h
+++ b/splash/SplashScreen.h
@@ -36,6 +36,7 @@ public:
   GBool isStatic(Guchar value);
 
 private:
+  void createMatrix();
 
   void buildDispersedMatrix(int i, int j, int val,
 			    int delta, int offset);
@@ -43,6 +44,7 @@ private:
   int distance(int x0, int y0, int x1, int y1);
   void buildSCDMatrix(int r);
 
+  SplashScreenParams *screenParams;	// params to create the other members
   Guchar *mat;			// threshold matrix
   int size;			// size of the threshold matrix
   Guchar minVal;		// any pixel value below minVal generates
diff --git a/utils/pdftoppm.cc b/utils/pdftoppm.cc
index 38c26fd..3a511c7 100644
--- a/utils/pdftoppm.cc
+++ b/utils/pdftoppm.cc
@@ -41,6 +41,8 @@
 
 static int firstPage = 1;
 static int lastPage = 0;
+static GBool printOnlyOdd = gFalse;
+static GBool printOnlyEven = gFalse;
 static double resolution = 0.0;
 static double x_resolution = 150.0;
 static double y_resolution = 150.0;
@@ -70,6 +72,10 @@ static const ArgDesc argDesc[] = {
    "first page to print"},
   {"-l",      argInt,      &lastPage,      0,
    "last page to print"},
+  {"-o",      argFlag,      &printOnlyOdd, 0,
+   "print only odd pages"},
+  {"-e",      argFlag,      &printOnlyEven, 0,
+   "print only even pages"},
 
   {"-r",      argFP,       &resolution,    0,
    "resolution, in DPI (default is 150)"},
@@ -272,6 +278,8 @@ int main(int argc, char *argv[]) {
   if (sz != 0) w = h = sz;
   pg_num_len = (int)ceil(log((double)doc->getNumPages()) / log((double)10));
   for (pg = firstPage; pg <= lastPage; ++pg) {
+    if (printOnlyEven && pg % 2 == 0) continue;
+    if (printOnlyOdd && pg % 2 == 1) continue;
     if (useCropBox) {
       pg_w = doc->getPageCropWidth(pg);
       pg_h = doc->getPageCropHeight(pg);


More information about the poppler mailing list