From bfc6572614727565d883b9545d4b6665f3c2fdfe Mon Sep 17 00:00:00 2001 From: Carlos Garcia Campos Date: Sat, 28 Feb 2009 13:16:49 +0100 Subject: [PATCH] Return an error code instead of a GBool when saving --- poppler/PDFDoc.cc | 22 +++++++++++----------- poppler/PDFDoc.h | 8 ++++---- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/poppler/PDFDoc.cc b/poppler/PDFDoc.cc index f73359c..1be1261 100644 --- a/poppler/PDFDoc.cc +++ b/poppler/PDFDoc.cc @@ -462,14 +462,14 @@ GBool PDFDoc::isLinearized() { return lin; } -GBool PDFDoc::saveAs(GooString *name, PDFWriteMode mode) { +int PDFDoc::saveAs(GooString *name, PDFWriteMode mode) { FILE *f; OutStream *outStr; - GBool res; + int res; if (!(f = fopen(name->getCString(), "wb"))) { error(-1, "Couldn't open file '%s'", name->getCString()); - return gFalse; + return errOpenFile; } outStr = new FileOutStream(f,0); res = saveAs(outStr, mode); @@ -478,7 +478,7 @@ GBool PDFDoc::saveAs(GooString *name, PDFWriteMode mode) { return res; } -GBool PDFDoc::saveAs(OutStream *outStr, PDFWriteMode mode) { +int PDFDoc::saveAs(OutStream *outStr, PDFWriteMode mode) { // we don't support files with Encrypt at the moment Object obj; @@ -486,7 +486,7 @@ GBool PDFDoc::saveAs(OutStream *outStr, PDFWriteMode mode) { if (!obj.isNull()) { obj.free(); - return gFalse; + return errEncrypted; } obj.free(); @@ -511,17 +511,17 @@ GBool PDFDoc::saveAs(OutStream *outStr, PDFWriteMode mode) { } } - return gTrue; + return errNone; } -GBool PDFDoc::saveWithoutChangesAs(GooString *name) { +int PDFDoc::saveWithoutChangesAs(GooString *name) { FILE *f; OutStream *outStr; - GBool res; + int res; if (!(f = fopen(name->getCString(), "wb"))) { error(-1, "Couldn't open file '%s'", name->getCString()); - return gFalse; + return errOpenFile; } outStr = new FileOutStream(f,0); @@ -533,7 +533,7 @@ GBool PDFDoc::saveWithoutChangesAs(GooString *name) { return res; } -GBool PDFDoc::saveWithoutChangesAs(OutStream *outStr) { +int PDFDoc::saveWithoutChangesAs(OutStream *outStr) { int c; str->reset(); @@ -542,7 +542,7 @@ GBool PDFDoc::saveWithoutChangesAs(OutStream *outStr) { } str->close(); - return gTrue; + return errNone; } void PDFDoc::saveIncrementalUpdate (OutStream* outStr) diff --git a/poppler/PDFDoc.h b/poppler/PDFDoc.h index 35b966e..5bc1953 100644 --- a/poppler/PDFDoc.h +++ b/poppler/PDFDoc.h @@ -197,13 +197,13 @@ public: double getPDFVersion() { return pdfVersion; } // Save this file with another name. - GBool saveAs(GooString *name, PDFWriteMode mode=writeStandard); + int saveAs(GooString *name, PDFWriteMode mode=writeStandard); // Save this file in the given output stream. - GBool saveAs(OutStream *outStr, PDFWriteMode mode=writeStandard); + int saveAs(OutStream *outStr, PDFWriteMode mode=writeStandard); // Save this file with another name without saving changes - GBool saveWithoutChangesAs(GooString *name); + int saveWithoutChangesAs(GooString *name); // Save this file in the given output stream without saving changes - GBool saveWithoutChangesAs(OutStream *outStr); + int saveWithoutChangesAs(OutStream *outStr); // Return a pointer to the GUI (XPDFCore or WinPDFCore object). void *getGUIData() { return guiData; } -- 1.5.6.3