Bug 55786 - FILEOPEN: read error for unsupported Lotus123 .wk3, .wk4
Summary: FILEOPEN: read error for unsupported Lotus123 .wk3, .wk4
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: filters and storage (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: x86-64 (AMD64) All
: low enhancement
Assignee: osnola
URL:
Whiteboard: target:5.0.0
Keywords:
Depends on:
Blocks:
 
Reported: 2012-10-09 00:15 UTC by Horst
Modified: 2015-05-19 08:30 UTC (History)
7 users (show)

See Also:
Crash report or crash signature:


Attachments
.wk4 example (14.55 KB, application/vnd.lotus-1-2-3)
2012-10-09 00:15 UTC, Horst
Details
universal-content.wk4 (2.89 KB, application/vnd.lotus-1-2-3)
2012-10-09 00:37 UTC, Horst
Details
universal-content.wk3 (516 bytes, application/vnd.lotus-1-2-3)
2012-10-09 00:43 UTC, Horst
Details
universal-content.fm3 (516 bytes, application/vnd.lotus-1-2-3)
2012-10-09 00:44 UTC, Horst
Details
universal-content.wk1 (667 bytes, application/vnd.lotus-1-2-3)
2012-10-09 00:45 UTC, Horst
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Horst 2012-10-09 00:15:35 UTC
Created attachment 68303 [details]
.wk4 example

When trying to open older Lotus 123 files with extensions .wks, .wk1 til .wk4 I get file read error after the question for the character set.
 "Read-Error unkown Lotus 1-2-3 file format"
Comment 1 Horst 2012-10-09 00:37:01 UTC
Created attachment 68305 [details]
universal-content.wk4

 .wk4 returns "file read error" after the question for the character set.
 "Read-Error unkown Lotus 1-2-3 file format"
Comment 2 Horst 2012-10-09 00:43:19 UTC
Created attachment 68306 [details]
universal-content.wk3

.wk3 returns "Read error, there is no filter available for this file type"

.FM3 file in next attaxchment.

Could not produce a .wk2 or .wks file.

.wk1 works fine.
Comment 3 Horst 2012-10-09 00:44:09 UTC
Created attachment 68307 [details]
universal-content.fm3
Comment 4 Horst 2012-10-09 00:45:27 UTC
Created attachment 68308 [details]
universal-content.wk1

for testing
Comment 5 Rainer Bielefeld Retired 2012-10-12 05:10:09 UTC
Hi Horst, LibO also can't open cans, but is that a bug?  ;-)
Additionally lifecycle of 3.5 has ended, so it's not useful to add Bugs there.
For gerneral criteria whether a bug should be rated as MAB please see <http://wiki.documentfoundation.org/Most_Annoying_Bugs>!

My results with "LibreOffice 3.5.7.2 rc German UI/Locale [Build-ID: 3215f89-f603614-ab984f2-7348103-1225a5b] on German WIN7 Home Premium (64bit): 

"universal-content.wk4": Error Message: "Unknown Lotus-123 format" . Result is expected, in Fileopen only .WK1, .WKS, .123 are offered. Master 3.7 also fails, like AOOo 3.4.1. Gnumeric 1.10.14 opens the document without problems. So we also should be able to do that?

"universal-content.wk3" in reality has name extension ".fm3" seems to be bit by bit identical with "universal-content.fm3", I do not know ".fm3". I also renamed second attachment to .wk3 and checked. None of the test programs was able to open the documents.

.wk1 can be opened without problems, as stated by reporter, so I obsolete this not required attachment

This is not a MAB, but  an enhancement request.
I believe this never worked , inherited from OOo, so I modified 

@Horst 
Please contribute info concerning "universal-content.wk3" - "universal-content.fm3", why did you attach 2 identical(?) documents?
Comment 6 Rainer Bielefeld Retired 2012-10-12 05:21:17 UTC
Can't see a regression (also not working in 3.3.3) so I remove Regression key work (@Markus: hope I did not miss something?)

Removed unrelated CRASH bugs.
Comment 7 Rainer Bielefeld Retired 2012-10-12 05:25:57 UTC
Comment on attachment 68308 [details]
universal-content.wk1

Is a document what can be imported without problems, so useless
Comment 8 Alex Thurgood 2012-10-12 06:12:59 UTC
Hi Rainer,

FM3 files are the formatting data for wk3 formatted files, so they go together with the wk3 file. Lotus 123 used to use both. See here :

http://www.fileinfo.com/extension/fm3


Not that that changes anything with respect to this bug report. I don't think these files were ever imported by OOo, let alone LO, so IMHO this would be a feature request, or enhancement of the existing file filters.

Alex
Comment 9 Horst 2012-10-12 22:10:15 UTC
1) I think Alex answered the question about not identical .wk3 and .fm3 file.

2) You are right it shows only .wks, .wk1 and .123 as legal imports. But it is odd that LO recognizes the Lotus format and I was browsing in the Lotus filter source and it has header readings for .wk3/.fm3 in it. So it looks somebody worked on this problem in the past (Markus?).

I opened this bug in response to Markus in bug 55222, which was not a crash but a read error. 

I can not decide right now how importent the import of older Lotus files is for the users of LO. .wk3 is first Win version of Lotus 1-2-3.

I would say if @markus sees it important and has nothing more important to do :-)) let him decide to change it to enhancement.

Thank for effort anyway and I am not realy glued to this bug.
Comment 10 Markus Mohrhard 2012-10-25 14:53:50 UTC
I'll make this one an easy hack at some point.

It is not a regression. Lotus filter import is not that important but I'm willing to mentor anyone wanting to spend some time improving the filter.

Some code pointers:

Lotus import code is in sc/source/filter/lotus/ and a file format specification is at http://www.schnarff.com/file-formats/lotus-1-2-3/WSFF2.TXT and http://www.schnarff.com/file-formats/lotus-1-2-3/WSFF1.TXT.

If you are interested in extending the support please contact me and I'll provide some smaller test documents.
Comment 11 Markus Mohrhard 2012-10-25 14:57:28 UTC
There are some more code pointers needed and I will add them as soon as someone shows interest in this easy hack.
Comment 12 Björn Michaelsen 2013-10-04 18:47:06 UTC
adding LibreOffice developer list as CC to unresolved EasyHacks for better visibility.

see e.g. http://nabble.documentfoundation.org/minutes-of-ESC-call-td4076214.html for details
Comment 13 Thomas Kluyver 2014-11-05 03:06:24 UTC
I had to spend a while digging into an old WK4 file to extract some data. I thought I'd document my main finding here:

opcode 0x17 appears to be a 10-byte extended precision float. After the record header, there is a two byte row number, one byte sheet number, and one byte column number. These are common to a few record types. The remainder of it is the value, in the format described here:

http://en.wikipedia.org/wiki/Extended_precision#x86_Extended_Precision_Format

I was able to extract these, at least for the small positive numbers in my sample, using the following Python code:

        a = int.from_bytes(r.data[-2:], 'little')
        sign = -1 if (a & (1<<15)) else 1
        e = a - (a & (1 << 15)) - 16383
        m = int.from_bytes(r.data[4:-2], 'little')
        val = m / (1<<(63-e))

0x16 is a label, with the same row/sheet/column fields.

I started looking into making a patch, but I got confused because there appear to be opcode lookup tables both in optab.cxx and as switch statements in lotread.cxx, with different opcodes in them.
Comment 14 osnola 2015-02-19 16:59:57 UTC
Hello,
just for note as I am working on libwps(*) on a filter for Lotus wk3, wk4 files, ... 

The following opcodes stores the main content:
- 0x16: contains the text strings, 
- 0x17: contains big float ( 10 bytes)
- 0x18: contains small int/float ( 2 bytes)
- 0x19: contains big float ( 10 bytes ) + a formula + sometimes a string ( maybe comment)
- 0x1a: contains a string ( the result of a formula )
while the opcode 0x1b stores different data : colors, font names, graphic styles, graphic, ....

You can find some details in the file Lotus.cpp ( function LotusParser::readZone ), LotusSpreadsheet.cpp at http://sourceforge.net/p/libwps/code/ci/master/tree/src/lib/
( even if this is a work in progress )

(*) by error, libwps can already read the wk1 files ( which shares the same format as MsWorks DOS Wks files ), so why not convert also the other Lotus's files :-~
Comment 15 David Tardon 2015-02-20 09:23:26 UTC
Let's mark this as assigned then. We will close it when the new libwps is integrated to LibreOffice.