2015-06-01 09:35:51 +00:00
|
|
|
package com.bytezone.diskbrowser.applefile;
|
|
|
|
|
2016-03-06 08:05:32 +00:00
|
|
|
import com.bytezone.diskbrowser.visicalc.Sheet;
|
2015-06-01 09:35:51 +00:00
|
|
|
|
2020-02-07 11:44:51 +00:00
|
|
|
// -----------------------------------------------------------------------------------//
|
2015-06-01 09:35:51 +00:00
|
|
|
public class VisicalcFile extends AbstractFile
|
2020-02-07 11:44:51 +00:00
|
|
|
// -----------------------------------------------------------------------------------//
|
2015-06-01 09:35:51 +00:00
|
|
|
{
|
2016-03-14 22:35:22 +00:00
|
|
|
private static boolean debug;
|
2016-03-06 08:05:32 +00:00
|
|
|
private Sheet sheet;
|
2015-06-01 09:35:51 +00:00
|
|
|
|
2020-02-07 11:44:51 +00:00
|
|
|
// ---------------------------------------------------------------------------------//
|
2015-06-01 09:35:51 +00:00
|
|
|
public VisicalcFile (String name, byte[] buffer)
|
2020-02-07 11:44:51 +00:00
|
|
|
// ---------------------------------------------------------------------------------//
|
2015-06-01 09:35:51 +00:00
|
|
|
{
|
|
|
|
super (name, buffer);
|
|
|
|
}
|
|
|
|
|
2020-02-07 11:44:51 +00:00
|
|
|
// ---------------------------------------------------------------------------------//
|
2015-06-01 09:35:51 +00:00
|
|
|
@Override
|
|
|
|
public String getText ()
|
2020-02-07 11:44:51 +00:00
|
|
|
// ---------------------------------------------------------------------------------//
|
2015-06-01 09:35:51 +00:00
|
|
|
{
|
|
|
|
if (sheet == null)
|
2016-03-06 08:05:32 +00:00
|
|
|
sheet = new Sheet (buffer);
|
2015-06-01 09:35:51 +00:00
|
|
|
|
|
|
|
StringBuilder text = new StringBuilder ();
|
|
|
|
|
2017-03-08 09:18:59 +00:00
|
|
|
text.append ("Visicalc : " + name + "\n\n");
|
2016-03-14 22:35:22 +00:00
|
|
|
text.append (sheet.getTextDisplay (debug));
|
|
|
|
|
2015-06-01 09:35:51 +00:00
|
|
|
return text.toString ();
|
|
|
|
}
|
|
|
|
|
2020-02-07 11:44:51 +00:00
|
|
|
// ---------------------------------------------------------------------------------//
|
2016-03-14 22:35:22 +00:00
|
|
|
public static void setDefaultDebug (boolean value)
|
2020-02-07 11:44:51 +00:00
|
|
|
// ---------------------------------------------------------------------------------//
|
2016-03-14 22:35:22 +00:00
|
|
|
{
|
|
|
|
debug = value;
|
|
|
|
}
|
|
|
|
|
2020-02-07 11:44:51 +00:00
|
|
|
// ---------------------------------------------------------------------------------//
|
2016-03-23 23:37:59 +00:00
|
|
|
public static void setDebug (boolean value)
|
2020-02-07 11:44:51 +00:00
|
|
|
// ---------------------------------------------------------------------------------//
|
2016-03-14 22:35:22 +00:00
|
|
|
{
|
|
|
|
debug = value;
|
|
|
|
}
|
|
|
|
|
2020-02-07 11:44:51 +00:00
|
|
|
// ---------------------------------------------------------------------------------//
|
2015-06-01 09:35:51 +00:00
|
|
|
public static boolean isVisicalcFile (byte[] buffer)
|
2020-02-07 11:44:51 +00:00
|
|
|
// ---------------------------------------------------------------------------------//
|
2015-06-01 09:35:51 +00:00
|
|
|
{
|
|
|
|
int firstByte = buffer[0] & 0xFF;
|
|
|
|
if (firstByte != 0xBE && firstByte != 0xAF)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
int last = buffer.length - 1;
|
|
|
|
|
|
|
|
while (buffer[last] == 0)
|
|
|
|
last--;
|
|
|
|
|
|
|
|
if (buffer[last] != (byte) 0x8D)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|