mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:17:35 +00:00
LibPDF: Store page number, not Value, in OutlineItem
The Value previously stored corresponded to a Reference to a Page object in the PDF document. This isn't useful information, since what we want to display at the end of the day is the page an outline item refers to. This commit changes the page member on OutlineItem to be a Optional<u32> (some destinations don't necessarily refer to a Page), which we resolve while building OutlineItems.
This commit is contained in:
parent
3db6af6360
commit
6df9aa8f2c
2 changed files with 30 additions and 20 deletions
|
@ -50,7 +50,7 @@ struct Destination {
|
|||
};
|
||||
|
||||
Type type;
|
||||
Value page;
|
||||
Optional<u32> page;
|
||||
Vector<float> parameters;
|
||||
};
|
||||
|
||||
|
@ -145,10 +145,10 @@ private:
|
|||
PDFErrorOr<void> add_page_tree_node_to_page_tree(NonnullRefPtr<DictObject> const& page_tree);
|
||||
|
||||
PDFErrorOr<void> build_outline();
|
||||
PDFErrorOr<NonnullRefPtr<OutlineItem>> build_outline_item(NonnullRefPtr<DictObject> const& outline_item_dict);
|
||||
PDFErrorOr<NonnullRefPtrVector<OutlineItem>> build_outline_item_chain(Value const& first_ref);
|
||||
PDFErrorOr<NonnullRefPtr<OutlineItem>> build_outline_item(NonnullRefPtr<DictObject> const& outline_item_dict, HashMap<u32, u32> const&);
|
||||
PDFErrorOr<NonnullRefPtrVector<OutlineItem>> build_outline_item_chain(Value const& first_ref, HashMap<u32, u32> const&);
|
||||
|
||||
PDFErrorOr<Destination> create_destination_from_parameters(NonnullRefPtr<ArrayObject>);
|
||||
PDFErrorOr<Destination> create_destination_from_parameters(NonnullRefPtr<ArrayObject>, HashMap<u32, u32> const&);
|
||||
|
||||
PDFErrorOr<NonnullRefPtr<Object>> get_inheritable_object(FlyString const& name, NonnullRefPtr<DictObject>);
|
||||
|
||||
|
@ -227,10 +227,16 @@ struct Formatter<PDF::Destination> : Formatter<FormatString> {
|
|||
}
|
||||
|
||||
StringBuilder param_builder;
|
||||
for (auto& param : destination.parameters)
|
||||
param_builder.appendff("{} ", param);
|
||||
|
||||
return Formatter<FormatString>::format(builder, "{{ type={} page={} params={} }}"sv, type_str, destination.page, param_builder.to_deprecated_string());
|
||||
TRY(Formatter<FormatString>::format(builder, "{{ type={} page="sv, type_str));
|
||||
if (destination.page.has_value())
|
||||
TRY(builder.put_literal("{}"sv));
|
||||
else
|
||||
TRY(builder.put_u64(destination.page.value()));
|
||||
for (auto& param : destination.parameters) {
|
||||
TRY(builder.put_f64(double(param)));
|
||||
TRY(builder.put_literal(" "sv));
|
||||
}
|
||||
return builder.put_literal("}}"sv);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue