Merge pull request #14152 from Snuffleupagus/xfaFactory-typo
Fix a `xfaFaxtory` typo in the shadowing in the `PDFDocument.xfaFactory` getter, and some other clean-up
This commit is contained in:
commit
52fce0d17b
@ -82,10 +82,11 @@ class Catalog {
|
|||||||
|
|
||||||
get version() {
|
get version() {
|
||||||
const version = this._catDict.get("Version");
|
const version = this._catDict.get("Version");
|
||||||
if (!isName(version)) {
|
return shadow(
|
||||||
return shadow(this, "version", null);
|
this,
|
||||||
}
|
"version",
|
||||||
return shadow(this, "version", version.name);
|
version instanceof Name ? version.name : null
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -94,10 +95,11 @@ class Catalog {
|
|||||||
*/
|
*/
|
||||||
get needsRendering() {
|
get needsRendering() {
|
||||||
const needsRendering = this._catDict.get("NeedsRendering");
|
const needsRendering = this._catDict.get("NeedsRendering");
|
||||||
if (!isBool(needsRendering)) {
|
return shadow(
|
||||||
return shadow(this, "needsRendering", false);
|
this,
|
||||||
}
|
"needsRendering",
|
||||||
return shadow(this, "needsRendering", needsRendering);
|
typeof needsRendering === "boolean" ? needsRendering : false
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
get collection() {
|
get collection() {
|
||||||
|
@ -263,12 +263,13 @@ class Page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get xfaData() {
|
get xfaData() {
|
||||||
if (this.xfaFactory) {
|
return shadow(
|
||||||
return shadow(this, "xfaData", {
|
this,
|
||||||
bbox: this.xfaFactory.getBoundingBox(this.pageIndex),
|
"xfaData",
|
||||||
});
|
this.xfaFactory
|
||||||
}
|
? { bbox: this.xfaFactory.getBoundingBox(this.pageIndex) }
|
||||||
return shadow(this, "xfaData", null);
|
: null
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
save(handler, task, annotationStorage) {
|
save(handler, task, annotationStorage) {
|
||||||
@ -784,11 +785,14 @@ class PDFDocument {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get numPages() {
|
get numPages() {
|
||||||
|
let num = 0;
|
||||||
if (this.xfaFactory) {
|
if (this.xfaFactory) {
|
||||||
return shadow(this, "numPages", this.xfaFactory.numberPages);
|
num = this.xfaFactory.numPages;
|
||||||
|
} else if (this.linearization) {
|
||||||
|
num = this.linearization.numPages;
|
||||||
|
} else {
|
||||||
|
num = this.catalog.numPages;
|
||||||
}
|
}
|
||||||
const linearization = this.linearization;
|
|
||||||
const num = linearization ? linearization.numPages : this.catalog.numPages;
|
|
||||||
return shadow(this, "numPages", num);
|
return shadow(this, "numPages", num);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -883,27 +887,24 @@ class PDFDocument {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get xfaFactory() {
|
get xfaFactory() {
|
||||||
|
let data;
|
||||||
if (
|
if (
|
||||||
this.pdfManager.enableXfa &&
|
this.pdfManager.enableXfa &&
|
||||||
this.catalog.needsRendering &&
|
this.catalog.needsRendering &&
|
||||||
this.formInfo.hasXfa &&
|
this.formInfo.hasXfa &&
|
||||||
!this.formInfo.hasAcroForm
|
!this.formInfo.hasAcroForm
|
||||||
) {
|
) {
|
||||||
const data = this.xfaData;
|
data = this.xfaData;
|
||||||
return shadow(this, "xfaFactory", data ? new XFAFactory(data) : null);
|
|
||||||
}
|
}
|
||||||
return shadow(this, "xfaFaxtory", null);
|
return shadow(this, "xfaFactory", data ? new XFAFactory(data) : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
get isPureXfa() {
|
get isPureXfa() {
|
||||||
return this.xfaFactory && this.xfaFactory.isValid();
|
return this.xfaFactory ? this.xfaFactory.isValid() : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
get htmlForXfa() {
|
get htmlForXfa() {
|
||||||
if (this.xfaFactory) {
|
return this.xfaFactory ? this.xfaFactory.getPages() : null;
|
||||||
return this.xfaFactory.getPages();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async loadXfaImages() {
|
async loadXfaImages() {
|
||||||
@ -1084,10 +1085,9 @@ class PDFDocument {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async serializeXfaData(annotationStorage) {
|
async serializeXfaData(annotationStorage) {
|
||||||
if (this.xfaFactory) {
|
return this.xfaFactory
|
||||||
return this.xfaFactory.serializeData(annotationStorage);
|
? this.xfaFactory.serializeData(annotationStorage)
|
||||||
}
|
: null;
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get formInfo() {
|
get formInfo() {
|
||||||
|
@ -54,7 +54,7 @@ class XFAFactory {
|
|||||||
return this.dims[pageIndex];
|
return this.dims[pageIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
get numberPages() {
|
get numPages() {
|
||||||
if (!this.pages) {
|
if (!this.pages) {
|
||||||
this._createPages();
|
this._createPages();
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ describe("XFAFactory", function () {
|
|||||||
const factory = new XFAFactory({ "xdp:xdp": xml });
|
const factory = new XFAFactory({ "xdp:xdp": xml });
|
||||||
factory.setFonts([]);
|
factory.setFonts([]);
|
||||||
|
|
||||||
expect(factory.numberPages).toEqual(2);
|
expect(factory.numPages).toEqual(2);
|
||||||
|
|
||||||
const pages = factory.getPages();
|
const pages = factory.getPages();
|
||||||
const page1 = pages.children[0];
|
const page1 = pages.children[0];
|
||||||
@ -174,7 +174,7 @@ describe("XFAFactory", function () {
|
|||||||
`;
|
`;
|
||||||
const factory = new XFAFactory({ "xdp:xdp": xml });
|
const factory = new XFAFactory({ "xdp:xdp": xml });
|
||||||
|
|
||||||
expect(factory.numberPages).toEqual(1);
|
expect(factory.numPages).toEqual(1);
|
||||||
|
|
||||||
const pages = factory.getPages();
|
const pages = factory.getPages();
|
||||||
const field = searchHtmlNode(pages, "name", "img");
|
const field = searchHtmlNode(pages, "name", "img");
|
||||||
@ -208,7 +208,7 @@ describe("XFAFactory", function () {
|
|||||||
`;
|
`;
|
||||||
const factory = new XFAFactory({ "xdp:xdp": xml });
|
const factory = new XFAFactory({ "xdp:xdp": xml });
|
||||||
|
|
||||||
expect(factory.numberPages).toEqual(1);
|
expect(factory.numPages).toEqual(1);
|
||||||
|
|
||||||
const pages = factory.getPages();
|
const pages = factory.getPages();
|
||||||
const page1 = pages.children[0];
|
const page1 = pages.children[0];
|
||||||
@ -263,7 +263,7 @@ describe("XFAFactory", function () {
|
|||||||
const factory = new XFAFactory({ "xdp:xdp": xml });
|
const factory = new XFAFactory({ "xdp:xdp": xml });
|
||||||
factory.setFonts([]);
|
factory.setFonts([]);
|
||||||
|
|
||||||
expect(factory.numberPages).toEqual(1);
|
expect(factory.numPages).toEqual(1);
|
||||||
|
|
||||||
const pages = factory.getPages();
|
const pages = factory.getPages();
|
||||||
const table = searchHtmlNode(
|
const table = searchHtmlNode(
|
||||||
@ -336,7 +336,7 @@ describe("XFAFactory", function () {
|
|||||||
`;
|
`;
|
||||||
const factory = new XFAFactory({ "xdp:xdp": xml });
|
const factory = new XFAFactory({ "xdp:xdp": xml });
|
||||||
|
|
||||||
expect(factory.numberPages).toEqual(1);
|
expect(factory.numPages).toEqual(1);
|
||||||
|
|
||||||
const pages = factory.getPages();
|
const pages = factory.getPages();
|
||||||
const field = searchHtmlNode(pages, "name", "input");
|
const field = searchHtmlNode(pages, "name", "input");
|
||||||
@ -378,7 +378,7 @@ describe("XFAFactory", function () {
|
|||||||
`;
|
`;
|
||||||
const factory = new XFAFactory({ "xdp:xdp": xml });
|
const factory = new XFAFactory({ "xdp:xdp": xml });
|
||||||
|
|
||||||
expect(factory.numberPages).toEqual(1);
|
expect(factory.numPages).toEqual(1);
|
||||||
|
|
||||||
const pages = factory.getPages();
|
const pages = factory.getPages();
|
||||||
const field = searchHtmlNode(pages, "name", "input");
|
const field = searchHtmlNode(pages, "name", "input");
|
||||||
@ -420,7 +420,7 @@ describe("XFAFactory", function () {
|
|||||||
`;
|
`;
|
||||||
const factory = new XFAFactory({ "xdp:xdp": xml });
|
const factory = new XFAFactory({ "xdp:xdp": xml });
|
||||||
|
|
||||||
expect(factory.numberPages).toEqual(1);
|
expect(factory.numPages).toEqual(1);
|
||||||
|
|
||||||
const pages = factory.getPages();
|
const pages = factory.getPages();
|
||||||
const field = searchHtmlNode(pages, "name", "input");
|
const field = searchHtmlNode(pages, "name", "input");
|
||||||
@ -463,7 +463,7 @@ describe("XFAFactory", function () {
|
|||||||
`;
|
`;
|
||||||
const factory = new XFAFactory({ "xdp:xdp": xml });
|
const factory = new XFAFactory({ "xdp:xdp": xml });
|
||||||
|
|
||||||
expect(factory.numberPages).toEqual(1);
|
expect(factory.numPages).toEqual(1);
|
||||||
|
|
||||||
const pages = factory.getPages();
|
const pages = factory.getPages();
|
||||||
const field1 = searchHtmlNode(pages, "name", "input");
|
const field1 = searchHtmlNode(pages, "name", "input");
|
||||||
@ -517,7 +517,7 @@ describe("XFAFactory", function () {
|
|||||||
`;
|
`;
|
||||||
const factory = new XFAFactory({ "xdp:xdp": xml });
|
const factory = new XFAFactory({ "xdp:xdp": xml });
|
||||||
|
|
||||||
expect(factory.numberPages).toEqual(1);
|
expect(factory.numPages).toEqual(1);
|
||||||
|
|
||||||
const pages = factory.getPages();
|
const pages = factory.getPages();
|
||||||
const field1 = searchHtmlNode(pages, "name", "input");
|
const field1 = searchHtmlNode(pages, "name", "input");
|
||||||
@ -560,7 +560,7 @@ describe("XFAFactory", function () {
|
|||||||
|
|
||||||
// A valid, and complete, URL.
|
// A valid, and complete, URL.
|
||||||
factory = new XFAFactory({ "xdp:xdp": getXml("https://www.example.com/") });
|
factory = new XFAFactory({ "xdp:xdp": getXml("https://www.example.com/") });
|
||||||
expect(factory.numberPages).toEqual(1);
|
expect(factory.numPages).toEqual(1);
|
||||||
pages = factory.getPages();
|
pages = factory.getPages();
|
||||||
a = searchHtmlNode(pages, "name", "a");
|
a = searchHtmlNode(pages, "name", "a");
|
||||||
expect(a.value).toEqual("https://www.example.com/");
|
expect(a.value).toEqual("https://www.example.com/");
|
||||||
@ -568,7 +568,7 @@ describe("XFAFactory", function () {
|
|||||||
|
|
||||||
// A valid, but incomplete, URL.
|
// A valid, but incomplete, URL.
|
||||||
factory = new XFAFactory({ "xdp:xdp": getXml("www.example.com/") });
|
factory = new XFAFactory({ "xdp:xdp": getXml("www.example.com/") });
|
||||||
expect(factory.numberPages).toEqual(1);
|
expect(factory.numPages).toEqual(1);
|
||||||
pages = factory.getPages();
|
pages = factory.getPages();
|
||||||
a = searchHtmlNode(pages, "name", "a");
|
a = searchHtmlNode(pages, "name", "a");
|
||||||
expect(a.value).toEqual("www.example.com/");
|
expect(a.value).toEqual("www.example.com/");
|
||||||
@ -576,7 +576,7 @@ describe("XFAFactory", function () {
|
|||||||
|
|
||||||
// A valid email-address.
|
// A valid email-address.
|
||||||
factory = new XFAFactory({ "xdp:xdp": getXml("mailto:test@example.com") });
|
factory = new XFAFactory({ "xdp:xdp": getXml("mailto:test@example.com") });
|
||||||
expect(factory.numberPages).toEqual(1);
|
expect(factory.numPages).toEqual(1);
|
||||||
pages = factory.getPages();
|
pages = factory.getPages();
|
||||||
a = searchHtmlNode(pages, "name", "a");
|
a = searchHtmlNode(pages, "name", "a");
|
||||||
expect(a.value).toEqual("mailto:test@example.com");
|
expect(a.value).toEqual("mailto:test@example.com");
|
||||||
@ -584,7 +584,7 @@ describe("XFAFactory", function () {
|
|||||||
|
|
||||||
// Not a valid URL.
|
// Not a valid URL.
|
||||||
factory = new XFAFactory({ "xdp:xdp": getXml("qwerty/") });
|
factory = new XFAFactory({ "xdp:xdp": getXml("qwerty/") });
|
||||||
expect(factory.numberPages).toEqual(1);
|
expect(factory.numPages).toEqual(1);
|
||||||
pages = factory.getPages();
|
pages = factory.getPages();
|
||||||
a = searchHtmlNode(pages, "name", "a");
|
a = searchHtmlNode(pages, "name", "a");
|
||||||
expect(a.value).toEqual("qwerty/");
|
expect(a.value).toEqual("qwerty/");
|
||||||
@ -635,7 +635,7 @@ describe("XFAFactory", function () {
|
|||||||
`;
|
`;
|
||||||
const factory = new XFAFactory({ "xdp:xdp": xml });
|
const factory = new XFAFactory({ "xdp:xdp": xml });
|
||||||
|
|
||||||
expect(factory.numberPages).toEqual(1);
|
expect(factory.numPages).toEqual(1);
|
||||||
|
|
||||||
const pages = factory.getPages();
|
const pages = factory.getPages();
|
||||||
let a = searchHtmlNode(pages, "name", "a");
|
let a = searchHtmlNode(pages, "name", "a");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user