[poppler] Branch 'poppler-0.18' - poppler/PDFDoc.cc

Albert Astals Cid aacid at kemper.freedesktop.org
Sun Dec 4 08:32:18 PST 2011


 poppler/PDFDoc.cc |   49 +++++++++++++++++++++++++++++--------------------
 1 file changed, 29 insertions(+), 20 deletions(-)

New commits:
commit 74f4299e8f9e2d204979479f6579dd784db678a4
Author: Albert Astals Cid <aacid at kde.org>
Date:   Sun Dec 4 17:29:45 2011 +0100

    Do not fail if we are trying to save a file with Encrypt but that we have not modified at all
    
    Fixes KDE bug #288045
    (cherry picked from commit 63c942a45227ef28fb94ef4765171d9812fffafa)

diff --git a/poppler/PDFDoc.cc b/poppler/PDFDoc.cc
index 01d2759..2758206 100644
--- a/poppler/PDFDoc.cc
+++ b/poppler/PDFDoc.cc
@@ -707,35 +707,44 @@ int PDFDoc::saveAs(GooString *name, PDFWriteMode mode) {
 
 int PDFDoc::saveAs(OutStream *outStr, PDFWriteMode mode) {
 
-  // we don't support files with Encrypt at the moment
+  // find if we have updated objects
+  GBool updated = gFalse;
+  for(int i=0; i<xref->getNumObjects(); i++) {
+    if (xref->getEntry(i)->updated) {
+      updated = gTrue;
+      break;
+    }
+  }
+
+  // we don't support rewriting files with Encrypt at the moment
   Object obj;
   xref->getTrailerDict()->getDict()->lookupNF("Encrypt", &obj);
   if (!obj.isNull())
   {
     obj.free();
-    return errEncrypted;
+    if (!updated && mode == writeStandard) {
+      // simply copy the original file
+      saveWithoutChangesAs (outStr);
+    } else {
+      return errEncrypted;
+    }
   }
-  obj.free();
+  else
+  {
+    obj.free();
 
-  if (mode == writeForceRewrite) {
-    saveCompleteRewrite(outStr);
-  } else if (mode == writeForceIncremental) {
-    saveIncrementalUpdate(outStr); 
-  } else { // let poppler decide
-    // find if we have updated objects
-    GBool updated = gFalse;
-    for(int i=0; i<xref->getNumObjects(); i++) {
-      if (xref->getEntry(i)->updated) {
-        updated = gTrue;
-        break;
+    if (mode == writeForceRewrite) {
+      saveCompleteRewrite(outStr);
+    } else if (mode == writeForceIncremental) {
+      saveIncrementalUpdate(outStr); 
+    } else { // let poppler decide
+      if(updated) { 
+        saveIncrementalUpdate(outStr);
+      } else {
+        // simply copy the original file
+        saveWithoutChangesAs (outStr);
       }
     }
-    if(updated) { 
-      saveIncrementalUpdate(outStr);
-    } else {
-      // simply copy the original file
-      saveWithoutChangesAs (outStr);
-    }
   }
 
   return errNone;


More information about the poppler mailing list