mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:37:43 +00:00
LibPDF: Extract a Document::read_filters() method
No behavior change.
This commit is contained in:
parent
9f4feb7315
commit
532230c0e4
3 changed files with 20 additions and 11 deletions
|
@ -297,6 +297,23 @@ PDFErrorOr<Optional<InfoDict>> Document::info_dict()
|
||||||
return InfoDict(this, TRY(trailer()->get_dict(this, CommonNames::Info)));
|
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()
|
PDFErrorOr<void> Document::build_page_tree()
|
||||||
{
|
{
|
||||||
auto page_tree = TRY(m_catalog->get_dict(this, CommonNames::Pages));
|
auto page_tree = TRY(m_catalog->get_dict(this, CommonNames::Pages));
|
||||||
|
|
|
@ -146,6 +146,8 @@ public:
|
||||||
|
|
||||||
PDFErrorOr<Optional<InfoDict>> info_dict();
|
PDFErrorOr<Optional<InfoDict>> info_dict();
|
||||||
|
|
||||||
|
PDFErrorOr<Vector<DeprecatedFlyString>> read_filters(NonnullRefPtr<DictObject>);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit Document(NonnullRefPtr<DocumentParser> const& parser);
|
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());
|
m_document->security_handler()->decrypt(stream_object, m_current_reference_stack.last());
|
||||||
|
|
||||||
if (dict->contains(CommonNames::Filter) && m_enable_filters) {
|
if (dict->contains(CommonNames::Filter) && m_enable_filters) {
|
||||||
Vector<DeprecatedFlyString> filters;
|
Vector<DeprecatedFlyString> filters = TRY(m_document->read_filters(dict));
|
||||||
|
|
||||||
// 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());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Every filter may get its own parameter dictionary
|
// Every filter may get its own parameter dictionary
|
||||||
Vector<RefPtr<DictObject>> decode_parms_vector;
|
Vector<RefPtr<DictObject>> decode_parms_vector;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue