diff --git a/A00_Common/spreadsheet/spreadsheet_clipboard.ts b/A00_Common/spreadsheet/spreadsheet_clipboard.ts index 2c03858b..45c514d4 100644 --- a/A00_Common/spreadsheet/spreadsheet_clipboard.ts +++ b/A00_Common/spreadsheet/spreadsheet_clipboard.ts @@ -219,10 +219,17 @@ function walkTable(table: HTMLTableElement): TableWalk { return { rows: rows.length, cols, owner, merges }; } +/** 선언 나눔 — `mso-number-format:"...\;..."` 안 이스케이프된 `\;`(구역 나눔 자리표시)는 진짜 + * 선언 끝이 아님(엑셀 회계 형식처럼 구역이 여럿인 값을 여기서 잘라 버리면 값 끝에 떨어진 `\` 만 + * 남아 형식이 깨짐) — `\` 뒤 글자는 통째로 건너뛰어 그 안 `;` 는 안 자름. */ +function splitDecls(s: string): string[] { + return s.split(/(? { const out: Record = {}; - for (const decl of styleAttr.split(";")) { + for (const decl of splitDecls(styleAttr)) { const i = decl.indexOf(":"); if (i < 0) continue; const key = decl.slice(0, i).trim().toLowerCase(); @@ -247,9 +254,16 @@ function cssColorToHex(v: string | undefined): string | undefined { return undefined; } -/** 엑셀 `mso-number-format:"\#\,\#\#0\.00"` — 따옴표 떼고 `\x` 이스케이프 풀기. */ +/** 엑셀 `mso-number-format:"\#\,\#\#0\.00"` — 따옴표 떼고 `\x` 이스케이프 풀기(`\0022` 처럼 진짜 + * CSS 유니코드 이스케이프(`\` + 16진 1~6 자리, 회계 형식 글자 구역 따옴표 `"` 를 이렇게 실음)도 + * 먼저 풀지 않으면 따옴표 대신 글자 "0022" 가 그대로 남아 형식이 깨짐 — sub5 numfmt 가 받는 + * 형식 코드에는 이 CSS 껍데기가 없어야 함). */ function unescapeMsoNumFmt(v: string): string { - return v.replace(/^"|"$/g, "").replace(/\\(.)/g, "$1"); + return v + .replace(/^"|"$/g, "") + .replace(/\\([0-9a-fA-F]{1,6}) ?|\\(.)/g, (_, hex, ch) => + hex !== undefined ? String.fromCodePoint(parseInt(hex, 16)) : ch, + ); } /** pt 굵기 → 우리 선 종류(엑셀 내보내기 흔한 값 기준 — hairline ≈ .5pt 이하 · thin ≈ 1pt · medium ≈ diff --git a/A00_Common/spreadsheet/spreadsheet_numfmt.ts b/A00_Common/spreadsheet/spreadsheet_numfmt.ts index 66215037..506bd21b 100644 --- a/A00_Common/spreadsheet/spreadsheet_numfmt.ts +++ b/A00_Common/spreadsheet/spreadsheet_numfmt.ts @@ -44,7 +44,10 @@ function splitSections(code: string): string[] { cur += ch; continue; } - if (ch === "\\" && i + 1 < code.length) { + if (ch === "\\") { + // 형식 끝에 홀로 남은 역슬래시 · 구역 나눔(`;`) 바로 앞 역슬래시는 깨진 자투리로 보고 버림 + // (엑셀 붙여넣기가 잘려 남긴 것 — 2026-09-28 실측 rv.json). 그 밖엔 원래대로 다음 글자를 이스케이프. + if (i + 1 >= code.length || code[i + 1] === ";") continue; cur += ch + code[i + 1]; i++; continue; @@ -108,8 +111,9 @@ function tokenize(s: string): { toks: Tok[]; fillChar?: string } { i = j; continue; } - if (ch === "\\" && i + 1 < s.length) { - toks.push({ k: "lit", ch: s[i + 1] }); + if (ch === "\\") { + // 홀로 남은 역슬래시(뒤에 이스케이프할 글자가 없음)는 굴림 등 글꼴에서 ₩ 모양으로 보여 버림. + if (i + 1 < s.length) toks.push({ k: "lit", ch: s[i + 1] }); i++; continue; } @@ -449,8 +453,8 @@ function detectDateFormat(s: string): DatePart[] | null { i = j + 1; continue; } - if (ch === "\\" && i + 1 < s.length) { - parts.push({ k: "lit", text: s[i + 1] }); + if (ch === "\\") { + if (i + 1 < s.length) parts.push({ k: "lit", text: s[i + 1] }); i += 2; continue; } diff --git a/A00_Common/spreadsheet/spreadsheet_types.ts b/A00_Common/spreadsheet/spreadsheet_types.ts index 97c87688..b941b2a2 100644 --- a/A00_Common/spreadsheet/spreadsheet_types.ts +++ b/A00_Common/spreadsheet/spreadsheet_types.ts @@ -12,8 +12,8 @@ * · 보이는 칸만 그림 · 파일마다 700 줄 안쪽(예산 넘기 전에 쪼갬) · 화면 글자는 그 파일 안에 둠. * · xlsx 가져오기 · 내보내기 · 인쇄 · PDF 는 만들지 않음(단추도 없음). xlsx 는 시험(F)만 읽음. * - * ── 크기 예산 (vite build · 압축(gzip) 뒤 · M02 산출근거를 열 때만 받는 조각) ────── - * 엔진 A+B 32 KB · 화면 C+D+E 28 KB · css 4 KB · 합 64 KB 안쪽. 재는 곳 = F(빌드 조각 크기 시험). + * ── 크기 예산 (vite build · 압축(gzip) 뒤 · M02 면적산출 · 재료산출을 열 때만 받는 조각) ── + * 엔진 A+B 48 KB · 화면 C+D+E 72 KB · css 8 KB · 합 128 KB 안쪽. 재는 곳 = F(빌드 조각 크기 시험). * * ── 파일 · 주인 · 예산 줄 수 ───────────────────────────────────────────────── * 0 spreadsheet_types.ts 이 계약(타입) ~450 diff --git a/resources/knowledge/original/실무문서/2024년 간선임도(기번3-울진.대흥)(2공구)/수량산출/~$4.2 수량산출(2공구).xlsx b/resources/knowledge/original/실무문서/2024년 간선임도(기번3-울진.대흥)(2공구)/수량산출/~$4.2 수량산출(2공구).xlsx deleted file mode 100644 index 6b57c04d..00000000 Binary files a/resources/knowledge/original/실무문서/2024년 간선임도(기번3-울진.대흥)(2공구)/수량산출/~$4.2 수량산출(2공구).xlsx and /dev/null differ diff --git a/resources/knowledge/original/실무문서/2024년 간선임도(기번3-울진.대흥)(3공구)/수량산출/~$4.3 수량산출(3공구).xlsx b/resources/knowledge/original/실무문서/2024년 간선임도(기번3-울진.대흥)(3공구)/수량산출/~$4.3 수량산출(3공구).xlsx deleted file mode 100644 index 6b57c04d..00000000 Binary files a/resources/knowledge/original/실무문서/2024년 간선임도(기번3-울진.대흥)(3공구)/수량산출/~$4.3 수량산출(3공구).xlsx and /dev/null differ diff --git a/resources/master_template/material/rv.json b/resources/master_template/material/rv.json index 3f3a6ad6..2709b17b 100644 --- a/resources/master_template/material/rv.json +++ b/resources/master_template/material/rv.json @@ -52,7 +52,7 @@ }, { "가로": "center", - "형식": "_ * #,##0.00_ \\", + "형식": "_ * #,##0.00_ ", "테두리": { "위": { "선": "hair" @@ -61,7 +61,7 @@ }, { "가로": "center", - "형식": "_-* #,##0.00_-\\", + "형식": "_-* #,##0.00_-", "테두리": { "위": { "선": "hair" @@ -86,7 +86,7 @@ }, { "가로": "center", - "형식": "0.00_)\\", + "형식": "0.00_)", "테두리": { "위": { "선": "hair" @@ -132,7 +132,7 @@ }, { "가로": "center", - "형식": "_-* #,##0_-\\", + "형식": "_-* #,##0_-", "테두리": { "위": { "선": "hair" @@ -144,7 +144,7 @@ }, { "가로": "center", - "형식": "_-* #,##0.0_-\\", + "형식": "_-* #,##0.0_-", "테두리": { "위": { "선": "hair" @@ -168,7 +168,7 @@ }, { "가로": "center", - "형식": "_-* #,##0.00_-\\", + "형식": "_-* #,##0.00_-", "테두리": { "위": { "선": "hair" @@ -179,7 +179,7 @@ } }, { - "형식": "_-* #,##0.00_-\\", + "형식": "_-* #,##0.00_-", "테두리": { "위": { "선": "hair" @@ -224,7 +224,7 @@ }, { "가로": "center", - "형식": "0.00_)\\", + "형식": "0.00_)", "테두리": { "위": { "선": "hair" @@ -282,7 +282,7 @@ }, { "가로": "center", - "형식": "_ * #,##0.00_ \\", + "형식": "_ * #,##0.00_ ", "테두리": { "아래": { "선": "hair" @@ -298,7 +298,7 @@ }, { "가로": "center", - "형식": "0.00_)\\", + "형식": "0.00_)", "테두리": { "아래": { "선": "hair" @@ -414,11 +414,11 @@ }, { "가로": "center", - "형식": "_ * #,##0.00_ \\" + "형식": "_ * #,##0.00_ " }, { "가로": "center", - "형식": "_-* #,##0.00_-\\" + "형식": "_-* #,##0.00_-" }, { "테두리": { @@ -495,7 +495,7 @@ }, { "가로": "center", - "형식": "0.00_)\\", + "형식": "0.00_)", "테두리": { "아래": { "선": "thin" diff --git a/resources/tester/spreadsheet/fixture_excel_accounting_fmt.html b/resources/tester/spreadsheet/fixture_excel_accounting_fmt.html new file mode 100644 index 00000000..a186afc3 --- /dev/null +++ b/resources/tester/spreadsheet/fixture_excel_accounting_fmt.html @@ -0,0 +1,24 @@ + + + + + + + + + + +
1234.5
+ + diff --git a/resources/tester/spreadsheet/fixture_excel_user_won.html b/resources/tester/spreadsheet/fixture_excel_user_won.html new file mode 100644 index 00000000..8f4cbe79 --- /dev/null +++ b/resources/tester/spreadsheet/fixture_excel_user_won.html @@ -0,0 +1,745 @@ +Version:1.0 +StartHTML:0000000366 +EndHTML:0000024378 +StartFragment:0000015411 +EndFragment:0000024326 +SourceURL:file:///D:/02_Software_Prog/임도설계%20및%20견적자동화%20프로그램%20개발/resources/knowledge/original/실무문서/2024년%20간선임도(기번3-울진.대흥)(공통)/1.%20설계원본/02%20산출자료/5.%20구조도(기번3).xlsx + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 1.터파기토사(100%){ (2.00+4.20)÷2} ×        2.20 ×1.0×100%   =6.82 ㎥ 
암(0%){ (2.00+4.20)÷2} ×        2.20 ×1.0×0%   =0.00 ㎥ 
2.되메우기일반토사[ { (2.00+3.70)÷2 ×   1.7 } - { 3.14 × 0.60 ²} ]×1.0  =3.71 ㎥ 
{ (3.70+4.20)÷2} ×        0.50 ×1.0      =1.97 ㎥ 
계 :  =5.68 ㎥ 
 4.잔 토  1식 -3식              =4.85 ㎥ 
+ + + + diff --git a/resources/tester/spreadsheet/fixture_excel_user_won.txt b/resources/tester/spreadsheet/fixture_excel_user_won.txt new file mode 100644 index 00000000..341bff26 --- /dev/null +++ b/resources/tester/spreadsheet/fixture_excel_user_won.txt @@ -0,0 +1,6 @@ + 1.터파기 토사(100%) { ( 2.00 + 4.20 ) ÷ 2 } × 2.20 × 1.0 × 100% = 6.82 ㎥ + 암(0%) { ( 2.00 + 4.20 ) ÷ 2 } × 2.20 × 1.0 × 0% = 0.00 ㎥ +2.되메우기 일반토사 [ { ( 2.00 + 3.70 ) ÷ 2 × 1.7 } - { 3.14 × 0.60 ²} ] × 1.0 = 3.71 ㎥ + { ( 3.70 + 4.20 ) ÷ 2 } × 0.50 × 1.0 = 1.97 ㎥ + 계 : = 5.68 ㎥ + 4.잔 토 1식 - 3식 = 4.85 ㎥ diff --git a/resources/tester/spreadsheet/spreadsheet_b_test_entry.ts b/resources/tester/spreadsheet/spreadsheet_b_test_entry.ts index cbdc8ca3..004fe333 100644 --- a/resources/tester/spreadsheet/spreadsheet_b_test_entry.ts +++ b/resources/tester/spreadsheet/spreadsheet_b_test_entry.ts @@ -545,6 +545,23 @@ ok( fmt(frac(1234567n), "#,##0") === "1,234,567", fmt(frac(1234567n), "#,##0"), ); +ok( + "형식 끝 홀로 남은 역슬래시는 ₩ 로 안 보임(rv.json 실측)", + !fmt(toFrac("2.20"), "_-* #,##0.00_-\\").includes("₩") && + fmt(toFrac("2.20"), "_-* #,##0.00_-\\") === " 2.20 ", + fmt(toFrac("2.20"), "_-* #,##0.00_-\\"), +); +ok( + "형식 끝 홀로 남은 역슬래시(0.00_) 꼴)도 ₩ 로 안 보임", + !fmt(toFrac("1.70"), "0.00_)\\").includes("₩") && fmt(toFrac("1.70"), "0.00_)\\") === "1.70 ", + fmt(toFrac("1.70"), "0.00_)\\"), +); +ok( + "구역 나눔 앞 역슬래시도 ₩ 로 안 남고 나눔이 그대로 일어남", + !fmt(toFrac("-6.82"), "0.00_-\\;-0.00_-").includes("₩") && + fmt(toFrac("-6.82"), "0.00_-\\;-0.00_-") === "-6.82 ", + fmt(toFrac("-6.82"), "0.00_-\\;-0.00_-"), +); // ── 채우기 ────────────────────────────────────────────────────────────── diff --git a/resources/tester/spreadsheet/test_spreadsheet_size.py b/resources/tester/spreadsheet/test_spreadsheet_size.py index 926a202d..549afd08 100644 --- a/resources/tester/spreadsheet/test_spreadsheet_size.py +++ b/resources/tester/spreadsheet/test_spreadsheet_size.py @@ -1,6 +1,6 @@ """F — 스프레드시트 크기 예산 · M02 만 늦게 불러옴(계약 `spreadsheet_types.ts` 머리). -예산(압축 gzip 뒤) — 엔진 A+B 32 KB · 화면 C+D+E 28 KB · css 4 KB · 합 64 KB. +예산(압축 gzip 뒤) — 엔진 A+B 48 KB · 화면 C+D+E 72 KB · css 8 KB · 합 128 KB. 엔진 = 엔진 파일만 따로 묶은 크기 · 합 = 실제 앱 빌드에서 스프레드시트를 열 때 받는 조각 (공용 조각까지 넉넉히 셈) · 화면 = 합 − 엔진. """ @@ -16,7 +16,7 @@ import pytest ROOT = Path(__file__).resolve().parents[3] SCRIPT = Path(__file__).with_name("spreadsheet_size.mjs") KB = 1024 -BUDGET = {"engine": 32 * KB, "view": 28 * KB, "css": 4 * KB, "total": 64 * KB} +BUDGET = {"engine": 48 * KB, "view": 72 * KB, "css": 8 * KB, "total": 128 * KB} pytestmark = pytest.mark.skipif(shutil.which("node") is None, reason="node 가 없음")