[poppler] 7 commits - poppler/Annot.cc poppler/CharCodeToUnicode.cc poppler/SplashOutputDev.cc

Albert Astals Cid aacid at kemper.freedesktop.org
Sat Aug 2 16:07:05 PDT 2014


 poppler/Annot.cc             |    3 ++-
 poppler/CharCodeToUnicode.cc |    3 ++-
 poppler/SplashOutputDev.cc   |    9 ++++-----
 3 files changed, 8 insertions(+), 7 deletions(-)

New commits:
commit b72a534d6c7d8bc026812b68f9d9ac6bf9a2200a
Merge: f2e4154 ef3f758
Author: Albert Astals Cid <aacid at kde.org>
Date:   Sun Aug 3 01:06:57 2014 +0200

    Merge remote-tracking branch 'origin/poppler-0.26'

commit ef3f7585fac086de0919aa0bb0ef91a5070ac23e
Author: Jiri Slaby <jirislaby at gmail.com>
Date:   Sun Aug 3 01:05:00 2014 +0200

    Improve non-latin characters in inline notes
    
    Preview commit had by mistake changes in these two files that belong here
    
    Bug #65956

diff --git a/poppler/Annot.cc b/poppler/Annot.cc
index 591fe79..fa98b69 100644
--- a/poppler/Annot.cc
+++ b/poppler/Annot.cc
@@ -30,6 +30,7 @@
 // Copyright (C) 2013 Peter Breitenlohner <peb at mppmu.mpg.de>
 // Copyright (C) 2013 Adrian Johnson <ajohnson at redneon.com>
 // Copyright (C) 2014 Marek Kasik <mkasik at redhat.com>
+// Copyright (C) 2014 Jiri Slaby <jirislaby at gmail.com>
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
diff --git a/poppler/CharCodeToUnicode.cc b/poppler/CharCodeToUnicode.cc
index b1c1bab..59b7c93 100644
--- a/poppler/CharCodeToUnicode.cc
+++ b/poppler/CharCodeToUnicode.cc
@@ -22,6 +22,7 @@
 // Copyright (C) 2010 Jakub Wilk <ubanus at users.sf.net>
 // Copyright (C) 2012 Thomas Freitag <Thomas.Freitag at alfa.de>
 // Copyright (C) 2012 Adrian Johnson <ajohnson at redneon.com>
+// Copyright (C) 2014 Jiri Slaby <jirislaby at gmail.com>
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
commit 1b9c54286a4cdfaa284795933c20acf3c7e13bfc
Author: Ed Porras <ed at moto-research.com>
Date:   Sun Aug 3 01:01:35 2014 +0200

    Don't check for inlineImg twice
    
    Bug #82059

