mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-25 09:38:06 +02:00
When saving some annotations with the same name, set the value in the parent
It fixes #18630.
This commit is contained in:
parent
9bf9bbda0b
commit
2da586527f
3 changed files with 138 additions and 24 deletions
|
@ -146,6 +146,36 @@ function getInheritableProperty({
|
|||
return values;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the parent dictionary to update when a property is set.
|
||||
*
|
||||
* @param {Dict} dict - Dictionary from where to start the traversal.
|
||||
* @param {Ref} ref - The reference to the dictionary.
|
||||
* @param {XRef} xref - The `XRef` instance.
|
||||
*/
|
||||
function getParentToUpdate(dict, ref, xref) {
|
||||
const visited = new RefSet();
|
||||
const firstDict = dict;
|
||||
const result = { dict: null, ref: null };
|
||||
|
||||
while (dict instanceof Dict && !visited.has(ref)) {
|
||||
visited.put(ref);
|
||||
if (dict.has("T")) {
|
||||
break;
|
||||
}
|
||||
ref = dict.getRaw("Parent");
|
||||
if (!(ref instanceof Ref)) {
|
||||
return result;
|
||||
}
|
||||
dict = xref.fetch(ref);
|
||||
}
|
||||
if (dict instanceof Dict && dict !== firstDict) {
|
||||
result.dict = dict;
|
||||
result.ref = ref;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// prettier-ignore
|
||||
const ROMAN_NUMBER_MAP = [
|
||||
"", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM",
|
||||
|
@ -672,6 +702,7 @@ export {
|
|||
getInheritableProperty,
|
||||
getLookupTableFactory,
|
||||
getNewAnnotationsMap,
|
||||
getParentToUpdate,
|
||||
getRotationMatrix,
|
||||
getSizeInBytes,
|
||||
isAscii,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue