kordoc 4.24.1 → 4.24.3
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/README.md +12 -10
- package/dist/{-TSN4SWFV.js → -Q56U3KCA.js} +11 -11
- package/dist/{chunk-LEUS275C.js → chunk-33NZN73M.js} +2 -2
- package/dist/{chunk-5EP6VFP5.js → chunk-3EWXRIPH.js} +3 -3
- package/dist/{chunk-MI25BZSU.js → chunk-42FSKT7R.js} +2 -2
- package/dist/{chunk-NAPPGU3W.js → chunk-4X73CGIL.js} +2 -2
- package/dist/{chunk-TYXXTWPH.cjs → chunk-6ZRZLV3J.cjs} +2 -2
- package/dist/chunk-6ZRZLV3J.cjs.map +1 -0
- package/dist/{chunk-6H7D4QTM.js → chunk-AEEQN6L3.js} +2 -2
- package/dist/{chunk-G7SKCXQG.js → chunk-EEXIFCXC.js} +2 -2
- package/dist/{chunk-YE4T2P6F.js → chunk-EWCJCWTT.js} +2 -2
- package/dist/{chunk-AJ3DJSO6.js → chunk-FZT34MUI.js} +4 -4
- package/dist/chunk-GS7T56RP.cjs.map +1 -1
- package/dist/{chunk-BIVO2GMU.js → chunk-HNX2I7D6.js} +2 -2
- package/dist/{chunk-JSI5T77E.cjs → chunk-HTG3VVET.cjs} +24 -24
- package/dist/chunk-HTG3VVET.cjs.map +1 -0
- package/dist/{chunk-W4P3QPSB.js → chunk-HU7POUBS.js} +2 -2
- package/dist/{chunk-RVKOFZAT.js → chunk-I2QETSZN.js} +2 -2
- package/dist/{chunk-LBPUPT6S.js → chunk-J45OVEUM.js} +203 -35
- package/dist/chunk-J45OVEUM.js.map +1 -0
- package/dist/chunk-J55UQC5H.cjs.map +1 -1
- package/dist/{chunk-4VNIEHWM.cjs → chunk-JILIA5EV.cjs} +23 -23
- package/dist/chunk-JILIA5EV.cjs.map +1 -0
- package/dist/{chunk-WYYUWBTS.js → chunk-KXHNIHLC.js} +2 -2
- package/dist/{chunk-5QBTJ4LA.cjs → chunk-N65EY5BI.cjs} +6 -6
- package/dist/chunk-N65EY5BI.cjs.map +1 -0
- package/dist/{chunk-2SMANR76.js → chunk-NKDPCALC.js} +4 -4
- package/dist/{chunk-4BCQ3FQS.js → chunk-OAOM7IEI.js} +11 -11
- package/dist/{chunk-SWCO5NP6.js → chunk-PHZDAHZC.js} +3 -3
- package/dist/{chunk-L2OJUIII.js → chunk-PMX5CPK5.js} +2 -2
- package/dist/{chunk-LEL5UBGR.js → chunk-Q2QKRE4P.js} +2 -2
- package/dist/chunk-TK3FDAEE.cjs.map +1 -1
- package/dist/{chunk-RS2Q64N5.js → chunk-TZ753B6A.js} +2 -2
- package/dist/{chunk-RIQVVWVF.cjs → chunk-VFEI2GIE.cjs} +3 -3
- package/dist/chunk-VFEI2GIE.cjs.map +1 -0
- package/dist/{chunk-B77K6J3U.js → chunk-W6O7KBOD.js} +2 -2
- package/dist/{chunk-ZR3BPESP.js → chunk-XAZ5RGVG.js} +3 -3
- package/dist/{chunk-V2GW3M2F.js → chunk-XNNMMYFO.js} +2 -2
- package/dist/{chunk-HP24FYLJ.js → chunk-XZOAE2Q7.js} +4 -4
- package/dist/{chunk-KGOVG47P.cjs → chunk-YG4YOPK6.cjs} +3 -3
- package/dist/chunk-YG4YOPK6.cjs.map +1 -0
- package/dist/chunks-REYSCBPB.js +10 -0
- package/dist/cli.js +30 -30
- package/dist/{formula-5DGAZK6N.cjs → formula-2BPHF6O7.cjs} +9 -9
- package/dist/formula-2BPHF6O7.cjs.map +1 -0
- package/dist/{formula-6J26PNHL.js → formula-EA5GDCUD.js} +4 -4
- package/dist/{formula-PNZX2ZAZ.js → formula-IREEAC4T.js} +3 -3
- package/dist/{image-ocr-I4PGBAJ7.cjs → image-ocr-CCTE7HX3.cjs} +17 -17
- package/dist/image-ocr-CCTE7HX3.cjs.map +1 -0
- package/dist/{image-ocr-RPHNFU7I.js → image-ocr-JQJC5HWK.js} +6 -6
- package/dist/{image-ocr-UNTKJLQL.js → image-ocr-LGOFUS3O.js} +9 -9
- package/dist/index.cjs +601 -433
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +203 -35
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +23 -23
- package/dist/{model-bundle-ZSDEJFA7.js → model-bundle-YW62Y6UD.js} +5 -5
- package/dist/{models-JS66XYKO.js → models-AAL3IS2R.js} +5 -5
- package/dist/page-range-QHHFTL7X.cjs.map +1 -1
- package/dist/{parse-worker-v2-JHPEY3MI.js → parse-worker-v2-3JAHV7NY.js} +12 -12
- package/dist/{parser-YKATDDQV.js → parser-4FCKKJ2N.js} +18 -14
- package/dist/parser-4FCKKJ2N.js.map +1 -0
- package/dist/{parser-NMV5GTKC.cjs → parser-HE45CCSG.cjs} +163 -159
- package/dist/parser-HE45CCSG.cjs.map +1 -0
- package/dist/{parser-N64TUIWU.js → parser-ZBP5GOQK.js} +15 -11
- package/dist/parser-ZBP5GOQK.js.map +1 -0
- package/dist/pdf-ocr-7MDCLWAA.cjs +31 -0
- package/dist/pdf-ocr-7MDCLWAA.cjs.map +1 -0
- package/dist/{pdf-ocr-W3LDJYCA.js → pdf-ocr-HFAEOA7W.js} +6 -6
- package/dist/{pdf-ocr-KTKR2JQH.js → pdf-ocr-Q4TPGDDI.js} +9 -9
- package/dist/{profile-io-JRODOL7A.js → profile-io-EDQTKLLL.js} +3 -3
- package/dist/{rasterize-2DMR7RGP.js → rasterize-VD2XGHUJ.js} +3 -3
- package/dist/{redact-doc-TC6QSTPM.js → redact-doc-TBIBQJCT.js} +11 -11
- package/dist/{render-WEUU5EDS.js → render-J5KAZAQH.js} +7 -7
- package/dist/seal-H2JNAZU7.js +10 -0
- package/dist/{setup-LKJKGMKJ.js → setup-5LYHCQRU.js} +3 -3
- package/dist/visual-7EO6GR3M.js +21 -0
- package/dist/{watch-HHFVXB3G.js → watch-YP4IWM75.js} +12 -12
- package/package.json +1 -1
- package/dist/chunk-4VNIEHWM.cjs.map +0 -1
- package/dist/chunk-5QBTJ4LA.cjs.map +0 -1
- package/dist/chunk-JSI5T77E.cjs.map +0 -1
- package/dist/chunk-KGOVG47P.cjs.map +0 -1
- package/dist/chunk-LBPUPT6S.js.map +0 -1
- package/dist/chunk-RIQVVWVF.cjs.map +0 -1
- package/dist/chunk-TYXXTWPH.cjs.map +0 -1
- package/dist/chunks-HPPVNSBT.js +0 -10
- package/dist/formula-5DGAZK6N.cjs.map +0 -1
- package/dist/image-ocr-I4PGBAJ7.cjs.map +0 -1
- package/dist/parser-N64TUIWU.js.map +0 -1
- package/dist/parser-NMV5GTKC.cjs.map +0 -1
- package/dist/parser-YKATDDQV.js.map +0 -1
- package/dist/pdf-ocr-JXK752RC.cjs +0 -31
- package/dist/pdf-ocr-JXK752RC.cjs.map +0 -1
- package/dist/seal-LSALFURW.js +0 -10
- package/dist/visual-PHZHJRY5.js +0 -21
- /package/dist/{-TSN4SWFV.js.map → -Q56U3KCA.js.map} +0 -0
- /package/dist/{chunk-LEUS275C.js.map → chunk-33NZN73M.js.map} +0 -0
- /package/dist/{chunk-5EP6VFP5.js.map → chunk-3EWXRIPH.js.map} +0 -0
- /package/dist/{chunk-MI25BZSU.js.map → chunk-42FSKT7R.js.map} +0 -0
- /package/dist/{chunk-NAPPGU3W.js.map → chunk-4X73CGIL.js.map} +0 -0
- /package/dist/{chunk-6H7D4QTM.js.map → chunk-AEEQN6L3.js.map} +0 -0
- /package/dist/{chunk-G7SKCXQG.js.map → chunk-EEXIFCXC.js.map} +0 -0
- /package/dist/{chunk-YE4T2P6F.js.map → chunk-EWCJCWTT.js.map} +0 -0
- /package/dist/{chunk-AJ3DJSO6.js.map → chunk-FZT34MUI.js.map} +0 -0
- /package/dist/{chunk-BIVO2GMU.js.map → chunk-HNX2I7D6.js.map} +0 -0
- /package/dist/{chunk-W4P3QPSB.js.map → chunk-HU7POUBS.js.map} +0 -0
- /package/dist/{chunk-RVKOFZAT.js.map → chunk-I2QETSZN.js.map} +0 -0
- /package/dist/{chunk-WYYUWBTS.js.map → chunk-KXHNIHLC.js.map} +0 -0
- /package/dist/{chunk-2SMANR76.js.map → chunk-NKDPCALC.js.map} +0 -0
- /package/dist/{chunk-4BCQ3FQS.js.map → chunk-OAOM7IEI.js.map} +0 -0
- /package/dist/{chunk-SWCO5NP6.js.map → chunk-PHZDAHZC.js.map} +0 -0
- /package/dist/{chunk-L2OJUIII.js.map → chunk-PMX5CPK5.js.map} +0 -0
- /package/dist/{chunk-LEL5UBGR.js.map → chunk-Q2QKRE4P.js.map} +0 -0
- /package/dist/{chunk-RS2Q64N5.js.map → chunk-TZ753B6A.js.map} +0 -0
- /package/dist/{chunk-B77K6J3U.js.map → chunk-W6O7KBOD.js.map} +0 -0
- /package/dist/{chunk-ZR3BPESP.js.map → chunk-XAZ5RGVG.js.map} +0 -0
- /package/dist/{chunk-V2GW3M2F.js.map → chunk-XNNMMYFO.js.map} +0 -0
- /package/dist/{chunk-HP24FYLJ.js.map → chunk-XZOAE2Q7.js.map} +0 -0
- /package/dist/{chunks-HPPVNSBT.js.map → chunks-REYSCBPB.js.map} +0 -0
- /package/dist/{formula-6J26PNHL.js.map → formula-EA5GDCUD.js.map} +0 -0
- /package/dist/{formula-PNZX2ZAZ.js.map → formula-IREEAC4T.js.map} +0 -0
- /package/dist/{image-ocr-RPHNFU7I.js.map → image-ocr-JQJC5HWK.js.map} +0 -0
- /package/dist/{image-ocr-UNTKJLQL.js.map → image-ocr-LGOFUS3O.js.map} +0 -0
- /package/dist/{model-bundle-ZSDEJFA7.js.map → model-bundle-YW62Y6UD.js.map} +0 -0
- /package/dist/{models-JS66XYKO.js.map → models-AAL3IS2R.js.map} +0 -0
- /package/dist/{parse-worker-v2-JHPEY3MI.js.map → parse-worker-v2-3JAHV7NY.js.map} +0 -0
- /package/dist/{pdf-ocr-KTKR2JQH.js.map → pdf-ocr-HFAEOA7W.js.map} +0 -0
- /package/dist/{pdf-ocr-W3LDJYCA.js.map → pdf-ocr-Q4TPGDDI.js.map} +0 -0
- /package/dist/{profile-io-JRODOL7A.js.map → profile-io-EDQTKLLL.js.map} +0 -0
- /package/dist/{rasterize-2DMR7RGP.js.map → rasterize-VD2XGHUJ.js.map} +0 -0
- /package/dist/{redact-doc-TC6QSTPM.js.map → redact-doc-TBIBQJCT.js.map} +0 -0
- /package/dist/{render-WEUU5EDS.js.map → render-J5KAZAQH.js.map} +0 -0
- /package/dist/{seal-LSALFURW.js.map → seal-H2JNAZU7.js.map} +0 -0
- /package/dist/{setup-LKJKGMKJ.js.map → setup-5LYHCQRU.js.map} +0 -0
- /package/dist/{visual-PHZHJRY5.js.map → visual-7EO6GR3M.js.map} +0 -0
- /package/dist/{watch-HHFVXB3G.js.map → watch-YP4IWM75.js.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
visibleText
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-HNX2I7D6.js";
|
|
5
5
|
|
|
6
6
|
// src/script-tags.ts
|
|
7
7
|
var LITERAL_TAG = /<(?=\/?(?:u|sup|sub)>)/g;
|
|
@@ -328,4 +328,4 @@ export {
|
|
|
328
328
|
HEADING_RATIO_H2,
|
|
329
329
|
HEADING_RATIO_H3
|
|
330
330
|
};
|
|
331
|
-
//# sourceMappingURL=chunk-
|
|
331
|
+
//# sourceMappingURL=chunk-HU7POUBS.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/utils.ts
|
|
2
|
-
var VERSION = true ? "4.24.
|
|
2
|
+
var VERSION = true ? "4.24.3" : "0.0.0-dev";
|
|
3
3
|
function toArrayBuffer(buf) {
|
|
4
4
|
if (buf.byteOffset === 0 && buf.byteLength === buf.buffer.byteLength) {
|
|
5
5
|
return buf.buffer;
|
|
@@ -161,4 +161,4 @@ export {
|
|
|
161
161
|
classifyError,
|
|
162
162
|
partExtension
|
|
163
163
|
};
|
|
164
|
-
//# sourceMappingURL=chunk-
|
|
164
|
+
//# sourceMappingURL=chunk-I2QETSZN.js.map
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
loadSharp,
|
|
4
4
|
rasterizePageSvg
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-Q2QKRE4P.js";
|
|
6
6
|
import {
|
|
7
7
|
inlineImagesIntoMarkdown
|
|
8
8
|
} from "./chunk-VKVDMH7X.js";
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
HEADING_RATIO_H3,
|
|
17
17
|
tidyScriptTags,
|
|
18
18
|
unframeLayoutTables
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-HU7POUBS.js";
|
|
20
20
|
import {
|
|
21
21
|
MAX_COLS,
|
|
22
22
|
MAX_ROWS,
|
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
mapPuaText,
|
|
33
33
|
markNonLayoutTable,
|
|
34
34
|
romanNumeral
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-HNX2I7D6.js";
|
|
36
36
|
import {
|
|
37
37
|
DEFAULT_CHAR,
|
|
38
38
|
DEFAULT_PARA_GEOM,
|
|
@@ -46,7 +46,7 @@ import {
|
|
|
46
46
|
hwpxAppMajor,
|
|
47
47
|
parseRenderStyles,
|
|
48
48
|
readZipEntry
|
|
49
|
-
} from "./chunk-
|
|
49
|
+
} from "./chunk-PMX5CPK5.js";
|
|
50
50
|
import {
|
|
51
51
|
KordocError,
|
|
52
52
|
compareSectionPaths,
|
|
@@ -54,7 +54,7 @@ import {
|
|
|
54
54
|
precheckZipSize,
|
|
55
55
|
sanitizeHref,
|
|
56
56
|
toArrayBuffer
|
|
57
|
-
} from "./chunk-
|
|
57
|
+
} from "./chunk-EWCJCWTT.js";
|
|
58
58
|
|
|
59
59
|
// src/render/svg-render.ts
|
|
60
60
|
import JSZip from "jszip";
|
|
@@ -130,7 +130,7 @@ function tableColumnBoundaries(constraints, count, total, noExactRow = false) {
|
|
|
130
130
|
const lp = longestPathBoundaries(constraints, count);
|
|
131
131
|
return lp && Math.abs(lp.x[count] - total) <= 2 && (noExactRow || lp.x.every((v, k) => Math.abs(v - prop[k]) <= 2 || lp.tight[k])) ? lp.x : prop;
|
|
132
132
|
}
|
|
133
|
-
function solveRowHeights(cells, rowCount, maxTotal = Number.POSITIVE_INFINITY) {
|
|
133
|
+
function solveRowHeights(cells, rowCount, maxTotal = Number.POSITIVE_INFINITY, shrinkLast = false) {
|
|
134
134
|
const h = new Array(rowCount).fill(0);
|
|
135
135
|
for (const c of cells) {
|
|
136
136
|
if (c.rowSpan === 1 && c.rowAddr >= 0 && c.rowAddr < rowCount) {
|
|
@@ -163,6 +163,12 @@ function solveRowHeights(cells, rowCount, maxTotal = Number.POSITIVE_INFINITY) {
|
|
|
163
163
|
for (const r of missing) h[r] = each;
|
|
164
164
|
return true;
|
|
165
165
|
};
|
|
166
|
+
for (let r = 0; r < rowCount; r++) {
|
|
167
|
+
if (h[r] !== 0) continue;
|
|
168
|
+
let need = 0;
|
|
169
|
+
for (const { c, rows } of spans) if (rows[rows.length - 1] === r && rows.slice(0, -1).every((q) => h[q] > 0)) need = Math.max(need, c.height - rows.slice(0, -1).reduce((t, q) => t + h[q], 0));
|
|
170
|
+
if (need > 0) h[r] = need;
|
|
171
|
+
}
|
|
166
172
|
for (let again = true; again; ) {
|
|
167
173
|
again = false;
|
|
168
174
|
for (let k = 0; k < spans.length; k++) if (!done.has(k) && solve(k, true)) again = true;
|
|
@@ -177,6 +183,9 @@ function solveRowHeights(cells, rowCount, maxTotal = Number.POSITIVE_INFINITY) {
|
|
|
177
183
|
total += add;
|
|
178
184
|
}
|
|
179
185
|
}
|
|
186
|
+
const last = rowCount - 1, over = total - maxTotal;
|
|
187
|
+
const lastCells = cells.filter((c) => c.rowAddr + c.rowSpan - 1 === last);
|
|
188
|
+
if (shrinkLast && over > 0 && last >= 0 && lastCells.length && lastCells.every((c) => c.rowSpan === 1 && c.contentH != null && c.contentH <= h[last] - over)) h[last] -= over;
|
|
180
189
|
return h;
|
|
181
190
|
}
|
|
182
191
|
|
|
@@ -11443,9 +11452,9 @@ function cellContentExtent(cell, memo) {
|
|
|
11443
11452
|
const pos = findChildByLocalName(o.el, "pos");
|
|
11444
11453
|
if ((pos?.getAttribute("vertRelTo") ?? "PARA") !== "PARA") continue;
|
|
11445
11454
|
const om = findChildByLocalName(o.el, "outMargin");
|
|
11446
|
-
const pushed = baseV - (num(om, "top") + o.height + num(om, "bottom"));
|
|
11447
|
-
const anchor = pushed >= (paraStart > 0 ? paraStart - 100 : -100) ? pushed : baseV - (memo?.paraGeom?.get(p.getAttribute("paraPrIDRef") ?? "")?.spaceBefore ?? 0);
|
|
11448
11455
|
const vo = num(pos, "vertOffset");
|
|
11456
|
+
const pushed = baseV - (Math.max(0, vo) + num(om, "top") + o.height + num(om, "bottom"));
|
|
11457
|
+
const anchor = pushed >= (paraStart > 0 ? paraStart - 100 : -100) ? pushed : baseV - (memo?.paraGeom?.get(p.getAttribute("paraPrIDRef") ?? "")?.spaceBefore ?? 0);
|
|
11449
11458
|
const oh = o.tag === "tbl" ? Math.max(o.height, measureTableHeight(o.el, memo)) : o.height;
|
|
11450
11459
|
ext = Math.max(ext, anchor + num(om, "top") + Math.max(0, vo) + oh);
|
|
11451
11460
|
}
|
|
@@ -11491,6 +11500,21 @@ function collectCells(tbl) {
|
|
|
11491
11500
|
}
|
|
11492
11501
|
return cells;
|
|
11493
11502
|
}
|
|
11503
|
+
function inCell(el) {
|
|
11504
|
+
for (let n = el.parentNode; n; n = n.parentNode) if (ln(n) === "tc") return true;
|
|
11505
|
+
return false;
|
|
11506
|
+
}
|
|
11507
|
+
function splitSaved(c) {
|
|
11508
|
+
let prev = Number.NEGATIVE_INFINITY;
|
|
11509
|
+
for (const p of c.sub ? elements(c.sub) : []) {
|
|
11510
|
+
if (ln(p) !== "p") continue;
|
|
11511
|
+
for (const s of buildPara(p).segs) {
|
|
11512
|
+
if (s.vertpos < prev) return true;
|
|
11513
|
+
prev = s.vertpos;
|
|
11514
|
+
}
|
|
11515
|
+
}
|
|
11516
|
+
return false;
|
|
11517
|
+
}
|
|
11494
11518
|
function measureTableRowHeights(tbl, memo) {
|
|
11495
11519
|
const cells = collectCells(tbl);
|
|
11496
11520
|
if (cells.length === 0 || cells.length > 4096) return [];
|
|
@@ -11501,7 +11525,8 @@ function measureTableRowHeights(tbl, memo) {
|
|
|
11501
11525
|
// (같은 판 PDF: 두 줄 든 2행 병합 칸 내용 2882 > 저장 2564 → 둘째 행이 318 자라고 첫 행은 그대로)
|
|
11502
11526
|
cells.map((c) => ({ rowAddr: c.ra, rowSpan: c.rs, height: (c.rs > 1 ? Math.max(c.h, cellContentExtent(c, memo) + c.marginT + c.marginB) : c.h) - sp * (c.rs - 1), contentH: c.rs === 1 ? cellContentExtent(c, memo) + c.marginT + c.marginB : void 0 })),
|
|
11503
11527
|
nRows,
|
|
11504
|
-
num(findChildByLocalName(tbl, "sz"), "height") - (sp > 0 ? sp * (nRows + 1) : 0) || Number.POSITIVE_INFINITY
|
|
11528
|
+
num(findChildByLocalName(tbl, "sz"), "height") - (sp > 0 ? sp * (nRows + 1) : 0) || Number.POSITIVE_INFINITY,
|
|
11529
|
+
!inCell(tbl) && !cells.some((c) => c.ra + c.rs === nRows && splitSaved(c))
|
|
11505
11530
|
);
|
|
11506
11531
|
if (sp > 0) {
|
|
11507
11532
|
for (let r = 0; r < rows.length; r++) rows[r] += sp;
|
|
@@ -11625,6 +11650,7 @@ function splitTableRows(tbl, top, lim, bodyH, styles, notes) {
|
|
|
11625
11650
|
const fl = () => notes && nN > 0 ? Math.min(floor, bodyH - notes.area((moved ? 0 : notes.n0) + nN, (moved ? 0 : notes.s0) + nS)) : floor;
|
|
11626
11651
|
const sp = num(tbl, "cellSpacing");
|
|
11627
11652
|
const cells = mode === "CELL" ? collectCells(tbl) : [];
|
|
11653
|
+
const tableCells = mode === "TABLE" ? collectCells(tbl) : [];
|
|
11628
11654
|
const record = mode === "CELL" ? /* @__PURE__ */ new Map() : void 0;
|
|
11629
11655
|
const carries = /* @__PURE__ */ new Map();
|
|
11630
11656
|
for (let r = 0; r < rows.length; r++) {
|
|
@@ -11653,7 +11679,20 @@ function splitTableRows(tbl, top, lim, bodyH, styles, notes) {
|
|
|
11653
11679
|
y += h;
|
|
11654
11680
|
continue;
|
|
11655
11681
|
}
|
|
11656
|
-
|
|
11682
|
+
let need = h;
|
|
11683
|
+
if (!tableCells.some((c) => c.ra < r && c.ra + c.rs > r)) {
|
|
11684
|
+
let end = r + 1;
|
|
11685
|
+
for (let grown = true; grown; ) {
|
|
11686
|
+
grown = false;
|
|
11687
|
+
for (const c of tableCells) if (c.ra >= r && c.ra < end && c.ra + c.rs > end) {
|
|
11688
|
+
end = c.ra + c.rs;
|
|
11689
|
+
grown = true;
|
|
11690
|
+
}
|
|
11691
|
+
}
|
|
11692
|
+
const groupH = rows.slice(r, end).reduce((a, b) => a + b, 0);
|
|
11693
|
+
if (end > r + 1 && groupH <= bodyH - outT - outB - headH) need = groupH;
|
|
11694
|
+
}
|
|
11695
|
+
if (y + need + outB > fl() && !(moved && y === outT + headH)) {
|
|
11657
11696
|
if (!moved && r === 0) splitWhole = true;
|
|
11658
11697
|
y = outT + headH;
|
|
11659
11698
|
floor = bodyH;
|
|
@@ -13261,6 +13300,26 @@ function cellLineBoxes(c) {
|
|
|
13261
13300
|
function cellLines(c) {
|
|
13262
13301
|
return cellLineBoxes(c).map((b) => [b.top, b.bottom]);
|
|
13263
13302
|
}
|
|
13303
|
+
function spanPartRows(cells, rowY) {
|
|
13304
|
+
const out = /* @__PURE__ */ new Set();
|
|
13305
|
+
for (const c of cells) {
|
|
13306
|
+
if (c.rs < 2) continue;
|
|
13307
|
+
const bs = cellLineBoxes(c);
|
|
13308
|
+
const parts = bs.length ? bs[bs.length - 1].part : 0;
|
|
13309
|
+
let s = c.ra;
|
|
13310
|
+
for (let k = 0; k < parts; k++) {
|
|
13311
|
+
const inK = bs.filter((b) => b.part === k);
|
|
13312
|
+
if (!inK.length) break;
|
|
13313
|
+
const ext = Math.max(...inK.map((b) => b.bottom)) - inK[0].origin + c.marginT + c.marginB;
|
|
13314
|
+
let r = s + 1;
|
|
13315
|
+
while (r < c.ra + c.rs && rowY[r] - rowY[s] < ext - 100) r++;
|
|
13316
|
+
if (r >= c.ra + c.rs) break;
|
|
13317
|
+
out.add(r);
|
|
13318
|
+
s = r;
|
|
13319
|
+
}
|
|
13320
|
+
}
|
|
13321
|
+
return out;
|
|
13322
|
+
}
|
|
13264
13323
|
function planTableRows(tbl, cells, rowH, ty, MT, BODY_H, slack = 0, floatSpan, nested = false, contMT = MT) {
|
|
13265
13324
|
if (nested) slack = 0;
|
|
13266
13325
|
const nRows = rowH.length;
|
|
@@ -13293,9 +13352,15 @@ function planTableRows(tbl, cells, rowH, ty, MT, BODY_H, slack = 0, floatSpan, n
|
|
|
13293
13352
|
const out = [];
|
|
13294
13353
|
const flows = (findChildByLocalName(tbl, "pos")?.getAttribute("vertRelTo") ?? "PARA") === "PARA";
|
|
13295
13354
|
let page = 0, y = ty, first = !flows || ty - MT < 2e3;
|
|
13355
|
+
const spanStarts = cellSplit ? spanPartRows(cells, rowY) : /* @__PURE__ */ new Set();
|
|
13296
13356
|
for (let r = 0; r < nRows; r++) {
|
|
13297
13357
|
let h = rowH[r];
|
|
13298
13358
|
const pieces = [];
|
|
13359
|
+
if (!first && r >= hdrRows && spanStarts.has(r)) {
|
|
13360
|
+
page++;
|
|
13361
|
+
y = contTop;
|
|
13362
|
+
first = true;
|
|
13363
|
+
}
|
|
13299
13364
|
const rowCells = cells.filter((c) => c.ra === r && c.rs === 1);
|
|
13300
13365
|
const splittable = cellSplit && r >= hdrRows && rowCells.length > 0;
|
|
13301
13366
|
const stack = splittable && rowCells.length === 1 ? stackedFloats(rowCells[0]) : [];
|
|
@@ -13461,7 +13526,8 @@ function planTableRows(tbl, cells, rowH, ty, MT, BODY_H, slack = 0, floatSpan, n
|
|
|
13461
13526
|
rem = Math.max(rem, end - ls[k][0] + c.marginT + c.marginB);
|
|
13462
13527
|
}
|
|
13463
13528
|
if (allFit) {
|
|
13464
|
-
|
|
13529
|
+
const spanCells = cells.filter((c) => c.ra === r && c.rs > 1);
|
|
13530
|
+
if (!first && h <= pageBottom - contTop && [...rowCells, ...spanCells].some((c) => cellContentExtent(c) + c.marginT + c.marginB > avail)) {
|
|
13465
13531
|
page++;
|
|
13466
13532
|
y = contTop;
|
|
13467
13533
|
first = true;
|
|
@@ -13509,6 +13575,21 @@ function planTableRows(tbl, cells, rowH, ty, MT, BODY_H, slack = 0, floatSpan, n
|
|
|
13509
13575
|
page++;
|
|
13510
13576
|
y = contTop;
|
|
13511
13577
|
first = true;
|
|
13578
|
+
} else if (!first && tbl.getAttribute("pageBreak") === "TABLE" && r >= hdrRows && !cells.some((c) => c.ra < r && c.ra + c.rs > r)) {
|
|
13579
|
+
let end = r + 1;
|
|
13580
|
+
for (let grown = true; grown; ) {
|
|
13581
|
+
grown = false;
|
|
13582
|
+
for (const c of cells) if (c.ra >= r && c.ra < end && c.ra + c.rs > end) {
|
|
13583
|
+
end = c.ra + c.rs;
|
|
13584
|
+
grown = true;
|
|
13585
|
+
}
|
|
13586
|
+
}
|
|
13587
|
+
const groupH = rowY[Math.min(end, nRows)] - rowY[r];
|
|
13588
|
+
if (end > r + 1 && y + groupH + outB > pageBottom && groupH <= pageBottom - contTop) {
|
|
13589
|
+
page++;
|
|
13590
|
+
y = contTop;
|
|
13591
|
+
first = true;
|
|
13592
|
+
}
|
|
13512
13593
|
}
|
|
13513
13594
|
out.push([{ page, y, h }]);
|
|
13514
13595
|
y += h;
|
|
@@ -13551,12 +13632,27 @@ function renderingMatrix(el) {
|
|
|
13551
13632
|
const info = findChildByLocalName(el, "renderingInfo");
|
|
13552
13633
|
if (!info) return null;
|
|
13553
13634
|
let m = null;
|
|
13635
|
+
let pendingS = null;
|
|
13636
|
+
const apply = (n) => {
|
|
13637
|
+
m = m ? mulAffine(m, n) : n;
|
|
13638
|
+
};
|
|
13554
13639
|
for (const c of elements(info)) {
|
|
13555
13640
|
const tag = ln(c);
|
|
13556
13641
|
if (tag !== "transMatrix" && tag !== "scaMatrix" && tag !== "rotMatrix") continue;
|
|
13557
13642
|
const n = [num(c, "e1", 1), num(c, "e4"), num(c, "e2"), num(c, "e5", 1), num(c, "e3"), num(c, "e6")];
|
|
13558
|
-
|
|
13643
|
+
if (tag === "scaMatrix") {
|
|
13644
|
+
if (pendingS) apply(pendingS);
|
|
13645
|
+
pendingS = n;
|
|
13646
|
+
continue;
|
|
13647
|
+
}
|
|
13648
|
+
if (tag === "rotMatrix" && pendingS) {
|
|
13649
|
+
apply(mulAffine(n, pendingS));
|
|
13650
|
+
pendingS = null;
|
|
13651
|
+
continue;
|
|
13652
|
+
}
|
|
13653
|
+
apply(n);
|
|
13559
13654
|
}
|
|
13655
|
+
if (pendingS) apply(pendingS);
|
|
13560
13656
|
return m;
|
|
13561
13657
|
}
|
|
13562
13658
|
function objectGeometry(el, x, y, w, h, boxW = w, boxH = h) {
|
|
@@ -13659,9 +13755,11 @@ function shapeGeometry(o, boxX, boxY, defs, images, warn, local = false) {
|
|
|
13659
13755
|
function linePushedBy(o, lineV, paraTop) {
|
|
13660
13756
|
if (paraTop === void 0) return false;
|
|
13661
13757
|
const om = findChildByLocalName(o.el, "outMargin");
|
|
13662
|
-
|
|
13758
|
+
const pos = findChildByLocalName(o.el, "pos");
|
|
13759
|
+
const raw = num(pos, "vertOffset"), vo = (pos?.getAttribute("vertRelTo") ?? "PARA") === "PARA" ? Math.max(0, raw >= 2 ** 31 ? raw - 2 ** 32 : raw) : 0;
|
|
13760
|
+
return Math.abs(lineV - (vo + num(om, "top") + o.height + num(om, "bottom")) - paraTop) <= 10;
|
|
13663
13761
|
}
|
|
13664
|
-
function anchorObject(o, ox, oy, baseV, areaW, ctx, anchorLineV, stayLine = false, paraStartV,
|
|
13762
|
+
function anchorObject(o, ox, oy, baseV, areaW, ctx, anchorLineV, stayLine = false, paraStartV, lineH, lineSB = 0, anchorAt = "end") {
|
|
13665
13763
|
const { PW, PH, ML, MT, BODY_W, BODY_H } = ctx.geom;
|
|
13666
13764
|
const pos = findChildByLocalName(o.el, "pos");
|
|
13667
13765
|
const om = findChildByLocalName(o.el, "outMargin");
|
|
@@ -13683,13 +13781,15 @@ function anchorObject(o, ox, oy, baseV, areaW, ctx, anchorLineV, stayLine = fals
|
|
|
13683
13781
|
y = va === "BOTTOM" ? MT + BODY_H - h - vo : va === "CENTER" ? MT + (BODY_H - h) / 2 + vo : MT + vo;
|
|
13684
13782
|
} else if (wrap === "TOP_AND_BOTTOM") {
|
|
13685
13783
|
const lineV = anchorLineV ?? baseV;
|
|
13686
|
-
const pushed = lineV - (omT + h + omB);
|
|
13687
|
-
const below =
|
|
13688
|
-
const anchor = below ? lineV : stayLine !== false ? lineV - stayLine : pushed >= -100 ? pushed : paraStartV !== void 0 ? paraStartV : lineV;
|
|
13784
|
+
const pushed = lineV - (vo + omT + h + omB);
|
|
13785
|
+
const below = lineH !== void 0 && vo + omT >= lineH && !(paraStartV !== void 0 && Math.abs(pushed - paraStartV) <= 10);
|
|
13786
|
+
const anchor = below ? lineV - lineSB : stayLine !== false ? lineV - stayLine : pushed >= -100 ? pushed : paraStartV !== void 0 ? paraStartV : lineV;
|
|
13689
13787
|
y = oy + anchor + omT + vo;
|
|
13690
13788
|
} else {
|
|
13691
13789
|
const origin = vrel === "PARA" && wrap === "SQUARE" ? paraStartV ?? baseV : baseV;
|
|
13692
|
-
|
|
13790
|
+
const later = vrel === "PARA" && wrap === "SQUARE" && anchorAt === "end" && anchorLineV !== void 0 && anchorLineV > baseV;
|
|
13791
|
+
const midLater = vrel === "PARA" && wrap === "SQUARE" && anchorAt === "top" && anchorLineV !== void 0 && anchorLineV > baseV;
|
|
13792
|
+
y = later ? oy + anchorLineV + vo + omT : oy + Math.max(origin + vo, wrap === "SQUARE" && !midLater && anchorLineV !== void 0 ? anchorLineV : -Infinity) + omT;
|
|
13693
13793
|
}
|
|
13694
13794
|
let x;
|
|
13695
13795
|
const omL = num(om, "left"), omR = num(om, "right");
|
|
@@ -14525,6 +14625,7 @@ function planLines(m, styles, numText = "") {
|
|
|
14525
14625
|
}
|
|
14526
14626
|
if (fixedTo > start) fixedW = lineNaturalWidth(m, styles, start, fixedTo).text + [...tabs.values()].reduce((a, b) => a + b, 0);
|
|
14527
14627
|
let textEnd = Math.min(end, m.chars.length);
|
|
14628
|
+
while (textEnd > fixedTo && m.chars[textEnd - 1].br) textEnd--;
|
|
14528
14629
|
while (textEnd > fixedTo && m.chars[textEnd - 1].ch === " ") textEnd--;
|
|
14529
14630
|
const nat = lineNaturalWidth(m, styles, fixedTo, textEnd);
|
|
14530
14631
|
for (const o of m.objs) if (o.inline && o.index >= textEnd && o.index < end) nat.obj += o.omL + o.width + o.omR;
|
|
@@ -14744,6 +14845,7 @@ function drawPara(p, ox, oy, areaW, ctx, depth, segPages) {
|
|
|
14744
14845
|
if (gOpenOn >= 0) ctx.pages[gOpenOn].push("</g>");
|
|
14745
14846
|
if (paraRegionId) ctx.parentStack.push(paraRegionId);
|
|
14746
14847
|
let tbStack;
|
|
14848
|
+
let tbStackTop;
|
|
14747
14849
|
for (const o of m.objs) {
|
|
14748
14850
|
if (o.inline) {
|
|
14749
14851
|
let planIdx = 0;
|
|
@@ -14754,7 +14856,8 @@ function drawPara(p, ox, oy, areaW, ctx, depth, segPages) {
|
|
|
14754
14856
|
const plan = plans[planIdx];
|
|
14755
14857
|
if (segPages && segPages[planIdx] !== void 0) ctx.page = segPages[planIdx];
|
|
14756
14858
|
const x = ox + plan.seg.horzpos + plan.xoff + advanceTo(m, ctx.styles, plan, o.index) + o.omL;
|
|
14757
|
-
const
|
|
14859
|
+
const shadowed = o.tag === "pic" && !!findChildByLocalName(findChildByLocalName(o.el, "effects") ?? o.el, "shadow") && plan.seg.textheight > o.height && Math.abs(plan.seg.baseline - Math.round(plan.seg.textheight * 0.85)) <= 2;
|
|
14860
|
+
const eqAsc = o.tag === "equation" && Number(o.el.getAttribute("baseLine")) > 0 ? Math.round(o.height * Number(o.el.getAttribute("baseLine")) / 100) : shadowed ? Math.round(plan.seg.textheight * 0.85) : o.tag === "pic" ? Math.round(o.height * 0.85) : o.height;
|
|
14758
14861
|
const iom = findChildByLocalName(o.el, "outMargin"), iomT = num(iom, "top"), iomB = num(iom, "bottom");
|
|
14759
14862
|
const yTop = oy + plan.seg.vertpos + Math.max(iomT, plan.seg.baseline - eqAsc - iomB - captionExtra(o.el));
|
|
14760
14863
|
drawObject(o, x, yTop, baseV, areaW, ctx, depth);
|
|
@@ -14768,9 +14871,11 @@ function drawPara(p, ox, oy, areaW, ctx, depth, segPages) {
|
|
|
14768
14871
|
}
|
|
14769
14872
|
let anchorLineV;
|
|
14770
14873
|
let anchorLineH = 0;
|
|
14874
|
+
let anchorSeg;
|
|
14771
14875
|
for (const pl of plans) if (pl.start <= o.index) {
|
|
14772
14876
|
anchorLineV = pl.seg.vertpos;
|
|
14773
14877
|
anchorLineH = pl.seg.textheight;
|
|
14878
|
+
anchorSeg = pl.seg;
|
|
14774
14879
|
}
|
|
14775
14880
|
let objBaseV = baseV;
|
|
14776
14881
|
const pTop = depth === 0 ? ctx.paraTops?.get(p) : void 0;
|
|
@@ -14781,6 +14886,9 @@ function drawPara(p, ox, oy, areaW, ctx, depth, segPages) {
|
|
|
14781
14886
|
if (baseV > start + 100) {
|
|
14782
14887
|
objBaseV = start;
|
|
14783
14888
|
if (anchorLineV === baseV) anchorLineV = start;
|
|
14889
|
+
} else if (depth > 0 && start > top0 && Math.abs(baseV - start) <= 100) {
|
|
14890
|
+
objBaseV = top0;
|
|
14891
|
+
if (anchorLineV === baseV) anchorLineV = top0;
|
|
14784
14892
|
}
|
|
14785
14893
|
}
|
|
14786
14894
|
const tbFloats = m.objs.filter((q) => !q.inline && (q.el.getAttribute("textWrap") ?? "TOP_AND_BOTTOM") === "TOP_AND_BOTTOM" && (findChildByLocalName(q.el, "pos")?.getAttribute("vertRelTo") ?? "PARA") === "PARA").length;
|
|
@@ -14788,21 +14896,40 @@ function drawPara(p, ox, oy, areaW, ctx, depth, segPages) {
|
|
|
14788
14896
|
const sbA = m.paraPrId != null ? ctx.styles.paraGeom.get(m.paraPrId)?.spaceBefore ?? 0 : 0;
|
|
14789
14897
|
if (stay && wrapA === "TOP_AND_BOTTOM" && linePushedBy(o, anchorLineV ?? baseV, pTop ?? (depth > 0 ? cellParaTop(p, ctx.styles.paraGeom) : void 0))) stay = false;
|
|
14790
14898
|
const firstLine = anchorLineV === void 0 || anchorLineV === baseV;
|
|
14791
|
-
let { x, y } = anchorObject(
|
|
14792
|
-
|
|
14899
|
+
let { x, y } = anchorObject(
|
|
14900
|
+
o,
|
|
14901
|
+
ax,
|
|
14902
|
+
oy,
|
|
14903
|
+
objBaseV,
|
|
14904
|
+
aw,
|
|
14905
|
+
ctx,
|
|
14906
|
+
anchorLineV,
|
|
14907
|
+
stay ? sbA : false,
|
|
14908
|
+
(firstLine || wrapA === "SQUARE") && pTop !== void 0 && pTop < baseV ? pTop : void 0,
|
|
14909
|
+
anchorLineH,
|
|
14910
|
+
firstLine ? sbA : 0,
|
|
14911
|
+
// 문단 중간 글자 앵커인데 첫 줄부터 앵커 줄만큼 좁게 저장됐으면 개체는 문단 위에 있다(같은 판 한컴 PDF: 둘째 줄 앵커 사진, 네 줄 모두 34602)
|
|
14912
|
+
m.chars.slice(o.index).some((c) => c.ch.trim() !== "") && !!anchorSeg && plans.length > 0 && plans[0].seg !== anchorSeg && Math.abs(plans[0].seg.horzsize - anchorSeg.horzsize) <= 100 && anchorSeg.horzpos + anchorSeg.horzsize < aw - 1e3 ? "top" : m.chars.slice(o.index).some((c) => c.ch.trim() !== "") ? "mid" : "end"
|
|
14913
|
+
);
|
|
14914
|
+
let stackTop = depth === 0 ? pTop ?? 0 : cellParaTop(p, ctx.styles.paraGeom);
|
|
14915
|
+
if (tbFloats >= 2 && wrapA === "TOP_AND_BOTTOM" && stackTop !== void 0) {
|
|
14793
14916
|
if (!tbStack) {
|
|
14794
14917
|
tbStack = /* @__PURE__ */ new Map();
|
|
14795
|
-
|
|
14918
|
+
const placed = [];
|
|
14796
14919
|
const stackable = m.objs.filter((q) => !q.inline && (q.el.getAttribute("textWrap") ?? "TOP_AND_BOTTOM") === "TOP_AND_BOTTOM" && (findChildByLocalName(q.el, "pos")?.getAttribute("vertRelTo") ?? "PARA") === "PARA" && findChildByLocalName(q.el, "pos")?.getAttribute("allowOverlap") !== "1");
|
|
14797
14920
|
for (const q of stackable.length >= 2 ? stackable.sort((a, b) => a.index - b.index) : []) {
|
|
14798
|
-
const
|
|
14799
|
-
const
|
|
14921
|
+
const posQ = findChildByLocalName(q.el, "pos"), omQ = findChildByLocalName(q.el, "outMargin"), raw = num(posQ, "vertOffset");
|
|
14922
|
+
const x0 = num(posQ, "horzOffset"), x1 = x0 + num(omQ, "left") + q.width + num(omQ, "right");
|
|
14923
|
+
const below = Math.max(0, ...placed.filter((r) => r.x0 < x1 && x0 < r.x1).map((r) => r.bottom));
|
|
14924
|
+
const top = Math.max(below, depth > 0 ? Math.max(0, raw) : raw);
|
|
14800
14925
|
tbStack.set(q.el, top + num(omQ, "top"));
|
|
14801
|
-
|
|
14926
|
+
placed.push({ x0, x1, bottom: top + num(omQ, "top") + (q.tag === "tbl" ? Math.max(q.height, measureTableHeight(q.el, ctx.extentMemo)) : q.height) + num(omQ, "bottom") });
|
|
14802
14927
|
}
|
|
14928
|
+
if (depth > 0 && placed.length) tbStackTop = Math.max(stackTop, baseV - Math.max(...placed.map((r) => r.bottom)));
|
|
14803
14929
|
}
|
|
14930
|
+
if (depth > 0 && tbStackTop !== void 0) stackTop = tbStackTop;
|
|
14804
14931
|
const st = tbStack.get(o.el);
|
|
14805
|
-
if (st !== void 0) y = oy +
|
|
14932
|
+
if (st !== void 0) y = oy + stackTop + st;
|
|
14806
14933
|
}
|
|
14807
14934
|
const moved = ctx.objPlace?.get(o.el);
|
|
14808
14935
|
if (moved) {
|
|
@@ -15025,7 +15152,7 @@ function drawTable(tbl, tx, ty, ctx, depth) {
|
|
|
15025
15152
|
const slack = ctx.geom.PH - ctx.geom.MT - ctx.geom.BODY_H;
|
|
15026
15153
|
const splitHere = depth === 1 || !!ctx.splitCell && findChildByLocalName(tbl, "pos")?.getAttribute("treatAsChar") !== "1";
|
|
15027
15154
|
const plan = splitHere ? planTableRows(tbl, cells, rowH, ty, ctx.geom.MT, ctx.geom.BODY_H, slack, cellFloatSpan(ctx.geom.MT, ctx.geom.BODY_H, ctx.extentMemo, slack), depth !== 1, depth !== 1 && ctx.splitContMT !== void 0 ? ctx.splitContMT : ctx.geom.MT) : rowH.map((h, r) => [{ page: 0, y: ty + rowY[r], h }]);
|
|
15028
|
-
const
|
|
15155
|
+
const splitSaved2 = ctx.splitCell;
|
|
15029
15156
|
ctx.splitCell = false;
|
|
15030
15157
|
for (const pc of plan.flat()) for (const [el, py] of pc.place ?? []) (ctx.objPlace ??= /* @__PURE__ */ new Map()).set(el, { page: startPage + pc.page, y: py });
|
|
15031
15158
|
const contPages = [...new Set(plan.flat().map((pc) => pc.page).filter((pg) => pg > 0))].map((pg) => startPage + pg);
|
|
@@ -15038,10 +15165,28 @@ function drawTable(tbl, tx, ty, ctx, depth) {
|
|
|
15038
15165
|
pcs.forEach((pc, k) => geom.push({ c, page: startPage + pc.page, ...xw(c), y: pc.y, h: pc.h, pieces: k === 0 ? pcs : [] }));
|
|
15039
15166
|
continue;
|
|
15040
15167
|
}
|
|
15168
|
+
if (c.rs > 1) {
|
|
15169
|
+
const span = plan.slice(c.ra, Math.min(c.ra + c.rs, nRows)).flat();
|
|
15170
|
+
const pages = [...new Set(span.map((pc) => pc.page))];
|
|
15171
|
+
if (pages.length > 1) {
|
|
15172
|
+
const bs = cellLineBoxes(c);
|
|
15173
|
+
const partTop = (k) => bs.find((b) => b.part === k);
|
|
15174
|
+
const groups = pages.map((pg, k) => {
|
|
15175
|
+
const on = span.filter((pc) => pc.page === pg);
|
|
15176
|
+
const y0 = Math.min(...on.map((pc) => pc.y)), y1 = Math.max(...on.map((pc) => pc.y + pc.h));
|
|
15177
|
+
const from = k === 0 ? 0 : partTop(k)?.origin ?? Number.POSITIVE_INFINITY;
|
|
15178
|
+
const to = k === pages.length - 1 ? Number.POSITIVE_INFINITY : partTop(k + 1)?.top ?? Number.POSITIVE_INFINITY;
|
|
15179
|
+
return { page: pg, y: y0, h: y1 - y0, range: /* @__PURE__ */ new Map([[c.el, [from, to]]]) };
|
|
15180
|
+
});
|
|
15181
|
+
groups.forEach((pc, k) => geom.push({ c, page: startPage + pc.page, ...xw(c), y: pc.y, h: pc.h, pieces: k === 0 ? groups : [] }));
|
|
15182
|
+
continue;
|
|
15183
|
+
}
|
|
15184
|
+
}
|
|
15041
15185
|
const h = c.rs === 1 ? pcs[0].h : rowY[Math.min(c.ra + c.rs, nRows)] - rowY[c.ra];
|
|
15042
15186
|
geom.push({ c, page: startPage + pcs[0].page, ...xw(c), y: pcs[0].y, h });
|
|
15043
15187
|
}
|
|
15044
|
-
|
|
15188
|
+
const contBase = depth !== 1 && ctx.splitContMT !== void 0 ? ctx.splitContMT : ctx.geom.MT;
|
|
15189
|
+
for (const page of contPages) for (const c of cells) if (c.ra < hdrRows) geom.push({ c, page, ...xw(c), y: contBase + num(findChildByLocalName(tbl, "outMargin"), "top") + rowY[c.ra], h: rowY[Math.min(c.ra + c.rs, nRows)] - rowY[c.ra] });
|
|
15045
15190
|
for (const g of geom) {
|
|
15046
15191
|
ctx.page = g.page;
|
|
15047
15192
|
const bf = g.c.bfId != null ? ctx.styles.borderFill.get(g.c.bfId) : void 0;
|
|
@@ -15086,7 +15231,7 @@ function drawTable(tbl, tx, ty, ctx, depth) {
|
|
|
15086
15231
|
});
|
|
15087
15232
|
ctx.splitCell = splitHere;
|
|
15088
15233
|
const contMTSaved = ctx.splitContMT;
|
|
15089
|
-
ctx.splitContMT = ctx.geom.MT + num(findChildByLocalName(tbl, "outMargin"), "top") + rowY[hdrRows] + c.marginT;
|
|
15234
|
+
ctx.splitContMT = (depth > 1 && contMTSaved !== void 0 ? contMTSaved : ctx.geom.MT) + num(findChildByLocalName(tbl, "outMargin"), "top") + rowY[hdrRows] + c.marginT;
|
|
15090
15235
|
drawPara(p, g.x + c.marginL, base, g.w - c.marginL - c.marginR, ctx, depth + 1, pages);
|
|
15091
15236
|
ctx.splitContMT = contMTSaved;
|
|
15092
15237
|
ctx.splitCell = false;
|
|
@@ -15145,7 +15290,7 @@ function drawTable(tbl, tx, ty, ctx, depth) {
|
|
|
15145
15290
|
if (bf.right) emit(ctx, edgeLine(g.x + g.w, g.y, g.x + g.w, g.y + g.h, bf.right));
|
|
15146
15291
|
}
|
|
15147
15292
|
ctx.page = startPage;
|
|
15148
|
-
ctx.splitCell =
|
|
15293
|
+
ctx.splitCell = splitSaved2;
|
|
15149
15294
|
ctx.parentStack.pop();
|
|
15150
15295
|
emit(ctx, "</g>");
|
|
15151
15296
|
}
|
|
@@ -15304,6 +15449,7 @@ function renderSectionToPages(root, geom, ctxBase, doReflow, reflowMode, masters
|
|
|
15304
15449
|
}
|
|
15305
15450
|
const paraSegPages = /* @__PURE__ */ new Map();
|
|
15306
15451
|
const paraTops = /* @__PURE__ */ new Map();
|
|
15452
|
+
const backPlace = /* @__PURE__ */ new Map();
|
|
15307
15453
|
const geom0 = ctxBase.styles.paraGeom;
|
|
15308
15454
|
let tableEndPage = -1;
|
|
15309
15455
|
let nPages = 1;
|
|
@@ -15315,6 +15461,7 @@ function renderSectionToPages(root, geom, ctxBase, doReflow, reflowMode, masters
|
|
|
15315
15461
|
let cur = 0, col = 0;
|
|
15316
15462
|
let pendingEnd = 0, pendingEndY = 0;
|
|
15317
15463
|
let lastEnd = 0, lastPage = -1;
|
|
15464
|
+
let lastSA = 0;
|
|
15318
15465
|
let prevSeg;
|
|
15319
15466
|
for (const p of elements(root)) {
|
|
15320
15467
|
if (ln(p) !== "p") continue;
|
|
@@ -15352,6 +15499,7 @@ function renderSectionToPages(root, geom, ctxBase, doReflow, reflowMode, masters
|
|
|
15352
15499
|
if (prevSeg.p !== p) {
|
|
15353
15500
|
lastPage = cur;
|
|
15354
15501
|
lastEnd = v;
|
|
15502
|
+
lastSA = 0;
|
|
15355
15503
|
}
|
|
15356
15504
|
}
|
|
15357
15505
|
}
|
|
@@ -15365,11 +15513,13 @@ function renderSectionToPages(root, geom, ctxBase, doReflow, reflowMode, masters
|
|
|
15365
15513
|
prevEnd = v + num(s, "vertsize") + num(s, "spacing");
|
|
15366
15514
|
}
|
|
15367
15515
|
paraSegPages.set(p, pagesOf);
|
|
15368
|
-
|
|
15516
|
+
const prevEnd0 = lastEnd, prevPage0 = lastPage;
|
|
15517
|
+
if (segEls.length) paraTops.set(p, pagesOf[0] === lastPage ? lastEnd + lastSA : 0);
|
|
15369
15518
|
if (segEls.length) {
|
|
15370
15519
|
const ls = segEls[segEls.length - 1];
|
|
15371
15520
|
lastEnd = num(ls, "vertpos") + num(ls, "vertsize") + num(ls, "spacing");
|
|
15372
15521
|
lastPage = pagesOf[pagesOf.length - 1];
|
|
15522
|
+
lastSA = geom0.get(p.getAttribute("paraPrIDRef") ?? "")?.spaceAfter ?? 0;
|
|
15373
15523
|
}
|
|
15374
15524
|
if (!localCols && segEls.length) {
|
|
15375
15525
|
const m0 = buildPara(p);
|
|
@@ -15381,6 +15531,13 @@ function renderSectionToPages(root, geom, ctxBase, doReflow, reflowMode, masters
|
|
|
15381
15531
|
const segV = num(segEls[segK], "vertpos");
|
|
15382
15532
|
const h = Math.max(o.height, measureTableHeight(o.el, ctxBase.extentMemo)), omT = num(om, "top"), omB = num(om, "bottom");
|
|
15383
15533
|
const pushed = segV - (omT + h + omB);
|
|
15534
|
+
if (!o.inline && segK === 0 && pushed < -100 && prevPage0 >= 0 && pagesOf[0] === prevPage0 + 1 && (o.el.getAttribute("textWrap") ?? "TOP_AND_BOTTOM") === "TOP_AND_BOTTOM") {
|
|
15535
|
+
const back = tableContPages(o.el, MT + prevEnd0 + omT, MT, BODY_H, ctxBase.extentMemo, PH - MT - BODY_H, cellFloatSpan(MT, BODY_H, ctxBase.extentMemo, PH - MT - BODY_H));
|
|
15536
|
+
if (back.pages === 1 && Math.abs(back.endY - MT + omB - segV) <= 300) {
|
|
15537
|
+
backPlace.set(o.el, { page: prevPage0, y: MT + prevEnd0 + omT });
|
|
15538
|
+
continue;
|
|
15539
|
+
}
|
|
15540
|
+
}
|
|
15384
15541
|
const nTb = m0.objs.filter((q) => !q.inline && (q.el.getAttribute("textWrap") ?? "TOP_AND_BOTTOM") === "TOP_AND_BOTTOM").length;
|
|
15385
15542
|
const wrapP = o.el.getAttribute("textWrap") ?? "TOP_AND_BOTTOM";
|
|
15386
15543
|
const pTop = paraTops.get(p), sbP = m0.paraPrId != null ? geom0.get(m0.paraPrId)?.spaceBefore ?? 0 : 0;
|
|
@@ -15388,7 +15545,8 @@ function renderSectionToPages(root, geom, ctxBase, doReflow, reflowMode, masters
|
|
|
15388
15545
|
const nonPush = wrapP !== "TOP_AND_BOTTOM" && pTop !== void 0 && segV > pTop + sbP + 100 ? pTop + sbP : void 0;
|
|
15389
15546
|
const voP = Math.max(0, toInt32(pos?.getAttribute("vertOffset") ?? void 0, 0));
|
|
15390
15547
|
const paraStart = segK === 0 && pTop !== void 0 && pTop < segV ? pTop : segV;
|
|
15391
|
-
const
|
|
15548
|
+
const below = !o.inline && wrapP === "TOP_AND_BOTTOM" && voP + omT >= num(segEls[segK], "textheight") && !linePushedBy(o, segV, pTop);
|
|
15549
|
+
const ty = o.inline ? MT + segV + omT : nonPush !== void 0 ? MT + nonPush + omT + voP : MT + (below ? segV - (segK === 0 ? sbP : 0) : stay ? segV - sbP : pushed - voP >= -100 ? pushed - voP : paraStart) + omT + voP;
|
|
15392
15550
|
const span = tableContPages(o.el, ty, MT, BODY_H, ctxBase.extentMemo, PH - MT - BODY_H, cellFloatSpan(MT, BODY_H, ctxBase.extentMemo, PH - MT - BODY_H));
|
|
15393
15551
|
const anchorPage = pagesOf[segK];
|
|
15394
15552
|
const sp = !o.inline && !stay && nonPush === void 0 && segV - (omT + o.height + omB) >= -100 && pagesOf.some((pg, j) => j > segK && pg > anchorPage) ? tableContPages(o.el, MT + segV - o.height - omB, MT, BODY_H, ctxBase.extentMemo, PH - MT - BODY_H, cellFloatSpan(MT, BODY_H, ctxBase.extentMemo, PH - MT - BODY_H)) : void 0;
|
|
@@ -15473,6 +15631,7 @@ function renderSectionToPages(root, geom, ctxBase, doReflow, reflowMode, masters
|
|
|
15473
15631
|
if (geom.mirrorDx) ctx.bodyDx = mirrorDx;
|
|
15474
15632
|
ctx.cols = multiCol ? { w: colW, gap: colGap } : void 0;
|
|
15475
15633
|
ctx.paraTops = paraTops;
|
|
15634
|
+
if (backPlace.size) ctx.objPlace = new Map([...ctx.objPlace ?? [], ...backPlace]);
|
|
15476
15635
|
for (const p of elements(root)) {
|
|
15477
15636
|
if (ln(p) !== "p") continue;
|
|
15478
15637
|
drawPara(p, ML, MT, BODY_W, ctx, 0, paraSegPages.get(p));
|
|
@@ -15592,7 +15751,7 @@ function drawPageNumbers(root, paraPages, ctx) {
|
|
|
15592
15751
|
const side = decl.el.getAttribute("sideChar") ?? "";
|
|
15593
15752
|
const pnId = ctx.styles.pageNumCharPr ?? decl.prId;
|
|
15594
15753
|
const st = (pnId != null ? ctx.styles.charPr.get(pnId) : void 0) ?? DEFAULT_CHAR;
|
|
15595
|
-
const {
|
|
15754
|
+
const { PH, ML, BODY_W } = ctx.geom;
|
|
15596
15755
|
const pagePr = findFirst(root, "pagePr"), margin = pagePr ? findChildByLocalName(pagePr, "margin") : null;
|
|
15597
15756
|
const h = 1e3;
|
|
15598
15757
|
for (let page = decl.page; page < ctx.pages.length; page++) {
|
|
@@ -15600,7 +15759,7 @@ function drawPageNumbers(root, paraPages, ctx) {
|
|
|
15600
15759
|
const n = ctx.pageBase + page + 1;
|
|
15601
15760
|
const text = side ? `${side} ${formatHeadNumber2(n, decl.el.getAttribute("formatType") ?? "DIGIT")} ${side}` : formatHeadNumber2(n, decl.el.getAttribute("formatType") ?? "DIGIT");
|
|
15602
15761
|
const w = measureTextWidth(text, h, 100, { faceClass: faceClassOf(st.face) });
|
|
15603
|
-
const x = /LEFT/.test(pos) ? ML : /RIGHT/.test(pos) ? ML + BODY_W - w : (
|
|
15762
|
+
const x = /LEFT/.test(pos) ? ML : /RIGHT/.test(pos) ? ML + BODY_W - w : ML + (BODY_W - w) / 2;
|
|
15604
15763
|
const y = /^TOP/.test(pos) ? num(margin, "top", 5668) - 225 : num(margin, "footer", 0) > 0 ? PH - num(margin, "bottom", 4252) - 225 : PH - Math.round(num(margin, "bottom", 4252) / 2) - 243;
|
|
15605
15764
|
const attrs = [`x="${pt2(x)}"`, `y="${pt2(y)}"`, `font-size="${pt2(h)}"`];
|
|
15606
15765
|
if (st.fontFamily) attrs.push(`font-family="${escapeXml(st.fontFamily)}"`);
|
|
@@ -15719,6 +15878,7 @@ async function renderHwpxInternal(input, options) {
|
|
|
15719
15878
|
}
|
|
15720
15879
|
const roots = [];
|
|
15721
15880
|
let noCacheSkipped = false;
|
|
15881
|
+
const lastParity = /* @__PURE__ */ new Map();
|
|
15722
15882
|
for (let si = 0; si < secXmls.length; si++) {
|
|
15723
15883
|
const secXml = secXmls[si];
|
|
15724
15884
|
const hasCache = /<(?:[A-Za-z][\w.-]*:)?linesegarray[\s/>]/.test(secXml);
|
|
@@ -15735,6 +15895,14 @@ async function renderHwpxInternal(input, options) {
|
|
|
15735
15895
|
}
|
|
15736
15896
|
const secPr = findFirst(root, "secPr");
|
|
15737
15897
|
const referenced = secPr ? elements(secPr).filter((el) => ln(el) === "masterPage").map((el) => masterPages.get(el.getAttribute("idRef") || "")).filter((el) => !!el) : [];
|
|
15898
|
+
const typeOf = (m) => m.getAttribute("type") || "BOTH";
|
|
15899
|
+
const has = (t) => referenced.some((m) => typeOf(m) === t);
|
|
15900
|
+
if (!has("BOTH")) for (const [t, other] of [["EVEN", "ODD"], ["ODD", "EVEN"]]) {
|
|
15901
|
+
const prev = lastParity.get(t);
|
|
15902
|
+
if (prev && !has(t) && has(other)) referenced.unshift(prev);
|
|
15903
|
+
}
|
|
15904
|
+
for (const m of referenced) if (typeOf(m) === "EVEN" || typeOf(m) === "ODD") lastParity.set(typeOf(m), m);
|
|
15905
|
+
if (has("BOTH")) lastParity.clear();
|
|
15738
15906
|
roots.push({ root, index: si, masterPages: referenced, hasDeletionMarkers: secXml.includes("deleteBegin") || secXml.includes("deleteEnd") });
|
|
15739
15907
|
}
|
|
15740
15908
|
if (roots.length === 0) {
|
|
@@ -19918,4 +20086,4 @@ export {
|
|
|
19918
20086
|
cropRect,
|
|
19919
20087
|
extractRenderedRegions
|
|
19920
20088
|
};
|
|
19921
|
-
//# sourceMappingURL=chunk-
|
|
20089
|
+
//# sourceMappingURL=chunk-J45OVEUM.js.map
|