mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 18:10:56 +09:00
LibPDF: Allow the page rotation to be inherited
This commit is contained in:
parent
b90a794d78
commit
95a804bc4e
Notes:
sideshowbarker
2024-07-17 18:38:54 +09:00
Author: https://github.com/janso3
Commit: 95a804bc4e
Pull-request: https://github.com/SerenityOS/serenity/pull/18031
Reviewed-by: https://github.com/ADKaster ✅
2 changed files with 15 additions and 2 deletions
|
@ -158,8 +158,9 @@ PDFErrorOr<Page> Document::get_page(u32 index)
|
|||
user_unit = raw_page_object->get_value(CommonNames::UserUnit).to_float();
|
||||
|
||||
int rotate = 0;
|
||||
if (raw_page_object->contains(CommonNames::Rotate)) {
|
||||
rotate = raw_page_object->get_value(CommonNames::Rotate).get<int>();
|
||||
auto maybe_rotate = TRY(get_inheritable_value(CommonNames::Rotate, raw_page_object));
|
||||
if (maybe_rotate.has_value()) {
|
||||
rotate = maybe_rotate.value().to_int();
|
||||
VERIFY(rotate % 90 == 0);
|
||||
}
|
||||
|
||||
|
@ -339,6 +340,17 @@ PDFErrorOr<Optional<NonnullRefPtr<Object>>> Document::get_inheritable_object(Dep
|
|||
return TRY(object->get_object(this, name));
|
||||
}
|
||||
|
||||
PDFErrorOr<Optional<Value>> Document::get_inheritable_value(DeprecatedFlyString const& name, NonnullRefPtr<DictObject> object)
|
||||
{
|
||||
if (!object->contains(name)) {
|
||||
if (!object->contains(CommonNames::Parent))
|
||||
return { OptionalNone() };
|
||||
auto parent = TRY(object->get_dict(this, CommonNames::Parent));
|
||||
return get_inheritable_value(name, parent);
|
||||
}
|
||||
return object->get(name);
|
||||
}
|
||||
|
||||
PDFErrorOr<Destination> Document::create_destination_from_dictionary_entry(NonnullRefPtr<Object> const& entry, HashMap<u32, u32> const& page_number_by_index_ref)
|
||||
{
|
||||
if (entry->is<ArrayObject>()) {
|
||||
|
|
|
@ -144,6 +144,7 @@ private:
|
|||
PDFErrorOr<Destination> create_destination_from_dictionary_entry(NonnullRefPtr<Object> const& entry, HashMap<u32, u32> const& page_number_by_index_ref);
|
||||
|
||||
PDFErrorOr<Optional<NonnullRefPtr<Object>>> get_inheritable_object(DeprecatedFlyString const& name, NonnullRefPtr<DictObject>);
|
||||
PDFErrorOr<Optional<Value>> get_inheritable_value(DeprecatedFlyString const& name, NonnullRefPtr<DictObject>);
|
||||
|
||||
PDFErrorOr<NonnullRefPtr<Object>> find_in_name_tree(NonnullRefPtr<DictObject> root, DeprecatedFlyString name);
|
||||
PDFErrorOr<NonnullRefPtr<Object>> find_in_name_tree_nodes(NonnullRefPtr<ArrayObject> siblings, DeprecatedFlyString name);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue