2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-12-22 10:58:58 +00:00

Make ABI-breaking changes that don't modify API at all

* Merge overloaded functions by adding default values
* Remove non-const methods that are identical to const methods
This commit is contained in:
Jay Berkenbilt 2022-04-15 19:54:34 -04:00
parent dd35966367
commit 2a7d2b63c2
12 changed files with 12 additions and 116 deletions

2
TODO
View File

@ -481,12 +481,10 @@ Comments appear in the code prefixed by "ABI"
* Search for ABI to find items not listed here.
* Switch default --json to latest
* See PointerHolder to std::shared_ptr above.
* See where anonymous namespaces can be used to keep things private to
a source file. Search for `(class|struct)` in **/*.cc.
* See if we can use constructor delegation instead of init() in
classes with overloaded constructors.
* Merge two versions of QPDFObjectHandle::makeDirect per comment
* After removing legacy QPDFNameTreeObjectHelper and
QPDFNumberTreeObjectHelper constructors, NNTreeImpl can switch to
having a QPDF reference and assume that the reference is always

View File

@ -619,13 +619,8 @@ class QPDF
QPDF_DLL
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(
std::map<int, int> const& object_stream_data,
bool allow_changes,
std::function<int(QPDFObjectHandle&)> skip_stream_parameters);
bool allow_changes = true,
std::function<int(QPDFObjectHandle&)> skip_stream_parameters = nullptr);
// Traverse page tree return all /Page objects. It also detects
// and resolves cases in which the same /Page object is

View File

@ -74,9 +74,6 @@ class QPDFMatrix
// and take the first and second rows of the result as xp and yp.
QPDF_DLL
void transform(double x, double y, double& xp, double& yp) const;
// ABI: delete non-const version
QPDF_DLL
void transform(double x, double y, double& xp, double& yp);
// Transform a rectangle by creating a new rectangle that tightly
// bounds the polygon resulting from transforming the four
@ -84,10 +81,6 @@ class QPDFMatrix
QPDF_DLL
QPDFObjectHandle::Rectangle
transformRectangle(QPDFObjectHandle::Rectangle r) const;
// ABI: delete non-const version
QPDF_DLL
QPDFObjectHandle::Rectangle
transformRectangle(QPDFObjectHandle::Rectangle r);
// operator== tests for exact equality, not considering deltas for
// floating point.

View File

@ -61,7 +61,6 @@ class QPDFNameTreeObjectHelper: public QPDFObjectHelper
QPDF_DLL
static QPDFNameTreeObjectHelper newEmpty(QPDF&, bool auto_repair = true);
// ABI: = default
QPDF_DLL
virtual ~QPDFNameTreeObjectHelper();

View File

@ -530,12 +530,8 @@ class QPDFObjectHandle
QPDF_DLL
static QPDFObjectHandle newReal(std::string const& value);
QPDF_DLL
static QPDFObjectHandle newReal(double value, int decimal_places = 0);
// 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 = 0, bool trim_trailing_zeroes = true);
// 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
@ -933,11 +929,8 @@ class QPDFObjectHandle
QPDF_DLL
void mergeResources(
QPDFObjectHandle other,
std::map<std::string, std::map<std::string, std::string>>* conflicts);
// ABI: eliminate version without conflicts and make conflicts
// default to nullptr.
QPDF_DLL
void mergeResources(QPDFObjectHandle other);
std::map<std::string, std::map<std::string, std::string>>* conflicts =
nullptr);
// Get all resource names from a resource dictionary. If this
// object is a dictionary, this method returns a set of all the
@ -964,12 +957,7 @@ class QPDFObjectHandle
std::string getUniqueResourceName(
std::string const& prefix,
int& min_suffix,
std::set<std::string>* resource_names);
// ABI: remove this version and make resource_names default to
// nullptr.
QPDF_DLL
std::string
getUniqueResourceName(std::string const& prefix, int& min_suffix);
std::set<std::string>* resource_names = nullptr);
// Return the QPDF object that owns an indirect object. Returns
// null for a direct object.
@ -1024,12 +1012,7 @@ class QPDFObjectHandle
// to the original QPDF object after this call completes
// successfully.
QPDF_DLL
void makeDirect(bool allow_streams);
// Zero-arg version is equivalent to makeDirect(false).
// ABI: delete zero-arg version of makeDirect, and make
// allow_streams default to false.
QPDF_DLL
void makeDirect();
void makeDirect(bool allow_streams = false);
// Mutator methods for array objects
QPDF_DLL

View File

@ -132,10 +132,7 @@ class QPDFPageObjectHelper: public QPDFObjectHelper
// this behavior. Prior to qpdf 10.1, form XObjects were ignored,
// but this was considered a bug.
QPDF_DLL
void externalizeInlineImages(size_t min_size, bool shallow);
// ABI: make shallow optional (default false) and merge
QPDF_DLL
void externalizeInlineImages(size_t min_size = 0);
void externalizeInlineImages(size_t min_size = 0, bool shallow = false);
// Return the annotations in the page's "/Annots" list, if any. If
// only_subtype is non-empty, only include annotations of the
@ -344,10 +341,7 @@ class QPDFPageObjectHelper: public QPDFObjectHelper
// rotated. If not, one will be created inside the function, which
// is less efficient.
QPDF_DLL
void flattenRotation();
// ABI: merge versions and make afdh default to nullptr
QPDF_DLL
void flattenRotation(QPDFAcroFormDocumentHelper* afdh);
void flattenRotation(QPDFAcroFormDocumentHelper* afdh = nullptr);
// Copy annotations from another page into this page. The other
// page may be from the same QPDF or from a different QPDF. Each

View File

@ -51,13 +51,8 @@ namespace QUtil
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 = 0, bool trim_trailing_zeroes = true);
// These string to number methods throw std::runtime_error on
// underflow/overflow.

View File

@ -109,12 +109,6 @@ QPDFMatrix::rotatex90(int angle)
}
}
void
QPDFMatrix::transform(double x, double y, double& xp, double& yp)
{
const_cast<QPDFMatrix const*>(this)->transform(x, y, xp, yp);
}
void
QPDFMatrix::transform(double x, double y, double& xp, double& yp) const
{
@ -122,12 +116,6 @@ QPDFMatrix::transform(double x, double y, double& xp, double& yp) const
yp = (this->b * x) + (this->d * y) + this->f;
}
QPDFObjectHandle::Rectangle
QPDFMatrix::transformRectangle(QPDFObjectHandle::Rectangle r)
{
return const_cast<QPDFMatrix const*>(this)->transformRectangle(r);
}
QPDFObjectHandle::Rectangle
QPDFMatrix::transformRectangle(QPDFObjectHandle::Rectangle r) const
{

View File

@ -1094,12 +1094,6 @@ QPDFObjectHandle::makeResourcesIndirect(QPDF& owning_qpdf)
}
}
void
QPDFObjectHandle::mergeResources(QPDFObjectHandle other)
{
mergeResources(other, nullptr);
}
void
QPDFObjectHandle::mergeResources(
QPDFObjectHandle other,
@ -1224,13 +1218,6 @@ QPDFObjectHandle::getResourceNames()
return result;
}
std::string
QPDFObjectHandle::getUniqueResourceName(
std::string const& prefix, int& min_suffix)
{
return getUniqueResourceName(prefix, min_suffix, nullptr);
}
std::string
QPDFObjectHandle::getUniqueResourceName(
std::string const& prefix, int& min_suffix, std::set<std::string>* namesp)
@ -2539,12 +2526,6 @@ QPDFObjectHandle::newReal(std::string const& value)
return QPDFObjectHandle(new QPDF_Real(value));
}
QPDFObjectHandle
QPDFObjectHandle::newReal(double value, int decimal_places)
{
return QPDFObjectHandle(new QPDF_Real(value, decimal_places, true));
}
QPDFObjectHandle
QPDFObjectHandle::newReal(
double value, int decimal_places, bool trim_trailing_zeroes)
@ -2915,12 +2896,6 @@ QPDFObjectHandle::copyStream()
return result;
}
void
QPDFObjectHandle::makeDirect()
{
makeDirect(false);
}
void
QPDFObjectHandle::makeDirect(bool allow_streams)
{

View File

@ -410,12 +410,6 @@ QPDFPageObjectHelper::getFormXObjects()
return result;
}
void
QPDFPageObjectHelper::externalizeInlineImages(size_t min_size)
{
externalizeInlineImages(min_size, false);
}
void
QPDFPageObjectHelper::externalizeInlineImages(size_t min_size, bool shallow)
{
@ -929,12 +923,6 @@ QPDFPageObjectHelper::placeFormXObject(
return ("q\n" + cm.unparse() + " cm\n" + name + " Do\n" + "Q\n");
}
void
QPDFPageObjectHelper::flattenRotation()
{
flattenRotation(nullptr);
}
void
QPDFPageObjectHelper::flattenRotation(QPDFAcroFormDocumentHelper* afdh)
{

View File

@ -52,12 +52,6 @@ QPDF::ObjUser::operator<(ObjUser const& rhs) const
return false;
}
void
QPDF::optimize(std::map<int, int> const& object_stream_data, bool allow_changes)
{
optimize(object_stream_data, allow_changes, nullptr);
}
void
QPDF::optimize(
std::map<int, int> const& object_stream_data,

View File

@ -326,12 +326,6 @@ QUtil::uint_to_string_base(unsigned long long num, int base, int length)
return int_to_string_base_internal(num, base, length);
}
std::string
QUtil::double_to_string(double num, int decimal_places)
{
return double_to_string(num, decimal_places, true);
}
std::string
QUtil::double_to_string(
double num, int decimal_places, bool trim_trailing_zeroes)