SonarCube fix - make members private
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1772585 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f5d9984c49
commit
75dc015766
@ -31,7 +31,7 @@ import org.apache.poi.util.LittleEndian;
|
|||||||
*/
|
*/
|
||||||
public abstract class AbstractEscherOptRecord extends EscherRecord
|
public abstract class AbstractEscherOptRecord extends EscherRecord
|
||||||
{
|
{
|
||||||
protected List<EscherProperty> properties = new ArrayList<EscherProperty>();
|
private List<EscherProperty> properties = new ArrayList<EscherProperty>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a property to this record.
|
* Add a property to this record.
|
||||||
|
@ -63,59 +63,47 @@ public final class EscherArrayProperty extends EscherComplexProperty implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getNumberOfElementsInArray() {
|
public int getNumberOfElementsInArray() {
|
||||||
return (emptyComplexPart) ? 0 : LittleEndian.getUShort(_complexData, 0);
|
return (emptyComplexPart) ? 0 : LittleEndian.getUShort(getComplexData(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNumberOfElementsInArray(int numberOfElements) {
|
public void setNumberOfElementsInArray(int numberOfElements) {
|
||||||
int expectedArraySize = numberOfElements * getActualSizeOfElements(getSizeOfElements()) + FIXED_SIZE;
|
int expectedArraySize = getArraySizeInBytes(numberOfElements, getSizeOfElements());
|
||||||
if (expectedArraySize != _complexData.length) {
|
resizeComplexData(expectedArraySize, getComplexData().length);
|
||||||
byte[] newArray = new byte[expectedArraySize];
|
LittleEndian.putShort(getComplexData(), 0, (short)numberOfElements);
|
||||||
System.arraycopy(_complexData, 0, newArray, 0, _complexData.length);
|
|
||||||
_complexData = newArray;
|
|
||||||
}
|
|
||||||
LittleEndian.putShort(_complexData, 0, (short) numberOfElements);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getNumberOfElementsInMemory() {
|
public int getNumberOfElementsInMemory() {
|
||||||
return (emptyComplexPart) ? 0 : LittleEndian.getUShort(_complexData, 2);
|
return (emptyComplexPart) ? 0 : LittleEndian.getUShort(getComplexData(), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNumberOfElementsInMemory(int numberOfElements) {
|
public void setNumberOfElementsInMemory(int numberOfElements) {
|
||||||
int expectedArraySize = numberOfElements * getActualSizeOfElements(getSizeOfElements()) + FIXED_SIZE;
|
int expectedArraySize = getArraySizeInBytes(numberOfElements, getSizeOfElements());
|
||||||
if (expectedArraySize != _complexData.length) {
|
resizeComplexData(expectedArraySize, expectedArraySize);
|
||||||
byte[] newArray = new byte[expectedArraySize];
|
LittleEndian.putShort(getComplexData(), 2, (short) numberOfElements);
|
||||||
System.arraycopy(_complexData, 0, newArray, 0, expectedArraySize);
|
|
||||||
_complexData = newArray;
|
|
||||||
}
|
|
||||||
LittleEndian.putShort(_complexData, 2, (short) numberOfElements);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public short getSizeOfElements() {
|
public short getSizeOfElements() {
|
||||||
return (emptyComplexPart) ? 0 : LittleEndian.getShort( _complexData, 4 );
|
return (emptyComplexPart) ? 0 : LittleEndian.getShort( getComplexData(), 4 );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSizeOfElements(int sizeOfElements) {
|
public void setSizeOfElements(int sizeOfElements) {
|
||||||
LittleEndian.putShort( _complexData, 4, (short) sizeOfElements );
|
LittleEndian.putShort( getComplexData(), 4, (short) sizeOfElements );
|
||||||
|
|
||||||
int expectedArraySize = getNumberOfElementsInArray() * getActualSizeOfElements(getSizeOfElements()) + FIXED_SIZE;
|
int expectedArraySize = getArraySizeInBytes(getNumberOfElementsInArray(), sizeOfElements);
|
||||||
if (expectedArraySize != _complexData.length) {
|
// Keep just the first 6 bytes. The rest is no good to us anyway.
|
||||||
// Keep just the first 6 bytes. The rest is no good to us anyway.
|
resizeComplexData(expectedArraySize, 6);
|
||||||
byte[] newArray = new byte[expectedArraySize];
|
|
||||||
System.arraycopy( _complexData, 0, newArray, 0, 6 );
|
|
||||||
_complexData = newArray;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] getElement(int index) {
|
public byte[] getElement(int index) {
|
||||||
int actualSize = getActualSizeOfElements(getSizeOfElements());
|
int actualSize = getActualSizeOfElements(getSizeOfElements());
|
||||||
byte[] result = new byte[actualSize];
|
byte[] result = new byte[actualSize];
|
||||||
System.arraycopy(_complexData, FIXED_SIZE + index * actualSize, result, 0, result.length );
|
System.arraycopy(getComplexData(), FIXED_SIZE + index * actualSize, result, 0, result.length );
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setElement(int index, byte[] element) {
|
public void setElement(int index, byte[] element) {
|
||||||
int actualSize = getActualSizeOfElements(getSizeOfElements());
|
int actualSize = getActualSizeOfElements(getSizeOfElements());
|
||||||
System.arraycopy( element, 0, _complexData, FIXED_SIZE + index * actualSize, actualSize);
|
System.arraycopy( element, 0, getComplexData(), FIXED_SIZE + index * actualSize, actualSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -152,7 +140,7 @@ public final class EscherArrayProperty extends EscherComplexProperty implements
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* We have this method because the way in which arrays in escher works
|
* We have this method because the way in which arrays in escher works
|
||||||
* is screwed for seemly arbitary reasons. While most properties are
|
* is screwed for seemly arbitrary reasons. While most properties are
|
||||||
* fairly consistent and have a predictable array size, escher arrays
|
* fairly consistent and have a predictable array size, escher arrays
|
||||||
* have special cases.
|
* have special cases.
|
||||||
*
|
*
|
||||||
@ -162,21 +150,25 @@ public final class EscherArrayProperty extends EscherComplexProperty implements
|
|||||||
*/
|
*/
|
||||||
public int setArrayData(byte[] data, int offset) {
|
public int setArrayData(byte[] data, int offset) {
|
||||||
if (emptyComplexPart){
|
if (emptyComplexPart){
|
||||||
_complexData = new byte[0];
|
resizeComplexData(0, 0);
|
||||||
} else {
|
return 0;
|
||||||
short numElements = LittleEndian.getShort(data, offset);
|
|
||||||
// LittleEndian.getShort(data, offset + 2); // numReserved
|
|
||||||
short sizeOfElements = LittleEndian.getShort(data, offset + 4);
|
|
||||||
|
|
||||||
int arraySize = getActualSizeOfElements(sizeOfElements) * numElements;
|
|
||||||
if (arraySize == _complexData.length) {
|
|
||||||
// The stored data size in the simple block excludes the header size
|
|
||||||
_complexData = new byte[arraySize + 6];
|
|
||||||
sizeIncludesHeaderSize = false;
|
|
||||||
}
|
|
||||||
System.arraycopy(data, offset, _complexData, 0, _complexData.length );
|
|
||||||
}
|
}
|
||||||
return _complexData.length;
|
|
||||||
|
short numElements = LittleEndian.getShort(data, offset);
|
||||||
|
// LittleEndian.getShort(data, offset + 2); // numReserved
|
||||||
|
short sizeOfElements = LittleEndian.getShort(data, offset + 4);
|
||||||
|
|
||||||
|
// TODO: this part is strange - it doesn't make sense to compare
|
||||||
|
// the size of the existing data when setting a new data array ...
|
||||||
|
int arraySize = getArraySizeInBytes(numElements, sizeOfElements);
|
||||||
|
if (arraySize - FIXED_SIZE == getComplexData().length) {
|
||||||
|
// The stored data size in the simple block excludes the header size
|
||||||
|
sizeIncludesHeaderSize = false;
|
||||||
|
}
|
||||||
|
int cpySize = Math.min(arraySize, data.length-offset);
|
||||||
|
resizeComplexData(cpySize, 0);
|
||||||
|
System.arraycopy(data, offset, getComplexData(), 0, cpySize);
|
||||||
|
return cpySize;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -188,7 +180,7 @@ public final class EscherArrayProperty extends EscherComplexProperty implements
|
|||||||
@Override
|
@Override
|
||||||
public int serializeSimplePart(byte[] data, int pos) {
|
public int serializeSimplePart(byte[] data, int pos) {
|
||||||
LittleEndian.putShort(data, pos, getId());
|
LittleEndian.putShort(data, pos, getId());
|
||||||
int recordSize = _complexData.length;
|
int recordSize = getComplexData().length;
|
||||||
if(!sizeIncludesHeaderSize) {
|
if(!sizeIncludesHeaderSize) {
|
||||||
recordSize -= 6;
|
recordSize -= 6;
|
||||||
}
|
}
|
||||||
@ -207,10 +199,15 @@ public final class EscherArrayProperty extends EscherComplexProperty implements
|
|||||||
return sizeOfElements;
|
return sizeOfElements;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static int getArraySizeInBytes(int numberOfElements, int sizeOfElements) {
|
||||||
|
return numberOfElements * getActualSizeOfElements((short)(sizeOfElements & 0xFFFF)) + FIXED_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterator<byte[]> iterator() {
|
public Iterator<byte[]> iterator() {
|
||||||
return new Iterator<byte[]>(){
|
return new Iterator<byte[]>(){
|
||||||
int idx = 0;
|
private int idx = 0;
|
||||||
@Override
|
@Override
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
return (idx < getNumberOfElementsInArray());
|
return (idx < getNumberOfElementsInArray());
|
||||||
|
@ -38,8 +38,7 @@ public class EscherBitmapBlip extends EscherBlipRecord {
|
|||||||
System.arraycopy( data, pos, field_1_UID, 0, 16 ); pos += 16;
|
System.arraycopy( data, pos, field_1_UID, 0, 16 ); pos += 16;
|
||||||
field_2_marker = data[pos]; pos++;
|
field_2_marker = data[pos]; pos++;
|
||||||
|
|
||||||
field_pictureData = new byte[bytesAfterHeader - 17];
|
setPictureData(data, pos, bytesAfterHeader - 17);
|
||||||
System.arraycopy( data, pos, field_pictureData, 0, field_pictureData.length );
|
|
||||||
|
|
||||||
return bytesAfterHeader + HEADER_SIZE;
|
return bytesAfterHeader + HEADER_SIZE;
|
||||||
}
|
}
|
||||||
@ -55,15 +54,16 @@ public class EscherBitmapBlip extends EscherBlipRecord {
|
|||||||
|
|
||||||
System.arraycopy( field_1_UID, 0, data, pos, 16 );
|
System.arraycopy( field_1_UID, 0, data, pos, 16 );
|
||||||
data[pos + 16] = field_2_marker;
|
data[pos + 16] = field_2_marker;
|
||||||
System.arraycopy( field_pictureData, 0, data, pos + 17, field_pictureData.length );
|
byte pd[] = getPicturedata();
|
||||||
|
System.arraycopy( pd, 0, data, pos + 17, pd.length );
|
||||||
|
|
||||||
listener.afterRecordSerialize(offset + getRecordSize(), getRecordId(), getRecordSize(), this);
|
listener.afterRecordSerialize(offset + getRecordSize(), getRecordId(), getRecordSize(), this);
|
||||||
return HEADER_SIZE + 16 + 1 + field_pictureData.length;
|
return HEADER_SIZE + 16 + 1 + pd.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getRecordSize() {
|
public int getRecordSize() {
|
||||||
return 8 + 16 + 1 + field_pictureData.length;
|
return 8 + 16 + 1 + getPicturedata().length;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -113,7 +113,7 @@ public class EscherBitmapBlip extends EscherBlipRecord {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
String nl = System.getProperty( "line.separator" );
|
String nl = System.getProperty( "line.separator" );
|
||||||
|
|
||||||
String extraData = HexDump.dump(this.field_pictureData, 0, 0);
|
String extraData = HexDump.dump(getPicturedata(), 0, 0);
|
||||||
|
|
||||||
return getClass().getName() + ":" + nl +
|
return getClass().getName() + ":" + nl +
|
||||||
" RecordId: 0x" + HexDump.toHex( getRecordId() ) + nl +
|
" RecordId: 0x" + HexDump.toHex( getRecordId() ) + nl +
|
||||||
@ -126,7 +126,7 @@ public class EscherBitmapBlip extends EscherBlipRecord {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toXml(String tab) {
|
public String toXml(String tab) {
|
||||||
String extraData = HexDump.dump(this.field_pictureData, 0, 0);
|
String extraData = HexDump.dump(getPicturedata(), 0, 0);
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
builder.append(tab).append(formatXmlRecordHeader(getClass().getSimpleName(), HexDump.toHex(getRecordId()), HexDump.toHex(getVersion()), HexDump.toHex(getInstance())))
|
builder.append(tab).append(formatXmlRecordHeader(getClass().getSimpleName(), HexDump.toHex(getRecordId()), HexDump.toHex(getVersion()), HexDump.toHex(getInstance())))
|
||||||
.append(tab).append("\t").append("<UID>0x").append(HexDump.toHex(field_1_UID)).append("</UID>\n")
|
.append(tab).append("\t").append("<UID>0x").append(HexDump.toHex(field_1_UID)).append("</UID>\n")
|
||||||
|
@ -27,7 +27,7 @@ public class EscherBlipRecord extends EscherRecord {
|
|||||||
|
|
||||||
private static final int HEADER_SIZE = 8;
|
private static final int HEADER_SIZE = 8;
|
||||||
|
|
||||||
protected byte[] field_pictureData;
|
private byte[] field_pictureData;
|
||||||
|
|
||||||
public EscherBlipRecord() {
|
public EscherBlipRecord() {
|
||||||
}
|
}
|
||||||
@ -81,10 +81,22 @@ public class EscherBlipRecord extends EscherRecord {
|
|||||||
* @param pictureData the picture data
|
* @param pictureData the picture data
|
||||||
*/
|
*/
|
||||||
public void setPictureData(byte[] pictureData) {
|
public void setPictureData(byte[] pictureData) {
|
||||||
if (pictureData == null) {
|
setPictureData(pictureData, 0, (pictureData == null ? 0 : pictureData.length));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the picture data bytes
|
||||||
|
*
|
||||||
|
* @param pictureData the picture data
|
||||||
|
* @param offset the offset into the picture data
|
||||||
|
* @param length the amount of bytes to be used
|
||||||
|
*/
|
||||||
|
public void setPictureData(byte[] pictureData, int offset, int length) {
|
||||||
|
if (pictureData == null || offset < 0 || length < 0 || pictureData.length < offset+length) {
|
||||||
throw new IllegalArgumentException("picture data can't be null");
|
throw new IllegalArgumentException("picture data can't be null");
|
||||||
}
|
}
|
||||||
field_pictureData = pictureData.clone();
|
field_pictureData = new byte[length];
|
||||||
|
System.arraycopy(pictureData, offset, field_pictureData, 0, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -49,7 +49,7 @@ public class EscherBoolProperty
|
|||||||
*/
|
*/
|
||||||
public boolean isTrue()
|
public boolean isTrue()
|
||||||
{
|
{
|
||||||
return propertyValue != 0;
|
return getPropertyValue() != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -61,7 +61,7 @@ public class EscherBoolProperty
|
|||||||
*/
|
*/
|
||||||
public boolean isFalse()
|
public boolean isFalse()
|
||||||
{
|
{
|
||||||
return propertyValue == 0;
|
return !isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
// public String toString()
|
// public String toString()
|
||||||
|
@ -24,8 +24,9 @@ import org.apache.poi.util.LittleEndian;
|
|||||||
* An OfficeArtCOLORREF structure entry which also handles color extension opid data
|
* An OfficeArtCOLORREF structure entry which also handles color extension opid data
|
||||||
*/
|
*/
|
||||||
public class EscherColorRef {
|
public class EscherColorRef {
|
||||||
int opid = -1;
|
@SuppressWarnings("unused")
|
||||||
int colorRef = 0;
|
private int opid = -1;
|
||||||
|
private int colorRef = 0;
|
||||||
|
|
||||||
public enum SysIndexSource {
|
public enum SysIndexSource {
|
||||||
/** Use the fill color of the shape. */
|
/** Use the fill color of the shape. */
|
||||||
@ -45,7 +46,7 @@ public class EscherColorRef {
|
|||||||
/** If the shape contains a fill, use the fill color of the shape. Otherwise, use the line color. */
|
/** If the shape contains a fill, use the fill color of the shape. Otherwise, use the line color. */
|
||||||
FILL_OR_LINE_COLOR(0xF7)
|
FILL_OR_LINE_COLOR(0xF7)
|
||||||
;
|
;
|
||||||
int value;
|
private int value;
|
||||||
SysIndexSource(int value) { this.value = value; }
|
SysIndexSource(int value) { this.value = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,7 +103,7 @@ public class EscherColorRef {
|
|||||||
*/
|
*/
|
||||||
INVERT_HIGHBIT_AFTER(0x40)
|
INVERT_HIGHBIT_AFTER(0x40)
|
||||||
;
|
;
|
||||||
BitField mask;
|
private BitField mask;
|
||||||
SysIndexProcedure(int mask) {
|
SysIndexProcedure(int mask) {
|
||||||
this.mask = new BitField(mask);
|
this.mask = new BitField(mask);
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ import org.apache.poi.util.LittleEndian;
|
|||||||
*/
|
*/
|
||||||
public class EscherComplexProperty extends EscherProperty {
|
public class EscherComplexProperty extends EscherProperty {
|
||||||
// TODO - make private and final
|
// TODO - make private and final
|
||||||
protected byte[] _complexData;
|
private byte[] _complexData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a complex property using the property id and a byte array containing the complex
|
* Create a complex property using the property id and a byte array containing the complex
|
||||||
@ -95,6 +95,16 @@ public class EscherComplexProperty extends EscherProperty {
|
|||||||
return _complexData;
|
return _complexData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void resizeComplexData(int newSize, int bytesToKeep) {
|
||||||
|
if (newSize == _complexData.length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
byte[] newArray = new byte[newSize];
|
||||||
|
System.arraycopy(_complexData, 0, newArray, 0, Math.min(bytesToKeep, newSize));
|
||||||
|
_complexData = newArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine whether this property is equal to another property.
|
* Determine whether this property is equal to another property.
|
||||||
*
|
*
|
||||||
|
@ -87,9 +87,9 @@ public final class EscherMetafileBlip extends EscherBlipRecord {
|
|||||||
// 0 means DEFLATE compression
|
// 0 means DEFLATE compression
|
||||||
// 0xFE means no compression
|
// 0xFE means no compression
|
||||||
if (field_6_fCompression == 0) {
|
if (field_6_fCompression == 0) {
|
||||||
field_pictureData = inflatePictureData(raw_pictureData);
|
super.setPictureData(inflatePictureData(raw_pictureData));
|
||||||
} else {
|
} else {
|
||||||
field_pictureData = raw_pictureData;
|
super.setPictureData(raw_pictureData);
|
||||||
}
|
}
|
||||||
|
|
||||||
int remaining = bytesAfterHeader - pos + offset + HEADER_SIZE;
|
int remaining = bytesAfterHeader - pos + offset + HEADER_SIZE;
|
||||||
|
@ -32,7 +32,7 @@ public class EscherOptRecord extends AbstractEscherOptRecord
|
|||||||
@Override
|
@Override
|
||||||
public short getInstance()
|
public short getInstance()
|
||||||
{
|
{
|
||||||
setInstance( (short) properties.size() );
|
setInstance( (short) getEscherProperties().size() );
|
||||||
return super.getInstance();
|
return super.getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,11 +76,11 @@ public final class EscherPictBlip extends EscherBlipRecord {
|
|||||||
// 0xFE means no compression
|
// 0xFE means no compression
|
||||||
if (field_6_fCompression == 0)
|
if (field_6_fCompression == 0)
|
||||||
{
|
{
|
||||||
field_pictureData = inflatePictureData(raw_pictureData);
|
super.setPictureData(inflatePictureData(raw_pictureData));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
field_pictureData = raw_pictureData;
|
super.setPictureData(raw_pictureData);
|
||||||
}
|
}
|
||||||
|
|
||||||
return bytesAfterHeader + HEADER_SIZE;
|
return bytesAfterHeader + HEADER_SIZE;
|
||||||
@ -264,7 +264,7 @@ public final class EscherPictBlip extends EscherBlipRecord {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
String extraData = HexDump.toHex(field_pictureData, 32);
|
String extraData = HexDump.toHex(getPicturedata(), 32);
|
||||||
return getClass().getName() + ":" + '\n' +
|
return getClass().getName() + ":" + '\n' +
|
||||||
" RecordId: 0x" + HexDump.toHex( getRecordId() ) + '\n' +
|
" RecordId: 0x" + HexDump.toHex( getRecordId() ) + '\n' +
|
||||||
" Version: 0x" + HexDump.toHex( getVersion() ) + '\n' +
|
" Version: 0x" + HexDump.toHex( getVersion() ) + '\n' +
|
||||||
|
@ -49,24 +49,28 @@ public final class EscherPropertyFactory {
|
|||||||
// boolean isBlipId = ( propId & (short) 0x4000 ) != 0;
|
// boolean isBlipId = ( propId & (short) 0x4000 ) != 0;
|
||||||
|
|
||||||
byte propertyType = EscherProperties.getPropertyType(propNumber);
|
byte propertyType = EscherProperties.getPropertyType(propNumber);
|
||||||
if ( propertyType == EscherPropertyMetaData.TYPE_BOOLEAN )
|
EscherProperty ep;
|
||||||
results.add( new EscherBoolProperty( propId, propData ) );
|
switch (propertyType) {
|
||||||
else if ( propertyType == EscherPropertyMetaData.TYPE_RGB )
|
case EscherPropertyMetaData.TYPE_BOOLEAN:
|
||||||
results.add( new EscherRGBProperty( propId, propData ) );
|
ep = new EscherBoolProperty( propId, propData );
|
||||||
else if ( propertyType == EscherPropertyMetaData.TYPE_SHAPEPATH )
|
break;
|
||||||
results.add( new EscherShapePathProperty( propId, propData ) );
|
case EscherPropertyMetaData.TYPE_RGB:
|
||||||
else
|
ep = new EscherRGBProperty( propId, propData );
|
||||||
{
|
break;
|
||||||
if ( !isComplex )
|
case EscherPropertyMetaData.TYPE_SHAPEPATH:
|
||||||
results.add( new EscherSimpleProperty( propId, propData ) );
|
ep = new EscherShapePathProperty( propId, propData );
|
||||||
else
|
break;
|
||||||
{
|
default:
|
||||||
if ( propertyType == EscherPropertyMetaData.TYPE_ARRAY)
|
if ( !isComplex ) {
|
||||||
results.add( new EscherArrayProperty( propId, new byte[propData]) );
|
ep = new EscherSimpleProperty( propId, propData );
|
||||||
else
|
} else if ( propertyType == EscherPropertyMetaData.TYPE_ARRAY) {
|
||||||
results.add( new EscherComplexProperty( propId, new byte[propData]) );
|
ep = new EscherArrayProperty( propId, new byte[propData]);
|
||||||
}
|
} else {
|
||||||
|
ep = new EscherComplexProperty( propId, new byte[propData]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
results.add( ep );
|
||||||
pos += 6;
|
pos += 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ public class EscherRGBProperty
|
|||||||
*/
|
*/
|
||||||
public int getRgbColor()
|
public int getRgbColor()
|
||||||
{
|
{
|
||||||
return propertyValue;
|
return getPropertyValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -44,7 +44,7 @@ public class EscherRGBProperty
|
|||||||
*/
|
*/
|
||||||
public byte getRed()
|
public byte getRed()
|
||||||
{
|
{
|
||||||
return (byte) ( propertyValue & 0xFF );
|
return (byte) ( getRgbColor() & 0xFF );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -52,7 +52,7 @@ public class EscherRGBProperty
|
|||||||
*/
|
*/
|
||||||
public byte getGreen()
|
public byte getGreen()
|
||||||
{
|
{
|
||||||
return (byte) ( (propertyValue >> 8) & 0xFF );
|
return (byte) ( (getRgbColor() >> 8) & 0xFF );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -60,7 +60,7 @@ public class EscherRGBProperty
|
|||||||
*/
|
*/
|
||||||
public byte getBlue()
|
public byte getBlue()
|
||||||
{
|
{
|
||||||
return (byte) ( (propertyValue >> 16) & 0xFF );
|
return (byte) ( (getRgbColor() >> 16) & 0xFF );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -68,7 +68,7 @@ public class EscherRGBProperty
|
|||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
builder.append(tab).append("<").append(getClass().getSimpleName()).append(" id=\"0x").append(HexDump.toHex(getId()))
|
builder.append(tab).append("<").append(getClass().getSimpleName()).append(" id=\"0x").append(HexDump.toHex(getId()))
|
||||||
.append("\" name=\"").append(getName()).append("\" blipId=\"")
|
.append("\" name=\"").append(getName()).append("\" blipId=\"")
|
||||||
.append(isBlipId()).append("\" value=\"0x").append(HexDump.toHex(propertyValue)).append("\"/>\n");
|
.append(isBlipId()).append("\" value=\"0x").append(HexDump.toHex(getRgbColor())).append("\"/>\n");
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ import org.apache.poi.util.HexDump;
|
|||||||
*/
|
*/
|
||||||
public class EscherSimpleProperty extends EscherProperty
|
public class EscherSimpleProperty extends EscherProperty
|
||||||
{
|
{
|
||||||
protected int propertyValue;
|
private int propertyValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The id is distinct from the actual property number. The id includes the property number the blip id
|
* The id is distinct from the actual property number. The id includes the property number the blip id
|
||||||
|
@ -24,17 +24,17 @@ public abstract class POIXMLRelation {
|
|||||||
/**
|
/**
|
||||||
* Describes the content stored in a part.
|
* Describes the content stored in a part.
|
||||||
*/
|
*/
|
||||||
protected String _type;
|
private String _type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The kind of connection between a source part and a target part in a package.
|
* The kind of connection between a source part and a target part in a package.
|
||||||
*/
|
*/
|
||||||
protected String _relation;
|
private String _relation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The path component of a pack URI.
|
* The path component of a pack URI.
|
||||||
*/
|
*/
|
||||||
protected String _defaultName;
|
private String _defaultName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines what object is used to construct instances of this relationship
|
* Defines what object is used to construct instances of this relationship
|
||||||
|
@ -368,7 +368,7 @@ public final class XSSFRelation extends POIXMLRelation {
|
|||||||
*/
|
*/
|
||||||
public InputStream getContents(PackagePart corePart) throws IOException, InvalidFormatException {
|
public InputStream getContents(PackagePart corePart) throws IOException, InvalidFormatException {
|
||||||
PackageRelationshipCollection prc =
|
PackageRelationshipCollection prc =
|
||||||
corePart.getRelationshipsByType(_relation);
|
corePart.getRelationshipsByType(getRelation());
|
||||||
Iterator<PackageRelationship> it = prc.iterator();
|
Iterator<PackageRelationship> it = prc.iterator();
|
||||||
if(it.hasNext()) {
|
if(it.hasNext()) {
|
||||||
PackageRelationship rel = it.next();
|
PackageRelationship rel = it.next();
|
||||||
@ -376,7 +376,7 @@ public final class XSSFRelation extends POIXMLRelation {
|
|||||||
PackagePart part = corePart.getPackage().getPart(relName);
|
PackagePart part = corePart.getPackage().getPart(relName);
|
||||||
return part.getInputStream();
|
return part.getInputStream();
|
||||||
}
|
}
|
||||||
log.log(POILogger.WARN, "No part " + _defaultName + " found");
|
log.log(POILogger.WARN, "No part " + getDefaultFileName() + " found");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,29 +17,26 @@
|
|||||||
|
|
||||||
package org.apache.poi.ddf;
|
package org.apache.poi.ddf;
|
||||||
|
|
||||||
import junit.framework.Test;
|
import org.junit.runner.RunWith;
|
||||||
import junit.framework.TestSuite;
|
import org.junit.runners.Suite;
|
||||||
/**
|
|
||||||
* Tests for org.apache.poi.ddf<br/>
|
@RunWith(Suite.class)
|
||||||
*/
|
@Suite.SuiteClasses({
|
||||||
|
TestEscherBSERecord.class,
|
||||||
|
TestEscherBlipRecord.class,
|
||||||
|
TestEscherBoolProperty.class,
|
||||||
|
TestEscherChildAnchorRecord.class,
|
||||||
|
TestEscherClientAnchorRecord.class,
|
||||||
|
TestEscherClientDataRecord.class,
|
||||||
|
TestEscherContainerRecord.class,
|
||||||
|
TestEscherDgRecord.class,
|
||||||
|
TestEscherDggRecord.class,
|
||||||
|
TestEscherOptRecord.class,
|
||||||
|
TestEscherPropertyFactory.class,
|
||||||
|
TestEscherSpRecord.class,
|
||||||
|
TestEscherSpgrRecord.class,
|
||||||
|
TestEscherSplitMenuColorsRecord.class,
|
||||||
|
TestUnknownEscherRecord.class
|
||||||
|
})
|
||||||
public final class AllPOIDDFTests {
|
public final class AllPOIDDFTests {
|
||||||
public static Test suite() {
|
|
||||||
TestSuite result = new TestSuite("Tests for org.apache.poi.ddf");
|
|
||||||
result.addTestSuite(TestEscherBSERecord.class);
|
|
||||||
result.addTestSuite(TestEscherBlipRecord.class);
|
|
||||||
result.addTestSuite(TestEscherBoolProperty.class);
|
|
||||||
result.addTestSuite(TestEscherChildAnchorRecord.class);
|
|
||||||
result.addTestSuite(TestEscherClientAnchorRecord.class);
|
|
||||||
result.addTestSuite(TestEscherClientDataRecord.class);
|
|
||||||
result.addTestSuite(TestEscherContainerRecord.class);
|
|
||||||
result.addTestSuite(TestEscherDgRecord.class);
|
|
||||||
result.addTestSuite(TestEscherDggRecord.class);
|
|
||||||
result.addTestSuite(TestEscherOptRecord.class);
|
|
||||||
result.addTestSuite(TestEscherPropertyFactory.class);
|
|
||||||
result.addTestSuite(TestEscherSpRecord.class);
|
|
||||||
result.addTestSuite(TestEscherSpgrRecord.class);
|
|
||||||
result.addTestSuite(TestEscherSplitMenuColorsRecord.class);
|
|
||||||
result.addTestSuite(TestUnknownEscherRecord.class);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -17,18 +17,16 @@
|
|||||||
|
|
||||||
package org.apache.poi.ddf;
|
package org.apache.poi.ddf;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.poi.util.HexRead;
|
|
||||||
import org.apache.poi.util.HexDump;
|
import org.apache.poi.util.HexDump;
|
||||||
|
import org.apache.poi.util.HexRead;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
/**
|
public class TestEscherPropertyFactory {
|
||||||
* @author Glen Stampoultzis (glens @ superlinksoftware.com)
|
@Test
|
||||||
*/
|
|
||||||
public class TestEscherPropertyFactory extends TestCase
|
|
||||||
{
|
|
||||||
public void testCreateProperties() {
|
public void testCreateProperties() {
|
||||||
String dataStr = "41 C1 " + // propid, complex ind
|
String dataStr = "41 C1 " + // propid, complex ind
|
||||||
"03 00 00 00 " + // size of complex property
|
"03 00 00 00 " + // size of complex property
|
||||||
@ -41,7 +39,7 @@ public class TestEscherPropertyFactory extends TestCase
|
|||||||
;
|
;
|
||||||
byte[] data = HexRead.readFromString( dataStr );
|
byte[] data = HexRead.readFromString( dataStr );
|
||||||
EscherPropertyFactory f = new EscherPropertyFactory();
|
EscherPropertyFactory f = new EscherPropertyFactory();
|
||||||
List props = f.createProperties( data, 0, (short)3 );
|
List<EscherProperty> props = f.createProperties( data, 0, (short)3 );
|
||||||
EscherComplexProperty p1 = (EscherComplexProperty) props.get( 0 );
|
EscherComplexProperty p1 = (EscherComplexProperty) props.get( 0 );
|
||||||
assertEquals( (short)0xC141, p1.getId() );
|
assertEquals( (short)0xC141, p1.getId() );
|
||||||
assertEquals( "[01, 02, 03]", HexDump.toHex( p1.getComplexData() ) );
|
assertEquals( "[01, 02, 03]", HexDump.toHex( p1.getComplexData() ) );
|
||||||
|
Loading…
Reference in New Issue
Block a user