mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-10 13:00:29 +03:00
LibPDF: Extract a Document::read_filters() method
No behavior change.
This commit is contained in:
parent
9f4feb7315
commit
532230c0e4
Notes:
sideshowbarker
2024-07-17 20:58:35 +09:00
Author: https://github.com/nico Commit: https://github.com/SerenityOS/serenity/commit/532230c0e4 Pull-request: https://github.com/SerenityOS/serenity/pull/20174
@ -297,6 +297,23 @@ PDFErrorOr<Optional<InfoDict>> Document::info_dict()
|
||||
return InfoDict(this, TRY(trailer()->get_dict(this, CommonNames::Info)));
|
||||
}
|
||||
|
||||
PDFErrorOr<Vector<DeprecatedFlyString>> Document::read_filters(NonnullRefPtr<DictObject> dict)
|
||||
{
|
||||
Vector<DeprecatedFlyString> filters;
|
||||
|
||||
// We may either get a single filter or an array of cascading filters
|
||||
auto filter_object = TRY(dict->get_object(this, CommonNames::Filter));
|
||||
if (filter_object->is<ArrayObject>()) {
|
||||
auto filter_array = filter_object->cast<ArrayObject>();
|
||||
for (size_t i = 0; i < filter_array->size(); ++i)
|
||||
filters.append(TRY(filter_array->get_name_at(this, i))->name());
|
||||
} else {
|
||||
filters.append(filter_object->cast<NameObject>()->name());
|
||||
}
|
||||
|
||||
return filters;
|
||||
}
|
||||
|
||||
PDFErrorOr<void> Document::build_page_tree()
|
||||
{
|
||||
auto page_tree = TRY(m_catalog->get_dict(this, CommonNames::Pages));
|
||||
|
@ -146,6 +146,8 @@ public:
|
||||
|
||||
PDFErrorOr<Optional<InfoDict>> info_dict();
|
||||
|
||||
PDFErrorOr<Vector<DeprecatedFlyString>> read_filters(NonnullRefPtr<DictObject>);
|
||||
|
||||
private:
|
||||
explicit Document(NonnullRefPtr<DocumentParser> const& parser);
|
||||
|
||||
|
@ -475,17 +475,7 @@ PDFErrorOr<NonnullRefPtr<StreamObject>> Parser::parse_stream(NonnullRefPtr<DictO
|
||||
m_document->security_handler()->decrypt(stream_object, m_current_reference_stack.last());
|
||||
|
||||
if (dict->contains(CommonNames::Filter) && m_enable_filters) {
|
||||
Vector<DeprecatedFlyString> filters;
|
||||
|
||||
// We may either get a single filter or an array of cascading filters
|
||||
auto filter_object = TRY(dict->get_object(m_document, CommonNames::Filter));
|
||||
if (filter_object->is<ArrayObject>()) {
|
||||
auto filter_array = filter_object->cast<ArrayObject>();
|
||||
for (size_t i = 0; i < filter_array->size(); ++i)
|
||||
filters.append(TRY(filter_array->get_name_at(m_document, i))->name());
|
||||
} else {
|
||||
filters.append(filter_object->cast<NameObject>()->name());
|
||||
}
|
||||
Vector<DeprecatedFlyString> filters = TRY(m_document->read_filters(dict));
|
||||
|
||||
// Every filter may get its own parameter dictionary
|
||||
Vector<RefPtr<DictObject>> decode_parms_vector;
|
||||
|
Loading…
Reference in New Issue
Block a user