mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-05 18:34:45 +00:00
Added: #2333 Changing Shape tag type (DefineShape, DefineShape2, ...)
This commit is contained in:
@@ -28,6 +28,7 @@ import java.io.IOException;
|
||||
|
||||
/**
|
||||
* DefineShape2 tag - defines shape. Extends functionality of DefineShape.
|
||||
* Adds more than 255 styles in style list, multiple style lists.
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
|
||||
@@ -28,7 +28,7 @@ import java.io.IOException;
|
||||
|
||||
/**
|
||||
* DefineShape3 tag - defines shape. Extends functionality of DefineShape2.
|
||||
*
|
||||
* Adds transparency in colors.
|
||||
* @author JPEXS
|
||||
*/
|
||||
@SWFVersion(from = 3)
|
||||
|
||||
@@ -32,7 +32,9 @@ import java.io.IOException;
|
||||
|
||||
/**
|
||||
* DefineShape4 tag - defines shape. Extends functionality of DefineShape3.
|
||||
*
|
||||
* Adds LINESTYLE2 (joins, caps, scaling), filling stroke, edge bounds,
|
||||
* focal gradient, spread mode, interpolation mode, numgradients > 8.
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
@SWFVersion(from = 8)
|
||||
@@ -115,6 +117,10 @@ public class DefineShape4Tag extends ShapeTag {
|
||||
@Override
|
||||
public void updateBounds() {
|
||||
super.updateBounds();
|
||||
updateEdgeBounds();
|
||||
}
|
||||
|
||||
public void updateEdgeBounds() {
|
||||
edgeBounds = SHAPERECORD.getBounds(shapes.shapeRecords, null, 4, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,180 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2024 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.tags.converters;
|
||||
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.tags.DefineShape2Tag;
|
||||
import com.jpexs.decompiler.flash.tags.DefineShape3Tag;
|
||||
import com.jpexs.decompiler.flash.tags.DefineShape4Tag;
|
||||
import com.jpexs.decompiler.flash.tags.DefineShapeTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.CharacterTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.ShapeTag;
|
||||
import com.jpexs.decompiler.flash.types.shaperecords.SHAPERECORD;
|
||||
import com.jpexs.decompiler.flash.types.shaperecords.StyleChangeRecord;
|
||||
import com.jpexs.helpers.Helper;
|
||||
|
||||
/**
|
||||
* Converts shape number (DefineShape, DefineShape2, ...)
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class ShapeTypeConverter {
|
||||
|
||||
/**
|
||||
* Get minimum DefineShape number, which can be converted to including loosing information.
|
||||
* @param shapeTag Shape tag
|
||||
* @return DefineShape number
|
||||
*/
|
||||
public int getForcedMinShapeNum(ShapeTag shapeTag) {
|
||||
if (shapeTag.getShapeNum() > 1) {
|
||||
if (shapeTag.shapes.fillStyles.fillStyles.length > 255) {
|
||||
return 2;
|
||||
}
|
||||
if (shapeTag.shapes.lineStyles.lineStyles != null && shapeTag.shapes.lineStyles.lineStyles.length > 255) {
|
||||
return 2;
|
||||
}
|
||||
if (shapeTag.shapes.lineStyles.lineStyles2 != null && shapeTag.shapes.lineStyles.lineStyles2.length > 255) {
|
||||
return 2;
|
||||
}
|
||||
for (SHAPERECORD rec : shapeTag.shapes.shapeRecords) {
|
||||
if (rec instanceof StyleChangeRecord) {
|
||||
StyleChangeRecord scr = (StyleChangeRecord) rec;
|
||||
if (scr.stateNewStyles) {
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get minimum DefineShape number, which can be shape converted to without loosing information.
|
||||
* @param shapeTag Shape tag
|
||||
* @return DefineShape number
|
||||
*/
|
||||
public int getMinShapeNum(ShapeTag shapeTag) {
|
||||
int result = shapeTag.shapes.getMinShapeNum(shapeTag.getShapeNum());
|
||||
if (shapeTag.getShapeNum() == 4) {
|
||||
DefineShape4Tag shape4 = (DefineShape4Tag) shapeTag;
|
||||
if (shape4.usesFillWindingRule) {
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts shape tag referenced by character id in selected SWF file.
|
||||
* @param swf SWF
|
||||
* @param characterId Character id
|
||||
* @param targetShapeNum Target shape num
|
||||
*/
|
||||
public void convertCharacter(SWF swf, int characterId, int targetShapeNum) {
|
||||
CharacterTag ct = swf.getCharacter(characterId);
|
||||
if (!(ct instanceof ShapeTag)) {
|
||||
throw new IllegalArgumentException("Character " + characterId + " is not a shape");
|
||||
}
|
||||
ShapeTag sh = (ShapeTag) ct;
|
||||
if (targetShapeNum == sh.getShapeNum()) {
|
||||
return;
|
||||
}
|
||||
ShapeTag converted = convertTagType(sh, swf, targetShapeNum);
|
||||
converted.setCharacterId(characterId);
|
||||
swf.replaceTag(ct, converted);
|
||||
converted.setTimelined(swf);
|
||||
swf.updateCharacters();
|
||||
swf.clearShapeCache();
|
||||
swf.assignClassesToSymbols();
|
||||
swf.assignExportNamesToSymbols();
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts DefineShape tag type
|
||||
* @param sourceShapeTag Source tag
|
||||
* @param targetSWF Target swf
|
||||
* @param targetShapeNum Target DefineShape number
|
||||
* @return Converted DefineShapeX tag
|
||||
* @throws IllegalArgumentException When conversion is not possible - see getForcedMinShapeNum
|
||||
*/
|
||||
public ShapeTag convertTagType(ShapeTag sourceShapeTag, SWF targetSWF, int targetShapeNum) {
|
||||
int sourceShapeNum = sourceShapeTag.getShapeNum();
|
||||
ShapeTag result;
|
||||
switch (targetShapeNum) {
|
||||
case 1:
|
||||
result = new DefineShapeTag(targetSWF);
|
||||
break;
|
||||
case 2:
|
||||
result = new DefineShape2Tag(targetSWF);
|
||||
break;
|
||||
case 3:
|
||||
result = new DefineShape3Tag(targetSWF);
|
||||
break;
|
||||
case 4:
|
||||
result = new DefineShape4Tag(targetSWF);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Target shape num must be 1-4. Provided: " + targetShapeNum);
|
||||
}
|
||||
result.shapeBounds = Helper.deepCopy(sourceShapeTag.shapeBounds);
|
||||
result.shapes = Helper.deepCopy(sourceShapeTag.shapes);
|
||||
|
||||
if (sourceShapeNum > 1 && targetShapeNum == 1) {
|
||||
if (result.shapes.fillStyles.fillStyles.length > 255) {
|
||||
throw new IllegalArgumentException("DefineShape1 does not allow more than 255 fill styles");
|
||||
}
|
||||
if (result.shapes.lineStyles.lineStyles != null && result.shapes.lineStyles.lineStyles.length > 255) {
|
||||
throw new IllegalArgumentException("DefineShape1 does not allow more than 255 line styles");
|
||||
}
|
||||
if (result.shapes.lineStyles.lineStyles2 != null && result.shapes.lineStyles.lineStyles2.length > 255) {
|
||||
throw new IllegalArgumentException("DefineShape1 does not allow more than 255 line styles");
|
||||
}
|
||||
for (SHAPERECORD rec : result.shapes.shapeRecords) {
|
||||
if (rec instanceof StyleChangeRecord) {
|
||||
StyleChangeRecord scr = (StyleChangeRecord) rec;
|
||||
if (scr.stateNewStyles) {
|
||||
throw new IllegalArgumentException("DefineShape1 does not allow multiple style lists");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
result.shapes.lineStyles = result.shapes.lineStyles.toShapeNum(sourceShapeNum, targetShapeNum);
|
||||
result.shapes.fillStyles = result.shapes.fillStyles.toShapeNum(targetShapeNum);
|
||||
for (SHAPERECORD rec : result.shapes.shapeRecords) {
|
||||
if (rec instanceof StyleChangeRecord) {
|
||||
StyleChangeRecord scr = (StyleChangeRecord) rec;
|
||||
if (scr.stateNewStyles) {
|
||||
scr.fillStyles = scr.fillStyles.toShapeNum(targetShapeNum);
|
||||
scr.lineStyles = scr.lineStyles.toShapeNum(sourceShapeNum, targetShapeNum);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (targetShapeNum == 4) {
|
||||
DefineShape4Tag result4 = (DefineShape4Tag) result;
|
||||
if (sourceShapeNum == 4) {
|
||||
DefineShape4Tag source4 = (DefineShape4Tag) sourceShapeTag;
|
||||
result4.edgeBounds = Helper.deepCopy(source4.edgeBounds);
|
||||
result4.usesFillWindingRule = source4.usesFillWindingRule;
|
||||
result4.usesNonScalingStrokes = source4.usesNonScalingStrokes;
|
||||
result4.usesScalingStrokes = source4.usesScalingStrokes;
|
||||
} else {
|
||||
result4.updateEdgeBounds();
|
||||
result4.usesScalingStrokes = true;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,7 @@ import com.jpexs.decompiler.flash.types.annotations.EnumValue;
|
||||
import com.jpexs.decompiler.flash.types.annotations.Internal;
|
||||
import com.jpexs.decompiler.flash.types.annotations.SWFType;
|
||||
import com.jpexs.decompiler.flash.types.annotations.SWFVersion;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Objects;
|
||||
@@ -366,4 +367,46 @@ public class FILLSTYLE implements NeedsCharacters, FieldChangeObserver, Serializ
|
||||
return Objects.equals(this.bitmapMatrix, other.bitmapMatrix);
|
||||
}
|
||||
|
||||
public FILLSTYLE toShapeNum(int targetShapeNum) {
|
||||
FILLSTYLE result = Helper.deepCopy(this);
|
||||
if (fillStyleType == SOLID) {
|
||||
if (targetShapeNum < 3) {
|
||||
result.color = new RGB(color);
|
||||
} else {
|
||||
result.color = new RGBA(color);
|
||||
}
|
||||
}
|
||||
if (fillStyleType == LINEAR_GRADIENT
|
||||
|| fillStyleType == RADIAL_GRADIENT
|
||||
|| fillStyleType == FOCAL_RADIAL_GRADIENT
|
||||
) {
|
||||
result.gradient = result.gradient.toShapeNum(targetShapeNum);
|
||||
}
|
||||
if (fillStyleType == FOCAL_RADIAL_GRADIENT && targetShapeNum < 4) {
|
||||
result.fillStyleType = RADIAL_GRADIENT;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public int getMinShapeNum() {
|
||||
int shapeNum = 1;
|
||||
if (fillStyleType == SOLID) {
|
||||
if (color instanceof RGBA) {
|
||||
RGBA colorA = (RGBA) color;
|
||||
if (colorA.alpha != 255) {
|
||||
shapeNum = 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (fillStyleType == LINEAR_GRADIENT || fillStyleType == RADIAL_GRADIENT) {
|
||||
int gradShapeNum = gradient.getMinShapeNum();
|
||||
if (gradShapeNum > shapeNum) {
|
||||
shapeNum = gradShapeNum;
|
||||
}
|
||||
}
|
||||
if (fillStyleType == FOCAL_RADIAL_GRADIENT) {
|
||||
shapeNum = 4;
|
||||
}
|
||||
return shapeNum;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,26 @@ public class FILLSTYLEARRAY implements NeedsCharacters, Serializable {
|
||||
@SWFArray(value = "fillStyle")
|
||||
public FILLSTYLE[] fillStyles;
|
||||
|
||||
public int getMinShapeNum() {
|
||||
int result = 1;
|
||||
for (FILLSTYLE fs : fillStyles) {
|
||||
int sn = fs.getMinShapeNum();
|
||||
if (sn > result) {
|
||||
result = sn;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public FILLSTYLEARRAY toShapeNum(int targetShapeNum) {
|
||||
FILLSTYLEARRAY result = new FILLSTYLEARRAY();
|
||||
result.fillStyles = new FILLSTYLE[fillStyles.length];
|
||||
for (int i = 0; i < fillStyles.length; i++) {
|
||||
result.fillStyles[i] = fillStyles[i].toShapeNum(targetShapeNum);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getNeededCharacters(Set<Integer> needed, SWF swf) {
|
||||
for (FILLSTYLE fs : fillStyles) {
|
||||
|
||||
@@ -17,7 +17,9 @@
|
||||
package com.jpexs.decompiler.flash.types;
|
||||
|
||||
import com.jpexs.decompiler.flash.types.annotations.SWFType;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Focal gradient. Gradient with focal point. Used in radial gradients.
|
||||
@@ -81,4 +83,18 @@ public class FOCALGRADIENT extends GRADIENT implements Serializable {
|
||||
}
|
||||
return morphGradient;
|
||||
}
|
||||
|
||||
public GRADIENT toShapeNum(int shapeNum) {
|
||||
if (shapeNum < 4) {
|
||||
GRADIENT result = new GRADIENT();
|
||||
result.gradientRecords = Helper.deepCopy(gradientRecords);
|
||||
result.spreadMode = 0;
|
||||
result.interpolationMode = 0;
|
||||
if (result.gradientRecords.length > 8) {
|
||||
result.gradientRecords = Arrays.copyOfRange(result.gradientRecords, 0, 8);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return Helper.deepCopy(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.types;
|
||||
import com.jpexs.decompiler.flash.types.annotations.EnumValue;
|
||||
import com.jpexs.decompiler.flash.types.annotations.SWFArray;
|
||||
import com.jpexs.decompiler.flash.types.annotations.SWFType;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -182,5 +183,37 @@ public class GRADIENT implements Serializable {
|
||||
}
|
||||
return Arrays.deepEquals(this.gradientRecords, other.gradientRecords);
|
||||
}
|
||||
|
||||
public GRADIENT toShapeNum(int shapeNum) {
|
||||
GRADIENT result = Helper.deepCopy(this);
|
||||
if (shapeNum < 4) {
|
||||
result.spreadMode = 0;
|
||||
result.interpolationMode = 0;
|
||||
if (gradientRecords.length > 8) {
|
||||
result.gradientRecords = Arrays.copyOfRange(result.gradientRecords, 0, 8);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public int getMinShapeNum() {
|
||||
if (gradientRecords.length > 8) {
|
||||
return 4;
|
||||
}
|
||||
if (spreadMode > 0) {
|
||||
return 4;
|
||||
}
|
||||
if (interpolationMode > 0) {
|
||||
return 4;
|
||||
}
|
||||
for (GRADRECORD rec : gradientRecords) {
|
||||
if (rec.color instanceof RGBA) {
|
||||
RGBA col = (RGBA) rec.color;
|
||||
if (col.alpha != 255) {
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,5 +122,21 @@ public class LINESTYLE implements NeedsCharacters, Serializable, ILINESTYLE {
|
||||
}
|
||||
return Objects.equals(this.color, other.color);
|
||||
}
|
||||
|
||||
public LINESTYLE2 toLineStyle2() {
|
||||
LINESTYLE2 result = new LINESTYLE2();
|
||||
result.color = new RGBA(color);
|
||||
result.width = width;
|
||||
return result;
|
||||
}
|
||||
|
||||
public int getMinShapeNum() {
|
||||
if (color instanceof RGBA) {
|
||||
RGBA acolor = (RGBA) color;
|
||||
if (acolor.alpha != 255) {
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.jpexs.decompiler.flash.types.annotations.Conditional;
|
||||
import com.jpexs.decompiler.flash.types.annotations.EnumValue;
|
||||
import com.jpexs.decompiler.flash.types.annotations.Reserved;
|
||||
import com.jpexs.decompiler.flash.types.annotations.SWFType;
|
||||
import java.awt.Color;
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
@@ -377,5 +378,48 @@ public class LINESTYLE2 implements NeedsCharacters, Serializable, ILINESTYLE {
|
||||
}
|
||||
return Objects.equals(this.fillType, other.fillType);
|
||||
}
|
||||
|
||||
public LINESTYLE toLineStyle1(int shapeNum) {
|
||||
LINESTYLE result = new LINESTYLE();
|
||||
if (hasFillFlag) {
|
||||
result.color = shapeNum >= 3 ? new RGBA(Color.black) : new RGB(Color.black);
|
||||
} else {
|
||||
result.color = color;
|
||||
}
|
||||
result.width = width;
|
||||
return result;
|
||||
}
|
||||
|
||||
public int getMinShapeNum() {
|
||||
int shapeNum = 1;
|
||||
if (hasFillFlag) {
|
||||
return 4;
|
||||
}
|
||||
if (startCapStyle != ROUND_CAP) {
|
||||
return 4;
|
||||
}
|
||||
if (endCapStyle != ROUND_CAP) {
|
||||
return 4;
|
||||
}
|
||||
if (joinStyle != ROUND_JOIN) {
|
||||
return 4;
|
||||
}
|
||||
if (noClose) {
|
||||
return 4;
|
||||
}
|
||||
if (noHScaleFlag) {
|
||||
return 4;
|
||||
}
|
||||
if (noVScaleFlag) {
|
||||
return 4;
|
||||
}
|
||||
if (pixelHintingFlag) {
|
||||
return 4;
|
||||
}
|
||||
if (color.alpha != 255) {
|
||||
return 3;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.jpexs.decompiler.flash.tags.DefineShapeTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.NeedsCharacters;
|
||||
import com.jpexs.decompiler.flash.types.annotations.Conditional;
|
||||
import com.jpexs.decompiler.flash.types.annotations.SWFArray;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import java.io.Serializable;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -48,6 +49,58 @@ public class LINESTYLEARRAY implements NeedsCharacters, Serializable {
|
||||
@Conditional(tags = {DefineShape4Tag.ID})
|
||||
public LINESTYLE2[] lineStyles2 = new LINESTYLE2[0];
|
||||
|
||||
public int getMinShapeNum(int sourceShapeNum) {
|
||||
int result = 1;
|
||||
if (sourceShapeNum >= 4) {
|
||||
for (LINESTYLE2 ls : lineStyles2) {
|
||||
int sn = ls.getMinShapeNum();
|
||||
if (sn > result) {
|
||||
result = sn;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (LINESTYLE ls : lineStyles) {
|
||||
int sn = ls.getMinShapeNum();
|
||||
if (sn > result) {
|
||||
result = sn;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public LINESTYLEARRAY toShapeNum(int sourceShapeNum, int targetShapeNum) {
|
||||
if (sourceShapeNum == targetShapeNum) {
|
||||
return Helper.deepCopy(this);
|
||||
}
|
||||
LINESTYLEARRAY result = new LINESTYLEARRAY();
|
||||
if (targetShapeNum >= 4) {
|
||||
result.lineStyles2 = new LINESTYLE2[lineStyles.length];
|
||||
for (int i = 0; i < lineStyles.length; i++) {
|
||||
result.lineStyles2[i] = lineStyles[i].toLineStyle2();
|
||||
}
|
||||
} else {
|
||||
result.lineStyles = new LINESTYLE[sourceShapeNum >=4 ? lineStyles2.length : lineStyles.length];
|
||||
if (sourceShapeNum >= 4) {
|
||||
for (int i = 0; i < lineStyles2.length; i++) {
|
||||
result.lineStyles[i] = lineStyles2[i].toLineStyle1(targetShapeNum);
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < lineStyles.length; i++) {
|
||||
LINESTYLE ls = new LINESTYLE();
|
||||
if (targetShapeNum < 3) {
|
||||
ls.color = new RGB(lineStyles[i].color);
|
||||
} else {
|
||||
ls.color = new RGBA(lineStyles[i].color);
|
||||
}
|
||||
ls.width = lineStyles[i].width;
|
||||
result.lineStyles[i] = ls;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getNeededCharacters(Set<Integer> needed, SWF swf) {
|
||||
if (lineStyles != null) {
|
||||
|
||||
@@ -57,8 +57,8 @@ public class SHAPE implements NeedsCharacters, Serializable {
|
||||
@SWFArray(value = "record")
|
||||
public List<SHAPERECORD> shapeRecords;
|
||||
|
||||
private Shape cachedOutline;
|
||||
private Shape fastCachedOutline;
|
||||
private transient Shape cachedOutline;
|
||||
private transient Shape fastCachedOutline;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
|
||||
@@ -249,4 +249,46 @@ public class SHAPEWITHSTYLE extends SHAPE implements NeedsCharacters, Serializab
|
||||
}
|
||||
}
|
||||
|
||||
public int getMinShapeNum(int sourceShapeNum) {
|
||||
int result = 1;
|
||||
int sn;
|
||||
|
||||
if (fillStyles.fillStyles.length > 255) {
|
||||
result = 2;
|
||||
}
|
||||
if (sourceShapeNum >= 4 && lineStyles.lineStyles2.length > 255) {
|
||||
result = 2;
|
||||
}
|
||||
if (sourceShapeNum < 4 && lineStyles.lineStyles.length > 255) {
|
||||
result = 2;
|
||||
}
|
||||
|
||||
sn = fillStyles.getMinShapeNum();
|
||||
if (sn > result) {
|
||||
result = sn;
|
||||
}
|
||||
sn = lineStyles.getMinShapeNum(sourceShapeNum);
|
||||
if (sn > result) {
|
||||
result = sn;
|
||||
}
|
||||
for (SHAPERECORD sr : shapeRecords) {
|
||||
if (sr instanceof StyleChangeRecord) {
|
||||
StyleChangeRecord scr = (StyleChangeRecord) sr;
|
||||
if (scr.stateNewStyles) {
|
||||
if (2 > result) {
|
||||
result = 2;
|
||||
}
|
||||
sn = scr.fillStyles.getMinShapeNum();
|
||||
if (sn > result) {
|
||||
result = sn;
|
||||
}
|
||||
sn = scr.lineStyles.getMinShapeNum(sourceShapeNum);
|
||||
if (sn > result) {
|
||||
result = sn;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user