luc 9 years ago
commit e0ac26d63e

Binary file not shown.

@ -56,28 +56,36 @@ public interface SWFConstants
public static final int TAG_DEFINEFONTINFO = 13; public static final int TAG_DEFINEFONTINFO = 13;
public static final int TAG_DEFINESOUND = 14; public static final int TAG_DEFINESOUND = 14;
public static final int TAG_STARTSOUND = 15; public static final int TAG_STARTSOUND = 15;
//??? public static final int TAG_DEFINEBUTTONSOUND = 17; //???
public static final int TAG_DEFINEBUTTONSOUND = 17;
public static final int TAG_SOUNDSTREAMHEAD = 18; public static final int TAG_SOUNDSTREAMHEAD = 18;
public static final int TAG_SOUNDSTREAMBLOCK = 19; public static final int TAG_SOUNDSTREAMBLOCK = 19;
public static final int TAG_DEFINEBITSLOSSLESS = 20; public static final int TAG_DEFINEBITSLOSSLESS = 20;
public static final int TAG_DEFINEBITSJPEG2 = 21; public static final int TAG_DEFINEBITSJPEG2 = 21;
public static final int TAG_DEFINESHAPE2 = 22; public static final int TAG_DEFINESHAPE2 = 22;
public static final int TAG_DEFINEBUTTONCXFORM = 23; public static final int TAG_DEFINEBUTTONCXFORM = 23;
public static final int TAG_PROTECT = 24; //??? public static final int TAG_PROTECT = 24;
public static final int TAG_PLACEOBJECT2 = 26; //??? //???
public static final int TAG_REMOVEOBJECT2 = 28; //??? public static final int TAG_PLACEOBJECT2 = 26;
//???
public static final int TAG_REMOVEOBJECT2 = 28;
//???
public static final int TAG_DEFINESHAPE3 = 32; public static final int TAG_DEFINESHAPE3 = 32;
public static final int TAG_DEFINETEXT2 = 33; public static final int TAG_DEFINETEXT2 = 33;
public static final int TAG_DEFINEBUTTON2 = 34; public static final int TAG_DEFINEBUTTON2 = 34;
public static final int TAG_DEFINEBITSJPEG3 = 35; public static final int TAG_DEFINEBITSJPEG3 = 35;
public static final int TAG_DEFINEBITSLOSSLESS2 = 36; public static final int TAG_DEFINETEXTFIELD = 37; public static final int TAG_DEFINEBITSLOSSLESS2 = 36;
public static final int TAG_DEFINETEXTFIELD = 37;
public static final int TAG_DEFINEQUICKTIMEMOVIE = 38; public static final int TAG_DEFINEQUICKTIMEMOVIE = 38;
public static final int TAG_DEFINESPRITE = 39; public static final int TAG_DEFINESPRITE = 39;
public static final int TAG_NAMECHARACTER = 40; public static final int TAG_SERIALNUMBER = 41; public static final int TAG_NAMECHARACTER = 40;
public static final int TAG_SERIALNUMBER = 41;
public static final int TAG_GENERATOR_TEXT = 42; public static final int TAG_GENERATOR_TEXT = 42;
public static final int TAG_FRAMELABEL = 43; //??? public static final int TAG_FRAMELABEL = 43;
//???
public static final int TAG_SOUNDSTREAMHEAD2 = 45; public static final int TAG_SOUNDSTREAMHEAD2 = 45;
public static final int TAG_DEFINEMORPHSHAPE = 46; //??? public static final int TAG_DEFINEMORPHSHAPE = 46;
//???
public static final int TAG_DEFINEFONT2 = 48; public static final int TAG_DEFINEFONT2 = 48;
public static final int TAG_TEMPLATECOMMAND = 49; public static final int TAG_TEMPLATECOMMAND = 49;
//??? //???
@ -90,11 +98,37 @@ public interface SWFConstants
public static final int TAG_IMPORT = 57; public static final int TAG_IMPORT = 57;
public static final int TAG_ENABLEDEBUG = 58; public static final int TAG_ENABLEDEBUG = 58;
public static final int TAG_DOINITACTION = 59; public static final int TAG_DOINITACTION = 59;
//??? public static final int TAG_DEFINEVIDEOSTREAM = 60;
//??? public static final int TAG_VIDEOFRAME = 61;
public static final int TAG_DEFINEFONTINFO2 = 62; public static final int TAG_DEFINEFONTINFO2 = 62;
//??? //???
public static final int TAG_ENABLEDEBUGGER2 = 64; public static final int TAG_ENABLEDEBUGGER2 = 64;
public static final int TAG_SCRIPTLIMITS = 65;
public static final int TAG_SETTABINDEX = 66;
public static final int TAG_FILEATTRIBUTES = 69;
public static final int TAG_PLACEOBJECT3 = 70;
public static final int TAG_IMPORTASSETS2 = 71;
public static final int TAG_DEFINEFONTALIGNZONES = 73;
public static final int TAG_CSMTEXTSETTINGS = 74;
public static final int TAG_DEFINEFONT3 = 75;
public static final int TAG_SYMBOLCLASS = 76;
public static final int TAG_METADATA = 77;
public static final int TAG_DEFINESCALINGGRID = 78;
public static final int TAG_DOABC = 82;
public static final int TAG_DEFINESHAPE4 = 83;
public static final int TAG_DEFINEMORPHSHAPE2 = 84;
public static final int TAG_DEFINESCENEANDFRAMELABELDATA = 86;
public static final int TAG_DEFINEBINARYDATA = 87;
public static final int TAG_DEFINEFONTNAME = 88;
public static final int TAG_STARTSOUND2 = 89;
public static final int TAG_DEFINEBITSJPEG4 = 90;
public static final int TAG_DEFINEFONT4 = 91;
public static final int TAG_ENABLETELEMETRY = 93;
//--Fill Types //--Fill Types
public static final int FILL_SOLID = 0x00; public static final int FILL_SOLID = 0x00;

