Merge pull request #16443 from Snuffleupagus/idFactory-shorter

[api-minor] Slightly shorten some `idFactory` strings
This commit is contained in:
Tim van der Meij 2023-05-19 11:36:06 +02:00 committed by GitHub
commit 38287d9435
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 21 additions and 22 deletions

View File

@ -102,7 +102,7 @@ class Page {
} }
static getPageObjId() { static getPageObjId() {
return `page${ref.toString()}`; return `p${ref.toString()}`;
} }
}; };
} }

View File

@ -3343,7 +3343,7 @@ class PartialEvaluator {
textContent.items.push({ textContent.items.push({
type: "beginMarkedContentProps", type: "beginMarkedContentProps",
id: Number.isInteger(mcid) id: Number.isInteger(mcid)
? `${self.idFactory.getPageObjId()}_mcid${mcid}` ? `${self.idFactory.getPageObjId()}_mc${mcid}`
: null, : null,
tag: args[0] instanceof Name ? args[0].name : null, tag: args[0] instanceof Name ? args[0].name : null,
}); });

View File

@ -400,8 +400,6 @@ function getFontSubstitution(
baseFontName, baseFontName,
standardFontName standardFontName
) { ) {
let mustAddBaseFont = false;
// It's possible to have a font name with spaces, commas or dashes, hence we // It's possible to have a font name with spaces, commas or dashes, hence we
// just replace them by a dash. // just replace them by a dash.
baseFontName = normalizeFontName(baseFontName); baseFontName = normalizeFontName(baseFontName);
@ -426,13 +424,14 @@ function getFontSubstitution(
} }
} }
let mustAddBaseFont = false;
if (!substitution) { if (!substitution) {
// If not, check if we've a substitution for the standard font. // If not, check if we've a substitution for the standard font.
substitution = substitutionMap.get(standardFontName); substitution = substitutionMap.get(standardFontName);
mustAddBaseFont = true; mustAddBaseFont = true;
} }
const loadedName = `${idFactory.getDocId()}_sf_${idFactory.createFontId()}`; const loadedName = `${idFactory.getDocId()}_s${idFactory.createFontId()}`;
if (!substitution) { if (!substitution) {
if (!validateFontName(baseFontName)) { if (!validateFontName(baseFontName)) {
systemFontCache.set(key, null); systemFontCache.set(key, null);

View File

@ -315,7 +315,7 @@ class StructTreePage {
) { ) {
obj.children.push({ obj.children.push({
type: "content", type: "content",
id: `page${kid.pageObjId}_mcid${kid.mcid}`, id: `p${kid.pageObjId}_mc${kid.mcid}`,
}); });
} else if (kid.type === StructElementType.OBJECT) { } else if (kid.type === StructElementType.OBJECT) {
obj.children.push({ obj.children.push({

View File

@ -2745,7 +2745,7 @@ Caron Broadcasting, Inc., an Ohio corporation (“Lessee”).`)
children: [ children: [
{ {
role: "NonStruct", role: "NonStruct",
children: [{ type: "content", id: "page2R_mcid0" }], children: [{ type: "content", id: "p2R_mc0" }],
}, },
], ],
}, },
@ -2754,7 +2754,7 @@ Caron Broadcasting, Inc., an Ohio corporation (“Lessee”).`)
children: [ children: [
{ {
role: "NonStruct", role: "NonStruct",
children: [{ type: "content", id: "page2R_mcid1" }], children: [{ type: "content", id: "p2R_mc1" }],
}, },
], ],
}, },
@ -2763,7 +2763,7 @@ Caron Broadcasting, Inc., an Ohio corporation (“Lessee”).`)
children: [ children: [
{ {
role: "NonStruct", role: "NonStruct",
children: [{ type: "content", id: "page2R_mcid2" }], children: [{ type: "content", id: "p2R_mc2" }],
}, },
], ],
}, },
@ -2772,7 +2772,7 @@ Caron Broadcasting, Inc., an Ohio corporation (“Lessee”).`)
children: [ children: [
{ {
role: "NonStruct", role: "NonStruct",
children: [{ type: "content", id: "page2R_mcid3" }], children: [{ type: "content", id: "p2R_mc3" }],
}, },
], ],
}, },

View File

@ -40,7 +40,7 @@ describe("getFontSubstitution", function () {
}, },
}) })
); );
expect(fontSubstitution.css).toMatch(/^g_d(\d+)_sf_f(\d+)$/); expect(fontSubstitution.css).toMatch(/^g_d(\d+)_sf(\d+)$/);
}); });
it("should substitute an unknown bold font", () => { it("should substitute an unknown bold font", () => {
@ -63,7 +63,7 @@ describe("getFontSubstitution", function () {
}, },
}) })
); );
expect(fontSubstitution.css).toMatch(/^g_d(\d+)_sf_f(\d+)$/); expect(fontSubstitution.css).toMatch(/^g_d(\d+)_sf(\d+)$/);
}); });
it("should substitute an unknown italic font", () => { it("should substitute an unknown italic font", () => {
@ -86,7 +86,7 @@ describe("getFontSubstitution", function () {
}, },
}) })
); );
expect(fontSubstitution.css).toMatch(/^g_d(\d+)_sf_f(\d+)$/); expect(fontSubstitution.css).toMatch(/^g_d(\d+)_sf(\d+)$/);
}); });
it("should substitute an unknown bold italic font", () => { it("should substitute an unknown bold italic font", () => {
@ -109,7 +109,7 @@ describe("getFontSubstitution", function () {
}, },
}) })
); );
expect(fontSubstitution.css).toMatch(/^g_d(\d+)_sf_f(\d+)$/); expect(fontSubstitution.css).toMatch(/^g_d(\d+)_sf(\d+)$/);
}); });
it("should substitute an unknown font but with a standard font", () => { it("should substitute an unknown font but with a standard font", () => {
@ -140,7 +140,7 @@ describe("getFontSubstitution", function () {
}, },
}) })
); );
expect(fontSubstitution.css).toMatch(/^g_d(\d+)_sf_f(\d+),sans-serif$/); expect(fontSubstitution.css).toMatch(/^g_d(\d+)_sf(\d+),sans-serif$/);
}); });
it("should substitute an unknown font but with a standard italic font", () => { it("should substitute an unknown font but with a standard italic font", () => {
@ -173,7 +173,7 @@ describe("getFontSubstitution", function () {
}, },
}) })
); );
expect(fontSubstitution.css).toMatch(/^g_d(\d+)_sf_f(\d+),sans-serif$/); expect(fontSubstitution.css).toMatch(/^g_d(\d+)_sf(\d+),sans-serif$/);
}); });
it("should substitute an unknown font but with a standard bold font", () => { it("should substitute an unknown font but with a standard bold font", () => {
@ -205,7 +205,7 @@ describe("getFontSubstitution", function () {
}, },
}) })
); );
expect(fontSubstitution.css).toMatch(/^g_d(\d+)_sf_f(\d+),sans-serif$/); expect(fontSubstitution.css).toMatch(/^g_d(\d+)_sf(\d+),sans-serif$/);
}); });
it("should substitute an unknown font but with a standard bold italic font", () => { it("should substitute an unknown font but with a standard bold italic font", () => {
@ -240,7 +240,7 @@ describe("getFontSubstitution", function () {
}, },
}) })
); );
expect(fontSubstitution.css).toMatch(/^g_d(\d+)_sf_f(\d+),sans-serif$/); expect(fontSubstitution.css).toMatch(/^g_d(\d+)_sf(\d+),sans-serif$/);
}); });
it("should substitute Calibri", () => { it("should substitute Calibri", () => {
@ -271,7 +271,7 @@ describe("getFontSubstitution", function () {
}, },
}) })
); );
expect(fontSubstitution.css).toMatch(/^g_d(\d+)_sf_f(\d+),sans-serif$/); expect(fontSubstitution.css).toMatch(/^g_d(\d+)_sf(\d+),sans-serif$/);
}); });
it("should substitute Calibri-Bold", () => { it("should substitute Calibri-Bold", () => {
@ -304,7 +304,7 @@ describe("getFontSubstitution", function () {
}, },
}) })
); );
expect(fontSubstitution.css).toMatch(/^g_d(\d+)_sf_f(\d+),sans-serif$/); expect(fontSubstitution.css).toMatch(/^g_d(\d+)_sf(\d+),sans-serif$/);
}); });
it("should substitute Arial Black", () => { it("should substitute Arial Black", () => {
@ -337,7 +337,7 @@ describe("getFontSubstitution", function () {
}, },
}) })
); );
expect(fontSubstitution.css).toMatch(/^g_d(\d+)_sf_f(\d+),sans-serif$/); expect(fontSubstitution.css).toMatch(/^g_d(\d+)_sf(\d+),sans-serif$/);
}); });
it("should substitute Arial Black Bold", () => { it("should substitute Arial Black Bold", () => {
@ -370,6 +370,6 @@ describe("getFontSubstitution", function () {
}, },
}) })
); );
expect(fontSubstitution.css).toMatch(/^g_d(\d+)_sf_f(\d+),sans-serif$/); expect(fontSubstitution.css).toMatch(/^g_d(\d+)_sf(\d+),sans-serif$/);
}); });
}); });