added missing getData functions

This commit is contained in:
honfika
2014-07-28 21:03:14 +02:00
parent 1089b741e8
commit 68dcce0a5f
13 changed files with 197 additions and 11 deletions
@@ -48,6 +48,7 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
@@ -662,10 +663,14 @@ public class GenericTagTreePanel extends GenericTagPanel {
this.tag = tag;
SWF swf = tag.getSwf();
try {
if (tag instanceof TagStub) {
this.editedTag = SWFInputStream.resolveTag((TagStub)tag, 0, false, true, swf.gfx);
}
byte[] data = tag.getData();
SWFInputStream tagDataStream = new SWFInputStream(swf, data, 0, data.length);
TagStub copy = new TagStub(swf, tag.getId(), "Unresolved", tag.getOriginalRange(), tagDataStream);
copy.forceWriteAsLong = tag.forceWriteAsLong;
this.editedTag = SWFInputStream.resolveTag(copy, 0, false, true, swf.gfx);
} catch (InterruptedException ex) {
} catch (IOException ex) {
Logger.getLogger(GenericTagTreePanel.class.getName()).log(Level.SEVERE, null, ex);
}
tree.setEditable(edit);
if (!edit) {
@@ -17,10 +17,13 @@
package com.jpexs.decompiler.flash.tags;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
public class DefineFontNameTag extends Tag {
@@ -36,4 +39,23 @@ public class DefineFontNameTag extends Tag {
fontName = sis.readString("fontName");
fontCopyright = sis.readString("fontCopyright");
}
/**
* Gets data bytes
*
* @return Bytes of data
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(fontId);
sos.writeString(fontName);
sos.writeString(fontCopyright);
} catch (IOException e) {
}
return baos.toByteArray();
}
}
@@ -17,6 +17,7 @@
package com.jpexs.decompiler.flash.tags;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.tags.base.BoundedTag;
import com.jpexs.decompiler.flash.tags.base.ShapeTag;
import com.jpexs.decompiler.flash.types.BasicType;
@@ -24,7 +25,9 @@ import com.jpexs.decompiler.flash.types.RECT;
import com.jpexs.decompiler.flash.types.SHAPEWITHSTYLE;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Set;
public class DefineShape2Tag extends ShapeTag {
@@ -76,6 +79,25 @@ public class DefineShape2Tag extends ShapeTag {
shapes = sis.readSHAPEWITHSTYLE(2, false, "shapes");
}
/**
* Gets data bytes
*
* @return Bytes of data
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(shapeId);
sos.writeRECT(shapeBounds);
sos.writeSHAPEWITHSTYLE(shapes, 2);
} catch (IOException e) {
}
return baos.toByteArray();
}
@Override
public int getNumFrames() {
return 1;
@@ -17,6 +17,7 @@
package com.jpexs.decompiler.flash.tags;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.tags.base.BoundedTag;
import com.jpexs.decompiler.flash.tags.base.ShapeTag;
import com.jpexs.decompiler.flash.types.BasicType;
@@ -24,7 +25,9 @@ import com.jpexs.decompiler.flash.types.RECT;
import com.jpexs.decompiler.flash.types.SHAPEWITHSTYLE;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Set;
public class DefineShape3Tag extends ShapeTag {
@@ -76,6 +79,25 @@ public class DefineShape3Tag extends ShapeTag {
shapes = sis.readSHAPEWITHSTYLE(3, false, "shapes");
}
/**
* Gets data bytes
*
* @return Bytes of data
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(shapeId);
sos.writeRECT(shapeBounds);
sos.writeSHAPEWITHSTYLE(shapes, 3);
} catch (IOException e) {
}
return baos.toByteArray();
}
@Override
public int getNumFrames() {
return 1;
@@ -17,6 +17,7 @@
package com.jpexs.decompiler.flash.tags;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.tags.base.BoundedTag;
import com.jpexs.decompiler.flash.tags.base.ShapeTag;
import com.jpexs.decompiler.flash.types.BasicType;
@@ -25,7 +26,9 @@ import com.jpexs.decompiler.flash.types.SHAPEWITHSTYLE;
import com.jpexs.decompiler.flash.types.annotations.Reserved;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Set;
public class DefineShape4Tag extends ShapeTag {
@@ -89,6 +92,30 @@ public class DefineShape4Tag extends ShapeTag {
shapes = sis.readSHAPEWITHSTYLE(4, false, "shapes");
}
/**
* Gets data bytes
*
* @return Bytes of data
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(shapeId);
sos.writeRECT(shapeBounds);
sos.writeRECT(edgeBounds);
sos.writeUB(5, reserved);
sos.writeUB(1, usesFillWindingRule ? 1 : 0);
sos.writeUB(5, usesNonScalingStrokes ? 1 : 0);
sos.writeUB(5, usesScalingStrokes ? 1 : 0);
sos.writeSHAPEWITHSTYLE(shapes, 4);
} catch (IOException e) {
}
return baos.toByteArray();
}
@Override
public int getNumFrames() {
return 1;
@@ -36,6 +36,7 @@ public class EndTag extends Tag {
public byte[] getData() {
return new byte[0];
}
public static final int ID = 0;
/**
@@ -17,9 +17,12 @@
package com.jpexs.decompiler.flash.tags;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.types.annotations.Internal;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
public class JPEGTablesTag extends Tag {
@@ -31,4 +34,21 @@ public class JPEGTablesTag extends Tag {
super(sis.getSwf(), ID, "JPEGTables", data);
jpegData = sis.readBytesEx(sis.available(), "jpegData");
}
/**
* Gets data bytes
*
* @return Bytes of data
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.write(jpegData);
} catch (IOException e) {
}
return baos.toByteArray();
}
}
@@ -17,11 +17,14 @@
package com.jpexs.decompiler.flash.tags;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.tags.base.RemoveTag;
import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
public class RemoveObject2Tag extends Tag implements RemoveTag {
@@ -34,6 +37,23 @@ public class RemoveObject2Tag extends Tag implements RemoveTag {
depth = sis.readUI16("depth");
}
/**
* Gets data bytes
*
* @return Bytes of data
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(depth);
} catch (IOException e) {
}
return baos.toByteArray();
}
@Override
public int getDepth() {
return depth;
@@ -62,6 +62,16 @@ public class ShowFrameTag extends Tag {
super(swf, ID, "ShowFrame", null);
}
/**
* Gets data bytes
*
* @return Bytes of data
*/
@Override
public byte[] getData() {
return new byte[0];
}
public static boolean isNestedTagType(int tagTypeId) {
return nestedTagTypeIds.contains(tagTypeId);
}
@@ -17,9 +17,12 @@
package com.jpexs.decompiler.flash.tags;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.types.annotations.Internal;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/**
*
@@ -45,4 +48,21 @@ public class SoundStreamBlockTag extends Tag {
//all data is streamSoundData
streamSoundData = sis.readBytesEx(sis.available(), "streamSoundData");
}
/**
* Gets data bytes
*
* @return Bytes of data
*/
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.write(streamSoundData);
} catch (IOException e) {
}
return baos.toByteArray();
}
}
+5 -7
View File
@@ -131,8 +131,8 @@ public abstract class Tag implements NeedsCharacters, Exportable, ContainerItem,
}
private static final Object lockObject = new Object();
private static List<Integer> knownTagIds;
private static List<Integer> requiredTagIds;
private volatile static List<Integer> knownTagIds;
private volatile static List<Integer> requiredTagIds;
public static List<Integer> getKnownTags() {
if (knownTagIds == null) {
@@ -349,10 +349,8 @@ public abstract class Tag implements NeedsCharacters, Exportable, ContainerItem,
*
* @return Bytes of data
*/
public byte[] getData() {
return getOriginalData().getRangeData();
}
public abstract byte[] getData();
public final ByteArrayRange getOriginalRange() {
return originalRange;
}
@@ -375,7 +373,7 @@ public abstract class Tag implements NeedsCharacters, Exportable, ContainerItem,
return originalRange.length - (isLongOriginal() ? 6 : 2);
}
private final boolean isLongOriginal() {
private boolean isLongOriginal() {
int shortLength = originalRange.array[(int) originalRange.pos] & 0x003F;
return shortLength == 0x3f;
}
@@ -43,6 +43,16 @@ public class TagStub extends Tag {
dataStream = sis;
}
/**
* Gets data bytes
*
* @return Bytes of data
*/
@Override
public byte[] getData() {
return getOriginalData().getRangeData();
}
public SWFInputStream getDataStream() {
return dataStream;
}
@@ -29,9 +29,18 @@ public class UnknownTag extends Tag {
super(swf, id, "Unknown", data);
}
/**
* Gets data bytes
*
* @return Bytes of data
*/
@Override
public byte[] getData() {
return getOriginalRange().getRangeData();
}
@Override
public String toString() {
return super.toString() + " (ID=" + id + ")";
}
}