From a9d8b9767921e9818423121d75f141e92de5c0fe Mon Sep 17 00:00:00 2001 From: m-holger Date: Thu, 16 Oct 2025 19:06:43 +0100 Subject: [PATCH] Refactor `Writer`: move into `qpdf::impl` namespace, update inheritance from `Doc::Common`, and adjust related `QPDFWriter` logic for improved encapsulation. --- libqpdf/QPDFWriter.cc | 29 ++++++++++++++++------------- libqpdf/qpdf/QPDF_private.hh | 1 - 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/libqpdf/QPDFWriter.cc b/libqpdf/QPDFWriter.cc index b0dbf3c..5957e2c 100644 --- a/libqpdf/QPDFWriter.cc +++ b/libqpdf/QPDFWriter.cc @@ -261,21 +261,24 @@ Pl_stack::Popper::pop() stack = nullptr; } -// Writer class is restricted to QPDFWriter so that only it can call certain methods. -class impl::Doc::Writer: impl::Doc::Common +namespace qpdf::impl { - friend class QPDFWriter; - Writer(QPDF& qpdf) : - Common(qpdf, qpdf.doc().m), - lin(m->lin) + // Writer class is restricted to QPDFWriter so that only it can call certain methods. + class Writer: protected Doc::Common { - } + public: + Writer(QPDF& qpdf) : + Common(qpdf.doc()), + lin(qpdf.doc().linearization()) + { + } - protected: - impl::Doc::Linearization& lin; -}; + protected: + Doc::Linearization& lin; + }; +} // namespace qpdf::impl -class QPDFWriter::Members: QPDF::Doc::Writer +class QPDFWriter::Members: impl::Writer { friend class QPDFWriter; @@ -289,8 +292,8 @@ class QPDFWriter::Members: QPDF::Doc::Writer enum trailer_e { t_normal, t_lin_first, t_lin_second }; - Members(QPDFWriter& w, QPDF& pdf) : - QPDF::Doc::Writer(pdf), + Members(QPDFWriter& w, QPDF& qpdf) : + impl::Writer(qpdf), w(w), root_og( qpdf.getRoot().getObjGen().isIndirect() ? qpdf.getRoot().getObjGen() diff --git a/libqpdf/qpdf/QPDF_private.hh b/libqpdf/qpdf/QPDF_private.hh index 8055c84..895b06f 100644 --- a/libqpdf/qpdf/QPDF_private.hh +++ b/libqpdf/qpdf/QPDF_private.hh @@ -276,7 +276,6 @@ class QPDF::Doc class Pages; class ParseGuard; class Resolver; - class Writer; // This is the common base-class for all document components. It is used by the other document // components to access common functionality. It is not meant to be used directly by the user. -- libgit2 0.21.4