Hi,

while working on the Qt4 frontend, I noticed the newly created 
PDFDoc::saveAs() can save only to file (whose name is specified as 
parameter).
Though, what it really does is creating a FileOutStream and saving to that 
stream. As using an output stream directly could be useful for the Qt4 
frontend, I did the following patch (sadly not tested).

Comments? Blamings? Commit (since I'm still waiting for the account)?
-- 
Pino Toscano
commit 4c8edbf03803481d7b66a4c880deb8275272f93a
Author: Pino Toscano <[EMAIL PROTECTED]>
Date:   Sat Jan 19 19:26:48 2008 +0100

    Added a saveAs() overload which takes a plain OutStream.

diff --git a/poppler/PDFDoc.cc b/poppler/PDFDoc.cc
index b3336a0..afafd92 100644
--- a/poppler/PDFDoc.cc
+++ b/poppler/PDFDoc.cc
@@ -439,13 +439,20 @@ GBool PDFDoc::isLinearized() {
 GBool PDFDoc::saveAs(GooString *name, PDFWriteMode mode) {
   FILE *f;
   OutStream *outStr;
+  GBool res;
 
   if (!(f = fopen(name->getCString(), "wb"))) {
     error(-1, "Couldn't open file '%s'", name->getCString());
     return gFalse;
   }
   outStr = new FileOutStream(f,0);
+  res = saveAs(outStr, mode);
+  delete outStr;
+  fclose(f);
+  return res;
+}
 
+GBool PDFDoc::saveAs(OutStream *outStr, PDFWriteMode mode) {
   if (mode == writeForceRewrite) {
     saveCompleteRewrite(outStr);
   } else if (mode == writeForceIncremental) {
@@ -472,8 +479,6 @@ GBool PDFDoc::saveAs(GooString *name, PDFWriteMode mode) {
     }
   }
 
-  delete outStr;
-  fclose(f);
   return gTrue;
 }
 
diff --git a/poppler/PDFDoc.h b/poppler/PDFDoc.h
index 2336694..1e497b2 100644
--- a/poppler/PDFDoc.h
+++ b/poppler/PDFDoc.h
@@ -176,6 +176,7 @@ public:
 
   // Save this file with another name.
   GBool saveAs(GooString *name, PDFWriteMode mode=writeStandard);
+  GBool saveAs(OutStream *outStr, PDFWriteMode mode=writeStandard);
 
   // Return a pointer to the GUI (XPDFCore or WinPDFCore object).
   void *getGUIData() { return guiData; }

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
poppler mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/poppler

Reply via email to