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_DEFINESOUND = 14;
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_SOUNDSTREAMBLOCK = 19;
public static final int TAG_DEFINEBITSLOSSLESS = 20;
public static final int TAG_DEFINEBITSJPEG2 = 21;
public static final int TAG_DEFINESHAPE2 = 22;
public static final int TAG_DEFINEBUTTONCXFORM = 23;
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_PROTECT = 24;
//???
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_DEFINETEXT2 = 33;
public static final int TAG_DEFINEBUTTON2 = 34;
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_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_FRAMELABEL = 43; //???
public static final int TAG_FRAMELABEL = 43;
//???
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_TEMPLATECOMMAND = 49;
//???
@ -89,12 +97,38 @@ public interface SWFConstants
public static final int TAG_EXPORT = 56;
public static final int TAG_IMPORT = 57;
public static final int TAG_ENABLEDEBUG = 58;
public static final int TAG_DOINITACTION = 59;
//???
//???
public static final int TAG_DEFINEFONTINFO2 = 62;
//???
public static final int TAG_ENABLEDEBUGGER2 = 64;
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_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
public static final int FILL_SOLID = 0x00;
@ -179,8 +213,8 @@ public interface SWFConstants
public static final int SOUND_FORMAT_RAW = 0;
public static final int SOUND_FORMAT_ADPCM = 1;
public static final int SOUND_FORMAT_MP3 = 2;
public static final int SOUND_FORMAT_RAW_LITTLEENDIAN = 3;
public static final int SOUND_FORMAT_NELLYMOSER = 6;
public static final int SOUND_FORMAT_RAW_LITTLEENDIAN = 3;
public static final int SOUND_FORMAT_NELLYMOSER = 6;
public static final int SOUND_FREQ_5_5KHZ = 0; //5.5 kHz
public static final int SOUND_FREQ_11KHZ = 1;
@ -188,18 +222,18 @@ public interface SWFConstants
public static final int SOUND_FREQ_44KHZ = 3;
//--Language Codes for DefineFontInfo2
public static final int LANGUAGE_CODE_NONE = 0;
public static final int LANGUAGE_CODE_LATIN = 1;
public static final int LANGUAGE_CODE_JAPANESE = 2;
public static final int LANGUAGE_CODE_KOREAN = 3;
public static final int LANGUAGE_CODE_SIMPLIFIED_CHINESE = 4;
public static final int LANGUAGE_CODE_TRADITIONAL_CHINESE = 5;
public static final int LANGUAGE_CODE_NONE = 0;
public static final int LANGUAGE_CODE_LATIN = 1;
public static final int LANGUAGE_CODE_JAPANESE = 2;
public static final int LANGUAGE_CODE_KOREAN = 3;
public static final int LANGUAGE_CODE_SIMPLIFIED_CHINESE = 4;
public static final int LANGUAGE_CODE_TRADITIONAL_CHINESE = 5;
//--String Encodings
public static final String STRING_ENCODING_PRE_MX = "US-ASCII";
public static final String STRING_ENCODING_MX = "UTF-8";
//--String Encodings
public static final String STRING_ENCODING_PRE_MX = "US-ASCII";
public static final String STRING_ENCODING_MX = "UTF-8";
//--MX Version number
public static final int FLASH_MX_VERSION = 6;
//--MX Version number
public static final int FLASH_MX_VERSION = 6;
}

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