diff --git a/poppler/Annot.cc b/poppler/Annot.cc
index a559836..591fe79 100644
--- a/poppler/Annot.cc
+++ b/poppler/Annot.cc
@@ -4087,7 +4087,7 @@ void Annot::layoutText(GooString *text, GooString *outBuf, int *i,
         // This assumes an identity CMap.
         outBuf->append((uChar >> 8) & 0xff);
         outBuf->append(uChar & 0xff);
-      } else if (ccToUnicode->mapToCharCode(&uChar, &c, 1)) {
+      } else if (ccToUnicode->mapToCharCode(&uChar, &c, 2)) {
         ccToUnicode->decRefCnt();
         if (font->isCIDFont()) {
           // TODO: This assumes an identity CMap.  It should be extended to
diff --git a/poppler/CharCodeToUnicode.cc b/poppler/CharCodeToUnicode.cc
index 16ba6d4..b1c1bab 100644
--- a/poppler/CharCodeToUnicode.cc
+++ b/poppler/CharCodeToUnicode.cc
@@ -633,7 +633,7 @@ int CharCodeToUnicode::mapToUnicode(CharCode c, Unicode **u) {
 
 int CharCodeToUnicode::mapToCharCode(Unicode* u, CharCode *c, int usize) {
   //look for charcode in map
-  if (usize == 1) {
+  if (usize == 1 || (usize > 1 && !(*u & ~0xff))) {
     if (isIdentity) {
       *c = (CharCode) *u;
       return 1;
diff --git a/poppler/SplashOutputDev.cc b/poppler/SplashOutputDev.cc
index 01979fd..fd0f841 100644
--- a/poppler/SplashOutputDev.cc
+++ b/poppler/SplashOutputDev.cc
@@ -32,6 +32,7 @@
 // Copyright (C) 2011, 2012 Adrian Johnson <ajohnson at redneon.com>
 // Copyright (C) 2013 Lu Wang <coolwanglu at gmail.com>
 // Copyright (C) 2013 Li Junling <lijunling at sina.com>
+// Copyright (C) 2014 Ed Porras <ed at moto-research.com>
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
@@ -2694,11 +2695,9 @@ void SplashOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str,
 
   splash->fillImageMask(&imageMaskSrc, &imgMaskData, width, height, mat, t3GlyphStack != NULL);
   if (inlineImg) {
-    if (inlineImg) {
-      while (imgMaskData.y < height) {
-        imgMaskData.imgStr->getLine();
-        ++imgMaskData.y;
-      }
+    while (imgMaskData.y < height) {
+      imgMaskData.imgStr->getLine();
+      ++imgMaskData.y;
     }
   }
 
commit e7825f7cbbe7cc9c324fcb34c2e0dcae75f4172a
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date:   Fri Jul 25 15:45:55 2014 +0200

    glib: Fix a memory leak when getting text layout and attributes

diff --git a/glib/poppler-page.cc b/glib/poppler-page.cc
index a4c9681..34d6e35 100644
--- a/glib/poppler-page.cc
+++ b/glib/poppler-page.cc
@@ -2233,6 +2233,8 @@ poppler_page_get_text_layout_for_area (PopplerPage       *page,
 	      rect->y2 = y2;
 	      offset++;
             }
+
+          delete word_sel;
         }
 
       if (i < n_lines - 1 && offset > 0)
@@ -2394,6 +2396,8 @@ poppler_page_get_text_attributes_for_area (PopplerPage      *page,
               attrs->end_index = offset;
               offset++;
             }
+
+          delete word_sel;
         }
 
       if (i < n_lines - 1)
commit a1ecff0f0ab81fe76f63244250d96e7ef275f402
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date:   Fri Jul 25 11:25:42 2014 +0200

    glib: Return NULL in poppler_annot_get_contents also for empty strings

diff --git a/glib/poppler-annot.cc b/glib/poppler-annot.cc
index 13bc768..e87bce3 100644
--- a/glib/poppler-annot.cc
+++ b/glib/poppler-annot.cc
@@ -799,7 +799,7 @@ poppler_annot_get_contents (PopplerAnnot *poppler_annot)
 
   contents = poppler_annot->annot->getContents ();
 
-  return contents ? _poppler_goo_string_to_utf8 (contents) : NULL;
+  return contents && contents->getLength() > 0 ? _poppler_goo_string_to_utf8 (contents) : NULL;
 }
 
 /**
commit ab1113d10ef712c7c44cd4b4bb6bc79f9ca3702c
Author: Anuj Khare <khareanuj18 at gmail.com>
Date:   Thu Jul 24 19:47:22 2014 +0200

    annots: Fix a crash when adding annot without contents
    
    Having no content in an annotation results in a crash when generating
    its appearance, since the contents pointer is dereferenced.
    For consistency, the same has been done in Annot::initialize.

diff --git a/poppler/Annot.cc b/poppler/Annot.cc
index fa29739..a559836 100644
--- a/poppler/Annot.cc
+++ b/poppler/Annot.cc
@@ -1265,7 +1265,7 @@ void Annot::initialize(PDFDoc *docA, Dict *dict) {
   if (dict->lookup("Contents", &obj1)->isString()) {
     contents = obj1.getString()->copy();
   } else {
-    contents = NULL;
+    contents = new GooString();
   }
   obj1.free();
 
@@ -1641,9 +1641,7 @@ Annot::~Annot() {
   annotObj.free();
   
   delete rect;
-  
-  if (contents)
-    delete contents;
+  delete contents;
 
   if (name)
     delete name;
@@ -3015,6 +3013,8 @@ void AnnotFreeText::generateFreeTextAppearance()
     fontsize = 10;
   if (fontcolor == NULL)
     fontcolor = new AnnotColor(0, 0, 0); // Black
+  if (!contents)
+    contents = new GooString ();
 
   // Draw box
   GBool doFill = (color && color->getSpace() != AnnotColor::colorTransparent);
commit 94ea9d8e1631abfbb8cc078100942d46b1356970
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date:   Thu Jul 24 10:46:17 2014 +0200

    cairo: Make sure we always push a transparency group in setSoftMaskFromImageMask()
    
    Because that's what unsetSoftMaskFromImageMask() assumes.
    
    https://bugs.freedesktop.org/show_bug.cgi?id=81624

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index f31b46b..c2827c6 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -1880,46 +1880,44 @@ void CairoOutputDev::setSoftMaskFromImageMask(GfxState *state, Object *ref, Stre
     delete imgStr;
 
     invert_bit = invert ? 1 : 0;
-    if (pix ^ invert_bit)
-      return;
-
-    cairo_save (cairo);
-    cairo_rectangle (cairo, 0., 0., width, height);
-    cairo_fill (cairo);
-    cairo_restore (cairo);
-    if (cairo_shape) {
-      cairo_save (cairo_shape);
-      cairo_rectangle (cairo_shape, 0., 0., width, height);
-      cairo_fill (cairo_shape);
-      cairo_restore (cairo_shape);
+    if (!(pix ^ invert_bit)) {
+      cairo_save (cairo);
+      cairo_rectangle (cairo, 0., 0., width, height);
+      cairo_fill (cairo);
+      cairo_restore (cairo);
+      if (cairo_shape) {
+        cairo_save (cairo_shape);
+        cairo_rectangle (cairo_shape, 0., 0., width, height);
+        cairo_fill (cairo_shape);
+        cairo_restore (cairo_shape);
+      }
     }
-    return;
-  }
+  } else {
+    cairo_push_group_with_content (cairo, CAIRO_CONTENT_ALPHA);
 
-  cairo_push_group_with_content (cairo, CAIRO_CONTENT_ALPHA);
+    /* shape is 1.0 for painted areas, 0.0 for unpainted ones */
 
-  /* shape is 1.0 for painted areas, 0.0 for unpainted ones */
+    cairo_matrix_t matrix;
+    cairo_get_matrix (cairo, &matrix);
+    //XXX: it is possible that we should only do sub pixel positioning if 
+    // we are rendering fonts */
+    if (!printing && prescaleImages && matrix.xy == 0.0 && matrix.yx == 0.0) {
+      drawImageMaskPrescaled(state, ref, str, width, height, invert, gFalse, inlineImg);
+    } else {
+      drawImageMaskRegular(state, ref, str, width, height, invert, gFalse, inlineImg);
+    }
 
-  cairo_matrix_t matrix;
-  cairo_get_matrix (cairo, &matrix);
-  //XXX: it is possible that we should only do sub pixel positioning if 
-  // we are rendering fonts */
-  if (!printing && prescaleImages && matrix.xy == 0.0 && matrix.yx == 0.0) {
-    drawImageMaskPrescaled(state, ref, str, width, height, invert, gFalse, inlineImg);
-  } else {
-    drawImageMaskRegular(state, ref, str, width, height, invert, gFalse, inlineImg);
-  }
+    if (state->getFillColorSpace()->getMode() == csPattern) {
+      cairo_set_source_rgb (cairo, 1, 1, 1);
+      cairo_set_matrix (cairo, &mask_matrix);
+      cairo_mask (cairo, mask);
+    }
 
-  if (state->getFillColorSpace()->getMode() == csPattern) {
-    cairo_set_source_rgb (cairo, 1, 1, 1);
-    cairo_set_matrix (cairo, &mask_matrix);
-    cairo_mask (cairo, mask);
+    if (mask)
+      cairo_pattern_destroy (mask);
+    mask = cairo_pop_group (cairo);
   }
 
-  if (mask)
-    cairo_pattern_destroy (mask);
-  mask = cairo_pop_group (cairo);
-
   saveState(state);
   double bbox[4] = {0,0,1,1}; // dummy
   beginTransparencyGroup(state, bbox, state->getFillColorSpace(),


More information about the poppler mailing list