From c40ac67be90f9d15b65f0ad0e369f807f2206986 Mon Sep 17 00:00:00 2001 From: Denis Molony Date: Sun, 19 Mar 2017 20:52:36 +1100 Subject: [PATCH] check font --- .../diskbrowser/applefile/FontFile.java | 10 +++++++++ .../diskbrowser/dos/AbstractCatalogEntry.java | 6 ++--- .../diskbrowser/visicalc/Condition.java | 5 +---- .../diskbrowser/visicalc/ConditionList.java | 6 ++--- src/com/bytezone/diskbrowser/visicalc/If.java | 2 +- .../bytezone/diskbrowser/visicalc/Sheet.java | 22 +++++++++---------- .../diskbrowser/visicalc/ValueList.java | 11 +++++++++- 7 files changed, 39 insertions(+), 23 deletions(-) diff --git a/src/com/bytezone/diskbrowser/applefile/FontFile.java b/src/com/bytezone/diskbrowser/applefile/FontFile.java index 8abbdb8..ed2cd91 100644 --- a/src/com/bytezone/diskbrowser/applefile/FontFile.java +++ b/src/com/bytezone/diskbrowser/applefile/FontFile.java @@ -66,6 +66,16 @@ public class FontFile extends AbstractFile return text.toString (); } + public static boolean isFont (byte[] buffer) + { + if (buffer.length % 8 != 0) + return false; + for (int i = 0; i < 8; i++) + if (buffer[i] != 0 && buffer[i] != 0x7F) + return false; + return true; + } + class Character { String[] lines = new String[8]; diff --git a/src/com/bytezone/diskbrowser/dos/AbstractCatalogEntry.java b/src/com/bytezone/diskbrowser/dos/AbstractCatalogEntry.java index 50822e2..7a20fb2 100644 --- a/src/com/bytezone/diskbrowser/dos/AbstractCatalogEntry.java +++ b/src/com/bytezone/diskbrowser/dos/AbstractCatalogEntry.java @@ -197,9 +197,9 @@ abstract class AbstractCatalogEntry implements AppleFileSource exactBuffer = new byte[buffer.length - 4]; // reported length is too long System.arraycopy (buffer, 4, exactBuffer, 0, exactBuffer.length); - - if (name.endsWith (".FONT") || name.endsWith (" FONT") || name.endsWith (".SET") - || name.startsWith ("ASCII.")) + if ((name.endsWith (".FONT") || name.endsWith (" FONT") + || name.endsWith (".SET") || name.startsWith ("ASCII.")) + && FontFile.isFont (exactBuffer)) appleFile = new FontFile (name, exactBuffer); else if (ShapeTable.isShapeTable (exactBuffer)) appleFile = new ShapeTable (name, exactBuffer); diff --git a/src/com/bytezone/diskbrowser/visicalc/Condition.java b/src/com/bytezone/diskbrowser/visicalc/Condition.java index f48c309..35aa6f9 100644 --- a/src/com/bytezone/diskbrowser/visicalc/Condition.java +++ b/src/com/bytezone/diskbrowser/visicalc/Condition.java @@ -7,8 +7,6 @@ class Condition extends AbstractValue implements Iterable { private static final String[] comparators = { "<>", "<=", ">=", "=", "<", ">" }; - private final Sheet parent; - private String comparator; private String conditionText; private String valueText; @@ -17,10 +15,9 @@ class Condition extends AbstractValue implements Iterable private Expression conditionExpression; private Expression valueExpression; - public Condition (Sheet parent, Cell cell, String text) + public Condition (Cell cell, String text) { super ("Cond"); - this.parent = parent; fullText = text; for (String comp : comparators) diff --git a/src/com/bytezone/diskbrowser/visicalc/ConditionList.java b/src/com/bytezone/diskbrowser/visicalc/ConditionList.java index d5b6e67..c2d943c 100644 --- a/src/com/bytezone/diskbrowser/visicalc/ConditionList.java +++ b/src/com/bytezone/diskbrowser/visicalc/ConditionList.java @@ -6,17 +6,17 @@ import java.util.List; public class ConditionList implements Iterable { - protected final List conditions = new ArrayList (); + private final List conditions = new ArrayList (); public ConditionList (Cell cell, String text) { - Sheet parent = cell.getParent (); + // Sheet parent = cell.getParent (); String remainder = text; while (true) { String parameter = Expression.getParameter (remainder); - conditions.add (new Condition (parent, cell, parameter)); + conditions.add (new Condition (cell, parameter)); if (remainder.length () == parameter.length ()) break; remainder = remainder.substring (parameter.length () + 1); diff --git a/src/com/bytezone/diskbrowser/visicalc/If.java b/src/com/bytezone/diskbrowser/visicalc/If.java index cac6b38..b4a588b 100644 --- a/src/com/bytezone/diskbrowser/visicalc/If.java +++ b/src/com/bytezone/diskbrowser/visicalc/If.java @@ -22,7 +22,7 @@ class If extends Function textFalse = Expression.getParameter ( functionText.substring (conditionText.length () + textTrue.length () + 2)); - condition = new Condition (parent, cell, conditionText); + condition = new Condition (cell, conditionText); values.add (condition); expTrue = new Expression (cell, textTrue); diff --git a/src/com/bytezone/diskbrowser/visicalc/Sheet.java b/src/com/bytezone/diskbrowser/visicalc/Sheet.java index 4851691..e45d5ec 100644 --- a/src/com/bytezone/diskbrowser/visicalc/Sheet.java +++ b/src/com/bytezone/diskbrowser/visicalc/Sheet.java @@ -399,25 +399,25 @@ public class Sheet while (counts.size () < 18) counts.add (""); - text.append (String.format ("%-85.85s%n", underline)); - text.append (String.format ("Global format : %-18s %-18s %-18s %s%n", globalFormat, - counts.get (0), counts.get (6), counts.get (12))); - text.append (String.format ("Column width : %-2d %-15s %-18s %-18s %s%n", + text.append (String.format ("+%-83.83s+%n", underline)); + text.append (String.format ("| Global format : %-18s %-14s %-14s %-14s |%n", + globalFormat, counts.get (0), counts.get (6), counts.get (12))); + text.append (String.format ("| Column width : %-2d %-15s %-14s %-14s %-14s |%n", columnWidth, "", counts.get (1), counts.get (7), counts.get (13))); - text.append (String.format ("Recalc order : %-18s %-18s %-18s %s%n", + text.append (String.format ("| Recalc order : %-18s %-14s %-14s %-14s |%n", recalculationOrder == 'R' ? "Row" : "Column", counts.get (2), counts.get (8), counts.get (14))); - text.append (String.format ("Recalculation : %-18s %-18s %-18s %s%n", + text.append (String.format ("| Recalculation : %-18s %-14s %-14s %-14s |%n", recalculation == 'A' ? "Automatic" : "Manual", counts.get (3), counts.get (9), counts.get (15))); - text.append (String.format ("Cells : %-5d %-11s %-18s %-18s %s%n", size (), - "", counts.get (4), counts.get (10), counts.get (16))); + text.append (String.format ("| Cells : %-5d %-11s %-14s %-14s %-14s |%n", + size (), "", counts.get (4), counts.get (10), counts.get (16))); String rangeText = size () > 0 ? Address.getCellName (minRow + 1, minColumn) + ":" + Address.getCellName (maxRow + 1, maxColumn) : ""; - text.append (String.format ("Range : %-18s %-18s %-18s %s%n", rangeText, - counts.get (5), counts.get (11), counts.get (17))); - text.append (String.format ("%-85.85s%n", underline)); + text.append (String.format ("| Range : %-18s %-14s %-14s %-14s |%n", + rangeText, counts.get (5), counts.get (11), counts.get (17))); + text.append (String.format ("+%-83.83s+%n", underline)); if (debug) { diff --git a/src/com/bytezone/diskbrowser/visicalc/ValueList.java b/src/com/bytezone/diskbrowser/visicalc/ValueList.java index 203fc3c..48fd144 100644 --- a/src/com/bytezone/diskbrowser/visicalc/ValueList.java +++ b/src/com/bytezone/diskbrowser/visicalc/ValueList.java @@ -6,7 +6,8 @@ import java.util.List; public class ValueList implements Iterable { - protected List values = new ArrayList (); + private final List values = new ArrayList (); + private boolean rangeFound; public ValueList (Cell cell, String text) { @@ -18,8 +19,11 @@ public class ValueList implements Iterable String parameter = Expression.getParameter (remainder); if (Range.isRange (parameter)) + { + rangeFound = true; for (Address address : new Range (parent, cell, parameter)) values.add (parent.getCell (address)); + } else values.add (new Expression (cell, parameter).reduce ()); @@ -30,6 +34,11 @@ public class ValueList implements Iterable } } + public boolean hasRange () + { + return rangeFound; + } + public Value get (int index) { return values.get (index);