preserver original tag header and endtag, organize imports, missing javadoc params

This commit is contained in:
Honfika
2014-04-05 16:10:43 +02:00
parent 079f642e40
commit ca52f63769
118 changed files with 523 additions and 423 deletions
+12 -3
View File
@@ -79,6 +79,7 @@ import com.jpexs.decompiler.flash.tags.DefineSoundTag;
import com.jpexs.decompiler.flash.tags.DefineSpriteTag;
import com.jpexs.decompiler.flash.tags.DefineVideoStreamTag;
import com.jpexs.decompiler.flash.tags.DoInitActionTag;
import com.jpexs.decompiler.flash.tags.EndTag;
import com.jpexs.decompiler.flash.tags.ExportAssetsTag;
import com.jpexs.decompiler.flash.tags.FileAttributesTag;
import com.jpexs.decompiler.flash.tags.JPEGTablesTag;
@@ -204,6 +205,7 @@ public final class SWF implements TreeItem, Timelined {
* Tags inside of file
*/
public List<Tag> tags = new ArrayList<>();
public boolean hasEndTag;
/**
* ExportRectangle for the display
*/
@@ -282,7 +284,7 @@ public final class SWF implements TreeItem, Timelined {
Tag t = tags.get(i);
if (t instanceof DefineSpriteTag) {
if (!isSpriteValid((DefineSpriteTag) t, new ArrayList<Integer>())) {
tags.set(i, new Tag(this, t.getId(), "InvalidSprite", t.getData(), t.getPos()));
tags.set(i, new Tag(this, t.getId(), "InvalidSprite", t.getOriginalHeaderData(), t.getOriginalData(), t.getPos()));
}
}
}
@@ -349,7 +351,9 @@ public final class SWF implements TreeItem, Timelined {
sos.writeUI16(frameCount);
sos.writeTags(tags);
sos.writeUI16(0);
if (hasEndTag) {
sos.writeUI16(0);
}
sos.close();
if (compressed && lzma) {
os.write('Z');
@@ -578,7 +582,12 @@ public final class SWF implements TreeItem, Timelined {
sis.readUI8(); //tmpFirstByetOfFrameRate
frameRate = sis.readUI8();
frameCount = sis.readUI16();
tags = sis.readTagList(this, this, 0, parallelRead, true, !checkOnly, gfx);
List<Tag> tags = sis.readTagList(this, this, 0, parallelRead, true, !checkOnly, gfx);
if (tags.get(tags.size() - 1).getId() == EndTag.ID) {
hasEndTag = true;
tags.remove(tags.size() - 1);
}
this.tags = tags;
if (!checkOnly) {
checkInvalidSprites();
updateInnerTagsForShowFrameTags();
@@ -908,6 +908,7 @@ public class SWFInputStream extends InputStream {
case SoundStreamHead2Tag.ID:
case SoundStreamBlockTag.ID:
case VideoFrameTag.ID:
case EndTag.ID:
doParse = true;
break;
default:
@@ -930,6 +931,10 @@ public class SWFInputStream extends InputStream {
futureResults.add(future);
}
}
if (tag.getId() == EndTag.ID) {
break;
}
}
if (parallel) {
@@ -952,131 +957,132 @@ public class SWFInputStream extends InputStream {
Tag ret;
byte[] data = tag.getData();
byte[] headerData = tag.getOriginalHeaderData();
long pos = tag.getPos();
try {
switch (tag.getId()) {
case 0:
ret = new EndTag(swf, data, pos);
ret = new EndTag(swf, headerData, data, pos);
break;
case 1:
ret = new ShowFrameTag(swf, pos);
ret = new ShowFrameTag(swf, headerData, data, pos);
break;
case 2:
ret = new DefineShapeTag(swf, data, pos);
ret = new DefineShapeTag(swf, headerData, data, pos);
break;
//case 3: FreeCharacter
case 4:
ret = new PlaceObjectTag(swf, data, pos);
ret = new PlaceObjectTag(swf, headerData, data, pos);
break;
case 5:
ret = new RemoveObjectTag(swf, data, pos);
ret = new RemoveObjectTag(swf, headerData, data, pos);
break;
case 6:
ret = new DefineBitsTag(swf, data, pos);
ret = new DefineBitsTag(swf, headerData, data, pos);
break;
case 7:
ret = new DefineButtonTag(swf, data, pos);
ret = new DefineButtonTag(swf, headerData, data, pos);
break;
case 8:
ret = new JPEGTablesTag(swf, data, pos);
ret = new JPEGTablesTag(swf, headerData, data, pos);
break;
case 9:
ret = new SetBackgroundColorTag(swf, data, pos);
ret = new SetBackgroundColorTag(swf, headerData, data, pos);
break;
case 10:
ret = new DefineFontTag(swf, data, pos);
ret = new DefineFontTag(swf, headerData, data, pos);
break;
case 11:
ret = new DefineTextTag(swf, data, pos);
ret = new DefineTextTag(swf, headerData, data, pos);
break;
case 12:
ret = new DoActionTag(swf, data, pos);
ret = new DoActionTag(swf, headerData, data, pos);
break;
case 13:
ret = new DefineFontInfoTag(swf, data, pos);
ret = new DefineFontInfoTag(swf, headerData, data, pos);
break;
case 14:
ret = new DefineSoundTag(swf, data, pos);
ret = new DefineSoundTag(swf, headerData, data, pos);
break;
case 15:
ret = new StartSoundTag(swf, data, pos);
ret = new StartSoundTag(swf, headerData, data, pos);
break;
//case 16:
case 17:
ret = new DefineButtonSoundTag(swf, data, pos);
ret = new DefineButtonSoundTag(swf, headerData, data, pos);
break;
case 18:
ret = new SoundStreamHeadTag(swf, data, pos);
ret = new SoundStreamHeadTag(swf, headerData, data, pos);
break;
case 19:
ret = new SoundStreamBlockTag(swf, data, pos);
ret = new SoundStreamBlockTag(swf, headerData, data, pos);
break;
case 21:
ret = new DefineBitsJPEG2Tag(swf, data, pos);
ret = new DefineBitsJPEG2Tag(swf, headerData, data, pos);
break;
case 20:
ret = new DefineBitsLosslessTag(swf, data, pos);
ret = new DefineBitsLosslessTag(swf, headerData, data, pos);
break;
case 22:
ret = new DefineShape2Tag(swf, data, pos);
ret = new DefineShape2Tag(swf, headerData, data, pos);
break;
case 23:
ret = new DefineButtonCxformTag(swf, data, pos);
ret = new DefineButtonCxformTag(swf, headerData, data, pos);
break;
case 24:
ret = new ProtectTag(swf, data, pos);
ret = new ProtectTag(swf, headerData, data, pos);
break;
//case 25: PathsArePostscript
case 26:
ret = new PlaceObject2Tag(swf, data, pos);
ret = new PlaceObject2Tag(swf, headerData, data, pos);
break;
//case 27:
case 28:
ret = new RemoveObject2Tag(swf, data, pos);
ret = new RemoveObject2Tag(swf, headerData, data, pos);
break;
//case 29: SyncFrame
//case 30:
//case 31: FreeAll
case 32:
ret = new DefineShape3Tag(swf, data, pos);
ret = new DefineShape3Tag(swf, headerData, data, pos);
break;
case 33:
ret = new DefineText2Tag(swf, data, pos);
ret = new DefineText2Tag(swf, headerData, data, pos);
break;
case 34:
ret = new DefineButton2Tag(swf, data, pos);
ret = new DefineButton2Tag(swf, headerData, data, pos);
break;
case 35:
ret = new DefineBitsJPEG3Tag(swf, data, pos);
ret = new DefineBitsJPEG3Tag(swf, headerData, data, pos);
break;
case 36:
ret = new DefineBitsLossless2Tag(swf, data, pos);
ret = new DefineBitsLossless2Tag(swf, headerData, data, pos);
break;
case 37:
ret = new DefineEditTextTag(swf, data, pos);
ret = new DefineEditTextTag(swf, headerData, data, pos);
break;
//case 38: DefineVideo
case 39:
ret = new DefineSpriteTag(swf, data, level, pos, parallel, skipUnusualTags);
ret = new DefineSpriteTag(swf, headerData, data, level, pos, parallel, skipUnusualTags);
break;
//case 40: NameCharacter
case 41:
ret = new ProductInfoTag(swf, data, pos);
ret = new ProductInfoTag(swf, headerData, data, pos);
break;
//case 42: DefineTextFormat
case 43:
ret = new FrameLabelTag(swf, data, pos);
ret = new FrameLabelTag(swf, headerData, data, pos);
break;
//case 44:
case 45:
ret = new SoundStreamHead2Tag(swf, data, pos);
ret = new SoundStreamHead2Tag(swf, headerData, data, pos);
break;
case 46:
ret = new DefineMorphShapeTag(swf, data, pos);
ret = new DefineMorphShapeTag(swf, headerData, data, pos);
break;
//case 47: GenerateFrame
case 48:
ret = new DefineFont2Tag(swf, data, pos);
ret = new DefineFont2Tag(swf, headerData, data, pos);
break;
//case 49: GeneratorCommand
//case 50: DefineCommandObject
@@ -1084,148 +1090,148 @@ public class SWFInputStream extends InputStream {
//case 52: ExternalFont
//case 53-55
case 56:
ret = new ExportAssetsTag(swf, data, pos);
ret = new ExportAssetsTag(swf, headerData, data, pos);
break;
case 57:
ret = new ImportAssetsTag(swf, data, pos);
ret = new ImportAssetsTag(swf, headerData, data, pos);
break;
case 58:
ret = new EnableDebuggerTag(swf, data, pos);
ret = new EnableDebuggerTag(swf, headerData, data, pos);
break;
case 59:
ret = new DoInitActionTag(swf, data, pos);
ret = new DoInitActionTag(swf, headerData, data, pos);
break;
case 60:
ret = new DefineVideoStreamTag(swf, data, pos);
ret = new DefineVideoStreamTag(swf, headerData, data, pos);
break;
case 61:
ret = new VideoFrameTag(swf, data, pos);
ret = new VideoFrameTag(swf, headerData, data, pos);
break;
case 62:
ret = new DefineFontInfo2Tag(swf, data, pos);
ret = new DefineFontInfo2Tag(swf, headerData, data, pos);
break;
case 63:
ret = new DebugIDTag(swf, data, pos);
ret = new DebugIDTag(swf, headerData, data, pos);
break;
case 64:
ret = new EnableDebugger2Tag(swf, data, pos);
ret = new EnableDebugger2Tag(swf, headerData, data, pos);
break;
case 65:
ret = new ScriptLimitsTag(swf, data, pos);
ret = new ScriptLimitsTag(swf, headerData, data, pos);
break;
case 66:
ret = new SetTabIndexTag(swf, data, pos);
ret = new SetTabIndexTag(swf, headerData, data, pos);
break;
//case 67-68:
case 69:
ret = new FileAttributesTag(swf, data, pos);
ret = new FileAttributesTag(swf, headerData, data, pos);
break;
case 70:
ret = new PlaceObject3Tag(swf, data, pos);
ret = new PlaceObject3Tag(swf, headerData, data, pos);
break;
case 71:
ret = new ImportAssets2Tag(swf, data, pos);
ret = new ImportAssets2Tag(swf, headerData, data, pos);
break;
case 72:
ret = new DoABCTag(swf, data, pos);
ret = new DoABCTag(swf, headerData, data, pos);
break;
case 73:
ret = new DefineFontAlignZonesTag(swf, data, pos);
ret = new DefineFontAlignZonesTag(swf, headerData, data, pos);
break;
case 74:
ret = new CSMTextSettingsTag(swf, data, pos);
ret = new CSMTextSettingsTag(swf, headerData, data, pos);
break;
case 75:
ret = new DefineFont3Tag(swf, data, pos);
ret = new DefineFont3Tag(swf, headerData, data, pos);
break;
case 76:
ret = new SymbolClassTag(swf, data, pos);
ret = new SymbolClassTag(swf, headerData, data, pos);
break;
case 77:
ret = new MetadataTag(swf, data, pos);
ret = new MetadataTag(swf, headerData, data, pos);
break;
case 78:
ret = new DefineScalingGridTag(swf, data, pos);
ret = new DefineScalingGridTag(swf, headerData, data, pos);
break;
//case 79-81:
case 82:
ret = new DoABCDefineTag(swf, data, pos);
ret = new DoABCDefineTag(swf, headerData, data, pos);
break;
case 83:
ret = new DefineShape4Tag(swf, data, pos);
ret = new DefineShape4Tag(swf, headerData, data, pos);
break;
case 84:
ret = new DefineMorphShape2Tag(swf, data, pos);
ret = new DefineMorphShape2Tag(swf, headerData, data, pos);
break;
//case 85:
case 86:
ret = new DefineSceneAndFrameLabelDataTag(swf, data, pos);
ret = new DefineSceneAndFrameLabelDataTag(swf, headerData, data, pos);
break;
case 87:
ret = new DefineBinaryDataTag(swf, data, pos);
ret = new DefineBinaryDataTag(swf, headerData, data, pos);
break;
case 88:
ret = new DefineFontNameTag(swf, data, pos);
ret = new DefineFontNameTag(swf, headerData, data, pos);
break;
case 89:
ret = new StartSound2Tag(swf, data, pos);
ret = new StartSound2Tag(swf, headerData, data, pos);
break;
case 90:
ret = new DefineBitsJPEG4Tag(swf, data, pos);
ret = new DefineBitsJPEG4Tag(swf, headerData, data, pos);
break;
case 91:
ret = new DefineFont4Tag(swf, data, pos);
ret = new DefineFont4Tag(swf, headerData, data, pos);
break;
//case 92: certificate
case 93:
ret = new EnableTelemetryTag(swf, data, pos);
ret = new EnableTelemetryTag(swf, headerData, data, pos);
break;
case 94:
ret = new PlaceObject4Tag(swf, data, pos);
ret = new PlaceObject4Tag(swf, headerData, data, pos);
break;
default:
if (gfx) { //GFX tags only in GFX files. There may be incorrect GFX tags in non GFX files
switch (tag.getId()) {
case 1000:
ret = new ExporterInfoTag(swf, data, pos);
ret = new ExporterInfoTag(swf, headerData, data, pos);
break;
case 1001:
ret = new DefineExternalImage(swf, data, pos);
ret = new DefineExternalImage(swf, headerData, data, pos);
break;
case 1002:
ret = new FontTextureInfo(swf, data, pos);
ret = new FontTextureInfo(swf, headerData, data, pos);
break;
case 1003:
ret = new DefineExternalGradient(swf, data, pos);
ret = new DefineExternalGradient(swf, headerData, data, pos);
break;
case 1004:
ret = new DefineGradientMap(swf, data, pos);
ret = new DefineGradientMap(swf, headerData, data, pos);
break;
case 1005:
ret = new DefineCompactedFont(swf, data, pos);
ret = new DefineCompactedFont(swf, headerData, data, pos);
break;
case 1006:
ret = new DefineExternalSound(swf, data, pos);
ret = new DefineExternalSound(swf, headerData, data, pos);
break;
case 1007:
ret = new DefineExternalStreamSound(swf, data, pos);
ret = new DefineExternalStreamSound(swf, headerData, data, pos);
break;
case 1008:
ret = new DefineSubImage(swf, data, pos);
ret = new DefineSubImage(swf, headerData, data, pos);
break;
case 1009:
ret = new DefineExternalImage2(swf, data, pos);
ret = new DefineExternalImage2(swf, headerData, data, pos);
break;
default:
ret = new UnknownTag(swf, tag.getId(), data, pos);
ret = new UnknownTag(swf, tag.getId(), headerData, data, pos);
}
} else {
ret = new UnknownTag(swf, tag.getId(), data, pos);
ret = new UnknownTag(swf, tag.getId(), headerData, data, pos);
}
}
} catch (IOException ex) {
Logger.getLogger(SWFInputStream.class.getName()).log(Level.SEVERE, "Error during tag reading", ex);
ret = new Tag(swf, tag.getId(), "ErrorTag", data, pos);
ret = new Tag(swf, tag.getId(), "ErrorTag", headerData, data, pos);
}
ret.previousTag = tag.previousTag;
ret.forceWriteAsLong = tag.forceWriteAsLong;
@@ -1251,9 +1257,6 @@ public class SWFInputStream extends InputStream {
public Tag readTag(SWF swf, int level, long pos, boolean resolve, boolean parallel, boolean skipUnusualTags, boolean gfx) throws IOException, InterruptedException {
int tagIDTagLength = readUI16();
int tagID = (tagIDTagLength) >> 6;
if (tagID == 0) {
return null;
}
logger.log(Level.INFO, "Reading tag. ID={0}, position: {1}", new Object[]{tagID, pos});
@@ -1264,7 +1267,7 @@ public class SWFInputStream extends InputStream {
readLong = true;
}
byte[] data = readBytes((int) tagLength);
Tag ret = new Tag(swf, tagID, "Unresolved", data, pos);
Tag ret = new Tag(swf, tagID, "Unresolved", Tag.getTagHeader(tagIDTagLength, tagLength, readLong, swf.version), data, pos);
ret.forceWriteAsLong = readLong;
if (resolve) {
@@ -1675,6 +1678,7 @@ public class SWFInputStream extends InputStream {
* Reads one CLIPACTIONRECORD value from the stream
*
* @param swf
* @param tag
* @return CLIPACTIONRECORD value
* @throws IOException
*/
@@ -1691,6 +1695,7 @@ public class SWFInputStream extends InputStream {
* Reads one CLIPACTIONS value from the stream
*
* @param swf
* @param tag
* @return CLIPACTIONS value
* @throws IOException
*/
@@ -2032,6 +2037,7 @@ public class SWFInputStream extends InputStream {
* Reads list of BUTTONCONDACTION values from the stream
*
* @param swf
* @param tag
* @return List of BUTTONCONDACTION values
* @throws IOException
*/
@@ -2049,6 +2055,7 @@ public class SWFInputStream extends InputStream {
* Reads one BUTTONCONDACTION value from the stream
*
* @param swf
* @param tag
* @return BUTTONCONDACTION value
* @throws IOException
*/
@@ -418,7 +418,7 @@ public class SWFOutputStream extends OutputStream {
public void writeTags(List<Tag> tags) throws IOException {
for (Tag tag : tags) {
//try {
writeTag(tag);
tag.writeTag(this);
/*} catch (NotSameException nse) {
throw new RuntimeException("error in tag "+tag+" at pos "+Helper.formatHex((int)tag.getPos(), 8), nse);
}*/
@@ -426,39 +426,6 @@ public class SWFOutputStream extends OutputStream {
}
}
public static byte[] getTagHeader(Tag tag, byte[] data, int version) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
SWFOutputStream sos = new SWFOutputStream(baos, version);
int tagLength = data.length;
int tagID = tag.getId();
int tagIDLength = (tagID << 6);
if ((tagLength <= 62) && (!tag.forceWriteAsLong)) {
tagIDLength += tagLength;
sos.writeUI16(tagIDLength);
} else {
tagIDLength += 0x3f;
sos.writeUI16(tagIDLength);
sos.writeSI32(tagLength);
}
} catch (IOException iex) {
}
return baos.toByteArray();
}
/**
* Writes Tag value to the stream
*
* @param tag Tag value
* @throws IOException
*/
public void writeTag(Tag tag) throws IOException {
byte[] data = tag.getDataOrOriginalData();
write(getTagHeader(tag, data, version));
write(data);
}
/**
* Calculates number of bits needed for representing unsigned value
*
@@ -20,7 +20,6 @@ import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.avm2.instructions.comparison.GreaterEqualsIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfEqIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfGeIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfNGeIns;
import com.jpexs.decompiler.flash.ecma.EcmaScript;
@@ -20,7 +20,6 @@ import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.avm2.instructions.comparison.GreaterThanIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfEqIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfGtIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfNGtIns;
import com.jpexs.decompiler.flash.ecma.EcmaScript;
@@ -20,7 +20,6 @@ import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.avm2.instructions.comparison.LessEqualsIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfEqIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfLeIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfNLeIns;
import com.jpexs.decompiler.flash.ecma.EcmaScript;
@@ -20,7 +20,6 @@ import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.avm2.instructions.comparison.LessThanIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfEqIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfLtIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfNLtIns;
import com.jpexs.decompiler.flash.ecma.EcmaScript;
@@ -20,7 +20,6 @@ import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.avm2.instructions.comparison.StrictEqualsIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfNeIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfStrictEqIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfStrictNeIns;
import com.jpexs.decompiler.flash.ecma.EcmaScript;
@@ -21,7 +21,6 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.NotIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.comparison.StrictEqualsIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfNeIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfStrictEqIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfStrictNeIns;
import com.jpexs.decompiler.flash.ecma.EcmaScript;
@@ -22,11 +22,9 @@ import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.NotIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.comparison.EqualsIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.comparison.StrictEqualsIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.construction.ConstructSuperIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.construction.NewClassIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfEqIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfFalseIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfTrueIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.JumpIns;
@@ -611,7 +609,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
}
public void generateClass(int namespace, int initScope, PackageAVM2Item pkg, ClassInfo classInfo, InstanceInfo instanceInfo, SourceGeneratorLocalData localData, boolean isInterface, String name, String superName, GraphTargetItem extendsVal, List<GraphTargetItem> implementsStr, GraphTargetItem constructor, List<GraphTargetItem> traitItems) throws ParseException {
localData.currentClass = pkg.packageName.equals("") ? name : pkg.packageName + "." + name;
localData.currentClass = pkg.packageName.isEmpty() ? name : pkg.packageName + "." + name;
List<GraphSourceItem> ret = new ArrayList<>();
if (extendsVal == null && !isInterface) {
extendsVal = new TypeItem("Object");
@@ -720,8 +718,8 @@ public class AVM2SourceGenerator implements SourceGenerator {
String name = type.toString();
TypeItem nameItem = (TypeItem) type;
if (name.contains(".")) {
pkg = name.substring(0, name.lastIndexOf("."));
name = name.substring(name.lastIndexOf(".") + 1);
pkg = name.substring(0, name.lastIndexOf('.'));
name = name.substring(name.lastIndexOf('.') + 1);
}
/*int nsKind = Namespace.KIND_PACKAGE;
@@ -853,7 +853,7 @@ public final class ActionScriptLexer {
return yychar;
}
private Stack<ParsedSymbol> pushedBack = new Stack<ParsedSymbol>();
private Stack<ParsedSymbol> pushedBack = new Stack<>();
public int yyline() {
return yyline + 1;
@@ -995,6 +995,7 @@ public final class ActionScriptLexer {
/**
* Closes the input stream.
* @throws java.io.IOException
*/
public final void yyclose() throws java.io.IOException {
zzAtEOF = true; /* indicate end of file */
@@ -1035,6 +1036,7 @@ public final class ActionScriptLexer {
/**
* Returns the current lexical state.
* @return
*/
public final int yystate() {
return zzLexicalState;
@@ -1051,6 +1053,7 @@ public final class ActionScriptLexer {
/**
* Returns the text matched by the current regular expression.
* @return
*/
public final String yytext() {
return new String(zzBuffer, zzStartRead, zzMarkedPos - zzStartRead);
@@ -1072,6 +1075,7 @@ public final class ActionScriptLexer {
/**
* Returns the length of the matched text region.
* @return
*/
public final int yylength() {
return zzMarkedPos - zzStartRead;
@@ -1123,6 +1127,7 @@ public final class ActionScriptLexer {
*
* @return the next token
* @exception java.io.IOException if any I/O-Error occurs
* @throws com.jpexs.decompiler.flash.abc.avm2.parser.ParseException
*/
public ParsedSymbol yylex() throws java.io.IOException, ParseException {
int zzInput;
@@ -1587,7 +1592,7 @@ public final class ActionScriptLexer {
String s = yytext();
s = s.substring(1, s.length() - 1);
if (s.contains(" ")) {
s = s.substring(0, s.indexOf(" "));
s = s.substring(0, s.indexOf(' '));
}
xmlTagName = s;
string.append(yytext());
@@ -75,7 +75,6 @@ import com.jpexs.decompiler.flash.abc.types.Multiname;
import com.jpexs.decompiler.flash.abc.types.Namespace;
import com.jpexs.decompiler.flash.action.swf4.ActionIf;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.gui.Main;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import com.jpexs.decompiler.flash.tags.Tag;
import com.jpexs.decompiler.graph.GraphTargetItem;
@@ -284,8 +283,8 @@ public class ActionScriptParser {
String iname = importedClasses.get(i);
String ipkg = "";
if (iname.contains(".")) {
ipkg = iname.substring(0, iname.lastIndexOf("."));
iname = iname.substring(iname.lastIndexOf(".") + 1);
ipkg = iname.substring(0, iname.lastIndexOf('.'));
iname = iname.substring(iname.lastIndexOf('.') + 1);
}
if (iname.equals(parts.get(0))) {
k = 0;
@@ -305,7 +304,7 @@ public class ActionScriptParser {
}
name = parts.get(k);
String fname = pkg.equals("") ? name : pkg + "." + name;
String fname = pkg.isEmpty() ? name : pkg + "." + name;
for (ABC a : allAbcs) {
int c = a.findClassByName(fname);
@@ -321,7 +320,7 @@ public class ActionScriptParser {
String nsname = ns.getName(abc.constants);
if (nsKind == Namespace.KIND_PACKAGE) {
for (ABC a : allAbcs) {
int c = a.findClassByName(nsname.equals("") ? fname : nsname + "." + fname);
int c = a.findClassByName(nsname.isEmpty() ? fname : nsname + "." + fname);
if (c != -1) {
pkg = nsname;
break loopk;
@@ -693,7 +692,7 @@ public class ActionScriptParser {
nval = s.value.toString();
s = lex();
} else {
nval = (packageName.equals("") ? classNameStr : packageName + ":" + classNameStr) + "/" + nname;
nval = (packageName.isEmpty() ? classNameStr : packageName + ":" + classNameStr) + "/" + nname;
}
if (s.type != SymbolType.SEMICOLON) {
lexer.pushback(s);
@@ -768,15 +767,15 @@ public class ActionScriptParser {
int publicNs = namespace;
int protectedStaticNs = 0;
openedNamespaces.add(protectedNs = abc.constants.addNamespace(new Namespace(Namespace.KIND_PROTECTED, abc.constants.getStringId(packageName.equals("") ? classNameStr : packageName + ":" + classNameStr, true))));
openedNamespaces.add(protectedStaticNs = abc.constants.addNamespace(new Namespace(Namespace.KIND_STATIC_PROTECTED, abc.constants.getStringId(packageName.equals("") ? classNameStr : packageName + ":" + classNameStr, true))));
openedNamespaces.add(protectedNs = abc.constants.addNamespace(new Namespace(Namespace.KIND_PROTECTED, abc.constants.getStringId(packageName.isEmpty() ? classNameStr : packageName + ":" + classNameStr, true))));
openedNamespaces.add(protectedStaticNs = abc.constants.addNamespace(new Namespace(Namespace.KIND_STATIC_PROTECTED, abc.constants.getStringId(packageName.isEmpty() ? classNameStr : packageName + ":" + classNameStr, true))));
List<Integer> indices = new ArrayList<>();
List<String> names = new ArrayList<>();
List<String> namespaces = new ArrayList<>();
AVM2SourceGenerator.parentNamesAddNames(abc, otherABCs, ((TypeItem) extendsStr).resolveClass(abc), indices, names, namespaces);
for (int i = 0; i < names.size(); i++) {
if (namespaces.get(i).equals("")) {
if (namespaces.get(i).isEmpty()) {
continue;
}
openedNamespaces.add(abc.constants.getNamespaceId(new Namespace(Namespace.KIND_STATIC_PROTECTED, abc.constants.getStringId(namespaces.get(i) + ":" + names.get(i), true)), 0, true));
@@ -1589,10 +1588,10 @@ public class ActionScriptParser {
lexer.pushback(s);
GraphTargetItem num = expression(importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables);
if (num instanceof IntegerValueAVM2Item) {
((IntegerValueAVM2Item) num).value = -(Long) ((IntegerValueAVM2Item) num).value;
((IntegerValueAVM2Item) num).value = -((IntegerValueAVM2Item) num).value;
ret = num;
} else if (num instanceof FloatValueAVM2Item) {
Double d = (Double) ((FloatValueAVM2Item) num).value;
Double d = ((FloatValueAVM2Item) num).value;
if (d.isInfinite()) {
((FloatValueAVM2Item) num).value = Double.NEGATIVE_INFINITY;
} else {
@@ -1782,10 +1781,10 @@ public class ActionScriptParser {
int privateNs = 0;
int publicNs = 0;
if (fileName.contains("/")) {
fileName = fileName.substring(fileName.lastIndexOf("/") + 1);
fileName = fileName.substring(fileName.lastIndexOf('/') + 1);
}
if (fileName.contains("\\")) {
fileName = fileName.substring(fileName.lastIndexOf("\\") + 1);
fileName = fileName.substring(fileName.lastIndexOf('\\') + 1);
}
String className = fileName;
if (className.endsWith(".as")) {
@@ -1797,7 +1796,7 @@ public class ActionScriptParser {
openedNamespaces.add(publicNs = abc.constants.getNamespaceId(new Namespace(Namespace.KIND_PACKAGE, abc.constants.getStringId("", true)), 0, true));
openedNamespaces.add(abc.constants.addNamespace(new Namespace(Namespace.KIND_PRIVATE, 0))); //abc.constants.getStringId(fileName + "$", true)
if (!name.equals("")) {
if (!name.isEmpty()) {
openedNamespaces.add(publicNs = abc.constants.getNamespaceId(new Namespace(Namespace.KIND_PACKAGE, abc.constants.getStringId(name, true)), 0, true));
}
@@ -68,8 +68,8 @@ public class CallAVM2Item extends AVM2Item {
String pkgName = "";
cname = localData.currentClass;
if (cname.contains(".")) {
pkgName = cname.substring(0, cname.lastIndexOf("."));
cname = cname.substring(cname.lastIndexOf(".") + 1);
pkgName = cname.substring(0, cname.lastIndexOf('.'));
cname = cname.substring(cname.lastIndexOf('.') + 1);
}
GraphTargetItem obj = null;
Reference<String> outName = new Reference<>("");
@@ -30,9 +30,6 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.other.GetPropertyIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.other.SetPropertyIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.DupIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PopIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushByteIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushNanIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushNullIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.types.CoerceAIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.types.CoerceIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.types.CoerceSIns;
@@ -437,8 +437,8 @@ public class PropertyAVM2Item extends AssignableAVM2Item {
String pkgName = "";
cname = localData.currentClass;
if (cname.contains(".")) {
pkgName = cname.substring(0, cname.lastIndexOf("."));
cname = cname.substring(cname.lastIndexOf(".") + 1);
pkgName = cname.substring(0, cname.lastIndexOf('.'));
cname = cname.substring(cname.lastIndexOf('.') + 1);
}
Reference<String> outName = new Reference<>("");
Reference<String> outNs = new Reference<>("");
@@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.abc.avm2.parser.script;
/**
*
* @author JPEXS
* @param <T>
*/
public class Reference<T> {
@@ -1934,7 +1934,7 @@ public final class ActionScriptLexer {
String s = yytext();
s = s.substring(1, s.length() - 1);
if (s.contains(" ")) {
s = s.substring(0, s.indexOf(" "));
s = s.substring(0, s.indexOf(' '));
}
xmlTagName = s;
string.append(yytext());
@@ -100,13 +100,13 @@ public class EcmaScript {
if (ny.isNaN()) {
return new Undefined();
}
if (((Double) nx).compareTo((Double) ny) == 0) {
if ((nx).compareTo(ny) == 0) {
return false;
}
if ((Double.compare((Double) nx, -0.0) == 0) && (Double.compare((Double) ny, 0.0) == 0)) {
if ((Double.compare(nx, -0.0) == 0) && (Double.compare(ny, 0.0) == 0)) {
return false;
}
if ((Double.compare((Double) nx, 0.0) == 0) && (Double.compare((Double) ny, -0.0) == 0)) {
if ((Double.compare(nx, 0.0) == 0) && (Double.compare(ny, -0.0) == 0)) {
return false;
}
if (nx.isInfinite() && nx > 0) {
@@ -506,15 +506,11 @@ public abstract class ShapeExporterBase implements IShapeExporter {
}
protected void appendFillStyles(List<FILLSTYLE> v1, FILLSTYLE[] v2) {
for (int i = 0; i < v2.length; i++) {
v1.add(v2[i]);
}
v1.addAll(Arrays.asList(v2));
}
protected void appendLineStyles(List<LINESTYLE> v1, LINESTYLE[] v2) {
for (int i = 0; i < v2.length; i++) {
v1.add(v2[i]);
}
v1.addAll(Arrays.asList(v2));
}
protected void appendEdges(List<IEdge> v1, List<IEdge> v2) {
@@ -91,7 +91,7 @@ public class FontPreviewDialog extends AppDialog {
} catch (IOException ex) {
Logger.getLogger(FontPreviewDialog.class.getName()).log(Level.SEVERE, "Cannot read font preview dialog sample texts", ex);
}
return new DefaultComboBoxModel<>(sampleTexts.toArray(new String[0]));
return new DefaultComboBoxModel<>(sampleTexts.toArray(new String[sampleTexts.size()]));
}
/**
@@ -266,7 +266,7 @@ public class GenericTagPanel extends JPanel implements ChangeListener {
final JScrollBar sb = genericTagPropertiesEditPanelScrollPanel.getVerticalScrollBar();
final int val = sb.getValue(); //save scroll top
SWFType swfType = field.getAnnotation(SWFType.class);
if (swfType != null && !swfType.countField().equals("")) { //Fields with same countField must be removed from too
if (swfType != null && !swfType.countField().isEmpty()) { //Fields with same countField must be removed from too
Field fields[] = obj.getClass().getDeclaredFields();
for (int f = 0; f < fields.length; f++) {
SWFType fieldSwfType = fields[f].getAnnotation(SWFType.class);
@@ -318,7 +318,7 @@ public class GenericTagPanel extends JPanel implements ChangeListener {
final JScrollBar sb = genericTagPropertiesEditPanelScrollPanel.getVerticalScrollBar();
final int val = sb.getValue(); //save scroll top
SWFType swfType = field.getAnnotation(SWFType.class);
if (swfType != null && !swfType.countField().equals("")) { //Fields with same countField must be enlarged too
if (swfType != null && !swfType.countField().isEmpty()) { //Fields with same countField must be enlarged too
Field fields[] = obj.getClass().getDeclaredFields();
for (int f = 0; f < fields.length; f++) {
SWFType fieldSwfType = fields[f].getAnnotation(SWFType.class);
@@ -450,7 +450,7 @@ public class GenericTagPanel extends JPanel implements ChangeListener {
result += " + " + swfType.countAdd();
}
result += "]";
} else if (!swfType.countField().equals("")) {
} else if (!swfType.countField().isEmpty()) {
result += "[" + swfType.countField();
if (swfType.countAdd() > 0) {
result += " + " + swfType.countAdd();
@@ -510,7 +510,7 @@ public class GenericTagPanel extends JPanel implements ChangeListener {
Field f = path.get(i);
int index = indices.get(i);
String par = p;
if (!p.equals("")) {
if (!p.isEmpty()) {
p += ".";
}
p += f.getName();
@@ -526,7 +526,7 @@ public class GenericTagPanel extends JPanel implements ChangeListener {
Map<String, Boolean> fields = new HashMap<>();
for (String fld : fieldNames) {
String ckey = "";
if (!par.equals("")) {
if (!par.isEmpty()) {
ckey = par + ".";
}
ckey += fld;
@@ -239,7 +239,7 @@ public class GenericTagTreePanel extends GenericTagPanel {
if (swfArray != null) {
itemStr = swfArray.value();
}
if (itemStr.equals("")) {
if (itemStr.isEmpty()) {
itemStr = AppStrings.translate("generictag.array.item");
}
if (ReflectionTools.needsIndex(fnode.field)) {
@@ -519,7 +519,7 @@ public class GenericTagTreePanel extends GenericTagPanel {
Conditional cond = fnode.field.getAnnotation(Conditional.class);
if (cond != null) {
ConditionEvaluator ev = new ConditionEvaluator(cond);
String parentPath = currentPath.indexOf(".") == -1 ? "" : currentPath.substring(0, currentPath.lastIndexOf("."));
String parentPath = currentPath.indexOf('.') == -1 ? "" : currentPath.substring(0, currentPath.lastIndexOf('.'));
try {
for (String cname : ev.getFields()) {
String fullParh = parentPath + "." + cname;
@@ -705,7 +705,7 @@ public class GenericTagTreePanel extends GenericTagPanel {
}
if (swfArray.count() > 0) {
result += "[" + swfArray.count() + "]";
} else if (!swfArray.countField().equals("")) {
} else if (!swfArray.countField().isEmpty()) {
result += "[" + swfArray.countField() + "]";
}
return result;
@@ -726,7 +726,7 @@ public class GenericTagTreePanel extends GenericTagPanel {
result += " + " + swfType.countAdd();
}
result += "]";
} else if (!swfType.countField().equals("")) {
} else if (!swfType.countField().isEmpty()) {
result += "[" + swfType.countField();
if (swfType.countAdd() > 0) {
result += " + " + swfType.countAdd();
@@ -822,7 +822,7 @@ public class GenericTagTreePanel extends GenericTagPanel {
private void addItem(Object obj, Field field, int index) {
SWFArray swfArray = field.getAnnotation(SWFArray.class);
if (swfArray != null && !swfArray.countField().equals("")) { //Fields with same countField must be enlarged too
if (swfArray != null && !swfArray.countField().isEmpty()) { //Fields with same countField must be enlarged too
Field fields[] = obj.getClass().getDeclaredFields();
List<Integer> sameFlds = new ArrayList<>();
for (int f = 0; f < fields.length; f++) {
@@ -868,7 +868,7 @@ public class GenericTagTreePanel extends GenericTagPanel {
private void removeItem(Object obj, Field field, int index) {
SWFArray swfArray = field.getAnnotation(SWFArray.class);
if (swfArray != null && !swfArray.countField().equals("")) { //Fields with same countField must be removed from too
if (swfArray != null && !swfArray.countField().isEmpty()) { //Fields with same countField must be removed from too
Field fields[] = obj.getClass().getDeclaredFields();
for (int f = 0; f < fields.length; f++) {
SWFArray fieldSwfArray = fields[f].getAnnotation(SWFArray.class);
@@ -1050,7 +1050,7 @@ public class Main {
String acceptVersions = "";
for (String a : accepted) {
if (!acceptVersions.equals("")) {
if (!acceptVersions.isEmpty()) {
acceptVersions += ",";
}
acceptVersions += a;
@@ -531,7 +531,7 @@ public class MainFrameRibbonMenu implements MainFrameMenu, ActionListener {
private void clearModified(SWF swf) {
for (Tag tag : swf.tags) {
if (tag.isModified()) {
tag.setOriginalData(tag.getData());
tag.createOriginalData();
tag.setModified(false);
}
}
@@ -2030,7 +2030,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
try {
SWF swf = it.getSwf();
if (it instanceof DefineBitsTag) {
DefineBitsJPEG2Tag jpeg2Tag = new DefineBitsJPEG2Tag(swf, it.getOriginalData(), it.getPos(), it.getCharacterId(), data);
DefineBitsJPEG2Tag jpeg2Tag = new DefineBitsJPEG2Tag(swf, it.getOriginalHeaderData(), it.getOriginalData(), it.getPos(), it.getCharacterId(), data);
jpeg2Tag.setModified(true);
swf.tags.set(swf.tags.indexOf(it), jpeg2Tag);
swf.updateCharacters();
@@ -526,7 +526,7 @@ public class PreviewPanel extends JSplitPane implements ActionListener {
/*FileAttributesTag fa = new FileAttributesTag();
sos2.writeTag(fa);
*/
sos2.writeTag(new SetBackgroundColorTag(null, new RGB(backgroundColor)));
new SetBackgroundColorTag(null, new RGB(backgroundColor)).writeTag(sos2);
if (tagObj instanceof FrameNodeItem) {
FrameNodeItem fn = (FrameNodeItem) tagObj;
@@ -559,7 +559,7 @@ public class PreviewPanel extends JSplitPane implements ActionListener {
Set<Integer> needed = t.getDeepNeededCharacters(swf.characters);
for (int n : needed) {
if (!doneCharacters.contains(n)) {
sos2.writeTag(classicTag(swf.characters.get(n)));
classicTag(swf.characters.get(n)).writeTag(sos2);
doneCharacters.add(n);
}
}
@@ -569,7 +569,7 @@ public class PreviewPanel extends JSplitPane implements ActionListener {
doneCharacters.add(((CharacterTag) t).getCharacterId());
}
}
sos2.writeTag(classicTag(t));
classicTag(t).writeTag(sos2);
if (parent != null) {
if (t instanceof PlaceObjectTypeTag) {
@@ -589,28 +589,28 @@ public class PreviewPanel extends JSplitPane implements ActionListener {
mat.translateX += width / 2;
mat.translateY += height / 2;
}
sos2.writeTag(new PlaceObject2Tag(null, false, false, false, false, false, true, false, true, depth, chid, mat, null, 0, null, 0, null));
new PlaceObject2Tag(null, false, false, false, false, false, true, false, true, depth, chid, mat, null, 0, null, 0, null).writeTag(sos2);
}
}
}
sos2.writeTag(new ShowFrameTag(null));
new ShowFrameTag(null).writeTag(sos2);
} else {
if (tagObj instanceof DefineBitsTag) {
JPEGTablesTag jtt = swf.jtt;
if (jtt != null) {
sos2.writeTag(jtt);
jtt.writeTag(sos2);
}
} else if (tagObj instanceof AloneTag) {
} else {
Set<Integer> needed = ((Tag) tagObj).getDeepNeededCharacters(swf.characters);
for (int n : needed) {
sos2.writeTag(classicTag(swf.characters.get(n)));
classicTag(swf.characters.get(n)).writeTag(sos2);
}
}
sos2.writeTag(classicTag((Tag) tagObj));
classicTag((Tag) tagObj).writeTag(sos2);
int chtId = 0;
if (tagObj instanceof CharacterTag) {
@@ -663,34 +663,34 @@ public class PreviewPanel extends JSplitPane implements ActionListener {
rec.add(tr);
mat.translateX = x * width / cols;
mat.translateY = y * height / rows;
sos2.writeTag(new DefineTextTag(null, 999 + f, new RECT(0, width, 0, height), new MATRIX(), rec));
sos2.writeTag(new PlaceObject2Tag(null, false, false, false, true, false, true, true, false, 1 + f, 999 + f, mat, null, 0, null, 0, null));
new DefineTextTag(null, 999 + f, new RECT(0, width, 0, height), new MATRIX(), rec).writeTag(sos2);
new PlaceObject2Tag(null, false, false, false, true, false, true, true, false, 1 + f, 999 + f, mat, null, 0, null, 0, null).writeTag(sos2);
x++;
}
sos2.writeTag(new ShowFrameTag(null));
new ShowFrameTag(null).writeTag(sos2);
} else if ((tagObj instanceof DefineMorphShapeTag) || (tagObj instanceof DefineMorphShape2Tag)) {
sos2.writeTag(new PlaceObject2Tag(null, false, false, false, true, false, true, true, false, 1, chtId, mat, null, 0, null, 0, null));
sos2.writeTag(new ShowFrameTag(null));
new PlaceObject2Tag(null, false, false, false, true, false, true, true, false, 1, chtId, mat, null, 0, null, 0, null).writeTag(sos2);
new ShowFrameTag(null).writeTag(sos2);
int numFrames = 100;
for (int ratio = 0; ratio < 65536; ratio += 65536 / numFrames) {
sos2.writeTag(new PlaceObject2Tag(null, false, false, false, true, false, true, false, true, 1, chtId, mat, null, ratio, null, 0, null));
sos2.writeTag(new ShowFrameTag(null));
new PlaceObject2Tag(null, false, false, false, true, false, true, false, true, 1, chtId, mat, null, ratio, null, 0, null).writeTag(sos2);
new ShowFrameTag(null).writeTag(sos2);
}
} else if (tagObj instanceof SoundStreamHeadTypeTag) {
for (SoundStreamBlockTag blk : soundFrames) {
sos2.writeTag(blk);
sos2.writeTag(new ShowFrameTag(null));
blk.writeTag(sos2);
new ShowFrameTag(null).writeTag(sos2);
}
} else if (tagObj instanceof DefineSoundTag) {
ExportAssetsTag ea = new ExportAssetsTag();
DefineSoundTag ds = (DefineSoundTag) tagObj;
ea.tags.add(ds.soundId);
ea.names.add("my_define_sound");
sos2.writeTag(ea);
ea.writeTag(sos2);
List<Action> actions;
DoActionTag doa;
doa = new DoActionTag(swf, new byte[]{}, 0);
doa = new DoActionTag(swf, new byte[0], new byte[0], 0);
actions = ASMParser.parse(0, 0, false,
"ConstantPool \"_root\" \"my_sound\" \"Sound\" \"my_define_sound\" \"attachSound\"\n"
+ "Push \"_root\"\n"
@@ -707,8 +707,8 @@ public class PreviewPanel extends JSplitPane implements ActionListener {
+ "Pop\n"
+ "Stop", swf.version, false);
doa.setActions(actions);
sos2.writeTag(doa);
sos2.writeTag(new ShowFrameTag(null));
doa.writeTag(sos2);
new ShowFrameTag(null).writeTag(sos2);
actions = ASMParser.parse(0, 0, false,
"ConstantPool \"_root\" \"my_sound\" \"Sound\" \"my_define_sound\" \"attachSound\" \"start\"\n"
@@ -734,8 +734,8 @@ public class PreviewPanel extends JSplitPane implements ActionListener {
+ "Pop\n"
+ "Stop", swf.version, false);
doa.setActions(actions);
sos2.writeTag(doa);
sos2.writeTag(new ShowFrameTag(null));
doa.writeTag(sos2);
new ShowFrameTag(null).writeTag(sos2);
actions = ASMParser.parse(0, 0, false,
"ConstantPool \"_root\" \"my_sound\" \"Sound\" \"my_define_sound\" \"attachSound\" \"onSoundComplete\" \"start\" \"execParam\"\n"
@@ -778,23 +778,23 @@ public class PreviewPanel extends JSplitPane implements ActionListener {
+ "Pop\n"
+ "Stop", swf.version, false);
doa.setActions(actions);
sos2.writeTag(doa);
sos2.writeTag(new ShowFrameTag(null));
doa.writeTag(sos2);
new ShowFrameTag(null).writeTag(sos2);
actions = ASMParser.parse(0, 0, false,
"StopSounds\n"
+ "Stop", swf.version, false);
doa.setActions(actions);
sos2.writeTag(doa);
sos2.writeTag(new ShowFrameTag(null));
doa.writeTag(sos2);
new ShowFrameTag(null).writeTag(sos2);
sos2.writeTag(new ShowFrameTag(null));
new ShowFrameTag(null).writeTag(sos2);
if (flashPanel != null) {
flashPanel.specialPlayback = true;
}
} else if (tagObj instanceof DefineVideoStreamTag) {
sos2.writeTag(new PlaceObject2Tag(null, false, false, false, false, false, true, true, false, 1, chtId, mat, null, 0, null, 0, null));
new PlaceObject2Tag(null, false, false, false, false, false, true, true, false, 1, chtId, mat, null, 0, null, 0, null).writeTag(sos2);
List<VideoFrameTag> frs = new ArrayList<>(videoFrames.values());
Collections.sort(frs, new Comparator<VideoFrameTag>() {
@Override
@@ -807,20 +807,20 @@ public class PreviewPanel extends JSplitPane implements ActionListener {
for (VideoFrameTag f : frs) {
if (!first) {
ratio++;
sos2.writeTag(new PlaceObject2Tag(null, false, false, false, true, false, false, false, true, 1, 0, null, null, ratio, null, 0, null));
new PlaceObject2Tag(null, false, false, false, true, false, false, false, true, 1, 0, null, null, ratio, null, 0, null).writeTag(sos2);
}
sos2.writeTag(f);
sos2.writeTag(new ShowFrameTag(null));
f.writeTag(sos2);
new ShowFrameTag(null).writeTag(sos2);
first = false;
}
} else {
sos2.writeTag(new PlaceObject2Tag(null, false, false, false, true, false, true, true, false, 1, chtId, mat, null, 0, null, 0, null));
sos2.writeTag(new ShowFrameTag(null));
new PlaceObject2Tag(null, false, false, false, true, false, true, true, false, 1, chtId, mat, null, 0, null, 0, null).writeTag(sos2);
new ShowFrameTag(null).writeTag(sos2);
}
}//not showframe
sos2.writeTag(new EndTag(null));
new EndTag(null).writeTag(sos2);
data = baos.toByteArray();
}
@@ -86,12 +86,13 @@ public class CSMTextSettingsTag extends Tag {
* Constructor
*
* @param swf
* @param headerData
* @param data Data bytes
* @param pos
* @throws IOException
*/
public CSMTextSettingsTag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "CSMTextSettings", data, pos);
public CSMTextSettingsTag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "CSMTextSettings", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
textID = sis.readUI16();
useFlashType = (int) sis.readUB(2);
@@ -59,12 +59,13 @@ public class DebugIDTag extends Tag {
* Constructor
*
* @param swf
* @param headerData
* @param data Data bytes
* @param pos
* @throws IOException
*/
public DebugIDTag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "DebugID", data, pos);
public DebugIDTag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "DebugID", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
debugId = sis.readBytesEx(16);
}
@@ -60,8 +60,8 @@ public class DefineBinaryDataTag extends CharacterTag {
return baos.toByteArray();
}
public DefineBinaryDataTag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineBinaryData", data, pos);
public DefineBinaryDataTag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineBinaryData", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
tag = sis.readUI16();
reserved = sis.readUI32();
@@ -68,15 +68,15 @@ public class DefineBitsJPEG2Tag extends ImageTag implements AloneTag {
return null;
}
public DefineBitsJPEG2Tag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineBitsJPEG2", data, pos);
public DefineBitsJPEG2Tag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineBitsJPEG2", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
characterID = sis.readUI16();
imageData = sis.readBytesEx(sis.available());
}
public DefineBitsJPEG2Tag(SWF swf, byte[] data, long pos, int characterID, byte[] imageData) throws IOException {
super(swf, ID, "DefineBitsJPEG2", data, pos);
public DefineBitsJPEG2Tag(SWF swf, byte[] headerData, byte[] data, long pos, int characterID, byte[] imageData) throws IOException {
super(swf, ID, "DefineBitsJPEG2", headerData, data, pos);
this.characterID = characterID;
this.imageData = imageData;
}
@@ -107,8 +107,8 @@ public class DefineBitsJPEG3Tag extends ImageTag implements AloneTag {
return null;
}
public DefineBitsJPEG3Tag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineBitsJPEG3", data, pos);
public DefineBitsJPEG3Tag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineBitsJPEG3", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
characterID = sis.readUI16();
long alphaDataOffset = sis.readUI32();
@@ -134,12 +134,13 @@ public class DefineBitsJPEG4Tag extends ImageTag implements AloneTag {
* Constructor
*
* @param swf
* @param headerData
* @param data Data bytes
* @param pos
* @throws IOException
*/
public DefineBitsJPEG4Tag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineBitsJPEG4", data, pos);
public DefineBitsJPEG4Tag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineBitsJPEG4", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
characterID = sis.readUI16();
long alphaDataOffset = sis.readUI32();
@@ -107,8 +107,8 @@ public class DefineBitsLossless2Tag extends ImageTag implements AloneTag {
setModified(true);
}
public DefineBitsLossless2Tag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineBitsLossless2", data, pos);
public DefineBitsLossless2Tag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineBitsLossless2", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
characterID = sis.readUI16();
bitmapFormat = sis.readUI8();
@@ -181,8 +181,8 @@ public class DefineBitsLosslessTag extends ImageTag implements AloneTag {
decompressed = true;
}
public DefineBitsLosslessTag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineBitsLossless", data, pos);
public DefineBitsLosslessTag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineBitsLossless", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
characterID = sis.readUI16();
bitmapFormat = sis.readUI8();
@@ -54,8 +54,8 @@ public class DefineBitsTag extends ImageTag {
return true;
}
public DefineBitsTag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineBits", data, pos);
public DefineBitsTag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineBits", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
characterID = sis.readUI16();
jpegData = sis.readBytesEx(sis.available());
@@ -100,12 +100,13 @@ public class DefineButton2Tag extends ButtonTag implements Container {
* Constructor
*
* @param swf
* @param headerData
* @param data Data bytes
* @param pos
* @throws IOException
*/
public DefineButton2Tag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineButton2", data, pos);
public DefineButton2Tag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineButton2", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
buttonId = sis.readUI16();
reserved = (int) sis.readUB(7);
@@ -61,12 +61,13 @@ public class DefineButtonCxformTag extends Tag {
* Constructor
*
* @param swf
* @param headerData
* @param data Data bytes
* @param pos
* @throws IOException
*/
public DefineButtonCxformTag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineButtonCxform", data, pos);
public DefineButtonCxformTag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineButtonCxform", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
buttonId = sis.readUI16();
buttonColorTransform = sis.readCXFORM();
@@ -101,12 +101,13 @@ public class DefineButtonSoundTag extends CharacterIdTag {
* Constructor
*
* @param swf
* @param headerData
* @param data Data bytes
* @param pos
* @throws IOException
*/
public DefineButtonSoundTag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineButtonSound", data, pos);
public DefineButtonSoundTag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineButtonSound", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
buttonId = sis.readUI16();
buttonSoundChar0 = sis.readUI16();
@@ -99,12 +99,13 @@ public class DefineButtonTag extends ButtonTag implements ASMSource {
* Constructor
*
* @param swf
* @param headerData
* @param data Data bytes
* @param pos
* @throws IOException
*/
public DefineButtonTag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineButton", data, pos);
public DefineButtonTag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineButton", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
buttonId = sis.readUI16();
characters = sis.readBUTTONRECORDList(false);
@@ -695,12 +695,13 @@ public class DefineEditTextTag extends TextTag {
* Constructor
*
* @param swf
* @param headerData
* @param data Data bytes
* @param pos
* @throws IOException
*/
public DefineEditTextTag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineEditText", data, pos);
public DefineEditTextTag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineEditText", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
characterID = sis.readUI16();
bounds = sis.readRECT();
@@ -186,19 +186,20 @@ public class DefineFont2Tag extends FontTag {
}
public DefineFont2Tag(SWF swf) throws IOException {
super(swf, ID, "DefineFont2", null, 0);
super(swf, ID, "DefineFont2", null, null, 0);
}
/**
* Constructor
*
* @param swf
* @param headerData
* @param data Data bytes
* @param pos
* @throws IOException
*/
public DefineFont2Tag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineFont2", data, pos);
public DefineFont2Tag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineFont2", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
fontId = sis.readUI16();
fontFlagsHasLayout = sis.readUB(1) == 1;
@@ -110,8 +110,8 @@ public class DefineFont3Tag extends FontTag {
return codeTable.indexOf((Integer) (int) c);
}
public DefineFont3Tag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineFont3", data, pos);
public DefineFont3Tag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineFont3", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
fontId = sis.readUI16();
fontFlagsHasLayout = sis.readUB(1) == 1;
@@ -48,8 +48,8 @@ public class DefineFont4Tag extends CharacterTag {
return fontID;
}
public DefineFont4Tag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineFont4", data, pos);
public DefineFont4Tag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineFont4", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
fontID = sis.readUI16();
reserved = (int) sis.readUB(5);
@@ -44,8 +44,8 @@ public class DefineFontAlignZonesTag extends Tag {
public List<ZONERECORD> zoneTable;
public static final int ID = 73;
public DefineFontAlignZonesTag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineFontAlignZones", data, pos);
public DefineFontAlignZonesTag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineFontAlignZones", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
fontID = sis.readUI16();
CSMTableHint = (int) sis.readUB(2);
@@ -90,12 +90,13 @@ public class DefineFontInfo2Tag extends Tag {
* Constructor
*
* @param swf
* @param headerData
* @param data Data bytes
* @param pos
* @throws IOException
*/
public DefineFontInfo2Tag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineFontInfo2", data, pos);
public DefineFontInfo2Tag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineFontInfo2", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
fontID = sis.readUI16();
int fontNameLen = sis.readUI8();
@@ -91,12 +91,13 @@ public class DefineFontInfoTag extends Tag {
* Constructor
*
* @param swf
* @param headerData
* @param data Data bytes
* @param pos
* @throws IOException
*/
public DefineFontInfoTag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineFontInfo", data, pos);
public DefineFontInfoTag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineFontInfo", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
fontId = sis.readUI16();
int fontNameLen = sis.readUI8();
@@ -31,8 +31,8 @@ public class DefineFontNameTag extends Tag {
public String fontCopyright;
public static final int ID = 88;
public DefineFontNameTag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineFontName", data, pos);
public DefineFontNameTag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineFontName", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
fontId = sis.readUI16();
fontName = sis.readString();
@@ -138,12 +138,13 @@ public class DefineFontTag extends FontTag {
* Constructor
*
* @param swf
* @param headerData
* @param data Data bytes
* @param pos
* @throws IOException
*/
public DefineFontTag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineFont", data, pos);
public DefineFontTag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineFont", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
fontId = sis.readUI16();
int firstOffset = sis.readUI16();
@@ -138,12 +138,13 @@ public class DefineMorphShape2Tag extends CharacterTag implements MorphShapeTag,
* Constructor
*
* @param swf
* @param headerData
* @param data Data bytes
* @param pos
* @throws IOException
*/
public DefineMorphShape2Tag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineMorphShape2", data, pos);
public DefineMorphShape2Tag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineMorphShape2", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
characterId = sis.readUI16();
startBounds = sis.readRECT();
@@ -116,12 +116,13 @@ public class DefineMorphShapeTag extends CharacterTag implements MorphShapeTag,
* Constructor
*
* @param swf
* @param headerData
* @param data Data bytes
* @param pos
* @throws IOException
*/
public DefineMorphShapeTag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineMorphShape", data, pos);
public DefineMorphShapeTag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineMorphShape", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
characterId = sis.readUI16();
startBounds = sis.readRECT();
@@ -37,8 +37,8 @@ public class DefineScalingGridTag extends Tag {
public RECT splitter;
public static final int ID = 78;
public DefineScalingGridTag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineScalingGrid", data, pos);
public DefineScalingGridTag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineScalingGrid", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
characterId = sis.readUI16();
splitter = sis.readRECT();
@@ -80,12 +80,13 @@ public class DefineSceneAndFrameLabelDataTag extends Tag {
* Constructor
*
* @param swf
* @param headerData
* @param data Data bytes
* @param pos
* @throws IOException
*/
public DefineSceneAndFrameLabelDataTag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineSceneAndFrameLabelData", data, pos);
public DefineSceneAndFrameLabelDataTag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineSceneAndFrameLabelData", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
int sceneCount = (int) sis.readEncodedU32();
sceneOffsets = new long[sceneCount];
@@ -75,8 +75,8 @@ public class DefineShape2Tag extends ShapeTag {
return shapeBounds;
}
public DefineShape2Tag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineShape2", data, pos);
public DefineShape2Tag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineShape2", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
shapeId = sis.readUI16();
shapeBounds = sis.readRECT();
@@ -79,8 +79,8 @@ public class DefineShape3Tag extends ShapeTag {
return shapeId;
}
public DefineShape3Tag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineShape3", data, pos);
public DefineShape3Tag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineShape3", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
shapeId = sis.readUI16();
shapeBounds = sis.readRECT();
@@ -83,8 +83,8 @@ public class DefineShape4Tag extends ShapeTag {
return shapeBounds;
}
public DefineShape4Tag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineShape4", data, pos);
public DefineShape4Tag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineShape4", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
shapeId = sis.readUI16();
shapeBounds = sis.readRECT();
@@ -60,8 +60,8 @@ public class DefineShapeTag extends ShapeTag {
return shapeBounds;
}
public DefineShapeTag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineShape", data, pos);
public DefineShapeTag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineShape", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
shapeId = sis.readUI16();
shapeBounds = sis.readRECT();
@@ -97,12 +97,13 @@ public class DefineSoundTag extends CharacterTag implements SoundTag {
* Constructor
*
* @param swf
* @param headerData
* @param data Data bytes
* @param pos
* @throws IOException
*/
public DefineSoundTag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineSound", data, pos);
public DefineSoundTag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineSound", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
soundId = sis.readUI16();
soundFormat = (int) sis.readUB(4);
@@ -70,6 +70,7 @@ public class DefineSpriteTag extends CharacterTag implements Container, Drawable
* A series of tags
*/
public List<Tag> subTags;
public boolean hasEndTag;
public static final int ID = 39;
@@ -190,6 +191,7 @@ public class DefineSpriteTag extends CharacterTag implements Container, Drawable
* Constructor
*
* @param swf
* @param headerData
* @param data Data bytes
* @param level
* @param pos
@@ -198,12 +200,17 @@ public class DefineSpriteTag extends CharacterTag implements Container, Drawable
* @throws IOException
* @throws java.lang.InterruptedException
*/
public DefineSpriteTag(SWF swf, byte[] data, int level, long pos, boolean parallel, boolean skipUnusualTags) throws IOException, InterruptedException {
super(swf, ID, "DefineSprite", data, pos);
public DefineSpriteTag(SWF swf, byte[] headerData, byte[] data, int level, long pos, boolean parallel, boolean skipUnusualTags) throws IOException, InterruptedException {
super(swf, ID, "DefineSprite", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version, pos);
spriteId = sis.readUI16();
frameCount = sis.readUI16();
subTags = sis.readTagList(swf, this, level + 1, parallel, skipUnusualTags, true, swf.gfx);
List<Tag> subTags = sis.readTagList(swf, this, level + 1, parallel, skipUnusualTags, true, swf.gfx);
if (subTags.get(subTags.size() - 1).getId() == EndTag.ID) {
hasEndTag = true;
subTags.remove(subTags.size() - 1);
}
this.subTags = subTags;
}
static int c = 0;
@@ -226,7 +233,9 @@ public class DefineSpriteTag extends CharacterTag implements Container, Drawable
try {
sos.writeUI16(spriteId);
sos.writeUI16(frameCount);
sos.writeTags(subTags);
if (hasEndTag) {
sos.writeTags(subTags);
}
sos.writeUI16(0);
sos.close();
} catch (IOException e) {
@@ -456,12 +456,13 @@ public class DefineText2Tag extends TextTag {
* Constructor
*
* @param swf
* @param headerData
* @param data Data bytes
* @param pos
* @throws IOException
*/
public DefineText2Tag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineText2", data, pos);
public DefineText2Tag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineText2", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
characterID = sis.readUI16();
textBounds = sis.readRECT();
@@ -421,7 +421,7 @@ public class DefineTextTag extends TextTag {
}
public DefineTextTag(SWF swf, int characterID, RECT textBounds, MATRIX textMatrix, List<TEXTRECORD> textRecords) {
super(swf, ID, "DefineText", null, 0);
super(swf, ID, "DefineText", null, null, 0);
this.characterID = characterID;
this.textBounds = textBounds;
this.textMatrix = textMatrix;
@@ -467,12 +467,13 @@ public class DefineTextTag extends TextTag {
* Constructor
*
* @param swf
* @param headerData
* @param data Data bytes
* @param pos
* @throws IOException
*/
public DefineTextTag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineText", data, pos);
public DefineTextTag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineText", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
characterID = sis.readUI16();
textBounds = sis.readRECT();
@@ -100,12 +100,13 @@ public class DefineVideoStreamTag extends CharacterTag implements BoundedTag {
* Constructor
*
* @param swf
* @param headerData
* @param data Data bytes
* @param pos
* @throws IOException
*/
public DefineVideoStreamTag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineVideoStream", data, pos);
public DefineVideoStreamTag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "DefineVideoStream", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
characterID = sis.readUI16();
numFrames = sis.readUI16();
@@ -68,12 +68,13 @@ public class DoABCDefineTag extends Tag implements ABCContainerTag {
* Constructor
*
* @param swf
* @param headerData
* @param data Data bytes
* @param pos
* @throws IOException
*/
public DoABCDefineTag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "DoABCDefine", data, pos);
public DoABCDefineTag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "DoABCDefine", headerData, data, pos);
InputStream is = new ByteArrayInputStream(data);
SWFInputStream sis = new SWFInputStream(is, swf.version);
flags = sis.readUI32();
@@ -54,12 +54,13 @@ public class DoABCTag extends Tag implements ABCContainerTag {
* Constructor
*
* @param swf
* @param headerData
* @param data Data bytes
* @param pos
* @throws IOException
*/
public DoABCTag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "DoABC", data, pos);
public DoABCTag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "DoABC", headerData, data, pos);
InputStream is = new ByteArrayInputStream(data);
abc = new ABC(is, swf, this);
}
@@ -18,7 +18,6 @@ package com.jpexs.decompiler.flash.tags;
import com.jpexs.decompiler.flash.DisassemblyListener;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.ActionListReader;
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
@@ -51,11 +50,12 @@ public class DoActionTag extends Tag implements ASMSource {
* Constructor
*
* @param swf
* @param headerData
* @param data Data bytes
* @param pos
*/
public DoActionTag(SWF swf, byte[] data, long pos) {
super(swf, ID, "DoAction", data, pos);
public DoActionTag(SWF swf, byte[] headerData, byte[] data, long pos) {
super(swf, ID, "DoAction", headerData, data, pos);
actionBytes = data;
}
@@ -114,7 +114,7 @@ public class DoActionTag extends Tag implements ASMSource {
byte[] prevData = previousTag.getData();
baos.write(prevData);
prevLength = prevData.length;
byte[] header = SWFOutputStream.getTagHeader(this, data, getVersion());
byte[] header = getHeader(data);
baos.write(header);
prevLength += header.length;
}
@@ -58,12 +58,13 @@ public class DoInitActionTag extends CharacterIdTag implements ASMSource {
* Constructor
*
* @param swf
* @param headerData
* @param data Data bytes
* @param pos
* @throws IOException
*/
public DoInitActionTag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "DoInitAction", data, pos);
public DoInitActionTag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "DoInitAction", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
spriteId = sis.readUI16();
//actions = sis.readActionList();
@@ -127,7 +128,7 @@ public class DoInitActionTag extends CharacterIdTag implements ASMSource {
baos.write(0);
baos.write(0);
prevLength += 2;
byte[] header = SWFOutputStream.getTagHeader(this, data, getVersion());
byte[] header = getHeader(data);
baos.write(header);
prevLength += header.length;
}
@@ -66,12 +66,13 @@ public class EnableDebugger2Tag extends Tag {
* Constructor
*
* @param swf
* @param headerData
* @param data Data bytes
* @param pos
* @throws IOException
*/
public EnableDebugger2Tag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "EnableDebugger2", data, pos);
public EnableDebugger2Tag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "EnableDebugger2", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
reserved = sis.readUI16();
passwordHash = sis.readString();
@@ -60,12 +60,13 @@ public class EnableDebuggerTag extends Tag {
* Constructor
*
* @param swf
* @param headerData
* @param data Data bytes
* @param pos
* @throws IOException
*/
public EnableDebuggerTag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "EnableDebugger", data, pos);
public EnableDebuggerTag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "EnableDebugger", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
passwordHash = sis.readString();
}
@@ -69,12 +69,13 @@ public class EnableTelemetryTag extends Tag {
* Constructor
*
* @param swf
* @param headerData
* @param data Data bytes
* @param pos
* @throws IOException
*/
public EnableTelemetryTag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "", data, pos);
public EnableTelemetryTag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
reserved = (int) sis.readUB(16);
if (sis.available() > 0) {
@@ -41,16 +41,17 @@ public class EndTag extends Tag {
* Constructor
*
* @param swf
* @param headerData
* @param data Data bytes
* @param pos
* @throws IOException
*/
public EndTag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "End", data, pos);
public EndTag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "End", headerData, data, pos);
}
public EndTag(SWF swf) {
super(swf, ID, "End", new byte[0], 0);
super(swf, ID, "End", new byte[0], new byte[0], 0);
}
}
@@ -48,7 +48,7 @@ public class ExportAssetsTag extends Tag {
public static final int ID = 56;
public ExportAssetsTag() {
super(null, ID, "ExportAssets", new byte[]{}, 0);
super(null, ID, "ExportAssets", new byte[0], new byte[0], 0);
tags = new ArrayList<>();
names = new ArrayList<>();
}
@@ -57,12 +57,13 @@ public class ExportAssetsTag extends Tag {
* Constructor
*
* @param swf
* @param headerData
* @param data Data bytes
* @param pos
* @throws IOException
*/
public ExportAssetsTag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "ExportAssets", data, pos);
public ExportAssetsTag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "ExportAssets", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
int count = sis.readUI16();
tags = new ArrayList<>();
@@ -46,11 +46,11 @@ public class FileAttributesTag extends Tag {
public static final int ID = 69;
public FileAttributesTag() {
super(null, ID, "FileAttributes", new byte[]{}, 0);
super(null, ID, "FileAttributes", new byte[0], new byte[0], 0);
}
public FileAttributesTag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "FileAttributes", data, pos);
public FileAttributesTag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "FileAttributes", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
reserved1 = sis.readUB(1) == 1; // reserved
// UB[1] == 0 (reserved)
@@ -38,8 +38,8 @@ public class FrameLabelTag extends Tag {
return namedAnchor;
}
public FrameLabelTag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "FrameLabel", data, pos);
public FrameLabelTag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "FrameLabel", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
name = sis.readString();
if (sis.available() > 0) {
@@ -61,12 +61,13 @@ public class ImportAssets2Tag extends Tag implements ImportTag {
* Constructor
*
* @param swf
* @param headerData
* @param data Data bytes
* @param pos
* @throws IOException
*/
public ImportAssets2Tag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "ImportAssets2", data, pos);
public ImportAssets2Tag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "ImportAssets2", headerData, data, pos);
tags = new ArrayList<>();
names = new ArrayList<>();
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
@@ -54,12 +54,13 @@ public class ImportAssetsTag extends Tag implements ImportTag {
* Constructor
*
* @param swf
* @param headerData
* @param data Data bytes
* @param pos
* @throws IOException
*/
public ImportAssetsTag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "ImportAssets", data, pos);
public ImportAssetsTag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "ImportAssets", headerData, data, pos);
tags = new ArrayList<>();
names = new ArrayList<>();
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
@@ -23,7 +23,6 @@ public class JPEGTablesTag extends Tag {
public static final int ID = 8;
public JPEGTablesTag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "JPEGTables", data, pos); //data is JPEG data
}
public JPEGTablesTag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "JPEGTables", headerData, data, pos); }
}
@@ -31,8 +31,8 @@ public class MetadataTag extends Tag {
public String xmlMetadata;
public static final int ID = 77;
public MetadataTag(SWF swf, byte[] data, long pos) {
super(swf, ID, "Metadata", data, pos);
public MetadataTag(SWF swf, byte[] headerData, byte[] data, long pos) {
super(swf, ID, "Metadata", headerData, data, pos);
try {
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
xmlMetadata = sis.readString();
@@ -195,7 +195,7 @@ public class PlaceObject2Tag extends CharacterIdTag implements Container, PlaceO
}
public PlaceObject2Tag(SWF swf, boolean placeFlagHasClipActions, boolean placeFlagHasClipDepth, boolean placeFlagHasName, boolean placeFlagHasRatio, boolean placeFlagHasColorTransform, boolean placeFlagHasMatrix, boolean placeFlagHasCharacter, boolean placeFlagMove, int depth, int characterId, MATRIX matrix, CXFORMWITHALPHA colorTransform, int ratio, String name, int clipDepth, CLIPACTIONS clipActions) {
super(swf, ID, "PlaceObject2", null, 0);
super(swf, ID, "PlaceObject2", null, null, 0);
this.placeFlagHasClipActions = placeFlagHasClipActions;
this.placeFlagHasClipDepth = placeFlagHasClipDepth;
this.placeFlagHasName = placeFlagHasName;
@@ -218,12 +218,13 @@ public class PlaceObject2Tag extends CharacterIdTag implements Container, PlaceO
* Constructor
*
* @param swf
* @param headerData
* @param data Data bytes
* @param pos
* @throws IOException
*/
public PlaceObject2Tag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "PlaceObject2", data, pos);
public PlaceObject2Tag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "PlaceObject2", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
placeFlagHasClipActions = sis.readUB(1) == 1;
placeFlagHasClipDepth = sis.readUB(1) == 1;
@@ -302,12 +302,13 @@ public class PlaceObject3Tag extends CharacterIdTag implements Container, PlaceO
* Constructor
*
* @param swf
* @param headerData
* @param data Data bytes
* @param pos
* @throws IOException
*/
public PlaceObject3Tag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "PlaceObject3", data, pos);
public PlaceObject3Tag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "PlaceObject3", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
placeFlagHasClipActions = sis.readUB(1) == 1;
placeFlagHasClipDepth = sis.readUB(1) == 1;
@@ -304,12 +304,13 @@ public class PlaceObject4Tag extends CharacterIdTag implements Container, PlaceO
* Constructor
*
* @param swf
* @param headerData
* @param data Data bytes
* @param pos
* @throws IOException
*/
public PlaceObject4Tag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "PlaceObject4", data, pos);
public PlaceObject4Tag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "PlaceObject4", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
placeFlagHasClipActions = sis.readUB(1) == 1;
placeFlagHasClipDepth = sis.readUB(1) == 1;
@@ -102,12 +102,13 @@ public class PlaceObjectTag extends CharacterIdTag implements PlaceObjectTypeTag
* Constructor
*
* @param swf
* @param headerData
* @param data Data bytes
* @param pos
* @throws IOException
*/
public PlaceObjectTag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "PlaceObject", data, pos);
public PlaceObjectTag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "PlaceObject", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
characterId = sis.readUI16();
depth = sis.readUI16();
@@ -118,7 +119,7 @@ public class PlaceObjectTag extends CharacterIdTag implements PlaceObjectTypeTag
}
public PlaceObjectTag(SWF swf, int characterId, int depth, MATRIX matrix, CXFORM colorTransform) {
super(swf, ID, "PlaceObject", null, 0);
super(swf, ID, "PlaceObject", null, null, 0);
this.characterId = characterId;
this.depth = depth;
this.matrix = matrix;
@@ -46,8 +46,8 @@ public class ProductInfoTag extends Tag {
public long compilationDateHigh;
public static final int ID = 41;
public ProductInfoTag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "ProductInfo", data, pos);
public ProductInfoTag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "ProductInfo", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
/*
* 0: Unknown
@@ -60,12 +60,13 @@ public class ProtectTag extends Tag {
* Constructor
*
* @param swf
* @param headerData
* @param data Data bytes
* @param pos
* @throws IOException
*/
public ProtectTag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "Protect", data, pos);
public ProtectTag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "Protect", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
if (sis.available() > 0) {
passwordHash = sis.readString();
@@ -30,8 +30,8 @@ public class RemoveObject2Tag extends Tag implements RemoveTag {
public int depth;
public static final int ID = 28;
public RemoveObject2Tag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "RemoveObject2", data, pos);
public RemoveObject2Tag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "RemoveObject2", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
depth = sis.readUI16();
}
@@ -69,12 +69,13 @@ public class RemoveObjectTag extends CharacterIdTag implements RemoveTag {
* Constructor
*
* @param swf
* @param headerData
* @param data Data bytes
* @param pos
* @throws IOException
*/
public RemoveObjectTag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "RemoveObject", data, pos);
public RemoveObjectTag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "RemoveObject", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
characterId = sis.readUI16();
depth = sis.readUI16();
@@ -36,8 +36,8 @@ public class ScriptLimitsTag extends Tag {
public static final int ID = 65;
public ScriptLimitsTag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "ScriptLimits", data, pos);
public ScriptLimitsTag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "ScriptLimits", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
maxRecursionDepth = sis.readUI16();
scriptTimeoutSeconds = sis.readUI16();
@@ -29,14 +29,14 @@ public class SetBackgroundColorTag extends Tag {
public RGB backgroundColor;
public static final int ID = 9;
public SetBackgroundColorTag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "SetBackgroundColor", data, pos);
public SetBackgroundColorTag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "SetBackgroundColor", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
backgroundColor = sis.readRGB();
}
public SetBackgroundColorTag(SWF swf, RGB backgroundColor) {
super(swf, ID, "SetBackgroundColor", null, 0);
super(swf, ID, "SetBackgroundColor", null, null, 0);
this.backgroundColor = backgroundColor;
}
@@ -67,12 +67,13 @@ public class SetTabIndexTag extends Tag {
* Constructor
*
* @param swf
* @param headerData
* @param data Data bytes
* @param pos
* @throws IOException
*/
public SetTabIndexTag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "SetTabIndex", data, pos);
public SetTabIndexTag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "SetTabIndex", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
depth = sis.readUI16();
tabIndex = sis.readUI16();
@@ -52,14 +52,16 @@ public class ShowFrameTag extends Tag {
* Constructor
*
* @param swf
* @param headerData
* @param pos
* @param data
*/
public ShowFrameTag(SWF swf, long pos) {
super(swf, ID, "ShowFrame", new byte[0], pos);
public ShowFrameTag(SWF swf, byte[] headerData, byte[] data, long pos) {
super(swf, ID, "ShowFrame", headerData, data, pos);
}
public ShowFrameTag(SWF swf) {
super(swf, ID, "ShowFrame", null, 0);
super(swf, ID, "ShowFrame", null, null, 0);
}
public static boolean isNestedTagType(int tagTypeId) {
@@ -32,11 +32,11 @@ public class SoundStreamBlockTag extends Tag {
* Constructor
*
* @param swf
* @param headerData
* @param data Data bytes
* @param pos
* @throws IOException
*/
public SoundStreamBlockTag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "SoundStreamBlock", data, pos); //all data is streamSoundData
}
public SoundStreamBlockTag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "SoundStreamBlock", headerData, data, pos); }
}
@@ -139,12 +139,13 @@ public class SoundStreamHead2Tag extends CharacterIdTag implements SoundStreamHe
* Constructor
*
* @param swf
* @param headerData
* @param data Data bytes
* @param pos
* @throws IOException
*/
public SoundStreamHead2Tag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "SoundStreamHead2", data, pos);
public SoundStreamHead2Tag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "SoundStreamHead2", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
reserved = (int) sis.readUB(4);
playBackSoundRate = (int) sis.readUB(2);
@@ -132,12 +132,13 @@ public class SoundStreamHeadTag extends CharacterIdTag implements SoundStreamHea
* Constructor
*
* @param swf
* @param headerData
* @param data Data bytes
* @param pos
* @throws IOException
*/
public SoundStreamHeadTag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "SoundStreamHead", data, pos);
public SoundStreamHeadTag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "SoundStreamHead", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
reserved = (int) sis.readUB(4);
playBackSoundRate = (int) sis.readUB(2);
@@ -57,12 +57,13 @@ public class StartSound2Tag extends Tag {
* Constructor
*
* @param swf
* @param headerData
* @param data Data bytes
* @param pos
* @throws IOException
*/
public StartSound2Tag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "StartSound2", data, pos);
public StartSound2Tag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "StartSound2", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
soundClassName = sis.readString();
soundInfo = sis.readSOUNDINFO();
@@ -61,12 +61,13 @@ public class StartSoundTag extends Tag {
* Constructor
*
* @param swf
* @param headerData
* @param data Data bytes
* @param pos
* @throws IOException
*/
public StartSoundTag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "StartSound", data, pos);
public StartSoundTag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "StartSound", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
soundId = sis.readUI16();
soundInfo = sis.readSOUNDINFO();
@@ -36,8 +36,8 @@ public class SymbolClassTag extends Tag {
public String[] names;
public static final int ID = 76;
public SymbolClassTag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "SymbolClass", data, pos);
public SymbolClassTag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "SymbolClass", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
int numSymbols = sis.readUI16();
tags = new int[numSymbols];
@@ -17,6 +17,7 @@
package com.jpexs.decompiler.flash.tags;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.tags.base.CharacterTag;
import com.jpexs.decompiler.flash.tags.base.ContainerItem;
import com.jpexs.decompiler.flash.tags.base.Exportable;
@@ -33,6 +34,8 @@ import com.jpexs.decompiler.flash.tags.gfx.ExporterInfoTag;
import com.jpexs.decompiler.flash.tags.gfx.FontTextureInfo;
import com.jpexs.decompiler.flash.timeline.Timelined;
import com.jpexs.decompiler.flash.types.annotations.Internal;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.Serializable;
import java.util.Arrays;
import java.util.HashSet;
@@ -49,6 +52,10 @@ public class Tag implements NeedsCharacters, Exportable, ContainerItem, Serializ
* Identifier of tag type
*/
protected int id;
/**
* Original header data in the tag
*/
protected byte[] headerData;
/**
* Data in the tag
*/
@@ -116,12 +123,14 @@ public class Tag implements NeedsCharacters, Exportable, ContainerItem, Serializ
* @param swf
* @param id Tag type identifier
* @param name Tag name
* @param headerData
* @param data Bytes of data
* @param pos
*/
public Tag(SWF swf, int id, String name, byte[] data, long pos) {
public Tag(SWF swf, int id, String name, byte[] headerData, byte[] data, long pos) {
this.id = id;
this.tagName = name;
this.headerData = headerData;
this.data = data;
this.pos = pos;
this.swf = swf;
@@ -293,6 +302,15 @@ public class Tag implements NeedsCharacters, Exportable, ContainerItem, Serializ
return swf.version;
}
/**
* Gets original read header data
*
* @return Bytes of data
*/
public byte[] getOriginalHeaderData() {
return headerData;
}
/**
* Gets original read data
*
@@ -302,15 +320,62 @@ public class Tag implements NeedsCharacters, Exportable, ContainerItem, Serializ
return data;
}
public void setOriginalData(byte[] data) {
this.data = data;
public void createOriginalData() {
data = getData();
headerData = getHeader(data);
}
public byte[] getDataOrOriginalData() {
if (isModified()) {
return getData();
protected byte[] getHeader(byte[] data) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
SWFOutputStream sos = new SWFOutputStream(baos, swf.version);
int tagLength = data.length;
int tagID = getId();
int tagIDLength = (tagID << 6);
if ((tagLength <= 62) && (!forceWriteAsLong)) {
tagIDLength += tagLength;
sos.writeUI16(tagIDLength);
} else {
tagIDLength += 0x3f;
sos.writeUI16(tagIDLength);
sos.writeSI32(tagLength);
}
} catch (IOException iex) {
}
return data;
return baos.toByteArray();
}
public static byte[] getTagHeader(int tagIDTagLength, long tagLength, boolean writeLong, int version) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
SWFOutputStream sos = new SWFOutputStream(baos, version);
sos.writeUI16(tagIDTagLength);
if (writeLong) {
sos.writeSI32(tagLength);
}
} catch (IOException iex) {
}
return baos.toByteArray();
}
/**
* Writes Tag value to the stream
*
* @param sos SWF output stream
* @throws IOException
*/
public void writeTag(SWFOutputStream sos) throws IOException {
if (isModified()) {
byte[] newData = getData();
sos.write(getHeader(newData));
sos.write(newData);
return;
}
sos.write(headerData);
sos.write(data);
}
/**
@@ -54,12 +54,13 @@ public class TagStub extends Tag {
* Constructor
*
* @param swf
* @param headerData
* @param data Data bytes
* @param pos
* @throws IOException
*/
public TagStub(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "" /*TODO:Insert name here*/, data, pos);
public TagStub(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "" /*TODO:Insert name here*/, headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
}
@@ -24,7 +24,7 @@ import com.jpexs.decompiler.flash.SWF;
*/
public class UnknownTag extends Tag {
public UnknownTag(SWF swf, int id, byte[] data, long pos) {
super(swf, id, "Unknown", data, pos);
public UnknownTag(SWF swf, int id, byte[] headerData, byte[] data, long pos) {
super(swf, id, "Unknown", headerData, data, pos);
}
}
@@ -63,12 +63,13 @@ public class VideoFrameTag extends Tag {
* Constructor
*
* @param swf
* @param headerData
* @param data Data bytes
* @param pos
* @throws IOException
*/
public VideoFrameTag(SWF swf, byte[] data, long pos) throws IOException {
super(swf, ID, "VideoFrame", data, pos);
public VideoFrameTag(SWF swf, byte[] headerData, byte[] data, long pos) throws IOException {
super(swf, ID, "VideoFrame", headerData, data, pos);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version);
streamID = sis.readUI16();
frameNum = sis.readUI16();
@@ -39,8 +39,8 @@ public abstract class ButtonTag extends CharacterTag implements DrawableTag, Tim
public static int FRAME_DOWN = 2;
public static int FRAME_HITTEST = 3;
public ButtonTag(SWF swf, int id, String name, byte[] data, long pos) {
super(swf, id, name, data, pos);
public ButtonTag(SWF swf, int id, String name, byte[] headerData, byte[] data, long pos) {
super(swf, id, name, headerData, data, pos);
}
public abstract List<BUTTONRECORD> getRecords();
@@ -29,8 +29,8 @@ import java.util.List;
*/
public abstract class CharacterIdTag extends Tag {
public CharacterIdTag(SWF swf, int id, String name, byte[] data, long pos) {
super(swf, id, name, data, pos);
public CharacterIdTag(SWF swf, int id, String name, byte[] headerData, byte[] data, long pos) {
super(swf, id, name, headerData, data, pos);
}
public abstract int getCharacterId();
@@ -66,7 +66,7 @@ public abstract class CharacterIdTag extends Tag {
if (getCharacterId() != -1) {
return super.getName() + " (" + getCharacterId() + nameAppend + ")";
}
if (!nameAppend.equals("")) {
if (!nameAppend.isEmpty()) {
return super.getName() + " (" + nameAppend + ")";
}
return super.getName();

Some files were not shown because too many files have changed in this diff Show More