guerinoni / qTsConverter

A simple tool to convert qt translation file (ts) to other format (xlsx / csv) and vice versa
MIT License
42 stars 16 forks source link

[BUG] Xlsx exporter overwrites headers and then parser fails #83

Open warmist opened 1 year ago

warmist commented 1 year ago

Describe the bug

Xlsx exporter eats the headers.

To Reproduce Steps to reproduce the behavior:

  1. Export Xlsx
  2. Import back to ts
  3. Get error "Invalid XLSX file, check the headers!"

Expected behavior

Not have an error.

Desktop (please complete the following information):

Additional context Offending line: Xlsxbuilder.cpp:41

Reasoning:

hannes-ma commented 1 year ago

We have encountered the same error. Even though the xlsx file contains the correct header line as first line in the document.

I figured the parser always expects on import that the version info is present on the first 2 rows and looks for the header line on the 3rd row. Version output can be omitted at export by setting the parameter "--no-version".

XslxParser.cpp:22: const auto appVersion = qApp->applicationVersion(); const auto currentVersion = QVersionNumber::fromString(appVersion); const auto TsSupportVersion = QVersionNumber(4, 5, 0); InOutParameter p{ "", "", m_ioParameter.tsVersion, {} }; if (QVersionNumber::compare(currentVersion, TsSupportVersion) >= 0) { p.tsVersion = xlsx.read(2, 1).toString(); offsetRow = 2; }

IMO it should be checked that the document contains the ts version info and only if present advance by 2 rows: if (QVersionNumber::compare(currentVersion, TsSupportVersion) >= 0) { if (xlsx.read(1,1) == TitleHeader::TsVersion) { p.tsVersion = xlsx.read(2, 1).toString(); offsetRow = 2; } }

EDIT: github code tag is somehow messing up my code formatting...don't know how to fix that, sry for that.