mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 05:07:35 +00:00
LibPDF: Support null destination parameters
Destination arrays contain a page number, a mode name, and parameters specific to that mode. In many cases these parameters can be set to "null", which our code wasn't taking into consideration. This commit parses these parameters taking into account whether they are null or actual numbers, and stores them as Optional<float> instead of plain floats. The parameters are not yet used anywhere else other than when formatting a Destination object, so the change is fairly small.
This commit is contained in:
parent
2485c500a3
commit
f510b2b180
2 changed files with 19 additions and 7 deletions
|
@ -232,9 +232,15 @@ PDFErrorOr<Destination> Document::create_destination_from_parameters(NonnullRefP
|
|||
auto page_ref = array->at(0);
|
||||
auto type_name = TRY(array->get_name_at(this, 1))->name();
|
||||
|
||||
Vector<float> parameters;
|
||||
for (size_t i = 2; i < array->size(); i++)
|
||||
parameters.append(array->at(i).to_float());
|
||||
Vector<Optional<float>> parameters;
|
||||
TRY(parameters.try_ensure_capacity(array->size() - 2));
|
||||
for (size_t i = 2; i < array->size(); i++) {
|
||||
auto& param = array->at(i);
|
||||
if (param.has<nullptr_t>())
|
||||
parameters.unchecked_append({});
|
||||
else
|
||||
parameters.append(param.to_float());
|
||||
}
|
||||
|
||||
Destination::Type type;
|
||||
if (type_name == CommonNames::XYZ) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue