Skip to content

Commit

Permalink
xreftable: renamed XRefToCompressedObj as XRefToCompressedObject
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume Delugré committed Aug 26, 2016
1 parent 448b0b0 commit f3f0193
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion bin/gui/menu.rb
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ def popup_menu_struct_key(struct)
case struct
when ::Array
'Body'
when Origami::XRef, Origami::XRefToCompressedObj
when Origami::XRef, Origami::XRefToCompressedObject
'XRef'
else
struct.class.name.split('::').last
Expand Down
4 changes: 2 additions & 2 deletions lib/origami/pdf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ def get_object(no, generation = 0, use_xrefstm: true) #:nodoc:
#
# We found a matching XRef.
#
if xref.is_a?(XRefToCompressedObj)
if xref.is_a?(XRefToCompressedObject)
objstm = get_object(xref.objstmno, 0, use_xrefstm: use_xrefstm)

object = objstm.extract_by_index(xref.index)
Expand Down Expand Up @@ -913,7 +913,7 @@ def output(params = {})
if options[:use_xrefstm] and obj.parent != obj and obj.parent.is_a?(ObjectStream)
index = obj.parent.index(obj.no)

xrefs_stm << XRefToCompressedObj.new(obj.parent.no, index)
xrefs_stm << XRefToCompressedObject.new(obj.parent.no, index)

lastno_stm = obj.no
else
Expand Down
7 changes: 5 additions & 2 deletions lib/origami/xreftable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ def to_s
#
# An xref poiting to an Object embedded in an ObjectStream.
#
class XRefToCompressedObj
class XRefToCompressedObject
attr_accessor :objstmno, :index

def initialize(objstmno, index)
Expand All @@ -345,6 +345,9 @@ def to_xrefstm_data(type_w, field1_w, field2_w)

[ type , objstmno, index ].pack("B#{type_w}B#{field1_w}B#{field2_w}")
end

def used?; true end
def free?; false end
end

class InvalidXRefStreamObjectError < InvalidStreamObjectError ; end
Expand Down Expand Up @@ -503,7 +506,7 @@ def load! #:nodoc:
when XREF_USED
@xrefs << XRef.new(field1, field2, XRef::USED)
when XREF_COMPRESSED
@xrefs << XRefToCompressedObj.new(field1, field2)
@xrefs << XRefToCompressedObject.new(field1, field2)
end
end
else
Expand Down
4 changes: 2 additions & 2 deletions test/test_xrefs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ def test_xrefstream
xrefstm = pdf.revisions.last.xrefstm

assert_instance_of XRefStream, xrefstm
assert xrefstm.entries.all?{ |xref| xref.is_a?(XRef) or xref.is_a?(XRefToCompressedObj) }
assert xrefstm.entries.all?{ |xref| xref.is_a?(XRef) or xref.is_a?(XRefToCompressedObject) }

pdf.each_object(compressed: true) do |object|
xref = xrefstm.find(object.no)

if object.parent.is_a?(ObjectStream)
assert_instance_of XRefToCompressedObj, xref
assert_instance_of XRefToCompressedObject, xref
assert_equal xref.objstmno, object.parent.no
assert_equal xref.index, object.parent.index(object.no)
else
Expand Down

0 comments on commit f3f0193

Please sign in to comment.