git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@805284 13f79535-47bb-0310-9956-ffa450edef68pull/1/head
@@ -238,7 +238,6 @@ public class AddDimensionedImage { | |||
String imageFile, double reqImageWidthMM, double reqImageHeightMM, | |||
int resizeBehaviour) throws FileNotFoundException, IOException, | |||
IllegalArgumentException { | |||
HSSFRow row = null; | |||
HSSFClientAnchor anchor = null; | |||
HSSFPatriarch patriarch = null; | |||
ClientAnchorDetail rowClientAnchorDetail = null; | |||
@@ -280,7 +279,7 @@ public class AddDimensionedImage { | |||
// image as the size of the row/column is adjusted. This could easilly | |||
// become another parameter passed to the method. | |||
anchor.setAnchorType(HSSFClientAnchor.DONT_MOVE_AND_RESIZE); | |||
// Now, add the picture to the workbook. Note that the type is assumed | |||
// to be a JPEG/JPG, this could easily (and should) be parameterised | |||
// however. | |||
@@ -485,7 +484,6 @@ public class AddDimensionedImage { | |||
double colWidthMM = 0.0D; | |||
double overlapMM = 0.0D; | |||
double coordinatePositionsPerMM = 0.0D; | |||
int fromNumber = startingColumn; | |||
int toColumn = startingColumn; | |||
int inset = 0; | |||
@@ -522,7 +520,7 @@ public class AddDimensionedImage { | |||
// total number of co-ordinate positions to the third paramater | |||
// of the ClientAnchorDetail constructor. For no sepcific reason, | |||
// the latter option is used below. | |||
anchorDetail = new ClientAnchorDetail(startingColumn, | |||
anchorDetail = new ClientAnchorDetail(startingColumn, | |||
toColumn, ConvertImageUnits.TOTAL_COLUMN_COORDINATE_POSITIONS); | |||
} | |||
// In this case, the image will overlap part of another column and it is | |||
@@ -706,8 +704,6 @@ public class AddDimensionedImage { | |||
* @param args the command line arguments | |||
*/ | |||
public static void main(String[] args) { | |||
File file = null; | |||
FileInputStream fis = null; | |||
FileOutputStream fos = null; | |||
HSSFWorkbook workbook = null; | |||
HSSFSheet sheet = null; | |||
@@ -761,13 +757,13 @@ public class AddDimensionedImage { | |||
* * Together, parameter seven and eight determine the column and row | |||
* co-ordinates of the cell whose top left hand corner will be aligned | |||
* with the images bottom right hand corner. | |||
* | |||
* | |||
* An instance of the ClientAnchorDetail class provides three of the eight | |||
* parameters, one of the co-ordinates for the images top left hand corner, | |||
* one of the co-ordinates for the images bottom right hand corner and | |||
* one of the co-ordinates for the images bottom right hand corner and | |||
* either how far the image should be inset from the top or the left hand | |||
* edge of the cell. | |||
* | |||
* | |||
* @author Mark Beardsley [msb at apache.org] | |||
* @version 1.00 5th August 2009. | |||
*/ | |||
@@ -892,7 +888,7 @@ public class AddDimensionedImage { | |||
int pixels = (widthUnits / EXCEL_COLUMN_WIDTH_FACTOR) | |||
* UNIT_OFFSET_LENGTH; | |||
int offsetWidthUnits = widthUnits % EXCEL_COLUMN_WIDTH_FACTOR; | |||
pixels += Math.round((float) offsetWidthUnits / | |||
pixels += Math.round(offsetWidthUnits / | |||
((float) EXCEL_COLUMN_WIDTH_FACTOR / UNIT_OFFSET_LENGTH)); | |||
return pixels; | |||
} | |||
@@ -923,4 +919,4 @@ public class AddDimensionedImage { | |||
ConvertImageUnits.PIXELS_PER_MILLIMETRES))); | |||
} | |||
} | |||
} | |||
} |
@@ -177,7 +177,7 @@ public class Util | |||
* | |||
* @param date The date to be converted | |||
* @return The filetime | |||
* | |||
* | |||
* @see #filetimeToDate(long) | |||
* @see #filetimeToDate(int, int) | |||
*/ | |||
@@ -211,10 +211,10 @@ public class Util | |||
* @return <code>true</code> if the collections are equal, else | |||
* <code>false</code>. | |||
*/ | |||
public static boolean equals(final Collection c1, final Collection c2) | |||
public static boolean equals(Collection<?> c1, Collection<?> c2) | |||
{ | |||
final Object[] o1 = c1.toArray(); | |||
final Object[] o2 = c2.toArray(); | |||
Object[] o1 = c1.toArray(); | |||
Object[] o2 = c2.toArray(); | |||
return internalEquals(o1, o2); | |||
} | |||
@@ -229,14 +229,14 @@ public class Util | |||
* @return <code>true</code> if the object arrays are equal, | |||
* <code>false</code> if they are not. | |||
*/ | |||
public static boolean equals(final Object[] c1, final Object[] c2) | |||
public static boolean equals(Object[] c1, Object[] c2) | |||
{ | |||
final Object[] o1 = (Object[]) c1.clone(); | |||
final Object[] o2 = (Object[]) c2.clone(); | |||
final Object[] o1 = c1.clone(); | |||
final Object[] o2 = c2.clone(); | |||
return internalEquals(o1, o2); | |||
} | |||
private static boolean internalEquals(final Object[] o1, final Object[] o2) | |||
private static boolean internalEquals(Object[] o1, Object[] o2) | |||
{ | |||
for (int i1 = 0; i1 < o1.length; i1++) | |||
{ | |||
@@ -326,9 +326,9 @@ public class Util | |||
/** | |||
* <p>Returns a textual representation of a {@link Throwable}, including a | |||
* stacktrace.</p> | |||
* | |||
* | |||
* @param t The {@link Throwable} | |||
* | |||
* | |||
* @return a string containing the output of a call to | |||
* <code>t.printStacktrace()</code>. | |||
*/ |
@@ -24,10 +24,10 @@ import org.apache.poi.hssf.record.*; | |||
/** | |||
* Event-based record factory. As opposed to RecordFactory | |||
* this version sends {@link ERFListener#processRecord(Record) } messages to | |||
* this version sends {@link ERFListener#processRecord(Record) } messages to | |||
* the supplied listener. Record notifications are sent one record behind | |||
* to ensure that {@link ContinueRecord}s are processed first. | |||
* | |||
* | |||
* @author Andrew C. Oliver (acoliver@apache.org) - probably to blame for the bugs (so yank his chain on the list) | |||
* @author Marc Johnson (mjohnson at apache dot org) - methods taken from RecordFactory | |||
* @author Glen Stampoultzis (glens at apache.org) - methods taken from RecordFactory | |||
@@ -35,87 +35,87 @@ import org.apache.poi.hssf.record.*; | |||
*/ | |||
public final class EventRecordFactory { | |||
private final ERFListener _listener; | |||
private final ERFListener _listener; | |||
private final short[] _sids; | |||
/** | |||
* | |||
* @param sids an array of Record.sid values identifying the records | |||
* the listener will work with. Alternatively if this is "null" then | |||
* all records are passed. For all 'known' record types use {@link RecordFactory#getAllKnownRecordSIDs()} | |||
*/ | |||
public EventRecordFactory(ERFListener listener, short[] sids) { | |||
_listener = listener; | |||
if (sids == null) { | |||
_sids = null; | |||
} else { | |||
_sids = (short[]) sids.clone(); | |||
Arrays.sort(_sids); // for faster binary search | |||
} | |||
} | |||
/** | |||
* | |||
* @param sids an array of Record.sid values identifying the records | |||
* the listener will work with. Alternatively if this is "null" then | |||
* all records are passed. For all 'known' record types use {@link RecordFactory#getAllKnownRecordSIDs()} | |||
*/ | |||
public EventRecordFactory(ERFListener listener, short[] sids) { | |||
_listener = listener; | |||
if (sids == null) { | |||
_sids = null; | |||
} else { | |||
_sids = sids.clone(); | |||
Arrays.sort(_sids); // for faster binary search | |||
} | |||
} | |||
private boolean isSidIncluded(short sid) { | |||
if (_sids == null) { | |||
return true; | |||
} | |||
return Arrays.binarySearch(_sids, sid) >= 0; | |||
} | |||
} | |||
/** | |||
* sends the record event to all registered listeners. | |||
* @param record the record to be thrown. | |||
* @return <code>false</code> to abort. This aborts | |||
* out of the event loop should the listener return false | |||
*/ | |||
private boolean processRecord(Record record) { | |||
if (!isSidIncluded(record.getSid())) { | |||
return true; | |||
} | |||
return _listener.processRecord(record); | |||
} | |||
/** | |||
* sends the record event to all registered listeners. | |||
* @param record the record to be thrown. | |||
* @return <code>false</code> to abort. This aborts | |||
* out of the event loop should the listener return false | |||
*/ | |||
private boolean processRecord(Record record) { | |||
if (!isSidIncluded(record.getSid())) { | |||
return true; | |||
} | |||
return _listener.processRecord(record); | |||
} | |||
/** | |||
* Create an array of records from an input stream | |||
* | |||
* @param in the InputStream from which the records will be | |||
* obtained | |||
* | |||
* @exception RecordFormatException on error processing the | |||
* InputStream | |||
*/ | |||
public void processRecords(InputStream in) throws RecordFormatException { | |||
Record last_record = null; | |||
/** | |||
* Create an array of records from an input stream | |||
* | |||
* @param in the InputStream from which the records will be | |||
* obtained | |||
* | |||
* @exception RecordFormatException on error processing the | |||
* InputStream | |||
*/ | |||
public void processRecords(InputStream in) throws RecordFormatException { | |||
Record last_record = null; | |||
RecordInputStream recStream = new RecordInputStream(in); | |||
RecordInputStream recStream = new RecordInputStream(in); | |||
while (recStream.hasNextRecord()) { | |||
recStream.nextRecord(); | |||
Record[] recs = RecordFactory.createRecord(recStream); // handle MulRK records | |||
if (recs.length > 1) { | |||
for (int k = 0; k < recs.length; k++) { | |||
if ( last_record != null ) { | |||
if (!processRecord(last_record)) { | |||
return; | |||
} | |||
} | |||
last_record = recs[ k ]; // do to keep the algorithm homogeneous...you can't | |||
} // actually continue a number record anyhow. | |||
} else { | |||
Record record = recs[ 0 ]; | |||
while (recStream.hasNextRecord()) { | |||
recStream.nextRecord(); | |||
Record[] recs = RecordFactory.createRecord(recStream); // handle MulRK records | |||
if (recs.length > 1) { | |||
for (int k = 0; k < recs.length; k++) { | |||
if ( last_record != null ) { | |||
if (!processRecord(last_record)) { | |||
return; | |||
} | |||
} | |||
last_record = recs[ k ]; // do to keep the algorithm homogeneous...you can't | |||
} // actually continue a number record anyhow. | |||
} else { | |||
Record record = recs[ 0 ]; | |||
if (record != null) { | |||
if (last_record != null) { | |||
if (!processRecord(last_record)) { | |||
return; | |||
} | |||
} | |||
last_record = record; | |||
} | |||
} | |||
} | |||
if (record != null) { | |||
if (last_record != null) { | |||
if (!processRecord(last_record)) { | |||
return; | |||
} | |||
} | |||
last_record = record; | |||
} | |||
} | |||
} | |||
if (last_record != null) { | |||
processRecord(last_record); | |||
} | |||
} | |||
} | |||
if (last_record != null) { | |||
processRecord(last_record); | |||
} | |||
} | |||
} |
@@ -65,8 +65,8 @@ import org.apache.poi.hssf.record.formula.Ref3DPtg; | |||
* @author Josh Micich | |||
*/ | |||
final class LinkTable { | |||
// TODO make this class into a record aggregate | |||
private static final class CRNBlock { | |||
@@ -84,7 +84,7 @@ final class LinkTable { | |||
_crns = crns; | |||
} | |||
public CRNRecord[] getCrns() { | |||
return (CRNRecord[]) _crns.clone(); | |||
return _crns.clone(); | |||
} | |||
} | |||
@@ -95,7 +95,7 @@ final class LinkTable { | |||
public ExternalBookBlock(RecordStream rs) { | |||
_externalBookRecord = (SupBookRecord) rs.getNext(); | |||
List temp = new ArrayList(); | |||
List<Object> temp = new ArrayList<Object>(); | |||
while(rs.peekNextClass() == ExternalNameRecord.class) { | |||
temp.add(rs.getNext()); | |||
} | |||
@@ -141,7 +141,7 @@ final class LinkTable { | |||
private final ExternalBookBlock[] _externalBookBlocks; | |||
private final ExternSheetRecord _externSheetRecord; | |||
private final List _definedNames; | |||
private final List<NameRecord> _definedNames; | |||
private final int _recordCount; | |||
private final WorkbookRecordList _workbookRecordList; // TODO - would be nice to remove this | |||
@@ -150,15 +150,15 @@ final class LinkTable { | |||
_workbookRecordList = workbookRecordList; | |||
RecordStream rs = new RecordStream(inputList, startIndex); | |||
List temp = new ArrayList(); | |||
List<ExternalBookBlock> temp = new ArrayList<ExternalBookBlock>(); | |||
while(rs.peekNextClass() == SupBookRecord.class) { | |||
temp.add(new ExternalBookBlock(rs)); | |||
} | |||
_externalBookBlocks = new ExternalBookBlock[temp.size()]; | |||
temp.toArray(_externalBookBlocks); | |||
temp.clear(); | |||
if (_externalBookBlocks.length > 0) { | |||
// If any ExternalBookBlock present, there is always 1 of ExternSheetRecord | |||
if (rs.peekNextClass() != ExternSheetRecord.class) { | |||
@@ -170,8 +170,8 @@ final class LinkTable { | |||
} else { | |||
_externSheetRecord = null; | |||
} | |||
_definedNames = new ArrayList(); | |||
_definedNames = new ArrayList<NameRecord>(); | |||
// collect zero or more DEFINEDNAMEs id=0x18 | |||
while(rs.peekNextClass() == NameRecord.class) { | |||
NameRecord nr = (NameRecord)rs.getNext(); | |||
@@ -183,19 +183,19 @@ final class LinkTable { | |||
} | |||
private static ExternSheetRecord readExtSheetRecord(RecordStream rs) { | |||
List temp = new ArrayList(2); | |||
List<ExternSheetRecord> temp = new ArrayList<ExternSheetRecord>(2); | |||
while(rs.peekNextClass() == ExternSheetRecord.class) { | |||
temp.add(rs.getNext()); | |||
temp.add((ExternSheetRecord) rs.getNext()); | |||
} | |||
int nItems = temp.size(); | |||
if (nItems < 1) { | |||
throw new RuntimeException("Expected an EXTERNSHEET record but got (" | |||
throw new RuntimeException("Expected an EXTERNSHEET record but got (" | |||
+ rs.peekNextClass().getName() + ")"); | |||
} | |||
if (nItems == 1) { | |||
// this is the normal case. There should be just one ExternSheetRecord | |||
return (ExternSheetRecord) temp.get(0); | |||
return temp.get(0); | |||
} | |||
// Some apps generate multiple ExternSheetRecords (see bug 45698). | |||
// It seems like the best thing to do might be to combine these into one | |||
@@ -206,7 +206,7 @@ final class LinkTable { | |||
public LinkTable(int numberOfSheets, WorkbookRecordList workbookRecordList) { | |||
_workbookRecordList = workbookRecordList; | |||
_definedNames = new ArrayList(); | |||
_definedNames = new ArrayList<NameRecord>(); | |||
_externalBookBlocks = new ExternalBookBlock[] { | |||
new ExternalBookBlock(numberOfSheets), | |||
}; | |||
@@ -267,7 +267,7 @@ final class LinkTable { | |||
} | |||
public NameRecord getNameRecord(int index) { | |||
return (NameRecord) _definedNames.get(index); | |||
return _definedNames.get(index); | |||
} | |||
public void addName(NameRecord name) { | |||
@@ -301,9 +301,9 @@ final class LinkTable { | |||
} | |||
return false; | |||
} | |||
private static boolean isDuplicatedNames(NameRecord firstName, NameRecord lastName) { | |||
return lastName.getNameText().equalsIgnoreCase(firstName.getNameText()) | |||
return lastName.getNameText().equalsIgnoreCase(firstName.getNameText()) | |||
&& isSameSheetNames(firstName, lastName); | |||
} | |||
private static boolean isSameSheetNames(NameRecord firstName, NameRecord lastName) { | |||
@@ -342,10 +342,10 @@ final class LinkTable { | |||
throw new RuntimeException("No external workbook with name '" + workbookName + "'"); | |||
} | |||
int sheetIndex = getSheetIndex(ebrTarget.getSheetNames(), sheetName); | |||
int result = _externSheetRecord.getRefIxForSheet(externalBookIndex, sheetIndex); | |||
if (result < 0) { | |||
throw new RuntimeException("ExternSheetRecord does not contain combination (" | |||
throw new RuntimeException("ExternSheetRecord does not contain combination (" | |||
+ externalBookIndex + ", " + sheetIndex + ")"); | |||
} | |||
return result; | |||
@@ -356,7 +356,7 @@ final class LinkTable { | |||
if (sheetNames[i].equals(sheetName)) { | |||
return i; | |||
} | |||
} | |||
throw new RuntimeException("External workbook does not contain sheet '" + sheetName + "'"); | |||
} | |||
@@ -428,7 +428,7 @@ final class LinkTable { | |||
continue; | |||
} | |||
// found it. | |||
int sheetRefIndex = findRefIndexFromExtBookIndex(i); | |||
int sheetRefIndex = findRefIndexFromExtBookIndex(i); | |||
if (sheetRefIndex >= 0) { | |||
return new NameXPtg(sheetRefIndex, definedNameIndex); | |||
} | |||
@@ -437,6 +437,6 @@ final class LinkTable { | |||
} | |||
private int findRefIndexFromExtBookIndex(int extBookIndex) { | |||
return _externSheetRecord.findRefIndexFromExtBookIndex(extBookIndex); | |||
return _externSheetRecord.findRefIndexFromExtBookIndex(extBookIndex); | |||
} | |||
} |
@@ -465,7 +465,7 @@ public final class EscherAggregate extends AbstractEscherHolderRecord { | |||
pos += temp; | |||
// Write the matching OBJ record | |||
Record obj = (Record) shapeToObj.get( shapes.get( i ) ); | |||
Record obj = shapeToObj.get( shapes.get( i ) ); | |||
temp = obj.serialize( pos, data ); | |||
pos += temp; | |||
@@ -535,7 +535,7 @@ public final class EscherAggregate extends AbstractEscherHolderRecord { | |||
{ | |||
this.patriarch = patriarch; | |||
} | |||
/** | |||
* Converts the Records into UserModel | |||
* objects on the bound HSSFPatriarch | |||
@@ -544,7 +544,7 @@ public final class EscherAggregate extends AbstractEscherHolderRecord { | |||
if(patriarch == null) { | |||
throw new IllegalStateException("Must call setPatriarch() first"); | |||
} | |||
// The top level container ought to have | |||
// the DgRecord and the container of one container | |||
// per shape group (patriach overall first) | |||
@@ -552,14 +552,13 @@ public final class EscherAggregate extends AbstractEscherHolderRecord { | |||
if(topContainer == null) { | |||
return; | |||
} | |||
topContainer = (EscherContainerRecord) | |||
topContainer.getChildContainers().get(0); | |||
topContainer = topContainer.getChildContainers().get(0); | |||
List tcc = topContainer.getChildContainers(); | |||
if(tcc.size() == 0) { | |||
throw new IllegalStateException("No child escher containers at the point that should hold the patriach data, and one container per top level shape!"); | |||
} | |||
// First up, get the patriach position | |||
// This is in the first EscherSpgrRecord, in | |||
// the first container, with a EscherSRecord too | |||
@@ -579,7 +578,7 @@ public final class EscherAggregate extends AbstractEscherHolderRecord { | |||
spgr.getRectX2(), spgr.getRectY2() | |||
); | |||
} | |||
// Now process the containers for each group | |||
// and objects | |||
for(int i=1; i<tcc.size(); i++) { | |||
@@ -587,7 +586,7 @@ public final class EscherAggregate extends AbstractEscherHolderRecord { | |||
(EscherContainerRecord)tcc.get(i); | |||
//System.err.println("\n\n*****\n\n"); | |||
//System.err.println(shapeContainer); | |||
// Could be a group, or a base object | |||
if(shapeContainer.getChildRecords().size() == 1 && | |||
shapeContainer.getChildContainers().size() == 1) { | |||
@@ -595,7 +594,7 @@ public final class EscherAggregate extends AbstractEscherHolderRecord { | |||
HSSFShapeGroup group = | |||
new HSSFShapeGroup(null, new HSSFClientAnchor()); | |||
patriarch.getChildren().add(group); | |||
EscherContainerRecord groupContainer = | |||
(EscherContainerRecord)shapeContainer.getChild(0); | |||
convertRecordsToUserModel(groupContainer, group); | |||
@@ -604,7 +603,7 @@ public final class EscherAggregate extends AbstractEscherHolderRecord { | |||
HSSFTextbox box = | |||
new HSSFTextbox(null, new HSSFClientAnchor()); | |||
patriarch.getChildren().add(box); | |||
convertRecordsToUserModel(shapeContainer, box); | |||
} else if(shapeContainer.hasChildOfType((short)0xF011)) { | |||
// Not yet supporting EscherClientDataRecord stuff | |||
@@ -613,7 +612,7 @@ public final class EscherAggregate extends AbstractEscherHolderRecord { | |||
convertRecordsToUserModel(shapeContainer, patriarch); | |||
} | |||
} | |||
// Now, clear any trace of what records make up | |||
// the patriarch | |||
// Otherwise, everything will go horribly wrong | |||
@@ -625,14 +624,14 @@ public final class EscherAggregate extends AbstractEscherHolderRecord { | |||
// back into shapes | |||
log.log(POILogger.WARN, "Not processing objects into Patriarch!"); | |||
} | |||
private void convertRecordsToUserModel(EscherContainerRecord shapeContainer, Object model) { | |||
for(Iterator<EscherRecord> it = shapeContainer.getChildIterator(); it.hasNext();) { | |||
EscherRecord r = it.next(); | |||
if(r instanceof EscherSpgrRecord) { | |||
// This may be overriden by a later EscherClientAnchorRecord | |||
EscherSpgrRecord spgr = (EscherSpgrRecord)r; | |||
if(model instanceof HSSFShapeGroup) { | |||
HSSFShapeGroup g = (HSSFShapeGroup)model; | |||
g.setCoordinates( | |||
@@ -642,10 +641,10 @@ public final class EscherAggregate extends AbstractEscherHolderRecord { | |||
} else { | |||
throw new IllegalStateException("Got top level anchor but not processing a group"); | |||
} | |||
} | |||
} | |||
else if(r instanceof EscherClientAnchorRecord) { | |||
EscherClientAnchorRecord car = (EscherClientAnchorRecord)r; | |||
if(model instanceof HSSFShape) { | |||
HSSFShape g = (HSSFShape)model; | |||
g.getAnchor().setDx1(car.getDx1()); | |||
@@ -658,7 +657,7 @@ public final class EscherAggregate extends AbstractEscherHolderRecord { | |||
} | |||
else if(r instanceof EscherTextboxRecord) { | |||
EscherTextboxRecord tbr = (EscherTextboxRecord)r; | |||
// Also need to find the TextObjectRecord too | |||
// TODO | |||
} | |||
@@ -673,7 +672,7 @@ public final class EscherAggregate extends AbstractEscherHolderRecord { | |||
} | |||
} | |||
} | |||
public void clear() | |||
{ | |||
clearEscherRecords(); | |||
@@ -742,7 +741,7 @@ public final class EscherAggregate extends AbstractEscherHolderRecord { | |||
EscherRecord escherTextbox = ( (TextboxShape) shapeModel ).getEscherTextbox(); | |||
shapeToObj.put( escherTextbox, ( (TextboxShape) shapeModel ).getTextObjectRecord() ); | |||
// escherParent.addChildRecord(escherTextbox); | |||
if ( shapeModel instanceof CommentShape ){ | |||
CommentShape comment = (CommentShape)shapeModel; | |||
tailRec.add(comment.getNoteRecord()); |
@@ -68,9 +68,6 @@ public final class SSTRecord extends ContinuableRecord { | |||
/** Offsets relative the start of the current SST or continue record */ | |||
int[] bucketRelativeOffsets; | |||
/** | |||
* default constructor | |||
*/ | |||
public SSTRecord() | |||
{ | |||
field_1_num_strings = 0; | |||
@@ -86,8 +83,7 @@ public final class SSTRecord extends ContinuableRecord { | |||
* | |||
* @return the index of that string in the table | |||
*/ | |||
public int addString( final UnicodeString string ) | |||
public int addString(UnicodeString string) | |||
{ | |||
field_1_num_strings++; | |||
UnicodeString ucs = ( string == null ) ? EMPTY_STRING | |||
@@ -95,12 +91,9 @@ public final class SSTRecord extends ContinuableRecord { | |||
int rval; | |||
int index = field_3_strings.getIndex(ucs); | |||
if ( index != -1 ) | |||
{ | |||
if ( index != -1 ) { | |||
rval = index; | |||
} | |||
else | |||
{ | |||
} else { | |||
// This is a new string -- we didn't see it among the | |||
// strings we've already collected | |||
rval = field_3_strings.size(); | |||
@@ -113,7 +106,6 @@ public final class SSTRecord extends ContinuableRecord { | |||
/** | |||
* @return number of strings | |||
*/ | |||
public int getNumStrings() | |||
{ | |||
return field_1_num_strings; | |||
@@ -122,7 +114,6 @@ public final class SSTRecord extends ContinuableRecord { | |||
/** | |||
* @return number of unique strings | |||
*/ | |||
public int getNumUniqueStrings() | |||
{ | |||
return field_2_num_unique_strings; | |||
@@ -136,8 +127,7 @@ public final class SSTRecord extends ContinuableRecord { | |||
* | |||
* @return the desired string | |||
*/ | |||
public UnicodeString getString( final int id ) | |||
public UnicodeString getString(int id ) | |||
{ | |||
return (UnicodeString) field_3_strings.get( id ); | |||
} | |||
@@ -148,9 +138,7 @@ public final class SSTRecord extends ContinuableRecord { | |||
* | |||
* @return string representation | |||
*/ | |||
public String toString() | |||
{ | |||
public String toString() { | |||
StringBuffer buffer = new StringBuffer(); | |||
buffer.append( "[SST]\n" ); | |||
@@ -168,11 +156,7 @@ public final class SSTRecord extends ContinuableRecord { | |||
return buffer.toString(); | |||
} | |||
/** | |||
* @return sid | |||
*/ | |||
public short getSid() | |||
{ | |||
public short getSid() { | |||
return sid; | |||
} | |||
@@ -254,9 +238,7 @@ public final class SSTRecord extends ContinuableRecord { | |||
* | |||
* @param in the RecordInputstream to read the record from | |||
*/ | |||
public SSTRecord( RecordInputStream in ) | |||
{ | |||
public SSTRecord(RecordInputStream in) { | |||
// this method is ALWAYS called after construction -- using | |||
// the nontrivial constructor, of course -- so this is where | |||
// we initialize our fields | |||
@@ -272,7 +254,6 @@ public final class SSTRecord extends ContinuableRecord { | |||
* @return an iterator of the strings we hold. All instances are | |||
* UnicodeStrings | |||
*/ | |||
Iterator getStrings() | |||
{ | |||
return field_3_strings.iterator(); | |||
@@ -281,9 +262,7 @@ public final class SSTRecord extends ContinuableRecord { | |||
/** | |||
* @return count of the strings we hold. | |||
*/ | |||
int countStrings() | |||
{ | |||
int countStrings() { | |||
return field_3_strings.size(); | |||
} | |||
@@ -294,8 +273,7 @@ public final class SSTRecord extends ContinuableRecord { | |||
bucketRelativeOffsets = serializer.getBucketRelativeOffsets(); | |||
} | |||
SSTDeserializer getDeserializer() | |||
{ | |||
SSTDeserializer getDeserializer() { | |||
return deserializer; | |||
} | |||
@@ -312,15 +290,14 @@ public final class SSTRecord extends ContinuableRecord { | |||
* SST record. | |||
* @return The new SST record. | |||
*/ | |||
public ExtSSTRecord createExtSSTRecord(int sstOffset) | |||
{ | |||
public ExtSSTRecord createExtSSTRecord(int sstOffset) { | |||
if (bucketAbsoluteOffsets == null || bucketAbsoluteOffsets == null) | |||
throw new IllegalStateException("SST record has not yet been serialized."); | |||
ExtSSTRecord extSST = new ExtSSTRecord(); | |||
extSST.setNumStringsPerBucket((short)8); | |||
int[] absoluteOffsets = (int[]) bucketAbsoluteOffsets.clone(); | |||
int[] relativeOffsets = (int[]) bucketRelativeOffsets.clone(); | |||
int[] absoluteOffsets = bucketAbsoluteOffsets.clone(); | |||
int[] relativeOffsets = bucketRelativeOffsets.clone(); | |||
for ( int i = 0; i < absoluteOffsets.length; i++ ) | |||
absoluteOffsets[i] += sstOffset; | |||
extSST.setBucketOffsets(absoluteOffsets, relativeOffsets); | |||
@@ -333,8 +310,7 @@ public final class SSTRecord extends ContinuableRecord { | |||
* | |||
* @return The size of the ExtSST record in bytes. | |||
*/ | |||
public int calcExtSSTRecordSize() | |||
{ | |||
public int calcExtSSTRecordSize() { | |||
return ExtSSTRecord.getRecordSizeForStrings(field_3_strings.size()); | |||
} | |||
} |
@@ -25,10 +25,10 @@ import org.apache.poi.util.LittleEndian; | |||
/** | |||
* Font Formatting Block of the Conditional Formatting Rule Record. | |||
* | |||
* | |||
* @author Dmitriy Kumshayev | |||
*/ | |||
public final class FontFormatting | |||
public final class FontFormatting | |||
{ | |||
private byte[] _rawData; | |||
@@ -45,7 +45,7 @@ public final class FontFormatting | |||
private static final int OFFSET_FONT_WEIGHT_MODIFIED = 100; | |||
private static final int OFFSET_NOT_USED1 = 104; | |||
private static final int OFFSET_NOT_USED2 = 108; | |||
private static final int OFFSET_NOT_USED3 = 112; // for some reason Excel always writes 0x7FFFFFFF at this offset | |||
private static final int OFFSET_NOT_USED3 = 112; // for some reason Excel always writes 0x7FFFFFFF at this offset | |||
private static final int OFFSET_FONT_FORMATING_END = 116; | |||
private static final int RAW_DATA_SIZE = 118; | |||
@@ -71,15 +71,15 @@ public final class FontFormatting | |||
public static final short SS_SUPER = 1; | |||
/** Escapement type - Subscript */ | |||
public static final short SS_SUB = 2; | |||
/** Underline type - None */ | |||
/** Underline type - None */ | |||
public static final byte U_NONE = 0; | |||
/** Underline type - Single */ | |||
/** Underline type - Single */ | |||
public static final byte U_SINGLE = 1; | |||
/** Underline type - Double */ | |||
/** Underline type - Double */ | |||
public static final byte U_DOUBLE = 2; | |||
/** Underline type - Single Accounting */ | |||
/** Underline type - Single Accounting */ | |||
public static final byte U_SINGLE_ACCOUNTING = 0x21; | |||
/** Underline type - Double Accounting */ | |||
/** Underline type - Double Accounting */ | |||
public static final byte U_DOUBLE_ACCOUNTING = 0x22; | |||
/** Normal boldness (not bold) */ | |||
private static final short FONT_WEIGHT_NORMAL = 0x190; | |||
@@ -92,7 +92,7 @@ public final class FontFormatting | |||
private FontFormatting(byte[] rawData) { | |||
_rawData = rawData; | |||
} | |||
public FontFormatting() | |||
{ | |||
this(new byte[RAW_DATA_SIZE]); | |||
@@ -144,7 +144,7 @@ public final class FontFormatting | |||
private void setInt(int offset, int value) { | |||
LittleEndian.putInt( _rawData, offset, value); | |||
} | |||
public byte[] getRawRecord() | |||
{ | |||
return _rawData; | |||
@@ -152,7 +152,7 @@ public final class FontFormatting | |||
/** | |||
* sets the height of the font in 1/20th point units | |||
* | |||
* | |||
* | |||
* @param height fontheight (in points/20); or -1 to preserve the cell font height | |||
*/ | |||
@@ -270,7 +270,7 @@ public final class FontFormatting | |||
/** | |||
* set the font weight to bold (weight=700) or to normal(weight=400) boldness. | |||
* | |||
* @param bold - set font weight to bold if true; to normal otherwise | |||
* @param bold - set font weight to bold if true; to normal otherwise | |||
*/ | |||
public void setBold(boolean bold) | |||
{ | |||
@@ -541,9 +541,9 @@ public final class FontFormatting | |||
return buffer.toString(); | |||
} | |||
public Object clone() | |||
public Object clone() | |||
{ | |||
byte[] rawData = (byte[]) _rawData.clone(); | |||
byte[] rawData = _rawData.clone(); | |||
return new FontFormatting(rawData); | |||
} | |||
} |
@@ -53,10 +53,7 @@ public final class OperandResolver { | |||
if (result instanceof ErrorEval) { | |||
throw new EvaluationException((ErrorEval) result); | |||
} | |||
if (result instanceof ValueEval) { | |||
return (ValueEval) result; | |||
} | |||
throw new RuntimeException("Unexpected eval type (" + result.getClass().getName() + ")"); | |||
return result; | |||
} | |||
/** |
@@ -283,7 +283,7 @@ public class EscherGraphics | |||
excelFont = new Font( font.getName(), font.getStyle(), (int) ( font.getSize() / verticalPixelsPerPoint )); | |||
} | |||
FontDetails d = StaticFontMetrics.getFontDetails( excelFont ); | |||
int width = (int) ( (d.getStringWidth( str ) * 8) + 12 ); | |||
int width = d.getStringWidth( str ) * 8 + 12; | |||
int height = (int) ( ( font.getSize() / verticalPixelsPerPoint ) + 6 ) * 2; | |||
y -= ( font.getSize() / verticalPixelsPerPoint ) + 2 * verticalPixelsPerPoint; // we want to draw the shape from the top-left | |||
HSSFTextbox textbox = escherGroup.createTextbox( new HSSFChildAnchor( x, y, x + width, y + height ) ); | |||
@@ -357,13 +357,13 @@ public class EscherGraphics | |||
* <p> | |||
* This draws the polygon, with <code>nPoint</code> line segments. | |||
* The first <code>nPoint - 1</code> line segments are | |||
* drawn between sequential points | |||
* drawn between sequential points | |||
* (<code>xPoints[i],yPoints[i],xPoints[i+1],yPoints[i+1]</code>). | |||
* The final line segment is a closing one, from the last point to | |||
* The final line segment is a closing one, from the last point to | |||
* the first (assuming they are different). | |||
* <p> | |||
* The area inside of the polygon is defined by using an | |||
* even-odd fill rule (also known as the alternating rule), and | |||
* even-odd fill rule (also known as the alternating rule), and | |||
* the area inside of it is filled. | |||
* @param xPoints array of the <code>x</code> coordinates. | |||
* @param yPoints array of the <code>y</code> coordinates. | |||
@@ -454,7 +454,7 @@ public class EscherGraphics | |||
public void setClip(int x, int y, int width, int height) | |||
{ | |||
setClip(((Shape) (new Rectangle(x,y,width,height)))); | |||
setClip(new Rectangle(x,y,width,height)); | |||
} | |||
public void setClip(Shape shape) |
@@ -70,14 +70,13 @@ import java.util.Map; | |||
* | |||
* @author Glen Stampoultzis (glens at apache.org) | |||
*/ | |||
public class EscherGraphics2d extends Graphics2D | |||
{ | |||
private EscherGraphics escherGraphics; | |||
private BufferedImage img; | |||
private AffineTransform trans; | |||
private Stroke stroke; | |||
private Paint paint; | |||
private Shape deviceclip; | |||
public final class EscherGraphics2d extends Graphics2D { | |||
private EscherGraphics _escherGraphics; | |||
private BufferedImage _img; | |||
private AffineTransform _trans; | |||
private Stroke _stroke; | |||
private Paint _paint; | |||
private Shape _deviceclip; | |||
private POILogger logger = POILogFactory.getLogger(getClass()); | |||
/** | |||
@@ -87,7 +86,7 @@ public class EscherGraphics2d extends Graphics2D | |||
*/ | |||
public EscherGraphics2d(EscherGraphics escherGraphics) | |||
{ | |||
this.escherGraphics = escherGraphics; | |||
this._escherGraphics = escherGraphics; | |||
setImg( new BufferedImage(1, 1, 2) ); | |||
setColor(Color.black); | |||
} | |||
@@ -130,7 +129,7 @@ public class EscherGraphics2d extends Graphics2D | |||
public Graphics create() | |||
{ | |||
EscherGraphics2d g2d = new EscherGraphics2d(escherGraphics); | |||
EscherGraphics2d g2d = new EscherGraphics2d(_escherGraphics); | |||
return g2d; | |||
} | |||
@@ -148,8 +147,8 @@ public class EscherGraphics2d extends Graphics2D | |||
Line2D shape2d = (Line2D) shape; | |||
int width = 0; | |||
if (stroke != null && stroke instanceof BasicStroke) { | |||
width = (int) ((BasicStroke)stroke).getLineWidth() * 12700; | |||
if (_stroke != null && _stroke instanceof BasicStroke) { | |||
width = (int) ((BasicStroke)_stroke).getLineWidth() * 12700; | |||
} | |||
drawLine((int)shape2d.getX1(), (int)shape2d.getY1(), (int)shape2d.getX2(), (int)shape2d.getY2(), width); | |||
@@ -223,7 +222,7 @@ public class EscherGraphics2d extends Graphics2D | |||
public void drawImage(BufferedImage bufferedimage, BufferedImageOp op, int x, int y) | |||
{ | |||
BufferedImage img = op.filter(bufferedimage, null); | |||
drawImage(((Image) (img)), new AffineTransform(1.0F, 0.0F, 0.0F, 1.0F, x, y), null); | |||
drawImage(img, new AffineTransform(1.0F, 0.0F, 0.0F, 1.0F, x, y), null); | |||
} | |||
public void drawLine(int x1, int y1, int x2, int y2, int width) | |||
@@ -234,8 +233,8 @@ public class EscherGraphics2d extends Graphics2D | |||
public void drawLine(int x1, int y1, int x2, int y2) | |||
{ | |||
int width = 0; | |||
if (stroke != null && stroke instanceof BasicStroke) { | |||
width = (int) ((BasicStroke)stroke).getLineWidth() * 12700; | |||
if (_stroke != null && _stroke instanceof BasicStroke) { | |||
width = (int) ((BasicStroke)_stroke).getLineWidth() * 12700; | |||
} | |||
getEscherGraphics().drawLine(x1,y1,x2,y2, width); | |||
// draw(new GeneralPath(new java.awt.geom.Line2D.Float(x1, y1, x2, y2))); | |||
@@ -268,7 +267,7 @@ public class EscherGraphics2d extends Graphics2D | |||
public void drawRect(int x, int y, int width, int height) | |||
{ | |||
escherGraphics.drawRect(x,y,width,height); | |||
_escherGraphics.drawRect(x,y,width,height); | |||
} | |||
public void drawRenderableImage(RenderableImage renderableimage, AffineTransform affinetransform) | |||
@@ -325,7 +324,7 @@ public class EscherGraphics2d extends Graphics2D | |||
public void fillOval(int x, int y, int width, int height) | |||
{ | |||
escherGraphics.fillOval(x,y,width,height); | |||
_escherGraphics.fillOval(x,y,width,height); | |||
} | |||
/** | |||
@@ -334,13 +333,13 @@ public class EscherGraphics2d extends Graphics2D | |||
* <p> | |||
* This draws the polygon, with <code>nPoint</code> line segments. | |||
* The first <code>nPoint - 1</code> line segments are | |||
* drawn between sequential points | |||
* drawn between sequential points | |||
* (<code>xPoints[i],yPoints[i],xPoints[i+1],yPoints[i+1]</code>). | |||
* The final line segment is a closing one, from the last point to | |||
* The final line segment is a closing one, from the last point to | |||
* the first (assuming they are different). | |||
* <p> | |||
* The area inside of the polygon is defined by using an | |||
* even-odd fill rule (also known as the alternating rule), and | |||
* even-odd fill rule (also known as the alternating rule), and | |||
* the area inside of it is filled. | |||
* @param xPoints array of the <code>x</code> coordinates. | |||
* @param yPoints array of the <code>y</code> coordinates. | |||
@@ -349,7 +348,7 @@ public class EscherGraphics2d extends Graphics2D | |||
*/ | |||
public void fillPolygon(int xPoints[], int yPoints[], int nPoints) | |||
{ | |||
escherGraphics.fillPolygon(xPoints, yPoints, nPoints); | |||
_escherGraphics.fillPolygon(xPoints, yPoints, nPoints); | |||
} | |||
public void fillRect(int x, int y, int width, int height) | |||
@@ -382,15 +381,15 @@ public class EscherGraphics2d extends Graphics2D | |||
public Rectangle getClipBounds() | |||
{ | |||
if(getDeviceclip() != null) | |||
if(getDeviceclip() != null) { | |||
return getClip().getBounds(); | |||
else | |||
return null; | |||
} | |||
return null; | |||
} | |||
public Color getColor() | |||
{ | |||
return escherGraphics.getColor(); | |||
return _escherGraphics.getColor(); | |||
} | |||
public Composite getComposite() | |||
@@ -421,7 +420,7 @@ public class EscherGraphics2d extends Graphics2D | |||
public Paint getPaint() | |||
{ | |||
return paint; | |||
return _paint; | |||
} | |||
public Object getRenderingHint(java.awt.RenderingHints.Key key) | |||
@@ -436,7 +435,7 @@ public class EscherGraphics2d extends Graphics2D | |||
public Stroke getStroke() | |||
{ | |||
return stroke; | |||
return _stroke; | |||
} | |||
public AffineTransform getTransform() | |||
@@ -474,7 +473,7 @@ public class EscherGraphics2d extends Graphics2D | |||
public void setClip(int i, int j, int k, int l) | |||
{ | |||
setClip(((Shape) (new Rectangle(i, j, k, l)))); | |||
setClip(new Rectangle(i, j, k, l)); | |||
} | |||
public void setClip(Shape shape) | |||
@@ -484,7 +483,7 @@ public class EscherGraphics2d extends Graphics2D | |||
public void setColor(Color c) | |||
{ | |||
escherGraphics.setColor(c); | |||
_escherGraphics.setColor(c); | |||
} | |||
public void setComposite(Composite composite) | |||
@@ -501,7 +500,7 @@ public class EscherGraphics2d extends Graphics2D | |||
{ | |||
if(paint1 != null) | |||
{ | |||
paint = paint1; | |||
_paint = paint1; | |||
if(paint1 instanceof Color) | |||
setColor( (Color)paint1 ); | |||
} | |||
@@ -524,7 +523,7 @@ public class EscherGraphics2d extends Graphics2D | |||
public void setStroke(Stroke s) | |||
{ | |||
stroke = s; | |||
_stroke = s; | |||
} | |||
public void setTransform(AffineTransform affinetransform) | |||
@@ -571,42 +570,42 @@ public class EscherGraphics2d extends Graphics2D | |||
private EscherGraphics getEscherGraphics() | |||
{ | |||
return escherGraphics; | |||
return _escherGraphics; | |||
} | |||
private BufferedImage getImg() | |||
{ | |||
return img; | |||
return _img; | |||
} | |||
private void setImg( BufferedImage img ) | |||
{ | |||
this.img = img; | |||
this._img = img; | |||
} | |||
private Graphics2D getG2D() | |||
{ | |||
return (Graphics2D) img.getGraphics(); | |||
return (Graphics2D) _img.getGraphics(); | |||
} | |||
private AffineTransform getTrans() | |||
{ | |||
return trans; | |||
return _trans; | |||
} | |||
private void setTrans( AffineTransform trans ) | |||
{ | |||
this.trans = trans; | |||
this._trans = trans; | |||
} | |||
private Shape getDeviceclip() | |||
{ | |||
return deviceclip; | |||
return _deviceclip; | |||
} | |||
private void setDeviceclip( Shape deviceclip ) | |||
{ | |||
this.deviceclip = deviceclip; | |||
this._deviceclip = deviceclip; | |||
} | |||
} |
@@ -28,15 +28,14 @@ import org.apache.poi.hssf.util.HSSFColor; | |||
* | |||
* @author Brian Sanders (bsanders at risklabs dot com) | |||
*/ | |||
public class HSSFPalette | |||
{ | |||
private PaletteRecord palette; | |||
public final class HSSFPalette { | |||
private PaletteRecord _palette; | |||
protected HSSFPalette(PaletteRecord palette) | |||
{ | |||
this.palette = palette; | |||
_palette = palette; | |||
} | |||
/** | |||
* Retrieves the color at a given index | |||
* | |||
@@ -45,16 +44,15 @@ public class HSSFPalette | |||
*/ | |||
public HSSFColor getColor(short index) | |||
{ | |||
//Handle the special AUTOMATIC case | |||
if (index == HSSFColor.AUTOMATIC.index) | |||
return HSSFColor.AUTOMATIC.getInstance(); | |||
else { | |||
byte[] b = palette.getColor(index); | |||
//Handle the special AUTOMATIC case | |||
if (index == HSSFColor.AUTOMATIC.index) { | |||
return HSSFColor.AUTOMATIC.getInstance(); | |||
} | |||
byte[] b = _palette.getColor(index); | |||
if (b != null) | |||
{ | |||
return new CustomColor(index, b); | |||
} | |||
} | |||
return null; | |||
} | |||
/** | |||
@@ -66,7 +64,7 @@ public class HSSFPalette | |||
public HSSFColor getColor(int index) { | |||
return getColor((short)index); | |||
} | |||
/** | |||
* Finds the first occurance of a given color | |||
* | |||
@@ -77,9 +75,9 @@ public class HSSFPalette | |||
*/ | |||
public HSSFColor findColor(byte red, byte green, byte blue) | |||
{ | |||
byte[] b = palette.getColor(PaletteRecord.FIRST_COLOR_INDEX); | |||
for (short i = (short) PaletteRecord.FIRST_COLOR_INDEX; b != null; | |||
b = palette.getColor(++i)) | |||
byte[] b = _palette.getColor(PaletteRecord.FIRST_COLOR_INDEX); | |||
for (short i = PaletteRecord.FIRST_COLOR_INDEX; b != null; | |||
b = _palette.getColor(++i)) | |||
{ | |||
if (b[0] == red && b[1] == green && b[2] == blue) | |||
{ | |||
@@ -104,11 +102,11 @@ public class HSSFPalette | |||
{ | |||
HSSFColor result = null; | |||
int minColorDistance = Integer.MAX_VALUE; | |||
byte[] b = palette.getColor(PaletteRecord.FIRST_COLOR_INDEX); | |||
for (short i = (short) PaletteRecord.FIRST_COLOR_INDEX; b != null; | |||
b = palette.getColor(++i)) | |||
byte[] b = _palette.getColor(PaletteRecord.FIRST_COLOR_INDEX); | |||
for (short i = PaletteRecord.FIRST_COLOR_INDEX; b != null; | |||
b = _palette.getColor(++i)) | |||
{ | |||
int colorDistance = Math.abs(red - b[0]) + | |||
int colorDistance = Math.abs(red - b[0]) + | |||
Math.abs(green - b[1]) + Math.abs(blue - b[2]); | |||
if (colorDistance < minColorDistance) | |||
{ | |||
@@ -129,7 +127,7 @@ public class HSSFPalette | |||
*/ | |||
public void setColorAtIndex(short index, byte red, byte green, byte blue) | |||
{ | |||
palette.setColor(index, red, green, blue); | |||
_palette.setColor(index, red, green, blue); | |||
} | |||
/** | |||
@@ -144,9 +142,9 @@ public class HSSFPalette | |||
*/ | |||
public HSSFColor addColor( byte red, byte green, byte blue ) | |||
{ | |||
byte[] b = palette.getColor(PaletteRecord.FIRST_COLOR_INDEX); | |||
byte[] b = _palette.getColor(PaletteRecord.FIRST_COLOR_INDEX); | |||
short i; | |||
for (i = (short) PaletteRecord.FIRST_COLOR_INDEX; i < PaletteRecord.STANDARD_PALETTE_SIZE + PaletteRecord.FIRST_COLOR_INDEX; b = palette.getColor(++i)) | |||
for (i = PaletteRecord.FIRST_COLOR_INDEX; i < PaletteRecord.STANDARD_PALETTE_SIZE + PaletteRecord.FIRST_COLOR_INDEX; b = _palette.getColor(++i)) | |||
{ | |||
if (b == null) | |||
{ | |||
@@ -157,52 +155,51 @@ public class HSSFPalette | |||
throw new RuntimeException("Could not find free color index"); | |||
} | |||
private static class CustomColor extends HSSFColor | |||
{ | |||
private short byteOffset; | |||
private byte red; | |||
private byte green; | |||
private byte blue; | |||
private CustomColor(short byteOffset, byte[] colors) | |||
private static final class CustomColor extends HSSFColor { | |||
private short _byteOffset; | |||
private byte _red; | |||
private byte _green; | |||
private byte _blue; | |||
public CustomColor(short byteOffset, byte[] colors) | |||
{ | |||
this(byteOffset, colors[0], colors[1], colors[2]); | |||
} | |||
private CustomColor(short byteOffset, byte red, byte green, byte blue) | |||
{ | |||
this.byteOffset = byteOffset; | |||
this.red = red; | |||
this.green = green; | |||
this.blue = blue; | |||
_byteOffset = byteOffset; | |||
_red = red; | |||
_green = green; | |||
_blue = blue; | |||
} | |||
public short getIndex() | |||
{ | |||
return byteOffset; | |||
return _byteOffset; | |||
} | |||
public short[] getTriplet() | |||
{ | |||
return new short[] | |||
{ | |||
(short) (red & 0xff), | |||
(short) (green & 0xff), | |||
(short) (blue & 0xff) | |||
(short) (_red & 0xff), | |||
(short) (_green & 0xff), | |||
(short) (_blue & 0xff) | |||
}; | |||
} | |||
public String getHexString() | |||
{ | |||
StringBuffer sb = new StringBuffer(); | |||
sb.append(getGnumericPart(red)); | |||
sb.append(getGnumericPart(_red)); | |||
sb.append(':'); | |||
sb.append(getGnumericPart(green)); | |||
sb.append(getGnumericPart(_green)); | |||
sb.append(':'); | |||
sb.append(getGnumericPart(blue)); | |||
sb.append(getGnumericPart(_blue)); | |||
return sb.toString(); | |||
} | |||
private String getGnumericPart(byte color) | |||
{ | |||
String s; |
@@ -524,9 +524,9 @@ public class HSSFWorkbook extends POIDocument implements org.apache.poi.ss.userm | |||
* Sets the sheet name. | |||
* Will throw IllegalArgumentException if the name is duplicated or contains /\?*[] | |||
* Note - Excel allows sheet names up to 31 chars in length but other applications allow more. | |||
* Excel does not crash with names longer than 31 chars, but silently truncates such names to | |||
* Excel does not crash with names longer than 31 chars, but silently truncates such names to | |||
* 31 chars. POI enforces uniqueness on the first 31 chars. | |||
* | |||
* | |||
* @param sheetIx number (0 based) | |||
*/ | |||
public void setSheetName(int sheetIx, String name) { | |||
@@ -552,7 +552,7 @@ public class HSSFWorkbook extends POIDocument implements org.apache.poi.ss.userm | |||
public void setHidden(boolean hiddenFlag) { | |||
workbook.getWindowOne().setHidden(hiddenFlag); | |||
} | |||
public boolean isSheetHidden(int sheetIx) { | |||
validateSheetIndex(sheetIx); | |||
return workbook.isSheetHidden(sheetIx); | |||
@@ -618,7 +618,7 @@ public class HSSFWorkbook extends POIDocument implements org.apache.poi.ss.userm | |||
/** | |||
* @deprecated for POI internal use only (formula rendering). This method is likely to | |||
* be removed in future versions of POI. | |||
* | |||
* | |||
* @param refIndex Index to REF entry in EXTERNSHEET record in the Link Table | |||
* @param definedNameIndex zero-based to DEFINEDNAME or EXTERNALNAME record | |||
* @return the string representation of the defined or external name | |||
@@ -665,10 +665,10 @@ public class HSSFWorkbook extends POIDocument implements org.apache.poi.ss.userm | |||
clonedSheet.setActive(false); | |||
String name = getUniqueSheetName(srcName); | |||
int newSheetIndex = _sheets.size(); | |||
int newSheetIndex = _sheets.size(); | |||
_sheets.add(clonedSheet); | |||
workbook.setSheetName(newSheetIndex, name); | |||
// Check this sheet has an autofilter, (which has a built-in NameRecord at workbook level) | |||
int filterDbNameIndex = findExistingBuiltinNameRecordIdx(sheetIndex, NameRecord.BUILTIN_FILTER_DB); | |||
if (filterDbNameIndex >=0) { | |||
@@ -679,7 +679,7 @@ public class HSSFWorkbook extends POIDocument implements org.apache.poi.ss.userm | |||
for (int i=0; i< ptgs.length; i++) { | |||
Ptg ptg = ptgs[i]; | |||
ptg = ptg.copy(); | |||
if (ptg instanceof Area3DPtg) { | |||
Area3DPtg a3p = (Area3DPtg) ptg; | |||
a3p.setExternSheetIndex(newExtSheetIx); | |||
@@ -698,7 +698,7 @@ public class HSSFWorkbook extends POIDocument implements org.apache.poi.ss.userm | |||
workbook.cloneDrawings(clonedSheet.getSheet()); | |||
} | |||
// TODO - maybe same logic required for other/all built-in name records | |||
return clonedSheet; | |||
} | |||
@@ -966,12 +966,12 @@ public class HSSFWorkbook extends POIDocument implements org.apache.poi.ss.userm | |||
temp.add(new MemFuncPtg(exprsSize)); | |||
} | |||
if (startColumn >= 0) { | |||
Area3DPtg colArea = new Area3DPtg(0, MAX_ROW, startColumn, endColumn, | |||
Area3DPtg colArea = new Area3DPtg(0, MAX_ROW, startColumn, endColumn, | |||
false, false, false, false, externSheetIndex); | |||
temp.add(colArea); | |||
} | |||
if (startRow >= 0) { | |||
Area3DPtg rowArea = new Area3DPtg(startRow, endRow, 0, MAX_COLUMN, | |||
Area3DPtg rowArea = new Area3DPtg(startRow, endRow, 0, MAX_COLUMN, | |||
false, false, false, false, externSheetIndex); | |||
temp.add(rowArea); | |||
} | |||
@@ -1136,7 +1136,7 @@ public class HSSFWorkbook extends POIDocument implements org.apache.poi.ss.userm | |||
*/ | |||
public HSSFCellStyle getCellStyleAt(short idx) | |||
{ | |||
ExtendedFormatRecord xfr = workbook.getExFormatAt((int)idx); | |||
ExtendedFormatRecord xfr = workbook.getExFormatAt(idx); | |||
HSSFCellStyle style = new HSSFCellStyle(idx, xfr, this); | |||
return style; | |||
@@ -1296,7 +1296,7 @@ public class HSSFWorkbook extends POIDocument implements org.apache.poi.ss.userm | |||
int result = names.size(); | |||
return result; | |||
} | |||
public HSSFName getName(String name) { | |||
int nameIndex = getNameIndex(name); | |||
if (nameIndex < 0) { | |||
@@ -1311,7 +1311,7 @@ public class HSSFWorkbook extends POIDocument implements org.apache.poi.ss.userm | |||
throw new IllegalStateException("There are no defined names in this workbook"); | |||
} | |||
if (nameIndex < 0 || nameIndex > nNames) { | |||
throw new IllegalArgumentException("Specified name index " + nameIndex | |||
throw new IllegalArgumentException("Specified name index " + nameIndex | |||
+ " is outside the allowable range (0.." + (nNames-1) + ")."); | |||
} | |||
return (HSSFName) names.get(nameIndex); | |||
@@ -1394,7 +1394,7 @@ public class HSSFWorkbook extends POIDocument implements org.apache.poi.ss.userm | |||
if (name == null) { | |||
return null; | |||
} | |||
return HSSFFormulaParser.toFormulaString(this, name.getNameDefinition()); | |||
} | |||
@@ -1684,7 +1684,7 @@ public class HSSFWorkbook extends POIDocument implements org.apache.poi.ss.userm | |||
} | |||
} | |||
} | |||
public CreationHelper getCreationHelper() { | |||
return new HSSFCreationHelper(this); | |||
} |
@@ -27,19 +27,16 @@ package org.apache.poi.hssf.util; | |||
* @see org.apache.poi.hssf.record.MulRKRecord | |||
* @see org.apache.poi.hssf.record.RKRecord | |||
*/ | |||
public class RKUtil | |||
{ | |||
private RKUtil() | |||
{ | |||
public final class RKUtil { | |||
private RKUtil() { | |||
// no instances of this class | |||
} | |||
/** | |||
* Do the dirty work of decoding; made a private static method to | |||
* facilitate testing the algorithm | |||
*/ | |||
public static double decodeNumber(int number) | |||
{ | |||
public static double decodeNumber(int number) { | |||
long raw_number = number; | |||
// mask off the two low-order bits, 'cause they're not part of | |||
@@ -51,7 +48,7 @@ public class RKUtil | |||
{ | |||
// ok, it's just a plain ol' int; we can handle this | |||
// trivially by casting | |||
rvalue = ( double ) (raw_number); | |||
rvalue = raw_number; | |||
} | |||
else | |||
{ | |||
@@ -72,5 +69,4 @@ public class RKUtil | |||
return rvalue; | |||
} | |||
} |
@@ -72,7 +72,7 @@ public final class POIFSDocument implements BATManaged, BlockWritable, POIFSView | |||
private static DocumentBlock[] convertRawBlocksToBigBlocks(ListManagedBlock[] blocks) throws IOException { | |||
DocumentBlock[] result = new DocumentBlock[blocks.length]; | |||
for (int i = 0; i < result.length; i++) { | |||
result[i] = new DocumentBlock((RawDataBlock)blocks[i]); | |||
result[i] = new DocumentBlock((RawDataBlock)blocks[i]); | |||
} | |||
return result; | |||
} | |||
@@ -127,7 +127,7 @@ public final class POIFSDocument implements BATManaged, BlockWritable, POIFSView | |||
* @param stream the InputStream we read data from | |||
*/ | |||
public POIFSDocument(String name, InputStream stream) throws IOException { | |||
List blocks = new ArrayList(); | |||
List<DocumentBlock> blocks = new ArrayList<DocumentBlock>(); | |||
_size = 0; | |||
while (true) { | |||
@@ -142,7 +142,7 @@ public final class POIFSDocument implements BATManaged, BlockWritable, POIFSView | |||
break; | |||
} | |||
} | |||
DocumentBlock[] bigBlocks = (DocumentBlock[]) blocks.toArray(new DocumentBlock[blocks.size()]); | |||
DocumentBlock[] bigBlocks = blocks.toArray(new DocumentBlock[blocks.size()]); | |||
_big_store = new BigBlockStore(bigBlocks); | |||
_property = new DocumentProperty(name, _size); | |||
@@ -201,7 +201,7 @@ public final class POIFSDocument implements BATManaged, BlockWritable, POIFSView | |||
int len = buffer.length; | |||
DataInputBlock currentBlock = getDataInputBlock(offset); | |||
int blockAvailable = currentBlock.available(); | |||
if (blockAvailable > len) { | |||
currentBlock.readFully(buffer, 0, len); | |||
@@ -249,9 +249,8 @@ public final class POIFSDocument implements BATManaged, BlockWritable, POIFSView | |||
} | |||
if (_property.shouldUseSmallBlocks()) { | |||
return SmallDocumentBlock.getDataInputBlock(_small_store.getBlocks(), offset); | |||
} else { | |||
return DocumentBlock.getDataInputBlock(_big_store.getBlocks(), offset); | |||
} | |||
return DocumentBlock.getDataInputBlock(_big_store.getBlocks(), offset); | |||
} | |||
/** | |||
@@ -377,11 +376,11 @@ public final class POIFSDocument implements BATManaged, BlockWritable, POIFSView | |||
/* ********** END begin implementation of POIFSViewable ********** */ | |||
private static final class SmallBlockStore { | |||
private SmallDocumentBlock[] smallBlocks; | |||
private final POIFSDocumentPath path; | |||
private final String name; | |||
private final int size; | |||
private final POIFSWriterListener writer; | |||
private SmallDocumentBlock[] _smallBlocks; | |||
private final POIFSDocumentPath _path; | |||
private final String _name; | |||
private final int _size; | |||
private final POIFSWriterListener _writer; | |||
/** | |||
* Constructor | |||
@@ -389,11 +388,11 @@ public final class POIFSDocument implements BATManaged, BlockWritable, POIFSView | |||
* @param blocks blocks to construct the store from | |||
*/ | |||
SmallBlockStore(SmallDocumentBlock[] blocks) { | |||
smallBlocks = (SmallDocumentBlock[]) blocks.clone(); | |||
this.path = null; | |||
this.name = null; | |||
this.size = -1; | |||
this.writer = null; | |||
_smallBlocks = blocks.clone(); | |||
this._path = null; | |||
this._name = null; | |||
this._size = -1; | |||
this._writer = null; | |||
} | |||
/** | |||
@@ -405,41 +404,41 @@ public final class POIFSDocument implements BATManaged, BlockWritable, POIFSView | |||
* @param writer the object that will eventually write the document | |||
*/ | |||
SmallBlockStore(POIFSDocumentPath path, String name, int size, POIFSWriterListener writer) { | |||
smallBlocks = new SmallDocumentBlock[0]; | |||
this.path = path; | |||
this.name = name; | |||
this.size = size; | |||
this.writer = writer; | |||
_smallBlocks = new SmallDocumentBlock[0]; | |||
this._path = path; | |||
this._name = name; | |||
this._size = size; | |||
this._writer = writer; | |||
} | |||
/** | |||
* @return <code>true</code> if this store is a valid source of data | |||
*/ | |||
boolean isValid() { | |||
return smallBlocks.length > 0 || writer != null; | |||
return _smallBlocks.length > 0 || _writer != null; | |||
} | |||
/** | |||
* @return the SmallDocumentBlocks | |||
*/ | |||
SmallDocumentBlock[] getBlocks() { | |||
if (isValid() && writer != null) { | |||
ByteArrayOutputStream stream = new ByteArrayOutputStream(size); | |||
DocumentOutputStream dstream = new DocumentOutputStream(stream, size); | |||
if (isValid() && _writer != null) { | |||
ByteArrayOutputStream stream = new ByteArrayOutputStream(_size); | |||
DocumentOutputStream dstream = new DocumentOutputStream(stream, _size); | |||
writer.processPOIFSWriterEvent(new POIFSWriterEvent(dstream, path, name, size)); | |||
smallBlocks = SmallDocumentBlock.convert(stream.toByteArray(), size); | |||
_writer.processPOIFSWriterEvent(new POIFSWriterEvent(dstream, _path, _name, _size)); | |||
_smallBlocks = SmallDocumentBlock.convert(stream.toByteArray(), _size); | |||
} | |||
return smallBlocks; | |||
return _smallBlocks; | |||
} | |||
} // end private class SmallBlockStore | |||
private static final class BigBlockStore { | |||
private DocumentBlock[] bigBlocks; | |||
private final POIFSDocumentPath path; | |||
private final String name; | |||
private final int size; | |||
private final POIFSWriterListener writer; | |||
private final POIFSDocumentPath _path; | |||
private final String _name; | |||
private final int _size; | |||
private final POIFSWriterListener _writer; | |||
/** | |||
* Constructor | |||
@@ -447,11 +446,11 @@ public final class POIFSDocument implements BATManaged, BlockWritable, POIFSView | |||
* @param blocks the blocks making up the store | |||
*/ | |||
BigBlockStore(DocumentBlock[] blocks) { | |||
bigBlocks = (DocumentBlock[]) blocks.clone(); | |||
this.path = null; | |||
this.name = null; | |||
this.size = -1; | |||
this.writer = null; | |||
bigBlocks = blocks.clone(); | |||
_path = null; | |||
_name = null; | |||
_size = -1; | |||
_writer = null; | |||
} | |||
/** | |||
@@ -464,29 +463,29 @@ public final class POIFSDocument implements BATManaged, BlockWritable, POIFSView | |||
*/ | |||
BigBlockStore(POIFSDocumentPath path, String name, int size, POIFSWriterListener writer) { | |||
bigBlocks = new DocumentBlock[0]; | |||
this.path = path; | |||
this.name = name; | |||
this.size = size; | |||
this.writer = writer; | |||
_path = path; | |||
_name = name; | |||
_size = size; | |||
_writer = writer; | |||
} | |||
/** | |||
* @return <code>true</code> if this store is a valid source of data | |||
*/ | |||
boolean isValid() { | |||
return bigBlocks.length > 0 || writer != null; | |||
return bigBlocks.length > 0 || _writer != null; | |||
} | |||
/** | |||
* @return the DocumentBlocks | |||
*/ | |||
DocumentBlock[] getBlocks() { | |||
if (isValid() && writer != null) { | |||
ByteArrayOutputStream stream = new ByteArrayOutputStream(size); | |||
DocumentOutputStream dstream = new DocumentOutputStream(stream, size); | |||
if (isValid() && _writer != null) { | |||
ByteArrayOutputStream stream = new ByteArrayOutputStream(_size); | |||
DocumentOutputStream dstream = new DocumentOutputStream(stream, _size); | |||
writer.processPOIFSWriterEvent(new POIFSWriterEvent(dstream, path, name, size)); | |||
bigBlocks = DocumentBlock.convert(stream.toByteArray(), size); | |||
_writer.processPOIFSWriterEvent(new POIFSWriterEvent(dstream, _path, _name, _size)); | |||
bigBlocks = DocumentBlock.convert(stream.toByteArray(), _size); | |||
} | |||
return bigBlocks; | |||
} | |||
@@ -498,10 +497,10 @@ public final class POIFSDocument implements BATManaged, BlockWritable, POIFSView | |||
*/ | |||
void writeBlocks(OutputStream stream) throws IOException { | |||
if (isValid()) { | |||
if (writer != null) { | |||
DocumentOutputStream dstream = new DocumentOutputStream(stream, size); | |||
if (_writer != null) { | |||
DocumentOutputStream dstream = new DocumentOutputStream(stream, _size); | |||
writer.processPOIFSWriterEvent(new POIFSWriterEvent(dstream, path, name, size)); | |||
_writer.processPOIFSWriterEvent(new POIFSWriterEvent(dstream, _path, _name, _size)); | |||
dstream.writeFiller(countBlocks() * POIFSConstants.BIG_BLOCK_SIZE, | |||
DocumentBlock.getFillByte()); | |||
} else { | |||
@@ -518,10 +517,10 @@ public final class POIFSDocument implements BATManaged, BlockWritable, POIFSView | |||
int countBlocks() { | |||
if (isValid()) { | |||
if (writer == null) { | |||
if (_writer == null) { | |||
return bigBlocks.length; | |||
} | |||
return (size + POIFSConstants.BIG_BLOCK_SIZE - 1) | |||
return (_size + POIFSConstants.BIG_BLOCK_SIZE - 1) | |||
/ POIFSConstants.BIG_BLOCK_SIZE; | |||
} | |||
return 0; |
@@ -15,7 +15,7 @@ | |||
See the License for the specific language governing permissions and | |||
limitations under the License. | |||
==================================================================== */ | |||
package org.apache.poi.poifs.property; | |||
@@ -39,9 +39,7 @@ import org.apache.poi.util.ShortField; | |||
* @author Marc Johnson (mjohnson at apache dot org) | |||
*/ | |||
public abstract class Property | |||
implements Child, POIFSViewable | |||
{ | |||
public abstract class Property implements Child, POIFSViewable { | |||
static final private byte _default_fill = ( byte ) 0x00; | |||
static final private int _name_size_offset = 0x40; | |||
static final private int _max_name_length = | |||
@@ -88,10 +86,6 @@ public abstract class Property | |||
private Child _next_child; | |||
private Child _previous_child; | |||
/** | |||
* Default constructor | |||
*/ | |||
protected Property() | |||
{ | |||
_raw_data = new byte[ POIFSConstants.PROPERTY_SIZE ]; | |||
@@ -129,8 +123,7 @@ public abstract class Property | |||
* @param array byte data | |||
* @param offset offset into byte data | |||
*/ | |||
protected Property(final int index, final byte [] array, final int offset) | |||
protected Property(int index, byte [] array, int offset) | |||
{ | |||
_raw_data = new byte[ POIFSConstants.PROPERTY_SIZE ]; | |||
System.arraycopy(array, offset, _raw_data, 0, | |||
@@ -187,8 +180,7 @@ public abstract class Property | |||
* @exception IOException on problems writing to the specified | |||
* stream. | |||
*/ | |||
public void writeData(final OutputStream stream) | |||
public void writeData(OutputStream stream) | |||
throws IOException | |||
{ | |||
stream.write(_raw_data); | |||
@@ -200,8 +192,7 @@ public abstract class Property | |||
* | |||
* @param startBlock the start block index | |||
*/ | |||
public void setStartBlock(final int startBlock) | |||
public void setStartBlock(int startBlock) | |||
{ | |||
_start_block.set(startBlock, _raw_data); | |||
} | |||
@@ -209,7 +200,6 @@ public abstract class Property | |||
/** | |||
* @return the start block | |||
*/ | |||
public int getStartBlock() | |||
{ | |||
return _start_block.get(); | |||
@@ -220,7 +210,6 @@ public abstract class Property | |||
* | |||
* @return size in bytes | |||
*/ | |||
public int getSize() | |||
{ | |||
return _size.get(); | |||
@@ -232,7 +221,6 @@ public abstract class Property | |||
* | |||
* @return true if the size is less than _big_block_minimum_bytes | |||
*/ | |||
public boolean shouldUseSmallBlocks() | |||
{ | |||
return Property.isSmall(_size.get()); | |||
@@ -246,8 +234,7 @@ public abstract class Property | |||
* @return true if the length is less than | |||
* _big_block_minimum_bytes | |||
*/ | |||
public static boolean isSmall(final int length) | |||
public static boolean isSmall(int length) | |||
{ | |||
return length < _big_block_minimum_bytes; | |||
} | |||
@@ -257,7 +244,6 @@ public abstract class Property | |||
* | |||
* @return property name as String | |||
*/ | |||
public String getName() | |||
{ | |||
return _name; | |||
@@ -266,7 +252,6 @@ public abstract class Property | |||
/** | |||
* @return true if a directory type Property | |||
*/ | |||
abstract public boolean isDirectory(); | |||
/** | |||
@@ -284,7 +269,7 @@ public abstract class Property | |||
* | |||
* @param name the new name | |||
*/ | |||
protected final void setName(final String name) | |||
protected void setName(String name) | |||
{ | |||
char[] char_array = name.toCharArray(); | |||
int limit = Math.min(char_array.length, _max_name_length); | |||
@@ -329,8 +314,7 @@ public abstract class Property | |||
* | |||
* @param propertyType the property type (root, file, directory) | |||
*/ | |||
protected void setPropertyType(final byte propertyType) | |||
protected void setPropertyType(byte propertyType) | |||
{ | |||
_property_type.set(propertyType, _raw_data); | |||
} | |||
@@ -340,8 +324,7 @@ public abstract class Property | |||
* | |||
* @param nodeColor the node color (red or black) | |||
*/ | |||
protected void setNodeColor(final byte nodeColor) | |||
protected void setNodeColor(byte nodeColor) | |||
{ | |||
_node_color.set(nodeColor, _raw_data); | |||
} | |||
@@ -351,8 +334,7 @@ public abstract class Property | |||
* | |||
* @param child the child property's index in the Property Table | |||
*/ | |||
protected void setChildProperty(final int child) | |||
protected void setChildProperty(int child) | |||
{ | |||
_child_property.set(child, _raw_data); | |||
} | |||
@@ -362,7 +344,6 @@ public abstract class Property | |||
* | |||
* @return child property index | |||
*/ | |||
protected int getChildIndex() | |||
{ | |||
return _child_property.get(); | |||
@@ -373,8 +354,7 @@ public abstract class Property | |||
* | |||
* @param size the size of the document, in bytes | |||
*/ | |||
protected void setSize(final int size) | |||
protected void setSize(int size) | |||
{ | |||
_size.set(size, _raw_data); | |||
} | |||
@@ -385,8 +365,7 @@ public abstract class Property | |||
* @param index this Property's index within its containing | |||
* Property Table | |||
*/ | |||
protected void setIndex(final int index) | |||
protected void setIndex(int index) | |||
{ | |||
_index = index; | |||
} | |||
@@ -396,7 +375,6 @@ public abstract class Property | |||
* | |||
* @return the index of this Property within its Property Table | |||
*/ | |||
protected int getIndex() | |||
{ | |||
return _index; | |||
@@ -406,7 +384,6 @@ public abstract class Property | |||
* Perform whatever activities need to be performed prior to | |||
* writing | |||
*/ | |||
abstract protected void preWrite(); | |||
/** | |||
@@ -414,7 +391,6 @@ public abstract class Property | |||
* | |||
* @return index of next sibling | |||
*/ | |||
int getNextChildIndex() | |||
{ | |||
return _next_property.get(); | |||
@@ -425,7 +401,6 @@ public abstract class Property | |||
* | |||
* @return index of previous sibling | |||
*/ | |||
int getPreviousChildIndex() | |||
{ | |||
return _previous_property.get(); | |||
@@ -438,20 +413,16 @@ public abstract class Property | |||
* | |||
* @return true if the index is valid | |||
*/ | |||
static boolean isValidIndex(int index) | |||
{ | |||
return index != _NO_INDEX; | |||
} | |||
/* ********** START implementation of Child ********** */ | |||
/** | |||
* Get the next Child, if any | |||
* | |||
* @return the next Child; may return null | |||
*/ | |||
public Child getNextChild() | |||
{ | |||
return _next_child; | |||
@@ -462,7 +433,6 @@ public abstract class Property | |||
* | |||
* @return the previous Child; may return null | |||
*/ | |||
public Child getPreviousChild() | |||
{ | |||
return _previous_child; | |||
@@ -474,8 +444,7 @@ public abstract class Property | |||
* @param child the new 'next' child; may be null, which has the | |||
* effect of saying there is no 'next' child | |||
*/ | |||
public void setNextChild(final Child child) | |||
public void setNextChild(Child child) | |||
{ | |||
_next_child = child; | |||
_next_property.set((child == null) ? _NO_INDEX | |||
@@ -489,8 +458,7 @@ public abstract class Property | |||
* @param child the new 'previous' child; may be null, which has | |||
* the effect of saying there is no 'previous' child | |||
*/ | |||
public void setPreviousChild(final Child child) | |||
public void setPreviousChild(Child child) | |||
{ | |||
_previous_child = child; | |||
_previous_property.set((child == null) ? _NO_INDEX | |||
@@ -498,16 +466,12 @@ public abstract class Property | |||
.getIndex(), _raw_data); | |||
} | |||
/* ********** END implementation of Child ********** */ | |||
/* ********** START begin implementation of POIFSViewable ********** */ | |||
/** | |||
* Get an array of objects, some of which may implement | |||
* POIFSViewable | |||
* | |||
* @return an array of Object; may not be null, but may be empty | |||
*/ | |||
public Object [] getViewableArray() | |||
{ | |||
Object[] results = new Object[ 5 ]; | |||
@@ -518,11 +482,11 @@ public abstract class Property | |||
long time = _days_1.get(); | |||
time <<= 32; | |||
time += (( long ) _seconds_1.get()) & 0x0000FFFFL; | |||
time += _seconds_1.get() & 0x0000FFFFL; | |||
results[ 3 ] = "Time 1 = " + time; | |||
time = _days_2.get(); | |||
time <<= 32; | |||
time += (( long ) _seconds_2.get()) & 0x0000FFFFL; | |||
time += _seconds_2.get() & 0x0000FFFFL; | |||
results[ 4 ] = "Time 2 = " + time; | |||
return results; | |||
} | |||
@@ -534,7 +498,6 @@ public abstract class Property | |||
* @return an Iterator; may not be null, but may have an empty | |||
* back end store | |||
*/ | |||
public Iterator getViewableIterator() | |||
{ | |||
return Collections.EMPTY_LIST.iterator(); | |||
@@ -547,7 +510,6 @@ public abstract class Property | |||
* @return true if a viewer should call getViewableArray, false if | |||
* a viewer should call getViewableIterator | |||
*/ | |||
public boolean preferArray() | |||
{ | |||
return true; | |||
@@ -559,7 +521,6 @@ public abstract class Property | |||
* | |||
* @return short description | |||
*/ | |||
public String getShortDescription() | |||
{ | |||
StringBuffer buffer = new StringBuffer(); | |||
@@ -567,7 +528,4 @@ public abstract class Property | |||
buffer.append("Property: \"").append(getName()).append("\""); | |||
return buffer.toString(); | |||
} | |||
/* ********** END begin implementation of POIFSViewable ********** */ | |||
} // end public abstract class Property | |||
} |
@@ -393,8 +393,7 @@ public final class WorkbookEvaluator { | |||
return fe.getFreeRefFunction().evaluate(ops, workbook, sheetIndex, srcRowNum, srcColNum); | |||
} | |||
} | |||
// TODO - fix return type of this evaluate method: | |||
return (ValueEval) operation.evaluate(ops, srcRowNum, (short)srcColNum); | |||
return operation.evaluate(ops, srcRowNum, (short)srcColNum); | |||
} | |||
private SheetRefEvaluator createExternSheetRefEvaluator(EvaluationTracker tracker, | |||
ExternSheetReferenceToken ptg) { |
@@ -26,197 +26,183 @@ package org.apache.poi.ss.util; | |||
* @author Andrew C. Oliver acoliver at apache dot org | |||
* @deprecated (Aug-2008) use {@link CellRangeAddress} | |||
*/ | |||
public class Region implements Comparable { | |||
private int rowFrom; | |||
private short colFrom; | |||
private int rowTo; | |||
private short colTo; | |||
/** | |||
* Creates a new instance of Region (0,0 - 0,0) | |||
*/ | |||
public Region() | |||
{ | |||
} | |||
public Region(int rowFrom, short colFrom, int rowTo, short colTo) | |||
{ | |||
this.rowFrom = rowFrom; | |||
this.rowTo = rowTo; | |||
this.colFrom = colFrom; | |||
this.colTo = colTo; | |||
} | |||
public Region(String ref) { | |||
CellReference cellReferenceFrom = new CellReference(ref.substring(0, ref.indexOf(":"))); | |||
CellReference cellReferenceTo = new CellReference(ref.substring(ref.indexOf(":") + 1)); | |||
this.rowFrom = cellReferenceFrom.getRow(); | |||
this.colFrom = (short) cellReferenceFrom.getCol(); | |||
this.rowTo = cellReferenceTo.getRow(); | |||
this.colTo = (short) cellReferenceTo.getCol(); | |||
public class Region implements Comparable<Region> { | |||
private int _rowFrom; | |||
private short _colFrom; | |||
private int _rowTo; | |||
private short _colTo; | |||
/** | |||
* Creates a new instance of Region (0,0 - 0,0) | |||
*/ | |||
public Region() | |||
{ | |||
} | |||
public Region(int rowFrom, short colFrom, int rowTo, short colTo) | |||
{ | |||
this._rowFrom = rowFrom; | |||
this._rowTo = rowTo; | |||
this._colFrom = colFrom; | |||
this._colTo = colTo; | |||
} | |||
public Region(String ref) { | |||
CellReference cellReferenceFrom = new CellReference(ref.substring(0, ref.indexOf(":"))); | |||
CellReference cellReferenceTo = new CellReference(ref.substring(ref.indexOf(":") + 1)); | |||
this._rowFrom = cellReferenceFrom.getRow(); | |||
this._colFrom = cellReferenceFrom.getCol(); | |||
this._rowTo = cellReferenceTo.getRow(); | |||
this._colTo = cellReferenceTo.getCol(); | |||
} | |||
/** | |||
* get the upper left hand corner column number | |||
* | |||
* @return column number for the upper left hand corner | |||
*/ | |||
public short getColumnFrom() | |||
{ | |||
return _colFrom; | |||
} | |||
/** | |||
* get the upper left hand corner row number | |||
* | |||
* @return row number for the upper left hand corner | |||
*/ | |||
public int getRowFrom() | |||
{ | |||
return _rowFrom; | |||
} | |||
/** | |||
* get the lower right hand corner column number | |||
* | |||
* @return column number for the lower right hand corner | |||
*/ | |||
public short getColumnTo() | |||
{ | |||
return _colTo; | |||
} | |||
/** | |||
* get the lower right hand corner row number | |||
* | |||
* @return row number for the lower right hand corner | |||
*/ | |||
public int getRowTo() | |||
{ | |||
return _rowTo; | |||
} | |||
/** | |||
* set the upper left hand corner column number | |||
* | |||
* @param colFrom column number for the upper left hand corner | |||
*/ | |||
public void setColumnFrom(short colFrom) | |||
{ | |||
this._colFrom = colFrom; | |||
} | |||
/** | |||
* set the upper left hand corner row number | |||
* | |||
* @param rowFrom row number for the upper left hand corner | |||
*/ | |||
public void setRowFrom(int rowFrom) | |||
{ | |||
this._rowFrom = rowFrom; | |||
} | |||
/** | |||
* set the lower right hand corner column number | |||
* | |||
* @param colTo column number for the lower right hand corner | |||
*/ | |||
/** | |||
* get the upper left hand corner column number | |||
* | |||
* @return column number for the upper left hand corner | |||
*/ | |||
public short getColumnFrom() | |||
{ | |||
return colFrom; | |||
} | |||
/** | |||
* get the upper left hand corner row number | |||
* | |||
* @return row number for the upper left hand corner | |||
*/ | |||
public int getRowFrom() | |||
{ | |||
return rowFrom; | |||
} | |||
/** | |||
* get the lower right hand corner column number | |||
* | |||
* @return column number for the lower right hand corner | |||
*/ | |||
public short getColumnTo() | |||
{ | |||
return colTo; | |||
} | |||
/** | |||
* get the lower right hand corner row number | |||
* | |||
* @return row number for the lower right hand corner | |||
*/ | |||
public int getRowTo() | |||
{ | |||
return rowTo; | |||
} | |||
/** | |||
* set the upper left hand corner column number | |||
* | |||
* @param colFrom column number for the upper left hand corner | |||
*/ | |||
public void setColumnFrom(short colFrom) | |||
{ | |||
this.colFrom = colFrom; | |||
} | |||
/** | |||
* set the upper left hand corner row number | |||
* | |||
* @param rowFrom row number for the upper left hand corner | |||
*/ | |||
public void setRowFrom(int rowFrom) | |||
{ | |||
this.rowFrom = rowFrom; | |||
} | |||
/** | |||
* set the lower right hand corner column number | |||
* | |||
* @param colTo column number for the lower right hand corner | |||
*/ | |||
public void setColumnTo(short colTo) | |||
{ | |||
this.colTo = colTo; | |||
} | |||
/** | |||
* get the lower right hand corner row number | |||
* | |||
* @param rowTo row number for the lower right hand corner | |||
*/ | |||
public void setRowTo(int rowTo) | |||
{ | |||
this.rowTo = rowTo; | |||
} | |||
/** | |||
* Answers: "is the row/column inside this range?" | |||
* | |||
* @return <code>true</code> if the cell is in the range and | |||
* <code>false</code> if it is not | |||
*/ | |||
public boolean contains(int row, short col) | |||
{ | |||
if ((this.rowFrom <= row) && (this.rowTo >= row) | |||
&& (this.colFrom <= col) && (this.colTo >= col)) | |||
{ | |||
// System.out.println("Region ("+rowFrom+","+colFrom+","+rowTo+","+ | |||
// colTo+") does contain "+row+","+col); | |||
return true; | |||
} | |||
return false; | |||
} | |||
public boolean equals(Region r) | |||
{ | |||
return (compareTo(r) == 0); | |||
} | |||
/** | |||
* Compares that the given region is the same less than or greater than this | |||
* region. If any regional coordiant passed in is less than this regions | |||
* coordinants then a positive integer is returned. Otherwise a negative | |||
* integer is returned. | |||
* | |||
* @param r region | |||
* @see #compareTo(Object) | |||
*/ | |||
public int compareTo(Region r) | |||
{ | |||
if ((this.getRowFrom() == r.getRowFrom()) | |||
&& (this.getColumnFrom() == r.getColumnFrom()) | |||
&& (this.getRowTo() == r.getRowTo()) | |||
&& (this.getColumnTo() == r.getColumnTo())) | |||
{ | |||
return 0; | |||
} | |||
if ((this.getRowFrom() < r.getRowFrom()) | |||
|| (this.getColumnFrom() < r.getColumnFrom()) | |||
|| (this.getRowTo() < r.getRowTo()) | |||
|| (this.getColumnTo() < r.getColumnTo())) | |||
{ | |||
return 1; | |||
} | |||
return -1; | |||
} | |||
public int compareTo(Object o) | |||
{ | |||
return compareTo(( Region ) o); | |||
} | |||
/** | |||
* @return the size of the region (number of cells in the area). | |||
*/ | |||
public int getArea() { | |||
return (rowTo - rowFrom + 1) * (colTo - colFrom + 1); | |||
} | |||
public void setColumnTo(short colTo) | |||
{ | |||
this._colTo = colTo; | |||
} | |||
/** | |||
* Convert a List of CellRange objects to an array of regions | |||
* | |||
* get the lower right hand corner row number | |||
* | |||
* @param rowTo row number for the lower right hand corner | |||
*/ | |||
public void setRowTo(int rowTo) | |||
{ | |||
this._rowTo = rowTo; | |||
} | |||
/** | |||
* Answers: "is the row/column inside this range?" | |||
* | |||
* @return <code>true</code> if the cell is in the range and | |||
* <code>false</code> if it is not | |||
*/ | |||
public boolean contains(int row, short col) | |||
{ | |||
if ((this._rowFrom <= row) && (this._rowTo >= row) | |||
&& (this._colFrom <= col) && (this._colTo >= col)) | |||
{ | |||
// System.out.println("Region ("+rowFrom+","+colFrom+","+rowTo+","+ | |||
// colTo+") does contain "+row+","+col); | |||
return true; | |||
} | |||
return false; | |||
} | |||
public boolean equals(Region r) | |||
{ | |||
return (compareTo(r) == 0); | |||
} | |||
/** | |||
* Compares that the given region is the same less than or greater than this | |||
* region. If any regional coordiant passed in is less than this regions | |||
* coordinants then a positive integer is returned. Otherwise a negative | |||
* integer is returned. | |||
* | |||
* @param r region | |||
* @see #compareTo(Object) | |||
*/ | |||
public int compareTo(Region r) | |||
{ | |||
if ((this.getRowFrom() == r.getRowFrom()) | |||
&& (this.getColumnFrom() == r.getColumnFrom()) | |||
&& (this.getRowTo() == r.getRowTo()) | |||
&& (this.getColumnTo() == r.getColumnTo())) | |||
{ | |||
return 0; | |||
} | |||
if ((this.getRowFrom() < r.getRowFrom()) | |||
|| (this.getColumnFrom() < r.getColumnFrom()) | |||
|| (this.getRowTo() < r.getRowTo()) | |||
|| (this.getColumnTo() < r.getColumnTo())) | |||
{ | |||
return 1; | |||
} | |||
return -1; | |||
} | |||
/** | |||
* @return the size of the region (number of cells in the area). | |||
*/ | |||
public int getArea() { | |||
return (_rowTo - _rowFrom + 1) * (_colTo - _colFrom + 1); | |||
} | |||
/** | |||
* Convert a List of CellRange objects to an array of regions | |||
* | |||
* @param cellRanges list of CellRange objects | |||
* @return regions | |||
*/ | |||
@@ -225,7 +211,7 @@ public class Region implements Comparable { | |||
if(size < 1) { | |||
return new Region[0]; | |||
} | |||
Region[] result = new Region[size]; | |||
for (int i = 0; i != size; i++) { | |||
@@ -235,9 +221,9 @@ public class Region implements Comparable { | |||
} | |||
private static Region convertToRegion(CellRangeAddress cr) { | |||
return new Region(cr.getFirstRow(), (short)cr.getFirstColumn(), cr.getLastRow(), (short)cr.getLastColumn()); | |||
} | |||
@@ -246,7 +232,7 @@ public class Region implements Comparable { | |||
if(size < 1) { | |||
return new CellRangeAddress[0]; | |||
} | |||
CellRangeAddress[] result = new CellRangeAddress[size]; | |||
for (int i = 0; i != size; i++) { | |||
@@ -259,13 +245,13 @@ public class Region implements Comparable { | |||
return new CellRangeAddress(r.getRowFrom(), r.getRowTo(), r.getColumnFrom(), r.getColumnTo()); | |||
} | |||
/** | |||
* @return the string reference for this region | |||
*/ | |||
public String getRegionRef() { | |||
CellReference cellRefFrom = new CellReference(rowFrom, colFrom); | |||
CellReference cellRefTo = new CellReference(rowTo, colTo); | |||
String ref = cellRefFrom.formatAsString() + ":" + cellRefTo.formatAsString(); | |||
/** | |||
* @return the string reference for this region | |||
*/ | |||
public String getRegionRef() { | |||
CellReference cellRefFrom = new CellReference(_rowFrom, _colFrom); | |||
CellReference cellRefTo = new CellReference(_rowTo, _colTo); | |||
String ref = cellRefFrom.formatAsString() + ":" + cellRefTo.formatAsString(); | |||
return ref; | |||
} | |||
} | |||
} |
@@ -1,4 +1,3 @@ | |||
/* ==================================================================== | |||
Licensed to the Apache Software Foundation (ASF) under one or more | |||
contributor license agreements. See the NOTICE file distributed with | |||
@@ -15,7 +14,6 @@ | |||
See the License for the specific language governing permissions and | |||
limitations under the License. | |||
==================================================================== */ | |||
package org.apache.poi.util; | |||
@@ -89,34 +87,20 @@ import java.util.*; | |||
* | |||
* @author Marc Johnson (mjohnson at apache dot org) | |||
*/ | |||
public final class BinaryTree // final for performance | |||
extends AbstractMap | |||
{ | |||
private Node[] _root = new Node[] | |||
{ | |||
null, null | |||
}; | |||
private int _size = 0; | |||
private int _modifications = 0; | |||
private Set[] _key_set = new Set[] | |||
{ | |||
null, null | |||
}; | |||
private Set[] _entry_set = new Set[] | |||
{ | |||
null, null | |||
}; | |||
private Collection[] _value_collection = new Collection[] | |||
{ | |||
null, null | |||
}; | |||
private static final int _KEY = 0; | |||
private static final int _VALUE = 1; | |||
private static final int _INDEX_SUM = _KEY + _VALUE; | |||
private static final int _MINIMUM_INDEX = 0; | |||
private static final int _INDEX_COUNT = 2; | |||
private static final String[] _data_name = new String[] | |||
//for performance | |||
public class BinaryTree extends AbstractMap { | |||
final Node[] _root; | |||
int _size = 0; | |||
int _modifications = 0; | |||
private final Set[] _key_set = new Set[] { null, null }; | |||
private final Set[] _entry_set = new Set[] { null, null }; | |||
private final Collection[] _value_collection = new Collection[] { null, null }; | |||
static int _KEY = 0; | |||
static int _VALUE = 1; | |||
private static int _INDEX_SUM = _KEY + _VALUE; | |||
private static int _MINIMUM_INDEX = 0; | |||
private static int _INDEX_COUNT = 2; | |||
private static String[] _data_name = new String[] | |||
{ | |||
"key", "value" | |||
}; | |||
@@ -124,9 +108,8 @@ public final class BinaryTree // final for performance | |||
/** | |||
* Construct a new BinaryTree | |||
*/ | |||
public BinaryTree() | |||
{ | |||
public BinaryTree() { | |||
_root = new Node[]{ null, null, }; | |||
} | |||
/** | |||
@@ -146,11 +129,11 @@ public final class BinaryTree // final for performance | |||
* or duplicate values in the | |||
* map | |||
*/ | |||
public BinaryTree(final Map map) | |||
public BinaryTree(Map map) | |||
throws ClassCastException, NullPointerException, | |||
IllegalArgumentException | |||
{ | |||
this(); | |||
putAll(map); | |||
} | |||
@@ -167,8 +150,7 @@ public final class BinaryTree // final for performance | |||
* inappropriate type for this map. | |||
* @exception NullPointerException if the value is null | |||
*/ | |||
public Object getKeyForValue(final Object value) | |||
public Object getKeyForValue(Object value) | |||
throws ClassCastException, NullPointerException | |||
{ | |||
return doGet(( Comparable ) value, _VALUE); | |||
@@ -182,8 +164,7 @@ public final class BinaryTree // final for performance | |||
* @return previous key associated with specified value, or null | |||
* if there was no mapping for value. | |||
*/ | |||
public Object removeValue(final Object value) | |||
public Object removeValue(Object value) | |||
{ | |||
return doRemove(( Comparable ) value, _VALUE); | |||
} | |||
@@ -207,7 +188,6 @@ public final class BinaryTree // final for performance | |||
* | |||
* @return a set view of the mappings contained in this map. | |||
*/ | |||
public Set entrySetByValue() | |||
{ | |||
if (_entry_set[ _VALUE ] == null) | |||
@@ -423,8 +403,7 @@ public final class BinaryTree // final for performance | |||
* key. null if the specified key or value could not be | |||
* found | |||
*/ | |||
private Object doRemove(final Comparable o, final int index) | |||
private Object doRemove(Comparable o, int index) | |||
{ | |||
Node node = lookup(o, index); | |||
Object rval = null; | |||
@@ -447,8 +426,7 @@ public final class BinaryTree // final for performance | |||
* key was mapped); null if we couldn't find the specified | |||
* object | |||
*/ | |||
private Object doGet(final Comparable o, final int index) | |||
private Object doGet(Comparable o, int index) | |||
{ | |||
checkNonNullComparable(o, index); | |||
Node node = lookup(o, index); | |||
@@ -464,8 +442,7 @@ public final class BinaryTree // final for performance | |||
* | |||
* @return _VALUE (if _KEY was specified), else _KEY | |||
*/ | |||
private int oppositeIndex(final int index) | |||
private int oppositeIndex(int index) | |||
{ | |||
// old trick ... to find the opposite of a value, m or n, | |||
@@ -483,8 +460,7 @@ public final class BinaryTree // final for performance | |||
* @return the desired Node, or null if there is no mapping of the | |||
* specified data | |||
*/ | |||
private Node lookup(final Comparable data, final int index) | |||
public Node lookup(Comparable data, int index) | |||
{ | |||
Node rval = null; | |||
Node node = _root[ index ]; | |||
@@ -498,11 +474,8 @@ public final class BinaryTree // final for performance | |||
rval = node; | |||
break; | |||
} | |||
else | |||
{ | |||
node = (cmp < 0) ? node.getLeft(index) | |||
: node.getRight(index); | |||
} | |||
node = (cmp < 0) ? node.getLeft(index) | |||
: node.getRight(index); | |||
} | |||
return rval; | |||
} | |||
@@ -516,10 +489,9 @@ public final class BinaryTree // final for performance | |||
* @return negative value if o1 < o2; 0 if o1 == o2; positive | |||
* value if o1 > o2 | |||
*/ | |||
private static int compare(final Comparable o1, final Comparable o2) | |||
private static int compare(Comparable o1, Comparable o2) | |||
{ | |||
return (( Comparable ) o1).compareTo(o2); | |||
return o1.compareTo(o2); | |||
} | |||
/** | |||
@@ -532,8 +504,7 @@ public final class BinaryTree // final for performance | |||
* @return the smallest node, from the specified node, in the | |||
* specified mapping | |||
*/ | |||
private static Node leastNode(final Node node, final int index) | |||
static Node leastNode(Node node, int index) | |||
{ | |||
Node rval = node; | |||
@@ -555,8 +526,7 @@ public final class BinaryTree // final for performance | |||
* | |||
* @return the specified node | |||
*/ | |||
private Node nextGreater(final Node node, final int index) | |||
static Node nextGreater(Node node, int index) | |||
{ | |||
Node rval = null; | |||
@@ -601,9 +571,7 @@ public final class BinaryTree // final for performance | |||
* @param to the node whose color we're changing; may be null | |||
* @param index _KEY or _VALUE | |||
*/ | |||
private static void copyColor(final Node from, final Node to, | |||
final int index) | |||
private static void copyColor(Node from, Node to, int index) | |||
{ | |||
if (to != null) | |||
{ | |||
@@ -627,11 +595,9 @@ public final class BinaryTree // final for performance | |||
* @param node the node (may be null) in question | |||
* @param index _KEY or _VALUE | |||
*/ | |||
private static boolean isRed(final Node node, final int index) | |||
private static boolean isRed(Node node, int index) | |||
{ | |||
return ((node == null) ? false | |||
: node.isRed(index)); | |||
return node == null ? false : node.isRed(index); | |||
} | |||
/** | |||
@@ -641,11 +607,9 @@ public final class BinaryTree // final for performance | |||
* @param node the node (may be null) in question | |||
* @param index _KEY or _VALUE | |||
*/ | |||
private static boolean isBlack(final Node node, final int index) | |||
private static boolean isBlack(Node node, int index) | |||
{ | |||
return ((node == null) ? true | |||
: node.isBlack(index)); | |||
return node == null ? true : node.isBlack(index); | |||
} | |||
/** | |||
@@ -654,8 +618,7 @@ public final class BinaryTree // final for performance | |||
* @param node the node (may be null) in question | |||
* @param index _KEY or _VALUE | |||
*/ | |||
private static void makeRed(final Node node, final int index) | |||
private static void makeRed(Node node, int index) | |||
{ | |||
if (node != null) | |||
{ | |||
@@ -669,8 +632,7 @@ public final class BinaryTree // final for performance | |||
* @param node the node (may be null) in question | |||
* @param index _KEY or _VALUE | |||
*/ | |||
private static void makeBlack(final Node node, final int index) | |||
private static void makeBlack(Node node, int index) | |||
{ | |||
if (node != null) | |||
{ | |||
@@ -685,8 +647,7 @@ public final class BinaryTree // final for performance | |||
* @param node the node (may be null) in question | |||
* @param index _KEY or _VALUE | |||
*/ | |||
private static Node getGrandParent(final Node node, final int index) | |||
private static Node getGrandParent(Node node, int index) | |||
{ | |||
return getParent(getParent(node, index), index); | |||
} | |||
@@ -698,8 +659,7 @@ public final class BinaryTree // final for performance | |||
* @param node the node (may be null) in question | |||
* @param index _KEY or _VALUE | |||
*/ | |||
private static Node getParent(final Node node, final int index) | |||
private static Node getParent(Node node, int index) | |||
{ | |||
return ((node == null) ? null | |||
: node.getParent(index)); | |||
@@ -712,8 +672,7 @@ public final class BinaryTree // final for performance | |||
* @param node the node (may be null) in question | |||
* @param index _KEY or _VALUE | |||
*/ | |||
private static Node getRightChild(final Node node, final int index) | |||
private static Node getRightChild(Node node, int index) | |||
{ | |||
return (node == null) ? null | |||
: node.getRight(index); | |||
@@ -726,8 +685,7 @@ public final class BinaryTree // final for performance | |||
* @param node the node (may be null) in question | |||
* @param index _KEY or _VALUE | |||
*/ | |||
private static Node getLeftChild(final Node node, final int index) | |||
private static Node getLeftChild(Node node, int index) | |||
{ | |||
return (node == null) ? null | |||
: node.getLeft(index); | |||
@@ -744,15 +702,14 @@ public final class BinaryTree // final for performance | |||
* @param node the node (may be null) in question | |||
* @param index _KEY or _VALUE | |||
*/ | |||
private static boolean isLeftChild(final Node node, final int index) | |||
{ | |||
return (node == null) ? true | |||
: ((node.getParent(index) == null) ? false | |||
: (node | |||
== node.getParent( | |||
index).getLeft( | |||
index))); | |||
private static boolean isLeftChild(Node node, int index) { | |||
if (node == null) { | |||
return true; | |||
} | |||
if (node.getParent(index) == null) { | |||
return false; | |||
} | |||
return node == node.getParent(index).getLeft(index); | |||
} | |||
/** | |||
@@ -766,15 +723,15 @@ public final class BinaryTree // final for performance | |||
* @param node the node (may be null) in question | |||
* @param index _KEY or _VALUE | |||
*/ | |||
private static boolean isRightChild(final Node node, final int index) | |||
private static boolean isRightChild(Node node, int index) | |||
{ | |||
return (node == null) ? true | |||
: ((node.getParent(index) == null) ? false | |||
: (node | |||
== node.getParent( | |||
index).getRight( | |||
index))); | |||
if (node == null) { | |||
return true; | |||
} | |||
if (node.getParent(index) == null) { | |||
return false; | |||
} | |||
return node == node.getParent(index).getRight(index); | |||
} | |||
/** | |||
@@ -783,8 +740,7 @@ public final class BinaryTree // final for performance | |||
* @param node the node to be rotated | |||
* @param index _KEY or _VALUE | |||
*/ | |||
private void rotateLeft(final Node node, final int index) | |||
private void rotateLeft(Node node, int index) | |||
{ | |||
Node right_child = node.getRight(index); | |||
@@ -818,8 +774,7 @@ public final class BinaryTree // final for performance | |||
* @param node the node to be rotated | |||
* @param index _KEY or _VALUE | |||
*/ | |||
private void rotateRight(final Node node, final int index) | |||
private void rotateRight(Node node, int index) | |||
{ | |||
Node left_child = node.getLeft(index); | |||
@@ -854,8 +809,7 @@ public final class BinaryTree // final for performance | |||
* @param inserted_node the node to be inserted | |||
* @param index _KEY or _VALUE | |||
*/ | |||
private void doRedBlackInsert(final Node inserted_node, final int index) | |||
private void doRedBlackInsert(Node inserted_node, int index) | |||
{ | |||
Node current_node = inserted_node; | |||
@@ -931,8 +885,7 @@ public final class BinaryTree // final for performance | |||
* | |||
* @param deleted_node the node to be deleted | |||
*/ | |||
private void doRedBlackDelete(final Node deleted_node) | |||
void doRedBlackDelete(Node deleted_node) | |||
{ | |||
for (int index = _MINIMUM_INDEX; index < _INDEX_COUNT; index++) | |||
{ | |||
@@ -1023,9 +976,8 @@ public final class BinaryTree // final for performance | |||
* @param replacement_node the node being replaced | |||
* @param index _KEY or _VALUE | |||
*/ | |||
private void doRedBlackDeleteFixup(final Node replacement_node, | |||
final int index) | |||
private void doRedBlackDeleteFixup(Node replacement_node, | |||
int index) | |||
{ | |||
Node current_node = replacement_node; | |||
@@ -1121,8 +1073,7 @@ public final class BinaryTree // final for performance | |||
* @param y another node | |||
* @param index _KEY or _VALUE | |||
*/ | |||
private void swapPosition(final Node x, final Node y, final int index) | |||
private void swapPosition(Node x, Node y, int index) | |||
{ | |||
// Save initial values. | |||
@@ -1244,9 +1195,8 @@ public final class BinaryTree // final for performance | |||
* @exception NullPointerException if o is null | |||
* @exception ClassCastException if o is not Comparable | |||
*/ | |||
private static void checkNonNullComparable(final Object o, | |||
final int index) | |||
private static void checkNonNullComparable(Object o, | |||
int index) | |||
{ | |||
if (o == null) | |||
{ | |||
@@ -1268,8 +1218,7 @@ public final class BinaryTree // final for performance | |||
* @exception NullPointerException if key is null | |||
* @exception ClassCastException if key is not Comparable | |||
*/ | |||
private static void checkKey(final Object key) | |||
private static void checkKey(Object key) | |||
{ | |||
checkNonNullComparable(key, _KEY); | |||
} | |||
@@ -1282,8 +1231,7 @@ public final class BinaryTree // final for performance | |||
* @exception NullPointerException if value is null | |||
* @exception ClassCastException if value is not Comparable | |||
*/ | |||
private static void checkValue(final Object value) | |||
private static void checkValue(Object value) | |||
{ | |||
checkNonNullComparable(value, _VALUE); | |||
} | |||
@@ -1298,8 +1246,7 @@ public final class BinaryTree // final for performance | |||
* @exception NullPointerException if key or value is null | |||
* @exception ClassCastException if key or value is not Comparable | |||
*/ | |||
private static void checkKeyAndValue(final Object key, final Object value) | |||
private static void checkKeyAndValue(Object key, Object value) | |||
{ | |||
checkKey(key); | |||
checkValue(value); | |||
@@ -1310,7 +1257,6 @@ public final class BinaryTree // final for performance | |||
* concurrent modification of the map through the map and through | |||
* an Iterator from one of its Set or Collection views | |||
*/ | |||
private void modify() | |||
{ | |||
_modifications++; | |||
@@ -1319,7 +1265,6 @@ public final class BinaryTree // final for performance | |||
/** | |||
* bump up the size and note that the map has changed | |||
*/ | |||
private void grow() | |||
{ | |||
modify(); | |||
@@ -1329,7 +1274,6 @@ public final class BinaryTree // final for performance | |||
/** | |||
* decrement the size and note that the map has changed | |||
*/ | |||
private void shrink() | |||
{ | |||
modify(); | |||
@@ -1344,8 +1288,7 @@ public final class BinaryTree // final for performance | |||
* @exception IllegalArgumentException if the node already exists | |||
* in the value mapping | |||
*/ | |||
private void insertValue(final Node newNode) | |||
private void insertValue(Node newNode) | |||
throws IllegalArgumentException | |||
{ | |||
Node node = _root[ _VALUE ]; | |||
@@ -1400,7 +1343,6 @@ public final class BinaryTree // final for performance | |||
* | |||
* @return the number of key-value mappings in this map. | |||
*/ | |||
public int size() | |||
{ | |||
return _size; | |||
@@ -1419,8 +1361,7 @@ public final class BinaryTree // final for performance | |||
* type for this map. | |||
* @exception NullPointerException if the key is null | |||
*/ | |||
public boolean containsKey(final Object key) | |||
public boolean containsKey(Object key) | |||
throws ClassCastException, NullPointerException | |||
{ | |||
checkKey(key); | |||
@@ -1436,8 +1377,7 @@ public final class BinaryTree // final for performance | |||
* @return true if this map maps one or more keys to the specified | |||
* value. | |||
*/ | |||
public boolean containsValue(final Object value) | |||
public boolean containsValue(Object value) | |||
{ | |||
checkValue(value); | |||
return lookup(( Comparable ) value, _VALUE) != null; | |||
@@ -1456,8 +1396,7 @@ public final class BinaryTree // final for performance | |||
* type for this map. | |||
* @exception NullPointerException if the key is null | |||
*/ | |||
public Object get(final Object key) | |||
public Object get(Object key) | |||
throws ClassCastException, NullPointerException | |||
{ | |||
return doGet(( Comparable ) key, _KEY); | |||
@@ -1483,8 +1422,7 @@ public final class BinaryTree // final for performance | |||
* value duplicates an | |||
* existing value | |||
*/ | |||
public Object put(final Object key, final Object value) | |||
public Object put(Object key, Object value) | |||
throws ClassCastException, NullPointerException, | |||
IllegalArgumentException | |||
{ | |||
@@ -1562,8 +1500,7 @@ public final class BinaryTree // final for performance | |||
* @return previous value associated with specified key, or null | |||
* if there was no mapping for key. | |||
*/ | |||
public Object remove(final Object key) | |||
public Object remove(Object key) | |||
{ | |||
return doRemove(( Comparable ) key, _KEY); | |||
} | |||
@@ -1571,7 +1508,6 @@ public final class BinaryTree // final for performance | |||
/** | |||
* Removes all mappings from this map | |||
*/ | |||
public void clear() | |||
{ | |||
modify(); | |||
@@ -1592,7 +1528,6 @@ public final class BinaryTree // final for performance | |||
* | |||
* @return a set view of the keys contained in this map. | |||
*/ | |||
public Set keySet() | |||
{ | |||
if (_key_set[ _KEY ] == null) | |||
@@ -1650,7 +1585,6 @@ public final class BinaryTree // final for performance | |||
* | |||
* @return a collection view of the values contained in this map. | |||
*/ | |||
public Collection values() | |||
{ | |||
if (_value_collection[ _KEY ] == null) | |||
@@ -1723,7 +1657,6 @@ public final class BinaryTree // final for performance | |||
* | |||
* @return a set view of the mappings contained in this map. | |||
*/ | |||
public Set entrySet() | |||
{ | |||
if (_entry_set[ _KEY ] == null) | |||
@@ -1803,8 +1736,7 @@ public final class BinaryTree // final for performance | |||
* | |||
* @param type | |||
*/ | |||
BinaryTreeIterator(final int type) | |||
BinaryTreeIterator(int type) | |||
{ | |||
_type = type; | |||
_expected_modifications = BinaryTree.this._modifications; | |||
@@ -1825,7 +1757,7 @@ public final class BinaryTree // final for performance | |||
* @return true if the iterator has more elements. | |||
*/ | |||
public final boolean hasNext() | |||
public boolean hasNext() | |||
{ | |||
return _next_node != null; | |||
} | |||
@@ -1842,7 +1774,7 @@ public final class BinaryTree // final for performance | |||
* back | |||
*/ | |||
public final Object next() | |||
public Object next() | |||
throws NoSuchElementException, ConcurrentModificationException | |||
{ | |||
if (_next_node == null) | |||
@@ -1878,7 +1810,7 @@ public final class BinaryTree // final for performance | |||
* back | |||
*/ | |||
public final void remove() | |||
public void remove() | |||
throws IllegalStateException, ConcurrentModificationException | |||
{ | |||
if (_last_returned_node == null) | |||
@@ -1897,7 +1829,7 @@ public final class BinaryTree // final for performance | |||
/* ********** END implementation of Iterator ********** */ | |||
} // end private abstract class BinaryTreeIterator | |||
// final for performance | |||
// for performance | |||
private static final class Node | |||
implements Map.Entry | |||
{ | |||
@@ -1917,7 +1849,7 @@ public final class BinaryTree // final for performance | |||
* @param value | |||
*/ | |||
Node(final Comparable key, final Comparable value) | |||
Node(Comparable key, Comparable value) | |||
{ | |||
_data = new Comparable[] | |||
{ | |||
@@ -1949,8 +1881,7 @@ public final class BinaryTree // final for performance | |||
* | |||
* @return the key or value | |||
*/ | |||
private Comparable getData(final int index) | |||
public Comparable getData(int index) | |||
{ | |||
return _data[ index ]; | |||
} | |||
@@ -1961,8 +1892,7 @@ public final class BinaryTree // final for performance | |||
* @param node the new left node | |||
* @param index _KEY or _VALUE | |||
*/ | |||
private void setLeft(final Node node, final int index) | |||
public void setLeft(Node node, int index) | |||
{ | |||
_left[ index ] = node; | |||
} | |||
@@ -1975,7 +1905,7 @@ public final class BinaryTree // final for performance | |||
* @return the left node -- may be null | |||
*/ | |||
private Node getLeft(final int index) | |||
public Node getLeft(int index) | |||
{ | |||
return _left[ index ]; | |||
} | |||
@@ -1986,8 +1916,7 @@ public final class BinaryTree // final for performance | |||
* @param node the new right node | |||
* @param index _KEY or _VALUE | |||
*/ | |||
private void setRight(final Node node, final int index) | |||
public void setRight(Node node, int index) | |||
{ | |||
_right[ index ] = node; | |||
} | |||
@@ -2000,7 +1929,7 @@ public final class BinaryTree // final for performance | |||
* @return the right node -- may be null | |||
*/ | |||
private Node getRight(final int index) | |||
public Node getRight(int index) | |||
{ | |||
return _right[ index ]; | |||
} | |||
@@ -2011,8 +1940,7 @@ public final class BinaryTree // final for performance | |||
* @param node the new parent node | |||
* @param index _KEY or _VALUE | |||
*/ | |||
private void setParent(final Node node, final int index) | |||
public void setParent(Node node, int index) | |||
{ | |||
_parent[ index ] = node; | |||
} | |||
@@ -2024,8 +1952,7 @@ public final class BinaryTree // final for performance | |||
* | |||
* @return the parent node -- may be null | |||
*/ | |||
private Node getParent(final int index) | |||
public Node getParent(int index) | |||
{ | |||
return _parent[ index ]; | |||
} | |||
@@ -2036,8 +1963,7 @@ public final class BinaryTree // final for performance | |||
* @param node the node to swap with | |||
* @param index _KEY or _VALUE | |||
*/ | |||
private void swapColors(final Node node, final int index) | |||
public void swapColors(Node node, int index) | |||
{ | |||
// Swap colors -- old hacker's trick | |||
@@ -2053,8 +1979,7 @@ public final class BinaryTree // final for performance | |||
* | |||
* @return true if black (which is represented as a true boolean) | |||
*/ | |||
private boolean isBlack(final int index) | |||
public boolean isBlack(int index) | |||
{ | |||
return _black[ index ]; | |||
} | |||
@@ -2066,8 +1991,7 @@ public final class BinaryTree // final for performance | |||
* | |||
* @return true if non-black | |||
*/ | |||
private boolean isRed(final int index) | |||
public boolean isRed(int index) | |||
{ | |||
return !_black[ index ]; | |||
} | |||
@@ -2077,8 +2001,7 @@ public final class BinaryTree // final for performance | |||
* | |||
* @param index _KEY or _VALUE | |||
*/ | |||
private void setBlack(final int index) | |||
public void setBlack(int index) | |||
{ | |||
_black[ index ] = true; | |||
} | |||
@@ -2088,8 +2011,7 @@ public final class BinaryTree // final for performance | |||
* | |||
* @param index _KEY or _VALUE | |||
*/ | |||
private void setRed(final int index) | |||
public void setRed(int index) | |||
{ | |||
_black[ index ] = false; | |||
} | |||
@@ -2100,8 +2022,7 @@ public final class BinaryTree // final for performance | |||
* @param node the node whose color we're adopting | |||
* @param index _KEY or _VALUE | |||
*/ | |||
private void copyColor(final Node node, final int index) | |||
public void copyColor(Node node, int index) | |||
{ | |||
_black[ index ] = node._black[ index ]; | |||
} | |||
@@ -2111,7 +2032,6 @@ public final class BinaryTree // final for performance | |||
/** | |||
* @return the key corresponding to this entry. | |||
*/ | |||
public Object getKey() | |||
{ | |||
return _data[ _KEY ]; | |||
@@ -2120,7 +2040,6 @@ public final class BinaryTree // final for performance | |||
/** | |||
* @return the value corresponding to this entry. | |||
*/ | |||
public Object getValue() | |||
{ | |||
return _data[ _VALUE ]; | |||
@@ -2133,10 +2052,7 @@ public final class BinaryTree // final for performance | |||
* @param ignored | |||
* | |||
* @return does not return | |||
* | |||
* @exception UnsupportedOperationException | |||
*/ | |||
public Object setValue(Object ignored) | |||
throws UnsupportedOperationException | |||
{ | |||
@@ -2154,7 +2070,6 @@ public final class BinaryTree // final for performance | |||
* @return true if the specified object is equal to this map | |||
* entry. | |||
*/ | |||
public boolean equals(Object o) | |||
{ | |||
if (this == o) | |||
@@ -2188,5 +2103,4 @@ public final class BinaryTree // final for performance | |||
/* ********** END implementation of Map.Entry ********** */ | |||
} | |||
} // end public class BinaryTree | |||
} |
@@ -1,4 +1,3 @@ | |||
/* ==================================================================== | |||
Licensed to the Apache Software Foundation (ASF) under one or more | |||
contributor license agreements. See the NOTICE file distributed with | |||
@@ -15,7 +14,6 @@ | |||
See the License for the specific language governing permissions and | |||
limitations under the License. | |||
==================================================================== */ | |||
package org.apache.poi.util; | |||
@@ -31,34 +29,32 @@ import java.util.*; | |||
* @author Glen Stampoultzis (glens at apache.org) | |||
* @author Nicola Ken Barozzi (nicolaken at apache.org) | |||
*/ | |||
public abstract class POILogger { | |||
public abstract class POILogger | |||
{ | |||
public static final int DEBUG = 1; | |||
public static final int INFO = 3; | |||
public static final int WARN = 5; | |||
public static final int ERROR = 7; | |||
public static final int FATAL = 9; | |||
public static int DEBUG = 1; | |||
public static int INFO = 3; | |||
public static int WARN = 5; | |||
public static int ERROR = 7; | |||
public static int FATAL = 9; | |||
/** | |||
* package scope so it cannot be instantiated outside of the util | |||
* package. You need a POILogger? Go to the POILogFactory for one | |||
* | |||
*/ | |||
POILogger() | |||
{} | |||
abstract public void initialize(final String cat); | |||
POILogger() { | |||
// no fields to initialise | |||
} | |||
abstract public void initialize(String cat); | |||
/** | |||
* Log a message | |||
* | |||
* @param level One of DEBUG, INFO, WARN, ERROR, FATAL | |||
* @param obj1 The object to log. This is converted to a string. | |||
*/ | |||
abstract public void log(final int level, final Object obj1); | |||
abstract public void log(int level, Object obj1); | |||
/** | |||
* Log a message | |||
* | |||
@@ -66,7 +62,7 @@ public abstract class POILogger | |||
* @param obj1 The object to log. This is converted to a string. | |||
* @param exception An exception to be logged | |||
*/ | |||
abstract public void log(final int level, final Object obj1, | |||
abstract public void log(int level, Object obj1, | |||
final Throwable exception); | |||
@@ -75,15 +71,7 @@ public abstract class POILogger | |||
* | |||
* @param level One of DEBUG, INFO, WARN, ERROR, FATAL | |||
*/ | |||
abstract public boolean check(final int level); | |||
/** | |||
* Log a message. Lazily appends Object parameters together. | |||
* | |||
* @param level One of DEBUG, INFO, WARN, ERROR, FATAL | |||
* @param obj1 first object to place in the message | |||
* @param obj2 second object to place in the message | |||
*/ | |||
abstract public boolean check(int level); | |||
/** | |||
* Log a message. Lazily appends Object parameters together. | |||
@@ -92,8 +80,7 @@ public abstract class POILogger | |||
* @param obj1 first object to place in the message | |||
* @param obj2 second object to place in the message | |||
*/ | |||
public void log(final int level, final Object obj1, final Object obj2) | |||
public void log(int level, Object obj1, Object obj2) | |||
{ | |||
if (check(level)) | |||
{ | |||
@@ -109,11 +96,10 @@ public abstract class POILogger | |||
* @param obj2 second Object to place in the message | |||
* @param obj3 third Object to place in the message | |||
*/ | |||
public void log(final int level, final Object obj1, final Object obj2, | |||
final Object obj3) | |||
public void log(int level, Object obj1, Object obj2, | |||
Object obj3) | |||
{ | |||
if (check(level)) | |||
{ | |||
@@ -132,11 +118,10 @@ public abstract class POILogger | |||
* @param obj3 third Object to place in the message | |||
* @param obj4 fourth Object to place in the message | |||
*/ | |||
public void log(final int level, final Object obj1, final Object obj2, | |||
final Object obj3, final Object obj4) | |||
public void log(int level, Object obj1, Object obj2, | |||
Object obj3, Object obj4) | |||
{ | |||
if (check(level)) | |||
{ | |||
@@ -156,11 +141,10 @@ public abstract class POILogger | |||
* @param obj4 fourth Object to place in the message | |||
* @param obj5 fifth Object to place in the message | |||
*/ | |||
public void log(final int level, final Object obj1, final Object obj2, | |||
final Object obj3, final Object obj4, final Object obj5) | |||
public void log(int level, Object obj1, Object obj2, | |||
Object obj3, Object obj4, Object obj5) | |||
{ | |||
if (check(level)) | |||
{ | |||
@@ -181,12 +165,11 @@ public abstract class POILogger | |||
* @param obj5 fifth Object to place in the message | |||
* @param obj6 sixth Object to place in the message | |||
*/ | |||
public void log(final int level, final Object obj1, final Object obj2, | |||
final Object obj3, final Object obj4, final Object obj5, | |||
final Object obj6) | |||
public void log(int level, Object obj1, Object obj2, | |||
Object obj3, Object obj4, Object obj5, | |||
Object obj6) | |||
{ | |||
if (check(level)) | |||
{ | |||
@@ -208,12 +191,11 @@ public abstract class POILogger | |||
* @param obj6 sixth Object to place in the message | |||
* @param obj7 seventh Object to place in the message | |||
*/ | |||
public void log(final int level, final Object obj1, final Object obj2, | |||
final Object obj3, final Object obj4, final Object obj5, | |||
final Object obj6, final Object obj7) | |||
public void log(int level, Object obj1, Object obj2, | |||
Object obj3, Object obj4, Object obj5, | |||
Object obj6, Object obj7) | |||
{ | |||
if (check(level)) | |||
{ | |||
@@ -237,12 +219,11 @@ public abstract class POILogger | |||
* @param obj7 seventh Object to place in the message | |||
* @param obj8 eighth Object to place in the message | |||
*/ | |||
public void log(final int level, final Object obj1, final Object obj2, | |||
final Object obj3, final Object obj4, final Object obj5, | |||
final Object obj6, final Object obj7, final Object obj8) | |||
public void log(int level, Object obj1, Object obj2, | |||
Object obj3, Object obj4, Object obj5, | |||
Object obj6, Object obj7, Object obj8) | |||
{ | |||
if (check(level)) | |||
{ | |||
@@ -259,8 +240,7 @@ public abstract class POILogger | |||
* @param level One of DEBUG, INFO, WARN, ERROR, FATAL | |||
* @param exception An exception to be logged | |||
*/ | |||
public void log(final int level, final Throwable exception) | |||
public void log(int level, final Throwable exception) | |||
{ | |||
log(level, null, exception); | |||
} | |||
@@ -273,11 +253,10 @@ public abstract class POILogger | |||
* @param obj2 second Object to place in the message | |||
* @param exception An exception to be logged | |||
*/ | |||
public void log(final int level, final Object obj1, final Object obj2, | |||
public void log(int level, Object obj1, Object obj2, | |||
final Throwable exception) | |||
{ | |||
if (check(level)) | |||
{ | |||
@@ -295,11 +274,10 @@ public abstract class POILogger | |||
* @param obj3 third object to place in the message | |||
* @param exception An error message to be logged | |||
*/ | |||
public void log(final int level, final Object obj1, final Object obj2, | |||
final Object obj3, final Throwable exception) | |||
public void log(int level, Object obj1, Object obj2, | |||
Object obj3, final Throwable exception) | |||
{ | |||
if (check(level)) | |||
{ | |||
@@ -318,12 +296,11 @@ public abstract class POILogger | |||
* @param obj4 fourth object to place in the message | |||
* @param exception An exception to be logged | |||
*/ | |||
public void log(final int level, final Object obj1, final Object obj2, | |||
final Object obj3, final Object obj4, | |||
public void log(int level, Object obj1, Object obj2, | |||
Object obj3, Object obj4, | |||
final Throwable exception) | |||
{ | |||
if (check(level)) | |||
{ | |||
@@ -343,12 +320,11 @@ public abstract class POILogger | |||
* @param obj5 fifth object to place in the message | |||
* @param exception An exception to be logged | |||
*/ | |||
public void log(final int level, final Object obj1, final Object obj2, | |||
final Object obj3, final Object obj4, final Object obj5, | |||
public void log(int level, Object obj1, Object obj2, | |||
Object obj3, Object obj4, Object obj5, | |||
final Throwable exception) | |||
{ | |||
if (check(level)) | |||
{ | |||
@@ -369,12 +345,11 @@ public abstract class POILogger | |||
* @param obj6 sixth object to place in the message | |||
* @param exception An exception to be logged | |||
*/ | |||
public void log(final int level, final Object obj1, final Object obj2, | |||
final Object obj3, final Object obj4, final Object obj5, | |||
final Object obj6, final Throwable exception) | |||
public void log(int level, Object obj1, Object obj2, | |||
Object obj3, Object obj4, Object obj5, | |||
Object obj6, final Throwable exception) | |||
{ | |||
if (check(level)) | |||
{ | |||
@@ -397,13 +372,12 @@ public abstract class POILogger | |||
* @param obj7 seventh object to place in the message | |||
* @param exception An exception to be logged | |||
*/ | |||
public void log(final int level, final Object obj1, final Object obj2, | |||
final Object obj3, final Object obj4, final Object obj5, | |||
final Object obj6, final Object obj7, | |||
public void log(int level, Object obj1, Object obj2, | |||
Object obj3, Object obj4, Object obj5, | |||
Object obj6, Object obj7, | |||
final Throwable exception) | |||
{ | |||
if (check(level)) | |||
{ | |||
@@ -427,13 +401,12 @@ public abstract class POILogger | |||
* @param obj8 eighth object to place in the message | |||
* @param exception An exception to be logged | |||
*/ | |||
public void log(final int level, final Object obj1, final Object obj2, | |||
final Object obj3, final Object obj4, final Object obj5, | |||
final Object obj6, final Object obj7, final Object obj8, | |||
public void log(int level, Object obj1, Object obj2, | |||
Object obj3, Object obj4, Object obj5, | |||
Object obj6, Object obj7, Object obj8, | |||
final Throwable exception) | |||
{ | |||
if (check(level)) | |||
{ | |||
@@ -467,9 +440,8 @@ public abstract class POILogger | |||
* @param message The message to log. | |||
* @param obj1 The first object to match against. | |||
*/ | |||
public void logFormatted(final int level, final String message, | |||
final Object obj1) | |||
public void logFormatted(int level, String message, | |||
Object obj1) | |||
{ | |||
commonLogFormatted(level, message, new Object[] | |||
{ | |||
@@ -502,9 +474,8 @@ public abstract class POILogger | |||
* @param obj1 The first object to match against. | |||
* @param obj2 The second object to match against. | |||
*/ | |||
public void logFormatted(final int level, final String message, | |||
final Object obj1, final Object obj2) | |||
public void logFormatted(int level, String message, | |||
Object obj1, Object obj2) | |||
{ | |||
commonLogFormatted(level, message, new Object[] | |||
{ | |||
@@ -538,10 +509,9 @@ public abstract class POILogger | |||
* @param obj2 The second object to match against. | |||
* @param obj3 The third object to match against. | |||
*/ | |||
public void logFormatted(final int level, final String message, | |||
final Object obj1, final Object obj2, | |||
final Object obj3) | |||
public void logFormatted(int level, String message, | |||
Object obj1, Object obj2, | |||
Object obj3) | |||
{ | |||
commonLogFormatted(level, message, new Object[] | |||
{ | |||
@@ -576,21 +546,20 @@ public abstract class POILogger | |||
* @param obj3 The third object to match against. | |||
* @param obj4 The forth object to match against. | |||
*/ | |||
public void logFormatted(final int level, final String message, | |||
final Object obj1, final Object obj2, | |||
final Object obj3, final Object obj4) | |||
public void logFormatted(int level, String message, | |||
Object obj1, Object obj2, | |||
Object obj3, Object obj4) | |||
{ | |||
commonLogFormatted(level, message, new Object[] | |||
{ | |||
obj1, obj2, obj3, obj4 | |||
}); | |||
} | |||
} | |||
private void commonLogFormatted(final int level, final String message, | |||
final Object [] unflatParams) | |||
private void commonLogFormatted(int level, String message, | |||
Object [] unflatParams) | |||
{ | |||
if (check(level)) | |||
{ | |||
@@ -611,21 +580,20 @@ public abstract class POILogger | |||
/** | |||
* Flattens any contained objects. Only tranverses one level deep. | |||
*/ | |||
private Object [] flattenArrays(final Object [] objects) | |||
private Object [] flattenArrays(Object [] objects) | |||
{ | |||
List results = new ArrayList(); | |||
List<Object> results = new ArrayList<Object>(); | |||
for (int i = 0; i < objects.length; i++) | |||
{ | |||
results.addAll(objectToObjectArray(objects[ i ])); | |||
} | |||
return ( Object [] ) results.toArray(new Object[ results.size() ]); | |||
return results.toArray(new Object[ results.size() ]); | |||
} | |||
private List objectToObjectArray(Object object) | |||
private List<Object> objectToObjectArray(Object object) | |||
{ | |||
List results = new ArrayList(); | |||
List<Object> results = new ArrayList<Object>(); | |||
if (object instanceof byte []) | |||
{ | |||
@@ -705,6 +673,4 @@ public abstract class POILogger | |||
} | |||
return results; | |||
} | |||
} // end package scope abstract class POILogger | |||
} |
@@ -52,7 +52,7 @@ import org.apache.poi.util.POILogFactory; | |||
/** | |||
* Represents a container that can store multiple data objects. | |||
* | |||
* | |||
* @author Julien Chable, CDubet | |||
* @version 0.1 | |||
*/ | |||
@@ -125,7 +125,7 @@ public abstract class OPCPackage implements RelationshipSource { | |||
/** | |||
* Constructor. | |||
* | |||
* | |||
* @param access | |||
* Package access. | |||
*/ | |||
@@ -166,7 +166,7 @@ public abstract class OPCPackage implements RelationshipSource { | |||
/** | |||
* Open a package with read/write permission. | |||
* | |||
* | |||
* @param path | |||
* The document path. | |||
* @return A Package object, else <b>null</b>. | |||
@@ -180,7 +180,7 @@ public abstract class OPCPackage implements RelationshipSource { | |||
/** | |||
* Open a package. | |||
* | |||
* | |||
* @param path | |||
* The document path. | |||
* @param access | |||
@@ -206,11 +206,11 @@ public abstract class OPCPackage implements RelationshipSource { | |||
/** | |||
* Open a package. | |||
* | |||
* | |||
* Note - uses quite a bit more memory than {@link #open(String)}, which | |||
* doesn't need to hold the whole zip file in memory, and can take advantage | |||
* of native methods | |||
* | |||
* | |||
* @param in | |||
* The InputStream to read the package from | |||
* @return A PackageBase object | |||
@@ -226,7 +226,7 @@ public abstract class OPCPackage implements RelationshipSource { | |||
/** | |||
* Opens a package if it exists, else it creates one. | |||
* | |||
* | |||
* @param file | |||
* The file to open or to create. | |||
* @return A newly created package if the specified file does not exist, | |||
@@ -246,7 +246,7 @@ public abstract class OPCPackage implements RelationshipSource { | |||
/** | |||
* Creates a new package. | |||
* | |||
* | |||
* @param path | |||
* Path of the document. | |||
* @return A newly created PackageBase ready to use. | |||
@@ -257,7 +257,7 @@ public abstract class OPCPackage implements RelationshipSource { | |||
/** | |||
* Creates a new package. | |||
* | |||
* | |||
* @param file | |||
* Path of the document. | |||
* @return A newly created PackageBase ready to use. | |||
@@ -292,7 +292,7 @@ public abstract class OPCPackage implements RelationshipSource { | |||
/** | |||
* Configure the package. | |||
* | |||
* | |||
* @param pkg | |||
*/ | |||
private static void configurePackage(OPCPackage pkg) { | |||
@@ -324,7 +324,7 @@ public abstract class OPCPackage implements RelationshipSource { | |||
/** | |||
* Flush the package : save all. | |||
* | |||
* | |||
* @see #close() | |||
*/ | |||
public void flush() { | |||
@@ -339,7 +339,7 @@ public abstract class OPCPackage implements RelationshipSource { | |||
/** | |||
* Close the package and save its content. | |||
* | |||
* | |||
* @throws IOException | |||
* If an IO exception occur during the saving process. | |||
*/ | |||
@@ -391,7 +391,7 @@ public abstract class OPCPackage implements RelationshipSource { | |||
* Add a thumbnail to the package. This method is provided to make easier | |||
* the addition of a thumbnail in a package. You can do the same work by | |||
* using the traditionnal relationship and part mechanism. | |||
* | |||
* | |||
* @param path | |||
* The full path to the image file. | |||
*/ | |||
@@ -443,7 +443,7 @@ public abstract class OPCPackage implements RelationshipSource { | |||
/** | |||
* Throws an exception if the package access mode is in read only mode | |||
* (PackageAccess.Read). | |||
* | |||
* | |||
* @throws InvalidOperationException | |||
* Throws if a writing operation is done on a read only package. | |||
* @see org.apache.poi.openxml4j.opc.PackageAccess | |||
@@ -458,7 +458,7 @@ public abstract class OPCPackage implements RelationshipSource { | |||
* Throws an exception if the package access mode is in write only mode | |||
* (PackageAccess.Write). This method is call when other methods need write | |||
* right. | |||
* | |||
* | |||
* @throws InvalidOperationException | |||
* Throws if a read operation is done on a write only package. | |||
* @see org.apache.poi.openxml4j.opc.PackageAccess | |||
@@ -471,7 +471,7 @@ public abstract class OPCPackage implements RelationshipSource { | |||
/** | |||
* Retrieves or creates if none exists, core package property part. | |||
* | |||
* | |||
* @return The PackageProperties part of this package. | |||
*/ | |||
public PackageProperties getPackageProperties() | |||
@@ -487,7 +487,7 @@ public abstract class OPCPackage implements RelationshipSource { | |||
/** | |||
* Retrieve a part identified by its name. | |||
* | |||
* | |||
* @param partName | |||
* Part name of the part to retrieve. | |||
* @return The part with the specified name, else <code>null</code>. | |||
@@ -511,7 +511,7 @@ public abstract class OPCPackage implements RelationshipSource { | |||
/** | |||
* Retrieve parts by content type. | |||
* | |||
* | |||
* @param contentType | |||
* The content type criteria. | |||
* @return All part associated to the specified content type. | |||
@@ -527,7 +527,7 @@ public abstract class OPCPackage implements RelationshipSource { | |||
/** | |||
* Retrieve parts by relationship type. | |||
* | |||
* | |||
* @param relationshipType | |||
* Relationship type. | |||
* @return All parts which are the target of a relationship with the | |||
@@ -547,7 +547,7 @@ public abstract class OPCPackage implements RelationshipSource { | |||
/** | |||
* Get the target part from the specified relationship. | |||
* | |||
* | |||
* @param partRel | |||
* The part relationship uses to retrieve the part. | |||
*/ | |||
@@ -571,7 +571,7 @@ public abstract class OPCPackage implements RelationshipSource { | |||
/** | |||
* Load the parts of the archive if it has not been done yet The | |||
* relationships of each part are not loaded | |||
* | |||
* | |||
* @return All this package's parts. | |||
*/ | |||
public ArrayList<PackagePart> getParts() throws InvalidFormatException { | |||
@@ -588,10 +588,10 @@ public abstract class OPCPackage implements RelationshipSource { | |||
PackagePart[] parts = this.getPartsImpl(); | |||
this.partList = new PackagePartCollection(); | |||
for (PackagePart part : parts) { | |||
if (partList.containsKey(part.partName)) | |||
if (partList.containsKey(part._partName)) | |||
throw new InvalidFormatException( | |||
"A part with the name '" | |||
+ part.partName | |||
+ part._partName | |||
+ "' already exist : Packages shall not contain equivalent part names and package implementers shall neither create nor recognize packages with equivalent part names. [M1.12]"); | |||
// Check OPC compliance rule M4.1 | |||
@@ -605,29 +605,29 @@ public abstract class OPCPackage implements RelationshipSource { | |||
} | |||
PartUnmarshaller partUnmarshaller = partUnmarshallers | |||
.get(part.contentType); | |||
.get(part._contentType); | |||
if (partUnmarshaller != null) { | |||
UnmarshallContext context = new UnmarshallContext(this, | |||
part.partName); | |||
part._partName); | |||
try { | |||
PackagePart unmarshallPart = partUnmarshaller | |||
.unmarshall(context, part.getInputStream()); | |||
partList.put(unmarshallPart.partName, unmarshallPart); | |||
partList.put(unmarshallPart._partName, unmarshallPart); | |||
// Core properties case | |||
if (unmarshallPart instanceof PackagePropertiesPart) | |||
this.packageProperties = (PackagePropertiesPart) unmarshallPart; | |||
} catch (IOException ioe) { | |||
logger.log(POILogger.WARN, "Unmarshall operation : IOException for " | |||
+ part.partName); | |||
+ part._partName); | |||
continue; | |||
} catch (InvalidOperationException invoe) { | |||
throw new InvalidFormatException(invoe.getMessage()); | |||
} | |||
} else { | |||
try { | |||
partList.put(part.partName, part); | |||
partList.put(part._partName, part); | |||
} catch (InvalidOperationException e) { | |||
throw new InvalidFormatException(e.getMessage()); | |||
} | |||
@@ -640,7 +640,7 @@ public abstract class OPCPackage implements RelationshipSource { | |||
/** | |||
* Create and add a part, with the specified name and content type, to the | |||
* package. | |||
* | |||
* | |||
* @param partName | |||
* Part name. | |||
* @param contentType | |||
@@ -650,7 +650,7 @@ public abstract class OPCPackage implements RelationshipSource { | |||
* If rule M1.12 is not verified : Packages shall not contain | |||
* equivalent part names and package implementers shall neither | |||
* create nor recognize packages with equivalent part names. | |||
* @see #createPartImpl(PackagePartName, String, boolean) | |||
* @see #createPartImpl(PackagePartName, String, boolean) | |||
*/ | |||
public PackagePart createPart(PackagePartName partName, String contentType) { | |||
return this.createPart(partName, contentType, true); | |||
@@ -660,7 +660,7 @@ public abstract class OPCPackage implements RelationshipSource { | |||
* Create and add a part, with the specified name and content type, to the | |||
* package. For general purpose, prefer the overload version of this method | |||
* without the 'loadRelationships' parameter. | |||
* | |||
* | |||
* @param partName | |||
* Part name. | |||
* @param contentType | |||
@@ -721,7 +721,7 @@ public abstract class OPCPackage implements RelationshipSource { | |||
/** | |||
* Add a part to the package. | |||
* | |||
* | |||
* @param partName | |||
* Part name of the part to create. | |||
* @param contentType | |||
@@ -730,7 +730,7 @@ public abstract class OPCPackage implements RelationshipSource { | |||
* the contents to add. In order to have faster operation in | |||
* document merge, the data are stored in memory not on a hard | |||
* disk | |||
* | |||
* | |||
* @return The new part. | |||
* @see #createPart(PackagePartName, String) | |||
*/ | |||
@@ -764,7 +764,7 @@ public abstract class OPCPackage implements RelationshipSource { | |||
* Add the specified part to the package. If a part already exists in the | |||
* package with the same name as the one specified, then we replace the old | |||
* part by the specified part. | |||
* | |||
* | |||
* @param part | |||
* The part to add (or replace). | |||
* @return The part added to the package, the same as the one specified. | |||
@@ -779,20 +779,20 @@ public abstract class OPCPackage implements RelationshipSource { | |||
throw new IllegalArgumentException("part"); | |||
} | |||
if (partList.containsKey(part.partName)) { | |||
if (!partList.get(part.partName).isDeleted()) { | |||
if (partList.containsKey(part._partName)) { | |||
if (!partList.get(part._partName).isDeleted()) { | |||
throw new InvalidOperationException( | |||
"A part with the name '" | |||
+ part.partName.getName() | |||
+ part._partName.getName() | |||
+ "' already exists : Packages shall not contain equivalent part names and package implementers shall neither create nor recognize packages with equivalent part names. [M1.12]"); | |||
} | |||
// If the specified partis flagged as deleted, we make it | |||
// available | |||
part.setDeleted(false); | |||
// and delete the old part to replace it thereafeter | |||
this.partList.remove(part.partName); | |||
this.partList.remove(part._partName); | |||
} | |||
this.partList.put(part.partName, part); | |||
this.partList.put(part._partName, part); | |||
this.isDirty = true; | |||
return part; | |||
} | |||
@@ -800,7 +800,7 @@ public abstract class OPCPackage implements RelationshipSource { | |||
/** | |||
* Remove the specified part in this package. If this part is relationship | |||
* part, then delete all relationships in the source part. | |||
* | |||
* | |||
* @param part | |||
* The part to remove. If <code>null</code>, skip the action. | |||
* @see #removePart(PackagePartName) | |||
@@ -814,7 +814,7 @@ public abstract class OPCPackage implements RelationshipSource { | |||
/** | |||
* Remove a part in this package. If this part is relationship part, then | |||
* delete all relationships in the source part. | |||
* | |||
* | |||
* @param partName | |||
* The part name of the part to remove. | |||
*/ | |||
@@ -867,7 +867,7 @@ public abstract class OPCPackage implements RelationshipSource { | |||
* Remove a part from this package as well as its relationship part, if one | |||
* exists, and all parts listed in the relationship part. Be aware that this | |||
* do not delete relationships which target the specified part. | |||
* | |||
* | |||
* @param partName | |||
* The name of the part to delete. | |||
* @throws InvalidFormatException | |||
@@ -893,11 +893,11 @@ public abstract class OPCPackage implements RelationshipSource { | |||
} | |||
// Finally delete its relationship part if one exists | |||
this.removePart(relPart.partName); | |||
this.removePart(relPart._partName); | |||
} | |||
// Delete the specified part | |||
this.removePart(partToRemove.partName); | |||
this.removePart(partToRemove._partName); | |||
} | |||
/** | |||
@@ -905,7 +905,7 @@ public abstract class OPCPackage implements RelationshipSource { | |||
* part if one exists. Prefer the use of this method to delete a part in the | |||
* package, compare to the remove() methods that don't remove associated | |||
* relationships part. | |||
* | |||
* | |||
* @param partName | |||
* Name of the part to delete | |||
*/ | |||
@@ -925,7 +925,7 @@ public abstract class OPCPackage implements RelationshipSource { | |||
* apply to all parts in the relationships part of the specified part. | |||
* Prefer the use of this method to delete a part in the package, compare to | |||
* the remove() methods that don't remove associated relationships part. | |||
* | |||
* | |||
* @param partName | |||
* Name of the part to delete | |||
*/ | |||
@@ -961,7 +961,7 @@ public abstract class OPCPackage implements RelationshipSource { | |||
/** | |||
* Check if a part already exists in this package from its name. | |||
* | |||
* | |||
* @param partName | |||
* Part name to check. | |||
* @return <i>true</i> if the part is logically added to this package, else | |||
@@ -973,18 +973,18 @@ public abstract class OPCPackage implements RelationshipSource { | |||
/** | |||
* Add a relationship to the package (except relationships part). | |||
* | |||
* | |||
* Check rule M4.1 : The format designer shall specify and the format | |||
* producer shall create at most one core properties relationship for a | |||
* package. A format consumer shall consider more than one core properties | |||
* relationship for a package to be an error. If present, the relationship | |||
* shall target the Core Properties part. | |||
* | |||
* | |||
* Check rule M1.25: The Relationships part shall not have relationships to | |||
* any other part. Package implementers shall enforce this requirement upon | |||
* the attempt to create such a relationship and shall treat any such | |||
* relationship as invalid. | |||
* | |||
* | |||
* @param targetPartName | |||
* Target part name. | |||
* @param targetMode | |||
@@ -1032,7 +1032,7 @@ public abstract class OPCPackage implements RelationshipSource { | |||
/** | |||
* Add a package relationship. | |||
* | |||
* | |||
* @param targetPartName | |||
* Target part name. | |||
* @param targetMode | |||
@@ -1049,11 +1049,11 @@ public abstract class OPCPackage implements RelationshipSource { | |||
/** | |||
* Adds an external relationship to a part (except relationships part). | |||
* | |||
* | |||
* The targets of external relationships are not subject to the same | |||
* validity checks that internal ones are, as the contents is potentially | |||
* any file, URL or similar. | |||
* | |||
* | |||
* @param target | |||
* External target of the relationship | |||
* @param relationshipType | |||
@@ -1069,11 +1069,11 @@ public abstract class OPCPackage implements RelationshipSource { | |||
/** | |||
* Adds an external relationship to a part (except relationships part). | |||
* | |||
* | |||
* The targets of external relationships are not subject to the same | |||
* validity checks that internal ones are, as the contents is potentially | |||
* any file, URL or similar. | |||
* | |||
* | |||
* @param target | |||
* External target of the relationship | |||
* @param relationshipType | |||
@@ -1109,7 +1109,7 @@ public abstract class OPCPackage implements RelationshipSource { | |||
/** | |||
* Delete a relationship from this package. | |||
* | |||
* | |||
* @param id | |||
* Id of the relationship to delete. | |||
*/ | |||
@@ -1122,7 +1122,7 @@ public abstract class OPCPackage implements RelationshipSource { | |||
/** | |||
* Retrieves all package relationships. | |||
* | |||
* | |||
* @return All package relationships of this package. | |||
* @throws OpenXML4JException | |||
* @see #getRelationshipsHelper(String) | |||
@@ -1133,7 +1133,7 @@ public abstract class OPCPackage implements RelationshipSource { | |||
/** | |||
* Retrieves all relationships with the specified type. | |||
* | |||
* | |||
* @param relationshipType | |||
* The filter specifying the relationship type. | |||
* @return All relationships with the specified relationship type. | |||
@@ -1150,7 +1150,7 @@ public abstract class OPCPackage implements RelationshipSource { | |||
/** | |||
* Retrieves all relationships with specified id (normally just ine because | |||
* a relationship id is supposed to be unique). | |||
* | |||
* | |||
* @param id | |||
* Id of the wanted relationship. | |||
*/ | |||
@@ -1214,7 +1214,7 @@ public abstract class OPCPackage implements RelationshipSource { | |||
/** | |||
* Add a marshaller. | |||
* | |||
* | |||
* @param contentType | |||
* The content type to bind to the specified marshaller. | |||
* @param marshaller | |||
@@ -1231,7 +1231,7 @@ public abstract class OPCPackage implements RelationshipSource { | |||
/** | |||
* Add an unmarshaller. | |||
* | |||
* | |||
* @param contentType | |||
* The content type to bind to the specified unmarshaller. | |||
* @param unmarshaller | |||
@@ -1250,7 +1250,7 @@ public abstract class OPCPackage implements RelationshipSource { | |||
/** | |||
* Remove a marshaller by its content type. | |||
* | |||
* | |||
* @param contentType | |||
* The content type associated with the marshaller to remove. | |||
*/ | |||
@@ -1260,7 +1260,7 @@ public abstract class OPCPackage implements RelationshipSource { | |||
/** | |||
* Remove an unmarshaller by its content type. | |||
* | |||
* | |||
* @param contentType | |||
* The content type associated with the unmarshaller to remove. | |||
*/ | |||
@@ -1272,7 +1272,7 @@ public abstract class OPCPackage implements RelationshipSource { | |||
/** | |||
* Get the package access mode. | |||
* | |||
* | |||
* @return the packageAccess The current package access. | |||
*/ | |||
public PackageAccess getPackageAccess() { | |||
@@ -1281,7 +1281,7 @@ public abstract class OPCPackage implements RelationshipSource { | |||
/** | |||
* Validates the package compliance with the OPC specifications. | |||
* | |||
* | |||
* @return <b>true</b> if the package is valid else <b>false</b> | |||
*/ | |||
public boolean validatePackage(OPCPackage pkg) throws InvalidFormatException { | |||
@@ -1290,7 +1290,7 @@ public abstract class OPCPackage implements RelationshipSource { | |||
/** | |||
* Save the document in the specified file. | |||
* | |||
* | |||
* @param targetFile | |||
* Destination file. | |||
* @throws IOException | |||
@@ -1313,7 +1313,7 @@ public abstract class OPCPackage implements RelationshipSource { | |||
/** | |||
* Save the document in the specified output stream. | |||
* | |||
* | |||
* @param outputStream | |||
* The stream to save the package. | |||
* @see #saveImpl(OutputStream) | |||
@@ -1326,7 +1326,7 @@ public abstract class OPCPackage implements RelationshipSource { | |||
/** | |||
* Core method to create a package part. This method must be implemented by | |||
* the subclass. | |||
* | |||
* | |||
* @param partName | |||
* URI of the part to create. | |||
* @param contentType | |||
@@ -1339,7 +1339,7 @@ public abstract class OPCPackage implements RelationshipSource { | |||
/** | |||
* Core method to delete a package part. This method must be implemented by | |||
* the subclass. | |||
* | |||
* | |||
* @param partName | |||
* The URI of the part to delete. | |||
*/ | |||
@@ -1352,7 +1352,7 @@ public abstract class OPCPackage implements RelationshipSource { | |||
/** | |||
* Close the package and cause a save of the package. | |||
* | |||
* | |||
*/ | |||
protected abstract void closeImpl() throws IOException; | |||
@@ -1364,7 +1364,7 @@ public abstract class OPCPackage implements RelationshipSource { | |||
/** | |||
* Save the package into the specified output stream. | |||
* | |||
* | |||
* @param outputStream | |||
* The output stream use to save this package. | |||
*/ | |||
@@ -1373,7 +1373,7 @@ public abstract class OPCPackage implements RelationshipSource { | |||
/** | |||
* Get the package part mapped to the specified URI. | |||
* | |||
* | |||
* @param partName | |||
* The URI of the part to retrieve. | |||
* @return The package part located by the specified URI, else <b>null</b>. | |||
@@ -1382,7 +1382,7 @@ public abstract class OPCPackage implements RelationshipSource { | |||
/** | |||
* Get all parts link to the package. | |||
* | |||
* | |||
* @return A list of the part owned by the package. | |||
*/ | |||
protected abstract PackagePart[] getPartsImpl() |
@@ -30,7 +30,7 @@ import org.apache.poi.openxml4j.opc.internal.ContentType; | |||
/** | |||
* Provides a base class for parts stored in a Package. | |||
* | |||
* | |||
* @author Julien Chable | |||
* @version 0.9 | |||
*/ | |||
@@ -39,36 +39,36 @@ public abstract class PackagePart implements RelationshipSource { | |||
/** | |||
* This part's container. | |||
*/ | |||
protected OPCPackage container; | |||
protected OPCPackage _container; | |||
/** | |||
* The part name. (required by the specification [M1.1]) | |||
*/ | |||
protected PackagePartName partName; | |||
protected PackagePartName _partName; | |||
/** | |||
* The type of content of this part. (required by the specification [M1.2]) | |||
*/ | |||
protected ContentType contentType; | |||
protected ContentType _contentType; | |||
/** | |||
* Flag to know if this part is a relationship. | |||
*/ | |||
private boolean isRelationshipPart; | |||
private boolean _isRelationshipPart; | |||
/** | |||
* Flag to know if this part has been logically deleted. | |||
*/ | |||
private boolean isDeleted; | |||
private boolean _isDeleted; | |||
/** | |||
* This part's relationships. | |||
*/ | |||
private PackageRelationshipCollection relationships; | |||
private PackageRelationshipCollection _relationships; | |||
/** | |||
* Constructor. | |||
* | |||
* | |||
* @param pack | |||
* Parent package. | |||
* @param partName | |||
@@ -85,7 +85,7 @@ public abstract class PackagePart implements RelationshipSource { | |||
/** | |||
* Constructor. | |||
* | |||
* | |||
* @param pack | |||
* Parent package. | |||
* @param partName | |||
@@ -100,12 +100,12 @@ public abstract class PackagePart implements RelationshipSource { | |||
protected PackagePart(OPCPackage pack, PackagePartName partName, | |||
ContentType contentType, boolean loadRelationships) | |||
throws InvalidFormatException { | |||
this.partName = partName; | |||
this.contentType = contentType; | |||
this.container = (ZipPackage) pack; // TODO - enforcing ZipPackage here - perhaps should change constructor signature | |||
_partName = partName; | |||
_contentType = contentType; | |||
_container = pack; | |||
// Check if this part is a relationship part | |||
isRelationshipPart = this.partName.isRelationshipPartURI(); | |||
_isRelationshipPart = this._partName.isRelationshipPartURI(); | |||
// Load relationships if any | |||
if (loadRelationships) | |||
@@ -114,7 +114,7 @@ public abstract class PackagePart implements RelationshipSource { | |||
/** | |||
* Constructor. | |||
* | |||
* | |||
* @param pack | |||
* Parent package. | |||
* @param partName | |||
@@ -130,11 +130,11 @@ public abstract class PackagePart implements RelationshipSource { | |||
/** | |||
* Adds an external relationship to a part (except relationships part). | |||
* | |||
* | |||
* The targets of external relationships are not subject to the same | |||
* validity checks that internal ones are, as the contents is potentially | |||
* any file, URL or similar. | |||
* | |||
* | |||
* @param target | |||
* External target of the relationship | |||
* @param relationshipType | |||
@@ -150,11 +150,11 @@ public abstract class PackagePart implements RelationshipSource { | |||
/** | |||
* Adds an external relationship to a part (except relationships part). | |||
* | |||
* | |||
* The targets of external relationships are not subject to the same | |||
* validity checks that internal ones are, as the contents is potentially | |||
* any file, URL or similar. | |||
* | |||
* | |||
* @param target | |||
* External target of the relationship | |||
* @param relationshipType | |||
@@ -174,8 +174,8 @@ public abstract class PackagePart implements RelationshipSource { | |||
throw new IllegalArgumentException("relationshipType"); | |||
} | |||
if (relationships == null) { | |||
relationships = new PackageRelationshipCollection(); | |||
if (_relationships == null) { | |||
_relationships = new PackageRelationshipCollection(); | |||
} | |||
URI targetURI; | |||
@@ -185,13 +185,13 @@ public abstract class PackagePart implements RelationshipSource { | |||
throw new IllegalArgumentException("Invalid target - " + e); | |||
} | |||
return relationships.addRelationship(targetURI, TargetMode.EXTERNAL, | |||
return _relationships.addRelationship(targetURI, TargetMode.EXTERNAL, | |||
relationshipType, id); | |||
} | |||
/** | |||
* Add a relationship to a part (except relationships part). | |||
* | |||
* | |||
* @param targetPartName | |||
* Name of the target part. This one must be relative to the | |||
* source root directory of the part. | |||
@@ -227,7 +227,7 @@ public abstract class PackagePart implements RelationshipSource { | |||
* @param id | |||
* Relationship unique id. | |||
* @return The newly created and added relationship | |||
* | |||
* | |||
* @throws InvalidFormatException | |||
* If the URI point to a relationship part URI. | |||
* @see org.apache.poi.openxml4j.opc.RelationshipSource#addRelationship(org.apache.poi.openxml4j.opc.PackagePartName, | |||
@@ -235,7 +235,7 @@ public abstract class PackagePart implements RelationshipSource { | |||
*/ | |||
public PackageRelationship addRelationship(PackagePartName targetPartName, | |||
TargetMode targetMode, String relationshipType, String id) { | |||
container.throwExceptionIfReadOnly(); | |||
_container.throwExceptionIfReadOnly(); | |||
if (targetPartName == null) { | |||
throw new IllegalArgumentException("targetPartName"); | |||
@@ -247,22 +247,22 @@ public abstract class PackagePart implements RelationshipSource { | |||
throw new IllegalArgumentException("relationshipType"); | |||
} | |||
if (this.isRelationshipPart || targetPartName.isRelationshipPartURI()) { | |||
if (this._isRelationshipPart || targetPartName.isRelationshipPartURI()) { | |||
throw new InvalidOperationException( | |||
"Rule M1.25: The Relationships part shall not have relationships to any other part."); | |||
} | |||
if (relationships == null) { | |||
relationships = new PackageRelationshipCollection(); | |||
if (_relationships == null) { | |||
_relationships = new PackageRelationshipCollection(); | |||
} | |||
return relationships.addRelationship(targetPartName.getURI(), | |||
return _relationships.addRelationship(targetPartName.getURI(), | |||
targetMode, relationshipType, id); | |||
} | |||
/** | |||
* Add a relationship to a part (except relationships part). | |||
* | |||
* | |||
* @param targetURI | |||
* URI the target part. Must be relative to the source root | |||
* directory of the part. | |||
@@ -297,7 +297,7 @@ public abstract class PackagePart implements RelationshipSource { | |||
* @param id | |||
* Relationship unique id. | |||
* @return The newly created and added relationship | |||
* | |||
* | |||
* @throws InvalidFormatException | |||
* If the URI point to a relationship part URI. | |||
* @see org.apache.poi.openxml4j.opc.RelationshipSource#addRelationship(org.apache.poi.openxml4j.opc.PackagePartName, | |||
@@ -305,7 +305,7 @@ public abstract class PackagePart implements RelationshipSource { | |||
*/ | |||
public PackageRelationship addRelationship(URI targetURI, | |||
TargetMode targetMode, String relationshipType, String id) { | |||
container.throwExceptionIfReadOnly(); | |||
_container.throwExceptionIfReadOnly(); | |||
if (targetURI == null) { | |||
throw new IllegalArgumentException("targetPartName"); | |||
@@ -319,17 +319,17 @@ public abstract class PackagePart implements RelationshipSource { | |||
// Try to retrieve the target part | |||
if (this.isRelationshipPart | |||
if (this._isRelationshipPart | |||
|| PackagingURIHelper.isRelationshipPartURI(targetURI)) { | |||
throw new InvalidOperationException( | |||
"Rule M1.25: The Relationships part shall not have relationships to any other part."); | |||
} | |||
if (relationships == null) { | |||
relationships = new PackageRelationshipCollection(); | |||
if (_relationships == null) { | |||
_relationships = new PackageRelationshipCollection(); | |||
} | |||
return relationships.addRelationship(targetURI, | |||
return _relationships.addRelationship(targetURI, | |||
targetMode, relationshipType, id); | |||
} | |||
@@ -337,27 +337,27 @@ public abstract class PackagePart implements RelationshipSource { | |||
* @see org.apache.poi.openxml4j.opc.RelationshipSource#clearRelationships() | |||
*/ | |||
public void clearRelationships() { | |||
if (relationships != null) { | |||
relationships.clear(); | |||
if (_relationships != null) { | |||
_relationships.clear(); | |||
} | |||
} | |||
/** | |||
* Delete the relationship specified by its id. | |||
* | |||
* | |||
* @param id | |||
* The ID identified the part to delete. | |||
* @see org.apache.poi.openxml4j.opc.RelationshipSource#removeRelationship(java.lang.String) | |||
*/ | |||
public void removeRelationship(String id) { | |||
this.container.throwExceptionIfReadOnly(); | |||
if (this.relationships != null) | |||
this.relationships.removeRelationship(id); | |||
this._container.throwExceptionIfReadOnly(); | |||
if (this._relationships != null) | |||
this._relationships.removeRelationship(id); | |||
} | |||
/** | |||
* Retrieve all the relationships attached to this part. | |||
* | |||
* | |||
* @return This part's relationships. | |||
* @throws OpenXML4JException | |||
* @see org.apache.poi.openxml4j.opc.RelationshipSource#getRelationships() | |||
@@ -369,20 +369,20 @@ public abstract class PackagePart implements RelationshipSource { | |||
/** | |||
* Retrieves a package relationship from its id. | |||
* | |||
* | |||
* @param id | |||
* ID of the package relationship to retrieve. | |||
* @return The package relationship | |||
* @see org.apache.poi.openxml4j.opc.RelationshipSource#getRelationship(java.lang.String) | |||
*/ | |||
public PackageRelationship getRelationship(String id) { | |||
return this.relationships.getRelationshipByID(id); | |||
return this._relationships.getRelationshipByID(id); | |||
} | |||
/** | |||
* Retrieve all relationships attached to this part which have the specified | |||
* type. | |||
* | |||
* | |||
* @param relationshipType | |||
* Relationship type filter. | |||
* @return All relationships from this part that have the specified type. | |||
@@ -394,14 +394,14 @@ public abstract class PackagePart implements RelationshipSource { | |||
*/ | |||
public PackageRelationshipCollection getRelationshipsByType( | |||
String relationshipType) throws InvalidFormatException { | |||
container.throwExceptionIfWriteOnly(); | |||
_container.throwExceptionIfWriteOnly(); | |||
return getRelationshipsCore(relationshipType); | |||
} | |||
/** | |||
* Implementation of the getRelationships method(). | |||
* | |||
* | |||
* @param filter | |||
* Relationship type filter. If <i>null</i> then the filter is | |||
* disabled and return all the relationships. | |||
@@ -415,29 +415,29 @@ public abstract class PackagePart implements RelationshipSource { | |||
*/ | |||
private PackageRelationshipCollection getRelationshipsCore(String filter) | |||
throws InvalidFormatException { | |||
this.container.throwExceptionIfWriteOnly(); | |||
if (relationships == null) { | |||
this._container.throwExceptionIfWriteOnly(); | |||
if (_relationships == null) { | |||
this.throwExceptionIfRelationship(); | |||
relationships = new PackageRelationshipCollection(this); | |||
_relationships = new PackageRelationshipCollection(this); | |||
} | |||
return new PackageRelationshipCollection(relationships, filter); | |||
return new PackageRelationshipCollection(_relationships, filter); | |||
} | |||
/** | |||
* Knows if the part have any relationships. | |||
* | |||
* | |||
* @return <b>true</b> if the part have at least one relationship else | |||
* <b>false</b>. | |||
* @see org.apache.poi.openxml4j.opc.RelationshipSource#hasRelationships() | |||
*/ | |||
public boolean hasRelationships() { | |||
return (!this.isRelationshipPart && (relationships != null && relationships | |||
return (!this._isRelationshipPart && (_relationships != null && _relationships | |||
.size() > 0)); | |||
} | |||
/** | |||
* Checks if the specified relationship is part of this package part. | |||
* | |||
* | |||
* @param rel | |||
* The relationship to check. | |||
* @return <b>true</b> if the specified relationship exists in this part, | |||
@@ -458,7 +458,7 @@ public abstract class PackagePart implements RelationshipSource { | |||
/** | |||
* Get the input stream of this part to read its content. | |||
* | |||
* | |||
* @return The input stream of the content of this part, else | |||
* <code>null</code>. | |||
*/ | |||
@@ -466,9 +466,9 @@ public abstract class PackagePart implements RelationshipSource { | |||
InputStream inStream = this.getInputStreamImpl(); | |||
if (inStream == null) { | |||
throw new IOException("Can't obtain the input stream from " | |||
+ partName.getName()); | |||
} else | |||
return inStream; | |||
+ _partName.getName()); | |||
} | |||
return inStream; | |||
} | |||
/** | |||
@@ -476,7 +476,7 @@ public abstract class PackagePart implements RelationshipSource { | |||
* Zip package, it'll be transform intot a <i>MemoryPackagePart</i> in | |||
* order to write inside (the standard Java API doesn't allow to write in | |||
* the file) | |||
* | |||
* | |||
* @see org.apache.poi.openxml4j.opc.internal.MemoryPackagePart | |||
*/ | |||
public OutputStream getOutputStream() { | |||
@@ -485,12 +485,12 @@ public abstract class PackagePart implements RelationshipSource { | |||
// this part into a MemoryPackagePart instance for write purpose. | |||
if (this instanceof ZipPackagePart) { | |||
// Delete logically this part | |||
this.container.removePart(this.partName); | |||
_container.removePart(this._partName); | |||
// Create a memory part | |||
PackagePart part = container.createPart(this.partName, | |||
this.contentType.toString(), false); | |||
part.relationships = this.relationships; | |||
PackagePart part = _container.createPart(this._partName, | |||
this._contentType.toString(), false); | |||
part._relationships = this._relationships; | |||
if (part == null) { | |||
throw new InvalidOperationException( | |||
"Can't create a temporary part !"); | |||
@@ -504,27 +504,27 @@ public abstract class PackagePart implements RelationshipSource { | |||
/** | |||
* Throws an exception if this package part is a relationship part. | |||
* | |||
* | |||
* @throws InvalidOperationException | |||
* If this part is a relationship part. | |||
*/ | |||
private void throwExceptionIfRelationship() | |||
throws InvalidOperationException { | |||
if (this.isRelationshipPart) | |||
if (this._isRelationshipPart) | |||
throw new InvalidOperationException( | |||
"Can do this operation on a relationship part !"); | |||
} | |||
/** | |||
* Ensure the package relationships collection instance is built. | |||
* | |||
* | |||
* @throws InvalidFormatException | |||
* Throws if | |||
*/ | |||
private void loadRelationships() throws InvalidFormatException { | |||
if (this.relationships == null && !this.isRelationshipPart) { | |||
if (this._relationships == null && !this._isRelationshipPart) { | |||
this.throwExceptionIfRelationship(); | |||
relationships = new PackageRelationshipCollection(this); | |||
_relationships = new PackageRelationshipCollection(this); | |||
} | |||
} | |||
@@ -536,22 +536,22 @@ public abstract class PackagePart implements RelationshipSource { | |||
* @return the uri | |||
*/ | |||
public PackagePartName getPartName() { | |||
return partName; | |||
return _partName; | |||
} | |||
/** | |||
* @return the contentType | |||
*/ | |||
public String getContentType() { | |||
return contentType.toString(); | |||
return _contentType.toString(); | |||
} | |||
/** | |||
* Set the content type. | |||
* | |||
* | |||
* @param contentType | |||
* the contentType to set | |||
* | |||
* | |||
* @throws InvalidFormatException | |||
* Throws if the content type is not valid. | |||
* @throws InvalidOperationException | |||
@@ -560,29 +560,29 @@ public abstract class PackagePart implements RelationshipSource { | |||
*/ | |||
public void setContentType(String contentType) | |||
throws InvalidFormatException { | |||
if (container == null) | |||
this.contentType = new ContentType(contentType); | |||
if (_container == null) | |||
this._contentType = new ContentType(contentType); | |||
else | |||
throw new InvalidOperationException( | |||
"You can't change the content type of a part."); | |||
} | |||
public OPCPackage getPackage() { | |||
return container; | |||
return _container; | |||
} | |||
/** | |||
* @return true if this part is a relationship | |||
*/ | |||
public boolean isRelationshipPart() { | |||
return this.isRelationshipPart; | |||
return this._isRelationshipPart; | |||
} | |||
/** | |||
* @return true if this part has been logically deleted | |||
*/ | |||
public boolean isDeleted() { | |||
return isDeleted; | |||
return _isDeleted; | |||
} | |||
/** | |||
@@ -590,20 +590,20 @@ public abstract class PackagePart implements RelationshipSource { | |||
* the isDeleted to set | |||
*/ | |||
public void setDeleted(boolean isDeleted) { | |||
this.isDeleted = isDeleted; | |||
this._isDeleted = isDeleted; | |||
} | |||
@Override | |||
public String toString() { | |||
return "Name: " + this.partName + " - Content Type: " | |||
+ this.contentType.toString(); | |||
return "Name: " + this._partName + " - Content Type: " | |||
+ this._contentType.toString(); | |||
} | |||
/*-------------- Abstract methods ------------- */ | |||
/** | |||
* Abtract method that get the input stream of this part. | |||
* | |||
* | |||
* @exception IOException | |||
* Throws if an IO Exception occur in the implementation | |||
* method. | |||
@@ -619,7 +619,7 @@ public abstract class PackagePart implements RelationshipSource { | |||
* Save the content of this part and the associated relationships part (if | |||
* this part own at least one relationship) into the specified output | |||
* stream. | |||
* | |||
* | |||
* @param zos | |||
* Output stream to save this part. | |||
* @throws OpenXML4JException | |||
@@ -629,7 +629,7 @@ public abstract class PackagePart implements RelationshipSource { | |||
/** | |||
* Load the content of this part. | |||
* | |||
* | |||
* @param ios | |||
* The input stream of the content to load. | |||
* @return <b>true</b> if the content has been successfully loaded, else |
@@ -22,7 +22,7 @@ import java.net.URISyntaxException; | |||
/** | |||
* A part relationship. | |||
* | |||
* | |||
* @author Julien Chable | |||
* @version 1.0 | |||
*/ | |||
@@ -86,7 +86,7 @@ public final class PackageRelationship { | |||
/** | |||
* Constructor. | |||
* | |||
* | |||
* @param pkg | |||
* @param sourcePart | |||
* @param targetUri | |||
@@ -171,19 +171,19 @@ public final class PackageRelationship { | |||
} | |||
/** | |||
* | |||
* | |||
* @return URL of the source part of this relationship | |||
*/ | |||
public URI getSourceURI() { | |||
if (source == null) { | |||
return PackagingURIHelper.PACKAGE_ROOT_URI; | |||
} | |||
return source.partName.getURI(); | |||
return source._partName.getURI(); | |||
} | |||
/** | |||
* public URI getSourceUri(){ } | |||
* | |||
* | |||
* @return the targetMode | |||
*/ | |||
public TargetMode getTargetMode() { | |||
@@ -199,7 +199,7 @@ public final class PackageRelationship { | |||
if(targetMode == TargetMode.EXTERNAL) { | |||
return targetUri; | |||
} | |||
// Internal target | |||
// If it isn't absolute, resolve it relative | |||
// to ourselves |
@@ -34,7 +34,7 @@ import org.apache.poi.util.POILogFactory; | |||
/** | |||
* Represents a collection of PackageRelationship elements that are owned by a | |||
* given PackagePart or the Package. | |||
* | |||
* | |||
* @author Julien Chable, CDubettier | |||
* @version 0.1 | |||
*/ | |||
@@ -83,11 +83,11 @@ public final class PackageRelationshipCollection implements | |||
/** | |||
* Copy constructor. | |||
* | |||
* | |||
* This collection will contain only elements from the specified collection | |||
* for which the type is compatible with the specified relationship type | |||
* filter. | |||
* | |||
* | |||
* @param coll | |||
* Collection to import. | |||
* @param filter | |||
@@ -112,21 +112,21 @@ public final class PackageRelationshipCollection implements | |||
/** | |||
* Constructor. | |||
* | |||
* | |||
* @throws InvalidFormatException | |||
* Throws if the format of the content part is invalid. | |||
* | |||
* | |||
* @throws InvalidOperationException | |||
* Throws if the specified part is a relationship part. | |||
*/ | |||
public PackageRelationshipCollection(PackagePart part) | |||
throws InvalidFormatException { | |||
this(part.container, part); | |||
this(part._container, part); | |||
} | |||
/** | |||
* Constructor. Parse the existing package relationship part if one exists. | |||
* | |||
* | |||
* @param container | |||
* The parent package. | |||
* @param part | |||
@@ -159,7 +159,7 @@ public final class PackageRelationshipCollection implements | |||
/** | |||
* Get the relationship part name of the specified part. | |||
* | |||
* | |||
* @param part | |||
* The part . | |||
* @return The relationship part name of the specified part. Be careful, | |||
@@ -181,7 +181,7 @@ public final class PackageRelationshipCollection implements | |||
/** | |||
* Add the specified relationship to the collection. | |||
* | |||
* | |||
* @param relPart | |||
* The relationship to add. | |||
*/ | |||
@@ -192,7 +192,7 @@ public final class PackageRelationshipCollection implements | |||
/** | |||
* Add a relationship to the collection. | |||
* | |||
* | |||
* @param targetUri | |||
* Target URI. | |||
* @param targetMode | |||
@@ -224,7 +224,7 @@ public final class PackageRelationshipCollection implements | |||
/** | |||
* Remove a relationship by its ID. | |||
* | |||
* | |||
* @param id | |||
* The relationship ID to remove. | |||
*/ | |||
@@ -240,7 +240,7 @@ public final class PackageRelationshipCollection implements | |||
/** | |||
* Remove a relationship by its reference. | |||
* | |||
* | |||
* @param rel | |||
* The relationship to delete. | |||
*/ | |||
@@ -254,7 +254,7 @@ public final class PackageRelationshipCollection implements | |||
/** | |||
* Retrieves a relationship by its index in the collection. | |||
* | |||
* | |||
* @param index | |||
* Must be a value between [0-relationships_count-1] | |||
*/ | |||
@@ -273,7 +273,7 @@ public final class PackageRelationshipCollection implements | |||
/** | |||
* Retrieves a package relationship based on its id. | |||
* | |||
* | |||
* @param id | |||
* ID of the package relationship to retrieve. | |||
* @return The package relationship identified by the specified id. | |||
@@ -291,7 +291,7 @@ public final class PackageRelationshipCollection implements | |||
/** | |||
* Parse the relationship part and add all relationship in this collection. | |||
* | |||
* | |||
* @param relPart | |||
* The package part to parse. | |||
* @throws InvalidFormatException | |||
@@ -376,7 +376,7 @@ public final class PackageRelationshipCollection implements | |||
/** | |||
* Retrieves all relations with the specified type. | |||
* | |||
* | |||
* @param typeFilter | |||
* Relationship type filter. If <b>null</b> then all | |||
* relationships are returned. | |||
@@ -398,7 +398,7 @@ public final class PackageRelationshipCollection implements | |||
/** | |||
* Get an iterator of a collection with all relationship with the specified | |||
* type. | |||
* | |||
* | |||
* @param typeFilter | |||
* Type filter. | |||
* @return An iterator to a collection containing all relationships with the | |||
@@ -429,15 +429,15 @@ public final class PackageRelationshipCollection implements | |||
} else { | |||
str = relationshipsByID.size() + " relationship(s) = ["; | |||
} | |||
if ((relationshipPart != null) && (relationshipPart.partName != null)) { | |||
str = str + "," + relationshipPart.partName; | |||
if ((relationshipPart != null) && (relationshipPart._partName != null)) { | |||
str = str + "," + relationshipPart._partName; | |||
} else { | |||
str = str + ",relationshipPart=null"; | |||
} | |||
// Source of this relationship | |||
if ((sourcePart != null) && (sourcePart.partName != null)) { | |||
str = str + "," + sourcePart.partName; | |||
if ((sourcePart != null) && (sourcePart._partName != null)) { | |||
str = str + "," + sourcePart._partName; | |||
} else { | |||
str = str + ",sourcePart=null"; | |||
} |
@@ -24,7 +24,7 @@ public interface RelationshipSource { | |||
/** | |||
* Add a relationship to a part (except relationships part). | |||
* | |||
* | |||
* @param targetPartName | |||
* Name of the target part. This one must be relative to the | |||
* source root directory of the part. | |||
@@ -56,7 +56,7 @@ public interface RelationshipSource { | |||
* @param id | |||
* Relationship unique id. | |||
* @return The newly created and added relationship | |||
* | |||
* | |||
* @throws InvalidFormatException | |||
* If the URI point to a relationship part URI. | |||
*/ | |||
@@ -67,28 +67,28 @@ public interface RelationshipSource { | |||
/** | |||
* Adds an external relationship to a part | |||
* (except relationships part). | |||
* | |||
* | |||
* The targets of external relationships are not | |||
* subject to the same validity checks that internal | |||
* ones are, as the contents is potentially | |||
* any file, URL or similar. | |||
* | |||
* | |||
* @param target External target of the relationship | |||
* @param relationshipType Type of relationship. | |||
* @return The newly created and added relationship | |||
* @see org.apache.poi.openxml4j.opc.RelationshipSource#addExternalRelationship(java.lang.String, java.lang.String) | |||
*/ | |||
public PackageRelationship addExternalRelationship(String target, String relationshipType); | |||
/** | |||
* Adds an external relationship to a part | |||
* (except relationships part). | |||
* | |||
* | |||
* The targets of external relationships are not | |||
* subject to the same validity checks that internal | |||
* ones are, as the contents is potentially | |||
* any file, URL or similar. | |||
* | |||
* | |||
* @param target External target of the relationship | |||
* @param relationshipType Type of relationship. | |||
* @param id Relationship unique id. | |||
@@ -96,7 +96,7 @@ public interface RelationshipSource { | |||
* @see org.apache.poi.openxml4j.opc.RelationshipSource#addExternalRelationship(java.lang.String, java.lang.String) | |||
*/ | |||
public PackageRelationship addExternalRelationship(String target, String relationshipType, String id); | |||
/** | |||
* Delete all the relationships attached to this. | |||
*/ | |||
@@ -104,7 +104,7 @@ public interface RelationshipSource { | |||
/** | |||
* Delete the relationship specified by its id. | |||
* | |||
* | |||
* @param id | |||
* The ID identified the part to delete. | |||
*/ | |||
@@ -112,7 +112,7 @@ public interface RelationshipSource { | |||
/** | |||
* Retrieve all the relationships attached to this. | |||
* | |||
* | |||
* @return This part's relationships. | |||
* @throws OpenXML4JException | |||
*/ | |||
@@ -121,7 +121,7 @@ public interface RelationshipSource { | |||
/** | |||
* Retrieves a package relationship from its id. | |||
* | |||
* | |||
* @param id | |||
* ID of the package relationship to retrieve. | |||
* @return The package relationship | |||
@@ -131,7 +131,7 @@ public interface RelationshipSource { | |||
/** | |||
* Retrieve all relationships attached to this part which have the specified | |||
* type. | |||
* | |||
* | |||
* @param relationshipType | |||
* Relationship type filter. | |||
* @return All relationships from this part that have the specified type. | |||
@@ -141,12 +141,12 @@ public interface RelationshipSource { | |||
* If the package is open in write only mode. | |||
*/ | |||
public abstract PackageRelationshipCollection getRelationshipsByType( | |||
String relationshipType) throws InvalidFormatException, | |||
String relationshipType) throws InvalidFormatException, | |||
IllegalArgumentException, OpenXML4JException; | |||
/** | |||
* Knows if the part have any relationships. | |||
* | |||
* | |||
* @return <b>true</b> if the part have at least one relationship else | |||
* <b>false</b>. | |||
*/ | |||
@@ -154,13 +154,12 @@ public interface RelationshipSource { | |||
/** | |||
* Checks if the specified relationship is part of this package part. | |||
* | |||
* | |||
* @param rel | |||
* The relationship to check. | |||
* @return <b>true</b> if the specified relationship exists in this part, | |||
* else returns <b>false</b> | |||
*/ | |||
@SuppressWarnings("finally") | |||
public abstract boolean isRelationshipExists(PackageRelationship rel); | |||
} |
@@ -423,7 +423,7 @@ public final class ZipPackage extends Package { | |||
+ ZipHelper.getZipItemNameFromOPCName(part | |||
.getPartName().getName()) + "'"); | |||
PartMarshaller marshaller = partMarshallers | |||
.get(part.contentType); | |||
.get(part._contentType); | |||
if (marshaller != null) { | |||
if (!marshaller.marshall(part, zos)) { | |||
throw new OpenXML4JException( |
@@ -29,7 +29,7 @@ import org.apache.poi.openxml4j.opc.internal.marshallers.ZipPartMarshaller; | |||
/** | |||
* Zip implementation of a PackagePart. | |||
* | |||
* | |||
* @author Julien Chable | |||
* @version 1.0 | |||
* @see PackagePart | |||
@@ -43,7 +43,7 @@ public class ZipPackagePart extends PackagePart { | |||
/** | |||
* Constructor. | |||
* | |||
* | |||
* @param container | |||
* The container package. | |||
* @param partName | |||
@@ -60,7 +60,7 @@ public class ZipPackagePart extends PackagePart { | |||
/** | |||
* Constructor. | |||
* | |||
* | |||
* @param container | |||
* The container package. | |||
* @param zipEntry | |||
@@ -81,7 +81,7 @@ public class ZipPackagePart extends PackagePart { | |||
/** | |||
* Get the zip entry of this part. | |||
* | |||
* | |||
* @return The zip entry in the zip structure coresponding to this part. | |||
*/ | |||
public ZipEntry getZipArchive() { | |||
@@ -91,21 +91,21 @@ public class ZipPackagePart extends PackagePart { | |||
/** | |||
* Implementation of the getInputStream() which return the inputStream of | |||
* this part zip entry. | |||
* | |||
* | |||
* @return Input stream of this part zip entry. | |||
*/ | |||
@Override | |||
protected InputStream getInputStreamImpl() throws IOException { | |||
// We use the getInputStream() method from java.util.zip.ZipFile | |||
// class which return an InputStream to this part zip entry. | |||
return ((ZipPackage) container).getZipArchive() | |||
return ((ZipPackage) _container).getZipArchive() | |||
.getInputStream(zipEntry); | |||
} | |||
/** | |||
* Implementation of the getOutputStream(). Return <b>null</b>. Normally | |||
* will never be called since the MemoryPackage is use instead. | |||
* | |||
* | |||
* @return <b>null</b> | |||
*/ | |||
@Override | |||
@@ -119,7 +119,7 @@ public class ZipPackagePart extends PackagePart { | |||
} | |||
@Override | |||
public boolean load(InputStream ios) throws InvalidFormatException { | |||
public boolean load(InputStream ios) { | |||
throw new InvalidOperationException("Method not implemented !"); | |||
} | |||
@@ -43,9 +43,8 @@ import org.dom4j.io.SAXReader; | |||
/** | |||
* Manage package content types ([Content_Types].xml part). | |||
* | |||
* | |||
* @author Julien Chable | |||
* @version 1.0 | |||
*/ | |||
public abstract class ContentTypeManager { | |||
@@ -90,7 +89,7 @@ public abstract class ContentTypeManager { | |||
/** | |||
* Constructor. Parses the content of the specified input stream. | |||
* | |||
* | |||
* @param in | |||
* If different of <i>null</i> then the content types part is | |||
* retrieve and parse. | |||
@@ -161,7 +160,7 @@ public abstract class ContentTypeManager { | |||
/** | |||
* Add an override content type for a specific part. | |||
* | |||
* | |||
* @param partName | |||
* Name of the part. | |||
* @param contentType | |||
@@ -176,7 +175,7 @@ public abstract class ContentTypeManager { | |||
/** | |||
* Add a content type associated with the specified extension. | |||
* | |||
* | |||
* @param extension | |||
* The part name extension to bind to a content type. | |||
* @param contentType | |||
@@ -267,7 +266,7 @@ public abstract class ContentTypeManager { | |||
/** | |||
* Check if the specified content type is already register. | |||
* | |||
* | |||
* @param contentType | |||
* The content type to check. | |||
* @return <code>true</code> if the specified content type is already | |||
@@ -315,7 +314,7 @@ public abstract class ContentTypeManager { | |||
* @return The content type associated with the URI (in case of an override | |||
* content type) or the extension (in case of default content type), | |||
* else <code>null</code>. | |||
* | |||
* | |||
* @exception OpenXML4JRuntimeException | |||
* Throws if the content type manager is not able to find the | |||
* content from an existing part. | |||
@@ -342,9 +341,8 @@ public abstract class ContentTypeManager { | |||
if (this.container != null && this.container.getPart(partName) != null) { | |||
throw new OpenXML4JRuntimeException( | |||
"Rule M2.4 exception : this error should NEVER happen, if so please send a mail to the developers team, thanks !"); | |||
} else { | |||
return null; | |||
} | |||
return null; | |||
} | |||
/** | |||
@@ -358,7 +356,7 @@ public abstract class ContentTypeManager { | |||
/** | |||
* Clear all override content types. | |||
* | |||
* | |||
*/ | |||
public void clearOverrideContentTypes() { | |||
if (this.overrideContentType != null) | |||
@@ -367,7 +365,7 @@ public abstract class ContentTypeManager { | |||
/** | |||
* Parse the content types part. | |||
* | |||
* | |||
* @throws InvalidFormatException | |||
* Throws if the content type doesn't exist or the XML format is | |||
* invalid. | |||
@@ -414,7 +412,7 @@ public abstract class ContentTypeManager { | |||
/** | |||
* Save the contents type part. | |||
* | |||
* | |||
* @param outStream | |||
* The output stream use to save the XML content of the content | |||
* types part. | |||
@@ -448,7 +446,7 @@ public abstract class ContentTypeManager { | |||
/** | |||
* Use to append specific type XML elements, use by the save() method. | |||
* | |||
* | |||
* @param root | |||
* XML parent element use to append this override type element. | |||
* @param entry | |||
@@ -459,13 +457,13 @@ public abstract class ContentTypeManager { | |||
Entry<PackagePartName, String> entry) { | |||
root.addElement(OVERRIDE_TAG_NAME).addAttribute( | |||
PART_NAME_ATTRIBUTE_NAME, | |||
((PackagePartName) entry.getKey()).getName()).addAttribute( | |||
CONTENT_TYPE_ATTRIBUTE_NAME, (String) entry.getValue()); | |||
entry.getKey().getName()).addAttribute( | |||
CONTENT_TYPE_ATTRIBUTE_NAME, entry.getValue()); | |||
} | |||
/** | |||
* Use to append default types XML elements, use by the save() metid. | |||
* | |||
* | |||
* @param root | |||
* XML parent element use to append this default type element. | |||
* @param entry | |||
@@ -474,16 +472,16 @@ public abstract class ContentTypeManager { | |||
*/ | |||
private void appendDefaultType(Element root, Entry<String, String> entry) { | |||
root.addElement(DEFAULT_TAG_NAME).addAttribute( | |||
EXTENSION_ATTRIBUTE_NAME, (String) entry.getKey()) | |||
EXTENSION_ATTRIBUTE_NAME, entry.getKey()) | |||
.addAttribute(CONTENT_TYPE_ATTRIBUTE_NAME, | |||
(String) entry.getValue()); | |||
entry.getValue()); | |||
} | |||
/** | |||
* Specific implementation of the save method. Call by the save() method, | |||
* call before exiting. | |||
* | |||
* | |||
* @param out | |||
* The output stream use to write the content type XML. | |||
*/ |
@@ -41,7 +41,7 @@ public class XSSFExcelExtractor extends POIXMLTextExtractor implements org.apach | |||
private boolean formulasNotResults = false; | |||
private boolean includeCellComments = false; | |||
private boolean includeHeadersFooters = true; | |||
public XSSFExcelExtractor(String path) throws XmlException, OpenXML4JException, IOException { | |||
this(new XSSFWorkbook(path)); | |||
} | |||
@@ -52,14 +52,14 @@ public class XSSFExcelExtractor extends POIXMLTextExtractor implements org.apach | |||
super(workbook); | |||
this.workbook = workbook; | |||
} | |||
public static void main(String[] args) throws Exception { | |||
if(args.length < 1) { | |||
System.err.println("Use:"); | |||
System.err.println(" HXFExcelExtractor <filename.xlsx>"); | |||
System.exit(1); | |||
} | |||
POIXMLTextExtractor extractor = | |||
POIXMLTextExtractor extractor = | |||
new XSSFExcelExtractor(args[0]); | |||
System.out.println(extractor.getText()); | |||
} | |||
@@ -89,19 +89,19 @@ public class XSSFExcelExtractor extends POIXMLTextExtractor implements org.apach | |||
public void setIncludeHeadersFooters(boolean includeHeadersFooters) { | |||
this.includeHeadersFooters = includeHeadersFooters; | |||
} | |||
/** | |||
* Retreives the text contents of the file | |||
*/ | |||
public String getText() { | |||
StringBuffer text = new StringBuffer(); | |||
for(int i=0; i<workbook.getNumberOfSheets(); i++) { | |||
XSSFSheet sheet = (XSSFSheet)workbook.getSheetAt(i); | |||
XSSFSheet sheet = workbook.getSheetAt(i); | |||
if(includeSheetNames) { | |||
text.append(workbook.getSheetName(i) + "\n"); | |||
} | |||
// Header(s), if present | |||
if(includeHeadersFooters) { | |||
text.append( | |||
@@ -120,7 +120,7 @@ public class XSSFExcelExtractor extends POIXMLTextExtractor implements org.apach | |||
Row row = (Row)rawR; | |||
for(Iterator<Cell> ri = row.cellIterator(); ri.hasNext();) { | |||
Cell cell = ri.next(); | |||
// Is it a formula one? | |||
if(cell.getCellType() == Cell.CELL_TYPE_FORMULA && formulasNotResults) { | |||
text.append(cell.getCellFormula()); | |||
@@ -130,7 +130,7 @@ public class XSSFExcelExtractor extends POIXMLTextExtractor implements org.apach | |||
XSSFCell xc = (XSSFCell)cell; | |||
text.append(xc.getRawValue()); | |||
} | |||
// Output the comment, if requested and exists | |||
Comment comment = cell.getCellComment(); | |||
if(includeCellComments && comment != null) { | |||
@@ -139,13 +139,13 @@ public class XSSFExcelExtractor extends POIXMLTextExtractor implements org.apach | |||
String commentText = comment.getString().getString().replace('\n', ' '); | |||
text.append(" Comment by "+comment.getAuthor()+": "+commentText); | |||
} | |||
if(ri.hasNext()) | |||
text.append("\t"); | |||
} | |||
text.append("\n"); | |||
} | |||
// Finally footer(s), if present | |||
if(includeHeadersFooters) { | |||
text.append( | |||
@@ -159,10 +159,10 @@ public class XSSFExcelExtractor extends POIXMLTextExtractor implements org.apach | |||
); | |||
} | |||
} | |||
return text.toString(); | |||
} | |||
private String extractHeaderFooter(HeaderFooter hf) { | |||
return ExcelExtractor._extractHeaderFooter(hf); | |||
} |
@@ -585,9 +585,11 @@ public final class XSSFCell implements Cell { | |||
*/ | |||
public byte getErrorCellValue() { | |||
String code = getErrorCellString(); | |||
if(code == null) return 0; | |||
if (code == null) { | |||
return 0; | |||
} | |||
return (byte)FormulaError.forString(code).getCode(); | |||
return FormulaError.forString(code).getCode(); | |||
} | |||
/** | |||
@@ -778,7 +780,7 @@ public final class XSSFCell implements Cell { | |||
SpreadsheetVersion v = SpreadsheetVersion.EXCEL2007; | |||
int maxcol = SpreadsheetVersion.EXCEL2007.getLastColumnIndex(); | |||
if (cellIndex < 0 || cellIndex > maxcol) { | |||
throw new IllegalArgumentException("Invalid column index (" + cellIndex | |||
throw new IllegalArgumentException("Invalid column index (" + cellIndex | |||
+ "). Allowable column range for " + v.name() + " is (0.." | |||
+ maxcol + ") or ('A'..'" + v.getLastColumnName() + "')"); | |||
} | |||
@@ -848,7 +850,7 @@ public final class XSSFCell implements Cell { | |||
*/ | |||
private boolean convertCellValueToBoolean() { | |||
int cellType = getCellType(); | |||
if (cellType == CELL_TYPE_FORMULA) { | |||
cellType = getBaseCellType(false); | |||
} |
@@ -145,9 +145,8 @@ public class XSSFCellStyle implements CellStyle { | |||
CTCellAlignment align = cellXf.getAlignment(); | |||
if(align != null && align.isSetHorizontal()) { | |||
return HorizontalAlignment.values()[align.getHorizontal().intValue()-1]; | |||
} else { | |||
return HorizontalAlignment.GENERAL; | |||
} | |||
return HorizontalAlignment.GENERAL; | |||
} | |||
/** | |||
@@ -865,7 +864,7 @@ public class XSSFCellStyle implements CellStyle { | |||
*/ | |||
public void setDataFormat(short fmt) { | |||
cellXf.setApplyNumberFormat(true); | |||
cellXf.setNumFmtId((long)fmt); | |||
cellXf.setNumFmtId(fmt); | |||
} | |||
/** |
@@ -285,7 +285,7 @@ public class XSSFPrintSetup implements PrintSetup { | |||
* @see PaperSize | |||
*/ | |||
public PaperSize getPaperSizeEnum() { | |||
return PaperSize.values()[((int) getPaperSize() - 1)]; | |||
return PaperSize.values()[getPaperSize() - 1]; | |||
} | |||
/** |
@@ -255,7 +255,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { | |||
/** | |||
* Returns the name of this sheet | |||
* | |||
* | |||
* @return the name of this sheet | |||
*/ | |||
public String getSheetName() { | |||
@@ -358,7 +358,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { | |||
public void createFreezePane(int colSplit, int rowSplit) { | |||
createFreezePane( colSplit, rowSplit, colSplit, rowSplit ); | |||
} | |||
/** | |||
* Creates a split (freezepane). Any existing freezepane or split pane is overwritten. | |||
* @param colSplit Horizonatal position of split. | |||
@@ -533,7 +533,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { | |||
worksheet.getSheetFormatPr() : | |||
worksheet.addNewSheetFormatPr(); | |||
} | |||
/** | |||
* Returns the CellStyle that applies to the given | |||
* (0 based) column, or null if no style has been | |||
@@ -571,7 +571,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { | |||
/** | |||
* Gets the flag indicating whether the window should show 0 (zero) in cells containing zero value. | |||
* When false, cells with zero value appear blank instead of showing the number zero. | |||
* | |||
* | |||
* @return whether all zero values on the worksheet are displayed | |||
*/ | |||
public boolean isDisplayZeros(){ | |||
@@ -1333,7 +1333,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { | |||
.getOutlineLevel(), true); | |||
// write collapse field | |||
setColumn((int) (lastColMax + 1), null, 0, null, null, Boolean.TRUE); | |||
setColumn(lastColMax + 1, null, 0, null, null, Boolean.TRUE); | |||
} | |||
@@ -1433,7 +1433,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { | |||
/** | |||
* Sets all adjacent columns of the same outline level to the specified | |||
* hidden status. | |||
* | |||
* | |||
* @param pIdx | |||
* the col info index of the start of the outline group | |||
* @return the column index of the last column in the outline group | |||
@@ -1626,7 +1626,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { | |||
/** | |||
* 'Collapsed' state is stored in a single column col info record | |||
* immediately after the outline group | |||
* | |||
* | |||
* @param idx | |||
* @return a boolean represented if the column is collapsed | |||
*/ | |||
@@ -1764,7 +1764,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { | |||
* outline level collapsed, thus hiding all the child rows. Note that in | |||
* this case, if the lowest level were expanded, the middle level would | |||
* remain collapsed. | |||
* | |||
* | |||
* @param rowIndex - | |||
* the row involved, 0 based | |||
* @param collapse - | |||
@@ -1895,8 +1895,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { | |||
endLevel = 0; | |||
endHidden = false; | |||
} else { | |||
endLevel = (int) (getRow(endOfOutlineGroupIdx).getCTRow() | |||
.getOutlineLevel()); | |||
endLevel = getRow(endOfOutlineGroupIdx).getCTRow().getOutlineLevel(); | |||
endHidden = getRow(endOfOutlineGroupIdx).getCTRow().getHidden(); | |||
} | |||
@@ -1931,7 +1930,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { | |||
else | |||
return getRow(collapseRow).getCTRow().getCollapsed(); | |||
} | |||
/** | |||
* Sets the zoom magnication for the sheet. The zoom is expressed as a | |||
* fraction. For example to express a zoom of 75% use 3 for the numerator |
@@ -35,22 +35,23 @@ import org.apache.poi.POIXMLDocumentPart; | |||
import org.apache.poi.openxml4j.opc.OPCPackage; | |||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.*; | |||
import junit.framework.AssertionFailedError; | |||
import junit.framework.TestCase; | |||
public class TestCommentsTable extends TestCase { | |||
private static final String TEST_A2_TEXT = "test A2 text"; | |||
private static final String TEST_A1_TEXT = "test A1 text"; | |||
private static final String TEST_AUTHOR = "test author"; | |||
public void testfindAuthor() throws Exception { | |||
CommentsDocument doc = CommentsDocument.Factory.newInstance(); | |||
CommentsDocument doc = CommentsDocument.Factory.newInstance(); | |||
doc.setComments(CTComments.Factory.newInstance()); | |||
ByteArrayOutputStream out = new ByteArrayOutputStream(); | |||
doc.save(out, POIXMLDocumentPart.DEFAULT_XML_OPTIONS); | |||
CommentsTable sheetComments = new CommentsTable(); | |||
sheetComments.readFrom(new ByteArrayInputStream(out.toByteArray())); | |||
ByteArrayOutputStream out = new ByteArrayOutputStream(); | |||
doc.save(out, POIXMLDocumentPart.DEFAULT_XML_OPTIONS); | |||
CommentsTable sheetComments = new CommentsTable(); | |||
sheetComments.readFrom(new ByteArrayInputStream(out.toByteArray())); | |||
assertEquals(0, sheetComments.findAuthor(TEST_AUTHOR)); | |||
assertEquals(1, sheetComments.findAuthor("another author")); | |||
@@ -58,19 +59,19 @@ public class TestCommentsTable extends TestCase { | |||
assertEquals(2, sheetComments.findAuthor("YAA")); | |||
assertEquals(1, sheetComments.findAuthor("another author")); | |||
} | |||
public void testGetCellComment() throws Exception { | |||
CommentsDocument doc = CommentsDocument.Factory.newInstance(); | |||
CommentsDocument doc = CommentsDocument.Factory.newInstance(); | |||
doc.setComments(CTComments.Factory.newInstance()); | |||
ByteArrayOutputStream out = new ByteArrayOutputStream(); | |||
doc.save(out, POIXMLDocumentPart.DEFAULT_XML_OPTIONS); | |||
CommentsTable sheetComments = new CommentsTable(); | |||
sheetComments.readFrom(new ByteArrayInputStream(out.toByteArray())); | |||
ByteArrayOutputStream out = new ByteArrayOutputStream(); | |||
doc.save(out, POIXMLDocumentPart.DEFAULT_XML_OPTIONS); | |||
CommentsTable sheetComments = new CommentsTable(); | |||
sheetComments.readFrom(new ByteArrayInputStream(out.toByteArray())); | |||
CTComments comments = sheetComments.getCTComments(); | |||
CTCommentList commentList = comments.addNewCommentList(); | |||
// Create 2 comments for A1 and A" cells | |||
CTComment comment0 = commentList.insertNewComment(0); | |||
comment0.setRef("A1"); | |||
@@ -82,7 +83,7 @@ public class TestCommentsTable extends TestCase { | |||
CTRst ctrst1 = CTRst.Factory.newInstance(); | |||
ctrst1.setT(TEST_A2_TEXT); | |||
comment1.setText(ctrst1); | |||
// test finding the right comment for a cell | |||
assertEquals(TEST_A1_TEXT, sheetComments.findCellComment("A1").getString().getString()); | |||
assertEquals(TEST_A1_TEXT, sheetComments.findCellComment(0, 0).getString().getString()); | |||
@@ -91,77 +92,81 @@ public class TestCommentsTable extends TestCase { | |||
assertNull(sheetComments.findCellComment("A3")); | |||
assertNull(sheetComments.findCellComment(2, 0)); | |||
} | |||
public void testAddCellComment() throws Exception { | |||
CommentsDocument doc = CommentsDocument.Factory.newInstance(); | |||
CommentsDocument doc = CommentsDocument.Factory.newInstance(); | |||
doc.setComments(CTComments.Factory.newInstance()); | |||
ByteArrayOutputStream out = new ByteArrayOutputStream(); | |||
doc.save(out, POIXMLDocumentPart.DEFAULT_XML_OPTIONS); | |||
CommentsTable sheetComments = new CommentsTable(); | |||
sheetComments.readFrom(new ByteArrayInputStream(out.toByteArray())); | |||
ByteArrayOutputStream out = new ByteArrayOutputStream(); | |||
doc.save(out, POIXMLDocumentPart.DEFAULT_XML_OPTIONS); | |||
CommentsTable sheetComments = new CommentsTable(); | |||
sheetComments.readFrom(new ByteArrayInputStream(out.toByteArray())); | |||
CTCommentList commentList = sheetComments.getCTComments().addNewCommentList(); | |||
assertEquals(0, commentList.sizeOfCommentArray()); | |||
XSSFComment comment = sheetComments.addComment(); | |||
comment.setAuthor("test A1 author"); | |||
comment.setRow(0); | |||
comment.setColumn((short)0); | |||
assertEquals(1, commentList.sizeOfCommentArray()); | |||
assertEquals("test A1 author", sheetComments.getAuthor(commentList.getCommentArray(0).getAuthorId())); | |||
assertEquals("test A1 author", comment.getAuthor()); | |||
// Change the author, check it updates | |||
comment.setAuthor("Another Author"); | |||
assertEquals(1, commentList.sizeOfCommentArray()); | |||
assertEquals("Another Author", comment.getAuthor()); | |||
} | |||
public void testDontLoostNewLines() throws Exception { | |||
File xml = new File( | |||
System.getProperty("HSSF.testdata.path") + | |||
File.separator + "WithVariousData.xlsx" | |||
); | |||
assertTrue(xml.exists()); | |||
OPCPackage pkg = OPCPackage.open(xml.toString()); | |||
XSSFWorkbook wb = new XSSFWorkbook(pkg); | |||
List<POIXMLDocumentPart> rels = wb.getSheetAt(0).getRelations(); | |||
CommentsTable ct = null; | |||
for(POIXMLDocumentPart p : rels) { | |||
if(p instanceof CommentsTable){ | |||
ct = (CommentsTable)p; | |||
break; | |||
} | |||
} | |||
assertNotNull(ct); | |||
List<POIXMLDocumentPart> rels = wb.getSheetAt(0).getRelations(); | |||
CommentsTable ct = null; | |||
for(POIXMLDocumentPart p : rels) { | |||
if(p instanceof CommentsTable){ | |||
ct = (CommentsTable)p; | |||
break; | |||
} | |||
} | |||
if (ct == null) { | |||
throw new AssertionFailedError("didn't find comments table"); | |||
} | |||
assertEquals(2, ct.getNumberOfComments()); | |||
assertEquals(1, ct.getNumberOfAuthors()); | |||
XSSFComment comment = ct.findCellComment("C5"); | |||
assertEquals("Nick Burch", comment.getAuthor()); | |||
assertEquals("Nick Burch:\nThis is a comment", comment.getString().getString()); | |||
wb = XSSFTestDataSamples.writeOutAndReadBack(wb); | |||
rels = wb.getSheetAt(0).getRelations(); | |||
ct = null; | |||
for(POIXMLDocumentPart p : rels) { | |||
if(p instanceof CommentsTable){ | |||
ct = (CommentsTable)p; | |||
break; | |||
} | |||
} | |||
assertNotNull(ct); | |||
wb = XSSFTestDataSamples.writeOutAndReadBack(wb); | |||
rels = wb.getSheetAt(0).getRelations(); | |||
ct = null; | |||
for(POIXMLDocumentPart p : rels) { | |||
if(p instanceof CommentsTable){ | |||
ct = (CommentsTable)p; | |||
break; | |||
} | |||
} | |||
if (ct == null) { | |||
throw new AssertionFailedError("didn't find comments table"); | |||
} | |||
assertEquals(2, ct.getNumberOfComments()); | |||
assertEquals(1, ct.getNumberOfAuthors()); | |||
comment = ct.findCellComment("C5"); | |||
assertEquals("Nick Burch", comment.getAuthor()); | |||
assertEquals("Nick Burch:\nThis is a comment", comment.getString().getString()); | |||
} | |||
@@ -171,127 +176,127 @@ public class TestCommentsTable extends TestCase { | |||
File.separator + "WithVariousData.xlsx" | |||
); | |||
assertTrue(xml.exists()); | |||
XSSFWorkbook workbook = new XSSFWorkbook(xml.toString()); | |||
Sheet sheet1 = workbook.getSheetAt(0); | |||
Sheet sheet2 = workbook.getSheetAt(1); | |||
assertTrue( ((XSSFSheet)sheet1).hasComments() ); | |||
assertFalse( ((XSSFSheet)sheet2).hasComments() ); | |||
// Comments should be in C5 and C7 | |||
Row r5 = sheet1.getRow(4); | |||
Row r7 = sheet1.getRow(6); | |||
assertNotNull( r5.getCell(2).getCellComment() ); | |||
assertNotNull( r7.getCell(2).getCellComment() ); | |||
// Check they have what we expect | |||
// TODO: Rich text formatting | |||
Comment cc5 = r5.getCell(2).getCellComment(); | |||
Comment cc7 = r7.getCell(2).getCellComment(); | |||
assertEquals("Nick Burch", cc5.getAuthor()); | |||
assertEquals("Nick Burch:\nThis is a comment", cc5.getString().getString()); | |||
assertEquals(4, cc5.getRow()); | |||
assertEquals(2, cc5.getColumn()); | |||
assertEquals("Nick Burch", cc7.getAuthor()); | |||
assertEquals("Nick Burch:\nComment #1\n", cc7.getString().getString()); | |||
assertEquals(6, cc7.getRow()); | |||
assertEquals(2, cc7.getColumn()); | |||
} | |||
public void testWriteRead() throws Exception { | |||
File xml = new File( | |||
System.getProperty("HSSF.testdata.path") + | |||
File.separator + "WithVariousData.xlsx" | |||
); | |||
assertTrue(xml.exists()); | |||
XSSFWorkbook workbook = new XSSFWorkbook(xml.toString()); | |||
Sheet sheet1 = workbook.getSheetAt(0); | |||
XSSFSheet sheet2 = (XSSFSheet)workbook.getSheetAt(1); | |||
assertTrue( ((XSSFSheet)sheet1).hasComments() ); | |||
assertFalse( ((XSSFSheet)sheet2).hasComments() ); | |||
XSSFSheet sheet1 = workbook.getSheetAt(0); | |||
XSSFSheet sheet2 = workbook.getSheetAt(1); | |||
assertTrue( sheet1.hasComments() ); | |||
assertFalse( sheet2.hasComments() ); | |||
// Change on comment on sheet 1, and add another into | |||
// sheet 2 | |||
Row r5 = sheet1.getRow(4); | |||
Comment cc5 = r5.getCell(2).getCellComment(); | |||
cc5.setAuthor("Apache POI"); | |||
cc5.setString(new XSSFRichTextString("Hello!")); | |||
Row r2s2 = sheet2.createRow(2); | |||
Cell c1r2s2 = r2s2.createCell(1); | |||
assertNull(c1r2s2.getCellComment()); | |||
Comment cc2 = sheet2.createComment(); | |||
cc2.setAuthor("Also POI"); | |||
cc2.setString(new XSSFRichTextString("A new comment")); | |||
c1r2s2.setCellComment(cc2); | |||
// Save, and re-load the file | |||
workbook = XSSFTestDataSamples.writeOutAndReadBack(workbook); | |||
workbook = XSSFTestDataSamples.writeOutAndReadBack(workbook); | |||
// Check we still have comments where we should do | |||
sheet1 = workbook.getSheetAt(0); | |||
sheet2 = (XSSFSheet)workbook.getSheetAt(1); | |||
sheet2 = workbook.getSheetAt(1); | |||
assertNotNull(sheet1.getRow(4).getCell(2).getCellComment()); | |||
assertNotNull(sheet1.getRow(6).getCell(2).getCellComment()); | |||
assertNotNull(sheet2.getRow(2).getCell(1).getCellComment()); | |||
// And check they still have the contents they should do | |||
assertEquals("Apache POI", | |||
assertEquals("Apache POI", | |||
sheet1.getRow(4).getCell(2).getCellComment().getAuthor()); | |||
assertEquals("Nick Burch", | |||
assertEquals("Nick Burch", | |||
sheet1.getRow(6).getCell(2).getCellComment().getAuthor()); | |||
assertEquals("Also POI", | |||
assertEquals("Also POI", | |||
sheet2.getRow(2).getCell(1).getCellComment().getAuthor()); | |||
assertEquals("Nick Burch:\nThis is a comment", | |||
sheet1.getRow(4).getCell(2).getCellComment().getString().getString()); | |||
} | |||
public void testReadWriteMultipleAuthors() throws Exception { | |||
File xml = new File( | |||
System.getProperty("HSSF.testdata.path") + | |||
File.separator + "WithMoreVariousData.xlsx" | |||
); | |||
assertTrue(xml.exists()); | |||
XSSFWorkbook workbook = new XSSFWorkbook(xml.toString()); | |||
Sheet sheet1 = workbook.getSheetAt(0); | |||
XSSFSheet sheet2 = (XSSFSheet)workbook.getSheetAt(1); | |||
assertTrue( ((XSSFSheet)sheet1).hasComments() ); | |||
assertFalse( ((XSSFSheet)sheet2).hasComments() ); | |||
assertEquals("Nick Burch", | |||
XSSFSheet sheet1 = workbook.getSheetAt(0); | |||
XSSFSheet sheet2 = workbook.getSheetAt(1); | |||
assertTrue( sheet1.hasComments() ); | |||
assertFalse( sheet2.hasComments() ); | |||
assertEquals("Nick Burch", | |||
sheet1.getRow(4).getCell(2).getCellComment().getAuthor()); | |||
assertEquals("Nick Burch", | |||
assertEquals("Nick Burch", | |||
sheet1.getRow(6).getCell(2).getCellComment().getAuthor()); | |||
assertEquals("Torchbox", | |||
assertEquals("Torchbox", | |||
sheet1.getRow(12).getCell(2).getCellComment().getAuthor()); | |||
// Save, and re-load the file | |||
workbook = XSSFTestDataSamples.writeOutAndReadBack(workbook); | |||
workbook = XSSFTestDataSamples.writeOutAndReadBack(workbook); | |||
// Check we still have comments where we should do | |||
sheet1 = workbook.getSheetAt(0); | |||
assertNotNull(sheet1.getRow(4).getCell(2).getCellComment()); | |||
assertNotNull(sheet1.getRow(6).getCell(2).getCellComment()); | |||
assertNotNull(sheet1.getRow(12).getCell(2).getCellComment()); | |||
// And check they still have the contents they should do | |||
assertEquals("Nick Burch", | |||
assertEquals("Nick Burch", | |||
sheet1.getRow(4).getCell(2).getCellComment().getAuthor()); | |||
assertEquals("Nick Burch", | |||
assertEquals("Nick Burch", | |||
sheet1.getRow(6).getCell(2).getCellComment().getAuthor()); | |||
assertEquals("Torchbox", | |||
assertEquals("Torchbox", | |||
sheet1.getRow(12).getCell(2).getCellComment().getAuthor()); | |||
// Todo - check text too, once bug fixed | |||
} | |||
} |
@@ -24,10 +24,10 @@ import org.apache.poi.xssf.XSSFTestDataSamples; | |||
import org.apache.poi.xssf.XSSFITestDataProvider; | |||
public final class TestXSSFHyperlink extends BaseTestHyperlink { | |||
@Override | |||
protected XSSFITestDataProvider getTestDataProvider() { | |||
return XSSFITestDataProvider.getInstance(); | |||
} | |||
@Override | |||
protected XSSFITestDataProvider getTestDataProvider() { | |||
return XSSFITestDataProvider.getInstance(); | |||
} | |||
@Override | |||
protected void setUp() { | |||
@@ -48,7 +48,7 @@ public final class TestXSSFHyperlink extends BaseTestHyperlink { | |||
XSSFWorkbook workbook = new XSSFWorkbook(xml.toString()); | |||
assertEquals(3, workbook.getNumberOfSheets()); | |||
XSSFSheet sheet = (XSSFSheet)workbook.getSheetAt(0); | |||
XSSFSheet sheet = workbook.getSheetAt(0); | |||
// Check the hyperlinks | |||
assertEquals(4, sheet.getNumHyperlinks()); | |||
@@ -65,7 +65,7 @@ public final class TestXSSFHyperlink extends BaseTestHyperlink { | |||
XSSFWorkbook workbook = new XSSFWorkbook(xml.toString()); | |||
CreationHelper createHelper = workbook.getCreationHelper(); | |||
assertEquals(3, workbook.getNumberOfSheets()); | |||
XSSFSheet sheet = (XSSFSheet)workbook.getSheetAt(0); | |||
XSSFSheet sheet = workbook.getSheetAt(0); | |||
// Check hyperlinks | |||
assertEquals(4, sheet.getNumHyperlinks()); | |||
@@ -81,7 +81,7 @@ public final class TestXSSFHyperlink extends BaseTestHyperlink { | |||
assertNotNull(wb2.getSheetAt(1)); | |||
assertNotNull(wb2.getSheetAt(2)); | |||
sheet = (XSSFSheet)wb2.getSheetAt(0); | |||
sheet = wb2.getSheetAt(0); | |||
// Check hyperlinks again |
@@ -167,8 +167,8 @@ public final class StyleSheet { | |||
break; | |||
case 0x9: | |||
newCHP._fSpec = true; | |||
newCHP._ftcSym = (short)Utils.convertBytesToShort(varParam, 0); | |||
newCHP._xchSym = (short)Utils.convertBytesToShort(varParam, 2); | |||
newCHP._ftcSym = Utils.convertBytesToShort(varParam, 0); | |||
newCHP._xchSym = Utils.convertBytesToShort(varParam, 2); | |||
break; | |||
case 0xa: | |||
newCHP._fOle2 = getFlag(param); | |||
@@ -453,8 +453,8 @@ public final class StyleSheet { | |||
doCHPOperation(oldCHP, newCHP, 0x47, param, varParam, grpprl, offset, styleSheet); | |||
break; | |||
case 0x4d: | |||
float percentage = (float)param/100.0f; | |||
int add = (int)((float)percentage * (float)newCHP._hps); | |||
float percentage = param/100.0f; | |||
int add = (int)(percentage * newCHP._hps); | |||
newCHP._hps += add; | |||
break; | |||
case 0x4e: | |||
@@ -485,7 +485,7 @@ public final class StyleSheet { | |||
break; | |||
case 0x57: | |||
newCHP._fPropMark = getFlag(varParam[0]); | |||
newCHP._ibstPropRMark = (short)Utils.convertBytesToShort(varParam, 1); | |||
newCHP._ibstPropRMark = Utils.convertBytesToShort(varParam, 1); | |||
newCHP._dttmPropRMark = Utils.convertBytesToInt(varParam, 3); | |||
break; | |||
case 0x58: | |||
@@ -512,7 +512,7 @@ public final class StyleSheet { | |||
break; | |||
case 0x62: | |||
newCHP._fDispFldRMark = getFlag(varParam[0]); | |||
newCHP._ibstDispFldRMark = (short)Utils.convertBytesToShort(varParam, 1); | |||
newCHP._ibstDispFldRMark = Utils.convertBytesToShort(varParam, 1); | |||
newCHP._dttmDispFldRMark = Utils.convertBytesToInt(varParam, 3); | |||
System.arraycopy(varParam, 7, newCHP._xstDispFldRMark, 0, 32); | |||
break; | |||
@@ -524,8 +524,8 @@ public final class StyleSheet { | |||
newCHP._dttmRMarkDel[1] = Utils.convertBytesToShort(grpprl, offset - 2); | |||
break; | |||
case 0x65: | |||
newCHP._brc[0] = (short)Utils.convertBytesToShort(grpprl, offset - 4); | |||
newCHP._brc[1] = (short)Utils.convertBytesToShort(grpprl, offset - 2); | |||
newCHP._brc[0] = Utils.convertBytesToShort(grpprl, offset - 4); | |||
newCHP._brc[1] = Utils.convertBytesToShort(grpprl, offset - 2); | |||
break; | |||
case 0x66: | |||
newCHP._shd = (short)param; | |||
@@ -834,28 +834,28 @@ public final class StyleSheet { | |||
newPAP._wr = (byte)param; | |||
break; | |||
case 0x24: | |||
newPAP._brcTop[0] = (short)Utils.convertBytesToShort(grpprl, offset - 4); | |||
newPAP._brcTop[1] = (short)Utils.convertBytesToShort(grpprl, offset - 2); | |||
newPAP._brcTop[0] = Utils.convertBytesToShort(grpprl, offset - 4); | |||
newPAP._brcTop[1] = Utils.convertBytesToShort(grpprl, offset - 2); | |||
break; | |||
case 0x25: | |||
newPAP._brcLeft[0] = (short)Utils.convertBytesToShort(grpprl, offset - 4); | |||
newPAP._brcLeft[1] = (short)Utils.convertBytesToShort(grpprl, offset - 2); | |||
newPAP._brcLeft[0] = Utils.convertBytesToShort(grpprl, offset - 4); | |||
newPAP._brcLeft[1] = Utils.convertBytesToShort(grpprl, offset - 2); | |||
break; | |||
case 0x26: | |||
newPAP._brcBottom[0] = (short)Utils.convertBytesToShort(grpprl, offset - 4); | |||
newPAP._brcBottom[1] = (short)Utils.convertBytesToShort(grpprl, offset - 2); | |||
newPAP._brcBottom[0] = Utils.convertBytesToShort(grpprl, offset - 4); | |||
newPAP._brcBottom[1] = Utils.convertBytesToShort(grpprl, offset - 2); | |||
break; | |||
case 0x27: | |||
newPAP._brcRight[0] = (short)Utils.convertBytesToShort(grpprl, offset - 4); | |||
newPAP._brcRight[1] = (short)Utils.convertBytesToShort(grpprl, offset - 2); | |||
newPAP._brcRight[0] = Utils.convertBytesToShort(grpprl, offset - 4); | |||
newPAP._brcRight[1] = Utils.convertBytesToShort(grpprl, offset - 2); | |||
break; | |||
case 0x28: | |||
newPAP._brcBetween[0] = (short)Utils.convertBytesToShort(grpprl, offset - 4); | |||
newPAP._brcBetween[1] = (short)Utils.convertBytesToShort(grpprl, offset - 2); | |||
newPAP._brcBetween[0] = Utils.convertBytesToShort(grpprl, offset - 4); | |||
newPAP._brcBetween[1] = Utils.convertBytesToShort(grpprl, offset - 2); | |||
break; | |||
case 0x29: | |||
newPAP._brcBar[0] = (short)Utils.convertBytesToShort(grpprl, offset - 4); | |||
newPAP._brcBar[1] = (short)Utils.convertBytesToShort(grpprl, offset - 2); | |||
newPAP._brcBar[0] = Utils.convertBytesToShort(grpprl, offset - 4); | |||
newPAP._brcBar[1] = Utils.convertBytesToShort(grpprl, offset - 2); | |||
break; | |||
case 0x2a: | |||
newPAP._fNoAutoHyph = (byte)param; |
@@ -35,10 +35,10 @@ import org.apache.poi.util.LittleEndian; | |||
* | |||
* @author Ryan Ackley | |||
*/ | |||
public final class WordDocument | |||
{ | |||
/** byte buffer containing the main Document stream*/ | |||
public final class WordDocument { | |||
// TODO - name this constant properly | |||
private static final float K_1440_0F = 1440.0f; | |||
/** byte buffer containing the main Document stream*/ | |||
byte[] _header; | |||
/** contains all style information for this document see Word 97 Doc spec*/ | |||
StyleSheet _styleSheet; | |||
@@ -1160,19 +1160,19 @@ public final class WordDocument | |||
} | |||
if(pap._dxaLeft > 0) | |||
{ | |||
buf.append("start-indent=\"" + ((float)pap._dxaLeft)/1440.0f + "in\"\r\n"); | |||
buf.append("start-indent=\"" + pap._dxaLeft/K_1440_0F + "in\"\r\n"); | |||
} | |||
if(pap._dxaRight > 0) | |||
{ | |||
buf.append("end-indent=\"" + ((float)pap._dxaRight)/1440.0f + "in\"\r\n"); | |||
buf.append("end-indent=\"" + pap._dxaRight/K_1440_0F + "in\"\r\n"); | |||
} | |||
if(pap._dxaLeft1 != 0) | |||
{ | |||
buf.append("text-indent=\"" + ((float)pap._dxaLeft1)/1440.0f + "in\"\r\n"); | |||
buf.append("text-indent=\"" + pap._dxaLeft1/K_1440_0F + "in\"\r\n"); | |||
} | |||
if(pap._lspd[1] == 0) | |||
{ | |||
//buf.append("line-height=\"" + ((float)pap._lspd[0])/1440.0f + "in\"\r\n"); | |||
//buf.append("line-height=\"" + pap._lspd[0]/K_1440_0F + "in\"\r\n"); | |||
} | |||
addBorder(buf, pap._brcTop, "top"); | |||
addBorder(buf, pap._brcBottom, "bottom"); | |||
@@ -1190,7 +1190,7 @@ public final class WordDocument | |||
buf.append("font-size=\"" + (chp._hps / 2) + "pt\" "); | |||
buf.append("color=\"" + getColor(chp._ico) + "\" "); | |||
//not supported by fop | |||
//buf.append("letter-spacing=\"" + ((double)chp._dxaSpace)/1440.0f + "in\" "); | |||
//buf.append("letter-spacing=\"" + ((double)chp._dxaSpace)/K_1440_0F + "in\" "); | |||
addBorder(buf, chp._brc, "top"); | |||
addBorder(buf, chp._brc, "bottom"); | |||
@@ -1236,11 +1236,11 @@ public final class WordDocument | |||
} | |||
if(chp._paddingStart != 0) | |||
{ | |||
buf.append("padding-start=\"" + (float)chp._paddingStart/1440.0f + "in\" "); | |||
buf.append("padding-start=\"" + chp._paddingStart/K_1440_0F + "in\" "); | |||
} | |||
if(chp._paddingEnd != 0) | |||
{ | |||
buf.append("padding-end=\"" + (float)chp._paddingEnd/1440.0f + "in\" "); | |||
buf.append("padding-end=\"" + chp._paddingEnd/K_1440_0F + "in\" "); | |||
} | |||
buf.append(">"); | |||
} | |||
@@ -1416,12 +1416,12 @@ public final class WordDocument | |||
private String createPageMaster(SEP sep, String type, int section, | |||
String regionBefore, String regionAfter) | |||
{ | |||
float height = ((float)sep._yaPage)/1440.0f; | |||
float width = ((float)sep._xaPage)/1440.0f; | |||
float leftMargin = ((float)sep._dxaLeft)/1440.0f; | |||
float rightMargin = ((float)sep._dxaRight)/1440.0f; | |||
float topMargin = ((float)sep._dyaTop)/1440.0f; | |||
float bottomMargin = ((float)sep._dyaBottom)/1440.0f; | |||
float height = sep._yaPage/K_1440_0F; | |||
float width = sep._xaPage/K_1440_0F; | |||
float leftMargin = sep._dxaLeft/K_1440_0F; | |||
float rightMargin = sep._dxaRight/K_1440_0F; | |||
float topMargin = sep._dyaTop/K_1440_0F; | |||
float bottomMargin = sep._dyaBottom/K_1440_0F; | |||
//add these to the header | |||
String thisPage = type + "-page" + section; | |||
@@ -1452,7 +1452,7 @@ public final class WordDocument | |||
_headerBuffer.append("column-count=\"" + (sep._ccolM1 + 1) + "\" "); | |||
if(sep._fEvenlySpaced) | |||
{ | |||
_headerBuffer.append("column-gap=\"" + ((float)(sep._dxaColumns))/1440.0f + "in\""); | |||
_headerBuffer.append("column-gap=\"" + sep._dxaColumns/K_1440_0F + "in\""); | |||
} | |||
else | |||
{ | |||
@@ -1478,7 +1478,7 @@ public final class WordDocument | |||
if((brc[0] & 0xff00) != 0 && brc[0] != -1) | |||
{ | |||
int type = (brc[0] & 0xff00) >> 8; | |||
float width = ((float)(brc[0] & 0x00ff))/8.0f; | |||
float width = (brc[0] & 0x00ff)/8.0f; | |||
String style = getBorderStyle(brc[0]); | |||
String color = getColor(brc[1] & 0x00ff); | |||
String thickness = getBorderThickness(brc[0]); | |||
@@ -1764,7 +1764,7 @@ public final class WordDocument | |||
rowBuffer.append("<fo:table-row "); | |||
if(tap._dyaRowHeight > 0) | |||
{ | |||
rowBuffer.append("height=\"" + ((float)tap._dyaRowHeight)/1440.0f + "in\" "); | |||
rowBuffer.append("height=\"" + tap._dyaRowHeight/K_1440_0F + "in\" "); | |||
} | |||
if(tap._fCantSplit) | |||
{ | |||
@@ -1777,9 +1777,9 @@ public final class WordDocument | |||
TC tc = tap._rgtc[y]; | |||
overrideCellBorder(x, y, size, tap._itcMac, tc, tap); | |||
rowBuffer.append("<fo:table-cell "); | |||
rowBuffer.append("width=\"" + ((float)(tap._rgdxaCenter[y+1] - tap._rgdxaCenter[y]))/1440.0f + "in\" "); | |||
rowBuffer.append("padding-start=\"" + ((float)tap._dxaGapHalf)/1440.0f + "in\" "); | |||
rowBuffer.append("padding-end=\"" + ((float)tap._dxaGapHalf)/1440.0f + "in\" "); | |||
rowBuffer.append("width=\"" + (tap._rgdxaCenter[y+1] - tap._rgdxaCenter[y])/K_1440_0F + "in\" "); | |||
rowBuffer.append("padding-start=\"" + tap._dxaGapHalf/K_1440_0F + "in\" "); | |||
rowBuffer.append("padding-end=\"" + tap._dxaGapHalf/K_1440_0F + "in\" "); | |||
addBorder(rowBuffer, tc._brcTop, "top"); | |||
addBorder(rowBuffer, tc._brcLeft, "left"); | |||
addBorder(rowBuffer, tc._brcBottom, "bottom"); |
@@ -224,8 +224,8 @@ public final class StyleSheet implements HDFType { | |||
break; | |||
case 0x9: | |||
newCHP.setFSpec(true); | |||
newCHP.setFtcSym((short)LittleEndian.getShort(varParam, 0)); | |||
newCHP.setXchSym((short)LittleEndian.getShort(varParam, 2)); | |||
newCHP.setFtcSym(LittleEndian.getShort(varParam, 0)); | |||
newCHP.setXchSym(LittleEndian.getShort(varParam, 2)); | |||
break; | |||
case 0xa: | |||
newCHP.setFOle2(getFlag(param)); | |||
@@ -517,8 +517,8 @@ public final class StyleSheet implements HDFType { | |||
doCHPOperation(oldCHP, newCHP, 0x47, param, varParam, grpprl, offset, styleSheet); | |||
break; | |||
case 0x4d: | |||
float percentage = (float)param/100.0f; | |||
int add = (int)((float)percentage * (float)newCHP.getHps()); | |||
float percentage = param/100.0f; | |||
int add = (int)(percentage * newCHP.getHps()); | |||
newCHP.setHps(newCHP.getHps() + add); | |||
break; | |||
case 0x4e: | |||
@@ -549,7 +549,7 @@ public final class StyleSheet implements HDFType { | |||
break; | |||
case 0x57: | |||
newCHP.setFPropMark(varParam[0]); | |||
newCHP.setIbstPropRMark((short)LittleEndian.getShort(varParam, 1)); | |||
newCHP.setIbstPropRMark(LittleEndian.getShort(varParam, 1)); | |||
newCHP.setDttmPropRMark(LittleEndian.getInt(varParam, 3)); | |||
break; | |||
case 0x58: | |||
@@ -577,7 +577,7 @@ public final class StyleSheet implements HDFType { | |||
case 0x62: | |||
byte[] xstDispFldRMark = new byte[32]; | |||
newCHP.setFDispFldRMark(varParam[0]); | |||
newCHP.setIbstDispFldRMark((short)LittleEndian.getShort(varParam, 1)); | |||
newCHP.setIbstDispFldRMark(LittleEndian.getShort(varParam, 1)); | |||
newCHP.setDttmDispFldRMark(LittleEndian.getInt(varParam, 3)); | |||
System.arraycopy(varParam, 7, xstDispFldRMark, 0, 32); | |||
newCHP.setXstDispFldRMark(xstDispFldRMark); | |||
@@ -593,8 +593,8 @@ public final class StyleSheet implements HDFType { | |||
break; | |||
case 0x65: | |||
short[] brc = new short[2]; | |||
brc[0] = (short)LittleEndian.getShort(grpprl, offset - 4); | |||
brc[1] = (short)LittleEndian.getShort(grpprl, offset - 2); | |||
brc[0] = LittleEndian.getShort(grpprl, offset - 4); | |||
brc[1] = LittleEndian.getShort(grpprl, offset - 2); | |||
newCHP.setBrc(brc); | |||
break; | |||
case 0x66: | |||
@@ -947,33 +947,33 @@ public final class StyleSheet implements HDFType { | |||
break; | |||
case 0x24: | |||
short[] brcTop = newPAP.getBrcTop(); | |||
brcTop[0] = (short)LittleEndian.getShort(grpprl, offset - 4); | |||
brcTop[1] = (short)LittleEndian.getShort(grpprl, offset - 2); | |||
brcTop[0] = LittleEndian.getShort(grpprl, offset - 4); | |||
brcTop[1] = LittleEndian.getShort(grpprl, offset - 2); | |||
break; | |||
case 0x25: | |||
short[] brcLeft = newPAP.getBrcLeft(); | |||
brcLeft[0] = (short)LittleEndian.getShort(grpprl, offset - 4); | |||
brcLeft[1] = (short)LittleEndian.getShort(grpprl, offset - 2); | |||
brcLeft[0] = LittleEndian.getShort(grpprl, offset - 4); | |||
brcLeft[1] = LittleEndian.getShort(grpprl, offset - 2); | |||
break; | |||
case 0x26: | |||
short[] brcBottom = newPAP.getBrcBottom(); | |||
brcBottom[0] = (short)LittleEndian.getShort(grpprl, offset - 4); | |||
brcBottom[1] = (short)LittleEndian.getShort(grpprl, offset - 2); | |||
brcBottom[0] = LittleEndian.getShort(grpprl, offset - 4); | |||
brcBottom[1] = LittleEndian.getShort(grpprl, offset - 2); | |||
break; | |||
case 0x27: | |||
short[] brcRight = newPAP.getBrcRight(); | |||
brcRight[0] = (short)LittleEndian.getShort(grpprl, offset - 4); | |||
brcRight[1] = (short)LittleEndian.getShort(grpprl, offset - 2); | |||
brcRight[0] = LittleEndian.getShort(grpprl, offset - 4); | |||
brcRight[1] = LittleEndian.getShort(grpprl, offset - 2); | |||
break; | |||
case 0x28: | |||
short[] brcBetween = newPAP.getBrcBetween(); | |||
brcBetween[0] = (short)LittleEndian.getShort(grpprl, offset - 4); | |||
brcBetween[1] = (short)LittleEndian.getShort(grpprl, offset - 2); | |||
brcBetween[0] = LittleEndian.getShort(grpprl, offset - 4); | |||
brcBetween[1] = LittleEndian.getShort(grpprl, offset - 2); | |||
break; | |||
case 0x29: | |||
short[] brcBar = newPAP.getBrcBar(); | |||
brcBar[0] = (short)LittleEndian.getShort(grpprl, offset - 4); | |||
brcBar[1] = (short)LittleEndian.getShort(grpprl, offset - 2); | |||
brcBar[0] = LittleEndian.getShort(grpprl, offset - 4); | |||
brcBar[1] = LittleEndian.getShort(grpprl, offset - 2); | |||
break; | |||
case 0x2a: | |||
newPAP.setFNoAutoHyph((byte)param); |
@@ -814,9 +814,7 @@ public abstract class CHPAbstractType | |||
*/ | |||
public void setFBold(boolean value) | |||
{ | |||
field_2_format_flags = (int)fBold.setBoolean(field_2_format_flags, value); | |||
field_2_format_flags = fBold.setBoolean(field_2_format_flags, value); | |||
} | |||
/** | |||
@@ -826,7 +824,6 @@ public abstract class CHPAbstractType | |||
public boolean isFBold() | |||
{ | |||
return fBold.isSet(field_2_format_flags); | |||
} | |||
/** | |||
@@ -835,9 +832,7 @@ public abstract class CHPAbstractType | |||
*/ | |||
public void setFItalic(boolean value) | |||
{ | |||
field_2_format_flags = (int)fItalic.setBoolean(field_2_format_flags, value); | |||
field_2_format_flags = fItalic.setBoolean(field_2_format_flags, value); | |||
} | |||
/** | |||
@@ -847,7 +842,6 @@ public abstract class CHPAbstractType | |||
public boolean isFItalic() | |||
{ | |||
return fItalic.isSet(field_2_format_flags); | |||
} | |||
/** | |||
@@ -856,9 +850,7 @@ public abstract class CHPAbstractType | |||
*/ | |||
public void setFRMarkDel(boolean value) | |||
{ | |||
field_2_format_flags = (int)fRMarkDel.setBoolean(field_2_format_flags, value); | |||
field_2_format_flags = fRMarkDel.setBoolean(field_2_format_flags, value); | |||
} | |||
/** | |||
@@ -868,7 +860,6 @@ public abstract class CHPAbstractType | |||
public boolean isFRMarkDel() | |||
{ | |||
return fRMarkDel.isSet(field_2_format_flags); | |||
} | |||
/** | |||
@@ -877,9 +868,7 @@ public abstract class CHPAbstractType | |||
*/ | |||
public void setFOutline(boolean value) | |||
{ | |||
field_2_format_flags = (int)fOutline.setBoolean(field_2_format_flags, value); | |||
field_2_format_flags = fOutline.setBoolean(field_2_format_flags, value); | |||
} | |||
/** | |||
@@ -889,7 +878,6 @@ public abstract class CHPAbstractType | |||
public boolean isFOutline() | |||
{ | |||
return fOutline.isSet(field_2_format_flags); | |||
} | |||
/** | |||
@@ -898,9 +886,7 @@ public abstract class CHPAbstractType | |||
*/ | |||
public void setFFldVanish(boolean value) | |||
{ | |||
field_2_format_flags = (int)fFldVanish.setBoolean(field_2_format_flags, value); | |||
field_2_format_flags = fFldVanish.setBoolean(field_2_format_flags, value); | |||
} | |||
/** | |||
@@ -910,7 +896,6 @@ public abstract class CHPAbstractType | |||
public boolean isFFldVanish() | |||
{ | |||
return fFldVanish.isSet(field_2_format_flags); | |||
} | |||
/** | |||
@@ -919,9 +904,7 @@ public abstract class CHPAbstractType | |||
*/ | |||
public void setFSmallCaps(boolean value) | |||
{ | |||
field_2_format_flags = (int)fSmallCaps.setBoolean(field_2_format_flags, value); | |||
field_2_format_flags = fSmallCaps.setBoolean(field_2_format_flags, value); | |||
} | |||
/** | |||
@@ -931,7 +914,6 @@ public abstract class CHPAbstractType | |||
public boolean isFSmallCaps() | |||
{ | |||
return fSmallCaps.isSet(field_2_format_flags); | |||
} | |||
/** | |||
@@ -940,9 +922,7 @@ public abstract class CHPAbstractType | |||
*/ | |||
public void setFCaps(boolean value) | |||
{ | |||
field_2_format_flags = (int)fCaps.setBoolean(field_2_format_flags, value); | |||
field_2_format_flags = fCaps.setBoolean(field_2_format_flags, value); | |||
} | |||
/** | |||
@@ -952,7 +932,6 @@ public abstract class CHPAbstractType | |||
public boolean isFCaps() | |||
{ | |||
return fCaps.isSet(field_2_format_flags); | |||
} | |||
/** | |||
@@ -961,9 +940,7 @@ public abstract class CHPAbstractType | |||
*/ | |||
public void setFVanish(boolean value) | |||
{ | |||
field_2_format_flags = (int)fVanish.setBoolean(field_2_format_flags, value); | |||
field_2_format_flags = fVanish.setBoolean(field_2_format_flags, value); | |||
} | |||
/** | |||
@@ -973,7 +950,6 @@ public abstract class CHPAbstractType | |||
public boolean isFVanish() | |||
{ | |||
return fVanish.isSet(field_2_format_flags); | |||
} | |||
/** | |||
@@ -982,9 +958,7 @@ public abstract class CHPAbstractType | |||
*/ | |||
public void setFRMark(boolean value) | |||
{ | |||
field_2_format_flags = (int)fRMark.setBoolean(field_2_format_flags, value); | |||
field_2_format_flags = fRMark.setBoolean(field_2_format_flags, value); | |||
} | |||
/** | |||
@@ -994,7 +968,6 @@ public abstract class CHPAbstractType | |||
public boolean isFRMark() | |||
{ | |||
return fRMark.isSet(field_2_format_flags); | |||
} | |||
/** | |||
@@ -1003,9 +976,7 @@ public abstract class CHPAbstractType | |||
*/ | |||
public void setFSpec(boolean value) | |||
{ | |||
field_2_format_flags = (int)fSpec.setBoolean(field_2_format_flags, value); | |||
field_2_format_flags = fSpec.setBoolean(field_2_format_flags, value); | |||
} | |||
/** | |||
@@ -1015,7 +986,6 @@ public abstract class CHPAbstractType | |||
public boolean isFSpec() | |||
{ | |||
return fSpec.isSet(field_2_format_flags); | |||
} | |||
/** | |||
@@ -1024,9 +994,7 @@ public abstract class CHPAbstractType | |||
*/ | |||
public void setFStrike(boolean value) | |||
{ | |||
field_2_format_flags = (int)fStrike.setBoolean(field_2_format_flags, value); | |||
field_2_format_flags = fStrike.setBoolean(field_2_format_flags, value); | |||
} | |||
/** | |||
@@ -1036,7 +1004,6 @@ public abstract class CHPAbstractType | |||
public boolean isFStrike() | |||
{ | |||
return fStrike.isSet(field_2_format_flags); | |||
} | |||
/** | |||
@@ -1045,9 +1012,7 @@ public abstract class CHPAbstractType | |||
*/ | |||
public void setFObj(boolean value) | |||
{ | |||
field_2_format_flags = (int)fObj.setBoolean(field_2_format_flags, value); | |||
field_2_format_flags = fObj.setBoolean(field_2_format_flags, value); | |||
} | |||
/** | |||
@@ -1057,7 +1022,6 @@ public abstract class CHPAbstractType | |||
public boolean isFObj() | |||
{ | |||
return fObj.isSet(field_2_format_flags); | |||
} | |||
/** | |||
@@ -1066,9 +1030,7 @@ public abstract class CHPAbstractType | |||
*/ | |||
public void setFShadow(boolean value) | |||
{ | |||
field_2_format_flags = (int)fShadow.setBoolean(field_2_format_flags, value); | |||
field_2_format_flags = fShadow.setBoolean(field_2_format_flags, value); | |||
} | |||
/** | |||
@@ -1078,7 +1040,6 @@ public abstract class CHPAbstractType | |||
public boolean isFShadow() | |||
{ | |||
return fShadow.isSet(field_2_format_flags); | |||
} | |||
/** | |||
@@ -1087,9 +1048,7 @@ public abstract class CHPAbstractType | |||
*/ | |||
public void setFLowerCase(boolean value) | |||
{ | |||
field_2_format_flags = (int)fLowerCase.setBoolean(field_2_format_flags, value); | |||
field_2_format_flags = fLowerCase.setBoolean(field_2_format_flags, value); | |||
} | |||
/** | |||
@@ -1099,7 +1058,6 @@ public abstract class CHPAbstractType | |||
public boolean isFLowerCase() | |||
{ | |||
return fLowerCase.isSet(field_2_format_flags); | |||
} | |||
/** | |||
@@ -1108,9 +1066,7 @@ public abstract class CHPAbstractType | |||
*/ | |||
public void setFData(boolean value) | |||
{ | |||
field_2_format_flags = (int)fData.setBoolean(field_2_format_flags, value); | |||
field_2_format_flags = fData.setBoolean(field_2_format_flags, value); | |||
} | |||
/** | |||
@@ -1120,7 +1076,6 @@ public abstract class CHPAbstractType | |||
public boolean isFData() | |||
{ | |||
return fData.isSet(field_2_format_flags); | |||
} | |||
/** | |||
@@ -1129,9 +1084,7 @@ public abstract class CHPAbstractType | |||
*/ | |||
public void setFOle2(boolean value) | |||
{ | |||
field_2_format_flags = (int)fOle2.setBoolean(field_2_format_flags, value); | |||
field_2_format_flags = fOle2.setBoolean(field_2_format_flags, value); | |||
} | |||
/** | |||
@@ -1141,7 +1094,6 @@ public abstract class CHPAbstractType | |||
public boolean isFOle2() | |||
{ | |||
return fOle2.isSet(field_2_format_flags); | |||
} | |||
/** | |||
@@ -1150,9 +1102,7 @@ public abstract class CHPAbstractType | |||
*/ | |||
public void setFEmboss(boolean value) | |||
{ | |||
field_3_format_flags1 = (int)fEmboss.setBoolean(field_3_format_flags1, value); | |||
field_3_format_flags1 = fEmboss.setBoolean(field_3_format_flags1, value); | |||
} | |||
/** | |||
@@ -1162,7 +1112,6 @@ public abstract class CHPAbstractType | |||
public boolean isFEmboss() | |||
{ | |||
return fEmboss.isSet(field_3_format_flags1); | |||
} | |||
/** | |||
@@ -1171,9 +1120,7 @@ public abstract class CHPAbstractType | |||
*/ | |||
public void setFImprint(boolean value) | |||
{ | |||
field_3_format_flags1 = (int)fImprint.setBoolean(field_3_format_flags1, value); | |||
field_3_format_flags1 = fImprint.setBoolean(field_3_format_flags1, value); | |||
} | |||
/** | |||
@@ -1183,7 +1130,6 @@ public abstract class CHPAbstractType | |||
public boolean isFImprint() | |||
{ | |||
return fImprint.isSet(field_3_format_flags1); | |||
} | |||
/** | |||
@@ -1192,9 +1138,7 @@ public abstract class CHPAbstractType | |||
*/ | |||
public void setFDStrike(boolean value) | |||
{ | |||
field_3_format_flags1 = (int)fDStrike.setBoolean(field_3_format_flags1, value); | |||
field_3_format_flags1 = fDStrike.setBoolean(field_3_format_flags1, value); | |||
} | |||
/** | |||
@@ -1204,7 +1148,6 @@ public abstract class CHPAbstractType | |||
public boolean isFDStrike() | |||
{ | |||
return fDStrike.isSet(field_3_format_flags1); | |||
} | |||
/** | |||
@@ -1213,9 +1156,7 @@ public abstract class CHPAbstractType | |||
*/ | |||
public void setFUsePgsuSettings(boolean value) | |||
{ | |||
field_3_format_flags1 = (int)fUsePgsuSettings.setBoolean(field_3_format_flags1, value); | |||
field_3_format_flags1 = fUsePgsuSettings.setBoolean(field_3_format_flags1, value); | |||
} | |||
/** | |||
@@ -1225,7 +1166,6 @@ public abstract class CHPAbstractType | |||
public boolean isFUsePgsuSettings() | |||
{ | |||
return fUsePgsuSettings.isSet(field_3_format_flags1); | |||
} | |||
/** | |||
@@ -1235,8 +1175,6 @@ public abstract class CHPAbstractType | |||
public void setIcoHighlight(byte value) | |||
{ | |||
field_33_Highlight = (short)icoHighlight.setValue(field_33_Highlight, value); | |||
} | |||
/** | |||
@@ -1246,7 +1184,6 @@ public abstract class CHPAbstractType | |||
public byte getIcoHighlight() | |||
{ | |||
return ( byte )icoHighlight.getValue(field_33_Highlight); | |||
} | |||
/** | |||
@@ -1256,8 +1193,6 @@ public abstract class CHPAbstractType | |||
public void setFHighlight(boolean value) | |||
{ | |||
field_33_Highlight = (short)fHighlight.setBoolean(field_33_Highlight, value); | |||
} | |||
/** | |||
@@ -1267,7 +1202,6 @@ public abstract class CHPAbstractType | |||
public boolean isFHighlight() | |||
{ | |||
return fHighlight.isSet(field_33_Highlight); | |||
} | |||
/** | |||
@@ -1277,8 +1211,6 @@ public abstract class CHPAbstractType | |||
public void setKcd(byte value) | |||
{ | |||
field_33_Highlight = (short)kcd.setValue(field_33_Highlight, value); | |||
} | |||
/** | |||
@@ -1288,7 +1220,6 @@ public abstract class CHPAbstractType | |||
public byte getKcd() | |||
{ | |||
return ( byte )kcd.getValue(field_33_Highlight); | |||
} | |||
/** | |||
@@ -1298,8 +1229,6 @@ public abstract class CHPAbstractType | |||
public void setFNavHighlight(boolean value) | |||
{ | |||
field_33_Highlight = (short)fNavHighlight.setBoolean(field_33_Highlight, value); | |||
} | |||
/** | |||
@@ -1309,7 +1238,6 @@ public abstract class CHPAbstractType | |||
public boolean isFNavHighlight() | |||
{ | |||
return fNavHighlight.isSet(field_33_Highlight); | |||
} | |||
/** | |||
@@ -1319,8 +1247,6 @@ public abstract class CHPAbstractType | |||
public void setFChsDiff(boolean value) | |||
{ | |||
field_33_Highlight = (short)fChsDiff.setBoolean(field_33_Highlight, value); | |||
} | |||
/** | |||
@@ -1330,7 +1256,6 @@ public abstract class CHPAbstractType | |||
public boolean isFChsDiff() | |||
{ | |||
return fChsDiff.isSet(field_33_Highlight); | |||
} | |||
/** | |||
@@ -1340,8 +1265,6 @@ public abstract class CHPAbstractType | |||
public void setFMacChs(boolean value) | |||
{ | |||
field_33_Highlight = (short)fMacChs.setBoolean(field_33_Highlight, value); | |||
} | |||
/** | |||
@@ -1351,7 +1274,6 @@ public abstract class CHPAbstractType | |||
public boolean isFMacChs() | |||
{ | |||
return fMacChs.isSet(field_33_Highlight); | |||
} | |||
/** | |||
@@ -1361,8 +1283,6 @@ public abstract class CHPAbstractType | |||
public void setFFtcAsciSym(boolean value) | |||
{ | |||
field_33_Highlight = (short)fFtcAsciSym.setBoolean(field_33_Highlight, value); | |||
} | |||
/** | |||
@@ -1372,12 +1292,5 @@ public abstract class CHPAbstractType | |||
public boolean isFFtcAsciSym() | |||
{ | |||
return fFtcAsciSym.isSet(field_33_Highlight); | |||
} | |||
} // END OF CLASS | |||
} |
@@ -24,8 +24,8 @@ import java.io.OutputStream; | |||
/** | |||
* A decoder for the crazy LZW implementation used | |||
* in Visio. | |||
* According to VSDump, "it's a slightly perverted version of LZW | |||
* compression, with inverted meaning of flag byte and 0xFEE as an | |||
* According to VSDump, "it's a slightly perverted version of LZW | |||
* compression, with inverted meaning of flag byte and 0xFEE as an | |||
* 'initial shift'". It uses 12 bit codes | |||
* (http://www.gnome.ru/projects/vsdump_en.html) | |||
* | |||
@@ -36,7 +36,7 @@ import java.io.OutputStream; | |||
public class HDGFLZW { | |||
/** | |||
* Given an integer, turn it into a java byte, handling | |||
* Given an integer, turn it into a java byte, handling | |||
* the wrapping. | |||
* This is a convenience method | |||
*/ | |||
@@ -45,13 +45,15 @@ public static byte fromInt(int b) { | |||
return (byte)(b - 256); | |||
} | |||
/** | |||
* Given a java byte, turn it into an integer between 0 | |||
* Given a java byte, turn it into an integer between 0 | |||
* and 255 (i.e. handle the unwrapping). | |||
* This is a convenience method | |||
*/ | |||
public static int fromByte(byte b) { | |||
if(b >= 0) return (int)b; | |||
return (int)(b + 256); | |||
if(b >= 0) { | |||
return b; | |||
} | |||
return b + 256; | |||
} | |||
/** | |||
@@ -113,7 +115,7 @@ public void decode(InputStream src, OutputStream res) throws IOException { | |||
// It needs to be unsigned, so that bit stuff works | |||
int dataI; | |||
// The compressed code sequence is held over 2 bytes | |||
int dataIPt1, dataIPt2; | |||
int dataIPt1, dataIPt2; | |||
// How long a code sequence is, and where in the | |||
// dictionary to start at | |||
int len, pntr; | |||
@@ -138,7 +140,7 @@ public void decode(InputStream src, OutputStream res) throws IOException { | |||
dataIPt1 = src.read(); | |||
dataIPt2 = src.read(); | |||
if(dataIPt1 == -1 || dataIPt2 == -1) break; | |||
// Build up how long the code sequence is, and | |||
// what position of the code to start at | |||
// (The position is the first 12 bits, the | |||
@@ -153,14 +155,14 @@ public void decode(InputStream src, OutputStream res) throws IOException { | |||
} else { | |||
pntr = pntr + 18; | |||
} | |||
// Loop over the codes, outputting what they correspond to | |||
for(int i=0; i<len; i++) { | |||
buffer [(pos + i) & 4095] = buffer [(pntr + i) & 4095]; | |||
dataB = buffer[(pntr + i) & 4095]; | |||
res.write(new byte[] {dataB}); | |||
} | |||
// Record how far along the stream we have moved | |||
pos = pos + len; | |||
} | |||
@@ -183,14 +185,14 @@ public void compress(InputStream src, OutputStream res) throws IOException { | |||
* Need our own class to handle keeping track of the | |||
* code buffer, pending bytes to write out etc. | |||
*/ | |||
private class Compressor { | |||
private static final class Compressor { | |||
// We use 12 bit codes: | |||
// * 0-255 are real bytes | |||
// * 256-4095 are the substring codes | |||
// Java handily initialises our buffer / dictionary | |||
// to all zeros | |||
byte[] dict = new byte[4096]; | |||
// The next block of data to be written out, minus | |||
// its mask byte | |||
byte[] buffer = new byte[16]; | |||
@@ -198,21 +200,24 @@ private class Compressor { | |||
// (Un-compressed codes are 1 byte each, compressed codes | |||
// are two) | |||
int bufferLen = 0; | |||
// The raw length of a code is limited to 4 bits | |||
byte[] rawCode = new byte[16]; | |||
// And how much we're using | |||
int rawCodeLen = 0; | |||
// How far through the input and output streams we are | |||
int posInp = 0; | |||
int posOut = 0; | |||
// What the next mask byte to output will be | |||
int nextMask = 0; | |||
// And how many bits we've already set | |||
int maskBitsSet = 0; | |||
public Compressor() { | |||
// | |||
} | |||
/** | |||
* Returns the last place that the bytes from rawCode are found | |||
* at in the buffer, or -1 if they can't be found | |||
@@ -230,7 +235,7 @@ private int findRawCodeInBuffer() { | |||
matches = false; | |||
} | |||
} | |||
// Was this position a match? | |||
if(matches) { | |||
return i; | |||
@@ -255,7 +260,7 @@ private void outputCompressed(OutputStream res) throws IOException { | |||
} | |||
return; | |||
} | |||
// Increment the mask bit count, we've done another code | |||
maskBitsSet++; | |||
// Add the length+code to the buffer | |||
@@ -263,7 +268,7 @@ private void outputCompressed(OutputStream res) throws IOException { | |||
// length is the last 4 bits) | |||
// TODO | |||
posOut += 2; | |||
// If we're now at 8 codes, output | |||
if(maskBitsSet == 8) { | |||
output8Codes(res); | |||
@@ -273,15 +278,15 @@ private void outputCompressed(OutputStream res) throws IOException { | |||
* Output the un-compressed byte | |||
*/ | |||
private void outputUncompressed(byte b, OutputStream res) throws IOException { | |||
// Set the mask bit for us | |||
// Set the mask bit for us | |||
nextMask += (1<<maskBitsSet); | |||
// And add us to the buffer + dictionary | |||
buffer[bufferLen] = fromInt(b); | |||
bufferLen++; | |||
dict[(posOut&4095)] = fromInt(b); | |||
posOut++; | |||
// If we're now at 8 codes, output | |||
if(maskBitsSet == 8) { | |||
output8Codes(res); | |||
@@ -296,20 +301,20 @@ private void output8Codes(OutputStream res) throws IOException { | |||
// Output the mask and the data | |||
res.write(new byte[] { fromInt(nextMask) } ); | |||
res.write(buffer, 0, bufferLen); | |||
// Reset things | |||
nextMask = 0; | |||
maskBitsSet = 0; | |||
bufferLen = 0; | |||
} | |||
/** | |||
* Does the compression | |||
*/ | |||
private void compress(InputStream src, OutputStream res) throws IOException { | |||
// Have we hit the end of the file yet? | |||
boolean going = true; | |||
// This is a byte as looked up in the dictionary | |||
// It needs to be signed, as it'll get passed on to | |||
// the output stream | |||
@@ -317,27 +322,27 @@ private void compress(InputStream src, OutputStream res) throws IOException { | |||
// This is an unsigned byte read from the stream | |||
// It needs to be unsigned, so that bit stuff works | |||
int dataI; | |||
while( going ) { | |||
dataI = src.read(); | |||
posInp++; | |||
if(dataI == -1) { going = false; } | |||
dataB = fromInt(dataI); | |||
// If we've run out of data, output anything that's | |||
// pending then finish | |||
if(!going && rawCodeLen > 0) { | |||
outputCompressed(res); | |||
break; | |||
} | |||
// Try adding this new byte onto rawCode, and | |||
// see if all of that is still found in the | |||
// buffer dictionary or not | |||
rawCode[rawCodeLen] = dataB; | |||
rawCodeLen++; | |||
int rawAt = findRawCodeInBuffer(); | |||
// If we found it and are now at 16 bytes, | |||
// we need to output our pending code block | |||
if(rawCodeLen == 16 && rawAt > -1) { | |||
@@ -345,24 +350,24 @@ private void compress(InputStream src, OutputStream res) throws IOException { | |||
rawCodeLen = 0; | |||
continue; | |||
} | |||
// If we did find all of rawCode with our new | |||
// byte added on, we can wait to see what happens | |||
// with the next byte | |||
if(rawAt > -1) { | |||
continue; | |||
} | |||
// If we get here, then the rawCode + this byte weren't | |||
// found in the dictionary | |||
// If there was something in rawCode before, then that was | |||
// found in the dictionary, so output that compressed | |||
rawCodeLen--; | |||
if(rawCodeLen > 0) { | |||
// Output the old rawCode | |||
outputCompressed(res); | |||
// Can this byte start a new rawCode, or does | |||
// it need outputting itself? | |||
rawCode[0] = dataB; | |||
@@ -385,4 +390,4 @@ private void compress(InputStream src, OutputStream res) throws IOException { | |||
} | |||
} | |||
} | |||
} |
@@ -51,11 +51,11 @@ public abstract class ChunkHeader { | |||
} else if(documentVersion == 5 || documentVersion == 4) { | |||
ChunkHeaderV4V5 ch = new ChunkHeaderV4V5(); | |||
ch.type = (int)LittleEndian.getShort(data, offset + 0); | |||
ch.id = (int)LittleEndian.getShort(data, offset + 2); | |||
ch.type = LittleEndian.getShort(data, offset + 0); | |||
ch.id = LittleEndian.getShort(data, offset + 2); | |||
ch.unknown2 = (short)LittleEndian.getUnsignedByte(data, offset + 4); | |||
ch.unknown3 = (short)LittleEndian.getUnsignedByte(data, offset + 5); | |||
ch.unknown1 = (short)LittleEndian.getShort(data, offset + 6); | |||
ch.unknown1 = LittleEndian.getShort(data, offset + 6); | |||
ch.length = (int)LittleEndian.getUInt(data, offset + 8); | |||
return ch; |
@@ -257,7 +257,7 @@ public final class HSLFSlideShow extends POIDocument { | |||
Record[] rec = new Record[lst.size()]; | |||
for (int i = 0; i < a.length; i++) { | |||
Integer offset = (Integer)a[i]; | |||
rec[i] = (Record)Record.buildRecordAtOffset(docstream, offset.intValue()); | |||
rec[i] = Record.buildRecordAtOffset(docstream, offset.intValue()); | |||
if(rec[i] instanceof PersistRecord) { | |||
PersistRecord psr = (PersistRecord)rec[i]; | |||
Integer id = (Integer)offset2id.get(offset); |
@@ -41,9 +41,7 @@ import org.apache.poi.util.LittleEndian; | |||
* | |||
* @author Nick Burch | |||
*/ | |||
public final class SlideShowDumper | |||
{ | |||
public final class SlideShowDumper { | |||
private InputStream istream; | |||
private POIFSFileSystem filesystem; | |||
@@ -196,7 +194,7 @@ public final class SlideShowDumper | |||
} | |||
public String makeHex(short s) { | |||
String hex = Integer.toHexString((int)s).toUpperCase(); | |||
String hex = Integer.toHexString(s).toUpperCase(); | |||
if(hex.length() == 1) { return "0" + hex; } | |||
return hex; | |||
} | |||
@@ -232,7 +230,7 @@ public void walkTree(int depth, int startPos, int maxLen) { | |||
System.out.println(ind + "That's a " + recordName); | |||
// Now check if it's a container or not | |||
int container = (int)opt & 0x0f; | |||
int container = opt & 0x0f; | |||
// BinaryTagData seems to contain records, but it | |||
// isn't tagged as doing so. Try stepping in anyway |
@@ -53,9 +53,7 @@ import org.apache.poi.hslf.model.TextRun; | |||
* | |||
* @author Nick Burch | |||
*/ | |||
public final class QuickButCruddyTextExtractor | |||
{ | |||
public final class QuickButCruddyTextExtractor { | |||
private POIFSFileSystem fs; | |||
private InputStream is; | |||
private byte[] pptContents; | |||
@@ -169,7 +167,7 @@ public final class QuickButCruddyTextExtractor | |||
// If it's a container, step into it and return | |||
// (If it's a container, option byte 1 BINARY_AND 0x0f will be 0x0f) | |||
int container = (int)opt & 0x0f; | |||
int container = opt & 0x0f; | |||
if(container == 0x0f) { | |||
return (startPos+8); | |||
} |
@@ -17,13 +17,22 @@ | |||
package org.apache.poi.hslf.model; | |||
import org.apache.poi.ddf.*; | |||
import org.apache.poi.util.LittleEndian; | |||
import org.apache.poi.util.POILogger; | |||
import java.awt.geom.*; | |||
import java.awt.geom.AffineTransform; | |||
import java.awt.geom.GeneralPath; | |||
import java.awt.geom.PathIterator; | |||
import java.awt.geom.Point2D; | |||
import java.awt.geom.Rectangle2D; | |||
import java.util.ArrayList; | |||
import java.util.Arrays; | |||
import java.util.List; | |||
import org.apache.poi.ddf.EscherArrayProperty; | |||
import org.apache.poi.ddf.EscherContainerRecord; | |||
import org.apache.poi.ddf.EscherOptRecord; | |||
import org.apache.poi.ddf.EscherProperties; | |||
import org.apache.poi.ddf.EscherSimpleProperty; | |||
import org.apache.poi.util.LittleEndian; | |||
import org.apache.poi.util.POILogger; | |||
/** | |||
* A "Freeform" shape. | |||
@@ -85,8 +94,8 @@ public final class Freeform extends AutoShape { | |||
Rectangle2D bounds = path.getBounds2D(); | |||
PathIterator it = path.getPathIterator(new AffineTransform()); | |||
ArrayList segInfo = new ArrayList(); | |||
ArrayList pntInfo = new ArrayList(); | |||
List<byte[]> segInfo = new ArrayList<byte[]>(); | |||
List<Point2D.Double> pntInfo = new ArrayList<Point2D.Double>(); | |||
boolean isClosed = false; | |||
while (!it.isDone()) { | |||
double[] vals = new double[6]; | |||
@@ -135,7 +144,7 @@ public final class Freeform extends AutoShape { | |||
verticesProp.setNumberOfElementsInMemory(pntInfo.size()); | |||
verticesProp.setSizeOfElements(0xFFF0); | |||
for (int i = 0; i < pntInfo.size(); i++) { | |||
Point2D.Double pnt = (Point2D.Double)pntInfo.get(i); | |||
Point2D.Double pnt = pntInfo.get(i); | |||
byte[] data = new byte[4]; | |||
LittleEndian.putShort(data, 0, (short)((pnt.getX() - bounds.getX())*MASTER_DPI/POINT_DPI)); | |||
LittleEndian.putShort(data, 2, (short)((pnt.getY() - bounds.getY())*MASTER_DPI/POINT_DPI)); | |||
@@ -148,7 +157,7 @@ public final class Freeform extends AutoShape { | |||
segmentsProp.setNumberOfElementsInMemory(segInfo.size()); | |||
segmentsProp.setSizeOfElements(0x2); | |||
for (int i = 0; i < segInfo.size(); i++) { | |||
byte[] seg = (byte[])segInfo.get(i); | |||
byte[] seg = segInfo.get(i); | |||
segmentsProp.setElement(i, seg); | |||
} | |||
opt.addEscherProperty(segmentsProp); | |||
@@ -171,10 +180,10 @@ public final class Freeform extends AutoShape { | |||
opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__SHAPEPATH, 0x4)); | |||
EscherArrayProperty verticesProp = (EscherArrayProperty)getEscherProperty(opt, (short)(EscherProperties.GEOMETRY__VERTICES + 0x4000)); | |||
if(verticesProp == null) verticesProp = (EscherArrayProperty)getEscherProperty(opt, (short)(EscherProperties.GEOMETRY__VERTICES)); | |||
if(verticesProp == null) verticesProp = (EscherArrayProperty)getEscherProperty(opt, EscherProperties.GEOMETRY__VERTICES); | |||
EscherArrayProperty segmentsProp = (EscherArrayProperty)getEscherProperty(opt, (short)(EscherProperties.GEOMETRY__SEGMENTINFO + 0x4000)); | |||
if(segmentsProp == null) segmentsProp = (EscherArrayProperty)getEscherProperty(opt, (short)(EscherProperties.GEOMETRY__SEGMENTINFO)); | |||
if(segmentsProp == null) segmentsProp = (EscherArrayProperty)getEscherProperty(opt, EscherProperties.GEOMETRY__SEGMENTINFO); | |||
//sanity check | |||
if(verticesProp == null) { |
@@ -58,7 +58,7 @@ public final class CString extends RecordAtom { | |||
* The meaning of the count is specific to the type of the parent record | |||
*/ | |||
public int getOptions() { | |||
return (int)LittleEndian.getShort(_header); | |||
return LittleEndian.getShort(_header); | |||
} | |||
/** |
@@ -30,9 +30,7 @@ import java.io.ByteArrayOutputStream; | |||
* | |||
* @author Nick Burch | |||
*/ | |||
public final class ColorSchemeAtom extends RecordAtom | |||
{ | |||
public final class ColorSchemeAtom extends RecordAtom { | |||
private byte[] _header; | |||
private static long _type = 2032l; | |||
@@ -108,14 +106,14 @@ public final class ColorSchemeAtom extends RecordAtom | |||
System.arraycopy(source,start,_header,0,8); | |||
// Grab the rgb values | |||
backgroundColourRGB = (int)LittleEndian.getInt(source,start+8+0); | |||
textAndLinesColourRGB = (int)LittleEndian.getInt(source,start+8+4); | |||
shadowsColourRGB = (int)LittleEndian.getInt(source,start+8+8); | |||
titleTextColourRGB = (int)LittleEndian.getInt(source,start+8+12); | |||
fillsColourRGB = (int)LittleEndian.getInt(source,start+8+16); | |||
accentColourRGB = (int)LittleEndian.getInt(source,start+8+20); | |||
accentAndHyperlinkColourRGB = (int)LittleEndian.getInt(source,start+8+24); | |||
accentAndFollowingHyperlinkColourRGB = (int)LittleEndian.getInt(source,start+8+28); | |||
backgroundColourRGB = LittleEndian.getInt(source,start+8+0); | |||
textAndLinesColourRGB = LittleEndian.getInt(source,start+8+4); | |||
shadowsColourRGB = LittleEndian.getInt(source,start+8+8); | |||
titleTextColourRGB = LittleEndian.getInt(source,start+8+12); | |||
fillsColourRGB = LittleEndian.getInt(source,start+8+16); | |||
accentColourRGB = LittleEndian.getInt(source,start+8+20); | |||
accentAndHyperlinkColourRGB = LittleEndian.getInt(source,start+8+24); | |||
accentAndFollowingHyperlinkColourRGB = LittleEndian.getInt(source,start+8+28); | |||
} | |||
/** | |||
@@ -181,7 +179,7 @@ public final class ColorSchemeAtom extends RecordAtom | |||
byte[] with_zero = new byte[4]; | |||
System.arraycopy(rgb,0,with_zero,0,3); | |||
with_zero[3] = 0; | |||
int ret = (int)LittleEndian.getInt(with_zero,0); | |||
int ret = LittleEndian.getInt(with_zero,0); | |||
return ret; | |||
} | |||
@@ -205,16 +203,15 @@ public final class ColorSchemeAtom extends RecordAtom | |||
writeLittleEndian(accentAndFollowingHyperlinkColourRGB,out); | |||
} | |||
/** | |||
* Returns color by its index | |||
* | |||
* @param idx 0-based color index | |||
* @return color by its index | |||
*/ | |||
public int getColor(int idx){ | |||
int[] clr = {backgroundColourRGB, textAndLinesColourRGB, shadowsColourRGB, titleTextColourRGB, | |||
fillsColourRGB, accentColourRGB, accentAndHyperlinkColourRGB, accentAndFollowingHyperlinkColourRGB}; | |||
return clr[idx]; | |||
} | |||
/** | |||
* Returns color by its index | |||
* | |||
* @param idx 0-based color index | |||
* @return color by its index | |||
*/ | |||
public int getColor(int idx){ | |||
int[] clr = {backgroundColourRGB, textAndLinesColourRGB, shadowsColourRGB, titleTextColourRGB, | |||
fillsColourRGB, accentColourRGB, accentAndHyperlinkColourRGB, accentAndFollowingHyperlinkColourRGB}; | |||
return clr[idx]; | |||
} | |||
} |
@@ -80,16 +80,23 @@ public final class DocumentAtom extends RecordAtom | |||
/** Was the document saved with True Type fonts embeded? */ | |||
public boolean getSaveWithFonts() { | |||
if(saveWithFonts == 0) { return false; } else { return true; } } | |||
return saveWithFonts != 0; | |||
} | |||
/** Have the placeholders on the title slide been omitted? */ | |||
public boolean getOmitTitlePlace() { | |||
if(omitTitlePlace == 0) { return false; } else { return true; } } | |||
return omitTitlePlace != 0; | |||
} | |||
/** Is this a Bi-Directional PPT Doc? */ | |||
public boolean getRightToLeft() { | |||
if(rightToLeft == 0) { return false; } else { return true; } } | |||
return rightToLeft != 0; | |||
} | |||
/** Are comment shapes visible? */ | |||
public boolean getShowComments() { | |||
if(showComments == 0) { return false; } else { return true; } } | |||
return showComments != 0; | |||
} | |||
/* *************** record code follows ********************** */ | |||
@@ -118,10 +125,10 @@ public final class DocumentAtom extends RecordAtom | |||
handoutMasterPersist = LittleEndian.getInt(source,start+28+8); | |||
// Get the ID of the first slide | |||
firstSlideNum = (int)LittleEndian.getShort(source,start+32+8); | |||
firstSlideNum = LittleEndian.getShort(source,start+32+8); | |||
// Get the slide size type | |||
slideSizeType = (int)LittleEndian.getShort(source,start+34+8); | |||
slideSizeType = LittleEndian.getShort(source,start+34+8); | |||
// Get the booleans as bytes | |||
saveWithFonts = source[start+36+8]; |
@@ -32,12 +32,10 @@ import java.io.ByteArrayOutputStream; | |||
* | |||
* @author Nick Burch | |||
*/ | |||
public final class EscherTextboxWrapper extends RecordContainer | |||
{ | |||
public final class EscherTextboxWrapper extends RecordContainer { | |||
private EscherTextboxRecord _escherRecord; | |||
private long _type; | |||
private int shapeId; | |||
private int shapeId; | |||
/** | |||
* Returns the underlying DDF Escher Record | |||
@@ -49,7 +47,7 @@ public final class EscherTextboxWrapper extends RecordContainer | |||
*/ | |||
public EscherTextboxWrapper(EscherTextboxRecord textbox) { | |||
_escherRecord = textbox; | |||
_type = (long)_escherRecord.getRecordId(); | |||
_type = _escherRecord.getRecordId(); | |||
// Find the child records in the escher data | |||
byte[] data = _escherRecord.getData(); | |||
@@ -93,17 +91,17 @@ public final class EscherTextboxWrapper extends RecordContainer | |||
_escherRecord.setData(data); | |||
} | |||
/** | |||
* @return Shape ID | |||
*/ | |||
public int getShapeId(){ | |||
return shapeId; | |||
} | |||
/** | |||
* @param id Shape ID | |||
*/ | |||
public void setShapeId(int id){ | |||
shapeId = id; | |||
} | |||
/** | |||
* @return Shape ID | |||
*/ | |||
public int getShapeId(){ | |||
return shapeId; | |||
} | |||
/** | |||
* @param id Shape ID | |||
*/ | |||
public void setShapeId(int id){ | |||
shapeId = id; | |||
} | |||
} |
@@ -65,7 +65,7 @@ public final class NotesAtom extends RecordAtom | |||
System.arraycopy(source,start,_header,0,8); | |||
// Get the slide ID | |||
slideID = (int)LittleEndian.getInt(source,start+8); | |||
slideID = LittleEndian.getInt(source,start+8); | |||
// Grok the flags, stored as bits | |||
int flags = LittleEndian.getUShort(source,start+12); |
@@ -86,8 +86,8 @@ public final class SlideAtom extends RecordAtom | |||
layoutAtom = new SSlideLayoutAtom(SSlideLayoutAtomData); | |||
// Get the IDs of the master and notes | |||
masterID = (int)LittleEndian.getInt(source,start+12+8); | |||
notesID = (int)LittleEndian.getInt(source,start+16+8); | |||
masterID = LittleEndian.getInt(source,start+12+8); | |||
notesID = LittleEndian.getInt(source,start+16+8); | |||
// Grok the flags, stored as bits | |||
int flags = LittleEndian.getUShort(source,start+20+8); | |||
@@ -214,7 +214,7 @@ public final class SlideAtom extends RecordAtom | |||
} | |||
// Grab out our data | |||
geometry = (int)LittleEndian.getInt(data,0); | |||
geometry = LittleEndian.getInt(data,0); | |||
placeholderIDs = new byte[8]; | |||
System.arraycopy(data,4,placeholderIDs,0,8); | |||
} |
@@ -27,9 +27,7 @@ import java.io.OutputStream; | |||
* | |||
* @author Nick Burch | |||
*/ | |||
public final class SlidePersistAtom extends RecordAtom | |||
{ | |||
public final class SlidePersistAtom extends RecordAtom { | |||
private byte[] _header; | |||
private static long _type = 1011l; | |||
@@ -76,10 +74,10 @@ public final class SlidePersistAtom extends RecordAtom | |||
System.arraycopy(source,start,_header,0,8); | |||
// Grab the reference ID | |||
refID = (int)LittleEndian.getInt(source,start+8); | |||
refID = LittleEndian.getInt(source,start+8); | |||
// Next up is a set of flags, but only bit 3 is used! | |||
int flags = (int)LittleEndian.getInt(source,start+12); | |||
int flags = LittleEndian.getInt(source,start+12); | |||
if(flags == 4) { | |||
hasShapesOtherThanPlaceholders = true; | |||
} else { | |||
@@ -87,10 +85,10 @@ public final class SlidePersistAtom extends RecordAtom | |||
} | |||
// Now the number of Placeholder Texts | |||
numPlaceholderTexts = (int)LittleEndian.getInt(source,start+16); | |||
numPlaceholderTexts = LittleEndian.getInt(source,start+16); | |||
// Last useful one is the unique slide identifier | |||
slideIdentifier = (int)LittleEndian.getInt(source,start+20); | |||
slideIdentifier = LittleEndian.getInt(source,start+20); | |||
// Finally you have typically 4 or 8 bytes of reserved fields, | |||
// all zero running from 24 bytes in to the end |
@@ -72,7 +72,7 @@ public final class TextHeaderAtom extends RecordAtom implements ParentAwareRecor | |||
System.arraycopy(source,start,_header,0,8); | |||
// Grab the type | |||
textType = (int)LittleEndian.getInt(source,start+8); | |||
textType = LittleEndian.getInt(source,start+8); | |||
} | |||
/** |
@@ -82,30 +82,30 @@ public final class UserEditAtom extends PositionDependentRecordAtom | |||
System.arraycopy(source,start,_header,0,8); | |||
// Get the last viewed slide ID | |||
lastViewedSlideID = (int)LittleEndian.getInt(source,start+0+8); | |||
lastViewedSlideID = LittleEndian.getInt(source,start+0+8); | |||
// Get the PPT version | |||
pptVersion = (int)LittleEndian.getInt(source,start+4+8); | |||
pptVersion = LittleEndian.getInt(source,start+4+8); | |||
// Get the offset to the previous incremental save's UserEditAtom | |||
// This will be the byte offset on disk where the previous one | |||
// starts, or 0 if this is the first one | |||
lastUserEditAtomOffset = (int)LittleEndian.getInt(source,start+8+8); | |||
lastUserEditAtomOffset = LittleEndian.getInt(source,start+8+8); | |||
// Get the offset to the persist pointers | |||
// This will be the byte offset on disk where the preceding | |||
// PersistPtrFullBlock or PersistPtrIncrementalBlock starts | |||
persistPointersOffset = (int)LittleEndian.getInt(source,start+12+8); | |||
persistPointersOffset = LittleEndian.getInt(source,start+12+8); | |||
// Get the persist reference for the document persist object | |||
// Normally seems to be 1 | |||
docPersistRef = (int)LittleEndian.getInt(source,start+16+8); | |||
docPersistRef = LittleEndian.getInt(source,start+16+8); | |||
// Maximum number of persist objects written | |||
maxPersistWritten = (int)LittleEndian.getInt(source,start+20+8); | |||
maxPersistWritten = LittleEndian.getInt(source,start+20+8); | |||
// Last view type | |||
lastViewType = (short)LittleEndian.getShort(source,start+24+8); | |||
lastViewType = LittleEndian.getShort(source,start+24+8); | |||
// There might be a few more bytes, which are a reserved field | |||
reserved = new byte[len-26-8]; |
@@ -42,17 +42,13 @@ import org.apache.poi.poifs.property.DocumentProperty; | |||
import org.apache.poi.poifs.storage.BlockWritable; | |||
/** | |||
* Provides a HashMap with the ability to parse a PIOFS object and provide | |||
* Provides a HashMap with the ability to parse a PIOFS object and provide | |||
* an 'easy to access' hashmap structure for the document chunks inside it. | |||
* | |||
* | |||
* @author Travis Ferguson | |||
*/ | |||
public class POIFSChunkParser { | |||
/** | |||
* Constructor | |||
* @param fs | |||
* @throws IOException | |||
*/ | |||
public final class POIFSChunkParser { | |||
public POIFSChunkParser(POIFSFileSystem fs) throws IOException { | |||
this.setFileSystem(fs); | |||
} | |||
@@ -61,7 +57,6 @@ public class POIFSChunkParser { | |||
/** | |||
* Set the POIFileSystem object that this object is using. | |||
* @param fs | |||
* @throws IOException | |||
*/ | |||
public void setFileSystem(POIFSFileSystem fs) throws IOException { | |||
this.fs = fs; | |||
@@ -77,33 +72,32 @@ public class POIFSChunkParser { | |||
/** | |||
* Reparse the FileSystem object, resetting all the chunks stored in this object | |||
* @throws IOException | |||
* | |||
*/ | |||
public void reparseFileSystem() throws IOException { | |||
// first clear this object of all chunks | |||
DirectoryEntry root = this.fs.getRoot(); | |||
Iterator iter = root.getEntries(); | |||
this.directoryMap = this.processPOIIterator(iter); | |||
} | |||
/** | |||
* Returns a list of the standard chunk types, as | |||
* Returns a list of the standard chunk types, as | |||
* appropriate for the chunks we find in the file. | |||
*/ | |||
public Chunks identifyChunks() { | |||
return Chunks.getInstance(this.isNewChunkVersion(this.directoryMap)); | |||
} | |||
/** | |||
* Returns a list of the standard chunk types, as | |||
* Returns a list of the standard chunk types, as | |||
* appropriate for the chunks we find in the file attachment. | |||
*/ | |||
private AttachmentChunks identifyAttachmentChunks(Map attachmentMap) { | |||
return AttachmentChunks.getInstance(this.isNewChunkVersion(attachmentMap)); | |||
} | |||
/** | |||
* Return chunk version of the map in parameter | |||
*/ | |||
@@ -113,10 +107,10 @@ public class POIFSChunkParser { | |||
boolean hasNewStrings = false; | |||
String oldStringEnd = Types.asFileEnding(Types.OLD_STRING); | |||
String newStringEnd = Types.asFileEnding(Types.NEW_STRING); | |||
for(Iterator i = map.keySet().iterator(); i.hasNext();) { | |||
String entry = (String)i.next(); | |||
if(entry.endsWith( oldStringEnd )) { | |||
hasOldStrings = true; | |||
} | |||
@@ -124,7 +118,7 @@ public class POIFSChunkParser { | |||
hasNewStrings = true; | |||
} | |||
} | |||
if(hasOldStrings && hasNewStrings) { | |||
throw new IllegalStateException("Your file contains string chunks of both the old and new types. Giving up"); | |||
} else if(hasNewStrings) { | |||
@@ -132,18 +126,18 @@ public class POIFSChunkParser { | |||
} | |||
return false; | |||
} | |||
/** | |||
* Pull the chunk data that's stored in this object's hashmap out and return it as a HashMap. | |||
* @param entryName | |||
*/ | |||
public Object getChunk(HashMap dirMap, String entryName) { | |||
if(dirMap == null) return null; | |||
else { | |||
return dirMap.get(entryName); | |||
if(dirMap == null) { | |||
return null; | |||
} | |||
return dirMap.get(entryName); | |||
} | |||
/** | |||
* Pull a directory/hashmap out of this hashmap and return it | |||
* @param directoryName | |||
@@ -155,14 +149,14 @@ public class POIFSChunkParser { | |||
DirectoryChunkNotFoundException excep = new DirectoryChunkNotFoundException(directoryName); | |||
Object obj = getChunk(this.directoryMap, directoryName); | |||
if(obj == null || !(obj instanceof HashMap)) throw excep; | |||
return (HashMap)obj; | |||
} | |||
/** | |||
* Pulls a ByteArrayOutputStream from this objects HashMap, this can be used to read a byte array of the contents of the given chunk. | |||
* @param dirNode | |||
* @param chunk | |||
* @param chunk | |||
* @throws ChunkNotFoundException | |||
*/ | |||
public Chunk getDocumentNode(HashMap dirNode, Chunk chunk) throws ChunkNotFoundException { | |||
@@ -170,12 +164,12 @@ public class POIFSChunkParser { | |||
ChunkNotFoundException excep = new ChunkNotFoundException(entryName); | |||
Object obj = getChunk(dirNode, entryName); | |||
if(obj == null || !(obj instanceof ByteArrayOutputStream)) throw excep; | |||
chunk.setValue((ByteArrayOutputStream)obj); | |||
return chunk; | |||
} | |||
/** | |||
* Pulls a Chunk out of this objects root Node tree. | |||
* @param chunk | |||
@@ -184,9 +178,9 @@ public class POIFSChunkParser { | |||
public Chunk getDocumentNode(Chunk chunk) throws ChunkNotFoundException { | |||
return getDocumentNode(this.directoryMap, chunk); | |||
} | |||
/** | |||
* | |||
* | |||
* @return a map containing attachment name (String) and data (ByteArrayInputStream) | |||
*/ | |||
public Map getAttachmentList() { | |||
@@ -194,12 +188,12 @@ public class POIFSChunkParser { | |||
List attachmentList = new ArrayList(); | |||
for(Iterator i = directoryMap.keySet().iterator(); i.hasNext();) { | |||
String entry = (String)i.next(); | |||
if(entry.startsWith(AttachmentChunks.namePrefix)) { | |||
String attachmentIdString = entry.replace(AttachmentChunks.namePrefix, ""); | |||
try { | |||
int attachmentId = Integer.parseInt(attachmentIdString); | |||
attachmentList.add((HashMap)directoryMap.get(entry)); | |||
attachmentList.add(directoryMap.get(entry)); | |||
} catch (NumberFormatException nfe) { | |||
System.err.println("Invalid attachment id"); | |||
} | |||
@@ -218,7 +212,7 @@ public class POIFSChunkParser { | |||
} | |||
return attachments; | |||
} | |||
/** | |||
* Processes an iterator returned by a POIFS call to getRoot().getEntries() | |||
* @param iter | |||
@@ -226,85 +220,85 @@ public class POIFSChunkParser { | |||
* @throws IOException | |||
*/ | |||
private HashMap processPOIIterator(Iterator iter) throws IOException { | |||
HashMap currentNode = new HashMap(); | |||
while(iter.hasNext()) { | |||
Object obj = iter.next(); | |||
if(obj instanceof DocumentNode) { | |||
this.processDocumentNode((DocumentNode)obj, currentNode); | |||
} else if(obj instanceof DirectoryNode) { | |||
String blockName = ((DirectoryNode)obj).getName(); | |||
Iterator viewIt = null; | |||
if( ((DirectoryNode)obj).preferArray()) { | |||
Object[] arr = ((DirectoryNode)obj).getViewableArray(); | |||
ArrayList viewList = new ArrayList(arr.length); | |||
for(int i = 0; i < arr.length; i++) { | |||
viewList.add(arr[i]); | |||
} | |||
viewIt = viewList.iterator(); | |||
} else { | |||
viewIt = ((DirectoryNode)obj).getViewableIterator(); | |||
} | |||
//store the next node on the hashmap | |||
currentNode.put(blockName, processPOIIterator(viewIt)); | |||
} else if(obj instanceof DirectoryProperty) { | |||
//don't do anything with the directory property chunk... | |||
} else { | |||
System.err.println("Unknown node: " + obj.toString()); | |||
} | |||
} | |||
return currentNode; | |||
} | |||
HashMap currentNode = new HashMap(); | |||
while(iter.hasNext()) { | |||
Object obj = iter.next(); | |||
if(obj instanceof DocumentNode) { | |||
this.processDocumentNode((DocumentNode)obj, currentNode); | |||
} else if(obj instanceof DirectoryNode) { | |||
String blockName = ((DirectoryNode)obj).getName(); | |||
Iterator viewIt = null; | |||
if( ((DirectoryNode)obj).preferArray()) { | |||
Object[] arr = ((DirectoryNode)obj).getViewableArray(); | |||
ArrayList viewList = new ArrayList(arr.length); | |||
for(int i = 0; i < arr.length; i++) { | |||
viewList.add(arr[i]); | |||
} | |||
viewIt = viewList.iterator(); | |||
} else { | |||
viewIt = ((DirectoryNode)obj).getViewableIterator(); | |||
} | |||
//store the next node on the hashmap | |||
currentNode.put(blockName, processPOIIterator(viewIt)); | |||
} else if(obj instanceof DirectoryProperty) { | |||
//don't do anything with the directory property chunk... | |||
} else { | |||
System.err.println("Unknown node: " + obj.toString()); | |||
} | |||
} | |||
return currentNode; | |||
} | |||
/** | |||
* Processes a document node and adds it to the current directory HashMap | |||
* @param obj | |||
* @throws java.io.IOException | |||
*/ | |||
private void processDocumentNode(DocumentNode obj, HashMap currentObj) throws IOException { | |||
String blockName = ((DocumentNode)obj).getName(); | |||
Iterator viewIt = null; | |||
if( ((DocumentNode)obj).preferArray()) { | |||
Object[] arr = ((DocumentNode)obj).getViewableArray(); | |||
ArrayList viewList = new ArrayList(arr.length); | |||
for(int i = 0; i < arr.length; i++) { | |||
viewList.add(arr[i]); | |||
} | |||
viewIt = viewList.iterator(); | |||
} else { | |||
viewIt = ((DocumentNode)obj).getViewableIterator(); | |||
} | |||
while(viewIt.hasNext()) { | |||
Object view = viewIt.next(); | |||
if(view instanceof DocumentProperty) { | |||
//we don't care about the properties | |||
} else if(view instanceof POIFSDocument) { | |||
//check if our node has blocks or if it can just be read raw. | |||
int blockCount = ((POIFSDocument)view).countBlocks(); | |||
//System.out.println("Block Name: " + blockName); | |||
if(blockCount <= 0) { | |||
ByteArrayOutputStream out = new ByteArrayOutputStream(); | |||
BlockWritable[] bws = ((POIFSDocument)view).getSmallBlocks(); | |||
for(int i = 0; i < bws.length; i++) { | |||
bws[i].writeBlocks(out); | |||
} | |||
currentObj.put(blockName, out); | |||
} else { | |||
ByteArrayOutputStream out = new ByteArrayOutputStream(); | |||
((POIFSDocument)view).writeBlocks(out); | |||
currentObj.put(blockName, out); | |||
} | |||
} else { | |||
System.err.println("Unknown View Type: " + view.toString()); | |||
} | |||
} | |||
} | |||
* Processes a document node and adds it to the current directory HashMap | |||
* @param obj | |||
* @throws java.io.IOException | |||
*/ | |||
private void processDocumentNode(DocumentNode obj, HashMap currentObj) throws IOException { | |||
String blockName = obj.getName(); | |||
Iterator viewIt = null; | |||
if( obj.preferArray()) { | |||
Object[] arr = obj.getViewableArray(); | |||
ArrayList viewList = new ArrayList(arr.length); | |||
for(int i = 0; i < arr.length; i++) { | |||
viewList.add(arr[i]); | |||
} | |||
viewIt = viewList.iterator(); | |||
} else { | |||
viewIt = obj.getViewableIterator(); | |||
} | |||
while(viewIt.hasNext()) { | |||
Object view = viewIt.next(); | |||
if(view instanceof DocumentProperty) { | |||
//we don't care about the properties | |||
} else if(view instanceof POIFSDocument) { | |||
//check if our node has blocks or if it can just be read raw. | |||
int blockCount = ((POIFSDocument)view).countBlocks(); | |||
//System.out.println("Block Name: " + blockName); | |||
if(blockCount <= 0) { | |||
ByteArrayOutputStream out = new ByteArrayOutputStream(); | |||
BlockWritable[] bws = ((POIFSDocument)view).getSmallBlocks(); | |||
for(int i = 0; i < bws.length; i++) { | |||
bws[i].writeBlocks(out); | |||
} | |||
currentObj.put(blockName, out); | |||
} else { | |||
ByteArrayOutputStream out = new ByteArrayOutputStream(); | |||
((POIFSDocument)view).writeBlocks(out); | |||
currentObj.put(blockName, out); | |||
} | |||
} else { | |||
System.err.println("Unknown View Type: " + view.toString()); | |||
} | |||
} | |||
} | |||
/* private instance variables */ | |||
private static final long serialVersionUID = 1L; |
@@ -133,7 +133,7 @@ public final class ListData | |||
int resetListID() | |||
{ | |||
_lsid = (int)(Math.random() * (double)System.currentTimeMillis()); | |||
_lsid = (int)(Math.random() * System.currentTimeMillis()); | |||
return _lsid; | |||
} | |||
@@ -225,21 +225,19 @@ public final class StyleSheet implements HDFType { | |||
{ | |||
parentPAP = _styleDescriptions[baseIndex].getPAP(); | |||
if(parentPAP == null) | |||
{ | |||
if(baseIndex == istd) { | |||
// Oh dear, style claims that it is its own parent | |||
throw new IllegalStateException("Pap style " + istd + " claimed to have itself as its parent, which isn't allowed"); | |||
} else { | |||
// Create the parent style | |||
createPap(baseIndex); | |||
parentPAP = _styleDescriptions[baseIndex].getPAP(); | |||
} | |||
if(parentPAP == null) { | |||
if(baseIndex == istd) { | |||
// Oh dear, style claims that it is its own parent | |||
throw new IllegalStateException("Pap style " + istd + " claimed to have itself as its parent, which isn't allowed"); | |||
} | |||
// Create the parent style | |||
createPap(baseIndex); | |||
parentPAP = _styleDescriptions[baseIndex].getPAP(); | |||
} | |||
} | |||
pap = (ParagraphProperties)ParagraphSprmUncompressor.uncompressPAP(parentPAP, papx, 2); | |||
pap = ParagraphSprmUncompressor.uncompressPAP(parentPAP, papx, 2); | |||
sd.setPAP(pap); | |||
} | |||
} | |||
@@ -274,7 +272,7 @@ public final class StyleSheet implements HDFType { | |||
} | |||
chp = (CharacterProperties)CharacterSprmUncompressor.uncompressCHP(parentCHP, chpx, 0); | |||
chp = CharacterSprmUncompressor.uncompressCHP(parentCHP, chpx, 0); | |||
sd.setCHP(chp); | |||
} | |||
} |
@@ -818,9 +818,7 @@ public abstract class CHPAbstractType | |||
*/ | |||
public void setFBold(boolean value) | |||
{ | |||
field_2_format_flags = (int)fBold.setBoolean(field_2_format_flags, value); | |||
field_2_format_flags = fBold.setBoolean(field_2_format_flags, value); | |||
} | |||
/** | |||
@@ -830,7 +828,6 @@ public abstract class CHPAbstractType | |||
public boolean isFBold() | |||
{ | |||
return fBold.isSet(field_2_format_flags); | |||
} | |||
/** | |||
@@ -839,9 +836,7 @@ public abstract class CHPAbstractType | |||
*/ | |||
public void setFItalic(boolean value) | |||
{ | |||
field_2_format_flags = (int)fItalic.setBoolean(field_2_format_flags, value); | |||
field_2_format_flags = fItalic.setBoolean(field_2_format_flags, value); | |||
} | |||
/** | |||
@@ -851,7 +846,6 @@ public abstract class CHPAbstractType | |||
public boolean isFItalic() | |||
{ | |||
return fItalic.isSet(field_2_format_flags); | |||
} | |||
/** | |||
@@ -860,9 +854,7 @@ public abstract class CHPAbstractType | |||
*/ | |||
public void setFRMarkDel(boolean value) | |||
{ | |||
field_2_format_flags = (int)fRMarkDel.setBoolean(field_2_format_flags, value); | |||
field_2_format_flags = fRMarkDel.setBoolean(field_2_format_flags, value); | |||
} | |||
/** | |||
@@ -872,7 +864,6 @@ public abstract class CHPAbstractType | |||
public boolean isFRMarkDel() | |||
{ | |||
return fRMarkDel.isSet(field_2_format_flags); | |||
} | |||
/** | |||
@@ -881,9 +872,7 @@ public abstract class CHPAbstractType | |||
*/ | |||
public void setFOutline(boolean value) | |||
{ | |||
field_2_format_flags = (int)fOutline.setBoolean(field_2_format_flags, value); | |||
field_2_format_flags = fOutline.setBoolean(field_2_format_flags, value); | |||
} | |||
/** | |||
@@ -893,7 +882,6 @@ public abstract class CHPAbstractType | |||
public boolean isFOutline() | |||
{ | |||
return fOutline.isSet(field_2_format_flags); | |||
} | |||
/** | |||
@@ -902,9 +890,7 @@ public abstract class CHPAbstractType | |||
*/ | |||
public void setFFldVanish(boolean value) | |||
{ | |||
field_2_format_flags = (int)fFldVanish.setBoolean(field_2_format_flags, value); | |||
field_2_format_flags = fFldVanish.setBoolean(field_2_format_flags, value); | |||
} | |||
/** | |||
@@ -914,7 +900,6 @@ public abstract class CHPAbstractType | |||
public boolean isFFldVanish() | |||
{ | |||
return fFldVanish.isSet(field_2_format_flags); | |||
} | |||
/** | |||
@@ -923,9 +908,7 @@ public abstract class CHPAbstractType | |||
*/ | |||
public void setFSmallCaps(boolean value) | |||
{ | |||
field_2_format_flags = (int)fSmallCaps.setBoolean(field_2_format_flags, value); | |||
field_2_format_flags = fSmallCaps.setBoolean(field_2_format_flags, value); | |||
} | |||
/** | |||
@@ -935,7 +918,6 @@ public abstract class CHPAbstractType | |||
public boolean isFSmallCaps() | |||
{ | |||
return fSmallCaps.isSet(field_2_format_flags); | |||
} | |||
/** | |||
@@ -944,9 +926,7 @@ public abstract class CHPAbstractType | |||
*/ | |||
public void setFCaps(boolean value) | |||
{ | |||
field_2_format_flags = (int)fCaps.setBoolean(field_2_format_flags, value); | |||
field_2_format_flags = fCaps.setBoolean(field_2_format_flags, value); | |||
} | |||
/** | |||
@@ -956,7 +936,6 @@ public abstract class CHPAbstractType | |||
public boolean isFCaps() | |||
{ | |||
return fCaps.isSet(field_2_format_flags); | |||
} | |||
/** | |||
@@ -965,9 +944,7 @@ public abstract class CHPAbstractType | |||
*/ | |||
public void setFVanish(boolean value) | |||
{ | |||
field_2_format_flags = (int)fVanish.setBoolean(field_2_format_flags, value); | |||
field_2_format_flags = fVanish.setBoolean(field_2_format_flags, value); | |||
} | |||
/** | |||
@@ -977,7 +954,6 @@ public abstract class CHPAbstractType | |||
public boolean isFVanish() | |||
{ | |||
return fVanish.isSet(field_2_format_flags); | |||
} | |||
/** | |||
@@ -986,9 +962,7 @@ public abstract class CHPAbstractType | |||
*/ | |||
public void setFRMark(boolean value) | |||
{ | |||
field_2_format_flags = (int)fRMark.setBoolean(field_2_format_flags, value); | |||
field_2_format_flags = fRMark.setBoolean(field_2_format_flags, value); | |||
} | |||
/** | |||
@@ -998,7 +972,6 @@ public abstract class CHPAbstractType | |||
public boolean isFRMark() | |||
{ | |||
return fRMark.isSet(field_2_format_flags); | |||
} | |||
/** | |||
@@ -1007,9 +980,7 @@ public abstract class CHPAbstractType | |||
*/ | |||
public void setFSpec(boolean value) | |||
{ | |||
field_2_format_flags = (int)fSpec.setBoolean(field_2_format_flags, value); | |||
field_2_format_flags = fSpec.setBoolean(field_2_format_flags, value); | |||
} | |||
/** | |||
@@ -1019,7 +990,6 @@ public abstract class CHPAbstractType | |||
public boolean isFSpec() | |||
{ | |||
return fSpec.isSet(field_2_format_flags); | |||
} | |||
/** | |||
@@ -1028,9 +998,7 @@ public abstract class CHPAbstractType | |||
*/ | |||
public void setFStrike(boolean value) | |||
{ | |||
field_2_format_flags = (int)fStrike.setBoolean(field_2_format_flags, value); | |||
field_2_format_flags = fStrike.setBoolean(field_2_format_flags, value); | |||
} | |||
/** | |||
@@ -1040,7 +1008,6 @@ public abstract class CHPAbstractType | |||
public boolean isFStrike() | |||
{ | |||
return fStrike.isSet(field_2_format_flags); | |||
} | |||
/** | |||
@@ -1049,9 +1016,7 @@ public abstract class CHPAbstractType | |||
*/ | |||
public void setFObj(boolean value) | |||
{ | |||
field_2_format_flags = (int)fObj.setBoolean(field_2_format_flags, value); | |||
field_2_format_flags = fObj.setBoolean(field_2_format_flags, value); | |||
} | |||
/** | |||
@@ -1061,7 +1026,6 @@ public abstract class CHPAbstractType | |||
public boolean isFObj() | |||
{ | |||
return fObj.isSet(field_2_format_flags); | |||
} | |||
/** | |||
@@ -1070,9 +1034,7 @@ public abstract class CHPAbstractType | |||
*/ | |||
public void setFShadow(boolean value) | |||
{ | |||
field_2_format_flags = (int)fShadow.setBoolean(field_2_format_flags, value); | |||
field_2_format_flags = fShadow.setBoolean(field_2_format_flags, value); | |||
} | |||
/** | |||
@@ -1082,7 +1044,6 @@ public abstract class CHPAbstractType | |||
public boolean isFShadow() | |||
{ | |||
return fShadow.isSet(field_2_format_flags); | |||
} | |||
/** | |||
@@ -1091,9 +1052,7 @@ public abstract class CHPAbstractType | |||
*/ | |||
public void setFLowerCase(boolean value) | |||
{ | |||
field_2_format_flags = (int)fLowerCase.setBoolean(field_2_format_flags, value); | |||
field_2_format_flags = fLowerCase.setBoolean(field_2_format_flags, value); | |||
} | |||
/** | |||
@@ -1103,7 +1062,6 @@ public abstract class CHPAbstractType | |||
public boolean isFLowerCase() | |||
{ | |||
return fLowerCase.isSet(field_2_format_flags); | |||
} | |||
/** | |||
@@ -1112,9 +1070,7 @@ public abstract class CHPAbstractType | |||
*/ | |||
public void setFData(boolean value) | |||
{ | |||
field_2_format_flags = (int)fData.setBoolean(field_2_format_flags, value); | |||
field_2_format_flags = fData.setBoolean(field_2_format_flags, value); | |||
} | |||
/** | |||
@@ -1124,7 +1080,6 @@ public abstract class CHPAbstractType | |||
public boolean isFData() | |||
{ | |||
return fData.isSet(field_2_format_flags); | |||
} | |||
/** | |||
@@ -1133,9 +1088,7 @@ public abstract class CHPAbstractType | |||
*/ | |||
public void setFOle2(boolean value) | |||
{ | |||
field_2_format_flags = (int)fOle2.setBoolean(field_2_format_flags, value); | |||
field_2_format_flags = fOle2.setBoolean(field_2_format_flags, value); | |||
} | |||
/** | |||
@@ -1145,7 +1098,6 @@ public abstract class CHPAbstractType | |||
public boolean isFOle2() | |||
{ | |||
return fOle2.isSet(field_2_format_flags); | |||
} | |||
/** | |||
@@ -1154,9 +1106,7 @@ public abstract class CHPAbstractType | |||
*/ | |||
public void setFEmboss(boolean value) | |||
{ | |||
field_3_format_flags1 = (int)fEmboss.setBoolean(field_3_format_flags1, value); | |||
field_3_format_flags1 = fEmboss.setBoolean(field_3_format_flags1, value); | |||
} | |||
/** | |||
@@ -1166,7 +1116,6 @@ public abstract class CHPAbstractType | |||
public boolean isFEmboss() | |||
{ | |||
return fEmboss.isSet(field_3_format_flags1); | |||
} | |||
/** | |||
@@ -1175,9 +1124,7 @@ public abstract class CHPAbstractType | |||
*/ | |||
public void setFImprint(boolean value) | |||
{ | |||
field_3_format_flags1 = (int)fImprint.setBoolean(field_3_format_flags1, value); | |||
field_3_format_flags1 = fImprint.setBoolean(field_3_format_flags1, value); | |||
} | |||
/** | |||
@@ -1187,7 +1134,6 @@ public abstract class CHPAbstractType | |||
public boolean isFImprint() | |||
{ | |||
return fImprint.isSet(field_3_format_flags1); | |||
} | |||
/** | |||
@@ -1196,9 +1142,7 @@ public abstract class CHPAbstractType | |||
*/ | |||
public void setFDStrike(boolean value) | |||
{ | |||
field_3_format_flags1 = (int)fDStrike.setBoolean(field_3_format_flags1, value); | |||
field_3_format_flags1 = fDStrike.setBoolean(field_3_format_flags1, value); | |||
} | |||
/** | |||
@@ -1208,7 +1152,6 @@ public abstract class CHPAbstractType | |||
public boolean isFDStrike() | |||
{ | |||
return fDStrike.isSet(field_3_format_flags1); | |||
} | |||
/** | |||
@@ -1217,9 +1160,7 @@ public abstract class CHPAbstractType | |||
*/ | |||
public void setFUsePgsuSettings(boolean value) | |||
{ | |||
field_3_format_flags1 = (int)fUsePgsuSettings.setBoolean(field_3_format_flags1, value); | |||
field_3_format_flags1 = fUsePgsuSettings.setBoolean(field_3_format_flags1, value); | |||
} | |||
/** | |||
@@ -1229,7 +1170,6 @@ public abstract class CHPAbstractType | |||
public boolean isFUsePgsuSettings() | |||
{ | |||
return fUsePgsuSettings.isSet(field_3_format_flags1); | |||
} | |||
/** | |||
@@ -1239,8 +1179,6 @@ public abstract class CHPAbstractType | |||
public void setIcoHighlight(byte value) | |||
{ | |||
field_33_Highlight = (short)icoHighlight.setValue(field_33_Highlight, value); | |||
} | |||
/** | |||
@@ -1250,7 +1188,6 @@ public abstract class CHPAbstractType | |||
public byte getIcoHighlight() | |||
{ | |||
return ( byte )icoHighlight.getValue(field_33_Highlight); | |||
} | |||
/** | |||
@@ -1260,8 +1197,6 @@ public abstract class CHPAbstractType | |||
public void setFHighlight(boolean value) | |||
{ | |||
field_33_Highlight = (short)fHighlight.setBoolean(field_33_Highlight, value); | |||
} | |||
/** | |||
@@ -1271,7 +1206,6 @@ public abstract class CHPAbstractType | |||
public boolean isFHighlight() | |||
{ | |||
return fHighlight.isSet(field_33_Highlight); | |||
} | |||
/** | |||
@@ -1281,8 +1215,6 @@ public abstract class CHPAbstractType | |||
public void setKcd(byte value) | |||
{ | |||
field_33_Highlight = (short)kcd.setValue(field_33_Highlight, value); | |||
} | |||
/** | |||
@@ -1292,7 +1224,6 @@ public abstract class CHPAbstractType | |||
public byte getKcd() | |||
{ | |||
return ( byte )kcd.getValue(field_33_Highlight); | |||
} | |||
/** | |||
@@ -1302,8 +1233,6 @@ public abstract class CHPAbstractType | |||
public void setFNavHighlight(boolean value) | |||
{ | |||
field_33_Highlight = (short)fNavHighlight.setBoolean(field_33_Highlight, value); | |||
} | |||
/** | |||
@@ -1313,7 +1242,6 @@ public abstract class CHPAbstractType | |||
public boolean isFNavHighlight() | |||
{ | |||
return fNavHighlight.isSet(field_33_Highlight); | |||
} | |||
/** | |||
@@ -1323,8 +1251,6 @@ public abstract class CHPAbstractType | |||
public void setFChsDiff(boolean value) | |||
{ | |||
field_33_Highlight = (short)fChsDiff.setBoolean(field_33_Highlight, value); | |||
} | |||
/** | |||
@@ -1334,7 +1260,6 @@ public abstract class CHPAbstractType | |||
public boolean isFChsDiff() | |||
{ | |||
return fChsDiff.isSet(field_33_Highlight); | |||
} | |||
/** | |||
@@ -1344,8 +1269,6 @@ public abstract class CHPAbstractType | |||
public void setFMacChs(boolean value) | |||
{ | |||
field_33_Highlight = (short)fMacChs.setBoolean(field_33_Highlight, value); | |||
} | |||
/** | |||
@@ -1355,7 +1278,6 @@ public abstract class CHPAbstractType | |||
public boolean isFMacChs() | |||
{ | |||
return fMacChs.isSet(field_33_Highlight); | |||
} | |||
/** | |||
@@ -1365,8 +1287,6 @@ public abstract class CHPAbstractType | |||
public void setFFtcAsciSym(boolean value) | |||
{ | |||
field_33_Highlight = (short)fFtcAsciSym.setBoolean(field_33_Highlight, value); | |||
} | |||
/** | |||
@@ -1376,12 +1296,5 @@ public abstract class CHPAbstractType | |||
public boolean isFFtcAsciSym() | |||
{ | |||
return fFtcAsciSym.isSet(field_33_Highlight); | |||
} | |||
} // END OF CLASS | |||
} |
@@ -88,26 +88,24 @@ public abstract class FIBAbstractType implements HDFType { | |||
field_12_chsTables = LittleEndian.getShort(data, 0x16 + offset); | |||
field_13_fcMin = LittleEndian.getInt(data, 0x18 + offset); | |||
field_14_fcMac = LittleEndian.getInt(data, 0x1c + offset); | |||
} | |||
public void serialize(byte[] data, int offset) | |||
{ | |||
LittleEndian.putShort(data, 0x0 + offset, (short)field_1_wIdent);; | |||
LittleEndian.putShort(data, 0x2 + offset, (short)field_2_nFib);; | |||
LittleEndian.putShort(data, 0x4 + offset, (short)field_3_nProduct);; | |||
LittleEndian.putShort(data, 0x6 + offset, (short)field_4_lid);; | |||
LittleEndian.putShort(data, 0x8 + offset, (short)field_5_pnNext);; | |||
LittleEndian.putShort(data, 0xa + offset, (short)field_6_options);; | |||
LittleEndian.putShort(data, 0xc + offset, (short)field_7_nFibBack);; | |||
LittleEndian.putShort(data, 0xe + offset, (short)field_8_lKey);; | |||
LittleEndian.putShort(data, 0x10 + offset, (short)field_9_envr);; | |||
LittleEndian.putShort(data, 0x12 + offset, (short)field_10_history);; | |||
LittleEndian.putShort(data, 0x14 + offset, (short)field_11_chs);; | |||
LittleEndian.putShort(data, 0x16 + offset, (short)field_12_chsTables);; | |||
LittleEndian.putInt(data, 0x18 + offset, field_13_fcMin);; | |||
LittleEndian.putInt(data, 0x1c + offset, field_14_fcMac);; | |||
LittleEndian.putShort(data, 0x0 + offset, (short)field_1_wIdent); | |||
LittleEndian.putShort(data, 0x2 + offset, (short)field_2_nFib); | |||
LittleEndian.putShort(data, 0x4 + offset, (short)field_3_nProduct); | |||
LittleEndian.putShort(data, 0x6 + offset, (short)field_4_lid); | |||
LittleEndian.putShort(data, 0x8 + offset, (short)field_5_pnNext); | |||
LittleEndian.putShort(data, 0xa + offset, field_6_options); | |||
LittleEndian.putShort(data, 0xc + offset, (short)field_7_nFibBack); | |||
LittleEndian.putShort(data, 0xe + offset, (short)field_8_lKey); | |||
LittleEndian.putShort(data, 0x10 + offset, (short)field_9_envr); | |||
LittleEndian.putShort(data, 0x12 + offset, field_10_history); | |||
LittleEndian.putShort(data, 0x14 + offset, (short)field_11_chs); | |||
LittleEndian.putShort(data, 0x16 + offset, (short)field_12_chsTables); | |||
LittleEndian.putInt(data, 0x18 + offset, field_13_fcMin); | |||
LittleEndian.putInt(data, 0x1c + offset, field_14_fcMac); | |||
} | |||
public String toString() | |||
@@ -422,8 +420,6 @@ public abstract class FIBAbstractType implements HDFType { | |||
public void setFDot(boolean value) | |||
{ | |||
field_6_options = (short)fDot.setBoolean(field_6_options, value); | |||
} | |||
/** | |||
@@ -433,7 +429,6 @@ public abstract class FIBAbstractType implements HDFType { | |||
public boolean isFDot() | |||
{ | |||
return fDot.isSet(field_6_options); | |||
} | |||
/** | |||
@@ -443,8 +438,6 @@ public abstract class FIBAbstractType implements HDFType { | |||
public void setFGlsy(boolean value) | |||
{ | |||
field_6_options = (short)fGlsy.setBoolean(field_6_options, value); | |||
} | |||
/** | |||
@@ -454,7 +447,6 @@ public abstract class FIBAbstractType implements HDFType { | |||
public boolean isFGlsy() | |||
{ | |||
return fGlsy.isSet(field_6_options); | |||
} | |||
/** | |||
@@ -464,8 +456,6 @@ public abstract class FIBAbstractType implements HDFType { | |||
public void setFComplex(boolean value) | |||
{ | |||
field_6_options = (short)fComplex.setBoolean(field_6_options, value); | |||
} | |||
/** | |||
@@ -475,7 +465,6 @@ public abstract class FIBAbstractType implements HDFType { | |||
public boolean isFComplex() | |||
{ | |||
return fComplex.isSet(field_6_options); | |||
} | |||
/** | |||
@@ -485,8 +474,6 @@ public abstract class FIBAbstractType implements HDFType { | |||
public void setFHasPic(boolean value) | |||
{ | |||
field_6_options = (short)fHasPic.setBoolean(field_6_options, value); | |||
} | |||
/** | |||
@@ -496,7 +483,6 @@ public abstract class FIBAbstractType implements HDFType { | |||
public boolean isFHasPic() | |||
{ | |||
return fHasPic.isSet(field_6_options); | |||
} | |||
/** | |||
@@ -506,8 +492,6 @@ public abstract class FIBAbstractType implements HDFType { | |||
public void setCQuickSaves(byte value) | |||
{ | |||
field_6_options = (short)cQuickSaves.setValue(field_6_options, value); | |||
} | |||
/** | |||
@@ -517,7 +501,6 @@ public abstract class FIBAbstractType implements HDFType { | |||
public byte getCQuickSaves() | |||
{ | |||
return ( byte )cQuickSaves.getValue(field_6_options); | |||
} | |||
/** | |||
@@ -527,8 +510,6 @@ public abstract class FIBAbstractType implements HDFType { | |||
public void setFEncrypted(boolean value) | |||
{ | |||
field_6_options = (short)fEncrypted.setBoolean(field_6_options, value); | |||
} | |||
/** | |||
@@ -538,7 +519,6 @@ public abstract class FIBAbstractType implements HDFType { | |||
public boolean isFEncrypted() | |||
{ | |||
return fEncrypted.isSet(field_6_options); | |||
} | |||
/** | |||
@@ -548,8 +528,6 @@ public abstract class FIBAbstractType implements HDFType { | |||
public void setFWhichTblStm(boolean value) | |||
{ | |||
field_6_options = (short)fWhichTblStm.setBoolean(field_6_options, value); | |||
} | |||
/** | |||
@@ -559,7 +537,6 @@ public abstract class FIBAbstractType implements HDFType { | |||
public boolean isFWhichTblStm() | |||
{ | |||
return fWhichTblStm.isSet(field_6_options); | |||
} | |||
/** | |||
@@ -569,8 +546,6 @@ public abstract class FIBAbstractType implements HDFType { | |||
public void setFReadOnlyRecommended(boolean value) | |||
{ | |||
field_6_options = (short)fReadOnlyRecommended.setBoolean(field_6_options, value); | |||
} | |||
/** | |||
@@ -580,7 +555,6 @@ public abstract class FIBAbstractType implements HDFType { | |||
public boolean isFReadOnlyRecommended() | |||
{ | |||
return fReadOnlyRecommended.isSet(field_6_options); | |||
} | |||
/** | |||
@@ -590,8 +564,6 @@ public abstract class FIBAbstractType implements HDFType { | |||
public void setFWriteReservation(boolean value) | |||
{ | |||
field_6_options = (short)fWriteReservation.setBoolean(field_6_options, value); | |||
} | |||
/** | |||
@@ -601,7 +573,6 @@ public abstract class FIBAbstractType implements HDFType { | |||
public boolean isFWriteReservation() | |||
{ | |||
return fWriteReservation.isSet(field_6_options); | |||
} | |||
/** | |||
@@ -611,8 +582,6 @@ public abstract class FIBAbstractType implements HDFType { | |||
public void setFExtChar(boolean value) | |||
{ | |||
field_6_options = (short)fExtChar.setBoolean(field_6_options, value); | |||
} | |||
/** | |||
@@ -622,7 +591,6 @@ public abstract class FIBAbstractType implements HDFType { | |||
public boolean isFExtChar() | |||
{ | |||
return fExtChar.isSet(field_6_options); | |||
} | |||
/** | |||
@@ -632,8 +600,6 @@ public abstract class FIBAbstractType implements HDFType { | |||
public void setFLoadOverride(boolean value) | |||
{ | |||
field_6_options = (short)fLoadOverride.setBoolean(field_6_options, value); | |||
} | |||
/** | |||
@@ -643,7 +609,6 @@ public abstract class FIBAbstractType implements HDFType { | |||
public boolean isFLoadOverride() | |||
{ | |||
return fLoadOverride.isSet(field_6_options); | |||
} | |||
/** | |||
@@ -653,8 +618,6 @@ public abstract class FIBAbstractType implements HDFType { | |||
public void setFFarEast(boolean value) | |||
{ | |||
field_6_options = (short)fFarEast.setBoolean(field_6_options, value); | |||
} | |||
/** | |||
@@ -664,7 +627,6 @@ public abstract class FIBAbstractType implements HDFType { | |||
public boolean isFFarEast() | |||
{ | |||
return fFarEast.isSet(field_6_options); | |||
} | |||
/** | |||
@@ -674,8 +636,6 @@ public abstract class FIBAbstractType implements HDFType { | |||
public void setFCrypto(boolean value) | |||
{ | |||
field_6_options = (short)fCrypto.setBoolean(field_6_options, value); | |||
} | |||
/** | |||
@@ -685,7 +645,6 @@ public abstract class FIBAbstractType implements HDFType { | |||
public boolean isFCrypto() | |||
{ | |||
return fCrypto.isSet(field_6_options); | |||
} | |||
/** | |||
@@ -695,8 +654,6 @@ public abstract class FIBAbstractType implements HDFType { | |||
public void setFMac(boolean value) | |||
{ | |||
field_10_history = (short)fMac.setBoolean(field_10_history, value); | |||
} | |||
/** | |||
@@ -706,7 +663,6 @@ public abstract class FIBAbstractType implements HDFType { | |||
public boolean isFMac() | |||
{ | |||
return fMac.isSet(field_10_history); | |||
} | |||
/** | |||
@@ -716,8 +672,6 @@ public abstract class FIBAbstractType implements HDFType { | |||
public void setFEmptySpecial(boolean value) | |||
{ | |||
field_10_history = (short)fEmptySpecial.setBoolean(field_10_history, value); | |||
} | |||
/** | |||
@@ -727,7 +681,6 @@ public abstract class FIBAbstractType implements HDFType { | |||
public boolean isFEmptySpecial() | |||
{ | |||
return fEmptySpecial.isSet(field_10_history); | |||
} | |||
/** | |||
@@ -737,8 +690,6 @@ public abstract class FIBAbstractType implements HDFType { | |||
public void setFLoadOverridePage(boolean value) | |||
{ | |||
field_10_history = (short)fLoadOverridePage.setBoolean(field_10_history, value); | |||
} | |||
/** | |||
@@ -748,7 +699,6 @@ public abstract class FIBAbstractType implements HDFType { | |||
public boolean isFLoadOverridePage() | |||
{ | |||
return fLoadOverridePage.isSet(field_10_history); | |||
} | |||
/** | |||
@@ -758,8 +708,6 @@ public abstract class FIBAbstractType implements HDFType { | |||
public void setFFutureSavedUndo(boolean value) | |||
{ | |||
field_10_history = (short)fFutureSavedUndo.setBoolean(field_10_history, value); | |||
} | |||
/** | |||
@@ -769,7 +717,6 @@ public abstract class FIBAbstractType implements HDFType { | |||
public boolean isFFutureSavedUndo() | |||
{ | |||
return fFutureSavedUndo.isSet(field_10_history); | |||
} | |||
/** | |||
@@ -779,8 +726,6 @@ public abstract class FIBAbstractType implements HDFType { | |||
public void setFWord97Saved(boolean value) | |||
{ | |||
field_10_history = (short)fWord97Saved.setBoolean(field_10_history, value); | |||
} | |||
/** | |||
@@ -790,7 +735,6 @@ public abstract class FIBAbstractType implements HDFType { | |||
public boolean isFWord97Saved() | |||
{ | |||
return fWord97Saved.isSet(field_10_history); | |||
} | |||
/** | |||
@@ -800,8 +744,6 @@ public abstract class FIBAbstractType implements HDFType { | |||
public void setFSpare0(byte value) | |||
{ | |||
field_10_history = (short)fSpare0.setValue(field_10_history, value); | |||
} | |||
/** | |||
@@ -811,12 +753,5 @@ public abstract class FIBAbstractType implements HDFType { | |||
public byte getFSpare0() | |||
{ | |||
return ( byte )fSpare0.getValue(field_10_history); | |||
} | |||
} // END OF CLASS | |||
} |
@@ -67,13 +67,12 @@ public abstract class TCAbstractType implements HDFType { | |||
public void serialize(byte[] data, int offset) | |||
{ | |||
LittleEndian.putShort(data, 0x0 + offset, (short)field_1_rgf);; | |||
LittleEndian.putShort(data, 0x2 + offset, (short)field_2_unused);; | |||
field_3_brcTop.serialize(data, 0x4 + offset);; | |||
field_4_brcLeft.serialize(data, 0x8 + offset);; | |||
field_5_brcBottom.serialize(data, 0xc + offset);; | |||
field_6_brcRight.serialize(data, 0x10 + offset);; | |||
LittleEndian.putShort(data, 0x0 + offset, field_1_rgf); | |||
LittleEndian.putShort(data, 0x2 + offset, field_2_unused); | |||
field_3_brcTop.serialize(data, 0x4 + offset); | |||
field_4_brcLeft.serialize(data, 0x8 + offset); | |||
field_5_brcBottom.serialize(data, 0xc + offset); | |||
field_6_brcRight.serialize(data, 0x10 + offset); | |||
} | |||
public String toString() | |||
@@ -225,8 +224,6 @@ public abstract class TCAbstractType implements HDFType { | |||
public void setFFirstMerged(boolean value) | |||
{ | |||
field_1_rgf = (short)fFirstMerged.setBoolean(field_1_rgf, value); | |||
} | |||
/** | |||
@@ -236,7 +233,6 @@ public abstract class TCAbstractType implements HDFType { | |||
public boolean isFFirstMerged() | |||
{ | |||
return fFirstMerged.isSet(field_1_rgf); | |||
} | |||
/** | |||
@@ -246,8 +242,6 @@ public abstract class TCAbstractType implements HDFType { | |||
public void setFMerged(boolean value) | |||
{ | |||
field_1_rgf = (short)fMerged.setBoolean(field_1_rgf, value); | |||
} | |||
/** | |||
@@ -257,7 +251,6 @@ public abstract class TCAbstractType implements HDFType { | |||
public boolean isFMerged() | |||
{ | |||
return fMerged.isSet(field_1_rgf); | |||
} | |||
/** | |||
@@ -267,8 +260,6 @@ public abstract class TCAbstractType implements HDFType { | |||
public void setFVertical(boolean value) | |||
{ | |||
field_1_rgf = (short)fVertical.setBoolean(field_1_rgf, value); | |||
} | |||
/** | |||
@@ -278,7 +269,6 @@ public abstract class TCAbstractType implements HDFType { | |||
public boolean isFVertical() | |||
{ | |||
return fVertical.isSet(field_1_rgf); | |||
} | |||
/** | |||
@@ -288,8 +278,6 @@ public abstract class TCAbstractType implements HDFType { | |||
public void setFBackward(boolean value) | |||
{ | |||
field_1_rgf = (short)fBackward.setBoolean(field_1_rgf, value); | |||
} | |||
/** | |||
@@ -299,7 +287,6 @@ public abstract class TCAbstractType implements HDFType { | |||
public boolean isFBackward() | |||
{ | |||
return fBackward.isSet(field_1_rgf); | |||
} | |||
/** | |||
@@ -309,8 +296,6 @@ public abstract class TCAbstractType implements HDFType { | |||
public void setFRotateFont(boolean value) | |||
{ | |||
field_1_rgf = (short)fRotateFont.setBoolean(field_1_rgf, value); | |||
} | |||
/** | |||
@@ -320,7 +305,6 @@ public abstract class TCAbstractType implements HDFType { | |||
public boolean isFRotateFont() | |||
{ | |||
return fRotateFont.isSet(field_1_rgf); | |||
} | |||
/** | |||
@@ -330,8 +314,6 @@ public abstract class TCAbstractType implements HDFType { | |||
public void setFVertMerge(boolean value) | |||
{ | |||
field_1_rgf = (short)fVertMerge.setBoolean(field_1_rgf, value); | |||
} | |||
/** | |||
@@ -341,7 +323,6 @@ public abstract class TCAbstractType implements HDFType { | |||
public boolean isFVertMerge() | |||
{ | |||
return fVertMerge.isSet(field_1_rgf); | |||
} | |||
/** | |||
@@ -351,8 +332,6 @@ public abstract class TCAbstractType implements HDFType { | |||
public void setFVertRestart(boolean value) | |||
{ | |||
field_1_rgf = (short)fVertRestart.setBoolean(field_1_rgf, value); | |||
} | |||
/** | |||
@@ -362,7 +341,6 @@ public abstract class TCAbstractType implements HDFType { | |||
public boolean isFVertRestart() | |||
{ | |||
return fVertRestart.isSet(field_1_rgf); | |||
} | |||
/** | |||
@@ -372,8 +350,6 @@ public abstract class TCAbstractType implements HDFType { | |||
public void setVertAlign(byte value) | |||
{ | |||
field_1_rgf = (short)vertAlign.setValue(field_1_rgf, value); | |||
} | |||
/** | |||
@@ -383,12 +359,5 @@ public abstract class TCAbstractType implements HDFType { | |||
public byte getVertAlign() | |||
{ | |||
return ( byte )vertAlign.getValue(field_1_rgf); | |||
} | |||
} // END OF CLASS | |||
} |
@@ -46,7 +46,7 @@ public final class CharacterSprmUncompressor | |||
while (sprmIt.hasNext()) | |||
{ | |||
SprmOperation sprm = (SprmOperation)sprmIt.next(); | |||
SprmOperation sprm = sprmIt.next(); | |||
unCompressCHPOperation(parent, newProperties, sprm); | |||
} | |||
@@ -108,8 +108,8 @@ public final class CharacterSprmUncompressor | |||
break; | |||
case 0x9: | |||
newCHP.setFSpec (true); | |||
newCHP.setFtcSym ((short) LittleEndian.getShort (sprm.getGrpprl(), sprm.getGrpprlOffset())); | |||
newCHP.setXchSym ((short) LittleEndian.getShort (sprm.getGrpprl(), sprm.getGrpprlOffset() + 2)); | |||
newCHP.setFtcSym (LittleEndian.getShort (sprm.getGrpprl(), sprm.getGrpprlOffset())); | |||
newCHP.setXchSym (LittleEndian.getShort (sprm.getGrpprl(), sprm.getGrpprlOffset() + 2)); | |||
break; | |||
case 0xa: | |||
newCHP.setFOle2 (getFlag (sprm.getOperand())); | |||
@@ -426,8 +426,8 @@ public final class CharacterSprmUncompressor | |||
// styleSheet, opSize); | |||
break; | |||
case 0x4d: | |||
float percentage = (float) sprm.getOperand() / 100.0f; | |||
int add = (int) ((float) percentage * (float) newCHP.getHps ()); | |||
float percentage = sprm.getOperand() / 100.0f; | |||
int add = (int) (percentage * newCHP.getHps ()); | |||
newCHP.setHps (newCHP.getHps () + add); | |||
break; | |||
case 0x4e: | |||
@@ -462,7 +462,7 @@ public final class CharacterSprmUncompressor | |||
byte[] buf = sprm.getGrpprl(); | |||
int offset = sprm.getGrpprlOffset(); | |||
newCHP.setFPropMark (buf[offset]); | |||
newCHP.setIbstPropRMark ((short) LittleEndian.getShort (buf, offset + 1)); | |||
newCHP.setIbstPropRMark (LittleEndian.getShort (buf, offset + 1)); | |||
newCHP.setDttmPropRMark (new DateAndTime(buf, offset +3)); | |||
break; | |||
case 0x58: | |||
@@ -494,7 +494,7 @@ public final class CharacterSprmUncompressor | |||
buf = sprm.getGrpprl(); | |||
offset = sprm.getGrpprlOffset(); | |||
newCHP.setFDispFldRMark (buf[offset]); | |||
newCHP.setIbstDispFldRMark ((short) LittleEndian.getShort (buf, offset + 1)); | |||
newCHP.setIbstDispFldRMark (LittleEndian.getShort (buf, offset + 1)); | |||
newCHP.setDttmDispFldRMark (new DateAndTime(buf, offset + 3)); | |||
System.arraycopy (buf, offset + 7, xstDispFldRMark, 0, 32); | |||
newCHP.setXstDispFldRMark (xstDispFldRMark); | |||
@@ -553,14 +553,7 @@ public final class CharacterSprmUncompressor | |||
*/ | |||
public static boolean getFlag (int x) | |||
{ | |||
if (x != 0) | |||
{ | |||
return true; | |||
} | |||
else | |||
{ | |||
return false; | |||
} | |||
return x != 0; | |||
} | |||
private static boolean getCHPFlag (byte x, boolean oldVal) |
@@ -54,7 +54,7 @@ public final class ParagraphSprmUncompressor | |||
while (sprmIt.hasNext()) | |||
{ | |||
SprmOperation sprm = (SprmOperation)sprmIt.next(); | |||
SprmOperation sprm = sprmIt.next(); | |||
// PAPXs can contain table sprms if the paragraph marks the end of a | |||
// table row | |||
@@ -326,8 +326,8 @@ public final class ParagraphSprmUncompressor | |||
{ | |||
byte[] varParam = sprm.getGrpprl(); | |||
int offset = sprm.getGrpprlOffset(); | |||
newPAP.setFPropRMark ((int) varParam[offset]); | |||
newPAP.setIbstPropRMark ((int) LittleEndian.getShort (varParam, offset + 1)); | |||
newPAP.setFPropRMark (varParam[offset]); | |||
newPAP.setIbstPropRMark (LittleEndian.getShort (varParam, offset + 1)); | |||
newPAP.setDttmPropRMark (new DateAndTime(varParam, offset + 3)); | |||
} | |||
catch (Exception e) |
@@ -33,7 +33,7 @@ public final class SectionSprmUncompressor extends SprmUncompressor | |||
while (sprmIt.hasNext()) | |||
{ | |||
SprmOperation sprm = (SprmOperation)sprmIt.next(); | |||
SprmOperation sprm = sprmIt.next(); | |||
unCompressSEPOperation(newProperties, sprm); | |||
} | |||
@@ -39,7 +39,7 @@ public final class TableSprmUncompressor | |||
while (sprmIt.hasNext()) | |||
{ | |||
SprmOperation sprm = (SprmOperation)sprmIt.next(); | |||
SprmOperation sprm = sprmIt.next(); | |||
//TAPXs are actually PAPXs so we have to make sure we are only trying to | |||
//uncompress the right type of sprm. |
@@ -380,13 +380,11 @@ public final class CharacterProperties | |||
cp.field_23_dttmRMarkDel = (DateAndTime)field_23_dttmRMarkDel.clone(); | |||
cp.field_36_dttmPropRMark = (DateAndTime)field_36_dttmPropRMark.clone(); | |||
cp.field_40_dttmDispFldRMark = (DateAndTime)field_40_dttmDispFldRMark.clone(); | |||
cp.field_41_xstDispFldRMark = (byte[])field_41_xstDispFldRMark.clone(); | |||
cp.field_41_xstDispFldRMark = field_41_xstDispFldRMark.clone(); | |||
cp.field_42_shd = (ShadingDescriptor)field_42_shd.clone(); | |||
cp._ico24 = _ico24; | |||
return cp; | |||
} | |||
} |
@@ -546,7 +546,7 @@ public final class CharacterRun | |||
cp._props.setDttmPropRMark((DateAndTime)_props.getDttmPropRMark().clone()); | |||
cp._props.setDttmDispFldRMark((DateAndTime)_props.getDttmDispFldRMark(). | |||
clone()); | |||
cp._props.setXstDispFldRMark((byte[])_props.getXstDispFldRMark().clone()); | |||
cp._props.setXstDispFldRMark(_props.getXstDispFldRMark().clone()); | |||
cp._props.setShd((ShadingDescriptor)_props.getShd().clone()); | |||
return cp; |
@@ -55,7 +55,7 @@ public final class HWPFList { | |||
*/ | |||
public HWPFList(boolean numbered, StyleSheet styleSheet) | |||
{ | |||
_listData = new ListData((int)(Math.random() * (double)System.currentTimeMillis()), numbered); | |||
_listData = new ListData((int)(Math.random() * System.currentTimeMillis()), numbered); | |||
_override = new ListFormatOverride(_listData.getLsid()); | |||
_styleSheet = styleSheet; | |||
} |
@@ -65,7 +65,7 @@ public final class TableProperties | |||
tap.field_14_brcRight = (BorderCode)field_14_brcRight.clone(); | |||
tap.field_15_brcVertical = (BorderCode)field_15_brcVertical.clone(); | |||
tap.field_16_brcHorizontal = (BorderCode)field_16_brcHorizontal.clone(); | |||
tap.field_8_rgdxaCenter = (short[])field_8_rgdxaCenter.clone(); | |||
tap.field_8_rgdxaCenter = field_8_rgdxaCenter.clone(); | |||
tap.field_9_rgtc = new TableCellDescriptor[field_9_rgtc.length]; | |||
for (int x = 0; x < field_9_rgtc.length; x++) | |||
{ |
@@ -50,11 +50,10 @@ public class TestModelFactory extends TestCase { | |||
{ | |||
ModelFactory mf = new ModelFactory(); | |||
assertTrue("listeners member cannot be null", mf.listeners != null); | |||
assertTrue("listeners member must be a List", mf.listeners instanceof List); | |||
models = new ArrayList(3); | |||
factory = new ModelFactory(); | |||
book = new HSSFWorkbook(); | |||
ByteArrayOutputStream stream = (ByteArrayOutputStream)setupRunFile(book); | |||
ByteArrayOutputStream stream = setupRunFile(book); | |||
POIFSFileSystem fs = new POIFSFileSystem( | |||
new ByteArrayInputStream(stream.toByteArray()) | |||
); |
@@ -115,7 +115,6 @@ public final class TestRecordFactory extends TestCase { | |||
* constructs the expected array of records.<P> | |||
* SUCCESS: Record factory creates the expected records.<P> | |||
* FAILURE: The wrong records are created or contain the wrong values <P> | |||
* | |||
*/ | |||
public void testContinuedUnknownRecord() { | |||
byte[] data = { | |||
@@ -125,8 +124,7 @@ public final class TestRecordFactory extends TestCase { | |||
}; | |||
ByteArrayInputStream bois = new ByteArrayInputStream(data); | |||
Record[] records = (Record[]) | |||
RecordFactory.createRecords(bois).toArray(new Record[0]); | |||
Record[] records = RecordFactory.createRecords(bois).toArray(new Record[0]); | |||
assertEquals("Created record count", 3, records.length); | |||
assertEquals("1st record's type", | |||
UnknownRecord.class.getName(), |