@ -1,20 +0,0 @@
package pt.tumba.parser;
/**
*
* Generic interface for all document filters, converting a source format into HTML
*
* @author Bruno Martins
*
*/
public interface DocFilter {
/**
* Return the original size of the document, before the filtering process.
*
* @return The original size of the document, before the filtering process.
*/
public int originalSize();
}

@ -2,12 +2,11 @@ package pt.tumba.parser.swf;
import com.anotherbigidea.flash.SWFActionCodes; import com.anotherbigidea.flash.SWFActionCodes;
import java.io.IOException; import java.io.IOException;
import java.util.Enumeration; import java.util.ArrayList;
import java.util.Hashtable; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Stack; import java.util.Stack;
import java.util.Vector;
/** /**
* Parse action bytes and drive a SWFActions interface * Parse action bytes and drive a SWFActions interface
@ -16,13 +15,8 @@ import java.util.Vector;
*@created 15 de Setembro de 2002 *@created 15 de Setembro de 2002
*/ */
public class ActionParser implements SWFActionCodes { public class ActionParser implements SWFActionCodes {
/**
* Description of the Field
*/
protected SWFActions actions; protected SWFActions actions;
/**
* Description of the Field
*/
protected int blockDepth = 0; protected int blockDepth = 0;
@ -552,10 +546,10 @@ public class ActionParser implements SWFActionCodes {
*@exception IOException Description of the Exception *@exception IOException Description of the Exception
*/ */
protected List createRecords(InStream in) throws IOException { protected List createRecords(InStream in) throws IOException {
Vector records = new Vector(); List records = new ArrayList();
Vector jumpers = new Vector(); List<ActionRecord> jumpers = new ArrayList();
Vector skippers = new Vector(); List<Integer> skippers = new ArrayList();
Hashtable offsetTable = new Hashtable(); HashMap offsetTable = new HashMap();
Stack blockSizes = new Stack(); Stack blockSizes = new Stack();
@ -573,7 +567,7 @@ public class ActionParser implements SWFActionCodes {
//System.out.println( "size=" + dataLength ); System.out.flush(); //System.out.println( "size=" + dataLength ); System.out.flush();
ActionRecord rec = new ActionRecord(offset, code, data); ActionRecord rec = new ActionRecord(offset, code, data);
records.addElement(rec); records.add(rec);
offsetTable.put(new Integer(offset), rec); offsetTable.put(new Integer(offset), rec);
if (!blockSizes.isEmpty()) { if (!blockSizes.isEmpty()) {
@ -616,15 +610,14 @@ public class ActionParser implements SWFActionCodes {
int blockSize = in2.readUI16(); int blockSize = in2.readUI16();
blockSizes.push(new int[]{blockSize}); blockSizes.push(new int[]{blockSize});
} else if (code == WAIT_FOR_FRAME || code == WAIT_FOR_FRAME_2) { } else if (code == WAIT_FOR_FRAME || code == WAIT_FOR_FRAME_2) {
skippers.addElement(new Integer(records.size() - 1)); skippers.add(new Integer(records.size() - 1));
} else if (code == IF || code == JUMP) { } else if (code == IF || code == JUMP) {
jumpers.addElement(rec); jumpers.add(rec);
} }
} }
//--Tie up the jumpers with the offsets //--Tie up the jumpers with the offsets
for (Enumeration enumumerator = jumpers.elements(); enumumerator.hasMoreElements(); ) { for (ActionRecord rec : jumpers) {
ActionRecord rec = (ActionRecord) enumumerator.nextElement();
InStream in2 = new InStream(rec.data); InStream in2 = new InStream(rec.data);
int jumpOffset = in2.readSI16(); int jumpOffset = in2.readSI16();
@ -644,10 +637,9 @@ public class ActionParser implements SWFActionCodes {
} }
//--Tie up the skippers with labels //--Tie up the skippers with labels
for (Enumeration enumumerator = skippers.elements(); enumumerator.hasMoreElements(); ) { for (Integer idx : skippers) {
int idx = ((Integer) enumumerator.nextElement()).intValue();
ActionRecord rec = (ActionRecord) records.elementAt(idx); ActionRecord rec = (ActionRecord) records.get(idx);
InStream in2 = new InStream(rec.data); InStream in2 = new InStream(rec.data);
@ -659,7 +651,7 @@ public class ActionParser implements SWFActionCodes {
int skipIndex = idx + skip + 1; int skipIndex = idx + skip + 1;
if (skipIndex < records.size()) { if (skipIndex < records.size()) {
ActionRecord target = (ActionRecord) records.elementAt(skipIndex); ActionRecord target = (ActionRecord) records.get(skipIndex);
if (target.label == null) { if (target.label == null) {
target.label = rec.jumpLabel = "label" + (labelIndex++); target.label = rec.jumpLabel = "label" + (labelIndex++);

@ -3,11 +3,11 @@ package pt.tumba.parser.swf;
import com.anotherbigidea.flash.SWFActionCodes; import com.anotherbigidea.flash.SWFActionCodes;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.Hashtable; import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Stack; import java.util.Stack;
import java.util.Vector;
/** /**
* A writer that implements the SWFActions interface and writes action bytes to * A writer that implements the SWFActions interface and writes action bytes to
@ -17,53 +17,21 @@ import java.util.Vector;
*@created 15 de Setembro de 2002 *@created 15 de Setembro de 2002
*/ */
public class ActionWriter implements SWFActions, SWFActionCodes { public class ActionWriter implements SWFActions, SWFActionCodes {
/**
* Description of the Field
*/
protected TagWriter tagWriter; protected TagWriter tagWriter;
/**
* Description of the Field
*/
protected OutStream out; protected OutStream out;
/**
* Description of the Field
*/
protected ByteArrayOutputStream bout; protected ByteArrayOutputStream bout;
/**
* Description of the Field
*/
protected int count; protected int count;
/**
* Description of the Field
*/
protected int flashVersion; protected int flashVersion;
/**
* Description of the Field
*/
protected List pushValues; protected List pushValues;
/** protected HashMap labels;
* Description of the Field
*/
protected Hashtable labels;
/**
* Description of the Field
*/
protected List jumps; protected List jumps;
/**
* Description of the Field
*/
protected List skips; protected List skips;
//--for fixing up functions and WITH blocks.. //--for fixing up functions and WITH blocks..
/**
* Description of the Field
*/
protected List blocks; protected List blocks;
/**
* Description of the Field
*/
protected Stack blockStack; protected Stack blockStack;
@ -106,7 +74,7 @@ public class ActionWriter implements SWFActions, SWFActionCodes {
count = 0; count = 0;
bout = new ByteArrayOutputStream(); bout = new ByteArrayOutputStream();
out = new OutStream(bout); out = new OutStream(bout);
pushValues = new Vector(); pushValues = new ArrayList();
labels = null; labels = null;
jumps = null; jumps = null;
skips = null; skips = null;
@ -315,7 +283,7 @@ public class ActionWriter implements SWFActions, SWFActionCodes {
int offset = (int) out.getBytesWritten(); int offset = (int) out.getBytesWritten();
if (labels == null) { if (labels == null) {
labels = new Hashtable(); labels = new HashMap();
} }
labels.put(label, new int[]{offset, count + 1}); labels.put(label, new int[]{offset, count + 1});
} }
@ -452,7 +420,7 @@ public class ActionWriter implements SWFActions, SWFActionCodes {
//--save jump info for later fix-up logic //--save jump info for later fix-up logic
if (jumps == null) { if (jumps == null) {
jumps = new Vector(); jumps = new ArrayList();
} }
jumps.add(new Object[]{label, new Integer(here)}); jumps.add(new Object[]{label, new Integer(here)});
} }
@ -498,7 +466,7 @@ public class ActionWriter implements SWFActions, SWFActionCodes {
//--save skip info for later fix-up logic //--save skip info for later fix-up logic
if (skips == null) { if (skips == null) {
skips = new Vector(); skips = new ArrayList();
} }
skips.add(new Object[]{jumpLabel, new int[]{count, here}}); skips.add(new Object[]{jumpLabel, new int[]{count, here}});
} }
@ -520,7 +488,7 @@ public class ActionWriter implements SWFActions, SWFActionCodes {
//--save skip info for later fix-up logic //--save skip info for later fix-up logic
if (skips == null) { if (skips == null) {
skips = new Vector(); skips = new ArrayList();
} }
skips.add(new Object[]{jumpLabel, new int[]{count, here}}); skips.add(new Object[]{jumpLabel, new int[]{count, here}});
} }
@ -1032,7 +1000,7 @@ public class ActionWriter implements SWFActions, SWFActionCodes {
int[] blockInfo = (int[]) blockStack.pop(); int[] blockInfo = (int[]) blockStack.pop();
if (blocks == null) { if (blocks == null) {
blocks = new Vector(); blocks = new ArrayList();
} }
int offset = blockInfo[0]; int offset = blockInfo[0];

@ -2,7 +2,7 @@ package pt.tumba.parser.swf;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.Vector; import java.util.ArrayList;
/** /**
* A set of actions * A set of actions
@ -11,13 +11,8 @@ import java.util.Vector;
*@created 15 de Setembro de 2002 *@created 15 de Setembro de 2002
*/ */
public class Actions extends ActionWriter { public class Actions extends ActionWriter {
/**
* Description of the Field
*/
protected int conditions; protected int conditions;
/**
* Description of the Field
*/
protected byte[] bytes; protected byte[] bytes;
@ -34,7 +29,7 @@ public class Actions extends ActionWriter {
count = 0; count = 0;
bout = new ByteArrayOutputStream(); bout = new ByteArrayOutputStream();
out = new OutStream(bout); out = new OutStream(bout);
pushValues = new Vector(); pushValues = new ArrayList();
labels = null; labels = null;
jumps = null; jumps = null;
skips = null; skips = null;

@ -11,7 +11,7 @@ import java.io.Reader;
import java.io.StringReader; import java.io.StringReader;
import java.io.StringWriter; import java.io.StringWriter;
import java.io.Writer; import java.io.Writer;
import java.util.Hashtable; import java.util.HashMap;
/** /**
* Base64 encoding/decoding utilities * Base64 encoding/decoding utilities
@ -31,9 +31,6 @@ public class Base64 {
} }
/**
* Description of the Field
*/
public final static char[] charset = public final static char[] charset =
{ {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
@ -46,15 +43,9 @@ public class Base64 {
'4', '5', '6', '7', '8', '9', '+', '/' '4', '5', '6', '7', '8', '9', '+', '/'
}; };
/**
* Description of the Field
*/
public final static char paddingChar = '='; public final static char paddingChar = '=';
/** protected static HashMap charLookup = new HashMap();
* Description of the Field
*/
protected static Hashtable charLookup = new Hashtable();
static { static {
//initialize the hashtable //initialize the hashtable

@ -1,9 +1,9 @@
package pt.tumba.parser.swf; package pt.tumba.parser.swf;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Vector;
/** /**
* Description of the Class * Description of the Class
@ -12,38 +12,15 @@ import java.util.Vector;
*@created 15 de Setembro de 2002 *@created 15 de Setembro de 2002
*/ */
public class ButtonRecord { public class ButtonRecord {
/**
* Description of the Field
*/
public final static int BUTTON_HITTEST = 0x08; public final static int BUTTON_HITTEST = 0x08;
/**
* Description of the Field
*/
public final static int BUTTON_DOWN = 0x04; public final static int BUTTON_DOWN = 0x04;
/**
* Description of the Field
*/
public final static int BUTTON_OVER = 0x02; public final static int BUTTON_OVER = 0x02;
/**
* Description of the Field
*/
public final static int BUTTON_UP = 0x01; public final static int BUTTON_UP = 0x01;
/**
* Description of the Field
*/
protected int flags; protected int flags;
/**
* Description of the Field
*/
protected int id; protected int id;
/**
* Description of the Field
*/
protected int layer; protected int layer;
/**
* Description of the Field
*/
protected Matrix matrix; protected Matrix matrix;
@ -175,11 +152,11 @@ public class ButtonRecord {
*@exception IOException Description of the Exception *@exception IOException Description of the Exception
*/ */
public static List read(InStream in) throws IOException { public static List read(InStream in) throws IOException {
Vector records = new Vector(); List records = new ArrayList();
int firstByte = 0; int firstByte = 0;
while ((firstByte = in.readUI8()) != 0) { while ((firstByte = in.readUI8()) != 0) {
records.addElement(new ButtonRecord(in, firstByte)); records.add(new ButtonRecord(in, firstByte));
} }
return records; return records;

@ -1,9 +1,9 @@
package pt.tumba.parser.swf; package pt.tumba.parser.swf;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Vector;
/** /**
* Description of the Class * Description of the Class
@ -12,9 +12,7 @@ import java.util.Vector;
*@created 15 de Setembro de 2002 *@created 15 de Setembro de 2002
*/ */
public class ButtonRecord2 extends ButtonRecord { public class ButtonRecord2 extends ButtonRecord {
/**
* Description of the Field
*/
protected AlphaTransform transform; protected AlphaTransform transform;
@ -46,11 +44,11 @@ public class ButtonRecord2 extends ButtonRecord {
*@exception IOException Description of the Exception *@exception IOException Description of the Exception
*/ */
public static List read(InStream in) throws IOException { public static List read(InStream in) throws IOException {
Vector records = new Vector(); List records = new ArrayList();
int firstByte = 0; int firstByte = 0;
while ((firstByte = in.readUI8()) != 0) { while ((firstByte = in.readUI8()) != 0) {
records.addElement(new ButtonRecord2(in, firstByte)); records.add(new ButtonRecord2(in, firstByte));
} }
return records; return records;

@ -1,9 +1,8 @@
package pt.tumba.parser.swf; package pt.tumba.parser.swf;
import java.io.IOException; import java.io.IOException;
import java.util.Iterator; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Vector;
/** /**
* A Movie or Movie Clip frame * A Movie or Movie Clip frame
@ -12,29 +11,12 @@ import java.util.Vector;
*@created 15 de Setembro de 2002 *@created 15 de Setembro de 2002
*/ */
public class Frame { public class Frame {
/**
* Description of the Field
*/
protected int frameNumber; protected int frameNumber;
/**
* Description of the Field
*/
protected String label; protected String label;
/** protected List<Placement> placements = new ArrayList();
* Description of the Field
*/
protected List placements = new Vector();
/**
* Description of the Field
*/
protected boolean stop; protected boolean stop;
/**
* Description of the Field
*/
protected TimeLine timeline; protected TimeLine timeline;
/**
* Description of the Field
*/
protected Actions actions; protected Actions actions;
/** /**
@ -407,11 +389,7 @@ public class Frame {
SWFTagTypes timelineWriter, SWFTagTypes timelineWriter,
SWFTagTypes definitionWriter) SWFTagTypes definitionWriter)
throws IOException { throws IOException {
for (Iterator enumerator = placements.iterator(); for (Placement placement : placements) {
enumerator.hasNext();
) {
Placement placement = (Placement) enumerator.next();
placement.flushDefinitions(movie, timelineWriter, definitionWriter); placement.flushDefinitions(movie, timelineWriter, definitionWriter);
} }
} }
@ -445,11 +423,7 @@ public class Frame {
actions.done(); actions.done();
} }
for (Iterator enumumerator = placements.iterator(); for (Placement placement : placements) {
enumumerator.hasNext();
) {
Placement placement = (Placement) enumumerator.next();
placement.write(movie, movieTagWriter, timelineTagWriter); placement.write(movie, movieTagWriter, timelineTagWriter);
} }

@ -10,7 +10,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.SortedMap; import java.util.SortedMap;
import java.util.TreeMap; import java.util.TreeMap;
import java.util.Vector;
/** /**
* A Flash Movie * A Flash Movie
@ -19,63 +18,24 @@ import java.util.Vector;
*@created 15 de Setembro de 2002 *@created 15 de Setembro de 2002
*/ */
public class Movie implements TimeLine { public class Movie implements TimeLine {
/**
* Description of the Field
*/
protected int width; protected int width;
/**
* Description of the Field
*/
protected int height; protected int height;
/**
* Description of the Field
*/
protected int frameRate; protected int frameRate;
/**
* Description of the Field
*/
protected Color backColor; protected Color backColor;
/**
* Description of the Field
*/
protected int version; protected int version;
/**
* Description of the Field
*/
protected boolean isProtected; protected boolean isProtected;
/** protected Map<String, List> importLibraries;
* Description of the Field protected List<ExportedSymbol> exportedSymbols;
*/
protected Map importLibraries;
/**
* Description of the Field
*/
protected List exportedSymbols;
/** protected SortedMap<Integer, Frame> frames = new TreeMap();
* Description of the Field
*/
protected SortedMap frames = new TreeMap();
/**
* Description of the Field
*/
protected int frameCount = 0; protected int frameCount = 0;
//--Table of characters defined so far in the movie - while writing out //--Table of characters defined so far in the movie - while writing out
/**
* Description of the Field
*/
protected Map definedSymbols = new HashMap(); protected Map definedSymbols = new HashMap();
/** protected int depth = 1; //the next available depth
* Description of the Field
*/
protected int depth = 1;
//the next available depth
/**
* Description of the Field
*/
protected int maxId = 1; protected int maxId = 1;
@ -357,20 +317,16 @@ public class Movie implements TimeLine {
return new ImportedSymbol[0]; return new ImportedSymbol[0];
} }
Vector imports = new Vector(); List imports = new ArrayList();
for (Iterator iter = importLibraries.values().iterator(); iter.hasNext(); ) {
List list = (List) iter.next();
for (List list : importLibraries.values()) {
for (Iterator i2 = list.iterator(); i2.hasNext(); ) { for (Iterator i2 = list.iterator(); i2.hasNext(); ) {
imports.add(i2.next()); imports.add(i2.next());
} }
} }
ImportedSymbol[] imps = new ImportedSymbol[imports.size()]; ImportedSymbol[] imps = new ImportedSymbol[imports.size()];
imports.copyInto(imps); return (ImportedSymbol[])imports.toArray(imps);
return imps;
} }
@ -383,7 +339,7 @@ public class Movie implements TimeLine {
*/ */
public void exportSymbols(String[] exportNames, Symbol[] symbols) { public void exportSymbols(String[] exportNames, Symbol[] symbols) {
if (exportedSymbols == null) { if (exportedSymbols == null) {
exportedSymbols = new Vector(); exportedSymbols = new ArrayList();
} }
for (int i = 0; i < exportNames.length && i < symbols.length; i++) { for (int i = 0; i < exportNames.length && i < symbols.length; i++) {

@ -12,23 +12,12 @@ import java.io.OutputStream;
*@created 15 de Setembro de 2002 *@created 15 de Setembro de 2002
*/ */
public class OutStream { public class OutStream {
/**
* Description of the Field
*/
protected OutputStream out; protected OutputStream out;
/**
* Description of the Field
*/
protected long bytesWritten = 0L; protected long bytesWritten = 0L;
//--Bit buffer.. //--Bit buffer..
/**
* Description of the Field
*/
protected int bitBuf; protected int bitBuf;
/**
* Description of the Field
*/
protected int bitPos; protected int bitPos;
@ -104,6 +93,7 @@ public class OutStream {
*@exception IOException Description of the Exception *@exception IOException Description of the Exception
*/ */
public void close() throws IOException { public void close() throws IOException {
flushBits();
out.close(); out.close();
} }
@ -325,8 +315,7 @@ public class OutStream {
if (string != null) { if (string != null) {
out.write(string); out.write(string);
} }
out.write(0); out.write(0); //terminate string
//terminate string
bytesWritten += string.length + 1; bytesWritten += string.length + 1;
} }
@ -343,8 +332,7 @@ public class OutStream {
if (string == null) { if (string == null) {
return 1; return 1;
} }
return string.length + 1; return string.length + 1; //to include the terminating null
//to include the terminating null
} }
@ -361,8 +349,7 @@ public class OutStream {
} }
byte[] bytes = string.getBytes(); byte[] bytes = string.getBytes();
return bytes.length + 1; return bytes.length + 1; //to include the terminating null
//to include the terminating null
} }

@ -12,7 +12,6 @@ import java.net.URL;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import pt.tumba.parser.DocFilter;
/** /**
* Description of the Class * Description of the Class
@ -20,7 +19,7 @@ import pt.tumba.parser.DocFilter;
*@author bmartins *@author bmartins
*@created 22 de Agosto de 2002 *@created 22 de Agosto de 2002
*/ */
public class SWF2HTML extends SWFTagTypesImpl implements DocFilter { public class SWF2HTML extends SWFTagTypesImpl {
private int sizeCount = 0; private int sizeCount = 0;

@ -1,402 +0,0 @@
package pt.tumba.parser.swf;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.xml.sax.ContentHandler;
import org.xml.sax.DTDHandler;
import org.xml.sax.EntityResolver;
import org.xml.sax.ErrorHandler;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.SAXNotRecognizedException;
import org.xml.sax.SAXNotSupportedException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.AttributesImpl;
/**
* Base class for SAX2 Parsers
*
*@author unknown
*@created 15 de Setembro de 2002
*/
public abstract class SaxParserBase implements XMLReader {
/**
* Description of the Field
*/
protected EntityResolver resolver;
/**
* Description of the Field
*/
protected DTDHandler dtdhandler;
/**
* Description of the Field
*/
protected ContentHandler contenthandler;
/**
* Description of the Field
*/
protected ErrorHandler errorhandler;
/**
* Description of the Field
*/
protected List elementStack = new ArrayList();
/**
* Description of the Field
*/
protected String namespace;
/**
* Gets the namespace attribute of the SaxParserBase object
*
*@return The namespace value
*/
public String getNamespace() {
return namespace;
}
/**
* Sets the namespace attribute of the SaxParserBase object
*
*@param namespace The new namespace value
*/
public void setNamespace(String namespace) {
this.namespace = namespace;
}
/**
* Constructor for the SaxParserBase object
*
*@param namespace Description of the Parameter
*/
protected SaxParserBase(String namespace) {
this.namespace = namespace;
}
/**
* Description of the Method
*
*@exception IOException Description of the Exception
*/
protected void startDoc() throws IOException {
if (contenthandler == null) {
return;
}
try {
contenthandler.startDocument();
} catch (SAXException saxex) {
throw new IOException(saxex.toString());
}
}
/**
* Description of the Method
*
*@exception IOException Description of the Exception
*/
protected void endDoc() throws IOException {
if (contenthandler == null) {
return;
}
try {
contenthandler.endDocument();
} catch (SAXException saxex) {
throw new IOException(saxex.toString());
}
}
/**
* Description of the Method
*
*@param text Description of the Parameter
*@exception IOException Description of the Exception
*/
protected void text(String text) throws IOException {
if (contenthandler == null) {
return;
}
try {
contenthandler.characters(text.toCharArray(), 0, text.length());
} catch (SAXException saxex) {
throw new IOException(saxex.toString());
}
}
/**
* Description of the Method
*
*@param name Description of the Parameter
*@param attributes Description of the Parameter
*@exception IOException Description of the Exception
*/
protected void element(String name, String[] attributes)
throws IOException {
if (contenthandler == null) {
return;
}
AttributesImpl attrs = new AttributesImpl();
if (attributes != null) {
int topIndex = attributes.length - 1;
for (int i = 0; i < topIndex; i += 2) {
String attName = attributes[i];
String value = attributes[i + 1];
if (attName != null && value != null) {
attrs.addAttribute("", attName, attName, "CDATA", value);
}
}
}
try {
contenthandler.startElement(namespace, name, name, attrs);
contenthandler.endElement(namespace, name, name);
} catch (SAXException saxex) {
throw new IOException(saxex.toString());
}
}
/**
* Description of the Method
*
*@param name Description of the Parameter
*@param attributes Description of the Parameter
*@exception IOException Description of the Exception
*/
protected void start(String name, String[] attributes)
throws IOException {
elementStack.add(name);
if (contenthandler == null) {
return;
}
AttributesImpl attrs = new AttributesImpl();
if (attributes != null) {
int topIndex = attributes.length - 1;
for (int i = 0; i < topIndex; i += 2) {
String attName = attributes[i];
String value = attributes[i + 1];
if (attName != null && value != null) {
attrs.addAttribute("", attName, attName, "CDATA", value);
}
}
}
try {
contenthandler.startElement(namespace, name, name, attrs);
} catch (SAXException saxex) {
throw new IOException(saxex.toString());
}
}
/**
* Description of the Method
*
*@exception IOException Description of the Exception
*/
protected void end() throws IOException {
if (elementStack.isEmpty()) {
return;
}
if (contenthandler == null) {
return;
}
String name = (String) elementStack.remove(elementStack.size() - 1);
try {
contenthandler.endElement(namespace, name, name);
} catch (SAXException saxex) {
throw new IOException(saxex.toString());
}
}
//============ XMLReader interface follows: ================
/**
* Gets the feature attribute of the SaxParserBase object
*
*@param name Description of the Parameter
*@return The feature value
*@exception SAXNotRecognizedException Description of the Exception
*@exception SAXNotSupportedException Description of the Exception
*/
public boolean getFeature(String name)
throws SAXNotRecognizedException, SAXNotSupportedException {
if (name.equals("http://xml.org/sax/features/namespaces")) {
return true;
}
if (name.equals("http://xml.org/sax/features/namespace-prefixes")) {
return false;
}
throw new SAXNotRecognizedException(name);
}
/**
* Sets the feature attribute of the SaxParserBase object
*
*@param name The new feature value
*@param value The new feature value
*@exception SAXNotRecognizedException Description of the Exception
*@exception SAXNotSupportedException Description of the Exception
*/
public void setFeature(String name, boolean value)
throws SAXNotRecognizedException, SAXNotSupportedException {
if (name.equals("http://xml.org/sax/features/namespaces")
|| name.equals("http://xml.org/sax/features/namespace-prefixes")) {
return;
}
throw new SAXNotRecognizedException(name);
}
/**
* Gets the property attribute of the SaxParserBase object
*
*@param name Description of the Parameter
*@return The property value
*@exception SAXNotRecognizedException Description of the Exception
*@exception SAXNotSupportedException Description of the Exception
*/
public Object getProperty(String name)
throws SAXNotRecognizedException, SAXNotSupportedException {
throw new SAXNotRecognizedException(name);
}
/**
* Sets the property attribute of the SaxParserBase object
*
*@param name The new property value
*@param value The new property value
*@exception SAXNotRecognizedException Description of the Exception
*@exception SAXNotSupportedException Description of the Exception
*/
public void setProperty(String name, Object value)
throws SAXNotRecognizedException, SAXNotSupportedException {
throw new SAXNotRecognizedException(name);
}
/**
* Sets the entityResolver attribute of the SaxParserBase object
*
*@param resolver The new entityResolver value
*/
public void setEntityResolver(EntityResolver resolver) {
this.resolver = resolver;
}
/**
* Gets the entityResolver attribute of the SaxParserBase object
*
*@return The entityResolver value
*/
public EntityResolver getEntityResolver() {
return resolver;
}
/**
* Sets the dTDHandler attribute of the SaxParserBase object
*
*@param handler The new dTDHandler value
*/
public void setDTDHandler(DTDHandler handler) {
this.dtdhandler = handler;
}
/**
* Gets the dTDHandler attribute of the SaxParserBase object
*
*@return The dTDHandler value
*/
public DTDHandler getDTDHandler() {
return dtdhandler;
}
/**
* Sets the contentHandler attribute of the SaxParserBase object
*
*@param handler The new contentHandler value
*/
public void setContentHandler(ContentHandler handler) {
this.contenthandler = handler;
}
/**
* Gets the contentHandler attribute of the SaxParserBase object
*
*@return The contentHandler value
*/
public ContentHandler getContentHandler() {
return contenthandler;
}
/**
* Sets the errorHandler attribute of the SaxParserBase object
*
*@param handler The new errorHandler value
*/
public void setErrorHandler(ErrorHandler handler) {
this.errorhandler = handler;
}
/**
* Gets the errorHandler attribute of the SaxParserBase object
*
*@return The errorHandler value
*/
public ErrorHandler getErrorHandler() {
return errorhandler;
}
/**
* Description of the Method
*
*@param input Description of the Parameter
*@exception IOException Description of the Exception
*@exception SAXException Description of the Exception
*/
public abstract void parse(InputSource input) throws IOException, SAXException;
/**
* Description of the Method
*
*@param systemId Description of the Parameter
*@exception IOException Description of the Exception
*@exception SAXException Description of the Exception
*/
public abstract void parse(String systemId) throws IOException, SAXException;
}

@ -5,9 +5,8 @@ import java.io.ByteArrayInputStream;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.Enumeration; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Vector;
import java.util.zip.InflaterInputStream; import java.util.zip.InflaterInputStream;
/** /**
@ -17,9 +16,7 @@ import java.util.zip.InflaterInputStream;
*@created 15 de Setembro de 2002 *@created 15 de Setembro de 2002
*/ */
public class TagParser implements SWFTags, SWFConstants { public class TagParser implements SWFTags, SWFConstants {
/**
* Description of the Field
*/
protected SWFTagTypes tagtypes; protected SWFTagTypes tagtypes;
@ -123,6 +120,7 @@ public class TagParser implements SWFTags, SWFConstants {
parseFontInfo(in, length); parseFontInfo(in, length);
break; break;
case TAG_DEFINEFONT2: case TAG_DEFINEFONT2:
case TAG_DEFINEFONT3:
parseDefineFont2(in); parseDefineFont2(in);
break; break;
case TAG_DEFINETEXTFIELD: case TAG_DEFINETEXTFIELD:
@ -202,7 +200,7 @@ public class TagParser implements SWFTags, SWFConstants {
parseDefineBits(in); parseDefineBits(in);
break; break;
case TAG_JPEGTABLES: case TAG_JPEGTABLES:
parseDefineJPEGTables(in); //parseDefineJPEGTables(in); // TODO: content length=0 (in==null) occurs for unknown reason - find out!
break; break;
case TAG_DEFINEBITSJPEG3: case TAG_DEFINEBITSJPEG3:
parseDefineBitsJPEG3(in); parseDefineBitsJPEG3(in);
@ -817,7 +815,7 @@ public class TagParser implements SWFTags, SWFConstants {
String name = new String(in.read(nameLength)); String name = new String(in.read(nameLength));
int glyphCount = in.readUI16(); int glyphCount = in.readUI16();
Vector glyphs = new Vector(); List<byte[]> glyphs = new ArrayList();
int[] offsets = new int[glyphCount + 1]; int[] offsets = new int[glyphCount + 1];
boolean is32 = (flags & FONT2_32OFFSETS) != 0; boolean is32 = (flags & FONT2_32OFFSETS) != 0;
@ -828,7 +826,7 @@ public class TagParser implements SWFTags, SWFConstants {
for (int i = 1; i <= glyphCount; i++) { for (int i = 1; i <= glyphCount; i++) {
int glyphSize = offsets[i] - offsets[i - 1]; int glyphSize = offsets[i] - offsets[i - 1];
byte[] glyphBytes = in.read(glyphSize); byte[] glyphBytes = in.read(glyphSize);
glyphs.addElement(glyphBytes); glyphs.add(glyphBytes);
} }
boolean isWide = ((flags & FONT2_WIDECHARS) != 0) || (glyphCount > 256); boolean isWide = ((flags & FONT2_WIDECHARS) != 0) || (glyphCount > 256);
@ -891,11 +889,8 @@ public class TagParser implements SWFTags, SWFConstants {
if (glyphs.isEmpty()) { if (glyphs.isEmpty()) {
vectors.done(); vectors.done();
} else { } else {
for (Enumeration enumerator = glyphs.elements(); enumerator.hasMoreElements(); ) { for (byte[] glyphBytes : glyphs) {
byte[] glyphBytes = (byte[]) enumerator.nextElement();
InStream glyphIn = new InStream(glyphBytes); InStream glyphIn = new InStream(glyphBytes);
parseShape(glyphIn, vectors, false, false); parseShape(glyphIn, vectors, false, false);
} }
} }
@ -1051,10 +1046,8 @@ public class TagParser implements SWFTags, SWFConstants {
*/ */
protected void parsePlaceObject(InStream in, int length) throws IOException { protected void parsePlaceObject(InStream in, int length) throws IOException {
tagtypes.tagPlaceObject( tagtypes.tagPlaceObject(
in.readUI16(), in.readUI16(), //char id
//char id in.readUI16(), //depth
in.readUI16(),
//depth
new Matrix(in), new Matrix(in),
(in.getBytesRead() < length) ? new AlphaTransform(in) : null); (in.getBytesRead() < length) ? new AlphaTransform(in) : null);
} }
@ -1073,8 +1066,7 @@ public class TagParser implements SWFTags, SWFConstants {
return; return;
} }
actions.start(0); actions.start(0); //no conditions
//no conditions
ActionParser parser = new ActionParser(actions); ActionParser parser = new ActionParser(actions);
parser.parse(in); parser.parse(in);
actions.done(); actions.done();

@ -4,9 +4,9 @@ import com.anotherbigidea.flash.SWFConstants;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Vector;
import java.util.zip.DeflaterOutputStream; import java.util.zip.DeflaterOutputStream;
/** /**
@ -17,30 +17,13 @@ import java.util.zip.DeflaterOutputStream;
*@created 15 de Setembro de 2002 *@created 15 de Setembro de 2002
*/ */
public class TagWriter implements SWFTagTypes, SWFConstants { public class TagWriter implements SWFTagTypes, SWFConstants {
/**
* Description of the Field
*/
protected SWFTags tags; protected SWFTags tags;
/**
* Description of the Field
*/
protected OutStream out; protected OutStream out;
/**
* Description of the Field
*/
protected ByteArrayOutputStream bytes; protected ByteArrayOutputStream bytes;
/**
* Description of the Field
*/
protected int tagType; protected int tagType;
/**
* Description of the Field
*/
protected boolean longTag; protected boolean longTag;
/**
* Description of the Field
*/
protected int version; protected int version;
@ -1233,7 +1216,7 @@ public class TagWriter implements SWFTagTypes, SWFConstants {
/** /**
* Description of the Field * Description of the Field
*/ */
protected List offsets = new Vector(); protected List offsets = new ArrayList();
/** /**
* Description of the Field * Description of the Field
*/ */
@ -1370,7 +1353,7 @@ public class TagWriter implements SWFTagTypes, SWFConstants {
/** /**
* Description of the Field * Description of the Field
*/ */
protected List recs = new Vector(); protected List recs = new ArrayList();
/** /**
* Description of the Field * Description of the Field
*/ */
@ -1696,11 +1679,11 @@ public class TagWriter implements SWFTagTypes, SWFConstants {
/** /**
* Description of the Field * Description of the Field
*/ */
protected List lineStyles = new Vector(); protected List lineStyles = new ArrayList();
/** /**
* Description of the Field * Description of the Field
*/ */
protected List fillStyles = new Vector(); protected List fillStyles = new ArrayList();
/** /**
* Description of the Field * Description of the Field
@ -1760,7 +1743,7 @@ public class TagWriter implements SWFTagTypes, SWFConstants {
this.glyphCount = glyphCount; this.glyphCount = glyphCount;
bout = new ByteArrayOutputStream(); bout = new ByteArrayOutputStream();
out = new OutStream(bout); out = new OutStream(bout);
glyphByteArrays = new Vector(); glyphByteArrays = new ArrayList();
fill1Index = 1; fill1Index = 1;
lineIndex = 0; lineIndex = 0;

Loading…
Cancel
Save