def rebuild_dummy_xrefs #:nodoc

            build_dummy_xrefs = -> (objects) do
                lastno = 0
                brange = 0

                xrefs = [ XRef.new(0, XRef::FIRSTFREE, XRef::FREE) ]

                xrefsection = XRef::Section.new
                objects.sort_by {|object| object.reference }
                       .each do |object|

                    if (object.no - lastno).abs > 1
                        xrefsection << XRef::Subsection.new(brange, xrefs)
                        brange = object.no
                        xrefs.clear
                    end

                    xrefs << XRef.new(0, 0, XRef::FREE)

                    lastno = object.no
                end

                xrefsection << XRef::Subsection.new(brange, xrefs)

                xrefsection
            end

            size = 0
            startxref = @header.to_s.size

            @revisions.each do |revision|
                revision.each_object do |object|
                    startxref += object.to_s.size
                end

                size += revision.body.size
                revision.xreftable = build_dummy_xrefs.call(revision.objects)

                revision.trailer ||= Trailer.new
                revision.trailer.Size = size + 1
                revision.trailer.startxref = startxref

                startxref += revision.xreftable.to_s.size + revision.trailer.to_s.size
            end

            self
        end
def rebuild_dummy_xrefs #:nodoc

            build_dummy_xrefs = -> (objects) do
                lastno = 0
                brange = 0

                xrefs = [ XRef.new(0, XRef::FIRSTFREE, XRef::FREE) ]

                xrefsection = XRef::Section.new
                objects.sort_by {|object| object.reference }
                       .each do |object|

                    if (object.no - lastno).abs > 1
                        xrefsection << XRef::Subsection.new(brange, xrefs)
                        brange = object.no
                        xrefs.clear
                    end

                    xrefs << XRef.new(0, 0, XRef::FREE)

                    lastno = object.no
                end

                xrefsection << XRef::Subsection.new(brange, xrefs)

                xrefsection
            end

            size = 0
            startxref = @header.to_s.size

            @revisions.each do |revision|
                revision.each_object do |object|
                    startxref += object.to_s.size
                end

                size += revision.body.size
                revision.xreftable = build_dummy_xrefs.call(revision.objects)

                revision.trailer ||= Trailer.new
                revision.trailer.Size = size + 1
                revision.trailer.startxref = startxref

                startxref += revision.xreftable.to_s.size + revision.trailer.to_s.size
            end

            self
        end
Compute and update XRef::Section for each Revision.