aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2022-04-02 23:14:10 +0200
committerJay Berkenbilt <ejb@ql.org>2022-04-04 14:10:40 +0200
commit12f1eb15ca3fed6310402847559a7c99d3c77847 (patch)
tree8935675b623c6f3b4914b8b44f7fa5f2816a9241 /include
parentf20fa61eb4c323eb1642c69c236b3d9a1f8b2cdb (diff)
downloadqpdf-12f1eb15ca3fed6310402847559a7c99d3c77847.tar.zst
Programmatically apply new formatting to code
Run this: for i in **/*.cc **/*.c **/*.h **/*.hh; do clang-format < $i >| $i.new && mv $i.new $i done
Diffstat (limited to 'include')
-rw-r--r--include/qpdf/Buffer.hh2
-rw-r--r--include/qpdf/BufferInputSource.hh10
-rw-r--r--include/qpdf/Constants.h81
-rw-r--r--include/qpdf/DLL.h2
-rw-r--r--include/qpdf/InputSource.hh20
-rw-r--r--include/qpdf/JSON.hh25
-rw-r--r--include/qpdf/Pipeline.hh2
-rw-r--r--include/qpdf/Pl_Buffer.hh4
-rw-r--r--include/qpdf/Pl_Count.hh2
-rw-r--r--include/qpdf/Pl_DCT.hh29
-rw-r--r--include/qpdf/Pl_Flate.hh7
-rw-r--r--include/qpdf/Pl_QPDFTokenizer.hh11
-rw-r--r--include/qpdf/Pl_RunLength.hh3
-rw-r--r--include/qpdf/PointerHolder.hh74
-rw-r--r--include/qpdf/QIntC.hh140
-rw-r--r--include/qpdf/QPDF.hh519
-rw-r--r--include/qpdf/QPDFAcroFormDocumentHelper.hh43
-rw-r--r--include/qpdf/QPDFAnnotationObjectHelper.hh9
-rw-r--r--include/qpdf/QPDFCryptoImpl.hh17
-rw-r--r--include/qpdf/QPDFCryptoProvider.hh19
-rw-r--r--include/qpdf/QPDFDocumentHelper.hh6
-rw-r--r--include/qpdf/QPDFEmbeddedFileDocumentHelper.hh10
-rw-r--r--include/qpdf/QPDFExc.hh24
-rw-r--r--include/qpdf/QPDFFileSpecObjectHelper.hh19
-rw-r--r--include/qpdf/QPDFFormFieldObjectHelper.hh4
-rw-r--r--include/qpdf/QPDFJob.hh74
-rw-r--r--include/qpdf/QPDFMatrix.hh18
-rw-r--r--include/qpdf/QPDFNameTreeObjectHelper.hh28
-rw-r--r--include/qpdf/QPDFNumberTreeObjectHelper.hh27
-rw-r--r--include/qpdf/QPDFObject.hh20
-rw-r--r--include/qpdf/QPDFObjectHandle.hh265
-rw-r--r--include/qpdf/QPDFObjectHelper.hh6
-rw-r--r--include/qpdf/QPDFOutlineDocumentHelper.hh7
-rw-r--r--include/qpdf/QPDFOutlineObjectHelper.hh2
-rw-r--r--include/qpdf/QPDFPageDocumentHelper.hh11
-rw-r--r--include/qpdf/QPDFPageLabelDocumentHelper.hh9
-rw-r--r--include/qpdf/QPDFPageObjectHelper.hh67
-rw-r--r--include/qpdf/QPDFStreamFilter.hh2
-rw-r--r--include/qpdf/QPDFSystemError.hh11
-rw-r--r--include/qpdf/QPDFTokenizer.hh61
-rw-r--r--include/qpdf/QPDFUsage.hh2
-rw-r--r--include/qpdf/QPDFWriter.hh268
-rw-r--r--include/qpdf/QPDFXRefEntry.hh6
-rw-r--r--include/qpdf/QTC.hh2
-rw-r--r--include/qpdf/QUtil.hh82
-rw-r--r--include/qpdf/qpdf-c.h259
-rw-r--r--include/qpdf/qpdfjob-c.h1
47 files changed, 1312 insertions, 998 deletions
diff --git a/include/qpdf/Buffer.hh b/include/qpdf/Buffer.hh
index 345e5aaa..4bddc1ef 100644
--- a/include/qpdf/Buffer.hh
+++ b/include/qpdf/Buffer.hh
@@ -25,8 +25,8 @@
#include <qpdf/DLL.h>
#include <qpdf/PointerHolder.hh>
-#include <stddef.h>
#include <memory>
+#include <stddef.h>
class Buffer
{
diff --git a/include/qpdf/BufferInputSource.hh b/include/qpdf/BufferInputSource.hh
index ac6ed8dc..7f94b8e8 100644
--- a/include/qpdf/BufferInputSource.hh
+++ b/include/qpdf/BufferInputSource.hh
@@ -22,8 +22,8 @@
#ifndef QPDF_BUFFERINPUTSOURCE_HH
#define QPDF_BUFFERINPUTSOURCE_HH
-#include <qpdf/InputSource.hh>
#include <qpdf/Buffer.hh>
+#include <qpdf/InputSource.hh>
class BufferInputSource: public InputSource
{
@@ -31,11 +31,11 @@ class BufferInputSource: public InputSource
// If own_memory is true, BufferInputSource will delete the buffer
// when finished with it. Otherwise, the caller owns the memory.
QPDF_DLL
- BufferInputSource(std::string const& description, Buffer* buf,
- bool own_memory = false);
+ BufferInputSource(
+ std::string const& description, Buffer* buf, bool own_memory = false);
QPDF_DLL
- BufferInputSource(std::string const& description,
- std::string const& contents);
+ BufferInputSource(
+ std::string const& description, std::string const& contents);
QPDF_DLL
virtual ~BufferInputSource();
QPDF_DLL
diff --git a/include/qpdf/Constants.h b/include/qpdf/Constants.h
index ab3ca1fe..c50a9563 100644
--- a/include/qpdf/Constants.h
+++ b/include/qpdf/Constants.h
@@ -29,16 +29,15 @@
/* Error Codes */
-enum qpdf_error_code_e
-{
+enum qpdf_error_code_e {
qpdf_e_success = 0,
- qpdf_e_internal, /* logic/programming error -- indicates bug */
- qpdf_e_system, /* I/O error, memory error, etc. */
- qpdf_e_unsupported, /* PDF feature not (yet) supported by qpdf */
- qpdf_e_password, /* incorrect password for encrypted file */
- qpdf_e_damaged_pdf, /* syntax errors or other damage in PDF */
- qpdf_e_pages, /* erroneous or unsupported pages structure */
- qpdf_e_object, /* type/bounds errors accessing objects */
+ qpdf_e_internal, /* logic/programming error -- indicates bug */
+ qpdf_e_system, /* I/O error, memory error, etc. */
+ qpdf_e_unsupported, /* PDF feature not (yet) supported by qpdf */
+ qpdf_e_password, /* incorrect password for encrypted file */
+ qpdf_e_damaged_pdf, /* syntax errors or other damage in PDF */
+ qpdf_e_pages, /* erroneous or unsupported pages structure */
+ qpdf_e_object, /* type/bounds errors accessing objects */
};
/* Object Types */
@@ -75,62 +74,56 @@ enum qpdf_object_type_e {
/* Write Parameters. See QPDFWriter.hh for details. */
-enum qpdf_object_stream_e
-{
- qpdf_o_disable = 0, /* disable object streams */
- qpdf_o_preserve, /* preserve object streams */
- qpdf_o_generate /* generate object streams */
+enum qpdf_object_stream_e {
+ qpdf_o_disable = 0, /* disable object streams */
+ qpdf_o_preserve, /* preserve object streams */
+ qpdf_o_generate /* generate object streams */
};
-enum qpdf_stream_data_e
-{
- qpdf_s_uncompress = 0, /* uncompress stream data */
- qpdf_s_preserve, /* preserve stream data compression */
- qpdf_s_compress /* compress stream data */
+enum qpdf_stream_data_e {
+ qpdf_s_uncompress = 0, /* uncompress stream data */
+ qpdf_s_preserve, /* preserve stream data compression */
+ qpdf_s_compress /* compress stream data */
};
/* Stream data flags */
/* See pipeStreamData in QPDFObjectHandle.hh for details on these flags. */
-enum qpdf_stream_encode_flags_e
-{
- qpdf_ef_compress = 1 << 0, /* compress uncompressed streams */
+enum qpdf_stream_encode_flags_e {
+ qpdf_ef_compress = 1 << 0, /* compress uncompressed streams */
qpdf_ef_normalize = 1 << 1, /* normalize content stream */
};
-enum qpdf_stream_decode_level_e
-{
+enum qpdf_stream_decode_level_e {
/* These must be in order from less to more decoding. */
- qpdf_dl_none = 0, /* preserve all stream filters */
- qpdf_dl_generalized, /* decode general-purpose filters */
- qpdf_dl_specialized, /* also decode other non-lossy filters */
- qpdf_dl_all /* also decode lossy filters */
+ qpdf_dl_none = 0, /* preserve all stream filters */
+ qpdf_dl_generalized, /* decode general-purpose filters */
+ qpdf_dl_specialized, /* also decode other non-lossy filters */
+ qpdf_dl_all /* also decode lossy filters */
};
/* R3 Encryption Parameters */
-enum qpdf_r3_print_e
-{
- qpdf_r3p_full = 0, /* allow all printing */
- qpdf_r3p_low, /* allow only low-resolution printing */
- qpdf_r3p_none /* allow no printing */
+enum qpdf_r3_print_e {
+ qpdf_r3p_full = 0, /* allow all printing */
+ qpdf_r3p_low, /* allow only low-resolution printing */
+ qpdf_r3p_none /* allow no printing */
};
/* qpdf_r3_modify_e doesn't allow the full flexibility of the spec. It
* corresponds to options in Acrobat 5's menus. The new interface in
* QPDFWriter offers more granularity and no longer uses this type.
*/
-enum qpdf_r3_modify_e /* Allowed changes: */
+enum qpdf_r3_modify_e /* Allowed changes: */
{
- qpdf_r3m_all = 0, /* All editing */
- qpdf_r3m_annotate, /* Comments, fill forms, signing, assembly */
- qpdf_r3m_form, /* Fill forms, signing, assembly */
- qpdf_r3m_assembly, /* Only document assembly */
- qpdf_r3m_none /* No modifications */
+ qpdf_r3m_all = 0, /* All editing */
+ qpdf_r3m_annotate, /* Comments, fill forms, signing, assembly */
+ qpdf_r3m_form, /* Fill forms, signing, assembly */
+ qpdf_r3m_assembly, /* Only document assembly */
+ qpdf_r3m_none /* No modifications */
};
/* Form field flags from the PDF spec */
-enum pdf_form_field_flag_e
-{
+enum pdf_form_field_flag_e {
/* flags that apply to all form fields */
ff_all_read_only = 1 << 0,
ff_all_required = 1 << 1,
@@ -162,8 +155,7 @@ enum pdf_form_field_flag_e
/* Annotation flags from the PDF spec */
-enum pdf_annotation_flag_e
-{
+enum pdf_annotation_flag_e {
an_invisible = 1 << 0,
an_hidden = 1 << 1,
an_print = 1 << 2,
@@ -177,8 +169,7 @@ enum pdf_annotation_flag_e
};
/* Encryption/password status for QPDFJob */
-enum qpdf_encryption_status_e
-{
+enum qpdf_encryption_status_e {
qpdf_es_encrypted = 1 << 0,
qpdf_es_password_incorrect = 1 << 1
};
diff --git a/include/qpdf/DLL.h b/include/qpdf/DLL.h
index ca9d57a7..5c2c77d7 100644
--- a/include/qpdf/DLL.h
+++ b/include/qpdf/DLL.h
@@ -32,7 +32,7 @@
#if (defined _WIN32 || defined __CYGWIN__) && defined(DLL_EXPORT)
# define QPDF_DLL __declspec(dllexport)
#elif defined __GNUC__
-# define QPDF_DLL __attribute__ ((visibility ("default")))
+# define QPDF_DLL __attribute__((visibility("default")))
#else
# define QPDF_DLL
#endif
diff --git a/include/qpdf/InputSource.hh b/include/qpdf/InputSource.hh
index 500e2518..044dc385 100644
--- a/include/qpdf/InputSource.hh
+++ b/include/qpdf/InputSource.hh
@@ -23,12 +23,12 @@
#define QPDF_INPUTSOURCE_HH
#include <qpdf/DLL.h>
-#include <qpdf/Types.h>
#include <qpdf/PointerHolder.hh>
+#include <qpdf/Types.h>
+#include <memory>
#include <stdio.h>
#include <string>
-#include <memory>
class QPDF_DLL_CLASS InputSource
{
@@ -71,13 +71,17 @@ class QPDF_DLL_CLASS InputSource
// methods return true and leave the input source positioned
// wherever check() left it at the end of the matching pattern.
QPDF_DLL
- bool findFirst(char const* start_chars,
- qpdf_offset_t offset, size_t len,
- Finder& finder);
+ bool findFirst(
+ char const* start_chars,
+ qpdf_offset_t offset,
+ size_t len,
+ Finder& finder);
QPDF_DLL
- bool findLast(char const* start_chars,
- qpdf_offset_t offset, size_t len,
- Finder& finder);
+ bool findLast(
+ char const* start_chars,
+ qpdf_offset_t offset,
+ size_t len,
+ Finder& finder);
virtual qpdf_offset_t findAndSkipNextEOL() = 0;
virtual std::string const& getName() const = 0;
diff --git a/include/qpdf/JSON.hh b/include/qpdf/JSON.hh
index 55a3ec73..2f54721c 100644
--- a/include/qpdf/JSON.hh
+++ b/include/qpdf/JSON.hh
@@ -38,12 +38,12 @@
#include <qpdf/DLL.h>
#include <qpdf/PointerHolder.hh>
-#include <string>
-#include <map>
-#include <vector>
-#include <list>
#include <functional>
+#include <list>
+#include <map>
#include <memory>
+#include <string>
+#include <vector>
class JSON
{
@@ -134,14 +134,13 @@ class JSON
f_optional = 1 << 0,
};
QPDF_DLL
- bool checkSchema(JSON schema, unsigned long flags,
- std::list<std::string>& errors);
+ bool checkSchema(
+ JSON schema, unsigned long flags, std::list<std::string>& errors);
// Same as passing 0 for flags
QPDF_DLL
bool checkSchema(JSON schema, std::list<std::string>& errors);
-
// Create a JSON object from a string.
QPDF_DLL
static JSON parse(std::string const&);
@@ -198,11 +197,12 @@ class JSON
JSON(std::shared_ptr<JSON_value>);
- static bool
- checkSchemaInternal(JSON_value* this_v, JSON_value* sch_v,
- unsigned long flags,
- std::list<std::string>& errors,
- std::string prefix);
+ static bool checkSchemaInternal(
+ JSON_value* this_v,
+ JSON_value* sch_v,
+ unsigned long flags,
+ std::list<std::string>& errors,
+ std::string prefix);
class Members
{
@@ -222,5 +222,4 @@ class JSON
PointerHolder<Members> m;
};
-
#endif // JSON_HH
diff --git a/include/qpdf/Pipeline.hh b/include/qpdf/Pipeline.hh
index e1adc284..3b06b406 100644
--- a/include/qpdf/Pipeline.hh
+++ b/include/qpdf/Pipeline.hh
@@ -47,8 +47,8 @@
#include <qpdf/DLL.h>
#include <qpdf/PointerHolder.hh>
-#include <string>
#include <memory>
+#include <string>
class QPDF_DLL_CLASS Pipeline
{
diff --git a/include/qpdf/Pl_Buffer.hh b/include/qpdf/Pl_Buffer.hh
index b2777033..70f5e29b 100644
--- a/include/qpdf/Pl_Buffer.hh
+++ b/include/qpdf/Pl_Buffer.hh
@@ -33,9 +33,9 @@
// For this pipeline, "next" may be null. If a next pointer is
// provided, this pipeline will also pass the data through to it.
+#include <qpdf/Buffer.hh>
#include <qpdf/Pipeline.hh>
#include <qpdf/PointerHolder.hh>
-#include <qpdf/Buffer.hh>
#include <memory>
@@ -68,7 +68,7 @@ class Pl_Buffer: public Pipeline
// a buffer of size *len allocated with malloc(). It is the
// caller's responsibility to call free() on the buffer.
QPDF_DLL
- void getMallocBuffer(unsigned char **buf, size_t* len);
+ void getMallocBuffer(unsigned char** buf, size_t* len);
private:
class Members
diff --git a/include/qpdf/Pl_Count.hh b/include/qpdf/Pl_Count.hh
index ba5520fd..b21153d4 100644
--- a/include/qpdf/Pl_Count.hh
+++ b/include/qpdf/Pl_Count.hh
@@ -25,8 +25,8 @@
// This pipeline is reusable; i.e., it is safe to call write() after
// calling finish().
-#include <qpdf/Types.h>
#include <qpdf/Pipeline.hh>
+#include <qpdf/Types.h>
class Pl_Count: public Pipeline
{
diff --git a/include/qpdf/Pl_DCT.hh b/include/qpdf/Pl_DCT.hh
index be714bc7..55ca4ff9 100644
--- a/include/qpdf/Pl_DCT.hh
+++ b/include/qpdf/Pl_DCT.hh
@@ -52,12 +52,14 @@ class Pl_DCT: public Pipeline
// Constructor for compressing image data
QPDF_DLL
- Pl_DCT(char const* identifier, Pipeline* next,
- JDIMENSION image_width,
- JDIMENSION image_height,
- int components,
- J_COLOR_SPACE color_space,
- CompressConfig* config_callback = 0);
+ Pl_DCT(
+ char const* identifier,
+ Pipeline* next,
+ JDIMENSION image_width,
+ JDIMENSION image_height,
+ int components,
+ J_COLOR_SPACE color_space,
+ CompressConfig* config_callback = 0);
QPDF_DLL
virtual ~Pl_DCT();
@@ -82,13 +84,14 @@ class Pl_DCT: public Pipeline
~Members();
private:
- Members(action_e action,
- char const* buf_description,
- JDIMENSION image_width = 0,
- JDIMENSION image_height = 0,
- int components = 1,
- J_COLOR_SPACE color_space = JCS_GRAYSCALE,
- CompressConfig* config_callback = 0);
+ Members(
+ action_e action,
+ char const* buf_description,
+ JDIMENSION image_width = 0,
+ JDIMENSION image_height = 0,
+ int components = 1,
+ J_COLOR_SPACE color_space = JCS_GRAYSCALE,
+ CompressConfig* config_callback = 0);
Members(Members const&);
action_e action;
diff --git a/include/qpdf/Pl_Flate.hh b/include/qpdf/Pl_Flate.hh
index 188cf7fa..74d21c5a 100644
--- a/include/qpdf/Pl_Flate.hh
+++ b/include/qpdf/Pl_Flate.hh
@@ -35,8 +35,11 @@ class Pl_Flate: public Pipeline
enum action_e { a_inflate, a_deflate };
QPDF_DLL
- Pl_Flate(char const* identifier, Pipeline* next,
- action_e action, unsigned int out_bufsize = def_bufsize);
+ Pl_Flate(
+ char const* identifier,
+ Pipeline* next,
+ action_e action,
+ unsigned int out_bufsize = def_bufsize);
QPDF_DLL
virtual ~Pl_Flate();
diff --git a/include/qpdf/Pl_QPDFTokenizer.hh b/include/qpdf/Pl_QPDFTokenizer.hh
index 0a95f0ba..58a218b5 100644
--- a/include/qpdf/Pl_QPDFTokenizer.hh
+++ b/include/qpdf/Pl_QPDFTokenizer.hh
@@ -24,10 +24,10 @@
#include <qpdf/Pipeline.hh>
-#include <qpdf/QPDFTokenizer.hh>
+#include <qpdf/Pl_Buffer.hh>
#include <qpdf/PointerHolder.hh>
#include <qpdf/QPDFObjectHandle.hh>
-#include <qpdf/Pl_Buffer.hh>
+#include <qpdf/QPDFTokenizer.hh>
#include <memory>
@@ -48,9 +48,10 @@ class Pl_QPDFTokenizer: public Pipeline
// pipeline that the token filter writes to. If next is not
// provided, any output written by the filter will be discarded.
QPDF_DLL
- Pl_QPDFTokenizer(char const* identifier,
- QPDFObjectHandle::TokenFilter* filter,
- Pipeline* next = 0);
+ Pl_QPDFTokenizer(
+ char const* identifier,
+ QPDFObjectHandle::TokenFilter* filter,
+ Pipeline* next = 0);
QPDF_DLL
virtual ~Pl_QPDFTokenizer();
QPDF_DLL
diff --git a/include/qpdf/Pl_RunLength.hh b/include/qpdf/Pl_RunLength.hh
index 307703ef..6761bfeb 100644
--- a/include/qpdf/Pl_RunLength.hh
+++ b/include/qpdf/Pl_RunLength.hh
@@ -30,8 +30,7 @@ class Pl_RunLength: public Pipeline
enum action_e { a_encode, a_decode };
QPDF_DLL
- Pl_RunLength(char const* identifier, Pipeline* next,
- action_e action);
+ Pl_RunLength(char const* identifier, Pipeline* next, action_e action);
QPDF_DLL
virtual ~Pl_RunLength();
diff --git a/include/qpdf/PointerHolder.hh b/include/qpdf/PointerHolder.hh
index 45236456..fb186778 100644
--- a/include/qpdf/PointerHolder.hh
+++ b/include/qpdf/PointerHolder.hh
@@ -187,18 +187,16 @@ class PointerHolder
}
~Data()
{
- if (array)
- {
- delete [] this->pointer;
- }
- else
- {
+ if (array) {
+ delete[] this->pointer;
+ } else {
delete this->pointer;
}
}
T* pointer;
bool array;
int refcount;
+
private:
Data(Data const&) = delete;
Data& operator=(Data const&) = delete;
@@ -208,7 +206,7 @@ class PointerHolder
#if POINTERHOLDER_TRANSITION >= 1
explicit
#endif // POINTERHOLDER_TRANSITION >= 1
- PointerHolder(T* pointer = 0)
+ PointerHolder(T* pointer = 0)
{
this->init(new Data(pointer, false));
}
@@ -222,16 +220,17 @@ class PointerHolder
{
this->copy(rhs);
}
- PointerHolder& operator=(PointerHolder const& rhs)
+ PointerHolder&
+ operator=(PointerHolder const& rhs)
{
- if (this != &rhs)
- {
+ if (this != &rhs) {
this->destroy();
this->copy(rhs);
}
return *this;
}
- PointerHolder& operator=(decltype(nullptr))
+ PointerHolder&
+ operator=(decltype(nullptr))
{
this->operator=(PointerHolder<T>());
return *this;
@@ -240,21 +239,25 @@ class PointerHolder
{
this->destroy();
}
- bool operator==(PointerHolder const& rhs) const
+ bool
+ operator==(PointerHolder const& rhs) const
{
return this->data->pointer == rhs.data->pointer;
}
- bool operator==(decltype(nullptr)) const
+ bool
+ operator==(decltype(nullptr)) const
{
return this->data->pointer == nullptr;
}
- bool operator<(PointerHolder const& rhs) const
+ bool
+ operator<(PointerHolder const& rhs) const
{
return this->data->pointer < rhs.data->pointer;
}
// get() is for interface compatibility with std::shared_ptr
- T* get() const
+ T*
+ get() const
{
return this->data->pointer;
}
@@ -264,70 +267,79 @@ class PointerHolder
#if POINTERHOLDER_TRANSITION >= 2
[[deprecated("use PointerHolder<T>::get() instead of getPointer()")]]
#endif // POINTERHOLDER_TRANSITION >= 2
- T* getPointer()
+ T*
+ getPointer()
{
return this->data->pointer;
}
#if POINTERHOLDER_TRANSITION >= 2
[[deprecated("use PointerHolder<T>::get() instead of getPointer()")]]
#endif // POINTERHOLDER_TRANSITION >= 2
- T const* getPointer() const
+ T const*
+ getPointer() const
{
return this->data->pointer;
}
#if POINTERHOLDER_TRANSITION >= 2
[[deprecated("use use_count() instead of getRefcount()")]]
#endif // POINTERHOLDER_TRANSITION >= 2
- int getRefcount() const
+ int
+ getRefcount() const
{
return this->data->refcount;
}
// use_count() is for compatibility with std::shared_ptr
- long use_count()
+ long
+ use_count()
{
return static_cast<long>(this->data->refcount);
}
- T const& operator*() const
+ T const&
+ operator*() const
{
return *this->data->pointer;
}
- T& operator*()
+ T&
+ operator*()
{
return *this->data->pointer;
}
- T const* operator->() const
+ T const*
+ operator->() const
{
return this->data->pointer;
}
- T* operator->()
+ T*
+ operator->()
{
return this->data->pointer;
}
private:
- void init(Data* data)
+ void
+ init(Data* data)
{
this->data = data;
++this->data->refcount;
}
- void copy(PointerHolder const& rhs)
+ void
+ copy(PointerHolder const& rhs)
{
this->init(rhs.data);
}
- void destroy()
+ void
+ destroy()
{
bool gone = false;
{
- if (--this->data->refcount == 0)
- {
+ if (--this->data->refcount == 0) {
gone = true;
}
}
- if (gone)
- {
+ if (gone) {
delete this->data;
}
}
@@ -335,7 +347,7 @@ class PointerHolder
Data* data;
};
-template<typename T, typename... _Args>
+template <typename T, typename... _Args>
inline PointerHolder<T>
make_pointer_holder(_Args&&... __args)
{
diff --git a/include/qpdf/QIntC.hh b/include/qpdf/QIntC.hh
index 484bae1a..ce2f47e9 100644
--- a/include/qpdf/QIntC.hh
+++ b/include/qpdf/QIntC.hh
@@ -24,12 +24,12 @@
#include <qpdf/DLL.h>
#include <qpdf/Types.h>
-#include <stdexcept>
+#include <cassert>
#include <iostream>
#include <limits>
-#include <sstream>
-#include <cassert>
#include <locale>
+#include <sstream>
+#include <stdexcept>
#include <type_traits>
// This namespace provides safe integer conversion that detects
@@ -51,9 +51,11 @@ namespace QIntC // QIntC = qpdf Integer Conversion
// throws a range_error otherwise. This class is specialized for
// each permutation of signed/unsigned for the From and To
// classes.
- template <typename From, typename To,
- bool From_signed = std::numeric_limits<From>::is_signed,
- bool To_signed = std::numeric_limits<To>::is_signed>
+ template <
+ typename From,
+ typename To,
+ bool From_signed = std::numeric_limits<From>::is_signed,
+ bool To_signed = std::numeric_limits<To>::is_signed>
class IntConverter
{
};
@@ -62,17 +64,16 @@ namespace QIntC // QIntC = qpdf Integer Conversion
class IntConverter<From, To, false, false>
{
public:
- static To convert(From const& i)
+ static To
+ convert(From const& i)
{
// From and To are both unsigned.
- if (i > std::numeric_limits<To>::max())
- {
+ if (i > std::numeric_limits<To>::max()) {
std::ostringstream msg;
msg.imbue(std::locale::classic());
- msg << "integer out of range converting " << i
- << " from a "
- << sizeof(From) << "-byte unsigned type to a "
- << sizeof(To) << "-byte unsigned type";
+ msg << "integer out of range converting " << i << " from a "
+ << sizeof(From) << "-byte unsigned type to a " << sizeof(To)
+ << "-byte unsigned type";
throw std::range_error(msg.str());
}
return static_cast<To>(i);
@@ -83,18 +84,17 @@ namespace QIntC // QIntC = qpdf Integer Conversion
class IntConverter<From, To, true, true>
{
public:
- static To convert(From const& i)
+ static To
+ convert(From const& i)
{
// From and To are both signed.
if ((i < std::numeric_limits<To>::min()) ||
- (i > std::numeric_limits<To>::max()))
- {
+ (i > std::numeric_limits<To>::max())) {
std::ostringstream msg;
msg.imbue(std::locale::classic());
- msg << "integer out of range converting " << i
- << " from a "
- << sizeof(From) << "-byte signed type to a "
- << sizeof(To) << "-byte signed type";
+ msg << "integer out of range converting " << i << " from a "
+ << sizeof(From) << "-byte signed type to a " << sizeof(To)
+ << "-byte signed type";
throw std::range_error(msg.str());
}
return static_cast<To>(i);
@@ -105,20 +105,19 @@ namespace QIntC // QIntC = qpdf Integer Conversion
class IntConverter<From, To, true, false>
{
public:
- static To convert(From const& i)
+ static To
+ convert(From const& i)
{
// From is signed, and To is unsigned. If i > 0, it's safe to
// convert it to the corresponding unsigned type and to
// compare with To's max.
auto ii = static_cast<typename to_u<From>::type>(i);
- if ((i < 0) || (ii > std::numeric_limits<To>::max()))
- {
+ if ((i < 0) || (ii > std::numeric_limits<To>::max())) {
std::ostringstream msg;
msg.imbue(std::locale::classic());
- msg << "integer out of range converting " << i
- << " from a "
- << sizeof(From) << "-byte signed type to a "
- << sizeof(To) << "-byte unsigned type";
+ msg << "integer out of range converting " << i << " from a "
+ << sizeof(From) << "-byte signed type to a " << sizeof(To)
+ << "-byte unsigned type";
throw std::range_error(msg.str());
}
return static_cast<To>(i);
@@ -129,20 +128,19 @@ namespace QIntC // QIntC = qpdf Integer Conversion
class IntConverter<From, To, false, true>
{
public:
- static To convert(From const& i)
+ static To
+ convert(From const& i)
{
// From is unsigned, and to is signed. Convert To's max to the
// unsigned version of To and compare i against that.
auto maxval = static_cast<typename to_u<To>::type>(
std::numeric_limits<To>::max());
- if (i > maxval)
- {
+ if (i > maxval) {
std::ostringstream msg;
msg.imbue(std::locale::classic());
- msg << "integer out of range converting " << i
- << " from a "
- << sizeof(From) << "-byte unsigned type to a "
- << sizeof(To) << "-byte signed type";
+ msg << "integer out of range converting " << i << " from a "
+ << sizeof(From) << "-byte unsigned type to a " << sizeof(To)
+ << "-byte signed type";
throw std::range_error(msg.str());
}
return static_cast<To>(i);
@@ -152,97 +150,105 @@ namespace QIntC // QIntC = qpdf Integer Conversion
// Specific converters. The return type of each function must match
// the second template parameter to IntConverter.
template <typename T>
- char to_char(T const& i)
+ char
+ to_char(T const& i)
{
return IntConverter<T, char>::convert(i);
}
template <typename T>
- unsigned char to_uchar(T const& i)
+ unsigned char
+ to_uchar(T const& i)
{
return IntConverter<T, unsigned char>::convert(i);
}
template <typename T>
- short to_short(T const& i)
+ short
+ to_short(T const& i)
{
return IntConverter<T, short>::convert(i);
}
template <typename T>
- unsigned short to_ushort(T const& i)
+ unsigned short
+ to_ushort(T const& i)
{
return IntConverter<T, unsigned short>::convert(i);
}
template <typename T>
- int to_int(T const& i)
+ int
+ to_int(T const& i)
{
return IntConverter<T, int>::convert(i);
}
template <typename T>
- unsigned int to_uint(T const& i)
+ unsigned int
+ to_uint(T const& i)
{
return IntConverter<T, unsigned int>::convert(i);
}
template <typename T>
- size_t to_size(T const& i)
+ size_t
+ to_size(T const& i)
{
return IntConverter<T, size_t>::convert(i);
}
template <typename T>
- qpdf_offset_t to_offset(T const& i)
+ qpdf_offset_t
+ to_offset(T const& i)
{
return IntConverter<T, qpdf_offset_t>::convert(i);
}
template <typename T>
- long to_long(T const& i)
+ long
+ to_long(T const& i)
{
- return IntConverter<T, long >::convert(i);
+ return IntConverter<T, long>::convert(i);
}
template <typename T>
- unsigned long to_ulong(T const& i)
+ unsigned long
+ to_ulong(T const& i)
{
- return IntConverter<T, unsigned long >::convert(i);
+ return IntConverter<T, unsigned long>::convert(i);
}
template <typename T>
- long long to_longlong(T const& i)
+ long long
+ to_longlong(T const& i)
{
return IntConverter<T, long long>::convert(i);
}
template <typename T>
- unsigned long long to_ulonglong(T const& i)
+ unsigned long long
+ to_ulonglong(T const& i)
{
return IntConverter<T, unsigned long long>::convert(i);
}
template <typename T>
- void range_check(T const& cur, T const& delta)
+ void
+ range_check(T const& cur, T const& delta)
{
- if ((delta > 0) != (cur > 0))
- {
+ if ((delta > 0) != (cur > 0)) {
return;
}
- if ((delta > 0) &&
- ((std::numeric_limits<T>::max() - cur) < delta))
- {
+ if ((delta > 0) && ((std::numeric_limits<T>::max() - cur) < delta)) {
std::ostringstream msg;
msg.imbue(std::locale::classic());
msg << "adding " << delta << " to " << cur
<< " would cause an integer overflow";
throw std::range_error(msg.str());
- }
- else if ((delta < 0) &&
- ((std::numeric_limits<T>::min() - cur) > delta))
- {
+ } else if (
+ (delta < 0) && ((std::numeric_limits<T>::min() - cur) > delta)) {
std::ostringstream msg;
msg.imbue(std::locale::classic());
msg << "adding " << delta << " to " << cur
@@ -252,25 +258,21 @@ namespace QIntC // QIntC = qpdf Integer Conversion
}
template <typename T>
- void range_check_substract(T const& cur, T const& delta)
+ void
+ range_check_substract(T const& cur, T const& delta)
{
- if ((delta >= 0) == (cur >= 0))
- {
+ if ((delta >= 0) == (cur >= 0)) {
return;
}
- if ((delta > 0) &&
- ((std::numeric_limits<T>::min() + delta) > cur))
- {
+ if ((delta > 0) && ((std::numeric_limits<T>::min() + delta) > cur)) {
std::ostringstream msg;
msg.imbue(std::locale::classic());
msg << "subtracting " << delta << " from " << cur
<< " would cause an integer underflow";
throw std::range_error(msg.str());
- }
- else if ((delta < 0) &&
- ((std::numeric_limits<T>::max() + delta) < cur))
- {
+ } else if (
+ (delta < 0) && ((std::numeric_limits<T>::max() + delta) < cur)) {
std::ostringstream msg;
msg.imbue(std::locale::classic());
msg << "subtracting " << delta << " from " << cur
@@ -278,6 +280,6 @@ namespace QIntC // QIntC = qpdf Integer Conversion
throw std::range_error(msg.str());
}
}
-};
+}; // namespace QIntC
#endif // QINTC_HH
diff --git a/include/qpdf/QPDF.hh b/include/qpdf/QPDF.hh
index efb0db95..d1d9f268 100644
--- a/include/qpdf/QPDF.hh
+++ b/include/qpdf/QPDF.hh
@@ -25,26 +25,25 @@
#include <qpdf/DLL.h>
#include <qpdf/Types.h>
+#include <functional>
+#include <iostream>
+#include <list>
+#include <map>
+#include <memory>
#include <stdio.h>
#include <string>
-#include <map>
-#include <list>
-#include <iostream>
#include <vector>
-#include <functional>
-#include <memory>
+#include <qpdf/Buffer.hh>
+#include <qpdf/InputSource.hh>
+#include <qpdf/PDFVersion.hh>
#include <qpdf/QIntC.hh>
#include <qpdf/QPDFExc.hh>
-#include <qpdf/QPDFObjectHandle.hh>
#include <qpdf/QPDFObjGen.hh>
-#include <qpdf/QPDFXRefEntry.hh>
#include <qpdf/QPDFObjectHandle.hh>
-#include <qpdf/QPDFTokenizer.hh>
#include <qpdf/QPDFStreamFilter.hh>
-#include <qpdf/Buffer.hh>
-#include <qpdf/InputSource.hh>
-#include <qpdf/PDFVersion.hh>
+#include <qpdf/QPDFTokenizer.hh>
+#include <qpdf/QPDFXRefEntry.hh>
class QPDF_Stream;
class BitStream;
@@ -87,24 +86,29 @@ class QPDF
// file will be closed at the end. Otherwise, the caller is
// responsible for closing the file.
QPDF_DLL
- void processFile(char const* description, FILE* file,
- bool close_file, char const* password = 0);
+ void processFile(
+ char const* description,
+ FILE* file,
+ bool close_file,
+ char const* password = 0);
// Parse a PDF file loaded into a memory buffer. This works
// exactly like processFile except that the PDF file is in memory
// instead of on disk. The description appears in any warning or
// error message in place of the file name.
QPDF_DLL
- void processMemoryFile(char const* description,
- char const* buf, size_t length,
- char const* password = 0);
+ void processMemoryFile(
+ char const* description,
+ char const* buf,
+ size_t length,
+ char const* password = 0);
// Parse a PDF file loaded from a custom InputSource. If you have
// your own method of retrieving a PDF file, you can subclass
// InputSource and use this method.
QPDF_DLL
- void processInputSource(PointerHolder<InputSource>,
- char const* password = 0);
+ void
+ processInputSource(PointerHolder<InputSource>, char const* password = 0);
// Close or otherwise release the input source. Once this has been
// called, no other methods of qpdf can be called safely except
@@ -149,7 +153,7 @@ class QPDF
QPDF_DLL
static void registerStreamFilter(
std::string const& filter_name,
- std::function<std::shared_ptr<QPDFStreamFilter> ()> factory);
+ std::function<std::shared_ptr<QPDFStreamFilter>()> factory);
// Parameter settings
@@ -312,8 +316,7 @@ class QPDF
QPDF_DLL
void swapObjects(QPDFObjGen const& og1, QPDFObjGen const& og2);
QPDF_DLL
- void swapObjects(int objid1, int generation1,
- int objid2, int generation2);
+ void swapObjects(int objid1, int generation1, int objid2, int generation2);
// Replace a reserved object. This is a wrapper around
// replaceObject but it guarantees that the underlying object is a
@@ -321,8 +324,7 @@ class QPDF
// to replacement.
QPDF_DLL
void
- replaceReserved(QPDFObjectHandle reserved,
- QPDFObjectHandle replacement);
+ replaceReserved(QPDFObjectHandle reserved, QPDFObjectHandle replacement);
// Copy an object from another QPDF to this one. Starting with
// qpdf version 8.3.0, it is no longer necessary to keep the
@@ -377,13 +379,19 @@ class QPDF
class EncryptionData
{
public:
-
// This class holds data read from the encryption dictionary.
- EncryptionData(int V, int R, int Length_bytes, int P,
- std::string const& O, std::string const& U,
- std::string const& OE, std::string const& UE,
- std::string const& Perms,
- std::string const& id1, bool encrypt_metadata) :
+ EncryptionData(
+ int V,
+ int R,
+ int Length_bytes,
+ int P,
+ std::string const& O,
+ std::string const& U,
+ std::string const& OE,
+ std::string const& UE,
+ std::string const& Perms,
+ std::string const& id1,
+ bool encrypt_metadata) :
V(V),
R(R),
Length_bytes(Length_bytes),
@@ -412,11 +420,12 @@ class QPDF
void setO(std::string const&);
void setU(std::string const&);
- void setV5EncryptionParameters(std::string const& O,
- std::string const& OE,
- std::string const& U,
- std::string const& UE,
- std::string const& Perms);
+ void setV5EncryptionParameters(
+ std::string const& O,
+ std::string const& OE,
+ std::string const& U,
+ std::string const& UE,
+ std::string const& Perms);
private:
EncryptionData(EncryptionData const&) = delete;
@@ -442,10 +451,13 @@ class QPDF
bool isEncrypted(int& R, int& P);
QPDF_DLL
- bool isEncrypted(int& R, int& P, int& V,
- encryption_method_e& stream_method,
- encryption_method_e& string_method,
- encryption_method_e& file_method);
+ bool isEncrypted(
+ int& R,
+ int& P,
+ int& V,
+ encryption_method_e& stream_method,
+ encryption_method_e& string_method,
+ encryption_method_e& file_method);
QPDF_DLL
bool ownerPasswordMatched() const;
@@ -480,26 +492,44 @@ class QPDF
static void trim_user_password(std::string& user_password);
QPDF_DLL
static std::string compute_data_key(
- std::string const& encryption_key, int objid, int generation,
- bool use_aes, int encryption_V, int encryption_R);
+ std::string const& encryption_key,
+ int objid,
+ int generation,
+ bool use_aes,
+ int encryption_V,
+ int encryption_R);
QPDF_DLL
static std::string compute_encryption_key(
std::string const& password, EncryptionData const& data);
QPDF_DLL
static void compute_encryption_O_U(
- char const* user_password, char const* owner_password,
- int V, int R, int key_len, int P, bool encrypt_metadata,
+ char const* user_password,
+ char const* owner_password,
+ int V,
+ int R,
+ int key_len,
+ int P,
+ bool encrypt_metadata,
std::string const& id1,
- std::string& O, std::string& U);
+ std::string& O,
+ std::string& U);
QPDF_DLL
static void compute_encryption_parameters_V5(
- char const* user_password, char const* owner_password,
- int V, int R, int key_len, int P, bool encrypt_metadata,
+ char const* user_password,
+ char const* owner_password,
+ int V,
+ int R,
+ int key_len,
+ int P,
+ bool encrypt_metadata,
std::string const& id1,
std::string& encryption_key,
- std::string& O, std::string& U,
- std::string& OE, std::string& UE, std::string& Perms);
+ std::string& O,
+ std::string& U,
+ std::string& OE,
+ std::string& UE,
+ std::string& Perms);
// Return the full user password as stored in the PDF file. For
// files encrypted with 40-bit or 128-bit keys, the user password
// can be recovered when the file is opened using the owner
@@ -587,8 +617,9 @@ class QPDF
// keys. This is used by QPDFWriter to avoid creation of dangling
// objects for stream dictionary keys it will be regenerating.
QPDF_DLL
- void optimize(std::map<int, int> const& object_stream_data,
- bool allow_changes = true);
+ void optimize(
+ std::map<int, int> const& object_stream_data,
+ bool allow_changes = true);
// ABI: make function optional and merge overloaded versions
QPDF_DLL
void optimize(
@@ -650,8 +681,8 @@ class QPDF
QPDF_DLL
void addPage(QPDFObjectHandle newpage, bool first);
QPDF_DLL
- void addPageAt(QPDFObjectHandle newpage, bool before,
- QPDFObjectHandle refpage);
+ void
+ addPageAt(QPDFObjectHandle newpage, bool before, QPDFObjectHandle refpage);
QPDF_DLL
void removePage(QPDFObjectHandle page);
// End legacy page helpers
@@ -661,9 +692,10 @@ class QPDF
class Writer
{
friend class QPDFWriter;
- private:
- static void getLinearizedParts(
+ private:
+ static void
+ getLinearizedParts(
QPDF& qpdf,
std::map<int, int> const& object_stream_data,
std::vector<QPDFObjectHandle>& part4,
@@ -672,28 +704,32 @@ class QPDF
std::vector<QPDFObjectHandle>& part8,
std::vector<QPDFObjectHandle>& part9)
{
- qpdf.getLinearizedParts(object_stream_data,
- part4, part6, part7, part8, part9);
+ qpdf.getLinearizedParts(
+ object_stream_data, part4, part6, part7, part8, part9);
}
- static void generateHintStream(
+ static void
+ generateHintStream(
QPDF& qpdf,
std::map<int, QPDFXRefEntry> const& xref,
std::map<int, qpdf_offset_t> const& lengths,
std::map<int, int> const& obj_renumber,
PointerHolder<Buffer>& hint_stream,
- int& S, int& O)
+ int& S,
+ int& O)
{
- return qpdf.generateHintStream(xref, lengths, obj_renumber,
- hint_stream, S, O);
+ return qpdf.generateHintStream(
+ xref, lengths, obj_renumber, hint_stream, S, O);
}
- static void getObjectStreamData(QPDF& qpdf, std::map<int, int>& omap)
+ static void
+ getObjectStreamData(QPDF& qpdf, std::map<int, int>& omap)
{
qpdf.getObjectStreamData(omap);
}
- static std::vector<QPDFObjGen> getCompressibleObjGens(QPDF& qpdf)
+ static std::vector<QPDFObjGen>
+ getCompressibleObjGens(QPDF& qpdf)
{
return qpdf.getCompressibleObjGens();
}
@@ -704,13 +740,15 @@ class QPDF
class Resolver
{
friend class QPDFObjectHandle;
+
private:
- static PointerHolder<QPDFObject> resolve(
- QPDF* qpdf, int objid, int generation)
+ static PointerHolder<QPDFObject>
+ resolve(QPDF* qpdf, int objid, int generation)
{
return qpdf->resolve(objid, generation);
}
- static bool objectChanged(
+ static bool
+ objectChanged(
QPDF* qpdf, QPDFObjGen const& og, PointerHolder<QPDFObject>& oph)
{
return qpdf->objectChanged(og, oph);
@@ -723,10 +761,13 @@ class QPDF
class StreamCopier
{
friend class QPDFObjectHandle;
+
private:
- static void copyStreamData(QPDF* qpdf,
- QPDFObjectHandle const& dest,
- QPDFObjectHandle const& src)
+ static void
+ copyStreamData(
+ QPDF* qpdf,
+ QPDFObjectHandle const& dest,
+ QPDFObjectHandle const& src)
{
qpdf->copyStreamData(dest, src);
}
@@ -738,19 +779,18 @@ class QPDF
class ParseGuard
{
friend class QPDFObjectHandle;
+
private:
ParseGuard(QPDF* qpdf) :
qpdf(qpdf)
{
- if (qpdf)
- {
+ if (qpdf) {
qpdf->inParse(true);
}
}
~ParseGuard()
{
- if (qpdf)
- {
+ if (qpdf) {
qpdf->inParse(false);
}
}
@@ -762,17 +802,29 @@ class QPDF
class Pipe
{
friend class QPDF_Stream;
+
private:
- static bool pipeStreamData(QPDF* qpdf, int objid, int generation,
- qpdf_offset_t offset, size_t length,
- QPDFObjectHandle dict,
- Pipeline* pipeline,
- bool suppress_warnings,
- bool will_retry)
+ static bool
+ pipeStreamData(
+ QPDF* qpdf,
+ int objid,
+ int generation,
+ qpdf_offset_t offset,
+ size_t length,
+ QPDFObjectHandle dict,
+ Pipeline* pipeline,
+ bool suppress_warnings,
+ bool will_retry)
{
return qpdf->pipeStreamData(
- objid, generation, offset, length, dict, pipeline,
- suppress_warnings, will_retry);
+ objid,
+ generation,
+ offset,
+ length,
+ dict,
+ pipeline,
+ suppress_warnings,
+ will_retry);
}
};
friend class Pipe;
@@ -788,9 +840,10 @@ class QPDF
end_after_space(0)
{
}
- ObjCache(PointerHolder<QPDFObject> object,
- qpdf_offset_t end_before_space,
- qpdf_offset_t end_after_space) :
+ ObjCache(
+ PointerHolder<QPDFObject> object,
+ qpdf_offset_t end_before_space,
+ qpdf_offset_t end_after_space) :
object(object),
end_before_space(end_before_space),
end_after_space(end_after_space)
@@ -813,6 +866,7 @@ class QPDF
class EncryptionParameters
{
friend class QPDF;
+
public:
EncryptionParameters();
@@ -839,6 +893,7 @@ class QPDF
class ForeignStreamData
{
friend class QPDF;
+
public:
ForeignStreamData(
PointerHolder<EncryptionParameters> encp,
@@ -867,18 +922,21 @@ class QPDF
{
}
virtual bool provideStreamData(
- int objid, int generation, Pipeline* pipeline,
- bool suppress_warnings, bool will_retry) override;
- void registerForeignStream(QPDFObjGen const& local_og,
- QPDFObjectHandle foreign_stream);
- void registerForeignStream(QPDFObjGen const& local_og,
- PointerHolder<ForeignStreamData>);
+ int objid,
+ int generation,
+ Pipeline* pipeline,
+ bool suppress_warnings,
+ bool will_retry) override;
+ void registerForeignStream(
+ QPDFObjGen const& local_og, QPDFObjectHandle foreign_stream);
+ void registerForeignStream(
+ QPDFObjGen const& local_og, PointerHolder<ForeignStreamData>);
private:
QPDF& destination_qpdf;
std::map<QPDFObjGen, QPDFObjectHandle> foreign_streams;
- std::map<QPDFObjGen,
- PointerHolder<ForeignStreamData> > foreign_stream_data;
+ std::map<QPDFObjGen, PointerHolder<ForeignStreamData>>
+ foreign_stream_data;
};
class StringDecrypter: public QPDFObjectHandle::StringDecrypter
@@ -911,6 +969,7 @@ class QPDF
{
this->qpdf->m->resolving.erase(og);
}
+
private:
QPDF* qpdf;
QPDFObjGen og;
@@ -922,56 +981,72 @@ class QPDF
void setTrailer(QPDFObjectHandle obj);
void read_xref(qpdf_offset_t offset);
void reconstruct_xref(QPDFExc& e);
- bool parse_xrefFirst(std::string const& line,
- int& obj, int& num, int& bytes);
- bool parse_xrefEntry(std::string const& line,
- qpdf_offset_t& f1, int& f2, char& type);
+ bool
+ parse_xrefFirst(std::string const& line, int& obj, int& num, int& bytes);
+ bool parse_xrefEntry(
+ std::string const& line, qpdf_offset_t& f1, int& f2, char& type);
qpdf_offset_t read_xrefTable(qpdf_offset_t offset);
qpdf_offset_t read_xrefStream(qpdf_offset_t offset);
- qpdf_offset_t processXRefStream(
- qpdf_offset_t offset, QPDFObjectHandle& xref_stream);
- void insertXrefEntry(int obj, int f0, qpdf_offset_t f1, int f2,
- bool overwrite = false);
- void setLastObjectDescription(std::string const& description,
- int objid, int generation);
+ qpdf_offset_t
+ processXRefStream(qpdf_offset_t offset, QPDFObjectHandle& xref_stream);
+ void insertXrefEntry(
+ int obj, int f0, qpdf_offset_t f1, int f2, bool overwrite = false);
+ void setLastObjectDescription(
+ std::string const& description, int objid, int generation);
QPDFObjectHandle readObject(
- PointerHolder<InputSource>, std::string const& description,
- int objid, int generation, bool in_object_stream);
+ PointerHolder<InputSource>,
+ std::string const& description,
+ int objid,
+ int generation,
+ bool in_object_stream);
size_t recoverStreamLength(
- PointerHolder<InputSource> input, int objid, int generation,
+ PointerHolder<InputSource> input,
+ int objid,
+ int generation,
qpdf_offset_t stream_offset);
- QPDFTokenizer::Token readToken(PointerHolder<InputSource>,
- size_t max_len = 0);
+ QPDFTokenizer::Token
+ readToken(PointerHolder<InputSource>, size_t max_len = 0);
QPDFObjectHandle readObjectAtOffset(
bool attempt_recovery,
- qpdf_offset_t offset, std::string const& description,
- int exp_objid, int exp_generation,
- int& act_objid, int& act_generation);
+ qpdf_offset_t offset,
+ std::string const& description,
+ int exp_objid,
+ int exp_generation,
+ int& act_objid,
+ int& act_generation);
bool objectChanged(QPDFObjGen const& og, PointerHolder<QPDFObject>& oph);
PointerHolder<QPDFObject> resolve(int objid, int generation);
void resolveObjectsInStream(int obj_stream_number);
void stopOnError(std::string const& message);
// Calls finish() on the pipeline when done but does not delete it
- bool pipeStreamData(int objid, int generation,
- qpdf_offset_t offset, size_t length,
- QPDFObjectHandle dict,
- Pipeline* pipeline,
- bool suppress_warnings,
- bool will_retry);
+ bool pipeStreamData(
+ int objid,
+ int generation,
+ qpdf_offset_t offset,
+ size_t length,
+ QPDFObjectHandle dict,
+ Pipeline* pipeline,
+ bool suppress_warnings,
+ bool will_retry);
bool pipeForeignStreamData(
PointerHolder<ForeignStreamData>,
- Pipeline*, bool suppress_warnings, bool will_retry);
- static bool pipeStreamData(PointerHolder<QPDF::EncryptionParameters> encp,
- PointerHolder<InputSource> file,
- QPDF& qpdf_for_warning,
- int objid, int generation,
- qpdf_offset_t offset, size_t length,
- QPDFObjectHandle dict,
- Pipeline* pipeline,
- bool suppress_warnings,
- bool will_retry);
+ Pipeline*,
+ bool suppress_warnings,
+ bool will_retry);
+ static bool pipeStreamData(
+ PointerHolder<QPDF::EncryptionParameters> encp,
+ PointerHolder<InputSource> file,
+ QPDF& qpdf_for_warning,
+ int objid,
+ int generation,
+ qpdf_offset_t offset,
+ size_t length,
+ QPDFObjectHandle dict,
+ Pipeline* pipeline,
+ bool suppress_warnings,
+ bool will_retry);
// For QPDFWriter:
@@ -985,11 +1060,13 @@ class QPDF
std::vector<QPDFObjectHandle>& part8,
std::vector<QPDFObjectHandle>& part9);
- void generateHintStream(std::map<int, QPDFXRefEntry> const& xref,
- std::map<int, qpdf_offset_t> const& lengths,
- std::map<int, int> const& obj_renumber,
- PointerHolder<Buffer>& hint_stream,
- int& S, int& O);
+ void generateHintStream(
+ std::map<int, QPDFXRefEntry> const& xref,
+ std::map<int, qpdf_offset_t> const& lengths,
+ std::map<int, int> const& obj_renumber,
+ PointerHolder<Buffer>& hint_stream,
+ int& S,
+ int& O);
// Map object to object stream that contains it
void getObjectStreamData(std::map<int, int>&);
@@ -1000,45 +1077,51 @@ class QPDF
// methods to support page handling
- void getAllPagesInternal(QPDFObjectHandle cur_pages,
- std::vector<QPDFObjectHandle>& result,
- std::set<QPDFObjGen>& visited,
- std::set<QPDFObjGen>& seen);
+ void getAllPagesInternal(
+ QPDFObjectHandle cur_pages,
+ std::vector<QPDFObjectHandle>& result,
+ std::set<QPDFObjGen>& visited,
+ std::set<QPDFObjGen>& seen);
void insertPage(QPDFObjectHandle newpage, int pos);
void flattenPagesTree();
- void insertPageobjToPage(QPDFObjectHandle const& obj, int pos,
- bool check_duplicate);
+ void insertPageobjToPage(
+ QPDFObjectHandle const& obj, int pos, bool check_duplicate);
// methods to support encryption -- implemented in QPDF_encryption.cc
- static encryption_method_e interpretCF(
- PointerHolder<EncryptionParameters> encp, QPDFObjectHandle);
+ static encryption_method_e
+ interpretCF(PointerHolder<EncryptionParameters> encp, QPDFObjectHandle);
void initializeEncryption();
static std::string getKeyForObject(
PointerHolder<EncryptionParameters> encp,
- int objid, int generation, bool use_aes);
+ int objid,
+ int generation,
+ bool use_aes);
void decryptString(std::string&, int objid, int generation);
static std::string compute_encryption_key_from_password(
std::string const& password, EncryptionData const& data);
static std::string recover_encryption_key_with_password(
std::string const& password, EncryptionData const& data);
static std::string recover_encryption_key_with_password(
- std::string const& password, EncryptionData const& data,
+ std::string const& password,
+ EncryptionData const& data,
bool& perms_valid);
static void decryptStream(
PointerHolder<EncryptionParameters> encp,
PointerHolder<InputSource> file,
- QPDF& qpdf_for_warning, Pipeline*& pipeline,
- int objid, int generation,
+ QPDF& qpdf_for_warning,
+ Pipeline*& pipeline,
+ int objid,
+ int generation,
QPDFObjectHandle& stream_dict,
std::vector<std::shared_ptr<Pipeline>>& heap);
// Methods to support object copying
- void reserveObjects(QPDFObjectHandle foreign, ObjCopier& obj_copier,
- bool top);
+ void
+ reserveObjects(QPDFObjectHandle foreign, ObjCopier& obj_copier, bool top);
QPDFObjectHandle replaceForeignIndirectObjects(
QPDFObjectHandle foreign, ObjCopier& obj_copier, bool top);
- void copyStreamData(
- QPDFObjectHandle dest_stream, QPDFObjectHandle src_stream);
+ void
+ copyStreamData(QPDFObjectHandle dest_stream, QPDFObjectHandle src_stream);
// Linearization Hint table structures.
// Naming conventions:
@@ -1065,14 +1148,14 @@ class QPDF
{
}
- int delta_nobjects; // 1
- qpdf_offset_t delta_page_length; // 2
- int nshared_objects; // 3
+ int delta_nobjects; // 1
+ qpdf_offset_t delta_page_length; // 2
+ int nshared_objects; // 3
// vectors' sizes = nshared_objects
- std::vector<int> shared_identifiers; // 4
- std::vector<int> shared_numerators; // 5
- qpdf_offset_t delta_content_offset; // 6
- qpdf_offset_t delta_content_length; // 7
+ std::vector<int> shared_identifiers; // 4
+ std::vector<int> shared_numerators; // 5
+ qpdf_offset_t delta_content_offset; // 6
+ qpdf_offset_t delta_content_length; // 7
};
// PDF 1.4: Table F.3
@@ -1095,19 +1178,19 @@ class QPDF
{
}
- int min_nobjects; // 1
- qpdf_offset_t first_page_offset; // 2
- int nbits_delta_nobjects; // 3
- int min_page_length; // 4
- int nbits_delta_page_length; // 5
- int min_content_offset; // 6
- int nbits_delta_content_offset; // 7
- int min_content_length; // 8
- int nbits_delta_content_length; // 9
- int nbits_nshared_objects; // 10
- int nbits_shared_identifier; // 11
- int nbits_shared_numerator; // 12
- int shared_denominator; // 13
+ int min_nobjects; // 1
+ qpdf_offset_t first_page_offset; // 2
+ int nbits_delta_nobjects; // 3
+ int min_page_length; // 4
+ int nbits_delta_page_length; // 5
+ int min_content_offset; // 6
+ int nbits_delta_content_offset; // 7
+ int min_content_length; // 8
+ int nbits_delta_content_length; // 9
+ int nbits_nshared_objects; // 10
+ int nbits_shared_identifier; // 11
+ int nbits_shared_numerator; // 12
+ int shared_denominator; // 13
// vector size is npages
std::vector<HPageOffsetEntry> entries;
};
@@ -1123,9 +1206,9 @@ class QPDF
}
// Item 3 is a 128-bit signature (unsupported by Acrobat)
- int delta_group_length; // 1
- int signature_present; // 2 -- always 0
- int nobjects_minus_one; // 4 -- always 0
+ int delta_group_length; // 1
+ int signature_present; // 2 -- always 0
+ int nobjects_minus_one; // 4 -- always 0
};
// PDF 1.4: Table F.5
@@ -1142,13 +1225,13 @@ class QPDF
{
}
- int first_shared_obj; // 1
- qpdf_offset_t first_shared_offset; // 2
- int nshared_first_page; // 3
- int nshared_total; // 4
- int nbits_nobjects; // 5
- int min_group_length; // 6
- int nbits_delta_group_length; // 7
+ int first_shared_obj; // 1
+ qpdf_offset_t first_shared_offset; // 2
+ int nshared_first_page; // 3
+ int nshared_total; // 4
+ int nbits_nobjects; // 5
+ int min_group_length; // 6
+ int nbits_delta_group_length; // 7
// vector size is nshared_total
std::vector<HSharedObjectEntry> entries;
};
@@ -1164,10 +1247,10 @@ class QPDF
{
}
- int first_object; // 1
- qpdf_offset_t first_object_offset; // 2
- int nobjects; // 3
- int group_length; // 4
+ int first_object; // 1
+ qpdf_offset_t first_object_offset; // 2
+ int nobjects; // 3
+ int group_length; // 4
};
// Other linearization data structures
@@ -1261,15 +1344,13 @@ class QPDF
// No need for CHGeneric -- HGeneric is fine as is.
-
// Data structures to support optimization -- implemented in
// QPDF_optimization.cc
class ObjUser
{
public:
- enum user_e
- {
+ enum user_e {
ou_bad,
ou_page,
ou_thumb,
@@ -1293,8 +1374,8 @@ class QPDF
bool operator<(ObjUser const&) const;
user_e ou_type;
- int pageno; // if ou_page;
- std::string key; // if ou_trailer_key or ou_root_key
+ int pageno; // if ou_page;
+ std::string key; // if ou_trailer_key or ou_root_key
};
class PatternFinder: public InputSource::Finder
@@ -1308,7 +1389,8 @@ class QPDF
virtual ~PatternFinder()
{
}
- virtual bool check()
+ virtual bool
+ check()
{
return (this->qpdf.*checker)();
}
@@ -1328,8 +1410,8 @@ class QPDF
void readLinearizationData();
bool checkLinearizationInternal();
void dumpLinearizationDataInternal();
- QPDFObjectHandle readHintStream(
- Pipeline&, qpdf_offset_t offset, size_t length);
+ QPDFObjectHandle
+ readHintStream(Pipeline&, qpdf_offset_t offset, size_t length);
void readHPageOffset(BitStream);
void readHSharedObject(BitStream);
void readHGeneric(BitStream, HGeneric&);
@@ -1337,30 +1419,32 @@ class QPDF
qpdf_offset_t getLinearizationOffset(QPDFObjGen const&);
QPDFObjectHandle getUncompressedObject(
QPDFObjectHandle&, std::map<int, int> const& object_stream_data);
- int lengthNextN(int first_object, int n,
- std::list<std::string>& errors);
- void checkHPageOffset(std::list<std::string>& errors,
- std::list<std::string>& warnings,
- std::vector<QPDFObjectHandle> const& pages,
- std::map<int, int>& idx_to_obj);
- void checkHSharedObject(std::list<std::string>& warnings,
- std::list<std::string>& errors,
- std::vector<QPDFObjectHandle> const& pages,
- std::map<int, int>& idx_to_obj);
+ int lengthNextN(int first_object, int n, std::list<std::string>& errors);
+ void checkHPageOffset(
+ std::list<std::string>& errors,
+ std::list<std::string>& warnings,
+ std::vector<QPDFObjectHandle> const& pages,
+ std::map<int, int>& idx_to_obj);
+ void checkHSharedObject(
+ std::list<std::string>& warnings,
+ std::list<std::string>& errors,
+ std::vector<QPDFObjectHandle> const& pages,
+ std::map<int, int>& idx_to_obj);
void checkHOutlines(std::list<std::string>& warnings);
void dumpHPageOffset();
void dumpHSharedObject();
void dumpHGeneric(HGeneric&);
qpdf_offset_t adjusted_offset(qpdf_offset_t offset);
QPDFObjectHandle objGenToIndirect(QPDFObjGen const&);
- void calculateLinearizationData(
- std::map<int, int> const& object_stream_data);
+ void
+ calculateLinearizationData(std::map<int, int> const& object_stream_data);
void pushOutlinesToPart(
std::vector<QPDFObjectHandle>& part,
std::set<QPDFObjGen>& lc_outlines,
std::map<int, int> const& object_stream_data);
int outputLengthNextN(
- int in_object, int n,
+ int in_object,
+ int n,
std::map<int, qpdf_offset_t> const& lengths,
std::map<int, int> const& obj_renumber);
void calculateHPageOffset(
@@ -1379,37 +1463,46 @@ class QPDF
void writeHSharedObject(BitWriter&);
void writeHGeneric(BitWriter&, HGeneric&);
-
// Methods to support optimization
- void pushInheritedAttributesToPage(bool allow_changes,
- bool warn_skipped_keys);
+ void
+ pushInheritedAttributesToPage(bool allow_changes, bool warn_skipped_keys);
void pushInheritedAttributesToPageInternal(
QPDFObjectHandle,
- std::map<std::string, std::vector<QPDFObjectHandle> >&,
+ std::map<std::string, std::vector<QPDFObjectHandle>>&,
std::vector<QPDFObjectHandle>& all_pages,
- bool allow_changes, bool warn_skipped_keys,
+ bool allow_changes,
+ bool warn_skipped_keys,
std::set<QPDFObjGen>& visited);
void updateObjectMaps(
- ObjUser const& ou, QPDFObjectHandle oh,
+ ObjUser const& ou,
+ QPDFObjectHandle oh,
std::function<int(QPDFObjectHandle&)> skip_stream_parameters);
void updateObjectMapsInternal(
- ObjUser const& ou, QPDFObjectHandle oh,
+ ObjUser const& ou,
+ QPDFObjectHandle oh,
std::function<int(QPDFObjectHandle&)> skip_stream_parameters,
- std::set<QPDFObjGen>& visited, bool top,
+ std::set<QPDFObjGen>& visited,
+ bool top,
int depth);
void filterCompressedObjects(std::map<int, int> const& object_stream_data);
// Type conversion helper methods
- template<typename T> static qpdf_offset_t toO(T const& i)
+ template <typename T>
+ static qpdf_offset_t
+ toO(T const& i)
{
return QIntC::to_offset(i);
}
- template<typename T> static size_t toS(T const& i)
+ template <typename T>
+ static size_t
+ toS(T const& i)
{
return QIntC::to_size(i);
}
- template<typename T> static int toI(T const& i)
+ template <typename T>
+ static int
+ toI(T const& i)
{
return QIntC::to_int(i);
}
@@ -1490,8 +1583,8 @@ class QPDF
std::vector<QPDFObjectHandle> part9;
// Optimization data
- std::map<ObjUser, std::set<QPDFObjGen> > obj_user_to_objects;
- std::map<QPDFObjGen, std::set<ObjUser> > object_to_obj_users;
+ std::map<ObjUser, std::set<QPDFObjGen>> obj_user_to_objects;
+ std::map<QPDFObjGen, std::set<ObjUser>> object_to_obj_users;
};
// Keep all member variables inside the Members object, which we
diff --git a/include/qpdf/QPDFAcroFormDocumentHelper.hh b/include/qpdf/QPDFAcroFormDocumentHelper.hh
index dc4b05ad..236b2835 100644
--- a/include/qpdf/QPDFAcroFormDocumentHelper.hh
+++ b/include/qpdf/QPDFAcroFormDocumentHelper.hh
@@ -67,7 +67,6 @@
// the "/AcroForm" field entry until you find the annotation
// dictionary.
-
#include <qpdf/QPDFDocumentHelper.hh>
#include <qpdf/DLL.h>
@@ -144,8 +143,7 @@ class QPDFAcroFormDocumentHelper: public QPDFDocumentHelper
// information to be accurate, any changes to field names must be
// done through setFormFieldName() above.
QPDF_DLL
- std::set<QPDFObjGen>
- getFieldsWithQualifiedName(std::string const& name);
+ std::set<QPDFObjGen> getFieldsWithQualifiedName(std::string const& name);
// Return the annotations associated with a terminal field. Note
// that in the case of a field having a single annotation, the
@@ -153,17 +151,17 @@ class QPDFAcroFormDocumentHelper: public QPDFDocumentHelper
// object for the field.
QPDF_DLL
std::vector<QPDFAnnotationObjectHelper>
- getAnnotationsForField(QPDFFormFieldObjectHelper);
+ getAnnotationsForField(QPDFFormFieldObjectHelper);
// Return annotations of subtype /Widget for a page.
QPDF_DLL
std::vector<QPDFAnnotationObjectHelper>
- getWidgetAnnotationsForPage(QPDFPageObjectHelper);
+ getWidgetAnnotationsForPage(QPDFPageObjectHelper);
// Return top-level form fields for a page.
QPDF_DLL
std::vector<QPDFFormFieldObjectHelper>
- getFormFieldsForPage(QPDFPageObjectHelper);
+ getFormFieldsForPage(QPDFPageObjectHelper);
// Return the terminal field that is associated with this
// annotation. If the annotation dictionary is merged with the
@@ -173,8 +171,7 @@ class QPDFAcroFormDocumentHelper: public QPDFDocumentHelper
// not be an associated field, and this method will return a
// helper associated with a null object (isNull() == true).
QPDF_DLL
- QPDFFormFieldObjectHelper
- getFieldForAnnotation(QPDFAnnotationObjectHelper);
+ QPDFFormFieldObjectHelper getFieldForAnnotation(QPDFAnnotationObjectHelper);
// Return the current value of /NeedAppearances. If
// /NeedAppearances is missing, return false as that is how PDF
@@ -260,30 +257,33 @@ class QPDFAcroFormDocumentHelper: public QPDFDocumentHelper
// happens with qpdf --split-pages.
[[deprecated("Use fixCopiedAnnotations instead")]]
// ABI: delete this method
- QPDF_DLL
- void copyFieldsFromForeignPage(
+ QPDF_DLL void
+ copyFieldsFromForeignPage(
QPDFPageObjectHelper foreign_page,
QPDFAcroFormDocumentHelper& foreign_afdh,
std::vector<QPDFObjectHandle>* copied_fields = nullptr);
private:
void analyze();
- void traverseField(QPDFObjectHandle field,
- QPDFObjectHandle parent,
- int depth, std::set<QPDFObjGen>& visited);
+ void traverseField(
+ QPDFObjectHandle field,
+ QPDFObjectHandle parent,
+ int depth,
+ std::set<QPDFObjGen>& visited);
QPDFObjectHandle getOrCreateAcroForm();
void adjustInheritedFields(
QPDFObjectHandle obj,
- bool override_da, std::string const& from_default_da,
- bool override_q, int from_default_q);
+ bool override_da,
+ std::string const& from_default_da,
+ bool override_q,
+ int from_default_q);
void adjustDefaultAppearances(
QPDFObjectHandle obj,
- std::map<std::string,
- std::map<std::string, std::string>> const& dr_map);
+ std::map<std::string, std::map<std::string, std::string>> const&
+ dr_map);
void adjustAppearanceStream(
QPDFObjectHandle stream,
- std::map<std::string,
- std::map<std::string, std::string>> dr_map);
+ std::map<std::string, std::map<std::string, std::string>> dr_map);
class Members
{
@@ -298,9 +298,8 @@ class QPDFAcroFormDocumentHelper: public QPDFDocumentHelper
Members(Members const&);
bool cache_valid;
- std::map<QPDFObjGen,
- std::vector<QPDFAnnotationObjectHelper>
- > field_to_annotations;
+ std::map<QPDFObjGen, std::vector<QPDFAnnotationObjectHelper>>
+ field_to_annotations;
std::map<QPDFObjGen, QPDFFormFieldObjectHelper> annotation_to_field;
std::map<QPDFObjGen, std::string> field_to_name;
std::map<std::string, std::set<QPDFObjGen>> name_to_fields;
diff --git a/include/qpdf/QPDFAnnotationObjectHelper.hh b/include/qpdf/QPDFAnnotationObjectHelper.hh
index 480688e0..26ee050a 100644
--- a/include/qpdf/QPDFAnnotationObjectHelper.hh
+++ b/include/qpdf/QPDFAnnotationObjectHelper.hh
@@ -22,8 +22,8 @@
#ifndef QPDFANNOTATIONOBJECTHELPER_HH
#define QPDFANNOTATIONOBJECTHELPER_HH
-#include <qpdf/QPDFObjectHelper.hh>
#include <qpdf/Constants.h>
+#include <qpdf/QPDFObjectHelper.hh>
#include <qpdf/DLL.h>
@@ -78,8 +78,8 @@ class QPDFAnnotationObjectHelper: public QPDFObjectHelper
// which appearance stream is desired. If not specified, the
// appearance state in "/AS" will used.
QPDF_DLL
- QPDFObjectHandle getAppearanceStream(std::string const& which,
- std::string const& state = "");
+ QPDFObjectHandle getAppearanceStream(
+ std::string const& which, std::string const& state = "");
// Generate text suitable for addition to the containing page's
// content stream that draws this annotation's appearance stream
@@ -96,7 +96,8 @@ class QPDFAnnotationObjectHelper: public QPDFObjectHelper
// preparing to print.
QPDF_DLL
std::string getPageContentForAppearance(
- std::string const& name, int rotate,
+ std::string const& name,
+ int rotate,
int required_flags = 0,
int forbidden_flags = an_invisible | an_hidden);
diff --git a/include/qpdf/QPDFCryptoImpl.hh b/include/qpdf/QPDFCryptoImpl.hh
index 43d2f170..bf3c9087 100644
--- a/include/qpdf/QPDFCryptoImpl.hh
+++ b/include/qpdf/QPDFCryptoImpl.hh
@@ -77,19 +77,22 @@ class QPDF_DLL_CLASS QPDFCryptoImpl
virtual void RC4_init(unsigned char const* key_data, int key_len = -1) = 0;
// out_data = 0 means to encrypt/decrypt in place
QPDF_DLL
- virtual void RC4_process(unsigned char* in_data, size_t len,
- unsigned char* out_data = 0) = 0;
+ virtual void RC4_process(
+ unsigned char* in_data, size_t len, unsigned char* out_data = 0) = 0;
QPDF_DLL
virtual void RC4_finalize() = 0;
static size_t constexpr rijndael_buf_size = 16;
QPDF_DLL
virtual void rijndael_init(
- bool encrypt, unsigned char const* key_data, size_t key_len,
- bool cbc_mode, unsigned char* cbc_block) = 0;
- QPDF_DLL
- virtual void rijndael_process(
- unsigned char* in_data, unsigned char* out_data) = 0;
+ bool encrypt,
+ unsigned char const* key_data,
+ size_t key_len,
+ bool cbc_mode,
+ unsigned char* cbc_block) = 0;
+ QPDF_DLL
+ virtual void
+ rijndael_process(unsigned char* in_data, unsigned char* out_data) = 0;
QPDF_DLL
virtual void rijndael_finalize() = 0;
};
diff --git a/include/qpdf/QPDFCryptoProvider.hh b/include/qpdf/QPDFCryptoProvider.hh
index 057f6624..d8577859 100644
--- a/include/qpdf/QPDFCryptoProvider.hh
+++ b/include/qpdf/QPDFCryptoProvider.hh
@@ -24,11 +24,11 @@
#include <qpdf/DLL.h>
#include <qpdf/QPDFCryptoImpl.hh>
-#include <string>
+#include <functional>
#include <map>
-#include <set>
#include <memory>
-#include <functional>
+#include <set>
+#include <string>
// This class is part of qpdf's pluggable crypto provider support.
// Most users won't need to know or care about this class, but you can
@@ -38,7 +38,6 @@
class QPDFCryptoProvider
{
public:
-
// Methods for getting and registering crypto implementations.
// These methods are not thread-safe.
@@ -50,15 +49,13 @@ class QPDFCryptoProvider
// Return an instance of the crypto provider registered using the
// given name.
QPDF_DLL
- static std::shared_ptr<QPDFCryptoImpl>
- getImpl(std::string const& name);
+ static std::shared_ptr<QPDFCryptoImpl> getImpl(std::string const& name);
// Register the given type (T) as a crypto implementation. T must
// be derived from QPDFCryptoImpl and must have a constructor that
// takes no arguments.
- template<typename T>
- QPDF_DLL
- static void registerImpl(std::string const& name);
+ template <typename T>
+ QPDF_DLL static void registerImpl(std::string const& name);
// Set the crypto provider registered with the given name as the
// default crypto implementation.
@@ -83,7 +80,7 @@ class QPDFCryptoProvider
std::shared_ptr<QPDFCryptoImpl>
getImpl_internal(std::string const& name) const;
- template<typename T>
+ template <typename T>
void registerImpl_internal(std::string const& name);
void setDefaultProvider_internal(std::string const& name);
@@ -100,7 +97,7 @@ class QPDFCryptoProvider
Members(Members const&) = delete;
Members& operator=(Members const&) = delete;
- typedef std::function<std::shared_ptr<QPDFCryptoImpl> ()> provider_fn;
+ typedef std::function<std::shared_ptr<QPDFCryptoImpl>()> provider_fn;
std::string default_provider;
std::map<std::string, provider_fn> providers;
};
diff --git a/include/qpdf/QPDFDocumentHelper.hh b/include/qpdf/QPDFDocumentHelper.hh
index c198089a..d33e90b8 100644
--- a/include/qpdf/QPDFDocumentHelper.hh
+++ b/include/qpdf/QPDFDocumentHelper.hh
@@ -49,12 +49,14 @@ class QPDFDocumentHelper
{
}
QPDF_DLL
- QPDF& getQPDF()
+ QPDF&
+ getQPDF()
{
return this->qpdf;
}
QPDF_DLL
- QPDF const& getQPDF() const
+ QPDF const&
+ getQPDF() const
{
return this->qpdf;
}
diff --git a/include/qpdf/QPDFEmbeddedFileDocumentHelper.hh b/include/qpdf/QPDFEmbeddedFileDocumentHelper.hh
index 9691bfe6..73d5f041 100644
--- a/include/qpdf/QPDFEmbeddedFileDocumentHelper.hh
+++ b/include/qpdf/QPDFEmbeddedFileDocumentHelper.hh
@@ -24,13 +24,13 @@
#include <qpdf/QPDFDocumentHelper.hh>
+#include <qpdf/DLL.h>
#include <qpdf/QPDF.hh>
-#include <qpdf/QPDFNameTreeObjectHelper.hh>
#include <qpdf/QPDFFileSpecObjectHelper.hh>
-#include <qpdf/DLL.h>
+#include <qpdf/QPDFNameTreeObjectHelper.hh>
-#include <memory>
#include <map>
+#include <memory>
// This class provides a higher level interface around document-level
// file attachments, also known as embedded files. These are discussed
@@ -48,8 +48,8 @@ class QPDFEmbeddedFileDocumentHelper: public QPDFDocumentHelper
bool hasEmbeddedFiles() const;
QPDF_DLL
- std::map<std::string,
- std::shared_ptr<QPDFFileSpecObjectHelper>> getEmbeddedFiles();
+ std::map<std::string, std::shared_ptr<QPDFFileSpecObjectHelper>>
+ getEmbeddedFiles();
// If an embedded file with the given name exists, return a
// (shared) pointer to it. Otherwise, return nullptr.
diff --git a/include/qpdf/QPDFExc.hh b/include/qpdf/QPDFExc.hh
index 6a46aff8..1d88bcf9 100644
--- a/include/qpdf/QPDFExc.hh
+++ b/include/qpdf/QPDFExc.hh
@@ -22,22 +22,23 @@
#ifndef QPDFEXC_HH
#define QPDFEXC_HH
+#include <qpdf/Constants.h>
#include <qpdf/DLL.h>
#include <qpdf/Types.h>
-#include <qpdf/Constants.h>
-#include <string>
#include <stdexcept>
+#include <string>
class QPDF_DLL_CLASS QPDFExc: public std::runtime_error
{
public:
QPDF_DLL
- QPDFExc(qpdf_error_code_e error_code,
- std::string const& filename,
- std::string const& object,
- qpdf_offset_t offset,
- std::string const& message);
+ QPDFExc(
+ qpdf_error_code_e error_code,
+ std::string const& filename,
+ std::string const& object,
+ qpdf_offset_t offset,
+ std::string const& message);
QPDF_DLL
virtual ~QPDFExc() noexcept
{
@@ -65,10 +66,11 @@ class QPDF_DLL_CLASS QPDFExc: public std::runtime_error
std::string const& getMessageDetail() const;
private:
- static std::string createWhat(std::string const& filename,
- std::string const& object,
- qpdf_offset_t offset,
- std::string const& message);
+ static std::string createWhat(
+ std::string const& filename,
+ std::string const& object,
+ qpdf_offset_t offset,
+ std::string const& message);
// This class does not use the Members pattern to avoid needless
// memory allocations during exception handling.
diff --git a/include/qpdf/QPDFFileSpecObjectHelper.hh b/include/qpdf/QPDFFileSpecObjectHelper.hh
index 9f442145..87c94399 100644
--- a/include/qpdf/QPDFFileSpecObjectHelper.hh
+++ b/include/qpdf/QPDFFileSpecObjectHelper.hh
@@ -26,8 +26,8 @@
#include <qpdf/DLL.h>
-#include <qpdf/QPDFObjectHandle.hh>
#include <qpdf/QPDFEFStreamObjectHelper.hh>
+#include <qpdf/QPDFObjectHandle.hh>
// This class provides a higher level interface around File
// Specification dictionaries, which are discussed in section 7.11 of
@@ -77,22 +77,16 @@ class QPDFFileSpecObjectHelper: public QPDFObjectHelper
// filename, and attach the contents of the specified file as data
// in an embedded file stream.
QPDF_DLL
- static
- QPDFFileSpecObjectHelper createFileSpec(
- QPDF& qpdf,
- std::string const& filename,
- std::string const& fullpath);
+ static QPDFFileSpecObjectHelper createFileSpec(
+ QPDF& qpdf, std::string const& filename, std::string const& fullpath);
// Create a new filespec as an indirect object with the given
// unicode filename and embedded file stream. The file name will
// be used as both /UF and /F. If you need to override, call
// setFilename.
QPDF_DLL
- static
- QPDFFileSpecObjectHelper createFileSpec(
- QPDF& qpdf,
- std::string const& filename,
- QPDFEFStreamObjectHelper);
+ static QPDFFileSpecObjectHelper createFileSpec(
+ QPDF& qpdf, std::string const& filename, QPDFEFStreamObjectHelper);
QPDF_DLL
QPDFFileSpecObjectHelper& setDescription(std::string const&);
@@ -103,8 +97,7 @@ class QPDFFileSpecObjectHelper: public QPDFObjectHelper
// might happen to have.
QPDF_DLL
QPDFFileSpecObjectHelper& setFilename(
- std::string const& unicode_name,
- std::string const& compat_name = "");
+ std::string const& unicode_name, std::string const& compat_name = "");
private:
class Members
diff --git a/include/qpdf/QPDFFormFieldObjectHelper.hh b/include/qpdf/QPDFFormFieldObjectHelper.hh
index 64a3a81e..871816ab 100644
--- a/include/qpdf/QPDFFormFieldObjectHelper.hh
+++ b/include/qpdf/QPDFFormFieldObjectHelper.hh
@@ -185,8 +185,8 @@ class QPDFFormFieldObjectHelper: public QPDFObjectHelper
// of a field, use QPDFAcroFormDocumentHelper::setFormFieldName
// instead.
QPDF_DLL
- void setFieldAttribute(std::string const& key,
- std::string const& utf8_value);
+ void
+ setFieldAttribute(std::string const& key, std::string const& utf8_value);
// Set /V (field value) to the given value. If need_appearances is
// true and the field type is either /Tx (text) or /Ch (choice),
diff --git a/include/qpdf/QPDFJob.hh b/include/qpdf/QPDFJob.hh
index acaa956b..510c6d18 100644
--- a/include/qpdf/QPDFJob.hh
+++ b/include/qpdf/QPDFJob.hh
@@ -22,22 +22,21 @@
#ifndef QPDFJOB_HH
#define QPDFJOB_HH
-#include <qpdf/DLL.h>
#include <qpdf/Constants.h>
+#include <qpdf/DLL.h>
+#include <qpdf/PDFVersion.hh>
#include <qpdf/QPDF.hh>
#include <qpdf/QPDFPageObjectHelper.hh>
-#include <qpdf/PDFVersion.hh>
-#include <memory>
-#include <string>
+#include <functional>
+#include <iostream>
#include <list>
-#include <vector>
-#include <set>
#include <map>
-#include <iostream>
-#include <functional>
#include <memory>
+#include <set>
#include <stdexcept>
+#include <string>
+#include <vector>
class QPDFWriter;
@@ -79,8 +78,8 @@ class QPDFJob
// about converting arguments to UTF-8. This method will mutate
// arguments that are passed to it.
QPDF_DLL
- void initializeFromArgv(char const* const argv[],
- char const* progname_env = nullptr);
+ void initializeFromArgv(
+ char const* const argv[], char const* progname_env = nullptr);
// Initialize a QPDFJob from json. Passing partial = true prevents
// this method from doing the final checks (calling
@@ -155,9 +154,10 @@ class QPDFJob
struct PageSpec
{
- PageSpec(std::string const& filename,
- char const* password,
- std::string const& range);
+ PageSpec(
+ std::string const& filename,
+ char const* password,
+ std::string const& range);
std::string filename;
std::shared_ptr<char> password;
@@ -203,13 +203,14 @@ class QPDFJob
{
friend class QPDFJob;
friend class Config;
+
public:
QPDF_DLL
Config* endAddAttachment();
QPDF_DLL
AttConfig* file(std::string const& parameter);
-# include <qpdf/auto_job_c_att.hh>
+#include <qpdf/auto_job_c_att.hh>
private:
AttConfig(Config*);
@@ -223,13 +224,14 @@ class QPDFJob
{
friend class QPDFJob;
friend class Config;
+
public:
QPDF_DLL
Config* endCopyAttachmentsFrom();
QPDF_DLL
CopyAttConfig* file(std::string const& parameter);
-# include <qpdf/auto_job_c_copy_att.hh>
+#include <qpdf/auto_job_c_copy_att.hh>
private:
CopyAttConfig(Config*);
@@ -243,15 +245,17 @@ class QPDFJob
{
friend class QPDFJob;
friend class Config;
+
public:
QPDF_DLL
Config* endPages();
QPDF_DLL
- PagesConfig* pageSpec(std::string const& filename,
- std::string const& range,
- char const* password = nullptr);
+ PagesConfig* pageSpec(
+ std::string const& filename,
+ std::string const& range,
+ char const* password = nullptr);
-# include <qpdf/auto_job_c_pages.hh>
+#include <qpdf/auto_job_c_pages.hh>
private:
PagesConfig(Config*);
@@ -264,13 +268,14 @@ class QPDFJob
{
friend class QPDFJob;
friend class Config;
+
public:
QPDF_DLL
Config* endUnderlayOverlay();
QPDF_DLL
UOConfig* file(std::string const& parameter);
-# include <qpdf/auto_job_c_uo.hh>
+#include <qpdf/auto_job_c_uo.hh>
private:
UOConfig(Config*);
@@ -283,13 +288,14 @@ class QPDFJob
{
friend class QPDFJob;
friend class Config;
+
public:
QPDF_DLL
Config* endEncrypt();
QPDF_DLL
EncConfig* file(std::string const& parameter);
-# include <qpdf/auto_job_c_enc.hh>
+#include <qpdf/auto_job_c_enc.hh>
private:
EncConfig(Config*);
@@ -301,6 +307,7 @@ class QPDFJob
class Config
{
friend class QPDFJob;
+
public:
// Proxy to QPDFJob::checkConfiguration()
QPDF_DLL
@@ -331,7 +338,7 @@ class QPDFJob
std::string const& user_password,
std::string const& owner_password);
-# include <qpdf/auto_job_c_main.hh>
+#include <qpdf/auto_job_c_main.hh>
private:
Config() = delete;
@@ -444,32 +451,37 @@ class QPDFJob
// Basic file processing
std::shared_ptr<QPDF> processFile(
- char const* filename, char const* password,
- bool used_for_input);
+ char const* filename, char const* password, bool used_for_input);
std::shared_ptr<QPDF> processInputSource(
- PointerHolder<InputSource> is, char const* password,
+ PointerHolder<InputSource> is,
+ char const* password,
bool used_for_input);
std::shared_ptr<QPDF> doProcess(
std::function<void(QPDF*, char const*)> fn,
- char const* password, bool empty, bool used_for_input);
+ char const* password,
+ bool empty,
+ bool used_for_input);
std::shared_ptr<QPDF> doProcessOnce(
std::function<void(QPDF*, char const*)> fn,
- char const* password, bool empty, bool used_for_input);
+ char const* password,
+ bool empty,
+ bool used_for_input);
// Transformations
void setQPDFOptions(QPDF& pdf);
void handlePageSpecs(
- QPDF& pdf, bool& warnings,
+ QPDF& pdf,
+ bool& warnings,
std::vector<std::shared_ptr<QPDF>>& page_heap);
bool shouldRemoveUnreferencedResources(QPDF& pdf);
void handleRotations(QPDF& pdf);
- void getUOPagenos(UnderOverlay& uo,
- std::map<int, std::vector<int> >& pagenos);
+ void
+ getUOPagenos(UnderOverlay& uo, std::map<int, std::vector<int>>& pagenos);
void handleUnderOverlay(QPDF& pdf);
void doUnderOverlayForPage(
QPDF& pdf,
UnderOverlay& uo,
- std::map<int, std::vector<int> >& pagenos,
+ std::map<int, std::vector<int>>& pagenos,
size_t page_idx,
std::map<int, QPDFObjectHandle>& fo,
std::vector<QPDFPageObjectHelper>& pages,
diff --git a/include/qpdf/QPDFMatrix.hh b/include/qpdf/QPDFMatrix.hh
index ecf13bb3..f0516dbd 100644
--- a/include/qpdf/QPDFMatrix.hh
+++ b/include/qpdf/QPDFMatrix.hh
@@ -22,8 +22,8 @@
#ifndef QPDFMATRIX_HH
#define QPDFMATRIX_HH
-#include <qpdf/QPDFObjectHandle.hh>
#include <qpdf/DLL.h>
+#include <qpdf/QPDFObjectHandle.hh>
#include <string>
// This class represents a PDF transformation matrix using a tuple
@@ -41,8 +41,7 @@ class QPDFMatrix
QPDF_DLL
QPDFMatrix();
QPDF_DLL
- QPDFMatrix(double a, double b, double c,
- double d, double e, double f);
+ QPDFMatrix(double a, double b, double c, double d, double e, double f);
QPDF_DLL
QPDFMatrix(QPDFObjectHandle::Matrix const&);
@@ -83,21 +82,22 @@ class QPDFMatrix
// bounds the polygon resulting from transforming the four
// corners.
QPDF_DLL
- QPDFObjectHandle::Rectangle transformRectangle(
- QPDFObjectHandle::Rectangle r) const;
+ QPDFObjectHandle::Rectangle
+ transformRectangle(QPDFObjectHandle::Rectangle r) const;
// ABI: delete non-const version
QPDF_DLL
- QPDFObjectHandle::Rectangle transformRectangle(
- QPDFObjectHandle::Rectangle r);
+ QPDFObjectHandle::Rectangle
+ transformRectangle(QPDFObjectHandle::Rectangle r);
// operator== tests for exact equality, not considering deltas for
// floating point.
QPDF_DLL
bool operator==(QPDFMatrix const& rhs) const;
QPDF_DLL
- bool operator!=(QPDFMatrix const& rhs) const
+ bool
+ operator!=(QPDFMatrix const& rhs) const
{
- return ! operator==(rhs);
+ return !operator==(rhs);
}
double a;
diff --git a/include/qpdf/QPDFNameTreeObjectHelper.hh b/include/qpdf/QPDFNameTreeObjectHelper.hh
index baa6e5e9..1523b142 100644
--- a/include/qpdf/QPDFNameTreeObjectHelper.hh
+++ b/include/qpdf/QPDFNameTreeObjectHelper.hh
@@ -22,11 +22,11 @@
#ifndef QPDFNAMETREEOBJECTHELPER_HH
#define QPDFNAMETREEOBJECTHELPER_HH
-#include <qpdf/QPDFObjectHelper.hh>
#include <qpdf/QPDFObjGen.hh>
+#include <qpdf/QPDFObjectHelper.hh>
+#include <iterator>
#include <map>
#include <memory>
-#include <iterator>
#include <qpdf/DLL.h>
@@ -48,16 +48,14 @@ class QPDFNameTreeObjectHelper: public QPDFObjectHelper
// The qpdf object is required so that this class can issue
// warnings, attempt repairs, and add indirect objects.
QPDF_DLL
- QPDFNameTreeObjectHelper(QPDFObjectHandle, QPDF&,
- bool auto_repair = true);
+ QPDFNameTreeObjectHelper(QPDFObjectHandle, QPDF&, bool auto_repair = true);
// ABI: Legacy Constructor will be removed in QPDF 11. A
// QPDFNameTreeObjectHelper constructed in this way can't be
// modified or repaired and will silently ignore problems in the
// structure.
- [[deprecated("use constructor that takes QPDF&")]]
- QPDF_DLL
- QPDFNameTreeObjectHelper(QPDFObjectHandle);
+ [[deprecated("use constructor that takes QPDF&")]] QPDF_DLL
+ QPDFNameTreeObjectHelper(QPDFObjectHandle);
// Create an empty name tree
QPDF_DLL
@@ -80,6 +78,7 @@ class QPDFNameTreeObjectHelper: public QPDFObjectHelper
class iterator
{
friend class QPDFNameTreeObjectHelper;
+
public:
typedef std::pair<std::string, QPDFObjectHandle> T;
using iterator_category = std::bidirectional_iterator_tag;
@@ -94,7 +93,8 @@ class QPDFNameTreeObjectHelper: public QPDFObjectHelper
QPDF_DLL
iterator& operator++();
QPDF_DLL
- iterator operator++(int)
+ iterator
+ operator++(int)
{
iterator t = *this;
++(*this);
@@ -103,7 +103,8 @@ class QPDFNameTreeObjectHelper: public QPDFObjectHelper
QPDF_DLL
iterator& operator--();
QPDF_DLL
- iterator operator--(int)
+ iterator
+ operator--(int)
{
iterator t = *this;
--(*this);
@@ -116,9 +117,10 @@ class QPDFNameTreeObjectHelper: public QPDFObjectHelper
QPDF_DLL
bool operator==(iterator const& other) const;
QPDF_DLL
- bool operator!=(iterator const& other) const
+ bool
+ operator!=(iterator const& other) const
{
- return ! operator==(other);
+ return !operator==(other);
}
// DANGER: this method can create inconsistent trees if not
@@ -162,8 +164,8 @@ class QPDFNameTreeObjectHelper: public QPDFObjectHelper
// Find the entry with the given key. If return_prev_if_not_found
// is true and the item is not found, return the next lower item.
QPDF_DLL
- iterator find(std::string const& key,
- bool return_prev_if_not_found = false);
+ iterator
+ find(std::string const& key, bool return_prev_if_not_found = false);
// Insert a new item. If the key already exists, it is replaced.
QPDF_DLL
diff --git a/include/qpdf/QPDFNumberTreeObjectHelper.hh b/include/qpdf/QPDFNumberTreeObjectHelper.hh
index cfe20b72..0f0acf06 100644
--- a/include/qpdf/QPDFNumberTreeObjectHelper.hh
+++ b/include/qpdf/QPDFNumberTreeObjectHelper.hh
@@ -22,8 +22,8 @@
#ifndef QPDFNUMBERTREEOBJECTHELPER_HH
#define QPDFNUMBERTREEOBJECTHELPER_HH
-#include <qpdf/QPDFObjectHelper.hh>
#include <qpdf/QPDFObjGen.hh>
+#include <qpdf/QPDFObjectHelper.hh>
#include <map>
#include <memory>
@@ -45,16 +45,15 @@ class QPDFNumberTreeObjectHelper: public QPDFObjectHelper
// The qpdf object is required so that this class can issue
// warnings, attempt repairs, and add indirect objects.
QPDF_DLL
- QPDFNumberTreeObjectHelper(QPDFObjectHandle, QPDF&,
- bool auto_repair = true);
+ QPDFNumberTreeObjectHelper(
+ QPDFObjectHandle, QPDF&, bool auto_repair = true);
// ABI: Legacy Constructor will be removed in QPDF 11. A
// QPDFNumberTreeObjectHelper constructed in this way can't be
// modified or repaired and will silently ignore problems in the
// structure.
- [[deprecated("use constructor that takes QPDF&")]]
- QPDF_DLL
- QPDFNumberTreeObjectHelper(QPDFObjectHandle);
+ [[deprecated("use constructor that takes QPDF&")]] QPDF_DLL
+ QPDFNumberTreeObjectHelper(QPDFObjectHandle);
// ABI: = default
QPDF_DLL
@@ -93,12 +92,13 @@ class QPDFNumberTreeObjectHelper: public QPDFObjectHelper
// oh to the value with index 3, and set offset to 2 (5 - 3). See
// also find().
QPDF_DLL
- bool findObjectAtOrBelow(numtree_number idx, QPDFObjectHandle& oh,
- numtree_number& offset);
+ bool findObjectAtOrBelow(
+ numtree_number idx, QPDFObjectHandle& oh, numtree_number& offset);
class iterator
{
friend class QPDFNumberTreeObjectHelper;
+
public:
typedef std::pair<numtree_number, QPDFObjectHandle> T;
using iterator_category = std::bidirectional_iterator_tag;
@@ -113,7 +113,8 @@ class QPDFNumberTreeObjectHelper: public QPDFObjectHelper
QPDF_DLL
iterator& operator++();
QPDF_DLL
- iterator operator++(int)
+ iterator
+ operator++(int)
{
iterator t = *this;
++(*this);
@@ -122,7 +123,8 @@ class QPDFNumberTreeObjectHelper: public QPDFObjectHelper
QPDF_DLL
iterator& operator--();
QPDF_DLL
- iterator operator--(int)
+ iterator
+ operator--(int)
{
iterator t = *this;
--(*this);
@@ -135,9 +137,10 @@ class QPDFNumberTreeObjectHelper: public QPDFObjectHelper
QPDF_DLL
bool operator==(iterator const& other) const;
QPDF_DLL
- bool operator!=(iterator const& other) const
+ bool
+ operator!=(iterator const& other) const
{
- return ! operator==(other);
+ return !operator==(other);
}
// DANGER: this method can create inconsistent trees if not
diff --git a/include/qpdf/QPDFObject.hh b/include/qpdf/QPDFObject.hh
index d01ea8ed..9487e8f5 100644
--- a/include/qpdf/QPDFObject.hh
+++ b/include/qpdf/QPDFObject.hh
@@ -22,10 +22,10 @@
#ifndef QPDFOBJECT_HH
#define QPDFOBJECT_HH
+#include <qpdf/Constants.h>
#include <qpdf/DLL.h>
-#include <qpdf/Types.h>
#include <qpdf/JSON.hh>
-#include <qpdf/Constants.h>
+#include <qpdf/Types.h>
#include <string>
@@ -62,7 +62,9 @@ class QPDF_DLL_CLASS QPDFObject
static constexpr object_type_e ot_operator = ::ot_operator;
static constexpr object_type_e ot_inlineimage = ::ot_inlineimage;
- virtual ~QPDFObject() {}
+ virtual ~QPDFObject()
+ {
+ }
virtual std::string unparse() = 0;
virtual JSON getJSON() = 0;
@@ -78,11 +80,12 @@ class QPDF_DLL_CLASS QPDFObject
{
friend class QPDF;
friend class QPDFObjectHandle;
+
private:
- static void releaseResolved(QPDFObject* o)
+ static void
+ releaseResolved(QPDFObject* o)
{
- if (o)
- {
+ if (o) {
o->releaseResolved();
}
}
@@ -97,7 +100,10 @@ class QPDF_DLL_CLASS QPDFObject
qpdf_offset_t getParsedOffset();
protected:
- virtual void releaseResolved() {}
+ virtual void
+ releaseResolved()
+ {
+ }
private:
QPDFObject(QPDFObject const&) = delete;
diff --git a/include/qpdf/QPDFObjectHandle.hh b/include/qpdf/QPDFObjectHandle.hh
index e536c3cc..f304aacf 100644
--- a/include/qpdf/QPDFObjectHandle.hh
+++ b/include/qpdf/QPDFObjectHandle.hh
@@ -22,21 +22,21 @@
#ifndef QPDFOBJECTHANDLE_HH
#define QPDFOBJECTHANDLE_HH
+#include <qpdf/Constants.h>
#include <qpdf/DLL.h>
#include <qpdf/Types.h>
-#include <qpdf/Constants.h>
-#include <string>
-#include <vector>
-#include <set>
-#include <map>
#include <functional>
+#include <map>
#include <memory>
+#include <set>
+#include <string>
+#include <vector>
-#include <qpdf/QPDFObjGen.hh>
-#include <qpdf/PointerHolder.hh>
#include <qpdf/Buffer.hh>
#include <qpdf/InputSource.hh>
+#include <qpdf/PointerHolder.hh>
+#include <qpdf/QPDFObjGen.hh>
#include <qpdf/QPDFTokenizer.hh>
#include <qpdf/QPDFObject.hh>
@@ -117,12 +117,15 @@ class QPDFObjectHandle
// version of the method, which should also return a boolean
// indicating whether it ran without errors.
QPDF_DLL
- virtual void provideStreamData(int objid, int generation,
- Pipeline* pipeline);
+ virtual void
+ provideStreamData(int objid, int generation, Pipeline* pipeline);
QPDF_DLL
virtual bool provideStreamData(
- int objid, int generation, Pipeline* pipeline,
- bool suppress_warnings, bool will_retry);
+ int objid,
+ int generation,
+ Pipeline* pipeline,
+ bool suppress_warnings,
+ bool will_retry);
QPDF_DLL
bool supportsRetry();
@@ -183,8 +186,10 @@ class QPDFObjectHandle
class PipelineAccessor
{
friend class Pl_QPDFTokenizer;
+
private:
- static void setPipeline(TokenFilter* f, Pipeline* p)
+ static void
+ setPipeline(TokenFilter* f, Pipeline* p)
{
f->setPipeline(p);
}
@@ -230,8 +235,8 @@ class QPDFObjectHandle
QPDF_DLL
virtual void handleObject(QPDFObjectHandle);
QPDF_DLL
- virtual void handleObject(
- QPDFObjectHandle, size_t offset, size_t length);
+ virtual void
+ handleObject(QPDFObjectHandle, size_t offset, size_t length);
virtual void handleEOF() = 0;
@@ -261,8 +266,7 @@ class QPDFObjectHandle
ury(0.0)
{
}
- Rectangle(double llx, double lly,
- double urx, double ury) :
+ Rectangle(double llx, double lly, double urx, double ury) :
llx(llx),
lly(lly),
urx(urx),
@@ -292,8 +296,7 @@ class QPDFObjectHandle
f(0.0)
{
}
- Matrix(double a, double b, double c,
- double d, double e, double f) :
+ Matrix(double a, double b, double c, double d, double e, double f) :
a(a),
b(b),
c(c),
@@ -316,8 +319,7 @@ class QPDFObjectHandle
QPDF_DLL
QPDFObjectHandle(QPDFObjectHandle const&) = default;
QPDF_DLL
- QPDFObjectHandle&
- operator=(QPDFObjectHandle const&) = default;
+ QPDFObjectHandle& operator=(QPDFObjectHandle const&) = default;
QPDF_DLL
bool isInitialized() const;
@@ -381,14 +383,14 @@ class QPDFObjectHandle
// True if the object is a dictionary of the specified type and
// subtype, if any.
QPDF_DLL
- bool isDictionaryOfType(std::string const& type,
- std::string const& subtype = "");
+ bool isDictionaryOfType(
+ std::string const& type, std::string const& subtype = "");
// True if the object is a stream of the specified type and
// subtype, if any.
QPDF_DLL
- bool isStreamOfType(std::string const& type,
- std::string const& subtype = "");
+ bool
+ isStreamOfType(std::string const& type, std::string const& subtype = "");
// Public factory methods
@@ -406,8 +408,9 @@ class QPDFObjectHandle
// in the message of any QPDFExc exception thrown for invalid
// syntax. See also the global `operator ""_qpdf` defined below.
QPDF_DLL
- static QPDFObjectHandle parse(std::string const& object_str,
- std::string const& object_description = "");
+ static QPDFObjectHandle parse(
+ std::string const& object_str,
+ std::string const& object_description = "");
// Construct an object of any type from a string representation of
// the object. Indirect object syntax (obj gen R) is allowed and
@@ -419,9 +422,10 @@ class QPDFObjectHandle
// object, which will just be the first number and will report
// that there is trailing data at the end of the string.
QPDF_DLL
- static QPDFObjectHandle parse(QPDF* context,
- std::string const& object_str,
- std::string const& object_description = "");
+ static QPDFObjectHandle parse(
+ QPDF* context,
+ std::string const& object_str,
+ std::string const& object_description = "");
// Construct an object as above by reading from the given
// InputSource at its current position and using the tokenizer you
@@ -429,11 +433,13 @@ class QPDFObjectHandle
// This method is intended to be called by QPDF for parsing
// objects that are ready from the object's input stream.
QPDF_DLL
- static QPDFObjectHandle parse(PointerHolder<InputSource> input,
- std::string const& object_description,
- QPDFTokenizer&, bool& empty,
- StringDecrypter* decrypter,
- QPDF* context);
+ static QPDFObjectHandle parse(
+ PointerHolder<InputSource> input,
+ std::string const& object_description,
+ QPDFTokenizer&,
+ bool& empty,
+ StringDecrypter* decrypter,
+ QPDF* context);
// Return the offset where the object was found when parsed. A
// negative value means that the object was created without
@@ -449,8 +455,8 @@ class QPDFObjectHandle
// error messages will also be more useful because the page object
// information will be known.
QPDF_DLL
- static void parseContentStream(QPDFObjectHandle stream_or_array,
- ParserCallbacks* callbacks);
+ static void parseContentStream(
+ QPDFObjectHandle stream_or_array, ParserCallbacks* callbacks);
// When called on a stream or stream array that is some page's
// content streams, do the same as pipePageContents. This method
@@ -469,8 +475,10 @@ class QPDFObjectHandle
// Pl_Concatenate and then call manualFinish() on the
// Pl_Concatenate pipeline at the end.
QPDF_DLL
- void pipeContentStreams(Pipeline* p, std::string const& description,
- std::string& all_description);
+ void pipeContentStreams(
+ Pipeline* p,
+ std::string const& description,
+ std::string& all_description);
// As of qpdf 8, it is possible to add custom token filters to a
// stream. The tokenized stream data is passed through the token
@@ -525,8 +533,8 @@ class QPDFObjectHandle
// ABI: combine with other newReal by adding trim_trailing_zeroes
// above as an optional parameter with a default of true.
QPDF_DLL
- static QPDFObjectHandle newReal(double value, int decimal_places,
- bool trim_trailing_zeroes);
+ static QPDFObjectHandle
+ newReal(double value, int decimal_places, bool trim_trailing_zeroes);
// Note about name objects: qpdf's internal representation of a
// PDF name is a sequence of bytes, excluding the NUL character,
// and starting with a slash. Name objects as represented in the
@@ -562,8 +570,8 @@ class QPDFObjectHandle
QPDF_DLL
static QPDFObjectHandle newArray();
QPDF_DLL
- static QPDFObjectHandle newArray(
- std::vector<QPDFObjectHandle> const& items);
+ static QPDFObjectHandle
+ newArray(std::vector<QPDFObjectHandle> const& items);
QPDF_DLL
static QPDFObjectHandle newArray(Rectangle const&);
QPDF_DLL
@@ -573,8 +581,8 @@ class QPDFObjectHandle
QPDF_DLL
static QPDFObjectHandle newDictionary();
QPDF_DLL
- static QPDFObjectHandle newDictionary(
- std::map<std::string, QPDFObjectHandle> const& items);
+ static QPDFObjectHandle
+ newDictionary(std::map<std::string, QPDFObjectHandle> const& items);
// Create an array from a rectangle. Equivalent to the rectangle
// form of newArray.
@@ -646,8 +654,8 @@ class QPDFObjectHandle
// with proper context in some cases where it would otherwise
// raise exceptions.
QPDF_DLL
- void setObjectDescription(QPDF* owning_qpdf,
- std::string const& object_description);
+ void setObjectDescription(
+ QPDF* owning_qpdf, std::string const& object_description);
QPDF_DLL
bool hasObjectDescription();
@@ -959,8 +967,8 @@ class QPDFObjectHandle
// ABI: remove this version and make resource_names default to
// nullptr.
QPDF_DLL
- std::string getUniqueResourceName(std::string const& prefix,
- int& min_suffix);
+ std::string
+ getUniqueResourceName(std::string const& prefix, int& min_suffix);
// Return the QPDF object that owns an indirect object. Returns
// null for a direct object.
@@ -1081,8 +1089,8 @@ class QPDFObjectHandle
// Returns filtered (uncompressed) stream data. Throws an
// exception if the stream is filtered and we can't decode it.
QPDF_DLL
- PointerHolder<Buffer> getStreamData(
- qpdf_stream_decode_level_e level = qpdf_dl_generalized);
+ PointerHolder<Buffer>
+ getStreamData(qpdf_stream_decode_level_e level = qpdf_dl_generalized);
// Returns unfiltered (raw) stream data.
QPDF_DLL
@@ -1146,21 +1154,24 @@ class QPDFObjectHandle
// Return value is overall success, even if filtering is not
// requested.
QPDF_DLL
- bool pipeStreamData(Pipeline*, bool* filtering_attempted,
- int encode_flags,
- qpdf_stream_decode_level_e decode_level,
- bool suppress_warnings = false,
- bool will_retry = false);
+ bool pipeStreamData(
+ Pipeline*,
+ bool* filtering_attempted,
+ int encode_flags,
+ qpdf_stream_decode_level_e decode_level,
+ bool suppress_warnings = false,
+ bool will_retry = false);
// Legacy version. Return value is whether filtering was
// attempted. There is no way to determine success if filtering
// was not attempted.
QPDF_DLL
- bool pipeStreamData(Pipeline*,
- int encode_flags,
- qpdf_stream_decode_level_e decode_level,
- bool suppress_warnings = false,
- bool will_retry = false);
+ bool pipeStreamData(
+ Pipeline*,
+ int encode_flags,
+ qpdf_stream_decode_level_e decode_level,
+ bool suppress_warnings = false,
+ bool will_retry = false);
// Legacy pipeStreamData. This maps to the the flags-based
// pipeStreamData as follows:
@@ -1170,8 +1181,7 @@ class QPDFObjectHandle
// compress = true -> encode_flags |= qpdf_sf_compress
// Return value is whether filtering was attempted.
QPDF_DLL
- bool pipeStreamData(Pipeline*, bool filter,
- bool normalize, bool compress);
+ bool pipeStreamData(Pipeline*, bool filter, bool normalize, bool compress);
// Replace a stream's dictionary. The new dictionary must be
// consistent with the stream's data. This is most appropriately
@@ -1190,18 +1200,20 @@ class QPDFObjectHandle
// interpreted as if the data read from the file, after any
// decryption filters have been applied, is as presented.
QPDF_DLL
- void replaceStreamData(PointerHolder<Buffer> data,
- QPDFObjectHandle const& filter,
- QPDFObjectHandle const& decode_parms);
+ void replaceStreamData(
+ PointerHolder<Buffer> data,
+ QPDFObjectHandle const& filter,
+ QPDFObjectHandle const& decode_parms);
// Replace the stream's stream data with the given string.
// This method will create a copy of the data rather than using
// the user-provided buffer as in the PointerHolder<Buffer> version
// of replaceStreamData.
QPDF_DLL
- void replaceStreamData(std::string const& data,
- QPDFObjectHandle const& filter,
- QPDFObjectHandle const& decode_parms);
+ void replaceStreamData(
+ std::string const& data,
+ QPDFObjectHandle const& filter,
+ QPDFObjectHandle const& decode_parms);
// As above, replace this stream's stream data. Instead of
// directly providing a buffer with the stream data, call the
@@ -1229,9 +1241,10 @@ class QPDFObjectHandle
// parameter. You can also simplify your code by not having to
// compute the length in advance.
QPDF_DLL
- void replaceStreamData(PointerHolder<StreamDataProvider> provider,
- QPDFObjectHandle const& filter,
- QPDFObjectHandle const& decode_parms);
+ void replaceStreamData(
+ PointerHolder<StreamDataProvider> provider,
+ QPDFObjectHandle const& filter,
+ QPDFObjectHandle const& decode_parms);
// Starting in qpdf 10.2, you can use C++-11 function objects
// instead of StreamDataProvider.
@@ -1240,16 +1253,16 @@ class QPDFObjectHandle
// a one-liner to replace stream data with the contents of a file,
// pass QUtil::file_provider(filename) as provider.
QPDF_DLL
- void replaceStreamData(std::function<void(Pipeline*)> provider,
- QPDFObjectHandle const& filter,
- QPDFObjectHandle const& decode_parms);
+ void replaceStreamData(
+ std::function<void(Pipeline*)> provider,
+ QPDFObjectHandle const& filter,
+ QPDFObjectHandle const& decode_parms);
// The provider should write the stream data to the pipeline,
// returning true if it succeeded without errors.
QPDF_DLL
void replaceStreamData(
- std::function<bool(Pipeline*,
- bool suppress_warnings,
- bool will_retry)> provider,
+ std::function<bool(Pipeline*, bool suppress_warnings, bool will_retry)>
+ provider,
QPDFObjectHandle const& filter,
QPDFObjectHandle const& decode_parms);
@@ -1321,8 +1334,8 @@ class QPDFObjectHandle
// descriptions. See comments on setObjectDescription for
// additional details.
QPDF_DLL
- void warnIfPossible(std::string const& warning,
- bool throw_if_no_description = false);
+ void warnIfPossible(
+ std::string const& warning, bool throw_if_no_description = false);
// Initializers for objects. This Factory class gives the QPDF
// class specific permission to call factory methods without
@@ -1330,16 +1343,22 @@ class QPDFObjectHandle
class Factory
{
friend class QPDF;
+
private:
- static QPDFObjectHandle newIndirect(QPDF* qpdf,
- int objid, int generation)
+ static QPDFObjectHandle
+ newIndirect(QPDF* qpdf, int objid, int generation)
{
return QPDFObjectHandle::newIndirect(qpdf, objid, generation);
}
// object must be dictionary object
- static QPDFObjectHandle newStream(
- QPDF* qpdf, int objid, int generation,
- QPDFObjectHandle stream_dict, qpdf_offset_t offset, size_t length)
+ static QPDFObjectHandle
+ newStream(
+ QPDF* qpdf,
+ int objid,
+ int generation,
+ QPDFObjectHandle stream_dict,
+ qpdf_offset_t offset,
+ size_t length)
{
return QPDFObjectHandle::newStream(
qpdf, objid, generation, stream_dict, offset, length);
@@ -1352,8 +1371,10 @@ class QPDFObjectHandle
class ObjAccessor
{
friend class QPDF;
+
private:
- static PointerHolder<QPDFObject> getObject(QPDFObjectHandle& o)
+ static PointerHolder<QPDFObject>
+ getObject(QPDFObjectHandle& o)
{
o.dereference();
return o.obj;
@@ -1368,8 +1389,10 @@ class QPDFObjectHandle
friend class QPDF_Dictionary;
friend class QPDF_Stream;
friend class SparseOHArray;
+
private:
- static void releaseResolved(QPDFObjectHandle& o)
+ static void
+ releaseResolved(QPDFObjectHandle& o)
{
o.releaseResolved();
}
@@ -1433,14 +1456,13 @@ class QPDFObjectHandle
// Indicate if this is an image. If exclude_imagemask is true,
// don't count image masks as images.
QPDF_DLL
- bool isImage(bool exclude_imagemask=true);
+ bool isImage(bool exclude_imagemask = true);
private:
QPDFObjectHandle(QPDF*, int objid, int generation);
QPDFObjectHandle(QPDFObject*);
- enum parser_state_e
- {
+ enum parser_state_e {
st_top,
st_start,
st_stop,
@@ -1452,31 +1474,41 @@ class QPDFObjectHandle
// Private object factory methods
static QPDFObjectHandle newIndirect(QPDF*, int objid, int generation);
static QPDFObjectHandle newStream(
- QPDF* qpdf, int objid, int generation,
- QPDFObjectHandle stream_dict, qpdf_offset_t offset, size_t length);
-
- void typeWarning(char const* expected_type,
- std::string const& warning);
+ QPDF* qpdf,
+ int objid,
+ int generation,
+ QPDFObjectHandle stream_dict,
+ qpdf_offset_t offset,
+ size_t length);
+
+ void typeWarning(char const* expected_type, std::string const& warning);
void objectWarning(std::string const& warning);
void assertType(char const* type_name, bool istype);
void dereference();
- void copyObject(std::set<QPDFObjGen>& visited, bool cross_indirect,
- bool first_level_only, bool stop_at_streams);
+ void copyObject(
+ std::set<QPDFObjGen>& visited,
+ bool cross_indirect,
+ bool first_level_only,
+ bool stop_at_streams);
void shallowCopyInternal(QPDFObjectHandle& oh, bool first_level_only);
void releaseResolved();
static void setObjectDescriptionFromInput(
- QPDFObjectHandle, QPDF*, std::string const&,
- PointerHolder<InputSource>, qpdf_offset_t);
+ QPDFObjectHandle,
+ QPDF*,
+ std::string const&,
+ PointerHolder<InputSource>,
+ qpdf_offset_t);
static QPDFObjectHandle parseInternal(
PointerHolder<InputSource> input,
std::string const& object_description,
- QPDFTokenizer& tokenizer, bool& empty,
- StringDecrypter* decrypter, QPDF* context,
+ QPDFTokenizer& tokenizer,
+ bool& empty,
+ StringDecrypter* decrypter,
+ QPDF* context,
bool content_stream);
void setParsedOffset(qpdf_offset_t offset);
void parseContentStream_internal(
- std::string const& description,
- ParserCallbacks* callbacks);
+ std::string const& description, ParserCallbacks* callbacks);
static void parseContentStream_data(
PointerHolder<Buffer>,
std::string const& description,
@@ -1493,7 +1525,7 @@ class QPDFObjectHandle
// a substantial performance penalty since QPDFObjectHandle
// objects are copied around so frequently.
QPDF* qpdf;
- int objid; // 0 for direct object
+ int objid; // 0 for direct object
int generation;
PointerHolder<QPDFObject> obj;
bool reserved;
@@ -1507,7 +1539,7 @@ class QPDFObjectHandle
// If this is causing problems in your code, define
// QPDF_NO_QPDF_STRING to prevent the declaration from being here.
QPDF_DLL
-QPDFObjectHandle operator ""_qpdf(char const* v, size_t len);
+QPDFObjectHandle operator""_qpdf(char const* v, size_t len);
#endif // QPDF_NO_QPDF_STRING
class QPDFObjectHandle::QPDFDictItems
@@ -1531,6 +1563,7 @@ class QPDFObjectHandle::QPDFDictItems
class iterator
{
friend class QPDFDictItems;
+
public:
typedef std::pair<std::string, QPDFObjectHandle> T;
using iterator_category = std::bidirectional_iterator_tag;
@@ -1544,7 +1577,8 @@ class QPDFObjectHandle::QPDFDictItems
QPDF_DLL
iterator& operator++();
QPDF_DLL
- iterator operator++(int)
+ iterator
+ operator++(int)
{
iterator t = *this;
++(*this);
@@ -1553,7 +1587,8 @@ class QPDFObjectHandle::QPDFDictItems
QPDF_DLL
iterator& operator--();
QPDF_DLL
- iterator operator--(int)
+ iterator
+ operator--(int)
{
iterator t = *this;
--(*this);
@@ -1566,9 +1601,10 @@ class QPDFObjectHandle::QPDFDictItems
QPDF_DLL
bool operator==(iterator const& other) const;
QPDF_DLL
- bool operator!=(iterator const& other) const
+ bool
+ operator!=(iterator const& other) const
{
- return ! operator==(other);
+ return !operator==(other);
}
private:
@@ -1626,6 +1662,7 @@ class QPDFObjectHandle::QPDFArrayItems
class iterator
{
friend class QPDFArrayItems;
+
public:
typedef QPDFObjectHandle T;
using iterator_category = std::bidirectional_iterator_tag;
@@ -1639,7 +1676,8 @@ class QPDFObjectHandle::QPDFArrayItems
QPDF_DLL
iterator& operator++();
QPDF_DLL
- iterator operator++(int)
+ iterator
+ operator++(int)
{
iterator t = *this;
++(*this);
@@ -1648,7 +1686,8 @@ class QPDFObjectHandle::QPDFArrayItems
QPDF_DLL
iterator& operator--();
QPDF_DLL
- iterator operator--(int)
+ iterator
+ operator--(int)
{
iterator t = *this;
--(*this);
@@ -1661,9 +1700,10 @@ class QPDFObjectHandle::QPDFArrayItems
QPDF_DLL
bool operator==(iterator const& other) const;
QPDF_DLL
- bool operator!=(iterator const& other) const
+ bool
+ operator!=(iterator const& other) const
{
- return ! operator==(other);
+ return !operator==(other);
}
private:
@@ -1700,5 +1740,4 @@ class QPDFObjectHandle::QPDFArrayItems
QPDFObjectHandle oh;
};
-
#endif // QPDFOBJECTHANDLE_HH
diff --git a/include/qpdf/QPDFObjectHelper.hh b/include/qpdf/QPDFObjectHelper.hh
index f8e3cc21..32577681 100644
--- a/include/qpdf/QPDFObjectHelper.hh
+++ b/include/qpdf/QPDFObjectHelper.hh
@@ -50,12 +50,14 @@ class QPDFObjectHelper
{
}
QPDF_DLL
- QPDFObjectHandle getObjectHandle()
+ QPDFObjectHandle
+ getObjectHandle()
{
return this->oh;
}
QPDF_DLL
- QPDFObjectHandle const getObjectHandle() const
+ QPDFObjectHandle const
+ getObjectHandle() const
{
return this->oh;
}
diff --git a/include/qpdf/QPDFOutlineDocumentHelper.hh b/include/qpdf/QPDFOutlineDocumentHelper.hh
index 5b2dca54..60079718 100644
--- a/include/qpdf/QPDFOutlineDocumentHelper.hh
+++ b/include/qpdf/QPDFOutlineDocumentHelper.hh
@@ -23,8 +23,8 @@
#define QPDFOUTLINEDOCUMENTHELPER_HH
#include <qpdf/QPDFDocumentHelper.hh>
-#include <qpdf/QPDFOutlineObjectHelper.hh>
#include <qpdf/QPDFNameTreeObjectHelper.hh>
+#include <qpdf/QPDFOutlineObjectHelper.hh>
#include <qpdf/QPDF.hh>
#include <map>
@@ -58,8 +58,7 @@ class QPDFOutlineDocumentHelper: public QPDFDocumentHelper
// the name tree pointed to by the /Dests key of the names
// dictionary.
QPDF_DLL
- QPDFObjectHandle
- resolveNamedDest(QPDFObjectHandle name);
+ QPDFObjectHandle resolveNamedDest(QPDFObjectHandle name);
// Return a list outlines that are known to target the specified
// page
@@ -99,7 +98,7 @@ class QPDFOutlineDocumentHelper: public QPDFDocumentHelper
std::set<QPDFObjGen> seen;
QPDFObjectHandle dest_dict;
PointerHolder<QPDFNameTreeObjectHelper> names_dest;
- std::map<QPDFObjGen, std::vector<QPDFOutlineObjectHelper> > by_page;
+ std::map<QPDFObjGen, std::vector<QPDFOutlineObjectHelper>> by_page;
};
PointerHolder<Members> m;
diff --git a/include/qpdf/QPDFOutlineObjectHelper.hh b/include/qpdf/QPDFOutlineObjectHelper.hh
index 3f310eeb..e8ed414d 100644
--- a/include/qpdf/QPDFOutlineObjectHelper.hh
+++ b/include/qpdf/QPDFOutlineObjectHelper.hh
@@ -22,8 +22,8 @@
#ifndef QPDFOUTLINEOBJECTHELPER_HH
#define QPDFOUTLINEOBJECTHELPER_HH
-#include <qpdf/QPDFObjectHelper.hh>
#include <qpdf/QPDFObjGen.hh>
+#include <qpdf/QPDFObjectHelper.hh>
#include <vector>
class QPDFOutlineDocumentHelper;
diff --git a/include/qpdf/QPDFPageDocumentHelper.hh b/include/qpdf/QPDFPageDocumentHelper.hh
index 5db8ef6d..d8b2e915 100644
--- a/include/qpdf/QPDFPageDocumentHelper.hh
+++ b/include/qpdf/QPDFPageDocumentHelper.hh
@@ -22,9 +22,9 @@
#ifndef QPDFPAGEDOCUMENTHELPER_HH
#define QPDFPAGEDOCUMENTHELPER_HH
+#include <qpdf/Constants.h>
#include <qpdf/QPDFDocumentHelper.hh>
#include <qpdf/QPDFPageObjectHelper.hh>
-#include <qpdf/Constants.h>
#include <qpdf/DLL.h>
@@ -106,8 +106,10 @@ class QPDFPageDocumentHelper: public QPDFDocumentHelper
// Add new page before or after refpage. See comments for addPage
// for details about what newpage should be.
QPDF_DLL
- void addPageAt(QPDFPageObjectHelper newpage, bool before,
- QPDFPageObjectHelper refpage);
+ void addPageAt(
+ QPDFPageObjectHelper newpage,
+ bool before,
+ QPDFPageObjectHelper refpage);
// Remove page from the pdf.
QPDF_DLL
@@ -126,8 +128,7 @@ class QPDFPageDocumentHelper: public QPDFDocumentHelper
// those flags.
QPDF_DLL
void flattenAnnotations(
- int required_flags = 0,
- int forbidden_flags = an_invisible | an_hidden);
+ int required_flags = 0, int forbidden_flags = an_invisible | an_hidden);
private:
void flattenAnnotationsForPage(
diff --git a/include/qpdf/QPDFPageLabelDocumentHelper.hh b/include/qpdf/QPDFPageLabelDocumentHelper.hh
index 3e7652f1..6922e0a9 100644
--- a/include/qpdf/QPDFPageLabelDocumentHelper.hh
+++ b/include/qpdf/QPDFPageLabelDocumentHelper.hh
@@ -77,10 +77,11 @@ class QPDFPageLabelDocumentHelper: public QPDFDocumentHelper
// behavior facilitates using this function to incrementally build
// up a page labels tree when merging files.
QPDF_DLL
- void
- getLabelsForPageRange(long long start_idx, long long end_idx,
- long long new_start_idx,
- std::vector<QPDFObjectHandle>& new_labels);
+ void getLabelsForPageRange(
+ long long start_idx,
+ long long end_idx,
+ long long new_start_idx,
+ std::vector<QPDFObjectHandle>& new_labels);
private:
class Members
diff --git a/include/qpdf/QPDFPageObjectHelper.hh b/include/qpdf/QPDFPageObjectHelper.hh
index ec446772..961bac4b 100644
--- a/include/qpdf/QPDFPageObjectHelper.hh
+++ b/include/qpdf/QPDFPageObjectHelper.hh
@@ -22,9 +22,9 @@
#ifndef QPDFPAGEOBJECTHELPER_HH
#define QPDFPAGEOBJECTHELPER_HH
-#include <qpdf/QPDFObjectHelper.hh>
#include <qpdf/QPDFAnnotationObjectHelper.hh>
#include <qpdf/QPDFMatrix.hh>
+#include <qpdf/QPDFObjectHelper.hh>
#include <qpdf/DLL.h>
@@ -57,23 +57,19 @@ class QPDFPageObjectHelper: public QPDFObjectHelper
// going to modify the returned object and want the modifications
// to apply to the current page/form XObject only.
QPDF_DLL
- QPDFObjectHandle
- getAttribute(std::string const& name, bool copy_if_shared);
+ QPDFObjectHandle getAttribute(std::string const& name, bool copy_if_shared);
// Return the TrimBox. If not defined, fall back to CropBox
QPDF_DLL
- QPDFObjectHandle
- getTrimBox(bool copy_if_shared = false);
+ QPDFObjectHandle getTrimBox(bool copy_if_shared = false);
// Return the CropBox. If not defined, fall back to MediaBox
QPDF_DLL
- QPDFObjectHandle
- getCropBox(bool copy_if_shared = false);
+ QPDFObjectHandle getCropBox(bool copy_if_shared = false);
// Return the MediaBox
QPDF_DLL
- QPDFObjectHandle
- getMediaBox(bool copy_if_shared = false);
+ QPDFObjectHandle getMediaBox(bool copy_if_shared = false);
// Iterate through XObjects, possibly recursing into form
// XObjects. This works with pages or form XObjects. Call action
@@ -86,24 +82,27 @@ class QPDFPageObjectHelper: public QPDFObjectHelper
QPDF_DLL
void forEachXObject(
bool recursive,
- std::function<void(QPDFObjectHandle& obj,
- QPDFObjectHandle& xobj_dict,
- std::string const& key)> action,
- std::function<bool(QPDFObjectHandle)> selector=nullptr);
+ std::function<void(
+ QPDFObjectHandle& obj,
+ QPDFObjectHandle& xobj_dict,
+ std::string const& key)> action,
+ std::function<bool(QPDFObjectHandle)> selector = nullptr);
// Only call action for images
QPDF_DLL
void forEachImage(
bool recursive,
- std::function<void(QPDFObjectHandle& obj,
- QPDFObjectHandle& xobj_dict,
- std::string const& key)> action);
+ std::function<void(
+ QPDFObjectHandle& obj,
+ QPDFObjectHandle& xobj_dict,
+ std::string const& key)> action);
// Only call action for form XObjects
QPDF_DLL
void forEachFormXObject(
bool recursive,
- std::function<void(QPDFObjectHandle& obj,
- QPDFObjectHandle& xobj_dict,
- std::string const& key)> action);
+ std::function<void(
+ QPDFObjectHandle& obj,
+ QPDFObjectHandle& xobj_dict,
+ std::string const& key)> action);
// Returns an empty map if there are no images or no resources.
// Prior to qpdf 8.4.0, this function did not support inherited
@@ -142,8 +141,8 @@ class QPDFPageObjectHelper: public QPDFObjectHelper
// only_subtype is non-empty, only include annotations of the
// given subtype.
QPDF_DLL
- std::vector<QPDFAnnotationObjectHelper> getAnnotations(
- std::string const& only_subtype = "");
+ std::vector<QPDFAnnotationObjectHelper>
+ getAnnotations(std::string const& only_subtype = "");
// Returns a vector of stream objects representing the content
// streams for the given page. This routine allows the caller to
@@ -203,13 +202,13 @@ class QPDFPageObjectHelper: public QPDFObjectHelper
// contents, as happens with addContentTokenFilter. See
// examples/pdf-count-strings.cc for an example.
QPDF_DLL
- void filterContents(QPDFObjectHandle::TokenFilter* filter,
- Pipeline* next = 0);
+ void
+ filterContents(QPDFObjectHandle::TokenFilter* filter, Pipeline* next = 0);
// Old name -- calls filterContents()
QPDF_DLL
- void filterPageContents(QPDFObjectHandle::TokenFilter* filter,
- Pipeline* next = 0);
+ void filterPageContents(
+ QPDFObjectHandle::TokenFilter* filter, Pipeline* next = 0);
// Pipe a page's contents through the given pipeline. This method
// works whether the contents are a single stream or an array of
@@ -303,7 +302,8 @@ class QPDFPageObjectHelper: public QPDFObjectHelper
// behavior.
QPDF_DLL
std::string placeFormXObject(
- QPDFObjectHandle fo, std::string const& name,
+ QPDFObjectHandle fo,
+ std::string const& name,
QPDFObjectHandle::Rectangle rect,
bool invert_transformations = true,
bool allow_shrink = true,
@@ -313,7 +313,8 @@ class QPDFPageObjectHelper: public QPDFObjectHelper
// matrix that was used.
QPDF_DLL
std::string placeFormXObject(
- QPDFObjectHandle fo, std::string const& name,
+ QPDFObjectHandle fo,
+ std::string const& name,
QPDFObjectHandle::Rectangle rect,
QPDFMatrix& cm,
bool invert_transformations = true,
@@ -326,9 +327,11 @@ class QPDFPageObjectHelper: public QPDFObjectHelper
// placeFormXObject.
QPDF_DLL
QPDFMatrix getMatrixForFormXObjectPlacement(
- QPDFObjectHandle fo, QPDFObjectHandle::Rectangle rect,
+ QPDFObjectHandle fo,
+ QPDFObjectHandle::Rectangle rect,
bool invert_transformations = true,
- bool allow_shrink = true, bool allow_expand = false);
+ bool allow_shrink = true,
+ bool allow_expand = false);
// If a page is rotated using /Rotate in the page's dictionary,
// instead rotate the page by the same amount by altering the
@@ -372,13 +375,13 @@ class QPDFPageObjectHelper: public QPDFObjectHelper
// these outside and pass them in.
QPDF_DLL
void copyAnnotations(
- QPDFPageObjectHelper from_page, QPDFMatrix const& cm = QPDFMatrix(),
+ QPDFPageObjectHelper from_page,
+ QPDFMatrix const& cm = QPDFMatrix(),
QPDFAcroFormDocumentHelper* afdh = nullptr,
QPDFAcroFormDocumentHelper* from_afdh = nullptr);
private:
- static bool
- removeUnreferencedResourcesHelper(
+ static bool removeUnreferencedResourcesHelper(
QPDFPageObjectHelper ph, std::set<std::string>& unresolved);
class Members
diff --git a/include/qpdf/QPDFStreamFilter.hh b/include/qpdf/QPDFStreamFilter.hh
index 31a8b317..a9daf028 100644
--- a/include/qpdf/QPDFStreamFilter.hh
+++ b/include/qpdf/QPDFStreamFilter.hh
@@ -23,8 +23,8 @@
#define QPDFSTREAMFILTER_HH
#include <qpdf/DLL.h>
-#include <qpdf/QPDFObjectHandle.hh>
#include <qpdf/Pipeline.hh>
+#include <qpdf/QPDFObjectHandle.hh>
class QPDF_DLL_CLASS QPDFStreamFilter
{
diff --git a/include/qpdf/QPDFSystemError.hh b/include/qpdf/QPDFSystemError.hh
index 92c88329..b8595e09 100644
--- a/include/qpdf/QPDFSystemError.hh
+++ b/include/qpdf/QPDFSystemError.hh
@@ -22,19 +22,18 @@
#ifndef QPDFSYSTEMERROR_HH
#define QPDFSYSTEMERROR_HH
+#include <qpdf/Constants.h>
#include <qpdf/DLL.h>
#include <qpdf/Types.h>
-#include <qpdf/Constants.h>
-#include <string>
#include <stdexcept>
+#include <string>
class QPDF_DLL_CLASS QPDFSystemError: public std::runtime_error
{
public:
QPDF_DLL
- QPDFSystemError(std::string const& description,
- int system_errno);
+ QPDFSystemError(std::string const& description, int system_errno);
QPDF_DLL
virtual ~QPDFSystemError() noexcept;
@@ -48,8 +47,8 @@ class QPDF_DLL_CLASS QPDFSystemError: public std::runtime_error
int getErrno() const;
private:
- static std::string createWhat(std::string const& description,
- int system_errno);
+ static std::string
+ createWhat(std::string const& description, int system_errno);
// This class does not use the Members pattern to avoid needless
// memory allocations during exception handling.
diff --git a/include/qpdf/QPDFTokenizer.hh b/include/qpdf/QPDFTokenizer.hh
index 0202d43f..8adc7db9 100644
--- a/include/qpdf/QPDFTokenizer.hh
+++ b/include/qpdf/QPDFTokenizer.hh
@@ -27,9 +27,9 @@
#include <qpdf/InputSource.hh>
#include <qpdf/PointerHolder.hh>
-#include <string>
-#include <stdio.h>
#include <memory>
+#include <stdio.h>
+#include <string>
class QPDFTokenizer
{
@@ -38,8 +38,7 @@ class QPDFTokenizer
// the tokenizer. tt_eof was introduced in QPDF version 4.1.
// tt_space, tt_comment, and tt_inline_image were added in QPDF
// version 8.
- enum token_type_e
- {
+ enum token_type_e {
tt_bad,
tt_array_close,
tt_array_open,
@@ -63,39 +62,50 @@ class QPDFTokenizer
class Token
{
public:
- Token() : type(tt_bad) {}
+ Token() :
+ type(tt_bad)
+ {
+ }
QPDF_DLL
Token(token_type_e type, std::string const& value);
- Token(token_type_e type, std::string const& value,
- std::string raw_value, std::string error_message) :
+ Token(
+ token_type_e type,
+ std::string const& value,
+ std::string raw_value,
+ std::string error_message) :
type(type),
value(value),
raw_value(raw_value),
error_message(error_message)
{
}
- token_type_e getType() const
+ token_type_e
+ getType() const
{
return this->type;
}
- std::string const& getValue() const
+ std::string const&
+ getValue() const
{
return this->value;
}
- std::string const& getRawValue() const
+ std::string const&
+ getRawValue() const
{
return this->raw_value;
}
- std::string const& getErrorMessage() const
+ std::string const&
+ getErrorMessage() const
{
return this->error_message;
}
- bool operator==(Token const& rhs) const
+ bool
+ operator==(Token const& rhs) const
{
// Ignore fields other than type and value
- return ((this->type != tt_bad) &&
- (this->type == rhs.type) &&
- (this->value == rhs.value));
+ return (
+ (this->type != tt_bad) && (this->type == rhs.type) &&
+ (this->value == rhs.value));
}
private:
@@ -162,10 +172,11 @@ class QPDFTokenizer
// offset" as returned by input->getLastOffset() points to the
// beginning of the token.
QPDF_DLL
- Token readToken(PointerHolder<InputSource> input,
- std::string const& context,
- bool allow_bad = false,
- size_t max_len = 0);
+ Token readToken(
+ PointerHolder<InputSource> input,
+ std::string const& context,
+ bool allow_bad = false,
+ size_t max_len = 0);
// Calling this method puts the tokenizer in a state for reading
// inline images. You should call this method after reading the
@@ -188,8 +199,16 @@ class QPDFTokenizer
void findEI(PointerHolder<InputSource> input);
enum state_e {
- st_top, st_in_space, st_in_comment, st_in_string, st_lt, st_gt,
- st_literal, st_in_hexstring, st_inline_image, st_token_ready
+ st_top,
+ st_in_space,
+ st_in_comment,
+ st_in_string,
+ st_lt,
+ st_gt,
+ st_literal,
+ st_in_hexstring,
+ st_inline_image,
+ st_token_ready
};
class Members
diff --git a/include/qpdf/QPDFUsage.hh b/include/qpdf/QPDFUsage.hh
index 064dc24e..eacfd97b 100644
--- a/include/qpdf/QPDFUsage.hh
+++ b/include/qpdf/QPDFUsage.hh
@@ -24,8 +24,8 @@
#include <qpdf/DLL.h>
-#include <string>
#include <stdexcept>
+#include <string>
class QPDF_DLL_CLASS QPDFUsage: public std::runtime_error
{
diff --git a/include/qpdf/QPDFWriter.hh b/include/qpdf/QPDFWriter.hh
index 1f8fc360..369bc946 100644
--- a/include/qpdf/QPDFWriter.hh
+++ b/include/qpdf/QPDFWriter.hh
@@ -29,24 +29,24 @@
#include <qpdf/DLL.h>
#include <qpdf/Types.h>
-#include <stdio.h>
-#include <string>
#include <list>
-#include <vector>
-#include <set>
#include <map>
#include <memory>
+#include <set>
+#include <stdio.h>
+#include <string>
+#include <vector>
#include <qpdf/Constants.h>
-#include <qpdf/QPDFObjectHandle.hh>
-#include <qpdf/QPDFObjGen.hh>
-#include <qpdf/QPDFXRefEntry.hh>
-#include <qpdf/Pl_Buffer.hh>
-#include <qpdf/PointerHolder.hh>
-#include <qpdf/Pipeline.hh>
#include <qpdf/Buffer.hh>
#include <qpdf/PDFVersion.hh>
+#include <qpdf/Pipeline.hh>
+#include <qpdf/Pl_Buffer.hh>
+#include <qpdf/PointerHolder.hh>
+#include <qpdf/QPDFObjGen.hh>
+#include <qpdf/QPDFObjectHandle.hh>
+#include <qpdf/QPDFXRefEntry.hh>
class QPDF;
class Pl_Count;
@@ -372,72 +372,104 @@ class QPDFWriter
// it unless you have to.
QPDF_DLL
void setR2EncryptionParameters(
- char const* user_password, char const* owner_password,
- bool allow_print, bool allow_modify,
- bool allow_extract, bool allow_annotate);
+ char const* user_password,
+ char const* owner_password,
+ bool allow_print,
+ bool allow_modify,
+ bool allow_extract,
+ bool allow_annotate);
// R3 uses RC4, which is a weak cryptographic algorithm. Don't use
// it unless you have to.
QPDF_DLL
void setR3EncryptionParameters(
- char const* user_password, char const* owner_password,
- bool allow_accessibility, bool allow_extract,
- bool allow_assemble, bool allow_annotate_and_form,
- bool allow_form_filling, bool allow_modify_other,
+ char const* user_password,
+ char const* owner_password,
+ bool allow_accessibility,
+ bool allow_extract,
+ bool allow_assemble,
+ bool allow_annotate_and_form,
+ bool allow_form_filling,
+ bool allow_modify_other,
qpdf_r3_print_e print);
// R4 uses RC4, which is a weak cryptographic algorithm, when
// use_aes=false. Don't use it unless you have to.
QPDF_DLL
void setR4EncryptionParameters(
- char const* user_password, char const* owner_password,
- bool allow_accessibility, bool allow_extract,
- bool allow_assemble, bool allow_annotate_and_form,
- bool allow_form_filling, bool allow_modify_other,
- qpdf_r3_print_e print, bool encrypt_metadata, bool use_aes);
+ char const* user_password,
+ char const* owner_password,
+ bool allow_accessibility,
+ bool allow_extract,
+ bool allow_assemble,
+ bool allow_annotate_and_form,
+ bool allow_form_filling,
+ bool allow_modify_other,
+ qpdf_r3_print_e print,
+ bool encrypt_metadata,
+ bool use_aes);
// R5 is deprecated. Do not use it for production use. Writing
// R5 is supported by qpdf primarily to generate test files for
// applications that may need to test R5 support.
QPDF_DLL
void setR5EncryptionParameters(
- char const* user_password, char const* owner_password,
- bool allow_accessibility, bool allow_extract,
- bool allow_assemble, bool allow_annotate_and_form,
- bool allow_form_filling, bool allow_modify_other,
- qpdf_r3_print_e print, bool encrypt_metadata);
+ char const* user_password,
+ char const* owner_password,
+ bool allow_accessibility,
+ bool allow_extract,
+ bool allow_assemble,
+ bool allow_annotate_and_form,
+ bool allow_form_filling,
+ bool allow_modify_other,
+ qpdf_r3_print_e print,
+ bool encrypt_metadata);
QPDF_DLL
void setR6EncryptionParameters(
- char const* user_password, char const* owner_password,
- bool allow_accessibility, bool allow_extract,
- bool allow_assemble, bool allow_annotate_and_form,
- bool allow_form_filling, bool allow_modify_other,
- qpdf_r3_print_e print, bool encrypt_metadata_aes);
+ char const* user_password,
+ char const* owner_password,
+ bool allow_accessibility,
+ bool allow_extract,
+ bool allow_assemble,
+ bool allow_annotate_and_form,
+ bool allow_form_filling,
+ bool allow_modify_other,
+ qpdf_r3_print_e print,
+ bool encrypt_metadata_aes);
// Pre qpdf 8.4.0 API
- [[deprecated("see newer API above")]]
- QPDF_DLL
- void setR3EncryptionParameters(
- char const* user_password, char const* owner_password,
- bool allow_accessibility, bool allow_extract,
- qpdf_r3_print_e print, qpdf_r3_modify_e modify);
- [[deprecated("see newer API above")]]
- QPDF_DLL
- void setR4EncryptionParameters(
- char const* user_password, char const* owner_password,
- bool allow_accessibility, bool allow_extract,
- qpdf_r3_print_e print, qpdf_r3_modify_e modify,
- bool encrypt_metadata, bool use_aes);
- [[deprecated("see newer API above")]]
- QPDF_DLL
- void setR5EncryptionParameters(
- char const* user_password, char const* owner_password,
- bool allow_accessibility, bool allow_extract,
- qpdf_r3_print_e print, qpdf_r3_modify_e modify,
+ [[deprecated("see newer API above")]] QPDF_DLL void
+ setR3EncryptionParameters(
+ char const* user_password,
+ char const* owner_password,
+ bool allow_accessibility,
+ bool allow_extract,
+ qpdf_r3_print_e print,
+ qpdf_r3_modify_e modify);
+ [[deprecated("see newer API above")]] QPDF_DLL void
+ setR4EncryptionParameters(
+ char const* user_password,
+ char const* owner_password,
+ bool allow_accessibility,
+ bool allow_extract,
+ qpdf_r3_print_e print,
+ qpdf_r3_modify_e modify,
+ bool encrypt_metadata,
+ bool use_aes);
+ [[deprecated("see newer API above")]] QPDF_DLL void
+ setR5EncryptionParameters(
+ char const* user_password,
+ char const* owner_password,
+ bool allow_accessibility,
+ bool allow_extract,
+ qpdf_r3_print_e print,
+ qpdf_r3_modify_e modify,
bool encrypt_metadata);
- [[deprecated("see newer API above")]]
- QPDF_DLL
- void setR6EncryptionParameters(
- char const* user_password, char const* owner_password,
- bool allow_accessibility, bool allow_extract,
- qpdf_r3_print_e print, qpdf_r3_modify_e modify,
+ [[deprecated("see newer API above")]] QPDF_DLL void
+ setR6EncryptionParameters(
+ char const* user_password,
+ char const* owner_password,
+ bool allow_accessibility,
+ bool allow_extract,
+ qpdf_r3_print_e print,
+ qpdf_r3_modify_e modify,
bool encrypt_metadata_aes);
// Create linearized output. Disables qdf mode, content
@@ -496,11 +528,11 @@ class QPDFWriter
private:
// flags used by unparseObject
- static int const f_stream = 1 << 0;
- static int const f_filtered = 1 << 1;
- static int const f_in_ostream = 1 << 2;
- static int const f_hex_string = 1 << 3;
- static int const f_no_encryption = 1 << 4;
+ static int const f_stream = 1 << 0;
+ static int const f_filtered = 1 << 1;
+ static int const f_in_ostream = 1 << 2;
+ static int const f_hex_string = 1 << 3;
+ static int const f_no_encryption = 1 << 4;
enum trailer_e { t_normal, t_lin_first, t_lin_second };
@@ -516,9 +548,9 @@ class QPDFWriter
class PipelinePopper
{
friend class QPDFWriter;
+
public:
- PipelinePopper(QPDFWriter* qw,
- PointerHolder<Buffer>* bp = 0) :
+ PipelinePopper(QPDFWriter* qw, PointerHolder<Buffer>* bp = 0) :
qw(qw),
bp(bp)
{
@@ -545,15 +577,24 @@ class QPDFWriter
std::vector<qpdf_offset_t>& offsets, int first_obj);
void writeObjectStream(QPDFObjectHandle object);
void writeObject(QPDFObjectHandle object, int object_stream_index = -1);
- void writeTrailer(trailer_e which, int size,
- bool xref_stream, qpdf_offset_t prev,
- int linearization_pass);
- bool willFilterStream(QPDFObjectHandle stream,
- bool& compress_stream, bool& is_metadata,
- PointerHolder<Buffer>* stream_data);
- void unparseObject(QPDFObjectHandle object, int level, int flags,
- // for stream dictionaries
- size_t stream_length = 0, bool compress = false);
+ void writeTrailer(
+ trailer_e which,
+ int size,
+ bool xref_stream,
+ qpdf_offset_t prev,
+ int linearization_pass);
+ bool willFilterStream(
+ QPDFObjectHandle stream,
+ bool& compress_stream,
+ bool& is_metadata,
+ PointerHolder<Buffer>* stream_data);
+ void unparseObject(
+ QPDFObjectHandle object,
+ int level,
+ int flags,
+ // for stream dictionaries
+ size_t stream_length = 0,
+ bool compress = false);
void unparseChild(QPDFObjectHandle child, int level, int flags);
void initializeSpecialStreams();
void preserveObjectStreams();
@@ -562,23 +603,39 @@ class QPDFWriter
void generateID();
void interpretR3EncryptionParameters(
std::set<int>& bits_to_clear,
- char const* user_password, char const* owner_password,
- bool allow_accessibility, bool allow_extract,
- bool allow_assemble, bool allow_annotate_and_form,
- bool allow_form_filling, bool allow_modify_other,
- qpdf_r3_print_e print, qpdf_r3_modify_e modify);
- void disableIncompatibleEncryption(int major, int minor,
- int extension_level);
+ char const* user_password,
+ char const* owner_password,
+ bool allow_accessibility,
+ bool allow_extract,
+ bool allow_assemble,
+ bool allow_annotate_and_form,
+ bool allow_form_filling,
+ bool allow_modify_other,
+ qpdf_r3_print_e print,
+ qpdf_r3_modify_e modify);
+ void
+ disableIncompatibleEncryption(int major, int minor, int extension_level);
void parseVersion(std::string const& version, int& major, int& minor) const;
int compareVersions(int major1, int minor1, int major2, int minor2) const;
void setEncryptionParameters(
- char const* user_password, char const* owner_password,
- int V, int R, int key_len, std::set<int>& bits_to_clear);
+ char const* user_password,
+ char const* owner_password,
+ int V,
+ int R,
+ int key_len,
+ std::set<int>& bits_to_clear);
void setEncryptionParametersInternal(
- int V, int R, int key_len, int P,
- std::string const& O, std::string const& U,
- std::string const& OE, std::string const& UE, std::string const& Perms,
- std::string const& id1, std::string const& user_password,
+ int V,
+ int R,
+ int key_len,
+ int P,
+ std::string const& O,
+ std::string const& U,
+ std::string const& OE,
+ std::string const& UE,
+ std::string const& Perms,
+ std::string const& id1,
+ std::string const& user_password,
std::string const& encryption_key);
void setDataKey(int objid);
int openObject(int objid = 0);
@@ -595,10 +652,13 @@ class QPDFWriter
void doWriteSetup();
void writeHeader();
void writeHintStream(int hint_id);
+ qpdf_offset_t
+ writeXRefTable(trailer_e which, int first, int last, int size);
qpdf_offset_t writeXRefTable(
- trailer_e which, int first, int last, int size);
- qpdf_offset_t writeXRefTable(
- trailer_e which, int first, int last, int size,
+ trailer_e which,
+ int first,
+ int last,
+ int size,
// for linearization
qpdf_offset_t prev,
bool suppress_offsets,
@@ -607,11 +667,21 @@ class QPDFWriter
qpdf_offset_t hint_length,
int linearization_pass);
qpdf_offset_t writeXRefStream(
- int objid, int max_id, qpdf_offset_t max_offset,
- trailer_e which, int first, int last, int size);
+ int objid,
+ int max_id,
+ qpdf_offset_t max_offset,
+ trailer_e which,
+ int first,
+ int last,
+ int size);
qpdf_offset_t writeXRefStream(
- int objid, int max_id, qpdf_offset_t max_offset,
- trailer_e which, int first, int last, int size,
+ int objid,
+ int max_id,
+ qpdf_offset_t max_offset,
+ trailer_e which,
+ int first,
+ int last,
+ int size,
// for linearization
qpdf_offset_t prev,
int hint_id,
@@ -627,7 +697,7 @@ class QPDFWriter
// popped.
Pipeline* pushPipeline(Pipeline*);
void activatePipelineStack(PipelinePopper&);
- void initializePipelineStack(Pipeline *);
+ void initializePipelineStack(Pipeline*);
void adjustAESStreamLength(size_t& length);
void pushEncryptionFilter(PipelinePopper&);
@@ -635,8 +705,8 @@ class QPDFWriter
void pushMD5Pipeline(PipelinePopper&);
void computeDeterministicIDData();
- void discardGeneration(std::map<QPDFObjGen, int> const& in,
- std::map<int, int>& out);
+ void discardGeneration(
+ std::map<QPDFObjGen, int> const& in, std::map<int, int>& out);
class Members
{
@@ -681,8 +751,8 @@ class QPDFWriter
int encryption_V;
int encryption_R;
- std::string id1; // for /ID key of
- std::string id2; // trailer dictionary
+ std::string id1; // for /ID key of
+ std::string id2; // trailer dictionary
std::string final_pdf_version;
int final_extension_level;
std::string min_pdf_version;
@@ -707,7 +777,7 @@ class QPDFWriter
std::map<QPDFObjGen, int> page_object_to_seq;
std::map<QPDFObjGen, int> contents_to_page_seq;
std::map<QPDFObjGen, int> object_to_object_stream;
- std::map<int, std::set<QPDFObjGen> > object_stream_to_objects;
+ std::map<int, std::set<QPDFObjGen>> object_stream_to_objects;
std::list<Pipeline*> pipeline_stack;
unsigned long long next_stack_id;
bool deterministic_id;
diff --git a/include/qpdf/QPDFXRefEntry.hh b/include/qpdf/QPDFXRefEntry.hh
index 78056312..8ed39d94 100644
--- a/include/qpdf/QPDFXRefEntry.hh
+++ b/include/qpdf/QPDFXRefEntry.hh
@@ -42,11 +42,11 @@ class QPDFXRefEntry
QPDF_DLL
int getType() const;
QPDF_DLL
- qpdf_offset_t getOffset() const; // only for type 1
+ qpdf_offset_t getOffset() const; // only for type 1
QPDF_DLL
- int getObjStreamNumber() const; // only for type 2
+ int getObjStreamNumber() const; // only for type 2
QPDF_DLL
- int getObjStreamIndex() const; // only for type 2
+ int getObjStreamIndex() const; // only for type 2
private:
// This class does not use the Members pattern to avoid a memory
diff --git a/include/qpdf/QTC.hh b/include/qpdf/QTC.hh
index e9b8565e..1fa55901 100644
--- a/include/qpdf/QTC.hh
+++ b/include/qpdf/QTC.hh
@@ -28,6 +28,6 @@ namespace QTC
{
QPDF_DLL
void TC(char const* const scope, char const* const ccase, int n = 0);
-};
+}; // namespace QTC
#endif // QTC_HH
diff --git a/include/qpdf/QUtil.hh b/include/qpdf/QUtil.hh
index c1c22110..37eea484 100644
--- a/include/qpdf/QUtil.hh
+++ b/include/qpdf/QUtil.hh
@@ -23,16 +23,16 @@
#define QUTIL_HH
#include <qpdf/DLL.h>
-#include <qpdf/Types.h>
#include <qpdf/PointerHolder.hh>
-#include <string>
-#include <list>
-#include <vector>
-#include <stdexcept>
+#include <qpdf/Types.h>
#include <functional>
+#include <list>
#include <memory>
+#include <stdexcept>
#include <stdio.h>
+#include <string>
#include <time.h>
+#include <vector>
class RandomDataProvider;
class Pipeline;
@@ -48,16 +48,16 @@ namespace QUtil
QPDF_DLL
std::string int_to_string_base(long long, int base, int length = 0);
QPDF_DLL
- std::string uint_to_string_base(unsigned long long, int base,
- int length = 0);
+ std::string
+ uint_to_string_base(unsigned long long, int base, int length = 0);
QPDF_DLL
std::string double_to_string(double, int decimal_places = 0);
// ABI: combine with other double_to_string by adding
// trim_trailing_zeroes above as an optional parameter with a
// default of true.
QPDF_DLL
- std::string double_to_string(double, int decimal_places,
- bool trim_trailing_zeroes);
+ std::string
+ double_to_string(double, int decimal_places, bool trim_trailing_zeroes);
// These string to number methods throw std::runtime_error on
// underflow/overflow.
@@ -217,8 +217,14 @@ namespace QUtil
QPDFTime() = default;
QPDFTime(QPDFTime const&) = default;
QPDFTime& operator=(QPDFTime const&) = default;
- QPDFTime(int year, int month, int day, int hour,
- int minute, int second, int tz_delta) :
+ QPDFTime(
+ int year,
+ int month,
+ int day,
+ int hour,
+ int minute,
+ int second,
+ int tz_delta) :
year(year),
month(month),
day(day),
@@ -228,13 +234,13 @@ namespace QUtil
tz_delta(tz_delta)
{
}
- int year; // actual year, no 1900 stuff
- int month; // 1--12
- int day; // 1--31
+ int year; // actual year, no 1900 stuff
+ int month; // 1--12
+ int day; // 1--31
int hour;
int minute;
int second;
- int tz_delta; // minutes before UTC
+ int tz_delta; // minutes before UTC
};
QPDF_DLL
@@ -284,17 +290,16 @@ namespace QUtil
// encoding system by replacing all unsupported characters with
// the given unknown_char.
QPDF_DLL
- std::string utf8_to_ascii(
- std::string const& utf8, char unknown_char = '?');
+ std::string utf8_to_ascii(std::string const& utf8, char unknown_char = '?');
QPDF_DLL
- std::string utf8_to_win_ansi(
- std::string const& utf8, char unknown_char = '?');
+ std::string
+ utf8_to_win_ansi(std::string const& utf8, char unknown_char = '?');
QPDF_DLL
- std::string utf8_to_mac_roman(
- std::string const& utf8, char unknown_char = '?');
+ std::string
+ utf8_to_mac_roman(std::string const& utf8, char unknown_char = '?');
QPDF_DLL
- std::string utf8_to_pdf_doc(
- std::string const& utf8, char unknown_char = '?');
+ std::string
+ utf8_to_pdf_doc(std::string const& utf8, char unknown_char = '?');
// These versions return true if the conversion was successful and
// false if any unrepresentable characters were found and had to
@@ -338,10 +343,11 @@ namespace QUtil
// the PDF spec requires UTF-16 to be UTF-16BE, qpdf (and just
// about everything else) accepts UTF-16LE (as of 10.6.2).
QPDF_DLL
- void analyze_encoding(std::string const& str,
- bool& has_8bit_chars,
- bool& is_valid_utf8,
- bool& is_utf16);
+ void analyze_encoding(
+ std::string const& str,
+ bool& has_8bit_chars,
+ bool& is_valid_utf8,
+ bool& is_utf16);
// Try to compensate for previously incorrectly encoded strings.
// We want to compensate for the following errors:
@@ -398,14 +404,14 @@ namespace QUtil
// Filename is UTF-8 encoded, even on Windows, as described in the
// comments for safe_fopen.
QPDF_DLL
- std::list<std::string> read_lines_from_file(
- char const* filename, bool preserve_eol = false);
+ std::list<std::string>
+ read_lines_from_file(char const* filename, bool preserve_eol = false);
QPDF_DLL
- std::list<std::string> read_lines_from_file(
- std::istream&, bool preserve_eol = false);
+ std::list<std::string>
+ read_lines_from_file(std::istream&, bool preserve_eol = false);
QPDF_DLL
- std::list<std::string> read_lines_from_file(
- FILE*, bool preserve_eol = false);
+ std::list<std::string>
+ read_lines_from_file(FILE*, bool preserve_eol = false);
QPDF_DLL
void read_lines_from_file(
std::function<bool(char&)> next_char,
@@ -420,7 +426,7 @@ namespace QUtil
// platforms, so we have to give it a name that is not likely to
// be a macro anywhere.
QPDF_DLL
- int str_compare_nocase(char const *, char const *);
+ int str_compare_nocase(char const*, char const*);
// These routines help the tokenizer recognize certain character
// classes without using ctype, which we avoid because of locale
@@ -454,13 +460,13 @@ namespace QUtil
// another main.
QPDF_DLL
int call_main_from_wmain(
- int argc, wchar_t* argv[],
- std::function<int(int, char*[])> realmain);
+ int argc, wchar_t* argv[], std::function<int(int, char*[])> realmain);
QPDF_DLL
int call_main_from_wmain(
- int argc, wchar_t const* const argv[],
+ int argc,
+ wchar_t const* const argv[],
std::function<int(int, char const* const[])> realmain);
#endif // QPDF_NO_WCHAR_T
-};
+}; // namespace QUtil
#endif // QUTIL_HH
diff --git a/include/qpdf/qpdf-c.h b/include/qpdf/qpdf-c.h
index af7e83f8..9c7557ab 100644
--- a/include/qpdf/qpdf-c.h
+++ b/include/qpdf/qpdf-c.h
@@ -137,9 +137,9 @@
* https://github.com/qpdf/qpdf/issues/new.
*/
+#include <qpdf/Constants.h>
#include <qpdf/DLL.h>
#include <qpdf/Types.h>
-#include <qpdf/Constants.h>
#include <string.h>
#ifdef __cplusplus
@@ -154,13 +154,13 @@ extern "C" {
* that the values below can be logically orred together.
*/
typedef int QPDF_ERROR_CODE;
-# define QPDF_SUCCESS 0
-# define QPDF_WARNINGS 1 << 0
-# define QPDF_ERRORS 1 << 1
+#define QPDF_SUCCESS 0
+#define QPDF_WARNINGS 1 << 0
+#define QPDF_ERRORS 1 << 1
typedef int QPDF_BOOL;
-# define QPDF_TRUE 1
-# define QPDF_FALSE 0
+#define QPDF_TRUE 1
+#define QPDF_FALSE 0
/* From qpdf 10.5: call this method to signal to the library that
* you are explicitly handling errors from functions that don't
@@ -273,8 +273,8 @@ extern "C" {
* pointer or an empty string as the password.
*/
QPDF_DLL
- QPDF_ERROR_CODE qpdf_read(qpdf_data qpdf, char const* filename,
- char const* password);
+ QPDF_ERROR_CODE
+ qpdf_read(qpdf_data qpdf, char const* filename, char const* password);
/* Calling qpdf_read_memory causes processMemoryFile to be called
* in the C++ API. Otherwise, it behaves in the same way as
@@ -283,11 +283,12 @@ extern "C" {
* library.
*/
QPDF_DLL
- QPDF_ERROR_CODE qpdf_read_memory(qpdf_data qpdf,
- char const* description,
- char const* buffer,
- unsigned long long size,
- char const* password);
+ QPDF_ERROR_CODE qpdf_read_memory(
+ qpdf_data qpdf,
+ char const* description,
+ char const* buffer,
+ unsigned long long size,
+ char const* password);
/* Calling qpdf_empty_pdf initializes this qpdf object with an
* empty PDF, making it possible to create a PDF from scratch
@@ -409,24 +410,23 @@ extern "C" {
unsigned char const* qpdf_get_buffer(qpdf_data qpdf);
QPDF_DLL
- void qpdf_set_object_stream_mode(qpdf_data qpdf,
- enum qpdf_object_stream_e mode);
+ void
+ qpdf_set_object_stream_mode(qpdf_data qpdf, enum qpdf_object_stream_e mode);
QPDF_DLL
- void qpdf_set_stream_data_mode(qpdf_data qpdf,
- enum qpdf_stream_data_e mode);
+ void
+ qpdf_set_stream_data_mode(qpdf_data qpdf, enum qpdf_stream_data_e mode);
QPDF_DLL
void qpdf_set_compress_streams(qpdf_data qpdf, QPDF_BOOL value);
-
QPDF_DLL
- void qpdf_set_decode_level(qpdf_data qpdf,
- enum qpdf_stream_decode_level_e level);
+ void qpdf_set_decode_level(
+ qpdf_data qpdf, enum qpdf_stream_decode_level_e level);
QPDF_DLL
- void qpdf_set_preserve_unreferenced_objects(
- qpdf_data qpdf, QPDF_BOOL value);
+ void
+ qpdf_set_preserve_unreferenced_objects(qpdf_data qpdf, QPDF_BOOL value);
QPDF_DLL
void qpdf_set_newline_before_endstream(qpdf_data qpdf, QPDF_BOOL value);
@@ -453,77 +453,120 @@ extern "C" {
void qpdf_set_static_aes_IV(qpdf_data qpdf, QPDF_BOOL value);
QPDF_DLL
- void qpdf_set_suppress_original_object_IDs(
- qpdf_data qpdf, QPDF_BOOL value);
+ void qpdf_set_suppress_original_object_IDs(qpdf_data qpdf, QPDF_BOOL value);
QPDF_DLL
void qpdf_set_preserve_encryption(qpdf_data qpdf, QPDF_BOOL value);
QPDF_DLL
void qpdf_set_r2_encryption_parameters(
- qpdf_data qpdf, char const* user_password, char const* owner_password,
- QPDF_BOOL allow_print, QPDF_BOOL allow_modify,
- QPDF_BOOL allow_extract, QPDF_BOOL allow_annotate);
+ qpdf_data qpdf,
+ char const* user_password,
+ char const* owner_password,
+ QPDF_BOOL allow_print,
+ QPDF_BOOL allow_modify,
+ QPDF_BOOL allow_extract,
+ QPDF_BOOL allow_annotate);
QPDF_DLL
void qpdf_set_r3_encryption_parameters2(
- qpdf_data qpdf, char const* user_password, char const* owner_password,
- QPDF_BOOL allow_accessibility, QPDF_BOOL allow_extract,
- QPDF_BOOL allow_assemble, QPDF_BOOL allow_annotate_and_form,
- QPDF_BOOL allow_form_filling, QPDF_BOOL allow_modify_other,
+ qpdf_data qpdf,
+ char const* user_password,
+ char const* owner_password,
+ QPDF_BOOL allow_accessibility,
+ QPDF_BOOL allow_extract,
+ QPDF_BOOL allow_assemble,
+ QPDF_BOOL allow_annotate_and_form,
+ QPDF_BOOL allow_form_filling,
+ QPDF_BOOL allow_modify_other,
enum qpdf_r3_print_e print);
QPDF_DLL
void qpdf_set_r4_encryption_parameters2(
- qpdf_data qpdf, char const* user_password, char const* owner_password,
- QPDF_BOOL allow_accessibility, QPDF_BOOL allow_extract,
- QPDF_BOOL allow_assemble, QPDF_BOOL allow_annotate_and_form,
- QPDF_BOOL allow_form_filling, QPDF_BOOL allow_modify_other,
+ qpdf_data qpdf,
+ char const* user_password,
+ char const* owner_password,
+ QPDF_BOOL allow_accessibility,
+ QPDF_BOOL allow_extract,
+ QPDF_BOOL allow_assemble,
+ QPDF_BOOL allow_annotate_and_form,
+ QPDF_BOOL allow_form_filling,
+ QPDF_BOOL allow_modify_other,
enum qpdf_r3_print_e print,
- QPDF_BOOL encrypt_metadata, QPDF_BOOL use_aes);
+ QPDF_BOOL encrypt_metadata,
+ QPDF_BOOL use_aes);
QPDF_DLL
void qpdf_set_r5_encryption_parameters2(
- qpdf_data qpdf, char const* user_password, char const* owner_password,
- QPDF_BOOL allow_accessibility, QPDF_BOOL allow_extract,
- QPDF_BOOL allow_assemble, QPDF_BOOL allow_annotate_and_form,
- QPDF_BOOL allow_form_filling, QPDF_BOOL allow_modify_other,
- enum qpdf_r3_print_e print, QPDF_BOOL encrypt_metadata);
+ qpdf_data qpdf,
+ char const* user_password,
+ char const* owner_password,
+ QPDF_BOOL allow_accessibility,
+ QPDF_BOOL allow_extract,
+ QPDF_BOOL allow_assemble,
+ QPDF_BOOL allow_annotate_and_form,
+ QPDF_BOOL allow_form_filling,
+ QPDF_BOOL allow_modify_other,
+ enum qpdf_r3_print_e print,
+ QPDF_BOOL encrypt_metadata);
QPDF_DLL
void qpdf_set_r6_encryption_parameters2(
- qpdf_data qpdf, char const* user_password, char const* owner_password,
- QPDF_BOOL allow_accessibility, QPDF_BOOL allow_extract,
- QPDF_BOOL allow_assemble, QPDF_BOOL allow_annotate_and_form,
- QPDF_BOOL allow_form_filling, QPDF_BOOL allow_modify_other,
- enum qpdf_r3_print_e print, QPDF_BOOL encrypt_metadata);
+ qpdf_data qpdf,
+ char const* user_password,
+ char const* owner_password,
+ QPDF_BOOL allow_accessibility,
+ QPDF_BOOL allow_extract,
+ QPDF_BOOL allow_assemble,
+ QPDF_BOOL allow_annotate_and_form,
+ QPDF_BOOL allow_form_filling,
+ QPDF_BOOL allow_modify_other,
+ enum qpdf_r3_print_e print,
+ QPDF_BOOL encrypt_metadata);
/* Pre 8.4.0 encryption API */
QPDF_DLL
void qpdf_set_r3_encryption_parameters(
- qpdf_data qpdf, char const* user_password, char const* owner_password,
- QPDF_BOOL allow_accessibility, QPDF_BOOL allow_extract,
- enum qpdf_r3_print_e print, enum qpdf_r3_modify_e modify);
+ qpdf_data qpdf,
+ char const* user_password,
+ char const* owner_password,
+ QPDF_BOOL allow_accessibility,
+ QPDF_BOOL allow_extract,
+ enum qpdf_r3_print_e print,
+ enum qpdf_r3_modify_e modify);
QPDF_DLL
void qpdf_set_r4_encryption_parameters(
- qpdf_data qpdf, char const* user_password, char const* owner_password,
- QPDF_BOOL allow_accessibility, QPDF_BOOL allow_extract,
- enum qpdf_r3_print_e print, enum qpdf_r3_modify_e modify,
- QPDF_BOOL encrypt_metadata, QPDF_BOOL use_aes);
+ qpdf_data qpdf,
+ char const* user_password,
+ char const* owner_password,
+ QPDF_BOOL allow_accessibility,
+ QPDF_BOOL allow_extract,
+ enum qpdf_r3_print_e print,
+ enum qpdf_r3_modify_e modify,
+ QPDF_BOOL encrypt_metadata,
+ QPDF_BOOL use_aes);
QPDF_DLL
void qpdf_set_r5_encryption_parameters(
- qpdf_data qpdf, char const* user_password, char const* owner_password,
- QPDF_BOOL allow_accessibility, QPDF_BOOL allow_extract,
- enum qpdf_r3_print_e print, enum qpdf_r3_modify_e modify,
+ qpdf_data qpdf,
+ char const* user_password,
+ char const* owner_password,
+ QPDF_BOOL allow_accessibility,
+ QPDF_BOOL allow_extract,
+ enum qpdf_r3_print_e print,
+ enum qpdf_r3_modify_e modify,
QPDF_BOOL encrypt_metadata);
QPDF_DLL
void qpdf_set_r6_encryption_parameters(
- qpdf_data qpdf, char const* user_password, char const* owner_password,
- QPDF_BOOL allow_accessibility, QPDF_BOOL allow_extract,
- enum qpdf_r3_print_e print, enum qpdf_r3_modify_e modify,
+ qpdf_data qpdf,
+ char const* user_password,
+ char const* owner_password,
+ QPDF_BOOL allow_accessibility,
+ QPDF_BOOL allow_extract,
+ enum qpdf_r3_print_e print,
+ enum qpdf_r3_modify_e modify,
QPDF_BOOL encrypt_metadata);
QPDF_DLL
@@ -648,8 +691,8 @@ extern "C" {
QPDF_DLL
qpdf_oh qpdf_make_indirect_object(qpdf_data qpdf, qpdf_oh oh);
QPDF_DLL
- void qpdf_replace_object(
- qpdf_data qpdf, int objid, int generation, qpdf_oh oh);
+ void
+ qpdf_replace_object(qpdf_data qpdf, int objid, int generation, qpdf_oh oh);
/* Wrappers around QPDFObjectHandle methods. Be sure to read
* corresponding comments in QPDFObjectHandle.hh to understand
@@ -690,8 +733,8 @@ extern "C" {
QPDF_BOOL qpdf_oh_is_scalar(qpdf_data qpdf, qpdf_oh oh);
QPDF_DLL
- QPDF_BOOL qpdf_oh_is_name_and_equals(
- qpdf_data qpdf, qpdf_oh oh, char const* name);
+ QPDF_BOOL
+ qpdf_oh_is_name_and_equals(qpdf_data qpdf, qpdf_oh oh, char const* name);
QPDF_DLL
QPDF_BOOL qpdf_oh_is_dictionary_of_type(
@@ -711,19 +754,18 @@ extern "C" {
QPDF_DLL
QPDF_BOOL qpdf_oh_get_bool_value(qpdf_data qpdf, qpdf_oh oh);
QPDF_DLL
- QPDF_BOOL qpdf_oh_get_value_as_bool(
- qpdf_data qpdf, qpdf_oh oh, QPDF_BOOL* value);
+ QPDF_BOOL
+ qpdf_oh_get_value_as_bool(qpdf_data qpdf, qpdf_oh oh, QPDF_BOOL* value);
QPDF_DLL
long long qpdf_oh_get_int_value(qpdf_data qpdf, qpdf_oh oh);
QPDF_DLL
- QPDF_BOOL qpdf_oh_get_value_as_longlong(
- qpdf_data qpdf, qpdf_oh oh, long long* value);
+ QPDF_BOOL
+ qpdf_oh_get_value_as_longlong(qpdf_data qpdf, qpdf_oh oh, long long* value);
QPDF_DLL
int qpdf_oh_get_int_value_as_int(qpdf_data qpdf, qpdf_oh oh);
QPDF_DLL
- QPDF_BOOL qpdf_oh_get_value_as_int(
- qpdf_data qpdf, qpdf_oh oh, int* value);
+ QPDF_BOOL qpdf_oh_get_value_as_int(qpdf_data qpdf, qpdf_oh oh, int* value);
QPDF_DLL
unsigned long long qpdf_oh_get_uint_value(qpdf_data qpdf, qpdf_oh oh);
QPDF_DLL
@@ -732,8 +774,8 @@ extern "C" {
QPDF_DLL
unsigned int qpdf_oh_get_uint_value_as_uint(qpdf_data qpdf, qpdf_oh oh);
QPDF_DLL
- QPDF_BOOL qpdf_oh_get_value_as_uint(
- qpdf_data qpdf, qpdf_oh oh, unsigned int* value);
+ QPDF_BOOL
+ qpdf_oh_get_value_as_uint(qpdf_data qpdf, qpdf_oh oh, unsigned int* value);
QPDF_DLL
char const* qpdf_oh_get_real_value(qpdf_data qpdf, qpdf_oh oh);
@@ -746,8 +788,8 @@ extern "C" {
QPDF_DLL
double qpdf_oh_get_numeric_value(qpdf_data qpdf, qpdf_oh oh);
QPDF_DLL
- QPDF_BOOL qpdf_oh_get_value_as_number(
- qpdf_data qpdf, qpdf_oh oh, double* value);
+ QPDF_BOOL
+ qpdf_oh_get_value_as_number(qpdf_data qpdf, qpdf_oh oh, double* value);
QPDF_DLL
char const* qpdf_oh_get_name(qpdf_data qpdf, qpdf_oh oh);
@@ -782,11 +824,11 @@ extern "C" {
QPDF_BOOL qpdf_oh_get_value_as_utf8(
qpdf_data qpdf, qpdf_oh oh, char const** value, size_t* length);
QPDF_DLL
- char const* qpdf_oh_get_binary_string_value(
- qpdf_data qpdf, qpdf_oh oh, size_t* length);
+ char const*
+ qpdf_oh_get_binary_string_value(qpdf_data qpdf, qpdf_oh oh, size_t* length);
QPDF_DLL
- char const* qpdf_oh_get_binary_utf8_value(
- qpdf_data qpdf, qpdf_oh oh, size_t* length);
+ char const*
+ qpdf_oh_get_binary_utf8_value(qpdf_data qpdf, qpdf_oh oh, size_t* length);
QPDF_DLL
int qpdf_oh_get_array_n_items(qpdf_data qpdf, qpdf_oh oh);
@@ -822,12 +864,12 @@ extern "C" {
QPDF_DLL
qpdf_oh qpdf_oh_get_key(qpdf_data qpdf, qpdf_oh oh, char const* key);
QPDF_DLL
- qpdf_oh qpdf_oh_get_key_if_dict(
- qpdf_data qpdf, qpdf_oh oh, char const* key);
+ qpdf_oh
+ qpdf_oh_get_key_if_dict(qpdf_data qpdf, qpdf_oh oh, char const* key);
QPDF_DLL
- QPDF_BOOL qpdf_oh_is_or_has_name(
- qpdf_data qpdf, qpdf_oh oh, char const* key);
+ QPDF_BOOL
+ qpdf_oh_is_or_has_name(qpdf_data qpdf, qpdf_oh oh, char const* key);
QPDF_DLL
qpdf_oh qpdf_oh_new_uninitialized(qpdf_data qpdf);
@@ -840,8 +882,8 @@ extern "C" {
QPDF_DLL
qpdf_oh qpdf_oh_new_real_from_string(qpdf_data qpdf, char const* value);
QPDF_DLL
- qpdf_oh qpdf_oh_new_real_from_double(qpdf_data qpdf,
- double value, int decimal_places);
+ qpdf_oh qpdf_oh_new_real_from_double(
+ qpdf_data qpdf, double value, int decimal_places);
QPDF_DLL
qpdf_oh qpdf_oh_new_name(qpdf_data qpdf, char const* name);
QPDF_DLL
@@ -852,9 +894,9 @@ extern "C" {
* contain atrbitary binary data including embedded null characters.
*/
QPDF_DLL
- qpdf_oh qpdf_oh_new_binary_string(
- qpdf_data qpdf, char const* str, size_t length);
- QPDF_DLL
+ qpdf_oh
+ qpdf_oh_new_binary_string(qpdf_data qpdf, char const* str, size_t length);
+ QPDF_DLL
qpdf_oh qpdf_oh_new_binary_unicode_string(
qpdf_data qpdf, char const* str, size_t length);
QPDF_DLL
@@ -867,7 +909,7 @@ extern "C" {
* comments in QPDFObjectHandle.hh for newStream() for additional
* notes. You must call qpdf_oh_replace_stream_data to provide
* data for the stream. See STREAM FUNCTIONS below.
- */
+ */
QPDF_DLL
qpdf_oh qpdf_oh_new_stream(qpdf_data qpdf);
@@ -875,8 +917,8 @@ extern "C" {
void qpdf_oh_make_direct(qpdf_data qpdf, qpdf_oh oh);
QPDF_DLL
- void qpdf_oh_set_array_item(qpdf_data qpdf, qpdf_oh oh,
- int at, qpdf_oh item);
+ void
+ qpdf_oh_set_array_item(qpdf_data qpdf, qpdf_oh oh, int at, qpdf_oh item);
QPDF_DLL
void qpdf_oh_insert_item(qpdf_data qpdf, qpdf_oh oh, int at, qpdf_oh item);
QPDF_DLL
@@ -885,13 +927,13 @@ extern "C" {
void qpdf_oh_erase_item(qpdf_data qpdf, qpdf_oh oh, int at);
QPDF_DLL
- void qpdf_oh_replace_key(qpdf_data qpdf, qpdf_oh oh,
- char const* key, qpdf_oh item);
+ void qpdf_oh_replace_key(
+ qpdf_data qpdf, qpdf_oh oh, char const* key, qpdf_oh item);
QPDF_DLL
void qpdf_oh_remove_key(qpdf_data qpdf, qpdf_oh oh, char const* key);
QPDF_DLL
- void qpdf_oh_replace_or_remove_key(qpdf_data qpdf, qpdf_oh oh,
- char const* key, qpdf_oh item);
+ void qpdf_oh_replace_or_remove_key(
+ qpdf_data qpdf, qpdf_oh oh, char const* key, qpdf_oh item);
QPDF_DLL
qpdf_oh qpdf_oh_get_dict(qpdf_data qpdf, qpdf_oh oh);
@@ -946,9 +988,12 @@ extern "C" {
*/
QPDF_DLL
QPDF_ERROR_CODE qpdf_oh_get_stream_data(
- qpdf_data qpdf, qpdf_oh stream_oh,
- enum qpdf_stream_decode_level_e decode_level, QPDF_BOOL* filtered,
- unsigned char** bufp, size_t* len);
+ qpdf_data qpdf,
+ qpdf_oh stream_oh,
+ enum qpdf_stream_decode_level_e decode_level,
+ QPDF_BOOL* filtered,
+ unsigned char** bufp,
+ size_t* len);
/* This function returns the concatenation of all of a page's
* content streams as a single, dynamically allocated buffer. As
@@ -957,17 +1002,19 @@ extern "C" {
*/
QPDF_DLL
QPDF_ERROR_CODE qpdf_oh_get_page_content_data(
- qpdf_data qpdf, qpdf_oh page_oh,
- unsigned char** bufp, size_t* len);
+ qpdf_data qpdf, qpdf_oh page_oh, unsigned char** bufp, size_t* len);
/* The data pointed to by bufp will be copied by the library. It
* does not need to remain valid after the call returns.
*/
QPDF_DLL
void qpdf_oh_replace_stream_data(
- qpdf_data qpdf, qpdf_oh stream_oh,
- unsigned char const* buf, size_t len,
- qpdf_oh filter, qpdf_oh decode_parms);
+ qpdf_data qpdf,
+ qpdf_oh stream_oh,
+ unsigned char const* buf,
+ size_t len,
+ qpdf_oh filter,
+ qpdf_oh decode_parms);
/* PAGE FUNCTIONS */
@@ -1018,14 +1065,17 @@ extern "C" {
QPDF_DLL
QPDF_ERROR_CODE qpdf_add_page(
qpdf_data qpdf,
- qpdf_data newpage_qpdf, qpdf_oh newpage,
+ qpdf_data newpage_qpdf,
+ qpdf_oh newpage,
QPDF_BOOL first);
/* addPageAt() */
QPDF_DLL
QPDF_ERROR_CODE qpdf_add_page_at(
qpdf_data qpdf,
- qpdf_data newpage_qpdf, qpdf_oh newpage,
- QPDF_BOOL before, qpdf_oh refpage);
+ qpdf_data newpage_qpdf,
+ qpdf_oh newpage,
+ QPDF_BOOL before,
+ qpdf_oh refpage);
/* removePage() */
QPDF_DLL
QPDF_ERROR_CODE qpdf_remove_page(qpdf_data qpdf, qpdf_oh page);
@@ -1033,5 +1083,4 @@ extern "C" {
}
#endif
-
#endif /* QPDF_C_H */
diff --git a/include/qpdf/qpdfjob-c.h b/include/qpdf/qpdfjob-c.h
index fdc3511c..93ab3e28 100644
--- a/include/qpdf/qpdfjob-c.h
+++ b/include/qpdf/qpdfjob-c.h
@@ -75,5 +75,4 @@ extern "C" {
}
#endif
-
#endif /* QPDFJOB_C_H */