Commit 5491d16d authored by Albert Astals Cid's avatar Albert Astals Cid
Browse files

Move poppler core away from using a double as PDF file version

Frontends are yet to come
parent efd5dd63
......@@ -646,7 +646,7 @@ poppler_document_get_property (GObject *object,
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:
......
......@@ -304,7 +304,8 @@ void PDFDoc::checkHeader() {
char *p;
int i;
pdfVersion = 0;
pdfMajorVersion = 0;
pdfMinorVersion = 0;
for (i = 0; i < headerSearchSize; ++i) {
hdrBuf[i] = str->getChar();
}
......@@ -323,7 +324,7 @@ void PDFDoc::checkHeader() {
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.
}
......@@ -578,7 +579,7 @@ void PDFDoc::saveIncrementalUpdate (OutStream* outStr)
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++) {
......
......@@ -14,7 +14,7 @@
// 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>
......@@ -199,7 +199,8 @@ public:
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);
......@@ -234,7 +235,8 @@ private:
FILE *file;
BaseStream *str;
void *guiData;
double pdfVersion;
int pdfMajorVersion;
int pdfMinorVersion;
XRef *xref;
Catalog *catalog;
#ifndef DISABLE_OUTLINE
......
/* 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>
*
......@@ -270,7 +270,7 @@ bool Document::okToAddNotes() const
double Document::getPDFVersion() const
{
return data->doc.getPDFVersion();
return data->doc.getPDFMajorVersion () + data->doc.getPDFMinorVersion() / 10.0;
}
QDomDocument *Document::toc() const
......
/* 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
......@@ -379,7 +379,7 @@ namespace Poppler {
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
......
......@@ -14,7 +14,7 @@
// 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
......@@ -303,7 +303,7 @@ int main(int argc, char *argv[]) {
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())) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment