|
|
|
@ -128,26 +128,29 @@ var Catalog = (function CatalogClosure() {
@@ -128,26 +128,29 @@ var Catalog = (function CatalogClosure() {
|
|
|
|
|
return shadow(this, 'documentOutline', obj); |
|
|
|
|
}, |
|
|
|
|
readDocumentOutline: function Catalog_readDocumentOutline() { |
|
|
|
|
var xref = this.xref; |
|
|
|
|
var obj = this.catDict.get('Outlines'); |
|
|
|
|
var root = { items: [] }; |
|
|
|
|
if (isDict(obj)) { |
|
|
|
|
if (!isDict(obj)) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
obj = obj.getRaw('First'); |
|
|
|
|
var processed = new RefSet(); |
|
|
|
|
if (isRef(obj)) { |
|
|
|
|
if (!isRef(obj)) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
var root = { items: [] }; |
|
|
|
|
var queue = [{obj: obj, parent: root}]; |
|
|
|
|
// to avoid recursion keeping track of the items
|
|
|
|
|
// in the processed dictionary
|
|
|
|
|
// To avoid recursion, keep track of the already processed items.
|
|
|
|
|
var processed = new RefSet(); |
|
|
|
|
processed.put(obj); |
|
|
|
|
var xref = this.xref; |
|
|
|
|
|
|
|
|
|
while (queue.length > 0) { |
|
|
|
|
var i = queue.shift(); |
|
|
|
|
var outlineDict = xref.fetchIfRef(i.obj); |
|
|
|
|
if (outlineDict === null) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
if (!outlineDict.has('Title')) { |
|
|
|
|
error('Invalid outline item'); |
|
|
|
|
} |
|
|
|
|
assert(outlineDict.has('Title'), 'Invalid outline item'); |
|
|
|
|
|
|
|
|
|
var actionDict = outlineDict.get('A'), dest = null, url = null; |
|
|
|
|
if (actionDict) { |
|
|
|
|
var destEntry = actionDict.get('D'); |
|
|
|
@ -188,8 +191,6 @@ var Catalog = (function CatalogClosure() {
@@ -188,8 +191,6 @@ var Catalog = (function CatalogClosure() {
|
|
|
|
|
processed.put(obj); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return (root.items.length > 0 ? root.items : null); |
|
|
|
|
}, |
|
|
|
|
get numPages() { |
|
|
|
|