kordoc 4.17.3 → 4.17.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{-WP4ZCXHV.js → -SQRLFE4N.js} +11 -11
- package/dist/{chunk-TTSXZO2A.js → chunk-4D52VUGA.js} +3 -3
- package/dist/{chunk-EM2J3MAE.js → chunk-6DXSRQ65.js} +2 -2
- package/dist/{chunk-TOPQ7T4N.js → chunk-7TE6TK52.js} +2 -2
- package/dist/{chunk-WFXZRYFS.js → chunk-AAQR4RIX.js} +2 -2
- package/dist/{chunk-HNPRQKLZ.cjs → chunk-AFXX3YSP.cjs} +6 -6
- package/dist/chunk-AFXX3YSP.cjs.map +1 -0
- package/dist/{chunk-YKL7GP7E.cjs → chunk-AOONZC4S.cjs} +3 -3
- package/dist/chunk-AOONZC4S.cjs.map +1 -0
- package/dist/{chunk-5BDNDGUI.js → chunk-DD6AY6EI.js} +2 -2
- package/dist/{chunk-ZWPINXUX.cjs → chunk-EXBZHI25.cjs} +2 -2
- package/dist/chunk-EXBZHI25.cjs.map +1 -0
- package/dist/{chunk-OOUW3ROZ.js → chunk-FSCVZR4A.js} +4 -4
- package/dist/{chunk-2VMTMIGD.cjs → chunk-GNORDND5.cjs} +12 -12
- package/dist/chunk-GNORDND5.cjs.map +1 -0
- package/dist/chunk-GS7T56RP.cjs.map +1 -1
- package/dist/{chunk-YDWHS7FP.js → chunk-HQ6TM2JE.js} +3 -3
- package/dist/{chunk-C3MC7HOB.js → chunk-HY33WBAH.js} +2 -2
- package/dist/{chunk-5HIJXVED.js → chunk-IERSVUW6.js} +2 -2
- package/dist/chunk-J55UQC5H.cjs.map +1 -1
- package/dist/{chunk-DUHHMIPS.cjs → chunk-KIYHQQVO.cjs} +3 -3
- package/dist/chunk-KIYHQQVO.cjs.map +1 -0
- package/dist/{chunk-UHGWEWZI.js → chunk-NNNRN6BY.js} +2 -2
- package/dist/{chunk-JNCWHGJG.js → chunk-O5T5OIJM.js} +2 -2
- package/dist/{chunk-UTKVDI22.js → chunk-ODVIUG6Q.js} +2 -2
- package/dist/{chunk-JORDNRVS.js → chunk-P2ZPPRM7.js} +2 -2
- package/dist/{chunk-BAEABKCB.js → chunk-PNXJYEOR.js} +2 -2
- package/dist/{chunk-DPMDJYHX.js → chunk-PTMYCK7R.js} +2 -2
- package/dist/{chunk-K7W5L4GI.js → chunk-PVJFCDND.js} +38 -13
- package/dist/chunk-PVJFCDND.js.map +1 -0
- package/dist/{chunk-JPQNRW7C.js → chunk-RCS7WXOM.js} +2 -2
- package/dist/{chunk-UJZABAVA.js → chunk-SSY6FQLS.js} +200 -97
- package/dist/chunk-SSY6FQLS.js.map +1 -0
- package/dist/{chunk-CKF5HTM6.js → chunk-TMHMJUYU.js} +302 -75
- package/dist/chunk-TMHMJUYU.js.map +1 -0
- package/dist/{chunk-4PY2V33D.js → chunk-VJP7O6BL.js} +2 -2
- package/dist/{chunk-Q7SPGAAA.js → chunk-W3OY3SLY.js} +3 -3
- package/dist/chunk-W3OY3SLY.js.map +1 -0
- package/dist/{chunk-K2GXTJPK.cjs → chunk-WNF3TSV3.cjs} +129 -104
- package/dist/chunk-WNF3TSV3.cjs.map +1 -0
- package/dist/{chunk-VNDVI3MJ.js → chunk-YBIWPCUX.js} +39 -14
- package/dist/chunk-YBIWPCUX.js.map +1 -0
- package/dist/chunks-VNSLMJQD.js +10 -0
- package/dist/cli.js +26 -26
- package/dist/{formula-Y3L3RPPI.cjs → formula-U37MTMBD.cjs} +9 -9
- package/dist/formula-U37MTMBD.cjs.map +1 -0
- package/dist/{formula-H2NAOQHD.js → formula-U3MJXXIL.js} +4 -4
- package/dist/{formula-NZ7G4AXC.js → formula-WZH5CMA3.js} +3 -3
- package/dist/{image-ocr-BGMQPELF.js → image-ocr-HYWDBN72.js} +6 -6
- package/dist/{image-ocr-QYLWWB7R.cjs → image-ocr-OXU55EW3.cjs} +15 -15
- package/dist/image-ocr-OXU55EW3.cjs.map +1 -0
- package/dist/{image-ocr-UTSJ2Q4Q.js → image-ocr-V6MICC6R.js} +9 -9
- package/dist/index.cjs +1193 -863
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +520 -190
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +22 -22
- package/dist/{model-bundle-QHZYIAUP.js → model-bundle-AHBUQ6SD.js} +5 -5
- package/dist/{models-MCBWWGBX.js → models-UF7B5LLG.js} +5 -5
- package/dist/page-range-QHHFTL7X.cjs.map +1 -1
- package/dist/{parser-72NGANOD.js → parser-F6N6ID25.js} +22 -13
- package/dist/parser-F6N6ID25.js.map +1 -0
- package/dist/{parser-BEPVGAMI.cjs → parser-IXRGUYZW.cjs} +206 -197
- package/dist/parser-IXRGUYZW.cjs.map +1 -0
- package/dist/{parser-IGTNLJ6E.js → parser-T4FBG2FR.js} +19 -10
- package/dist/parser-T4FBG2FR.js.map +1 -0
- package/dist/pdf-ocr-2CITOAIG.cjs +16 -0
- package/dist/pdf-ocr-2CITOAIG.cjs.map +1 -0
- package/dist/pdf-ocr-RG2MFWBX.js +15 -0
- package/dist/pdf-ocr-U7Z4IUMA.js +19 -0
- package/dist/{profile-io-H2BCBNRL.js → profile-io-GM3NVLV3.js} +3 -3
- package/dist/{rasterize-HIEA3MGV.js → rasterize-4A3LJXTG.js} +3 -3
- package/dist/{redact-doc-MHIY4AWT.js → redact-doc-SQ7C3LIG.js} +11 -11
- package/dist/{render-NIX6VP3C.js → render-6LTQZG4W.js} +7 -7
- package/dist/seal-ROSVLTRQ.js +10 -0
- package/dist/{setup-DU5WIHAX.js → setup-DGBJOROA.js} +3 -3
- package/dist/visual-6W34SFIW.js +20 -0
- package/dist/{watch-XW6CSLL7.js → watch-DJVJRSLE.js} +12 -12
- package/package.json +1 -1
- package/dist/chunk-2VMTMIGD.cjs.map +0 -1
- package/dist/chunk-CKF5HTM6.js.map +0 -1
- package/dist/chunk-DUHHMIPS.cjs.map +0 -1
- package/dist/chunk-HNPRQKLZ.cjs.map +0 -1
- package/dist/chunk-K2GXTJPK.cjs.map +0 -1
- package/dist/chunk-K7W5L4GI.js.map +0 -1
- package/dist/chunk-Q7SPGAAA.js.map +0 -1
- package/dist/chunk-UJZABAVA.js.map +0 -1
- package/dist/chunk-VNDVI3MJ.js.map +0 -1
- package/dist/chunk-YKL7GP7E.cjs.map +0 -1
- package/dist/chunk-ZWPINXUX.cjs.map +0 -1
- package/dist/chunks-S7XODMX4.js +0 -10
- package/dist/formula-Y3L3RPPI.cjs.map +0 -1
- package/dist/image-ocr-QYLWWB7R.cjs.map +0 -1
- package/dist/parser-72NGANOD.js.map +0 -1
- package/dist/parser-BEPVGAMI.cjs.map +0 -1
- package/dist/parser-IGTNLJ6E.js.map +0 -1
- package/dist/pdf-ocr-BW6RUT4H.cjs +0 -16
- package/dist/pdf-ocr-BW6RUT4H.cjs.map +0 -1
- package/dist/pdf-ocr-EWG24RNY.js +0 -15
- package/dist/pdf-ocr-TCDSJFQT.js +0 -19
- package/dist/seal-QTCJFT7G.js +0 -10
- package/dist/visual-TU2BS63P.js +0 -20
- /package/dist/{-WP4ZCXHV.js.map → -SQRLFE4N.js.map} +0 -0
- /package/dist/{chunk-TTSXZO2A.js.map → chunk-4D52VUGA.js.map} +0 -0
- /package/dist/{chunk-EM2J3MAE.js.map → chunk-6DXSRQ65.js.map} +0 -0
- /package/dist/{chunk-TOPQ7T4N.js.map → chunk-7TE6TK52.js.map} +0 -0
- /package/dist/{chunk-WFXZRYFS.js.map → chunk-AAQR4RIX.js.map} +0 -0
- /package/dist/{chunk-5BDNDGUI.js.map → chunk-DD6AY6EI.js.map} +0 -0
- /package/dist/{chunk-OOUW3ROZ.js.map → chunk-FSCVZR4A.js.map} +0 -0
- /package/dist/{chunk-YDWHS7FP.js.map → chunk-HQ6TM2JE.js.map} +0 -0
- /package/dist/{chunk-C3MC7HOB.js.map → chunk-HY33WBAH.js.map} +0 -0
- /package/dist/{chunk-5HIJXVED.js.map → chunk-IERSVUW6.js.map} +0 -0
- /package/dist/{chunk-UHGWEWZI.js.map → chunk-NNNRN6BY.js.map} +0 -0
- /package/dist/{chunk-JNCWHGJG.js.map → chunk-O5T5OIJM.js.map} +0 -0
- /package/dist/{chunk-UTKVDI22.js.map → chunk-ODVIUG6Q.js.map} +0 -0
- /package/dist/{chunk-JORDNRVS.js.map → chunk-P2ZPPRM7.js.map} +0 -0
- /package/dist/{chunk-BAEABKCB.js.map → chunk-PNXJYEOR.js.map} +0 -0
- /package/dist/{chunk-DPMDJYHX.js.map → chunk-PTMYCK7R.js.map} +0 -0
- /package/dist/{chunk-JPQNRW7C.js.map → chunk-RCS7WXOM.js.map} +0 -0
- /package/dist/{chunk-4PY2V33D.js.map → chunk-VJP7O6BL.js.map} +0 -0
- /package/dist/{chunks-S7XODMX4.js.map → chunks-VNSLMJQD.js.map} +0 -0
- /package/dist/{formula-H2NAOQHD.js.map → formula-U3MJXXIL.js.map} +0 -0
- /package/dist/{formula-NZ7G4AXC.js.map → formula-WZH5CMA3.js.map} +0 -0
- /package/dist/{image-ocr-BGMQPELF.js.map → image-ocr-HYWDBN72.js.map} +0 -0
- /package/dist/{image-ocr-UTSJ2Q4Q.js.map → image-ocr-V6MICC6R.js.map} +0 -0
- /package/dist/{model-bundle-QHZYIAUP.js.map → model-bundle-AHBUQ6SD.js.map} +0 -0
- /package/dist/{models-MCBWWGBX.js.map → models-UF7B5LLG.js.map} +0 -0
- /package/dist/{pdf-ocr-EWG24RNY.js.map → pdf-ocr-RG2MFWBX.js.map} +0 -0
- /package/dist/{pdf-ocr-TCDSJFQT.js.map → pdf-ocr-U7Z4IUMA.js.map} +0 -0
- /package/dist/{profile-io-H2BCBNRL.js.map → profile-io-GM3NVLV3.js.map} +0 -0
- /package/dist/{rasterize-HIEA3MGV.js.map → rasterize-4A3LJXTG.js.map} +0 -0
- /package/dist/{redact-doc-MHIY4AWT.js.map → redact-doc-SQ7C3LIG.js.map} +0 -0
- /package/dist/{render-NIX6VP3C.js.map → render-6LTQZG4W.js.map} +0 -0
- /package/dist/{seal-QTCJFT7G.js.map → seal-ROSVLTRQ.js.map} +0 -0
- /package/dist/{setup-DU5WIHAX.js.map → setup-DGBJOROA.js.map} +0 -0
- /package/dist/{visual-TU2BS63P.js.map → visual-6W34SFIW.js.map} +0 -0
- /package/dist/{watch-XW6CSLL7.js.map → watch-DJVJRSLE.js.map} +0 -0
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
HEADING_RATIO_H3,
|
|
10
10
|
tidyScriptTags,
|
|
11
11
|
unframeLayoutTables
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-ODVIUG6Q.js";
|
|
13
13
|
import {
|
|
14
14
|
parsePageRange
|
|
15
15
|
} from "./chunk-VQFA55IC.js";
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
findChildByLocalName,
|
|
23
23
|
hwpFaceToCssStack,
|
|
24
24
|
parseRenderStyles
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-W3OY3SLY.js";
|
|
26
26
|
import {
|
|
27
27
|
MAX_COLS,
|
|
28
28
|
MAX_ROWS,
|
|
@@ -33,18 +33,18 @@ import {
|
|
|
33
33
|
flattenLayoutTables,
|
|
34
34
|
mapPuaText,
|
|
35
35
|
markNonLayoutTable
|
|
36
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-HY33WBAH.js";
|
|
37
37
|
import {
|
|
38
38
|
loadSharp,
|
|
39
39
|
rasterizePageSvg
|
|
40
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-O5T5OIJM.js";
|
|
41
41
|
import {
|
|
42
42
|
KordocError,
|
|
43
43
|
escapeHtml,
|
|
44
44
|
precheckZipSize,
|
|
45
45
|
sanitizeHref,
|
|
46
46
|
toArrayBuffer
|
|
47
|
-
} from "./chunk-
|
|
47
|
+
} from "./chunk-DD6AY6EI.js";
|
|
48
48
|
|
|
49
49
|
// src/render/svg-render.ts
|
|
50
50
|
import JSZip from "jszip";
|
|
@@ -1706,7 +1706,7 @@ function findFirst(el, name, depth = 0) {
|
|
|
1706
1706
|
}
|
|
1707
1707
|
return null;
|
|
1708
1708
|
}
|
|
1709
|
-
var OBJ_TAGS = /* @__PURE__ */ new Set(["tbl", "pic", "container", "equation", "rect", "ellipse", "polygon", "curv", "line", "arc", "ole", "textart"]);
|
|
1709
|
+
var OBJ_TAGS = /* @__PURE__ */ new Set(["tbl", "pic", "container", "equation", "rect", "ellipse", "polygon", "curv", "curve", "line", "arc", "ole", "textart"]);
|
|
1710
1710
|
var CHAR_CTRL_1SLOT = /* @__PURE__ */ new Set(["lineBreak", "hyphen", "nbSpace", "fwSpace"]);
|
|
1711
1711
|
function pushFillers(chars, n, prId) {
|
|
1712
1712
|
for (let i = 0; i < n; i++) chars.push({ ch: "", prId });
|
|
@@ -1736,10 +1736,51 @@ function pushTextSlots(t, chars, prId, depth) {
|
|
|
1736
1736
|
}
|
|
1737
1737
|
}
|
|
1738
1738
|
}
|
|
1739
|
+
var deletedStarts = /* @__PURE__ */ new WeakMap();
|
|
1740
|
+
var deletedControls = /* @__PURE__ */ new WeakMap();
|
|
1741
|
+
function isDeletedControl(el) {
|
|
1742
|
+
return deletedControls.get(el) === true;
|
|
1743
|
+
}
|
|
1744
|
+
function deletionDelta(ctrl, depth, xmlDepth = 0) {
|
|
1745
|
+
if (xmlDepth > 64) return depth;
|
|
1746
|
+
if (ln(ctrl) === "deleteBegin") return depth + 1;
|
|
1747
|
+
if (ln(ctrl) === "deleteEnd") return Math.max(0, depth - 1);
|
|
1748
|
+
if (ln(ctrl) === "ctrl") for (const ch of elements(ctrl)) depth = deletionDelta(ch, depth, xmlDepth + 1);
|
|
1749
|
+
return depth;
|
|
1750
|
+
}
|
|
1751
|
+
function prepareDeletedRanges(root, depth = 0) {
|
|
1752
|
+
if (depth > 64) return;
|
|
1753
|
+
let deleted = 0;
|
|
1754
|
+
for (const p of elements(root)) {
|
|
1755
|
+
if (ln(p) !== "p") continue;
|
|
1756
|
+
deletedStarts.set(p, deleted);
|
|
1757
|
+
const scan = (el, xmlDepth) => {
|
|
1758
|
+
if (xmlDepth > 64) return;
|
|
1759
|
+
if (ln(el) === "ctrl") for (const ch of elements(el)) scan(ch, xmlDepth + 1);
|
|
1760
|
+
else {
|
|
1761
|
+
if (ln(el) === "deleteBegin" || ln(el) === "deleteEnd") deleted = deletionDelta(el, deleted);
|
|
1762
|
+
deletedControls.set(el, deleted > 0);
|
|
1763
|
+
}
|
|
1764
|
+
};
|
|
1765
|
+
for (const ch of elements(p)) {
|
|
1766
|
+
if (ln(ch) === "run") for (const el of elements(ch)) scan(el, depth + 2);
|
|
1767
|
+
else if (ln(ch) === "deleteBegin" || ln(ch) === "deleteEnd") scan(ch, depth + 1);
|
|
1768
|
+
}
|
|
1769
|
+
}
|
|
1770
|
+
function nested(el, depth2) {
|
|
1771
|
+
if (depth2 > 64) return;
|
|
1772
|
+
for (const ch of elements(el)) {
|
|
1773
|
+
if (ln(ch) === "subList") prepareDeletedRanges(ch, depth2 + 1);
|
|
1774
|
+
else nested(ch, depth2 + 1);
|
|
1775
|
+
}
|
|
1776
|
+
}
|
|
1777
|
+
nested(root, depth);
|
|
1778
|
+
}
|
|
1739
1779
|
function buildPara(p) {
|
|
1740
1780
|
const chars = [];
|
|
1741
1781
|
const objs = [];
|
|
1742
1782
|
let segs = [];
|
|
1783
|
+
let deleted = deletedStarts.get(p) ?? 0;
|
|
1743
1784
|
for (const runEl of elements(p)) {
|
|
1744
1785
|
const tag = ln(runEl);
|
|
1745
1786
|
if (tag === "run") {
|
|
@@ -1747,7 +1788,9 @@ function buildPara(p) {
|
|
|
1747
1788
|
for (const ch of elements(runEl)) {
|
|
1748
1789
|
const cn = ln(ch);
|
|
1749
1790
|
if (cn === "t") {
|
|
1791
|
+
const start = chars.length;
|
|
1750
1792
|
pushTextSlots(ch, chars, prId, 0);
|
|
1793
|
+
if (deleted) for (let i = start; i < chars.length; i++) chars[i] = { ch: "", prId };
|
|
1751
1794
|
} else if (OBJ_TAGS.has(cn)) {
|
|
1752
1795
|
const sz = findChildByLocalName(ch, "sz");
|
|
1753
1796
|
const pos = findChildByLocalName(ch, "pos");
|
|
@@ -1755,7 +1798,7 @@ function buildPara(p) {
|
|
|
1755
1798
|
const h = num(sz, "height") || num(findChildByLocalName(ch, "curSz"), "height") || num(findChildByLocalName(ch, "orgSz"), "height");
|
|
1756
1799
|
const inline = pos?.getAttribute("treatAsChar") === "1";
|
|
1757
1800
|
const om = inline && cn === "tbl" ? findChildByLocalName(ch, "outMargin") : null;
|
|
1758
|
-
objs.push({
|
|
1801
|
+
if (!deleted) objs.push({
|
|
1759
1802
|
el: ch,
|
|
1760
1803
|
tag: cn,
|
|
1761
1804
|
index: chars.length,
|
|
@@ -1767,9 +1810,12 @@ function buildPara(p) {
|
|
|
1767
1810
|
});
|
|
1768
1811
|
pushFillers(chars, 8, prId);
|
|
1769
1812
|
} else {
|
|
1813
|
+
if (cn === "ctrl" || cn === "deleteBegin" || cn === "deleteEnd") deleted = deletionDelta(ch, deleted);
|
|
1770
1814
|
pushFillers(chars, 8, prId);
|
|
1771
1815
|
}
|
|
1772
1816
|
}
|
|
1817
|
+
} else if (tag === "deleteBegin" || tag === "deleteEnd") {
|
|
1818
|
+
deleted = deletionDelta(runEl, deleted);
|
|
1773
1819
|
} else if (tag === "linesegarray") {
|
|
1774
1820
|
segs = elements(runEl).filter((s) => ln(s) === "lineseg").map((s) => ({
|
|
1775
1821
|
textpos: num(s, "textpos"),
|
|
@@ -2106,18 +2152,179 @@ var RegionCollector = class {
|
|
|
2106
2152
|
}
|
|
2107
2153
|
};
|
|
2108
2154
|
|
|
2155
|
+
// src/render/page-stories.ts
|
|
2156
|
+
function pageStories(root, masters, paraPages, pageCount, pageBase, geom) {
|
|
2157
|
+
const secPr = findFirst(root, "secPr"), visibility = secPr && findChildByLocalName(secPr, "visibility");
|
|
2158
|
+
const pagePr = secPr && findChildByLocalName(secPr, "pagePr"), margin = pagePr && findChildByLocalName(pagePr, "margin");
|
|
2159
|
+
const declarations = [];
|
|
2160
|
+
const hidden = /* @__PURE__ */ new Map();
|
|
2161
|
+
for (const p of elements(root)) if (ln(p) === "p") {
|
|
2162
|
+
const page = paraPages.get(p)?.[0] ?? 0;
|
|
2163
|
+
for (const run of elements(p)) if (ln(run) === "run") {
|
|
2164
|
+
for (const ctrl of elements(run)) if (ln(ctrl) === "ctrl") {
|
|
2165
|
+
for (const el of elements(ctrl)) {
|
|
2166
|
+
if (isDeletedControl(el)) continue;
|
|
2167
|
+
const kind = ln(el);
|
|
2168
|
+
if (kind === "header" || kind === "footer") declarations.push({ el, page, kind });
|
|
2169
|
+
else if (kind === "pageHiding") {
|
|
2170
|
+
const kinds = hidden.get(page) ?? /* @__PURE__ */ new Set();
|
|
2171
|
+
for (const name of ["Header", "Footer", "MasterPage"]) if (num(el, `hide${name}`)) kinds.add(name);
|
|
2172
|
+
hidden.set(page, kinds);
|
|
2173
|
+
}
|
|
2174
|
+
}
|
|
2175
|
+
}
|
|
2176
|
+
}
|
|
2177
|
+
}
|
|
2178
|
+
const parity = (type, n) => type === "BOTH" || type === "ODD" && n % 2 === 1 || type === "EVEN" && n % 2 === 0;
|
|
2179
|
+
const out = [];
|
|
2180
|
+
for (let page = 0; page < pageCount; page++) {
|
|
2181
|
+
const n = pageBase + page + 1;
|
|
2182
|
+
const hides = (name) => hidden.get(page)?.has(name) === true || page === 0 && num(visibility, `hideFirst${name}`) !== 0;
|
|
2183
|
+
if (!hides("MasterPage")) {
|
|
2184
|
+
const matching = masters.filter((m) => m.getAttribute("type") === (n % 2 ? "ODD" : "EVEN"));
|
|
2185
|
+
const both = masters.filter((m) => (m.getAttribute("type") || "BOTH") === "BOTH");
|
|
2186
|
+
const normal = (matching.length ? matching : both).slice(-1);
|
|
2187
|
+
const specific = masters.filter((m) => m.getAttribute("type") === "LAST_PAGE" ? page === pageCount - 1 : m.getAttribute("type") === "OPTIONAL_PAGE" && num(m, "pageNumber") === page + 1);
|
|
2188
|
+
const special = specific.slice(-1);
|
|
2189
|
+
const selected = special.length && !num(special[0], "pageDuplicate") ? special : [...normal, ...special];
|
|
2190
|
+
for (const master of selected) {
|
|
2191
|
+
const sub = findChildByLocalName(master, "subList");
|
|
2192
|
+
if (sub) out.push({ sub, page, x: geom.ML, y: geom.MT, width: geom.BODY_W, layer: num(master, "pageFront") ? 2 : -2 });
|
|
2193
|
+
}
|
|
2194
|
+
}
|
|
2195
|
+
for (const kind of ["header", "footer"]) {
|
|
2196
|
+
if (hides(kind === "header" ? "Header" : "Footer")) continue;
|
|
2197
|
+
const eligible = declarations.filter((d) => d.kind === kind && d.page <= page && parity(d.el.getAttribute("applyPageType") || "BOTH", n));
|
|
2198
|
+
const decl = eligible[eligible.length - 1];
|
|
2199
|
+
const sub = decl && findChildByLocalName(decl.el, "subList");
|
|
2200
|
+
if (sub) out.push({ sub, page, x: geom.ML, y: kind === "header" ? num(margin, "top", 5668) : geom.PH - num(margin, "bottom", 4252) - num(margin, "footer"), width: geom.BODY_W });
|
|
2201
|
+
}
|
|
2202
|
+
}
|
|
2203
|
+
return out;
|
|
2204
|
+
}
|
|
2205
|
+
|
|
2206
|
+
// src/render/shape-geometry.ts
|
|
2207
|
+
var pt = (u) => String(Math.round(u) / 100);
|
|
2208
|
+
var esc = (s) => s.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g, "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
2209
|
+
var SHAPE_TAGS = /* @__PURE__ */ new Set(["rect", "ellipse", "line", "polygon", "curv", "curve", "arc"]);
|
|
2210
|
+
function rotatedBounds(box, rotations) {
|
|
2211
|
+
if (!rotations.length) return box;
|
|
2212
|
+
let points = [[box.x, box.y], [box.x + box.w, box.y], [box.x + box.w, box.y + box.h], [box.x, box.y + box.h]];
|
|
2213
|
+
for (let i = rotations.length - 1; i >= 0; i--) {
|
|
2214
|
+
const { angle, cx, cy } = rotations[i];
|
|
2215
|
+
const a = angle * Math.PI / 180, c = Math.cos(a), s = Math.sin(a);
|
|
2216
|
+
points = points.map(([x2, y2]) => [cx + c * (x2 - cx) - s * (y2 - cy), cy + s * (x2 - cx) + c * (y2 - cy)]);
|
|
2217
|
+
}
|
|
2218
|
+
const x = Math.min(...points.map((p) => p[0])), y = Math.min(...points.map((p) => p[1]));
|
|
2219
|
+
return { x, y, w: Math.max(...points.map((p) => p[0])) - x, h: Math.max(...points.map((p) => p[1])) - y };
|
|
2220
|
+
}
|
|
2221
|
+
function objectGeometry(el, x, y, w, h) {
|
|
2222
|
+
const rot = findChildByLocalName(el, "rotationInfo");
|
|
2223
|
+
const angle = num(rot, "angle") % 360;
|
|
2224
|
+
if (!angle) return { x, y, w, h, bbox: { x, y, w, h }, transform: "" };
|
|
2225
|
+
const org = findChildByLocalName(el, "orgSz");
|
|
2226
|
+
const cx = x + num(rot, "centerX", num(org, "width", w) / 2) * (w / (num(org, "width") || w || 1));
|
|
2227
|
+
const cy = y + num(rot, "centerY", num(org, "height", h) / 2) * (h / (num(org, "height") || h || 1));
|
|
2228
|
+
const rotation = { angle, cx: Math.round(cx), cy: Math.round(cy) };
|
|
2229
|
+
return { x, y, w, h, bbox: rotatedBounds({ x, y, w, h }, [rotation]), rotation, transform: `rotate(${angle} ${pt(cx)} ${pt(cy)})` };
|
|
2230
|
+
}
|
|
2231
|
+
function shapeFill(el, defs, images, warn) {
|
|
2232
|
+
const brush = findChildByLocalName(el, "fillBrush");
|
|
2233
|
+
const win = brush && findChildByLocalName(brush, "winBrush");
|
|
2234
|
+
const face = win?.getAttribute("faceColor");
|
|
2235
|
+
if (face && face.toLowerCase() !== "none") return esc(face);
|
|
2236
|
+
const grad = brush && findChildByLocalName(brush, "gradation");
|
|
2237
|
+
if (grad) {
|
|
2238
|
+
const colors = elements(grad).filter((c) => ln(c) === "color").map((c) => c.getAttribute("value") || "#000000");
|
|
2239
|
+
if (!colors.length) return "none";
|
|
2240
|
+
const type = grad.getAttribute("type") ?? "LINEAR";
|
|
2241
|
+
if (type !== "LINEAR" && type !== "RADIAL") {
|
|
2242
|
+
warn(`gradient:${type}`, `\uADF8\uB77C\uB370\uC774\uC158(${type}) \uBBF8\uC9C0\uC6D0 \u2014 \uCCAB \uC0C9\uC73C\uB85C \uCC44\uC6C0`);
|
|
2243
|
+
return esc(colors[0]);
|
|
2244
|
+
}
|
|
2245
|
+
const id = `paint${defs.length}`;
|
|
2246
|
+
const opacity = Math.max(0, Math.min(1, 1 - num(grad, "alpha") / 255));
|
|
2247
|
+
const stops = colors.map((color, i) => `<stop offset="${colors.length === 1 ? 0 : i / (colors.length - 1)}" stop-color="${esc(color)}" stop-opacity="${opacity}"/>`).join("");
|
|
2248
|
+
if (type === "RADIAL") defs.push(`<radialGradient id="${id}" cx="${num(grad, "centerX", 50)}%" cy="${num(grad, "centerY", 50)}%">${stops}</radialGradient>`);
|
|
2249
|
+
else {
|
|
2250
|
+
const a = num(grad, "angle") * Math.PI / 180, dx = Math.cos(a) / 2, dy = -Math.sin(a) / 2;
|
|
2251
|
+
defs.push(`<linearGradient id="${id}" x1="${0.5 - dx}" y1="${0.5 - dy}" x2="${0.5 + dx}" y2="${0.5 + dy}">${stops}</linearGradient>`);
|
|
2252
|
+
}
|
|
2253
|
+
return `url(#${id})`;
|
|
2254
|
+
}
|
|
2255
|
+
const imgBrush = brush && findChildByLocalName(brush, "imgBrush");
|
|
2256
|
+
const img = imgBrush && findChildByLocalName(imgBrush, "img");
|
|
2257
|
+
if (imgBrush && img) {
|
|
2258
|
+
const ref = img.getAttribute("binaryItemIDRef") ?? "";
|
|
2259
|
+
const loaded = images.get(ref);
|
|
2260
|
+
if (!loaded) {
|
|
2261
|
+
warn(`brush-image:${ref}`, `\uADF8\uB9BC \uCC44\uC6C0 \uC774\uBBF8\uC9C0(${ref}) \uC5C6\uC74C \u2014 \uCC44\uC6C0 \uC0DD\uB7B5`);
|
|
2262
|
+
return "none";
|
|
2263
|
+
}
|
|
2264
|
+
const mode = imgBrush.getAttribute("mode") ?? "TOTAL";
|
|
2265
|
+
if (mode !== "TOTAL") {
|
|
2266
|
+
warn(`brush-mode:${mode}`, `\uADF8\uB9BC \uCC44\uC6C0(${mode}) \uBBF8\uC9C0\uC6D0 \u2014 \uCC44\uC6C0 \uC0DD\uB7B5`);
|
|
2267
|
+
return "none";
|
|
2268
|
+
}
|
|
2269
|
+
if (loaded.paintId) return `url(#${loaded.paintId})`;
|
|
2270
|
+
const id = `paint${defs.length}`;
|
|
2271
|
+
defs.push(`<pattern id="${id}" width="1" height="1" patternContentUnits="objectBoundingBox"><image href="${esc(loaded.dataUri)}" width="1" height="1" preserveAspectRatio="none"/></pattern>`);
|
|
2272
|
+
loaded.paintId = id;
|
|
2273
|
+
return `url(#${id})`;
|
|
2274
|
+
}
|
|
2275
|
+
return "none";
|
|
2276
|
+
}
|
|
2277
|
+
function shapeGeometry(o, x, y, defs, images, warn) {
|
|
2278
|
+
const el = o.el, org = findChildByLocalName(el, "orgSz"), cur = findChildByLocalName(el, "curSz");
|
|
2279
|
+
const ow = num(org, "width"), oh = num(org, "height");
|
|
2280
|
+
const w = num(cur, "width") || ow || o.width, h = num(cur, "height") || oh || o.height;
|
|
2281
|
+
const sx = ow > 0 ? w / ow : 1, sy = oh > 0 ? h / oh : 1;
|
|
2282
|
+
const line = findChildByLocalName(el, "lineShape"), style = line?.getAttribute("style") ?? "SOLID";
|
|
2283
|
+
const color = esc(line?.getAttribute("color") || "#000000");
|
|
2284
|
+
const strokeW = style === "NONE" ? 0 : Math.max(0.2, num(line, "width", 33) / 100 * 2.834645);
|
|
2285
|
+
const dash = /DASH|DOT/.test(style) ? ` stroke-dasharray="${style.includes("DOT") ? "1,1.5" : "3,1.5"}"` : "";
|
|
2286
|
+
const stroke = strokeW ? ` stroke="${color}" stroke-width="${strokeW.toFixed(2)}"${dash}` : "";
|
|
2287
|
+
const fill = ` fill="${shapeFill(el, defs, images, warn)}"`;
|
|
2288
|
+
let svg = "";
|
|
2289
|
+
if (o.tag === "rect") svg = `<rect x="${pt(x)}" y="${pt(y)}" width="${pt(w)}" height="${pt(h)}"${fill}${stroke}/>`;
|
|
2290
|
+
else if (o.tag === "ellipse") svg = `<ellipse cx="${pt(x + w / 2)}" cy="${pt(y + h / 2)}" rx="${pt(w / 2)}" ry="${pt(h / 2)}"${fill}${stroke}/>`;
|
|
2291
|
+
else if (o.tag === "line") {
|
|
2292
|
+
const s = findChildByLocalName(el, "startPt"), e = findChildByLocalName(el, "endPt");
|
|
2293
|
+
svg = `<line x1="${pt(x + num(s, "x") * sx)}" y1="${pt(y + num(s, "y") * sy)}" x2="${pt(x + num(e, "x") * sx)}" y2="${pt(y + num(e, "y") * sy)}" stroke="${color}" stroke-width="${(strokeW || 0.3).toFixed(2)}"${dash}/>`;
|
|
2294
|
+
} else if (o.tag === "polygon" || o.tag === "curv") {
|
|
2295
|
+
const pts = elements(el).filter((c) => ln(c) === "pt").map((c) => `${pt(x + num(c, "x") * sx)},${pt(y + num(c, "y") * sy)}`);
|
|
2296
|
+
if (pts.length >= 2) svg = `<polygon points="${pts.join(" ")}"${fill}${stroke}/>`;
|
|
2297
|
+
} else if (o.tag === "curve") {
|
|
2298
|
+
const segs = elements(el).filter((c) => ln(c) === "seg");
|
|
2299
|
+
if (segs.some((s) => s.getAttribute("type") !== "LINE")) warn("curve:bezier", "\uBE44\uC120\uD615 \uACE1\uC120 \uB80C\uB354 \uBBF8\uC9C0\uC6D0 \u2014 \uC0DD\uB7B5");
|
|
2300
|
+
else if (segs.length) {
|
|
2301
|
+
let path = "", lastX, lastY;
|
|
2302
|
+
for (const s of segs) {
|
|
2303
|
+
const x1 = num(s, "x1"), y1 = num(s, "y1"), x2 = num(s, "x2"), y2 = num(s, "y2");
|
|
2304
|
+
if (x1 !== lastX || y1 !== lastY) path += `M${pt(x + x1 * sx)} ${pt(y + y1 * sy)}`;
|
|
2305
|
+
path += `L${pt(x + x2 * sx)} ${pt(y + y2 * sy)}`;
|
|
2306
|
+
lastX = x2;
|
|
2307
|
+
lastY = y2;
|
|
2308
|
+
}
|
|
2309
|
+
svg = `<path d="${path}"${fill}${stroke}/>`;
|
|
2310
|
+
}
|
|
2311
|
+
} else if (o.tag === "arc") svg = `<ellipse cx="${pt(x + w / 2)}" cy="${pt(y + h / 2)}" rx="${pt(w / 2)}" ry="${pt(h / 2)}" fill="none"${stroke || ` stroke="${color}" stroke-width="0.3"`}/>`;
|
|
2312
|
+
return { ...objectGeometry(el, x, y, w, h), svg };
|
|
2313
|
+
}
|
|
2314
|
+
|
|
2109
2315
|
// src/render/svg-render.ts
|
|
2110
2316
|
function escapeXml(s) {
|
|
2111
2317
|
return s.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g, "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
2112
2318
|
}
|
|
2113
|
-
var
|
|
2319
|
+
var pt2 = (u) => String(Math.round(u) / 100);
|
|
2114
2320
|
var ptNum = (u) => Math.round(u) / 100;
|
|
2115
2321
|
function pageNo(ctx) {
|
|
2116
2322
|
return ctx.pageBase + ctx.page + 1;
|
|
2117
2323
|
}
|
|
2118
2324
|
function bboxOf(ctx, x, y, w, h) {
|
|
2119
|
-
const
|
|
2120
|
-
|
|
2325
|
+
const b = rotatedBounds({ x, y, w, h }, ctx.regionRotations);
|
|
2326
|
+
const clippedH = Math.max(0, Math.min(b.h, ctx.pageH - b.y));
|
|
2327
|
+
return { page: pageNo(ctx), x: ptNum(b.x), y: ptNum(b.y), width: ptNum(Math.max(0, b.w)), height: ptNum(clippedH) };
|
|
2121
2328
|
}
|
|
2122
2329
|
function regionOpenTag(id, type, page) {
|
|
2123
2330
|
return `<g data-kordoc-id="${id}" data-kordoc-type="${type}" data-kordoc-page="${page}">`;
|
|
@@ -2210,7 +2417,10 @@ function drawPara(p, ox, oy, areaW, ctx, depth, segPages) {
|
|
|
2210
2417
|
if (m.chars.some((c) => c.ch !== "")) {
|
|
2211
2418
|
warnOnce(ctx, "no-lineseg", "\uC870\uD310 \uCE90\uC2DC \uC5C6\uB294 \uBB38\uB2E8 \uD14D\uC2A4\uD2B8 \uC0DD\uB7B5 \u2014 reflow \uC635\uC158\uC73C\uB85C \uD569\uC131 \uAC00\uB2A5");
|
|
2212
2419
|
}
|
|
2213
|
-
for (const o of m.objs)
|
|
2420
|
+
for (const o of m.objs) {
|
|
2421
|
+
const { x, y } = o.inline ? { x: ox, y: oy } : anchorObject(o, ox, oy, 0, areaW, ctx);
|
|
2422
|
+
drawObject(o, x, y, 0, areaW, ctx, depth);
|
|
2423
|
+
}
|
|
2214
2424
|
return;
|
|
2215
2425
|
}
|
|
2216
2426
|
const plans = planLines(m, ctx.styles);
|
|
@@ -2269,13 +2479,13 @@ function drawPara(p, ox, oy, areaW, ctx, depth, segPages) {
|
|
|
2269
2479
|
const renderSeg = (text, cx, hit) => {
|
|
2270
2480
|
const sw = measureTextWidth(text, st.height, st.ratio, { spacingPct: st.spacing, faceClass: faceClassOf(st.face) }) * scale;
|
|
2271
2481
|
if (hit) {
|
|
2272
|
-
emit(ctx, `<rect x="${
|
|
2482
|
+
emit(ctx, `<rect x="${pt2(cx)}" y="${pt2(oy + seg.vertpos)}" width="${pt2(sw)}" height="${pt2(seg.textheight)}" fill="#ffd54f" fill-opacity="0.45"/>`);
|
|
2273
2483
|
}
|
|
2274
2484
|
if (text.trim().length > 0) {
|
|
2275
|
-
const attrs = [`x="${
|
|
2485
|
+
const attrs = [`x="${pt2(cx)}"`, `y="${pt2(y)}"`, `font-size="${pt2(st.height)}"`];
|
|
2276
2486
|
if (st.fontFamily) attrs.push(`font-family="${escapeXml(st.fontFamily)}"`);
|
|
2277
2487
|
if ([...text].length > 1 && sw > 50) {
|
|
2278
|
-
attrs.push(`textLength="${
|
|
2488
|
+
attrs.push(`textLength="${pt2(sw)}"`, `lengthAdjust="${scale < 1 ? "spacingAndGlyphs" : "spacing"}"`);
|
|
2279
2489
|
}
|
|
2280
2490
|
if (st.bold) attrs.push(`font-weight="bold"`);
|
|
2281
2491
|
if (st.italic) attrs.push(`font-style="italic"`);
|
|
@@ -2377,6 +2587,19 @@ function anchorObject(o, ox, oy, baseV, areaW, ctx) {
|
|
|
2377
2587
|
return { x, y };
|
|
2378
2588
|
}
|
|
2379
2589
|
function drawObject(o, x, y, baseV, areaW, ctx, depth) {
|
|
2590
|
+
if (!o.inline && depth === 0 && ctx.paintJobs) {
|
|
2591
|
+
const wrap = o.el.getAttribute("textWrap");
|
|
2592
|
+
const layer = wrap === "BEHIND_TEXT" ? -1 : wrap === "IN_FRONT_OF_TEXT" ? 1 : 0;
|
|
2593
|
+
const page = ctx.page, parents = [...ctx.parentStack];
|
|
2594
|
+
ctx.paintJobs.push({ page, layer, z: num(o.el, "zOrder"), draw: () => {
|
|
2595
|
+
ctx.page = page;
|
|
2596
|
+
const saved = ctx.parentStack;
|
|
2597
|
+
ctx.parentStack = parents;
|
|
2598
|
+
drawObject(o, x, y, baseV, areaW, ctx, depth);
|
|
2599
|
+
ctx.parentStack = saved;
|
|
2600
|
+
} });
|
|
2601
|
+
return;
|
|
2602
|
+
}
|
|
2380
2603
|
if (o.tag === "tbl") drawTable(o.el, x, y, ctx, depth + 1);
|
|
2381
2604
|
else if (o.tag === "pic") drawPic(o.el, x, y, ctx);
|
|
2382
2605
|
else if (o.tag === "container") {
|
|
@@ -2396,62 +2619,29 @@ function drawObject(o, x, y, baseV, areaW, ctx, depth) {
|
|
|
2396
2619
|
warnOnce(ctx, `shape:${o.tag}`, `\uAC1C\uCCB4(${o.tag}) \uB80C\uB354 \uBBF8\uC9C0\uC6D0 \u2014 \uC0DD\uB7B5`);
|
|
2397
2620
|
}
|
|
2398
2621
|
}
|
|
2399
|
-
var SHAPE_TAGS = /* @__PURE__ */ new Set(["rect", "ellipse", "line", "polygon", "curv", "arc"]);
|
|
2400
|
-
function shapeStrokePt(v) {
|
|
2401
|
-
return Math.max(0.2, v / 100 * 2.834645);
|
|
2402
|
-
}
|
|
2403
2622
|
function drawShape(o, x, y, ctx, depth) {
|
|
2404
|
-
const
|
|
2405
|
-
const
|
|
2406
|
-
|
|
2407
|
-
const ow = num(orgSz, "width"), oh = num(orgSz, "height");
|
|
2408
|
-
const w = num(curSz, "width") || ow || o.width;
|
|
2409
|
-
const h = num(curSz, "height") || oh || o.height;
|
|
2410
|
-
const sx = ow > 0 ? w / ow : 1;
|
|
2411
|
-
const sy = oh > 0 ? h / oh : 1;
|
|
2412
|
-
const lineShape = findChildByLocalName(el, "lineShape");
|
|
2413
|
-
const lstyle = lineShape?.getAttribute("style") ?? "SOLID";
|
|
2414
|
-
const strokeCol = lineShape?.getAttribute("color") || "#000000";
|
|
2415
|
-
const hasStroke = lstyle !== "NONE";
|
|
2416
|
-
const strokeW = hasStroke ? shapeStrokePt(lineShape ? num(lineShape, "width") : 33) : 0;
|
|
2417
|
-
const dash = /DASH|DOT/.test(lstyle) ? ` stroke-dasharray="${lstyle.includes("DOT") ? "1,1.5" : "3,1.5"}"` : "";
|
|
2418
|
-
const strokeAttr = hasStroke ? ` stroke="${escapeXml(strokeCol)}" stroke-width="${strokeW.toFixed(2)}"${dash}` : "";
|
|
2419
|
-
const fillBrush = findChildByLocalName(el, "fillBrush");
|
|
2420
|
-
const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
|
|
2421
|
-
const face = winBrush?.getAttribute("faceColor");
|
|
2422
|
-
const fill = face && face.toLowerCase() !== "none" ? face : "none";
|
|
2423
|
-
const fillAttr = ` fill="${fill === "none" ? "none" : escapeXml(fill)}"`;
|
|
2623
|
+
const geometry = shapeGeometry(o, x, y, ctx.defs, ctx.images, (key, msg) => warnOnce(ctx, key, msg));
|
|
2624
|
+
const b = geometry;
|
|
2625
|
+
if (geometry.rotation) ctx.regionRotations.push(geometry.rotation);
|
|
2424
2626
|
ctx.stats.shapes++;
|
|
2425
|
-
const shapeId = ctx.regions.add("shape", bboxOf(ctx, x, y, w, h), { parentId: parentId(ctx) });
|
|
2627
|
+
const shapeId = ctx.regions.add("shape", bboxOf(ctx, b.x, b.y, b.w, b.h), { parentId: parentId(ctx) });
|
|
2426
2628
|
emit(ctx, regionOpenTag(shapeId, "shape", pageNo(ctx)));
|
|
2427
2629
|
ctx.parentStack.push(shapeId);
|
|
2428
|
-
if (
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
emit(ctx, `<ellipse cx="${pt(x + w / 2)}" cy="${pt(y + h / 2)}" rx="${pt(w / 2)}" ry="${pt(h / 2)}"${fillAttr}${strokeAttr}/>`);
|
|
2432
|
-
} else if (o.tag === "line") {
|
|
2433
|
-
const s = findChildByLocalName(el, "startPt"), e = findChildByLocalName(el, "endPt");
|
|
2434
|
-
const x1 = x + num(s, "x") * sx, y1 = y + num(s, "y") * sy;
|
|
2435
|
-
const x2 = x + num(e, "x") * sx, y2 = y + num(e, "y") * sy;
|
|
2436
|
-
emit(ctx, `<line x1="${pt(x1)}" y1="${pt(y1)}" x2="${pt(x2)}" y2="${pt(y2)}" stroke="${escapeXml(strokeCol)}" stroke-width="${(strokeW || 0.3).toFixed(2)}"${dash}/>`);
|
|
2437
|
-
} else if (o.tag === "polygon" || o.tag === "curv") {
|
|
2438
|
-
const pts = [];
|
|
2439
|
-
for (const c of elements(el)) if (ln(c) === "pt") pts.push(`${pt(x + num(c, "x") * sx)},${pt(y + num(c, "y") * sy)}`);
|
|
2440
|
-
if (pts.length >= 2) emit(ctx, `<polygon points="${pts.join(" ")}"${fillAttr}${strokeAttr}/>`);
|
|
2441
|
-
} else if (o.tag === "arc") {
|
|
2442
|
-
emit(ctx, `<ellipse cx="${pt(x + w / 2)}" cy="${pt(y + h / 2)}" rx="${pt(w / 2)}" ry="${pt(h / 2)}" fill="none"${strokeAttr || ` stroke="${escapeXml(strokeCol)}" stroke-width="0.3"`}/>`);
|
|
2443
|
-
}
|
|
2444
|
-
const dt = findChildByLocalName(el, "drawText");
|
|
2630
|
+
if (geometry.transform) emit(ctx, `<g transform="${geometry.transform}">`);
|
|
2631
|
+
emit(ctx, geometry.svg);
|
|
2632
|
+
const dt = findChildByLocalName(o.el, "drawText");
|
|
2445
2633
|
const sub = dt ? findChildByLocalName(dt, "subList") : null;
|
|
2446
2634
|
if (sub) {
|
|
2447
|
-
for (const p of elements(sub)) if (ln(p) === "p") drawPara(p, x, y, w, ctx, depth + 1);
|
|
2635
|
+
for (const p of elements(sub)) if (ln(p) === "p") drawPara(p, x, y, geometry.w, ctx, depth + 1);
|
|
2448
2636
|
}
|
|
2637
|
+
if (geometry.rotation) ctx.regionRotations.pop();
|
|
2638
|
+
if (geometry.transform) emit(ctx, "</g>");
|
|
2449
2639
|
ctx.parentStack.pop();
|
|
2450
2640
|
emit(ctx, "</g>");
|
|
2451
2641
|
}
|
|
2452
2642
|
function edgeLine(x1, y1, x2, y2, e) {
|
|
2453
2643
|
const dash = /DASH|DOT/.test(e.type) ? ` stroke-dasharray="${e.type.includes("DOT") ? "1,1.5" : "3,1.5"}"` : "";
|
|
2454
|
-
return `<line x1="${
|
|
2644
|
+
return `<line x1="${pt2(x1)}" y1="${pt2(y1)}" x2="${pt2(x2)}" y2="${pt2(y2)}" stroke="${escapeXml(e.color)}" stroke-width="${e.widthPt.toFixed(2)}"${dash}/>`;
|
|
2455
2645
|
}
|
|
2456
2646
|
function drawTable(tbl, tx, ty, ctx, depth) {
|
|
2457
2647
|
if (depth > 16) {
|
|
@@ -2486,7 +2676,7 @@ function drawTable(tbl, tx, ty, ctx, depth) {
|
|
|
2486
2676
|
}));
|
|
2487
2677
|
for (const g of geom) {
|
|
2488
2678
|
const bf = g.c.bfId != null ? ctx.styles.borderFill.get(g.c.bfId) : void 0;
|
|
2489
|
-
if (bf?.fill) emit(ctx, `<rect x="${
|
|
2679
|
+
if (bf?.fill) emit(ctx, `<rect x="${pt2(g.x)}" y="${pt2(g.y)}" width="${pt2(g.w)}" height="${pt2(g.h)}" fill="${escapeXml(bf.fill)}"/>`);
|
|
2490
2680
|
}
|
|
2491
2681
|
for (const g of geom) {
|
|
2492
2682
|
const { c } = g;
|
|
@@ -2531,7 +2721,7 @@ function drawPic(pic, x, y, ctx) {
|
|
|
2531
2721
|
const imgId = ctx.regions.add("image", bboxOf(ctx, x, y, w, h), { sourceId: ref ?? void 0, parentId: parentId(ctx) });
|
|
2532
2722
|
emit(ctx, regionOpenTag(imgId, "image", pageNo(ctx)));
|
|
2533
2723
|
if (!loaded) {
|
|
2534
|
-
emit(ctx, `<rect x="${
|
|
2724
|
+
emit(ctx, `<rect x="${pt2(x)}" y="${pt2(y)}" width="${pt2(w)}" height="${pt2(h)}" fill="#eee" stroke="#c00" stroke-width="0.5"/>`);
|
|
2535
2725
|
warnOnce(ctx, `img:${ref}`, `\uC774\uBBF8\uC9C0 \uBC14\uC774\uB108\uB9AC \uB204\uB77D: ${ref ?? "(ref \uC5C6\uC74C)"}`);
|
|
2536
2726
|
emit(ctx, "</g>");
|
|
2537
2727
|
return;
|
|
@@ -2550,10 +2740,10 @@ function drawPic(pic, x, y, ctx) {
|
|
|
2550
2740
|
if (cropped) {
|
|
2551
2741
|
emit(
|
|
2552
2742
|
ctx,
|
|
2553
|
-
`<svg x="${
|
|
2743
|
+
`<svg x="${pt2(x)}" y="${pt2(y)}" width="${pt2(w)}" height="${pt2(h)}" viewBox="${pt2(cl)} ${pt2(ct)} ${pt2(cr - cl)} ${pt2(cb - ct)}" preserveAspectRatio="none"><use href="#${symId}" x="0" y="0" width="${pt2(refW)}" height="${pt2(refH)}"/></svg>`
|
|
2554
2744
|
);
|
|
2555
2745
|
} else {
|
|
2556
|
-
emit(ctx, `<use href="#${symId}" x="${
|
|
2746
|
+
emit(ctx, `<use href="#${symId}" x="${pt2(x)}" y="${pt2(y)}" width="${pt2(w)}" height="${pt2(h)}"/>`);
|
|
2557
2747
|
}
|
|
2558
2748
|
emit(ctx, "</g>");
|
|
2559
2749
|
}
|
|
@@ -2581,8 +2771,9 @@ function readSectionGeom(root) {
|
|
|
2581
2771
|
const BODY_W = PW - ML - num(margin, "right", 8504);
|
|
2582
2772
|
return { PW, PH, ML, MT, BODY_W, BODY_H };
|
|
2583
2773
|
}
|
|
2584
|
-
function renderSectionToPages(root, geom, ctxBase, doReflow, reflowMode) {
|
|
2774
|
+
function renderSectionToPages(root, geom, ctxBase, doReflow, reflowMode, masters = [], hasDeletionMarkers = true) {
|
|
2585
2775
|
const { PW, PH, ML, MT, BODY_W, BODY_H } = geom;
|
|
2776
|
+
if (hasDeletionMarkers) prepareDeletedRanges(root);
|
|
2586
2777
|
if (doReflow) reflowSection(root, ctxBase.styles, { BODY_W, BODY_H }, reflowMode);
|
|
2587
2778
|
const colPr = findFirst(root, "colPr");
|
|
2588
2779
|
const multiCol = num(colPr, "colCount", 1) > 1;
|
|
@@ -2620,12 +2811,35 @@ function renderSectionToPages(root, geom, ctxBase, doReflow, reflowMode) {
|
|
|
2620
2811
|
pages: Array.from({ length: nPages }, () => []),
|
|
2621
2812
|
page: 0,
|
|
2622
2813
|
geom,
|
|
2623
|
-
pageH
|
|
2814
|
+
pageH,
|
|
2815
|
+
paintJobs: [],
|
|
2816
|
+
regionRotations: []
|
|
2624
2817
|
};
|
|
2818
|
+
for (const story of pageStories(root, masters, paraSegPages, nPages, ctx.pageBase, geom)) {
|
|
2819
|
+
prepareDeletedRanges(story.sub);
|
|
2820
|
+
if (doReflow) reflowSection(story.sub, ctx.styles, { BODY_W: story.width, BODY_H: 0 }, reflowMode);
|
|
2821
|
+
const draw = () => {
|
|
2822
|
+
ctx.page = story.page;
|
|
2823
|
+
for (const p of elements(story.sub)) if (ln(p) === "p") drawPara(p, story.x, story.y, story.width, ctx, 0);
|
|
2824
|
+
};
|
|
2825
|
+
if (story.layer !== void 0) ctx.paintJobs.push({ page: story.page, layer: story.layer, z: 0, draw });
|
|
2826
|
+
else draw();
|
|
2827
|
+
}
|
|
2828
|
+
ctx.page = 0;
|
|
2625
2829
|
for (const p of elements(root)) {
|
|
2626
2830
|
if (ln(p) !== "p") continue;
|
|
2627
2831
|
drawPara(p, ML, MT, BODY_W, ctx, 0, paraSegPages.get(p));
|
|
2628
2832
|
}
|
|
2833
|
+
const normal = ctx.pages;
|
|
2834
|
+
const jobs = ctx.paintJobs;
|
|
2835
|
+
ctx.paintJobs = null;
|
|
2836
|
+
const behind = Array.from({ length: nPages }, () => []);
|
|
2837
|
+
const front = Array.from({ length: nPages }, () => []);
|
|
2838
|
+
for (const job of jobs.sort((a, b) => a.layer - b.layer || a.z - b.z)) {
|
|
2839
|
+
ctx.pages = job.layer < 0 ? behind : front;
|
|
2840
|
+
job.draw();
|
|
2841
|
+
}
|
|
2842
|
+
ctx.pages = normal.map((buf, page) => [...behind[page], ...buf, ...front[page]]);
|
|
2629
2843
|
return { pages: ctx.pages, pageH };
|
|
2630
2844
|
}
|
|
2631
2845
|
function renderSectionRoots(sections, input) {
|
|
@@ -2643,9 +2857,9 @@ function renderSectionRoots(sections, input) {
|
|
|
2643
2857
|
pageBase: 0
|
|
2644
2858
|
};
|
|
2645
2859
|
const rendered = [];
|
|
2646
|
-
for (const { root, index } of sections) {
|
|
2860
|
+
for (const { root, index, masterPages, hasDeletionMarkers } of sections) {
|
|
2647
2861
|
const geom = readSectionGeom(root);
|
|
2648
|
-
const { pages, pageH } = renderSectionToPages(root, geom, ctxBase, input.reflow, input.reflowMode);
|
|
2862
|
+
const { pages, pageH } = renderSectionToPages(root, geom, ctxBase, input.reflow, input.reflowMode, masterPages, hasDeletionMarkers);
|
|
2649
2863
|
rendered.push({ pages, PW: geom.PW, pageH, clipId: `pgclip${index}` });
|
|
2650
2864
|
ctxBase.pageBase += pages.length;
|
|
2651
2865
|
}
|
|
@@ -2675,6 +2889,17 @@ async function renderHwpxInternal(input, options) {
|
|
|
2675
2889
|
if (xml.length > MAX_DECOMPRESS_SIZE) throw new KordocError("\uC139\uC158 XML\uC774 \uD5C8\uC6A9 \uD06C\uAE30\uB97C \uCD08\uACFC");
|
|
2676
2890
|
secXmls.push(xml);
|
|
2677
2891
|
}
|
|
2892
|
+
const masterPages = /* @__PURE__ */ new Map();
|
|
2893
|
+
const masterXmls = [];
|
|
2894
|
+
for (const file of zip.file(/Contents\/masterpage[^/]*\.xml$/i)) {
|
|
2895
|
+
const xml = await file.async("string");
|
|
2896
|
+
if (xml.length > MAX_DECOMPRESS_SIZE) throw new KordocError("\uBC14\uD0D5\uCABD XML\uC774 \uD5C8\uC6A9 \uD06C\uAE30\uB97C \uCD08\uACFC");
|
|
2897
|
+
const root = createXmlParser().parseFromString(xml, "text/xml").documentElement;
|
|
2898
|
+
if (root && ln(root) === "masterPage") {
|
|
2899
|
+
masterPages.set(root.getAttribute("id") || file.name.replace(/^.*\/|\.xml$/g, ""), root);
|
|
2900
|
+
masterXmls.push(xml);
|
|
2901
|
+
}
|
|
2902
|
+
}
|
|
2678
2903
|
const binmap = /* @__PURE__ */ new Map();
|
|
2679
2904
|
const hpf = zip.file(/content\.hpf$/i)[0];
|
|
2680
2905
|
if (hpf) {
|
|
@@ -2686,7 +2911,7 @@ async function renderHwpxInternal(input, options) {
|
|
|
2686
2911
|
const MAX_TOTAL_IMAGE_BYTES = 128 * 1024 * 1024;
|
|
2687
2912
|
const images = /* @__PURE__ */ new Map();
|
|
2688
2913
|
const refs = /* @__PURE__ */ new Set();
|
|
2689
|
-
for (const xml of secXmls) for (const m of xml.matchAll(/binaryItemIDRef="([^"]+)"/g)) refs.add(m[1]);
|
|
2914
|
+
for (const xml of [...secXmls, ...masterXmls]) for (const m of xml.matchAll(/binaryItemIDRef="([^"]+)"/g)) refs.add(m[1]);
|
|
2690
2915
|
let totalImgBytes = 0;
|
|
2691
2916
|
for (const ref of refs) {
|
|
2692
2917
|
if (images.size >= MAX_IMAGE_REFS) {
|
|
@@ -2729,7 +2954,9 @@ async function renderHwpxInternal(input, options) {
|
|
|
2729
2954
|
warnings.push(`\uAD6C\uC5ED ${si} XML \uD30C\uC2F1 \uC2E4\uD328 \u2014 \uC0DD\uB7B5`);
|
|
2730
2955
|
continue;
|
|
2731
2956
|
}
|
|
2732
|
-
|
|
2957
|
+
const secPr = findFirst(root, "secPr");
|
|
2958
|
+
const referenced = secPr ? elements(secPr).filter((el) => ln(el) === "masterPage").map((el) => masterPages.get(el.getAttribute("idRef") || "")).filter((el) => !!el) : [];
|
|
2959
|
+
roots.push({ root, index: si, masterPages: referenced, hasDeletionMarkers: secXml.includes("deleteBegin") || secXml.includes("deleteEnd") });
|
|
2733
2960
|
}
|
|
2734
2961
|
if (roots.length === 0) {
|
|
2735
2962
|
if (noCacheSkipped) {
|
|
@@ -2749,11 +2976,11 @@ async function renderHwpxToSvg(input, options) {
|
|
|
2749
2976
|
let pageNo2 = 0;
|
|
2750
2977
|
for (const rs of r.sections) {
|
|
2751
2978
|
maxPW = Math.max(maxPW, rs.PW);
|
|
2752
|
-
clipDefs.push(`<clipPath id="${rs.clipId}"><rect x="0" y="0" width="${
|
|
2979
|
+
clipDefs.push(`<clipPath id="${rs.clipId}"><rect x="0" y="0" width="${pt2(rs.PW)}" height="${pt2(rs.pageH)}"/></clipPath>`);
|
|
2753
2980
|
for (const buf of rs.pages) {
|
|
2754
2981
|
pageNo2++;
|
|
2755
2982
|
groups.push(
|
|
2756
|
-
`<g data-page="${pageNo2}" transform="translate(0 ${
|
|
2983
|
+
`<g data-page="${pageNo2}" transform="translate(0 ${pt2(y)})"><rect width="${pt2(rs.PW)}" height="${pt2(rs.pageH)}" fill="white" stroke="#c9c7c4" stroke-width="0.75"/><g clip-path="url(#${rs.clipId})">
|
|
2757
2984
|
${buf.join("\n")}
|
|
2758
2985
|
</g></g>`
|
|
2759
2986
|
);
|
|
@@ -2761,7 +2988,7 @@ ${buf.join("\n")}
|
|
|
2761
2988
|
}
|
|
2762
2989
|
}
|
|
2763
2990
|
const totalH = Math.max(0, y - GAP);
|
|
2764
|
-
const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${
|
|
2991
|
+
const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${pt2(maxPW)} ${pt2(totalH)}" width="${pt2(maxPW)}pt" height="${pt2(totalH)}pt" font-family="${SVG_FONT_FAMILY}" xml:space="preserve">
|
|
2765
2992
|
<defs>${clipDefs.join("")}${r.defs.join("")}</defs>
|
|
2766
2993
|
${groups.join("\n")}
|
|
2767
2994
|
</svg>`;
|
|
@@ -2788,9 +3015,9 @@ function assemblePageSvgs(r, format, select) {
|
|
|
2788
3015
|
const clipId = `pgclip${pageNo2}`;
|
|
2789
3016
|
pageSvgs.set(
|
|
2790
3017
|
pageNo2,
|
|
2791
|
-
`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${
|
|
2792
|
-
<defs><clipPath id="${clipId}"><rect x="0" y="0" width="${
|
|
2793
|
-
<rect width="${
|
|
3018
|
+
`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${pt2(rs.PW)} ${pt2(rs.pageH)}" width="${pt2(rs.PW)}pt" height="${pt2(rs.pageH)}pt" font-family="${SVG_FONT_FAMILY}" xml:space="preserve" data-page="${pageNo2}">
|
|
3019
|
+
<defs><clipPath id="${clipId}"><rect x="0" y="0" width="${pt2(rs.PW)}" height="${pt2(rs.pageH)}"/></clipPath>${defs.join("")}</defs>
|
|
3020
|
+
<rect width="${pt2(rs.PW)}" height="${pt2(rs.pageH)}" fill="white"/>
|
|
2794
3021
|
<g clip-path="url(#${clipId})">
|
|
2795
3022
|
${body}
|
|
2796
3023
|
</g>
|
|
@@ -7387,4 +7614,4 @@ export {
|
|
|
7387
7614
|
cropRect,
|
|
7388
7615
|
extractRenderedRegions
|
|
7389
7616
|
};
|
|
7390
|
-
//# sourceMappingURL=chunk-
|
|
7617
|
+
//# sourceMappingURL=chunk-TMHMJUYU.js.map
|