Currently all empty (0-byte) files are detected as HTML/Web files (this is actually a change in 6.2.0.3 since 6.1.0.3, until then they were detected as text files). Since there's no other identifying information, they should be detected based on extension. Current behavior is a problem, because in Windows right click -> New -> <various MS Office formats> tend to create 0-byte files with MS Office installed, and opening and editing them in LibreOffice can cause confusion and potential data loss if the user doesn't notice the wrong format before saving their document.
Well - then not only detection should be changed, but also something needs to be done with document initialization as well - because *reading* from such a file using detected filter would be impossible.
See also: https://ask.libreoffice.org/en/question/179707 https://ask.libreoffice.org/en/question/178368
Regarding the initialization: should something specific be done with the new document depending on the filter? E.g., for a 0-byte .docx, should we simply create a new Writer document (using default template) and set its filter to DOCX, or should we initialize it as if that is a DOCX - which would mean different default fonts, compatibility options, etc. (whatever is done in DOCX importer when a valid DOCX is imported, before actual DOCX data is read)? Should all filters be modified to be able to do that then? Would that require to have own default templates for all filters, of should the one default template for the module be used anyway, with application of filter-specific modifications (with a risk of the resulting new document to differ from the template as used in normal new document creation)?
(In reply to Mike Kaganski from comment #1) > Well - then not only detection should be changed, but also something needs > to be done with document initialization as well - because *reading* from > such a file using detected filter would be impossible. Sure, the point is not to read from an empty file, but to correctly initialize one.
(In reply to Mike Kaganski from comment #3) > Regarding the initialization: should something specific be done with the new > document depending on the filter? E.g., for a 0-byte .docx, should we simply > create a new Writer document (using default template) and set its filter to > DOCX, or should we initialize it as if that is a DOCX - which would mean > different default fonts, compatibility options, etc. (whatever is done in > DOCX importer when a valid DOCX is imported, before actual DOCX data is > read)? Should all filters be modified to be able to do that then? Would that > require to have own default templates for all filters, of should the one > default template for the module be used anyway, with application of > filter-specific modifications (with a risk of the resulting new document to > differ from the template as used in normal new document creation)? All very good questions, I'd say just create an empty document/spreadsheet/presentation, set the export type to the identified one, and do an export+import cycle. Out of that the last step is optional if it'd be a larger task, the most important is to start in the correct application and set the correct save format. While I think the above method would be applicable to most formats, it's really relevant for the formats that could come in as 0-byte files in real life, ie. the ones that can be created by MS Office via Explorer context menu.
I plan to look at this.
Miklos Vajna committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/ada07f303e7cd1e39c73abe0741aefe7d9d73a57 tdf#123476 filter: try to detect 0-byte files based on extension It will be available in 7.1.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Mike Kaganski committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/2854362f429e476d4a1ab4759c6a1f1c04150280 tdf#123476 filter: Also handle empty ODF It will be available in 7.2.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Mike Kaganski committed a patch related to this issue. It has been pushed to "libreoffice-7-1": https://git.libreoffice.org/core/commit/e3307e5e76d5c35ee79b262d519c4a777acce536 tdf#123476 filter: Also handle empty ODF It will be available in 7.1.1. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.