11use std:: collections:: BTreeMap ;
22
33use pdf_object:: {
4- cross_reference_table:: {
5- CrossReferenceEntry , CrossReferenceEntryType , CrossReferenceStatus , CrossReferenceTable ,
6- } ,
4+ cross_reference_table:: { CrossReferenceEntryType , CrossReferenceStatus , CrossReferenceTable } ,
75 object_resolver:: ObjectResolver ,
86} ;
97use pdf_tokenizer:: PdfToken ;
@@ -37,7 +35,7 @@ impl PdfParser<'_> {
3735 /// Parses the contiguous subsections that follow an `xref` keyword.
3836 pub ( crate ) fn parse_cross_reference_subsections (
3937 & mut self ,
40- ) -> Result < BTreeMap < usize , CrossReferenceEntry > , ParserError > {
38+ ) -> Result < BTreeMap < usize , CrossReferenceEntryType > , ParserError > {
4139 let mut entries = BTreeMap :: new ( ) ;
4240
4341 loop {
@@ -60,7 +58,7 @@ impl PdfParser<'_> {
6058 /// Parses one xref subsection header and its declared number of entries.
6159 fn parse_cross_reference_subsection (
6260 & mut self ,
63- ) -> Result < ( usize , Vec < CrossReferenceEntry > ) , ParserError > {
61+ ) -> Result < ( usize , Vec < CrossReferenceEntryType > ) , ParserError > {
6462 let start_object_number = self . read_number :: < usize > ( true ) ?;
6563 self . skip_whitespace_and_comments ( ) ;
6664 let entry_count = self . read_number :: < usize > ( true ) ?;
@@ -76,7 +74,7 @@ impl PdfParser<'_> {
7674 /// Parses a traditional xref row into its corresponding entry.
7775 pub ( crate ) fn parse_cross_reference_entry (
7876 & mut self ,
79- ) -> Result < CrossReferenceEntry , ParserError > {
77+ ) -> Result < CrossReferenceEntryType , ParserError > {
8078 self . skip_whitespace_and_comments ( ) ;
8179 let field1 = self . read_number :: < usize > ( true ) ?;
8280 self . skip_whitespace_and_comments ( ) ;
@@ -93,9 +91,9 @@ impl PdfParser<'_> {
9391 } ) ?;
9492
9593 Ok ( match status {
96- CrossReferenceStatus :: Normal => CrossReferenceEntry :: new_normal ( field1, field2) ,
94+ CrossReferenceStatus :: Normal => CrossReferenceEntryType :: new_normal ( field1, field2) ,
9795 CrossReferenceStatus :: Free | CrossReferenceStatus :: Old => {
98- CrossReferenceEntry :: new_free ( field1, field2)
96+ CrossReferenceEntryType :: new_free ( field1, field2)
9997 }
10098 } )
10199 }
@@ -105,8 +103,8 @@ impl PdfParser<'_> {
105103/// leading free-object-zero pattern encountered in some PDFs.
106104fn normalize_xref_subsection_entries (
107105 start_object_number : usize ,
108- entries : Vec < CrossReferenceEntry > ,
109- ) -> Vec < ( usize , CrossReferenceEntry ) > {
106+ entries : Vec < CrossReferenceEntryType > ,
107+ ) -> Vec < ( usize , CrossReferenceEntryType ) > {
110108 let has_leading_free_object_zero = start_object_number > 0
111109 && entries
112110 . first ( )
@@ -132,14 +130,12 @@ fn normalize_xref_subsection_entries(
132130
133131/// Returns whether an entry is the object-zero free entry incorrectly included
134132/// at the start of a non-zero xref subsection.
135- fn is_malformed_leading_free_object_zero ( entry : & CrossReferenceEntry ) -> bool {
133+ fn is_malformed_leading_free_object_zero ( entry : & CrossReferenceEntryType ) -> bool {
136134 matches ! (
137135 entry,
138- CrossReferenceEntry {
139- entry_type: CrossReferenceEntryType :: Free {
140- next_free_object: 0 ,
141- generation_number: 65_535 ,
142- }
136+ CrossReferenceEntryType :: Free {
137+ next_free_object: 0 ,
138+ generation_number: 65_535 ,
143139 }
144140 )
145141}
@@ -271,8 +267,8 @@ mod tests {
271267 #[ test]
272268 fn test_normalize_xref_subsection_entries_uses_declared_range ( ) {
273269 let entries = vec ! [
274- CrossReferenceEntry :: new_normal( 17 , 0 ) ,
275- CrossReferenceEntry :: new_normal( 81 , 0 ) ,
270+ CrossReferenceEntryType :: new_normal( 17 , 0 ) ,
271+ CrossReferenceEntryType :: new_normal( 81 , 0 ) ,
276272 ] ;
277273
278274 let normalized = normalize_xref_subsection_entries ( 4 , entries) ;
@@ -284,9 +280,9 @@ mod tests {
284280 #[ test]
285281 fn test_normalize_xref_subsection_entries_handles_leading_free_object_zero ( ) {
286282 let entries = vec ! [
287- CrossReferenceEntry :: new_free( 0 , 65_535 ) ,
288- CrossReferenceEntry :: new_normal( 17 , 0 ) ,
289- CrossReferenceEntry :: new_normal( 81 , 0 ) ,
283+ CrossReferenceEntryType :: new_free( 0 , 65_535 ) ,
284+ CrossReferenceEntryType :: new_normal( 17 , 0 ) ,
285+ CrossReferenceEntryType :: new_normal( 81 , 0 ) ,
290286 ] ;
291287
292288 let normalized = normalize_xref_subsection_entries ( 4 , entries) ;
0 commit comments