Use lookup_chain more
This commit is contained in:
parent
c329895094
commit
d749660873
49
cpdfua.ml
49
cpdfua.ml
|
@ -6,8 +6,6 @@ open Cpdferror
|
||||||
a) Those which require looking deep inside font files; and
|
a) Those which require looking deep inside font files; and
|
||||||
b) Those which require reading inside the graphics stream. *)
|
b) Those which require reading inside the graphics stream. *)
|
||||||
|
|
||||||
(* FIXME maximise chain usage *)
|
|
||||||
|
|
||||||
exception MatterhornError of Cpdfyojson.Safe.t
|
exception MatterhornError of Cpdfyojson.Safe.t
|
||||||
|
|
||||||
exception MatterhornUnimplemented
|
exception MatterhornUnimplemented
|
||||||
|
@ -213,32 +211,16 @@ let matterhorn_06_003 _ _ pdf =
|
||||||
(* ViewerPreferences dictionary of the Catalog dictionary does not contain a
|
(* ViewerPreferences dictionary of the Catalog dictionary does not contain a
|
||||||
DisplayDocTitle entry. *)
|
DisplayDocTitle entry. *)
|
||||||
let matterhorn_07_001 _ _ pdf =
|
let matterhorn_07_001 _ _ pdf =
|
||||||
match Pdf.lookup_direct pdf "/Root" pdf.Pdf.trailerdict with
|
match Pdf.lookup_chain pdf pdf.Pdf.trailerdict ["/Root"; "/ViewerPreferences"; "/DisplayDocTitle"] with
|
||||||
| Some catalog ->
|
|
||||||
begin match Pdf.lookup_direct pdf "/ViewerPreferences" catalog with
|
|
||||||
| Some d ->
|
|
||||||
begin match Pdf.lookup_direct pdf "/DisplayDocTitle" d with
|
|
||||||
| Some _ -> ()
|
|
||||||
| None -> merror ()
|
| None -> merror ()
|
||||||
end
|
| _ -> ()
|
||||||
| None -> merror ()
|
|
||||||
end
|
|
||||||
| _ -> merror ()
|
|
||||||
|
|
||||||
(* ViewerPreferences dictionary of the Catalog dictionary contains a
|
(* ViewerPreferences dictionary of the Catalog dictionary contains a
|
||||||
DisplayDocTitle entry with a value of false. *)
|
DisplayDocTitle entry with a value of false. *)
|
||||||
let matterhorn_07_002 _ _ pdf =
|
let matterhorn_07_002 _ _ pdf =
|
||||||
match Pdf.lookup_direct pdf "/Root" pdf.Pdf.trailerdict with
|
match Pdf.lookup_chain pdf pdf.Pdf.trailerdict ["/Root"; "/ViewerPreferences"; "/DisplayDocTitle"] with
|
||||||
| Some catalog ->
|
|
||||||
begin match Pdf.lookup_direct pdf "/ViewerPreferences" catalog with
|
|
||||||
| Some d ->
|
|
||||||
begin match Pdf.lookup_direct pdf "/DisplayDocTitle" d with
|
|
||||||
| Some (Pdf.Boolean false) -> merror ()
|
| Some (Pdf.Boolean false) -> merror ()
|
||||||
| _ -> ()
|
| _ -> ()
|
||||||
end
|
|
||||||
| None -> ()
|
|
||||||
end
|
|
||||||
| _ -> ()
|
|
||||||
|
|
||||||
(* A table-related structure element is used in a way that does not conform to
|
(* A table-related structure element is used in a way that does not conform to
|
||||||
the syntax defined in ISO 32000-1, Table 337. We assume no nesting of whole
|
the syntax defined in ISO 32000-1, Table 337. We assume no nesting of whole
|
||||||
|
@ -519,18 +501,9 @@ let matterhorn_20_003 _ _ pdf =
|
||||||
and UF entries. *)
|
and UF entries. *)
|
||||||
let matterhorn_21_001 _ _ pdf =
|
let matterhorn_21_001 _ _ pdf =
|
||||||
let from_nametree =
|
let from_nametree =
|
||||||
match Pdf.lookup_direct pdf "/Root" pdf.Pdf.trailerdict with
|
match Pdf.lookup_chain pdf pdf.Pdf.trailerdict ["/Root"; "/Names"; "/EmbeddedFiles"] with
|
||||||
| Some catalog ->
|
| Some embeddedfiles -> map snd (Pdf.contents_of_nametree pdf embeddedfiles)
|
||||||
begin match Pdf.lookup_direct pdf "/Names" catalog with
|
| _ -> []
|
||||||
| Some names ->
|
|
||||||
begin match Pdf.lookup_direct pdf "/EmbeddedFiles" names with
|
|
||||||
| Some embeddedfiles ->
|
|
||||||
map snd (Pdf.contents_of_nametree pdf embeddedfiles)
|
|
||||||
| None -> []
|
|
||||||
end
|
|
||||||
| None -> []
|
|
||||||
end
|
|
||||||
| None -> []
|
|
||||||
in
|
in
|
||||||
let from_annots =
|
let from_annots =
|
||||||
option_map
|
option_map
|
||||||
|
@ -557,11 +530,7 @@ let matterhorn_25_001 _ _ pdf =
|
||||||
| Cpdfmetadata.E (_, children) -> List.exists contains_required_dynamicRender children
|
| Cpdfmetadata.E (_, children) -> List.exists contains_required_dynamicRender children
|
||||||
| Cpdfmetadata.D _ -> false
|
| Cpdfmetadata.D _ -> false
|
||||||
in
|
in
|
||||||
match Pdf.lookup_direct pdf "/Root" pdf.Pdf.trailerdict with
|
match Pdf.lookup_chain pdf pdf.Pdf.trailerdict ["/Root"; "/AcroForm"; "/XFA"] with
|
||||||
| Some catalog ->
|
|
||||||
begin match Pdf.lookup_direct pdf "/AcroForm" catalog with
|
|
||||||
| Some d ->
|
|
||||||
begin match Pdf.lookup_direct pdf "/XFA" d with
|
|
||||||
| Some (Pdf.Array xfa) ->
|
| Some (Pdf.Array xfa) ->
|
||||||
begin match option_map (function (Pdf.String "config", x) -> Some x | _ -> None) (pairs xfa) with
|
begin match option_map (function (Pdf.String "config", x) -> Some x | _ -> None) (pairs xfa) with
|
||||||
| [config] ->
|
| [config] ->
|
||||||
|
@ -579,10 +548,6 @@ let matterhorn_25_001 _ _ pdf =
|
||||||
| _ -> ()
|
| _ -> ()
|
||||||
end
|
end
|
||||||
| _ -> ()
|
| _ -> ()
|
||||||
end
|
|
||||||
| _ -> ()
|
|
||||||
end
|
|
||||||
| None -> ()
|
|
||||||
|
|
||||||
(* The file is encrypted but does not contain a P entry in its encryption
|
(* The file is encrypted but does not contain a P entry in its encryption
|
||||||
dictionary. *)
|
dictionary. *)
|
||||||
|
|
Loading…
Reference in New Issue