|
|
@ -153,17 +153,16 @@ var Catalog = (function CatalogClosure() { |
|
|
|
var obj = this.catDict.get('Outlines'); |
|
|
|
var obj = this.catDict.get('Outlines'); |
|
|
|
var root = { items: [] }; |
|
|
|
var root = { items: [] }; |
|
|
|
if (isDict(obj)) { |
|
|
|
if (isDict(obj)) { |
|
|
|
var ref = obj.getRaw('First'); |
|
|
|
obj = obj.getRaw('First'); |
|
|
|
obj = obj.get('First'); |
|
|
|
|
|
|
|
var processed = new RefSet(); |
|
|
|
var processed = new RefSet(); |
|
|
|
if (isRef(ref)) { |
|
|
|
if (isRef(obj)) { |
|
|
|
var queue = [{obj: obj, parent: root}]; |
|
|
|
var queue = [{obj: obj, parent: root}]; |
|
|
|
// to avoid recursion keeping track of the items
|
|
|
|
// to avoid recursion keeping track of the items
|
|
|
|
// in the processed dictionary
|
|
|
|
// in the processed dictionary
|
|
|
|
processed.put(ref); |
|
|
|
processed.put(obj); |
|
|
|
while (queue.length > 0) { |
|
|
|
while (queue.length > 0) { |
|
|
|
var i = queue.shift(); |
|
|
|
var i = queue.shift(); |
|
|
|
var outlineDict = i.obj; |
|
|
|
var outlineDict = xref.fetchIfRef(i.obj); |
|
|
|
if (outlineDict === null) |
|
|
|
if (outlineDict === null) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
if (!outlineDict.has('Title')) |
|
|
|
if (!outlineDict.has('Title')) |
|
|
@ -187,17 +186,15 @@ var Catalog = (function CatalogClosure() { |
|
|
|
items: [] |
|
|
|
items: [] |
|
|
|
}; |
|
|
|
}; |
|
|
|
i.parent.items.push(outlineItem); |
|
|
|
i.parent.items.push(outlineItem); |
|
|
|
ref = outlineDict.getRaw('First'); |
|
|
|
obj = outlineDict.getRaw('First'); |
|
|
|
if (isRef(ref) && !processed.has(ref)) { |
|
|
|
if (isRef(obj) && !processed.has(obj)) { |
|
|
|
obj = outlineDict.get('First'); |
|
|
|
|
|
|
|
queue.push({obj: obj, parent: outlineItem}); |
|
|
|
queue.push({obj: obj, parent: outlineItem}); |
|
|
|
processed.put(ref); |
|
|
|
processed.put(obj); |
|
|
|
} |
|
|
|
} |
|
|
|
ref = outlineDict.getRaw('Next'); |
|
|
|
obj = outlineDict.getRaw('Next'); |
|
|
|
if (isRef(ref) && !processed.has(ref)) { |
|
|
|
if (isRef(obj) && !processed.has(obj)) { |
|
|
|
obj = outlineDict.get('Next'); |
|
|
|
|
|
|
|
queue.push({obj: obj, parent: i.parent}); |
|
|
|
queue.push({obj: obj, parent: i.parent}); |
|
|
|
processed.put(ref); |
|
|
|
processed.put(obj); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -236,8 +233,7 @@ var Catalog = (function CatalogClosure() { |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
get destinations() { |
|
|
|
get destinations() { |
|
|
|
function fetchDestination(xref, ref) { |
|
|
|
function fetchDestination(dest) { |
|
|
|
var dest = ref; |
|
|
|
|
|
|
|
return isDict(dest) ? dest.get('D') : dest; |
|
|
|
return isDict(dest) ? dest.get('D') : dest; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -254,7 +250,7 @@ var Catalog = (function CatalogClosure() { |
|
|
|
obj = nameDictionaryRef; |
|
|
|
obj = nameDictionaryRef; |
|
|
|
obj.forEach(function catalogForEach(key, value) { |
|
|
|
obj.forEach(function catalogForEach(key, value) { |
|
|
|
if (!value) return; |
|
|
|
if (!value) return; |
|
|
|
dests[key] = fetchDestination(xref, value); |
|
|
|
dests[key] = fetchDestination(value); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
if (nameTreeRef) { |
|
|
|
if (nameTreeRef) { |
|
|
@ -278,7 +274,7 @@ var Catalog = (function CatalogClosure() { |
|
|
|
} |
|
|
|
} |
|
|
|
var names = obj.get('Names'); |
|
|
|
var names = obj.get('Names'); |
|
|
|
for (i = 0, n = names.length; i < n; i += 2) { |
|
|
|
for (i = 0, n = names.length; i < n; i += 2) { |
|
|
|
dests[names[i]] = fetchDestination(xref, names[i + 1]); |
|
|
|
dests[names[i]] = fetchDestination(xref.fetchIfRef(names[i + 1])); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|