mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 21:52:45 +00:00 
			
		
		
		
	LibPDF: Make some variable names in parse_xref_stream() more clear
I found these to be a bit misleading.
This commit is contained in:
		
							parent
							
								
									f926dfe36b
								
							
						
					
					
						commit
						a17a23a3f0
					
				
					 1 changed files with 12 additions and 9 deletions
				
			
		|  | @ -298,23 +298,23 @@ PDFErrorOr<NonnullRefPtr<XRefTable>> DocumentParser::parse_xref_stream() | ||||||
|     if (field_sizes->size() != 3) |     if (field_sizes->size() != 3) | ||||||
|         return error("Malformed xref dictionary"); |         return error("Malformed xref dictionary"); | ||||||
| 
 | 
 | ||||||
|     auto object_count = dict->get_value("Size").get<int>(); |     auto highest_object_number = dict->get_value("Size").get<int>() - 1; | ||||||
| 
 | 
 | ||||||
|     Vector<Tuple<int, int>> subsection_indices; |     Vector<Tuple<int, int>> subsections; | ||||||
|     if (dict->contains(CommonNames::Index)) { |     if (dict->contains(CommonNames::Index)) { | ||||||
|         auto index_array = TRY(dict->get_array(m_document, CommonNames::Index)); |         auto index_array = TRY(dict->get_array(m_document, CommonNames::Index)); | ||||||
|         if (index_array->size() % 2 != 0) |         if (index_array->size() % 2 != 0) | ||||||
|             return error("Malformed xref dictionary"); |             return error("Malformed xref dictionary"); | ||||||
| 
 | 
 | ||||||
|         for (size_t i = 0; i < index_array->size(); i += 2) |         for (size_t i = 0; i < index_array->size(); i += 2) | ||||||
|             subsection_indices.append({ index_array->at(i).get<int>(), index_array->at(i + 1).get<int>() - 1 }); |             subsections.append({ index_array->at(i).get<int>(), index_array->at(i + 1).get<int>() - 1 }); | ||||||
|     } else { |     } else { | ||||||
|         subsection_indices.append({ 0, object_count - 1 }); |         subsections.append({ 0, highest_object_number }); | ||||||
|     } |     } | ||||||
|     auto stream = TRY(parse_stream(dict)); |     auto stream = TRY(parse_stream(dict)); | ||||||
|     auto table = adopt_ref(*new XRefTable()); |     auto table = adopt_ref(*new XRefTable()); | ||||||
| 
 | 
 | ||||||
|     auto field_to_long = [](Span<const u8> field) -> long { |     auto field_to_long = [](Span<u8 const> field) -> long { | ||||||
|         long value = 0; |         long value = 0; | ||||||
|         const u8 max = (field.size() - 1) * 8; |         const u8 max = (field.size() - 1) * 8; | ||||||
|         for (size_t i = 0; i < field.size(); ++i) { |         for (size_t i = 0; i < field.size(); ++i) { | ||||||
|  | @ -328,7 +328,7 @@ PDFErrorOr<NonnullRefPtr<XRefTable>> DocumentParser::parse_xref_stream() | ||||||
| 
 | 
 | ||||||
|     Vector<XRefEntry> entries; |     Vector<XRefEntry> entries; | ||||||
| 
 | 
 | ||||||
|     for (int entry_index = 0; entry_index < object_count; ++entry_index) { |     for (int entry_index = 0; entry_index < highest_object_number; ++entry_index) { | ||||||
|         Array<long, 3> fields; |         Array<long, 3> fields; | ||||||
|         for (size_t field_index = 0; field_index < 3; ++field_index) { |         for (size_t field_index = 0; field_index < 3; ++field_index) { | ||||||
|             auto field_size = field_sizes->at(field_index).get_u32(); |             auto field_size = field_sizes->at(field_index).get_u32(); | ||||||
|  | @ -343,9 +343,12 @@ PDFErrorOr<NonnullRefPtr<XRefTable>> DocumentParser::parse_xref_stream() | ||||||
| 
 | 
 | ||||||
|         entries.append({ fields[1], static_cast<u16>(fields[2]), type != 0, type == 2 }); |         entries.append({ fields[1], static_cast<u16>(fields[2]), type != 0, type == 2 }); | ||||||
| 
 | 
 | ||||||
|         auto indices = subsection_indices[subsection_index]; |         if (subsection_index >= subsections.size()) | ||||||
|         if (entry_index >= indices.get<1>()) { |             break; | ||||||
|             table->add_section({ indices.get<0>(), indices.get<1>(), entries }); | 
 | ||||||
|  |         auto subsection = subsections[subsection_index]; | ||||||
|  |         if (entry_index >= subsection.get<1>()) { | ||||||
|  |             table->add_section({ subsection.get<0>(), subsection.get<1>(), entries }); | ||||||
|             entries.clear(); |             entries.clear(); | ||||||
|             subsection_index++; |             subsection_index++; | ||||||
|         } |         } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Julian Offenhäuser
						Julian Offenhäuser