fix(libreoffice): use separate input/output filters and add Calc category
LibreOffice Writer has no CSV export filter. The shared filter map used Text for csv in both directions, which made any Writer-category conversion to csv fail with: no export filter for <file>.csv found, aborting. Root cause: getFilters() looked up the same filters map for the infilter and the outfilter. Text is a valid *input* filter for reading delimiter- separated files in Writer but is not accepted as an *output* filter for the .csv extension. Fix: - Split into separate inputFilters / outputFilters maps so csv can remain readable by the text (Writer) category without offering it as a write target there. - Remove csv from properties.to.text so the UI/router no longer exposes the unsupported Writer → CSV path. - Populate the previously-empty filters.calc with correct LibreOffice Calc filter names and add spreadsheet formats to properties.from.calc / properties.to.calc, enabling conversions such as xlsx → csv, csv → xlsx, ods → xlsx, etc. via the Calc module. Fixes #561 Signed-off-by: Radhakrishnan Pachyappan <gingeekrishna@gmail.com>
This commit is contained in:
parent
0965928949
commit
089105fd09
2 changed files with 150 additions and 7 deletions
|
|
@ -166,3 +166,59 @@ test("logs stderr on exec error as well", async () => {
|
|||
// The callback still provided stderr; your implementation logs it before settling
|
||||
expect(errors).toContain("stderr: EPIPE");
|
||||
});
|
||||
|
||||
// --- calc (spreadsheet) category --------------------------------------------
|
||||
test("uses Calc infilter and outfilter for xlsx -> csv (regression for issue #561)", async () => {
|
||||
await convert("in.xlsx", "xlsx", "csv", "out/out.csv", undefined, mockExecFile);
|
||||
|
||||
const { args } = requireDefined(calls[0], "Expected at least one execFile call");
|
||||
expect(args).toEqual([
|
||||
"--headless",
|
||||
"--infilter=Calc MS Excel 2007 XML",
|
||||
"--convert-to",
|
||||
"csv:Text - txt - csv (StarCalc)",
|
||||
"--outdir",
|
||||
"out",
|
||||
"in.xlsx",
|
||||
]);
|
||||
});
|
||||
|
||||
test("uses Calc infilter and outfilter for csv -> xlsx", async () => {
|
||||
await convert("in.csv", "csv", "xlsx", "out/out.xlsx", undefined, mockExecFile);
|
||||
|
||||
const { args } = requireDefined(calls[0], "Expected at least one execFile call");
|
||||
expect(args).toEqual([
|
||||
"--headless",
|
||||
"--infilter=Text - txt - csv (StarCalc)",
|
||||
"--convert-to",
|
||||
"xlsx:Calc MS Excel 2007 XML",
|
||||
"--outdir",
|
||||
"out",
|
||||
"in.csv",
|
||||
]);
|
||||
});
|
||||
|
||||
test("uses Calc infilter and outfilter for ods -> xlsx", async () => {
|
||||
await convert("in.ods", "ods", "xlsx", "out/out.xlsx", undefined, mockExecFile);
|
||||
|
||||
const { args } = requireDefined(calls[0], "Expected at least one execFile call");
|
||||
expect(args).toEqual([
|
||||
"--headless",
|
||||
"--infilter=calc8",
|
||||
"--convert-to",
|
||||
"xlsx:Calc MS Excel 2007 XML",
|
||||
"--outdir",
|
||||
"out",
|
||||
"in.ods",
|
||||
]);
|
||||
});
|
||||
|
||||
test("pdf -> csv produces no filters (cross-category: not supported via LibreOffice Writer)", async () => {
|
||||
await convert("in.pdf", "pdf", "csv", "out/out.csv", undefined, mockExecFile);
|
||||
|
||||
const { args } = requireDefined(calls[0], "Expected at least one execFile call");
|
||||
// pdf is Writer-category; csv output requires Calc — no valid cross-category
|
||||
// filter exists, so soffice is invoked without explicit filters and will fail
|
||||
// gracefully. The properties list no longer exposes this combination.
|
||||
expect(args).toEqual(["--headless", "--convert-to", "csv", "--outdir", "out", "in.pdf"]);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue