[poppler] 3 commits - cpp/poppler-document.cpp cpp/poppler-document-private.h poppler/Form.cc
Pino Toscano
pino at kemper.freedesktop.org
Sat Mar 12 03:16:33 PST 2011
cpp/poppler-document-private.h | 19 +++++++++-----
cpp/poppler-document.cpp | 54 ++++++++++++++++++++++-------------------
poppler/Form.cc | 1
3 files changed, 42 insertions(+), 32 deletions(-)
New commits:
commit c0dffbe28f91b30b36310ab0b9a9b948610550ae
Author: Pino Toscano <pino at kde.org>
Date: Sat Mar 12 12:15:58 2011 +0100
update copyright years
diff --git a/cpp/poppler-document-private.h b/cpp/poppler-document-private.h
index 4d3b685..5ca9e14 100644
--- a/cpp/poppler-document-private.h
+++ b/cpp/poppler-document-private.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2010, Pino Toscano <pino at kde.org>
+ * Copyright (C) 2009-2011, Pino Toscano <pino at 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
diff --git a/cpp/poppler-document.cpp b/cpp/poppler-document.cpp
index 9d6a2dc..c5b2733 100644
--- a/cpp/poppler-document.cpp
+++ b/cpp/poppler-document.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2010, Pino Toscano <pino at kde.org>
+ * Copyright (C) 2009-2011, Pino Toscano <pino at 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
commit b8fab173ffdd1e62a34b530228d08bc5ec6725ac
Author: Pino Toscano <pino at kde.org>
Date: Sat Mar 12 12:13:05 2011 +0100
[cpp] init the globalParams early in the document loading
introduce a small RAII class to init/deinit the globalParams, and make document_private inherit from it
diff --git a/cpp/poppler-document-private.h b/cpp/poppler-document-private.h
index f78e57c..4d3b685 100644
--- a/cpp/poppler-document-private.h
+++ b/cpp/poppler-document-private.h
@@ -33,7 +33,17 @@ namespace poppler
class document;
class embedded_file;
-class document_private
+class initer
+{
+public:
+ initer();
+ ~initer();
+
+private:
+ static unsigned int count;
+};
+
+class document_private : private initer
{
public:
document_private(GooString *file_path, const std::string &owner_password,
@@ -53,11 +63,6 @@ public:
int raw_doc_data_length;
bool is_locked;
std::vector<embedded_file *> embedded_files;
-
-private:
- void init();
-
- static unsigned int count;
};
}
diff --git a/cpp/poppler-document.cpp b/cpp/poppler-document.cpp
index 3495a4b..9d6a2dc 100644
--- a/cpp/poppler-document.cpp
+++ b/cpp/poppler-document.cpp
@@ -37,11 +37,33 @@
using namespace poppler;
-unsigned int poppler::document_private::count = 0U;
+unsigned int poppler::initer::count = 0U;
+
+initer::initer()
+{
+ if (!count) {
+ globalParams = new GlobalParams();
+ setErrorFunction(detail::error_function);
+ }
+ count++;
+}
+
+initer::~initer()
+{
+ if (count > 0) {
+ --count;
+ if (!count) {
+ delete globalParams;
+ globalParams = 0;
+ }
+ }
+}
+
document_private::document_private(GooString *file_path, const std::string &owner_password,
const std::string &user_password)
- : doc(0)
+ : initer()
+ , doc(0)
, raw_doc_data(0)
, raw_doc_data_length(0)
, is_locked(false)
@@ -49,13 +71,13 @@ document_private::document_private(GooString *file_path, const std::string &owne
GooString goo_owner_password(owner_password.c_str());
GooString goo_user_password(user_password.c_str());
doc = new PDFDoc(file_path, &goo_owner_password, &goo_user_password);
- init();
}
document_private::document_private(byte_array *file_data,
const std::string &owner_password,
const std::string &user_password)
- : doc(0)
+ : initer()
+ , doc(0)
, raw_doc_data(0)
, raw_doc_data_length(0)
, is_locked(false)
@@ -67,13 +89,13 @@ document_private::document_private(byte_array *file_data,
GooString goo_owner_password(owner_password.c_str());
GooString goo_user_password(user_password.c_str());
doc = new PDFDoc(memstr, &goo_owner_password, &goo_user_password);
- init();
}
document_private::document_private(const char *file_data, int file_data_length,
const std::string &owner_password,
const std::string &user_password)
- : doc(0)
+ : initer()
+ , doc(0)
, raw_doc_data(file_data)
, raw_doc_data_length(file_data_length)
, is_locked(false)
@@ -84,7 +106,6 @@ document_private::document_private(const char *file_data, int file_data_length,
GooString goo_owner_password(owner_password.c_str());
GooString goo_user_password(user_password.c_str());
doc = new PDFDoc(memstr, &goo_owner_password, &goo_user_password);
- init();
}
document_private::~document_private()
@@ -92,23 +113,6 @@ document_private::~document_private()
delete_all(embedded_files);
delete doc;
-
- if (count > 0) {
- --count;
- if (!count) {
- delete globalParams;
- globalParams = 0;
- }
- }
-}
-
-void document_private::init()
-{
- if (!count) {
- globalParams = new GlobalParams();
- setErrorFunction(detail::error_function);
- }
- count++;
}
document* document_private::check_document(document_private *doc, byte_array *file_data)
commit a97a54cb22def2a9fc381fb81842dad9e5c3931f
Author: Pino Toscano <pino at kde.org>
Date: Sat Mar 12 12:12:11 2011 +0100
forms: delete tmp_str after being converted to GooString
diff --git a/poppler/Form.cc b/poppler/Form.cc
index 0b9ce25..f02820a 100644
--- a/poppler/Form.cc
+++ b/poppler/Form.cc
@@ -857,6 +857,7 @@ FormFieldText::FormFieldText(XRef *xrefA, Object *aobj, const Ref& ref, std::set
int tmp_length;
char* tmp_str = pdfDocEncodingToUTF16(obj1.getString(), &tmp_length);
content = new GooString(tmp_str, tmp_length);
+ delete [] tmp_str;
}
}
obj1.free();
More information about the poppler
mailing list