@Override
public byte[] getData(){
byte[] rawdata = getRawData();
- int prefixLen = 16*uidInstanceCount+1;
+ int prefixLen = 16*getUIDInstanceCount()+1;
byte[] imgdata = new byte[rawdata.length-prefixLen];
System.arraycopy(rawdata, prefixLen, imgdata, 0, imgdata.length);
return imgdata;
@Override
public void setData(byte[] data) throws IOException {
+ byte[] checksum = getChecksum(data);
ByteArrayOutputStream out = new ByteArrayOutputStream();
- for (int i=0; i<uidInstanceCount; i++) {
- byte[] checksum = getChecksum(data);
+ out.write(checksum);
+ if (getUIDInstanceCount() == 2) {
out.write(checksum);
}
out.write(0);
* @return DIB signature ({@code 0x7A80} or {@code 0x7A90})
*/
public int getSignature(){
- return (uidInstanceCount == 1 ? 0x7A80 : 0x7A90);
+ return (getUIDInstanceCount() == 1 ? 0x7A80 : 0x7A90);
}
/**
public void setSignature(int signature) {
switch (signature) {
case 0x7A80:
- uidInstanceCount = 1;
+ setUIDInstanceCount(1);
break;
case 0x7A90:
- uidInstanceCount = 2;
+ setUIDInstanceCount(2);
break;
default:
throw new IllegalArgumentException(signature+" is not a valid instance/signature value for DIB");
byte[] checksum = getChecksum(data);
ByteArrayOutputStream out = new ByteArrayOutputStream();
out.write(checksum);
- if (uidInstanceCount == 2) {
+ if (getUIDInstanceCount() == 2) {
out.write(checksum);
}
header.write(out);
* @return EMF signature ({@code 0x3D40} or {@code 0x3D50})
*/
public int getSignature(){
- return (uidInstanceCount == 1 ? 0x3D40 : 0x3D50);
+ return (getUIDInstanceCount() == 1 ? 0x3D40 : 0x3D50);
}
/**
public void setSignature(int signature) {
switch (signature) {
case 0x3D40:
- uidInstanceCount = 1;
+ setUIDInstanceCount(1);
break;
case 0x3D50:
- uidInstanceCount = 2;
+ setUIDInstanceCount(2);
break;
default:
throw new IllegalArgumentException(signature+" is not a valid instance/signature value for EMF");
*/
public int getSignature(){
return (colorSpace == ColorSpace.rgb)
- ? (uidInstanceCount == 1 ? 0x46A0 : 0x46B0)
- : (uidInstanceCount == 1 ? 0x6E20 : 0x6E30);
+ ? (getUIDInstanceCount() == 1 ? 0x46A0 : 0x46B0)
+ : (getUIDInstanceCount() == 1 ? 0x6E20 : 0x6E30);
}
/**
public void setSignature(int signature) {
switch (signature) {
case 0x46A0:
- uidInstanceCount = 1;
+ setUIDInstanceCount(1);
colorSpace = ColorSpace.rgb;
break;
case 0x46B0:
- uidInstanceCount = 2;
+ setUIDInstanceCount(2);
colorSpace = ColorSpace.rgb;
break;
case 0x6E20:
- uidInstanceCount = 1;
+ setUIDInstanceCount(1);
colorSpace = ColorSpace.cymk;
break;
case 0x6E30:
- uidInstanceCount = 2;
+ setUIDInstanceCount(2);
colorSpace = ColorSpace.cymk;
break;
default:
@Override
public Dimension getImageDimension() {
- int prefixLen = 16*uidInstanceCount;
+ int prefixLen = 16*getUIDInstanceCount();
Header header = new Header();
header.read(getRawData(), prefixLen);
return new Dimension(
byte[] macheader = new byte[512];
ByteArrayOutputStream out = new ByteArrayOutputStream();
out.write(macheader);
- int pos = CHECKSUM_SIZE*uidInstanceCount;
+ int pos = CHECKSUM_SIZE*getUIDInstanceCount();
byte[] pict = read(rawdata, pos);
out.write(pict);
return out.toByteArray();
byte[] checksum = getChecksum(data);
ByteArrayOutputStream out = new ByteArrayOutputStream();
out.write(checksum);
- if (uidInstanceCount == 2) {
+ if (getUIDInstanceCount() == 2) {
out.write(checksum);
}
header.write(out);
* @return PICT signature ({@code 0x5420} or {@code 0x5430})
*/
public int getSignature(){
- return (uidInstanceCount == 1 ? 0x5420 : 0x5430);
+ return (getUIDInstanceCount() == 1 ? 0x5420 : 0x5430);
}
/**
public void setSignature(int signature) {
switch (signature) {
case 0x5420:
- uidInstanceCount = 1;
+ setUIDInstanceCount(1);
break;
case 0x5430:
- uidInstanceCount = 2;
+ setUIDInstanceCount(2);
break;
default:
throw new IllegalArgumentException(signature+" is not a valid instance/signature value for PICT");
* @return PNG signature ({@code 0x6E00} or {@code 0x6E10})
*/
public int getSignature(){
- return (uidInstanceCount == 1 ? 0x6E00 : 0x6E10);
+ return (getUIDInstanceCount() == 1 ? 0x6E00 : 0x6E10);
}
/**
public void setSignature(int signature) {
switch (signature) {
case 0x6E00:
- uidInstanceCount = 1;
+ setUIDInstanceCount(1);
break;
case 0x6E10:
- uidInstanceCount = 2;
+ setUIDInstanceCount(2);
break;
default:
throw new IllegalArgumentException(signature+" is not a valid instance/signature value for PNG");
ByteArrayOutputStream out = new ByteArrayOutputStream();
InputStream is = new ByteArrayInputStream( rawdata );
Header header = new Header();
- header.read(rawdata, CHECKSUM_SIZE*uidInstanceCount);
- long len = is.skip(header.getSize() + CHECKSUM_SIZE*uidInstanceCount);
- assert(len == header.getSize() + CHECKSUM_SIZE*uidInstanceCount);
+ header.read(rawdata, CHECKSUM_SIZE*getUIDInstanceCount());
+ long len = is.skip(header.getSize() + CHECKSUM_SIZE*getUIDInstanceCount());
+ assert(len == header.getSize() + CHECKSUM_SIZE*getUIDInstanceCount());
ImageHeaderWMF aldus = new ImageHeaderWMF(header.getBounds());
aldus.write(out);
byte[] checksum = getChecksum(data);
ByteArrayOutputStream out = new ByteArrayOutputStream();
- for (int i=0; i<uidInstanceCount; i++) {
+ out.write(checksum);
+ if (getUIDInstanceCount() == 2) {
out.write(checksum);
}
header.write(out);
* WMF signature is either {@code 0x2160} or {@code 0x2170}
*/
public int getSignature(){
- return (uidInstanceCount == 1 ? 0x2160 : 0x2170);
+ return (getUIDInstanceCount() == 1 ? 0x2160 : 0x2170);
}
/**
public void setSignature(int signature) {
switch (signature) {
case 0x2160:
- uidInstanceCount = 1;
+ setUIDInstanceCount(1);
break;
case 0x2170:
- uidInstanceCount = 2;
+ setUIDInstanceCount(2);
break;
default:
throw new IllegalArgumentException(signature+" is not a valid instance/signature value for WMF");
* Represents functionality provided by the 'Fill Effects' dialog in PowerPoint.
*/
public final class HSLFFill {
- // For logging
- protected POILogger logger = POILogFactory.getLogger(this.getClass());
+ private static final POILogger LOG = POILogFactory.getLogger(HSLFFill.class);
/**
* Fill with a solid color
/**
* The shape this background applies to
*/
- protected HSLFShape shape;
+ private HSLFShape shape;
/**
* Construct a <code>Fill</code> object for a shape.
case FILL_PICTURE:
return getTexturePaint();
default:
- logger.log(POILogger.WARN, "unsuported fill type: " + fillType);
+ LOG.log(POILogger.WARN, "unsuported fill type: " + fillType);
return null;
}
}
protected EscherBSERecord getEscherBSERecord(int idx){
HSLFSheet sheet = shape.getSheet();
if(sheet == null) {
- logger.log(POILogger.DEBUG, "Fill has not yet been assigned to a sheet");
+ LOG.log(POILogger.DEBUG, "Fill has not yet been assigned to a sheet");
return null;
}
HSLFSlideShow ppt = sheet.getSlideShow();
EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer();
EscherContainerRecord bstore = HSLFShape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER);
if(bstore == null) {
- logger.log(POILogger.DEBUG, "EscherContainerRecord.BSTORE_CONTAINER was not found ");
+ LOG.log(POILogger.DEBUG, "EscherContainerRecord.BSTORE_CONTAINER was not found ");
return null;
}
List<EscherRecord> lst = bstore.getChildRecords();
java.util.List<EscherRecord> lst = bstore.getChildRecords();
int idx = p.getPropertyValue();
if (idx == 0){
- logger.log(POILogger.WARN, "no reference to picture data found ");
+ LOG.log(POILogger.WARN, "no reference to picture data found ");
} else {
EscherBSERecord bse = (EscherBSERecord)lst.get(idx - 1);
for (HSLFPictureData pd : pict) {
enum PathInfo {
lineTo(0),curveTo(1),moveTo(2),close(3),end(4),escape(5),clientEscape(6);
- int flag;
+ private final int flag;
PathInfo(int flag) {
this.flag = flag;
}
+ public int getFlag() {
+ return flag;
+ }
static PathInfo valueOf(int flag) {
for (PathInfo v : values()) {
if (v.flag == flag) {
FILL_COLOR(0X0015),
LINE_COLOR(0X0016);
- int flag;
+ private final int flag;
EscapeInfo(int flag) {
this.flag = flag;
}
+ public int getFlag() {
+ return flag;
+ }
static EscapeInfo valueOf(int flag) {
for (EscapeInfo v : values()) {
if (v.flag == flag) {
CURVES_CLOSED(3),
COMPLEX(4);
- int flag;
+ private final int flag;
ShapePath(int flag) {
this.flag = flag;
}
+ public int getFlag() {
+ return flag;
+ }
static ShapePath valueOf(int flag) {
for (ShapePath v : values()) {
if (v.flag == flag) {
/**
* A class that represents image data contained in a slide show.
- *
- * @author Yegor Kozlov
*/
public abstract class HSLFPictureData implements PictureData {
/**
* The offset to the picture in the stream
*/
- protected int offset;
+ private int offset;
/**
* The instance type/signatures defines if one or two UID instances will be included
*/
- protected int uidInstanceCount = 1;
+ private int uidInstanceCount = 1;
/**
* The 1-based index within the pictures stream
*/
- protected int index = -1;
+ private int index = -1;
/**
* Blip signature.
return uidInstanceCount;
}
+ /**
+ * The instance type/signatures defines if one or two UID instances will be included
+ *
+ * @param uidInstanceCount the number of uid sequences
+ */
+ protected void setUIDInstanceCount(int uidInstanceCount) {
+ this.uidInstanceCount = uidInstanceCount;
+ }
+
/**
* Returns the raw binary data of this Picture excluding the first 8 bytes
* which hold image signature and size of the image data.