Мост .doc → .docx: конвертация бинарного Word 97-2003 (MS-DOC/MS-CFB/MS-OLEPS/MS-ODRAW)
PR checks / java (pull_request) Successful in 1m17s
PR checks / web (pull_request) Successful in 16m43s

- internal/doc: CfbReader, FibHeader, PieceTable, Grpprl, ChpxIndex, PapxIndex,
  Sections, FontTable, SummaryInfo, Headers, OfficeArt, DocFile, DocxWriter,
  DocToDocx — разбор бинарного .doc и сборка in-memory .docx (прямые свойства,
  колонтитуки с PAGE/NUMPAGES → fldSimple, BLIP-картинки PNG/JPEG/DIB)
- роутинг WordPdfConverter по сигнатуре CFB; валидация страниц .doc по сырым
  байтам (SummaryInfo PageCount + 0x0C + pageBreakBefore) до конвертации
- .docx/.doc: ConvertController, safeBaseName, фронт (DropZone accept)
- фикстуры: 12 .doc (11 эталонов заказчика + doc-formats); doc-пары тестов
- тесты: 13 классов internal/doc (98 @Test) + пары в конвертере/валидаторе/app;
  гейт mvn clean verify зелёный (core BRANCH 0.852, LINE 0.947)
- AGENTS.md: секция «Мост .doc → .docx», обновлены счётчики и каталоги
This commit is contained in:
Pjandro
2026-10-29 23:51:42 +00:00
parent abfa673b85
commit ef3feaa94d
52 changed files with 4739 additions and 84 deletions
+1 -1
View File
@@ -64,7 +64,7 @@ export async function convertDocx(
// флаг i обязателен; фолбэк — имя исходника с заменой расширения
const cd = resp.headers.get('Content-Disposition') ?? ''
const m = /filename\*=utf-8''([^;]+)/i.exec(cd)
const filename = m ? decodeURIComponent(m[1]) : file.name.replace(/\.docx$/i, '') + '.pdf'
const filename = m ? decodeURIComponent(m[1]) : file.name.replace(/\.docx?$/i, '') + '.pdf'
const blob = await resp.blob()
return { blob, filename }
}
+1 -1
View File
@@ -130,7 +130,7 @@ export default function App() {
<div>
<h1 className="text-2xl font-semibold">Word → PDF</h1>
<p className="mt-1 text-sm text-muted">
docx → PDF на docx4j + Apache FOP. Лимиты задаёт сервер;
docx/doc → PDF на docx4j + Apache FOP. Лимиты задаёт сервер;
переопределение из формы убрано.
</p>
</div>
+3 -3
View File
@@ -8,7 +8,7 @@ interface Props {
}
/**
* Зона drag&drop + клик для выбора .docx. Скрытый input[type=file] —
* Зона drag&drop + клик для выбора .docx/.doc. Скрытый input[type=file] —
* единственный источник выбора; drop берёт первый файл.
*/
export default function DropZone({ file, disabled, onSelect }: Props) {
@@ -53,7 +53,7 @@ export default function DropZone({ file, disabled, onSelect }: Props) {
<path d="M12 16V4m0 0-4 4m4-4 4 4" />
<path d="M4 16v3a1 1 0 0 0 1 1h14a1 1 0 0 0 1-1v-3" />
</svg>
<span>Перетащите .docx сюда или нажмите для выбора</span>
<span>Перетащите .docx или .doc сюда или нажмите для выбора</span>
{file && (
<span className="text-sm text-muted">
{file.name} · {(file.size / 1024).toFixed(0)} КБ
@@ -62,7 +62,7 @@ export default function DropZone({ file, disabled, onSelect }: Props) {
<input
ref={inputRef}
type="file"
accept=".docx"
accept=".docx,.doc"
className="sr-only"
disabled={disabled}
onChange={(e) => {