diff options
author | Albert Astals Cid <aacid@kde.org> | 2009-08-17 00:24:41 +0200 |
---|---|---|
committer | Albert Astals Cid <aacid@kde.org> | 2009-08-17 00:24:41 +0200 |
commit | 5491d16dfbd73f0256c62e49d02622dc3185012e (patch) | |
tree | e3e08ab690bf6d8f3c4916850d2012e9228d44bb | |
parent | efd5dd63a5b08249529d9a9f5906aefe806fb3aa (diff) |
Move poppler core away from using a double as PDF file version
Frontends are yet to come
-rw-r--r-- | glib/poppler-document.cc | 2 | ||||
-rw-r--r-- | poppler/PDFDoc.cc | 7 | ||||
-rw-r--r-- | poppler/PDFDoc.h | 8 | ||||
-rw-r--r-- | qt/poppler-document.cc | 4 | ||||
-rw-r--r-- | qt4/src/poppler-document.cc | 4 | ||||
-rw-r--r-- | utils/pdfinfo.cc | 4 |
6 files changed, 16 insertions, 13 deletions
diff --git a/glib/poppler-document.cc b/glib/poppler-document.cc index dfdfb803..6b46fc03 100644 --- a/glib/poppler-document.cc +++ b/glib/poppler-document.cc @@ -643,13 +643,13 @@ poppler_document_get_property (GObject *object, info_dict_get_string (obj.getDict(), "Title", value); obj.free (); break; case PROP_FORMAT: str = g_strndup("PDF-", 15); /* allocates 16 chars, pads with \0s */ g_ascii_formatd (str + 4, 15 + 1 - 4, - "%.2g", document->doc->getPDFVersion ()); + "%.2g", document->doc->getPDFMajorVersion () + document->doc->getPDFMinorVersion() / 10.0); g_value_take_string (value, str); break; case PROP_AUTHOR: document->doc->getDocInfo (&obj); if (obj.isDict ()) info_dict_get_string (obj.getDict(), "Author", value); diff --git a/poppler/PDFDoc.cc b/poppler/PDFDoc.cc index 463488fa..435ad100 100644 --- a/poppler/PDFDoc.cc +++ b/poppler/PDFDoc.cc @@ -301,13 +301,14 @@ GBool PDFDoc::checkFooter() { // if necessary. void PDFDoc::checkHeader() { char hdrBuf[headerSearchSize+1]; char *p; int i; - pdfVersion = 0; + pdfMajorVersion = 0; + pdfMinorVersion = 0; for (i = 0; i < headerSearchSize; ++i) { hdrBuf[i] = str->getChar(); } hdrBuf[headerSearchSize] = '\0'; for (i = 0; i < headerSearchSize - 5; ++i) { if (!strncmp(&hdrBuf[i], "%PDF-", 5)) { @@ -320,13 +321,13 @@ void PDFDoc::checkHeader() { } str->moveStart(i); if (!(p = strtok(&hdrBuf[i+5], " \t\n\r"))) { error(-1, "May not be a PDF file (continuing anyway)"); return; } - pdfVersion = gatof(p); + sscanf(p, "%d.%d", &pdfMajorVersion, &pdfMinorVersion); // We don't do the version check. Don't add it back in. } GBool PDFDoc::checkEncryption(GooString *ownerPassword, GooString *userPassword) { Object encrypt; GBool encrypted; @@ -575,13 +576,13 @@ void PDFDoc::saveIncrementalUpdate (OutStream* outStr) delete uxref; } void PDFDoc::saveCompleteRewrite (OutStream* outStr) { - outStr->printf("%%PDF-%.1f\r\n",pdfVersion); + outStr->printf("%%PDF-%d.%d\r\n",pdfMajorVersion,pdfMinorVersion); XRef *uxref = new XRef(); uxref->add(0, 65535, 0, gFalse); for(int i=0; i<xref->getNumObjects(); i++) { Object obj1; Ref ref; XRefEntryType type = xref->getEntry(i)->type; diff --git a/poppler/PDFDoc.h b/poppler/PDFDoc.h index 94229b79..75273160 100644 --- a/poppler/PDFDoc.h +++ b/poppler/PDFDoc.h @@ -11,13 +11,13 @@ // Modified under the Poppler project - http://poppler.freedesktop.org // // All changes made under the Poppler project to this file are licensed // under GPL version 2 or later // // Copyright (C) 2005, 2006, 2008 Brad Hards <bradh@frogmouth.net> -// Copyright (C) 2005 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2005, 2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2008 Julien Rebetez <julienr@svn.gnome.org> // Copyright (C) 2008 Pino Toscano <pino@kde.org> // Copyright (C) 2008 Carlos Garcia Campos <carlosgc@gnome.org> // Copyright (C) 2009 Eric Toombs <ewtoombs@uwaterloo.ca> // // To see a description of the changes please see the Changelog file that @@ -196,13 +196,14 @@ public: // Return the document's Info dictionary (if any). Object *getDocInfo(Object *obj) { return xref->getDocInfo(obj); } Object *getDocInfoNF(Object *obj) { return xref->getDocInfoNF(obj); } // Return the PDF version specified by the file. - double getPDFVersion() { return pdfVersion; } + int getPDFMajorVersion() { return pdfMajorVersion; } + int getPDFMinorVersion() { return pdfMinorVersion; } // Save this file with another name. int saveAs(GooString *name, PDFWriteMode mode=writeStandard); // Save this file in the given output stream. int saveAs(OutStream *outStr, PDFWriteMode mode=writeStandard); // Save this file with another name without saving changes @@ -231,13 +232,14 @@ private: GBool checkEncryption(GooString *ownerPassword, GooString *userPassword); GooString *fileName; FILE *file; BaseStream *str; void *guiData; - double pdfVersion; + int pdfMajorVersion; + int pdfMinorVersion; XRef *xref; Catalog *catalog; #ifndef DISABLE_OUTLINE Outline *outline; #endif diff --git a/qt/poppler-document.cc b/qt/poppler-document.cc index 4c47e625..fe746760 100644 --- a/qt/poppler-document.cc +++ b/qt/poppler-document.cc @@ -1,9 +1,9 @@ /* poppler-document.cc: qt interface to poppler * Copyright (C) 2005, Net Integration Technologies, Inc. - * Copyright (C) 2005-2008, Albert Astals Cid <aacid@kde.org> + * Copyright (C) 2005-2009, Albert Astals Cid <aacid@kde.org> * Copyright (C) 2006, Stefan Kebekus <stefan.kebekus@math.uni-koeln.de> * Copyright (C) 2006, Wilfried Huss <Wilfried.Huss@gmx.at> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) @@ -267,13 +267,13 @@ bool Document::okToAddNotes() const { return data->doc.okToAddNotes(); } double Document::getPDFVersion() const { - return data->doc.getPDFVersion(); + return data->doc.getPDFMajorVersion () + data->doc.getPDFMinorVersion() / 10.0; } QDomDocument *Document::toc() const { Outline * outline = data->doc.getOutline(); if ( !outline ) diff --git a/qt4/src/poppler-document.cc b/qt4/src/poppler-document.cc index 4eb1abaf..3e4b086c 100644 --- a/qt4/src/poppler-document.cc +++ b/qt4/src/poppler-document.cc @@ -1,10 +1,10 @@ /* poppler-document.cc: qt interface to poppler * Copyright (C) 2005, Net Integration Technologies, Inc. * Copyright (C) 2005, 2008, Brad Hards <bradh@frogmouth.net> - * Copyright (C) 2005-2008, Albert Astals Cid <aacid@kde.org> + * Copyright (C) 2005-2009, Albert Astals Cid <aacid@kde.org> * Copyright (C) 2006-2009, Pino Toscano <pino@kde.org> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. @@ -376,13 +376,13 @@ namespace Poppler { { return m_doc->doc->okToAssemble(); } double Document::pdfVersion() const { - return m_doc->doc->getPDFVersion(); + return m_doc->doc->getPDFMajorVersion () + m_doc->doc->getPDFMinorVersion() / 10.0; } Page *Document::page(const QString &label) const { GooString label_g(label.toAscii().data()); int index; diff --git a/utils/pdfinfo.cc b/utils/pdfinfo.cc index 9063f87d..bfbe0b3d 100644 --- a/utils/pdfinfo.cc +++ b/utils/pdfinfo.cc @@ -11,13 +11,13 @@ // Modified under the Poppler project - http://poppler.freedesktop.org // // All changes made under the Poppler project to this file are licensed // under GPL version 2 or later // // Copyright (C) 2006 Dom Lachowicz <cinamod@hotmail.com> -// Copyright (C) 2007-2008 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2007-2009 Albert Astals Cid <aacid@kde.org> // // 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 // //======================================================================== @@ -300,13 +300,13 @@ int main(int argc, char *argv[]) { } // print linearization info printf("Optimized: %s\n", doc->isLinearized() ? "yes" : "no"); // print PDF version - printf("PDF version: %.1f\n", doc->getPDFVersion()); + printf("PDF version: %d.%d\n", doc->getPDFMajorVersion(), doc->getPDFMinorVersion()); // print the metadata if (printMetadata && (metadata = doc->readMetadata())) { fputs("Metadata:\n", stdout); fputs(metadata->getCString(), stdout); fputc('\n', stdout); |