| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118 | 1×
1×
1×
1×
4×
4×
4×
1×
1128×
1×
368×
1×
1×
92×
92×
92×
4×
92×
92×
1×
210×
210×
88×
122×
4×
118×
1562×
1562×
118×
118×
122×
1×
118×
118×
118×
118×
118×
118×
118×
1×
92×
92×
92×
92×
92×
92×
1×
4×
92×
92×
92×
92×
92×
92×
4×
4×
4×
1×
1×
1×
1×
92×
92×
1×
1746×
1×
390×
1×
92×
1×
1×
| define(["require", "exports", "./../collections/dictionary", "./enum"], function (require, exports, dictionary_1, enum_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var PdfMainObjectCollection = (function () {
function PdfMainObjectCollection() {
this.objectCollections = [];
this.mainObjectCollection = new dictionary_1.Dictionary();
this.primitiveObjectCollection = new dictionary_1.Dictionary();
}
Object.defineProperty(PdfMainObjectCollection.prototype, "count", {
get: function () {
return this.objectCollections.length;
},
enumerable: true,
configurable: true
});
PdfMainObjectCollection.prototype.items = function (index) {
return this.objectCollections[index];
};
Object.defineProperty(PdfMainObjectCollection.prototype, "outIsNew", {
get: function () {
return this.isNew;
},
enumerable: true,
configurable: true
});
PdfMainObjectCollection.prototype.add = function (element) {
var objInfo = new ObjectInfo(element);
this.objectCollections.push(objInfo);
if (!this.primitiveObjectCollection.containsKey(element)) {
this.primitiveObjectCollection.setValue(element, this.objectCollections.length - 1);
}
element.position = this.index = this.objectCollections.length - 1;
element.status = enum_1.ObjectStatus.Registered;
};
PdfMainObjectCollection.prototype.lookFor = function (obj) {
var index = -1;
if (obj.position !== -1) {
return obj.position;
}
if (this.primitiveObjectCollection.containsKey(obj) && this.count === this.primitiveObjectCollection.size()) {
index = this.primitiveObjectCollection.getValue(obj);
}
else {
for (var i = this.count - 1; i >= 0; i--) {
var oi = this.objectCollections[i];
if (oi.object === obj) {
index = i;
break;
}
}
}
return index;
};
PdfMainObjectCollection.prototype.getReference = function (index, isNew) {
this.index = this.lookFor(index);
var reference;
this.isNew = false;
var oi = this.objectCollections[this.index];
reference = oi.reference;
var obj = { reference: reference, wasNew: isNew };
return obj;
};
PdfMainObjectCollection.prototype.trySetReference = function (obj, reference, found) {
var result = true;
found = true;
this.index = this.lookFor(obj);
var oi = this.objectCollections[this.index];
oi.setReference(reference);
return result;
};
PdfMainObjectCollection.prototype.destroy = function () {
for (var _i = 0, _a = this.objectCollections; _i < _a.length; _i++) {
var obj = _a[_i];
Eif (obj !== undefined) {
obj.pdfObject.position = -1;
obj.pdfObject.isSaving = undefined;
obj.pdfObject.objectCollectionIndex = undefined;
obj.pdfObject.position = undefined;
}
}
this.objectCollections = [];
this.mainObjectCollection = new dictionary_1.Dictionary();
this.primitiveObjectCollection = new dictionary_1.Dictionary();
};
return PdfMainObjectCollection;
}());
exports.PdfMainObjectCollection = PdfMainObjectCollection;
var ObjectInfo = (function () {
function ObjectInfo(obj, reference) {
this.pdfObject = obj;
this.pdfReference = reference;
}
Object.defineProperty(ObjectInfo.prototype, "object", {
get: function () {
return this.pdfObject;
},
set: function (value) {
this.pdfObject = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ObjectInfo.prototype, "reference", {
get: function () {
return this.pdfReference;
},
enumerable: true,
configurable: true
});
ObjectInfo.prototype.setReference = function (reference) {
this.pdfReference = reference;
};
return ObjectInfo;
}());
exports.ObjectInfo = ObjectInfo;
});
|