@ -3,11 +3,11 @@ package pt.tumba.parser.swf;
import com.anotherbigidea.flash.SWFActionCodes;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Hashtable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Stack;
import java.util.Vector;
/**
* 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
*/
public class ActionWriter implements SWFActions, SWFActionCodes {
/**
* Description of the Field
*/
protected TagWriter tagWriter;
/**
* Description of the Field
*/
protected OutStream out;
/**
* Description of the Field
*/
protected ByteArrayOutputStream bout;
/**
* Description of the Field
*/
protected int count;
/**
* Description of the Field
*/
protected int flashVersion;
/**
* Description of the Field
*/
protected List pushValues;
/**
* Description of the Field
*/
protected Hashtable labels;
/**
* Description of the Field
*/
protected HashMap labels;
protected List jumps;
/**
* Description of the Field
*/
protected List skips;
//--for fixing up functions and WITH blocks..
/**
* Description of the Field
*/
protected List blocks;
/**
* Description of the Field
*/
protected Stack blockStack;
@ -106,7 +74,7 @@ public class ActionWriter implements SWFActions, SWFActionCodes {
count = 0;
bout = new ByteArrayOutputStream();
out = new OutStream(bout);
pushValues = new Vector();
pushValues = new ArrayList();
labels = null;
jumps = null;
skips = null;
@ -315,7 +283,7 @@ public class ActionWriter implements SWFActions, SWFActionCodes {
int offset = (int) out.getBytesWritten();
if (labels == null) {
labels = new Hashtable();
labels = new HashMap();
}
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
if (jumps == null) {
jumps = new Vector();
jumps = new ArrayList();
}
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
if (skips == null) {
skips = new Vector();
skips = new ArrayList();
}
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
if (skips == null) {
skips = new Vector();
skips = new ArrayList();
}
skips.add(new Object[]{jumpLabel, new int[]{count, here}});
}
@ -1032,7 +1000,7 @@ public class ActionWriter implements SWFActions, SWFActionCodes {
int[] blockInfo = (int[]) blockStack.pop();
if (blocks == null) {
blocks = new Vector();
blocks = new ArrayList();
}
int offset = blockInfo[0];

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

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

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

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

@ -1,9 +1,8 @@
package pt.tumba.parser.swf;
import java.io.IOException;
import java.util.Iterator;
import java.util.ArrayList;
import java.util.List;
import java.util.Vector;
/**
* A Movie or Movie Clip frame
@ -12,29 +11,12 @@ import java.util.Vector;
*@created 15 de Setembro de 2002
*/
public class Frame {
/**
* Description of the Field
*/
protected int frameNumber;
/**
* Description of the Field
*/
protected String label;
/**
* Description of the Field
*/
protected List placements = new Vector();
/**
* Description of the Field
*/
protected List<Placement> placements = new ArrayList();
protected boolean stop;
/**
* Description of the Field
*/
protected TimeLine timeline;
/**
* Description of the Field
*/
protected Actions actions;
/**
@ -402,19 +384,15 @@ public class Frame {
*@param definitionWriter Description of the Parameter
*@exception IOException Description of the Exception
*/
protected void flushDefinitions(
Movie movie,
SWFTagTypes timelineWriter,
SWFTagTypes definitionWriter)
throws IOException {
for (Iterator enumerator = placements.iterator();
enumerator.hasNext();
) {
Placement placement = (Placement) enumerator.next();
placement.flushDefinitions(movie, timelineWriter, definitionWriter);
}
}
protected void flushDefinitions(
Movie movie,
SWFTagTypes timelineWriter,
SWFTagTypes definitionWriter)
throws IOException {
for (Placement placement : placements) {
placement.flushDefinitions(movie, timelineWriter, definitionWriter);
}
}
/**
* Write the frame
@ -424,38 +402,34 @@ public class Frame {
*@param timelineTagWriter Description of the Parameter
*@exception IOException Description of the Exception
*/
protected void write(
Movie movie,
SWFTagTypes movieTagWriter,
SWFTagTypes timelineTagWriter)
throws IOException {
if (actions != null) {
SWFActions acts = timelineTagWriter.tagDoAction();
acts.start(0);
acts.blob(actions.bytes);
acts.done();
}
if (stop) {
SWFActions actions = timelineTagWriter.tagDoAction();
actions.start(0);
actions.stop();
actions.end();
actions.done();
}
for (Iterator enumumerator = placements.iterator();
enumumerator.hasNext();
) {
Placement placement = (Placement) enumumerator.next();
placement.write(movie, movieTagWriter, timelineTagWriter);
}
if (label != null) {
timelineTagWriter.tagFrameLabel(label);
}
timelineTagWriter.tagShowFrame();
}
protected void write(
Movie movie,
SWFTagTypes movieTagWriter,
SWFTagTypes timelineTagWriter)
throws IOException {
if (actions != null) {
SWFActions acts = timelineTagWriter.tagDoAction();
acts.start(0);
acts.blob(actions.bytes);
acts.done();
}
if (stop) {
SWFActions actions = timelineTagWriter.tagDoAction();
actions.start(0);
actions.stop();
actions.end();
actions.done();
}
for (Placement placement : placements) {
placement.write(movie, movieTagWriter, timelineTagWriter);
}
if (label != null) {
timelineTagWriter.tagFrameLabel(label);
}
timelineTagWriter.tagShowFrame();
}
}

@ -10,7 +10,6 @@ import java.util.List;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;
import java.util.Vector;
/**
* A Flash Movie
@ -19,63 +18,24 @@ import java.util.Vector;
*@created 15 de Setembro de 2002
*/
public class Movie implements TimeLine {
/**
* Description of the Field
*/
protected int width;
/**
* Description of the Field
*/
protected int height;
/**
* Description of the Field
*/
protected int frameRate;
/**
* Description of the Field
*/
protected Color backColor;
/**
* Description of the Field
*/
protected int version;
/**
* Description of the Field
*/
protected boolean isProtected;
/**
* Description of the Field
*/
protected Map importLibraries;
/**
* Description of the Field
*/
protected List exportedSymbols;
protected Map<String, List> importLibraries;
protected List<ExportedSymbol> exportedSymbols;
/**
* Description of the Field
*/
protected SortedMap frames = new TreeMap();
/**
* Description of the Field
*/
protected SortedMap<Integer, Frame> frames = new TreeMap();
protected int frameCount = 0;
//--Table of characters defined so far in the movie - while writing out
/**
* Description of the Field
*/
protected Map definedSymbols = new HashMap();
/**
* Description of the Field
*/
protected int depth = 1;
//the next available depth
/**
* Description of the Field
*/
protected int depth = 1; //the next available depth
protected int maxId = 1;
@ -357,20 +317,16 @@ public class Movie implements TimeLine {
return new ImportedSymbol[0];
}
Vector imports = new Vector();
for (Iterator iter = importLibraries.values().iterator(); iter.hasNext(); ) {
List list = (List) iter.next();
List imports = new ArrayList();
for (List list : importLibraries.values()) {
for (Iterator i2 = list.iterator(); i2.hasNext(); ) {
imports.add(i2.next());
}
}
ImportedSymbol[] imps = new ImportedSymbol[imports.size()];
imports.copyInto(imps);
return imps;
return (ImportedSymbol[])imports.toArray(imps);
}
@ -383,7 +339,7 @@ public class Movie implements TimeLine {
*/
public void exportSymbols(String[] exportNames, Symbol[] symbols) {
if (exportedSymbols == null) {
exportedSymbols = new Vector();
exportedSymbols = new ArrayList();
}
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
*/
public class OutStream {
/**
* Description of the Field
*/
protected OutputStream out;
/**
* Description of the Field
*/
protected long bytesWritten = 0L;
//--Bit buffer..
/**
* Description of the Field
*/
protected int bitBuf;
/**
* Description of the Field
*/
protected int bitPos;
@ -104,6 +93,7 @@ public class OutStream {
*@exception IOException Description of the Exception
*/
public void close() throws IOException {
flushBits();
out.close();
}
@ -325,8 +315,7 @@ public class OutStream {
if (string != null) {
out.write(string);
}
out.write(0);
//terminate string
out.write(0); //terminate string
bytesWritten += string.length + 1;
}
@ -343,8 +332,7 @@ public class OutStream {
if (string == null) {
return 1;
}
return string.length + 1;
//to include the terminating null
return string.length + 1; //to include the terminating null
}
@ -361,8 +349,7 @@ public class OutStream {
}
byte[] bytes = string.getBytes();
return bytes.length + 1;
//to include the terminating null
return bytes.length + 1; //to include the terminating null
}

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

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

Loading…
Cancel
Save